@myrialabs/clopen 0.4.50 → 0.4.51

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 (457) hide show
  1. package/README.md +2 -1
  2. package/backend/chat/attachments.test.ts +106 -17
  3. package/backend/chat/attachments.ts +131 -34
  4. package/backend/chat/engine-handoff.ts +42 -6
  5. package/backend/chat/stream-manager.ts +41 -5
  6. package/backend/containers/actions.ts +22 -0
  7. package/backend/control/actions/projects.ts +93 -37
  8. package/backend/control/folders.test.ts +27 -2
  9. package/backend/control/index.ts +2 -1
  10. package/backend/database/migrations/056_support_mssql_driver.ts +7 -0
  11. package/backend/database/migrations/077_create_integration_db_links.ts +7 -0
  12. package/backend/database/migrations/086_single_owner.ts +66 -73
  13. package/backend/database/migrations/090_create_storage_tables.ts +83 -0
  14. package/backend/database/migrations/index.ts +11 -2
  15. package/backend/database/queries/integration-queries.ts +10 -0
  16. package/backend/database/queries/memory-queue-queries.ts +11 -0
  17. package/backend/database/queries/project-queries.ts +6 -0
  18. package/backend/database/queries/session-queries.ts +3 -0
  19. package/backend/database/utils/migration-runner.test.ts +196 -0
  20. package/backend/database/utils/migration-runner.ts +61 -16
  21. package/backend/database/utils/seeder-runner.ts +22 -16
  22. package/backend/engine/adapters/claude/stream.ts +5 -0
  23. package/backend/engine/adapters/cursor/environment.ts +1 -1
  24. package/backend/engine/adapters/qwen/session-store.ts +10 -1
  25. package/backend/engine/types.ts +7 -0
  26. package/backend/git/identity/cli.ts +35 -0
  27. package/backend/git/identity/env.test.ts +52 -1
  28. package/backend/git/identity/env.ts +69 -10
  29. package/backend/git/identity/index.ts +25 -6
  30. package/backend/git/identity/resolve.ts +2 -1
  31. package/backend/git/identity/scope-config.ts +13 -7
  32. package/backend/git-hosts/accounts.ts +106 -0
  33. package/backend/git-hosts/auth/client-ids.ts +34 -0
  34. package/backend/git-hosts/auth/connect.ts +110 -0
  35. package/backend/git-hosts/auth/endpoints.ts +130 -0
  36. package/backend/git-hosts/auth/flows.ts +355 -0
  37. package/backend/git-hosts/auth/local.ts +152 -0
  38. package/backend/git-hosts/ci.ts +18 -0
  39. package/backend/git-hosts/cli.test.ts +82 -0
  40. package/backend/git-hosts/cli.ts +342 -0
  41. package/backend/git-hosts/credentials.ts +173 -0
  42. package/backend/git-hosts/git-credential.ts +30 -0
  43. package/backend/git-hosts/health.ts +39 -0
  44. package/backend/git-hosts/http.ts +174 -0
  45. package/backend/git-hosts/index.ts +34 -0
  46. package/backend/git-hosts/providers/bitbucket.ts +186 -0
  47. package/backend/git-hosts/providers/gitea.ts +208 -0
  48. package/backend/git-hosts/providers/github.ts +270 -0
  49. package/backend/git-hosts/providers/gitlab-client.ts +70 -0
  50. package/backend/git-hosts/providers/gitlab.ts +285 -0
  51. package/backend/git-hosts/providers/locators.test.ts +68 -0
  52. package/backend/git-hosts/registry.ts +50 -0
  53. package/backend/git-hosts/service.ts +432 -0
  54. package/backend/git-hosts/types.ts +82 -0
  55. package/backend/git-hosts/urls.test.ts +42 -0
  56. package/backend/git-hosts/urls.ts +69 -0
  57. package/backend/index.ts +50 -10
  58. package/backend/integrations/accounts.ts +50 -3
  59. package/backend/integrations/registry/define.ts +9 -0
  60. package/backend/integrations/registry/index.ts +11 -0
  61. package/backend/integrations/registry/providers/bitbucket.ts +51 -0
  62. package/backend/integrations/registry/providers/gitea.ts +53 -0
  63. package/backend/integrations/registry/providers/github.ts +24 -7
  64. package/backend/integrations/registry/providers/gitlab.ts +57 -0
  65. package/backend/integrations/registry/types.ts +13 -1
  66. package/backend/mcp/internal/servers/browser-automation/actions/inspect.ts +115 -31
  67. package/backend/mcp/internal/servers/browser-automation/description.ts +5 -0
  68. package/backend/mentions/diff.ts +63 -0
  69. package/backend/mentions/index.ts +109 -0
  70. package/backend/mentions/mentions.test.ts +27 -0
  71. package/backend/mentions/shared.ts +82 -0
  72. package/backend/mentions/sources/ai-changes.ts +140 -0
  73. package/backend/mentions/sources/chats.ts +122 -0
  74. package/backend/mentions/sources/database.ts +211 -0
  75. package/backend/mentions/sources/files.ts +240 -0
  76. package/backend/mentions/sources/git.ts +308 -0
  77. package/backend/mentions/sources/notes-memory.ts +121 -0
  78. package/backend/mentions/sources/ops.ts +125 -0
  79. package/backend/mentions/sources/preview.ts +153 -0
  80. package/backend/mentions/sources/projects.ts +114 -0
  81. package/backend/mentions/sources/system.ts +135 -0
  82. package/backend/mentions/sources/terminal.ts +50 -0
  83. package/backend/mentions/types.ts +75 -0
  84. package/backend/preview/browser/bot-check-frames.test.ts +49 -0
  85. package/backend/preview/browser/bot-check-frames.ts +66 -0
  86. package/backend/preview/browser/browser-dialog-handler.ts +6 -5
  87. package/backend/preview/browser/browser-host-bridge.ts +4 -2
  88. package/backend/preview/browser/browser-native-ui-handler.ts +21 -0
  89. package/backend/preview/browser/browser-pool.ts +26 -17
  90. package/backend/preview/browser/browser-preview-service.ts +164 -2
  91. package/backend/preview/browser/browser-screenshot.test.ts +113 -0
  92. package/backend/preview/browser/browser-screenshot.ts +396 -0
  93. package/backend/preview/browser/browser-tab-manager.ts +35 -186
  94. package/backend/preview/browser/browser-video-capture.ts +12 -17
  95. package/backend/preview/browser/element-describe.ts +125 -0
  96. package/backend/preview/browser/page-binding.ts +141 -0
  97. package/backend/preview/browser/screenshot-files.test.ts +117 -0
  98. package/backend/preview/browser/screenshot-files.ts +134 -0
  99. package/backend/preview/browser/user-agent.test.ts +25 -0
  100. package/backend/preview/browser/user-agent.ts +100 -0
  101. package/backend/projects/engine-transcripts.ts +153 -0
  102. package/backend/projects/folder-guard.ts +55 -0
  103. package/backend/projects/move.test.ts +208 -0
  104. package/backend/projects/move.ts +277 -0
  105. package/backend/projects/project-cleanup.integration.test.ts +3 -1
  106. package/backend/projects/project-cleanup.ts +10 -0
  107. package/backend/storage/actions.ts +260 -0
  108. package/backend/storage/chats.test.ts +57 -0
  109. package/backend/storage/chats.ts +170 -0
  110. package/backend/storage/database.ts +105 -0
  111. package/backend/storage/engine-homes.ts +145 -0
  112. package/backend/storage/fs-size.ts +111 -0
  113. package/backend/storage/history.ts +39 -0
  114. package/backend/storage/policy.ts +156 -0
  115. package/backend/storage/preview-profiles.ts +169 -0
  116. package/backend/storage/purge.ts +158 -0
  117. package/backend/storage/scanner.ts +339 -0
  118. package/backend/storage/session-index.ts +208 -0
  119. package/backend/storage/snapshots.ts +99 -0
  120. package/backend/storage/storage-flow.test.ts +137 -0
  121. package/backend/storage/transcripts/aliases.ts +75 -0
  122. package/backend/storage/transcripts/claude-dedupe.test.ts +101 -0
  123. package/backend/storage/transcripts/claude-dedupe.ts +152 -0
  124. package/backend/storage/transcripts/claude.ts +155 -0
  125. package/backend/storage/transcripts/cursor.ts +165 -0
  126. package/backend/storage/transcripts/file-stores.ts +224 -0
  127. package/backend/storage/transcripts/index.ts +207 -0
  128. package/backend/storage/transcripts/opencode.ts +124 -0
  129. package/backend/storage/transcripts/references.ts +42 -0
  130. package/backend/storage/transcripts/types.ts +58 -0
  131. package/backend/storage/worktrees.ts +114 -0
  132. package/backend/terminal/ptykit.ts +25 -0
  133. package/backend/update/registry.ts +24 -0
  134. package/backend/update/release-notes.test.ts +110 -0
  135. package/backend/update/release-notes.ts +132 -0
  136. package/backend/update/restart.ts +159 -0
  137. package/backend/utils/env.test.ts +64 -0
  138. package/backend/utils/env.ts +23 -55
  139. package/backend/utils/port-utils.ts +13 -0
  140. package/backend/work/index.ts +13 -2
  141. package/backend/work/providers/github/actions-logs.ts +1 -1
  142. package/backend/work/providers/github/adapter.ts +32 -1
  143. package/backend/work/providers/github/client.ts +7 -3
  144. package/backend/work/providers/gitlab/adapter.ts +770 -0
  145. package/backend/work/providers/gitlab/system-notes.test.ts +24 -0
  146. package/backend/work/service.ts +60 -36
  147. package/backend/work/start-work.ts +1 -1
  148. package/backend/work/types.ts +4 -0
  149. package/backend/worktrees/index.ts +1 -0
  150. package/backend/worktrees/service.ts +23 -2
  151. package/backend/ws/chat/composer.ts +47 -6
  152. package/backend/ws/files/search.ts +1 -1
  153. package/backend/ws/files/write.ts +27 -0
  154. package/backend/ws/hosting/index.ts +231 -0
  155. package/backend/ws/index.ts +12 -2
  156. package/backend/ws/integrations/crud.ts +31 -5
  157. package/backend/ws/integrations/hosting-auth.ts +227 -0
  158. package/backend/ws/integrations/index.ts +2 -0
  159. package/backend/ws/mentions/index.ts +81 -0
  160. package/backend/ws/preview/browser/screenshot.ts +184 -0
  161. package/backend/ws/preview/index.ts +23 -0
  162. package/backend/ws/projects/crud.ts +66 -58
  163. package/backend/ws/sessions/crud.ts +7 -95
  164. package/backend/ws/snapshot/changes.ts +3 -3
  165. package/backend/ws/storage/index.ts +102 -0
  166. package/backend/ws/system/index.ts +7 -0
  167. package/backend/ws/system/operations.ts +125 -69
  168. package/backend/ws/work/context.ts +3 -4
  169. package/backend/ws/work/crud.ts +33 -0
  170. package/backend/ws/work/schemas.ts +4 -1
  171. package/bin/clopen.ts +15 -16
  172. package/dist/assets/{index-By6KdSLT.js → index-B9rHDvjg.js} +1 -1
  173. package/dist/assets/index-B9rHDvjg.js.br +0 -0
  174. package/dist/assets/index-B9rHDvjg.js.gz +0 -0
  175. package/dist/assets/{index-DV4TiDn1.js → index-DFlwOd7k.js} +1 -1
  176. package/dist/assets/index-DFlwOd7k.js.br +0 -0
  177. package/dist/assets/index-DFlwOd7k.js.gz +0 -0
  178. package/dist/assets/main-Bz_brxxS.css +1 -0
  179. package/dist/assets/main-Bz_brxxS.css.br +0 -0
  180. package/dist/assets/main-Bz_brxxS.css.gz +0 -0
  181. package/dist/assets/main-DRcX9SHx.js +1273 -0
  182. package/dist/assets/main-DRcX9SHx.js.br +0 -0
  183. package/dist/assets/main-DRcX9SHx.js.gz +0 -0
  184. package/dist/assets/pdf-DfwfQPLy.js +57 -0
  185. package/dist/assets/pdf-DfwfQPLy.js.br +0 -0
  186. package/dist/assets/pdf-DfwfQPLy.js.gz +0 -0
  187. package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs +27 -0
  188. package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.br +0 -0
  189. package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.gz +0 -0
  190. package/dist/assets/pdf.worker.min-BOrSNwfp.js +1 -0
  191. package/dist/index.html +2 -2
  192. package/dist/index.html.br +0 -0
  193. package/dist/index.html.gz +0 -0
  194. package/dist/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  195. package/dist/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  196. package/dist/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
  197. package/dist/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  198. package/dist/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  199. package/dist/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
  200. package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  201. package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  202. package/dist/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  203. package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  204. package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  205. package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  206. package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  207. package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  208. package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  209. package/dist/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
  210. package/dist/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  211. package/dist/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  212. package/dist/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
  213. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  214. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  215. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  216. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  217. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  218. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  219. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  220. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  221. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  222. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  223. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  224. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  225. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  226. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  227. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  228. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  229. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  230. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  231. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  232. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  233. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  234. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  235. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  236. package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  237. package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  238. package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  239. package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  240. package/dist/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
  241. package/dist/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
  242. package/dist/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  243. package/dist/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  244. package/dist/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  245. package/dist/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  246. package/dist/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  247. package/dist/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  248. package/dist/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  249. package/dist/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  250. package/dist/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  251. package/dist/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  252. package/dist/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  253. package/dist/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  254. package/dist/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  255. package/dist/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  256. package/dist/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
  257. package/dist/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
  258. package/dist/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
  259. package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  260. package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  261. package/dist/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
  262. package/dist/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  263. package/dist/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  264. package/dist/vendor/pdfjs/cmaps/GB-H.bcmap +6 -0
  265. package/dist/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
  266. package/dist/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  267. package/dist/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  268. package/dist/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  269. package/dist/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  270. package/dist/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  271. package/dist/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  272. package/dist/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  273. package/dist/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  274. package/dist/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
  275. package/dist/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
  276. package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  277. package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  278. package/dist/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  279. package/dist/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  280. package/dist/vendor/pdfjs/cmaps/H.bcmap +0 -0
  281. package/dist/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  282. package/dist/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  283. package/dist/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  284. package/dist/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  285. package/dist/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  286. package/dist/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  287. package/dist/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  288. package/dist/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  289. package/dist/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  290. package/dist/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  291. package/dist/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  292. package/dist/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  293. package/dist/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
  294. package/dist/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
  295. package/dist/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  296. package/dist/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  297. package/dist/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
  298. package/dist/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  299. package/dist/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  300. package/dist/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
  301. package/dist/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  302. package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  303. package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  304. package/dist/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  305. package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  306. package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  307. package/dist/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
  308. package/dist/vendor/pdfjs/cmaps/LICENSE +36 -0
  309. package/dist/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
  310. package/dist/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
  311. package/dist/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  312. package/dist/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  313. package/dist/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
  314. package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  315. package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  316. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  317. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  318. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  319. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  320. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  321. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  322. package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  323. package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  324. package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  325. package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  326. package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  327. package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  328. package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  329. package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  330. package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  331. package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  332. package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  333. package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  334. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  335. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  336. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  337. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  338. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  339. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  340. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  341. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  342. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  343. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  344. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  345. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  346. package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  347. package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  348. package/dist/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  349. package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  350. package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  351. package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  352. package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  353. package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  354. package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  355. package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  356. package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  357. package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  358. package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  359. package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  360. package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  361. package/dist/vendor/pdfjs/cmaps/V.bcmap +0 -0
  362. package/dist/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  363. package/dist/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
  364. package/dist/vendor/pdfjs/iccs/LICENSE +116 -0
  365. package/dist/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  366. package/dist/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  367. package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  368. package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  369. package/dist/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  370. package/dist/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  371. package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  372. package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  373. package/dist/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  374. package/dist/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  375. package/dist/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  376. package/dist/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
  377. package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  378. package/dist/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  379. package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  380. package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  381. package/dist/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
  382. package/dist/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
  383. package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  384. package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  385. package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
  386. package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QUICKJS +21 -0
  387. package/dist/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
  388. package/dist/vendor/pdfjs/wasm/LICENSE_QUICKJS +22 -0
  389. package/dist/vendor/pdfjs/wasm/jbig2.wasm +0 -0
  390. package/dist/vendor/pdfjs/wasm/jbig2.wasm.br +0 -0
  391. package/dist/vendor/pdfjs/wasm/jbig2.wasm.gz +0 -0
  392. package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +2 -0
  393. package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.br +0 -0
  394. package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.gz +0 -0
  395. package/dist/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
  396. package/dist/vendor/pdfjs/wasm/openjpeg.wasm.br +0 -0
  397. package/dist/vendor/pdfjs/wasm/openjpeg.wasm.gz +0 -0
  398. package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +2 -0
  399. package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.br +0 -0
  400. package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.gz +0 -0
  401. package/dist/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
  402. package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.br +0 -0
  403. package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.gz +0 -0
  404. package/dist/vendor/pdfjs/wasm/quickjs-eval.js +16 -0
  405. package/dist/vendor/pdfjs/wasm/quickjs-eval.js.br +0 -0
  406. package/dist/vendor/pdfjs/wasm/quickjs-eval.js.gz +0 -0
  407. package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm +0 -0
  408. package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.br +0 -0
  409. package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.gz +0 -0
  410. package/package.json +6 -7
  411. package/scripts/start.ts +21 -4
  412. package/shared/constants/binary-extensions.ts +20 -4
  413. package/shared/constants/support.test.ts +27 -0
  414. package/shared/constants/support.ts +79 -0
  415. package/shared/constants/tool-icons.ts +7 -1
  416. package/shared/types/database/schema.ts +6 -0
  417. package/shared/types/git-hosting.ts +241 -0
  418. package/shared/types/integrations.ts +51 -1
  419. package/shared/types/mentions.ts +96 -0
  420. package/shared/types/release-notes.ts +31 -0
  421. package/shared/types/storage.ts +175 -0
  422. package/shared/types/stores/settings.ts +16 -0
  423. package/shared/types/unified/index.ts +1 -0
  424. package/shared/types/unified/message.ts +26 -1
  425. package/shared/types/unified/tool.ts +4 -0
  426. package/shared/types/work.ts +6 -0
  427. package/shared/utils/attachment-mentions.test.ts +39 -0
  428. package/shared/utils/attachment-mentions.ts +100 -0
  429. package/shared/utils/context-document.test.ts +53 -0
  430. package/shared/utils/context-document.ts +226 -0
  431. package/shared/utils/device-frame.test.ts +73 -0
  432. package/shared/utils/device-frame.ts +320 -0
  433. package/shared/utils/fuzzy.ts +79 -0
  434. package/shared/utils/launcher-fingerprint.test.ts +73 -0
  435. package/shared/utils/launcher-fingerprint.ts +108 -0
  436. package/shared/utils/logger.ts +2 -0
  437. package/shared/utils/page-colors.test.ts +17 -0
  438. package/shared/utils/page-colors.ts +24 -0
  439. package/shared/utils/process-supervisor.test.ts +18 -1
  440. package/shared/utils/process-supervisor.ts +12 -23
  441. package/shared/utils/restart-intent.test.ts +57 -0
  442. package/shared/utils/restart-intent.ts +80 -0
  443. package/shared/utils/semver.test.ts +33 -0
  444. package/shared/utils/semver.ts +35 -0
  445. package/shared/utils/supervised-child.ts +44 -0
  446. package/shared/utils/supervisor-protocol.ts +20 -0
  447. package/.env.example +0 -9
  448. package/dist/assets/index-By6KdSLT.js.br +0 -0
  449. package/dist/assets/index-By6KdSLT.js.gz +0 -0
  450. package/dist/assets/index-DV4TiDn1.js.br +0 -0
  451. package/dist/assets/index-DV4TiDn1.js.gz +0 -0
  452. package/dist/assets/main-DIESTGTD.css +0 -1
  453. package/dist/assets/main-DIESTGTD.css.br +0 -0
  454. package/dist/assets/main-DIESTGTD.css.gz +0 -0
  455. package/dist/assets/main-Da3JKoua.js +0 -1240
  456. package/dist/assets/main-Da3JKoua.js.br +0 -0
  457. package/dist/assets/main-Da3JKoua.js.gz +0 -0
@@ -0,0 +1,57 @@
1
+ var Zr=h=>{throw TypeError(h)};var Bi=(h,t,e)=>t.has(h)||Zr("Cannot "+e);var mt=(h,t,e)=>(Bi(h,t,"read from private field"),e?e.call(h):t.get(h)),le=(h,t,e)=>t.has(h)?Zr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(h):t.set(h,e),Ht=(h,t,e,s)=>(Bi(h,t,"write to private field"),s?s.call(h,e):t.set(h,e),e),ge=(h,t,e)=>(Bi(h,t,"access private method"),e);var tn=(h,t,e,s)=>({set _(i){Ht(h,t,i,e)},get _(){return mt(h,t,s)}});var Ya={463(h){var t=TypeError;h.exports=function(e){if(typeof e=="string")return e;throw new t("Argument is not a string")}},804(h){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=t+"+/",s=t+"-_",i=function(r){for(var n={},a=0;a<64;a++)n[r.charAt(a)]=a;return n};h.exports={i2c:e,c2i:i(e),i2cUrl:s,c2iUrl:i(s)}},529(h){h.exports=function(t,e){return{value:t,done:e}}},837(h){var t=TypeError,e=9007199254740991;h.exports=function(s){if(s>e)throw new t("Maximum allowed index exceeded");return s}},2(h){h.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},944(h){var t=TypeError;h.exports=function(e){var s=e&&e.alphabet;if(s===void 0||s==="base64"||s==="base64url")return s||"base64";throw new t("Incorrect `alphabet` option")}},767(h){h.exports=function(t){return{iterator:t,next:t.next,done:!1}}},117(h){h.exports=function(t){return t==null}},859(h){h.exports=function(t){t.iterator=t.next=t.nextHandler=t.mapper=t.predicate=t.inner=t.iterables=t.iters=t.openIters=t.padding=t.finishResults=t.buffer=null}},684(h){h.exports=function(t,e){var s=typeof Iterator=="function"&&Iterator.prototype[t];if(s)try{s.call({next:null},e).next()}catch{return!0}}},269(h){h.exports=Object.create?Object.create(null):{}},741(h){var t=Math.ceil,e=Math.floor;h.exports=Math.trunc||function(i){var r=+i;return(r>0?e:t)(r)}},149(h){var t=RangeError;h.exports=function(e){if(e===e)return e;throw new t("NaN is not allowed")}},717(h,t){t.f=Object.getOwnPropertySymbols},103(h){h.exports=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}}},750(h,t,e){var s=e(117),i=TypeError;h.exports=function(r){if(s(r))throw new i("Can't call method on "+r);return r}},835(h){h.exports=function(t){try{var e=new Set,s={size:0,has:function(){return!0},keys:function(){return Object.defineProperty({},"next",{get:function(){return e.clear(),e.add(4),function(){return{done:!0}}}})}},i=e[t](s);return i.size===1&&i.values().next().value===4}catch{return!1}}},291(h,t,e){var s=e(741);h.exports=function(i){var r=+i;return r!==r||r===0?0:s(r)}},14(h,t,e){var s=e(291),i=Math.min;h.exports=function(r){var n=s(r);return n>0?i(n,9007199254740991):0}},981(h,t,e){var s=e(750),i=Object;h.exports=function(r){return i(s(r))}},590(h,t,e){var s=e(291),i=RangeError;h.exports=function(r){var n=s(r);if(n<0)throw new i("The argument can't be less than 0");return n}},812(h){var t=TypeError;h.exports=function(e,s){if(e<s)throw new t("Not enough arguments");return e}}};const en={};function S(h){const t=en[h];if(t!==void 0)return t.exports;const e=en[h]={exports:{}};return Ya[h](e,e.exports,S),e.exports}S.cw=h=>{var t;return()=>{if(h){var e=h;h=0,t={exports:{}},e.call(t.exports,t,t.exports)}return t.exports}};S.d=(h,t)=>{for(var e in t)S.o(t,e)&&!S.o(h,e)&&Object.defineProperty(h,e,{enumerable:!0,get:t[e]})};S.o=(h,t)=>Object.prototype.hasOwnProperty.call(h,t);var Nt=S.cw(h=>{var t=Ct(),e=yi(),s=TypeError;h.exports=function(i){if(t(i))return i;throw new s(e(i)+" is not a function")}}),Ka=S.cw(h=>{var t=Co(),e=String,s=TypeError;h.exports=function(i){if(t(i))return i;throw new s("Can't set "+e(i)+" as a prototype")}}),ze=S.cw(h=>{var t=fe().has;h.exports=function(e){return t(e),e}}),Mn=()=>S(463),qa=S.cw(h=>{var t=wi(),e=new t.WeakMap,s=t.set,i=t.remove;h.exports=function(r){return s(e,r,1),i(e,r),r}}),Ja=S.cw(h=>{var t=wi().has;h.exports=function(e){return t(e),e}}),Qa=S.cw(h=>{var t=se(),e=fi(),s=Oe().f,i=t("unscopables"),r=Array.prototype;r[i]===void 0&&s(r,i,{configurable:!0,value:e(null)}),h.exports=function(n){r[i][n]=!0}}),Fn=S.cw(h=>{var t=pi(),e=TypeError;h.exports=function(s,i){if(t(i,s))return s;throw new e("Incorrect invocation")}}),Rn=S.cw(h=>{var t=Ut(),e=String,s=TypeError;h.exports=function(i){if(i===void 0||t(i))return i;throw new s(e(i)+" is not an object or undefined")}}),bt=S.cw(h=>{var t=Ut(),e=String,s=TypeError;h.exports=function(i){if(t(i))return i;throw new s(e(i)+" is not an object")}}),ri=S.cw(h=>{var t=ai(),e=TypeError;h.exports=function(s){if(t(s)==="Uint8Array")return s;throw new e("Argument is not an Uint8Array")}}),Dn=S.cw(h=>{h.exports=typeof ArrayBuffer<"u"&&typeof DataView<"u"}),Za=S.cw(h=>{var t=gt(),e=pr(),s=Ve(),i=t.ArrayBuffer,r=t.TypeError;h.exports=i&&e(i.prototype,"byteLength","get")||function(n){if(s(n)!=="ArrayBuffer")throw new r("ArrayBuffer expected");return n.byteLength}}),to=S.cw(h=>{var t=gt(),e=Dn(),s=Za(),i=t.DataView;h.exports=function(r){if(!e||s(r)!==0)return!1;try{return new i(r),!1}catch{return!0}}}),ni=S.cw(h=>{var t=to(),e=TypeError;h.exports=function(s){if(t(s))throw new e("ArrayBuffer is detached");return s}}),eo=S.cw(h=>{var t=Dn(),e=Lt(),s=gt(),i=Ct(),r=Ut(),n=Bt(),a=ai(),o=yi(),l=oi(),c=ci(),d=Bn(),u=pi(),f=br(),p=wr(),g=se(),m=bi(),v=ui(),b=v.enforce,y=v.get,w=s.Int8Array,A=w&&w.prototype,_=s.Uint8ClampedArray,E=_&&_.prototype,x=w&&f(w),T=A&&f(A),C=Object.prototype,P=s.TypeError,k=g("toStringTag"),R=m("TYPED_ARRAY_TAG"),B="TypedArrayConstructor",U=t&&!!p&&a(s.opera)!=="Opera",M=!1,O,V,q,Q={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Z={BigInt64Array:8,BigUint64Array:8},K=function(J){if(!r(J))return!1;var ct=a(J);return ct==="DataView"||n(Q,ct)||n(Z,ct)},F=function($){var J=f($);if(r(J)){var ct=y(J);return ct&&n(ct,B)?ct[B]:F(J)}},I=function($){if(!r($))return!1;var J=a($);return n(Q,J)||n(Z,J)},N=function($){if(I($))return $;throw new P("Target is not a typed array")},G=function($){if(i($)&&(!p||u(x,$)))return $;throw new P(o($)+" is not a typed array constructor")},W=function($,J,ct,Mt){if(e){if(ct)for(var ht in Q){var Ot=s[ht];if(Ot&&n(Ot.prototype,$))try{delete Ot.prototype[$]}catch{try{Ot.prototype[$]=J}catch{}}}(!T[$]||ct)&&c(T,$,ct?J:U&&A[$]||J,Mt)}},tt=function($,J,ct){var Mt,ht;if(e){if(p){if(ct){for(Mt in Q)if(ht=s[Mt],ht&&n(ht,$))try{delete ht[$]}catch{}}if(!x[$]||ct)try{return c(x,$,ct?J:U&&x[$]||J)}catch{}else return}for(Mt in Q)ht=s[Mt],ht&&(!ht[$]||ct)&&c(ht,$,J)}};for(O in Q)V=s[O],q=V&&V.prototype,q?b(q)[B]=V:U=!1;for(O in Z)V=s[O],q=V&&V.prototype,q&&(b(q)[B]=V);if((!U||!i(x)||x===Function.prototype)&&(x=function(){throw new P("Incorrect invocation")},U))for(O in Q)s[O]&&p(s[O],x);if((!U||!T||T===C)&&(T=x.prototype,U))for(O in Q)s[O]&&p(s[O].prototype,T);if(U&&f(E)!==T&&p(E,T),e&&!n(T,k)){M=!0,d(T,k,{configurable:!0,get:function(){return r(this)?this[R]:void 0}});for(O in Q)s[O]&&l(s[O].prototype,R,O)}h.exports={NATIVE_ARRAY_BUFFER_VIEWS:U,TYPED_ARRAY_TAG:M&&R,aTypedArray:N,aTypedArrayConstructor:G,exportTypedArrayMethod:W,exportTypedArrayStaticMethod:tt,getTypedArrayConstructor:F,isView:K,isTypedArray:I,TypedArray:x,TypedArrayPrototype:T}}),so=S.cw(h=>{var t=cs();h.exports=function(e,s,i){for(var r=0,n=arguments.length>2?i:t(s),a=new e(n);n>r;)a[r]=s[r++];return a}}),hr=S.cw(h=>{var t=mi(),e=Jo(),s=cs(),i=function(r){return function(n,a,o){var l=t(n),c=s(l);if(c===0)return!r&&-1;var d=e(o,c),u;if(r&&a!==a){for(;c>d;)if(u=l[d++],u!==u)return!0}else for(;c>d;d++)if((r||d in l)&&l[d]===a)return r||d||0;return!r&&-1}};h.exports={includes:i(!0),indexOf:i(!1)}}),io=S.cw(h=>{var t=Lt(),e=vr(),s=TypeError,i=Object.getOwnPropertyDescriptor,r=t&&!(function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(n){return n instanceof TypeError}})();h.exports=r?function(n,a){if(e(n)&&!i(n,"length").writable)throw new s("Cannot set read only .length");return n.length=a}:function(n,a){return n.length=a}}),ro=S.cw(h=>{var t=pt();h.exports=t([].slice)}),Nn=()=>S(804),Ln=S.cw(h=>{var t=bt(),e=jt();h.exports=function(s,i,r,n){try{return n?i(t(r)[0],r[1]):i(r)}catch(a){e(s,"throw",a)}}}),Ve=S.cw(h=>{var t=pt(),e=t({}.toString),s=t("".slice);h.exports=function(i){return s(e(i),8,-1)}}),ai=S.cw(h=>{var t=tl(),e=Ct(),s=Ve(),i=se(),r=i("toStringTag"),n=Object,a=s((function(){return arguments})())==="Arguments",o=function(l,c){try{return l[c]}catch{}};h.exports=t?s:function(l){var c,d,u;return l===void 0?"Undefined":l===null?"Null":typeof(d=o(c=n(l),r))=="string"?d:a?s(c):(u=s(c))==="Object"&&e(c.callee)?"Arguments":u}}),no=S.cw(h=>{var t=Bt(),e=jo(),s=Kn(),i=Oe();h.exports=function(r,n,a){for(var o=e(n),l=i.f,c=s.f,d=0;d<o.length;d++){var u=o[d];!t(r,u)&&!(a&&t(a,u))&&l(r,u,c(n,u))}}}),ao=S.cw(h=>{var t=wt();h.exports=!t(function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype})}),oo=()=>S(529),oi=S.cw(h=>{var t=Lt(),e=Oe(),s=li();h.exports=t?function(i,r,n){return e.f(i,r,s(1,n))}:function(i,r,n){return i[r]=n,i}}),li=S.cw(h=>{h.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}}),dr=S.cw(h=>{var t=Lt(),e=Oe(),s=li();h.exports=function(i,r,n){t?e.f(i,r,s(0,n)):i[r]=n}}),Bn=S.cw(h=>{var t=zn(),e=Oe();h.exports=function(s,i,r){return r.get&&t(r.get,i,{getter:!0}),r.set&&t(r.set,i,{setter:!0}),e.f(s,i,r)}}),ci=S.cw(h=>{var t=Ct(),e=Oe(),s=zn(),i=ur();h.exports=function(r,n,a,o){o||(o={});var l=o.enumerable,c=o.name!==void 0?o.name:n;if(t(a)&&s(a,c,o),o.global)l?r[n]=a:i(n,a);else{try{o.unsafe?r[n]&&(l=!0):delete r[n]}catch{}l?r[n]=a:e.f(r,n,{value:a,enumerable:!1,configurable:!o.nonConfigurable,writable:!o.nonWritable})}return r}}),lo=S.cw(h=>{var t=ci();h.exports=function(e,s,i){for(var r in s)t(e,r,s[r],i);return e}}),ur=S.cw(h=>{var t=gt(),e=Object.defineProperty;h.exports=function(s,i){try{e(t,s,{value:i,configurable:!0,writable:!0})}catch{t[s]=i}return i}}),Lt=S.cw(h=>{var t=wt();h.exports=!t(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})}),Un=S.cw(h=>{var t=gt(),e=Ut(),s=t.document,i=e(s)&&e(s.createElement);h.exports=function(r){return i?s.createElement(r):{}}}),co=()=>S(837),ho=()=>S(2),fr=S.cw(h=>{h.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]}),uo=S.cw(h=>{var t=gt(),e=t.navigator,s=e&&e.userAgent;h.exports=s?String(s):""}),fo=S.cw(h=>{var t=gt(),e=uo(),s=t.process,i=t.Deno,r=s&&s.versions||i&&i.version,n=r&&r.v8,a,o;n&&(a=n.split("."),o=a[0]>0&&a[0]<4?1:+(a[0]+a[1])),!o&&e&&(a=e.match(/Edge\/(\d+)/),(!a||a[1]>=74)&&(a=e.match(/Chrome\/(\d+)/),a&&(o=+a[1]))),h.exports=o}),po=S.cw(h=>{var t=pt(),e=Error,s=t("".replace),i=(function(a){return String(new e(a).stack)})("zxcasd"),r=/\n\s*at [^:]*:[^\n]*/,n=r.test(i);h.exports=function(a,o){if(n&&typeof a=="string"&&!e.prepareStackTrace)for(;o--;)a=s(a,r,"");return a}}),rt=S.cw(h=>{var t=gt(),e=Kn().f,s=oi(),i=ci(),r=ur(),n=no(),a=xo();h.exports=function(o,l){var c=o.target,d=o.global,u=o.stat,f,p,g,m,v,b;if(d?p=t:u?p=t[c]||r(c,{}):p=t[c]&&t[c].prototype,p)for(g in l){if(v=l[g],o.dontCallGetSet?(b=e(p,g),m=b&&b.value):m=p[g],f=a(d?g:c+(u?".":"#")+g,o.forced),!f&&m!==void 0){if(typeof v==typeof m)continue;n(v,m)}(o.sham||m&&m.sham)&&s(v,"sham",!0),i(p,g,v,o)}}}),wt=S.cw(h=>{h.exports=function(t){try{return!!t()}catch{return!0}}}),go=S.cw(h=>{var t=hi(),e=Function.prototype,s=e.apply,i=e.call;h.exports=typeof Reflect=="object"&&Reflect.apply||(t?i.bind(s):function(){return i.apply(s,arguments)})}),mo=S.cw(h=>{var t=yo(),e=Nt(),s=hi(),i=t(t.bind);h.exports=function(r,n){return e(r),n===void 0?r:s?i(r,n):function(){return r.apply(n,arguments)}}}),hi=S.cw(h=>{var t=wt();h.exports=!t(function(){var e=(function(){}).bind();return typeof e!="function"||e.hasOwnProperty("prototype")})}),At=S.cw(h=>{var t=hi(),e=Function.prototype.call;h.exports=t?e.bind(e):function(){return e.apply(e,arguments)}}),vo=S.cw(h=>{var t=Lt(),e=Bt(),s=Function.prototype,i=t&&Object.getOwnPropertyDescriptor,r=e(s,"name"),n=r&&(!t||t&&i(s,"name").configurable);h.exports={CONFIGURABLE:n}}),pr=S.cw(h=>{var t=pt(),e=Nt();h.exports=function(s,i,r){try{return t(e(Object.getOwnPropertyDescriptor(s,i)[r]))}catch{}}}),yo=S.cw(h=>{var t=Ve(),e=pt();h.exports=function(s){if(t(s)==="Function")return e(s)}}),pt=S.cw(h=>{var t=hi(),e=Function.prototype,s=e.call,i=t&&e.bind.bind(s,s);h.exports=t?i:function(r){return function(){return s.apply(r,arguments)}}}),jn=()=>S(944),ke=S.cw(h=>{var t=gt(),e=Ct(),s=function(i){return e(i)?i:void 0};h.exports=function(i,r){return arguments.length<2?s(t[i]):t[i]&&t[i][r]}}),ee=()=>S(767),bo=S.cw(h=>{var t=At(),e=bt(),s=ee(),i=gr();h.exports=function(r,n){(!n||typeof r!="string")&&e(r);var a=i(r);return s(e(a!==void 0?t(a,r):r))}}),Hn=S.cw(h=>{var t=At(),e=Ct(),s=bt(),i=yi(),r=gr(),n=TypeError;h.exports=function(a,o){var l=arguments.length<2?r(a):o;if(e(l))return s(t(l,a));throw new n(i(a)+" is not iterable")}}),gr=S.cw(h=>{var t=Ve(),e=Gn(),s=di(),i=se(),r=i("iterator"),n=Array.prototype;h.exports=function(a){if(!e(a))return s(a,r)||s(a,"@@iterator")||(t(a)==="Arguments"?n[r]:void 0)}}),di=S.cw(h=>{var t=Nt(),e=Gn();h.exports=function(s,i){var r=s[i];return e(r)?void 0:t(r)}}),Xe=S.cw(h=>{var t=Nt(),e=bt(),s=At(),i=Er(),r=ee(),n="Invalid size",a=RangeError,o=TypeError,l=Math.max,c=function(d,u){this.set=d,this.size=l(u,0),this.has=t(d.has),this.keys=t(d.keys)};c.prototype={getIterator:function(){return r(e(s(this.keys,this.set)))},includes:function(d){return s(this.has,this.set,d)}},h.exports=function(d){e(d);var u=+d.size;if(u!==u)throw new o(n);var f=i(u);if(f<0)throw new a(n);return new c(d,f)}}),gt=S.cw(function(h){var t=function(e){return e&&e.Math===Math&&e};h.exports=t(typeof globalThis=="object"&&globalThis)||t(typeof window=="object"&&window)||t(typeof self=="object"&&self)||t(typeof global=="object"&&global)||t(typeof this=="object"&&this)||(function(){return this})()||Function("return this")()}),Bt=S.cw(h=>{var t=pt(),e=Tr(),s=t({}.hasOwnProperty);h.exports=Object.hasOwn||function(r,n){return s(e(r),n)}}),mr=S.cw(h=>{h.exports={}}),wo=S.cw(h=>{var t=ke();h.exports=t("document","documentElement")}),$n=S.cw(h=>{var t=Lt(),e=wt(),s=Un();h.exports=!t&&!e(function(){return Object.defineProperty(s("div"),"a",{get:function(){return 7}}).a!==7})}),_o=S.cw(h=>{var t=pt(),e=wt(),s=Ve(),i=Object,r=t("".split);h.exports=e(function(){return!i("z").propertyIsEnumerable(0)})?function(n){return s(n)==="String"?r(n,""):i(n)}:i}),Ao=S.cw(h=>{var t=Ct(),e=Ut(),s=wr();h.exports=function(i,r,n){var a,o;return s&&t(a=r.constructor)&&a!==n&&e(o=a.prototype)&&o!==n.prototype&&s(i,o),i}}),So=S.cw(h=>{var t=pt(),e=Ct(),s=Sr(),i=t(Function.toString);e(s.inspectSource)||(s.inspectSource=function(r){return i(r)}),h.exports=s.inspectSource}),ui=S.cw(h=>{var t=rl(),e=gt(),s=Ut(),i=oi(),r=Bt(),n=Sr(),a=Ar(),o=mr(),l="Object already initialized",c=e.TypeError,d=e.WeakMap,u,f,p,g=function(y){return p(y)?f(y):u(y,{})},m=function(y){return function(w){var A;if(!s(w)||(A=f(w)).type!==y)throw new c("Incompatible receiver, "+y+" required");return A}};if(t||n.state){var v=n.state||(n.state=new d);v.get=v.get,v.has=v.has,v.set=v.set,u=function(y,w){if(v.has(y))throw new c(l);return w.facade=y,v.set(y,w),w},f=function(y){return v.get(y)||{}},p=function(y){return v.has(y)}}else{var b=a("state");o[b]=!0,u=function(y,w){if(r(y,b))throw new c(l);return w.facade=y,i(y,b,w),w},f=function(y){return r(y,b)?y[b]:{}},p=function(y){return r(y,b)}}h.exports={set:u,get:f,has:p,enforce:g,getterFor:m}}),Eo=S.cw(h=>{var t=se(),e=Oo(),s=t("iterator"),i=Array.prototype;h.exports=function(r){return r!==void 0&&(e.Array===r||i[s]===r)}}),vr=S.cw(h=>{var t=Ve();h.exports=Array.isArray||function(s){return t(s)==="Array"}}),To=S.cw(h=>{var t=ai();h.exports=function(e){var s=t(e);return s==="BigInt64Array"||s==="BigUint64Array"}}),Ct=S.cw(h=>{var t=typeof document=="object"&&document.all;h.exports=typeof t>"u"&&t!==void 0?function(e){return typeof e=="function"||e===t}:function(e){return typeof e=="function"}}),xo=S.cw(h=>{var t=wt(),e=Ct(),s=/#|\.prototype\./,i=function(l,c){var d=n[r(l)];return d===o?!0:d===a?!1:e(c)?t(c):!!c},r=i.normalize=function(l){return String(l).replace(s,".").toLowerCase()},n=i.data={},a=i.NATIVE="N",o=i.POLYFILL="P";h.exports=i}),Gn=()=>S(117),Ut=S.cw(h=>{var t=Ct();h.exports=function(e){return typeof e=="object"?e!==null:t(e)}}),Co=S.cw(h=>{var t=Ut();h.exports=function(e){return t(e)||e===null}}),zt=S.cw(h=>{h.exports=!1}),Po=S.cw(h=>{var t=Ut(),e=ui().get;h.exports=function(i){if(!t(i))return!1;var r=e(i);return!!r&&r.type==="RawJSON"}}),yr=S.cw(h=>{var t=ke(),e=Ct(),s=pi(),i=na(),r=Object;h.exports=i?function(n){return typeof n=="symbol"}:function(n){var a=t("Symbol");return e(a)&&s(a.prototype,r(n))}}),Ye=S.cw(h=>{var t=At();h.exports=function(e,s,i){for(var r=i?e:e.iterator,n=e.next,a,o;!(a=t(n,r)).done;)if(o=s(a.value),o!==void 0)return o}}),ls=S.cw(h=>{var t=mo(),e=At(),s=bt(),i=yi(),r=Eo(),n=cs(),a=pi(),o=Hn(),l=gr(),c=jt(),d=TypeError,u=function(p,g){this.stopped=p,this.result=g},f=u.prototype;h.exports=function(p,g,m){var v=m&&m.that,b=!!(m&&m.AS_ENTRIES),y=!!(m&&m.IS_RECORD),w=!!(m&&m.IS_ITERATOR),A=!!(m&&m.INTERRUPTED),_=t(g,v),E,x,T,C,P,k,R,B=function(O){var V=E;return E=void 0,V&&c(V,"normal"),new u(!0,O)},U=function(O){return b?(s(O),A?_(O[0],O[1],B):_(O[0],O[1])):A?_(O,B):_(O)};if(y)E=p.iterator;else if(w)E=p;else{if(x=l(p),!x)throw new d(i(p)+" is not iterable");if(r(x)){for(T=0,C=n(p);C>T;T++)if(P=U(p[T]),P&&a(f,P))return P;return new u(!1)}E=o(p,x)}for(k=y?p.next:E.next;!(R=e(k,E)).done;){var M=R.value;try{P=U(M)}catch(O){if(E)c(E,"throw",O);else throw O}if(typeof P=="object"&&P&&a(f,P))return P}return new u(!1)}}),Io=()=>S(859),ko=S.cw(h=>{var t=jt();h.exports=function(e,s,i){for(var r=e.length-1;r>=0;r--)if(e[r]!==void 0)try{i=t(e[r].iterator,s,i)}catch(n){s="throw",i=n}if(s==="throw")throw i;return i}}),jt=S.cw(h=>{var t=At(),e=bt(),s=di();h.exports=function(i,r,n){var a,o;e(i);try{if(a=s(i,"return"),!a){if(r==="throw")throw n;return n}a=t(a,i)}catch(l){o=!0,a=l}if(r==="throw")throw n;if(o)throw a;return e(a),n}}),Ps=S.cw(h=>{var t=At(),e=fi(),s=oi(),i=lo(),r=se(),n=ui(),a=di(),o=Wn().IteratorPrototype,l=oo(),c=jt(),d=ko(),u=Io(),f=r("toStringTag"),p="IteratorHelper",g="WrapForValidIterator",m="normal",v="throw",b=n.set,y=function(_){var E=n.getterFor(_?g:p);return i(e(o),{next:function(){var T=E(this);if(_)return T.nextHandler();if(T.done)return l(void 0,!0);try{var C=T.nextHandler();return T.done&&u(T),T.returnHandlerResult?C:l(C,T.done)}catch(P){throw T.done=!0,u(T),P}},return:function(){var x=E(this),T=x.iterator,C=x.inner,P=x.openIters,k=x.done;if(x.done=!0,_){var R=a(T,"return");return R?t(R,T):l(void 0,!0)}if(u(x),k)return l(void 0,!0);if(C)try{c(C.iterator,m)}catch(B){return c(T,v,B)}if(P)try{d(P,m)}catch(B){if(T)return c(T,v,B);throw B}return T&&c(T,m),l(void 0,!0)}})},w=y(!0),A=y(!1);s(A,f,"Iterator Helper"),h.exports=function(_,E,x){var T=function(P,k){k?(k.iterator=P.iterator,k.next=P.next):k=P,k.type=E?g:p,k.returnHandlerResult=!!x,k.nextHandler=_,k.counter=0,k.done=!1,b(this,k)};return T.prototype=E?w:A,T}}),Is=()=>S(684),Ae=S.cw(h=>{var t=gt();h.exports=function(e,s){var i=t.Iterator,r=i&&i.prototype,n=r&&r[e],a=!1;if(n)try{n.call({next:function(){return{done:!0}},return:function(){a=!0}},-1)}catch(o){o instanceof s||(a=!1)}if(!a)return n}}),Wn=S.cw(h=>{var t=wt(),e=Ct(),s=Ut(),i=fi(),r=br(),n=ci(),a=se(),o=zt(),l=a("iterator"),c,d,u;[].keys&&(u=[].keys(),"next"in u&&(d=r(r(u)),d!==Object.prototype&&(c=d)));var f=!s(c)||t(function(){var p={};return c[l].call(p)!==p});f?c={}:o&&(c=i(c)),e(c[l])||n(c,l,function(){return this}),h.exports={IteratorPrototype:c}}),Oo=()=>S(269),cs=S.cw(h=>{var t=Zo();h.exports=function(e){return t(e.length)}}),zn=S.cw(h=>{var t=pt(),e=wt(),s=Ct(),i=Bt(),r=Lt(),n=vo().CONFIGURABLE,a=So(),o=ui(),l=o.enforce,c=o.get,d=String,u=Object.defineProperty,f=t("".slice),p=t("".replace),g=t([].join),m=r&&!e(function(){return u(function(){},"length",{value:8}).length!==8}),v=String(String).split("String"),b=h.exports=function(y,w,A){f(d(w),0,7)==="Symbol("&&(w="["+p(d(w),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),A&&A.getter&&(w="get "+w),A&&A.setter&&(w="set "+w),(!i(y,"name")||n&&y.name!==w)&&(r?u(y,"name",{value:w,configurable:!0}):y.name=w),m&&A&&i(A,"arity")&&y.length!==A.arity&&u(y,"length",{value:A.arity});try{A&&i(A,"constructor")&&A.constructor?r&&u(y,"prototype",{writable:!1}):y.prototype&&(y.prototype=void 0)}catch{}var _=l(y);return i(_,"source")||(_.source=g(v,typeof w=="string"?w:"")),y};Function.prototype.toString=b(function(){return s(this)&&c(this).source||a(this)},"toString")}),Vn=S.cw(h=>{var t=pt(),e=Map.prototype;h.exports={Map,set:t(e.set),get:t(e.get),has:t(e.has),remove:t(e.delete),proto:e}}),Mo=S.cw(h=>{var t=wt();h.exports=!t(function(){var e="9007199254740993",s=JSON.rawJSON(e);return!JSON.isRawJSON(s)||JSON.stringify(s)!==e})}),Xn=S.cw(h=>{var t=Nt(),e=TypeError,s=function(i){var r,n;this.promise=new i(function(a,o){if(r!==void 0||n!==void 0)throw new e("Bad Promise constructor");r=a,n=o}),this.resolve=t(r),this.reject=t(n)};h.exports.f=function(i){return new s(i)}}),Fo=S.cw(h=>{var t=vi();h.exports=function(e,s){return e===void 0?arguments.length<2?"":s:t(e)}}),Yn=()=>S(149),fi=S.cw(h=>{var t=bt(),e=Ro(),s=fr(),i=mr(),r=wo(),n=Un(),a=Ar(),o=">",l="<",c="prototype",d="script",u=a("IE_PROTO"),f=function(){},p=function(y){return l+d+o+y+l+"/"+d+o},g=function(y){y.write(p("")),y.close();var w=y.parentWindow.Object;return y=null,w},m=function(){var y=n("iframe"),w="java"+d+":",A;return y.style.display="none",r.appendChild(y),y.src=String(w),A=y.contentWindow.document,A.open(),A.write(p("document.F=Object")),A.close(),A.F},v,b=function(){try{v=new ActiveXObject("htmlfile")}catch{}b=typeof document<"u"?document.domain&&v?g(v):m():g(v);for(var y=s.length;y--;)delete b[c][s[y]];return b()};i[u]=!0,h.exports=Object.create||function(w,A){var _;return w!==null?(f[c]=t(w),_=new f,f[c]=null,_[u]=w):_=b(),A===void 0?_:e.f(_,A)}}),Ro=S.cw((h,t)=>{var e=Lt(),s=aa(),i=Oe(),r=bt(),n=mi(),a=Lo();t.f=e&&!s?Object.defineProperties:function(l,c){r(l);for(var d=n(c),u=a(c),f=u.length,p=0,g;f>p;)i.f(l,g=u[p++],d[g]);return l}}),Oe=S.cw((h,t)=>{var e=Lt(),s=$n(),i=aa(),r=bt(),n=ia(),a=TypeError,o=Object.defineProperty,l=Object.getOwnPropertyDescriptor,c="enumerable",d="configurable",u="writable";t.f=e?i?function(p,g,m){if(r(p),g=n(g),r(m),typeof p=="function"&&g==="prototype"&&"value"in m&&u in m&&!m[u]){var v=l(p,g);v&&v[u]&&(p[g]=m.value,m={configurable:d in m?m[d]:v[d],enumerable:c in m?m[c]:v[c],writable:!1})}return o(p,g,m)}:o:function(p,g,m){if(r(p),g=n(g),r(m),s)try{return o(p,g,m)}catch{}if("get"in m||"set"in m)throw new a("Accessors not supported");return"value"in m&&(p[g]=m.value),p}}),Kn=S.cw((h,t)=>{var e=Lt(),s=At(),i=Bo(),r=li(),n=mi(),a=ia(),o=Bt(),l=$n(),c=Object.getOwnPropertyDescriptor;t.f=e?c:function(u,f){if(u=n(u),f=a(f),l)try{return c(u,f)}catch{}if(o(u,f))return r(!s(i.f,u,f),u[f])}}),Do=S.cw((h,t)=>{var e=qn(),s=fr(),i=s.concat("length","prototype");t.f=Object.getOwnPropertyNames||function(n){return e(n,i)}}),No=()=>S(717),br=S.cw(h=>{var t=Bt(),e=Ct(),s=Tr(),i=Ar(),r=ao(),n=i("IE_PROTO"),a=Object,o=a.prototype;h.exports=r?a.getPrototypeOf:function(l){var c=s(l);if(t(c,n))return c[n];var d=c.constructor;return e(d)&&c instanceof d?d.prototype:c instanceof a?o:null}}),pi=S.cw(h=>{var t=pt();h.exports=t({}.isPrototypeOf)}),qn=S.cw(h=>{var t=pt(),e=Bt(),s=mi(),i=hr().indexOf,r=mr(),n=t([].push);h.exports=function(a,o){var l=s(a),c=0,d=[],u;for(u in l)!e(r,u)&&e(l,u)&&n(d,u);for(;o.length>c;)e(l,u=o[c++])&&(~i(d,u)||n(d,u));return d}}),Lo=S.cw(h=>{var t=qn(),e=fr();h.exports=Object.keys||function(i){return t(i,e)}}),Bo=S.cw((h,t)=>{var e={}.propertyIsEnumerable,s=Object.getOwnPropertyDescriptor,i=s&&!e.call({1:2},1);t.f=i?function(n){var a=s(this,n);return!!a&&a.enumerable}:e}),wr=S.cw(h=>{var t=pr(),e=Ut(),s=Qn(),i=Ka();h.exports=Object.setPrototypeOf||("__proto__"in{}?(function(){var r=!1,n={},a;try{a=t(Object.prototype,"__proto__","set"),a(n,[]),r=n instanceof Array}catch{}return function(l,c){return s(l),i(c),e(l)&&(r?a(l,c):l.__proto__=c),l}})():void 0)}),Uo=S.cw(h=>{var t=At(),e=Ct(),s=Ut(),i=TypeError;h.exports=function(r,n){var a,o;if(n==="string"&&e(a=r.toString)&&!s(o=t(a,r))||e(a=r.valueOf)&&!s(o=t(a,r))||n!=="string"&&e(a=r.toString)&&!s(o=t(a,r)))return o;throw new i("Can't convert object to primitive value")}}),jo=S.cw(h=>{var t=ke(),e=pt(),s=Do(),i=No(),r=bt(),n=e([].concat);h.exports=t("Reflect","ownKeys")||function(o){var l=s.f(r(o)),c=i.f;return c?n(l,c(o)):l}}),Jn=S.cw(h=>{var t=pt(),e=Bt(),s=SyntaxError,i=parseInt,r=String.fromCharCode,n=t("".charAt),a=t("".slice),o=t(/./.exec),l={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":`
2
+ `,"\\r":"\r","\\t":" "},c=/^[\da-f]{4}$/i,d=/^[\u0000-\u001F]$/;h.exports=function(u,f){for(var p=!0,g="";f<u.length;){var m=n(u,f);if(m==="\\"){var v=a(u,f,f+2);if(e(l,v))g+=l[v],f+=2;else if(v==="\\u"){f+=2;var b=a(u,f,f+4);if(!o(c,b))throw new s("Bad Unicode escape at: "+f);g+=r(i(b,16)),f+=4}else throw new s('Unknown escape sequence: "'+v+'"')}else if(m==='"'){p=!1,f++;break}else{if(o(d,m))throw new s("Bad control character in string literal at: "+f);g+=m,f++}}if(p)throw new s("Unterminated string at: "+f);return{value:g,end:f}}}),Ho=()=>S(103),$o=S.cw(h=>{var t=bt(),e=Ut(),s=Xn();h.exports=function(i,r){if(t(i),e(r)&&r.constructor===i)return r;var n=s.f(i),a=n.resolve;return a(r),n.promise}}),Qn=()=>S(750),_r=S.cw(h=>{var t=fe(),e=ks(),s=t.Set,i=t.add;h.exports=function(r){var n=new s;return e(r,function(a){i(n,a)}),n}}),Go=S.cw(h=>{var t=ze(),e=fe(),s=_r(),i=Os(),r=Xe(),n=ks(),a=Ye(),o=e.has,l=e.remove;h.exports=function(d){var u=t(this),f=r(d),p=s(u);return i(p)<=f.size?n(p,function(g){f.includes(g)&&l(p,g)}):a(f.getIterator(),function(g){o(p,g)&&l(p,g)}),p}}),fe=S.cw(h=>{var t=pt(),e=Set.prototype;h.exports={Set,add:t(e.add),has:t(e.has),remove:t(e.delete),proto:e}}),Wo=S.cw(h=>{var t=ze(),e=fe(),s=Os(),i=Xe(),r=ks(),n=Ye(),a=e.Set,o=e.add,l=e.has;h.exports=function(d){var u=t(this),f=i(d),p=new a;return s(u)>f.size?n(f.getIterator(),function(g){l(u,g)&&o(p,g)}):r(u,function(g){f.includes(g)&&o(p,g)}),p}}),zo=S.cw(h=>{var t=ze(),e=fe().has,s=Os(),i=Xe(),r=ks(),n=Ye(),a=jt();h.exports=function(l){var c=t(this),d=i(l);if(s(c)<=d.size)return r(c,function(f){if(d.includes(f))return!1},!0)!==!1;var u=d.getIterator();return n(u,function(f){if(e(c,f))return a(u.iterator,"normal",!1)})!==!1}}),Vo=S.cw(h=>{var t=ze(),e=Os(),s=ks(),i=Xe();h.exports=function(n){var a=t(this),o=i(n);return e(a)>o.size?!1:s(a,function(l){if(!o.includes(l))return!1},!0)!==!1}}),Xo=S.cw(h=>{var t=ze(),e=fe().has,s=Os(),i=Xe(),r=Ye(),n=jt();h.exports=function(o){var l=t(this),c=i(o);if(s(l)<c.size)return!1;var d=c.getIterator();return r(d,function(u){if(!e(l,u))return n(d.iterator,"normal",!1)})!==!1}}),ks=S.cw(h=>{var t=pt(),e=Ye(),s=fe(),i=s.Set,r=s.proto,n=t(r.forEach),a=t(r.keys),o=a(new i).next;h.exports=function(l,c,d){return d?e({iterator:a(l),next:o},c):n(l,c)}}),Ke=S.cw(h=>{var t=ke(),e=function(i){return{size:i,has:function(){return!1},keys:function(){return{next:function(){return{done:!0}}}}}},s=function(i){return{size:i,has:function(){return!0},keys:function(){throw new Error("e")}}};h.exports=function(i,r){var n=t("Set");try{new n()[i](e(0));try{return new n()[i](e(-1)),!1}catch{if(!r)return!0;try{return new n()[i](s(-1/0)),!1}catch{var a=new n([1,2]);return r(a[i](s(1/0)))}}}catch{return!1}}}),Zn=()=>S(835),Os=S.cw(h=>{var t=pr(),e=fe();h.exports=t(e.proto,"size","get")||function(s){return s.size}}),Yo=S.cw(h=>{var t=ze(),e=fe(),s=_r(),i=Xe(),r=Ye(),n=e.add,a=e.has,o=e.remove;h.exports=function(c){var d=t(this),u=i(c).getIterator(),f=s(d);return r(u,function(p){a(d,p)?o(f,p):n(f,p)}),f}}),Ko=S.cw(h=>{var t=ze(),e=fe().add,s=_r(),i=Xe(),r=Ye();h.exports=function(a){var o=t(this),l=i(a).getIterator(),c=s(o);return r(l,function(d){e(c,d)}),c}}),Ar=S.cw(h=>{var t=ta(),e=bi(),s=t("keys");h.exports=function(i){return s[i]||(s[i]=e(i))}}),Sr=S.cw(h=>{var t=zt(),e=gt(),s=ur(),i="__core-js_shared__",r=h.exports=e[i]||s(i,{});(r.versions||(r.versions=[])).push({version:"3.51.0",mode:t?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.51.0/LICENSE",source:"https://github.com/zloirock/core-js"})}),ta=S.cw(h=>{var t=Sr(),e=Object.create||Object;h.exports=function(s,i){return t[s]||(t[s]=i||e(null))}}),gi=S.cw(h=>{var t=fo(),e=wt(),s=gt(),i=s.String;h.exports=!!Object.getOwnPropertySymbols&&!e(function(){var r=Symbol("symbol detection");return!i(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&t&&t<41})}),qo=S.cw(h=>{var t=pt();h.exports=t(1.1.valueOf)}),Jo=S.cw(h=>{var t=Er(),e=Math.max,s=Math.min;h.exports=function(i,r){var n=t(i);return n<0?e(n+r,0):s(n,r)}}),Qo=S.cw(h=>{var t=sa(),e=TypeError;h.exports=function(s){var i=t(s,"number");if(typeof i=="number")throw new e("Can't convert number to bigint");return BigInt(i)}}),mi=S.cw(h=>{var t=_o(),e=Qn();h.exports=function(s){return t(e(s))}}),Er=()=>S(291),Zo=()=>S(14),Tr=()=>S(981),ea=()=>S(590),sa=S.cw(h=>{var t=At(),e=Ut(),s=yr(),i=di(),r=Uo(),n=se(),a=TypeError,o=n("toPrimitive");h.exports=function(l,c){if(!e(l)||s(l))return l;var d=i(l,o),u;if(d){if(c===void 0&&(c="default"),u=t(d,l,c),!e(u)||s(u))return u;throw new a("Can't convert object to primitive value")}return c===void 0&&(c="number"),r(l,c)}}),ia=S.cw(h=>{var t=sa(),e=yr();h.exports=function(s){var i=t(s,"string");return e(i)?i:i+""}}),tl=S.cw(h=>{var t=se(),e=t("toStringTag"),s={};s[e]="z",h.exports=String(s)==="[object z]"}),vi=S.cw(h=>{var t=ai(),e=String;h.exports=function(s){if(t(s)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return e(s)}}),yi=S.cw(h=>{var t=String;h.exports=function(e){try{return t(e)}catch{return"Object"}}}),bi=S.cw(h=>{var t=pt(),e=0,s=Math.random(),i=t(1.1.toString);h.exports=function(r){return"Symbol("+(r===void 0?"":r)+")_"+i(++e+s,36)}}),ra=S.cw(h=>{var t=gt(),e=pt(),s=Rn(),i=Mn(),r=Bt(),n=Nn(),a=jn(),o=ni(),l=n.c2i,c=n.c2iUrl,d=t.SyntaxError,u=t.TypeError,f=t.Array,p=e("".charAt),g=Math.floor,m=function(y,w){for(var A=y.length;w<A;w++){var _=p(y,w);if(_!==" "&&_!==" "&&_!==`
3
+ `&&_!=="\f"&&_!=="\r")break}return w},v=function(y,w,A){var _=y.length;_<4&&(y+=_===2?"AA":"A");var E=(w[p(y,0)]<<18)+(w[p(y,1)]<<12)+(w[p(y,2)]<<6)+w[p(y,3)],x=[E>>16&255,E>>8&255,E&255];if(_===2){if(A&&x[1]!==0)throw new d("Extra bits");return[x[0]]}if(_===3){if(A&&x[2]!==0)throw new d("Extra bits");return[x[0],x[1]]}return x},b=function(y,w,A){for(var _=w.length,E=0;E<_;E++)y[A+E]=w[E];return A+_};h.exports=function(y,w,A,_){i(y),s(w);var E=a(w)==="base64"?l:c,x=w?w.lastChunkHandling:void 0;if(x===void 0&&(x="loose"),x!=="loose"&&x!=="strict"&&x!=="stop-before-partial")throw new u("Incorrect `lastChunkHandling` option");A&&o(A.buffer);var T=y.length,C=A||f(g(T*3/4)),P=0,k=0,R="",B=0;if(_)for(;;){if(B=m(y,B),B===T){if(R.length>0){if(x==="stop-before-partial")break;if(x==="loose"){if(R.length===1)throw new d("Malformed padding: exactly one additional character");P=b(C,v(R,E,!1),P)}else throw new d("Missing padding")}k=T;break}var U=p(y,B);if(++B,U==="="){if(R.length<2)throw new d("Padding is too early");if(B=m(y,B),R.length===2){if(B===T){if(x==="stop-before-partial")break;throw new d("Malformed padding: only one =")}p(y,B)==="="&&(++B,B=m(y,B))}if(B<T)throw new d("Unexpected character after padding");P=b(C,v(R,E,x==="strict"),P),k=T;break}if(!r(E,U))throw new d("Unexpected character");var M=_-P;if(M===1&&R.length===2||M===2&&R.length===3||(R+=U,R.length===4&&(P=b(C,v(R,E,!1),P),R="",k=B,P===_)))break}return A||(C.length=P),{bytes:C,read:k,written:P}}}),el=S.cw(h=>{var t=gt(),e=pt(),s=t.Uint8Array,i=t.SyntaxError,r=Math.min,n=e("".match);h.exports=function(a,o){var l=a.length;if(l%2!==0)throw new i("String should be an even number of characters");for(var c=o?r(o.length,l/2):l/2,d=o||new s(c),u=n(a,/[\S\s]{2}/g),f=0;f<c;f++){var p=+("0x"+u[f]+"0");if(p!==p)throw new i("String should only contain hex characters");d[f]=p>>4}return{bytes:d,read:f<<1}}}),sl=S.cw(h=>{var t=wt(),e=se(),s=Lt(),i=zt(),r=e("iterator");h.exports=!t(function(){var n=new URL("b?a=1&b=2&c=3","https://a"),a=n.searchParams,o=new URLSearchParams("a=1&a=2&b=3"),l="";return n.pathname="c%20d",a.forEach(function(c,d){a.delete("b"),l+=d+c}),o.delete("a",2),o.delete("b",void 0),i&&(!n.toJSON||!o.has("a",1)||o.has("a",2)||!o.has("a",void 0)||o.has("b"))||!a.size&&(i||!s)||!a.sort||n.href!=="https://a/c%20d?a=1&c=3"||a.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!a[r]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("https://тест").host!=="xn--e1aybc"||new URL("https://a#б").hash!=="#%D0%B1"||l!=="a1c3"||new URL("https://x",void 0).host!=="x"})}),na=S.cw(h=>{var t=gi();h.exports=t&&!Symbol.sham&&typeof Symbol.iterator=="symbol"}),aa=S.cw(h=>{var t=Lt(),e=wt();h.exports=t&&e(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})}),il=()=>S(812),rl=S.cw(h=>{var t=gt(),e=Ct(),s=t.WeakMap;h.exports=e(s)&&/native code/.test(String(s))}),wi=S.cw(h=>{var t=pt(),e=WeakMap.prototype;h.exports={WeakMap,set:t(e.set),get:t(e.get),has:t(e.has),remove:t(e.delete)}}),se=S.cw(h=>{var t=gt(),e=ta(),s=Bt(),i=bi(),r=gi(),n=na(),a=t.Symbol,o=e("wks"),l=n?a.for||a:a&&a.withoutSetter||i;h.exports=function(c){return s(o,c)||(o[c]=r&&s(a,c)?a[c]:l("Symbol."+c)),o[c]}}),nl=S.cw(()=>{var h=rt(),t=hr().includes,e=wt(),s=Qa(),i=e(function(){return!Array(1).includes()}),r=e(function(){return[,1].includes(void 0,1)});h({target:"Array",proto:!0,forced:i||r},{includes:function(a){return t(this,a,arguments.length>1?arguments[1]:void 0)}}),s("includes")}),al=S.cw(()=>{var h=rt(),t=Tr(),e=cs(),s=io(),i=co(),r=wt(),n=r(function(){return[].push.call({length:4294967296},1)!==4294967297}),a=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(l){return l instanceof TypeError}},o=n||!a();h({target:"Array",proto:!0,arity:1,forced:o},{push:function(c){var d=t(this),u=e(d),f=arguments.length;i(u+f);for(var p=0;p<f;p++)d[u]=arguments[p],u++;return s(d,u),u}})}),ol=S.cw(()=>{var h=rt(),t=gt(),e=Fn(),s=bt(),i=Ct(),r=br(),n=Bn(),a=dr(),o=wt(),l=Bt(),c=se(),d=Wn().IteratorPrototype,u=Lt(),f=zt(),p="constructor",g="Iterator",m=c("toStringTag"),v=TypeError,b=t[g],y=f||!i(b)||b.prototype!==d||!o(function(){b({})}),w=function(){if(e(this,d),r(this)===d)throw new v("Abstract class Iterator not directly constructable")},A=function(_,E){u?n(d,_,{configurable:!0,get:function(){return E},set:function(x){if(s(this),this===d)throw new v("You can't redefine this property");l(this,_)?this[_]=x:a(this,_,x)}}):d[_]=E};l(d,m)||A(m,g),(y||!l(d,p)||d[p]===Object)&&A(p,w),w.prototype=d,h({global:!0,constructor:!0,forced:y},{Iterator:w})}),ll=S.cw(()=>{var h=rt(),t=At(),e=bt(),s=ee(),i=Yn(),r=ea(),n=jt(),a=Ps(),o=Is(),l=Ae(),c=zt(),d=RangeError,u=1/0,f=!c&&!o("drop",0),p=!c&&!f&&l("drop",RangeError),g=c||f||p||!(function(){try{Iterator.prototype.drop.call({next:function(){return{done:!0}}},9007199254740992)}catch(v){return v instanceof d}})(),m=a(function(){for(var v=this.iterator,b=this.next,y,w;this.remaining;)if(this.remaining--,y=e(t(b,v)),w=this.done=!!y.done,w)return;if(y=e(t(b,v)),w=this.done=!!y.done,!w)return y.value});h({target:"Iterator",proto:!0,real:!0,forced:g},{drop:function(b){e(this);var y;try{if(y=r(i(+b)),y>9007199254740991&&y!==u)throw new d("The argument should be a safe integer")}catch(w){n(this,"throw",w)}return p?t(p,this,y):new m(s(this),{remaining:y})}})}),cl=S.cw(()=>{var h=rt(),t=At(),e=ls(),s=Nt(),i=bt(),r=ee(),n=jt(),a=Ae(),o=a("every",TypeError);h({target:"Iterator",proto:!0,real:!0,forced:o},{every:function(c){i(this);try{s(c)}catch(f){n(this,"throw",f)}if(o)return t(o,this,c);var d=r(this),u=0;return!e(d,function(f,p){if(!c(f,u++))return p()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),hl=S.cw(()=>{var h=rt(),t=At(),e=Nt(),s=bt(),i=ee(),r=Ps(),n=Ln(),a=zt(),o=jt(),l=Is(),c=Ae(),d=!a&&!l("filter",function(){}),u=!a&&!d&&c("filter",TypeError),f=a||d||u,p=r(function(){for(var g=this.iterator,m=this.predicate,v=this.next,b,y,w;;){if(b=s(t(v,g)),y=this.done=!!b.done,y)return;if(w=b.value,n(g,m,[w,this.counter++],!0))return w}});h({target:"Iterator",proto:!0,real:!0,forced:f},{filter:function(m){s(this);try{e(m)}catch(v){o(this,"throw",v)}return u?t(u,this,m):new p(i(this),{predicate:m})}})}),dl=S.cw(()=>{var h=rt(),t=At(),e=ls(),s=Nt(),i=bt(),r=ee(),n=jt(),a=Ae(),o=a("find",TypeError);h({target:"Iterator",proto:!0,real:!0,forced:o},{find:function(c){i(this);try{s(c)}catch(f){n(this,"throw",f)}if(o)return t(o,this,c);var d=r(this),u=0;return e(d,function(f,p){if(c(f,u++))return p(f)},{IS_RECORD:!0,INTERRUPTED:!0}).result}})}),ul=S.cw(()=>{var h=rt(),t=At(),e=Nt(),s=bt(),i=ee(),r=bo(),n=Ps(),a=jt(),o=wt(),l=zt(),c=Is(),d=Ae(),u=!l&&o(function(){return[1].values().flatMap(function(){return[1]}).find(function(){return!0})!==1}),f=!l&&!u&&!c("flatMap",function(){}),p=!l&&!u&&!f&&d("flatMap",TypeError),g=l||u||f||p,m=n(function(){for(var v=this.iterator,b=this.mapper,y,w;;){if(w=this.inner)try{if(y=s(t(w.next,w.iterator)),!y.done)return y.value;this.inner=null}catch(A){a(v,"throw",A)}if(y=s(t(this.next,v)),this.done=!!y.done)return;try{this.inner=r(b(y.value,this.counter++),!1)}catch(A){a(v,"throw",A)}}});h({target:"Iterator",proto:!0,real:!0,forced:g},{flatMap:function(b){s(this);try{e(b)}catch(y){a(this,"throw",y)}return p?t(p,this,b):new m(i(this),{mapper:b,inner:null})}})}),fl=S.cw(()=>{var h=rt(),t=At(),e=ls(),s=Nt(),i=bt(),r=ee(),n=jt(),a=Ae(),o=a("forEach",TypeError);h({target:"Iterator",proto:!0,real:!0,forced:o},{forEach:function(c){i(this);try{s(c)}catch(f){n(this,"throw",f)}if(o)return t(o,this,c);var d=r(this),u=0;e(d,function(f){c(f,u++)},{IS_RECORD:!0})}})}),pl=S.cw(()=>{var h=rt(),t=At(),e=Nt(),s=bt(),i=ee(),r=Ps(),n=Ln(),a=jt(),o=Is(),l=Ae(),c=zt(),d=!c&&!o("map",function(){}),u=!c&&!d&&l("map",TypeError),f=c||d||u,p=r(function(){var g=this.iterator,m=s(t(this.next,g)),v=this.done=!!m.done;if(!v)return n(g,this.mapper,[m.value,this.counter++],!0)});h({target:"Iterator",proto:!0,real:!0,forced:f},{map:function(m){s(this);try{e(m)}catch(v){a(this,"throw",v)}return u?t(u,this,m):new p(i(this),{mapper:m})}})}),gl=S.cw(()=>{var h=rt(),t=At(),e=ls(),s=Nt(),i=bt(),r=ee(),n=jt(),a=Ae(),o=a("some",TypeError);h({target:"Iterator",proto:!0,real:!0,forced:o},{some:function(c){i(this);try{s(c)}catch(f){n(this,"throw",f)}if(o)return t(o,this,c);var d=r(this),u=0;return e(d,function(f,p){if(c(f,u++))return p()},{IS_RECORD:!0,INTERRUPTED:!0}).stopped}})}),ml=S.cw(()=>{var h=rt(),t=At(),e=bt(),s=ee(),i=Yn(),r=ea(),n=Ps(),a=jt(),o=Is(),l=Ae(),c=zt(),d=RangeError,u=1/0,f=!c&&!o("take",1),p=!c&&!f&&l("take",RangeError),g=c||f||p||!(function(){try{Iterator.prototype.take.call({next:function(){return{done:!0}}},9007199254740992)}catch(v){return v instanceof d}})(),m=n(function(){var v=this.iterator;if(!this.remaining--)return this.done=!0,a(v,"normal",void 0);var b=e(t(this.next,v)),y=this.done=!!b.done;if(!y)return b.value});h({target:"Iterator",proto:!0,real:!0,forced:g},{take:function(b){e(this);var y;try{if(y=r(i(+b)),y>9007199254740991&&y!==u)throw new d("The argument should be a safe integer")}catch(w){a(this,"throw",w)}return p?t(p,this,y):new m(s(this),{remaining:y})}})}),vl=S.cw(()=>{var h=rt(),t=bt(),e=dr(),s=ls(),i=ee();h({target:"Iterator",proto:!0,real:!0},{toArray:function(){var n=[],a=0;return s(i(t(this)),function(o){e(n,a++,o)},{IS_RECORD:!0}),n}})}),yl=S.cw(()=>{var h=rt(),t=Lt(),e=gt(),s=ke(),i=pt(),r=At(),n=Ct(),a=Ut(),o=vr(),l=Bt(),c=vi(),d=cs(),u=dr(),f=wt(),p=Jn(),g=gi(),m=e.JSON,v=e.Number,b=e.SyntaxError,y=m&&m.parse,w=s("Object","keys"),A=Object.getOwnPropertyDescriptor,_=i("".charAt),E=i("".slice),x=i(/./.exec),T=i([].push),C=/^\d$/,P=/^[1-9]$/,k=/^[\d-]$/,R=/^[\t\n\r ]$/,B=0,U=1,M=function(F,I){F=c(F);var N=new Q(F,0),G=N.parse(),W=G.value,tt=N.skip(R,G.end);if(tt<F.length)throw new b('Unexpected extra character: "'+_(F,tt)+'" after the parsed data at: '+tt);return n(I)?O({"":W},"",I,G):W},O=function(F,I,N,G){var W=F[I],tt=G&&W===G.value,$=tt&&typeof G.source=="string"?{source:G.source}:{},J,ct,Mt,ht,Ot;if(a(W)){var us=o(W),Me=tt?G.nodes:us?[]:{};if(us)for(J=Me.length,Mt=d(W),ht=0;ht<Mt;ht++)V(W,ht,O(W,""+ht,N,ht<J?Me[ht]:void 0));else for(ct=w(W),Mt=d(ct),ht=0;ht<Mt;ht++)Ot=ct[ht],V(W,Ot,O(W,Ot,N,l(Me,Ot)?Me[Ot]:void 0))}return r(N,F,I,W,$)},V=function(F,I,N){if(t){var G=A(F,I);if(G&&!G.configurable)return}N===void 0?delete F[I]:u(F,I,N)},q=function(F,I,N,G){this.value=F,this.end=I,this.source=N,this.nodes=G},Q=function(F,I){this.source=F,this.index=I};Q.prototype={fork:function(F){return new Q(this.source,F)},parse:function(){var F=this.source,I=this.skip(R,this.index),N=this.fork(I),G=_(F,I);if(x(k,G))return N.number();switch(G){case"{":return N.object();case"[":return N.array();case'"':return N.string();case"t":return N.keyword(!0);case"f":return N.keyword(!1);case"n":return N.keyword(null)}throw new b('Unexpected character: "'+G+'" at: '+I)},node:function(F,I,N,G,W){return new q(I,G,F?null:E(this.source,N,G),W)},object:function(){for(var F=this.source,I=this.index+1,N=!1,G={},W={},tt=!1;I<F.length;){if(I=this.until(['"',"}"],I),_(F,I)==="}"&&!N){I++,tt=!0;break}var $=this.fork(I).string(),J=$.value;I=$.end,I=this.until([":"],I)+1,I=this.skip(R,I),$=this.fork(I).parse(),u(W,J,$),u(G,J,$.value),I=this.until([",","}"],$.end);var ct=_(F,I);if(ct===",")N=!0,I++;else if(ct==="}"){I++,tt=!0;break}}if(!tt)throw new b("Unterminated object at: "+I);return this.node(U,G,this.index,I,W)},array:function(){for(var F=this.source,I=this.index+1,N=!1,G=[],W=[],tt=!1;I<F.length;){if(I=this.skip(R,I),_(F,I)==="]"&&!N){I++,tt=!0;break}var $=this.fork(I).parse();if(T(W,$),T(G,$.value),I=this.until([",","]"],$.end),_(F,I)===",")N=!0,I++;else if(_(F,I)==="]"){I++,tt=!0;break}}if(!tt)throw new b("Unterminated array at: "+I);return this.node(U,G,this.index,I,W)},string:function(){var F=this.index,I=p(this.source,this.index+1);return this.node(B,I.value,F,I.end)},number:function(){var F=this.source,I=this.index,N=I;if(_(F,N)==="-"&&N++,_(F,N)==="0")N++;else if(x(P,_(F,N)))N=this.skip(C,N+1);else throw new b("Failed to parse number at: "+N);if(_(F,N)==="."){var G=N+1;if(N=this.skip(C,G),G===N)throw new b("Failed to parse number's fraction at: "+N)}if(_(F,N)==="e"||_(F,N)==="E"){N++,(_(F,N)==="+"||_(F,N)==="-")&&N++;var W=N;if(N=this.skip(C,N),W===N)throw new b("Failed to parse number's exponent value at: "+N)}return this.node(B,v(E(F,I,N)),I,N)},keyword:function(F){var I=""+F,N=this.index,G=N+I.length;if(E(this.source,N,G)!==I)throw new b("Failed to parse value at: "+N);return this.node(B,F,N,G)},skip:function(F,I){for(var N=this.source;I<N.length&&x(F,_(N,I));I++);return I},until:function(F,I){I=this.skip(R,I);for(var N=_(this.source,I),G=0;G<F.length;G++)if(F[G]===N)return I;throw new b('Unexpected character: "'+N+'" at: '+I)}};var Z=f(function(){var F="9007199254740993",I;return y(F,function(N,G,W){I=W.source}),I!==F}),K=g&&!f(function(){return 1/y("-0 ")!==-1/0});h({target:"JSON",stat:!0,forced:Z},{parse:function(I,N){return K&&!n(N)?y(I):M(I,N)}})}),bl=S.cw(()=>{var h=rt(),t=ke(),e=At(),s=pt(),i=wt(),r=vr(),n=Ct(),a=Ut(),o=fi(),l=Po(),c=yr(),d=Ve(),u=qo(),f=hr().includes,p=Bt(),g=vi(),m=Jn(),v=bi(),b=gi(),y=Mo(),w=String,A=TypeError,_=t("JSON","stringify"),E=t("BigInt"),x=s("".valueOf),T=s((!0).valueOf),C=E&&s(E.prototype.valueOf),P=s(/./.exec),k=s("".charAt),R=s("".charCodeAt),B=s("".replace),U=s("".slice),M=s([].push),O=s([].pop),V=s(1.1.toString),q=/[\uD800-\uDFFF]/g,Q=/^[\uD800-\uDBFF]$/,Z=/^[\uDC00-\uDFFF]$/,K=/^\d+$/,F=v(),I=v(),N=v(),G=F.length,W=I.length,tt=!b||i(function(){var it=t("Symbol")("stringify detection");return _([it])!=="[null]"||_({a:it})!=="{}"||_(Object(it))!=="{}"}),$=i(function(){return _("\uDF06\uD834")!=='"\\udf06\\ud834"'||_("\uDEAD")!=='"\\udead"'}),J=y?t("JSON","isRawJSON"):l,ct=tt?function(it,dt,vt){return _(it,function(Ft,Rt){var Pt=e(dt,this,Ft,Rt);if(!c(Pt))return Pt},vt)}:_,Mt=function(it,dt,vt){var Ft=k(vt,dt-1),Rt=k(vt,dt+1);return P(Q,it)&&!P(Z,Rt)||P(Z,it)&&!P(Q,Ft)?"\\u"+V(R(it,0),16):it},ht=function(it){if(r(it)){for(var dt=it.length,vt=[],Ft=o(null),Rt=0;Rt<dt;Rt++){var Pt=it[Rt],ie;if(typeof Pt=="string")ie=Pt;else if(typeof Pt=="number"||d(Pt)==="Number"||d(Pt)==="String")ie=g(Pt);else continue;p(Ft,ie)||(Ft[ie]=!0,M(vt,ie))}return vt}},Ot=function(it,dt){try{return it(dt),!0}catch{return!1}},us=function(it){var dt=d(it);return dt==="Number"&&Ot(u,it)||dt==="String"&&Ot(x,it)||dt==="Boolean"&&Ot(T,it)||!!C&&dt==="BigInt"&&Ot(C,it)},Me=function(it){if(!a(it)||n(it)||r(it))return!1;try{return!us(it)}catch{return!0}},Wa=function(it,dt){return{toJSON:function(){var vt=it[dt];if(a(vt)||typeof vt=="bigint"){var Ft=vt.toJSON;n(Ft)&&(vt=e(Ft,vt,dt))}return vt}}},za=function(it){for(var dt=0,vt=it.length;dt<vt;dt++)if(P(K,it[dt]))return I;return""},Va=function(it,dt,vt){for(var Ft=o(null),Rt=0,Pt=dt.length;Rt<Pt;Rt++){var ie=dt[Rt];Ft[vt+ie]=Wa(it,ie)}return Ft[N]=null,Ft};_&&h({target:"JSON",stat:!0,arity:3,forced:tt||$||!y},{stringify:function(dt,vt,Ft){var Rt=n(vt)?vt:void 0,Pt=Rt?void 0:ht(vt),ie=Pt&&za(Pt),Xr=[],Ni=[],Yr=[],Ds,Li=!1,Kr=!0,pe=ct(dt,function(gs,oe){if(gs=w(gs),Pt){if(gs===N){O(Ni),Ds=O(Yr);return}if(Kr)Kr=!1;else if(this!==Ds&&!r(this)&&!f(Pt,gs))return}else Rt&&(oe=e(Rt,this,gs,oe));if(J(oe))return y?oe:(Li=!0,F+(M(Xr,oe.rawJSON)-1));if(Pt&&Me(oe)){if(f(Ni,oe))throw new A("Converting circular structure to JSON");var Qr=Va(oe,Pt,ie);return M(Ni,oe),M(Yr,Ds),Ds=Qr,ie&&(Li=!0),Qr}return oe},Ft);if(typeof pe!="string"||($&&(pe=B(pe,q,Mt)),!Li))return pe;for(var fs="",Xa=pe.length,Qe=0;Qe<Xa;Qe++){var qr=k(pe,Qe);if(qr==='"'){var Jr=m(pe,++Qe).end-1,ps=U(pe,Qe,Jr);U(ps,0,G)===F?fs+=Xr[U(ps,G)]:U(ps,0,W)===I?fs+='"'+U(ps,W)+'"':fs+='"'+ps+'"',Qe=Jr}else fs+=qr}return fs}})}),wl=S.cw(()=>{var h=rt(),t=Nt(),e=Vn(),s=zt(),i=e.get,r=e.has,n=e.set;h({target:"Map",proto:!0,real:!0,forced:s},{getOrInsertComputed:function(o,l){var c=r(this,o);if(t(l),c)return i(this,o);o===0&&1/o===-1/0&&(o=0);var d=l(o);return n(this,o,d),d}})}),_l=S.cw(()=>{var h=rt(),t=Vn(),e=zt(),s=t.get,i=t.has,r=t.set;h({target:"Map",proto:!0,real:!0,forced:e},{getOrInsert:function(a,o){return i(this,a)?s(this,a):(r(this,a,o),o)}})}),Al=S.cw(()=>{var h=rt(),t=pt(),e=ls(),s=wt(),i=Hn(),r=wr(),n=se(),a=RangeError,o=TypeError,l=1/0,c=NaN,d=Math.sumPrecise,u=Math.abs,f=Math.pow,p=t([].push),g=n("iterator"),m=f(2,1023),v=f(2,53)-1,b=Number.MAX_VALUE,y=f(2,971),w={},A={},_={},E={},x={},T=s(function(){if(d([-1])!==-1||d([-b])!==-b)return!0;if(!r)return!1;try{return d(r([1],{})),!0}catch{}try{var P={};return P[g]=function(){return this},d(r(i([1]),P)),!0}catch{}}),C=function(P,k){var R=P+k,B=k-(R-P);return{hi:R,lo:B}};h({target:"Math",stat:!0,forced:T},{sumPrecise:function(k){var R=[],B=0,U=E;switch(e(k,function(J){if(++B>v)throw new a("Maximum allowed index exceeded");if(typeof J!="number")throw new o("Value is not a number");U!==w&&(J!==J?U=w:J===l?U=U===A?w:_:J===-l?U=U===_?w:A:(J!==0||1/J===l)&&(U===E||U===x)&&(U=x,p(R,J)))}),U){case w:return c;case A:return-l;case _:return l;case E:return-0}for(var M=[],O=0,V,q,Q,Z,K,F,I=0;I<R.length;I++){V=R[I];for(var N=0,G=0;G<M.length;G++){if(q=M[G],u(V)<u(q)&&(F=V,V=q,q=F),Q=C(V,q),Z=Q.hi,K=Q.lo,u(Z)===l){var W=Z===l?1:-1;O+=W,V=V-W*m-W*m,u(V)<u(q)&&(F=V,V=q,q=F),Q=C(V,q),Z=Q.hi,K=Q.lo}K!==0&&(M[N++]=K),V=Z}M.length=N,V!==0&&p(M,V)}var tt=M.length-1;if(Z=0,K=0,O!==0){var $=tt>=0?M[tt]:0;if(tt--,u(O)>1||O>0&&$>0||O<0&&$<0)return O>0?l:-l;if(Q=C(O*m,$/2),Z=Q.hi,K=Q.lo,K*=2,u(2*Z)===l)return Z>0?Z===m&&K===-(y/2)&&tt>=0&&M[tt]<0?b:l:Z===-m&&K===y/2&&tt>=0&&M[tt]>0?-b:-l;K!==0&&(M[++tt]=K,K=0),Z*=2}for(;tt>=0&&(Q=C(Z,M[tt--]),Z=Q.hi,K=Q.lo,K===0););return tt>=0&&(K<0&&M[tt]<0||K>0&&M[tt]>0)&&(q=K*2,V=Z+q,q===V-Z&&(Z=V)),Z}})}),Sl=S.cw(()=>{var h=rt(),t=gt(),e=go(),s=ro(),i=$o(),r=Xn(),n=Nt(),a=Ho(),o=wt(),l=t.Promise,c=!1,d=!l||!l.try||o(function(){var u=l.resolve();return l.try(function(f){return c=f===8,u},8)!==u})||!c;h({target:"Promise",stat:!0,forced:d},{try:function(u){var f=arguments.length>1?s(arguments,1):[],p=a(function(){return e(n(u),void 0,f)});if(!p.error)return i(this,p.value);var g=r.f(this),m=g.reject;return m(p.value),g.promise}})}),El=S.cw(()=>{var h=rt(),t=Go(),e=wt(),s=Ke(),i=!s("difference",function(n){return n.size===0}),r=i||e(function(){var n={size:1,has:function(){return!0},keys:function(){var o=0;return{next:function(){var l=o++>1;return a.has(1)&&a.clear(),{done:l,value:2}}}}},a=new Set([1,2,3,4]);return a.difference(n).size!==3});h({target:"Set",proto:!0,real:!0,forced:r},{difference:t})}),Tl=S.cw(()=>{var h=rt(),t=wt(),e=Wo(),s=Ke(),i=!s("intersection",function(r){return r.size===2&&r.has(1)&&r.has(2)})||t(function(){return String(Array.from(new Set([1,2,3]).intersection(new Set([3,2]))))!=="3,2"});h({target:"Set",proto:!0,real:!0,forced:i},{intersection:e})}),xl=S.cw(()=>{var h=rt(),t=zo(),e=Ke(),s=!e("isDisjointFrom",function(i){return!i});h({target:"Set",proto:!0,real:!0,forced:s},{isDisjointFrom:t})}),Cl=S.cw(()=>{var h=rt(),t=Vo(),e=Ke(),s=!e("isSubsetOf",function(i){return i});h({target:"Set",proto:!0,real:!0,forced:s},{isSubsetOf:t})}),Pl=S.cw(()=>{var h=rt(),t=Xo(),e=Ke(),s=!e("isSupersetOf",function(i){return!i});h({target:"Set",proto:!0,real:!0,forced:s},{isSupersetOf:t})}),Il=S.cw(()=>{var h=rt(),t=Yo(),e=Zn(),s=Ke(),i=!s("symmetricDifference")||!e("symmetricDifference");h({target:"Set",proto:!0,real:!0,forced:i},{symmetricDifference:t})}),kl=S.cw(()=>{var h=rt(),t=Ko(),e=Zn(),s=Ke(),i=!s("union")||!e("union");h({target:"Set",proto:!0,real:!0,forced:i},{union:t})}),Ol=S.cw(()=>{var h=eo(),t=To(),e=cs(),s=Er(),i=Qo(),r=h.aTypedArray,n=h.getTypedArrayConstructor,a=h.exportTypedArrayMethod,o=RangeError,l=(function(){try{new Int8Array(1).with(2,{valueOf:function(){throw 8}})}catch(d){return d===8}})(),c=l&&(function(){try{new Int8Array(1).with(-.5,1)}catch{return!0}})();a("with",function(d,u){var f=r(this),p=e(f),g=s(d),m=g<0?p+g:g,v=t(f)?i(u):+u;if(m>=p||m<0)throw new o("Incorrect index");for(var b=new(n(f))(p),y=0;y<p;y++)b[y]=y===m?v:f[y];return b},!l||c)}),Ml=S.cw(()=>{var h=rt(),t=gt(),e=so(),s=ra(),i=t.Uint8Array,r=!i||!i.fromBase64||!(function(){try{i.fromBase64("a");return}catch{}try{i.fromBase64("",null)}catch{return!0}})();i&&h({target:"Uint8Array",stat:!0,forced:r},{fromBase64:function(a){var o=s(a,arguments.length>1?arguments[1]:void 0,null,9007199254740991);return e(i,o.bytes)}})}),Fl=S.cw(()=>{var h=rt(),t=gt(),e=ra(),s=ri(),i=t.Uint8Array,r=!i||!i.prototype.setFromBase64||!(function(){var n=new i([255,255,255,255,255]);try{n.setFromBase64("",null);return}catch{}try{n.setFromBase64("a");return}catch{}try{n.setFromBase64("MjYyZg===")}catch{return n[0]===50&&n[1]===54&&n[2]===50&&n[3]===255&&n[4]===255}})();i&&h({target:"Uint8Array",proto:!0,forced:r},{setFromBase64:function(a){s(this);var o=e(a,arguments.length>1?arguments[1]:void 0,this,this.length);return{read:o.read,written:o.written}}})}),Rl=S.cw(()=>{var h=rt(),t=gt(),e=Mn(),s=ri(),i=ni(),r=el();function n(){try{var a=new ArrayBuffer(16,{maxByteLength:1024});new Uint8Array(a).setFromHex("cafed00d")}catch{return!0}}t.Uint8Array&&h({target:"Uint8Array",proto:!0,forced:n()},{setFromHex:function(o){s(this),e(o),i(this.buffer);var l=r(o,this).read;return{read:l,written:l/2}}})}),Dl=S.cw(()=>{var h=rt(),t=gt(),e=pt(),s=Rn(),i=ri(),r=ni(),n=Nn(),a=jn(),o=n.i2c,l=n.i2cUrl,c=Math.floor,d=Math.ceil,u=e("".charAt),f=t.Uint8Array,p=t.Array,g=e([].join),m=!f||!f.prototype.toBase64||!(function(){try{var v=new f;v.toBase64(null)}catch{return!0}})();f&&h({target:"Uint8Array",proto:!0,forced:m},{toBase64:function(){var b=i(this),y=arguments.length?s(arguments[0]):void 0,w=a(y)==="base64"?o:l,A=!!y&&!!y.omitPadding;r(this.buffer);for(var _=0,E=b.length,x=p(A?c(E/3)*4+(E%3?E%3+1:0):d(E/3)*4),T=0,C,P=function(k){return u(w,C>>6*k&63)};_+2<E;_+=3)C=(b[_]<<16)+(b[_+1]<<8)+b[_+2],x[T++]=P(3),x[T++]=P(2),x[T++]=P(1),x[T++]=P(0);return _+2===E?(C=(b[_]<<16)+(b[_+1]<<8),x[T++]=P(3),x[T++]=P(2),x[T++]=P(1),A||(x[T++]="=")):_+1===E&&(C=b[_]<<16,x[T++]=P(3),x[T++]=P(2),A||(x[T++]="=",x[T++]="=")),g(x,"")}})}),Nl=S.cw(()=>{var h=rt(),t=gt(),e=pt(),s=ri(),i=ni(),r=e(1.1.toString),n=e([].join),a=Array,o=t.Uint8Array,l=!o||!o.prototype.toHex||!(function(){try{var c=new o([255,255,255,255,255,255,255,255]);return c.toHex()==="ffffffffffffffff"}catch{return!1}})();o&&h({target:"Uint8Array",proto:!0,forced:l},{toHex:function(){s(this),i(this.buffer);for(var d=a(this.length),u=0,f=this.length;u<f;u++){var p=r(this[u],16);d[u]=p.length===1?"0"+p:p}return n(d,"")}})}),Ll=S.cw(()=>{var h=rt(),t=Nt(),e=Ja(),s=qa(),i=wi(),r=zt(),n=i.get,a=i.has,o=i.set,l=r||!(function(){try{WeakMap.prototype.getOrInsertComputed&&new WeakMap().getOrInsertComputed(1,function(){throw 1})}catch(c){return c instanceof TypeError}})();h({target:"WeakMap",proto:!0,real:!0,forced:l},{getOrInsertComputed:function(d,u){if(r||e(this),s(d),t(u),a(this,d))return n(this,d);var f=u(d);return o(this,d,f),f}})}),Bl=S.cw(()=>{var h=rt(),t=wi(),e=zt(),s=t.get,i=t.has,r=t.set;h({target:"WeakMap",proto:!0,real:!0,forced:e},{getOrInsert:function(a,o){return i(this,a)?s(this,a):(r(this,a,o),o)}})}),Ul=S.cw(()=>{var h=rt(),t=gt(),e=ke(),s=li(),i=Oe().f,r=Bt(),n=Fn(),a=Ao(),o=Fo(),l=ho(),c=po(),d=Lt(),u=zt(),f="DOMException",p=e("Error"),g=e(f),m=function(){n(this,v);var R=arguments.length,B=o(R<1?void 0:arguments[0]),U=o(R<2?void 0:arguments[1],"Error"),M=new g(B,U),O=new p(B);return O.name=f,i(M,"stack",s(1,c(O.stack,1))),a(M,this,m),M},v=m.prototype=g.prototype,b="stack"in new p(f),y="stack"in new g(1,2),w=g&&d&&Object.getOwnPropertyDescriptor(t,f),A=!!w&&!(w.writable&&w.configurable),_=b&&!A&&!y;h({global:!0,constructor:!0,forced:u||_},{DOMException:_?m:g});var E=e(f),x=E.prototype;if(x.constructor!==E){u||i(x,"constructor",s(1,E));for(var T in l)if(r(l,T)){var C=l[T],P=C.s;r(E,P)||i(E,P,s(6,C.c))}}}),jl=S.cw(()=>{var h=rt(),t=ke(),e=il(),s=vi(),i=sl(),r=t("URL");h({target:"URL",stat:!0,forced:!i},{parse:function(a){var o=e(arguments.length,1),l=s(a),c=o<2||arguments[1]===void 0?void 0:s(arguments[1]);try{return new r(l,c)}catch{return null}}})});nl();al();ol();hl();_l();wl();El();Tl();xl();Cl();Pl();Il();kl();Ol();Fl();Rl();Dl();Nl();jl();const Yt=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),ue=[1/0,1/0,-1/0,-1/0],Le=new Float32Array(ue),Xi=[.001,0,0,.001,0,0],Dt="http://www.w3.org/2000/svg",Vt={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Ee={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},is="pdfjs_internal_id_",as="pdfjs_internal_editor_",Y={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},st={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},Hl={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Et={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Vs={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},yt={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,RICHMEDIA:27},es={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},_i={ERRORS:0,WARNINGS:1,INFOS:5},ye={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},ms={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},$l={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Ai=_i.WARNINGS;function Gl(h){Number.isInteger(h)&&(Ai=h)}function oa(){return Ai}function Si(h){Ai>=_i.INFOS&&console.info(`Info: ${h}`)}function z(h){Ai>=_i.WARNINGS&&console.warn(`Warning: ${h}`)}function nt(h){throw new Error(h)}function _t(h,t){h||nt(t)}function Wl(h){switch(h?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function la(h,t=null,e=null){if(!h)return null;if(e&&typeof h=="string"&&(e.addDefaultProtocol&&h.startsWith("www.")&&h.match(/\./g)?.length>=2&&(h=`http://${h}`),e.tryConvertEncoding))try{h=Xl(h)}catch{}const s=t?URL.parse(h,t):URL.parse(h);return Wl(s)?s:null}function ca(h,t,e=!1){const s=URL.parse(h);return s?(s.hash=t,s.href):e&&la(h,"http://example.com")?h.split("#",1)[0]+`${t?`#${t}`:""}`:""}function Yi(h){return h.substring(h.lastIndexOf("/")+1)}function L(h,t,e,s=!1){return Object.defineProperty(h,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const qe=(function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t})();class Ki extends qe{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Ns extends qe{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class qi extends qe{constructor(t){super(t,"InvalidPDFException")}}class Qs extends qe{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class zl extends qe{constructor(t){super(t,"FormatError")}}class Pe extends qe{constructor(t){super(t,"AbortException")}}function Vl(h){(typeof h!="object"||h?.length===void 0)&&nt("Invalid argument for bytesToString");const t=h.length,e=8192;if(t<e)return String.fromCharCode.apply(null,h);const s=[];for(let i=0;i<t;i+=e){const r=Math.min(i+e,t),n=h.subarray(i,r);s.push(String.fromCharCode.apply(null,n))}return s.join("")}function Ei(h){typeof h!="string"&&nt("Invalid argument for stringToBytes");const t=h.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=h.charCodeAt(s)&255;return e}class ot{static get isLittleEndian(){const t=new Uint8Array(4);t[0]=1;const e=new Uint32Array(t.buffer,0,1);return L(this,"isLittleEndian",e[0]===1)}static get isOffscreenCanvasSupported(){return L(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return L(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isVideoFrameSupported(){return L(this,"isVideoFrameSupported",typeof VideoFrame<"u")}static get isFloat16ArraySupported(){return L(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return L(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return L(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCanvasFilterSupported(){let t;return this.isOffscreenCanvasSupported?t=new OffscreenCanvas(1,1).getContext("2d"):typeof document<"u"&&(t=document.createElement("canvas").getContext("2d")),L(this,"isCanvasFilterSupported",t?.filter!==void 0)}static get isAlphaColorInputSupported(){if(typeof document>"u")return L(this,"isAlphaColorInputSupported",!1);const t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",L(this,"isAlphaColorInputSupported",t.value!=="#ff0000")}static get isBackdropFilterSupported(){return L(this,"isBackdropFilterSupported",typeof CSS<"u"&&CSS.supports("backdrop-filter","blur(1px)"))}}class D{static get hexNums(){return L(this,"hexNums",Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0")))}static makeHexColor(t,e,s){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[s]}`}static get identity0to256Map(){return L(this,"identity0to256Map",Uint8Array.from({length:256},(t,e)=>e))}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,s=0){const i=t[s],r=t[s+1];t[s]=i*e[0]+r*e[2]+e[4],t[s+1]=i*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5];for(let c=0;c<6;c+=2){const d=t[s+c],u=t[s+c+1];t[s+c]=d*i+u*n+o,t[s+c+1]=d*r+u*a+l}}static applyInverseTransform(t,e){const s=t[0],i=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,s){const i=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5],c=t[0],d=t[1],u=t[2],f=t[3];let p=i*c+o,g=p,m=i*u+o,v=m,b=a*d+l,y=b,w=a*f+l,A=w;if(r!==0||n!==0){const _=r*c,E=r*u,x=n*d,T=n*f;p+=x,v+=x,m+=T,g+=T,b+=_,A+=_,w+=E,y+=E}s[0]=Math.min(s[0],p,m,Math.min(g,v)),s[1]=Math.min(s[1],b,w,Math.min(y,A)),s[2]=Math.max(s[2],p,m,Math.max(g,v)),s[3]=Math.max(s[3],b,w,Math.max(y,A))}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const s=t[0],i=t[1],r=t[2],n=t[3],a=s**2+i**2,o=s*r+i*n,l=r**2+n**2,c=(a+l)/2,d=Math.sqrt(c**2-(a*l-o**2));e[0]=Math.sqrt(c+d||1),e[1]=Math.sqrt(c-d||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),n=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>n?null:[s,r,i,n]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,r){r[0]=Math.min(r[0],t,s),r[1]=Math.min(r[1],e,i),r[2]=Math.max(r[2],t,s),r[3]=Math.max(r[3],e,i)}static#t(t,e,s,i,r,n,a,o,l,c){if(l<=0||l>=1)return;const d=1-l,u=l*l,f=u*l,p=d*(d*(d*t+3*l*e)+3*u*s)+f*i,g=d*(d*(d*r+3*l*n)+3*u*a)+f*o;c[0]=Math.min(c[0],p),c[1]=Math.min(c[1],g),c[2]=Math.max(c[2],p),c[3]=Math.max(c[3],g)}static#e(t,e,s,i,r,n,a,o,l,c,d,u){if(Math.abs(l)<1e-12){Math.abs(c)>=1e-12&&this.#t(t,e,s,i,r,n,a,o,-d/c,u);return}const f=c**2-4*d*l;if(f<0)return;const p=Math.sqrt(f),g=2*l;this.#t(t,e,s,i,r,n,a,o,(-c+p)/g,u),this.#t(t,e,s,i,r,n,a,o,(-c-p)/g,u)}static bezierBoundingBox(t,e,s,i,r,n,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,s,r,a,e,i,n,o,3*(-t+3*(s-r)+a),6*(t-2*s+r),3*(s-t),l),this.#e(t,s,r,a,e,i,n,o,3*(-e+3*(i-n)+o),6*(e-2*i+n),3*(i-e),l)}}function Xl(h){return decodeURIComponent(escape(h))}let Ui=null,sn=null;function Yl(h){return Ui||(Ui=/([\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,sn=new Map([["ſt","ſt"]])),h.replaceAll(Ui,(t,e,s)=>e?e.normalize("NFKC"):sn.get(s))}function ha(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const h=new Uint8Array(32);return crypto.getRandomValues(h),Vl(h)}function Kl(h,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...r]=e;if(!h(s)&&!Number.isInteger(s)||!t(i))return!1;const n=r.length;let a=!0;switch(i.name){case"XYZ":if(n<2||n>3)return!1;break;case"Fit":case"FitB":return n===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(n>1)return!1;break;case"FitR":if(n!==4)return!1;a=!1;break;default:return!1}for(const o of r)if(!(typeof o=="number"||a&&o===null))return!1;return!0}const hs=()=>[],Zs=()=>new Map,Ji=()=>Object.create(null),ql=()=>new Set;typeof Blob.prototype.bytes!="function"&&(Blob.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())});typeof Response.prototype.bytes!="function"&&(Response.prototype.bytes=async function(){return new Uint8Array(await this.arrayBuffer())});typeof Iterator.prototype.join!="function"&&(Iterator.prototype.join=function(h){return[...this].join(h)});pl();function ft(h,t,e){return Math.min(Math.max(h,t),e)}class os{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}class xr extends qe{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function ds(h){if(h.startsWith("#")){const e=h.slice(1);return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16),e.length>=8?parseInt(e.slice(6,8),16)/255:1]}if(h.startsWith("rgb(")){const[e,s,i]=h.slice(4,-1).split(",").map(r=>parseInt(r,10));return[e,s,i,1]}if(h.startsWith("rgba(")){const e=h.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}const t=h.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(parseFloat(t[1])*255),Math.round(parseFloat(t[2])*255),Math.round(parseFloat(t[3])*255),t[4]!==void 0&&t[4]!=="none"?parseFloat(t[4]):1]:null}function Ms(h){const t=ds(h);return t?t.slice(0,3):(z(`Not a valid color format: "${h}"`),[0,0,0])}function ut(h){const{a:t,b:e,c:s,d:i,e:r,f:n}=h.getTransform();return[t,e,s,i,r,n]}function me(h){const{a:t,b:e,c:s,d:i,e:r,f:n}=h.getTransform().invertSelf();return[t,e,s,i,r,n]}class Jt{constructor(){const{pixelRatio:t}=Jt;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,r=-1){let n=1/0,a=1/0,o=1/0;s=Jt.capPixels(s,r),s>0&&(n=Math.sqrt(s/(t*e))),i!==-1&&(a=i/t,o=i/e);const l=Math.min(n,a,o);return this.sx>l||this.sy>l?(this.sx=l,this.sy=l,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}function Jl(h,t){t=ft(t??1,0,1);const e=255*(1-t);return h.map(s=>Math.round(s*t+e))}function rn(h,t){const e=h[0]/255,s=h[1]/255,i=h[2]/255,r=Math.max(e,s,i),n=Math.min(e,s,i),a=(r+n)/2;if(r===n)t[0]=t[1]=0;else{const o=r-n;switch(t[1]=a<.5?o/(r+n):o/(2-r-n),r){case e:t[0]=((s-i)/o+(s<i?6:0))*60;break;case s:t[0]=((i-e)/o+2)*60;break;case i:t[0]=((e-s)/o+4)*60;break}}t[2]=a}function Qi(h,t){const e=h[0],s=h[1],i=h[2],r=(1-Math.abs(2*i-1))*s,n=r*(1-Math.abs(e/60%2-1)),a=i-r/2;switch(Math.floor(e/60)){case 0:t[0]=r+a,t[1]=n+a,t[2]=a;break;case 1:t[0]=n+a,t[1]=r+a,t[2]=a;break;case 2:t[0]=a,t[1]=r+a,t[2]=n+a;break;case 3:t[0]=a,t[1]=n+a,t[2]=r+a;break;case 4:t[0]=n+a,t[1]=a,t[2]=r+a;break;case 5:case 6:t[0]=r+a,t[1]=a,t[2]=n+a;break}}function Zi(h){return h<=.03928?h/12.92:((h+.055)/1.055)**2.4}function nn(h,t,e){Qi(h,e),e.map(Zi);const s=.2126*e[0]+.7152*e[1]+.0722*e[2];Qi(t,e),e.map(Zi);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];return s>i?(s+.05)/(i+.05):(i+.05)/(s+.05)}const an=new Map;function Ql(h,t){const e=h[0]+h[1]*256+h[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let s=an.get(e);if(s)return s;const i=new Float32Array(9),r=i.subarray(0,3),n=i.subarray(3,6);rn(h,n);const a=i.subarray(6,9);rn(t,a);const o=a[2]<.5,l=o?12:4.5;if(n[2]=o?Math.sqrt(n[2]):1-Math.sqrt(1-n[2]),nn(n,a,r)<l){let c,d;o?(c=n[2],d=1):(c=0,d=n[2]);const u=.005;for(;d-c>u;){const f=n[2]=(c+d)/2;o===nn(n,a,r)<l?c=f:d=f}n[2]=o?d:c}return Qi(n,r),s=D.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),an.set(e,s),s}function da(h){const t=new Path2D;if(!h)return t;for(let e=0,s=h.length;e<s;)switch(h[e++]){case ms.moveTo:t.moveTo(h[e++],h[e++]);break;case ms.lineTo:t.lineTo(h[e++],h[e++]);break;case ms.curveTo:t.bezierCurveTo(h[e++],h[e++],h[e++],h[e++],h[e++],h[e++]);break;case ms.quadraticCurveTo:t.quadraticCurveTo(h[e++],h[e++],h[e++],h[e++]);break;case ms.closePath:t.closePath();break;default:z(`Unrecognized drawing path operator: ${h[e-1]}`);break}return t}ml();Bl();Ll();gl();bl();Ul();ll();cl();dl();yl();class Fs{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:r=0,offsetY:n=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=r,this.offsetY=n,s*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let c,d,u,f;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,d=0,u=0,f=1;break;case 90:c=0,d=1,u=1,f=0;break;case 270:c=0,d=-1,u=-1,f=0;break;case 0:c=1,d=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f);let p,g,m,v;c===0?(p=Math.abs(l-t[1])*s+r,g=Math.abs(o-t[0])*s+n,m=(t[3]-t[1])*s,v=(t[2]-t[0])*s):(p=Math.abs(o-t[0])*s+r,g=Math.abs(l-t[1])*s+n,m=(t[2]-t[0])*s,v=(t[3]-t[1])*s),this.transform=[c*s,d*s,u*s,f*s,p-c*s*o-u*s*l,g-d*s*o-f*s*l],this.width=m,this.height=v}get rawDims(){const t=this.viewBox;return L(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new Fs({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}convertToViewportPoint(t,e){const s=[t,e];return D.applyTransform(s,this.transform),s}convertToPdfPoint(t,e){const s=[t,e];return D.applyInverseTransform(s,this.transform),s}}class Ss{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(r){if(!r)return;let n=null;const a=r.name;if(a==="#text")n=r.value;else if(Ss.shouldBuildText(a))r?.attributes?.textContent?n=r.attributes.textContent:r.value&&(n=r.value);else return;if(n!==null&&e.push({str:n}),!!r.children)for(const o of r.children)i(o)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const Zl=/url\(|image-set\(/i,tc=/^on/i;class ua{static get _allowedHtmlElements(){return L(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return L(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return L(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return L(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return L(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(t,e,s,i,r){const n=i.getValue(e,{value:null});switch(s.name){case"textarea":if(n.value!==null&&(t.textContent=n.value),r==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(n.value===s.attributes.xfaOn?t.setAttribute("checked",!0):n.value===s.attributes.xfaOff&&t.removeAttribute("checked"),r==="print")break;t.addEventListener("change",a=>{i.setValue(e,{value:a.target.checked?a.target.getAttribute("xfaOn"):a.target.getAttribute("xfaOff")})})}else{if(n.value!==null&&t.setAttribute("value",n.value),r==="print")break;t.addEventListener("input",a=>{i.setValue(e,{value:a.target.value})})}break;case"select":if(n.value!==null){t.setAttribute("value",n.value);for(const a of s.children)a.attributes.value===n.value?a.attributes.selected=!0:Object.hasOwn(a.attributes,"selected")&&delete a.attributes.selected}t.addEventListener("input",a=>{const o=a.target.options,l=o.selectedIndex===-1?"":o[o.selectedIndex].value;i.setValue(e,{value:l})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:r}){const{attributes:n}=e,a=t instanceof HTMLAnchorElement;n.type==="radio"&&(n.name=`${n.name}-${i}`);for(const[o,l]of Object.entries(n))if(!(l==null||tc.test(o))&&!(i==="richText"&&!this._allowedRichTextAttributes.has(o)))switch(o){case"class":l.length&&t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":if(i==="richText"){const c=this._allowedRichTextStyles;for(const[d,u]of Object.entries(l))c.has(d)&&!Zl.test(u)&&(t.style[d]=u)}else Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!a||o!=="href"&&o!=="newWindow")&&t.setAttribute(o,l)}a&&r?.addLinkAttributes(t,n.href,n.newWindow),s&&n.dataId&&this.setupStorage(t,n.dataId,e,s)}static#t(t,e,s){return s==="richText"?!e&&this._allowedRichTextElements.has(t)?document.createElement(t):null:e?e===Dt&&this._allowedSvgElements.has(t)?document.createElementNS(Dt,t):null:this._allowedHtmlElements.has(t)?document.createElement(t):null}static render(t){const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",n=this.#t(i.name,i.attributes?.xmlns,r)??document.createElement("div");i.attributes&&this.setAttributes({html:n,element:i,intent:r,linkService:s});const a=r!=="richText",o=t.div;if(o.append(n),t.viewport){const d=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=d}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(i.children.length===0){if(i.value){const d=document.createTextNode(i.value);n.append(d),a&&Ss.shouldBuildText(i.name)&&l.push(d)}return{textDivs:l}}const c=[[i,-1,n]];for(;c.length>0;){const[d,u,f]=c.at(-1);if(u+1===d.children.length){c.pop();continue}const p=d.children[++c.at(-1)[1]];if(p===null)continue;const{name:g}=p;if(g==="#text"){const v=document.createTextNode(p.value);l.push(v),f.append(v);continue}const m=this.#t(g,p.attributes?.xmlns,r);if(m){if(f.append(m),p.attributes&&this.setAttributes({html:m,element:p,storage:e,intent:r,linkService:s}),p.children?.length>0)c.push([p,-1,m]);else if(p.value){const v=document.createTextNode(p.value);a&&Ss.shouldBuildText(g)&&l.push(v),m.append(v)}}}for(const d of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))d.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:s=0}){const{width:i,height:r}=t.attributes.style;return new Fs({viewBox:[0,0,parseInt(i,10),parseInt(r,10)],userUnit:1,scale:e,rotation:s})}}async function Cr(h,t="text"){if(bs(h,document.baseURI)){const e=await fetch(h);if(!e.ok)throw new Error(e.statusText);switch(t){case"blob":return e.blob();case"bytes":return e.bytes();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",h,!0),i.responseType=t==="bytes"?"arraybuffer":t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"bytes":e(new Uint8Array(i.response));return;case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}function Ti(h){const t=h.length;let e=0;for(;e<t&&h[e].trim()==="";)e++;return h.substring(e,e+5).toLowerCase()==="data:"}function Pr(h){return typeof h=="string"&&/\.pdf$/i.test(h)}function ec(h){return[h]=h.split(/[#?]/,1),Yi(h)}function sc(h,t="document.pdf"){if(typeof h!="string")return t;if(Ti(h))return z('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(a=>{try{return new URL(a)}catch{}try{return new URL(decodeURIComponent(a))}catch{}try{return new URL(a,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(a),"https://foo.bar")}catch{}return null})(h);if(!s)return t;const i=a=>{try{let o=decodeURIComponent(a);return o.includes("/")&&(o=Yi(o),o.length===4&&r.test(o))?a:o}catch{return a}},r=/\.pdf$/i,n=Yi(s.pathname);if(r.test(n))return i(n);if(s.searchParams.size>0){const a=l=>[...l].findLast(c=>r.test(c)),o=a(s.searchParams.values())??a(s.searchParams.keys());if(o)return i(o)}if(s.hash){const{hash:a}=s;let o=-1;for(const{index:l}of a.matchAll(/\.pdf\b/gi))o=l;if(o>0){let l=o;for(;l>0&&!"/?#=".includes(a[l-1]);)l--;if(l<o)return i(a.slice(l,o+4))}}return t}function bs(h,t){const e=t?URL.parse(h,t):URL.parse(h);return/https?:/.test(e?.protocol??"")}function ae(h){h.preventDefault()}function xt(h){h.preventDefault(),h.stopPropagation()}class tr{static#t;static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;this.#t||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#t.exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let n=parseInt(e[4],10);n=n>=0&&n<=23?n: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;const l=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,l==="-"?(n+=c,a+=d):l==="+"&&(n-=c,a-=d),new Date(Date.UTC(s,i,r,n,a,o))}}function ic(h){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of h.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;h.set(e,Ms(s))}t.remove()}function Ge(h,t,e=!1,s=!0){if(t instanceof Fs){const{pageWidth:i,pageHeight:r}=t.rawDims,{style:n}=h,a=`round(down, var(--total-scale-factor) * ${i}px, var(--scale-round-x))`,o=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-y))`;!e||t.rotation%180===0?(n.width=a,n.height=o):(n.width=o,n.height=a)}s&&h.setAttribute("data-main-rotation",t.rotation)}const er=new Set(["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"]);class rc{static get isDarkMode(){return L(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class nc{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:s}=window.getComputedStyle(t);return t.remove(),L(this,"commentForegroundColor",Ms(s))}}function fa({html:h,dir:t,className:e},s){const i=document.createDocumentFragment();if(typeof h=="string"){const r=document.createElement("p");r.dir=t||"auto";const n=h.split(/\r\n?|\n/);for(let a=0,o=n.length;a<o;++a){const l=n[a];r.append(document.createTextNode(l)),a<o-1&&r.append(document.createElement("br"))}i.append(r)}else ua.render({xfaHtml:h,div:i,intent:"richText"});i.firstElementChild.classList.add("richText",e),s.append(i)}class ws{#t=null;#e=null;#s;#i=null;#r=null;#n=null;#a=null;#o=null;static#l=null;constructor(t){this.#s=t,ws.#l||=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(){const t=this.#t=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#s._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",ae,{signal:e}),t.addEventListener("pointerdown",ws.#c,{signal:e}));const s=this.#i=document.createElement("div");s.className="buttons",t.append(s);const i=this.#s.toolbarPosition;if(i){const{style:r}=t,n=this.#s._uiManager.direction==="ltr"?1-i[0]:i[0];r.insetInlineEnd=`${100*n}%`,r.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#t}static#c(t){t.stopPropagation()}#u(t){this.#s._focusEventsAllowed=!1,xt(t)}#h(t){this.#s._focusEventsAllowed=!0,xt(t)}#f(t){const e=this.#s._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#h.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",ae,{signal:e}),!0)}hide(){this.#t.classList.add("hidden"),this.#e?.hideDropdown()}show(){this.#t.classList.remove("hidden"),this.#r?.shown(),this.#n?.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=this.#s,s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",ws.#l[t]),this.#f(s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),this.#i.append(s)}get#p(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#f(e),this.#i.append(e,this.#p),this.#r=t}addComment(t,e=null){if(this.#n)return;const s=t.renderForToolbar();if(!s)return;this.#f(s);const i=this.#a=this.#p;e?(this.#i.insertBefore(s,e),this.#i.insertBefore(i,e)):this.#i.append(s,i),this.#n=t,t.toolbar=this}addColorPicker(t){if(this.#e)return;this.#e=t;const e=t.renderButton();this.#f(e),this.#i.append(e,this.#p)}async addEditSignatureButton(t){const e=this.#o=await t.renderEditButton(this.#s);e&&(this.#f(e),this.#i.append(e,this.#p))}removeButton(t){t==="comment"&&(this.#n?.removeToolbarCommentButton(),this.#n=null,this.#a?.remove(),this.#a=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);break}}async addButtonBefore(t,e,s){if(!e&&t==="comment")return;const i=this.#i.querySelector(s);i&&t==="comment"&&this.addComment(e,i)}updateEditSignatureButton(t){this.#o&&(this.#o.title=t)}remove(){this.#t.remove(),this.#e?.destroy(),this.#e=null}}class ac{#t=null;#e=null;#s;constructor(t){this.#s=t}#i(){const t=this.#e=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.dir=this.#s.direction;const e=this.#s._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",ae,{signal:e});const s=this.#t=document.createElement("div");return s.className="buttons",t.append(s),this.#s.hasCommentManager()&&this.#n("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#s.commentSelection("floating_button")}),this.#n("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#s.highlightSelection("floating_button")}),t}#r(t,e){let s=0,i=0;for(const r of t){const n=r.y+r.height;if(n<s)continue;const a=r.x+(e?r.width:0);if(n>s){i=a,s=n;continue}e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]}show(t,e,s){const[i,r]=this.#r(e,s),{style:n}=this.#e||=this.#i();t.append(this.#e),n.insetInlineEnd=`${100*i}%`,n.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){this.#e.remove()}#n(t,e,s,i){const r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);const n=document.createElement("span");r.append(n),n.className="visuallyHidden",n.setAttribute("data-l10n-id",s);const a=this.#s._signal;a instanceof AbortSignal&&!a.aborted&&(r.addEventListener("contextmenu",ae,{signal:a}),r.addEventListener("click",i,{signal:a})),this.#t.append(r)}}const oc="0a475cb6-573c-46ed-869d-fa7c5839d995",ji=Object.freeze({internal:oc});function pa(h,t,e){for(const s of e)t.addEventListener(s,h[s].bind(h))}class at{static#t=NaN;static#e=null;static#s=NaN;static#i=null;static initializeAndAddPointerId(t){(at.#e||=new Set).add(t)}static setPointer(t,e){at.#t||=e,at.#i??=t}static setTimeStamp(t){at.#s=t}static isSamePointerId(t){return at.#t===t}static isSamePointerIdOrRemove(t){return at.#t===t?!0:(at.#e?.delete(t),!1)}static isSamePointerType(t){return at.#i===t}static isInitializedAndDifferentPointerType(t){return at.#i!==null&&!at.isSamePointerType(t)}static isSameTimeStamp(t){return at.#s===t}static isUsingMultiplePointers(){return at.#e?.size>=1}static clearPointerType(){at.#i=null}static clearPointerIds(){at.#t=NaN,at.#e=null}static clearTimeStamp(){at.#s=NaN}}class lc{#t=0;get id(){return`${as}${this.#t++}`}}class Ir{#t=ha();#e=0;#s=null;static get _isSVGFittingCanvas(){const t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${Dt}"><rect width="1" height="1" style="fill:red;"/></svg>`,s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const r=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return L(this,"_isSVGFittingCanvas",r)}async#i(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s===null)return null;if(s?.bitmap)return s.refCounter+=1,s;try{s||={bitmap:null,id:`image_${this.#t}_${this.#e++}`,refCounter:0,isSvg:!1};let i;if(typeof e=="string"?(s.url=e,i=await Cr(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const r=Ir._isSVGFittingCanvas,n=new FileReader,a=new Image,o=new Promise((l,c)=>{a.onload=()=>{s.bitmap=a,s.isSvg=!0,l()},n.onload=async()=>{const d=s.svgUrl=n.result;a.src=await r?`${d}#svgView(preserveAspectRatio(none))`:d},a.onerror=n.onerror=c});n.readAsDataURL(i),await o}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){z(i),s=null}return this.#s.set(t,s),s&&this.#s.set(s.id,s),s}async getFromFile(t){const{lastModified:e,name:s,size:i,type:r}=t;return this.#i(`${e}_${s}_${i}_${r}`,t)}async getFromUrl(t){return this.#i(t,t)}async getFromBlob(t,e){const s=await e;return this.#i(t,s)}async getFromId(t){this.#s||=new Map;const e=this.#s.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){const{blobPromise:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#s||=new Map;let s=this.#s.get(t);if(s?.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${this.#t}_${this.#e++}`,refCounter:1,isSvg:!1},this.#s.set(t,s),this.#s.set(s.id,s),s}getSvgUrl(t){const e=this.#s.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#s||=new Map;const e=this.#s.get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const i=new OffscreenCanvas(s.width,s.height);i.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=i.convertToBlob()}s.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#t}_`)}}class cc{#t=[];#e=!1;#s;#i=-1;constructor(t=128){this.#s=t}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:n=!1,keepUndo:a=!1}){if(i&&t(),this.#e)return;const o={cmd:t,undo:e,post:s,type:r};if(this.#i===-1){this.#t.length>0&&(this.#t.length=0),this.#i=0,this.#t.push(o);return}if(n&&this.#t[this.#i].type===r){a&&(o.undo=this.#t[this.#i].undo),this.#t[this.#i]=o;return}const l=this.#i+1;l===this.#s?this.#t.splice(0,1):(this.#i=l,l<this.#t.length&&this.#t.splice(l)),this.#t.push(o)}undo(){if(this.#i===-1)return;this.#e=!0;const{undo:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1,this.#i-=1}redo(){if(this.#i<this.#t.length-1){this.#i+=1,this.#e=!0;const{cmd:t,post:e}=this.#t[this.#i];t(),e?.(),this.#e=!1}}hasSomethingToUndo(){return this.#i!==-1}hasSomethingToRedo(){return this.#i<this.#t.length-1}cleanType(t){if(this.#i!==-1){for(let e=this.#i;e>=0;e--)if(this.#t[e].type!==t){this.#t.splice(e+1,this.#i-e),this.#i=e;return}this.#t.length=0,this.#i=-1}}destroy(){this.#t=null}}class Kt{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;const{isMac:e}=ot.platform;for(const[s,i,r={}]of t){const n=s.some(a=>a.startsWith("mac+"));for(const a of s){let o=a;if(n){const d=a.startsWith("mac+");if(e!==d)continue;d&&(o=a.slice(4))}const[l,c]=Kt.#t(o);l!==null&&this.callbacks.getOrInsertComputed(l,hs).push({callback:i,options:r,modifiers:c})}}}static#t(t){let e=null,s=0;for(let i of t.split("+")){if(i=i.trim(),!i)continue;const r=i.toUpperCase(),n=Kt[r];if(n){s|=n;continue}if(e!==null){z(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e=r==="SPACE"?" ":i}return e===null&&z(`KeyboardManager: no key found in shortcut "${t}"`),[e,s]}static#e(t){const e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return e?e[1]?.toLowerCase()??e[2]:null}exec(t,e){let s=this.callbacks.get(e.key);if(!s){if(/^[a-z]$/i.test(e.key))return;const c=Kt.#e(e.code);if(c===null||c===e.key||(s=this.callbacks.get(c),!s))return}const i=(e.altKey?Kt.ALT:0)|(e.ctrlKey?Kt.CTRL:0)|(e.metaKey?Kt.META:0)|(e.shiftKey?Kt.SHIFT:0),r=s.find(c=>c.modifiers===i);if(!r)return;const{callback:n,options:{bubbles:a=!1,args:o=[],checker:l=null}}=r;l&&!l(t,e)||(n.bind(t,...o,e)(),a||xt(e))}}class kr{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return ic(t),L(this,"_colors",t)}convert(t){const e=Ms(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((r,n)=>r===e[n]))return kr._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?D.makeHexColor(...e):t}}class Ie{#t=new AbortController;#e=null;#s=null;#i=new Map;#r=new Map;#n=null;#a=null;#o=null;#l=null;#c=null;#u=new cc;#h=null;#f=null;#p=null;#m=0;#d=new Set;#g=null;#v=null;#y=new Set;_editorUndoBar=null;#b=!1;#w=!1;#A=!1;#S=null;#_=null;#E=null;#O=null;#P=!1;#C=null;#R=new lc;#I=!1;#M=!1;#D=!1;#F=null;#B=null;#z=null;#U=null;#$=null;#x=Y.NONE;#T=new Set;#j=null;#G=null;#V=null;#q=null;#Y=null;#K={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#N=[0,0];#L=null;#X=null;#tt=null;#et=null;#H=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=Ie.prototype,e=n=>n.#X.contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&n.hasSomethingToControl(),s=(n,{target:a})=>{if(a instanceof HTMLInputElement){const{type:o}=a;return o!=="text"&&o!=="number"}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return L(this,"_keyboardManager",new Kt([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:s}],[["Enter"],t.addNewEditorFromKeyboard,{checker:(n,{target:a})=>!(a instanceof HTMLButtonElement)&&n.#X.contains(a)&&!n.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(n,{target:a})=>!(a instanceof HTMLButtonElement)&&n.#X.contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}constructor(t,e,s,i,r,n,a,o,l,c,d,u,f,p,g,m,v){const b=this._signal=this.#t.signal;this.#X=t,this.#tt=e,this.#et=s,this.#o=i,this.#h=r,this.#G=n,this.#Y=o,this._eventBus=a;const y={signal:b,...ji};a.on("editingaction",this.onEditingAction.bind(this),y),a.on("pagechanging",this.onPageChanging.bind(this),y),a.on("scalechanging",this.onScaleChanging.bind(this),y),a.on("rotationchanging",this.onRotationChanging.bind(this),y),a.on("setpreference",this.onSetPreference.bind(this),y),a.on("switchannotationeditorparams",w=>this.updateParams(w.type,w.value),y),window.addEventListener("pointerdown",()=>{this.#M=!0},{capture:!0,signal:b}),window.addEventListener("pointerup",()=>{this.#M=!1},{capture:!0,signal:b}),window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:b}),this.#lt(),this.#pt(),this.#it(),this.#l=o.annotationStorage,this.#S=o.filterFactory,this.#V=l,this.#O=c||null,this.#b=d,this.#w=u,this.#A=f,this.#$=p||null,this.viewParameters={realScale:os.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=m!==!1,this._keepToolbarInPage=v===!0,r?.setSidebarUiManager(this)}destroy(){this.#H?.resolve(),this.#H=null,this.#t?.abort(),this.#t=null,this._signal=null;for(const t of this.#r.values())t.destroy();this.#r.clear(),this.#i.clear(),this.#y.clear(),this.#U?.clear(),this.#e=null,this.#T.clear(),this.#u.destroy(),this.#o?.destroy(),this.#h?.destroy(),this.#G?.destroy(),this.#C?.hide(),this.#C=null,this.#z?.destroy(),this.#z=null,this.#s=null,this.#_&&(clearTimeout(this.#_),this.#_=null),this.#L&&(clearTimeout(this.#L),this.#L=null),this._editorUndoBar?.destroy(),this.#Y=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#$}get useNewAltTextFlow(){return this.#w}get useNewAltTextWhenAddingImage(){return this.#A}get hcmFilter(){return L(this,"hcmFilter",this.#V?this.#S.addHCMFilter(this.#V.foreground,this.#V.background):"none")}get direction(){return L(this,"direction",getComputedStyle(this.#X).direction)}get _highlightColors(){return L(this,"_highlightColors",this.#O?new Map(this.#O.split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return L(this,"highlightColors",null);const e=new Map,s=!!this.#V;for(const[i,r]of t){const n=i.endsWith("_HCM");if(s&&n){e.set(i.replace("_HCM",""),r);continue}!s&&!n&&e.set(i,r)}return L(this,"highlightColors",e)}get highlightColorNames(){return L(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const 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.#p=t}setMainHighlightColorPicker(t){this.#z=t}editAltText(t,e=!1){this.#o?.editAltText(this,t,e)}hasCommentManager(){return!!this.#h}editComment(t,e,s,i){this.#h?.showDialog(this,t,e,s,i)}selectComment(t,e){this.#r.get(t)?.getEditorByUID(e)?.toggleComment(!0,!0)}updateComment(t){this.#h?.updateComment(t.getData())}updatePopupColor(t){this.#h?.updatePopupColor(t)}removeComment(t){this.#h?.removeComments([t.uid])}deleteComment(t,e){const s=()=>{t.comment=e},i=()=>{this._editorUndoBar?.show(s,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:i,undo:s,mustExec:!0})}toggleComment(t,e,s=void 0){this.#h?.toggleCommentPopup(t,e,s)}makeCommentColor(t,e){return t&&this.#h?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#h?.dialogElement||null}async waitForEditorsRendered(t){if(this.#r.has(t-1))return;const{resolve:e,promise:s}=Promise.withResolvers(),i=r=>{r.pageNumber===t&&(this._eventBus.off("editorsrendered",i),e())};this._eventBus.on("editorsrendered",i,ji),await s}getSignature(t){this.#G?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#G}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...ji}),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}){t==="enableNewAltTextWhenAddingImage"&&(this.#A=e)}onPageChanging({pageNumber:t}){this.#m=t-1}deletePage(t){for(const e of this.getEditors(t))e.remove();this.#r.delete(t),this.#m===t&&(this.#m=0)}focusMainContainer(){this.#X.focus()}findParent(t,e){for(const s of this.#r.values()){const{x:i,y:r,width:n,height:a}=s.div.getBoundingClientRect();if(t>=i&&t<=i+n&&e>=r&&e<=r+a)return s}return null}disableUserSelect(t=!1){this.#tt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#y.add(t)}removeShouldRescale(t){this.#y.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*os.PDF_TO_CSS_UNITS;for(const e of this.#y)e.onScaleChanging();this.#p?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#Z({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#st(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of this.#r.values())if(s.hasTextLayer(t))return s;return null}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:r,focusNode:n,focusOffset:a}=s,o=s.toString(),c=this.#Z(s).closest(".textLayer"),d=this.getSelectionBoxes(c);if(!d)return;s.empty();const u=this.#st(c),f=this.#x===Y.NONE,p=()=>{const g=u?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:i,anchorOffset:r,focusNode:n,focusOffset:a,text:o});f&&this.showAllEditors("highlight",!0,!0),e&&g?.editComment()};if(f){this.switchToMode(Y.HIGHLIGHT,p);return}p()}commentSelection(t=""){this.highlightSelection(t,!0)}endCurrentEditing(){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#at(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=this.#Z(t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(this.#C||=new ac(this),this.#C.show(s,i,this.direction==="ltr"))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#l)return null;const e=`${as}${t}`,s=this.#l.getRawValue(e);return s&&this.#l.remove(e),s}addToAnnotationStorage(t){!t.isEmpty()&&this.#l&&!this.#l.has(t.id)&&this.#l.setValue(t.id,t)}a11yAlert(t,e=null){const s=this.#et;s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}#ot(){const t=document.getSelection();if(!t||t.isCollapsed){this.#j&&(this.#C?.hide(),this.#j=null,this.#k({hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===this.#j)return;const i=this.#Z(t).closest(".textLayer");if(!i){this.#j&&(this.#C?.hide(),this.#j=null,this.#k({hasSelectedText:!1}));return}if(this.#C?.hide(),this.#j=e,this.#k({hasSelectedText:!0}),!(this.#x!==Y.HIGHLIGHT&&this.#x!==Y.NONE)&&(this.#x===Y.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#P=this.isShiftKeyDown,!this.isShiftKeyDown)){const r=this.#x===Y.HIGHLIGHT?this.#st(i):null;if(r?.toggleDrawing(),this.#M){const n=new AbortController,a=this.combinedSignal(n),o=l=>{l.type==="pointerup"&&l.button!==0||(n.abort(),r?.toggleDrawing(!0),l.type==="pointerup"&&this.#J("main_toolbar"))};window.addEventListener("pointerup",o,{signal:a}),window.addEventListener("blur",o,{signal:a})}else r?.toggleDrawing(!0),this.#J("main_toolbar")}}#J(t=""){this.#x===Y.HIGHLIGHT?this.highlightSelection(t):this.#b&&this.#at()}#lt(){document.addEventListener("selectionchange",this.#ot.bind(this),{signal:this._signal})}#ct(){if(this.#E)return;this.#E=new AbortController;const t=this.combinedSignal(this.#E);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#ht(){this.#E?.abort(),this.#E=null}blur(){if(this.isShiftKeyDown=!1,this.#P&&(this.#P=!1,this.#J("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#T)if(e.div.contains(t)){this.#B=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#B)return;const[t,e]=this.#B;this.#B=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#it(){if(this.#F)return;this.#F=new AbortController;const t=this.combinedSignal(this.#F);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#dt(){this.#F?.abort(),this.#F=null}#ut(){if(this.#f)return;this.#f=new AbortController;const t=this.combinedSignal(this.#f);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})}#ft(){this.#f?.abort(),this.#f=null}#pt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#it(),this.setEditingState(!0)}removeEditListeners(){this.#dt(),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of this.#v)if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of this.#v)if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#e?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const s of this.#T){const i=s.serialize(!0);i&&e.push(i)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const r of e.items)for(const n of this.#v)if(n.isHandlingMimeForPasting(r.type)){n.paste(r,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){z(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const o of s){const l=await i.deserialize(o);if(!l)return;r.push(l)}const n=()=>{for(const o of r)this.#rt(o);this.#nt(r)},a=()=>{for(const o of r)o.remove()};this.addCommands({cmd:n,undo:a,mustExec:!0})}catch(r){z(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),this.#x!==Y.NONE&&!this.isEditorHandlingKeyboard&&Ie._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,this.#P&&(this.#P=!1,this.#J("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");break}}updatePageIndex(t,e){for(const i of this.#a.get(t)||[])i.pageIndex=e;const s=this.#n.get(t);s&&(s.pageIndex=e,this.#r.set(e,s),this.#I?s.enable():s.disable())}startUpdatePages(){this.#n=new Map(this.#r),this.#r.clear();const t=this.#a=new Map,e=s=>{t.getOrInsertComputed(s.pageIndex,hs).push(s)};for(const s of this.#i.values())e(s);for(const[s,i]of this.#l)s.startsWith(as)&&!this.#i.has(s)&&Number.isInteger(i?.pageIndex)&&e(i)}endUpdatePages(){this.#n=null,this.#a=null}clonePage(t,e){for(const s of this.getEditors(t)){const i=s.serialize(s.mode!==Y.HIGHLIGHT);i&&(i.pageIndex=e,i.id=this.getId(),i.isClone=!0,delete i.popupRef,this.#l.setValue(i.id,i))}}findClonesForPage(t){const e=[],{pageIndex:s}=t;for(const[i,r]of this.#l)r.pageIndex===s&&r.isClone&&(this.#l.remove(i),e.push(t.deserialize(r).then(n=>{n&&(n.isClone=!0,t.addOrRebuild(n))})));return Promise.all(e)}#k(t){Object.entries(t).some(([s,i])=>this.#K[s]!==i)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#K,t)}),this.#x===Y.HIGHLIGHT&&t.hasSelectedEditor===!1&&this.#W([[st.HIGHLIGHT_FREE,!0]]))}#W(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#ct(),this.#ut(),this.#k({isEditing:this.#x!==Y.NONE,isEmpty:this.#Q(),hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:this.#u.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ht(),this.#ft(),this.#k({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#v){this.#v=t;for(const e of this.#v)this.#W(e.defaultPropertiesToUpdate)}}getId(){return this.#R.id}get currentLayer(){return this.#r.get(this.#m)}getLayer(t){return this.#r.get(t)}get currentPageIndex(){return this.#m}addLayer(t){this.#r.set(t.pageIndex,t),this.#I?t.enable():t.disable()}removeLayer(t){this.#r.delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,r=!1,n=!1){if(this.#x!==t&&!(this.#H&&(await this.#H.promise,!this.#H))){if(this.#H=Promise.withResolvers(),this.#p?.commitOrRemove(),this.#x===Y.POPUP&&this.#h?.hideSidebar(),this.#h?.destroyPopup(),this.#x=t,t===Y.NONE){this.setEditingState(!1),this.#mt();for(const a of this.#i.values())a.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#H.resolve();return}for(const a of this.#i.values())a.addStandaloneCommentButton();t===Y.SIGNATURE&&await this.#G?.loadSignatures(),s&&at.clearPointerType(),this.setEditingState(!0),await this.#gt(),this.unselectAll();for(const a of this.#r.values())a.updateMode(t);if(t===Y.POPUP){this.#s||=await this.#Y.getAnnotationsByType(new Set(this.#v.map(l=>l._editorType)));const a=new Set,o=[];for(const l of this.#i.values()){const{annotationElementId:c,hasComment:d,deleted:u}=l;c&&a.add(c),d&&!u&&o.push(l.getData())}for(const l of this.#s){const{id:c,popupRef:d,contentsObj:u}=l;d&&u?.str&&!a.has(c)&&!this.#d.has(c)&&o.push(l)}this.#h?.showSidebar(o)}if(!e){i&&this.addNewEditorFromKeyboard(),this.#H.resolve();return}for(const a of this.#i.values())a.uid===e?(this.setSelected(a),n?a.editComment():r?a.enterInEditMode():a.focus()):a.unselect();this.#H.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#x&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#v){switch(t){case st.CREATE:this.currentLayer.addNewEditor(e);return;case st.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#q||=new Map).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of this.#T)s.updateParams(t,e);else for(const s of this.#v)s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const r of this.#i.values())r.editorType===t&&r.show(e);(this.#q?.get(st.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#W([[st.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#D!==t){this.#D=t;for(const e of this.#r.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#gt(){if(!this.#I){this.#I=!0;const t=[];for(const e of this.#r.values())t.push(e.enable());await Promise.all(t);for(const e of this.#i.values())e.enable()}}#mt(){if(this.unselectAll(),this.#I){this.#I=!1;for(const t of this.#r.values())t.disable();for(const t of this.#i.values())t.disable()}}*getEditors(t){for(const e of this.#i.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#i.get(t)}addEditor(t){this.#i.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#_&&clearTimeout(this.#_),this.#_=setTimeout(()=>{this.focusMainContainer(),this.#_=null},0)),this.#i.delete(t.id),t.annotationElementId&&this.#U?.delete(t.annotationElementId),this.unselect(t),(!t.annotationElementId||!this.#d.has(t.annotationElementId))&&this.#l?.remove(t.id)}addDeletedAnnotationElement(t){this.#d.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#d.has(t)}removeDeletedAnnotationElement(t){this.#d.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#rt(t){const e=this.#r.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#e!==t&&(this.#e=t,t&&this.#W(t.propertiesToUpdate))}get#vt(){let t=null;for(t of this.#T);return t}updateUI(t){this.#vt===t&&this.#W(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#W(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#T.has(t)){this.#T.delete(t),t.unselect(),this.#k({hasSelectedEditor:this.hasSelection});return}this.#T.add(t),t.select(),this.#W(t.propertiesToUpdate),this.#k({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#p?.commitOrRemove();for(const e of this.#T)e!==t&&e.unselect();this.#h?.destroyPopup(),this.#T.clear(),this.#T.add(t),t.select(),this.#W(t.propertiesToUpdate),this.#k({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#T.values().next().value}unselect(t){t.unselect(),this.#T.delete(t),this.#k({hasSelectedEditor:this.hasSelection})}get hasSelection(){return this.#T.size!==0}get isEnterHandled(){return this.#T.size===1&&this.firstSelectedEditor.isEnterHandled}undo(){this.#u.undo(),this.#k({hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:this.#u.hasSomethingToRedo(),isEmpty:this.#Q()}),this._editorUndoBar?.hide()}redo(){this.#u.redo(),this.#k({hasSomethingToUndo:this.#u.hasSomethingToUndo(),hasSomethingToRedo:this.#u.hasSomethingToRedo(),isEmpty:this.#Q()})}addCommands(t){this.#u.add(t),this.#k({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Q()})}cleanUndoStack(t){this.#u.cleanType(t)}#Q(){if(this.#i.size===0)return!0;if(this.#i.size===1)for(const t of this.#i.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#T],s=()=>{this._editorUndoBar?.show(i,e.length===1?e[0].editorType:e.length);for(const r of e)r.remove()},i=()=>{for(const r of e)this.#rt(r)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){this.#e?.commitOrRemove()}hasSomethingToControl(){return this.#e||this.hasSelection}#nt(t){for(const e of this.#T)e.unselect();this.#T.clear();for(const e of t)e.isEmpty()||(this.#T.add(e),e.select());this.#k({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#T)t.commit();this.#nt(this.#i.values())}unselectAll(){if(!(this.#e&&(this.#e.commitOrRemove(),this.#x!==Y.NONE))&&!this.#p?.commitOrRemove()&&(this.#h?.destroyPopup(),!!this.hasSelection)){for(const t of this.#T)t.unselect();this.#T.clear(),this.#k({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;this.#N[0]+=t,this.#N[1]+=e;const[i,r]=this.#N,n=[...this.#T],a=1e3;this.#L&&clearTimeout(this.#L),this.#L=setTimeout(()=>{this.#L=null,this.#N[0]=this.#N[1]=0,this.addCommands({cmd:()=>{for(const o of n)this.#i.has(o.id)&&(o.translateInPage(i,r),o.translationDone())},undo:()=>{for(const o of n)this.#i.has(o.id)&&(o.translateInPage(-i,-r),o.translationDone())},mustExec:!1})},a);for(const o of n)o.translateInPage(t,e),o.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#g=new Map;for(const t of this.#T)this.#g.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#g)return!1;this.disableUserSelect(!1);const t=this.#g;this.#g=null;let e=!1;for(const[{x:i,y:r,pageIndex:n},a]of t)a.newX=i,a.newY=r,a.newPageIndex=n,e||=i!==a.savedX||r!==a.savedY||n!==a.savedPageIndex;if(!e)return!1;const s=(i,r,n,a)=>{if(this.#i.has(i.id)){const o=this.#r.get(a);o?i._setParentAndPosition(o,r,n):(i.pageIndex=a,i.x=r,i.y=n)}};return this.addCommands({cmd:()=>{for(const[i,{newX:r,newY:n,newPageIndex:a}]of t)s(i,r,n,a)},undo:()=>{for(const[i,{savedX:r,savedY:n,savedPageIndex:a}]of t)s(i,r,n,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#g)for(const s of this.#g.keys())s.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||this.#T.size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#e===t}getActive(){return this.#e}getMode(){return this.#x}isEditingMode(){return this.#x!==Y.NONE}get imageManager(){return L(this,"imageManager",new Ir)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let l=0,c=e.rangeCount;l<c;l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;const{x:s,y:i,width:r,height:n}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(l,c,d,u)=>({x:(c-i)/n,y:1-(l+d-s)/r,width:u/n,height:d/r});break;case"180":a=(l,c,d,u)=>({x:1-(l+d-s)/r,y:1-(c+u-i)/n,width:d/r,height:u/n});break;case"270":a=(l,c,d,u)=>({x:1-(c+u-i)/n,y:(l-s)/r,width:u/n,height:d/r});break;default:a=(l,c,d,u)=>({x:(l-s)/r,y:(c-i)/n,width:d/r,height:u/n});break}const o=[];for(let l=0,c=e.rangeCount;l<c;l++){const d=e.getRangeAt(l);if(!d.collapsed)for(const{x:u,y:f,width:p,height:g}of d.getClientRects())p===0||g===0||o.push(a(u,f,p,g))}return o.length===0?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#c||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#c?.delete(t)}renderAnnotationElement(t){const e=this.#c?.get(t.data.id);if(!e)return;const s=this.#l.getRawValue(e);s&&(this.#x===Y.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){const i=this.#U?.get(t);i&&(i.setCanvas(e,s),this.#U.delete(t))}addMissingCanvas(t,e){(this.#U||=new Map).set(t,e)}}class de{#t=null;#e=!1;#s=null;#i=null;#r=null;#n=null;#a=!1;#o=null;#l=null;#c=null;#u=null;#h=!1;static#f=null;static _l10n=null;constructor(t){this.#l=t,this.#h=t._uiManager.useNewAltTextFlow,de.#f||=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){de._l10n??=t}async render(){const t=this.#s=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#i=document.createElement("span");t.append(e),this.#h?(t.classList.add("new"),t.setAttribute("data-l10n-id",de.#f.missing),e.setAttribute("data-l10n-id",de.#f["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=this.#l._uiManager._signal;t.addEventListener("contextmenu",ae,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),this.#l._uiManager.editAltText(this.#l),this.#h&&this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#p}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(this.#a=!0,i(r))},{signal:s}),await this.#m(),t}get#p(){return this.#t&&"added"||this.#t===null&&this.guessedText&&"review"||"missing"}finish(){this.#s&&(this.#s.focus({focusVisible:this.#a}),this.#a=!1)}isEmpty(){return this.#h?this.#t===null:!this.#t&&!this.#e}hasData(){return this.#h?this.#t!==null||!!this.#c:this.isEmpty()}get guessedText(){return this.#c}async setGuessedText(t){this.#t===null&&(this.#c=t,this.#u=await de._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#m())}toggleAltTextBadge(t=!1){if(!this.#h||this.#t){this.#o?.remove(),this.#o=null;return}if(!this.#o){const e=this.#o=document.createElement("div");e.className="noAltTextBadge",this.#l.div.append(e)}this.#o.classList.toggle("hidden",!t)}serialize(t){let e=this.#t;return!t&&this.#c===e&&(e=this.#u),{altText:e,decorative:this.#e,guessedText:this.#c,textWithDisclaimer:this.#u}}get data(){return{altText:this.#t,decorative:this.#e}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(this.#c=s,this.#u=i),!(this.#t===t&&this.#e===e)&&(r||(this.#t=t,this.#e=e),this.#m())}toggle(t=!1){this.#s&&(!t&&this.#n&&(clearTimeout(this.#n),this.#n=null),this.#s.disabled=!t)}shown(){this.#l._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#p}})}destroy(){this.#s?.remove(),this.#s=null,this.#i=null,this.#r=null,this.#o?.remove(),this.#o=null}async#m(){const t=this.#s;if(!t)return;if(this.#h){if(t.classList.toggle("done",!!this.#t),t.setAttribute("data-l10n-id",de.#f[this.#p]),this.#i?.setAttribute("data-l10n-id",de.#f[`${this.#p}-label`]),!this.#t){this.#r?.remove();return}}else{if(!this.#t&&!this.#e){t.classList.remove("done"),this.#r?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#r;if(!e){this.#r=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#l.id}`;const i=100,r=this.#l._uiManager._signal;r.addEventListener("abort",()=>{clearTimeout(this.#n),this.#n=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#n=setTimeout(()=>{this.#n=null,this.#r.classList.add("show"),this.#l._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:r}),t.addEventListener("mouseleave",()=>{this.#n&&(clearTimeout(this.#n),this.#n=null),this.#r?.classList.remove("show")},{signal:r})}this.#e?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#t),e.parentNode||t.append(e),this.#l.getElementForAltText()?.setAttribute("aria-describedby",e.id)}}class Ls{#t=null;#e=null;#s=!1;#i=null;#r=null;#n=null;#a=null;#o=null;#l=!1;#c=null;constructor(t){this.#i=t}renderForToolbar(){const t=this.#e=document.createElement("button");return t.className="comment",this.#u(t,!1)}renderForStandalone(){const t=this.#t=document.createElement("button");t.className="annotationCommentButton";const e=this.#i.commentButtonPosition;if(e){const{style:s}=t;s.insetInlineEnd=`calc(${100*(this.#i._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,s.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const i=this.#i.commentButtonColor;i&&(s.backgroundColor=i)}return this.#u(t,!0)}focusButton(){setTimeout(()=>{(this.#t??this.#e)?.focus()},0)}onUpdatedColor(){if(!this.#t)return;const t=this.#i.commentButtonColor;t&&(this.#t.style.backgroundColor=t),this.#i._uiManager.updatePopupColor(this.#i)}get commentButtonWidth(){return(this.#t?.getBoundingClientRect().width??0)/this.#i.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#c)return this.#c;if(!this.#t)return null;const{x:t,y:e,height:s}=this.#t.getBoundingClientRect(),{x:i,y:r,width:n,height:a}=this.#i.parent.boundingClientRect;return[(t-i)/n,(e+s-r)/a]}set commentPopupPositionInLayer(t){this.#c=t}hasDefaultPopupPosition(){return this.#c===null}removeStandaloneCommentButton(){this.#t?.remove(),this.#t=null}removeToolbarCommentButton(){this.#e?.remove(),this.#e=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#t&&(this.#t.classList.toggle("selected",t),this.#t.ariaExpanded=e)}#u(t,e){if(!this.#i._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.#i._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const s=this.#i._uiManager._signal;if(!(s instanceof AbortSignal)||s.aborted)return t;t.addEventListener("contextmenu",ae,{signal:s}),e&&(t.addEventListener("focusin",r=>{this.#i._focusEventsAllowed=!1,xt(r)},{capture:!0,signal:s}),t.addEventListener("focusout",r=>{this.#i._focusEventsAllowed=!0,xt(r)},{capture:!0,signal:s})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),t===this.#e?this.edit():this.#i.toggleComment(!0)};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(this.#s=!0,i(r))},{signal:s}),t.addEventListener("pointerenter",()=>{this.#i.toggleComment(!1,!0)},{signal:s}),t.addEventListener("pointerleave",()=>{this.#i.toggleComment(!1,!1)},{signal:s}),t}edit(t){const e=this.commentPopupPositionInLayer;let s,i;if(e)[s,i]=e;else{[s,i]=this.#i.commentButtonPosition;const{width:c,height:d,x:u,y:f}=this.#i;s=u+s*c,i=f+i*d}const r=this.#i.parent.boundingClientRect,{x:n,y:a,width:o,height:l}=r;this.#i._uiManager.editComment(this.#i,n+s*o,a+i*l,{...t,parentDimensions:r})}finish(){this.#e&&(this.#e.focus({focusVisible:this.#s}),this.#s=!1)}isDeleted(){return this.#l||this.#a===""}isEmpty(){return this.#a===null}hasBeenEdited(){return this.isDeleted()||this.#a!==this.#r}serialize(){return this.data}get data(){return{text:this.#a,richText:this.#n,date:this.#o,deleted:this.isDeleted()}}set data(t){if(t!==this.#a&&(this.#n=null),t===null){this.#a="",this.#l=!0;return}this.#a=t,this.#o=new Date,this.#l=!1}restoreData({text:t,richText:e,date:s}){this.#a=t,this.#n=e,this.#o=s,this.#l=!1}setInitialText(t,e=null){this.#r=t,this.data=t,this.#o=null,this.#n=e}shown(){}destroy(){this.#e?.remove(),this.#e=null,this.#t?.remove(),this.#t=null,this.#a="",this.#n=null,this.#o=null,this.#i=null,this.#s=!1,this.#l=!1}}function on(h){h.preventDefault()}const ln=1e-4;function Hi(h){return h.cancelable?(xt(h),!0):(h.stopPropagation(),!1)}class ga{#t;#e=!1;#s=null;#i;#r;#n;#a;#o;#l=!1;#c=null;#u;#h=new Set;#f=null;#p;#m=null;#d=0;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:n=null,onPanning:a=null,signal:o}){this.#t=t,this.#s=s,this.#i=e,this.#r=i,this.#n=r,this.#a=n,this.#o=a,this.#p=new AbortController,this.#u=AbortSignal.any([o,this.#p.signal]),t.addEventListener("touchstart",this.#g.bind(this),{passive:!1,signal:this.#u})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Jt.pixelRatio}get MIN_TOUCH_DISTANCE_TO_SCALE(){return 4/Jt.pixelRatio}#g(t){if(this.#i?.())return;this.#y(t);const e=this.#h;for(const{identifier:s}of t.changedTouches)e.add(s);if(e.size===1){this.#v();return}if(!this.#m){this.#m=new AbortController;const s=AbortSignal.any([this.#u,this.#m.signal]),i=this.#t,r={signal:s,capture:!1,passive:!1};i.addEventListener("touchmove",this.#A.bind(this),r);const n=this.#S.bind(this);i.addEventListener("touchend",n,r),i.addEventListener("touchcancel",n,r),r.capture=!0,i.addEventListener("pointerdown",xt,r),i.addEventListener("pointermove",xt,r),i.addEventListener("pointercancel",on,r),i.addEventListener("pointerup",on,r),this.#r?.()}this.#l=Hi(t),this.#w(t)}#v(){if(this.#c)return;const t=this.#c=new AbortController,e=AbortSignal.any([this.#u,t.signal]),s=this.#t,i={capture:!0,signal:e,passive:!1},r=n=>{n.pointerType==="touch"&&(this.#c?.abort(),this.#c=null)};s.addEventListener("pointerdown",n=>{n.pointerType==="touch"&&(xt(n),r(n))},i),s.addEventListener("pointerup",r,i),s.addEventListener("pointercancel",r,i)}#y(t){const e=this.#h;if(e.size===0)return;const s=this.#h=new Set;for(const{identifier:i}of t.touches)e.has(i)&&s.add(i)}#b(t){const e=this.#h,s=[];for(const i of t.touches)e.has(i.identifier)&&s.push(i);return s}#w(t){const e=this.#b(t);if(e.length!==2||this.#s?.()){this.#f=null;return}const[s,i]=e;this.#f={touch0X:s.screenX,touch0Y:s.screenY,touch1X:i.screenX,touch1Y:i.screenY,panX:(s.clientX+i.clientX)/2,panY:(s.clientY+i.clientY)/2,screenPanX:(s.screenX+i.screenX)/2,screenPanY:(s.screenY+i.screenY)/2}}#A(t){if(!this.#f)return;const e=this.#b(t);if(e.length!==2)return;const s=this.#l;if(this.#l=Hi(t),!this.#l)return;if(!s){this.#w(t);return}const[i,r]=e,{screenX:n,screenY:a}=i,{screenX:o,screenY:l}=r,c=this.#f,{touch0X:d,touch0Y:u,touch1X:f,touch1Y:p,panX:g,panY:m}=c,v=f-d,b=p-u,y=o-n,w=l-a,A=(i.clientX+r.clientX)/2,_=(i.clientY+r.clientY)/2;c.panX=A,c.panY=_;const E=A-g,x=_-m,T=(n+o)/2,C=(a+l)/2,P=Math.hypot(T-c.screenPanX,C-c.screenPanY);c.screenPanX=T,c.screenPanY=C;const k=Math.hypot(y,w),R=Math.hypot(v,b),B=this.#e?this.MIN_TOUCH_DISTANCE_TO_SCALE:this.MIN_TOUCH_DISTANCE_TO_PINCH+2*P;if(k<ln||R<ln||Math.abs(R-k)<=B){(E||x)&&this.#o?.(E,x);return}c.touch0X=n,c.touch0Y=a,c.touch1X=o,c.touch1Y=l;const U=Math.sign(k-R);if(!this.#e){this.#e=!0,this.#d=U,(E||x)&&this.#o?.(E,x);return}if(this.#d){const M=this.#d;if(this.#d=0,U!==M&&Math.abs(k-R)<=2*P){this.#e=!1,(E||x)&&this.#o?.(E,x);return}}this.#n?.([g,m],R,k,E,x)}#S(t){if(this.#y(t),this.#h.size>=2){this.#w(t);return}const e=!!this.#f;this.#_(),this.#h.size===1&&this.#v(),e&&Hi(t)}#_(){this.#f=null,this.#e=!1,this.#d=0,this.#l=!1,this.#m&&(this.#m.abort(),this.#m=null,this.#a?.())}destroy(){this.#_(),this.#h.clear(),this.#p?.abort(),this.#p=null,this.#c?.abort(),this.#c=null}}class H{#t=null;#e=null;#s=null;#i=null;#r=null;#n=!1;#a=null;#o="";#l=null;#c=null;#u=null;#h=null;#f=null;#p="";#m=!1;#d=null;#g=!1;#v=!1;#y=!1;#b=null;#w=0;#A=0;#S=null;#_=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nAlert=null;static _l10nResizer=null;#E=!1;#O=H._zIndex++;static _borderLineWidth=-1;static _colorManager=new kr;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=H.prototype._resizeWithKeyboard,e=Ie.TRANSLATE_SMALL,s=Ie.TRANSLATE_BIG;return L(this,"_resizerKeyboardManager",new Kt([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape"],H.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:s,pageHeight:i,pageX:r,pageY:n}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[r,n];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 L(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new hc({id:t._uiManager.getId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(H._l10n??=t,H._l10nAlert??=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"}),H._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"}),H._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);H._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){nt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#E}set _isDraggable(t){this.#E=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}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.#O}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#N(),this.#h?.remove(),this.#h=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#m?this.#m=!1:this.parent.setSelected(this))}focusout(t){!this._focusEventsAllowed||!this.isAttachedToDOM||t.relatedTarget?.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,s,i){const[r,n]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/r,this.y=(e+i)/n,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone){delete this.isClone;return}const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}#P([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#P(this.parentDimensions,t,e)}translateInPage(t,e){this.#d||=[this.x,this.y,this.width,this.height],this.#P(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#d||=[this.x,this.y,this.width,this.height];const{div:s,parentDimensions:[i,r]}=this;if(this.x+=t/i,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:d,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,d,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:a}=this;const[o,l]=this.getBaseTranslation();n+=o,a+=l;const{style:c}=s;c.left=`${(100*n).toFixed(2)}%`,c.top=`${(100*a).toFixed(2)}%`,this._onTranslating(n,a)}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#d&&(this.#d[0]!==this.x||this.#d[1]!==this.y)}get _hasBeenResized(){return!!this.#d&&(this.#d[2]!==this.width||this.#d[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=H,i=s/t,r=s/e;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:r,y:n,width:a,height:o}=this;a*=s,o*=i,r*=s,n*=i;let l=0,c=0;const d=this._uiManager._keepToolbarInPage&&this._editToolbar?.div;if(d?.offsetParent){const p=this.parentScale,g=d.offsetLeft+this.div.clientLeft,m=d.offsetTop+this.div.clientTop,v=Math.min(0,g)/p,b=Math.min(0,m)/p,y=a-v+Math.max(0,g+d.offsetWidth-this.div.offsetWidth)/p,w=o-b+Math.max(0,m+d.offsetHeight-this.div.offsetHeight)/p;y<=(t%180?i:s)&&(a=y,l=v),w<=(t%180?s:i)&&(o=w,c=b),[l,c]=H.#C(l,c,t),r+=l,n+=c}if(this._mustFixPosition)switch(t){case 0:r=ft(r,0,s-a),n=ft(n,0,i-o);break;case 90:r=ft(r,0,s-o),n=ft(n,a,i);break;case 180:r=ft(r,a,s),n=ft(n,o,i);break;case 270:r=ft(r,o,s),n=ft(n,0,i-a);break}this.x=r=(r-l)/s,this.y=n=(n-c)/i;const[u,f]=this.getBaseTranslation();r+=u,n+=f,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static#C(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return H.#C(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return H.#C(t,e,360-this.parentRotation)}#R(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(){const{div:{style:t},width:e,height:s}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*s).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#I(){if(this.#l)return;this.#l=document.createElement("div"),this.#l.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const s of t){const i=document.createElement("div");this.#l.append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",this.#M.bind(this,s),{signal:e}),i.addEventListener("contextmenu",ae,{signal:e}),i.tabIndex=-1}this.div.prepend(this.#l)}#M(t,e){e.preventDefault();const{isMac:s}=ot.platform;if(e.button!==0||e.ctrlKey&&s)return;this.#s?.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,this.#c=[e.screenX,e.screenY];const r=new AbortController,n=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#B.bind(this,t),{passive:!0,capture:!0,signal:n}),window.addEventListener("touchmove",xt,{passive:!1,signal:n}),window.addEventListener("contextmenu",ae,{signal:n}),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const 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;const l=()=>{r.abort(),this.parent.togglePointerEvents(!0),this.#s?.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#F()};window.addEventListener("pointerup",l,{signal:n}),window.addEventListener("blur",l,{signal:n})}#D(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#F(){if(!this.#u)return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=this.#u;this.#u=null;const r=this.x,n=this.y,a=this.width,o=this.height;r===t&&n===e&&a===s&&o===i||this.addCommands({cmd:this.#D.bind(this,r,n,a,o),undo:this.#D.bind(this,t,e,s,i),mustExec:!0})}static _round(t){return Math.round(t*1e4)/1e4}#B(t,e){const[s,i]=this.parentDimensions,r=this.x,n=this.y,a=this.width,o=this.height,l=H.MIN_SIZE/s,c=H.MIN_SIZE/i,d=this.#R(this.rotation),u=(M,O)=>[d[0]*M+d[2]*O,d[1]*M+d[3]*O],f=this.#R(360-this.rotation),p=(M,O)=>[f[0]*M+f[2]*O,f[1]*M+f[3]*O];let g,m,v=!1,b=!1;switch(t){case"topLeft":v=!0,g=(M,O)=>[0,0],m=(M,O)=>[M,O];break;case"topMiddle":g=(M,O)=>[M/2,0],m=(M,O)=>[M/2,O];break;case"topRight":v=!0,g=(M,O)=>[M,0],m=(M,O)=>[0,O];break;case"middleRight":b=!0,g=(M,O)=>[M,O/2],m=(M,O)=>[0,O/2];break;case"bottomRight":v=!0,g=(M,O)=>[M,O],m=(M,O)=>[0,0];break;case"bottomMiddle":g=(M,O)=>[M/2,O],m=(M,O)=>[M/2,0];break;case"bottomLeft":v=!0,g=(M,O)=>[0,O],m=(M,O)=>[M,0];break;case"middleLeft":b=!0,g=(M,O)=>[0,O/2],m=(M,O)=>[M,O/2];break}const y=g(a,o),w=m(a,o);let A=u(...w);const _=H._round(r+A[0]),E=H._round(n+A[1]);let x=1,T=1,C,P;if(e.fromKeyboard)({deltaX:C,deltaY:P}=e);else{const{screenX:M,screenY:O}=e,[V,q]=this.#c;[C,P]=this.screenToPageTranslation(M-V,O-q),this.#c[0]=M,this.#c[1]=O}if([C,P]=p(C/s,P/i),v){const M=Math.hypot(a,o);x=T=Math.max(Math.min(Math.hypot(w[0]-y[0]-C,w[1]-y[1]-P)/M,1/a,1/o),l/a,c/o)}else b?x=ft(Math.abs(w[0]-y[0]-C),l,1)/a:T=ft(Math.abs(w[1]-y[1]-P),c,1)/o;const k=H._round(a*x),R=H._round(o*T);A=u(...m(k,R));const B=_-A[0],U=E-A[1];this.#d||=[this.x,this.y,this.width,this.height],this.width=k,this.height=R,this.x=B,this.y=U,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#s?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#v)return this._editToolbar;this._editToolbar=new ws(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);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.#s?.destroy()}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return this.#s||(de.initialize(H._l10n),this.#s=new de(this),this.#t&&(this.#s.data=this.#t,this.#t=null)),this.#s}get altTextData(){return this.#s?.data}set altTextData(t){this.#s&&(this.#s.data=t)}get guessedAltText(){return this.#s?.guessedText}async setGuessedAltText(t){await this.#s?.setGuessedText(t)}serializeAltText(t){return this.#s?.serialize(t)}hasAltText(){return!!this.#s&&!this.#s.isEmpty()}hasAltTextData(){return this.#s?.hasData()??!1}focusCommentButton(){this.#i?.focusButton()}addCommentButton(){return this.canAddComment?this.#i||=new Ls(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#r){this._uiManager.isEditingMode()&&this.#r.classList.remove("hidden");return}this.hasComment&&(this.#r=this.#i.renderForStandalone(),this.div.append(this.#r))}}removeStandaloneCommentButton(){this.#i.removeStandaloneCommentButton(),this.#r=null}hideStandaloneCommentButton(){this.#r?.classList.add("hidden")}get comment(){if(!this.#i)return null;const{data:{richText:t,text:e,date:s,deleted:i}}=this.#i;return{text:e,richText:t,date:s,deleted:i,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#i||=new Ls(this),typeof t=="object"&&t!==null?this.#i.restoreData(t):this.#i.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:s}){if(!e||(this.#i||=new Ls(this),this.#i.setInitialText(t,s),!this.annotationElementId))return;const i=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);i&&this.updateFromAnnotationLayer(i)}get hasEditedComment(){return this.#i?.hasBeenEdited()}get hasDeletedComment(){return this.#i?.isDeleted()}get hasComment(){return!!this.#i&&!this.#i.isEmpty()&&!this.#i.isDeleted()}async editComment(t){this.#i||=new Ls(this),this.#i.edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#i.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,i]=t.rect,[r]=this.pageDimensions,[n]=this.pageTranslation,a=n+r+1,o=i-100,l=a+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,l,i]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#i.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const 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.#n?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#j();const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,r]=this.getInitialTranslation();return this.translate(i,r),pa(this,t,["keydown","pointerdown","dblclick"]),this.#G(),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#z(){this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#s?.toggle(!1),this.parent.togglePointerEvents(!1)}#U(t,e,s){let r=.7*(s/e)+1-.7;if(r===1)return;const n=this.#R(this.rotation),a=(_,E)=>[n[0]*_+n[2]*E,n[1]*_+n[3]*E],[o,l]=this.parentDimensions,c=this.x,d=this.y,u=this.width,f=this.height,p=H.MIN_SIZE/o,g=H.MIN_SIZE/l;r=Math.max(Math.min(r,1/u,1/f),p/u,g/f);const m=H._round(u*r),v=H._round(f*r);if(m===u&&v===f)return;this.#d||=[c,d,u,f];const b=a(u/2,f/2),y=H._round(c+b[0]),w=H._round(d+b[1]),A=a(m/2,v/2);this.x=y-A[0],this.y=w-A[1],this.width=m,this.height=v,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#$(){this.#s?.toggle(!0),this.parent.togglePointerEvents(!0),this.#F()}pointerdown(t){const{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(this.#m=!0,this._isDraggable){this.#T(t);return}this.#x(t)}#x(t){const{isMac:e}=ot.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#T(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,r=this._uiManager.combinedSignal(i),n={capture:!0,passive:!1,signal:r},a=l=>{i.abort(),this.#a=null,this.#m=!1,this._uiManager.endDragSession()||this.#x(l),s&&this._onStopDragging()};e&&(this.#w=t.clientX,this.#A=t.clientY,this.#a=t.pointerId,this.#o=t.pointerType,window.addEventListener("pointermove",l=>{s||(s=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:c,clientY:d,pointerId:u}=l;if(u!==this.#a){xt(l);return}const[f,p]=this.screenToPageTranslation(c-this.#w,d-this.#A);this.#w=c,this.#A=d,this._uiManager.dragSelectedEditors(f,p),this.div.scrollIntoView({block:"nearest"})},n),window.addEventListener("touchmove",xt,n),window.addEventListener("pointerdown",l=>{l.pointerType===this.#o&&(this.#_||l.isPrimary)&&a(l),xt(l)},n));const o=l=>{if(!this.#a||this.#a===l.pointerId){a(l);return}xt(l)};window.addEventListener("pointerup",o,{signal:r}),window.addEventListener("blur",o,{signal:r})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#b&&clearTimeout(this.#b),this.#b=setTimeout(()=>{this.#b=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[r,n]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/i,c=e/i,d=this.x*r,u=this.y*n,f=this.width*r,p=this.height*n;switch(s){case 0:return[d+l+a,n-u-c-p+o,d+l+f+a,n-u-c+o];case 90:return[d+c+a,n-u+l+o,d+c+p+a,n-u+l+f+o];case 180:return[d-l-f+a,n-u+c+o,d-l+a,n-u+c+p+o];case 270:return[d-c-p+a,n-u-l-f+o,d-c+a,n-u-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,r,n]=t,a=r-s,o=n-i;switch(this.rotation){case 0:return[s,e-n,a,o];case 90:return[s,e-i,o,a];case 180:return[r,e-i,a,o];case 270:return[r,e-n,o,a];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&H._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#i?.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:s,opacity:i,deleted:r,richText:n},uid:a,pageIndex:o,creationDate:l,modificationDate:c}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:n,contentsObj:{str:t},creationDate:l,modificationDate:s||c,popupRef:!r,color:e,opacity:i}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),this.#v=!0,!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),this.#v=!1,!0):!1}isInEditMode(){return this.#v}shouldGetKeyboardEvents(){return this.#y}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:r,innerWidth:n}=window;return e<n&&i>0&&t<r&&s>0}#j(){if(this.#f||!this.div)return;this.#f=new AbortController;const t=this._uiManager.combinedSignal(this.#f);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}#G(){this.#_||!this.div||!this.isResizable||!this._uiManager._supportsPinchToZoom||(this.#_=new ga({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#z.bind(this),onPinching:this.#U.bind(this),onPinchEnd:this.#$.bind(this),signal:this._uiManager._signal}))}rebuild(){this.#j(),this.#G()}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,s){const i=new this.prototype.constructor({parent:e,id:s.getId(),uiManager:s,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});i.rotation=t.rotation,i.#t=t.accessibilityData,i._isCopy=t.isCopy||!1;const[r,n]=i.pageDimensions,[a,o,l,c]=i.getRectInCurrentCoords(t.rect,n);return i.x=a/r,i.y=o/n,i.width=l/r,i.height=c/n,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){if(this.#f?.abort(),this.#f=null,this.isEmpty()||this.commit(),this.#_?.destroy(),this.#_=null,this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#b&&(clearTimeout(this.#b),this.#b=null),this.#N(),this.removeEditToolbar(),this.#S){for(const t of this.#S.values())clearTimeout(t);this.#S=null}this.parent=null,this.#h?.remove(),this.#h=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#I(),this.#l.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[s,i,r,n]=this.getPDFRect();return[H._round(s+(r-s)*t),H._round(i+(n-i)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#i.commentPopupPositionInLayer}set commentPopupPosition(t){this.#i.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#i.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#i.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#i?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),this.#u={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#l.children;if(!this.#e){this.#e=Array.from(e);const n=this.#V.bind(this),a=this.#q.bind(this),o=this._uiManager._signal;for(const l of this.#e){const c=l.getAttribute("data-resizer-name");l.setAttribute("role","spinbutton"),l.addEventListener("keydown",n,{signal:o}),l.addEventListener("blur",a,{signal:o}),l.addEventListener("focus",this.#Y.bind(this,c),{signal:o}),l.setAttribute("data-l10n-id",H._l10nResizer[c])}}const s=this.#e[0];let i=0;for(const n of e){if(n===s)break;i++}const r=(360-this.rotation+this.parentRotation)%360/90*(this.#e.length/4);if(r!==i){if(r<i)for(let a=0;a<i-r;a++)this.#l.append(this.#l.firstElementChild);else if(r>i)for(let a=0;a<r-i;a++)this.#l.firstElementChild.before(this.#l.lastElementChild);let n=0;for(const a of e){const l=this.#e[n++].getAttribute("data-resizer-name");a.setAttribute("data-l10n-id",H._l10nResizer[l])}}this.#K(0),this.#y=!0,this.#l.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#V(t){H._resizerKeyboardManager.exec(this,t)}#q(t){this.#y&&t.relatedTarget?.parentNode!==this.#l&&this.#N()}#Y(t){this.#p=this.#y?t:""}#K(t){if(this.#e)for(const e of this.#e)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#y&&this.#B(this.#p,{deltaX:t,deltaY:e,fromKeyboard:!0})}#N(){this.#y=!1,this.#K(-1),this.#F()}_stopResizingWithKeyboard(){this.#N(),this.div.focus()}select(){if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this.#L()});return}this.#L(),this.#s?.toggleAltTextBadge(!1)}#L(){this._editToolbar?.show(),this._uiManager._keepToolbarInPage&&(this.fixAndSetPosition(),this._onTranslated())}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#l?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#s?.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){t.target.nodeName!=="BUTTON"&&(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.#g}set isEditing(t){this.#g=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.#S||=new Map;const{action:s}=t;let i=this.#S.get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#S.delete(s),this.#S.size===0&&(this.#S=null)},H._telemetryTimeout),this.#S.set(s,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.#n=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#n=!0}updateFakeAnnotationElement(t){if(!this.#h&&!this.deleted){this.#h=t.addFakeAnnotation(this);return}if(this.deleted){this.#h.remove(),this.#h=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#h.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstElementChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class hc extends H{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const cn=3285377520,Qt=4294901760,ce=65535;class sr{constructor(t){this.h1=t?t&4294967295:cn,this.h2=t?t&4294967295:cn}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let g=0,m=t.length;g<m;g++){const v=t.charCodeAt(g);v<=255?e[s++]=v:(e[s++]=v>>>8,e[s++]=v&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,r=s-i*4,n=new Uint32Array(e.buffer,0,i);let a=0,o=0,l=this.h1,c=this.h2;const d=3432918353,u=461845907,f=d&ce,p=u&ce;for(let g=0;g<i;g++)g&1?(a=n[g],a=a*d&Qt|a*f&ce,a=a<<15|a>>>17,a=a*u&Qt|a*p&ce,l^=a,l=l<<13|l>>>19,l=l*5+3864292196):(o=n[g],o=o*d&Qt|o*f&ce,o=o<<15|o>>>17,o=o*u&Qt|o*p&ce,c^=o,c=c<<13|c>>>19,c=c*5+3864292196);switch(a=0,r){case 3:a^=e[i*4+2]<<16;case 2:a^=e[i*4+1]<<8;case 1:a^=e[i*4],a=a*d&Qt|a*f&ce,a=a<<15|a>>>17,a=a*u&Qt|a*p&ce,i&1?l^=a:c^=a}this.h1=l,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Qt|t*36045&ce,e=e*4283543511&Qt|((e<<16|t>>>16)*2950163797&Qt)>>>16,t^=e>>>1,t=t*444984403&Qt|t*60499&ce,e=e*3301882366&Qt|((e<<16|t>>>16)*3120437893&Qt)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Es=Object.freeze({map:null,hash:"",transfer:void 0});class Or{#t=!1;#e=null;#s=null;#i=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){const s=this.#i.get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return this.#i.get(t)}remove(t){const e=this.#i.get(t);e!==void 0&&(e instanceof H&&this.#s.delete(e.annotationElementId),this.#i.delete(t),this.#i.size===0&&this.resetModified(),!this.#i.values().some(s=>s instanceof H)&&this.onAnnotationEditor?.(null))}setValue(t,e){const s=this.#i.get(t);let i=!1;if(s!==void 0)for(const[r,n]of Object.entries(e))s[r]!==n&&(i=!0,s[r]=n);else i=!0,this.#i.set(t,e);i&&this.#r(),e instanceof H&&((this.#s||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type))}has(t){return this.#i.has(t)}get size(){return this.#i.size}#r(){this.#t||(this.#t=!0,this.onSetModified?.())}resetModified(){this.#t&&(this.#t=!1,this.onResetModified?.())}get print(){return new ma(this)}get serializable(){if(this.#i.size===0)return Es;const t=new Map,e=new sr,s=[],i=Object.create(null);let r=!1;for(const[n,a]of this.#i){const o=a instanceof H?a.serialize(!1,i):a;a.page&&(a.pageIndex=a.page._pageIndex,delete a.page),o&&(t.set(n,o),e.update(`${n}:${JSON.stringify(o)}`),r||=!!o.bitmap)}if(r)for(const n of t.values())n.bitmap&&s.push(n.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:Es}get editorStats(){let t=null;const e=new Map;let s=0,i=0;for(const r of this.#i.values()){if(!(r instanceof H)){r.popup&&(r.popup.deleted?i+=1:s+=1);continue}r.isCommentDeleted?i+=1:r.hasEditedComment&&(s+=1);const n=r.telemetryFinalData;if(!n)continue;const{type:a}=n;e.getOrInsertComputed(a,()=>Object.getPrototypeOf(r).constructor),t||=Object.create(null);const o=t[a]||=new Map;for(const[l,c]of Object.entries(n)){if(l==="type")continue;const d=o.getOrInsertComputed(l,Zs);d.set(c,(d.get(c)??0)+1)}}if((i>0||s>0)&&(t||=Object.create(null),t.comments={deleted:i,edited:s}),!t)return null;for(const[r,n]of e)t[r]=n.computeTelemetryFinalData(t[r]);return t}resetModifiedIds(){this.#e=null}updateEditor(t,e){const s=this.#s?.get(t);return s?(s.updateFromAnnotationLayer(e),!0):!1}getEditor(t){return this.#s?.get(t)||null}get modifiedIds(){if(this.#e)return this.#e;const t=[];if(this.#s)for(const s of this.#s.values())s.serialize()&&t.push(s.annotationElementId);let e="";if(t.length){const s=new sr;s.update(t.join(",")),e=s.hexdigest()}return this.#e={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#i.entries()}}class ma extends Or{#t=Es;constructor(t){super();const{serializable:e}=t;if(e===Es)return;const{map:s,hash:i,transfer:r}=e,n=structuredClone(s,r?{transfer:r}:null);this.#t={map:n,hash:i,transfer:[]}}get print(){nt("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#t}get modifiedIds(){return L(this,"modifiedIds",{ids:new Set,hash:""})}}function dc(h){if(h instanceof URL)return h;if(typeof h=="string"){if(Yt){if(/^[a-z][a-z0-9\-+.]+:/i.test(h))return new URL(h);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(h))}const t=URL.parse(h,window.location);if(t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function uc(h){if(Yt&&typeof Buffer<"u"&&h instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(h instanceof Uint8Array&&h.byteLength===h.buffer.byteLength)return h;if(typeof h=="string")return Ei(h);if(h instanceof ArrayBuffer||ArrayBuffer.isView(h)||typeof h=="object"&&!isNaN(h?.length))return new Uint8Array(h);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Bs(h){if(typeof h!="string")return null;if(h.endsWith("/"))return h;throw new Error(`Invalid factory url: "${h}" must include trailing slash.`)}const ir=h=>typeof h=="object"&&Number.isInteger(h?.num)&&h.num>=0&&Number.isInteger(h?.gen)&&h.gen>=0,fc=h=>typeof h=="object"&&typeof h?.name=="string",pc=Kl.bind(null,ir,fc);function gc(h,t){const e=URL.parse(h);if(!e?.origin||e.origin==="null")return!1;const s=new URL(t,e);return e.origin===s.origin}function va(h){if(!gc(window.location,h)){const t=`await import("${new URL(h,window.location).href}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}return h}class mc{#t=new Map;#e=Promise.resolve();postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};this.#e.then(()=>{for(const[i]of this.#t)i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if(s?.signal instanceof AbortSignal){const{signal:r}=s;if(r.aborted){z("LoopbackPort - cannot use an `aborted` signal.");return}const n=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",n),r.addEventListener("abort",n)}this.#t.set(e,i)}removeEventListener(t,e){this.#t.get(e)?.(),this.#t.delete(e)}terminate(){for(const[,t]of this.#t)t?.();this.#t.clear()}}class hn{#t=new Map;times=[];time(t){this.#t.has(t)&&z(`Timer is already running for ${t}`),this.#t.set(t,Date.now())}timeEnd(t){this.#t.has(t)||z(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.#t.get(t),end:Date.now()}),this.#t.delete(t)}toString(){const t=Math.max(...this.times.map(e=>e.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms
4
+ `).join("")}}const vc=`
5
+ struct Uniforms {
6
+ offsetX : f32,
7
+ offsetY : f32,
8
+ scaleX : f32,
9
+ scaleY : f32,
10
+ paddedWidth : f32,
11
+ paddedHeight : f32,
12
+ borderSize : f32,
13
+ _pad : f32,
14
+ };
15
+
16
+ @group(0) @binding(0) var<uniform> u : Uniforms;
17
+
18
+ struct VertexInput {
19
+ @location(0) position : vec2<f32>,
20
+ @location(1) color : vec4<f32>,
21
+ };
22
+
23
+ struct VertexOutput {
24
+ @builtin(position) position : vec4<f32>,
25
+ @location(0) color : vec3<f32>,
26
+ };
27
+
28
+ @vertex
29
+ fn vs_main(in : VertexInput) -> VertexOutput {
30
+ var out : VertexOutput;
31
+ let cx = (in.position.x + u.offsetX) * u.scaleX;
32
+ let cy = (in.position.y + u.offsetY) * u.scaleY;
33
+ out.position = vec4<f32>(
34
+ ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
35
+ 1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
36
+ 0.0,
37
+ 1.0
38
+ );
39
+ out.color = in.color.rgb;
40
+ return out;
41
+ }
42
+
43
+ @fragment
44
+ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
45
+ return vec4<f32>(in.color, 1.0);
46
+ }
47
+ `;class yc{#t=null;#e=null;#s=null;#i=null;async#r(){if(!globalThis.navigator?.gpu)return!1;try{const t=await navigator.gpu.requestAdapter();return t?(this.#i=navigator.gpu.getPreferredCanvasFormat(),this.#e=await t.requestDevice(),!0):!1}catch{return!1}}init(){return this.#t||=this.#r()}get isReady(){return this.#e!==null}loadMeshShader(){if(!this.#e||this.#s)return;const t=this.#e.createShaderModule({code:vc});this.#s=this.#e.createRenderPipeline({layout:"auto",vertex:{module:t,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:t,entryPoint:"fs_main",targets:[{format:this.#i}]},primitive:{topology:"triangle-list"}})}draw(t,e,s,i,r,n,a,o){this.loadMeshShader();const l=this.#e,{offsetX:c,offsetY:d,scaleX:u,scaleY:f}=i,p=l.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&l.queue.writeBuffer(p,0,t);const g=l.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&l.queue.writeBuffer(g,0,e);const m=l.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l.queue.writeBuffer(m,0,new Float32Array([c,d,u,f,n,a,o,0]));const v=l.createBindGroup({layout:this.#s.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:m}}]}),b=new OffscreenCanvas(n,a),y=b.getContext("webgpu");y.configure({device:l,format:this.#i,alphaMode:r?"opaque":"premultiplied"});const w=r?{r:r[0]/255,g:r[1]/255,b:r[2]/255,a:1}:{r:0,g:0,b:0,a:0},A=l.createCommandEncoder(),_=A.beginRenderPass({colorAttachments:[{view:y.getCurrentTexture().createView(),clearValue:w,loadOp:"clear",storeOp:"store"}]});return s>0&&(_.setPipeline(this.#s),_.setBindGroup(0,v),_.setVertexBuffer(0,p),_.setVertexBuffer(1,g),_.draw(s)),_.end(),l.queue.submit([A.finish()]),p.destroy(),g.destroy(),m.destroy(),b.transferToImageBitmap()}}const xi=new yc;function ya(){return xi.init()}function ba(){return xi.isReady}function bc(){xi.loadMeshShader()}function wc(h,t,e,s,i,r,n,a){return xi.draw(h,t,e,s,i,r,n,a)}Sl();const Us={DATA:1,ERROR:2},St={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function dn(){}function $t(h){if(h instanceof Pe||h instanceof qi||h instanceof Ki||h instanceof Qs||h instanceof Ns)return h;if(typeof h!="object"||h===null)return new Ns(String(h),String(h));switch(h.name){case"AbortException":return new Pe(h.message);case"InvalidPDFException":return new qi(h.message);case"PasswordException":return new Ki(h.message,h.code);case"ResponseException":return new Qs(h.message,h.status,h.missing);case"UnknownErrorException":return new Ns(h.message,h.details)}return new Ns(h.message,h.toString())}class xe{#t=new Map;#e=new Map;#s=1;#i;#r=new AbortController;#n;#a=new Map;#o=1;#l=new Map;#c;constructor(t,e,s){this.#n=t,this.#c=e,this.#i=s,s.addEventListener("message",this.#u.bind(this),{signal:this.#r.signal})}#u({data:t}){if(t.targetName!==this.#n)return;if(t.stream){this.#f(t);return}if(t.callback){const{callbackId:s,callback:i}=t,r=this.#e.get(s);if(!r)throw new Error(`Cannot resolve callback ${s}`);if(this.#e.delete(s),i===Us.DATA)r.resolve(t.data);else if(i===Us.ERROR)r.reject($t(t.reason));else throw new Error("Unexpected callback case");return}const e=this.#t.get(t.action);if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.#n,i=t.sourceName,r=this.#i;Promise.try(e,t.data).then(n=>{r.postMessage({sourceName:s,targetName:i,callback:Us.DATA,callbackId:t.callbackId,data:n})}).catch(n=>{r.postMessage({sourceName:s,targetName:i,callback:Us.ERROR,callbackId:t.callbackId,reason:$t(n)})});return}if(t.streamId){this.#h(t);return}e(t.data)}on(t,e){const s=this.#t;if(s.has(t))throw new Error(`There is already a "${t}" handler.`);s.set(t,e)}send(t,e,s){this.#i.postMessage({sourceName:this.#n,targetName:this.#c,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.#s++,r=Promise.withResolvers();this.#e.set(i,r);try{this.#i.postMessage({sourceName:this.#n,targetName:this.#c,action:t,callbackId:i,data:e},s)}catch(n){r.reject(n)}return r.promise}sendWithStream(t,e,s,i){const r=this.#o++,n=this.#n,a=this.#c,o=this.#i;return new ReadableStream({start:l=>{const c=Promise.withResolvers();return this.#a.set(r,{controller:l,startCall:c,pullCall:null,cancelCall:null,isClosed:!1}),o.postMessage({sourceName:n,targetName:a,action:t,streamId:r,data:e,desiredSize:l.desiredSize},i),c.promise},pull:l=>{const c=Promise.withResolvers();return this.#a.get(r).pullCall=c,o.postMessage({sourceName:n,targetName:a,stream:St.PULL,streamId:r,desiredSize:l.desiredSize}),c.promise},cancel:l=>{_t(l instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.#a.get(r).cancelCall=c,this.#a.get(r).isClosed=!0,o.postMessage({sourceName:n,targetName:a,stream:St.CANCEL,streamId:r,reason:$t(l)}),c.promise}},s)}#h(t){const e=t.streamId,s=this.#n,i=t.sourceName,r=this.#i,n=this.#l,a=this.#t.get(t.action),o={enqueue(l,c=1,d){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=c,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:i,stream:St.ENQUEUE,streamId:e,chunk:l},d)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:St.CLOSE,streamId:e}),n.delete(e))},error(l){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:St.ERROR,streamId:e,reason:$t(l)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,n.set(e,o),Promise.try(a,t.data,o).then(()=>{r.postMessage({sourceName:s,targetName:i,stream:St.START_COMPLETE,streamId:e,success:!0})},l=>{r.postMessage({sourceName:s,targetName:i,stream:St.START_COMPLETE,streamId:e,reason:$t(l)})})}#f(t){const e=t.streamId,s=this.#n,i=t.sourceName,r=this.#i,n=this.#a.get(e),a=this.#l.get(e);switch(t.stream){case St.START_COMPLETE:t.success?n.startCall.resolve():n.startCall.reject($t(t.reason));break;case St.PULL_COMPLETE:t.success?n.pullCall.resolve():n.pullCall.reject($t(t.reason));break;case St.PULL:if(!a){r.postMessage({sourceName:s,targetName:i,stream:St.PULL_COMPLETE,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||dn).then(()=>{r.postMessage({sourceName:s,targetName:i,stream:St.PULL_COMPLETE,streamId:e,success:!0})},l=>{r.postMessage({sourceName:s,targetName:i,stream:St.PULL_COMPLETE,streamId:e,reason:$t(l)})});break;case St.ENQUEUE:if(_t(n,"enqueue should have stream controller"),n.isClosed)break;n.controller.enqueue(t.chunk);break;case St.CLOSE:if(_t(n,"close should have stream controller"),n.isClosed)break;n.isClosed=!0,n.controller.close(),this.#p(n,e);break;case St.ERROR:_t(n,"error should have stream controller"),n.controller.error($t(t.reason)),this.#p(n,e);break;case St.CANCEL_COMPLETE:t.success?n.cancelCall.resolve():n.cancelCall.reject($t(t.reason)),this.#p(n,e);break;case St.CANCEL:if(!a)break;const o=$t(t.reason);Promise.try(a.onCancel||dn,o).then(()=>{r.postMessage({sourceName:s,targetName:i,stream:St.CANCEL_COMPLETE,streamId:e,success:!0})},l=>{r.postMessage({sourceName:s,targetName:i,stream:St.CANCEL_COMPLETE,streamId:e,reason:$t(l)})}),a.sinkCapability.reject(o),a.isCancelled=!0,this.#l.delete(e);break;default:throw new Error("Unexpected stream case")}}async#p(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),this.#a.delete(e)}destroy(){this.#r?.abort(),this.#r=null}get destroyed(){return!this.#r}}class wa{#t=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:s=null}){this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=s}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:nt(`Not implemented: ${t}`)}const s=this[t];if(!s)throw new Error(`Ensure that the \`${t}\` API parameter is provided.`);const i=`${s}${e}`;return this._fetch(i,t).catch(r=>{throw new Error(`Unable to load ${this.#t[t]} data at: ${i}`)})}async _fetch(t,e){nt("Abstract method `_fetch` called.")}}class un extends wa{async _fetch(t,e){const s=e==="cMapUrl"&&!t.endsWith(".bcmap")?"text":"bytes",i=await Cr(t,s);return i instanceof Uint8Array?i:Ei(i)}}class _a{#t=!1;constructor({enableHWA:t=!1}){this.#t=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!this.#t})}}reset({canvas:t},e,s){if(!t)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.width=e,t.height=s}destroy(t){const{canvas:e}=t;if(!e)throw new Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}getNoAlphaContext(t){return t.getContext("2d",{alpha:!1,willReadFrequently:!this.#t})}_createCanvas(t,e){nt("Abstract method `_createCanvas` called.")}}class Aa{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addKnockoutFilter(t=0){return"none"}addHighlightHCMFilter(t,e,s,i,r){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}if(Yt){let h;try{const t=process.getBuiltinModule("module").createRequire(import.meta.url);try{h=t("@napi-rs/canvas")}catch(e){z(`Cannot load "@napi-rs/canvas" package: "${e}".`)}}catch(t){z(`Cannot access the \`require\` function: "${t}".`)}globalThis.DOMMatrix||(h?.DOMMatrix?globalThis.DOMMatrix=h.DOMMatrix:z("Cannot polyfill `DOMMatrix`, rendering may be broken.")),globalThis.Path2D||(h?.Path2D?globalThis.Path2D=h.Path2D:z("Cannot polyfill `Path2D`, rendering may be broken.")),globalThis.navigator?.language||(globalThis.navigator={language:"en-US",platform:"",userAgent:""})}async function _c(h){const e=await process.getBuiltinModule("fs/promises").readFile(h);return new Uint8Array(e)}class Ac extends Aa{}class Sc extends _a{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class Ec extends wa{async _fetch(t,e){return _c(t)}}fl();const Ze="__forcedDependency",{floor:fn,ceil:pn}=Math;function gn(h,t,e,s,i,r){h[t*4+0]=Math.min(h[t*4+0],e),h[t*4+1]=Math.min(h[t*4+1],s),h[t*4+2]=Math.max(h[t*4+2],i),h[t*4+3]=Math.max(h[t*4+3],r)}function Tc(h,t,e,s,i){let r;h?(h<0&&(r=i[0],i[0]=i[2],i[2]=r),i[0]*=h,i[2]*=h,t<0&&(r=i[1],i[1]=i[3],i[3]=r),i[1]*=t,i[3]*=t):i.fill(0),i[0]+=e,i[1]+=s,i[2]+=e,i[3]+=s}const rr=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class Ci{#t;#e;constructor(t,e){this.#t=t,this.#e=e}static fromBuffer(t){return new Ci(new Uint32Array(t),new Uint8ClampedArray(t))}get buffer(){return this.#t.buffer}get length(){return this.#t.length}isEmpty(t){return this.#t[t]===rr}minX(t){return this.#e[t*4+0]/256}minY(t){return this.#e[t*4+1]/256}maxX(t){return(this.#e[t*4+2]+1)/256}maxY(t){return(this.#e[t*4+3]+1)/256}}const mn=(h,t)=>h?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));class xc{#t=[[1,0,0,1,0,0]];#e=[-1/0,-1/0,1/0,1/0];#s=new Float64Array(ue);_pendingBBoxIdx=-1;#i;#r;#n;#a;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#i=t.width,this.#r=t.height,this.#o(e)}growOperationsCount(t){t>=this.#a.length&&this.#o(t,this.#a)}#o(t,e){const s=new ArrayBuffer(t*4);this.#n=new Uint8ClampedArray(s),this.#a=new Uint32Array(s),e&&e.length>0?(this.#a.set(e),this.#a.fill(rr,e.length)):this.#a.fill(rr)}get clipBox(){return this.#e}save(t){return this.#e={__proto__:this.#e},this._savesStack.push(t),this}restore(t,e){const s=Object.getPrototypeOf(this.#e);if(s===null)return this;this.#e=s;const i=this._savesStack.pop();return i!==void 0&&(e?.(i,t),this.#a[t]=this.#a[i]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return this._savesStack.length===0?null:this._savesStack.at(-1)}recordCloseMarker(t,e){const s=this._savesStack.pop();return s!==void 0&&(e?.(s,t),this.#a[t]=this.#a[s]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){const s=this._markedContentStack.pop();return s!==void 0&&(e?.(s,t),this.#a[t]=this.#a[s]),this}pushBaseTransform(t){return this.#t.push(D.multiplyByDOMMatrix(this.#t.at(-1),t.getTransform())),this}popBaseTransform(){return this.#t.length>1&&this.#t.pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,this.#s.set(ue,0)),this}recordClipBox(t,e,s,i,r,n){const a=D.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform()),o=ue.slice();D.axialAlignedBoundingBox([s,r,i,n],a,o);const l=D.intersect(this.#e,o);return l?(this.#e[0]=l[0],this.#e[1]=l[1],this.#e[2]=l[2],this.#e[3]=l[3]):(this.#e[0]=this.#e[1]=1/0,this.#e[2]=this.#e[3]=-1/0),this}recordBBox(t,e,s,i,r,n){const a=this.#e;if(a[0]===1/0)return this;const o=D.multiplyByDOMMatrix(this.#t.at(-1),e.getTransform());if(a[0]===-1/0)return D.axialAlignedBoundingBox([s,r,i,n],o,this.#s),this;const l=ue.slice();return D.axialAlignedBoundingBox([s,r,i,n],o,l),this.#s[0]=ft(l[0],a[0],this.#s[0]),this.#s[1]=ft(l[1],a[1],this.#s[1]),this.#s[2]=ft(l[2],this.#s[2],a[2]),this.#s[3]=ft(l[3],this.#s[3],a[3]),this}recordFullPageBBox(t){return this.#s[0]=Math.max(0,this.#e[0]),this.#s[1]=Math.max(0,this.#e[1]),this.#s[2]=Math.min(this.#i,this.#e[2]),this.#s[3]=Math.min(this.#r,this.#e[3]),this}recordOperation(t,e=!1,s){if(this._pendingBBoxIdx!==t)return this;const i=fn(this.#s[0]*256/this.#i),r=fn(this.#s[1]*256/this.#r),n=pn(this.#s[2]*256/this.#i),a=pn(this.#s[3]*256/this.#r);if(gn(this.#n,t,i,r,n,a),s)for(const o of s)for(const l of o)l!==t&&gn(this.#n,l,i,r,n,a);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,this.#e[0]=Math.max(this.#e[0],this.#s[0]),this.#e[1]=Math.max(this.#e[1],this.#s[1]),this.#e[2]=Math.min(this.#e[2],this.#s[2]),this.#e[3]=Math.min(this.#e[3],this.#s[3])),this}take(){return new Ci(this.#a,this.#n)}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(t,e){return this}recordIncrementalData(t,e){return this}resetIncrementalData(t,e){return this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,s,i=1,r=0,n=0,a){return this}getSimpleIndex(t){}recordDependencies(t,e){return this}recordNamedDependency(t,e){return this}recordShowTextOperation(t,e=!1){return this}}class Cc{#t={__proto__:null};#e={__proto__:null,transform:[],moveText:[],sameLineText:[],[Ze]:[]};#s=new Map;#i=new Set;#r=new Map;#n;#a;#o;constructor(t,e=!1){this.#o=t,e&&(this.#n=new Map,this.#a=(s,i)=>{mn(this.#n,i).dependencies.add(s)})}get clipBox(){return this.#o.clipBox}growOperationsCount(t){this.#o.growOperationsCount(t)}save(t){return this.#t={__proto__:this.#t},this.#e={__proto__:this.#e,transform:{__proto__:this.#e.transform},moveText:{__proto__:this.#e.moveText},sameLineText:{__proto__:this.#e.sameLineText},[Ze]:{__proto__:this.#e[Ze]}},this.#o.save(t),this}restore(t){this.#o.restore(t,this.#a);const e=Object.getPrototypeOf(this.#t);return e===null?this:(this.#t=e,this.#e=Object.getPrototypeOf(this.#e),this)}recordOpenMarker(t){return this.#o.recordOpenMarker(t,this.#a),this}getOpenMarker(){return this.#o.getOpenMarker()}recordCloseMarker(t){return this.#o.recordCloseMarker(t,this.#a),this}beginMarkedContent(t){return this.#o.beginMarkedContent(t),this}endMarkedContent(t){return this.#o.endMarkedContent(t,this.#a),this}pushBaseTransform(t){return this.#o.pushBaseTransform(t),this}popBaseTransform(){return this.#o.popBaseTransform(),this}recordSimpleData(t,e){return this.#t[t]=e,this}recordIncrementalData(t,e){return this.#e[t].push(e),this}resetIncrementalData(t,e){return this.#e[t].length=0,this}recordNamedData(t,e){return this.#s.set(t,e),this}recordSimpleDataFromNamed(t,e,s){this.#t[t]=this.#s.get(e)??s}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Ze,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in this.#t&&this.recordFutureForcedDependency(e,this.#t[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of this.#i)this.recordFutureForcedDependency(Ze,t);return this}resetBBox(t){return this.#o.resetBBox(t),this}recordClipBox(t,e,s,i,r,n){return this.#o.recordClipBox(t,e,s,i,r,n),this}recordBBox(t,e,s,i,r,n){return this.#o.recordBBox(t,e,s,i,r,n),this}recordCharacterBBox(t,e,s,i=1,r=0,n=0,a){const o=s.bbox;let l,c;if(o&&(l=o[2]!==o[0]&&o[3]!==o[1]&&this.#r.get(s),l!==!1&&(c=[0,0,0,0],D.axialAlignedBoundingBox(o,s.fontMatrix,c),(i!==1||r!==0||n!==0)&&Tc(i,-i,r,n,c),l)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!a)return this.recordFullPageBBox(t);const d=a();return o&&c&&l===void 0&&(l=c[0]<=r-d.actualBoundingBoxLeft&&c[2]>=r+d.actualBoundingBoxRight&&c[1]<=n-d.actualBoundingBoxAscent&&c[3]>=n+d.actualBoundingBoxDescent,this.#r.set(s,l),l)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,r-d.actualBoundingBoxLeft,r+d.actualBoundingBoxRight,n-d.actualBoundingBoxAscent,n+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#o.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#t[t]}recordDependencies(t,e){const s=this.#i,i=this.#t,r=this.#e;for(const n of e)n in this.#t?s.add(i[n]):n in r&&r[n].forEach(s.add,s);return this}recordNamedDependency(t,e){return this.#s.has(e)&&this.#i.add(this.#s.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Ze]),this.#n){const i=mn(this.#n,t),{dependencies:r}=i;this.#i.forEach(r.add,r),this.#o._savesStack.forEach(r.add,r),this.#o._markedContentStack.forEach(r.add,r),r.delete(t),i.isRenderingOperation=!0}const s=!e&&t===this.#o._pendingBBoxIdx;return this.#o.recordOperation(t,e,[this.#i,this.#o._savesStack,this.#o._markedContentStack]),s&&this.#i.clear(),this}recordShowTextOperation(t,e=!1){const s=Array.from(this.#i);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const i of s)this.recordIncrementalData("sameLineText",i);return this}bboxToClipBoxDropOperation(t,e=!1){const s=!e&&t===this.#o._pendingBBoxIdx;return this.#o.bboxToClipBoxDropOperation(t),s&&this.#i.clear(),this}take(){return this.#r.clear(),this.#o.take()}takeDebugMetadata(){return this.#n}}class Ts{#t;#e;#s;#i=0;#r=0;constructor(t,e,s){if(t instanceof Ts&&t.#s===!!s)return t;this.#t=t,this.#e=e,this.#s=!!s}get clipBox(){return this.#t.clipBox}growOperationsCount(){throw new Error("Unreachable")}save(t){return this.#r++,this.#t.save(this.#e),this}restore(t){return this.#r>0&&(this.#t.restore(this.#e),this.#r--),this}recordOpenMarker(t){return this.#i++,this}getOpenMarker(){return this.#i>0?this.#e:this.#t.getOpenMarker()}recordCloseMarker(t){return this.#i--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#t.pushBaseTransform(t),this}popBaseTransform(){return this.#t.popBaseTransform(),this}recordSimpleData(t,e){return this.#t.recordSimpleData(t,this.#e),this}recordIncrementalData(t,e){return this.#t.recordIncrementalData(t,this.#e),this}resetIncrementalData(t,e){return this.#t.resetIncrementalData(t,this.#e),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,s){return this.#t.recordSimpleDataFromNamed(t,e,this.#e),this}recordFutureForcedDependency(t,e){return this.#t.recordFutureForcedDependency(t,this.#e),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#t.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#t.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#s||this.#t.resetBBox(this.#e),this}recordClipBox(t,e,s,i,r,n){return this.#s||this.#t.recordClipBox(this.#e,e,s,i,r,n),this}recordBBox(t,e,s,i,r,n){return this.#s||this.#t.recordBBox(this.#e,e,s,i,r,n),this}recordCharacterBBox(t,e,s,i,r,n,a){return this.#s||this.#t.recordCharacterBBox(this.#e,e,s,i,r,n,a),this}recordFullPageBBox(t){return this.#s||this.#t.recordFullPageBBox(this.#e),this}getSimpleIndex(t){return this.#t.getSimpleIndex(t)}recordDependencies(t,e){return this.#t.recordDependencies(this.#e,e),this}recordNamedDependency(t,e){return this.#t.recordNamedDependency(this.#e,e),this}recordOperation(t){return this.#t.recordOperation(this.#e,!0),this}recordShowTextOperation(t){return this.#t.recordShowTextOperation(this.#e,!0),this}bboxToClipBoxDropOperation(t){return this.#s||this.#t.bboxToClipBoxDropOperation(this.#e,!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const Zt={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","filter","fillColor"]};class ti{#t;#e;#s=4;#i=0;#r=new ti.#n(this.#s*6);static#n=ot.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#t=t.width,this.#e=t.height}record(t,e,s,i){if(this.#i===this.#s){this.#s*=2;const a=new ti.#n(this.#s*6);a.set(this.#r),this.#r=a}const r=ut(t);let n;if(i[0]!==1/0){const a=ue.slice();D.axialAlignedBoundingBox([0,-s,e,0],r,a);const o=D.intersect(i,a);if(!o)return;const[l,c,d,u]=o;if(l!==a[0]||c!==a[1]||d!==a[2]||u!==a[3]){const f=Math.atan2(r[1],r[0]),p=Math.abs(Math.sin(f)),g=Math.abs(Math.cos(f));if(p<1e-6||g<1e-6||Math.abs(p-g)<1e-6)n=[l,c,l,u,d,c];else{const m=d-l,v=u-c,b=p*p,y=g*g,w=g*p,A=y-b,_=(v*y-m*w)/A,E=(v*w-m*b)/A;n=[l+E,c,l,c+_,d,u-_]}}}n||(n=[0,-s,0,0,e,-s],D.applyTransform(n,r,0),D.applyTransform(n,r,2),D.applyTransform(n,r,4)),n[0]/=this.#t,n[1]/=this.#e,n[2]/=this.#t,n[3]/=this.#e,n[4]/=this.#t,n[5]/=this.#e,this.#r.set(n,this.#i*6),this.#i++}take(){return this.#r.subarray(0,this.#i*6)}}function Pc(h,t,{recordOperations:e=!1,recordImages:s=!1,recordDebugMetadata:i=!1}){const r=e||s?new xc(h,t):null;return{dependencyTracker:e?new Cc(r,i):r,imagesTracker:s?new ti(h):null}}function Sa({src:h,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:n=!1}){const a=ot.isLittleEndian?4278190080:255,[o,l]=n?[r,a]:[a,r],c=s>>3,d=s&7,u=o^l,f=h.length;e=new Uint32Array(e.buffer);let p=0;for(let g=0;g<i;++g){for(const v=t+c;t<v;++t,p+=8){const b=h[t];e[p]=o^-(b>>7&1)&u,e[p+1]=o^-(b>>6&1)&u,e[p+2]=o^-(b>>5&1)&u,e[p+3]=o^-(b>>4&1)&u,e[p+4]=o^-(b>>3&1)&u,e[p+5]=o^-(b>>2&1)&u,e[p+6]=o^-(b>>1&1)&u,e[p+7]=o^-(b&1)&u}if(d===0)continue;const m=t<f?h[t++]:255;for(let v=0;v<d;++v,++p)e[p]=o^-(m>>7-v&1)&u}return{srcPos:t,destPos:p}}function Ic({src:h,srcPos:t=0,dest:e,destPos:s=0,width:i,height:r}){let n=0;const a=i*r*3,o=h.byteOffset+t,l=o%4===0?Math.floor(ft(h.length-t,0,a)/4):0,c=l>0?new Uint32Array(h.buffer,o,l):null,d=ot.isLittleEndian?4278190080:255;if(ot.isLittleEndian){for(;n<l-2;n+=3,s+=4){const u=c[n],f=c[n+1],p=c[n+2];e[s]=u|d,e[s+1]=u>>>24|f<<8|d,e[s+2]=f>>>16|p<<16|d,e[s+3]=p>>>8|d}for(let u=t+n*4,f=t+a;u<f;u+=3)e[s++]=h[u]|h[u+1]<<8|h[u+2]<<16|d}else{for(;n<l-2;n+=3,s+=4){const u=c[n],f=c[n+1],p=c[n+2];e[s]=u|d,e[s+1]=u<<24|f>>>8|d,e[s+2]=f<<16|p>>>16|d,e[s+3]=p<<8|d}for(let u=t+n*4,f=t+a;u<f;u+=3)e[s++]=h[u]<<24|h[u+1]<<16|h[u+2]<<8|d}return{srcPos:t+a,destPos:s}}const Tt={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Xs(h,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),h.clip(i)}class Mr{matrix=null;isModifyingCurrentTransform(){return!1}getPattern(){nt("Abstract method `getPattern` called.")}}class kc extends Mr{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]}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}areConic(){if(!this.isRadial())return!1;const t=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return t+this._r1>this._r0&&t+this._r0>this._r1}_createGradient(t,e=null){let s,i=this._p0,r=this._p1;if(e&&(i=i.slice(),r=r.slice(),D.applyTransform(i,e),D.applyTransform(r,e)),this._type==="axial")s=t.createLinearGradient(i[0],i[1],r[0],r[1]);else if(this._type==="radial"){let n=this._r0,a=this._r1;if(e){const o=new Float32Array(2);D.singularValueDecompose2dScale(e,o),n*=o[0],a*=o[0]}s=t.createRadialGradient(i[0],i[1],n,r[0],r[1],a)}for(const n of this._colorStops)s.addColorStop(n[0],n[1]);return s}_createReversedGradient(t,e=null){let s=this._p1,i=this._p0;e&&(s=s.slice(),i=i.slice(),D.applyTransform(s,e),D.applyTransform(i,e));let r=this._r1,n=this._r0;if(e){const l=new Float32Array(2);D.singularValueDecompose2dScale(e,l),r*=l[0],n*=l[0]}const a=t.createRadialGradient(s[0],s[1],r,i[0],i[1],n),o=this._colorStops.map(([l,c])=>[1-l,c]).reverse();for(const[l,c]of o)a.addColorStop(l,c);return a}_createRasterPattern(t,e,s,i,r,n){const a=Math.ceil(i[2]-i[0])||1,o=Math.ceil(i[3]-i[1])||1,l=e.canvasFactory.create(a,o),c=l.context;c.clearRect(0,0,a,o),c.beginPath(),c.rect(0,0,a,o),c.translate(-i[0],-i[1]),s=D.transform(s,[1,0,0,1,i[0],i[1]]),c.transform(...r),Xs(c,this._bbox),this.areConic()&&(c.fillStyle=this._createReversedGradient(c),c.fill()),c.fillStyle=this._createGradient(c),c.fill(),n?.applyToCanvas(c);const d=t.createPattern(l.canvas,"no-repeat");return e.canvasFactory.destroy(l),d.setTransform(new DOMMatrix(s)),d}getPattern(t,e,s,i){const r=e.current.transferMapsFallback;if(i===Tt.STROKE||i===Tt.FILL){if(this.isOriginBased()&&!r){let o=D.transform(s,e.baseTransform);this.matrix&&(o=D.transform(o,this.matrix));const l=.001,c=Math.hypot(o[0],o[1]),d=Math.hypot(o[2],o[3]),u=(o[0]*o[2]+o[1]*o[3])/(c*d);if(Math.abs(u)<l)if(this.isRadial()){if(Math.abs(c-d)<l)return this._createGradient(t,o)}else return this._createGradient(t,o)}const n=e.current.getClippedPathBoundingBox(i,ut(t))||[0,0,0,0],a=this.matrix?D.transform(e.baseTransform,this.matrix):e.baseTransform;return this._createRasterPattern(t,e,s,n,a,r)}return r&&s?this._createRasterPattern(t,e,s,e.current.clipBox,ut(t),r):(this.areConic()&&(t.save(),Xs(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),Xs(t,this._bbox),this._createGradient(t))}}function Oc(h,t,e,s,i,r,n,a){const o=t.coords,l=t.colors,c=h.data,d=h.width*4;let u;o[e*2+1]>o[s*2+1]&&(u=e,e=s,s=u,u=r,r=n,n=u),o[s*2+1]>o[i*2+1]&&(u=s,s=i,i=u,u=n,n=a,a=u),o[e*2+1]>o[s*2+1]&&(u=e,e=s,s=u,u=r,r=n,n=u);const f=(o[e*2]+t.offsetX)*t.scaleX,p=(o[e*2+1]+t.offsetY)*t.scaleY,g=(o[s*2]+t.offsetX)*t.scaleX,m=(o[s*2+1]+t.offsetY)*t.scaleY,v=(o[i*2]+t.offsetX)*t.scaleX,b=(o[i*2+1]+t.offsetY)*t.scaleY;if(p>=b)return;const y=l[r*4],w=l[r*4+1],A=l[r*4+2],_=l[n*4],E=l[n*4+1],x=l[n*4+2],T=l[a*4],C=l[a*4+1],P=l[a*4+2],k=Math.round(p),R=Math.round(b);let B,U,M,O,V,q,Q,Z;for(let K=k;K<=R;K++){if(K<m){const W=K<p?0:(p-K)/(p-m);B=f-(f-g)*W,U=y-(y-_)*W,M=w-(w-E)*W,O=A-(A-x)*W}else{let W;K>b?W=1:m===b?W=0:W=(m-K)/(m-b),B=g-(g-v)*W,U=_-(_-T)*W,M=E-(E-C)*W,O=x-(x-P)*W}let F;K<p?F=0:K>b?F=1:F=(p-K)/(p-b),V=f-(f-v)*F,q=y-(y-T)*F,Q=w-(w-C)*F,Z=A-(A-P)*F;const I=Math.round(Math.min(B,V)),N=Math.round(Math.max(B,V));let G=d*K+I*4;for(let W=I;W<=N;W++)F=(B-W)/(B-V),F<0?F=0:F>1&&(F=1),c[G++]=U-(U-q)*F|0,c[G++]=M-(M-Q)*F|0,c[G++]=O-(O-Z)*F|0,c[G++]=255}}class Mc extends Mr{constructor(t){super(),this._posData=t[2],this._colData=t[3],this._vertexCount=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],bc()}_createMeshCanvas(t,e,s,i=null){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),c=Math.ceil(this._bounds[2])-o,d=Math.ceil(this._bounds[3])-l,u=Math.min(Math.ceil(Math.abs(c*t[0]*1.1)),3e3)||1,f=Math.min(Math.ceil(Math.abs(d*t[1]*1.1)),3e3)||1,p=c?c/u:1,g=d?d/f:1,m={coords:this._posData,colors:this._colData,offsetX:-o,offsetY:-l,scaleX:1/p,scaleY:1/g},v=u+4,b=f+4,y=s.create(v,b);if(ba()&&this._vertexCount>48)y.context.drawImage(wc(this._posData,this._colData,this._vertexCount,m,e,v,b,2),0,0);else{const w=y.context.createImageData(u,f);if(e){const A=w.data;for(let _=0,E=A.length;_<E;_+=4)A[_]=e[0],A[_+1]=e[1],A[_+2]=e[2],A[_+3]=255}for(let A=0,_=this._vertexCount;A<_;A+=3)Oc(w,m,A,A+1,A+2,A,A+1,A+2);y.context.putImageData(w,2,2)}return i?.applyToCanvas(y.context),{canvas:y.canvas,offsetX:o-2*p,offsetY:l-2*g,scaleX:p,scaleY:g}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){Xs(t,this._bbox);const r=new Float32Array(2);if(i===Tt.SHADING)D.singularValueDecompose2dScale(ut(t),r);else if(this.matrix){D.singularValueDecompose2dScale(this.matrix,r);const[o,l]=r;D.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=o,r[1]*=l}else D.singularValueDecompose2dScale(e.baseTransform,r);const n=this._createMeshCanvas(r,i===Tt.SHADING?null:this._background,e.canvasFactory,e.current.transferMapsFallback);i!==Tt.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(n.offsetX,n.offsetY),t.scale(n.scaleX,n.scaleY);const a=t.createPattern(n.canvas,"no-repeat");return e.canvasFactory.destroy(n),a}}class Fc extends Mr{getPattern(){return"hotpink"}}function Rc(h){switch(h[0]){case"RadialAxial":return new kc(h);case"Mesh":return new Mc(h);case"Dummy":return new Fc}throw new Error(`Unknown IR type: ${h[0]}`)}const vn={COLORED:1,UNCOLORED:2};class _s{static MAX_PATTERN_SIZE=3e3;constructor(t,e,s,i){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.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i,this.patternBaseMatrix=this.matrix?D.transform(i,this.matrix):i}canSkipPatternCanvas([t,e,s,i]){const[r,n,a,o]=this.bbox,l=Math.abs(this.xstep),c=Math.abs(this.ystep);if(t>l+1e-6||e>c+1e-6)return null;const d=Math.floor((s-a)/l)+1,u=Math.ceil((s+t-r)/l)-1,f=Math.floor((i-o)/c)+1,p=Math.ceil((i+e-n)/c)-1;return u<=d&&p<=f?[d,f]:null}updatePatternDims(t,e){const s=ue.slice();D.axialAlignedBoundingBox(t,D.inverseTransform(this.patternBaseMatrix),s),e[0]=s[2]-s[0],e[1]=s[3]-s[1],e[2]=s[0],e[3]=s[1]}_renderTileCanvas(t,e,s,i){const[r,n,a,o]=this.bbox,l=t.canvasFactory.create(s.size,i.size),c=l.context,d=this.canvasGraphicsFactory.createCanvasGraphics(c,e);return d.groupLevel=t.groupLevel,d.current.transferMapsFallback=t.current.transferMapsFallback,this.setFillAndStrokeStyleToContext(d,this.paintType,this.color),c.translate(-s.scale*r,-i.scale*n),d.transform(0,s.scale,0,0,i.scale,0,0),c.save(),d.dependencyTracker?.save(),this.clipBbox(d,r,n,a,o),d.baseTransform=ut(d.ctx),d.executeOperatorList(this.operatorList),d.endDrawing(),d.dependencyTracker?.restore(),c.restore(),l}_getCombinedScales(){const t=new Float32Array(2);D.singularValueDecompose2dScale(this.matrix,t);const[e,s]=t;return D.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],s*t[1]]}drawPattern(t,e,s=!1,[i,r],n){const[a,o,l,c]=this.bbox,d=t.dependencyTracker;d&&(t.dependencyTracker=new Ts(d,n));try{if(t.save(),s?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(i*this.xstep,r*this.ystep),this.needsIsolation||t.ctx.globalAlpha!==1||t.ctx.globalCompositeOperation!=="source-over"||t.inSMaskMode){const u=l-a,f=c-o,[p,g]=this._getCombinedScales(),m=this.getSizeAndScale(u,this.ctx.canvas.width,p),v=this.getSizeAndScale(f,this.ctx.canvas.height,g),b=this._renderTileCanvas(t,n,m,v);t.ctx.drawImage(b.canvas,a,o,u,f),t.canvasFactory.destroy(b)}else t.resetGraphicsState(),this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,a,o,l,c),t.baseTransformStack.push(t.baseTransform),t.baseTransform=ut(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore()}finally{d&&(t.dependencyTracker=d)}}createPatternCanvas(t,e){const[s,i,r,n]=this.bbox,a=r-s,o=n-i;let{xstep:l,ystep:c}=this;l=Math.abs(l),c=Math.abs(c),Si("TilingType: "+this.tilingType);const[d,u]=this._getCombinedScales();let f=a,p=o,g=!1,m=!1;Math.ceil(l*d)>=Math.ceil(a*d)?f=l:g=!0,Math.ceil(c*u)>=Math.ceil(o*u)?p=c:m=!0;const v=this.getSizeAndScale(f,this.ctx.canvas.width,d),b=this.getSizeAndScale(p,this.ctx.canvas.height,u),y=this._renderTileCanvas(t,e,v,b);if(g||m){const w=y.canvas;g&&(f=l),m&&(p=c);const A=this.getSizeAndScale(f,this.ctx.canvas.width,d),_=this.getSizeAndScale(p,this.ctx.canvas.height,u),E=A.size,x=_.size,T=t.canvasFactory.create(E,x),C=T.context,P=g?Math.min(Math.floor(a/l),Math.ceil(w.width/E)):0,k=m?Math.min(Math.floor(o/c),Math.ceil(w.height/x)):0;let R=w,B=null;if(m){B=t.canvasFactory.create(w.width,x);const U=B.context;for(let M=k;M>=0;M--)U.drawImage(w,0,x*M,w.width,x,0,0,w.width,x);R=B.canvas}for(let U=P;U>=0;U--)C.drawImage(R,E*U,0,E,x,0,0,E,x);return B&&t.canvasFactory.destroy(B),t.canvasFactory.destroy(y),{canvas:T.canvas,canvasEntry:T,scaleX:A.scale,scaleY:_.scale,offsetX:s,offsetY:i}}return{canvas:y.canvas,canvasEntry:y,scaleX:v.scale,scaleY:b.scale,offsetX:s,offsetY:i}}getSizeAndScale(t,e,s){const i=Math.max(_s.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*s);return r>=i?r=i:s=r/t,{scale:s,size:r}}clipBbox(t,e,s,i,r){const n=i-e,a=r-s,o=new Path2D;o.rect(e,s,n,a),D.axialAlignedBoundingBox([e,s,i,r],ut(t.ctx),t.current.minMax),t.ctx.clip(o),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,s){switch(e){case vn.COLORED:s="#000000";break;case vn.UNCOLORED:break;default:throw new zl(`Unsupported paint type: ${e}`)}const{ctx:i,current:r}=t;r.patternFill=r.patternStroke=!1,i.fillStyle=i.strokeStyle=r.transferMapsFallback?.applyToColor(s)??s,r.fillColor=r.strokeColor=s}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i,r){const n=i!==Tt.SHADING?D.transform(s,this.patternBaseMatrix):s,a=this.createPatternCanvas(e,r);let o=new DOMMatrix(n);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);const l=t.createPattern(a.canvas,"repeat");return e.canvasFactory.destroy(a.canvasEntry),l.setTransform(o),l}}const Dc=16,Nc=100,Lc=15,yn=10,Gt=16,qt=new Float32Array(2);function bn(h,t){if(h._removeMirroring)throw new Error("Context is already forwarding operations.");const e=new Map;for(const s of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){const i=h[s];typeof i!="function"||typeof t[s]!="function"||(e.set(s,i),h[s]=function(...r){return t[s](...r),i.apply(this,r)})}h._removeMirroring=()=>{for(const[s,i]of e)h[s]=i;delete h._removeMirroring}}function js(h,t,e,s,i,r,n,a,o,l){const[c,d,u,f,p,g]=ut(h);if(d===0&&u===0){const b=n*c+p,y=Math.round(b),w=a*f+g,A=Math.round(w),_=(n+o)*c+p,E=Math.abs(Math.round(_)-y)||1,x=(a+l)*f+g,T=Math.abs(Math.round(x)-A)||1;return h.setTransform(Math.sign(c),0,0,Math.sign(f),y,A),h.drawImage(t,e,s,i,r,0,0,E,T),h.setTransform(c,d,u,f,p,g),[E,T]}if(c===0&&f===0){const b=a*u+p,y=Math.round(b),w=n*d+g,A=Math.round(w),_=(a+l)*u+p,E=Math.abs(Math.round(_)-y)||1,x=(n+o)*d+g,T=Math.abs(Math.round(x)-A)||1;return h.setTransform(0,Math.sign(d),Math.sign(u),0,y,A),h.drawImage(t,e,s,i,r,0,0,T,E),h.setTransform(c,d,u,f,p,g),[T,E]}h.drawImage(t,e,s,i,r,n,a,o,l);const m=Math.hypot(c,d),v=Math.hypot(u,f);return[m*o,v*l]}class $i{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=Xi;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=Et.FILL;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";transferMapsFallback=null;minMax=Le.slice();constructor(t,e){this.clipBox=new Float32Array([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=this.tilingPatternDims?.slice(),t}getPathBoundingBox(t=Tt.FILL,e=null){const s=this.minMax.slice();if(t===Tt.STROKE){e||nt("Stroke bounding box must include transform."),D.singularValueDecompose2dScale(e,qt);const i=qt[0]*this.lineWidth/2,r=qt[1]*this.lineWidth/2;s[0]-=i,s[1]-=r,s[2]+=i,s[3]+=r}return s}updateClipFromPath(){const t=D.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(Le,0)}getClippedPathBoundingBox(t=Tt.FILL,e=null){return D.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function wn(h,t){const{width:e,height:s,kind:i}=t,r=s%Gt,n=(s-r)/Gt,a=r===0?n:n+1,o=h.createImageData(e,Gt);let l=0;const c=t.data,d=o.data;let u;if(i===Vs.GRAYSCALE_1BPP)for(u=0;u<a;u++)({srcPos:l}=Sa({src:c,srcPos:l,dest:d,width:e,height:u<n?Gt:r})),h.putImageData(o,0,u*Gt);else if(i===Vs.RGBA_32BPP){let f=0,p=e*Gt*4;for(u=0;u<n;u++)d.set(c.subarray(l,l+p)),l+=p,h.putImageData(o,0,f),f+=Gt;u<a&&(p=e*r*4,d.set(c.subarray(l,l+p)),h.putImageData(o,0,f))}else if(i===Vs.RGB_24BPP)for(u=0;u<a;u++)({srcPos:l}=Ic({src:c,srcPos:l,dest:new Uint32Array(d.buffer),width:e,height:u<n?Gt:r})),h.putImageData(o,0,u*Gt);else throw new Error(`bad image kind: ${i}`)}function _n(h,t){if(t.bitmap){h.drawImage(t.bitmap,0,0);return}const{width:e,height:s}=t,i=s%Gt,r=(s-i)/Gt,n=i===0?r:r+1,a=h.createImageData(e,Gt);let o=0;const l=t.data,c=a.data;for(let d=0;d<n;d++)({srcPos:o}=Sa({src:l,srcPos:o,dest:c,width:e,height:d<r?Gt:i,nonBlackColor:0})),h.putImageData(a,0,d*Gt)}function Fe(h,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)h[s]!==void 0&&(t[s]=h[s]);h.setLineDash!==void 0&&(t.setLineDash(h.getLineDash()),t.lineDashOffset=h.lineDashOffset)}function Ea(h,t){h.setAttribute?.("data-canvas-name",t),h._pdfjsCanvasName=t}function Bc(h){return h._pdfjsCanvasName??null}function Hs(h){h.strokeStyle=h.fillStyle="#000000",h.fillRule="nonzero",h.globalAlpha=1,h.lineWidth=1,h.lineCap="butt",h.lineJoin="miter",h.miterLimit=10,h.globalCompositeOperation="source-over",h.font="10px sans-serif",h.setLineDash!==void 0&&(h.setLineDash([]),h.lineDashOffset=0);const{filter:t}=h;t!=="none"&&t!==""&&(h.filter="none")}class Uc{#t;constructor(t){const[e,s=e,i=e]=t,r=D.identity0to256Map.slice();this.#t=[e||r,s||r,i||r]}applyToColor(t){if(typeof t!="string"||!t.startsWith("#"))return t;const[e,s,i]=ds(t),[r,n,a]=this.#t;return D.makeHexColor(r[e],n[s],a[i])}applyToImageData({data:t}){const[e,s,i]=this.#t;for(let r=0,n=t.length;r<n;r+=4)t[r]=e[t[r]],t[r+1]=s[t[r+1]],t[r+2]=i[t[r+2]]}applyToCanvas(t){const{width:e,height:s}=t.canvas,i=t.getImageData(0,0,e,s);this.applyToImageData(i),t.putImageData(i,0,0)}}function An(h,t,e){if(t)return!0;D.singularValueDecompose2dScale(h,qt);const s=Math.fround(e*os.PDF_TO_CSS_UNITS);return qt[0]<=s&&qt[1]<=s}const jc=["butt","round","square"],Hc=["miter","round","bevel"],$c={},Sn={};class Ce{static#t=null;static#e=new WeakMap;#s=0;#i=0;#r=null;#n=null;#a=null;#o=null;#l=1;#c;#u=null;#h=[];constructor(t,e,s,i,r,{optionalContentConfig:n,markedContentStack:a=null,pixelRatio:o=Jt.pixelRatio},l,c,d,u){this.ctx=t,this.current=new $i(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.tempSMask=null,this.smaskGroupCanvases=[],this.smaskPreparedEntry=null,this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=a||[],this.optionalContentConfig=n,this.pixelRatio=o,this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=c,this._cachedScaleForStroking=[-1,0],this._cachedBitmapsMap=new Map,this.dependencyTracker=d??null,this.imagesTracker=u??null}getObject(t,e,s=null){return typeof e=="string"?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const r=this.ctx.canvas.width,n=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,n),this.ctx.fillStyle=a,s){const o=this.transparentCanvasEntry=this.canvasFactory.create(r,n);this.compositeCtx=this.ctx,{canvas:this.transparentCanvas,context:this.ctx}=o,this.ctx.save(),this.ctx.transform(...ut(this.compositeCtx))}this.ctx.save(),Hs(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[3]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=ut(this.ctx)}executeOperatorList(t,e,s,i,r,n){const a=t.argsArray,o=t.fnArray,l=this._pathCache;this._pathCache=t.pathCache??Ce.#e.getOrInsertComputed(t,Zs);try{let c=e||0;const d=a.length;if(d===c)return c;const u=d-c>yn&&typeof s=="function",f=u?Date.now()+Lc:0;let p=0;const g=this.commonObjs,m=this.objs;let v,b;for(;;){if(r!==void 0){if(c===r.nextBreakPoint)return r.breakIt(c,s),c;if(r.shouldSkip(c)){if(++c===d)return c;continue}}if(!n||n(c,t))if(v=o[c],b=a[c]??null,v!==ye.dependency)b===null?this[v](c):this[v](c,...b);else for(const y of b){this.dependencyTracker?.recordNamedData(y,c);const w=y.startsWith("g_")?g:m;if(!w.has(y))return w.get(y,s,i),c}if(c++,c===d)return c;if(u&&++p>yn){if(Date.now()>f)return s(),c;p=0}}}finally{this._pathCache=l}}#f(){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.canvasFactory.destroy(this.transparentCanvasEntry),this.transparentCanvas=null,this.transparentCanvasEntry=null)}endDrawing(){this.#f();for(const t of this.smaskGroupCanvases)this.canvasFactory.destroy(t);this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0;for(const t of this.#h)this.#_(t);this.#h.length=0,this.#r=null,this.#n=null,this.#a=null,this.#o=null,this.#l=1,this.#u=null,this.#i=0,this.#s=0,this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#p()}#p(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight,r=Math.max(Math.hypot(e[0],e[1]),1),n=Math.max(Math.hypot(e[2],e[3]),1),a=[];let o=r,l=n,c=s,d=i;for(;o>2&&c>1||l>2&&d>1;){let v=c,b=d;o>2&&c>1&&(v=Math.ceil(c/2),o/=c/v),l>2&&d>1&&(b=Math.ceil(d/2),l/=d/b),a.push({newWidth:v,newHeight:b}),c=v,d=b}if(a.length===0)return{img:t,paintWidth:s,paintHeight:i,tmpCanvas:null};if(a.length===1){const{newWidth:v,newHeight:b}=a[0],y=this.canvasFactory.create(v,b);return y.context.drawImage(t,0,0,s,i,0,0,v,b),{img:y.canvas,paintWidth:v,paintHeight:b,tmpCanvas:y}}let u=this.canvasFactory.create(1,1),f=this.canvasFactory.create(1,1),p=s,g=i,m=t;for(const{newWidth:v,newHeight:b}of a)this.canvasFactory.reset(f,v,b),f.context.drawImage(m,0,0,p,g,0,0,v,b),[u,f]=[f,u],m=u.canvas,p=v,g=b;return this.canvasFactory.destroy(f),{img:u.canvas,paintWidth:p,paintHeight:g,tmpCanvas:u}}_createMaskCanvas(t,e){const s=this.ctx,{width:i,height:r}=e,n=this.current.patternFill,a=n?this.current.fillColor:s.fillStyle,o=ut(s);let l,c,d,u;if((e.bitmap||e.data)&&e.count>1){const P=e.bitmap||e.data.buffer;c=JSON.stringify(n?o:[o.slice(0,4),a]),l=this._cachedBitmapsMap.getOrInsertComputed(P,Zs);const k=l.get(c);if(k&&!n){const R=Math.round(Math.min(o[0],o[2])+o[4]),B=Math.round(Math.min(o[1],o[3])+o[5]);return this.dependencyTracker?.recordDependencies(t,Zt.transformAndFill),{canvas:k,offsetX:R,offsetY:B}}d=k}d||(u=this.canvasFactory.create(i,r),_n(u.context,e));let f=D.transform(o,[1/i,0,0,-1/r,0,0]);f=D.transform(f,[1,0,0,1,0,-r]);const p=Le.slice();D.axialAlignedBoundingBox([0,0,i,r],f,p);const[g,m,v,b]=p,y=Math.round(v-g)||1,w=Math.round(b-m)||1,A=this.canvasFactory.create(y,w),_=A.context,E=g,x=m;_.translate(-E,-x),_.transform(...f);let T=null;if(!d){const P=this._scaleImage(u.canvas,me(_));d=P.img,T=P.tmpCanvas,d!==u.canvas&&(this.canvasFactory.destroy(u),u=null),l&&n&&(l.set(c,d),T=null,u=null)}_.imageSmoothingEnabled=An(ut(_),e.interpolate,this.pixelRatio),js(_,d,0,0,d.width,d.height,0,0,i,r),T&&this.canvasFactory.destroy(T),u&&this.canvasFactory.destroy(u),_.globalCompositeOperation="source-in";const C=D.transform(me(_),[1,0,0,1,-E,-x]);return _.fillStyle=n?a.getPattern(s,this,C,Tt.FILL,t):a,_.fillRect(0,0,i,r),l&&!n&&l.set(c,A.canvas),this.dependencyTracker?.recordDependencies(t,Zt.transformAndFill),{canvas:A.canvas,canvasEntry:l&&!n?null:A,offsetX:Math.round(E),offsetY:Math.round(x)}}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=jc[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=Hc[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){this.dependencyTracker?.recordSimpleData("dash",t);const i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(e),i.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(const[s,i]of e)switch(s){case"LW":this.setLineWidth(t,i);break;case"LC":this.setLineCap(t,i);break;case"LJ":this.setLineJoin(t,i);break;case"ML":this.setMiterLimit(t,i);break;case"D":this.setDash(t,i[0],i[1]);break;case"RI":this.setRenderingIntent(t,i);break;case"FL":this.setFlatness(t,i);break;case"Font":this.setFont(t,i[0],i[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=i;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=i;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=i;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=i?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":{this.dependencyTracker?.recordSimpleData("filter",t);let r=this.filterFactory.addFilter(i);this.ctx.filter=r;let n=null;i&&(r==="none"||!ot.isCanvasFilterSupported||this.ctx.filter==="none"||this.ctx.filter==="")&&(this.ctx.filter=r="none",n=new Uc(i)),this.current.transferMaps=r,(n||this.current.transferMapsFallback)&&(this.current.transferMapsFallback=n,this.current.patternFill||(this.ctx.fillStyle=this.#A(this.current.fillColor)),this.current.patternStroke||(this.ctx.strokeStyle=this.#A(this.current.strokeColor)));break}}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){this.smaskPreparedEntry&&(this.canvasFactory.destroy(this.smaskPreparedEntry),this.smaskPreparedEntry=null),this.smaskPreparedFor=null,this.smaskPreparedOffsetX=0,this.smaskPreparedOffsetY=0,this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(t){t!==this.smaskPreparedFor&&(this._clearPreparedSMask(),this._prepareSMaskCanvas(t))}checkSMaskState(t){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode(t):!this.current.activeSMask&&e?this.endSMaskMode():this.current.activeSMask&&e&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(t){const{canvas:e,subtype:s,backdrop:i,transferMap:r}=t,n=s==="Luminosity"||s==="Alpha"&&r;if(!n&&!(s==="Luminosity"&&i)){this.smaskPreparedFor=t;return}let a;if(s==="Luminosity"&&i){const[b,y,w]=ds(i),A=Math.round(.3*b+.59*y+.11*w);a=r?.[A]??A}else a=r?.[0]??0;const o=4,{width:l,height:c}=this.ctx.canvas,d=e.width*e.height,u=l*c<o*d,f=n?{url:s==="Alpha"?this.filterFactory.addAlphaFilter(r):this.filterFactory.addLuminosityFilter(r),subtype:s,transferMap:r}:null,p=s==="Luminosity"?i:null;let g,m,v;u?(g=this._bakeSMaskCanvas(e,t.offsetX,t.offsetY,l,c,p,f),m=0,v=0):(g=this._bakeSMaskCanvas(e,0,0,e.width,e.height,p,f),m=t.offsetX,v=t.offsetY),this.smaskPreparedEntry=g,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=m,this.smaskPreparedOffsetY=v,this.smaskPreparedOOBAlpha=!u&&a!==0?a:null}_bakeSMaskCanvas(t,e,s,i,r,n,a){!n&&!a&&nt("_bakeSMaskCanvas with neither backdrop nor filter");const o=this.canvasFactory.create(i,r),l=o.context;if(l.drawImage(t,e,s),n&&(l.globalCompositeOperation="destination-atop",l.fillStyle=n,l.fillRect(0,0,i,r)),!a)return o;const c=this.canvasFactory.create(i,r),d=c.context;d.filter=a.url;const u=ot.isCanvasFilterSupported&&d.filter!=="none"&&d.filter!=="";if(d.drawImage(o.canvas,0,0),ot.isCanvasFilterSupported&&(d.filter="none"),!u){const f=d.getImageData(0,0,i,r),{data:p}=f,{transferMap:g}=a;if(a.subtype==="Luminosity")for(let m=0,v=p.length;m<v;m+=4){const b=.3*p[m]+.59*p[m+1]+.11*p[m+2]+.5|0;p[m]=p[m+1]=p[m+2]=0,p[m+3]=g?.[b]??b}else for(let m=3,v=p.length;m<v;m+=4)p[m]=g[p[m]];d.putImageData(f,0,0)}return this.canvasFactory.destroy(o),c}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const{width:e,height:s}=this.ctx.canvas,i=this.canvasFactory.create(e,s);this.smaskScratchCanvas=i,this.suspendedCtx=this.ctx;const r=this.ctx=i.context;r.setTransform(this.suspendedCtx.getTransform()),Fe(this.suspendedCtx,r),bn(r,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Fe(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}#m(t,e=null,s=1){const{width:i,height:r}=t,n=e??this.canvasFactory.create(i,r),a=n.context;s=Math.round(s*255)/255;const o=s<1;o&&this.#c===void 0&&(this.#c=ot.isCanvasFilterSupported?new Map:"none");let l="none";if(o&&this.#c instanceof Map&&(l=this.#c.getOrInsertComputed(s,()=>this.filterFactory.addKnockoutFilter(s))),!o||l!=="none")return e&&(a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,i,r),a.restore()),a.filter=l,a.drawImage(t,0,0),a.filter="none",n;const c=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,i,r),d=a.createImageData(i,r),u=c.data,f=d.data,p=s>0?1/s:1e6;for(let g=3,m=u.length;g<m;g+=4)f[g]=Math.min(Math.round(u[g]*p),255);return a.putImageData(d,0,0),n}#d(t,e,s,i){let r=t?.[e]??null;if(r&&(r.canvas.width!==s||r.canvas.height!==i)&&(this.canvasFactory.destroy(r),r=null),!r)return r=this.canvasFactory.create(s,i),t&&(t[e]=r),r;const n=r.context;return n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,s,i),n.restore(),r}#g(t,e,s={}){const{backdropCanvas:i=null,destTransform:r=[1,0,0,1,0,0],backdropOffset:n=[0,0],reuseMaskEntry:a=null,poolMeta:o=null,sourceAlpha:l=1,sourceFilter:c="none",knockoutAlpha:d=1}=s,{width:u,height:f}=e,p=this.#m(e,a,d),g=t.globalCompositeOperation;if(t.save(),t.setTransform(...r),t.globalAlpha=1,ot.isCanvasFilterSupported&&(t.filter="none"),t.globalCompositeOperation="destination-out",t.drawImage(p.canvas,0,0),i){const[m,v]=n,b=this.#d(o,"knockoutBackdropEntry",u,f),y=b.context;y.drawImage(i,m,v,u,f,0,0,u,f),y.globalCompositeOperation="destination-in",y.drawImage(p.canvas,0,0),y.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(b.canvas,0,0),o||this.canvasFactory.destroy(b)}t.globalCompositeOperation=g,t.globalAlpha=l,ot.isCanvasFilterSupported&&(t.filter=c??"none"),t.drawImage(e,0,0),t.restore(),a||this.canvasFactory.destroy(p)}#v(t=1){if(this.#s===0||this.#i>0||!this.contentVisible)return!1;this.#i++,this.#l=t;const e=this.#h.at(-1),{canvas:s}=this.ctx,i=this.#d(e,"knockoutTempEntry",s.width,s.height);this.#r=i;const r=i.context;return r.save(),r.setTransform(this.ctx.getTransform()),Fe(this.ctx,r),this.#o=r.globalCompositeOperation,r.globalCompositeOperation="source-over",bn(r,this.ctx),this.#u=e,this.#n=this.ctx,this.#a=this.suspendedCtx,this.ctx=r,this.inSMaskMode&&(this.suspendedCtx=r),!0}#y(t){if(!t)return;const e=this.#r,s=this.#n,i=this.#a,r=e.context;this.#r=null,this.#n=null,this.#a=null,this.inSMaskMode&&this.suspendedCtx===r&&this.ctx!==r&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=i),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=this.#o,this.#o=null,Fe(this.ctx,s),this.ctx=s;const n=this.#u;this.#u=null;const a=this.#l;this.#l=1;try{this.#g(i??s,e.canvas,{backdropCanvas:n?.backdropCtx?.canvas??null,backdropOffset:n?.backdropCtx?[n.offsetX,n.offsetY]:[0,0],reuseMaskEntry:n?.knockoutMaskEntry??null,poolMeta:n,knockoutAlpha:a})}finally{r.restore(),this.#i--,n||this.canvasFactory.destroy(e)}}compose(t){if(!this.current.activeSMask)return;t=t?[Math.floor(t[0]),Math.floor(t[1]),Math.ceil(t[2]),Math.ceil(t[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,s=this.suspendedCtx,i=this.#i>0&&s===this.ctx;this.composeSMask(i?null:s,e,this.ctx,t),!i&&(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}composeSMask(t,e,s,i){const r=i[0],n=i[1],a=i[2]-r,o=i[3]-n;if(a===0||o===0)return;const l=this.smaskPreparedEntry;if(l){let c=r,d=n,u=a,f=o;const p=this.smaskPreparedOOBAlpha,g=p!==null;if(g){c=Math.max(r,e.offsetX),d=Math.max(n,e.offsetY);const m=Math.min(r+a,e.offsetX+e.canvas.width),v=Math.min(n+o,e.offsetY+e.canvas.height);u=m-c,f=v-d}if(u>0&&f>0){const m=c-this.smaskPreparedOffsetX,v=d-this.smaskPreparedOffsetY;s.save(),s.globalAlpha=1,s.setTransform(1,0,0,1,0,0);const b=new Path2D;b.rect(c,d,u,f),s.clip(b),s.globalCompositeOperation="destination-in",s.drawImage(l.canvas,m,v,u,f,c,d,u,f),s.restore()}g&&p<255&&this._applySMaskOOBAlpha(s,r,n,a,o,c,d,c+u,d+f,p)}else this.genericComposeSMask(e,s,a,o,r,n);t&&(t.save(),t.globalAlpha=1,t.globalCompositeOperation=e.blendMode||"source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,r,n,a,o,r,n,a,o),t.restore())}_applySMaskOOBAlpha(t,e,s,i,r,n,a,o,l,c){const d=n<o&&a<l;if(d&&n===e&&a===s&&o===e+i&&l===s+r)return;const u=new Path2D;u.rect(e,s,i,r),d&&u.rect(n,a,o-n,l-a),t.save(),t.globalAlpha=c/255,t.setTransform(1,0,0,1,0,0),t.clip(u,"evenodd"),t.globalCompositeOperation="destination-in",t.fillStyle="#000000",t.fillRect(e,s,i,r),t.restore()}genericComposeSMask(t,e,s,i,r,n){const{context:a,offsetX:o,offsetY:l}=t;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const c=new Path2D;c.rect(r,n,s,i),e.clip(c),e.globalCompositeOperation="destination-in",e.drawImage(a.canvas,r-o,n-l,s,i,r,n,s,i),e.restore()}save(t){this.inSMaskMode&&Fe(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(Fe(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1}resetGraphicsState(){const{clipBox:t,transferMaps:e,transferMapsFallback:s}=this.current,i=this.current=new $i(0,0);i.clipBox=t,i.transferMaps=e,i.transferMapsFallback=s;const r=this.ctx;r.lineWidth=1,r.lineCap="butt",r.lineJoin="miter",r.miterLimit=10,r.setLineDash!==void 0&&(r.setLineDash([]),r.lineDashOffset=0),this._cachedScaleForStroking[0]=-1}transform(t,e,s,i,r,n,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,s,i,r,n,a),this._cachedScaleForStroking[0]=-1}constructPath(t,e,s,i){let r=this._pathCache.get(t);if(!i){r||(r=new Path2D,this._pathCache.set(t,r)),e!==ye.stroke&&e!==ye.closeStroke&&(this.current.tilingPatternDims=null),this[e](t,r);return}if(this.dependencyTracker!==null){const a=e===ye.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-a,i[2]+a,i[1]-a,i[3]+a).recordDependencies(t,["transform"])}r||(r=da(s[0]),this._pathCache.set(t,r)),D.axialAlignedBoundingBox(i,ut(this.ctx),this.current.minMax);const n=this.current.tilingPatternDims;if(n&&e!==ye.stroke&&e!==ye.closeStroke&&this.current.fillColor instanceof _s){const a=D.intersect(this.current.clipBox,this.current.minMax);a?this.current.fillColor.updatePatternDims(a,n):this.current.tilingPatternDims=null}this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){const i=s&&this.#v(this.current.strokeAlpha),r=this.ctx,n=this.current.strokeColor;if(r.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof n=="object"&&n?.getPattern){const a=n.isModifyingCurrentTransform()?r.getTransform():null;if(r.save(),r.strokeStyle=n.getPattern(r,this,me(r),Tt.STROKE,t),a){const o=new Path2D;o.addPath(e,r.getTransform().invertSelf().multiplySelf(a)),e=o}this.rescaleAndStroke(e,!1),r.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,Zt.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(Tt.STROKE,ut(this.ctx))),r.globalAlpha=this.current.fillAlpha,this.#y(i)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){const i=s&&this.#v(this.current.fillAlpha),r=this.ctx,n=this.current.fillColor,a=this.current.patternFill;let o=!1;const l=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(t,Zt.fill),a){const c=this.current.tilingPatternDims,d=c&&n.canSkipPatternCanvas(c);if(d){const{pendingClip:f,pendingEOFill:p}=this;this.pendingClip=null,this.pendingEOFill=!1,n.drawPattern(this,e,p,d,t),this.pendingClip=f,s&&this.consumePath(t,e,l),this.current.tilingPatternDims=null,this.#y(i);return}const u=n.isModifyingCurrentTransform()?r.getTransform():null;if(this.dependencyTracker?.save(t),r.save(),r.fillStyle=n.getPattern(r,this,me(r),Tt.FILL,t),u){const f=new Path2D;f.addPath(e,r.getTransform().invertSelf().multiplySelf(u)),e=f}o=!0}this.contentVisible&&l!==null&&(this.pendingEOFill?(r.fill(e,"evenodd"),this.pendingEOFill=!1):r.fill(e)),o&&(r.restore(),this.dependencyTracker?.restore(t)),s&&this.consumePath(t,e,l),this.#y(i)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){const s=this.#v(Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e),this.#y(s)}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){const s=this.#v(this.current.fillAlpha);this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,Zt.rawFillPath).recordOperation(t),this.#y(s)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=$c}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=Sn}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){const e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;e!==void 0&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(e!==void 0){const i=new Path2D,r=s.getTransform().invertSelf();for(const{transform:n,x:a,y:o,fontSize:l,path:c}of e)c&&i.addPath(c,new DOMMatrix(n).preMultiplySelf(r).translate(a,o).scale(l,-l));s.clip(i)}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,s){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const i=this.commonObjs.get(e),r=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=i.fontMatrix||Xi,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&z("Invalid font matrix for font "+e),s<0?(s=-s,r.fontDirection=-1):r.fontDirection=1,this.current.font=i,this.current.fontSize=s,i.isType3Font)return;const n=i.loadedName||"sans-serif",a=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let o="normal";i.black?o="900":i.bold&&(o="bold");const l=i.italic?"italic":"normal",c=ft(s,Dc,Nc);this.current.fontSizeScale=s/c,this.ctx.font=`${l} ${o} ${c}px ${a}`}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,s){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#b(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i}paintChar(t,e,s,i,r,n){const a=this.ctx,o=this.current,l=o.font,c=o.textRenderingMode,d=o.fontSize/o.fontSizeScale,u=c&Et.FILL_STROKE_MASK,f=!!(c&Et.ADD_TO_PATH_FLAG),p=o.patternFill&&!l.missingFile,g=o.patternStroke&&!l.missingFile;let m;if((l.disableFontFace||f||p||g)&&!l.missingFile&&(m=l.getPathGenerator(this.commonObjs,e)),m&&(l.disableFontFace||p||g)){a.save(),a.translate(s,i),a.scale(d,-d),this.dependencyTracker?.recordCharacterBBox(t,a,l);let v;if(u===Et.FILL||u===Et.FILL_STROKE)if(r){v=a.getTransform(),a.setTransform(...r);const b=this.#b(m,v,r);a.fill(b)}else a.fill(m);if(u===Et.STROKE||u===Et.FILL_STROKE)if(n){v||=a.getTransform(),a.setTransform(...n);const{a:b,b:y,c:w,d:A}=v,_=D.inverseTransform(n),E=D.transform([b,y,w,A,0,0],_);D.singularValueDecompose2dScale(E,qt),a.lineWidth*=Math.max(qt[0],qt[1])/d,a.stroke(this.#b(m,v,n))}else a.lineWidth/=d,a.stroke(m);a.restore()}else(u===Et.FILL||u===Et.FILL_STROKE)&&(a.fillText(e,s,i),this.dependencyTracker?.recordCharacterBBox(t,a,l,d,s,i,()=>a.measureText(e))),(u===Et.STROKE||u===Et.FILL_STROKE)&&(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,a,l,d,s,i,()=>a.measureText(e)).recordDependencies(t,Zt.stroke),a.strokeText(e,s,i));f&&((this.pendingTextPaths||=[]).push({transform:ut(a),x:s,y:i,fontSize:d,path:m}),this.dependencyTracker?.recordCharacterBBox(t,a,l,d,s,i))}get isFontSubpixelAAEnabled(){const t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);const s=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let i=!1;for(let r=3;r<s.length;r+=4)if(s[r]>0&&s[r]<255){i=!0;break}return L(this,"isFontSubpixelAAEnabled",i)}#w(t,e,s){const i=this.ctx;i.save();const r=t.getPattern(i,this,me(i),e,s),n=ut(i);return i.restore(),[r,n]}showText(t,e){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,Zt.showText).resetBBox(t),this.current.textRenderingMode&Et.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,i=s.font;if(i.isType3Font){const k=this.#v(s.fillAlpha);this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t),this.#y(k);return}const r=s.fontSize;if(r===0){this.dependencyTracker?.recordOperation(t);return}const n=this.#v(s.fillAlpha),a=this.ctx,o=s.fontSizeScale,l=s.charSpacing,c=s.wordSpacing,d=s.fontDirection,u=s.textHScale*d,f=e.length,p=i.vertical,g=p?1:-1,m=r*s.fontMatrix[0],v=s.textRenderingMode===Et.FILL&&!i.disableFontFace&&!s.patternFill;a.save(),s.textMatrix&&a.transform(...s.textMatrix),a.translate(s.x,s.y+s.textRise),d>0?a.scale(u,-1):a.scale(u,1);let b,y;const w=s.textRenderingMode&Et.FILL_STROKE_MASK,A=w===Et.FILL||w===Et.FILL_STROKE,_=w===Et.STROKE||w===Et.FILL_STROKE;let E=s.lineWidth;const x=s.textMatrixScale;if(x===0||E===0?_&&(E=this.getSinglePixelWidth()):E/=x,o!==1&&(a.scale(o,o),E/=o),a.lineWidth=E,A&&s.patternFill&&([a.fillStyle,b]=this.#w(s.fillColor,Tt.FILL,t)),_&&s.patternStroke&&([a.strokeStyle,y]=this.#w(s.strokeColor,Tt.STROKE,t)),i.isInvalidPDFjsFont){const k=[];let R=0;for(const U of e)k.push(U.unicode),R+=U.width;const B=k.join("");if(a.fillText(B,0,0),this.dependencyTracker!==null){const U=a.measureText(B);this.dependencyTracker.recordBBox(t,this.ctx,-U.actualBoundingBoxLeft,U.actualBoundingBoxRight,-U.actualBoundingBoxAscent,U.actualBoundingBoxDescent).recordShowTextOperation(t)}s.x+=R*m*u,a.restore(),this.compose(),this.#y(n);return}let T=0,C,P=null;for(C=0;C<f;++C){const k=e[C];if(typeof k=="number"){T+=g*k*r/1e3;continue}let R=!1;const B=(k.isSpace?c:0)+l,U=k.fontChar,M=k.accent;let O,V,q,Q=k.width;if(p){const I=k.vmetric,N=-I[1]*m,G=I[2]*m;if(Q=-I[0],O=N/o,V=(T+G)/o,k.isRotated){q=a.measureText(U);const W=m/o,tt=k.width/2*W,$=O+tt;O=V-(880-1e3/2)*W-tt,V=(q.actualBoundingBoxAscent-q.actualBoundingBoxDescent)/2-$,R=!0,a.save(),a.rotate(Math.PI/2)}}else O=T/o,V=0;const Z=k.isRotated?k.width:Q;let K=1;if((i.remeasure||k.isRotated)&&Z>0){q??=a.measureText(U);const I=q.width*1e3/r*o;Z<I&&this.isFontSubpixelAAEnabled?(K=Z/I,R||(R=!0,a.save()),a.scale(K,1),O/=K):Z!==I&&(O+=(Z-I)/2e3*r/o)}if(R&&i.missingFile&&(b||y)&&(P||=new Map,[a.fillStyle,a.strokeStyle]=P.getOrInsertComputed(k.isRotated?-K:K,()=>[b?this.#w(s.fillColor,Tt.FILL,t)[0]:a.fillStyle,y?this.#w(s.strokeColor,Tt.STROKE,t)[0]:a.strokeStyle])),this.contentVisible&&(k.isInFont||i.missingFile)){if(v&&!M)a.fillText(U,O,V),this.dependencyTracker?.recordCharacterBBox(t,a,q?{bbox:null}:i,r/o,O,V,()=>q??a.measureText(U));else if(this.paintChar(t,U,O,V,b,y),M){const I=O+r*M.offset.x/o,N=V-r*M.offset.y/o;this.paintChar(t,M.fontChar,I,N,b,y)}}const F=p?Q*m-B*d:Q*m+B*d;T+=F,R&&a.restore()}p?s.y-=T:s.x+=T*u,a.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t),this.#y(n)}showType3Text(t,e){const s=this.ctx,i=this.current,r=i.font,n=i.fontSize,a=i.fontDirection,o=r.vertical?1:-1,l=i.charSpacing,c=i.wordSpacing,d=i.textHScale*a,u=i.fontMatrix||Xi,f=e.length,p=i.textRenderingMode!==Et.INVISIBLE;let g,m,v,b;if(n===0)return;this._cachedScaleForStroking[0]=-1,s.save(),i.textMatrix&&s.transform(...i.textMatrix),s.translate(i.x,i.y+i.textRise),s.scale(d,a);const y=this.dependencyTracker;this.dependencyTracker=y?new Ts(y,t):null;try{for(g=0;g<f;++g){if(m=e[g],typeof m=="number"){b=o*m*n/1e3,this.ctx.translate(b,0),i.x+=b*d;continue}const w=(m.isSpace?c:0)+l,A=r.charProcOperatorList.get(m.operatorListId);A?this.contentVisible&&p&&(this.save(),s.scale(n,n),s.transform(...u),this.executeOperatorList(A),this.restore()):z(`Type3 character "${m.operatorListId}" is not available.`),v=m.width*u[0]*n+w*a,s.translate(v,0),i.x+=v*d}}finally{y&&(this.dependencyTracker=y)}s.restore()}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,r,n,a){const o=new Path2D;o.rect(i,r,n-i,a-r),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,i,n,r,a).recordClipBox(t,this.ctx,i,n,r,a),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const i=this.baseTransform||ut(this.ctx),r={createCanvasGraphics:(n,a)=>new Ce(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack,pixelRatio:this.pixelRatio},void 0,void 0,this.dependencyTracker?new Ts(this.dependencyTracker,a,!0):null)};s=new _s(e,this.ctx,r,i)}else s=this._getPattern(t,e[1],e[2]);return s}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);const s=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=s instanceof _s?[0,0,0,0]:null}#A(t){return this.current.transferMapsFallback?.applyToColor(t)??t}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=e,this.ctx.strokeStyle=this.#A(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.current.fillColor=e,this.ctx.fillStyle=this.#A(e),this.current.patternFill=!1,this.current.tilingPatternDims=null}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1,this.current.tilingPatternDims=null}_getPattern(t,e,s=null){const i=this.cachedPatterns.getOrInsertComputed(e,()=>Rc(this.getObject(t,e)));return s&&(i.matrix=s),i}shadingFill(t,e){if(!this.contentVisible)return;const s=this.#v(this.current.fillAlpha),i=this.ctx;this.save(t);const r=this._getPattern(t,e);i.fillStyle=r.getPattern(i,this,me(i),Tt.SHADING,t);const n=me(i);if(n){const{width:a,height:o}=i.canvas,l=Le.slice();D.axialAlignedBoundingBox([0,0,a,o],n,l);const[c,d,u,f]=l;this.ctx.fillRect(c,d,u-c,f-d)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Zt.transform).recordDependencies(t,Zt.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),this.#y(s)}beginInlineImage(){nt("Should not call beginInlineImage")}beginImageData(){nt("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=ut(this.ctx),s)){D.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[i,r,n,a]=s,o=new Path2D;o.rect(i,r,n-i,a-r),this.ctx.clip(o),this.dependencyTracker?.recordClipBox(t,this.ctx,i,n,r,a),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);const{inSMaskMode:s}=this;s&&(this.endSMaskMode(),this.current.activeSMask=null);const i=this.ctx;if((!e.needsIsolation||!e.isolated&&!e.hasSoftMask)&&!e.knockout&&!e.isGray&&this.#s===0&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&!s){if(e.bbox){let w=new Path2D;const[A,_,E,x]=e.bbox;if(w.rect(A,_,E-A,x-_),e.matrix){const T=new Path2D;T.addPath(w,new DOMMatrix(e.matrix)),w=T}i.clip(w)}this.groupStack.push(null),this.#h.push(null),this.groupLevel++;return}!e.isolated&&!e.knockout&&this.#s===0&&Si("TODO: Fully support non-isolated non-knockout groups.");const r=ut(i);e.matrix&&i.transform(...e.matrix);const n=[0,0,i.canvas.width,i.canvas.height];let a;e.bbox?(a=Le.slice(),D.axialAlignedBoundingBox(e.bbox,ut(i),a),a=D.intersect(a,n)||[0,0,0,0]):a=n;const o=Math.floor(a[0]),l=Math.floor(a[1]),c=Math.max(Math.ceil(a[2])-o,1),d=Math.max(Math.ceil(a[3])-l,1);this.current.startNewPathAndClipBox([0,0,c,d]);const u=this.canvasFactory.create(c,d);e.smask&&this.smaskGroupCanvases.push(u);const f=u.context,p=e.knockout&&!e.isolated?i:null,g=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&this.#s>0,m=e.knockout?this.canvasFactory.create(c,d):null,v=this.#s;e.knockout?this.#s++:this.#s=0,f.translate(-o,-l),f.transform(...r);const b=!e.isolated&&!e.smask&&e.needsIsolation,y=b&&!s&&v===0&&!e.knockout&&!e.isGray&&e.hasSoftMask&&i.globalAlpha===1&&i.globalCompositeOperation==="source-over"&&this.current.transferMaps==="none"&&!this.current.transferMapsFallback;if(b&&(s||y)&&(f.save(),f.setTransform(1,0,0,1,0,0),f.drawImage(i.canvas,-o,-l),f.restore()),e.bbox){let w=new Path2D;const[A,_,E,x]=e.bbox;if(w.rect(A,_,E-A,x-_),e.matrix){const T=new Path2D;T.addPath(w,new DOMMatrix(e.matrix)),w=T}f.clip(w)}e.smask&&this.smaskStack.push({canvas:u.canvas,context:f,offsetX:o,offsetY:l,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null}),(!e.smask||this.dependencyTracker)&&(i.setTransform(1,0,0,1,0,0),i.translate(o,l),i.save()),Fe(i,f),this.ctx=f,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(i),this.#h.push({backdropCtx:p,savedKnockoutLevel:v,offsetX:o,offsetY:l,hasInnerBackdrop:g,replaceBackdrop:y,knockoutMaskEntry:m,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,i=this.groupStack.pop(),r=this.#h.pop();if(r&&(this.#s=r.savedKnockoutLevel),i===null){this.restore(t);return}if(e.isGray&&this.#S(s),this.ctx=i,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),this.#_(r);else{this.ctx.restore();const n=ut(this.ctx);this.restore(t),this.current.transferMapsFallback?.applyToCanvas(s),this.ctx.save(),this.ctx.setTransform(...n);const a=Le.slice();D.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],n,a);const o=this.#h.at(-1);if(this.#s>0)if(r.hasInnerBackdrop){const{width:l,height:c}=s.canvas,d=this.canvasFactory.create(l,c),u=d.context;u.drawImage(i.canvas,r.offsetX,r.offsetY,l,c,0,0,l,c),u.globalCompositeOperation="source-over",u.drawImage(s.canvas,0,0);const f=this.#m(s.canvas);u.globalCompositeOperation="destination-in",u.drawImage(f.canvas,0,0);const p=this.ctx.globalCompositeOperation,g=this.ctx.globalAlpha,m=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...n),this.ctx.globalAlpha=1,ot.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(f.canvas,0,0),this.ctx.globalCompositeOperation=p,this.ctx.globalAlpha=g,ot.isCanvasFilterSupported&&(this.ctx.filter=m??"none"),this.ctx.drawImage(d.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(f),this.canvasFactory.destroy(d)}else{const l=o?.backdropCtx??null;this.#g(this.ctx,s.canvas,{backdropCanvas:l?.canvas??null,destTransform:n,backdropOffset:l?[o.offsetX+r.offsetX,o.offsetY+r.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else{if(r.replaceBackdrop){const l=new Path2D;l.rect(0,0,s.canvas.width,s.canvas.height),this.ctx.clip(l),this.ctx.globalCompositeOperation="copy"}this.ctx.drawImage(s.canvas,0,0)}this.ctx.restore(),this.canvasFactory.destroy({canvas:s.canvas,context:s}),this.#_(r),this.compose(a)}}#S(t){const{canvas:e}=t,{width:s,height:i}=e;if(ot.isCanvasFilterSupported){t.save(),t.setTransform(1,0,0,1,0,0),t.filter="grayscale(1)",t.globalAlpha=1,t.globalCompositeOperation="copy",t.drawImage(e,0,0),t.restore();return}const r=t.getImageData(0,0,s,i),{data:n}=r;for(let a=0,o=n.length;a<o;a+=4){const l=n[a]*.2126+n[a+1]*.7152+n[a+2]*.0722+.5|0;n[a]=n[a+1]=n[a+2]=l}t.putImageData(r,0,0)}#_(t){t&&(t.knockoutMaskEntry&&(this.canvasFactory.destroy(t.knockoutMaskEntry),t.knockoutMaskEntry=null),t.knockoutTempEntry&&(this.canvasFactory.destroy(t.knockoutTempEntry),t.knockoutTempEntry=null),t.knockoutBackdropEntry&&(this.canvasFactory.destroy(t.knockoutBackdropEntry),t.knockoutBackdropEntry=null))}beginAnnotation(t,e,s,i,r,n,a){if(this.#f(),Hs(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const o=s[2]-s[0],l=s[3]-s[1];if(n&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],D.singularValueDecompose2dScale(ut(this.ctx),qt);const{viewportScale:c}=this,d=Math.ceil(o*this.outputScaleX*c),u=Math.ceil(l*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(d,u);const{canvas:f,context:p}=this.annotationCanvas;if(a){const g=this.annotationCanvasMap.getOrInsertComputed(e,hs);Ea(f,a);const m=g.findIndex(v=>Bc(v)===a);m===-1?g.push(f):g[m]=f}else this.annotationCanvasMap.set(e,f);this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(qt[0],0,0,-qt[1],0,l*qt[1]),Hs(this.ctx)}else{Hs(this.ctx),this.endPath(t);const c=new Path2D;c.rect(s[0],s[1],o,l),this.ctx.clip(c)}}this.current=new $i(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...i),this.transform(t,...r),this.baseTransform=ut(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#p(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){if(!this.contentVisible)return;const s=e.count;e=this.getObject(t,e.data,e),e.count=s;const i=this.#v(this.current.fillAlpha),r=this.ctx,n=this._createMaskCanvas(t,e),a=n.canvas;r.save(),r.setTransform(1,0,0,1,0,0),r.drawImage(a,n.offsetX,n.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,n.offsetX,n.offsetX+a.width,n.offsetY,n.offsetY+a.height).recordOperation(t),r.restore(),n.canvasEntry&&this.canvasFactory.destroy(n.canvasEntry),this.compose(),this.#y(i)}paintImageMaskXObjectRepeat(t,e,s,i=0,r=0,n,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const o=this.#v(this.current.fillAlpha),l=this.ctx;l.save();const c=ut(l);l.transform(s,i,r,n,0,0);const d=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,d.offsetX-c[4],d.offsetY-c[5]),this.dependencyTracker?.resetBBox(t);for(let u=0,f=a.length;u<f;u+=2){const p=D.transform(c,[s,i,r,n,a[u],a[u+1]]);l.drawImage(d.canvas,p[4],p[5]),this.dependencyTracker?.recordBBox(t,this.ctx,p[4],p[4]+d.canvas.width,p[5],p[5]+d.canvas.height)}l.restore(),d.canvasEntry&&this.canvasFactory.destroy(d.canvasEntry),this.compose(),this.dependencyTracker?.recordOperation(t),this.#y(o)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.#v(this.current.fillAlpha),i=this.ctx,r=this.current.patternFill,n=r?this.current.fillColor:i.fillStyle;this.dependencyTracker?.resetBBox(t).recordDependencies(t,Zt.transformAndFill);for(const a of e){const{data:o,width:l,height:c,transform:d}=a,u=this.canvasFactory.create(l,c),f=u.context;f.save();const p=this.getObject(t,o,a);_n(f,p),f.globalCompositeOperation="source-in",f.fillStyle=r?n.getPattern(f,this,me(i),Tt.FILL,t):n,f.fillRect(0,0,l,c),f.restore(),i.save(),i.transform(...d),i.scale(1,-1),js(i,u.canvas,0,0,l,c,0,-1,1,1),this.canvasFactory.destroy(u),this.dependencyTracker?.recordBBox(t,i,0,l,0,c),i.restore()}this.compose(),this.dependencyTracker?.recordOperation(t),this.#y(s)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){z("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,r){if(!this.contentVisible)return;const n=this.getObject(t,e);if(!n){z("Dependent image isn't ready yet");return}const a=n.width,o=n.height,l=[];for(let c=0,d=r.length;c<d;c+=2)l.push({transform:[s,0,0,i,r[c],r[c+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,n,l)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"?(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"):this.current.transferMapsFallback?.applyToCanvas(t),t.canvas}applyTransferMapsToBitmap(t){const{transferMaps:e,transferMapsFallback:s}=this.current;if(e==="none"&&!s)return{img:t.bitmap,canvasEntry:null};const{bitmap:i,width:r,height:n}=t,a=this.canvasFactory.create(r,n),o=a.context;return o.filter=e,o.drawImage(i,0,0),o.filter="none",s?.applyToCanvas(o),{img:a.canvas,canvasEntry:a}}paintInlineImageXObject(t,e){if(!this.contentVisible)return;const s=e.width,i=e.height,r=this.#v(this.current.fillAlpha),n=this.ctx;this.save(t);const{filter:a}=n;a!=="none"&&a!==""&&(n.filter="none"),n.scale(1/s,-1/i);let o,l=null;if(e.bitmap){const d=this.applyTransferMapsToBitmap(e);o=d.img,l=d.canvasEntry}else{const d=this.canvasFactory.create(s,i);wn(d.context,e),o=this.applyTransferMapsToCanvas(d.context),l=d}const c=this._scaleImage(o,me(n));n.imageSmoothingEnabled=An(ut(n),e.interpolate,this.pixelRatio),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,n,0,s,-i,0).recordDependencies(t,Zt.imageXObject).recordOperation(t),this.imagesTracker?.record(n,s,i,this.dependencyTracker.clipBox)),js(n,c.img,0,0,c.paintWidth,c.paintHeight,0,-i,s,i),c.tmpCanvas&&this.canvasFactory.destroy(c.tmpCanvas),l&&this.canvasFactory.destroy(l),this.compose(),this.restore(t),this.#y(r)}paintInlineImageXObjectGroup(t,e,s){if(!this.contentVisible)return;const i=this.#v(this.current.fillAlpha),r=this.ctx;let n,a=null;if(e.bitmap&&!this.current.transferMapsFallback)n=e.bitmap;else if(e.bitmap)({img:n,canvasEntry:a}=this.applyTransferMapsToBitmap(e));else{const o=e.width,l=e.height,c=this.canvasFactory.create(o,l);wn(c.context,e),n=this.applyTransferMapsToCanvas(c.context),a=c}this.dependencyTracker?.resetBBox(t);for(const o of s)r.save(),r.transform(...o.transform),r.scale(1,-1),js(r,n,o.x,o.y,o.w,o.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,r,0,1,-1,0),r.restore();a&&this.canvasFactory.destroy(a),this.dependencyTracker?.recordOperation(t),this.compose(),this.#y(i)}paintSolidColorImageMask(t){if(!this.contentVisible)return;const e=this.#v(this.current.fillAlpha);this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Zt.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),this.#y(e)}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){this.dependencyTracker?.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):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,s){const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const r=this.ctx;this.pendingClip?(i||(this.pendingClip===Sn?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){const t=ut(this.ctx);if(t[1]===0&&t[2]===0)return 1/Math.min(Math.abs(t[0]),Math.abs(t[3]));const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);return Math.max(s,i)/e}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:r}=this.ctx.getTransform();let n,a;if(s===0&&i===0){const o=Math.abs(e),l=Math.abs(r);if(o===l)if(t===0)n=a=1/o;else{const c=o*t;n=a=c<1?1/c:1}else if(t===0)n=1/o,a=1/l;else{const c=o*t,d=l*t;n=c<1?1/c:1,a=d<1?1/d:1}}else{const o=Math.abs(e*r-s*i),l=Math.hypot(e,s),c=Math.hypot(i,r);if(t===0)n=c/o,a=l/o;else{const d=t*o;n=c>d?c/d:1,a=l>d?l/d:1}}this._cachedScaleForStroking[0]=n,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:i}}=this,[r,n]=this.getScaleForStroking();if(r===n){s.lineWidth=(i||1)*r,s.stroke(t);return}const a=Ce.#t??=new DOMMatrix,o=s.getLineDash();e&&s.save(),s.scale(r,n),a.a=1/r,a.d=1/n;const l=new Path2D;if(l.addPath(t,a),o.length>0){const c=Math.max(r,n);s.setLineDash(o.map(d=>d/c)),s.lineDashOffset/=c}s.lineWidth=i||1,s.stroke(l),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const h in ye)Ce.prototype[h]!==void 0&&(Ce.prototype[ye[h]]=Ce.prototype[h]);class Gc extends _a{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class Wc extends Aa{#t;#e;#s;#i;#r;#n;#a=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#i=t,this.#r=e}get#o(){return this.#e||=new Map}get#l(){return this.#n||=new Map}get#c(){if(!this.#s){const t=this.#r.createElement("div"),{style:e}=t;e.colorScheme="only light",e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const s=this.#r.createElementNS(Dt,"svg");s.setAttribute("width",0),s.setAttribute("height",0),this.#s=this.#r.createElementNS(Dt,"defs"),t.append(s),s.append(this.#s),this.#r.body.append(t)}return this.#s}#u(t){const e=n=>n&&Array.from(n,a=>a/255).join(",");if(t.length===1){const n=e(t[0]);return[n,n,n]}const[s,i,r]=t;return[e(s),e(i),e(r)]}#h(t){if(this.#t===void 0){this.#t="";const e=this.#r.URL;e!==this.#r.baseURI&&(Ti(e)?z('#createUrl: ignore "data:"-URL for performance reasons.'):this.#t=ca(e,""))}return`url(${this.#t}#${t})`}addFilter(t){if(!t)return"none";let e=this.#o.get(t);if(e)return e;const[s,i,r]=this.#u(t),n=t.length===1?s:`${s}${i}${r}`;if(e=this.#o.get(n),e)return this.#o.set(t,e),e;const a=`g_${this.#i}_transfer_map_${this.#a++}`,o=this.#h(a);this.#o.set(t,o),this.#o.set(n,o);const l=this.#m(a);return this.#g(s,i,r,l),o}addHCMFilter(t,e){const s=`${t}-${e}`,i="base";let r=this.#l.get(i);if(r?.key===s||(r?(r.filter?.remove(),r.key=s,r.url="none",r.filter=null):(r={key:s,url:"none",filter:null},this.#l.set(i,r)),!t||!e))return r.url;const n=this.#y(t);t=D.makeHexColor(...n);const a=this.#y(e);if(e=D.makeHexColor(...a),this.#w(),t==="#000000"&&e==="#ffffff"||t===e)return r.url;const l=Array.from({length:256},(f,p)=>Zi(p/255)).join(","),c=`g_${this.#i}_hcm_filter`,d=r.filter=this.#m(c);this.#g(l,l,l,d),this.#p(d);const u=(f,p)=>{const g=n[f]/255,m=a[f]/255,v=new Array(p+1);for(let b=0;b<=p;b++)v[b]=g+b/p*(m-g);return v.join(",")};return this.#g(u(0,5),u(1,5),u(2,5),d),r.url=this.#h(c),r.url}addSelectionHCMFilter(t,e){return this.addHighlightHCMFilter("selection",t,e,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(t=null){const e=t?this.addSelectionHCMFilter(t.foreground,t.background):this.addSelectionFilter();return e==="none"||!ot.platform.isFirefox?null:{"backdrop-filter":e,"background-color":"transparent"}}addAlphaFilter(t){let e=this.#o.get(t);if(e)return e;const[s]=this.#u([t]),i=`alpha_${s}`;if(e=this.#o.get(i),e)return this.#o.set(t,e),e;const r=`g_${this.#i}_alpha_map_${this.#a++}`,n=this.#h(r);this.#o.set(t,n),this.#o.set(i,n);const a=this.#m(r);return this.#v(s,a),n}addLuminosityFilter(t){let e=this.#o.get(t||"luminosity");if(e)return e;let s,i;if(t?([s]=this.#u([t]),i=`luminosity_${s}`):i="luminosity",e=this.#o.get(i),e)return this.#o.set(t,e),e;const r=`g_${this.#i}_luminosity_map_${this.#a++}`,n=this.#h(r);this.#o.set(t,n),this.#o.set(i,n);const a=this.#m(r);return this.#f(a),t&&this.#v(s,a),n}addKnockoutFilter(t=0){const e=t>0?Math.min(1/t,1e6):1e6,s=`knockout_${e}`,i=this.#o.get(s);if(i)return i;const r=`g_${this.#i}_knockout_filter_${this.#a++}`,n=this.#h(r);this.#o.set(s,n);const a=this.#m(r),o=this.#r.createElementNS(Dt,"feComponentTransfer");a.append(o);const l=this.#r.createElementNS(Dt,"feFuncA");return l.setAttribute("type","linear"),l.setAttribute("slope",`${e}`),l.setAttribute("intercept","0"),o.append(l),n}addHighlightHCMFilter(t,e,s,i,r){const n=`${e}-${s}-${i}-${r}`;let a=this.#l.get(t);if(a?.key===n||(a?(a.filter?.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},this.#l.set(t,a)),!e||!s))return a.url;const[o,l]=[e,s].map(this.#y.bind(this));let c=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[u,f]=[i,r].map(this.#A.bind(this));d<c&&([c,d,u,f]=[d,c,f,u]),this.#w();const p=(v,b,y)=>{const w=new Array(256),A=(d-c)/y,_=v/255,E=(b-v)/(255*y);let x=0;for(let T=0;T<=y;T++){const C=Math.round(c+T*A),P=_+T*E;for(let k=x;k<=C;k++)w[k]=P;x=C+1}for(let T=x;T<256;T++)w[T]=w[x-1];return w.join(",")},g=`g_${this.#i}_hcm_${t}_filter`,m=a.filter=this.#m(g);return this.#p(m),this.#g(p(u[0],f[0],5),p(u[1],f[1],5),p(u[2],f[2],5),m),a.url=this.#h(g),a.url}destroy(t=!1){t&&this.#n?.size||(this.#s?.parentNode.parentNode.remove(),this.#s=null,this.#e?.clear(),this.#e=null,this.#n?.clear(),this.#n=null,this.#a=0)}#f(t){const e=this.#r.createElementNS(Dt,"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)}#p(t){const e=this.#r.createElementNS(Dt,"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)}#m(t){const e=this.#r.createElementNS(Dt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#c.append(e),e}#d(t,e,s){if(!s)return;const i=this.#r.createElementNS(Dt,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)}#g(t,e,s,i){const r=this.#r.createElementNS(Dt,"feComponentTransfer");i.append(r),this.#d(r,"feFuncR",t),this.#d(r,"feFuncG",e),this.#d(r,"feFuncB",s)}#v(t,e){const s=this.#r.createElementNS(Dt,"feComponentTransfer");e.append(s),this.#d(s,"feFuncA",t)}#y(t){return this.#c.style.color="CanvasText",this.#c.style.backgroundColor=t,Ms(getComputedStyle(this.#c).getPropertyValue("background-color"))}#b(t){return this.#c.style.color="CanvasText",this.#c.style.backgroundColor=t,ds(getComputedStyle(this.#c).getPropertyValue("background-color"))}#w(){this.#c.style.color="",this.#c.style.backgroundColor=""}#A(t){const[e,s,i,r]=this.#b(t);if(r===1)return[e,s,i];const[n,a,o]=this.#y("Canvas");return[Gi(e,n,r),Gi(s,a,r),Gi(i,o,r)]}}function Gi(h,t,e){return Math.round(e*h+(1-e)*t)}const En=new RegExp("\\p{Cc}","u");function zc(h){const t=h[0];if(h.length<2||t!=='"'&&t!=="'"||h.at(-1)!==t)return!1;const e=h.length-1;for(let s=1;s<e;s++){const i=h[s];if(i===t||En.test(i)||i==="\\"&&(++s>=e||En.test(h[s])))return!1}return!0}function Tn(h){return zc(h)?h:`"${h.replaceAll(/["\\\p{Cc}]/gu,e=>e==='"'||e==="\\"?`\\${e}`:`\\${e.codePointAt(0).toString(16)} `)}"`}class Vc{#t=new Set;#e=new Set;#s=null;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.#t.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.#t.delete(t),this._document.fonts.delete(t)}insertRule(t){const e=this.#i();e.insertRule(t,e.cssRules.length)}#i(){if(this.#s)return this.#s;const t=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&t){const{adoptedStyleSheets:e}=this._document;if(e){const s=new t;return e.push(s),this.#s=s}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),this.#s=this.styleElement.sheet}clear(){for(const t of this.#t)this._document.fonts.delete(t);if(this.#t.clear(),this.#e.clear(),this.#s){const{adoptedStyleSheets:t}=this._document;t?.includes(this.#s)&&(this._document.adoptedStyleSheets=t.filter(e=>e!==this.#s)),this.#s=null}this.styleElement?.remove(),this.styleElement=null}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||this.#e.has(t.loadedName))){if(_t(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:r,style:n}=t,a=new FontFace(i,r,n);this.addNativeFontFace(a);try{await a.load(),this.#e.add(i),s?.(t)}catch{z(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}nt("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){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw z(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await this.#r(t)}}get isFontLoadingAPISupported(){return L(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return L(this,"isSyncFontLoadingSupported",Yt||ot.platform.isFirefox)}#r(t){function e(){for(_t(!n.done,"completeRequest() cannot be called twice."),n.done=!0;s.length>0&&s[0].done;){const T=s.shift();setTimeout(T.resolve,0)}}const{loadingRequests:s}=this,{promise:i,resolve:r}=Promise.withResolvers(),n={done:!1,resolve:r};s.push(n),this._loadTestFont??=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");function a(T,C){return T.charCodeAt(C)<<24|T.charCodeAt(C+1)<<16|T.charCodeAt(C+2)<<8|T.charCodeAt(C+3)&255}function o(T){return String.fromCharCode(T>>24&255,T>>16&255,T>>8&255,T&255)}function l(T,C,P,k){const R=T.substring(0,C),B=T.substring(C+P);return R+k+B}let c,d;const u=this._document.createElement("canvas");u.width=1,u.height=1;const f=u.getContext("2d");let p=0;function g(T,C){if(++p>30){z("Load test font never loaded."),C();return}if(f.font="30px "+T,f.fillText(".",0,20),f.getImageData(0,0,1,1).data[3]>0){C();return}setTimeout(g.bind(null,T,C))}const m=`lt${Date.now()}${this.loadTestFontId++}`;let v=this._loadTestFont;v=l(v,976,m.length,m);const y=16,w=1482184792;let A=a(v,y);for(c=0,d=m.length-3;c<d;c+=4)A=A-w+a(m,c)|0;c<m.length&&(A=A-w+a(m+"XXX",c)|0),v=l(v,y,4,o(A));const _=`url(data:font/opentype;base64,${btoa(v)});`,E=`@font-face {font-family:"${m}";src:${_}}`;this.insertRule(E);const x=this._document.createElement("div");x.style.visibility="hidden",x.style.width=x.style.height="10px",x.style.position="absolute",x.style.top=x.style.left="0px";for(const T of[t.loadedName,m]){const C=this._document.createElement("span");C.textContent="Hi",C.style.fontFamily=T,x.append(C)}return this._document.body.append(x),g(m,()=>{x.remove(),e()}),i}}class Xc{#t=new Map;#e;constructor(t,e=null,s,i){this.#e=t,this._inspectFont=e,s&&(this.charProcOperatorList=s),i&&Object.assign(this,i)}createNativeFontFace(){const{data:t}=this;if(!t||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,t,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(Tn(this.cssFontInfo.fontFamily),t,s)}return this._inspectFont?.(this),e}createFontFaceRule(){const{data:t}=this;if(!t||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${t.toBase64()});`;let s;if(!this.cssFontInfo)s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:${Tn(this.cssFontInfo.fontFamily)};${i}src:${e}}`}return this._inspectFont?.(this,e),s}getPathGenerator(t,e){let s=this.#t.get(e);if(s)return s;const i=`${this.loadedName}_path_${e}`;let r;try{r=t.get(i)}catch(n){z(`getPathGenerator - ignoring character: "${n}".`)}return s=da(r?.path),this.fontExtraProperties||t.delete(i),this.#t.set(e,s),s}get black(){return this.#e.black}get bold(){return this.#e.bold}get disableFontFace(){return this.#e.disableFontFace}set disableFontFace(t){L(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#e.fontExtraProperties}get isInvalidPDFjsFont(){return this.#e.isInvalidPDFjsFont}get isType3Font(){return this.#e.isType3Font}get italic(){return this.#e.italic}get missingFile(){return this.#e.missingFile}get remeasure(){return this.#e.remeasure}get vertical(){return this.#e.vertical}get bbox(){return this.#e.bbox}get fontMatrix(){return this.#e.fontMatrix}get fallbackName(){return this.#e.fallbackName}get loadedName(){return this.#e.loadedName}get mimetype(){return this.missingFile?null:"font/opentype"}get data(){return this.#e.data}clearData(){this.#e.clearData()}get cssFontInfo(){return this.#e.cssFontInfo}get systemFontInfo(){return this.#e.systemFontInfo}}class Pi{#t=null;#e=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,s){this._source=t,this.#t=e,this.#e=s}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return _t(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#t(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new this.#e(this,t,e);return this._rangeReaders.add(s),s}cancelAllRequests(t){this._fullReader?.cancel(t);for(const e of new Set(this._rangeReaders))e.cancel(t)}}class Ii{onProgress=null;_contentLength=0;_filename=null;_headersCapability=Promise.withResolvers();_isRangeSupported=!1;_isStreamingSupported=!1;_loaded=0;_stream=null;constructor(t){this._stream=t}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}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(){nt("Abstract method `read` called")}cancel(t){nt("Abstract method `cancel` called")}}class ki{_stream=null;constructor(t,e,s){this._stream=t}async read(){nt("Abstract method `read` called")}cancel(t){nt("Abstract method `cancel` called")}}function Yc(h){let t=!0,e=s("filename\\*","i").exec(h);if(e){e=e[1];let c=a(e);return c=unescape(c),c=o(c),c=l(c),r(c)}if(e=n(h),e){const c=l(e);return r(c)}if(e=s("filename","i").exec(h),e){e=e[1];let c=a(e);return c=l(c),r(c)}function s(c,d){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',d)}function i(c,d){if(c){if(!/^[\x00-\xFF]+$/.test(d))return d;try{const u=new TextDecoder(c,{fatal:!0}),f=Ei(d);d=u.decode(f),t=!1}catch{}}return d}function r(c){return t&&/[\x80-\xff]/.test(c)&&(c=i("utf-8",c),t&&(c=i("iso-8859-1",c))),c}function n(c){const d=[];let u;const f=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=f.exec(c))!==null;){let[,g,m,v]=u;if(g=parseInt(g,10),g in d){if(g===0)break;continue}d[g]=[m,v]}const p=[];for(let g=0;g<d.length&&g in d;++g){let[m,v]=d[g];v=a(v),m&&(v=unescape(v),g===0&&(v=o(v))),p.push(v)}return p.join("")}function a(c){if(c.startsWith('"')){const d=c.slice(1).split('\\"');for(let u=0;u<d.length;++u){const f=d[u].indexOf('"');f!==-1&&(d[u]=d[u].slice(0,f),d.length=u+1),d[u]=d[u].replaceAll(/\\(.)/g,"$1")}c=d.join('"')}return c}function o(c){const d=c.indexOf("'");if(d===-1)return c;const u=c.slice(0,d),p=c.slice(d+1).replace(/^[^']*'/,"");return i(u,p)}function l(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(d,u,f,p){if(f==="q"||f==="Q")return p=p.replaceAll("_"," ").replaceAll(/=([0-9a-f]{2})/gi,(g,m)=>String.fromCharCode(parseInt(m,16))),i(u,p);try{p=atob(p)}catch{}return i(u,p)})}return""}function Ta(h,t){const e=new Headers;if(!h||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function Kc(h){let t=h.length;for(;t>0&&h[t-1]!==" "&&/\s/.test(h[t-1]);)t--;return h.slice(0,t)}function Oi(h){return URL.parse(h)?.origin??null}function xa({responseHeaders:h,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={contentLength:0,isRangeSupported:!1},r=parseInt(h.get("Content-Length"),10);return!Number.isInteger(r)||(i.contentLength=r,r<=2*e)||s||!t||h.get("Accept-Ranges")!=="bytes"||(h.get("Content-Encoding")||"identity")==="identity"&&(i.isRangeSupported=!0),i}function Ca(h){const t=h.get("Content-Disposition");if(t){let e=Yc(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Pr(e))return e}return null}function Mi(h,t){return new Qs(`Unexpected server response (${h}) while retrieving PDF "${t.href}".`,h,h===404||h===0&&t.protocol==="file:")}function Pa(h,t){if(h!==t)throw new Error(`Expected range response-origin "${h}" to match "${t}".`)}function Ia(h,t,e,s){return fetch(h,{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"})}function ka(h,t){if(h!==200&&h!==206)throw Mi(h,t)}function Fi(h){if(h instanceof Uint8Array)return h.buffer;if(h instanceof ArrayBuffer)return h;throw new Error(`getArrayBuffer - unexpected data: ${h}`)}class qc extends Pi{_responseOrigin=null;constructor(t){super(t,Jc,Qc);const{httpHeaders:e,url:s}=t;_t(/https?:/.test(s.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=Ta(!0,e)}}class Jc extends Ii{_abortController=new AbortController;_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:s,rangeChunkSize:i,url:r,withCredentials:n}=t._source;this._isStreamingSupported=!s;const a=new Headers(t.headers);Ia(r,a,n,this._abortController).then(o=>{t._responseOrigin=Oi(o.url),ka(o.status,r),this._reader=o.body.getReader();const l=o.headers,{contentLength:c,isRangeSupported:d}=xa({responseHeaders:l,isHttp:!0,rangeChunkSize:i,disableRange:e});this._contentLength=c,this._isRangeSupported=d,this._filename=Ca(l),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Pe("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:Fi(t),done:!1})}cancel(t){this._reader?.cancel(t).catch(()=>{}),this._abortController.abort()}}class Qc extends ki{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,s){super(t,e,s);const{url:i,withCredentials:r}=t._source,n=new Headers(t.headers);n.append("Range",`bytes=${e}-${s-1}`),Ia(i,n,r,this._abortController).then(a=>{const o=Oi(a.url);Pa(o,t._responseOrigin),ka(a.status,i),this._reader=a.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject),this._readCapability.promise.catch(()=>{})}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:Fi(t),done:!1}}cancel(t){this._reader?.cancel(t).catch(()=>{}),this._abortController.abort()}}function xn(h){return h instanceof Uint8Array&&h.byteLength===h.buffer.byteLength?h.buffer:new Uint8Array(h).buffer}function Ri(){for(const h of this._requests)h.resolve({value:void 0,done:!0});this._requests.length=0}class Zc extends Pi{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,th,eh);const{pdfDataRangeTransport:e}=t,{initialData:s,progressiveDone:i}=e;if(s?.length>0){const n=xn(s);this._queuedChunks.push(n)}this._progressiveDone=i;const r=n=>{switch(n.type){case"range":case"progressiveRead":this.#t(n.begin,n.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone(),this._progressiveDone=!0;break}};e.transportReady(r)}#t(t,e){const s=xn(e);if(t===void 0)this._fullReader?this._fullReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.keys().find(r=>r._begin===t);_t(i,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),i._enqueue(s)}}getFullReader(){const t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){const s=super.getRangeReader(t,e);return s&&(s.onDone=()=>this._rangeReaders.delete(s),this._source.pdfDataRangeTransport.requestDataRange(t,e)),s}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class th extends Ii{#t=Ri.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);const{pdfDataRangeTransport:e,disableRange:s,disableStream:i}=t._source,{length:r,contentDispositionFilename:n}=e;this._queuedChunks=t._queuedChunks||[];for(const o of this._queuedChunks)this._loaded+=o.byteLength;this._done=t._progressiveDone,this._contentLength=r,this._isStreamingSupported=!i,this._isRangeSupported=!s,Pr(n)&&(this._filename=n),this._headersCapability.resolve();const a=this._loaded;Promise.resolve().then(()=>{a>0&&this._loaded===a&&this._callOnProgress()})}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength,this._callOnProgress())}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t()}progressiveDone(){this._done||=!0,this._queuedChunks.length===0&&this.#t()}}class eh extends ki{#t=Ri.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,s){super(t,e,s),this._begin=e}_enqueue(t){this._done||(this._requests.length===0?this._queuedChunk=t:(this._requests.shift().resolve({value:t,done:!1}),this.#t()),this._done=!0,this.onDone?.())}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this.onDone?.()}}const Wi=200,Cn=206;function sh(h){return typeof h!="string"?h:Ei(h).buffer}class ih extends Pi{#t=new WeakMap;_responseOrigin=null;constructor(t){super(t,rh,nh);const{httpHeaders:e,url:s}=t;this.url=s,this.isHttp=/https?:/.test(s.protocol),this.headers=Ta(this.isHttp,e)}_request(t){const e=new XMLHttpRequest,s={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};this.#t.set(e,s),e.open("GET",this.url),e.withCredentials=this._source.withCredentials;for(const[i,r]of this.headers)e.setRequestHeader(i,r);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.validateStatus=i=>i===Cn||i===Wi):s.validateStatus=i=>i===Wi,e.responseType="arraybuffer",_t(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#s.bind(this,e),e.onprogress=this.#e.bind(this,e),e.send(null),e}#e(t,e){this.#t.get(t)?.onProgress?.(e)}#s(t,e){const s=this.#t.get(t);if(!s||(t.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),t.readyState!==4)||!this.#t.has(t))return;if(this.#t.delete(t),t.status===0&&this.isHttp){s.onError(t.status);return}const i=t.status||Wi;if(!s.validateStatus(i)){s.onError(t.status);return}const r=sh(t.response);if(i===Cn){const n=t.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(n)?s.onDone(r):(z('Missing or invalid "Content-Range" header.'),s.onError(0))}else r?s.onDone(r):s.onError(t.status)}_abortRequest(t){this.#t.has(t)&&(this.#t.delete(t),t.abort())}getRangeReader(t,e){const s=super.getRangeReader(t,e);return s&&(s.onClosed=()=>this._rangeReaders.delete(s)),s}}class rh extends Ii{#t=Ri.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t),this._fullRequestXhr=t._request({onHeadersReceived:this.#e.bind(this),onDone:this.#s.bind(this),onError:this.#i.bind(this),onProgress:this.#r.bind(this)})}#e(){const t=this._stream,{disableRange:e,rangeChunkSize:s}=t._source,i=this._fullRequestXhr;t._responseOrigin=Oi(i.responseURL);const r=i.getAllResponseHeaders(),n=new Headers(r?Kc(r.trimStart()).split(/[\r\n]+/).map(l=>{const[c,...d]=l.split(": ");return[c,d.join(": ")]}):[]),{contentLength:a,isRangeSupported:o}=xa({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:s,disableRange:e});this._contentLength=a,this._isRangeSupported=o,this._filename=Ca(n),this._isRangeSupported&&t._abortRequest(i),this._headersCapability.resolve()}#s(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._cachedChunks.push(t),this._done=!0,this._cachedChunks.length===0&&this.#t()}#i(t){this._storedError=Mi(t,this._stream.url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#r(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};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t),this.#t(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class nh extends ki{#t=Ri.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,s){super(t,e,s),this._requestXhr=t._request({begin:e,end:s,onHeadersReceived:this.#e.bind(this),onDone:this.#s.bind(this),onError:this.#i.bind(this),onProgress:null})}#e(){const t=Oi(this._requestXhr?.responseURL);try{Pa(t,this._stream._responseOrigin)}catch(e){this._storedError=e,this.#i(0)}}#s(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0,this.#t(),this.onClosed?.()}#i(t){this._storedError??=Mi(t,this._stream.url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#t(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function Oa(h,t=null){const e=process.getBuiltinModule("fs"),{Readable:s}=process.getBuiltinModule("stream"),i=e.createReadStream(h,t);return s.toWeb(i)}class ah extends Pi{constructor(t){super(t,oh,lh);const{url:e}=t;_t(e.protocol==="file:","PDFNodeStream only supports file:// URLs.")}}class oh extends Ii{_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:s,rangeChunkSize:i,url:r}=t._source;this._isStreamingSupported=!s,process.getBuiltinModule("fs/promises").lstat(r).then(a=>{const o=Oa(r);this._reader=o.getReader();const{size:l}=a;this._contentLength=l,this._isRangeSupported=!e&&l>2*i,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Pe("Streaming is disabled.")),this._headersCapability.resolve()}).catch(a=>{a.code==="ENOENT"&&(a=Mi(0,r)),this._headersCapability.reject(a)})}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:Fi(t),done:!1})}cancel(t){this._reader?.cancel(t).catch(()=>{})}}class lh extends ki{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,s){super(t,e,s);const{url:i}=t._source;try{const r=Oa(i,{start:e,end:s-1});this._reader=r.getReader(),this._readCapability.resolve()}catch(r){this._readCapability.reject(r)}this._readCapability.promise.catch(()=>{})}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:Fi(t),done:!1}}cancel(t){this._reader?.cancel(t).catch(()=>{})}}function ch(h){return bs(h)?qc:Yt?ah:ih}class _e{static#t=null;static#e=[];static#s="";static#i="";static get rendererPorts(){return this.#e}static set rendererPorts(t){if(!Array.isArray(t)||!t.every(e=>typeof Worker<"u"&&e instanceof Worker))throw new Error("Invalid `rendererPorts` type.");this.#e=t}static get rendererSrc(){return this.#s}static set rendererSrc(t){if(typeof t!="string")throw new Error("Invalid `rendererSrc` type.");this.#s=t}static get workerPort(){return this.#t}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");this.#t=t}static get workerSrc(){return this.#i}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");this.#i=t}}class hh{#t;#e;constructor({parsedData:t,rawData:e}){this.#t=t,this.#e=e}getRaw(){return this.#e}get(t){return this.#t.get(t)??null}[Symbol.iterator](){return this.#t.entries()}}class dh{static strings=["fontFamily","fontWeight","italicAngle"]}class uh{static strings=["css","loadedName","baseFontName","src"]}class ts{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static strings=["fallbackName","loadedName"];static OFFSET_BBOX=Math.ceil(this.bools.length*2/8);static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_STRINGS=this.OFFSET_FONT_MATRIX+1+48}class Re{static KIND=0;static HAS_BBOX=1;static HAS_BACKGROUND=2;static SHADING_TYPE=3;static N_COORD=4;static N_COLOR=8;static N_STOP=12;static N_FIGURES=16}class fh{static get decoder(){return L(this,"decoder",new TextDecoder)}static get encoder(){return L(this,"encoder",new TextEncoder)}}function As(h,t,e,s=0){const{decoder:i}=fh;for(let n=0;n<e;n++)s+=t.getUint32(s)+4;const r=t.getUint32(s);return i.decode(new Uint8Array(h,s+4,r))}class ph{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#s(t){return _t(t<dh.strings.length,"Invalid string index"),As(this.#t,this.#e,t)}get fontFamily(){return L(this,"fontFamily",this.#s(0))}get fontWeight(){return L(this,"fontWeight",this.#s(1))}get italicAngle(){return L(this,"italicAngle",this.#s(2))}}class gh{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#s(t){return _t(t<uh.strings.length,"Invalid string index"),As(this.#t,this.#e,t,4)}get css(){return L(this,"css",this.#s(0))}get loadedName(){return L(this,"loadedName",this.#s(1))}get baseFontName(){return L(this,"baseFontName",this.#s(2))}get src(){return L(this,"src",this.#s(3))}get style(){let t=0;t+=4+this.#e.getUint32(t);const e=As(this.#t,this.#e,0,t),s=As(this.#t,this.#e,1,t);return L(this,"style",{style:e,weight:s})}}class mh{#t;#e;constructor(t){this.#t=t,this.#e=new DataView(t)}#s(t){_t(t<ts.bools.length,"Invalid boolean index");const e=Math.floor(t/4),s=t*2%8,i=this.#e.getUint8(e)>>s&3;return i===0?void 0:i===2}get black(){return L(this,"black",this.#s(0))}get bold(){return L(this,"bold",this.#s(1))}get disableFontFace(){return L(this,"disableFontFace",this.#s(2))}get fontExtraProperties(){return L(this,"fontExtraProperties",this.#s(3))}get isInvalidPDFjsFont(){return L(this,"isInvalidPDFjsFont",this.#s(4))}get isType3Font(){return L(this,"isType3Font",this.#s(5))}get italic(){return L(this,"italic",this.#s(6))}get missingFile(){return L(this,"missingFile",this.#s(7))}get remeasure(){return L(this,"remeasure",this.#s(8))}get vertical(){return L(this,"vertical",this.#s(9))}#i(t,e,s,i){const r=this.#e.getUint8(t++);if(r===0)return;_t(r===e,"Invalid array length.");const n=new Array(r);for(let a=0;a<r;a++)n[a]=this.#e[s](t,!0),t+=i;return n}get bbox(){return L(this,"bbox",this.#i(ts.OFFSET_BBOX,4,"getInt16",2))}get fontMatrix(){return L(this,"fontMatrix",this.#i(ts.OFFSET_FONT_MATRIX,6,"getFloat64",8))}#r(t){return _t(t<ts.strings.length,"Invalid string index"),As(this.#t,this.#e,t,ts.OFFSET_STRINGS+4)}get fallbackName(){return L(this,"fallbackName",this.#r(0))}get loadedName(){return L(this,"loadedName",this.#r(1))}#n(t){let e=ts.OFFSET_STRINGS;for(let i=0;i<=t;i++)e+=4+this.#e.getUint32(e);const s=this.#e.getUint32(e);return{offset:e,length:s}}get data(){const{offset:t,length:e}=this.#n(2);return e?new Uint8Array(this.#t,t+4,e):void 0}clearData(){const{offset:t,length:e}=this.#n(2);e&&(this.#e.setUint32(t,0),this.#t=new Uint8Array(this.#t,0,t+4).slice().buffer,this.#e=new DataView(this.#t))}get cssFontInfo(){const{offset:t,length:e}=this.#n(1);let s=null;if(e){const i=new Uint8Array(this.#t,t+4,e).slice();s=new ph(i.buffer)}return L(this,"cssFontInfo",s)}get systemFontInfo(){const{offset:t,length:e}=this.#n(0);let s=null;if(e){const i=new Uint8Array(this.#t,t+4,e).slice();s=new gh(i.buffer)}return L(this,"systemFontInfo",s)}}class vh{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){const t=this.view,e=this.data[Re.KIND],s=!!this.data[Re.HAS_BBOX],i=!!this.data[Re.HAS_BACKGROUND],r=t.getUint32(Re.N_COORD,!0),n=t.getUint32(Re.N_COLOR,!0),a=t.getUint32(Re.N_STOP,!0);let o=20;const l=new Float32Array(this.buffer,o,r*2);o+=r*8;const c=new Uint8Array(this.buffer,o,n*4);o+=n*4;const d=[];for(let p=0;p<a;++p){const g=t.getFloat32(o,!0);o+=4;const m=t.getUint32(o,!0);o+=4,d.push([g,`#${m.toString(16).padStart(6,"0")}`])}let u=null;if(s){u=[];for(let p=0;p<4;++p)u.push(t.getFloat32(o,!0)),o+=4}let f=null;if(i&&(f=new Uint8Array(this.buffer,o,3),o+=3),e===1)return["RadialAxial","axial",u,d,[l[0],l[1]],[l[2],l[3]],null,null];if(e===2)return["RadialAxial","radial",u,d,[l[0],l[1]],[l[3],l[4]],l[2],l[5]];if(e===3){const p=this.data[Re.SHADING_TYPE];let g=null;if(l.length>0){g=ue.slice();for(let m=0,v=l.length;m<v;m+=2)D.pointBoundingBox(l[m],l[m+1],g)}return["Mesh",p,l,c,r,g,u,f]}throw new Error(`Unsupported pattern kind: ${e}`)}}class yh{#t;constructor(t){this.#t=t}get path(){return ot.isFloat16ArraySupported?new Float16Array(this.#t):new Float32Array(this.#t)}}const De=Symbol("INITIAL_DATA"),zi=()=>({...Promise.withResolvers(),data:De});class Fr{#t=new Map;get(t,e=null,s=null){if(e){const r=this.#t.getOrInsertComputed(t,zi);return r.promise.then(()=>e(r.data),s),null}const i=this.#t.get(t);if(!i||i.data===De)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#t.get(t);return!!e&&e.data!==De}delete(t){const e=this.#t.get(t);return!e||e.data===De?!1:(this.#t.delete(t),!0)}resolve(t,e=null){const s=this.#t.getOrInsertComputed(t,zi);if(s.data!==De)throw new Error(`Object already resolved ${t}.`);s.data=e,s.resolve()}reject(t,e){const s=this.#t.getOrInsertComputed(t,zi);s.data===De&&(s.promise.catch(()=>{}),s.reject(e))}clear(){for(const{data:t}of this.#t.values())t?.bitmap?.close();this.#t.clear()}*[Symbol.iterator](){for(const[t,{data:e}]of this.#t)e!==De&&(yield[t,e])}}class bh{constructor({messageHandler:t,commonObjs:e,fontLoader:s,pageCache:i,pdfBug:r=!1,shouldCreatePageObjs:n=!1}){this.messageHandler=t,this.commonObjs=e,this.fontLoader=s,this.pageCache=i,this.pdfBug=r,this.shouldCreatePageObjs=n}resolveCommonObject(t,e,s){if(e==="CopyLocalImage"){const{imageRef:i}=s;_t(i,"The imageRef must be defined.");for(const r of this.pageCache.values()){const n=r.objs||r;for(const[,a]of n){if(a?.ref!==i)continue;if(!a.dataLen)return null;const o=structuredClone(a);return this.commonObjs.resolve(t,o),a.dataLen}}return null}switch(e){case"Font":if("error"in s){const o=s.error;z(`Error during font loading: ${o}`),this.commonObjs.resolve(t,o);break}const i=new mh(s.buffer),r=this.pdfBug&&globalThis.FontInspector?.enabled?(o,l)=>globalThis.FontInspector.fontAdded(o,l):null,n=new Xc(i,r,s.charProcOperatorList,s.extra);this.fontLoader.bind(n).catch(()=>this.messageHandler.sendWithPromise("FontFallback",{id:t}).catch(o=>{z(`FontFallback failed for "${t}": ${o}`)})).finally(()=>{n.fontExtraProperties||n.clearData(),this.commonObjs.resolve(t,n)});break;case"FontPath":this.commonObjs.resolve(t,new yh(s));break;case"Image":this.commonObjs.resolve(t,s);break;case"Pattern":const a=new vh(s);this.commonObjs.resolve(t,a.getIR());break;default:throw new Error(`Got unknown common object type ${e}`)}return null}resolveObject(t,e,s,i){let r=this.pageCache.get(e);if(!r){if(!this.shouldCreatePageObjs)return!1;r=new Fr,this.pageCache.set(e,r)}const n=r.objs||r;if(n.has(t))return!1;if(r._intentStates?.size===0)return i?.bitmap?.close(),!1;switch(s){case"Image":case"Pattern":return n.resolve(t,i),!0;default:throw new Error(`Got unknown object type ${s}`)}}}const Ne=Symbol("INTERNAL");class wh{#t=!1;#e=!1;#s=!1;#i=!0;constructor(t,{name:e,intent:s,usage:i,rbGroups:r}){this.#t=!!(t&Vt.DISPLAY),this.#e=!!(t&Vt.PRINT),this.name=e,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(this.#s)return this.#i;if(!this.#i)return!1;const{print:t,view:e}=this.usage;return this.#t?e?.viewState!=="OFF":this.#e?t?.printState!=="OFF":!0}_setVisible(t,e,s=!1){t!==Ne&&nt("Internal method `_setVisible` called."),this.#s=s,this.#i=e}get serializable(){return{userSet:this.#s,visible:this.#i}}}class Rr{#t=null;#e=new Map;#s=null;#i=null;#r;creator=null;name=null;constructor(t,e=Vt.DISPLAY,s=null){if(this.#r=t,this.renderingIntent=e,t!==null){this.name=t.name,this.creator=t.creator,this.#i=t.order;for(const i of t.groups)this.#e.set(i.id,new wh(e,i));if(s){s.size!==this.#e.size&&nt("Incorrect serialized groupState.");for(const[i,r]of s)this.#e.get(i)._setVisible(Ne,r.visible,r.userSet)}else{if(t.baseState==="OFF")for(const i of this.#e.values())i._setVisible(Ne,!1);for(const i of t.on)this.#e.get(i)._setVisible(Ne,!0);for(const i of t.off)this.#e.get(i)._setVisible(Ne,!1)}this.#s=this.getHash()}}#n(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const r=t[i];let n;if(Array.isArray(r))n=this.#n(r);else if(this.#e.has(r))n=this.#e.get(r).visible;else return z(`Optional content group not found: ${r}`),!0;switch(s){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return s==="And"}isVisible(t){if(this.#e.size===0)return!0;if(!t)return Si("Optional content group not defined."),!0;if(t.type==="OCG")return this.#e.has(t.id)?this.#e.get(t.id).visible:(z(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return this.#n(t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(!this.#e.get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!this.#e.has(e))return z(`Optional content group not found: ${e}`),!0;if(this.#e.get(e).visible)return!1}return!0}return z(`Unknown optional content policy ${t.policy}.`),!0}return z(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){const i=this.#e.get(t);if(!i){z(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const r of i.rbGroups)for(const n of r)n!==t&&this.#e.get(n)?._setVisible(Ne,!1,!0);i._setVisible(Ne,!!e,!0),this.#t=null}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const r=this.#e.get(i);if(r)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!r.visible,e);break}}this.#t=null}get hasInitialVisibility(){return this.#s===null||this.getHash()===this.#s}getOrder(){return this.#e.size?this.#i?this.#i.slice():[...this.#e.keys()]:null}getGroup(t){return this.#e.get(t)||null}getHash(){if(this.#t!==null)return this.#t;const t=new sr;for(const[e,s]of this.#e)t.update(`${e}:${s.visible}`);return this.#t=t.hexdigest()}[Symbol.iterator](){return this.#e.entries()}get serializable(){const t=new Map;for(const[e,s]of this.#e)t.set(e,s.serializable);return{data:this.#r,renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:s}){return new Rr(t,e,s)}}class _h{#t=null;#e=null;#s=0;#i=0;#r=null;#n=null;get pagesNumber(){return this.#s}set pagesNumber(t){this.#s!==t&&(this.#s=this.#i=t,this.#t=null,this.#e=null)}#a(){if(this.#t)return;const t=this.#s,e=this.#t=new Uint32Array(t);for(let s=0;s<t;s++)e[s]=s+1;this.#e=new Int32Array(e)}#o(){const t=new Map,e=this.#t;for(let s=0,i=this.#s;s<i;s++){const r=e[s],n=t.get(r);n?n.push(s+1):t.set(r,[s+1])}return t}movePages(t,e,s){this.#a();const i=this.#t,r=e.length,n=new Uint32Array(r);let a=0;for(let u=0;u<r;u++){const f=e[u]-1;n[u]=i[f],f<s&&a++}const o=this.#s,l=o-r,c=new Int32Array(o),d=ft(s-a,0,l);for(let u=0,f=0;u<o;u++)t.has(u+1)||(i[f]=i[u],c[f++]=u+1);i.copyWithin(d+r,d,l),i.set(n,d),c.copyWithin(d+r,d,l),c.set(e,d),this.#e=c,o===this.#i&&i.every((u,f)=>u===f+1)&&(this.#t=null)}deletePages(t){this.#a();const e=this.#t,s=this.#o();this.#n={pageNumberToId:e.slice(),pagesNumber:this.#s,prevPageNumbers:this.#e.slice()};const i=this.#s-t.length;this.#s=i;const r=this.#t=new Uint32Array(i);this.#e=new Int32Array(i);let n=0,a=0;for(const o of t){const l=o-1;l!==n&&(r.set(e.subarray(n,l),a),a+=l-n),n=l+1}n<e.length&&r.set(e.subarray(n),a),this.#l(s,new Set(t))}cancelDelete(){this.#n&&(this.#t=this.#n.pageNumberToId,this.#s=this.#n.pagesNumber,this.#e=this.#n.prevPageNumbers,this.#n=null)}cleanSavedData(){this.#n=null}copyPages(t){this.#a(),this.#r={pageNumbers:t,pageIds:t.map(e=>this.#t[e-1])}}cancelCopy(){this.#r=null}pastePages(t){this.#a();const e=this.#t,s=this.#o(),{pageNumbers:i,pageIds:r}=this.#r,n=this.#s+i.length;this.#s=n;const a=this.#t=new Uint32Array(n);this.#e=new Int32Array(n),a.set(e.subarray(0,t),0),a.set(r,t),a.set(e.subarray(t),t+i.length),this.#l(s,null,t,i),this.#r=null}#l(t,e=null,s=-1,i=null){const r=this.#e,n=this.#t,a=s+(i?.length??0),o=new Map;for(let l=0,c=this.#s;l<c;l++){if(l>=s&&l<a){r[l]=-i[l-s];continue}const d=n[l],u=t.get(d);let f=o.get(d)||0;if(e&&u)for(;f<u.length&&e.has(u[f]);)f++;r[l]=u?.[f],o.set(d,f+1)}}hasBeenAltered(){return this.#t!==null}#c(t=null){if(!this.#t)return null;const e=new Int32Array(this.#s).fill(-1),s=new Map;if(t)for(const i of t){const r=this.getPageId(i),n=s.get(r)??0;s.set(r,n+1),e[i-1]=n}else for(let i=0,r=this.#s;i<r;i++){const n=this.#t[i],a=s.get(n)??0;s.set(n,a+1),e[i]=a}return e}getPageMappingForSaving(t=null,e=this.#c()){t??=this.#o();let s=0;for(const r of t.values())s=Math.max(s,r.length);const i=new Array(s);for(let r=0;r<s;r++)i[r]={document:null,pageIndices:[],includePages:[]};for(const[r,n]of t)for(let a=0,o=n.length;a<o;a++)i[a].includePages.push([r-1,n[a]-1]);for(const{includePages:r,pageIndices:n}of i){r.sort((a,o)=>a[0]-o[0]);for(let a=0,o=r.length;a<o;a++)n.push(r[a][1]),r[a]=r[a][0]}return{pageInfos:i,copyLevels:e}}extractPages(t){t=Array.from(t).sort((s,i)=>s-i);const e=new Map;for(let s=0,i=t.length;s<i;s++){const r=this.getPageId(t[s]);e.getOrInsertComputed(r,hs).push(s+1)}return this.getPageMappingForSaving(e,this.#c(t))}getPrevPageNumber(t){return this.#e?.[t-1]??0}getPageNumber(t){if(!this.#t)return t;const e=this.#t;for(let s=0,i=this.#s;s<i;s++)if(e[s]===t)return s+1;return 0}getPageId(t){return this.#t?.[t-1]??t}getMapping(){return this.#t?.subarray(0,this.pagesNumber)}}const Pn=5e3;function nr({bitmap:h,annotationBitmaps:t}){if(h?.close(),t)for(const[,,e]of t)e.close()}class Ah{#t;#e=!1;#s;#i;#r=0;#n;#a;#o;#l;#c;#u;#h;imageCoordinates=null;recordedBBoxes=null;constructor({rendererWorker:t,renderTasks:e,canvas:s,canvasFactory:i,annotationCanvasMap:r,operatorListState:n,initParams:a,onFrame:o,onError:l}){this.#u=t,this.#h=e,this.#s=s,this.#i=i,this.#t=r,this.#c=n,this.#a=a,this.#n=a.renderTaskId,this.#l=o,this.#o=l}async initialize(t,e){try{await this.#u.promise}catch{return!1}if(!this.#u.messageHandler||this.#e)return!1;try{await this.#u.sendWithPromise("InitializeGraphics",{...this.#a,width:this.#s.width,height:this.#s.height,transparency:t,optionalContentConfig:e.serializable})}catch(s){return this.#e||z(`Failed to initialize graphics in renderer worker: ${s.message}. Falling back to main-thread rendering.`),!1}return this.#e||this.#h.set(this.#n,this),!0}async executeOperatorList(t,e,s){const i=this.#u.messageHandler;if(!i)throw new Error("Renderer worker was destroyed during rendering.");const{lastChunk:r}=t,n=t.argsArray.length,a=this.#c;if(a.sentLength<n){const c=a.sentLength;i.send("AppendOperatorList",{pageProxyId:this.#a.pageProxyId,operatorListId:a.id,fnArray:t.fnArray.slice(c,n),argsArray:t.argsArray.slice(c,n)}),a.sentLength=n}let o=null;if(s&&this.#r<n){const c=this.#r;o=new Uint8Array(n-c);for(let d=c;d<n;d++)o[d-c]=s(d,t)?1:0;this.#r=n}const l=await this.#u.sendWithPromise("ExecuteOperatorList",{renderTaskId:this.#n,operatorListIdx:e,operatorListLength:n,operationsFilterMask:o,lastChunk:r}).catch(c=>{if(!this.#e)throw c;return{operatorListIdx:e,aborted:!0}});if(l.aborted&&!this.#e)throw new Error("Render task was aborted in the renderer worker.");if(r&&l.operatorListIdx===n){this.#h.delete(this.#n);const{recordedBBoxesBuffer:c,imageCoordinates:d}=l;c&&(this.recordedBBoxes=Ci.fromBuffer(c)),this.imageCoordinates=d??null}return l.operatorListIdx}cancel(){this.#e=!0,this.#h.delete(this.#n),this.#u.messageHandler?.send("CleanupRenderTask",{renderTaskId:this.#n})}drawFrame(t){try{t.bitmap&&this.#i.getNoAlphaContext(this.#s).drawImage(t.bitmap,0,0),t.annotationBitmaps&&this.#f(t.annotationBitmaps)}catch(e){this.#o(e);return}finally{nr(t)}this.#l()}#f(t){const e=this.#t,s=new Set;for(const[i,r,n]of t){const{canvas:a,context:o}=this.#i.create(n.width,n.height);if(o.drawImage(n,0,0),!r){e.set(i,a);continue}Ea(a,r),s.has(i)?e.get(i).push(a):(s.add(i),e.set(i,[a]))}}}class Be{#t=Promise.withResolvers();#e;#s;#i=null;#r=0;#n=new WeakMap;#a=[];#o=new Set;#l=null;#c=null;#u=0;#h=new Map;#f=null;#p=null;#m=null;static#d=0;static#g=new WeakSet;destroyed=!1;constructor({port:t=null,verbosity:e=oa(),enableHWA:s=!1,enableWebGPU:i=!1}={}){this.verbosity=e,this.#e=s,this.#s=i,t?this.#b(t):this.#w()}static get isAvailable(){return(!!_e.rendererSrc||_e.rendererPorts.length>0)&&typeof Worker<"u"&&ot.isOffscreenCanvasSupported&&!!globalThis.document?.fonts}get promise(){return this.#t.promise}get messageHandler(){return this.#i}get port(){return this.#l}#v(){this.#i.on("RenderFrame",e=>{const s=this.#h.get(e.renderTaskId);s?s.drawFrame(e):nr(e)}),this.#t.resolve(),this.#i.send("configure",{verbosity:this.verbosity,enableHWA:this.#e,enableWebGPU:this.#s});const t=this.#a;this.#a=null;for(const e of t)e()}#y(t){this.#a=null,this.#t.reject(t)}#b(t){Be.#g.add(t),this.#l=t;const e=Be.#d++,s=`main${e}`,i=`renderer${e}`;this.#c={sourceName:s,targetName:i};const r=new xe("main","renderer",t);r.send("Connect",{sourceName:i,targetName:s}),r.destroy(),this.#A(t,new xe(s,i,t),!0)}#w(){try{const{rendererSrc:t}=_e;if(!t)throw new Error('No "GlobalWorkerOptions.rendererSrc" specified.');const e=new Worker(va(t),{type:"module"});this.#A(e,new xe("main","renderer",e),!1)}catch(t){this.#y(t)}}#A(t,e,s){let i=null;const r=o=>{this.#f=null,clearTimeout(i),n.abort(),e.destroy(),s?this.#l=null:t.terminate(),this.#y(new Error(`Renderer worker failed to initialize: "${o?.message??o}".`))};this.#f=r;const n=new AbortController,a=(o,l)=>{if(!this.#i){r(l);return}o.preventDefault(),z(`Renderer worker failed: "${l}". Falling back to main-thread rendering.`),this.destroy()};t.addEventListener("error",o=>a(o,o.error?.message??o.message),{signal:n.signal}),t.addEventListener("messageerror",o=>a(o,"Cannot deserialize a message."),{signal:n.signal}),s&&(i=setTimeout(()=>r("Connection timed out."),Pn)),e.on("ready",o=>{if(!(o?.testObj instanceof Uint8Array)){r("TypedArray transfer test failed.");return}const l="6.5.438";if(l!==o.workerVersion){r(`The API version "${l}" does not match the Worker version "${o.workerVersion}".`);return}this.#f=null,clearTimeout(i),this.#i=e,s||(this.#p=t),this.#m=n,this.#v()})}destroy(){this.destroyed=!0,this.#l&&(this.#i&&(this.#S(this.#l),this.#i.send("Disconnect",null)),Be.#g.delete(this.#l),this.#l=null),this.#f?.("Worker was destroyed."),this.#m?.abort(),this.#m=null,this.#p?.terminate(),this.#p=null,this.#i?.destroy(),this.#i=null;for(const t of this.#o)t(new Error("Renderer worker was destroyed."));this.#o.clear()}#S(t){const{sourceName:e,targetName:s}=this.#c,i=new AbortController,r=setTimeout(()=>i.abort(),Pn);t.addEventListener("message",({data:n})=>{n?.targetName!==e||n.sourceName!==s||(n.action==="RenderFrame"?nr(n.data):n.action==="Disconnected"&&(clearTimeout(r),i.abort()))},{signal:i.signal})}static create({ports:t=[],...e}={}){const s=t.find(i=>!this.#g.has(i))??null;return!s&&t.length>0&&z("RendererWorker.create - no unused `rendererPorts` available, falling back to `rendererSrc`."),new Be({...e,port:s})}sendWithPromise(t,e){const s=this.#i;if(!s)return Promise.reject(new Error("Renderer worker was destroyed."));const{promise:i,resolve:r,reject:n}=Promise.withResolvers();return this.#o.add(n),s.sendWithPromise(t,e).then(r,n),i.finally(()=>{this.#o.delete(n)})}#_(t,e){if(this.#a){this.#a.push(()=>this.#_(t,e));return}this.#i?.send(t,e)}#E(t,e,s,i,r=!1){try{if(this.#a){const n=r?structuredClone(e):e;this.#a.push(()=>this.#E(t,n,s,i));return}this.#i?.send(t,e)}catch(n){z(`RendererWorker - failed to send "${t}": ${n}`),this.#_("objFailed",{id:s,pageProxyId:i,reason:n.message})}}sendCommonObj(t,e,s){this.#E("commonobj",[t,e,s],t,null,e==="Font")}sendObj(t,e,s,i){this.#E("obj",[t,e,s,i],t,e)}cleanup(t){this.#_("Cleanup",{keepLoadedFonts:t})}cleanupPage(t){this.#_("cleanupPage",{pageProxyId:t})}createRenderTask({pageProxyId:t,operatorList:e,params:s,pageColors:i,canvasFactory:r,annotationCanvasMap:n,onFrame:a,onError:o}){const{canvas:l,canvasContext:c,background:d}=s;if(!this.#i&&!this.#a||c||d&&typeof d!="string"||i||s.recordForDebugger)return null;const u=this.#n.getOrInsertComputed(e,()=>({id:this.#r++,sentLength:0}));return new Ah({rendererWorker:this,renderTasks:this.#h,canvas:l,canvasFactory:r,annotationCanvasMap:n,operatorListState:u,initParams:{pageProxyId:t,operatorListId:u.id,renderTaskId:this.#u++,hasAnnotationCanvasMap:!!n,recordOperations:s.recordOperations,recordImages:s.recordImages,partialFrames:s.partialFrames,transform:s.transform,viewport:s.viewport,background:d,pixelRatio:Jt.pixelRatio},onFrame:a,onError:o})}}const Sh=1e5,Eh=30;class Xt{#t=Promise.withResolvers();#e=null;#s=!1;#i=!!globalThis.FontInspector?.enabled;#r=null;#n=null;#a=null;#o=0;#l=0;#c=Jt.pixelRatio;#u=null;#h=null;#f=0;#p=0;#m=Object.create(null);#d=[];#g=null;#v=[];#y=null;static#b=new Map;static#w=new Map;static#A=new WeakMap;static#S=null;static#_=new Set;constructor({textContentSource:t,images:e,container:s,viewport:i}){if(t instanceof ReadableStream)this.#g=t;else if(typeof t=="object")this.#g=new ReadableStream({start(l){l.enqueue(t),l.close()}});else throw new Error('No "textContentSource" parameter specified.');this.#e=this.#h=s,this.#r=e,this.#p=i.scale*this.#c,this.#f=i.rotation,this.#a={div:null,properties:null,ctx:null};const{pageWidth:r,pageHeight:n,pageX:a,pageY:o}=i.rawDims;this.#y=[1,0,0,-1,-a,o+n],this.#l=r,this.#o=n,Xt.#M(),s.style.setProperty("--min-font-size",Xt.#S),Ge(s,i),this.#t.promise.finally(()=>{Xt.#_.delete(this),this.#a=null,this.#m=null}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=ot.platform;return L(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){this.#r&&this.#e.append(this.#r.render());const t=()=>{this.#u.read().then(({value:e,done:s})=>{if(s){this.#t.resolve();return}this.#n??=e.lang,Object.assign(this.#m,e.styles),this.#E(e.items),t()},this.#t.reject)};return this.#u=this.#g.getReader(),Xt.#_.add(this),t(),this.#t.promise}update({viewport:t}){const e=t.scale*Jt.pixelRatio,s=t.rotation;s!==this.#f&&(this.#f=s,Ge(this.#h,{rotation:s})),e!==this.#p&&(this.#p=e,this.#c=Jt.pixelRatio)}cancel(){const t=new Pe("TextLayer task cancelled.");this.#u?.cancel(t).catch(()=>{}),this.#u=null,this.#t.reject(t)}get textDivs(){return this.#v}get textContentItemsStr(){return this.#d}#E(t){if(this.#s)return;this.#a.ctx??=Xt.#C(this.#n);const e=this.#v,s=this.#d;for(const i of t){if(e.length>Sh){z("Ignoring additional textDivs for performance reasons."),this.#s=!0;return}if(i.str===void 0){if(i.type==="beginMarkedContentProps"||i.type==="beginMarkedContent"){const r=this.#e;this.#e=document.createElement("span"),this.#e.classList.add("markedContent"),i.id&&this.#e.setAttribute("id",i.id),i.tag==="Artifact"&&(this.#e.ariaHidden=!0),r.append(this.#e)}else i.type==="endMarkedContent"&&(this.#e=this.#e.parentNode);continue}s.push(i.str),this.#O(i)}}#O(t){const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};this.#v.push(e);const i=D.transform(this.#y,t.transform);let r=Math.atan2(i[1],i[0]);const n=this.#m[t.fontName];n.vertical&&(r+=Math.PI/2);let a=this.#i&&n.fontSubstitution||n.fontFamily;a=Xt.fontFamilyMap.get(a)||a;const o=Math.hypot(i[2],i[3]),l=o*Xt.#D(a,n,this.#n);let c,d;r===0?(c=i[4],d=i[5]-l):(c=i[4]+l*Math.sin(r),d=i[5]-l*Math.cos(r));const u=e.style;u.left=`${(100*c/this.#l).toFixed(2)}%`,u.top=`${(100*d/this.#o).toFixed(2)}%`;const f=Math.round(o*100)/100;u.setProperty("--font-height",`${f}px`),u.fontFamily=a,s.fontSize=f,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#i&&(e.dataset.fontName=n.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let p=!1;if(t.str.length>1)p=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const g=Math.abs(t.transform[0]),m=Math.abs(t.transform[3]);g!==m&&Math.max(g,m)/Math.min(g,m)>1.5&&(p=!0)}if(p&&(s.canvasWidth=n.vertical?t.height:t.width),this.#a.div=e,this.#a.properties=s,this.#P(this.#a),s.hasText&&this.#e.append(e),s.hasEOL){const g=document.createElement("br");g.setAttribute("role","presentation"),this.#e.append(g)}}#P(t){const{div:e,properties:s,ctx:i}=t,{style:r}=e,{canvasWidth:n,fontSize:a}=s;if(n!==0&&a!==0&&s.hasText){const{fontFamily:o}=r,l=this.#c,c=Xt.#R(a*this.#p/l)*l;Xt.#I(i,c,o);const{width:d}=i.measureText(e.textContent);d>0&&r.setProperty("--scale-x",n*c/(d*a))}s.angle!==0&&r.setProperty("--rotate",`${s.angle}deg`)}static cleanup(){if(!(this.#_.size>0)){this.#b.clear();for(const{canvas:t}of this.#w.values())t.remove();this.#w.clear()}}static#C(t=null){let e=this.#w.get(t||="");if(!e){const s=document.createElement("canvas");s.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#w.set(t,e),this.#A.set(e,{size:0,family:""})}return e}static#R(t){t=Math.fround(t);const e=Math.fround(t*((1<<17)+1));return Math.fround(e-Math.fround(e-t))}static#I(t,e,s){const i=this.#A.get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)}static#M(){if(this.#S!==null)return;const 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.#S=t.getBoundingClientRect().height,t.remove()}static#D(t,e,s){const i=this.#b.get(t);if(i)return i;const r=this.#C(s);this.#I(r,Eh,t);const n=r.measureText(""),a=n.fontBoundingBoxAscent,o=Math.abs(n.fontBoundingBoxDescent);let l=.8;return a?l=a/(a+o):(ot.platform.isFirefox&&z("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.#b.set(t,l),l}}const Th=100;function xh(h={}){const t=new Dr,{docId:e}=t,s=h.url?dc(h.url):null,i=h.data?uc(h.data):null,r=h.httpHeaders||null,n=h.withCredentials===!0,a=h.password??null,o=h.range instanceof Ma?h.range:null,l=Number.isInteger(h.rangeChunkSize)&&h.rangeChunkSize>0?h.rangeChunkSize:2**16;let c=h.worker instanceof xs?h.worker:null;const d=h.verbosity,u=typeof h.docBaseUrl=="string"&&!Ti(h.docBaseUrl)?h.docBaseUrl:null,f=Bs(h.cMapUrl),p=h.cMapPacked!==!1,g=Bs(h.iccUrl),m=Bs(h.standardFontDataUrl),v=Bs(h.wasmUrl),b=h.stopAtErrors!==!0,y=Number.isInteger(h.maxImageSize)&&h.maxImageSize>-1?h.maxImageSize:-1,w=typeof h.isOffscreenCanvasSupported=="boolean"?h.isOffscreenCanvasSupported:!Yt,A=typeof h.isImageDecoderSupported=="boolean"?h.isImageDecoderSupported:!Yt,_=Number.isInteger(h.canvasMaxAreaInBytes)?h.canvasMaxAreaInBytes:-1,E=typeof h.disableFontFace=="boolean"?h.disableFontFace:Yt,x=h.fontExtraProperties===!0,T=h.enableXfa===!0,C=h.ownerDocument||globalThis.document,P=h.disableRange===!0,k=h.disableStream===!0,R=h.disableAutoFetch===!0,B=h.pdfBug===!0,U=h.CanvasFactory||(Yt?Sc:Gc),M=h.FilterFactory||(Yt?Ac:Wc),O=h.BinaryDataFactory||(Yt?Ec:un),V=h.enableHWA===!0,q=h.enableWebGPU===!0;q&&ya();const Q=h.useWasm!==!1,Z=h.pagesMapper||new _h,K=null,F=typeof h.useSystemFonts=="boolean"?h.useSystemFonts:!Yt&&!E,I=typeof h.useWorkerFetch=="boolean"?h.useWorkerFetch:!!(O===un&&f&&p&&m&&v&&bs(f,document.baseURI)&&bs(m,document.baseURI)&&bs(v,document.baseURI)),N=h.disableWorkerRendering===!0||!w||C!==globalThis.document||!1||!Be.isAvailable;Gl(d);const G={canvasFactory:new U({ownerDocument:C,enableHWA:V}),filterFactory:new M({docId:e,ownerDocument:C}),binaryDataFactory:I?null:new O({cMapUrl:f,standardFontDataUrl:m,wasmUrl:v})};if(c||(c=xs.create({verbosity:d,port:_e.workerPort}),t._worker=c),!N){const $=Be.create({verbosity:d,enableHWA:V,enableWebGPU:q,ports:_e.rendererPorts});$.promise.catch(J=>{$.destroyed||(z(`Renderer worker disabled: ${J.message}`),$.destroy())}),t._rendererWorker=$}const W={docId:e,apiVersion:"6.5.438",data:i,password:a,disableAutoFetch:R,rangeChunkSize:l,docBaseUrl:u,enableXfa:T,evaluatorOptions:{maxImageSize:y,disableFontFace:E,ignoreErrors:b,isOffscreenCanvasSupported:w,isImageDecoderSupported:A,canvasMaxAreaInBytes:_,fontExtraProperties:x,useSystemFonts:F,useWasm:Q,useWorkerFetch:I,cMapUrl:f,cMapPacked:p,iccUrl:g,standardFontDataUrl:m,wasmUrl:v}},tt={ownerDocument:C,pdfBug:B,styleElement:K,rendererWorker:t._rendererWorker,enableWebGPU:q,loadingParams:{disableAutoFetch:R,enableXfa:T}};return c.promise.then(function(){if(c.destroyed)throw new Error("Worker was destroyed");const $=c.messageHandler.sendWithPromise("GetDocRequest",W,i?[i.buffer]:null);let J;if(!i)if(o)J=new Zc({pdfDataRangeTransport:o,disableRange:P,disableStream:k});else if(s){const ct=ch(s);J=new ct({url:s,httpHeaders:r,withCredentials:n,rangeChunkSize:l,disableRange:P,disableStream:k})}else throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");return $.then(ct=>{if(c.destroyed)throw new Error("Worker was destroyed");const Mt=new xe(e,ct,c.port),ht=new Ph(Mt,t,J,tt,G,Z);if(t._transport=ht,t.destroyed)throw new Error("Loading aborted");Mt.send("Ready",null)})}).catch(t._capability.reject).finally(t._setupCapability.resolve),t}class Dr{static#t=0;_capability=Promise.withResolvers();_setupCapability=Promise.withResolvers();_transport=null;_worker=null;_rendererWorker=null;docId=`d${Dr.#t++}`;destroyed=!1;onPassword=null;onProgress=null;get promise(){return this._capability.promise}async destroy(){this.destroyed=!0,this._capability.promise.catch(()=>{});try{this._worker?.port&&(this._worker._pendingDestroy=!0),await this._setupCapability.promise,await this._transport?.destroy()}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}finally{this._rendererWorker?.destroy(),this._rendererWorker=null}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class Ma{#t=Promise.withResolvers();#e=null;constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}onDataRange(t,e){this.#e({type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){this.#t.promise.then(()=>{this.#e({type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){this.#t.promise.then(()=>{this.#e({type:"progressiveDone"})})}transportReady(t){this.#e=t,this.#t.resolve()}requestDataRange(t,e){nt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class Ch{constructor(t,e){this._pdfInfo=t,this._transport=e}get pagesMapper(){return this._transport.pagesMapper}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 L(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()}getAttachmentContent(t){return this._transport.getAttachmentContent(t)}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(t){return this._transport.saveDocument(t)}extractPages(t,e=null){return this._transport.extractPages(t,e)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}getSignatures(){return this._transport.getSignatures()}getSignatureData(t){return this._transport.getSignatureData(t)}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class ei{#t=!1;#e=null;static#s=0;constructor(t,e,s,i,r=!1){this._pageIndex=t,this._id=ei.#s++,this._pageInfo=e,this._transport=s,this._stats=r?new hn:null,this._pdfBug=r,this.commonObjs=s.commonObjs,this.objs=new Fr,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#e=i,this.imageCoordinates=null}clone(t){const e=new ei(t,this._pageInfo,this._transport,this.#e,this._pdfBug);return e.clonedFromIndex=this.clonedFromIndex??this._pageIndex,this._transport.updatePage(e),e}get pageNumber(){return this._pageIndex+1}set pageNumber(t){this._pageIndex=t-1,this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:r=!1}={}){return new Fs({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return L(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:r=Ee.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:d=null,isEditing:u=!1,recordImages:f=!1,recordOperations:p=!1,partialFrames:g=!1,operationsFilter:m=null}){this._stats?.time("Overall");const v=this._transport.getRenderingIntent(i,r,d,u),{renderingIntent:b,cacheKey:y}=v;this.#t=!1,o||=this._transport.getOptionalContentConfig(b);const w=this._intentStates.getOrInsertComputed(y,Ji);w.streamReaderCancelTimeout&&(clearTimeout(w.streamReaderCancelTimeout),w.streamReaderCancelTimeout=null);const A=!!(b&Vt.PRINT);w.displayReadyCapability||(w.displayReadyCapability=Promise.withResolvers(),w.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(v));const _=!!(this._pdfBug&&globalThis.StepperManager?.enabled),E=!!e&&!this.recordedBBoxes&&(p||_),x=!!e&&!this.imageCoordinates&&f,T=k=>{if(w.renderTasks.delete(C),E){const{recordedBBoxes:R}=C;R&&(C.stepper?.setOperatorBBoxes(R,C.debugMetadata),p&&(this.recordedBBoxes=R))}x&&!k&&(this.imageCoordinates=C.imageCoordinates),A&&(this.#t=!0),this.#i(),k?(C.capability.reject(k),this._abortOperatorList({intentState:w,reason:k instanceof Error?k:new Error(k)})):C.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},C=new rs({callback:T,params:{canvas:e,canvasContext:t,viewport:s,transform:n,background:a,recordOperations:E,recordImages:x,partialFrames:g,recordForDebugger:_},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:w.operatorList,pageIndex:this._pageIndex,pageProxyId:this._id,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!A,pdfBug:this._pdfBug,pageColors:c,operationsFilter:m,rendererWorker:this._transport.rendererWorker,waitForGPU:()=>this._transport.waitForGPU()});(w.renderTasks||=new Set).add(C);const P=C.task;return Promise.all([w.displayReadyCapability.promise,o]).then(async([k,R])=>{if(this.destroyed){T();return}if(this._stats?.time("Rendering"),!(R.renderingIntent&b))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");await C.initializeGraphics({transparency:k,optionalContentConfig:R}),C.operatorListChanged()}).catch(T),P}getOperatorList({intent:t="display",annotationMode:e=Ee.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){function r(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(o))}const n=this._transport.getRenderingIntent(t,e,s,i,!0),a=this._intentStates.getOrInsertComputed(n.cacheKey,Ji);let o;return a.opListReadCapability||(o=Object.create(null),o.operatorListChanged=r,a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(o),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size:i=>i.items.length})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(r=>Ss.textContent(r));const s=this.streamTextContent(t).getReader(),i={items:[],styles:Object.create(null),lang:null};for(;;){const{value:r,done:n}=await s.read();if(n)break;i.lang??=r.lang,Object.assign(i.styles,r.styles),i.items.push(...r.items)}return i}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),this._transport.cleanupPage(this._id),this.#t=!1,Promise.all(t)}cleanup(t=!1){this.#t=!0;const e=this.#i();return t&&e&&(this._stats&&=new hn),e}#i(){if(!this.#t||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this._transport.cleanupPage(this._id),this.#t=!1,!0}_startRenderPage(t,e){const s=this._intentStates.get(e);s&&(this._stats?.timeEnd("Page Request"),s.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&this.#i()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:r,transfer:n}=s,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#e.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,pageProxyId:this._id,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:i},void 0,n).getReader(),l=this._intentStates.get(e);l.streamReader=o;const c=()=>{o.read().then(({value:d,done:u})=>{if(u){l.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(d,l),c())},d=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){l.operatorList.lastChunk=!0;for(const u of l.renderTasks)u.operatorListChanged();this.#i()}if(l.displayReadyCapability)l.displayReadyCapability.reject(d);else if(l.opListReadCapability)l.opListReadCapability.reject(d);else throw d}})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof xr){let i=Th;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 Pe(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,r]of this._intentStates)if(r===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}var Te,ne,be,je,ii,He,$e,Wt,Ys,Fa,Ra,Ks,ns,qs;const kt=class kt{constructor({name:t=null,port:e=null,verbosity:s=oa()}={}){le(this,Wt);le(this,Te,Promise.withResolvers());le(this,ne,null);le(this,be,null);le(this,je,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(mt(kt,$e).has(e))throw new Error("Cannot use more than one PDFWorker per port.");mt(kt,$e).set(e,this),ge(this,Wt,Fa).call(this,e)}else ge(this,Wt,Ra).call(this)}get promise(){return mt(this,Te).promise}get port(){return mt(this,be)}get messageHandler(){return mt(this,ne)}destroy(){this.destroyed=!0,mt(this,je)?.terminate(),Ht(this,je,null),mt(kt,$e).delete(mt(this,be)),Ht(this,be,null),mt(this,ne)?.destroy(),Ht(this,ne,null)}static create(t){const e=mt(this,$e).get(t?.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new kt(t)}static get workerSrc(){if(_e.workerSrc)return _e.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return L(this,"_setupFakeWorkerGlobal",(async()=>mt(this,ns,qs)?mt(this,ns,qs):(await import(this.workerSrc)).WorkerMessageHandler)())}};Te=new WeakMap,ne=new WeakMap,be=new WeakMap,je=new WeakMap,ii=new WeakMap,He=new WeakMap,$e=new WeakMap,Wt=new WeakSet,Ys=function(){mt(this,Te).resolve(),mt(this,ne).send("configure",{verbosity:this.verbosity})},Fa=function(t){Ht(this,be,t),Ht(this,ne,new xe("main","worker",t)),mt(this,ne).on("ready",()=>{}),ge(this,Wt,Ys).call(this)},Ra=function(){if(mt(kt,He)||mt(kt,ns,qs)){ge(this,Wt,Ks).call(this);return}const{workerSrc:t}=kt;try{const e=new Worker(va(t),{type:"module"}),s=new xe("main","worker",e),i=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?mt(this,Te).reject(new Error("Worker was destroyed")):ge(this,Wt,Ks).call(this)},r=new AbortController;e.addEventListener("error",()=>{mt(this,je)||i()},{signal:r.signal}),s.on("ready",n=>{if(r.abort(),this.destroyed||!(n instanceof Uint8Array)){i();return}Ht(this,ne,s),Ht(this,be,e),Ht(this,je,e),ge(this,Wt,Ys).call(this)})}catch{Si("The worker has been disabled."),ge(this,Wt,Ks).call(this)}},Ks=function(){mt(kt,He)||(z("Setting up fake worker."),Ht(kt,He,!0)),kt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){mt(this,Te).reject(new Error("Worker was destroyed"));return}const e=new mc;Ht(this,be,e);const s=`fake${tn(kt,ii)._++}`,i=new xe(s+"_worker",s,e);t.setup(i,e),Ht(this,ne,new xe(s,s+"_worker",e)),ge(this,Wt,Ys).call(this)}).catch(t=>{mt(this,Te).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},ns=new WeakSet,qs=function(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}},le(kt,ns),le(kt,ii,0),le(kt,He,!1),le(kt,$e,new WeakMap),Yt&&(Ht(kt,He,!0),_e.workerSrc||="./pdf.worker.mjs");let xs=kt;class Ph{downloadInfoCapability=Promise.withResolvers();#t=null;#e=!1;#s=new Map;#i=null;#r=new Map;#n=new Map;#a=new Map;#o=null;#l=null;constructor(t,e,s,i,r,n){this.messageHandler=t,this.loadingTask=e,this.#i=s,this.commonObjs=new Fr,this.fontLoader=new Vc({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.rendererWorker=i.rendererWorker,this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.binaryDataFactory=r.binaryDataFactory,this.pagesMapper=n,this.destroyed=!1,this.destroyCapability=null,this.setupMessageHandler()}updatePage(t){this.#r.set(t._id,t),this.#n.set(t._pageIndex,Promise.resolve(t))}#c(t,e=null){return this.#s.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))}#u({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:e?ft(Math.round(t/e*100),0,100):NaN})}get annotationStorage(){return L(this,"annotationStorage",new Or)}getRenderingIntent(t,e=Ee.ENABLE,s=null,i=!1,r=!1){let n=Vt.DISPLAY,a=Es;switch(t){case"any":n=Vt.ANY;break;case"display":break;case"print":n=Vt.PRINT;break;default:z(`getRenderingIntent - invalid intent: ${t}`)}const o=n&Vt.PRINT&&s instanceof ma?s:this.annotationStorage;switch(e){case Ee.DISABLE:n+=Vt.ANNOTATIONS_DISABLE;break;case Ee.ENABLE:break;case Ee.ENABLE_FORMS:n+=Vt.ANNOTATIONS_FORMS;break;case Ee.ENABLE_STORAGE:n+=Vt.ANNOTATIONS_STORAGE,a=o.serializable;break;default:z(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(n+=Vt.IS_EDITING),r&&(n+=Vt.OPLIST);const{ids:l,hash:c}=o.modifiedIds,d=[n,a.hash,c];return{renderingIntent:n,cacheKey:d.join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#o?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const s of this.#r.values())t.push(s._destroy());this.#r.clear(),this.#n.clear(),this.#a.clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#s.clear(),this.filterFactory.destroy(),Xt.cleanup(),this.#i?.cancelAllRequests(new Pe("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.rendererWorker=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(i,r)=>{_t(this.#i,"GetReader - no `BasePDFStream` instance available."),this.#t=this.#i.getFullReader(),this.#t.onProgress=n=>this.#u(n),r.onPull=()=>{this.#t.read().then(function({value:n,done:a}){if(a){r.close();return}_t(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{r.error(n)})},r.onCancel=n=>{this.#t.cancel(n),r.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async i=>{await this.#t.headersReady;const{isStreamingSupported:r,isRangeSupported:n,contentLength:a}=this.#t;return r&&n&&(this.#t.onProgress=null),{isStreamingSupported:r,isRangeSupported:n,contentLength:a}}),t.on("GetRangeReader",(i,r)=>{_t(this.#i,"GetRangeReader - no `BasePDFStream` instance available.");const n=this.#i.getRangeReader(i.begin,i.end);if(!n){r.close();return}r.onPull=()=>{n.read().then(function({value:a,done:o}){if(o){r.close();return}_t(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),r.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{r.error(a)})},r.onCancel=a=>{n.cancel(a),r.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("GetDoc",({pdfInfo:i})=>{this.pagesMapper.pagesNumber=i.numPages,this._numPages=i.numPages,this._htmlForXfa=i.htmlForXfa,delete i.htmlForXfa,e._capability.resolve(new Ch(i,this))}),t.on("DocException",i=>{e._capability.reject($t(i))}),t.on("PasswordRequest",i=>{this.#o=Promise.withResolvers();try{if(!e.onPassword)throw $t(i);const r=n=>{n instanceof Error?this.#o.reject(n):this.#o.resolve({password:n})};e.onPassword(r,i.code)}catch(r){this.#o.reject(r)}return this.#o.promise}),t.on("DataLoaded",i=>{this.#u({loaded:i.length,total:i.length}),this.downloadInfoCapability.resolve(i)}),t.on("StartRenderPage",i=>{if(this.destroyed)return;this.#r.get(i.pageProxyId)._startRenderPage(i.transparency,i.cacheKey)});const s=new bh({messageHandler:t,commonObjs:this.commonObjs,fontLoader:this.fontLoader,pageCache:this.#r,pdfBug:this._params.pdfBug});this.rendererWorker?.promise.then(()=>{this.rendererWorker?.messageHandler?.on("FontFallback",i=>this.destroyed?null:t.sendWithPromise("FontFallback",i))},()=>{}),t.on("commonobj",([i,r,n])=>{if(this.destroyed)return null;const{rendererWorker:a}=this;if(r==="CopyLocalImage"){if(this.commonObjs.has(i))return null;const o=s.resolveCommonObject(i,r,n);return o&&a?.sendCommonObj(i,"Image",this.commonObjs.get(i)),o}return a?.sendCommonObj(i,r,n),this.commonObjs.has(i)||(s.resolveCommonObject(i,r,n),r==="Pattern"&&this.commonObjs.get(i)[0]==="Mesh"&&(this.#e=!0)),null}),t.on("obj",([i,r,n,a])=>{this.destroyed||(n==="Pattern"&&a[0]==="Mesh"&&(this.#e=!0),s.resolveObject(i,r,n,a)&&this.rendererWorker?.sendObj(i,r,n,a))}),t.on("DocProgress",i=>{this.destroyed||this.#u(i)}),t.on("FetchBinaryData",async i=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(i)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(t=null){this.annotationStorage.size<=0&&z("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:s}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,supportsPrintToPDF:this.#l!==null,filename:this.#t?.filename??null},s).finally(()=>{this.#l=null,this.annotationStorage.resetModified()})}extractPages(t,e=null){const s={pageInfos:t};let i;const r=globalThis.ImageBitmap;if(typeof r=="function"){const n=Array.isArray(t)?t:[t];for(const a of n)a?.image instanceof r&&(i||=[]).push(a.image)}if(this.annotationStorage.size>0){const n=this.annotationStorage.serializable;let{map:a}=n;n.transfer?.length&&(i?i.push(...n.transfer):i=n.transfer);const o=this.pagesMapper.getMapping();if(o){const l=new Map;for(const[c,d]of a){if(d?.pageIndex!==void 0&&d.pageIndex>=0&&d.pageIndex<o.length){const u=e?.[d.pageIndex]??0,f=o[d.pageIndex]-1;if(f!==d.pageIndex||u!==0){l.set(c,{...d,pageIndex:f,copyLevel:u});continue}}l.set(c,d)}a=l}s.annotationStorage=a}return this.messageHandler.sendWithPromise("ExtractPages",s,i).finally(()=>{this.annotationStorage.resetModified()})}waitForGPU(){return this._params.enableWebGPU&&this.#e&&!ba()?ya():null}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.pagesMapper.getPageId(t)-1,i=this.#n.get(e);if(i)return i;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:s}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#a.set(n.refStr,s);const a=new ei(e,n,this,this.pagesMapper,this._params.pdfBug);return this.#r.set(a._id,a),a});return this.#n.set(e,r),r}async getPageIndex(t){if(!ir(t))throw new Error("Invalid pageIndex request.");const e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),s=this.pagesMapper.getPageNumber(e+1);if(s===0)throw new Error("GetPageIndex: page has been removed.");return s-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#c("GetFieldObjects")}getSignatures(){return this.#c("GetSignatures")}getSignatureData(t){return this.messageHandler.sendWithPromise("GetSignatureData",t)}hasJSActions(){return this.#c("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAttachmentContent(t){return this.messageHandler.sendWithPromise("GetAttachmentContent",t)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#c("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(t+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){const e="GetOptionalContentConfig";return this.#s.getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,null).catch(s=>(z(`${e}: "${s}".`),null))).then(s=>new Rr(s,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata";return this.#s.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(e=>({info:e[0],metadata:e[1]?new hh(e[1]):null,contentDispositionFilename:this.#t?.filename??null,contentLength:this.#t?.contentLength??null,hasStructTree:e[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#r.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.rendererWorker?.cleanup(t),this.#s.clear(),this.filterFactory.destroy(!0),Xt.cleanup()}}cleanupPage(t){this.destroyed||this.messageHandler.send("CleanupPage",{pageProxyId:t}),this.rendererWorker?.cleanupPage(t)}cachedPageNumber(t){if(!ir(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`,s=this.#a.get(e);if(s>=0){const i=this.pagesMapper.getPageNumber(s+1);if(i!==0)return i}return null}}class Ih{_internalRenderTask=null;onContinue=null;onError=null;onFrame=null;constructor(t){this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&e?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}get isWorkerRendering(){return this._internalRenderTask.isWorkerRendering}}class rs{#t=null;#e=null;#s=null;#i=null;#r=null;static#n=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:n,pageIndex:a,pageProxyId:o,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:d=!1,pdfBug:u=!1,pageColors:f=null,operationsFilter:p=null,rendererWorker:g=null,waitForGPU:m=null}){this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=n,this._pageIndex=a,this.canvasFactory=l,this.filterFactory=c,this._pdfBug=u,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=d===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Ih(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._operationsFilter=p,this.#r=m,this.#i=g?.createRenderTask({pageProxyId:o,operatorList:n,params:e,pageColors:f,canvasFactory:l,annotationCanvasMap:r,onFrame:()=>this.task.onFrame?.(),onError:v=>this.cancel(v)})??null}get completed(){return this.capability.promise.catch(()=>{})}get isWorkerRendering(){return!!this.#i}get imageCoordinates(){return this.#i?this.#i.imageCoordinates:this.#e?.take()}get recordedBBoxes(){return this.#i?this.#i.recordedBBoxes:this.#t?.take()}get debugMetadata(){return this.#t?.takeDebugMetadata()??null}async initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(!this.cancelled){if(this._canvas){if(rs.#n.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");rs.#n.add(this._canvas)}if(this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint()),this.#i){const s=await this.#i.initialize(t,e);if(this.cancelled)return;s||(this.#i=null)}if(!this.#i){const{viewport:s,transform:i,background:r,recordOperations:n,recordImages:a,recordForDebugger:o}=this.params,l=this._canvasContext||this.canvasFactory.getNoAlphaContext(this._canvas),{dependencyTracker:c,imagesTracker:d}=Pc(this._canvas,this.operatorList.fnArray.length,{recordOperations:n,recordImages:a,recordDebugMetadata:o});this.#t=c,this.#e=d,this.gfx=new Ce(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,c,d),this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:r})}this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.#i?.cancel(),this.gfx?.endDrawing(),this.#s&&(window.cancelAnimationFrame(this.#s),this.#s=null),rs.#n.delete(this._canvas),t||=new xr(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.#t?.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.#s=window.requestAnimationFrame(()=>{this.#s=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){if(this.cancelled)return;if(!this.#i){const s=this.#r?.();if(s&&(await s,this.cancelled))return}const{operatorList:t}=this,{lastChunk:e}=t;if(this.#i){if(this.operatorListIdx=await this.#i.executeOperatorList(t,this.operatorListIdx,this._operationsFilter),this.cancelled)return;if(this.operatorListIdx!==t.argsArray.length||e!==t.lastChunk){this._continue();return}}else this.operatorListIdx=this.gfx.executeOperatorList(t,this.operatorListIdx,this._continueBound,null,this.stepper,this._operationsFilter);this.operatorListIdx===t.argsArray.length&&(this.running=!1,e&&(this.gfx?.endDrawing(),rs.#n.delete(this._canvas),this.callback()))}}const kh="6.5.438",Oh="0a4153349";Al();class te{#t=null;#e=null;#s;#i=null;#r=!1;#n=!1;#a=null;#o;#l=null;#c=null;static#u=null;static get _keyboardManager(){return L(this,"_keyboardManager",new Kt([[["Escape"],te.prototype._hideDropdownFromKeyboard],[["Space"],te.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],te.prototype._moveToNext],[["ArrowUp","ArrowLeft"],te.prototype._moveToPrevious],[["Home"],te.prototype._moveToBeginning],[["End"],te.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#n=!1,this.#a=t):this.#n=!0,this.#c=t?._uiManager||e,this.#o=this.#c._eventBus,this.#s=t?.color?.toUpperCase()||this.#c?.highlightColors.values().next().value||"#FFFF98",te.#u||=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(){const t=this.#t=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#a&&(t.ariaControls=`${this.#a.id}_colorpicker_dropdown`);const e=this.#c._signal;t.addEventListener("click",this.#m.bind(this),{signal:e}),t.addEventListener("keydown",this.#p.bind(this),{signal:e});const s=this.#e=document.createElement("span");return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=this.#s,t.append(s),t}renderMainDropdown(){const t=this.#i=this.#h();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#h(){const t=document.createElement("div"),e=this.#c._signal;t.addEventListener("contextmenu",ae,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#a&&(t.id=`${this.#a.id}_colorpicker_dropdown`);for(const[s,i]of this.#c.highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",i),r.title=s,r.setAttribute("data-l10n-id",te.#u[s]);const n=document.createElement("span");r.append(n),n.className="swatch",n.style.backgroundColor=i,r.ariaSelected=i===this.#s,r.addEventListener("click",this.#f.bind(this,i),{signal:e}),t.append(r)}return t.addEventListener("keydown",this.#p.bind(this),{signal:e}),t}#f(t,e){e.stopPropagation(),this.#o.dispatch("switchannotationeditorparams",{source:this,type:st.HIGHLIGHT_COLOR,value:t}),this.update(t)}_colorSelectFromKeyboard(t){if(t.target===this.#t){this.#m(t);return}const e=t.target.getAttribute("data-color");e&&this.#f(e,t)}_moveToNext(t){if(!this.#g){this.#m(t);return}if(t.target===this.#t){this.#i.firstElementChild?.focus();return}t.target.nextSibling?.focus()}_moveToPrevious(t){if(t.target===this.#i?.firstElementChild||t.target===this.#t){this.#g&&this._hideDropdownFromKeyboard();return}this.#g||this.#m(t),t.target.previousSibling?.focus()}_moveToBeginning(t){if(!this.#g){this.#m(t);return}this.#i.firstElementChild?.focus()}_moveToEnd(t){if(!this.#g){this.#m(t);return}this.#i.lastElementChild?.focus()}#p(t){te._keyboardManager.exec(this,t)}#m(t){if(this.#g){this.hideDropdown();return}if(this.#r=t.detail===0,this.#l||(this.#l=new AbortController,window.addEventListener("pointerdown",this.#d.bind(this),{signal:this.#c.combinedSignal(this.#l)})),this.#t.ariaExpanded="true",this.#i){this.#i.classList.remove("hidden");return}const e=this.#i=this.#h();this.#t.append(e)}#d(t){this.#i?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#i?.classList.add("hidden"),this.#t.ariaExpanded="false",this.#l?.abort(),this.#l=null}get#g(){return this.#i&&!this.#i.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#n){if(!this.#g){this.#a?.unselect();return}this.hideDropdown(),this.#t.focus({preventScroll:!0,focusVisible:this.#r})}}update(t){if(this.#e&&(this.#e.style.backgroundColor=t),!this.#i)return;const e=this.#c.highlightColors.values();for(const s of this.#i.children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#t?.remove(),this.#t=null,this.#e=null,this.#i?.remove(),this.#i=null}}class Cs{#t=null;#e=!1;#s=null;#i=null;static#r=null;constructor(t){this.#s=t,this.#i=t._uiManager,Cs.#r||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#t)return this.#t;const{editorType:t,colorType:e,colorAndOpacityType:s,opacityType:i,color:r,opacity:n}=this.#s,a=this.#e=ot.isAlphaColorInputSupported&&i!==void 0,o=this.#t=document.createElement("input");if(o.type="color",a){o.setAttribute("alpha","");const l=D.hexNums[Math.round((n??1)*255)];o.value=(r||"#000000")+l}else o.value=r||"#000000";return o.className="basicColorPicker",o.tabIndex=0,o.setAttribute("data-l10n-id",Cs.#r[t]),o.addEventListener("input",()=>{if(a){const l=ds(o.value);if(!l)return;const[c,d,u,f]=l,p=D.makeHexColor(c,d,u);s!==void 0?this.#i.updateParams(s,{color:p,opacity:f}):(this.#i.updateParams(e,p),this.#i.updateParams(i,f))}else this.#i.updateParams(e,o.value)},{signal:this.#i._signal}),o}update(t){if(this.#t)if(this.#e){const e=D.hexNums[Math.round(this.#s.opacity*255)];this.#t.value=t+e}else this.#t.value=t}updateOpacity(t){if(!this.#t||!this.#e)return;const e=D.hexNums[Math.round(t*255)];this.#t.value=this.#s.color+e}destroy(){this.#t?.remove(),this.#t=null}hideDropdown(){}}ul();function In(h){return Math.floor(ft(h,0,1)*255).toString(16).padStart(2,"0")}function vs(h){return ft(h,0,1)*255}class kn{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=vs(t),[t,t,t]}static G_HTML([t]){const e=In(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(vs)}static RGB_HTML(t){return`#${t.map(In).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[vs(1-Math.min(1,t+i)),vs(1-Math.min(1,s+i)),vs(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,r=1-e,n=1-s,a=Math.min(i,r,n);return["CMYK",i,r,n,a]}}class Mh{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){nt("Abstract method `_createSVG` called.")}}class Nr extends Mh{_createSVG(t){return document.createElementNS(Dt,t)}}const Fh=9,We=new WeakSet,Rh=new Date().getTimezoneOffset()*60*1e3;class Vi{static create(t){switch(t.data.annotationType){case yt.LINK:return new Lr(t);case yt.TEXT:return new Nh(t);case yt.WIDGET:switch(t.data.fieldType){case"Tx":return new Lh(t);case"Btn":return t.data.radioButton?new jh(t):t.data.checkBox?new Uh(t):new Hh(t);case"Ch":return new $h(t);case"Sig":return new Bh(t)}return new Je(t);case yt.POPUP:return new ar(t);case yt.FREETEXT:return new Da(t);case yt.LINE:return new Wh(t);case yt.SQUARE:return new zh(t);case yt.CIRCLE:return new Vh(t);case yt.POLYLINE:return new Na(t);case yt.CARET:return new Yh(t);case yt.INK:return new Br(t);case yt.POLYGON:return new Xh(t);case yt.HIGHLIGHT:return new La(t);case yt.UNDERLINE:return new Kh(t);case yt.SQUIGGLY:return new qh(t);case yt.STRIKEOUT:return new Jh(t);case yt.STAMP:return new Ba(t);case yt.FILEATTACHMENT:return new Qh(t);case yt.RICHMEDIA:case yt.SCREEN:case yt.SOUND:return new Ua(t);default:return new lt(t)}}}class lt{#t=null;#e=!1;#s=null;constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableAnnotationEditing=t.enableAnnotationEditing!==!1,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(s)),i&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}static get _svgFactory(){return L(this,"_svgFactory",new Nr)}get _isEditable(){return this.enableAnnotationEditing&&this.data.isEditable}get hasPopupData(){return lt._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){const{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){const t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:s,rect:i}=this.data;let r=-1/0,n=-1/0;if(e?.length>=8){for(let a=0;a<e.length;a+=8)e[a+1]>n?(n=e[a+1],r=e[a+2]):e[a+1]===n&&(r=Math.max(r,e[a+2]));return[r,n]}if(s?.length>=1){for(const a of s)for(let o=0,l=a.length;o<l;o+=2)a[o+1]>n?(n=a[o+1],r=a[o]):a[o+1]===n&&(r=Math.max(r,a[o]));if(r!==1/0)return[r,n]}return i?[i[2],i[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:n}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/s,t[1]=100*(t[1]-n)/i,t}get commentText(){const{data:t}=this;return this.annotationStorage.getRawValue(`${as}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){const{data:e}=this,s={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:s})||this.annotationStorage.setValue(`${as}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:s,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#s?.popup||this.popup)?.remove(),this.#s=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#t||={rect:this.data.rect.slice(0)});const{rect:e,popup:s}=t;e&&this.#i(e);let i=this.#s?.popup||this.popup;!i&&s?.text&&(this._createPopup(s),i=this.#s.popup),i&&(i.updateEdited(t),s?.deleted&&(i.remove(),this.#s=null,this.popup=null))}resetEdited(){this.#t&&(this.#i(this.#t.rect),this.#s?.popup.resetEdited(),this.#t=null)}#i(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:n,pageX:a,pageY:o}}}}=this;s?.splice(0,4,...t),e.left=`${100*(t[0]-a)/r}%`,e.top=`${100*(n-t[3]+o)/n}%`,i===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/n}%`):this.setRotation(i)}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),!(this instanceof Je)&&!(this instanceof Lr)&&!(this instanceof Ua)&&(r.tabIndex=0);const{style:n}=r;if(n.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof ar){const{rotation:g}=e;return!e.hasOwnCanvas&&g!==0&&this.setRotation(g,r),r}const{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){n.borderWidth=`${e.borderStyle.width}px`;const g=e.borderStyle.horizontalCornerRadius,m=e.borderStyle.verticalCornerRadius;if(g>0||m>0){const b=`calc(${g}px * var(--total-scale-factor)) / calc(${m}px * var(--total-scale-factor))`;n.borderRadius=b}switch(e.borderStyle.style){case es.SOLID:n.borderStyle="solid";break;case es.DASHED:n.borderStyle="dashed";break;case es.BEVELED:z("Unimplemented border style: beveled");break;case es.INSET:z("Unimplemented border style: inset");break;case es.UNDERLINE:n.borderBottomStyle="solid";break}const v=e.borderColor||null;v?(this.#e=!0,n.borderColor=D.makeHexColor(...v)):n.borderWidth=0}const l=D.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:d,pageX:u,pageY:f}=i.rawDims;n.left=`${100*(l[0]-u)/c}%`,n.top=`${100*(l[1]-f)/d}%`;const{rotation:p}=e;return e.hasOwnCanvas||p===0?(n.width=`${100*a/c}%`,n.height=`${100*o/d}%`):this.setRotation(p,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:r,height:n}=this;t%180!==0&&([r,n]=[n,r]),e.style.width=`${100*r/s}%`,e.style.height=`${100*n/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const r=i.detail[e],n=r[0],a=r.slice(1);i.target.style[s]=kn[`${n}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[s]:kn[`${n}_rgb`](a)})};return L(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.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:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail))(t[i]||s[i])?.(e)}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,r]of Object.entries(e)){const n=s[i];if(n){const a={detail:{[i]:r},target:t};n(a),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,r]=this.data.rect.map(Math.fround);if(t.length===8){const[g,m,v,b]=t.subarray(2,6);if(i===g&&r===m&&e===v&&s===b)return}const{style:n}=this.container;let a;if(this.#e){const{borderColor:g,borderWidth:m}=n;n.borderWidth=0,a=["url('data:image/svg+xml;utf8,",`<svg xmlns="${Dt}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${g}" stroke-width="${m}">`],this.container.classList.add("hasBorder")}const o=i-e,l=r-s,c=lt._svgFactory,d=c.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";const u=c.createElement("defs");d.append(u);const f=c.createElement("clipPath"),p=`clippath_${this.data.id}`;f.setAttribute("id",p),f.setAttribute("clipPathUnits","objectBoundingBox"),u.append(f);for(let g=2,m=t.length;g<m;g+=8){const v=t[g],b=t[g+1],y=t[g+2],w=t[g+3],A=c.createElement("rect"),_=(y-e)/o,E=(r-b)/l,x=(v-y)/o,T=(b-w)/l;A.setAttribute("x",_),A.setAttribute("y",E),A.setAttribute("width",x),A.setAttribute("height",T),f.append(A),a?.push(`<rect vector-effect="non-scaling-stroke" x="${_}" y="${E}" width="${x}" height="${T}"/>`)}this.#e&&(a.push("</g></svg>')"),n.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){const{data:e}=this;let s,i;t?(s={str:t.text},i=t.date):(s=e.contentsObj,i=e.modificationDate),this.#s=new ar({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#s||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#s}render(){nt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects.get(t)||[];for(const{page:r,id:n,exportValues:a}of i){if(r===-1||n===e)continue;const o=typeof a=="string"?a:null,l=document.querySelector(`[data-element-id="${n}"]`);if(l&&!We.has(l)){z(`_getElementsByName - element not allowed: ${n}`);continue}s.push({id:n,exportValue:o,domElement:l})}return s}for(const i of document.getElementsByName(t)){const{exportValue:r}=i,n=i.getAttribute("data-element-id");n===e||!We.has(i)||s.push({id:n,exportValue:r,domElement:i})}return s}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}updateOC(t){if(!this.data.oc||!t)return;t.isVisible(this.data.oc)?this.show():this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":D.makeHexColor(...e)}}class Dh extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{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 Lr extends lt{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(s,t.action,t.overlaidText),i=!0):t.attachment?(this.#e(s,t.attachmentId,t.attachment,t.overlaidText,t.attachmentDest),i=!0):t.setOCGState?(this.#s(s,t.setOCGState,t.overlaidText),i=!0):t.dest?(this._bindLink(s,t.dest,t.overlaidText),i=!0):(t.actions&&(t.actions.has("Action")||t.actions.has("Mouse Up")||t.actions.has("Mouse Down"))&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),i=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(s,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&(this.contentElement=s,this.container.append(s)),this.container}#t(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,s=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||e==="")&&this.#t(),s&&(t.title=s)}_bindNamedAction(t,e,s=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),s&&(t.title=s),this.#t()}#e(t,e,s,i="",r=null){t.href=this.linkService.getAnchorUrl(""),s.description?t.title=s.description:i&&(t.title=i);const n=async()=>{const a=await this.linkService.getAttachmentContent(e);a&&this.downloadManager?.openOrDownloadData(a,s.filename,r)};t.onclick=()=>(n(),!1),this.#t()}#s(t,e,s=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),s&&(t.title=s),this.#t()}_bindJSAction(t,{actions:e,id:s,overlaidText:i}){t.href=this.linkService.getAnchorUrl("");const r=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of e.keys()){const a=r.get(n);a&&(t[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s,name:n}}),!1))}i&&(t.title=i),t.onclick||=()=>!1,this.#t()}_bindResetFormAction(t,e){const s=t.onclick;if(s||(t.href=this.linkService.getAnchorUrl("")),this.#t(),!this._fieldObjects){z('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),s||(t.onclick=()=>!1);return}t.onclick=()=>{s?.();const{fields:i,refs:r,include:n}=e,a=[];if(i.length!==0||r.length!==0){const c=new Set(r);for(const u of i){const f=this._fieldObjects.get(u)||[];for(const{id:p}of f)c.add(p)}const d=new Map;for(const u of this._fieldObjects.values())for(const{id:f,kidIds:p}of u)p&&d.set(f,p);for(const u of c)for(const f of d.get(u)||[])c.add(f);for(const u of this._fieldObjects.values())for(const f of u)c.has(f.id)===n&&a.push(f)}else for(const c of this._fieldObjects.values())a.push(...c);const o=this.annotationStorage,l=[];for(const c of a){const{id:d}=c;switch(l.push(d),c.type){case"text":{const f=c.defaultValue||"";o.setValue(d,{value:f});break}case"checkbox":case"radiobutton":{const f=c.defaultValue===c.exportValues;o.setValue(d,{value:f});break}case"combobox":case"listbox":{const f=c.defaultValue||"";o.setValue(d,{value:f});break}default:continue}const u=document.querySelector(`[data-element-id="${d}"]`);if(u){if(!We.has(u)){z(`_bindResetFormAction - element not allowed: ${d}`);continue}}else continue;u.dispatchEvent(new Event("resetform"))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}}),!1}}}class Nh extends lt{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}class Je extends lt{render(){return this.container}_getKeyModifier(t){return ot.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,r){s.includes("mouse")?t.addEventListener(s,n=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(n),shift:n.shiftKey,modifier:this._getKeyModifier(n)}})}):t.addEventListener(s,n=>{if(s==="blur"){if(!e.focused||!n.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(n)}})})}_setEventListeners(t,e,s,i){const{actions:r}=this.data;for(const[n,a]of s)(a==="Action"||r?.has(a))&&((a==="Focus"||a==="Blur")&&(e||={focused:!1}),this._setEventListener(t,e,n,a,i),a==="Focus"&&!r?.has("Blur")?this._setEventListener(t,e,"blur","Blur",null):a==="Blur"&&!r?.has("Focus")&&this._setEventListener(t,e,"focus","Focus",null))}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||Fh,r=t.style;let n;const a=2,o=l=>Math.round(10*l)/10;if(this.data.multiLine){const l=Math.abs(this.data.rect[3]-this.data.rect[1]-a),c=Math.round(l/(1.35*i))||1,d=l/c;n=Math.min(i,o(d/1.35))}else{const l=Math.abs(this.data.rect[3]-this.data.rect[1]-a);n=Math.min(i,o(l/1.35))}r.fontSize=`calc(${n}px * var(--total-scale-factor))`,r.color=D.makeHexColor(...s),this.data.textAlignment!==null&&!this.data.comb&&(r.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Lh extends Je{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const r=this.annotationStorage;for(const n of this._getElementsByName(t.name,t.id))n.domElement&&(n.domElement[e]=s),r.setValue(n.id,{[i]:s})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const i=t.getValue(e,{value:this.data.fieldValue});let r=i.value||"";const n=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;n&&r.length>n&&(r=r.slice(0,n));let a=i.formattedValue||this.data.textContent?.join(`
48
+ `)||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:r,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=a??r,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",a??r),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(this.container.classList.add("hasOwnCanvas"),t.has(e)&&this.container.classList.add("sandboxModified")),We.add(s),this.contentElement=s,s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:l,datetimeType:c,timeStep:d}=this.data,u=!!c&&this.enableScripting;l&&(s.title=l),this._setRequired(s,this.data.required),n&&(s.maxLength=n),s.addEventListener("input",p=>{t.setValue(e,{value:p.target.value}),this.setPropertyOnSiblings(s,"value",p.target.value,"value"),o.formattedValue=null}),s.addEventListener("resetform",p=>{const g=this.data.defaultFieldValue??"";s.value=o.userValue=g,o.formattedValue=null});let f=p=>{const{formattedValue:g}=o;g!=null&&(p.target.value=g),p.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",g=>{if(o.focused)return;const{target:m}=g;if(u&&(m.type=c,d&&(m.step=d)),o.userValue){const v=o.userValue;if(u)if(c==="time"){const b=new Date(v),y=[b.getHours(),b.getMinutes(),b.getSeconds()];m.value=y.map(w=>w.toString().padStart(2,"0")).join(":")}else m.value=new Date(v-Rh).toISOString().split(c==="date"?"T":".",1)[0];else m.value=v}o.lastCommittedValue=m.value,o.commitKey=1,this.data.actions?.has("Focus")||(o.focused=!0)}),s.addEventListener("updatefromsandbox",g=>{this.container.classList.add("sandboxModified");const m={value(v){o.userValue=v.detail.value??"",u||t.setValue(e,{value:o.userValue.toString()}),v.target.value=o.userValue},formattedValue(v){const{formattedValue:b}=v.detail;o.formattedValue=b,b!=null&&v.target!==document.activeElement&&(v.target.value=b);const y={formattedValue:b};u&&(y.value=b),t.setValue(e,y)},selRange(v){v.target.setSelectionRange(...v.detail.selRange)},charLimit:v=>{const{charLimit:b}=v.detail,{target:y}=v;if(b===0){y.removeAttribute("maxLength");return}y.setAttribute("maxLength",b);let w=o.userValue;!w||w.length<=b||(w=w.slice(0,b),y.value=o.userValue=w,t.setValue(e,{value:w}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:w,willCommit:!0,commitKey:1,selStart:y.selectionStart,selEnd:y.selectionEnd}}))}};this._dispatchEventFromSandbox(m,g)}),s.addEventListener("keydown",g=>{o.commitKey=1;let m=-1;if(g.key==="Escape"?m=0:g.key==="Enter"&&!this.data.multiLine?m=2:g.key==="Tab"&&(o.commitKey=3),m===-1)return;const{value:v}=g.target;o.lastCommittedValue!==v&&(o.lastCommittedValue=v,o.userValue=v,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:m,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}))});const p=f;f=null,s.addEventListener("blur",g=>{if(!o.focused||!g.relatedTarget)return;this.data.actions?.has("Blur")||(o.focused=!1);const{target:m}=g;let{value:v}=m;if(u){if(v&&c==="time"){const b=v.split(":").map(y=>parseInt(y,10));v=new Date(2e3,0,1,b[0],b[1],b[2]||0).valueOf(),m.step=""}else v.includes("T")||(v=`${v}T00:00`),v=new Date(v).valueOf();m.type="text"}o.userValue=v,o.lastCommittedValue!==v&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:v,willCommit:!0,commitKey:o.commitKey,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}),p(g)}),this.data.actions?.has("Keystroke")&&s.addEventListener("beforeinput",g=>{o.lastCommittedValue=null;const{data:m,target:v}=g,{value:b,selectionStart:y,selectionEnd:w}=v;let A=y,_=w;switch(g.inputType){case"deleteWordBackward":{const E=/\w/;for(;A>0&&!E.test(b[A-1]);)A--;for(;A>0&&E.test(b[A-1]);)A--;break}case"deleteWordForward":{const E=b.substring(y).match(/^\W*\w*/);E&&(_+=E[0].length);break}case"deleteContentBackward":y===w&&(A-=1);break;case"deleteContentForward":y===w&&(_+=1);break}g.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,change:m||"",willCommit:!1,selStart:A,selEnd:_}})}),this._setEventListeners(s,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],g=>g.target.value)}if(f&&s.addEventListener("blur",f),this.data.comb){const g=(this.data.rect[2]-this.data.rect[0])/n;s.classList.add("comb"),s.style.setProperty("--comb-width",`calc(${g}px * var(--total-scale-factor))`);const m=this.data.textAlignment;if(m===1||m===2){const v=()=>{const b=n-s.value.length;s.style.setProperty("--comb-offset",`${m===1?b>>1:b}`)};v();for(const b of["input","blur","resetform","updatefromsandbox"])s.addEventListener(b,v)}}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Bh extends Je{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Uh extends Je{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return We.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",n=>{const{name:a,checked:o}=n.target;for(const l of this._getElementsByName(a,s)){const c=o&&l.exportValue===e.exportValue;l.domElement&&(l.domElement.checked=c),t.setValue(l.id,{value:c})}t.setValue(s,{value:o})}),r.addEventListener("resetform",n=>{const a=e.defaultFieldValue||"Off";n.target.checked=a===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",n=>{const a={value(o){o.target.checked=o.detail.value!=="Off",t.setValue(s,{value:o.target.checked})}};this._dispatchEventFromSandbox(a,n)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],n=>n.target.checked)),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class jh extends Je{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.buttonValue!==null&&e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const n of this._getElementsByName(e.fieldName,s))t.setValue(n.id,{value:!1});const r=document.createElement("input");if(We.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",n=>{const{name:a,checked:o}=n.target;for(const l of this._getElementsByName(a,s))t.setValue(l.id,{value:!1});t.setValue(s,{value:o})}),r.addEventListener("resetform",n=>{const a=e.defaultFieldValue;n.target.checked=a!=null&&a===e.buttonValue}),this.enableScripting&&this.hasJSActions){const n=e.buttonValue;r.addEventListener("updatefromsandbox",a=>{const o={value:l=>{const c=n===l.detail.value;for(const d of this._getElementsByName(l.target.name)){const u=c&&d.id===s;d.domElement&&(d.domElement.checked=u),t.setValue(d.id,{value:u})}}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)}return this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class Hh extends Lr{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",s=>{this._dispatchEventFromSandbox({},s)})),t}}class $h extends Je{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");We.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",d=>{const u=this.data.defaultFieldValue;for(const f of i.options)f.selected=f.value===u});const n=(d,u)=>{const f=u.replaceAll(" "," ");d.textContent=f,f!==u&&d.setAttribute("display-value",u)};for(const d of this.data.options){const u=document.createElement("option");n(u,d.displayValue),u.value=d.exportValue,s.value.includes(d.exportValue)&&(u.setAttribute("selected",!0),r=!1),i.append(u)}let a=null;if(r){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),i.prepend(d),a=()=>{d.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}const o=d=>{const u=d?"value":"textContent",{options:f,multiple:p}=i;return p?Array.prototype.filter.call(f,g=>g.selected).map(g=>g[u]):f.selectedIndex===-1?null:f[f.selectedIndex][u]};let l=o(!1);const c=d=>{const u=d.target.options;return Array.prototype.map.call(u,f=>({displayValue:f.getAttribute("display-value")||f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",d=>{const u={value(f){a?.();const p=f.detail.value,g=new Set(Array.isArray(p)?p:[p]);for(const m of i.options)m.selected=g.has(m.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(f){i.multiple=!0},remove(f){const p=i.options,g=f.detail.remove;p[g].selected=!1,i.remove(g),p.length>0&&Array.prototype.findIndex.call(p,v=>v.selected)===-1&&(p[0].selected=!0),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},clear(f){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(f){const{index:p,displayValue:g,exportValue:m}=f.detail.insert,v=i.children[p],b=document.createElement("option");n(b,g),b.value=m,v?v.before(b):i.append(b),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},items(f){const{items:p}=f.detail;for(;i.length!==0;)i.remove(0);for(const g of p){const{displayValue:m,exportValue:v}=g,b=document.createElement("option");n(b,m),b.value=v,i.append(b)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},indices(f){const p=new Set(f.detail.indices);for(const g of f.target.options)g.selected=p.has(g.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(u,d)}),i.addEventListener("input",d=>{const u=o(!0),f=o(!1);t.setValue(e,{value:u}),d.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:f,changeEx:u,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],d=>d.target.value)):i.addEventListener("input",function(d){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class ar extends lt{constructor(t){const{data:e,elements:s,parent:i}=t,r=!!i._commentManager;if(super(t,{isRenderable:!r&&lt._hasPopupData(e)}),this.elements=s,r&&lt._hasPopupData(e)){const n=this.popup=this.#t();for(const a of s)a.popup=n}else this.popup=null}#t(){return new Gh({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(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const e=this.popup=this.#t(),s=[];for(const i of this.elements)i.popup=e,i.container.ariaHasPopup="dialog",s.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",s.map(i=>`${is}${i}`).join(",")),this.container}}class Gh{#t=null;#e=this.#z.bind(this);#s=this.#T.bind(this);#i=this.#x.bind(this);#r=this.#$.bind(this);#n=null;#a=null;#o=null;#l=null;#c=null;#u=null;#h=null;#f=!1;#p=null;#m=null;#d=null;#g=null;#v=null;#y=null;#b=null;#w=null;#A=null;#S=null;#_=!1;#E=null;#O=null;constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:r,contentsObj:n,richText:a,parent:o,rect:l,parentRect:c,open:d,commentManager:u=null}){this.#a=t,this.#A=i,this.#o=n,this.#w=a,this.#u=o,this.#n=e,this.#b=l,this.#h=c,this.#c=s,this.#t=u,this.#E=s[0],this.#l=tr.toDateObject(r),this.trigger=s.flatMap(f=>f.getElementsToTriggerPopup()),u||(this.#P(),this.#a.hidden=!0,d&&this.#$())}#P(){if(this.#m)return;this.#m=new AbortController;const{signal:t}=this.#m;for(const e of this.trigger)e.addEventListener("click",this.#r,{signal:t}),e.addEventListener("pointerenter",this.#i,{signal:t}),e.addEventListener("pointerleave",this.#s,{signal:t}),e.classList.add("popupTriggerArea");for(const e of this.#c)e.container?.addEventListener("keydown",this.#e,{signal:t})}#C(){const t=this.#c.find(e=>e.hasCommentButton);t&&(this.#v=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#g){this.#g.parentNode||this.#E.container.after(this.#g);return}if(this.#v||this.#C(),!this.#v)return;const{signal:t}=this.#m=new AbortController,e=this.#E.hasOwnCommentButton,s=()=>{this.#t.toggleCommentPopup(this,!0,void 0,!e)},i=()=>{this.#t.toggleCommentPopup(this,!1,!0,!e)},r=()=>{this.#t.toggleCommentPopup(this,!1,!1)};if(e){this.#g=this.#E.container;for(const n of this.trigger)n.ariaHasPopup="dialog",n.ariaControls="commentPopup",n.addEventListener("keydown",this.#e,{signal:t}),n.addEventListener("click",s,{signal:t}),n.addEventListener("pointerenter",i,{signal:t}),n.addEventListener("pointerleave",r,{signal:t}),n.classList.add("popupTriggerArea")}else{const n=this.#g=document.createElement("button");n.className="annotationCommentButton";const a=this.#E.container;n.style.zIndex=parseInt(a.style.zIndex,10)+1,n.tabIndex=0,n.ariaHasPopup="dialog",n.ariaControls="commentPopup",n.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#I(),this.#R(),n.addEventListener("keydown",this.#e,{signal:t}),n.addEventListener("click",s,{signal:t}),n.addEventListener("pointerenter",i,{signal:t}),n.addEventListener("pointerleave",r,{signal:t}),a.after(n)}}#R(){if(this.#E.extraPopupElement&&!this.#E.editor)return;this.#g||this.renderCommentButton();const[t,e]=this.#v,{style:s}=this.#g;s.left=`calc(${t}%)`,s.top=`calc(${e}% - var(--comment-button-dim))`}#I(){this.#E.extraPopupElement||(this.#g||this.renderCommentButton(),this.#g.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){const{color:t,opacity:e}=this.#E.commentData;return t?this.#u._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#g?.focus()},0)}getData(){const{richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}=this.#E.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:s,creationDate:i,modificationDate:r}}get elementBeforePopup(){return this.#g}get comment(){return this.#O||=this.#E.commentText,this.#O}set comment(t){t!==this.comment&&(this.#E.commentText=this.#O=t)}focus(){this.#E.container?.focus()}get parentBoundingClientRect(){return this.#E.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#g&&(this.#g.classList.toggle("selected",t),this.#g.ariaExpanded=e)}setSelectedCommentButton(t){this.#g.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#y)return this.#y;const{x:t,y:e,height:s}=this.#g.getBoundingClientRect(),{x:i,y:r,width:n,height:a}=this.#E.layer.getBoundingClientRect();return[(t-i)/n,(e+s-r)/a]}set commentPopupPosition(t){this.#y=t}hasDefaultPopupPosition(){return this.#y===null}get commentButtonPosition(){return this.#v}get commentButtonWidth(){return this.#g.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,s]=this.#y||this.commentButtonPosition.map(l=>l/100),i=this.parentBoundingClientRect,{x:r,y:n,width:a,height:o}=i;this.#t.showDialog(null,this,r+e*a,n+s*o,{...t,parentDimensions:i})}render(){if(this.#p)return;const t=this.#p=document.createElement("div");if(t.className="popup",this.#n){const s=t.style.outlineColor=D.makeHexColor(...this.#n);t.style.backgroundColor=`color-mix(in srgb, ${s} 30%, white)`}const e=document.createElement("span");if(e.className="header",this.#A?.str){const s=document.createElement("span");s.className="title",e.append(s),{dir:s.dir,str:s.textContent}=this.#A}if(t.append(e),this.#l){const s=document.createElement("time");s.className="popupDate",s.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),s.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#l.valueOf()})),s.dateTime=this.#l.toISOString(),e.append(s)}fa({html:this.#M||this.#o.str,dir:this.#o?.dir,className:"popupContent"},t),this.#a.append(t)}get#M(){const t=this.#w,e=this.#o;return t?.str&&(!e?.str||e.str===t.str)&&this.#w.html||null}get#D(){return this.#M?.attributes?.style?.fontSize||0}get#F(){return this.#M?.attributes?.style?.color||null}#B(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:this.#F,fontSize:this.#D?`calc(${this.#D}px * var(--total-scale-factor))`:""}};for(const r of t.split(`
49
+ `))e.push({name:"span",value:r,attributes:i});return s}#z(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&this.#f)&&this.#$()}updateEdited({rect:t,popup:e,deleted:s}){if(this.#t){s?(this.remove(),this.#O=null):e&&(e.deleted?this.remove():(this.#I(),this.#O=e.text)),t&&(this.#v=null,this.#C(),this.#R());return}if(s||e?.deleted){this.remove();return}this.#P(),this.#S||={contentsObj:this.#o,richText:this.#w},t&&(this.#d=null),e&&e.text&&(this.#w=this.#B(e.text),this.#l=tr.toDateObject(e.date),this.#o=null),this.#p?.remove(),this.#p=null}resetEdited(){this.#S&&({contentsObj:this.#o,richText:this.#w}=this.#S,this.#S=null,this.#p?.remove(),this.#p=null,this.#d=null)}remove(){if(this.#m?.abort(),this.#m=null,this.#p?.remove(),this.#p=null,this.#_=!1,this.#f=!1,this.#g?.remove(),this.#g=null,this.trigger)for(const t of this.trigger)t.classList.remove("popupTriggerArea")}#U(){if(this.#d!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:r}}}=this.#u;let n=!!this.#h,a=n?this.#h:this.#b;for(const p of this.#c)if(!a||D.intersect(p.data.rect,a)!==null){a=p.data.rect,n=!0;break}const o=D.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),c=n?a[2]-a[0]+5:0,d=o[0]+c,u=o[1];this.#d=[100*(d-i)/e,100*(u-r)/s];const{style:f}=this.#a;f.left=`${this.#d[0]}%`,f.top=`${this.#d[1]}%`}#$(){if(this.#t){this.#t.toggleCommentPopup(this,!1);return}this.#f=!this.#f,this.#f?(this.#x(),this.#a.addEventListener("click",this.#r),this.#a.addEventListener("keydown",this.#e)):(this.#T(),this.#a.removeEventListener("click",this.#r),this.#a.removeEventListener("keydown",this.#e))}#x(){this.#p||this.render(),this.isVisible?this.#f&&this.#a.classList.add("focused"):(this.#U(),this.#a.hidden=!1,this.#a.style.zIndex=parseInt(this.#a.style.zIndex,10)+1e3)}#T(){this.#a.classList.remove("focused"),!(this.#f||!this.isVisible)&&(this.#a.hidden=!0,this.#a.style.zIndex=parseInt(this.#a.style.zIndex,10)-1e3)}forceHide(){this.#_=this.isVisible,this.#_&&(this.#a.hidden=!0)}maybeShow(){this.#t||(this.#P(),this.#_&&(this.#p||this.#x(),this.#_=!1,this.#a.hidden=!1))}get isVisible(){return!this.#t&&this.#a.hidden===!1}}class Da extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Y.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class Wh extends lt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:s}=this,i=lt._svgFactory,r=i.create(e,s,!0),n=this.#t=i.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"),r.append(n),this.container.append(r),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class zh extends lt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:s}=this,i=lt._svgFactory,r=i.create(e,s,!0),n=t.borderStyle.width,a=this.#t=i.createElement("svg:rect");return a.setAttribute("x",n/2),a.setAttribute("y",n/2),a.setAttribute("width",e-n),a.setAttribute("height",s-n),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Vh extends lt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:s}=this,i=lt._svgFactory,r=i.create(e,s,!0),n=t.borderStyle.width,a=this.#t=i.createElement("svg:ellipse");return a.setAttribute("cx",e/2),a.setAttribute("cy",s/2),a.setAttribute("rx",e/2-n/2),a.setAttribute("ry",s/2-n/2),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Na extends lt{#t=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:s,popupRef:i},width:r,height:n}=this;if(!e)return this.container;const a=lt._svgFactory,o=a.create(r,n,!0);let l=[];for(let d=0,u=e.length;d<u;d+=2){const f=e[d]-t[0],p=t[3]-e[d+1];l.push(`${f},${p}`)}l=l.join(" ");const c=this.#t=a.createElement(this.svgElementName);return c.setAttribute("points",l),c.setAttribute("stroke-width",s.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),o.append(c),this.container.append(o),!i&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}}class Xh extends Na{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Yh extends lt{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 Br extends lt{#t=null;#e=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?Y.HIGHLIGHT:Y.INK}#s(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);const{data:{rect:t,rotation:e,inkLists:s,borderStyle:i,popupRef:r}}=this,{transform:n,width:a,height:o}=this.#s(e,t),l=lt._svgFactory,c=l.create(a,o,!0),d=this.#t=l.createElement("svg:g");c.append(d),d.setAttribute("stroke-width",i.width||1),d.setAttribute("stroke-linecap","round"),d.setAttribute("stroke-linejoin","round"),d.setAttribute("stroke-miterlimit",10),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),d.setAttribute("transform",n);for(const u of s){const f=l.createElement(this.svgElementName);this.#e.push(f),f.setAttribute("points",u.join(",")),d.append(f)}return!r&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:s,rect:i}=t,r=this.#t;if(e>=0&&r.setAttribute("stroke-width",e||1),s)for(let n=0,a=this.#e.length;n<a;n++)this.#e[n].setAttribute("points",s[n].join(","));if(i){const{transform:n,width:a,height:o}=this.#s(this.data.rotation,i);r.parentElement.setAttribute("viewBox",`0 0 ${a} ${o}`),r.setAttribute("transform",n)}}getElementsToTriggerPopup(){return this.#e}addHighlightArea(){this.container.classList.add("highlightArea")}}class La extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Y.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Kh extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class qh extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Jh extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){const s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Ba extends lt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Y.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 Qh extends lt{#t=null;constructor(t){super(t,{isRenderable:!0});const{fileId:e,file:s}=this.data;this.filename=s.filename,this.content=s.content,this.fileId=e,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let s;e.hasAppearance||e.fillAlpha===0?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(e.fillAlpha*100)}%);`)),s.addEventListener("dblclick",this.#e.bind(this)),this.#t=s;const{isMac:i}=ot.platform;return t.addEventListener("keydown",r=>{r.key==="Enter"&&(i?r.metaKey:r.ctrlKey)&&this.#e()}),!e.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return this.#t}addHighlightArea(){this.container.classList.add("highlightArea")}async#e(){const{fileId:t,filename:e,content:s}=this,i=await this.linkService.getAttachmentContent(t)||s;i&&this.downloadManager?.openOrDownloadData(i,e)}}class Ua extends lt{#t=new AbortController;#e=null;#s=null;constructor(t){super(t,{isRenderable:!!t.data.richMedia})}render(){this.container.classList.add("mediaAnnotation");const{filename:t}=this.data.richMedia,e=document.createElement("button");return e.className="mediaPlayButton",e.type="button",e.title=e.ariaLabel=t,e.addEventListener("click",()=>this.#i(e),{signal:this.#t.signal}),this.container.append(e),this.container}async#i(t){const{fileId:e,filename:s,contentType:i}=this.data.richMedia;t.disabled=!0;let r;try{r=await this.linkService.getAttachmentContent(e)}catch{return}finally{t.disabled=!1}if(!r||!t.isConnected)return;const{signal:n}=this.#t,a=new Blob([r],{type:i});if(!/^(?:video|audio)\//.test(a.type))return;const o=URL.createObjectURL(a);this.#e=o;const l=a.type.startsWith("audio/"),c=document.createElement(l?"audio":"video");if(this.#s=c,c.className="mediaContent",this._setBackgroundColor(c),c.src=o,c.title=s,c.controls=!0,c.autoplay=!0,c.tabIndex=0,l){let d=!1,u=!1;const f=()=>{c.controls=d||u};this.container.addEventListener("pointerenter",()=>{d=!0,f()},{signal:n}),this.container.addEventListener("pointerleave",()=>{d=!1,f()},{signal:n}),this.container.addEventListener("focusin",()=>{u=!0,f()},{signal:n}),this.container.addEventListener("focusout",()=>{u=!1,f()},{signal:n})}c.addEventListener("emptied",()=>this.#r(o),{once:!0,signal:n}),t.replaceWith(c),c.play().catch(()=>{})}#r(t=this.#e){t&&t===this.#e&&(URL.revokeObjectURL(t),this.#e=null)}destroy(){this.#t.abort(),this.#s&&(this.#s.pause(),this.#s.removeAttribute("src"),this.#s.load(),this.#s=null),this.#r()}}class Ur{#t=null;#e=null;#s=null;#i=new Map;#r=null;#n=null;#a=[];#o=!1;zIndex=0;constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:n,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:c}){this.div=t,this.#t=e,this.#e=s,this.#r=a||null,this.#n=l||null,this.#s=c||new Or,this.page=r,this.viewport=n,this._annotationEditorUIManager=i,this._commentManager=o||null}hasEditableAnnotations(){return this.#i.size>0}async render(t){const{annotations:e,optionalContentConfig:s}=t,i=this.div;Ge(i,this.viewport);const r=new Map,n=[],a={data:null,layer:i,linkService:this.#n,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,annotationStorage:this.#s,enableComment:t.enableComment===!0,enableAnnotationEditing:t.enableAnnotationEditing!==!1,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const o of e){if(o.noHTML)continue;const l=o.annotationType===yt.POPUP;if(l){const u=r.get(o.id);if(!u)continue;if(!this._commentManager){n.push(o);continue}a.elements=u}else if(o.rect[2]===o.rect[0]||o.rect[3]===o.rect[1])continue;a.data=o;const c=Vi.create(a);if(!c.isRenderable)continue;l||(this.#a.push(c),o.popupRef&&r.getOrInsertComputed(o.popupRef,hs).push(c));const d=c.render();o.hidden&&(d.style.visibility="hidden"),c.updateOC(s),c._isEditable&&(this.#i.set(c.data.id,c),this._annotationEditorUIManager?.renderAnnotationElement(c))}await this.#l();for(const o of n){const l=a.elements=r.get(o.id);a.data=o;const c=Vi.create(a);if(!c.isRenderable)continue;const d=c.render();c.contentElement.id=`${is}${o.id}`,o.hidden&&(d.style.visibility="hidden"),l.at(-1).container.after(d)}this.#c()}async#l(){if(this.#a.length===0)return;this.div.replaceChildren();const t=[];if(!this.#o){this.#o=!0;for(const{contentElement:s,data:{hidden:i,id:r,oc:n}}of this.#a){const a=s.id=`${is}${r}`,o=s.localName==="a"&&!i&&!n;t.push(this.#r?.getAriaAttributes(a,{enableLinkOwnership:o}).then(l=>{if(l)for(const[c,d]of l)s.setAttribute(c,d)}))}}this.#a.sort(({data:{rect:[s,i,r,n]}},{data:{rect:[a,o,l,c]}})=>{if(s===r&&i===n)return 1;if(a===l&&o===c)return-1;const d=n,u=i,f=(i+n)/2,p=c,g=o,m=(o+c)/2;if(f>=p&&m<=u)return-1;if(m>=d&&f<=g)return 1;const v=(s+r)/2,b=(a+l)/2;return v-b});const e=document.createDocumentFragment();for(const s of this.#a)e.append(s.container),this._commentManager?(s.extraPopupElement?.popup||s.popup)?.renderCommentButton():s.extraPopupElement&&e.append(s.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#t){const s=await this.#r?.getAnnotationIds();for(const{contentElement:i}of this.#a)s?.has(i.id)||this.#t.addPointerInTextLayer(i,!1)}}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:this.#n,parent:this};for(const s of t){s.borderStyle||=Ur._defaultBorderStyle,e.data=s;const i=Vi.create(e);i.isRenderable&&(i.render(),i.contentElement.id=`${is}${s.id}`,this.#a.push(i))}await this.#l()}update({viewport:t,optionalContentConfig:e}){const s=this.div;this.viewport=t,Ge(s,{rotation:t.rotation});for(const i of this.#a)i.updateOC(e);this.#c(),s.hidden=!1}destroy(){for(const t of this.#a)t.destroy?.(),this.#t?.removePointerInTextLayer(t.contentElement);this.#a.length=0,this.#i.clear(),this.div.replaceChildren()}#c(){if(!this.#e)return;const t=this.div;for(const[e,s]of this.#e){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;if(Array.isArray(s))for(const l of s)l.className="annotationContent",l.ariaHidden=!0;else s.className="annotationContent",s.ariaHidden=!0;const r=[];for(const l of i.children)l.nodeName==="CANVAS"&&r.push(l);for(const l of r)l.remove();const n=Array.isArray(s)?s[0]:s,{firstChild:a}=i;if(a?a.classList.contains("annotationContent")?a.after(n):a.before(n):i.append(n),Array.isArray(s)){let l=n;for(let c=1,d=s.length;c<d;c++)l.after(s[c]),l=s[c]}this.#e.delete(e);const o=this.#i.get(e);o&&(o._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,i.id,s),o._hasNoCanvas=!1):o.canvas=s)}}refreshCanvases(){this.#c()}getEditableAnnotations(){return this.#i.values()}getEditableAnnotation(t){return this.#i.get(t)}addFakeAnnotation(t){const{div:e}=this,{id:s,rotation:i}=t,r=new Dh({data:{id:s,rect:t.getPDFRect(),rotation:i},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#n,annotationStorage:this.#s});return r.render(),r.contentElement.id=`${is}${s}`,r.createOrUpdatePopup(),this.#a.push(r),r}removeAnnotation(t){const e=this.#a.findIndex(i=>i.data.id===t);if(e<0)return;const[s]=this.#a.splice(e,1);this.#t?.removePointerInTextLayer(s.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);this.#l()}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return L(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:es.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}const $s=/\r\n?|\n/g;class It extends H{#t="";#e=`${this.id}-editor`;#s=null;#i;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=It.prototype,e=r=>r.isEmpty(),s=Ie.TRANSLATE_SMALL,i=Ie.TRANSLATE_BIG;return L(this,"_keyboardManager",new Kt([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],t.commitOrRemove],[["Escape"],t.commitOrRemove],[["ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}]]))}static _type="freetext";static _editorType=Y.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||It._defaultColor||H._defaultLineColor,this.#i=t.fontSize||It._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert.freetext),this.canAddComment=!1}static initialize(t,e){H.initialize(t,e);const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case st.FREETEXT_SIZE:It._defaultFontSize=e;break;case st.FREETEXT_COLOR:It._defaultColor=e;break}}updateParams(t,e){switch(t){case st.FREETEXT_SIZE:this.#r(e);break;case st.FREETEXT_COLOR:this.#n(e);break}}static get defaultPropertiesToUpdate(){return[[st.FREETEXT_SIZE,It._defaultFontSize],[st.FREETEXT_COLOR,It._defaultColor||H._defaultLineColor]]}get propertiesToUpdate(){return[[st.FREETEXT_SIZE,this.#i],[st.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new Cs(this),[["colorPicker",this._colorPicker]]}get colorType(){return st.FREETEXT_COLOR}#r(t){const e=i=>{this.editorDiv.style.fontSize=`calc(${i}px * var(--total-scale-factor))`,this.translate(0,-(i-this.#i)*this.parentScale),this.#i=i,this.#o()},s=this.#i;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:st.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#n(t){const e=i=>{this.color=i,this.onUpdatedColor()},s=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:st.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-It._internalPadding*t,-(It._internalPadding+this.#i)*t]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(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.#s=new AbortController;const t=this._uiManager.combinedSignal(this.#s);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.#e),this._isDraggable=!0,this.#s?.abort(),this.#s=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}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()}#a(){const t=[];this.editorDiv.normalize();let e=null;for(const s of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&s.nodeName==="BR"||(t.push(It.#l(s)),e=s);return t.join(`
50
+ `)}#o(){const[t,e]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:i,div:r}=this,n=r.style.display,a=r.classList.contains("hidden");r.classList.remove("hidden"),r.style.display="hidden",i.div.append(this.div),s=r.getBoundingClientRect(),r.remove(),r.style.display=n,r.classList.toggle("hidden",a)}this.rotation%180===this.parentRotation%180?(this.width=s.width/t,this.height=s.height/e):(this.width=s.height/t,this.height=s.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#t,e=this.#t=this.#a().trimEnd();if(t===e)return;const s=i=>{if(this.#t=i,!i){this.remove();return}this.#c(),this._uiManager.rebuild(this),this.#o()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),this.#o()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&t.key==="Enter"&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){It._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(){if(this.div)return this.div;let t,e;(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.#e),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:s}=this.editorDiv;if(s.fontSize=`calc(${this.#i}px * var(--total-scale-factor))`,s.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){const[i,r]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[a,o]=this.getInitialTranslation();[a,o]=this.pageTranslationToScreen(a,o);const[l,c]=this.pageDimensions,[d,u]=this.pageTranslation;let f,p;switch(this.rotation){case 0:f=t+(n[0]-d)/l,p=e+this.height-(n[1]-u)/c;break;case 90:f=t+(n[0]-d)/l,p=e-(n[1]-u)/c,[a,o]=[o,-a];break;case 180:f=t-this.width+(n[0]-d)/l,p=e-(n[1]-u)/c,[a,o]=[-a,-o];break;case 270:f=t+(n[0]-d-this.height*c)/l,p=e+(n[1]-u-this.width*l)/c,[a,o]=[-o,a];break}this.setAt(f*i,p*r,a,o)}else this._moveAfterPaste(t,e);this.#c(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#l(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll($s,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:s}=e;if(s.length===1&&s[0]==="text/plain")return;t.preventDefault();const i=It.#h(e.getData("text")||"").replaceAll($s,`
51
+ `);if(!i)return;const r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();const n=r.getRangeAt(0);if(!i.includes(`
52
+ `)){n.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),r.collapseToStart();return}const{startContainer:a,startOffset:o}=n,l=[],c=[];if(a.nodeType===Node.TEXT_NODE){const f=a.parentElement;if(c.push(a.nodeValue.slice(o).replaceAll($s,"")),f!==this.editorDiv){let p=l;for(const g of this.editorDiv.childNodes){if(g===f){p=c;continue}p.push(It.#l(g))}}l.push(a.nodeValue.slice(0,o).replaceAll($s,""))}else if(a===this.editorDiv){let f=l,p=0;for(const g of this.editorDiv.childNodes)p++===o&&(f=c),f.push(It.#l(g))}this.#t=`${l.join(`
53
+ `)}${i}${c.join(`
54
+ `)}`,this.#c();const d=new Range;let u=Math.sumPrecise(l.map(f=>f.length));for(const{firstChild:f}of this.editorDiv.childNodes)if(f.nodeType===Node.TEXT_NODE){const p=f.nodeValue.length;if(u<=p){d.setStart(f,u),d.setEnd(f,u);break}u-=p}r.removeAllRanges(),r.addRange(d)}#c(){if(this.editorDiv.replaceChildren(),!!this.#t)for(const t of this.#t.split(`
55
+ `)){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#u(){return this.#t.replaceAll(" "," ")}static#h(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){const t=It._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,s){let i=null;if(t instanceof Da){const{data:{defaultAppearanceData:{fontSize:n,fontColor:a},rect:o,rotation:l,id:c,popupRef:d,richText:u,contentsObj:f,creationDate:p,modificationDate:g},textContent:m,textPosition:v,parent:{page:{pageNumber:b}}}=t;if(!m?.length)return null;i=t={annotationType:Y.FREETEXT,color:Array.from(a),fontSize:n,value:m.join(`
56
+ `),position:v,pageIndex:b-1,rect:o.slice(0),rotation:l,annotationElementId:c,id:c,deleted:!1,popupRef:d,comment:f?.str||null,richText:u,creationDate:p,modificationDate:g}}const r=await super.deserialize(t,e,s);return r.#i=t.fontSize,r.color=D.makeHexColor(...t.color),r.#t=It.#h(t.value),r._initialData=i,t.comment&&r.setCommentData(t),r}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=H._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),s=Object.assign(super.serialize(t),{color:e,fontSize:this.#i,value:this.#u()});return this.addComment(s),t?(s.isCopy=!0,s):this.annotationElementId&&!this.#f(s)?null:(s.id=this.annotationElementId,s)}#f(t){const{value:e,fontSize:s,color:i,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((n,a)=>n!==i[a])||t.pageIndex!==r}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(!e)return null;const{style:s}=e;s.fontSize=`calc(${this.#i}px * var(--total-scale-factor))`,s.color=this.color,e.replaceChildren();for(const i of this.#t.split(`
57
+ `)){const r=document.createElement("div");r.append(i?document.createTextNode(i):document.createElement("br")),e.append(r)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#t}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class jr{#t=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){this.#t[t]=e}toSVGProperties(){const t=this.#t;return this.#t=Object.create(null),{root:t}}reset(){this.#t=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){nt("Not implemented")}}class et extends H{#t=null;#e;_clipPathId=null;_colorPicker=null;_drawId=null;_drawOutlines=null;_focusDrawId=null;static _currentDrawId=-1;static _currentParent=null;static#s=null;static#i=null;static#r=null;static#n=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#e=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(t){t.drawOutlines&&(this.#a(t),this.#m())}#a({drawOutlines:t,drawId:e,drawingOptions:s,clipPathId:i}){this._drawOutlines=t,this._drawingOptions||=s,this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert[this.editorType]),e>=0?(this._drawId=e,this._clipPathId=i??null,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties),this.#l(this.parent)):this._drawId=this.#o(t,this.parent),this.#v(t.box)}#o(t,e){const{id:s,clipPathId:i}=e.drawLayer.draw(et._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,this.constructor._hasClipPath);return this.constructor._hasClipPath&&(this._clipPathId=i),this.#l(e),s}#l(t){const e=this._drawOutlines.getFocusSVGProperties(this.#f);e&&(this._focusDrawId=t.drawLayer.drawOutline(e,this._drawOutlines.focusMustRemoveSelfIntersections))}#c(t=this.#f){this._focusDrawId!==null&&this.parent?.drawLayer.updateProperties(this._focusDrawId,this._drawOutlines.getFocusSVGProperties(t))}#u(t){this._focusDrawId!==null&&this.parent?.drawLayer.updateProperties(this._focusDrawId,{rootClass:t})}#h(){const{parent:t,_drawId:e,_focusDrawId:s,_isVisible:i}=this;if(!t||e===null)return;const r={hidden:!i};t.drawLayer.updateProperties(e,{rootClass:r}),s!==null&&t.drawLayer.updateProperties(s,{rootClass:r})}static _mergeSVGProperties(t,e){const s=new Set(Object.keys(t));for(const[i,r]of Object.entries(e))s.has(i)?Object.assign(t[i],r):t[i]=r;return t}static getDefaultDrawingOptions(t){nt("Not implemented")}static get typesMap(){nt("Not implemented")}static get isDrawer(){return!0}static get _hasClipPath(){return!1}static get _hasDrawClass(){return!0}static get supportMultipleDrawings(){return!1}get _drawRotation(){return this.rotation}get _opacityName(){return this.constructor.typesMap.get(this.opacityType)}get#f(){return(this.parentRotation-this._drawRotation+360)%360}static updateDefaultParams(t,e){const s=this.typesMap.get(t);s&&this._defaultDrawingOptions.updateProperty(s,e),this._currentParent&&(et.#s.updateProperty(s,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const s=this.constructor.typesMap.get(t);s&&this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[s,i]of this.typesMap)t.push([s,e[i]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[s,i]of this.constructor.typesMap)t.push([s,e[i]]);return t}_updateProperty(t,e,s){const i=this._drawingOptions,r=i[e],n=a=>{i.updateProperty(e,a);const o=this._drawOutlines.updateProperty(e,a);o&&this.#v(o),this.parent?.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:n.bind(this,s),undo:n.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e,s=this.colorAndOpacityType){const i=this.constructor.typesMap.get(this.colorType),r=this._opacityName,n=this._drawingOptions,a=n[i],o=n[r],l=(c,d)=>{n.updateProperty(i,c),n.updateProperty(r,d),this._drawOutlines.updateProperty(i,c),this._drawOutlines.updateProperty(r,d),this.parent?.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:l.bind(this,t,e),undo:l.bind(this,a,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:s,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,et._mergeSVGProperties(this._drawOutlines.getPathResizingSVGProperties(this.#g()),{bbox:this.#y()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,et._mergeSVGProperties(this._drawOutlines.getPathResizedSVGProperties(this.#g()),{bbox:this.#y()})),this.#c()}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#y()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,et._mergeSVGProperties(this._drawOutlines.getPathTranslatedSVGProperties(this.#g(),this.parentDimensions),{bbox:this.#y()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}get _mustBeDisabledOnCommit(){return!0}commit(){super.commit(),this._mustBeDisabledOnCommit&&(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._drawId!==null&&this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#e&&(this.#e=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this._uiManager.removeShouldRescale(this),this.#p(),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.#m(),this.#v(this._drawOutlines.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#p()):t&&(this._uiManager.addShouldRescale(this),this.#m(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.#h(),e&&this.select()}#p(){if(this._drawId===null||!this.parent)return;const{drawLayer:t}=this.parent;t.remove(this._drawId),this._drawId=null,this._focusDrawId!==null&&(t.remove(this._focusDrawId),this._focusDrawId=null),this._drawingOptions.reset()}#m(t=this.parent){if(!(this._drawId!==null&&this.parent===t)){if(this._drawId!==null){const{drawLayer:e}=this.parent;e.updateParent(this._drawId,t.drawLayer),this._focusDrawId!==null&&e.updateParent(this._focusDrawId,t.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=this.#o(this._drawOutlines,t),this._clipPathId&&this.#t&&(this.#t.style.clipPath=this._clipPathId)}}#d([t,e,s,i]){const{parentDimensions:[r,n],_drawRotation:a}=this;switch(a){case 90:return[e,1-t,s*(n/r),i*(r/n)];case 180:return[1-t,1-e,s,i];case 270:return[1-e,t,s*(n/r),i*(r/n)];default:return[t,e,s,i]}}#g(){const{x:t,y:e,width:s,height:i,parentDimensions:[r,n],_drawRotation:a}=this;switch(a){case 90:return[1-e,t,s*(r/n),i*(n/r)];case 180:return[1-t,1-e,s,i];case 270:return[e,1-t,s*(r/n),i*(n/r)];default:return[t,e,s,i]}}#v(t){[this.x,this.y,this.width,this.height]=this.#d(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#y(t=this.parentRotation){const{x:e,y:s,width:i,height:r,_drawRotation:n,parentDimensions:[a,o]}=this;switch((n*4+t)/90){case 1:return[1-s-r,e,r,i];case 2:return[1-e-i,1-s-r,i,r];case 3:return[s,1-e-i,r,i];case 4:return[e,s-i*(a/o),r*(o/a),i*(a/o)];case 5:return[1-s,e,i*(a/o),r*(o/a)];case 6:return[1-e-r*(o/a),1-s,r*(o/a),i*(a/o)];case 7:return[s-i*(a/o),1-e-r*(o/a),i*(a/o),r*(o/a)];case 8:return[e-i,s-r,i,r];case 9:return[1-s,e-i,r,i];case 10:return[1-e,1-s,i,r];case 11:return[s-r,1-e,r,i];case 12:return[e-r*(o/a),s,r*(o/a),i*(a/o)];case 13:return[1-s-i*(a/o),e-r*(o/a),i*(a/o),r*(o/a)];case 14:return[1-e,1-s-i*(a/o),r*(o/a),i*(a/o)];case 15:return[s,1-e,i*(a/o),r*(o/a)];default:return[e,s,i,r]}}rotate(t=this.parentRotation){if(!this.parent||this._drawId===null)return;const e=(t-this._drawRotation+360)%360;this.parent.drawLayer.updateProperties(this._drawId,et._mergeSVGProperties({bbox:this.#y(t)},this._drawOutlines.updateRotation(e))),this.#c(e)}show(t=this._isVisible){super.show(t),this.#h()}select(){super.select(),this.#u({hovered:!1,selected:!0})}unselect(){super.unselect(),this.#u({selected:!1})}pointerover(){this.isSelected||this.#u({hovered:!0})}pointerleave(){this.isSelected||this.#u({hovered:!1})}onScaleChanging(){if(!this.parent)return;const t=this._drawOutlines.updateParentDimensions(this.parentDimensions,this.parent.scale);t&&this.#v(t)}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const s=super.render();this.constructor._hasDrawClass&&s.classList.add("draw");const i=this.#t=document.createElement("div");return s.append(i),i.setAttribute("aria-hidden","true"),i.className="internal",this._clipPathId&&(i.style.clipPath=this._clipPathId),pa(this,i,["pointerover","pointerleave"]),this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),s}static createDrawerInstance(t){nt("Not implemented")}static _getDrawingTarget(t,{target:e}){return e}static _getPointerCoords({offsetX:t,offsetY:e,clientX:s,clientY:i},r=null){if(!r)return[t,e];let n=s-r.clientX,a=i-r.clientY;switch(this._currentParent.viewport.rotation){case 90:[n,a]=[a,-n];break;case 180:[n,a]=[-n,-a];break;case 270:[n,a]=[-a,n];break}return[r.offsetX+n,r.offsetY+a]}static _addDrawingListeners(t,e){}static _endDrawingSession(t=!1){return this._currentParent.endDrawingSession(t)}static startDrawing(t,e,s,i){const{pointerId:r,pointerType:n}=i;if(at.isInitializedAndDifferentPointerType(n))return;const a=this._getDrawingTarget(t,i),[o,l]=this._getPointerCoords(i),{viewport:{rotation:c}}=t,{x:d,y:u,width:f,height:p}=a.getBoundingClientRect(),g=et.#i=new AbortController,m=t.combinedSignal(g);if(at.setPointer(n,r),window.addEventListener("pointerup",y=>{at.isSamePointerIdOrRemove(y.pointerId)&&this._endDraw(y)},{signal:m}),window.addEventListener("pointercancel",y=>{at.isSamePointerIdOrRemove(y.pointerId)&&this._endDrawingSession()},{signal:m}),window.addEventListener("pointerdown",y=>{at.isSamePointerType(y.pointerType)&&(at.initializeAndAddPointerId(y.pointerId),et.#s.isCancellable()&&(et.#s.removeLastElement(),et.#s.isEmpty()?this._endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",ae,{signal:m}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:m}),a.addEventListener("touchmove",y=>{at.isSameTimeStamp(y.timeStamp)&&xt(y)},{signal:m}),this._addDrawingListeners(a,m),t.toggleDrawing(),e._editorUndoBar?.hide(),et.#s){t.drawLayer.updateProperties(this._currentDrawId,et.#s.startNew(o,l,f,p,c,i.timeStamp));return}e.updateUIForDefaultProperties(this),et.#s=this.createDrawerInstance({x:o,y:l,box:[d,u,f,p],rotation:c,parent:t,isLTR:s,timeStamp:i.timeStamp}),et.#r=this.getDefaultDrawingOptions(),this._currentParent=t;const{id:v,clipPathId:b}=t.drawLayer.draw(this._mergeSVGProperties(et.#r.toSVGProperties(),et.#s.defaultSVGProperties),!0,this._hasClipPath);this._currentDrawId=v,et.#n=this._hasClipPath?b:null}static _drawMove(t){if(at.isSameTimeStamp(t.timeStamp),!et.#s||!at.isSamePointerId(t.pointerId))return;if(at.isUsingMultiplePointers()){this._endDraw(t);return}let e;const s=t.getCoalescedEvents?.();if(s?.length){const i=[],r=[];for(const n of s)i.push(...this._getPointerCoords(n,t)),r.push(n.timeStamp);e=et.#s.addPoints(i,r)}else e=et.#s.add(...this._getPointerCoords(t),t.timeStamp);this._currentParent.drawLayer.updateProperties(this._currentDrawId,e),at.setTimeStamp(t.timeStamp),xt(t)}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,et.#s=null,et.#r=null,et.#n=null,at.clearTimeStamp()),et.#i&&(et.#i.abort(),et.#i=null,at.clearPointerIds())}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),e.drawLayer.updateProperties(this._currentDrawId,t?.target===e.div?et.#s.end(...this._getPointerCoords(t),t.timeStamp):et.#s.end()),this.supportMultipleDrawings){const s=et.#s,i=this._currentDrawId,r=s.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,s.setLastElement(r))},undo:()=>{e.drawLayer.updateProperties(i,s.removeLastElement())},mustExec:!1,type:st.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(st.DRAW_STEP),!et.#s.isEmpty()){const{pageDimensions:[s,i],scale:r}=e,n=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,clipPathId:et.#n,drawOutlines:et.#s.getOutlines(s*r,i*r,r,this._INNER_MARGIN),drawingOptions:et.#r,mustBeCommitted:!t});return this._cleanup(!0),n}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,i,r,n,a){nt("Not implemented")}static async deserialize(t,e,s){const{rawDims:{pageWidth:i,pageHeight:r,pageX:n,pageY:a}}=e.viewport,o=this.deserializeDraw(n,a,i,r,this._INNER_MARGIN,t,s),l=await super.deserialize(t,e,s);return l.createDrawingOptions(t),l.#a({drawOutlines:o}),l.#m(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,s]=this.pageTranslation,[i,r]=this.pageDimensions;return this._drawOutlines.serialize([e,s,i,r],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class j{static PRECISION=1e-4;focusOutline=null;toSVGPath(){nt("Abstract method `toSVGPath` must be implemented.")}get box(){nt("Abstract getter `box` must be implemented.")}serialize(t,e){nt("Abstract method `serialize` must be implemented.")}get defaultSVGProperties(){nt("Abstract getter `defaultSVGProperties` must be implemented.")}get defaultProperties(){return this.defaultSVGProperties}getFocusSVGProperties(t){return null}get focusMustRemoveSelfIntersections(){return!1}updateProperty(t,e){return null}updateParentDimensions(t,e){return null}serializeQuadPoints(t,e){return null}updateRotation(t){return{}}getPathResizingSVGProperties(t){return{}}getPathResizedSVGProperties(t){return{}}getPathTranslatedSVGProperties(t,e){return{}}static _rotateBox([t,e,s,i],r){switch(r){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]}static _rescale(t,e,s,i,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a]*i,n[a+1]=s+t[a+1]*r;return n}static _rescaleAndSwap(t,e,s,i,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a+1]*i,n[a+1]=s+t[a]*r;return n}static _translate(t,e,s,i){i||=new Float32Array(t.length);for(let r=0,n=t.length;r<n;r+=2)i[r]=e+t[r],i[r+1]=s+t[r+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,r,n=[]){switch(r){case 90:n[0]=1-e/s,n[1]=t/i;break;case 180:n[0]=1-t/s,n[1]=1-e/i;break;case 270:n[0]=e/s,n[1]=1-t/i;break;default:n[0]=t/s,n[1]=e/i;break}return n}static createBezierPoints(t,e,s,i,r,n,a=[]){return a.push((t+5*s)/6,(e+5*i)/6,(5*s+r)/6,(5*i+n)/6,(s+r)/2,(i+n)/2),a}}class Ue{#t;#e=[];#s;#i;#r=[];#n=new Float32Array(18);#a;#o;#l;#c;#u;#h;#f=[];static#p=8;static#m=2;static#d=Ue.#p+Ue.#m;constructor(t,e,s,i,r,n,a=0){this.#t=s,this.#h=r*i,this.#i=n,this.#n.set([NaN,NaN,NaN,NaN,t,e],6),this.#s=a,this.#c=Ue.#p*i,this.#l=Ue.#d*i,this.#u=i,this.#f.push(t,e)}isEmpty(){return isNaN(this.#n[8])}isCancellable(){return this.#f.length<=10}removeLastElement(){return this.#n.fill(NaN),this.#r.length=this.#e.length=this.#f.length=0,{path:{d:""}}}#g(){const t=this.#n.subarray(4,6),e=this.#n.subarray(16,18),[s,i,r,n]=this.#t;return[(this.#a+(t[0]-e[0])/2-s)/r,(this.#o+(t[1]-e[1])/2-i)/n,(this.#a+(e[0]-t[0])/2-s)/r,(this.#o+(e[1]-t[1])/2-i)/n]}add(t,e){this.#a=t,this.#o=e;const[s,i,r,n]=this.#t;let[a,o,l,c]=this.#n.subarray(8,12);const d=t-l,u=e-c,f=Math.hypot(d,u);if(f<this.#l)return!1;const p=f-this.#c,g=p/f,m=g*d,v=g*u;let b=a,y=o;a=l,o=c,l+=m,c+=v,this.#f?.push(t,e);const w=-v/p,A=m/p,_=w*this.#h,E=A*this.#h;return this.#n.set(this.#n.subarray(2,8),0),this.#n.set([l+_,c+E],4),this.#n.set(this.#n.subarray(14,18),12),this.#n.set([l-_,c-E],16),isNaN(this.#n[6])?(this.#r.length===0&&(this.#n.set([a+_,o+E],2),this.#r.push(NaN,NaN,NaN,NaN,(a+_-s)/r,(o+E-i)/n),this.#n.set([a-_,o-E],14),this.#e.push(NaN,NaN,NaN,NaN,(a-_-s)/r,(o-E-i)/n)),this.#n.set([b,y,a,o,l,c],6),!this.isEmpty()):(this.#n.set([b,y,a,o,l,c],6),Math.abs(Math.atan2(y-o,b-a)-Math.atan2(v,m))<Math.PI/2?([a,o,l,c]=this.#n.subarray(2,6),this.#r.push(NaN,NaN,NaN,NaN,((a+l)/2-s)/r,((o+c)/2-i)/n),[a,o,b,y]=this.#n.subarray(14,18),this.#e.push(NaN,NaN,NaN,NaN,((b+a)/2-s)/r,((y+o)/2-i)/n),!0):([b,y,a,o,l,c]=this.#n.subarray(0,6),this.#r.push(((b+5*a)/6-s)/r,((y+5*o)/6-i)/n,((5*a+l)/6-s)/r,((5*o+c)/6-i)/n,((a+l)/2-s)/r,((o+c)/2-i)/n),[l,c,a,o,b,y]=this.#n.subarray(12,18),this.#e.push(((b+5*a)/6-s)/r,((y+5*o)/6-i)/n,((5*a+l)/6-s)/r,((5*o+c)/6-i)/n,((a+l)/2-s)/r,((o+c)/2-i)/n),!0))}toSVGPath(){if(this.isEmpty())return"";const t=this.#r,e=this.#e;if(isNaN(this.#n[6])&&!this.isEmpty())return this.#v();const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);this.#b(s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return this.#y(s),s.join(" ")}#v(){const[t,e,s,i]=this.#t,[r,n,a,o]=this.#g();return`M${(this.#n[2]-t)/s} ${(this.#n[3]-e)/i} L${(this.#n[4]-t)/s} ${(this.#n[5]-e)/i} L${r} ${n} L${a} ${o} L${(this.#n[16]-t)/s} ${(this.#n[17]-e)/i} L${(this.#n[14]-t)/s} ${(this.#n[15]-e)/i} Z`}#y(t){const e=this.#e;t.push(`L${e[4]} ${e[5]} Z`)}#b(t){const[e,s,i,r]=this.#t,n=this.#n.subarray(4,6),a=this.#n.subarray(16,18),[o,l,c,d]=this.#g();t.push(`L${(n[0]-e)/i} ${(n[1]-s)/r} L${o} ${l} L${c} ${d} L${(a[0]-e)/i} ${(a[1]-s)/r}`)}newFreeDrawOutline(t,e,s,i,r,n){return new ja(t,e,s,i,r,n)}getOutlines(){const t=this.#r,e=this.#e,s=this.#n,[i,r,n,a]=this.#t,o=new Float32Array((this.#f?.length??0)+2);for(let d=0,u=o.length-2;d<u;d+=2)o[d]=(this.#f[d]-i)/n,o[d+1]=(this.#f[d+1]-r)/a;if(o[o.length-2]=(this.#a-i)/n,o[o.length-1]=(this.#o-r)/a,isNaN(s[6])&&!this.isEmpty())return this.#w(o);const l=new Float32Array(this.#r.length+24+this.#e.length);let c=t.length;for(let d=0;d<c;d+=2){if(isNaN(t[d])){l[d]=l[d+1]=NaN;continue}l[d]=t[d],l[d+1]=t[d+1]}c=this.#S(l,c);for(let d=e.length-6;d>=6;d-=6)for(let u=0;u<6;u+=2){if(isNaN(e[d+u])){l[c]=l[c+1]=NaN,c+=2;continue}l[c]=e[d+u],l[c+1]=e[d+u+1],c+=2}return this.#A(l,c),this.newFreeDrawOutline(l,o,this.#t,this.#u,this.#s,this.#i)}#w(t){const e=this.#n,[s,i,r,n]=this.#t,[a,o,l,c]=this.#g(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-i)/n,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-i)/n,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-i)/n,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-i)/n],0),this.newFreeDrawOutline(d,t,this.#t,this.#u,this.#s,this.#i)}#A(t,e){const s=this.#e;return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6}#S(t,e){const s=this.#n.subarray(4,6),i=this.#n.subarray(16,18),[r,n,a,o]=this.#t,[l,c,d,u]=this.#g();return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/a,(s[1]-n)/o,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,d,u,NaN,NaN,NaN,NaN,(i[0]-r)/a,(i[1]-n)/o],e),e+=24}}class ja extends j{#t;#e=new Float32Array(4);#s;#i;#r;#n;#a;constructor(t,e,s,i,r,n){super(),this.#a=t,this.#r=e,this.#t=s,this.#n=i,this.#s=r,this.#i=n,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#o(n);const[a,o,l,c]=this.#e;for(let d=0,u=t.length;d<u;d+=2)t[d]=(t[d]-a)/l,t[d+1]=(t[d+1]-o)/c;for(let d=0,u=e.length;d<u;d+=2)e[d]=(e[d]-a)/l,e[d+1]=(e[d+1]-o)/c}toSVGPath(){const t=[`M${this.#a[4]} ${this.#a[5]}`];for(let e=6,s=this.#a.length;e<s;e+=6){if(isNaN(this.#a[e])){t.push(`L${this.#a[e+4]} ${this.#a[e+5]}`);continue}t.push(`C${this.#a[e]} ${this.#a[e+1]} ${this.#a[e+2]} ${this.#a[e+3]} ${this.#a[e+4]} ${this.#a[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,s,i],r){const n=s-t,a=i-e;let o,l;switch(r){case 0:o=j._rescale(this.#a,t,i,n,-a),l=j._rescale(this.#r,t,i,n,-a);break;case 90:o=j._rescaleAndSwap(this.#a,t,e,n,a),l=j._rescaleAndSwap(this.#r,t,e,n,a);break;case 180:o=j._rescale(this.#a,s,e,-n,a),l=j._rescale(this.#r,s,e,-n,a);break;case 270:o=j._rescaleAndSwap(this.#a,s,i,-n,-a),l=j._rescaleAndSwap(this.#r,s,i,-n,-a);break}return{outline:Array.from(o),points:[Array.from(l)]}}#o(t){const e=this.#a;let s=e[4],i=e[5];const r=[s,i,s,i];let n=s,a=i,o=s,l=i;const c=t?Math.max:Math.min,d=new Float32Array(4);for(let f=6,p=e.length;f<p;f+=6){const g=e[f+4],m=e[f+5];isNaN(e[f])?(D.pointBoundingBox(g,m,r),a>m?(n=g,a=m):a===m&&(n=c(n,g)),l<m?(o=g,l=m):l===m&&(o=c(o,g))):(d.set(ue,0),D.bezierBoundingBox(s,i,...e.slice(f,f+6),d),D.rectBoundingBox(...d,r),a>d[1]?(n=d[0],a=d[1]):a===d[1]&&(n=c(n,d[0])),l<d[3]?(o=d[2],l=d[3]):l===d[3]&&(o=c(o,d[2]))),s=g,i=m}const u=this.#e;u[0]=r[0]-this.#s,u[1]=r[1]-this.#s,u[2]=r[2]-r[0]+2*this.#s,u[3]=r[3]-r[1]+2*this.#s,this.firstPoint=[n,a],this.lastPoint=[o,l]}get box(){return this.#e}newOutliner(t,e,s,i,r,n,a=0){return new Ue(t,e,s,i,r,n,a)}updateThickness(t){const e=this.getNewOutline(t);return this.#a=e.#a,this.#r=e.#r,this.#e.set(e.#e),this.firstPoint=e.firstPoint,this.lastPoint=e.lastPoint,this.#e}getNewOutline(t,e){const[s,i,r,n]=this.#e,[a,o,l,c]=this.#t,d=r*l,u=n*c,f=s*l+a,p=i*c+o,g=this.#r,m=this.newOutliner(g[0]*d+f,g[1]*u+p,this.#t,this.#n,t,this.#i,e??this.#s);for(let v=2,b=g.length;v<b;v+=2)m.add(g[v]*d+f,g[v+1]*u+p);return m.getOutlines()}}function Ha(h){return{bbox:h.box,root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:h.isFree},path:{d:h.toSVGPath()}}}function $a(h,t){const{focusOutline:e}=h;return{bbox:j._rotateBox(e.box,t),root:{"data-main-rotation":t},rootClass:{highlightOutline:!0,free:h.isFree},path:{d:e.toSVGPath()}}}class or{#t;#e;#s;#i=[];#r=[];constructor(t,e=0,s=0,i=!0){const r=ue.slice(),n=10**-4;for(const{x:g,y:m,width:v,height:b}of t){const y=Math.floor((g-e)/n)*n,w=Math.ceil((g+v+e)/n)*n,A=Math.floor((m-e)/n)*n,_=Math.ceil((m+b+e)/n)*n,E=[y,A,_,!0],x=[w,A,_,!1];this.#i.push(E,x),D.rectBoundingBox(y,A,w,_,r)}const a=r[2]-r[0]+2*s,o=r[3]-r[1]+2*s,l=r[0]-s,c=r[1]-s;let d=i?-1/0:1/0,u=1/0;const f=this.#i.at(i?-1:-2),p=[f[0],f[2]];for(const g of this.#i){const[m,v,b,y]=g;!y&&i?v<u?(u=v,d=m):v===u&&(d=Math.max(d,m)):y&&!i&&(v<u?(u=v,d=m):v===u&&(d=Math.min(d,m))),g[0]=(m-l)/a,g[1]=(v-c)/o,g[2]=(b-c)/o}this.#t=new Float32Array([l,c,a,o]),this.#e=[d,u],this.#s=p}getOutlines(){this.#i.sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of this.#i)e[3]?(t.push(...this.#c(e)),this.#o(e)):(this.#l(e),t.push(...this.#c(e)));return this.#n(t)}#n(t){const e=[],s=new Set;for(const r of t){const[n,a,o]=r;e.push([n,a,r],[n,o,r])}e.sort((r,n)=>r[1]-n[1]||r[0]-n[0]);for(let r=0,n=e.length;r<n;r+=2){const a=e[r][2],o=e[r+1][2];a.push(o),o.push(a),s.add(a),s.add(o)}const i=[];for(;s.size>0;){const r=s.values().next().value;let[n,a,o,l,c]=r;s.delete(r);let d=n,u=a;const f=[n,o];for(i.push(f);;){let p;if(s.has(l))p=l;else if(s.has(c))p=c;else break;s.delete(p),[n,a,o,l,c]=p,d!==n&&(f.push(d,u,n,u===a?a:o),d=n),u=u===a?o:a}f.push(d,u)}return new lr(i,this.#t,this.#e,this.#s)}#a(t){const e=this.#r;let s=0,i=e.length-1;for(;s<=i;){const r=s+i>>1,n=e[r][0];if(n===t)return r;n<t?s=r+1:i=r-1}return i+1}#o([,t,e]){const s=this.#a(t);this.#r.splice(s,0,[t,e])}#l([,t,e]){const s=this.#a(t);for(let i=s;i<this.#r.length;i++){const[r,n]=this.#r[i];if(r!==t)break;if(r===t&&n===e){this.#r.splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,n]=this.#r[i];if(r!==t)break;if(r===t&&n===e){this.#r.splice(i,1);return}}}#c(t){const[e,s,i]=t,r=[[e,s,i]],n=this.#a(i);for(let a=0;a<n;a++){const[o,l]=this.#r[a];for(let c=0,d=r.length;c<d;c++){const[,u,f]=r[c];if(!(l<=u||f<=o)){if(u>=o){if(f>l)r[c][1]=l;else{if(d===1)return[];r.splice(c,1),c--,d--}continue}r[c][2]=o,f>l&&r.push([e,l,f])}}}return r}}class lr extends j{#t;#e=null;#s;constructor(t,e,s,i){super(),this.#s=t,this.#t=e,this.firstPoint=s,this.lastPoint=i}static build(t,e){const s=new or(t,.001).getOutlines();return s.#e=t,s.focusOutline=new or(t,.0025,.001,e).getOutlines(),s}get isFree(){return!1}get defaultSVGProperties(){return Ha(this)}getFocusSVGProperties(t){return $a(this,t)}updateRotation(t){return{root:{"data-main-rotation":t}}}serializeQuadPoints([t,e],[s,i]){const r=this.#e,n=new Float32Array(r.length*8);let a=0;for(const{x:o,y:l,width:c,height:d}of r){const u=o*s+t,f=(1-l)*i+e;n[a]=n[a+4]=u,n[a+1]=n[a+3]=f,n[a+2]=n[a+6]=u+c*s,n[a+5]=n[a+7]=f-d*i,a+=8}return n}toSVGPath(){const t=[];for(const e of this.#s){let[s,i]=e;t.push(`M${s} ${i}`);for(let r=2;r<e.length;r+=2){const n=e[r],a=e[r+1];n===s?(t.push(`V${a}`),i=a):a===i&&(t.push(`H${n}`),s=n)}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],r){const n=[],a=s-t,o=i-e;for(const l of this.#s){const c=new Array(l.length);for(let d=0;d<l.length;d+=2)c[d]=t+l[d]*a,c[d+1]=i-l[d+1]*o;n.push(c)}return n}get box(){return this.#t}}class Hr extends Ue{newFreeDrawOutline(t,e,s,i,r,n){return new $r(t,e,s,i,r,n)}}class Zh{#t;#e;constructor(t,e,s,i,r,n,a){this.#t=new Hr(t,e,s,i,r,n,a),this.#e=r}add(t,e){return this.#t.add(t,e)?{path:{d:this.#t.toSVGPath()}}:null}addPoints(t){let e=!1;for(let s=0,i=t.length;s<i;s+=2)e=this.#t.add(t[s],t[s+1])||e;return e?{path:{d:this.#t.toSVGPath()}}:null}end(t,e){return t===void 0?null:this.add(t,e)}isEmpty(){return this.#t.isEmpty()}isCancellable(){return this.#t.isCancellable()}removeLastElement(){return this.#t.removeLastElement()}updateProperty(t,e){return null}getOutlines(){const t=this.#t.getOutlines();return t.buildFocusOutline(2*this.#e),t}get defaultSVGProperties(){return{bbox:[0,0,1,1],root:{viewBox:"0 0 1 1"},rootClass:{highlight:!0,free:!0},path:{d:this.#t.toSVGPath()}}}}class $r extends ja{static#t=1.5;newOutliner(t,e,s,i,r,n,a=0){return new Hr(t,e,s,i,r,n,a)}get isFree(){return!0}buildFocusOutline(t){this.focusOutline=this.getNewOutline(t/2+$r.#t,.0025)}get defaultSVGProperties(){return Ha(this)}getFocusSVGProperties(t){return $a(this,t)}get focusMustRemoveSelfIntersections(){return!0}updateRotation(t){return{root:{"data-main-rotation":t}}}updateProperty(t,e){if(t!=="thickness")return null;const s=this.updateThickness(e/2);return this.buildFocusOutline(e),s}getPathResizedSVGProperties(){return{path:{d:this.toSVGPath()}}}}class Gr extends jr{constructor(t=null){super(),super.updateProperties(t)}updateSVGProperty(t,e){t!=="thickness"&&super.updateSVGProperty(t,e)}clone(){const t=new Gr;return t.updateAll(this),t}}class re extends et{#t=null;#e=0;#s=null;#i=0;#r="";#n="";static _DEFAULT_OPACITY=1;static _DEFAULT_THICKNESS=12;static _defaultDrawingOptions=null;static _type="highlight";static _editorType=Y.HIGHLIGHT;static get _keyboardManager(){const t=re.prototype;return L(this,"_keyboardManager",new Kt([[["ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.#t=t.anchorNode||null,this.#e=t.anchorOffset||0,this.#s=t.focusNode||null,this.#i=t.focusOffset||0,this.#r=t.methodOfCreation||(this._drawOutlines?.isFree?"main_toolbar":""),this.#n=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",this.rotate()}static initialize(t,e){H.initialize(t,e),this._defaultDrawingOptions||=new Gr({fill:e.highlightColors?.values().next().value||"#fff066","fill-opacity":re._DEFAULT_OPACITY,thickness:re._DEFAULT_THICKNESS})}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get typesMap(){return L(this,"typesMap",new Map([[st.HIGHLIGHT_COLOR,"fill"],[st.HIGHLIGHT_THICKNESS,"thickness"]]))}static get isDrawer(){return!1}static get _hasClipPath(){return!0}static get _hasDrawClass(){return!1}_addOutlines(t){const{boxes:e,drawOutlines:s}=t;!e&&!s||(this._drawingOptions||=t.drawingOptions||re.getDefaultDrawingOptions(),e&&(t={...t,drawOutlines:lr.build(e,this._uiManager.direction==="ltr")}),super._addOutlines(t))}get colorType(){return st.HIGHLIGHT_COLOR}get color(){return this._drawingOptions.fill}get opacity(){return this._drawingOptions["fill-opacity"]}get _opacityName(){return"fill-opacity"}get _drawRotation(){return this._drawOutlines?.isFree?this.rotation:0}get isResizable(){return!1}get _mustBeDisabledOnCommit(){return!1}get _mustFixPosition(){return!this._drawOutlines?.isFree}get telemetryInitialData(){return{action:"added",type:this._drawOutlines.isFree?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this._drawingOptions.thickness,methodOfCreation:this.#r}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}translateInPage(t,e){}get toolbarPosition(){return this.#a(this._drawOutlines.focusOutline.lastPoint)}get commentButtonPosition(){return this.#a(this._drawOutlines.firstPoint)}#a([t,e]){const[s,i,r,n]=this._drawOutlines.box;return[(t-s)/r,(e-i)/n]}updateParams(t,e){switch(t){case st.HIGHLIGHT_COLOR:this._updateColorAndOpacity(e,re._DEFAULT_OPACITY,t),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0);break;case st.HIGHLIGHT_THICKNESS:super.updateParams(t,e),this._reportTelemetry({action:"thickness_changed",thickness:e},!0);break}}get propertiesToUpdate(){const t=super.propertiesToUpdate;return t.push([st.HIGHLIGHT_FREE,this._drawOutlines.isFree]),t}get toolbarButtons(){return this._uiManager.highlightColors?(this._colorPicker=new te({editor:this}),[["colorPicker",this._colorPicker]]):super.toolbarButtons}fixAndSetPosition(){return super.fixAndSetPosition(this._drawRotation)}getRect(t,e){return super.getRect(t,e,this._drawRotation)}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this._reportTelemetry({action:"deleted"}),super.remove()}render(){if(this.div)return this.div;const t=super.render();return this.#n&&(t.setAttribute("aria-label",this.#n),t.setAttribute("role","mark")),this._drawOutlines.isFree?t.classList.add("free"):t.addEventListener("keydown",this.#o.bind(this),{signal:this._uiManager._signal}),this.enableEditing(),t}#o(t){re._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#l(!0);break;case 1:case 3:this.#l(!1);break}}#l(t){if(!this.#t)return;const e=window.getSelection();t?e.setPosition(this.#t,this.#e):e.setPosition(this.#s,this.#i)}unselect(){super.unselect(),this._drawOutlines.isFree||this.#l(!1)}static createDrawerInstance({x:t,y:e,box:s,parent:i,isLTR:r}){return new Zh(t,e,s,i.scale,this._defaultDrawingOptions.thickness/2,r,.001)}static _getDrawingTarget(t,{target:e}){return e.closest(".textLayer")}static _getPointerCoords({x:t,y:e}){return[t,e]}static _addDrawingListeners(t,e){t.classList.add("free"),e.addEventListener("abort",()=>t.classList.remove("free"),{once:!0}),window.addEventListener("blur",()=>this._endDraw(null),{signal:e}),window.addEventListener("pointerdown",xt,{capture:!0,passive:!1,signal:e})}static _endDrawingSession(t=!1){return this.endDrawing(t)}createDrawingOptions({color:t,opacity:e,thickness:s}){const{_defaultDrawingOptions:i,_DEFAULT_OPACITY:r}=re;this._drawingOptions=re.getDefaultDrawingOptions({fill:D.makeHexColor(...t),"fill-opacity":e||r,thickness:s||i.thickness})}static deserializeDraw(t,e,s,i,r,n,a){const{quadPoints:o}=n;if(o){const f=[];for(let p=0,g=o.length;p<g;p+=8)f.push({x:(o[p]-t)/s,y:1-(o[p+1]-e)/i,width:(o[p+2]-o[p])/s,height:(o[p+1]-o[p+5])/i});return lr.build(f,a.direction==="ltr")}const l=n.thickness||this._defaultDrawingOptions.thickness,c=(n.inkLists||n.outlines.points)[0],d=new Hr(c[0]-t,i-(c[1]-e),[0,0,s,i],1,l/2,!0,.001);for(let f=0,p=c.length;f<p;f+=2)d.add(c[f]-t,i-(c[f+1]-e));const u=d.getOutlines();return u.buildFocusOutline(l),u}static async deserialize(t,e,s){let i=null;if(t instanceof La){const{data:{quadPoints:n,rect:a,rotation:o,id:l,color:c,opacity:d,popupRef:u,richText:f,contentsObj:p,creationDate:g,modificationDate:m},parent:{page:{pageNumber:v}}}=t;i=t={annotationType:Y.HIGHLIGHT,color:Array.from(c),opacity:d,quadPoints:n,pageIndex:v-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:u,richText:f,comment:p?.str||null,creationDate:g,modificationDate:m}}else if(t instanceof Br){const{data:{inkLists:n,rect:a,rotation:o,id:l,color:c,borderStyle:{rawWidth:d},popupRef:u,richText:f,contentsObj:p,creationDate:g,modificationDate:m},parent:{page:{pageNumber:v}}}=t;i=t={annotationType:Y.HIGHLIGHT,color:Array.from(c),thickness:d,inkLists:n,pageIndex:v-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:u,richText:f,comment:p?.str||null,creationDate:g,modificationDate:m}}const r=await super.deserialize(t,e,s);return r._initialData=i,t.comment&&r.setCommentData(t),r}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=super.serialize(t);return Object.assign(e,{color:H._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),opacity:this.opacity,thickness:this._drawingOptions.thickness,quadPoints:this._drawOutlines.serializeQuadPoints(this.pageTranslation,this.pageDimensions),outlines:this._drawOutlines.serialize(e.rect,this._drawRotation)}),this.addComment(e),this.annotationElementId&&!this.#c(e)?null:(e.id=this.annotationElementId,e)}#c(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some((s,i)=>s!==e[i])}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}class Se{static#t=10;static#e=1e3/180;static#s=100;static#i=.001;#r;#n;#a;constructor(t,e,s){this.#r=[t,e,s],this.#n=this.#a=s}add(t,e,s){const i=this.#r,r=i.at(-1);s=s>r?s:r+Se.#i,i.push(t,e,s);const n=this.#o(s-Se.#t,!0),a=this.#l(this.#a-Se.#t);return a>=i.length/2&&(i.copyWithin(0,a),i.length-=a),n}get pendingPoints(){return this.#o(1/0,!1)}end(){return this.#o(1/0,!0)}#o(t,e){const s=this.#r,i=this.#n,r=s.at(-1),n=[],a=this.#a;for(let o=this.#l(a)+3;o<s.length;o+=3){const l=s[o-1],c=s[o+2]-l,d=Math.min(Math.ceil(c/Se.#e),Se.#s);for(let u=1;u<=d;u++){const f=u===d?s[o+2]:l+c*u/d;if(f<=a)continue;if(f>t)return n;const p=Math.min(Se.#t,f-i,r-f);this.#c(f-p,f+p,n),e&&(this.#a=f)}}return n}#l(t){const e=this.#r;let s=0,i=e.length/3-1;for(;s<i;){const r=s+i+1>>1;e[3*r+2]<=t?s=r:i=r-1}return 3*s}#c(t,e,s){const i=this.#r,r=this.#l(t);let n=0,a=0,o=0;for(let l=r;l<i.length-3&&i[l+2]<e;l+=3){const c=i[l],d=i[l+1],u=i[l+2],f=i[l+5],p=Math.max(u,t),g=Math.min(f,e);if(g<=p)continue;const m=g-p,v=(p+g-2*u)/(f-u);n+=m*(c+v*(i[l+3]-c)/2),a+=m*(d+v*(i[l+4]-d)/2),o+=m}o===0?s.push(i[r],i[r+1]):s.push(n/o,a/o)}}function we(h,t){return`${j.svgRound(h[t])} ${j.svgRound(h[t+1])}`}function Ga(h,t,e){for(let s=e,i=t.length;s<i;s+=6)h.push(`C${we(t,s)} ${we(t,s+2)} ${we(t,s+4)}`)}function Js(h){const t=`M${we(h,4)}`;if(h.length===6)return`${t}Z`;if(h.length===12&&isNaN(h[6]))return`${t}L${we(h,10)}`;const e=[t];return Ga(e,h,6),e.join("")}class td{#t=new Float64Array(6);#e=new Float64Array(2);#s;#i;#r;#n=null;#a;#o;#l=1;#c=new Float64Array(2);#u="";#h=0;#f=new Rs;#p;#m;constructor(t,e,s,i,r,n,a){this.#p=s,this.#m=i,this.#r=r,this.#a=n,this.#i=[],this.#d(t,e,a)}#d(t,e,s){[t,e]=this.#g(t,e);const i=this.#s=[NaN,NaN,NaN,NaN,t,e];this.#o=[t,e],this.#i.push({line:i,points:this.#o}),this.#t.set(i,0),this.#h=0,this.#l=1,this.#c.set(this.#e),this.#n=s===void 0?null:new Se(t,e,s)}updateProperty(t,e){t==="stroke-width"&&(this.#a=e)}#g(t,e){return j._normalizePoint(t,e,this.#p,this.#m,this.#r,this.#e)}isEmpty(){return!this.#i?.length}isCancellable(){return this.#l<=5}add(t,e,s){return this.#v(t,e,s),{path:{d:this.#_()}}}addPoints(t,e){for(let s=0,i=t.length;s<i;s+=2)this.#v(t[s],t[s+1],e?.[s/2]);return{path:{d:this.#_()}}}#v(t,e,s){[t,e]=this.#g(t,e);const[i,r]=this.#c;this.#y(t,e,i,r)||(this.#l++,this.#c.set(this.#e)),this.#n?this.#b(this.#n.add(t,e,s)):this.#w(t,e)}#y(t,e,s,i){return Math.hypot(this.#p*(t-s),this.#m*(e-i))<=2}#b(t){for(let e=0,s=t.length;e<s;e+=2)this.#w(t[e],t[e+1])}#w(t,e){const[,,s,i,r,n]=this.#t;this.#y(t,e,r,n)||(this.#o.push(t,e),isNaN(s)?this.#s.push(NaN,NaN,NaN,NaN,t,e):(isNaN(this.#t[0])&&this.#s.splice(6,6),j.createBezierPoints(s,i,r,n,t,e,this.#s)),this.#t.copyWithin(0,2),this.#t[4]=t,this.#t[5]=e)}#A(){const t=this.#s;if(this.#o.length<6||this.#h===t.length)return;const e=[this.#u];this.#h===0&&(e.push(`M${we(t,4)}`),this.#h=6),Ga(e,t,this.#h),this.#u=e.join(""),this.#h=t.length}#S(){if(this.#s){if(this.#n&&(this.#b(this.#n.end()),this.#n=null),this.#o.length<6)this.#u+=Js(this.#s);else{const[,,t,e,s,i]=this.#t;j.createBezierPoints(t,e,s,i,s,i,this.#s),this.#A()}this.#s=this.#o=null}}end(t,e,s){return this.#s&&t!==void 0&&this.#v(t,e,s),this.#S(),{path:{d:this.#u}}}startNew(t,e,s,i,r,n){this.#p=s,this.#m=i,this.#r=r;const a=this.#i.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#d(t,e,n),null}getLastElement(){return this.#i.at(-1)}setLastElement(t){return this.#i?(this.#i.push(t),this.#u+=Js(t.line),{path:{d:this.#u}}):this.#f.setLastElement(t)}removeLastElement(){return this.#i?(this.#s=this.#o=this.#n=null,this.#i.pop(),this.#u=this.#i.map(({line:t})=>Js(t)).join(""),{path:{d:this.#u}}):this.#f.removeLastElement()}#_(){this.#A();const t=[this.#u];this.#h===0&&(t.push(`M${we(this.#s,4)}`),this.#o.length===4&&t.push(`L${we(this.#s,10)}`));let e=this.#n?.pendingPoints;e?.length||(e=this.#e);for(let s=0,i=e.length;s<i;s+=2)t.push(`L${we(e,s)}`);return t.join("")}getOutlines(t,e,s,i){this.#S();const r=this.#i.at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),this.#f.build(this.#i,t,e,s,this.#r,this.#a,i),this.#t=null,this.#s=null,this.#i=null,this.#u=null,this.#f}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Rs extends j{#t;#e=0;#s;#i;#r;#n;#a;#o;#l;build(t,e,s,i,r,n,a){this.#r=e,this.#n=s,this.#a=i,this.#o=r,this.#l=n,this.#s=a??0,this.#i=t,this.#h()}get thickness(){return this.#l}setLastElement(t){return this.#i.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#i.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){return this.#i.map(({line:t})=>Js(t)).join("")}serialize([t,e,s,i],r){const n=[],a=[],[o,l,c,d]=this.#u();let u,f,p,g,m,v,b,y,w;switch(this.#o){case 0:w=j._rescale,u=t,f=e+i,p=s,g=-i,m=t+o*s,v=e+(1-l-d)*i,b=t+(o+c)*s,y=e+(1-l)*i;break;case 90:w=j._rescaleAndSwap,u=t,f=e,p=s,g=i,m=t+l*s,v=e+o*i,b=t+(l+d)*s,y=e+(o+c)*i;break;case 180:w=j._rescale,u=t+s,f=e,p=-s,g=i,m=t+(1-o-c)*s,v=e+l*i,b=t+(1-o)*s,y=e+(l+d)*i;break;case 270:w=j._rescaleAndSwap,u=t+s,f=e+i,p=-s,g=-i,m=t+(1-l-d)*s,v=e+(1-o-c)*i,b=t+(1-l)*s,y=e+(1-o)*i;break}for(const{line:A,points:_}of this.#i)n.push(w(A,u,f,p,g,r?new Array(A.length):null)),a.push(w(_,u,f,p,g,r?new Array(_.length):null));return{lines:n,points:a,rect:[m,v,b,y]}}static deserialize(t,e,s,i,r,{paths:{lines:n,points:a},rotation:o,thickness:l}){const c=[];let d,u,f,p,g;switch(o){case 0:g=j._rescale,d=-t/s,u=e/i+1,f=1/s,p=-1/i;break;case 90:g=j._rescaleAndSwap,d=-e/i,u=-t/s,f=1/i,p=1/s;break;case 180:g=j._rescale,d=t/s+1,u=-e/i,f=-1/s,p=1/i;break;case 270:g=j._rescaleAndSwap,d=e/i+1,u=t/s+1,f=-1/i,p=-1/s;break}if(!n){n=[];for(const v of a){const b=v.length;if(b===2){n.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1]]));continue}if(b===4){n.push(new Float32Array([NaN,NaN,NaN,NaN,v[0],v[1],NaN,NaN,NaN,NaN,v[2],v[3]]));continue}const y=new Float32Array(3*b);n.push(y);let[w,A,_,E]=v.subarray(0,4);y.set([NaN,NaN,NaN,NaN,w,A],0);for(let x=4;x<=b;x+=2){const T=Math.min(x,b-2),C=v[T],P=v[T+1];y.set(j.createBezierPoints(w,A,_,E,C,P),(x-2)*3),[w,A,_,E]=[_,E,C,P]}}}for(let v=0,b=n.length;v<b;v++)c.push({line:g(n[v].map(y=>y??NaN),d,u,f,p),points:g(a[v].map(y=>y??NaN),d,u,f,p)});const m=new this.prototype.constructor;return m.build(c,s,i,1,o,l,r),m}#c(t=this.#l){const e=this.#s+t/2*this.#a;return this.#o%180===0?[e/this.#r,e/this.#n]:[e/this.#n,e/this.#r]}#u(){const[t,e,s,i]=this.#t,[r,n]=this.#c(0);return[t+r,e+n,s-2*r,i-2*n]}#h(){const t=this.#t=Le.slice();for(const{line:i}of this.#i){if(i.length<=12){for(let a=4,o=i.length;a<o;a+=6)D.pointBoundingBox(i[a],i[a+1],t);continue}let r=i[4],n=i[5];for(let a=6,o=i.length;a<o;a+=6){const[l,c,d,u,f,p]=i.subarray(a,a+6);D.bezierBoundingBox(r,n,l,c,d,u,f,p,t),r=f,n=p}}const[e,s]=this.#c();t[0]=ft(t[0]-e,0,1),t[1]=ft(t[1]-s,0,1),t[2]=ft(t[2]+e,0,1),t[3]=ft(t[3]+s,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#t}updateProperty(t,e){return t==="stroke-width"?this.#f(e):null}#f(t){const[e,s]=this.#c();this.#l=t;const[i,r]=this.#c(),[n,a]=[i-e,r-s],o=this.#t;return o[0]-=n,o[1]-=a,o[2]+=2*n,o[3]+=2*a,o}updateParentDimensions([t,e],s){const[i,r]=this.#c();this.#r=t,this.#n=e,this.#a=s;const[n,a]=this.#c(),o=n-i,l=a-r,c=this.#t;return c[0]-=o,c[1]-=l,c[2]+=2*o,c[3]+=2*l,c}updateRotation(t){return this.#e=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#t.map(j.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#t;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${j.svgRound(t)} ${j.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#t;let s=0,i=0,r=0,n=0,a=0,o=0;switch(this.#e){case 90:i=e/t,r=-t/e,a=t;break;case 180:s=-1,n=-1,a=t,o=e;break;case 270:i=-e/t,r=t/e,o=e;break;default:return""}return`matrix(${s} ${i} ${r} ${n} ${j.svgRound(a)} ${j.svgRound(o)})`}getPathResizingSVGProperties([t,e,s,i]){const[r,n]=this.#c(),[a,o,l,c]=this.#t;if(Math.abs(l-r)<=j.PRECISION||Math.abs(c-n)<=j.PRECISION){const g=t+s/2-(a+l/2),m=e+i/2-(o+c/2);return{path:{"transform-origin":`${j.svgRound(t)} ${j.svgRound(e)}`,transform:`${this.rotationTransform} translate(${g} ${m})`}}}const d=(s-2*r)/(l-2*r),u=(i-2*n)/(c-2*n),f=l/s,p=c/i;return{path:{"transform-origin":`${j.svgRound(a)} ${j.svgRound(o)}`,transform:`${this.rotationTransform} scale(${f} ${p}) translate(${j.svgRound(r)} ${j.svgRound(n)}) scale(${d} ${u}) translate(${j.svgRound(-r)} ${j.svgRound(-n)})`}}}getPathResizedSVGProperties([t,e,s,i]){const[r,n]=this.#c(),a=this.#t,[o,l,c,d]=a;if(a[0]=t,a[1]=e,a[2]=s,a[3]=i,Math.abs(c-r)<=j.PRECISION||Math.abs(d-n)<=j.PRECISION){const m=t+s/2-(o+c/2),v=e+i/2-(l+d/2);for(const{line:b,points:y}of this.#i)j._translate(b,m,v,b),j._translate(y,m,v,y);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${j.svgRound(t)} ${j.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const u=(s-2*r)/(c-2*r),f=(i-2*n)/(d-2*n),p=-u*(o+r)+t+r,g=-f*(l+n)+e+n;if(u!==1||f!==1||p!==0||g!==0)for(const{line:m,points:v}of this.#i)j._rescale(m,p,g,u,f,m),j._rescale(v,p,g,u,f,v);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${j.svgRound(t)} ${j.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){const[i,r]=s,n=this.#t,a=t-n[0],o=e-n[1];if(this.#r===i&&this.#n===r)for(const{line:l,points:c}of this.#i)j._translate(l,a,o,l),j._translate(c,a,o,c);else{const l=this.#r/i,c=this.#n/r;this.#r=i,this.#n=r;for(const{line:d,points:u}of this.#i)j._rescale(d,a,o,l,c,d),j._rescale(u,a,o,l,c,u);n[2]*=l,n[3]*=c}return n[0]=t,n[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${j.svgRound(t)} ${j.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#t;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${j.svgRound(t[0])} ${j.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Di extends jr{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:H._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new Di(this._viewParameters);return t.updateAll(this),t}}class Wr extends et{static _type="ink";static _editorType=Y.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){H.initialize(t,e),this._defaultDrawingOptions=new Di(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return L(this,"typesMap",new Map([[st.INK_THICKNESS,"stroke-width"],[st.INK_COLOR,"stroke"],[st.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance({x:t,y:e,box:[,,s,i],rotation:r,timeStamp:n}){return new td(t,e,s,i,r,this._defaultDrawingOptions["stroke-width"],n)}static deserializeDraw(t,e,s,i,r,n){return Rs.deserialize(t,e,s,i,r,n)}static async deserialize(t,e,s){let i=null;if(t instanceof Br){const{data:{inkLists:n,rect:a,rotation:o,id:l,color:c,opacity:d,borderStyle:{rawWidth:u},popupRef:f,richText:p,contentsObj:g,creationDate:m,modificationDate:v},parent:{page:{pageNumber:b}}}=t;i=t={annotationType:Y.INK,color:Array.from(c),thickness:u,opacity:d,paths:{points:n},boxes:null,pageIndex:b-1,rect:a.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,popupRef:f,richText:p,comment:g?.str||null,creationDate:m,modificationDate:v}}const r=await super.deserialize(t,e,s);return r._initialData=i,t.comment&&r.setCommentData(t),r}get toolbarButtons(){return this._colorPicker||=new Cs(this),[["colorPicker",this._colorPicker]]}get colorType(){return st.INK_COLOR}get colorAndOpacityType(){return st.INK_COLOR_AND_OPACITY}get opacityType(){return st.INK_OPACITY}updateParams(t,e){if(t===st.INK_COLOR_AND_OPACITY){this._updateColorAndOpacity(e.color,e.opacity);return}super.updateParams(t,e)}static updateDefaultParams(t,e){if(t===st.INK_COLOR_AND_OPACITY){super.updateDefaultParams(st.INK_COLOR,e.color),super.updateDefaultParams(st.INK_OPACITY,e.opacity);return}super.updateDefaultParams(t,e)}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:s}=this;e.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const 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:s}){this._drawingOptions=Wr.getDefaultDrawingOptions({stroke:D.makeHexColor(...t),"stroke-width":e,"stroke-opacity":s})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{stroke:i,"stroke-opacity":r,"stroke-width":n}}=this,a=Object.assign(super.serialize(t),{color:H._colorManager.convert(i),opacity:r,thickness:n,paths:{lines:e,points:s}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!this.#t(a)?null:(a.id=this.annotationElementId,a)}#t(t){const{color:e,thickness:s,opacity:i,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((n,a)=>n!==e[a])||t.thickness!==s||t.opacity!==i||t.pageIndex!==r}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:s}=this.serializeDraw(!1);return t.updateEdited({rect:s,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class cr extends Rs{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}Ml();const Gs=8,ys=3;class ss{static#t={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#e(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i}static#s=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#i(t,e,s,i,r,n,a){const o=this.#e(s,i,r,n);for(let l=0;l<8;l++){const c=(-l+o-a+16)%8,d=this.#s[2*c],u=this.#s[2*c+1];if(t[(s+d)*e+(i+u)]!==0)return c}return-1}static#r(t,e,s,i,r,n,a){const o=this.#e(s,i,r,n);for(let l=0;l<8;l++){const c=(l+o+a+16)%8,d=this.#s[2*c],u=this.#s[2*c+1];if(t[(s+d)*e+(i+u)]!==0)return c}return-1}static#n(t,e,s,i){const r=t.length,n=new Int32Array(r);for(let c=0;c<r;c++)n[c]=t[c]<=i?1:0;for(let c=1;c<s-1;c++)n[c*e]=n[c*e+e-1]=0;for(let c=0;c<e;c++)n[c]=n[e*s-1-c]=0;let a=1,o;const l=[];for(let c=1;c<s-1;c++){o=1;for(let d=1;d<e-1;d++){const u=c*e+d,f=n[u];if(f===0)continue;let p=c,g=d;if(f===1&&n[u-1]===0)a+=1,g-=1;else if(f>=1&&n[u+1]===0)a+=1,g+=1,f>1&&(o=f);else{f!==1&&(o=Math.abs(f));continue}const m=[d,c],v=g===d+1,b={isHole:v,points:m,id:a,parent:0};l.push(b);let y;for(const P of l)if(P.id===o){y=P;break}y?y.isHole?b.parent=v?y.parent:o:b.parent=v?o:y.parent:b.parent=v?o:0;const w=this.#i(n,e,c,d,p,g,0);if(w===-1){n[u]=-a,n[u]!==1&&(o=Math.abs(n[u]));continue}let A=this.#s[2*w],_=this.#s[2*w+1];const E=c+A,x=d+_;p=E,g=x;let T=c,C=d;for(;;){const P=this.#r(n,e,T,C,p,g,1);A=this.#s[2*P],_=this.#s[2*P+1];const k=T+A,R=C+_;m.push(R,k);const B=T*e+C;if(n[B+1]===0?n[B]=-a:n[B]===1&&(n[B]=a),k===c&&R===d&&T===E&&C===x){n[u]!==1&&(o=Math.abs(n[u]));break}else p=T,g=C,T=k,C=R}}}return l}static#a(t,e,s,i){if(s-e<=4){for(let E=e;E<s-2;E+=2)i.push(t[E],t[E+1]);return}const r=t[e],n=t[e+1],a=t[s-4]-r,o=t[s-3]-n,l=Math.hypot(a,o),c=a/l,d=o/l,u=c*n-d*r,f=o/a,p=1/l,g=Math.atan(f),m=Math.cos(g),v=Math.sin(g),b=p*(Math.abs(m)+Math.abs(v)),y=p*(1-b+b**2),w=Math.max(Math.atan(Math.abs(v+m)*y),Math.atan(Math.abs(v-m)*y));let A=0,_=e;for(let E=e+2;E<s-2;E+=2){const x=Math.abs(u-c*t[E+1]+d*t[E]);x>A&&(_=E,A=x)}A>(l*w)**2?(this.#a(t,e,_+2,i),this.#a(t,_,s,i)):i.push(r,n)}static#o(t){const e=[],s=t.length;return this.#a(t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e}static#l(t,e,s,i,r,n){const a=new Float32Array(n**2),o=-2*i**2,l=n>>1;for(let g=0;g<n;g++){const m=(g-l)**2;for(let v=0;v<n;v++)a[g*n+v]=Math.exp((m+(v-l)**2)/o)}const c=new Float32Array(256),d=-2*r**2;for(let g=0;g<256;g++)c[g]=Math.exp(g**2/d);const u=t.length,f=new Uint8Array(u),p=new Uint32Array(256);for(let g=0;g<s;g++)for(let m=0;m<e;m++){const v=g*e+m,b=t[v];let y=0,w=0;for(let _=0;_<n;_++){const E=g+_-l;if(!(E<0||E>=s))for(let x=0;x<n;x++){const T=m+x-l;if(T<0||T>=e)continue;const C=t[E*e+T],P=a[_*n+x]*c[Math.abs(C-b)];y+=C*P,w+=P}}const A=f[v]=Math.round(y/w);p[A]++}return[f,p]}static#c(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e}static#u(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,r=1/0;for(let a=0,o=s.length;a<o;a++){const l=s[a]=t[a<<2];i=Math.max(i,l),r=Math.min(r,l)}const n=255/(i-r);for(let a=0,o=s.length;a<o;a++)s[a]=(s[a]-r)*n;return s}static#h(t){let e,s=-1/0,i=-1/0;const r=t.findIndex(o=>o!==0);let n=r,a=r;for(e=r;e<256;e++){const o=t[e];o>s&&(e-n>i&&(i=e-n,a=e-1),s=o,n=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#f(t){const e=t,{width:s,height:i}=t,{maxDim:r}=this.#t;let n=s,a=i;if(s>r||i>r){let u=s,f=i,p=Math.log2(Math.max(s,i)/r);const g=Math.floor(p);p=p===g?g-1:g;for(let v=0;v<p;v++){n=Math.ceil(u/2),a=Math.ceil(f/2);const b=new OffscreenCanvas(n,a);b.getContext("2d").drawImage(t,0,0,u,f,0,0,n,a),u=n,f=a,t!==e&&t.close(),t=b.transferToImageBitmap()}const m=Math.min(r/n,r/a);n=Math.round(n*m),a=Math.round(a*m)}const l=new OffscreenCanvas(n,a).getContext("2d",{willReadFrequently:!0});l.fillStyle="white",l.fillRect(0,0,n,a),l.filter="grayscale(1)",l.drawImage(t,0,0,t.width,t.height,0,0,n,a);const c=l.getImageData(0,0,n,a).data;return[this.#u(c),n,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},r,n,a,o){let l=new OffscreenCanvas(1,1),c=l.getContext("2d",{alpha:!1});const d=200,u=c.font=`${s} ${i} ${d}px ${e}`,{actualBoundingBoxLeft:f,actualBoundingBoxRight:p,actualBoundingBoxAscent:g,actualBoundingBoxDescent:m,fontBoundingBoxAscent:v,fontBoundingBoxDescent:b,width:y}=c.measureText(t),w=1.5,A=Math.ceil(Math.max(Math.abs(f)+Math.abs(p)||0,y)*w),_=Math.ceil(Math.max(Math.abs(g)+Math.abs(m)||d,Math.abs(v)+Math.abs(b)||d)*w);l=new OffscreenCanvas(A,_),c=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=u,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,A,_),c.fillStyle="black",c.fillText(t,A*(w-1)/2,_*(3-w)/2);const E=this.#u(c.getImageData(0,0,A,_).data),x=this.#c(E),T=this.#h(x),C=this.#n(E,A,_,T);return this.processDrawnLines({lines:{curves:C,width:A,height:_},pageWidth:r,pageHeight:n,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,r){const[n,a,o]=this.#f(t),[l,c]=this.#l(n,a,o,Math.hypot(a,o)*this.#t.sigmaSFactor,this.#t.sigmaR,this.#t.kernelSize),d=this.#h(c),u=this.#n(l,a,o,d);return this.processDrawnLines({lines:{curves:u,width:a,height:o},pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:n,areContours:a}){i%180!==0&&([e,s]=[s,e]);const{curves:o,width:l,height:c}=t,d=t.thickness??0,u=[],f=Math.min(e/l,s/c),p=f/e,g=f/s,m=[];for(const{points:b}of o){const y=n?this.#o(b):b;if(!y)continue;m.push(y);const w=y.length,A=new Float32Array(w),_=new Float32Array(3*(w===2?2:w-2));if(u.push({line:_,points:A}),w===2){A[0]=y[0]*p,A[1]=y[1]*g,_.set([NaN,NaN,NaN,NaN,A[0],A[1]],0);continue}let[E,x,T,C]=y;E*=p,x*=g,T*=p,C*=g,A.set([E,x,T,C],0),_.set([NaN,NaN,NaN,NaN,E,x],0);for(let P=4;P<w;P+=2){const k=A[P]=y[P]*p,R=A[P+1]=y[P+1]*g;_.set(j.createBezierPoints(E,x,T,C,k,R),(P-2)*3),[E,x,T,C]=[T,C,k,R]}}if(u.length===0)return null;const v=a?new cr:new Rs;return v.build(u,e,s,1,i,a?0:d,r),{outline:v,newCurves:m,areContours:a,thickness:d,width:l,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:r}){let n=1/0,a=-1/0,o=0;for(const b of t){o+=b.length;for(let y=2,w=b.length;y<w;y++){const A=b[y]-b[y-2];n=Math.min(n,A),a=Math.max(a,A)}}let l;n>=-128&&a<=127?l=Int8Array:n>=-32768&&a<=32767?l=Int16Array:l=Int32Array;const c=t.length,d=Gs+ys*c,u=new Uint32Array(d);let f=0;u[f++]=d*Uint32Array.BYTES_PER_ELEMENT+(o-2*c)*l.BYTES_PER_ELEMENT,u[f++]=0,u[f++]=i,u[f++]=r,u[f++]=e?0:1,u[f++]=Math.max(0,Math.floor(s??0)),u[f++]=c,u[f++]=l.BYTES_PER_ELEMENT;for(const b of t)u[f++]=b.length-2,u[f++]=b[0],u[f++]=b[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(u);const m=l.prototype.constructor;for(const b of t){const y=new m(b.length-2);for(let w=2,A=b.length;w<A;w++)y[w-2]=b[w]-b[w-2];g.write(y)}return g.close(),(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(t){try{const e=Uint8Array.fromBase64(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),r=i.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let n=null,a=0;for await(const y of s)n||=new Uint8Array(new Uint32Array(y.buffer,0,4)[0]),n.set(y,a),a+=y.length;const o=new Uint32Array(n.buffer,0,n.length>>2),l=o[1];if(l!==0)throw new Error(`Invalid version: ${l}`);const c=o[2],d=o[3],u=o[4]===0,f=o[5],p=o[6],g=o[7],m=[],v=(Gs+ys*p)*Uint32Array.BYTES_PER_ELEMENT;let b;switch(g){case Int8Array.BYTES_PER_ELEMENT:b=new Int8Array(n.buffer,v);break;case Int16Array.BYTES_PER_ELEMENT:b=new Int16Array(n.buffer,v);break;case Int32Array.BYTES_PER_ELEMENT:b=new Int32Array(n.buffer,v);break}a=0;for(let y=0;y<p;y++){const w=o[ys*y+Gs],A=new Float32Array(w+2);m.push(A);for(let _=0;_<ys-1;_++)A[_]=o[ys*y+Gs+_+1];for(let _=0;_<w;_++)A[_+2]=A[_]+b[a++]}return{areContours:u,thickness:f,outlines:m,width:c,height:d}}catch(e){return z(`decompressSignature: ${e}`),null}}}class zr extends jr{constructor(){super(),super.updateProperties({fill:H._defaultLineColor,"stroke-width":0})}clone(){const t=new zr;return t.updateAll(this),t}}class Vr extends Di{constructor(t){super(t),super.updateProperties({stroke:H._defaultLineColor,"stroke-width":1})}clone(){const t=new Vr(this._viewParameters);return t.updateAll(this),t}}class he extends et{#t=!1;#e=null;#s=null;#i=null;#r=!1;static _type="signature";static _editorType=Y.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#s=t.signatureData||null,this.#e=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){H.initialize(t,e),this._defaultDrawingOptions=new zr,this._defaultDrawnSignatureOptions=new Vr(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return L(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#e}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onceAdded(t){this.#r=this._drawId===null,super.onceAdded(t)}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:s}=this;if(s&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),this._drawId===null)if(this.#s){const{lines:i,mustSmooth:r,areContours:n,description:a,uuid:o,heightInPage:l}=this.#s,{rawDims:{pageWidth:c,pageHeight:d},rotation:u}=this.parent.viewport,f=ss.processDrawnLines({lines:i,pageWidth:c,pageHeight:d,rotation:u,innerMargin:he._INNER_MARGIN,mustSmooth:r,areContours:n});this.addSignature(f,l,a,o)}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.#e||""}));return s&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#i=t,this.addEditToolbar()}getUuid(){return this.#i}get description(){return this.#e}set description(t){this.#e=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:s,width:i,height:r}=this.#s,n=Math.max(i,r),a=ss.processDrawnLines({lines:{curves:t.map(o=>({points:o})),thickness:s,width:i,height:r},pageWidth:n,pageHeight:n,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,s,i){const{x:r,y:n}=this,{outline:a}=this.#s=t;this.#t=a instanceof cr,this.description=s;let o;this.#t?o=he.getDefaultDrawingOptions():(o=he._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness})),this._addOutlines({drawOutlines:a,drawingOptions:o});const[,l]=this.pageDimensions;let c=e/l;c=c>=1?.5:c,this.width*=c/this.height,this.width>=1&&(c*=.9/this.width,this.width=.9),this.height=c,this.setDims(),this.x=r,this.y=n,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(i),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!i,hasDescription:!!s}}),this.div.hidden=!1,this.#r&&(this.#r=!1,this.parent.addUndoableEditor(this))}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return ss.process(t,e,s,i,he._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return ss.extractContoursFromText(t,e,s,i,r,he._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:s},rotation:i}=this.parent.viewport;return ss.processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:he._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=he.getDefaultDrawingOptions():(this._drawingOptions=he._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:s}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":i}}=this,r=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#t,color:[0,0,0],thickness:this.#t?0:i});return this.addComment(r),t?(r.paths={lines:e,points:s},r.uuid=this.#i,r.isCopy=!0):r.lines=e,this.#e&&(r.accessibilityData={type:"Figure",alt:this.#e}),r}static deserializeDraw(t,e,s,i,r,n){return n.areContours?cr.deserialize(t,e,s,i,r,n):Rs.deserialize(t,e,s,i,r,n)}static async deserialize(t,e,s){const i=await super.deserialize(t,e,s);return i.#t=t.areContours,i.description=t.accessibilityData?.alt||"",i.#i=t.uuid,i}}class ed extends H{#t=null;#e=null;#s=null;#i=null;#r=null;#n="";#a=null;#o=!1;#l=null;#c=!1;#u=!1;static _type="stamp";static _editorType=Y.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#i=t.bitmapUrl,this.#r=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){H.initialize(t,e)}static isHandlingMimeForPasting(t){return er.has(t)}static paste(t,e){e.pasteEditor({mode:Y.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){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#h(t,e=!1){if(!t){this.remove();return}this.#t=t.bitmap,e||(this.#e=t.id,this.#c=t.isSvg),t.file&&(this.#n=t.file.name),this.#m()}#f(){if(this.#s=null,this._uiManager.enableWaiting(!1),!!this.#a){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#t){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;const{mlManager:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!await s.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:i,width:r,height:n}=t||this.copyCanvas(null,null,!0).imageData,a=await s.guess({name:"altText",request:{data:i,width:r,height:n,channels:i.length/(r*n)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#p(){if(this.#e){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#e).then(s=>this.#h(s,!0)).finally(()=>this.#f());return}if(this.#i){const s=this.#i;this.#i=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromUrl(s).then(i=>this.#h(i)).finally(()=>this.#f());return}if(this.#r){const s=this.#r;this.#r=null,this._uiManager.enableWaiting(!0),this.#s=this._uiManager.imageManager.getFromFile(s).then(i=>this.#h(i)).finally(()=>this.#f());return}const t=document.createElement("input");t.type="file",t.accept=er.keys().join(",");const e=this._uiManager._signal;this.#s=new Promise(s=>{t.addEventListener("change",async()=>{if(!t.files||t.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const i=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#h(i)}s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>this.#f()),t.click()}remove(){this.#e&&(this.#t=null,this._uiManager.imageManager.deleteId(this.#e),this.#a?.remove(),this.#a=null,this.#l&&(clearTimeout(this.#l),this.#l=null)),super.remove()}rebuild(){if(!this.parent){this.#e&&this.#p();return}super.rebuild(),this.div!==null&&(this.#e&&this.#a===null&&this.#p(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#s||this.#t||this.#i||this.#r||this.#e||this.#o)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#o||(this.#t?this.#m():this.#p()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:s,bitmap:i}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),s&&this._uiManager.imageManager.isValidId(s)&&(this.#e=s,i&&(this.#t=i),this.#o=!1,this.#m())}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;this.#l!==null&&clearTimeout(this.#l);const t=200;this.#l=setTimeout(()=>{this.#l=null,this.#g()},t)}#m(){const{div:t}=this;let{width:e,height:s}=this.#t;const[i,r]=this.pageDimensions,n=.75;if(this.width)e=this.width*i,s=this.height*r;else if(e>n*i||s>n*r){const o=Math.min(n*i/e,n*r/s);e*=o,s*=o}this._uiManager.enableWaiting(!1);const a=this.#a=document.createElement("canvas");a.setAttribute("role","img"),this.addContainer(a),this.width=e/i,this.height=s/r,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(t.hidden=!1),this.#g(),this.#u||(this.parent.addUndoableEditor(this),this.#u=!0),this._reportTelemetry({action:"inserted_image"}),this.#n&&this.div.setAttribute("aria-description",this.#n),this.annotationElementId||this._uiManager.a11yAlert(H._l10nAlert.stamp)}copyCanvas(t,e,s=!1){t||=224;const{width:i,height:r}=this.#t,n=new Jt;let a=this.#t,o=i,l=r,c=null;if(e){if(i>e||r>e){const _=Math.min(e/i,e/r);o=Math.floor(i*_),l=Math.floor(r*_)}c=document.createElement("canvas");const u=c.width=Math.ceil(o*n.sx),f=c.height=Math.ceil(l*n.sy);this.#c||(a=this.#d(u,f));const p=c.getContext("2d");p.filter=this._uiManager.hcmFilter;let g="white",m="#cfcfd8";this._uiManager.hcmFilter!=="none"?m="black":rc.isDarkMode&&(g="#8f8f9d",m="#42414d");const v=15,b=v*n.sx,y=v*n.sy,w=new OffscreenCanvas(b*2,y*2),A=w.getContext("2d");A.fillStyle=g,A.fillRect(0,0,b*2,y*2),A.fillStyle=m,A.fillRect(0,0,b,y),A.fillRect(b,y,b,y),p.fillStyle=p.createPattern(w,"repeat"),p.fillRect(0,0,u,f),p.drawImage(a,0,0,a.width,a.height,0,0,u,f)}let d=null;if(s){let u,f;if(n.symmetric&&a.width<t&&a.height<t)u=a.width,f=a.height;else if(a=this.#t,i>t||r>t){const m=Math.min(t/i,t/r);u=Math.floor(i*m),f=Math.floor(r*m),this.#c||(a=this.#d(u,f))}const g=new OffscreenCanvas(u,f).getContext("2d",{willReadFrequently:!0});g.drawImage(a,0,0,a.width,a.height,0,0,u,f),d={width:u,height:f,data:g.getImageData(0,0,u,f).data}}return{canvas:c,width:o,height:l,imageData:d}}#d(t,e){const{width:s,height:i}=this.#t;let r=s,n=i,a=this.#t;for(;r>2*t||n>2*e;){const o=r,l=n;r>2*t&&(r=Math.ceil(r/2)),n>2*e&&(n=Math.ceil(n/2));const c=new OffscreenCanvas(r,n);c.getContext("2d").drawImage(a,0,0,o,l,0,0,r,n),a=c.transferToImageBitmap()}return a}#g(){const[t,e]=this.parentDimensions,{width:s,height:i}=this,r=new Jt,n=Math.ceil(s*t*r.sx),a=Math.ceil(i*e*r.sy),o=this.#a;if(!o||o.width===n&&o.height===a)return;o.width=n,o.height=a;const l=this.#c?this.#t:this.#d(n,a),c=o.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(l,0,0,l.width,l.height,0,0,n,a)}#v(t){if(t){if(this.#c){const i=this._uiManager.imageManager.getSvgUrl(this.#e);if(i)return i}const e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#t,e.getContext("2d").drawImage(this.#t,0,0),e.toDataURL()}if(this.#c){const[e,s]=this.pageDimensions,i=Math.round(this.width*e*os.PDF_TO_CSS_UNITS),r=Math.round(this.height*s*os.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,r);return n.getContext("2d").drawImage(this.#t,0,0,this.#t.width,this.#t.height,0,0,i,r),n.transferToImageBitmap()}return structuredClone(this.#t)}static async deserialize(t,e,s){let i=null,r=!1;if(t instanceof Ba){const{data:{rect:g,rotation:m,id:v,structParent:b,popupRef:y,richText:w,contentsObj:A,creationDate:_,modificationDate:E},container:x,parent:{page:{pageNumber:T}},canvas:C}=t;let P,k;C?(delete t.canvas,{id:P,bitmap:k}=s.imageManager.getFromCanvas(x.id,C),C.remove()):(r=!0,t._hasNoCanvas=!0);const R=(await e._structTree.getAriaAttributes(`${is}${v}`))?.get("aria-label")||"";i=t={annotationType:Y.STAMP,bitmapId:P,bitmap:k,pageIndex:T-1,rect:g.slice(0),rotation:m,annotationElementId:v,id:v,deleted:!1,accessibilityData:{decorative:!1,altText:R},isSvg:!1,structParent:b,popupRef:y,richText:w,comment:A?.str||null,creationDate:_,modificationDate:E}}const n=await super.deserialize(t,e,s),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:c,isSvg:d,accessibilityData:u}=t;r?(s.addMissingCanvas(t.id,n),n.#o=!0):c&&s.imageManager.isValidId(c)?(n.#e=c,o&&(n.#t=o)):n.#i=l,n.#c=d;const[f,p]=n.pageDimensions;return n.width=(a[2]-a[0])/f,n.height=(a[3]-a[1])/p,u&&(n.altTextData=u),n._initialData=i,t.comment&&n.setCommentData(t),n.#u=!!i,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=Object.assign(super.serialize(t),{bitmapId:this.#e,isSvg:this.#c});if(this.addComment(s),t)return s.bitmapUrl=this.#v(!0),s.accessibilityData=this.serializeAltText(!0),s.isCopy=!0,s;const{decorative:i,altText:r}=this.serializeAltText(!1);if(!i&&r&&(s.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){const a=this.#y(s);if(a.isSame)return null;if(a.isSameAltText)delete s.accessibilityData;else{const o=this._initialData.structParent??-1;s.accessibilityData?s.accessibilityData.structParent=o:o>=0&&(s.accessibilityData={type:"Figure",alt:"",structParent:o})}return s.id=this.annotationElementId,delete s.bitmapId,s}if(e===null)return s;e.stamps||=new Map;const n=this.#c?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(!e.stamps.has(this.#e))e.stamps.set(this.#e,{area:n,serialized:s}),s.bitmap=this.#v(!1);else if(this.#c){const a=e.stamps.get(this.#e);n>a.area&&(a.area=n,a.serialized.bitmap.close(),a.serialized.bitmap=this.#v(!1))}return s}#y(t){const{pageIndex:e,accessibilityData:{altText:s}}=this._initialData,i=t.pageIndex===e,r=(t.accessibilityData?.alt||"")===s;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&i&&r,isSameAltText:r}}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}class ve{#t;#e=!1;#s=null;#i=null;#r=null;#n=new Map;#a=!1;#o=!1;#l=!1;#c=null;#u=null;#h=null;#f=null;#p=null;#m=-1;#d;static _initialized=!1;static#g=new Map([It,Wr,ed,re,he].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:n,drawLayer:a,textLayer:o,viewport:l,l10n:c}){const d=[...ve.#g.values()];if(!ve._initialized){ve._initialized=!0;for(const u of d)u.initialize(c,t)}t.registerEditorTypes(d),this.#d=t,this.pageIndex=e,this.div=s,this.#t=r,this.#s=n,this.viewport=l,this.#h=o,this.drawLayer=a,this._structTree=i,this.#d.addLayer(this)}get isEmpty(){return this.#n.size===0}get isInvisible(){return this.isEmpty&&this.#d.getMode()===Y.NONE}updateToolbar(t){this.#d.updateToolbar(t)}updateMode(t=this.#d.getMode()){switch(this.#S(),t){case Y.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case Y.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Y.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===Y.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const s of ve.#g.values())e.toggle(`${s._type}Editing`,t===s._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#h?.div}setEditingState(t){this.#d.setEditingState(t)}addCommands(t){this.#d.addCommands(t)}cleanUndoStack(t){this.#d.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#s?.togglePointerEvents(t)}get#v(){return this.#n.size!==0?this.#n.values():this.#d.getEditors(this.pageIndex)}async enable(){this.#l=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#p?.abort(),this.#p=null;const t=new Set;for(const s of this.#v)s.enableEditing(),s.show(!0),s.annotationElementId&&(this.#d.removeChangedExistingAnnotation(s),t.add(s.annotationElementId));const e=this.#s;if(e)for(const s of e.getEditableAnnotations()){if(s.hide(),this.#d.isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}this.#l=!1,this.#d._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#o=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#h&&!this.#p){this.#p=new AbortController;const i=this.#d.combinedSignal(this.#p);this.#h.div.addEventListener("pointerdown",r=>{const{clientX:a,clientY:o,timeStamp:l}=r,c=this.#m;if(l-c>500){this.#m=l;return}this.#m=-1;const{classList:d}=this.div;d.toggle("getElements",!0);const u=document.elementsFromPoint(a,o);if(d.toggle("getElements",!1),!this.div.contains(u[0]))return;let f;const p=new RegExp(`^${as}[0-9]+$`);for(const m of u)if(p.test(m.id)){f=m.id;break}if(!f)return;const g=this.#n.get(f);g?.annotationElementId===null&&(xt(r),g.dblclick(r))},{signal:i,capture:!0})}const t=this.#s,e=[];if(t){const i=new Map,r=new Map;for(const n of this.#v){if(n.disableEditing(),!n.annotationElementId){e.push(n);continue}if(n.serialize()!==null){i.set(n.annotationElementId,n);continue}else r.set(n.annotationElementId,n);this.getEditableAnnotation(n.annotationElementId)?.show(),n.remove()}for(const n of t.getEditableAnnotations()){const{id:a}=n.data;if(this.#d.isDeletedAnnotationElement(a)){n.updateEdited({deleted:!0});continue}let o=r.get(a);if(o){o.resetAnnotationElement(n),o.show(!1),n.show();continue}o=i.get(a),o&&(this.#d.addChangedExistingAnnotation(o),o.renderAnnotationElement(n)&&o.show(!1)),n.show()}}this.#S(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const i of ve.#g.values())s.remove(`${i._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#o=!1}getEditableAnnotation(t){return this.#s?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#d.getActive()!==t&&this.#d.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#h?.div&&!this.#f){this.#f=new AbortController;const t=this.#d.combinedSignal(this.#f);this.#h.div.addEventListener("pointerdown",this.#y.bind(this),{signal:t}),this.#h.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#h?.div&&this.#f&&(this.#f.abort(),this.#f=null,this.#h.div.classList.remove("highlighting"))}#y(t){this.#d.unselectAll();const{target:e}=t;if(e===this.#h.div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&this.#h.div.contains(e)){const{isMac:s}=ot.platform;if(t.button!==0||t.ctrlKey&&s)return;this.#d.showAllEditors("highlight",!0,!0),re.startDrawing(this,this.#d,this.#d.direction==="ltr",t),t.preventDefault()}}enableClick(){if(this.#i)return;this.#i=new AbortController;const t=this.#d.combinedSignal(this.#i);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#i?.abort(),this.#i=null}attach(t){this.#n.set(t.id,t);const{annotationElementId:e}=t;e&&this.#d.isDeletedAnnotationElement(e)&&this.#d.removeDeletedAnnotationElement(t)}detach(t){this.#n.delete(t.id),this.#t?.removePointerInTextLayer(t.contentDiv),!this.#o&&t.annotationElementId&&this.#d.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#d.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#d.addDeletedAnnotationElement(t),H.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.#d.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#l),this.#d.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#r&&(t._focusEventsAllowed=!1,this.#r=setTimeout(()=>{this.#r=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#d._signal}),e.focus())},0)),t._structTreeParentId=this.#t?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getEditorByUID(t){for(const e of this.#n.values())if(e.uid===t)return e;return null}get#b(){return ve.#g.get(this.#d.getMode())}combinedSignal(t){return this.#d.combinedSignal(t)}#w(t){const e=this.#b;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#b?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#d.updateMode(t.mode);const{offsetX:s,offsetY:i}=this.#A(),r=this.#d.getId(),n=this.#w({parent:this,id:r,x:s,y:i,uiManager:this.#d,isCentered:!0,...e});n&&this.add(n)}async deserialize(t){return await ve.#g.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#d)||null}createAndAddNewEditor(t,e,s={}){const i=this.#d.getId(),r=this.#w({parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:this.#d,isCentered:e,...s});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}#A(){const{x:t,y:e,width:s,height:i}=this.boundingClientRect,r=Math.max(0,t),n=Math.max(0,e),a=Math.min(window.innerWidth,t+s),o=Math.min(window.innerHeight,e+i),l=(r+a)/2-t,c=(n+o)/2-e,[d,u]=this.viewport.rotation%180===0?[l,c]:[c,l];return{offsetX:d,offsetY:u}}addNewEditor(t={}){this.createAndAddNewEditor(this.#A(),!0,t)}setSelected(t){this.#d.setSelected(t)}toggleSelected(t){this.#d.toggleSelected(t)}unselect(t){this.#d.unselect(t)}pointerup(t){const{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!this.#a||(this.#a=!1,this.#b?.isDrawer&&this.#b.supportMultipleDrawings))return;if(!this.#e){this.#e=!0;return}const s=this.#d.getMode();if(s===Y.STAMP||s===Y.POPUP||s===Y.SIGNATURE){this.#d.unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#d.getMode()===Y.HIGHLIGHT&&this.enableTextSelection(),this.#a){this.#a=!1;return}const{isMac:e}=ot.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(this.#a=!0,this.#b?.isDrawer){this.startDrawingSession(t);return}const s=this.#d.getActive();this.#e=!s||s.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#c){this.#b.startDrawing(this,this.#d,!1,t);return}this.#d.setCurrentDrawingSession(this),this.#c=new AbortController;const e=this.#d.combinedSignal(this.#c);this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(this.#u=null,this.commitOrRemove())},{signal:e}),this.#b.startDrawing(this,this.#d,!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&(this.#u=e);return}this.#u&&setTimeout(()=>{this.#u?.focus(),this.#u=null},0)}endDrawingSession(t=!1){return this.#c?(this.#d.setCurrentDrawingSession(null),this.#c.abort(),this.#c=null,this.#u=null,this.#b.endDrawing(t)):null}findNewParent(t,e,s){const i=this.#d.findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return this.#c?(this.endDrawingSession(),!0):!1}onScaleChanging(){this.#c&&this.#b.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#d.getActive()?.parent===this&&(this.#d.commitOrRemove(),this.#d.setActiveEditor(null)),this.#r&&(clearTimeout(this.#r),this.#r=null);for(const t of this.#n.values())this.#t?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#n.clear(),this.#d.removeLayer(this)}#S(){for(const t of this.#n.values())t.isEmpty()&&t.remove()}async render({viewport:t}){this.viewport=t,Ge(this.div,t);for(const e of this.#d.getEditors(this.pageIndex))this.add(e),e.rebuild();await this.#d.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#d.commitOrRemove(),this.#S();const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,Ge(this.div,{rotation:s}),e!==s)for(const i of this.#n.values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#d.viewParameters.realScale}}vl();function sd(h,t){return h===t?0:h.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function Ws(h){return h?h.nodeType===Node.ELEMENT_NODE?h.closest(".textLayer"):h.parentElement?.closest(".textLayer")||null:null}function id(h,t,e,s){if(h===e)return t<=s;const i=h.compareDocumentPosition(e);return i&Node.DOCUMENT_POSITION_FOLLOWING?!0:i&Node.DOCUMENT_POSITION_PRECEDING?!1:null}function On(h,t,e){if(h.nodeType!==Node.ELEMENT_NODE||!h.classList.contains("textLayer")||t!==h.childNodes.length)return{container:h,offset:t};let s=h.lastChild;return s?.nodeType===Node.ELEMENT_NODE&&s.classList.contains("endOfContent")&&(s=s.previousSibling),!s||!e.contains(s)?null:s.nodeType===Node.TEXT_NODE?{container:s,offset:s.textContent.length}:{container:s,offset:s.childNodes.length}}class X{#t=null;#e=new Map;#s=null;#i=null;#r=null;#n=null;#a=new Map;static#o=0;static#l=0;static#c=null;static#u=new Set;static#h=!1;static#f=new Set;static#p=new WeakMap;constructor({filterFactory:t=null,pageColors:e=null,pageIndex:s,textLayer:i=null}){if(this.pageIndex=s,this.#i=t,this.#r=e,i){const r=X.#p.get(i);if(r?.selectionDiv&&(r.selectionDiv.remove(),X.#u.delete(r.selectionDiv)),X.#p.set(i,{drawLayer:this}),X.#f.add(i),this.#s=i,this.#n=new MutationObserver(n=>{if(!(!this.#t||!this.#s?.isConnected||!X.#d())){for(const{addedNodes:a}of n)for(const o of a)if(o.nodeType===Node.ELEMENT_NODE&&o.classList.contains("endOfContent")){X.#v();return}}}),this.#n.observe(i,{childList:!0}),X.#c===null){X.#c=new AbortController;const{signal:n}=X.#c;document.addEventListener("selectionchange",X.#v.bind(X),{signal:n}),document.addEventListener("pointerdown",()=>{X.#h=!0},{signal:n}),document.addEventListener("pointerup",()=>{X.#h=!1},{signal:n}),window.addEventListener("blur",()=>{X.#h=!1},{signal:n})}}}setParent(t){if(!this.#t){this.#t=t,this.#s?.isConnected&&X.#d()&&X.#v();return}if(this.#t!==t){if(this.#e.size>0)for(const e of this.#e.values())e.remove(),t.append(e);this.#t=t}}static#m(t){const e=this.#p.get(t);e?.selectionDiv&&(e.selectionDiv.remove(),this.#u.delete(e.selectionDiv),e.selectionDiv=null,e.path=null)}static#d(){const t=document.getSelection();return!!t&&!t.isCollapsed}static#g(){return this.#f.keys().filter(t=>t.isConnected).toArray().sort(sd)}static#v(){const t=document.getSelection();if(!t||t.isCollapsed){for(const n of this.#u)n.remove();this.#u.clear();return}const e=new WeakMap,s=this.#g(),i=[];for(let n=0,a=t.rangeCount;n<a;n++){const o=t.getRangeAt(n);if(o.collapsed)continue;let{startContainer:l,startOffset:c,endContainer:d,endOffset:u}=o,f=Ws(l),p=Ws(d);const g=f===null,m=p===null;if(this.#h&&g!==m)return;if(t.rangeCount===1){const{anchorNode:y,anchorOffset:w,focusNode:A,focusOffset:_}=t,E=Ws(y),x=Ws(A),T=id(y,w,A,_);E&&x&&T!==null&&(T?(l=y,c=w,f=E,d=A,u=_,p=x):(l=A,c=_,f=x,d=y,u=w,p=E))}const v=s.filter(y=>o.intersectsNode(y));if(v.length===0)continue;let b=!1;if(f||(f=v[0],l=f,c=0,b=!0),p||(p=v.at(-1),d=p,u=p.childNodes.length,b=!0),d.nodeType===Node.ELEMENT_NODE){if(d.classList.contains("endOfContent")){const y=d.previousSibling;if(!y)continue;d=y,u=y.nodeType===Node.TEXT_NODE?y.textContent.length:y.childNodes.length}else if(d.classList.contains("textLayer")&&d.childNodes.length===u){const y=On(d,u,p);if(!y)continue;d=y.container,u=y.offset}}if(l.nodeType===Node.ELEMENT_NODE){const y=On(l,c,f);if(!y)continue;l=y.container,c=y.offset}if(f===p&&!b&&v.includes(f)){i.push([o,f]);continue}for(const y of v){const w=y.firstChild;if(!w)continue;const A=document.createRange();if(y===f?A.setStart(l,c):A.setStartBefore(w),y===p)A.setEnd(d,u);else{const _=y.lastChild;if(!_)continue;if(_.nodeType===Node.ELEMENT_NODE&&_.classList.contains("endOfContent")){const E=_.previousSibling;if(!E)continue;A.setEndAfter(E)}else A.setEndAfter(_)}A.collapsed||i.push([A,y])}}const r=new Set(i.map(n=>n[1]));for(const n of this.#f)r.has(n)||this.#m(n);for(const[n,a]of i){const o=X.#p.get(a);if(!o)continue;let l=e.get(a);if(!l){const p=a.getBoundingClientRect();l=(g,m,v,b)=>({x:(g-p.x)/p.width,y:(m-p.y)/p.height,width:v/p.width,height:b/p.height}),e.set(a,l)}const c=[];for(let{x:p,y:g,width:m,height:v}of n.getClientRects())m===0||v===0||({x:p,y:g,width:m,height:v}=l(p,g,m,v),!(m===1&&v===1)&&c.push(`M${p} ${g} h${m} v${v} h-${m} Z`));if(c.length===0)continue;const d=o.drawLayer;let u=o.selectionDiv,f=o.path;if(!u){const p=`clip_selection_${X.#l++}`;u=document.createElement("div"),u.className="selection",u.style.clipPath=`url(#${p})`;const g=d.#i?.createSelectionStyle(d.#r);if(g)for(const[b,y]of Object.entries(g))u.style.setProperty(b,y);const m=X._svgFactory.create(1,1,!0);m.setAttribute("aria-hidden","true"),m.setAttribute("width","100%"),m.setAttribute("height","100%");const v=X._svgFactory.createElement("clipPath");v.setAttribute("id",p),v.setAttribute("clipPathUnits","objectBoundingBox"),f=X._svgFactory.createElement("path"),v.append(f),m.append(v),u.append(m),o.path=f,o.selectionDiv=u}d.#t&&u.parentNode!==d.#t&&(d.#t.append(u),this.#u.add(u)),f.setAttribute("d",c.join(" "))}}static get _svgFactory(){return L(this,"_svgFactory",new Nr)}static#y(t,[e,s,i,r]){const{style:n}=t;n.top=`${100*s}%`,n.left=`${100*e}%`,n.width=`${100*i}%`,n.height=`${100*r}%`}#b(){const t=X._svgFactory.create(1,1,!0);return this.#t.append(t),t.setAttribute("aria-hidden","true"),t}#w(t,e){const s=X._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=X._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i}#A(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)}draw(t,e=!1,s=!1){const i=X.#o++,r=this.#b(),n=X._svgFactory.createElement("defs");r.append(n);const a=X._svgFactory.createElement("path");n.append(a);const o=`path_${i}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#a.set(i,a);const l=s?this.#w(n,o):null,c=X._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${o}`),this.updateProperties(r,t),this.#e.set(i,r),{id:i,clipPathId:`url(#${l})`}}drawOutline(t,e){const s=X.#o++,i=this.#b(),r=X._svgFactory.createElement("defs");i.append(r);const n=X._svgFactory.createElement("path");r.append(n);const a=`path_${s}`;n.setAttribute("id",a),n.setAttribute("vector-effect","non-scaling-stroke");let o;if(e){const d=X._svgFactory.createElement("mask");r.append(d),o=`mask_${s}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=X._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const f=X._svgFactory.createElement("use");d.append(f),f.setAttribute("href",`#${a}`),f.setAttribute("stroke","none"),f.setAttribute("fill","black"),f.setAttribute("fill-rule","nonzero"),f.classList.add("mask")}const l=X._svgFactory.createElement("use");i.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const c=l.cloneNode();return i.append(c),l.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,t),this.#e.set(s,i),s}finalizeDraw(t,e){this.#a.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;const{root:s,bbox:i,rootClass:r,path:n}=e,a=typeof t=="number"?this.#e.get(t):t;if(a){if(s&&this.#A(a,s),i&&X.#y(a,i),r){const{classList:o}=a;for(const[l,c]of Object.entries(r))o.toggle(l,c)}if(n){const l=a.firstElementChild.firstElementChild;this.#A(l,n)}}}updateParent(t,e){if(e===this)return;const s=this.#e.get(t);s&&(e.#t.append(s),this.#e.delete(t),e.#e.set(t,s))}remove(t){this.#a.delete(t),this.#t!==null&&(this.#e.get(t).remove(),this.#e.delete(t))}destroy(){this.#t=null;for(const t of this.#e.values())t.remove();this.#e.clear(),this.#a.clear(),this.#n?.disconnect(),this.#n=null,this.#s&&(X.#p.get(this.#s)?.drawLayer===this&&(X.#m(this.#s),X.#p.delete(this.#s),X.#f.delete(this.#s),X.#f.size===0&&(X.#c?.abort(),X.#c=null,X.#h=!1)),this.#s=null)}}function zs(h){return`${(h*100).toFixed(2)}%`}class si{#t=[];#e=new Map;#s=null;#i=0;#r=0;#n=0;static#a=null;constructor(t,e,s,i){this.#i=t,this.#t=e,this.#r=s.rawDims.pageWidth,this.#n=s.rawDims.pageHeight,this.#s=i}render(){const t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<this.#t.length;e+=6){const s=this.#o(this.#t.subarray(e,e+6));s&&t.append(s)}return t.addEventListener("contextmenu",e=>{if(!(e.target instanceof HTMLCanvasElement))return;const s=e.target,i=this.#e.get(s);if(!i)return;const r=si.#a?.deref();if(r===s)return;r&&(r.width=0,r.height=0),si.#a=new WeakRef(s);const{inverseTransform:n,x1:a,y1:o,width:l,height:c}=i,d=this.#s(),u=Math.ceil(a*d.width),f=Math.ceil(o*d.height),p=Math.floor((a+l/this.#r)*d.width),g=Math.floor((o+c/this.#n)*d.height);s.width=p-u,s.height=g-f;const m=s.getContext("2d");m.setTransform(...n),m.translate(-u,-f),m.drawImage(d,0,0)}),t}#o([t,e,s,i,r,n]){const a=Math.hypot((r-t)*this.#r,(n-e)*this.#n),o=Math.hypot((s-t)*this.#r,(i-e)*this.#n);if(a<this.#i||o<this.#i)return null;const l=[(r-t)*this.#r/a,(n-e)*this.#n/a,(s-t)*this.#r/o,(i-e)*this.#n/o,0,0],c=D.inverseTransform(l),d=document.createElement("canvas");return d.className="textLayerImagePlaceholder",d.width=0,d.height=0,Object.assign(d.style,{opacity:0,position:"absolute",left:zs(t),top:zs(e),width:zs(a/this.#r),height:zs(o/this.#n),transformOrigin:"0% 0%",transform:`matrix(${l.join(",")})`}),this.#e.set(d,{inverseTransform:c,width:a,height:o,x1:t,y1:e}),d}}globalThis._pdfjsTestingUtils={HighlightOutliner:or};globalThis.pdfjsLib={AbortException:Pe,AnnotationEditorLayer:ve,AnnotationEditorParamsType:st,AnnotationEditorType:Y,AnnotationEditorUIManager:Ie,AnnotationLayer:Ur,AnnotationMode:Ee,AnnotationType:yt,applyOpacity:Jl,build:Oh,ColorPicker:te,createValidAbsoluteUrl:la,CSSConstants:nc,DOMSVGFactory:Nr,DrawLayer:X,FeatureTest:ot,fetchData:Cr,findContrastColor:Ql,getDocument:xh,getFilenameFromUrl:ec,getPdfFilenameFromUrl:sc,getRGB:Ms,getRGBA:ds,getUuid:ha,GlobalWorkerOptions:_e,ImageKind:Vs,InvalidPDFException:qi,isDataScheme:Ti,isPdfFile:Pr,isValidExplicitDest:pc,makeArr:hs,makeMap:Zs,makeObj:Ji,makeSet:ql,MathClamp:ft,noContextMenu:ae,normalizeUnicode:Yl,OPS:ye,OutputScale:Jt,PasswordException:Ki,PasswordResponses:$l,PDFDataRangeTransport:Ma,PDFDateString:tr,PDFWorker:xs,PermissionFlag:Hl,PixelsPerInch:os,RenderingCancelledException:xr,renderRichText:fa,ResponseException:Qs,setLayerDimensions:Ge,shadow:L,SignatureExtractor:ss,stopEvent:xt,SupportedImageMimeTypes:er,TextLayer:Xt,TextLayerImages:si,TouchManager:ga,updateUrlHash:ca,Util:D,VerbosityLevel:_i,version:kh,XfaLayer:ua};export{Pe as AbortException,ve as AnnotationEditorLayer,st as AnnotationEditorParamsType,Y as AnnotationEditorType,Ie as AnnotationEditorUIManager,Ur as AnnotationLayer,Ee as AnnotationMode,yt as AnnotationType,nc as CSSConstants,te as ColorPicker,Nr as DOMSVGFactory,X as DrawLayer,ot as FeatureTest,_e as GlobalWorkerOptions,Vs as ImageKind,qi as InvalidPDFException,ft as MathClamp,ye as OPS,Jt as OutputScale,Ma as PDFDataRangeTransport,tr as PDFDateString,xs as PDFWorker,Ki as PasswordException,$l as PasswordResponses,Hl as PermissionFlag,os as PixelsPerInch,xr as RenderingCancelledException,Qs as ResponseException,ss as SignatureExtractor,er as SupportedImageMimeTypes,Xt as TextLayer,si as TextLayerImages,ga as TouchManager,D as Util,_i as VerbosityLevel,ua as XfaLayer,Jl as applyOpacity,Oh as build,la as createValidAbsoluteUrl,Cr as fetchData,Ql as findContrastColor,xh as getDocument,ec as getFilenameFromUrl,sc as getPdfFilenameFromUrl,Ms as getRGB,ds as getRGBA,ha as getUuid,Ti as isDataScheme,Pr as isPdfFile,pc as isValidExplicitDest,hs as makeArr,Zs as makeMap,Ji as makeObj,ql as makeSet,ae as noContextMenu,Yl as normalizeUnicode,fa as renderRichText,Ge as setLayerDimensions,L as shadow,xt as stopEvent,ca as updateUrlHash,kh as version};