larkup 0.1.14 → 0.1.21

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 (1047) hide show
  1. package/.next/BUILD_ID +1 -0
  2. package/.next/app-path-routes-manifest.json +69 -0
  3. package/.next/build/chunks/[root-of-the-server]__0cstldc._.js +206 -0
  4. package/.next/build/chunks/[root-of-the-server]__0s3ts0r._.js +500 -0
  5. package/.next/build/chunks/[turbopack-node]_transforms_postcss_ts_0xqnjlz._.js +13 -0
  6. package/.next/build/chunks/[turbopack]_runtime.js +890 -0
  7. package/.next/build/chunks/node_modules__pnpm_04zrf.1._.js +7126 -0
  8. package/.next/build/package.json +1 -0
  9. package/.next/build/postcss.js +6 -0
  10. package/.next/build-manifest.json +22 -0
  11. package/.next/diagnostics/build-diagnostics.json +6 -0
  12. package/.next/diagnostics/framework.json +1 -0
  13. package/.next/diagnostics/route-bundle-stats.json +133 -0
  14. package/.next/export-marker.json +6 -0
  15. package/.next/fallback-build-manifest.json +13 -0
  16. package/.next/images-manifest.json +68 -0
  17. package/.next/next-minimal-server.js.nft.json +1 -0
  18. package/.next/next-server.js.nft.json +1 -0
  19. package/.next/package.json +1 -0
  20. package/.next/prerender-manifest.json +210 -0
  21. package/.next/required-server-files.js +356 -0
  22. package/.next/required-server-files.json +356 -0
  23. package/.next/routes-manifest.json +462 -0
  24. package/.next/server/app/_global-error/page/app-paths-manifest.json +3 -0
  25. package/.next/server/app/_global-error/page/build-manifest.json +18 -0
  26. package/.next/server/app/_global-error/page/next-font-manifest.json +6 -0
  27. package/.next/server/app/_global-error/page/react-loadable-manifest.json +1 -0
  28. package/.next/server/app/_global-error/page/server-reference-manifest.json +4 -0
  29. package/.next/server/app/_global-error/page.js +10 -0
  30. package/.next/server/app/_global-error/page.js.nft.json +1 -0
  31. package/.next/server/app/_global-error/page_client-reference-manifest.js +3 -0
  32. package/.next/server/app/_global-error.html +1 -0
  33. package/.next/server/app/_global-error.meta +15 -0
  34. package/.next/server/app/_global-error.rsc +15 -0
  35. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +5 -0
  36. package/.next/server/app/_global-error.segments/_full.segment.rsc +15 -0
  37. package/.next/server/app/_global-error.segments/_head.segment.rsc +6 -0
  38. package/.next/server/app/_global-error.segments/_index.segment.rsc +5 -0
  39. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -0
  40. package/.next/server/app/_not-found/page/app-paths-manifest.json +3 -0
  41. package/.next/server/app/_not-found/page/build-manifest.json +18 -0
  42. package/.next/server/app/_not-found/page/next-font-manifest.json +11 -0
  43. package/.next/server/app/_not-found/page/react-loadable-manifest.json +1 -0
  44. package/.next/server/app/_not-found/page/server-reference-manifest.json +4 -0
  45. package/.next/server/app/_not-found/page.js +14 -0
  46. package/.next/server/app/_not-found/page.js.nft.json +1 -0
  47. package/.next/server/app/_not-found/page_client-reference-manifest.js +3 -0
  48. package/.next/server/app/_not-found.html +1 -0
  49. package/.next/server/app/_not-found.meta +16 -0
  50. package/.next/server/app/_not-found.rsc +28 -0
  51. package/.next/server/app/_not-found.segments/_full.segment.rsc +28 -0
  52. package/.next/server/app/_not-found.segments/_head.segment.rsc +6 -0
  53. package/.next/server/app/_not-found.segments/_index.segment.rsc +14 -0
  54. package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +5 -0
  55. package/.next/server/app/_not-found.segments/_not-found.segment.rsc +5 -0
  56. package/.next/server/app/_not-found.segments/_tree.segment.rsc +3 -0
  57. package/.next/server/app/analytics/page/app-paths-manifest.json +3 -0
  58. package/.next/server/app/analytics/page/build-manifest.json +18 -0
  59. package/.next/server/app/analytics/page/next-font-manifest.json +11 -0
  60. package/.next/server/app/analytics/page/react-loadable-manifest.json +1 -0
  61. package/.next/server/app/analytics/page/server-reference-manifest.json +4 -0
  62. package/.next/server/app/analytics/page.js +15 -0
  63. package/.next/server/app/analytics/page.js.nft.json +1 -0
  64. package/.next/server/app/analytics/page_client-reference-manifest.js +3 -0
  65. package/.next/server/app/analytics.html +1 -0
  66. package/.next/server/app/analytics.meta +15 -0
  67. package/.next/server/app/analytics.rsc +32 -0
  68. package/.next/server/app/analytics.segments/_full.segment.rsc +32 -0
  69. package/.next/server/app/analytics.segments/_head.segment.rsc +6 -0
  70. package/.next/server/app/analytics.segments/_index.segment.rsc +14 -0
  71. package/.next/server/app/analytics.segments/_tree.segment.rsc +5 -0
  72. package/.next/server/app/analytics.segments/analytics/__PAGE__.segment.rsc +6 -0
  73. package/.next/server/app/analytics.segments/analytics.segment.rsc +5 -0
  74. package/.next/server/app/api/analytics/route/app-paths-manifest.json +3 -0
  75. package/.next/server/app/api/analytics/route/build-manifest.json +9 -0
  76. package/.next/server/app/api/analytics/route/server-reference-manifest.json +4 -0
  77. package/.next/server/app/api/analytics/route.js +9 -0
  78. package/.next/server/app/api/analytics/route.js.nft.json +1 -0
  79. package/.next/server/app/api/analytics/route_client-reference-manifest.js +3 -0
  80. package/.next/server/app/api/chat/route/app-paths-manifest.json +3 -0
  81. package/.next/server/app/api/chat/route/build-manifest.json +9 -0
  82. package/.next/server/app/api/chat/route/server-reference-manifest.json +4 -0
  83. package/.next/server/app/api/chat/route.js +24 -0
  84. package/.next/server/app/api/chat/route.js.nft.json +1 -0
  85. package/.next/server/app/api/chat/route_client-reference-manifest.js +3 -0
  86. package/.next/server/app/api/chat/status/route/app-paths-manifest.json +3 -0
  87. package/.next/server/app/api/chat/status/route/build-manifest.json +9 -0
  88. package/.next/server/app/api/chat/status/route/server-reference-manifest.json +4 -0
  89. package/.next/server/app/api/chat/status/route.js +9 -0
  90. package/.next/server/app/api/chat/status/route.js.nft.json +1 -0
  91. package/.next/server/app/api/chat/status/route_client-reference-manifest.js +3 -0
  92. package/.next/server/app/api/chat/suggestions/route/app-paths-manifest.json +3 -0
  93. package/.next/server/app/api/chat/suggestions/route/build-manifest.json +9 -0
  94. package/.next/server/app/api/chat/suggestions/route/server-reference-manifest.json +4 -0
  95. package/.next/server/app/api/chat/suggestions/route.js +17 -0
  96. package/.next/server/app/api/chat/suggestions/route.js.nft.json +1 -0
  97. package/.next/server/app/api/chat/suggestions/route_client-reference-manifest.js +3 -0
  98. package/.next/server/app/api/config/route/app-paths-manifest.json +3 -0
  99. package/.next/server/app/api/config/route/build-manifest.json +9 -0
  100. package/.next/server/app/api/config/route/server-reference-manifest.json +4 -0
  101. package/.next/server/app/api/config/route.js +8 -0
  102. package/.next/server/app/api/config/route.js.nft.json +1 -0
  103. package/.next/server/app/api/config/route_client-reference-manifest.js +3 -0
  104. package/.next/server/app/api/config/test/route/app-paths-manifest.json +3 -0
  105. package/.next/server/app/api/config/test/route/build-manifest.json +9 -0
  106. package/.next/server/app/api/config/test/route/server-reference-manifest.json +4 -0
  107. package/.next/server/app/api/config/test/route.js +8 -0
  108. package/.next/server/app/api/config/test/route.js.nft.json +1 -0
  109. package/.next/server/app/api/config/test/route_client-reference-manifest.js +3 -0
  110. package/.next/server/app/api/config/test-embedding/route/app-paths-manifest.json +3 -0
  111. package/.next/server/app/api/config/test-embedding/route/build-manifest.json +9 -0
  112. package/.next/server/app/api/config/test-embedding/route/server-reference-manifest.json +4 -0
  113. package/.next/server/app/api/config/test-embedding/route.js +12 -0
  114. package/.next/server/app/api/config/test-embedding/route.js.nft.json +1 -0
  115. package/.next/server/app/api/config/test-embedding/route_client-reference-manifest.js +3 -0
  116. package/.next/server/app/api/config/test-llm/route/app-paths-manifest.json +3 -0
  117. package/.next/server/app/api/config/test-llm/route/build-manifest.json +9 -0
  118. package/.next/server/app/api/config/test-llm/route/server-reference-manifest.json +4 -0
  119. package/.next/server/app/api/config/test-llm/route.js +12 -0
  120. package/.next/server/app/api/config/test-llm/route.js.nft.json +1 -0
  121. package/.next/server/app/api/config/test-llm/route_client-reference-manifest.js +3 -0
  122. package/.next/server/app/api/config/test-provider/route/app-paths-manifest.json +3 -0
  123. package/.next/server/app/api/config/test-provider/route/build-manifest.json +9 -0
  124. package/.next/server/app/api/config/test-provider/route/server-reference-manifest.json +4 -0
  125. package/.next/server/app/api/config/test-provider/route.js +13 -0
  126. package/.next/server/app/api/config/test-provider/route.js.nft.json +1 -0
  127. package/.next/server/app/api/config/test-provider/route_client-reference-manifest.js +3 -0
  128. package/.next/server/app/api/config/verify/route/app-paths-manifest.json +3 -0
  129. package/.next/server/app/api/config/verify/route/build-manifest.json +9 -0
  130. package/.next/server/app/api/config/verify/route/server-reference-manifest.json +4 -0
  131. package/.next/server/app/api/config/verify/route.js +16 -0
  132. package/.next/server/app/api/config/verify/route.js.nft.json +1 -0
  133. package/.next/server/app/api/config/verify/route_client-reference-manifest.js +3 -0
  134. package/.next/server/app/api/connections/route/app-paths-manifest.json +3 -0
  135. package/.next/server/app/api/connections/route/build-manifest.json +9 -0
  136. package/.next/server/app/api/connections/route/server-reference-manifest.json +4 -0
  137. package/.next/server/app/api/connections/route.js +8 -0
  138. package/.next/server/app/api/connections/route.js.nft.json +1 -0
  139. package/.next/server/app/api/connections/route_client-reference-manifest.js +3 -0
  140. package/.next/server/app/api/connections/webhook/route/app-paths-manifest.json +3 -0
  141. package/.next/server/app/api/connections/webhook/route/build-manifest.json +9 -0
  142. package/.next/server/app/api/connections/webhook/route/server-reference-manifest.json +4 -0
  143. package/.next/server/app/api/connections/webhook/route.js +10 -0
  144. package/.next/server/app/api/connections/webhook/route.js.nft.json +1 -0
  145. package/.next/server/app/api/connections/webhook/route_client-reference-manifest.js +3 -0
  146. package/.next/server/app/api/demo/route/app-paths-manifest.json +3 -0
  147. package/.next/server/app/api/demo/route/build-manifest.json +9 -0
  148. package/.next/server/app/api/demo/route/server-reference-manifest.json +4 -0
  149. package/.next/server/app/api/demo/route.js +15 -0
  150. package/.next/server/app/api/demo/route.js.nft.json +1 -0
  151. package/.next/server/app/api/demo/route_client-reference-manifest.js +3 -0
  152. package/.next/server/app/api/deploy/cloud-project/route/app-paths-manifest.json +3 -0
  153. package/.next/server/app/api/deploy/cloud-project/route/build-manifest.json +9 -0
  154. package/.next/server/app/api/deploy/cloud-project/route/server-reference-manifest.json +4 -0
  155. package/.next/server/app/api/deploy/cloud-project/route.js +13 -0
  156. package/.next/server/app/api/deploy/cloud-project/route.js.nft.json +1 -0
  157. package/.next/server/app/api/deploy/cloud-project/route_client-reference-manifest.js +3 -0
  158. package/.next/server/app/api/deploy/ssh/route/app-paths-manifest.json +3 -0
  159. package/.next/server/app/api/deploy/ssh/route/build-manifest.json +9 -0
  160. package/.next/server/app/api/deploy/ssh/route/server-reference-manifest.json +4 -0
  161. package/.next/server/app/api/deploy/ssh/route.js +8 -0
  162. package/.next/server/app/api/deploy/ssh/route.js.nft.json +1 -0
  163. package/.next/server/app/api/deploy/ssh/route_client-reference-manifest.js +3 -0
  164. package/.next/server/app/api/deployment/blob-setup/route/app-paths-manifest.json +3 -0
  165. package/.next/server/app/api/deployment/blob-setup/route/build-manifest.json +9 -0
  166. package/.next/server/app/api/deployment/blob-setup/route/server-reference-manifest.json +4 -0
  167. package/.next/server/app/api/deployment/blob-setup/route.js +8 -0
  168. package/.next/server/app/api/deployment/blob-setup/route.js.nft.json +1 -0
  169. package/.next/server/app/api/deployment/blob-setup/route_client-reference-manifest.js +3 -0
  170. package/.next/server/app/api/deployment/config/route/app-paths-manifest.json +3 -0
  171. package/.next/server/app/api/deployment/config/route/build-manifest.json +9 -0
  172. package/.next/server/app/api/deployment/config/route/server-reference-manifest.json +4 -0
  173. package/.next/server/app/api/deployment/config/route.js +8 -0
  174. package/.next/server/app/api/deployment/config/route.js.nft.json +1 -0
  175. package/.next/server/app/api/deployment/config/route_client-reference-manifest.js +3 -0
  176. package/.next/server/app/api/describe-image/route/app-paths-manifest.json +3 -0
  177. package/.next/server/app/api/describe-image/route/build-manifest.json +9 -0
  178. package/.next/server/app/api/describe-image/route/server-reference-manifest.json +4 -0
  179. package/.next/server/app/api/describe-image/route.js +15 -0
  180. package/.next/server/app/api/describe-image/route.js.nft.json +1 -0
  181. package/.next/server/app/api/describe-image/route_client-reference-manifest.js +3 -0
  182. package/.next/server/app/api/doc-editor/edit/route/app-paths-manifest.json +3 -0
  183. package/.next/server/app/api/doc-editor/edit/route/build-manifest.json +9 -0
  184. package/.next/server/app/api/doc-editor/edit/route/server-reference-manifest.json +4 -0
  185. package/.next/server/app/api/doc-editor/edit/route.js +11 -0
  186. package/.next/server/app/api/doc-editor/edit/route.js.nft.json +1 -0
  187. package/.next/server/app/api/doc-editor/edit/route_client-reference-manifest.js +3 -0
  188. package/.next/server/app/api/doc-editor/export/route/app-paths-manifest.json +3 -0
  189. package/.next/server/app/api/doc-editor/export/route/build-manifest.json +9 -0
  190. package/.next/server/app/api/doc-editor/export/route/server-reference-manifest.json +4 -0
  191. package/.next/server/app/api/doc-editor/export/route.js +11 -0
  192. package/.next/server/app/api/doc-editor/export/route.js.nft.json +1 -0
  193. package/.next/server/app/api/doc-editor/export/route_client-reference-manifest.js +3 -0
  194. package/.next/server/app/api/doc-editor/extract-text/route/app-paths-manifest.json +3 -0
  195. package/.next/server/app/api/doc-editor/extract-text/route/build-manifest.json +9 -0
  196. package/.next/server/app/api/doc-editor/extract-text/route/server-reference-manifest.json +4 -0
  197. package/.next/server/app/api/doc-editor/extract-text/route.js +11 -0
  198. package/.next/server/app/api/doc-editor/extract-text/route.js.nft.json +1 -0
  199. package/.next/server/app/api/doc-editor/extract-text/route_client-reference-manifest.js +3 -0
  200. package/.next/server/app/api/doc-editor/parse/route/app-paths-manifest.json +3 -0
  201. package/.next/server/app/api/doc-editor/parse/route/build-manifest.json +9 -0
  202. package/.next/server/app/api/doc-editor/parse/route/server-reference-manifest.json +4 -0
  203. package/.next/server/app/api/doc-editor/parse/route.js +12 -0
  204. package/.next/server/app/api/doc-editor/parse/route.js.nft.json +1 -0
  205. package/.next/server/app/api/doc-editor/parse/route_client-reference-manifest.js +3 -0
  206. package/.next/server/app/api/doc-editor/restore/route/app-paths-manifest.json +3 -0
  207. package/.next/server/app/api/doc-editor/restore/route/build-manifest.json +9 -0
  208. package/.next/server/app/api/doc-editor/restore/route/server-reference-manifest.json +4 -0
  209. package/.next/server/app/api/doc-editor/restore/route.js +11 -0
  210. package/.next/server/app/api/doc-editor/restore/route.js.nft.json +1 -0
  211. package/.next/server/app/api/doc-editor/restore/route_client-reference-manifest.js +3 -0
  212. package/.next/server/app/api/document/sign/route/app-paths-manifest.json +3 -0
  213. package/.next/server/app/api/document/sign/route/build-manifest.json +9 -0
  214. package/.next/server/app/api/document/sign/route/server-reference-manifest.json +4 -0
  215. package/.next/server/app/api/document/sign/route.js +12 -0
  216. package/.next/server/app/api/document/sign/route.js.nft.json +1 -0
  217. package/.next/server/app/api/document/sign/route_client-reference-manifest.js +3 -0
  218. package/.next/server/app/api/documents/route/app-paths-manifest.json +3 -0
  219. package/.next/server/app/api/documents/route/build-manifest.json +9 -0
  220. package/.next/server/app/api/documents/route/server-reference-manifest.json +4 -0
  221. package/.next/server/app/api/documents/route.js +8 -0
  222. package/.next/server/app/api/documents/route.js.nft.json +1 -0
  223. package/.next/server/app/api/documents/route_client-reference-manifest.js +3 -0
  224. package/.next/server/app/api/firecrawl/local/route/app-paths-manifest.json +3 -0
  225. package/.next/server/app/api/firecrawl/local/route/build-manifest.json +9 -0
  226. package/.next/server/app/api/firecrawl/local/route/server-reference-manifest.json +4 -0
  227. package/.next/server/app/api/firecrawl/local/route.js +8 -0
  228. package/.next/server/app/api/firecrawl/local/route.js.nft.json +1 -0
  229. package/.next/server/app/api/firecrawl/local/route_client-reference-manifest.js +3 -0
  230. package/.next/server/app/api/index/route/app-paths-manifest.json +3 -0
  231. package/.next/server/app/api/index/route/build-manifest.json +9 -0
  232. package/.next/server/app/api/index/route/server-reference-manifest.json +4 -0
  233. package/.next/server/app/api/index/route.js +14 -0
  234. package/.next/server/app/api/index/route.js.nft.json +1 -0
  235. package/.next/server/app/api/index/route_client-reference-manifest.js +3 -0
  236. package/.next/server/app/api/integrations/notion/callback/route/app-paths-manifest.json +3 -0
  237. package/.next/server/app/api/integrations/notion/callback/route/build-manifest.json +9 -0
  238. package/.next/server/app/api/integrations/notion/callback/route/server-reference-manifest.json +4 -0
  239. package/.next/server/app/api/integrations/notion/callback/route.js +8 -0
  240. package/.next/server/app/api/integrations/notion/callback/route.js.nft.json +1 -0
  241. package/.next/server/app/api/integrations/notion/callback/route_client-reference-manifest.js +3 -0
  242. package/.next/server/app/api/integrations/notion/route/app-paths-manifest.json +3 -0
  243. package/.next/server/app/api/integrations/notion/route/build-manifest.json +9 -0
  244. package/.next/server/app/api/integrations/notion/route/server-reference-manifest.json +4 -0
  245. package/.next/server/app/api/integrations/notion/route.js +8 -0
  246. package/.next/server/app/api/integrations/notion/route.js.nft.json +1 -0
  247. package/.next/server/app/api/integrations/notion/route_client-reference-manifest.js +3 -0
  248. package/.next/server/app/api/jobs/[id]/route/app-paths-manifest.json +3 -0
  249. package/.next/server/app/api/jobs/[id]/route/build-manifest.json +9 -0
  250. package/.next/server/app/api/jobs/[id]/route/server-reference-manifest.json +4 -0
  251. package/.next/server/app/api/jobs/[id]/route.js +8 -0
  252. package/.next/server/app/api/jobs/[id]/route.js.nft.json +1 -0
  253. package/.next/server/app/api/jobs/[id]/route_client-reference-manifest.js +3 -0
  254. package/.next/server/app/api/jobs/route/app-paths-manifest.json +3 -0
  255. package/.next/server/app/api/jobs/route/build-manifest.json +9 -0
  256. package/.next/server/app/api/jobs/route/server-reference-manifest.json +4 -0
  257. package/.next/server/app/api/jobs/route.js +8 -0
  258. package/.next/server/app/api/jobs/route.js.nft.json +1 -0
  259. package/.next/server/app/api/jobs/route_client-reference-manifest.js +3 -0
  260. package/.next/server/app/api/marketplace/[toolId]/route/app-paths-manifest.json +3 -0
  261. package/.next/server/app/api/marketplace/[toolId]/route/build-manifest.json +9 -0
  262. package/.next/server/app/api/marketplace/[toolId]/route/server-reference-manifest.json +4 -0
  263. package/.next/server/app/api/marketplace/[toolId]/route.js +9 -0
  264. package/.next/server/app/api/marketplace/[toolId]/route.js.nft.json +1 -0
  265. package/.next/server/app/api/marketplace/[toolId]/route_client-reference-manifest.js +3 -0
  266. package/.next/server/app/api/marketplace/route/app-paths-manifest.json +3 -0
  267. package/.next/server/app/api/marketplace/route/build-manifest.json +9 -0
  268. package/.next/server/app/api/marketplace/route/server-reference-manifest.json +4 -0
  269. package/.next/server/app/api/marketplace/route.js +9 -0
  270. package/.next/server/app/api/marketplace/route.js.nft.json +1 -0
  271. package/.next/server/app/api/marketplace/route_client-reference-manifest.js +3 -0
  272. package/.next/server/app/api/media/[id]/route/app-paths-manifest.json +3 -0
  273. package/.next/server/app/api/media/[id]/route/build-manifest.json +9 -0
  274. package/.next/server/app/api/media/[id]/route/server-reference-manifest.json +4 -0
  275. package/.next/server/app/api/media/[id]/route.js +8 -0
  276. package/.next/server/app/api/media/[id]/route.js.nft.json +1 -0
  277. package/.next/server/app/api/media/[id]/route_client-reference-manifest.js +3 -0
  278. package/.next/server/app/api/media/process/route/app-paths-manifest.json +3 -0
  279. package/.next/server/app/api/media/process/route/build-manifest.json +9 -0
  280. package/.next/server/app/api/media/process/route/server-reference-manifest.json +4 -0
  281. package/.next/server/app/api/media/process/route.js +17 -0
  282. package/.next/server/app/api/media/process/route.js.nft.json +1 -0
  283. package/.next/server/app/api/media/process/route_client-reference-manifest.js +3 -0
  284. package/.next/server/app/api/media/route/app-paths-manifest.json +3 -0
  285. package/.next/server/app/api/media/route/build-manifest.json +9 -0
  286. package/.next/server/app/api/media/route/server-reference-manifest.json +4 -0
  287. package/.next/server/app/api/media/route.js +9 -0
  288. package/.next/server/app/api/media/route.js.nft.json +1 -0
  289. package/.next/server/app/api/media/route_client-reference-manifest.js +3 -0
  290. package/.next/server/app/api/media/stream/route/app-paths-manifest.json +3 -0
  291. package/.next/server/app/api/media/stream/route/build-manifest.json +9 -0
  292. package/.next/server/app/api/media/stream/route/server-reference-manifest.json +4 -0
  293. package/.next/server/app/api/media/stream/route.js +7 -0
  294. package/.next/server/app/api/media/stream/route.js.nft.json +1 -0
  295. package/.next/server/app/api/media/stream/route_client-reference-manifest.js +3 -0
  296. package/.next/server/app/api/models/route/app-paths-manifest.json +3 -0
  297. package/.next/server/app/api/models/route/build-manifest.json +9 -0
  298. package/.next/server/app/api/models/route/server-reference-manifest.json +4 -0
  299. package/.next/server/app/api/models/route.js +9 -0
  300. package/.next/server/app/api/models/route.js.nft.json +1 -0
  301. package/.next/server/app/api/models/route_client-reference-manifest.js +3 -0
  302. package/.next/server/app/api/parse-file/route/app-paths-manifest.json +3 -0
  303. package/.next/server/app/api/parse-file/route/build-manifest.json +9 -0
  304. package/.next/server/app/api/parse-file/route/server-reference-manifest.json +4 -0
  305. package/.next/server/app/api/parse-file/route.js +11 -0
  306. package/.next/server/app/api/parse-file/route.js.nft.json +1 -0
  307. package/.next/server/app/api/parse-file/route_client-reference-manifest.js +3 -0
  308. package/.next/server/app/api/proxy/verify/route/app-paths-manifest.json +3 -0
  309. package/.next/server/app/api/proxy/verify/route/build-manifest.json +9 -0
  310. package/.next/server/app/api/proxy/verify/route/server-reference-manifest.json +4 -0
  311. package/.next/server/app/api/proxy/verify/route.js +8 -0
  312. package/.next/server/app/api/proxy/verify/route.js.nft.json +1 -0
  313. package/.next/server/app/api/proxy/verify/route_client-reference-manifest.js +3 -0
  314. package/.next/server/app/api/sandbox/route/app-paths-manifest.json +3 -0
  315. package/.next/server/app/api/sandbox/route/build-manifest.json +9 -0
  316. package/.next/server/app/api/sandbox/route/server-reference-manifest.json +4 -0
  317. package/.next/server/app/api/sandbox/route.js +8 -0
  318. package/.next/server/app/api/sandbox/route.js.nft.json +1 -0
  319. package/.next/server/app/api/sandbox/route_client-reference-manifest.js +3 -0
  320. package/.next/server/app/api/search/bing/route/app-paths-manifest.json +3 -0
  321. package/.next/server/app/api/search/bing/route/build-manifest.json +9 -0
  322. package/.next/server/app/api/search/bing/route/server-reference-manifest.json +4 -0
  323. package/.next/server/app/api/search/bing/route.js +8 -0
  324. package/.next/server/app/api/search/bing/route.js.nft.json +1 -0
  325. package/.next/server/app/api/search/bing/route_client-reference-manifest.js +3 -0
  326. package/.next/server/app/api/search/brave/route/app-paths-manifest.json +3 -0
  327. package/.next/server/app/api/search/brave/route/build-manifest.json +9 -0
  328. package/.next/server/app/api/search/brave/route/server-reference-manifest.json +4 -0
  329. package/.next/server/app/api/search/brave/route.js +8 -0
  330. package/.next/server/app/api/search/brave/route.js.nft.json +1 -0
  331. package/.next/server/app/api/search/brave/route_client-reference-manifest.js +3 -0
  332. package/.next/server/app/api/search/exa/route/app-paths-manifest.json +3 -0
  333. package/.next/server/app/api/search/exa/route/build-manifest.json +9 -0
  334. package/.next/server/app/api/search/exa/route/server-reference-manifest.json +4 -0
  335. package/.next/server/app/api/search/exa/route.js +8 -0
  336. package/.next/server/app/api/search/exa/route.js.nft.json +1 -0
  337. package/.next/server/app/api/search/exa/route_client-reference-manifest.js +3 -0
  338. package/.next/server/app/api/search/google/route/app-paths-manifest.json +3 -0
  339. package/.next/server/app/api/search/google/route/build-manifest.json +9 -0
  340. package/.next/server/app/api/search/google/route/server-reference-manifest.json +4 -0
  341. package/.next/server/app/api/search/google/route.js +8 -0
  342. package/.next/server/app/api/search/google/route.js.nft.json +1 -0
  343. package/.next/server/app/api/search/google/route_client-reference-manifest.js +3 -0
  344. package/.next/server/app/api/search/route/app-paths-manifest.json +3 -0
  345. package/.next/server/app/api/search/route/build-manifest.json +9 -0
  346. package/.next/server/app/api/search/route/server-reference-manifest.json +4 -0
  347. package/.next/server/app/api/search/route.js +8 -0
  348. package/.next/server/app/api/search/route.js.nft.json +1 -0
  349. package/.next/server/app/api/search/route_client-reference-manifest.js +3 -0
  350. package/.next/server/app/api/search/tavily/route/app-paths-manifest.json +3 -0
  351. package/.next/server/app/api/search/tavily/route/build-manifest.json +9 -0
  352. package/.next/server/app/api/search/tavily/route/server-reference-manifest.json +4 -0
  353. package/.next/server/app/api/search/tavily/route.js +8 -0
  354. package/.next/server/app/api/search/tavily/route.js.nft.json +1 -0
  355. package/.next/server/app/api/search/tavily/route_client-reference-manifest.js +3 -0
  356. package/.next/server/app/api/search/verify/route/app-paths-manifest.json +3 -0
  357. package/.next/server/app/api/search/verify/route/build-manifest.json +9 -0
  358. package/.next/server/app/api/search/verify/route/server-reference-manifest.json +4 -0
  359. package/.next/server/app/api/search/verify/route.js +8 -0
  360. package/.next/server/app/api/search/verify/route.js.nft.json +1 -0
  361. package/.next/server/app/api/search/verify/route_client-reference-manifest.js +3 -0
  362. package/.next/server/app/api/server/agent/route/app-paths-manifest.json +3 -0
  363. package/.next/server/app/api/server/agent/route/build-manifest.json +9 -0
  364. package/.next/server/app/api/server/agent/route/server-reference-manifest.json +4 -0
  365. package/.next/server/app/api/server/agent/route.js +10 -0
  366. package/.next/server/app/api/server/agent/route.js.nft.json +1 -0
  367. package/.next/server/app/api/server/agent/route_client-reference-manifest.js +3 -0
  368. package/.next/server/app/api/server/download/route/app-paths-manifest.json +3 -0
  369. package/.next/server/app/api/server/download/route/build-manifest.json +9 -0
  370. package/.next/server/app/api/server/download/route/server-reference-manifest.json +4 -0
  371. package/.next/server/app/api/server/download/route.js +9 -0
  372. package/.next/server/app/api/server/download/route.js.nft.json +1 -0
  373. package/.next/server/app/api/server/download/route_client-reference-manifest.js +3 -0
  374. package/.next/server/app/api/server/generate/route/app-paths-manifest.json +3 -0
  375. package/.next/server/app/api/server/generate/route/build-manifest.json +9 -0
  376. package/.next/server/app/api/server/generate/route/server-reference-manifest.json +4 -0
  377. package/.next/server/app/api/server/generate/route.js +10 -0
  378. package/.next/server/app/api/server/generate/route.js.nft.json +1 -0
  379. package/.next/server/app/api/server/generate/route_client-reference-manifest.js +3 -0
  380. package/.next/server/app/api/server/local/route/app-paths-manifest.json +3 -0
  381. package/.next/server/app/api/server/local/route/build-manifest.json +9 -0
  382. package/.next/server/app/api/server/local/route/server-reference-manifest.json +4 -0
  383. package/.next/server/app/api/server/local/route.js +10 -0
  384. package/.next/server/app/api/server/local/route.js.nft.json +1 -0
  385. package/.next/server/app/api/server/local/route_client-reference-manifest.js +3 -0
  386. package/.next/server/app/api/servers/route/app-paths-manifest.json +3 -0
  387. package/.next/server/app/api/servers/route/build-manifest.json +9 -0
  388. package/.next/server/app/api/servers/route/server-reference-manifest.json +4 -0
  389. package/.next/server/app/api/servers/route.js +10 -0
  390. package/.next/server/app/api/servers/route.js.nft.json +1 -0
  391. package/.next/server/app/api/servers/route_client-reference-manifest.js +3 -0
  392. package/.next/server/app/api/tabular/query/route/app-paths-manifest.json +3 -0
  393. package/.next/server/app/api/tabular/query/route/build-manifest.json +9 -0
  394. package/.next/server/app/api/tabular/query/route/server-reference-manifest.json +4 -0
  395. package/.next/server/app/api/tabular/query/route.js +8 -0
  396. package/.next/server/app/api/tabular/query/route.js.nft.json +1 -0
  397. package/.next/server/app/api/tabular/query/route_client-reference-manifest.js +3 -0
  398. package/.next/server/app/api/tabular/route/app-paths-manifest.json +3 -0
  399. package/.next/server/app/api/tabular/route/build-manifest.json +9 -0
  400. package/.next/server/app/api/tabular/route/server-reference-manifest.json +4 -0
  401. package/.next/server/app/api/tabular/route.js +8 -0
  402. package/.next/server/app/api/tabular/route.js.nft.json +1 -0
  403. package/.next/server/app/api/tabular/route_client-reference-manifest.js +3 -0
  404. package/.next/server/app/api/upload-file/route/app-paths-manifest.json +3 -0
  405. package/.next/server/app/api/upload-file/route/build-manifest.json +9 -0
  406. package/.next/server/app/api/upload-file/route/server-reference-manifest.json +4 -0
  407. package/.next/server/app/api/upload-file/route.js +8 -0
  408. package/.next/server/app/api/upload-file/route.js.nft.json +1 -0
  409. package/.next/server/app/api/upload-file/route_client-reference-manifest.js +3 -0
  410. package/.next/server/app/api/uploads/[...slug]/route/app-paths-manifest.json +3 -0
  411. package/.next/server/app/api/uploads/[...slug]/route/build-manifest.json +9 -0
  412. package/.next/server/app/api/uploads/[...slug]/route/server-reference-manifest.json +4 -0
  413. package/.next/server/app/api/uploads/[...slug]/route.js +8 -0
  414. package/.next/server/app/api/uploads/[...slug]/route.js.nft.json +1 -0
  415. package/.next/server/app/api/uploads/[...slug]/route_client-reference-manifest.js +3 -0
  416. package/.next/server/app/api/vector-stores/install/route/app-paths-manifest.json +3 -0
  417. package/.next/server/app/api/vector-stores/install/route/build-manifest.json +9 -0
  418. package/.next/server/app/api/vector-stores/install/route/server-reference-manifest.json +4 -0
  419. package/.next/server/app/api/vector-stores/install/route.js +8 -0
  420. package/.next/server/app/api/vector-stores/install/route.js.nft.json +1 -0
  421. package/.next/server/app/api/vector-stores/install/route_client-reference-manifest.js +3 -0
  422. package/.next/server/app/api/vector-stores/status/route/app-paths-manifest.json +3 -0
  423. package/.next/server/app/api/vector-stores/status/route/build-manifest.json +9 -0
  424. package/.next/server/app/api/vector-stores/status/route/server-reference-manifest.json +4 -0
  425. package/.next/server/app/api/vector-stores/status/route.js +8 -0
  426. package/.next/server/app/api/vector-stores/status/route.js.nft.json +1 -0
  427. package/.next/server/app/api/vector-stores/status/route_client-reference-manifest.js +3 -0
  428. package/.next/server/app/chat/page/app-paths-manifest.json +3 -0
  429. package/.next/server/app/chat/page/build-manifest.json +18 -0
  430. package/.next/server/app/chat/page/next-font-manifest.json +11 -0
  431. package/.next/server/app/chat/page/react-loadable-manifest.json +1 -0
  432. package/.next/server/app/chat/page/server-reference-manifest.json +4 -0
  433. package/.next/server/app/chat/page.js +15 -0
  434. package/.next/server/app/chat/page.js.nft.json +1 -0
  435. package/.next/server/app/chat/page_client-reference-manifest.js +3 -0
  436. package/.next/server/app/chat.html +1 -0
  437. package/.next/server/app/chat.meta +15 -0
  438. package/.next/server/app/chat.rsc +29 -0
  439. package/.next/server/app/chat.segments/_full.segment.rsc +29 -0
  440. package/.next/server/app/chat.segments/_head.segment.rsc +6 -0
  441. package/.next/server/app/chat.segments/_index.segment.rsc +14 -0
  442. package/.next/server/app/chat.segments/_tree.segment.rsc +5 -0
  443. package/.next/server/app/chat.segments/chat/__PAGE__.segment.rsc +6 -0
  444. package/.next/server/app/chat.segments/chat.segment.rsc +5 -0
  445. package/.next/server/app/data/page/app-paths-manifest.json +3 -0
  446. package/.next/server/app/data/page/build-manifest.json +18 -0
  447. package/.next/server/app/data/page/next-font-manifest.json +11 -0
  448. package/.next/server/app/data/page/react-loadable-manifest.json +1 -0
  449. package/.next/server/app/data/page/server-reference-manifest.json +4 -0
  450. package/.next/server/app/data/page.js +15 -0
  451. package/.next/server/app/data/page.js.nft.json +1 -0
  452. package/.next/server/app/data/page_client-reference-manifest.js +3 -0
  453. package/.next/server/app/data.html +1 -0
  454. package/.next/server/app/data.meta +15 -0
  455. package/.next/server/app/data.rsc +32 -0
  456. package/.next/server/app/data.segments/_full.segment.rsc +32 -0
  457. package/.next/server/app/data.segments/_head.segment.rsc +6 -0
  458. package/.next/server/app/data.segments/_index.segment.rsc +14 -0
  459. package/.next/server/app/data.segments/_tree.segment.rsc +5 -0
  460. package/.next/server/app/data.segments/data/__PAGE__.segment.rsc +6 -0
  461. package/.next/server/app/data.segments/data.segment.rsc +5 -0
  462. package/.next/server/app/favicon.ico/route/app-paths-manifest.json +3 -0
  463. package/.next/server/app/favicon.ico/route/build-manifest.json +9 -0
  464. package/.next/server/app/favicon.ico/route.js +8 -0
  465. package/.next/server/app/favicon.ico/route.js.nft.json +1 -0
  466. package/.next/server/app/favicon.ico.body +0 -0
  467. package/.next/server/app/favicon.ico.meta +1 -0
  468. package/.next/server/app/index.html +1 -0
  469. package/.next/server/app/index.meta +14 -0
  470. package/.next/server/app/index.rsc +26 -0
  471. package/.next/server/app/index.segments/__PAGE__.segment.rsc +6 -0
  472. package/.next/server/app/index.segments/_full.segment.rsc +26 -0
  473. package/.next/server/app/index.segments/_head.segment.rsc +6 -0
  474. package/.next/server/app/index.segments/_index.segment.rsc +14 -0
  475. package/.next/server/app/index.segments/_tree.segment.rsc +5 -0
  476. package/.next/server/app/page/app-paths-manifest.json +3 -0
  477. package/.next/server/app/page/build-manifest.json +18 -0
  478. package/.next/server/app/page/next-font-manifest.json +11 -0
  479. package/.next/server/app/page/react-loadable-manifest.json +1 -0
  480. package/.next/server/app/page/server-reference-manifest.json +4 -0
  481. package/.next/server/app/page.js +16 -0
  482. package/.next/server/app/page.js.nft.json +1 -0
  483. package/.next/server/app/page_client-reference-manifest.js +3 -0
  484. package/.next/server/app/settings/page/app-paths-manifest.json +3 -0
  485. package/.next/server/app/settings/page/build-manifest.json +18 -0
  486. package/.next/server/app/settings/page/next-font-manifest.json +11 -0
  487. package/.next/server/app/settings/page/react-loadable-manifest.json +1 -0
  488. package/.next/server/app/settings/page/server-reference-manifest.json +41 -0
  489. package/.next/server/app/settings/page.js +16 -0
  490. package/.next/server/app/settings/page.js.nft.json +1 -0
  491. package/.next/server/app/settings/page_client-reference-manifest.js +3 -0
  492. package/.next/server/app/settings.html +1 -0
  493. package/.next/server/app/settings.meta +15 -0
  494. package/.next/server/app/settings.rsc +31 -0
  495. package/.next/server/app/settings.segments/_full.segment.rsc +31 -0
  496. package/.next/server/app/settings.segments/_head.segment.rsc +6 -0
  497. package/.next/server/app/settings.segments/_index.segment.rsc +14 -0
  498. package/.next/server/app/settings.segments/_tree.segment.rsc +5 -0
  499. package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +9 -0
  500. package/.next/server/app/settings.segments/settings.segment.rsc +5 -0
  501. package/.next/server/app-paths-manifest.json +69 -0
  502. package/.next/server/chunks/00i._ai_dist_index_mjs_0u4.k1t._.js +34 -0
  503. package/.next/server/chunks/02dz_web__next-internal_server_app_api_config_test-embedding_route_actions_09--owe.js +3 -0
  504. package/.next/server/chunks/02dz_web__next-internal_server_app_api_config_test-provider_route_actions_0l6xr0t.js +3 -0
  505. package/.next/server/chunks/02dz_web__next-internal_server_app_api_deploy_cloud-project_route_actions_0pghds2.js +3 -0
  506. package/.next/server/chunks/02dz_web__next-internal_server_app_api_deployment_blob-setup_route_actions_0f55gkq.js +3 -0
  507. package/.next/server/chunks/02dz_web__next-internal_server_app_api_doc-editor_extract-text_route_actions_0dzj6iq.js +3 -0
  508. package/.next/server/chunks/02dz_web__next-internal_server_app_api_marketplace_[toolId]_route_actions_0cxbtrw.js +3 -0
  509. package/.next/server/chunks/02dz_web__next-internal_server_app_api_vector-stores_install_route_actions_0_220fs.js +3 -0
  510. package/.next/server/chunks/02dz_web__next-internal_server_app_api_vector-stores_status_route_actions_0~_~b02.js +3 -0
  511. package/.next/server/chunks/0gvc_next_03p7xh-._.js +13 -0
  512. package/.next/server/chunks/0gvc_next_dist_esm_build_templates_app-route_0--xko7.js +24 -0
  513. package/.next/server/chunks/0gvc_next_dist_esm_build_templates_app-route_0.07y39.js +3 -0
  514. package/.next/server/chunks/0gvc_next_dist_esm_build_templates_app-route_04i84m2.js +10 -0
  515. package/.next/server/chunks/0gvc_next_dist_esm_build_templates_app-route_05yqn19.js +3 -0
  516. package/.next/server/chunks/0gvc_next_dist_esm_build_templates_app-route_0_c4eox.js +3 -0
  517. package/.next/server/chunks/0m6-_@ai-sdk_anthropic_dist_index_093y5mm.js +10 -0
  518. package/.next/server/chunks/0nf3_next-internal_server_app_api_integrations_notion_callback_route_actions_0hyfnmw.js +3 -0
  519. package/.next/server/chunks/0ntz_@ai-sdk_openai_dist_index_mjs_03ljy2u._.js +13 -0
  520. package/.next/server/chunks/0ozc_@vercel_oidc_dist_token_0m1934l.js +3 -0
  521. package/.next/server/chunks/0rgj_zod_v4_0ponial._.js +64 -0
  522. package/.next/server/chunks/0rgj_zod_v4_0zoqna9._.js +64 -0
  523. package/.next/server/chunks/[externals]__01hpkma._.js +3 -0
  524. package/.next/server/chunks/[externals]__01tm01i._.js +3 -0
  525. package/.next/server/chunks/[externals]_chromadb_0goja~y._.js +3 -0
  526. package/.next/server/chunks/[externals]_fs_0eo4gmu._.js +3 -0
  527. package/.next/server/chunks/[externals]_path_0.09pfe._.js +3 -0
  528. package/.next/server/chunks/[externals]_stream_0g9s3ok._.js +3 -0
  529. package/.next/server/chunks/[root-of-the-server]__0--6uey._.js +3 -0
  530. package/.next/server/chunks/[root-of-the-server]__0.qd1p3._.js +3 -0
  531. package/.next/server/chunks/[root-of-the-server]__0.r5yhr._.js +49 -0
  532. package/.next/server/chunks/[root-of-the-server]__0036943._.js +199 -0
  533. package/.next/server/chunks/[root-of-the-server]__00a7cyb._.js +3 -0
  534. package/.next/server/chunks/[root-of-the-server]__00nqa2u._.js +59 -0
  535. package/.next/server/chunks/[root-of-the-server]__0111be7._.js +3 -0
  536. package/.next/server/chunks/[root-of-the-server]__02c_z~9._.js +3 -0
  537. package/.next/server/chunks/[root-of-the-server]__02cpmox._.js +105 -0
  538. package/.next/server/chunks/[root-of-the-server]__02p-tv7._.js +105 -0
  539. package/.next/server/chunks/[root-of-the-server]__02p34d7._.js +3 -0
  540. package/.next/server/chunks/[root-of-the-server]__02t_0g7._.js +59 -0
  541. package/.next/server/chunks/[root-of-the-server]__03-x3no._.js +3 -0
  542. package/.next/server/chunks/[root-of-the-server]__03l~uw5._.js +143 -0
  543. package/.next/server/chunks/[root-of-the-server]__044l2_f._.js +143 -0
  544. package/.next/server/chunks/[root-of-the-server]__04kopvt._.js +63 -0
  545. package/.next/server/chunks/[root-of-the-server]__04l~ip-._.js +59 -0
  546. package/.next/server/chunks/[root-of-the-server]__04visk8._.js +105 -0
  547. package/.next/server/chunks/[root-of-the-server]__05wk..v._.js +3 -0
  548. package/.next/server/chunks/[root-of-the-server]__05x8tmf._.js +59 -0
  549. package/.next/server/chunks/[root-of-the-server]__06l96vc._.js +59 -0
  550. package/.next/server/chunks/[root-of-the-server]__06ohoeu._.js +59 -0
  551. package/.next/server/chunks/[root-of-the-server]__072q335._.js +3 -0
  552. package/.next/server/chunks/[root-of-the-server]__07_1411._.js +59 -0
  553. package/.next/server/chunks/[root-of-the-server]__09kos0n._.js +3 -0
  554. package/.next/server/chunks/[root-of-the-server]__09oyip3._.js +3 -0
  555. package/.next/server/chunks/[root-of-the-server]__09rsmk2._.js +3 -0
  556. package/.next/server/chunks/[root-of-the-server]__0_by00t._.js +11 -0
  557. package/.next/server/chunks/[root-of-the-server]__0a9jp5~._.js +3 -0
  558. package/.next/server/chunks/[root-of-the-server]__0acpo9m._.js +59 -0
  559. package/.next/server/chunks/[root-of-the-server]__0b17yoc._.js +3 -0
  560. package/.next/server/chunks/[root-of-the-server]__0cumfx6._.js +9 -0
  561. package/.next/server/chunks/[root-of-the-server]__0d7p0xo._.js +3 -0
  562. package/.next/server/chunks/[root-of-the-server]__0e_itje._.js +3 -0
  563. package/.next/server/chunks/[root-of-the-server]__0exyn0q._.js +88 -0
  564. package/.next/server/chunks/[root-of-the-server]__0fcf_rl._.js +59 -0
  565. package/.next/server/chunks/[root-of-the-server]__0f~eq1-._.js +59 -0
  566. package/.next/server/chunks/[root-of-the-server]__0g36cgg._.js +143 -0
  567. package/.next/server/chunks/[root-of-the-server]__0g4hq1o._.js +3 -0
  568. package/.next/server/chunks/[root-of-the-server]__0i9fj76._.js +3 -0
  569. package/.next/server/chunks/[root-of-the-server]__0lczaer._.js +143 -0
  570. package/.next/server/chunks/[root-of-the-server]__0ljy49-._.js +59 -0
  571. package/.next/server/chunks/[root-of-the-server]__0lk5hkk._.js +3 -0
  572. package/.next/server/chunks/[root-of-the-server]__0n0nerw._.js +59 -0
  573. package/.next/server/chunks/[root-of-the-server]__0np09bv._.js +3 -0
  574. package/.next/server/chunks/[root-of-the-server]__0ns~dg6._.js +3 -0
  575. package/.next/server/chunks/[root-of-the-server]__0oh5wgp._.js +59 -0
  576. package/.next/server/chunks/[root-of-the-server]__0oyc7s4._.js +105 -0
  577. package/.next/server/chunks/[root-of-the-server]__0pg~eys._.js +59 -0
  578. package/.next/server/chunks/[root-of-the-server]__0qhpl6k._.js +3 -0
  579. package/.next/server/chunks/[root-of-the-server]__0qhwzn-._.js +21 -0
  580. package/.next/server/chunks/[root-of-the-server]__0qs73xp._.js +143 -0
  581. package/.next/server/chunks/[root-of-the-server]__0qtx78g._.js +59 -0
  582. package/.next/server/chunks/[root-of-the-server]__0r03jcl._.js +59 -0
  583. package/.next/server/chunks/[root-of-the-server]__0rdjqpy._.js +3 -0
  584. package/.next/server/chunks/[root-of-the-server]__0sb7d93._.js +59 -0
  585. package/.next/server/chunks/[root-of-the-server]__0t36t5o._.js +60 -0
  586. package/.next/server/chunks/[root-of-the-server]__0t_hp52._.js +59 -0
  587. package/.next/server/chunks/[root-of-the-server]__0udlgj6._.js +3 -0
  588. package/.next/server/chunks/[root-of-the-server]__0ufk3d0._.js +3 -0
  589. package/.next/server/chunks/[root-of-the-server]__0uu6oan._.js +3 -0
  590. package/.next/server/chunks/[root-of-the-server]__0v.0gyp._.js +3 -0
  591. package/.next/server/chunks/[root-of-the-server]__0v03x56._.js +59 -0
  592. package/.next/server/chunks/[root-of-the-server]__0v4bbce._.js +59 -0
  593. package/.next/server/chunks/[root-of-the-server]__0v67rlo._.js +3 -0
  594. package/.next/server/chunks/[root-of-the-server]__0vcdpoc._.js +59 -0
  595. package/.next/server/chunks/[root-of-the-server]__0veqa4o._.js +3 -0
  596. package/.next/server/chunks/[root-of-the-server]__0wvxpqf._.js +59 -0
  597. package/.next/server/chunks/[root-of-the-server]__0wyl7x5._.js +59 -0
  598. package/.next/server/chunks/[root-of-the-server]__0y5y7tu._.js +3 -0
  599. package/.next/server/chunks/[root-of-the-server]__0yo._sm._.js +3 -0
  600. package/.next/server/chunks/[root-of-the-server]__0yx8vxp._.js +59 -0
  601. package/.next/server/chunks/[root-of-the-server]__0zh8t6z._.js +59 -0
  602. package/.next/server/chunks/[root-of-the-server]__0~q2fro._.js +59 -0
  603. package/.next/server/chunks/[root-of-the-server]__0~wsw0_._.js +3 -0
  604. package/.next/server/chunks/[root-of-the-server]__100gqj0._.js +143 -0
  605. package/.next/server/chunks/[root-of-the-server]__10au-r5._.js +13 -0
  606. package/.next/server/chunks/[root-of-the-server]__10d58x4._.js +59 -0
  607. package/.next/server/chunks/[root-of-the-server]__10zm06g._.js +143 -0
  608. package/.next/server/chunks/[root-of-the-server]__12kvuvp._.js +59 -0
  609. package/.next/server/chunks/[root-of-the-server]__13gq0t2._.js +3 -0
  610. package/.next/server/chunks/[turbopack]_runtime.js +903 -0
  611. package/.next/server/chunks/_01kokno._.js +3 -0
  612. package/.next/server/chunks/_059f-.0._.js +258 -0
  613. package/.next/server/chunks/_071mhy1._.js +32 -0
  614. package/.next/server/chunks/apps_web__next-internal_server_app_api_analytics_route_actions_0.uxcnt.js +3 -0
  615. package/.next/server/chunks/apps_web__next-internal_server_app_api_chat_route_actions_0q6zwqv.js +3 -0
  616. package/.next/server/chunks/apps_web__next-internal_server_app_api_chat_status_route_actions_0t_21~v.js +3 -0
  617. package/.next/server/chunks/apps_web__next-internal_server_app_api_chat_suggestions_route_actions_01umx_-.js +3 -0
  618. package/.next/server/chunks/apps_web__next-internal_server_app_api_config_route_actions_0-4ivvk.js +3 -0
  619. package/.next/server/chunks/apps_web__next-internal_server_app_api_config_test-llm_route_actions_0z5ew-0.js +3 -0
  620. package/.next/server/chunks/apps_web__next-internal_server_app_api_config_test_route_actions_08cur6r.js +3 -0
  621. package/.next/server/chunks/apps_web__next-internal_server_app_api_config_verify_route_actions_0hid6b..js +3 -0
  622. package/.next/server/chunks/apps_web__next-internal_server_app_api_connections_route_actions_0q3wdg3.js +3 -0
  623. package/.next/server/chunks/apps_web__next-internal_server_app_api_connections_webhook_route_actions_0wa28~b.js +3 -0
  624. package/.next/server/chunks/apps_web__next-internal_server_app_api_demo_route_actions_05lntn3.js +3 -0
  625. package/.next/server/chunks/apps_web__next-internal_server_app_api_deploy_ssh_route_actions_0r44rn0.js +3 -0
  626. package/.next/server/chunks/apps_web__next-internal_server_app_api_deployment_config_route_actions_0bkon.m.js +3 -0
  627. package/.next/server/chunks/apps_web__next-internal_server_app_api_describe-image_route_actions_0pmvs8v.js +3 -0
  628. package/.next/server/chunks/apps_web__next-internal_server_app_api_doc-editor_edit_route_actions_10hrovj.js +3 -0
  629. package/.next/server/chunks/apps_web__next-internal_server_app_api_doc-editor_export_route_actions_0rff01q.js +3 -0
  630. package/.next/server/chunks/apps_web__next-internal_server_app_api_doc-editor_parse_route_actions_0fkx6xw.js +3 -0
  631. package/.next/server/chunks/apps_web__next-internal_server_app_api_doc-editor_restore_route_actions_0g9uodw.js +3 -0
  632. package/.next/server/chunks/apps_web__next-internal_server_app_api_document_sign_route_actions_0_6rnl_.js +3 -0
  633. package/.next/server/chunks/apps_web__next-internal_server_app_api_documents_route_actions_0l2znaz.js +3 -0
  634. package/.next/server/chunks/apps_web__next-internal_server_app_api_firecrawl_local_route_actions_0ubjaim.js +3 -0
  635. package/.next/server/chunks/apps_web__next-internal_server_app_api_index_route_actions_0~2989e.js +3 -0
  636. package/.next/server/chunks/apps_web__next-internal_server_app_api_integrations_notion_route_actions_08es~5e.js +3 -0
  637. package/.next/server/chunks/apps_web__next-internal_server_app_api_jobs_[id]_route_actions_0.l39qd.js +3 -0
  638. package/.next/server/chunks/apps_web__next-internal_server_app_api_jobs_route_actions_08kx~8-.js +3 -0
  639. package/.next/server/chunks/apps_web__next-internal_server_app_api_marketplace_route_actions_0z~vymm.js +3 -0
  640. package/.next/server/chunks/apps_web__next-internal_server_app_api_media_[id]_route_actions_0wsnidd.js +3 -0
  641. package/.next/server/chunks/apps_web__next-internal_server_app_api_media_process_route_actions_0_j9maz.js +3 -0
  642. package/.next/server/chunks/apps_web__next-internal_server_app_api_media_route_actions_01szz-1.js +3 -0
  643. package/.next/server/chunks/apps_web__next-internal_server_app_api_media_stream_route_actions_0h2x_~2.js +3 -0
  644. package/.next/server/chunks/apps_web__next-internal_server_app_api_models_route_actions_0ervfbf.js +3 -0
  645. package/.next/server/chunks/apps_web__next-internal_server_app_api_parse-file_route_actions_134wu5p.js +3 -0
  646. package/.next/server/chunks/apps_web__next-internal_server_app_api_proxy_verify_route_actions_11frmb9.js +3 -0
  647. package/.next/server/chunks/apps_web__next-internal_server_app_api_sandbox_route_actions_0y9te9y.js +3 -0
  648. package/.next/server/chunks/apps_web__next-internal_server_app_api_search_bing_route_actions_0pfrdr1.js +3 -0
  649. package/.next/server/chunks/apps_web__next-internal_server_app_api_search_brave_route_actions_0sij14a.js +3 -0
  650. package/.next/server/chunks/apps_web__next-internal_server_app_api_search_exa_route_actions_013do9i.js +3 -0
  651. package/.next/server/chunks/apps_web__next-internal_server_app_api_search_google_route_actions_02aoghr.js +3 -0
  652. package/.next/server/chunks/apps_web__next-internal_server_app_api_search_route_actions_0_2o9ph.js +3 -0
  653. package/.next/server/chunks/apps_web__next-internal_server_app_api_search_tavily_route_actions_0z0cnd4.js +3 -0
  654. package/.next/server/chunks/apps_web__next-internal_server_app_api_search_verify_route_actions_0xtygzs.js +3 -0
  655. package/.next/server/chunks/apps_web__next-internal_server_app_api_server_agent_route_actions_11xuz1m.js +3 -0
  656. package/.next/server/chunks/apps_web__next-internal_server_app_api_server_download_route_actions_0vdr_bn.js +3 -0
  657. package/.next/server/chunks/apps_web__next-internal_server_app_api_server_generate_route_actions_12qf.pa.js +3 -0
  658. package/.next/server/chunks/apps_web__next-internal_server_app_api_server_local_route_actions_0c~tchb.js +3 -0
  659. package/.next/server/chunks/apps_web__next-internal_server_app_api_servers_route_actions_0_qimaq.js +3 -0
  660. package/.next/server/chunks/apps_web__next-internal_server_app_api_tabular_query_route_actions_0m_i8~j.js +3 -0
  661. package/.next/server/chunks/apps_web__next-internal_server_app_api_tabular_route_actions_06xgjmg.js +3 -0
  662. package/.next/server/chunks/apps_web__next-internal_server_app_api_upload-file_route_actions_0-df~h8.js +3 -0
  663. package/.next/server/chunks/apps_web__next-internal_server_app_api_uploads_[___slug]_route_actions_0-6rd8s.js +3 -0
  664. package/.next/server/chunks/apps_web__next-internal_server_app_favicon_ico_route_actions_0h5n1et.js +3 -0
  665. package/.next/server/chunks/node_modules__pnpm_00a45hz._.js +15 -0
  666. package/.next/server/chunks/node_modules__pnpm_01evtue._.js +36 -0
  667. package/.next/server/chunks/node_modules__pnpm_058qmaf._.js +36 -0
  668. package/.next/server/chunks/node_modules__pnpm_090g2s3._.js +3 -0
  669. package/.next/server/chunks/node_modules__pnpm_0of6.x_._.js +3 -0
  670. package/.next/server/chunks/node_modules__pnpm_0tui34u._.js +5 -0
  671. package/.next/server/chunks/node_modules__pnpm_11fyqx5._.js +15 -0
  672. package/.next/server/chunks/node_modules__pnpm_12rdsen._.js +36 -0
  673. package/.next/server/chunks/packages_070bs61._.js +3 -0
  674. package/.next/server/chunks/packages_0jmx5.-._.js +3 -0
  675. package/.next/server/chunks/packages_core_src_analytics-store_ts_03tqnqs._.js +3 -0
  676. package/.next/server/chunks/packages_core_src_embeddings_providers_ts_05f4_w-._.js +19 -0
  677. package/.next/server/chunks/packages_core_src_embeddings_registry_ts_031sc7-._.js +3 -0
  678. package/.next/server/chunks/packages_core_src_generator_generate-server_ts_0mt.je3._.js +1145 -0
  679. package/.next/server/chunks/packages_core_src_generator_server-runtime_ts_127f0ye._.js +648 -0
  680. package/.next/server/chunks/packages_core_src_index-store_ts_13sjtkb._.js +3 -0
  681. package/.next/server/chunks/packages_core_src_indexing_embedder_ts_0h75r~u._.js +20 -0
  682. package/.next/server/chunks/packages_core_src_media-store_ts_0v0lx36._.js +3 -0
  683. package/.next/server/chunks/packages_core_src_models-list_ts_03-odl5._.js +3 -0
  684. package/.next/server/chunks/packages_marketplace_src_0mxp_e3._.js +3 -0
  685. package/.next/server/chunks/packages_marketplace_src_storage-provider_ts_0mbs32-._.js +3 -0
  686. package/.next/server/chunks/packages_vector-stores_src_044u_tk._.js +3 -0
  687. package/.next/server/chunks/ssr/0ay0_framer-motion_dist_es_render_components_motion_proxy_mjs_00idub3._.js +3 -0
  688. package/.next/server/chunks/ssr/0gvc_next_dist_0e.uypd._.js +6 -0
  689. package/.next/server/chunks/ssr/0gvc_next_dist_client_components_0mj6fnc._.js +3 -0
  690. package/.next/server/chunks/ssr/0gvc_next_dist_client_components_builtin_forbidden_10qct8z.js +3 -0
  691. package/.next/server/chunks/ssr/0gvc_next_dist_client_components_builtin_global-error_0azu6.3.js +3 -0
  692. package/.next/server/chunks/ssr/0gvc_next_dist_client_components_builtin_unauthorized_03b6_.w.js +3 -0
  693. package/.next/server/chunks/ssr/0gvc_next_dist_esm_build_templates_app-page_0-imr0z.js +4 -0
  694. package/.next/server/chunks/ssr/0gvc_next_dist_esm_build_templates_app-page_00l31p..js +4 -0
  695. package/.next/server/chunks/ssr/0gvc_next_dist_esm_build_templates_app-page_0cjdc2w.js +4 -0
  696. package/.next/server/chunks/ssr/0gvc_next_dist_esm_build_templates_app-page_0fsrb82.js +4 -0
  697. package/.next/server/chunks/ssr/0gvc_next_dist_esm_build_templates_app-page_0l3eneq.js +4 -0
  698. package/.next/server/chunks/ssr/0gvc_next_dist_esm_build_templates_app-page_0l6387r.js +4 -0
  699. package/.next/server/chunks/ssr/0gvc_next_dist_esm_build_templates_app-page_0pk8tjk.js +4 -0
  700. package/.next/server/chunks/ssr/0hhw_pdfjs-dist_build_pdf_mjs_0emol.8._.js +47 -0
  701. package/.next/server/chunks/ssr/0ozc_@vercel_oidc_dist_token_0qkzh69.js +3 -0
  702. package/.next/server/chunks/ssr/[root-of-the-server]__03nybtv._.js +3 -0
  703. package/.next/server/chunks/ssr/[root-of-the-server]__061054q._.js +33 -0
  704. package/.next/server/chunks/ssr/[root-of-the-server]__0_lfs3c._.js +3 -0
  705. package/.next/server/chunks/ssr/[root-of-the-server]__0bxkvem._.js +3 -0
  706. package/.next/server/chunks/ssr/[root-of-the-server]__0ciwgj6._.js +3 -0
  707. package/.next/server/chunks/ssr/[root-of-the-server]__0f10~ff._.js +3 -0
  708. package/.next/server/chunks/ssr/[root-of-the-server]__0l9758p._.js +3 -0
  709. package/.next/server/chunks/ssr/[root-of-the-server]__0mib-aw._.js +3 -0
  710. package/.next/server/chunks/ssr/[root-of-the-server]__0o6u8a1._.js +3 -0
  711. package/.next/server/chunks/ssr/[root-of-the-server]__0q-0ign._.js +33 -0
  712. package/.next/server/chunks/ssr/[root-of-the-server]__0u7t7hm._.js +3 -0
  713. package/.next/server/chunks/ssr/[root-of-the-server]__0yxrvhy._.js +3 -0
  714. package/.next/server/chunks/ssr/[root-of-the-server]__0z9yy2_._.js +3 -0
  715. package/.next/server/chunks/ssr/[root-of-the-server]__0zl.q74._.js +3 -0
  716. package/.next/server/chunks/ssr/[turbopack]_runtime.js +903 -0
  717. package/.next/server/chunks/ssr/_0-uky5v._.js +3 -0
  718. package/.next/server/chunks/ssr/_0007q7_._.js +3 -0
  719. package/.next/server/chunks/ssr/_003vid-._.js +3 -0
  720. package/.next/server/chunks/ssr/_03casre._.js +6 -0
  721. package/.next/server/chunks/ssr/_06imf71._.js +4 -0
  722. package/.next/server/chunks/ssr/_08uade7._.js +3 -0
  723. package/.next/server/chunks/ssr/_09~o4f.._.js +13 -0
  724. package/.next/server/chunks/ssr/_0_aolb-._.js +3 -0
  725. package/.next/server/chunks/ssr/_0_zom3a._.js +3 -0
  726. package/.next/server/chunks/ssr/_0erod4k._.js +3 -0
  727. package/.next/server/chunks/ssr/_0gh6844._.js +3 -0
  728. package/.next/server/chunks/ssr/_0h9s_hw._.js +3 -0
  729. package/.next/server/chunks/ssr/_0p1j64v._.js +3 -0
  730. package/.next/server/chunks/ssr/_0qi5c9~._.js +132 -0
  731. package/.next/server/chunks/ssr/_0qopd-r._.js +120 -0
  732. package/.next/server/chunks/ssr/_0s5_0n1._.js +3 -0
  733. package/.next/server/chunks/ssr/_11.lrfy._.js +6 -0
  734. package/.next/server/chunks/ssr/_13gucvb._.js +3 -0
  735. package/.next/server/chunks/ssr/apps_web__next-internal_server_app__global-error_page_actions_0.u5cfa.js +3 -0
  736. package/.next/server/chunks/ssr/apps_web__next-internal_server_app__not-found_page_actions_0appun9.js +3 -0
  737. package/.next/server/chunks/ssr/apps_web__next-internal_server_app_analytics_page_actions_04e3dmk.js +3 -0
  738. package/.next/server/chunks/ssr/apps_web__next-internal_server_app_chat_page_actions_0x9i55t.js +3 -0
  739. package/.next/server/chunks/ssr/apps_web__next-internal_server_app_data_page_actions_0f9t7xs.js +3 -0
  740. package/.next/server/chunks/ssr/apps_web__next-internal_server_app_page_actions_0rm5_5w.js +3 -0
  741. package/.next/server/chunks/ssr/apps_web_app_template_tsx_0.4m7c9._.js +3 -0
  742. package/.next/server/chunks/ssr/apps_web_app_template_tsx_0j2myib._.js +3 -0
  743. package/.next/server/chunks/ssr/apps_web_components_analytics_analytics-dashboard_tsx_0lrr85m._.js +3 -0
  744. package/.next/server/chunks/ssr/apps_web_components_ui_tabs_tsx_0435ww5._.js +3 -0
  745. package/.next/server/chunks/ssr/apps_web_lib_pdf-images_ts_0nzct~e._.js +3 -0
  746. package/.next/server/chunks/ssr/node_modules__pnpm_0auud-z._.js +3 -0
  747. package/.next/server/chunks/ssr/node_modules__pnpm_0efi01o._.js +3 -0
  748. package/.next/server/chunks/ssr/node_modules__pnpm_0ge5k63._.js +3 -0
  749. package/.next/server/chunks/ssr/node_modules__pnpm_0j6v-w5._.js +3 -0
  750. package/.next/server/chunks/ssr/node_modules__pnpm_0jmin55._.js +33 -0
  751. package/.next/server/chunks/ssr/node_modules__pnpm_0qjmu5-._.js +3 -0
  752. package/.next/server/chunks/ssr/node_modules__pnpm_0q~5d-e._.js +3 -0
  753. package/.next/server/chunks/ssr/node_modules__pnpm_0xnq.u3._.js +19 -0
  754. package/.next/server/chunks/ssr/packages_core_src_generator_generate-server_ts_0o.y7vi._.js +1145 -0
  755. package/.next/server/functions-config-manifest.json +52 -0
  756. package/.next/server/interception-route-rewrite-manifest.js +1 -0
  757. package/.next/server/middleware-build-manifest.js +22 -0
  758. package/.next/server/middleware-manifest.json +6 -0
  759. package/.next/server/next-font-manifest.js +1 -0
  760. package/.next/server/next-font-manifest.json +31 -0
  761. package/.next/server/pages/404.html +1 -0
  762. package/.next/server/pages/500.html +1 -0
  763. package/.next/server/pages-manifest.json +4 -0
  764. package/.next/server/prefetch-hints.json +1 -0
  765. package/.next/server/server-reference-manifest.js +1 -0
  766. package/.next/server/server-reference-manifest.json +42 -0
  767. package/.next/static/KqIuNxkoeAlhCusoxtMrS/_buildManifest.js +16 -0
  768. package/.next/static/KqIuNxkoeAlhCusoxtMrS/_clientMiddlewareManifest.js +1 -0
  769. package/.next/static/KqIuNxkoeAlhCusoxtMrS/_ssgManifest.js +1 -0
  770. package/.next/static/chunks/0-l-_.e4~p-tu.js +1 -0
  771. package/.next/static/chunks/00bdh97xa16uo.js +1 -0
  772. package/.next/static/chunks/00h-ng_jqta-2.js +1 -0
  773. package/.next/static/chunks/03jot0gqi~a10.js +1 -0
  774. package/.next/static/chunks/03~yq9q893hmn.js +1 -0
  775. package/.next/static/chunks/066jf0nk75nic.css +2 -0
  776. package/.next/static/chunks/06lztj0p4bq9f.js +31 -0
  777. package/.next/static/chunks/06mvsykkx_ufi.js +1 -0
  778. package/.next/static/chunks/090nmx8zs_1wf.js +1 -0
  779. package/.next/static/chunks/0_~l8kd_h3sbq.js +1 -0
  780. package/.next/static/chunks/0c-2rnxmjsotm.js +118 -0
  781. package/.next/static/chunks/0ho7lc.x2uknx.js +1 -0
  782. package/.next/static/chunks/0i-8kxwbvp9.l.js +129 -0
  783. package/.next/static/chunks/0l27y8_9hhe7s.js +4 -0
  784. package/.next/static/chunks/0q_qvc60_3aw4.js +1 -0
  785. package/.next/static/chunks/0r4ctb~yxw0ip.js +45 -0
  786. package/.next/static/chunks/0rp85cjcakb29.js +1 -0
  787. package/.next/static/chunks/0uawaqqylt5zw.css +1 -0
  788. package/.next/static/chunks/0ufxt21gvl.3g.js +1 -0
  789. package/.next/static/chunks/0vnayejbagbex.js +1 -0
  790. package/.next/static/chunks/0w6lgn24.0eip.js +1 -0
  791. package/.next/static/chunks/0wrbyfcre8l1-.js +1 -0
  792. package/.next/static/chunks/0xil-1~ra.qnv.js +1 -0
  793. package/.next/static/chunks/0zoh3o_.geqbv.js +1 -0
  794. package/.next/static/chunks/0~074ua5vk6f8.js +1 -0
  795. package/.next/static/chunks/0~_-3fik2n4-i.js +1 -0
  796. package/.next/static/chunks/10a_hianorzj3.js +1 -0
  797. package/.next/static/chunks/10k--lk9wf4pw.js +1 -0
  798. package/.next/static/chunks/14x~vj_4i-4bz.js +1 -0
  799. package/.next/static/chunks/15tyhmsp4jgmc.js +11 -0
  800. package/.next/static/chunks/16alfqkklv-bt.js +2 -0
  801. package/.next/static/chunks/176ixsksxtch_.js +1 -0
  802. package/.next/static/chunks/turbopack-06_~2vs.chjg_.js +1 -0
  803. package/.next/static/media/4fa387ec64143e14-s.0wkzw~je483f-.woff2 +0 -0
  804. package/.next/static/media/53b9e256198e5412-s.0-wfv7uh4i7h9.woff2 +0 -0
  805. package/.next/static/media/5ce348bf30bf5439-s.0zgw-jeven.3w.woff2 +0 -0
  806. package/.next/static/media/6306c77e7c8268e4-s.0rhz0arwfsn~5.woff2 +0 -0
  807. package/.next/static/media/7178b3e590c64307-s.0nx0ww8fni_q3.woff2 +0 -0
  808. package/.next/static/media/797e433ab948586e-s.p.08e28id.o-okb.woff2 +0 -0
  809. package/.next/static/media/7d817b4c03b0c5f1-s.0l76wvqk9d84w.woff2 +0 -0
  810. package/.next/static/media/8a480f0b521d4e75-s.0jzbimsg8vl84.woff2 +0 -0
  811. package/.next/static/media/bbc41e54d2fcbd21-s.0k4k9394f2q-k.woff2 +0 -0
  812. package/.next/static/media/caa3a2e1cccd8315-s.p.09~u27dqhyhd6.woff2 +0 -0
  813. package/.next/static/media/favicon.01rzdfen4476b.ico +0 -0
  814. package/.next/static/media/fef07dbb0973bf53-s.12tyk43_3sh9u.woff2 +0 -0
  815. package/.next/types/cache-life.d.ts +145 -0
  816. package/.next/types/routes.d.ts +136 -0
  817. package/.next/types/validator.ts +637 -0
  818. package/CHANGELOG.md +24 -0
  819. package/LICENSE +176 -0
  820. package/app/actions/vercel.ts +325 -152
  821. package/app/analytics/page.tsx +19 -0
  822. package/app/api/analytics/route.ts +31 -0
  823. package/app/api/chat/route.ts +331 -145
  824. package/app/api/chat/status/route.ts +73 -22
  825. package/app/api/chat/suggestions/route.ts +61 -48
  826. package/app/api/chat/tools.ts +995 -0
  827. package/app/api/config/route.ts +56 -32
  828. package/app/api/config/test/route.ts +33 -32
  829. package/app/api/config/test-llm/route.ts +9 -10
  830. package/app/api/config/verify/route.ts +315 -0
  831. package/app/api/connections/route.ts +39 -0
  832. package/app/api/connections/webhook/route.ts +43 -0
  833. package/app/api/demo/route.ts +32 -44
  834. package/app/api/deploy/cloud-project/route.ts +125 -0
  835. package/app/api/deploy/ssh/route.ts +173 -132
  836. package/app/api/deployment/blob-setup/route.ts +28 -0
  837. package/app/api/deployment/config/route.ts +23 -0
  838. package/app/api/describe-image/route.ts +84 -0
  839. package/app/api/doc-editor/edit/route.ts +88 -0
  840. package/app/api/doc-editor/export/route.ts +33 -0
  841. package/app/api/doc-editor/extract-text/route.ts +41 -0
  842. package/app/api/doc-editor/parse/route.ts +66 -0
  843. package/app/api/doc-editor/restore/route.ts +74 -0
  844. package/app/api/document/sign/route.ts +56 -0
  845. package/app/api/documents/route.ts +185 -35
  846. package/app/api/firecrawl/local/route.ts +63 -23
  847. package/app/api/index/route.ts +73 -59
  848. package/app/api/integrations/notion/callback/route.ts +121 -0
  849. package/app/api/integrations/notion/route.ts +304 -0
  850. package/app/api/jobs/route.ts +45 -47
  851. package/app/api/marketplace/[toolId]/route.ts +70 -0
  852. package/app/api/marketplace/route.ts +32 -0
  853. package/app/api/media/[id]/route.ts +108 -0
  854. package/app/api/media/process/route.ts +1242 -0
  855. package/app/api/media/route.ts +284 -0
  856. package/app/api/media/stream/route.ts +113 -0
  857. package/app/api/models/route.ts +23 -0
  858. package/app/api/proxy/verify/route.ts +66 -0
  859. package/app/api/sandbox/route.ts +59 -0
  860. package/app/api/search/bing/route.ts +87 -0
  861. package/app/api/search/brave/route.ts +89 -0
  862. package/app/api/search/exa/route.ts +101 -0
  863. package/app/api/search/google/route.ts +16 -29
  864. package/app/api/search/tavily/route.ts +94 -0
  865. package/app/api/search/verify/route.ts +28 -0
  866. package/app/api/server/agent/route.ts +41 -0
  867. package/app/api/server/download/route.ts +42 -34
  868. package/app/api/server/generate/route.ts +23 -23
  869. package/app/api/servers/route.ts +46 -62
  870. package/app/api/tabular/query/route.ts +26 -0
  871. package/app/api/tabular/route.ts +63 -0
  872. package/app/api/upload-file/route.ts +38 -0
  873. package/app/api/uploads/[...slug]/route.ts +90 -0
  874. package/app/api/vector-stores/install/route.ts +5 -6
  875. package/app/api/vector-stores/status/route.ts +9 -7
  876. package/app/chat/page.tsx +4 -8
  877. package/app/data/page.tsx +15 -8
  878. package/app/globals.css +150 -22
  879. package/app/layout.tsx +19 -17
  880. package/app/page.tsx +3 -32
  881. package/app/settings/page.tsx +80 -0
  882. package/app/themes.css +38 -2
  883. package/archive/redesign-v2/app/configure/page.tsx +53 -0
  884. package/archive/redesign-v2/app/demo/page.tsx +15 -0
  885. package/archive/redesign-v2/app/server/page.tsx +22 -0
  886. package/archive/redesign-v2/app/simple/chat/page.tsx +17 -0
  887. package/archive/redesign-v2/app/simple/docs/page.tsx +21 -0
  888. package/archive/redesign-v2/app/simple/settings/page.tsx +1104 -0
  889. package/{app → archive/redesign-v2/app-routes}/server/page.tsx +2 -2
  890. package/archive/redesign-v2/app-routes/simple/settings/page.tsx +1104 -0
  891. package/archive/redesign-v2/components/app-sidebar.tsx +188 -0
  892. package/archive/redesign-v2/components/app-topnav.tsx +195 -0
  893. package/archive/redesign-v2/components/global-settings.tsx +288 -0
  894. package/archive/redesign-v2/components/simple/simple-sidebar.tsx +171 -0
  895. package/archive/redesign-v2/components/simple/simple-topnav.tsx +175 -0
  896. package/bin/larkup.js +28 -0
  897. package/components/analytics/analytics-dashboard.tsx +504 -0
  898. package/components/app-sidebar.tsx +46 -57
  899. package/components/app-topnav.tsx +64 -150
  900. package/components/chat/canvas/doc-editor-provider.tsx +343 -0
  901. package/components/chat/canvas/document-canvas.tsx +102 -0
  902. package/components/chat/canvas/document-field.tsx +171 -0
  903. package/components/chat/canvas/document-viewer.tsx +453 -0
  904. package/components/chat/canvas/file-attachment-button.tsx +88 -0
  905. package/components/chat/canvas/file-chip.tsx +151 -0
  906. package/components/chat/chat-settings-modal.tsx +253 -149
  907. package/components/chat/chat-workspace.tsx +961 -149
  908. package/components/chat/message-item.tsx +935 -71
  909. package/components/chat/tools/chat-card.tsx +116 -0
  910. package/components/chat/tools/chat-chart.tsx +548 -0
  911. package/components/chat/tools/chat-data-table.tsx +370 -0
  912. package/components/chat/tools/chat-grid.tsx +99 -0
  913. package/components/chat/tools/chat-media-preview.tsx +246 -0
  914. package/components/chat/tools/chat-metrics.tsx +76 -0
  915. package/components/chat/tools/chat-sandbox-result.tsx +175 -0
  916. package/components/chat/tools/chat-signature-request.tsx +809 -0
  917. package/components/chat/tools/chat-tabs.tsx +66 -0
  918. package/components/chat/tools/corpus-data-result.tsx +206 -0
  919. package/components/chat/tools/knowledge-base-result.tsx +135 -0
  920. package/components/chat/tools/visual-placement-modal.tsx +316 -0
  921. package/components/chat/tools/visualization-tabs.tsx +37 -0
  922. package/components/client-layout-wrapper.tsx +52 -124
  923. package/components/configure/configure-form.tsx +301 -530
  924. package/components/configure/custom-model-modal.tsx +205 -0
  925. package/components/configure/store-fields.tsx +4 -1
  926. package/components/data/corpus-panel.tsx +329 -137
  927. package/components/data/data-workspace.tsx +428 -185
  928. package/components/data/firecrawl-notice.tsx +94 -122
  929. package/components/data/integrations-panel.tsx +408 -0
  930. package/components/data/jobs-panel.tsx +83 -105
  931. package/components/data/media-panel.tsx +1701 -0
  932. package/components/data/notion-panel.tsx +372 -0
  933. package/components/data/paste-panel.tsx +4 -3
  934. package/components/data/scrape-panel.tsx +389 -343
  935. package/components/data/tabular-preview.tsx +228 -0
  936. package/components/data/upload-panel.tsx +500 -206
  937. package/components/demo/demo-workspace.tsx +50 -83
  938. package/components/global-settings.tsx +71 -108
  939. package/components/index/global-index-progress.tsx +46 -0
  940. package/components/index/index-action-dialog.tsx +545 -0
  941. package/components/index/index-workspace.tsx +138 -219
  942. package/components/onboarding/simple-setup.tsx +126 -180
  943. package/components/onboarding/welcome-screen.tsx +428 -157
  944. package/components/server/deploy-button.tsx +95 -1233
  945. package/components/server/deploy-sheet.tsx +1061 -0
  946. package/components/server/server-workspace.tsx +62 -95
  947. package/components/settings/appearance-section.tsx +300 -0
  948. package/components/settings/connections-section.tsx +471 -0
  949. package/components/settings/deploy-section.tsx +24 -0
  950. package/components/settings/deployment-section.tsx +430 -0
  951. package/components/settings/general-section.tsx +734 -0
  952. package/components/settings/marketplace-section.tsx +385 -0
  953. package/components/settings/marketplace-tools-settings.tsx +436 -0
  954. package/components/settings/models-section.tsx +810 -0
  955. package/components/settings/playground-section.tsx +17 -0
  956. package/components/settings/prompts-section.tsx +384 -0
  957. package/components/settings/server-section.tsx +808 -0
  958. package/components/settings/settings-layout.tsx +147 -0
  959. package/components/settings/storage-section.tsx +394 -0
  960. package/components/simple/sdk-connect-dialog.tsx +38 -33
  961. package/components/simple/simple-sidebar.tsx +69 -72
  962. package/components/simple/simple-topnav.tsx +154 -0
  963. package/components/theme-customizer-provider.tsx +56 -79
  964. package/components/theme-switcher.tsx +92 -114
  965. package/components/ui/button.tsx +11 -13
  966. package/components/ui/card.tsx +17 -17
  967. package/components/ui/checkbox.tsx +5 -5
  968. package/components/ui/dialog.tsx +1 -1
  969. package/components/ui/dropdown-menu.tsx +24 -38
  970. package/components/ui/input.tsx +2 -2
  971. package/components/ui/popover.tsx +21 -34
  972. package/components/ui/provider-icon.tsx +88 -17
  973. package/components/ui/select.tsx +44 -61
  974. package/components/ui/sheet.tsx +33 -46
  975. package/components/ui/slider.tsx +52 -0
  976. package/components/ui/sonner.tsx +23 -36
  977. package/components/ui/table.tsx +19 -19
  978. package/components/ui/tabs.tsx +17 -24
  979. package/components/ui/textarea.tsx +4 -4
  980. package/components/unified-sidebar.tsx +222 -0
  981. package/components/update-banner.tsx +203 -0
  982. package/components/workspace/server-form-dialog.tsx +7 -7
  983. package/components/workspace/server-switcher.tsx +15 -37
  984. package/hooks/use-notion-auth.ts +60 -0
  985. package/lib/chat-model-provider.ts +115 -0
  986. package/lib/deployments.ts +119 -0
  987. package/lib/env-utils.ts +27 -0
  988. package/lib/media-knowledge.ts +431 -0
  989. package/lib/os-concurrency.ts +37 -0
  990. package/lib/pdf-images.ts +80 -0
  991. package/lib/search-provider-verification.ts +95 -0
  992. package/next.config.mjs +19 -2
  993. package/package.json +37 -20
  994. package/parse_log.mjs +67 -0
  995. package/public/icons/Confluence.png +0 -0
  996. package/public/icons/Salesforce.png +0 -0
  997. package/public/icons/audio.png +0 -0
  998. package/public/icons/bing.png +0 -0
  999. package/public/icons/brave.png +0 -0
  1000. package/public/icons/deepgram.png +0 -0
  1001. package/public/icons/discord.png +0 -0
  1002. package/public/icons/elevenlabs.png +0 -0
  1003. package/public/icons/exa.png +0 -0
  1004. package/public/icons/excel.png +0 -0
  1005. package/public/icons/fal.png +0 -0
  1006. package/public/icons/firecrawl.png +0 -0
  1007. package/public/icons/google-calender.png +0 -0
  1008. package/public/icons/google-drive.png +0 -0
  1009. package/public/icons/google.png +0 -0
  1010. package/public/icons/grok.png +0 -0
  1011. package/public/icons/image.png +0 -0
  1012. package/public/icons/jira.png +0 -0
  1013. package/public/icons/linear.png +0 -0
  1014. package/public/icons/markdown.png +0 -0
  1015. package/public/icons/onedrive.png +0 -0
  1016. package/public/icons/outlook.png +0 -0
  1017. package/public/icons/pdf.png +0 -0
  1018. package/public/icons/revai.png +0 -0
  1019. package/public/icons/revai.svg +1 -0
  1020. package/public/icons/sap.png +0 -0
  1021. package/public/icons/serpapi.svg +34 -0
  1022. package/public/icons/serper.png +0 -0
  1023. package/public/icons/sharepoint.png +0 -0
  1024. package/public/icons/slack.png +0 -0
  1025. package/public/icons/tavily.png +0 -0
  1026. package/public/icons/telegram.png +0 -0
  1027. package/public/icons/video.png +0 -0
  1028. package/public/icons/webhook.png +0 -0
  1029. package/public/icons/whatsapp.png +0 -0
  1030. package/public/icons/word.png +0 -0
  1031. package/public/logo-light2.png +0 -0
  1032. package/public/logo.png +0 -0
  1033. package/public/notion-white.png +0 -0
  1034. package/public/notion.png +0 -0
  1035. package/store/chat-store.ts +19 -0
  1036. package/store/scrape-store.ts +78 -0
  1037. package/tsconfig.json +1 -1
  1038. package/verify-models.mjs +133 -0
  1039. package/.env +0 -2
  1040. package/app/index-data/page.tsx +0 -15
  1041. package/app/simple/settings/page.tsx +0 -627
  1042. package/components/chat/knowledge-base-result.tsx +0 -97
  1043. /package/{app → archive/redesign-v2/app-routes}/configure/page.tsx +0 -0
  1044. /package/{app → archive/redesign-v2/app-routes}/demo/page.tsx +0 -0
  1045. /package/{app → archive/redesign-v2/app-routes}/simple/chat/page.tsx +0 -0
  1046. /package/{app → archive/redesign-v2/app-routes}/simple/docs/page.tsx +0 -0
  1047. /package/{app → archive/redesign-v2/app-routes}/simple/layout.tsx +0 -0
@@ -0,0 +1,45 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,410386,t=>{"use strict";var e=t.i(799718),i=t.i(402779);let s={get url(){return`file://${t.P("node_modules/.pnpm/pdfjs-dist@6.1.200/node_modules/pdfjs-dist/build/pdf.mjs")}`}},r="object"==typeof e.default&&e.default+""=="[object process]"&&!e.default.versions.nw&&!(e.default.versions.electron&&e.default.type&&"browser"!==e.default.type),n=[1/0,1/0,-1/0,-1/0],a=new Float32Array(n),o=[.001,0,0,.001,0,0],l="http://www.w3.org/2000/svg",h={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},d="pdfjs_internal_id_",c="pdfjs_internal_editor_",u={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},p={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},g={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},m={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},f={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},b={ERRORS:0,WARNINGS:1,INFOS:5},y={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},v={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},A=b.WARNINGS;function x(t){A>=b.INFOS&&console.info(`Info: ${t}`)}function w(t){A>=b.WARNINGS&&console.warn(`Warning: ${t}`)}function C(t){throw Error(t)}function S(t,e){t||C(e)}function E(t,e=null,i=null){if(!t)return null;if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){let e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{var s;s=t,t=decodeURIComponent(escape(s))}catch{}}let r=e?URL.parse(t,e):URL.parse(t);return!function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r)?null:r}function T(t,e,i=!1){let s=URL.parse(t);return s?(s.hash=e,s.href):i&&E(t,"http://example.com")?t.split("#",1)[0]+`${e?`#${e}`:""}`:""}function _(t){return t.substring(t.lastIndexOf("/")+1)}function k(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}let M=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=Error(),t.constructor=t,t}();class P extends M{constructor(t,e){super(t,"PasswordException"),this.code=e}}class D extends M{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class I extends M{constructor(t){super(t,"InvalidPDFException")}}class F extends M{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class B extends M{constructor(t){super(t,"FormatError")}}class L extends M{constructor(t){super(t,"AbortException")}}function R(t){"string"!=typeof t&&C("Invalid argument for stringToBytes");let e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}class O{static get isLittleEndian(){let t=new Uint8Array(4);return t[0]=1,k(this,"isLittleEndian",1===new Uint32Array(t.buffer,0,1)[0])}static get isOffscreenCanvasSupported(){return k(this,"isOffscreenCanvasSupported","u">typeof OffscreenCanvas)}static get isImageDecoderSupported(){return k(this,"isImageDecoderSupported","u">typeof ImageDecoder)}static get isFloat16ArraySupported(){return k(this,"isFloat16ArraySupported","u">typeof Float16Array)}static get isSanitizerSupported(){return k(this,"isSanitizerSupported","u">typeof Sanitizer)}static get platform(){let{platform:t,userAgent:e}=navigator;return k(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"):"u">typeof document&&(t=document.createElement("canvas").getContext("2d")),k(this,"isCanvasFilterSupported",t?.filter!==void 0)}static get isAlphaColorInputSupported(){if("u"<typeof document)return k(this,"isAlphaColorInputSupported",!1);let t=document.createElement("input");return t.type="color",t.setAttribute("alpha",""),t.value="#ff000080",k(this,"isAlphaColorInputSupported","#ff0000"!==t.value)}static get isBackdropFilterSupported(){return k(this,"isBackdropFilterSupported","u">typeof CSS&&CSS.supports("backdrop-filter","blur(1px)"))}}class N{static get hexNums(){return k(this,"hexNums",Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0")))}static makeHexColor(t,e,i){return`#${this.hexNums[t]}${this.hexNums[e]}${this.hexNums[i]}`}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,i=0){let s=t[i],r=t[i+1];t[i]=s*e[0]+r*e[2]+e[4],t[i+1]=s*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){let s=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5];for(let e=0;e<6;e+=2){let h=t[i+e],d=t[i+e+1];t[i+e]=h*s+d*n+o,t[i+e+1]=h*r+d*a+l}}static applyInverseTransform(t,e){let i=t[0],s=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-s*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-i*e[1]+s*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,i){let s=e[0],r=e[1],n=e[2],a=e[3],o=e[4],l=e[5],h=t[0],d=t[1],c=t[2],u=t[3],p=s*h+o,g=p,m=s*c+o,f=m,b=a*d+l,y=b,v=a*u+l,A=v;if(0!==r||0!==n){let t=r*h,e=r*c,i=n*d,s=n*u;p+=i,f+=i,m+=s,g+=s,b+=t,A+=t,v+=e,y+=e}i[0]=Math.min(i[0],p,m,g,f),i[1]=Math.min(i[1],b,v,y,A),i[2]=Math.max(i[2],p,m,g,f),i[3]=Math.max(i[3],b,v,y,A)}static inverseTransform(t){let e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){let i=t[0],s=t[1],r=t[2],n=t[3],a=i**2+s**2,o=r**2+n**2,l=(a+o)/2,h=Math.sqrt(l**2-(a*o-(i*r+s*n)**2));e[0]=Math.sqrt(l+h||1),e[1]=Math.sqrt(l-h||1)}static normalizeRect(t){let e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){let i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;let 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:[i,r,s,n]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,s,r){r[0]=Math.min(r[0],t,i),r[1]=Math.min(r[1],e,s),r[2]=Math.max(r[2],t,i),r[3]=Math.max(r[3],e,s)}static #t(t,e,i,s,r,n,a,o,l,h){if(l<=0||l>=1)return;let d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*r+3*l*n)+3*c*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static #e(t,e,i,s,r,n,a,o,l,h,d,c){if(1e-12>Math.abs(l)){Math.abs(h)>=1e-12&&this.#t(t,e,i,s,r,n,a,o,-d/h,c);return}let u=h**2-4*d*l;if(u<0)return;let p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,r,n,a,o,(-h+p)/g,c),this.#t(t,e,i,s,r,n,a,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,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,i,r,a,e,s,n,o,3*(-t+3*(i-r)+a),6*(t-2*i+r),3*(i-t),l),this.#e(t,i,r,a,e,s,n,o,3*(-e+3*(s-n)+o),6*(e-2*s+n),3*(s-e),l)}}let U=null,H=null;function z(t){return U||(U=/([\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,H=new Map([["ſt","ſt"]])),t.replaceAll(U,(t,e,i)=>e?e.normalize("NFKC"):H.get(i))}function G(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();let t=new Uint8Array(32);return crypto.getRandomValues(t),function(t){("object"!=typeof t||t?.length===void 0)&&C("Invalid argument for bytesToString");let e=t.length;if(e<8192)return String.fromCharCode.apply(null,t);let i=[];for(let s=0;s<e;s+=8192){let r=Math.min(s+8192,e),n=t.subarray(s,r);i.push(String.fromCharCode.apply(null,n))}return i.join("")}(t)}let $=()=>[],j=()=>new Map,V=()=>Object.create(null);function W(t,e,i){return Math.min(Math.max(t,e),i)}class K{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:r=0,offsetY:n=0,dontFlip:a=!1}){let o,l,h,d,c,u,p,g;this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=r,this.offsetY=n,i*=e;const m=(t[2]+t[0])/2,f=(t[3]+t[1])/2;switch((s%=360)<0&&(s+=360),s){case 180:o=-1,l=0,h=0,d=1;break;case 90:o=0,l=1,h=1,d=0;break;case 270:o=0,l=-1,h=-1,d=0;break;case 0:o=1,l=0,h=0,d=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(h=-h,d=-d),0===o?(c=Math.abs(f-t[1])*i+r,u=Math.abs(m-t[0])*i+n,p=(t[3]-t[1])*i,g=(t[2]-t[0])*i):(c=Math.abs(m-t[0])*i+r,u=Math.abs(f-t[1])*i+n,p=(t[2]-t[0])*i,g=(t[3]-t[1])*i),this.transform=[o*i,l*i,h*i,d*i,c-o*i*m-h*i*f,u-l*i*m-d*i*f],this.width=p,this.height=g}get rawDims(){let t=this.viewBox;return k(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:r=!1}={}){return new K({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:r})}convertToViewportPoint(t,e){let i=[t,e];return N.applyTransform(i,this.transform),i}convertToPdfPoint(t,e){let i=[t,e];return N.applyInverseTransform(i,this.transform),i}}class X{static textContent(t){let e=[],i={items:e,styles:Object.create(null)};return!function t(i){if(!i)return;let s=null,r=i.name;if("#text"===r)s=i.value;else{if(!X.shouldBuildText(r))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(let e of i.children)t(e)}(t),i}static shouldBuildText(t){return"textarea"!==t&&"input"!==t&&"option"!==t&&"select"!==t}}class q{static setupStorage(t,e,i,s,r){let n=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==n.value&&(t.textContent=n.value),"print"===r)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(n.value===i.attributes.xfaOn?t.setAttribute("checked",!0):n.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===r)break;t.addEventListener("change",t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==n.value&&t.setAttribute("value",n.value),"print"===r)break;t.addEventListener("input",t=>{s.setValue(e,{value:t.target.value})})}break;case"select":if(null!==n.value)for(let e of(t.setAttribute("value",n.value),i.children))e.attributes.value===n.value?e.attributes.selected=!0:Object.hasOwn(e.attributes,"selected")&&delete e.attributes.selected;t.addEventListener("input",t=>{let i=t.target.options,r=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:r})})}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:r}){let{attributes:n}=e,a=t instanceof HTMLAnchorElement;for(let[e,i]of("radio"===n.type&&(n.name=`${n.name}-${s}`),Object.entries(n)))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:a&&("href"===e||"newWindow"===e)||t.setAttribute(e,i)}a&&r.addLinkAttributes(t,n.href,n.newWindow),i&&n.dataId&&this.setupStorage(t,n.dataId,e,i)}static render(t){let e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,r=t.intent||"display",n=document.createElement(s.name);s.attributes&&this.setAttributes({html:n,element:s,intent:r,linkService:i});let a="richText"!==r,o=t.div;if(o.append(n),t.viewport){let e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");let l=[];if(0===s.children.length){if(s.value){let t=document.createTextNode(s.value);n.append(t),a&&X.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}let h=[[s,-1,n]];for(;h.length>0;){let[t,s,n]=h.at(-1);if(s+1===t.children.length){h.pop();continue}let o=t.children[++h.at(-1)[1]];if(null===o)continue;let{name:d}=o;if("#text"===d){let t=document.createTextNode(o.value);l.push(t),n.append(t);continue}let c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(n.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:r,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){let t=document.createTextNode(o.value);a&&X.shouldBuildText(d)&&l.push(t),c.append(t)}}for(let t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){let e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}static getPageViewport(t,{scale:e=1,rotation:i=0}){let{width:s,height:r}=t.attributes.style;return new K({viewBox:[0,0,parseInt(s,10),parseInt(r,10)],userUnit:1,scale:e,rotation:i})}}class Y{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function Q(t,e="text"){if(tr(t,document.baseURI)){let i=await fetch(t);if(!i.ok)throw Error(i.statusText);switch(e){case"blob":return i.blob();case"bytes":return i.bytes();case"json":return i.json()}return i.text()}return new Promise((i,s)=>{let r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="bytes"===e?"arraybuffer":e,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(200===r.status||0===r.status){switch(e){case"bytes":i(new Uint8Array(r.response));return;case"blob":case"json":i(r.response);return}i(r.responseText);return}s(Error(r.statusText))}},r.send(null)})}class J extends M{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Z(t){let e=t.length,i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function tt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function te(t){return[t]=t.split(/[#?]/,1),_(t)}function ti(t,e="document.pdf"){if("string"!=typeof t)return e;if(Z(t))return w('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;let i=(t=>{try{return new URL(t)}catch{}try{return new URL(decodeURIComponent(t))}catch{}try{return new URL(t,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{}return null})(t);if(!i)return e;let s=t=>{try{let e=decodeURIComponent(t);if(e.includes("/")&&(e=_(e),4===e.length&&r.test(e)))return t;return e}catch{return t}},r=/\.pdf$/i,n=_(i.pathname);if(r.test(n))return s(n);if(i.searchParams.size>0){let t=t=>[...t].findLast(t=>r.test(t)),e=t(i.searchParams.values())??t(i.searchParams.keys());if(e)return s(e)}if(i.hash){let t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(t)return s(t[0])}return e}class ts{#i=new Map;times=[];time(t){this.#i.has(t)&&w(`Timer is already running for ${t}`),this.#i.set(t,Date.now())}timeEnd(t){this.#i.has(t)||w(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.#i.get(t),end:Date.now()}),this.#i.delete(t)}toString(){let t=Math.max(...this.times.map(t=>t.name.length));return this.times.map(e=>`${e.name.padEnd(t)} ${e.end-e.start}ms
2
+ `).join("")}}function tr(t,e){let i=e?URL.parse(t,e):URL.parse(t);return/https?:/.test(i?.protocol??"")}function tn(t){t.preventDefault()}function ta(t){t.preventDefault(),t.stopPropagation()}class to{static #s;static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;this.#s||=RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?");let e=this.#s.exec(t);if(!e)return null;let i=parseInt(e[1],10),s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let 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;let l=e[7]||"Z",h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===l?(n+=h,a+=d):"+"===l&&(n-=h,a-=d),new Date(Date.UTC(i,s,r,n,a,o))}}function tl(t){if(t.startsWith("#")){let e=t.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(t.startsWith("rgb(")){let[e,i,s]=t.slice(4,-1).split(",").map(t=>parseInt(t,10));return[e,i,s,1]}if(t.startsWith("rgba(")){let e=t.slice(5,-1).split(",");return[parseInt(e[0],10),parseInt(e[1],10),parseInt(e[2],10),parseFloat(e[3])]}let e=t.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return e?[Math.round(255*parseFloat(e[1])),Math.round(255*parseFloat(e[2])),Math.round(255*parseFloat(e[3])),void 0!==e[4]&&"none"!==e[4]?parseFloat(e[4]):1]:null}function th(t){let e=tl(t);return e?e.slice(0,3):(w(`Not a valid color format: "${t}"`),[0,0,0])}function td(t){let{a:e,b:i,c:s,d:r,e:n,f:a}=t.getTransform();return[e,i,s,r,n,a]}function tc(t){let{a:e,b:i,c:s,d:r,e:n,f:a}=t.getTransform().invertSelf();return[e,i,s,r,n,a]}function tu(t,e,i=!1,s=!0){if(e instanceof K){let{pageWidth:s,pageHeight:r}=e.rawDims,{style:n}=t,a=`round(down, var(--total-scale-factor) * ${s}px, var(--scale-round-x))`,o=`round(down, var(--total-scale-factor) * ${r}px, var(--scale-round-y))`;i&&e.rotation%180!=0?(n.width=o,n.height=a):(n.width=a,n.height=o)}s&&t.setAttribute("data-main-rotation",e.rotation)}class tp{constructor(){const{pixelRatio:t}=tp;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,s,r=-1){let n=1/0,a=1/0,o=1/0;(i=tp.capPixels(i,r))>0&&(n=Math.sqrt(i/(t*e))),-1!==s&&(a=s/t,o=s/e);let l=Math.min(n,a,o);return(this.sx>l||this.sy>l)&&(this.sx=l,this.sy=l,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){let i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}let tg=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class tm{static get isDarkMode(){return k(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class tf{static get commentForegroundColor(){let t=document.createElement("span");t.classList.add("comment","sidebar");let{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);let{color:i}=window.getComputedStyle(t);return t.remove(),k(this,"commentForegroundColor",th(i))}}function tb(t,e){let i=255*(1-(e=W(e??1,0,1)));return t.map(t=>Math.round(t*e+i))}function ty(t,e){let i=t[0]/255,s=t[1]/255,r=t[2]/255,n=Math.max(i,s,r),a=Math.min(i,s,r),o=(n+a)/2;if(n===a)e[0]=e[1]=0;else{let t=n-a;switch(e[1]=o<.5?t/(n+a):t/(2-n-a),n){case i:e[0]=((s-r)/t+6*(s<r))*60;break;case s:e[0]=((r-i)/t+2)*60;break;case r:e[0]=((i-s)/t+4)*60}}e[2]=o}function tv(t,e){let i=t[0],s=t[1],r=t[2],n=(1-Math.abs(2*r-1))*s,a=n*(1-Math.abs(i/60%2-1)),o=r-n/2;switch(Math.floor(i/60)){case 0:e[0]=n+o,e[1]=a+o,e[2]=o;break;case 1:e[0]=a+o,e[1]=n+o,e[2]=o;break;case 2:e[0]=o,e[1]=n+o,e[2]=a+o;break;case 3:e[0]=o,e[1]=a+o,e[2]=n+o;break;case 4:e[0]=a+o,e[1]=o,e[2]=n+o;break;case 5:case 6:e[0]=n+o,e[1]=o,e[2]=a+o}}function tA(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function tx(t,e,i){tv(t,i),i.map(tA);let s=.2126*i[0]+.7152*i[1]+.0722*i[2];tv(e,i),i.map(tA);let r=.2126*i[0]+.7152*i[1]+.0722*i[2];return s>r?(s+.05)/(r+.05):(r+.05)/(s+.05)}let tw=new Map;function tC(t,e){let i=t[0]+256*t[1]+65536*t[2]+0x1000000*e[0]+0x100000000*e[1]+0x10000000000*e[2],s=tw.get(i);if(s)return s;let r=new Float32Array(9),n=r.subarray(0,3),a=r.subarray(3,6);ty(t,a);let o=r.subarray(6,9);ty(e,o);let l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),tx(a,o,n)<h){let t,e;for(l?(t=a[2],e=1):(t=0,e=a[2]);e-t>.005;){let i=a[2]=(t+e)/2;l===tx(a,o,n)<h?t=i:e=i}a[2]=l?e:t}return tv(a,n),s=N.makeHexColor(Math.round(255*n[0]),Math.round(255*n[1]),Math.round(255*n[2])),tw.set(i,s),s}function tS({html:t,dir:e,className:i},s){let r=document.createDocumentFragment();if("string"==typeof t){let i=document.createElement("p");i.dir=e||"auto";let s=t.split(/\r\n?|\n/);for(let t=0,e=s.length;t<e;++t){let r=s[t];i.append(document.createTextNode(r)),t<e-1&&i.append(document.createElement("br"))}r.append(i)}else q.render({xfaHtml:t,div:r,intent:"richText"});r.firstElementChild.classList.add("richText",i),s.append(r)}function tE(t){let e=new Path2D;if(!t)return e;for(let i=0,s=t.length;i<s;)switch(t[i++]){case 0:e.moveTo(t[i++],t[i++]);break;case 1:e.lineTo(t[i++],t[i++]);break;case 2:e.bezierCurveTo(t[i++],t[i++],t[i++],t[i++],t[i++],t[i++]);break;case 3:e.quadraticCurveTo(t[i++],t[i++],t[i++],t[i++]);break;case 4:e.closePath();break;default:w(`Unrecognized drawing path operator: ${t[i-1]}`)}return e}class tT{#r=null;#n=null;#a;#o=null;#l=null;#h=null;#d=null;#c=null;static #u=null;constructor(t){this.#a=t,tT.#u||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"})}render(){let t=this.#r=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");let e=this.#a._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",tn,{signal:e}),t.addEventListener("pointerdown",tT.#p,{signal:e}));let i=this.#o=document.createElement("div");i.className="buttons",t.append(i);let s=this.#a.toolbarPosition;if(s){let{style:e}=t,i="ltr"===this.#a._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=`${100*i}%`,e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#r}static #p(t){t.stopPropagation()}#g(t){this.#a._focusEventsAllowed=!1,ta(t)}#m(t){this.#a._focusEventsAllowed=!0,ta(t)}#f(t){let e=this.#a._uiManager._signal;return e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("focusin",this.#g.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#m.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",tn,{signal:e}),!0)}hide(){this.#r.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#r.classList.remove("hidden"),this.#l?.shown(),this.#h?.shown()}addDeleteButton(){let{editorType:t,_uiManager:e}=this.#a,i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",tT.#u[t]),this.#f(i)&&i.addEventListener("click",t=>{e.delete()},{signal:e._signal}),this.#o.append(i)}get #b(){let t=document.createElement("div");return t.className="divider",t}async addAltText(t){let e=await t.render();this.#f(e),this.#o.append(e,this.#b),this.#l=t}addComment(t,e=null){if(this.#h)return;let i=t.renderForToolbar();if(!i)return;this.#f(i);let s=this.#d=this.#b;e?(this.#o.insertBefore(i,e),this.#o.insertBefore(s,e)):this.#o.append(i,s),this.#h=t,t.toolbar=this}addColorPicker(t){if(this.#n)return;this.#n=t;let e=t.renderButton();this.#f(e),this.#o.append(e,this.#b)}async addEditSignatureButton(t){let e=this.#c=await t.renderEditButton(this.#a);this.#f(e),this.#o.append(e,this.#b)}removeButton(t){"comment"===t&&(this.#h?.removeToolbarCommentButton(),this.#h=null,this.#d?.remove(),this.#d=null)}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e)}}async addButtonBefore(t,e,i){if(!e&&"comment"===t)return;let s=this.#o.querySelector(i);s&&"comment"===t&&this.addComment(e,s)}updateEditSignatureButton(t){this.#c&&(this.#c.title=t)}remove(){this.#r.remove(),this.#n?.destroy(),this.#n=null}}class t_{#o=null;#r=null;#y;constructor(t){this.#y=t}#v(){let t=this.#r=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");let e=this.#y._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",tn,{signal:e});let i=this.#o=document.createElement("div");return i.className="buttons",t.append(i),this.#y.hasCommentManager()&&this.#A("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#y.commentSelection("floating_button")}),this.#A("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#y.highlightSelection("floating_button")}),t}#x(t,e){let i=0,s=0;for(let r of t){let t=r.y+r.height;if(t<i)continue;let n=r.x+(e?r.width:0);if(t>i){s=n,i=t;continue}e?n>s&&(s=n):n<s&&(s=n)}return[e?1-s:s,i]}show(t,e,i){let[s,r]=this.#x(e,i),{style:n}=this.#r||=this.#v();t.append(this.#r),n.insetInlineEnd=`${100*s}%`,n.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){this.#r.remove()}#A(t,e,i,s){let r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);let n=document.createElement("span");r.append(n),n.className="visuallyHidden",n.setAttribute("data-l10n-id",i);let a=this.#y._signal;a instanceof AbortSignal&&!a.aborted&&(r.addEventListener("contextmenu",tn,{signal:a}),r.addEventListener("click",s,{signal:a})),this.#o.append(r)}}let tk=Object.freeze({internal:"068f09d6-5b37-4f77-a97a-f8ff4f253b68"});function tM(t,e,i){for(let s of i)e.addEventListener(s,t[s].bind(t))}class tP{static #w=NaN;static #C=null;static #S=NaN;static #E=null;static initializeAndAddPointerId(t){(tP.#C||=new Set).add(t)}static setPointer(t,e){tP.#w||=e,tP.#E??=t}static setTimeStamp(t){tP.#S=t}static isSamePointerId(t){return tP.#w===t}static isSamePointerIdOrRemove(t){return tP.#w===t||(tP.#C?.delete(t),!1)}static isSamePointerType(t){return tP.#E===t}static isInitializedAndDifferentPointerType(t){return null!==tP.#E&&!tP.isSamePointerType(t)}static isSameTimeStamp(t){return tP.#S===t}static isUsingMultiplePointers(){return tP.#C?.size>=1}static clearPointerType(){tP.#E=null}static clearPointerIds(){tP.#w=NaN,tP.#C=null}static clearTimeStamp(){tP.#S=NaN}}class tD{#T=0;get id(){return`${c}${this.#T++}`}}class tI{#_=G();#T=0;#k=null;static get _isSVGFittingCanvas(){let t=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${l}"><rect width="1" height="1" style="fill:red;"/></svg>`,e=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;return i.src=t,k(this,"_isSVGFittingCanvas",i.decode().then(()=>(e.drawImage(i,0,0,1,1,0,0,1,3),0===new Uint32Array(e.getImageData(0,0,1,1).data.buffer)[0])))}async #M(t,e){this.#k||=new Map;let i=this.#k.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#_}_${this.#T++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await Q(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){let e=tI._isSVGFittingCanvas,s=new FileReader,r=new Image,n=new Promise((t,n)=>{r.onload=()=>{i.bitmap=r,i.isSvg=!0,t()},s.onload=async()=>{let t=i.svgUrl=s.result;r.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},r.onerror=s.onerror=n});s.readAsDataURL(t),await n}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){w(t),i=null}return this.#k.set(t,i),i&&this.#k.set(i.id,i),i}async getFromFile(t){let{lastModified:e,name:i,size:s,type:r}=t;return this.#M(`${e}_${i}_${s}_${r}`,t)}async getFromUrl(t){return this.#M(t,t)}async getFromBlob(t,e){let i=await e;return this.#M(t,i)}async getFromId(t){this.#k||=new Map;let e=this.#k.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){let{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#k||=new Map;let i=this.#k.get(t);if(i?.bitmap)return i.refCounter+=1,i;let s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#_}_${this.#T++}`,refCounter:1,isSvg:!1},this.#k.set(t,i),this.#k.set(i.id,i),i}getSvgUrl(t){let e=this.#k.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#k||=new Map;let e=this.#k.get(t);if(!e||(e.refCounter-=1,0!==e.refCounter))return;let{bitmap:i}=e;if(!e.url&&!e.file){let t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#_}_`)}}class tF{#P=[];#D=!1;#I;#F=-1;constructor(t=128){this.#I=t}add({cmd:t,undo:e,post:i,mustExec:s,type:r=NaN,overwriteIfSameType:n=!1,keepUndo:a=!1}){if(s&&t(),this.#D)return;let o={cmd:t,undo:e,post:i,type:r};if(-1===this.#F){this.#P.length>0&&(this.#P.length=0),this.#F=0,this.#P.push(o);return}if(n&&this.#P[this.#F].type===r){a&&(o.undo=this.#P[this.#F].undo),this.#P[this.#F]=o;return}let l=this.#F+1;l===this.#I?this.#P.splice(0,1):(this.#F=l,l<this.#P.length&&this.#P.splice(l)),this.#P.push(o)}undo(){if(-1===this.#F)return;this.#D=!0;let{undo:t,post:e}=this.#P[this.#F];t(),e?.(),this.#D=!1,this.#F-=1}redo(){if(this.#F<this.#P.length-1){this.#F+=1,this.#D=!0;let{cmd:t,post:e}=this.#P[this.#F];t(),e?.(),this.#D=!1}}hasSomethingToUndo(){return -1!==this.#F}hasSomethingToRedo(){return this.#F<this.#P.length-1}cleanType(t){if(-1!==this.#F){for(let e=this.#F;e>=0;e--)if(this.#P[e].type!==t){this.#P.splice(e+1,this.#F-e),this.#F=e;return}this.#P.length=0,this.#F=-1}}destroy(){this.#P=null}}class tB{static ALT=1;static CTRL=2;static META=4;static SHIFT=8;constructor(t){this.callbacks=new Map;const{isMac:e}=O.platform;for(const[i,s,r={}]of t){const t=i.some(t=>t.startsWith("mac+"));for(const n of i){let i=n;if(t){const t=n.startsWith("mac+");if(e!==t)continue;t&&(i=n.slice(4))}const[a,o]=tB.#B(i);null!==a&&this.callbacks.getOrInsertComputed(a,$).push({callback:s,options:r,modifiers:o})}}}static #B(t){let e=null,i=0;for(let s of t.split("+")){if(!(s=s.trim()))continue;let r=s.toUpperCase(),n=tB[r];if(n){i|=n;continue}if(null!==e){w(`KeyboardManager: multiple keys in shortcut "${t}"`);break}e="SPACE"===r?" ":s}return null===e&&w(`KeyboardManager: no key found in shortcut "${t}"`),[e,i]}static #L(t){let e=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(t);return e?e[1]?.toLowerCase()??e[2]:null}exec(t,e){let i=this.callbacks.get(e.key);if(!i){if(/^[a-z]$/i.test(e.key))return;let t=tB.#L(e.code);if(null===t||t===e.key||!(i=this.callbacks.get(t)))return}let s=(e.altKey?tB.ALT:0)|(e.ctrlKey?tB.CTRL:0)|(e.metaKey?tB.META:0)|(e.shiftKey?tB.SHIFT:0),r=i.find(t=>t.modifiers===s);if(!r)return;let{callback:n,options:{bubbles:a=!1,args:o=[],checker:l=null}}=r;(!l||l(t,e))&&(n.bind(t,...o,e)(),a||ta(e))}}class tL{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){let t=new Map([["CanvasText",null],["Canvas",null]]),e=document.createElement("span");for(let i of(e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e),t.keys())){e.style.color=i;let s=window.getComputedStyle(e).color;t.set(i,th(s))}return e.remove(),k(this,"_colors",t)}convert(t){let e=th(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(let[t,i]of this._colors)if(i.every((t,i)=>t===e[i]))return tL._colorsMapping.get(t);return e}getHexCode(t){let e=this._colors.get(t);return e?N.makeHexColor(...e):t}}class tR{#R=new AbortController;#O=null;#N=null;#U=new Map;#H=new Map;#z=null;#G=null;#$=null;#j=null;#V=new tF;#W=null;#K=null;#X=null;#q=0;#Y=new Set;#Q=null;#J=null;#Z=new Set;_editorUndoBar=null;#tt=!1;#te=!1;#ti=!1;#ts=null;#tr=null;#tn=null;#ta=null;#to=!1;#tl=null;#th=new tD;#td=!1;#tc=!1;#tu=!1;#tp=null;#tg=null;#tm=null;#tf=null;#tb=null;#ty=u.NONE;#tv=new Set;#tA=null;#tx=null;#tw=null;#tC=null;#tS=null;#tE={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#tT=[0,0];#t_=null;#tk=null;#tM=null;#tP=null;#tD=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let t=tR.prototype,e=t=>t.#tk.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>{if(e instanceof HTMLInputElement){let{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return k(this,"_keyboardManager",new tB([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:i}],[["Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tk.contains(e)&&!t.isEnterHandled}],[["Space"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#tk.contains(document.activeElement)}],[["Escape"],t.unselectAll],[["ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}constructor(t,e,i,s,r,n,a,o,l,h,d,c,u,p,g,m){const f=this._signal=this.#R.signal;this.#tk=t,this.#tM=e,this.#tP=i,this.#G=s,this.#W=r,this.#tx=n,this.#tS=o,this._eventBus=a;const b={signal:f,...tk};a.on("editingaction",this.onEditingAction.bind(this),b),a.on("pagechanging",this.onPageChanging.bind(this),b),a.on("scalechanging",this.onScaleChanging.bind(this),b),a.on("rotationchanging",this.onRotationChanging.bind(this),b),a.on("setpreference",this.onSetPreference.bind(this),b),a.on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),b),window.addEventListener("pointerdown",()=>{this.#tc=!0},{capture:!0,signal:f}),window.addEventListener("pointerup",()=>{this.#tc=!1},{capture:!0,signal:f}),window.addEventListener("beforeunload",this.#tI.bind(this),{capture:!0,signal:f}),this.#tF(),this.#tB(),this.#tL(),this.#$=o.annotationStorage,this.#ts=o.filterFactory,this.#tw=l,this.#ta=h||null,this.#tt=d,this.#te=c,this.#ti=u,this.#tb=p||null,this.viewParameters={realScale:Y.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=!1!==m,r?.setSidebarUiManager(this)}destroy(){for(let t of(this.#tD?.resolve(),this.#tD=null,this.#R?.abort(),this.#R=null,this._signal=null,this.#H.values()))t.destroy();this.#H.clear(),this.#U.clear(),this.#Z.clear(),this.#tf?.clear(),this.#O=null,this.#tv.clear(),this.#V.destroy(),this.#G?.destroy(),this.#W?.destroy(),this.#tx?.destroy(),this.#tl?.hide(),this.#tl=null,this.#tm?.destroy(),this.#tm=null,this.#N=null,this.#tr&&(clearTimeout(this.#tr),this.#tr=null),this.#t_&&(clearTimeout(this.#t_),this.#t_=null),this._editorUndoBar?.destroy(),this.#tS=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#tb}get useNewAltTextFlow(){return this.#te}get useNewAltTextWhenAddingImage(){return this.#ti}get hcmFilter(){return k(this,"hcmFilter",this.#tw?this.#ts.addHCMFilter(this.#tw.foreground,this.#tw.background):"none")}get direction(){return k(this,"direction",getComputedStyle(this.#tk).direction)}get _highlightColors(){return k(this,"_highlightColors",this.#ta?new Map(this.#ta.split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){let{_highlightColors:t}=this;if(!t)return k(this,"highlightColors",null);let e=new Map,i=!!this.#tw;for(let[s,r]of t){let t=s.endsWith("_HCM");if(i&&t){e.set(s.replace("_HCM",""),r);continue}i||t||e.set(s,r)}return k(this,"highlightColors",e)}get highlightColorNames(){return k(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;let e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#X=t}setMainHighlightColorPicker(t){this.#tm=t}editAltText(t,e=!1){this.#G?.editAltText(this,t,e)}hasCommentManager(){return!!this.#W}editComment(t,e,i,s){this.#W?.showDialog(this,t,e,i,s)}selectComment(t,e){let i=this.#H.get(t),s=i?.getEditorByUID(e);s?.toggleComment(!0,!0)}updateComment(t){this.#W?.updateComment(t.getData())}updatePopupColor(t){this.#W?.updatePopupColor(t)}removeComment(t){this.#W?.removeComments([t.uid])}deleteComment(t,e){let i=()=>{t.comment=e},s=()=>{this._editorUndoBar?.show(i,"comment"),this.toggleComment(null),t.comment=null};this.addCommands({cmd:s,undo:i,mustExec:!0})}toggleComment(t,e,i){this.#W?.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){return t&&this.#W?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#W?.dialogElement||null}async waitForEditorsRendered(t){if(this.#H.has(t-1))return;let{resolve:e,promise:i}=Promise.withResolvers(),s=i=>{i.pageNumber===t&&(this._eventBus.off("editorsrendered",s),e())};this._eventBus.on("editorsrendered",s,tk),await i}getSignature(t){this.#tx?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#tx}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal,...tk}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){"enableNewAltTextWhenAddingImage"===t&&(this.#ti=e)}onPageChanging({pageNumber:t}){this.#q=t-1}deletePage(t){for(let e of this.getEditors(t))e.remove();this.#H.delete(t),this.#q===t&&(this.#q=0)}focusMainContainer(){this.#tk.focus()}findParent(t,e){for(let i of this.#H.values()){let{x:s,y:r,width:n,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+n&&e>=r&&e<=r+a)return i}return null}disableUserSelect(t=!1){this.#tM.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#Z.add(t)}removeShouldRescale(t){this.#Z.delete(t)}onScaleChanging({scale:t}){for(let e of(this.commitOrRemove(),this.viewParameters.realScale=t*Y.PDF_TO_CSS_UNITS,this.#Z))e.onScaleChanging();this.#X?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#tR({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#tO(t){let{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(let e of this.#H.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t="",e=!1){let i=document.getSelection();if(!i||i.isCollapsed)return;let{anchorNode:s,anchorOffset:r,focusNode:n,focusOffset:a}=i,o=i.toString(),l=this.#tR(i).closest(".textLayer"),h=this.getSelectionBoxes(l);if(!h)return;i.empty();let d=this.#tO(l),c=this.#ty===u.NONE,p=()=>{let i=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:r,focusNode:n,focusOffset:a,text:o});c&&this.showAllEditors("highlight",!0,!0),e&&i?.editComment()};c?this.switchToMode(u.HIGHLIGHT,p):p()}commentSelection(t=""){this.highlightSelection(t,!0)}#tI(t){this.commitOrRemove(),this.currentLayer?.endDrawingSession(!1)}#tN(){let t=document.getSelection();if(!t||t.isCollapsed)return;let e=this.#tR(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#tl||=new t_(this),this.#tl.show(e,i,"ltr"===this.direction))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#$)return null;let e=`${c}${t}`,i=this.#$.getRawValue(e);return i&&this.#$.remove(e),i}addToAnnotationStorage(t){t.isEmpty()||!this.#$||this.#$.has(t.id)||this.#$.setValue(t.id,t)}a11yAlert(t,e=null){let i=this.#tP;i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}#tU(){let t=document.getSelection();if(!t||t.isCollapsed){this.#tA&&(this.#tl?.hide(),this.#tA=null,this.#tH({hasSelectedText:!1}));return}let{anchorNode:e}=t;if(e===this.#tA)return;let i=this.#tR(t).closest(".textLayer");if(!i){this.#tA&&(this.#tl?.hide(),this.#tA=null,this.#tH({hasSelectedText:!1}));return}if(this.#tl?.hide(),this.#tA=e,this.#tH({hasSelectedText:!0}),(this.#ty===u.HIGHLIGHT||this.#ty===u.NONE)&&(this.#ty===u.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#to=this.isShiftKeyDown,!this.isShiftKeyDown)){let t=this.#ty===u.HIGHLIGHT?this.#tO(i):null;if(t?.toggleDrawing(),this.#tc){let e=new AbortController,i=this.combinedSignal(e),s=i=>{("pointerup"!==i.type||0===i.button)&&(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#tz("main_toolbar"))};window.addEventListener("pointerup",s,{signal:i}),window.addEventListener("blur",s,{signal:i})}else t?.toggleDrawing(!0),this.#tz("main_toolbar")}}#tz(t=""){this.#ty===u.HIGHLIGHT?this.highlightSelection(t):this.#tt&&this.#tN()}#tF(){document.addEventListener("selectionchange",this.#tU.bind(this),{signal:this._signal})}#tG(){if(this.#tn)return;this.#tn=new AbortController;let t=this.combinedSignal(this.#tn);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#t$(){this.#tn?.abort(),this.#tn=null}blur(){if(this.isShiftKeyDown=!1,this.#to&&(this.#to=!1,this.#tz("main_toolbar")),!this.hasSelection)return;let{activeElement:t}=document;for(let e of this.#tv)if(e.div.contains(t)){this.#tg=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#tg)return;let[t,e]=this.#tg;this.#tg=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#tL(){if(this.#tp)return;this.#tp=new AbortController;let t=this.combinedSignal(this.#tp);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#tj(){this.#tp?.abort(),this.#tp=null}#tV(){if(this.#K)return;this.#K=new AbortController;let t=this.combinedSignal(this.#K);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})}#tW(){this.#K?.abort(),this.#K=null}#tB(){let t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#tL(),this.setEditingState(!0)}removeEditListeners(){this.#tj(),this.setEditingState(!1)}dragOver(t){for(let{type:e}of t.dataTransfer.items)for(let i of this.#J)if(i.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(let e of t.dataTransfer.items)for(let i of this.#J)if(i.isHandlingMimeForPasting(e.type)){i.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){if(t.preventDefault(),this.#O?.commitOrRemove(),!this.hasSelection)return;let e=[];for(let t of this.#tv){let i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();let{clipboardData:e}=t;for(let t of e.items)for(let e of this.#J)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){w(`paste: "${t.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();let s=this.currentLayer;try{let t=[];for(let e of i){let i=await s.deserialize(e);if(!i)return;t.push(i)}let e=()=>{for(let e of t)this.#tK(e);this.#tX(t)};this.addCommands({cmd:e,undo:()=>{for(let e of t)e.remove()},mustExec:!0})}catch(t){w(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#ty===u.NONE||this.isEditorHandlingKeyboard||tR._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#to&&(this.#to=!1,this.#tz("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")}}updatePageIndex(t,e){for(let i of this.getEditors(t))i.pageIndex=e;let i=this.#z.get(t);i&&(i.pageIndex=e,this.#H.set(e,i),this.#td?i.enable():i.disable())}startUpdatePages(){this.#z=new Map(this.#H),this.#H.clear()}endUpdatePages(){this.#z=null}clonePage(t,e){for(let i of this.getEditors(t)){let t=i.serialize(i.mode!==u.HIGHLIGHT);t&&(t.pageIndex=e,t.id=this.getId(),t.isClone=!0,delete t.popupRef,this.#$.setValue(t.id,t))}}findClonesForPage(t){let e=[],{pageIndex:i}=t;for(let[s,r]of this.#$)r.pageIndex===i&&r.isClone&&(this.#$.remove(s),e.push(t.deserialize(r).then(e=>{e&&(e.isClone=!0,t.addOrRebuild(e))})));return Promise.all(e)}#tH(t){Object.entries(t).some(([t,e])=>this.#tE[t]!==e)&&(this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(this.#tE,t)}),this.#ty===u.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#tq([[p.HIGHLIGHT_FREE,!0]]))}#tq(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#tG(),this.#tV(),this.#tH({isEditing:this.#ty!==u.NONE,isEmpty:this.#tY(),hasSomethingToUndo:this.#V.hasSomethingToUndo(),hasSomethingToRedo:this.#V.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#t$(),this.#tW(),this.#tH({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#J)for(let e of(this.#J=t,this.#J))this.#tq(e.defaultPropertiesToUpdate)}getId(){return this.#th.id}get currentLayer(){return this.#H.get(this.#q)}getLayer(t){return this.#H.get(t)}get currentPageIndex(){return this.#q}addLayer(t){this.#H.set(t.pageIndex,t),this.#td?t.enable():t.disable()}removeLayer(t){this.#H.delete(t.pageIndex)}async updateMode(t,e=null,i=!1,s=!1,r=!1,n=!1){if(this.#ty!==t&&(!this.#tD||(await this.#tD.promise,this.#tD))){if(this.#tD=Promise.withResolvers(),this.#X?.commitOrRemove(),this.#ty===u.POPUP&&this.#W?.hideSidebar(),this.#W?.destroyPopup(),this.#ty=t,t===u.NONE){for(let t of(this.setEditingState(!1),this.#tQ(),this.#U.values()))t.hideStandaloneCommentButton();this._editorUndoBar?.hide(),this.toggleComment(null),this.#tD.resolve();return}for(let t of this.#U.values())t.addStandaloneCommentButton();for(let e of(t===u.SIGNATURE&&await this.#tx?.loadSignatures(),i&&tP.clearPointerType(),this.setEditingState(!0),await this.#tJ(),this.unselectAll(),this.#H.values()))e.updateMode(t);if(t===u.POPUP){this.#N||=await this.#tS.getAnnotationsByType(new Set(this.#J.map(t=>t._editorType)));let t=new Set,e=[];for(let i of this.#U.values()){let{annotationElementId:s,hasComment:r,deleted:n}=i;s&&t.add(s),r&&!n&&e.push(i.getData())}for(let i of this.#N){let{id:s,popupRef:r,contentsObj:n}=i;r&&n?.str&&!t.has(s)&&!this.#Y.has(s)&&e.push(i)}this.#W?.showSidebar(e)}if(!e){s&&this.addNewEditorFromKeyboard(),this.#tD.resolve();return}for(let t of this.#U.values())t.uid===e?(this.setSelected(t),n?t.editComment():r?t.enterInEditMode():t.focus()):t.unselect();this.#tD.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#ty&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#J){switch(t){case p.CREATE:this.currentLayer.addNewEditor(e);return;case p.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#tC||=new Map).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(let i of this.#tv)i.updateParams(t,e);else for(let i of this.#J)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(let i of this.#U.values())i.editorType===t&&i.show(e);(this.#tC?.get(p.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#tq([[p.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tu!==t)for(let e of(this.#tu=t,this.#H.values()))t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}async #tJ(){if(!this.#td){this.#td=!0;let t=[];for(let e of this.#H.values())t.push(e.enable());for(let e of(await Promise.all(t),this.#U.values()))e.enable()}}#tQ(){if(this.unselectAll(),this.#td){for(let t of(this.#td=!1,this.#H.values()))t.disable();for(let t of this.#U.values())t.disable()}}*getEditors(t){for(let e of this.#U.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#U.get(t)}addEditor(t){this.#U.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#tr&&clearTimeout(this.#tr),this.#tr=setTimeout(()=>{this.focusMainContainer(),this.#tr=null},0)),this.#U.delete(t.id),t.annotationElementId&&this.#tf?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#Y.has(t.annotationElementId)||this.#$?.remove(t.id)}addDeletedAnnotationElement(t){this.#Y.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#Y.has(t)}removeDeletedAnnotationElement(t){this.#Y.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#tK(t){let e=this.#H.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#O!==t&&(this.#O=t,t&&this.#tq(t.propertiesToUpdate))}get #tZ(){let t=null;for(t of this.#tv);return t}updateUI(t){this.#tZ===t&&this.#tq(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#tq(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#tv.has(t)){this.#tv.delete(t),t.unselect(),this.#tH({hasSelectedEditor:this.hasSelection});return}this.#tv.add(t),t.select(),this.#tq(t.propertiesToUpdate),this.#tH({hasSelectedEditor:!0})}setSelected(t){for(let e of(this.updateToolbar({mode:t.mode,editId:t.uid}),this.#X?.commitOrRemove(),this.#tv))e!==t&&e.unselect();this.#W?.destroyPopup(),this.#tv.clear(),this.#tv.add(t),t.select(),this.#tq(t.propertiesToUpdate),this.#tH({hasSelectedEditor:!0})}get firstSelectedEditor(){return this.#tv.values().next().value}unselect(t){t.unselect(),this.#tv.delete(t),this.#tH({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#tv.size}get isEnterHandled(){return 1===this.#tv.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#V.undo(),this.#tH({hasSomethingToUndo:this.#V.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#tY()}),this._editorUndoBar?.hide()}redo(){this.#V.redo(),this.#tH({hasSomethingToUndo:!0,hasSomethingToRedo:this.#V.hasSomethingToRedo(),isEmpty:this.#tY()})}addCommands(t){this.#V.add(t),this.#tH({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#tY()})}cleanUndoStack(t){this.#V.cleanType(t)}#tY(){if(0===this.#U.size)return!0;if(1===this.#U.size)for(let t of this.#U.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();let t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;let e=t?[t]:[...this.#tv],i=()=>{for(let t of(this._editorUndoBar?.show(s,1===e.length?e[0].editorType:e.length),e))t.remove()},s=()=>{for(let t of e)this.#tK(t)};this.addCommands({cmd:i,undo:s,mustExec:!0})}commitOrRemove(){this.#O?.commitOrRemove()}hasSomethingToControl(){return this.#O||this.hasSelection}#tX(t){for(let t of this.#tv)t.unselect();for(let e of(this.#tv.clear(),t))e.isEmpty()||(this.#tv.add(e),e.select());this.#tH({hasSelectedEditor:this.hasSelection})}selectAll(){for(let t of this.#tv)t.commit();this.#tX(this.#U.values())}unselectAll(){if(!this.#O||(this.#O.commitOrRemove(),this.#ty===u.NONE)){if(!this.#X?.commitOrRemove()&&(this.#W?.destroyPopup(),this.hasSelection)){for(let t of this.#tv)t.unselect();this.#tv.clear(),this.#tH({hasSelectedEditor:!1})}}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#tT[0]+=t,this.#tT[1]+=e;let[s,r]=this.#tT,n=[...this.#tv];for(let i of(this.#t_&&clearTimeout(this.#t_),this.#t_=setTimeout(()=>{this.#t_=null,this.#tT[0]=this.#tT[1]=0,this.addCommands({cmd:()=>{for(let t of n)this.#U.has(t.id)&&(t.translateInPage(s,r),t.translationDone())},undo:()=>{for(let t of n)this.#U.has(t.id)&&(t.translateInPage(-s,-r),t.translationDone())},mustExec:!1})},1e3),n))i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection)for(let t of(this.disableUserSelect(!0),this.#Q=new Map,this.#tv))this.#Q.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#Q)return!1;this.disableUserSelect(!1);let t=this.#Q;this.#Q=null;let e=!1;for(let[{x:i,y:s,pageIndex:r},n]of t)n.newX=i,n.newY=s,n.newPageIndex=r,e||=i!==n.savedX||s!==n.savedY||r!==n.savedPageIndex;if(!e)return!1;let i=(t,e,i,s)=>{if(this.#U.has(t.id)){let r=this.#H.get(s);r?t._setParentAndPosition(r,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(let[e,{newX:s,newY:r,newPageIndex:n}]of t)i(e,s,r,n)},undo:()=>{for(let[e,{savedX:s,savedY:r,savedPageIndex:n}]of t)i(e,s,r,n)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#Q)for(let i of this.#Q.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){let e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#tv.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#O===t}getActive(){return this.#O}getMode(){return this.#ty}isEditingMode(){return this.#ty!==u.NONE}get imageManager(){return k(this,"imageManager",new tI)}getSelectionBoxes(t){let e;if(!t)return null;let i=document.getSelection();for(let e=0,s=i.rangeCount;e<s;e++)if(!t.contains(i.getRangeAt(e).commonAncestorContainer))return null;let{x:s,y:r,width:n,height:a}=t.getBoundingClientRect();switch(t.getAttribute("data-main-rotation")){case"90":e=(t,e,i,o)=>({x:(e-r)/a,y:1-(t+i-s)/n,width:o/a,height:i/n});break;case"180":e=(t,e,i,o)=>({x:1-(t+i-s)/n,y:1-(e+o-r)/a,width:i/n,height:o/a});break;case"270":e=(t,e,i,o)=>({x:1-(e+o-r)/a,y:(t-s)/n,width:o/a,height:i/n});break;default:e=(t,e,i,o)=>({x:(t-s)/n,y:(e-r)/a,width:i/n,height:o/a})}let o=[];for(let t=0,s=i.rangeCount;t<s;t++){let s=i.getRangeAt(t);if(!s.collapsed)for(let{x:t,y:i,width:r,height:n}of s.getClientRects())0!==r&&0!==n&&o.push(e(t,i,r,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#j||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#j?.delete(t)}renderAnnotationElement(t){let e=this.#j?.get(t.data.id);if(!e)return;let i=this.#$.getRawValue(e);!i||(this.#ty!==u.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){let s=this.#tf?.get(t);s&&(s.setCanvas(e,i),this.#tf.delete(t))}addMissingCanvas(t,e){(this.#tf||=new Map).set(t,e)}}class tO{#l=null;#t0=!1;#t1=null;#t2=null;#t3=null;#t5=null;#t6=!1;#t4=null;#a=null;#t8=null;#t7=null;#t9=!1;static #et=null;static _l10n=null;constructor(t){this.#a=t,this.#t9=t._uiManager.useNewAltTextFlow,tO.#et||=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){tO._l10n??=t}async render(){let t=this.#t1=document.createElement("button");t.className="altText",t.tabIndex="0";let e=this.#t2=document.createElement("span");t.append(e),this.#t9?(t.classList.add("new"),t.setAttribute("data-l10n-id",tO.#et.missing),e.setAttribute("data-l10n-id",tO.#et["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));let i=this.#a._uiManager._signal;t.addEventListener("contextmenu",tn,{signal:i}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=t=>{t.preventDefault(),this.#a._uiManager.editAltText(this.#a),this.#t9&&this.#a._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#ee}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#t6=!0,s(e))},{signal:i}),await this.#ei(),t}get #ee(){return this.#l&&"added"||null===this.#l&&this.guessedText&&"review"||"missing"}finish(){this.#t1&&(this.#t1.focus({focusVisible:this.#t6}),this.#t6=!1)}isEmpty(){return this.#t9?null===this.#l:!this.#l&&!this.#t0}hasData(){return this.#t9?null!==this.#l||!!this.#t8:this.isEmpty()}get guessedText(){return this.#t8}async setGuessedText(t){null===this.#l&&(this.#t8=t,this.#t7=await tO._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#ei())}toggleAltTextBadge(t=!1){if(!this.#t9||this.#l){this.#t4?.remove(),this.#t4=null;return}if(!this.#t4){let t=this.#t4=document.createElement("div");t.className="noAltTextBadge",this.#a.div.append(t)}this.#t4.classList.toggle("hidden",!t)}serialize(t){let e=this.#l;return t||this.#t8!==e||(e=this.#t7),{altText:e,decorative:this.#t0,guessedText:this.#t8,textWithDisclaimer:this.#t7}}get data(){return{altText:this.#l,decorative:this.#t0}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:r=!1}){i&&(this.#t8=i,this.#t7=s),(this.#l!==t||this.#t0!==e)&&(r||(this.#l=t,this.#t0=e),this.#ei())}toggle(t=!1){this.#t1&&(!t&&this.#t5&&(clearTimeout(this.#t5),this.#t5=null),this.#t1.disabled=!t)}shown(){this.#a._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#ee}})}destroy(){this.#t1?.remove(),this.#t1=null,this.#t2=null,this.#t3=null,this.#t4?.remove(),this.#t4=null}async #ei(){let t=this.#t1;if(!t)return;if(this.#t9){if(t.classList.toggle("done",!!this.#l),t.setAttribute("data-l10n-id",tO.#et[this.#ee]),this.#t2?.setAttribute("data-l10n-id",tO.#et[`${this.#ee}-label`]),!this.#l)return void this.#t3?.remove()}else{if(!this.#l&&!this.#t0){t.classList.remove("done"),this.#t3?.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#t3;if(!e){this.#t3=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#a.id}`;let i=this.#a._uiManager._signal;i.addEventListener("abort",()=>{clearTimeout(this.#t5),this.#t5=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#t5=setTimeout(()=>{this.#t5=null,this.#t3.classList.add("show"),this.#a._reportTelemetry({action:"alt_text_tooltip"})},100)},{signal:i}),t.addEventListener("mouseleave",()=>{this.#t5&&(clearTimeout(this.#t5),this.#t5=null),this.#t3?.classList.remove("show")},{signal:i})}this.#t0?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#l),e.parentNode||t.append(e);let i=this.#a.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}class tN{#es=null;#er=null;#en=!1;#a=null;#ea=null;#eo=null;#el=null;#eh=null;#ed=!1;#ec=null;constructor(t){this.#a=t}renderForToolbar(){let t=this.#er=document.createElement("button");return t.className="comment",this.#v(t,!1)}renderForStandalone(){let t=this.#es=document.createElement("button");t.className="annotationCommentButton";let e=this.#a.commentButtonPosition;if(e){let{style:i}=t;i.insetInlineEnd=`calc(${100*("ltr"===this.#a._uiManager.direction?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;let s=this.#a.commentButtonColor;s&&(i.backgroundColor=s)}return this.#v(t,!0)}focusButton(){setTimeout(()=>{(this.#es??this.#er)?.focus()},0)}onUpdatedColor(){if(!this.#es)return;let t=this.#a.commentButtonColor;t&&(this.#es.style.backgroundColor=t),this.#a._uiManager.updatePopupColor(this.#a)}get commentButtonWidth(){return(this.#es?.getBoundingClientRect().width??0)/this.#a.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#ec)return this.#ec;if(!this.#es)return null;let{x:t,y:e,height:i}=this.#es.getBoundingClientRect(),{x:s,y:r,width:n,height:a}=this.#a.parent.boundingClientRect;return[(t-s)/n,(e+i-r)/a]}set commentPopupPositionInLayer(t){this.#ec=t}hasDefaultPopupPosition(){return null===this.#ec}removeStandaloneCommentButton(){this.#es?.remove(),this.#es=null}removeToolbarCommentButton(){this.#er?.remove(),this.#er=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#es&&(this.#es.classList.toggle("selected",t),this.#es.ariaExpanded=e)}#v(t,e){if(!this.#a._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.#a._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));let i=this.#a._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",tn,{signal:i}),e&&(t.addEventListener("focusin",t=>{this.#a._focusEventsAllowed=!1,ta(t)},{capture:!0,signal:i}),t.addEventListener("focusout",t=>{this.#a._focusEventsAllowed=!0,ta(t)},{capture:!0,signal:i})),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});let s=e=>{e.preventDefault(),t===this.#er?this.edit():this.#a.toggleComment(!0)};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#en=!0,s(e))},{signal:i}),t.addEventListener("pointerenter",()=>{this.#a.toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{this.#a.toggleComment(!1,!1)},{signal:i}),t}edit(t){let e,i,s=this.commentPopupPositionInLayer;if(s)[e,i]=s;else{[e,i]=this.#a.commentButtonPosition;let{width:t,height:s,x:r,y:n}=this.#a;e=r+e*t,i=n+i*s}let r=this.#a.parent.boundingClientRect,{x:n,y:a,width:o,height:l}=r;this.#a._uiManager.editComment(this.#a,n+e*o,a+i*l,{...t,parentDimensions:r})}finish(){this.#er&&(this.#er.focus({focusVisible:this.#en}),this.#en=!1)}isDeleted(){return this.#ed||""===this.#el}isEmpty(){return null===this.#el}hasBeenEdited(){return this.isDeleted()||this.#el!==this.#ea}serialize(){return this.data}get data(){return{text:this.#el,richText:this.#eo,date:this.#eh,deleted:this.isDeleted()}}set data(t){if(t!==this.#el&&(this.#eo=null),null===t){this.#el="",this.#ed=!0;return}this.#el=t,this.#eh=new Date,this.#ed=!1}restoreData({text:t,richText:e,date:i}){this.#el=t,this.#eo=e,this.#eh=i,this.#ed=!1}setInitialText(t,e=null){this.#ea=t,this.data=t,this.#eh=null,this.#eo=e}shown(){}destroy(){this.#er?.remove(),this.#er=null,this.#es?.remove(),this.#es=null,this.#el="",this.#eo=null,this.#eh=null,this.#a=null,this.#en=!1,this.#ed=!1}}class tU{#tk;#eu=!1;#ep=null;#eg;#em;#ef;#eb;#ey=null;#ev;#eA=null;#ex;#ew=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:r=null,onPinchEnd:n=null,signal:a}){this.#tk=t,this.#ep=i,this.#eg=e,this.#em=s,this.#ef=r,this.#eb=n,this.#ex=new AbortController,this.#ev=AbortSignal.any([a,this.#ex.signal]),t.addEventListener("touchstart",this.#eC.bind(this),{passive:!1,signal:this.#ev})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/tp.pixelRatio}#eC(t){if(this.#eg?.())return;if(1===t.touches.length){if(this.#ey)return;let t=this.#ey=new AbortController,e=AbortSignal.any([this.#ev,t.signal]),i=this.#tk,s={capture:!0,signal:e,passive:!1},r=t=>{"touch"===t.pointerType&&(this.#ey?.abort(),this.#ey=null)};i.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(ta(t),r(t))},s),i.addEventListener("pointerup",r,s),i.addEventListener("pointercancel",r,s);return}if(!this.#ew){this.#ew=new AbortController;let t=AbortSignal.any([this.#ev,this.#ew.signal]),e=this.#tk,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#eS.bind(this),i);let s=this.#eE.bind(this);e.addEventListener("touchend",s,i),e.addEventListener("touchcancel",s,i),i.capture=!0,e.addEventListener("pointerdown",ta,i),e.addEventListener("pointermove",ta,i),e.addEventListener("pointercancel",ta,i),e.addEventListener("pointerup",ta,i),this.#em?.()}if(ta(t),2!==t.touches.length||this.#ep?.()){this.#eA=null;return}let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#eA={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#eS(t){if(!this.#eA||2!==t.touches.length)return;ta(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);let{screenX:s,screenY:r}=e,{screenX:n,screenY:a}=i,o=this.#eA,{touch0X:l,touch0Y:h,touch1X:d,touch1Y:c}=o,u=Math.hypot(n-s,a-r)||1,p=Math.hypot(d-l,c-h)||1;if(!this.#eu&&Math.abs(p-u)<=tU.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(o.touch0X=s,o.touch0Y=r,o.touch1X=n,o.touch1Y=a,!this.#eu){this.#eu=!0;return}let g=[(s+n)/2,(r+a)/2];this.#ef?.(g,p,u)}#eE(t){t.touches.length>=2||(this.#ew&&(this.#ew.abort(),this.#ew=null,this.#eb?.()),this.#eA&&(ta(t),this.#eA=null,this.#eu=!1))}destroy(){this.#ex?.abort(),this.#ex=null,this.#ey?.abort(),this.#ey=null}}class tH{#eT=null;#e_=null;#l=null;#h=null;#es=null;#ek=!1;#eM=null;#eP="";#eD=null;#eI=null;#eF=null;#eB=null;#eL=null;#eR="";#eO=!1;#eN=null;#eU=!1;#eH=!1;#ez=!1;#eG=null;#e$=0;#ej=0;#eV=null;#eW=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;#eK=!1;#eX=tH._zIndex++;static _borderLineWidth=-1;static _colorManager=new tL;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let t=tH.prototype._resizeWithKeyboard,e=tR.TRANSLATE_SMALL,i=tR.TRANSLATE_BIG;return k(this,"_resizerKeyboardManager",new tB([[["ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape"],tH.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:r,pageY:n}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],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 k(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){let e=new tz({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(tH._l10n??=t,tH._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"}),tH._l10nResizer??=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==tH._borderLineWidth)return;let i=getComputedStyle(document.documentElement);tH._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){C("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#eK}set _isDraggable(t){this.#eK=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){let[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#eX}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#eq(),this.#eB?.remove(),this.#eB=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#eO?this.#eO=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;let e=t.relatedTarget;!e?.closest(`#${this.id}`)&&(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){let[r,n]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/r,this.y=(e+s)/n,this.fixAndSetPosition()}_moveAfterPaste(t,e){if(this.isClone)return void delete this.isClone;let[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s),this._onTranslated()}#eY([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#eY(this.parentDimensions,t,e)}translateInPage(t,e){this.#eN||=[this.x,this.y,this.width,this.height],this.#eY(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#eN||=[this.x,this.y,this.width,this.height];let{div:i,parentDimensions:[s,r]}=this;if(this.x+=t/s,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:a}=this,[o,l]=this.getBaseTranslation();n+=o,a+=l;let{style:h}=i;h.left=`${(100*n).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(n,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#eN&&(this.#eN[0]!==this.x||this.#eN[1]!==this.y)}get _hasBeenResized(){return!!this.#eN&&(this.#eN[2]!==this.width||this.#eN[3]!==this.height)}getBaseTranslation(){let[t,e]=this.parentDimensions,{_borderLineWidth:i}=tH,s=i/t,r=i/e;switch(this.rotation){case 90:return[-s,r];case 180:return[s,r];case 270:return[s,-r];default:return[-s,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){let{div:{style:e},pageDimensions:[i,s]}=this,{x:r,y:n,width:a,height:o}=this;if(a*=i,o*=s,r*=i,n*=s,this._mustFixPosition)switch(t){case 0:r=W(r,0,i-a),n=W(n,0,s-o);break;case 90:r=W(r,0,i-o),n=W(n,a,s);break;case 180:r=W(r,a,i),n=W(n,o,s);break;case 270:r=W(r,o,i),n=W(n,0,s-a)}this.x=r/=i,this.y=n/=s;let[l,h]=this.getBaseTranslation();r+=l,n+=h,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static #eQ(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return tH.#eQ(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return tH.#eQ(t,e,360-this.parentRotation)}#eJ(t){switch(t){case 90:{let[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{let[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){let{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(){let{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#eZ(){if(this.#eD)return;this.#eD=document.createElement("div"),this.#eD.classList.add("resizers");let t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(let i of t){let t=document.createElement("div");this.#eD.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#e0.bind(this,i),{signal:e}),t.addEventListener("contextmenu",tn,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#eD)}#e0(t,e){e.preventDefault();let{isMac:i}=O.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#l?.toggle(!1);let s=this._isDraggable;this._isDraggable=!1,this.#eI=[e.screenX,e.screenY];let r=new AbortController,n=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#e1.bind(this,t),{passive:!0,capture:!0,signal:n}),window.addEventListener("touchmove",ta,{passive:!1,signal:n}),window.addEventListener("contextmenu",tn,{signal:n}),this.#eF={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;let l=()=>{r.abort(),this.parent.togglePointerEvents(!0),this.#l?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#e2()};window.addEventListener("pointerup",l,{signal:n}),window.addEventListener("blur",l,{signal:n})}#e3(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#e2(){if(!this.#eF)return;let{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#eF;this.#eF=null;let r=this.x,n=this.y,a=this.width,o=this.height;(r!==t||n!==e||a!==i||o!==s)&&this.addCommands({cmd:this.#e3.bind(this,r,n,a,o),undo:this.#e3.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#e1(t,e){let i,s,r,n,a,o,[l,h]=this.parentDimensions,d=this.x,c=this.y,u=this.width,p=this.height,g=tH.MIN_SIZE/l,m=tH.MIN_SIZE/h,f=this.#eJ(this.rotation),b=(t,e)=>[f[0]*t+f[2]*e,f[1]*t+f[3]*e],y=this.#eJ(360-this.rotation),v=!1,A=!1;switch(t){case"topLeft":v=!0,i=(t,e)=>[0,0],s=(t,e)=>[t,e];break;case"topMiddle":i=(t,e)=>[t/2,0],s=(t,e)=>[t/2,e];break;case"topRight":v=!0,i=(t,e)=>[t,0],s=(t,e)=>[0,e];break;case"middleRight":A=!0,i=(t,e)=>[t,e/2],s=(t,e)=>[0,e/2];break;case"bottomRight":v=!0,i=(t,e)=>[t,e],s=(t,e)=>[0,0];break;case"bottomMiddle":i=(t,e)=>[t/2,e],s=(t,e)=>[t/2,0];break;case"bottomLeft":v=!0,i=(t,e)=>[0,e],s=(t,e)=>[t,0];break;case"middleLeft":A=!0,i=(t,e)=>[0,e/2],s=(t,e)=>[t,e/2]}let x=i(u,p),w=s(u,p),C=b(...w),S=tH._round(d+C[0]),E=tH._round(c+C[1]),T=1,_=1;if(e.fromKeyboard)({deltaX:r,deltaY:n}=e);else{let{screenX:t,screenY:i}=e,[s,a]=this.#eI;[r,n]=this.screenToPageTranslation(t-s,i-a),this.#eI[0]=t,this.#eI[1]=i}if([r,n]=(a=r/l,o=n/h,[y[0]*a+y[2]*o,y[1]*a+y[3]*o]),v){let t=Math.hypot(u,p);T=_=Math.max(Math.min(Math.hypot(w[0]-x[0]-r,w[1]-x[1]-n)/t,1/u,1/p),g/u,m/p)}else A?T=W(Math.abs(w[0]-x[0]-r),g,1)/u:_=W(Math.abs(w[1]-x[1]-n),m,1)/p;let k=tH._round(u*T),M=tH._round(p*_),P=S-(C=b(...s(k,M)))[0],D=E-C[1];this.#eN||=[this.x,this.y,this.width,this.height],this.width=k,this.height=M,this.x=P,this.y=D,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#l?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#eH)return this._editToolbar;this._editToolbar=new tT(this),this.div.append(this._editToolbar.render());let{toolbarButtons:t}=this;if(t)for(let[e,i]of t)await this._editToolbar.addButton(e,i);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove(),this._editToolbar=null,this.#l?.destroy()}addContainer(t){let e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return!this.#l&&(tO.initialize(tH._l10n),this.#l=new tO(this),this.#eT&&(this.#l.data=this.#eT,this.#eT=null)),this.#l}get altTextData(){return this.#l?.data}set altTextData(t){this.#l&&(this.#l.data=t)}get guessedAltText(){return this.#l?.guessedText}async setGuessedAltText(t){await this.#l?.setGuessedText(t)}serializeAltText(t){return this.#l?.serialize(t)}hasAltText(){return!!this.#l&&!this.#l.isEmpty()}hasAltTextData(){return this.#l?.hasData()??!1}focusCommentButton(){this.#h?.focusButton()}addCommentButton(){return this.canAddComment?this.#h||=new tN(this):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(this.#es){this._uiManager.isEditingMode()&&this.#es.classList.remove("hidden");return}this.hasComment&&(this.#es=this.#h.renderForStandalone(),this.div.append(this.#es))}}removeStandaloneCommentButton(){this.#h.removeStandaloneCommentButton(),this.#es=null}hideStandaloneCommentButton(){this.#es?.classList.add("hidden")}get comment(){if(!this.#h)return null;let{data:{richText:t,text:e,date:i,deleted:s}}=this.#h;return{text:e,richText:t,date:i,deleted:s,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#h||=new tN(this),"object"==typeof t&&null!==t?this.#h.restoreData(t):this.#h.data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:i}){if(!e||(this.#h||=new tN(this),this.#h.setInitialText(t,i),!this.annotationElementId))return;let s=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);s&&this.updateFromAnnotationLayer(s)}get hasEditedComment(){return this.#h?.hasBeenEdited()}get hasDeletedComment(){return this.#h?.isDeleted()}get hasComment(){return!!this.#h&&!this.#h.isEmpty()&&!this.#h.isDeleted()}async editComment(t){this.#h||=new tN(this),this.#h.edit(t)}toggleComment(t,e){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#h.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){let[,,,e]=t.rect,[i]=this.pageDimensions,[s]=this.pageTranslation,r=s+i+1;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[r,e-100,r+180,e]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#h.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){let t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#ek?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#e5();let[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);let[s,r]=this.getInitialTranslation();return this.translate(s,r),tM(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#eW||=new tU({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#e6.bind(this),onPinching:this.#e4.bind(this),onPinchEnd:this.#e8.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#e6(){this.#eF={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#l?.toggle(!1),this.parent.togglePointerEvents(!1)}#e4(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;let r=this.#eJ(this.rotation),n=(t,e)=>[r[0]*t+r[2]*e,r[1]*t+r[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height;s=Math.max(Math.min(s,1/d,1/c),tH.MIN_SIZE/a/d,tH.MIN_SIZE/o/c);let u=tH._round(d*s),p=tH._round(c*s);if(u===d&&p===c)return;this.#eN||=[l,h,d,c];let g=n(d/2,c/2),m=tH._round(l+g[0]),f=tH._round(h+g[1]),b=n(u/2,p/2);this.x=m-b[0],this.y=f-b[1],this.width=u,this.height=p,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#e8(){this.#l?.toggle(!0),this.parent.togglePointerEvents(!0),this.#e2()}pointerdown(t){let{isMac:e}=O.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#eO=!0,this._isDraggable)?this.#e7(t):this.#e9(t)}#e9(t){let{isMac:e}=O.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#e7(t){let{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1,s=new AbortController,r=this._uiManager.combinedSignal(s),n={capture:!0,passive:!1,signal:r},a=t=>{s.abort(),this.#eM=null,this.#eO=!1,this._uiManager.endDragSession()||this.#e9(t),i&&this._onStopDragging()};e&&(this.#e$=t.clientX,this.#ej=t.clientY,this.#eM=t.pointerId,this.#eP=t.pointerType,window.addEventListener("pointermove",t=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());let{clientX:e,clientY:s,pointerId:r}=t;if(r!==this.#eM)return void ta(t);let[n,a]=this.screenToPageTranslation(e-this.#e$,s-this.#ej);this.#e$=e,this.#ej=s,this._uiManager.dragSelectedEditors(n,a)},n),window.addEventListener("touchmove",ta,n),window.addEventListener("pointerdown",t=>{t.pointerType===this.#eP&&(this.#eW||t.isPrimary)&&a(t),ta(t)},n));let o=t=>{this.#eM&&this.#eM!==t.pointerId?ta(t):a(t)};window.addEventListener("pointerup",o,{signal:r}),window.addEventListener("blur",o,{signal:r})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#eG&&clearTimeout(this.#eG),this.#eG=setTimeout(()=>{this.#eG=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){let s=this.parentScale,[r,n]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*r,c=this.y*n,u=this.width*r,p=this.height*n;switch(i){case 0:return[d+l+a,n-c-h-p+o,d+l+u+a,n-c-h+o];case 90:return[d+h+a,n-c+l+o,d+h+p+a,n-c+l+u+o];case 180:return[d-l-u+a,n-c+h+o,d-l+a,n-c+h+p+o];case 270:return[d-h-p+a,n-c-l-u+o,d-h+a,n-c-l+o];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(t,e){let[i,s,r,n]=t,a=r-i,o=n-s;switch(this.rotation){case 0:return[i,e-n,a,o];case 90:return[i,e-s,o,a];case 180:return[r,e-s,a,o];case 270:return[r,e-n,o,a];default:throw Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&tH._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#h?.onUpdatedColor()}getData(){let{comment:{text:t,color:e,date:i,opacity:s,deleted:r,richText:n},uid:a,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:n,contentsObj:{str:t},creationDate:l,modificationDate:i||h,popupRef:!r,color:e,opacity:s}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#eH=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#eH=!1,!0)}isInEditMode(){return this.#eH}shouldGetKeyboardEvents(){return this.#ez}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){let{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:r,innerWidth:n}=window;return e<n&&s>0&&t<r&&i>0}#e5(){if(this.#eL||!this.div)return;this.#eL=new AbortController;let t=this._uiManager.combinedSignal(this.#eL);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#e5()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,i){let s=new this.prototype.constructor({parent:e,id:i.getId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});s.rotation=t.rotation,s.#eT=t.accessibilityData,s._isCopy=t.isCopy||!1;let[r,n]=s.pageDimensions,[a,o,l,h]=s.getRectInCurrentCoords(t.rect,n);return s.x=a/r,s.y=o/n,s.width=l/r,s.height=h/n,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#eL?.abort(),this.#eL=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#eG&&(clearTimeout(this.#eG),this.#eG=null),this.#eq(),this.removeEditToolbar(),this.#eV){for(let t of this.#eV.values())clearTimeout(t);this.#eV=null}this.parent=null,this.#eW?.destroy(),this.#eW=null,this.#eB?.remove(),this.#eB=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#eZ(),this.#eD.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){let{commentButtonPosition:[t,e]}=this,[i,s,r,n]=this.getPDFRect();return[tH._round(i+(r-i)*t),tH._round(s+(n-s)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#h.commentPopupPositionInLayer}set commentPopupPosition(t){this.#h.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#h.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#h.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#h?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#eF={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let e=this.#eD.children;if(!this.#e_){this.#e_=Array.from(e);let t=this.#it.bind(this),i=this.#ie.bind(this),s=this._uiManager._signal;for(let e of this.#e_){let r=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#ii.bind(this,r),{signal:s}),e.setAttribute("data-l10n-id",tH._l10nResizer[r])}}let i=this.#e_[0],s=0;for(let t of e){if(t===i)break;s++}let r=(360-this.rotation+this.parentRotation)%360/90*(this.#e_.length/4);if(r!==s){if(r<s)for(let t=0;t<s-r;t++)this.#eD.append(this.#eD.firstElementChild);else if(r>s)for(let t=0;t<r-s;t++)this.#eD.firstElementChild.before(this.#eD.lastElementChild);let t=0;for(let i of e){let e=this.#e_[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",tH._l10nResizer[e])}}this.#is(0),this.#ez=!0,this.#eD.firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#it(t){tH._resizerKeyboardManager.exec(this,t)}#ie(t){this.#ez&&t.relatedTarget?.parentNode!==this.#eD&&this.#eq()}#ii(t){this.#eR=this.#ez?t:""}#is(t){if(this.#e_)for(let e of this.#e_)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#ez&&this.#e1(this.#eR,{deltaX:t,deltaY:e,fromKeyboard:!0})}#eq(){this.#ez=!1,this.#is(-1),this.#e2()}_stopResizingWithKeyboard(){this.#eq(),this.div.focus()}select(){this.isSelected&&this._editToolbar?this._editToolbar.show():(this.isSelected=!0,this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar)?(this._editToolbar?.show(),this.#l?.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#eD?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#l?.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#eU}set isEditing(t){this.#eU=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.#eV||=new Map;let{action:e}=t,i=this.#eV.get(e);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#eV.delete(e),0===this.#eV.size&&(this.#eV=null)},tH._telemetryTimeout),this.#eV.set(e,i);return}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#ek=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#ek=!0}updateFakeAnnotationElement(t){if(!this.#eB&&!this.deleted){this.#eB=t.addFakeAnnotation(this);return}if(this.deleted){this.#eB.remove(),this.#eB=null;return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#eB.updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){let t=e;(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.before(e)}}else(e=document.createElement("div")).classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){let{firstElementChild:e}=t.container;e?.nodeName==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}}class tz extends tH{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}class tG{constructor(t){this.h1=t?0|t:0xc3d2e1f0,this.h2=t?0|t:0xc3d2e1f0}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,r=t.length;s<r;s++){let r=t.charCodeAt(s);r<=255?e[i++]=r:(e[i++]=r>>>8,e[i++]=255&r)}}else if(ArrayBuffer.isView(t))i=(e=t.slice()).byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let s=i>>2,r=i-4*s,n=new Uint32Array(e.buffer,0,s),a=0,o=0,l=this.h1,h=this.h2;for(let t=0;t<s;t++)1&t?(l^=a=0x1b873593*(a=(a=0xcc9e2d51*(a=n[t])&0xffff0000|11601*a&65535)<<15|a>>>17)&0xffff0000|13715*a&65535,l=5*(l=l<<13|l>>>19)+0xe6546b64):(h^=o=0x1b873593*(o=(o=0xcc9e2d51*(o=n[t])&0xffff0000|11601*o&65535)<<15|o>>>17)&0xffff0000|13715*o&65535,h=5*(h=h<<13|h>>>19)+0xe6546b64);switch(a=0,r){case 3:a^=e[4*s+2]<<16;case 2:a^=e[4*s+1]<<8;case 1:a^=e[4*s],a=0x1b873593*(a=(a=0xcc9e2d51*a&0xffff0000|11601*a&65535)<<15|a>>>17)&0xffff0000|13715*a&65535,1&s?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,e=0xff51afd7*e&0xffff0000|((e<<16|(t=0xed558ccd*t&0xffff0000|36045*t&65535)>>>16)*0xafd7ed55&0xffff0000)>>>16,t^=e>>>1,e=0xc4ceb9fe*e&0xffff0000|((e<<16|(t=0x1a85ec53*t&0xffff0000|60499*t&65535)>>>16)*0xb9fe1a85&0xffff0000)>>>16,((t^=e>>>1)>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}let t$=Object.freeze({map:null,hash:"",transfer:void 0});class tj{#ir=!1;#ia=null;#io=null;#il=new Map;onSetModified=null;onResetModified=null;onAnnotationEditor=null;getValue(t,e){let i=this.#il.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#il.get(t)}remove(t){let e=this.#il.get(t);void 0===e||(e instanceof tH&&this.#io.delete(e.annotationElementId),this.#il.delete(t),0===this.#il.size&&this.resetModified(),this.#il.values().some(t=>t instanceof tH)||this.onAnnotationEditor?.(null))}setValue(t,e){let i=this.#il.get(t),s=!1;if(void 0!==i)for(let[t,r]of Object.entries(e))i[t]!==r&&(s=!0,i[t]=r);else s=!0,this.#il.set(t,e);s&&this.#ih(),e instanceof tH&&((this.#io||=new Map).set(e.annotationElementId,e),this.onAnnotationEditor?.(e.constructor._type))}has(t){return this.#il.has(t)}get size(){return this.#il.size}#ih(){this.#ir||(this.#ir=!0,this.onSetModified?.())}resetModified(){this.#ir&&(this.#ir=!1,this.onResetModified?.())}get print(){return new tV(this)}get serializable(){if(0===this.#il.size)return t$;let t=new Map,e=new tG,i=[],s=Object.create(null),r=!1;for(let[i,n]of this.#il){let a=n instanceof tH?n.serialize(!1,s):n;n.page&&(n.pageIndex=n.page._pageIndex,delete n.page),a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),r||=!!a.bitmap)}if(r)for(let e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:t$}get editorStats(){let t=null,e=new Map,i=0,s=0;for(let r of this.#il.values()){if(!(r instanceof tH)){r.popup&&(r.popup.deleted?s+=1:i+=1);continue}r.isCommentDeleted?s+=1:r.hasEditedComment&&(i+=1);let n=r.telemetryFinalData;if(!n)continue;let{type:a}=n;e.getOrInsertComputed(a,()=>Object.getPrototypeOf(r).constructor),t||=Object.create(null);let o=t[a]||=new Map;for(let[t,e]of Object.entries(n)){if("type"===t)continue;let i=o.getOrInsertComputed(t,j);i.set(e,(i.get(e)??0)+1)}}if((s>0||i>0)&&((t||=Object.create(null)).comments={deleted:s,edited:i}),!t)return null;for(let[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#ia=null}updateEditor(t,e){let i=this.#io?.get(t);return!!i&&(i.updateFromAnnotationLayer(e),!0)}getEditor(t){return this.#io?.get(t)||null}get modifiedIds(){if(this.#ia)return this.#ia;let t=[];if(this.#io)for(let e of this.#io.values())e.serialize()&&t.push(e.annotationElementId);let e="";if(t.length){let i=new tG;i.update(t.join(",")),e=i.hexdigest()}return this.#ia={ids:new Set(t),hash:e}}[Symbol.iterator](){return this.#il.entries()}}class tV extends tj{#id=t$;constructor(t){super();const{serializable:e}=t;if(e===t$)return;const{map:i,hash:s,transfer:r}=e,n=structuredClone(i,r?{transfer:r}:null);this.#id={map:n,hash:s,transfer:[]}}get print(){C("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#id}get modifiedIds(){return k(this,"modifiedIds",{ids:new Set,hash:""})}}let tW="__forcedDependency",{floor:tK,ceil:tX}=Math;function tq(t,e,i,s,r,n){t[4*e+0]=Math.min(t[4*e+0],i),t[4*e+1]=Math.min(t[4*e+1],s),t[4*e+2]=Math.max(t[4*e+2],r),t[4*e+3]=Math.max(t[4*e+3],n)}let tY=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class tQ{#ic;#iu;constructor(t,e){this.#ic=t,this.#iu=e}get length(){return this.#ic.length}isEmpty(t){return this.#ic[t]===tY}minX(t){return this.#iu[4*t+0]/256}minY(t){return this.#iu[4*t+1]/256}maxX(t){return(this.#iu[4*t+2]+1)/256}maxY(t){return(this.#iu[4*t+3]+1)/256}}let tJ=(t,e)=>t?.getOrInsertComputed(e,()=>({dependencies:new Set,isRenderingOperation:!1}));class tZ{#ip=[[1,0,0,1,0,0]];#ig=[-1/0,-1/0,1/0,1/0];#im=new Float64Array(n);_pendingBBoxIdx=-1;#ib;#iy;#iv;#ic;_savesStack=[];_markedContentStack=[];constructor(t,e){this.#ib=t.width,this.#iy=t.height,this.#iA(e)}growOperationsCount(t){t>=this.#ic.length&&this.#iA(t,this.#ic)}#iA(t,e){let i=new ArrayBuffer(4*t);this.#iv=new Uint8ClampedArray(i),this.#ic=new Uint32Array(i),e&&e.length>0?(this.#ic.set(e),this.#ic.fill(tY,e.length)):this.#ic.fill(tY)}get clipBox(){return this.#ig}save(t){return this.#ig={__proto__:this.#ig},this._savesStack.push(t),this}restore(t,e){let i=Object.getPrototypeOf(this.#ig);if(null===i)return this;this.#ig=i;let s=this._savesStack.pop();return void 0!==s&&(e?.(s,t),this.#ic[t]=this.#ic[s]),this}recordOpenMarker(t){return this._savesStack.push(t),this}getOpenMarker(){return 0===this._savesStack.length?null:this._savesStack.at(-1)}recordCloseMarker(t,e){let i=this._savesStack.pop();return void 0!==i&&(e?.(i,t),this.#ic[t]=this.#ic[i]),this}beginMarkedContent(t){return this._markedContentStack.push(t),this}endMarkedContent(t,e){let i=this._markedContentStack.pop();return void 0!==i&&(e?.(i,t),this.#ic[t]=this.#ic[i]),this}pushBaseTransform(t){return this.#ip.push(N.multiplyByDOMMatrix(this.#ip.at(-1),t.getTransform())),this}popBaseTransform(){return this.#ip.length>1&&this.#ip.pop(),this}resetBBox(t){return this._pendingBBoxIdx!==t&&(this._pendingBBoxIdx=t,this.#im.set(n,0)),this}recordClipBox(t,e,i,s,r,a){let o=N.multiplyByDOMMatrix(this.#ip.at(-1),e.getTransform()),l=n.slice();N.axialAlignedBoundingBox([i,r,s,a],o,l);let h=N.intersect(this.#ig,l);return h?(this.#ig[0]=h[0],this.#ig[1]=h[1],this.#ig[2]=h[2],this.#ig[3]=h[3]):(this.#ig[0]=this.#ig[1]=1/0,this.#ig[2]=this.#ig[3]=-1/0),this}recordBBox(t,e,i,s,r,a){let o=this.#ig;if(o[0]===1/0)return this;let l=N.multiplyByDOMMatrix(this.#ip.at(-1),e.getTransform());if(o[0]===-1/0)return N.axialAlignedBoundingBox([i,r,s,a],l,this.#im),this;let h=n.slice();return N.axialAlignedBoundingBox([i,r,s,a],l,h),this.#im[0]=W(h[0],o[0],this.#im[0]),this.#im[1]=W(h[1],o[1],this.#im[1]),this.#im[2]=W(h[2],this.#im[2],o[2]),this.#im[3]=W(h[3],this.#im[3],o[3]),this}recordFullPageBBox(t){return this.#im[0]=Math.max(0,this.#ig[0]),this.#im[1]=Math.max(0,this.#ig[1]),this.#im[2]=Math.min(this.#ib,this.#ig[2]),this.#im[3]=Math.min(this.#iy,this.#ig[3]),this}recordOperation(t,e=!1,i){if(this._pendingBBoxIdx!==t)return this;let s=tK(256*this.#im[0]/this.#ib),r=tK(256*this.#im[1]/this.#iy),n=tX(256*this.#im[2]/this.#ib),a=tX(256*this.#im[3]/this.#iy);if(tq(this.#iv,t,s,r,n,a),i)for(let e of i)for(let i of e)i!==t&&tq(this.#iv,i,s,r,n,a);return e||(this._pendingBBoxIdx=-1),this}bboxToClipBoxDropOperation(t){return this._pendingBBoxIdx===t&&(this._pendingBBoxIdx=-1,this.#ig[0]=Math.max(this.#ig[0],this.#im[0]),this.#ig[1]=Math.max(this.#ig[1],this.#im[1]),this.#ig[2]=Math.min(this.#ig[2],this.#im[2]),this.#ig[3]=Math.min(this.#ig[3],this.#im[3])),this}take(){return new tQ(this.#ic,this.#iv)}takeDebugMetadata(){throw 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,i){return this}recordFutureForcedDependency(t,e){return this}inheritSimpleDataAsFutureForcedDependencies(t){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(t,e,i,s=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 t0{#ix={__proto__:null};#iw={__proto__:null,transform:[],moveText:[],sameLineText:[],[tW]:[]};#iC=new Map;#iS=new Set;#iE=new Map;#iT;#i_;#ik;constructor(t,e=!1){this.#ik=t,e&&(this.#iT=new Map,this.#i_=(t,e)=>{tJ(this.#iT,e).dependencies.add(t)})}get clipBox(){return this.#ik.clipBox}growOperationsCount(t){this.#ik.growOperationsCount(t)}save(t){return this.#ix={__proto__:this.#ix},this.#iw={__proto__:this.#iw,transform:{__proto__:this.#iw.transform},moveText:{__proto__:this.#iw.moveText},sameLineText:{__proto__:this.#iw.sameLineText},[tW]:{__proto__:this.#iw[tW]}},this.#ik.save(t),this}restore(t){this.#ik.restore(t,this.#i_);let e=Object.getPrototypeOf(this.#ix);return null===e||(this.#ix=e,this.#iw=Object.getPrototypeOf(this.#iw)),this}recordOpenMarker(t){return this.#ik.recordOpenMarker(t,this.#i_),this}getOpenMarker(){return this.#ik.getOpenMarker()}recordCloseMarker(t){return this.#ik.recordCloseMarker(t,this.#i_),this}beginMarkedContent(t){return this.#ik.beginMarkedContent(t),this}endMarkedContent(t){return this.#ik.endMarkedContent(t,this.#i_),this}pushBaseTransform(t){return this.#ik.pushBaseTransform(t),this}popBaseTransform(){return this.#ik.popBaseTransform(),this}recordSimpleData(t,e){return this.#ix[t]=e,this}recordIncrementalData(t,e){return this.#iw[t].push(e),this}resetIncrementalData(t,e){return this.#iw[t].length=0,this}recordNamedData(t,e){return this.#iC.set(t,e),this}recordSimpleDataFromNamed(t,e,i){this.#ix[t]=this.#iC.get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(tW,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(let e of t)e in this.#ix&&this.recordFutureForcedDependency(e,this.#ix[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(let t of this.#iS)this.recordFutureForcedDependency(tW,t);return this}resetBBox(t){return this.#ik.resetBBox(t),this}recordClipBox(t,e,i,s,r,n){return this.#ik.recordClipBox(t,e,i,s,r,n),this}recordBBox(t,e,i,s,r,n){return this.#ik.recordBBox(t,e,i,s,r,n),this}recordCharacterBBox(t,e,i,s=1,r=0,n=0,a){let o,l,h=i.bbox;if(h&&!1!==(o=h[2]!==h[0]&&h[3]!==h[1]&&this.#iE.get(i))){var d,c;let a;if(l=[0,0,0,0],N.axialAlignedBoundingBox(h,i.fontMatrix,l),(1!==s||0!==r||0!==n)&&(d=-s,c=l,s?(s<0&&(a=c[0],c[0]=c[2],c[2]=a),c[0]*=s,c[2]*=s,d<0&&(a=c[1],c[1]=c[3],c[3]=a),c[1]*=d,c[3]*=d):c.fill(0),c[0]+=r,c[1]+=n,c[2]+=r,c[3]+=n),o)return this.recordBBox(t,e,l[0],l[2],l[1],l[3])}if(!a)return this.recordFullPageBBox(t);let u=a();return h&&l&&void 0===o&&(o=l[0]<=r-u.actualBoundingBoxLeft&&l[2]>=r+u.actualBoundingBoxRight&&l[1]<=n-u.actualBoundingBoxAscent&&l[3]>=n+u.actualBoundingBoxDescent,this.#iE.set(i,o),o)?this.recordBBox(t,e,l[0],l[2],l[1],l[3]):this.recordBBox(t,e,r-u.actualBoundingBoxLeft,r+u.actualBoundingBoxRight,n-u.actualBoundingBoxAscent,n+u.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#ik.recordFullPageBBox(t),this}getSimpleIndex(t){return this.#ix[t]}recordDependencies(t,e){let i=this.#iS,s=this.#ix,r=this.#iw;for(let t of e)t in this.#ix?i.add(s[t]):t in r&&r[t].forEach(i.add,i);return this}recordNamedDependency(t,e){return this.#iC.has(e)&&this.#iS.add(this.#iC.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[tW]),this.#iT){let e=tJ(this.#iT,t),{dependencies:i}=e;this.#iS.forEach(i.add,i),this.#ik._savesStack.forEach(i.add,i),this.#ik._markedContentStack.forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}let i=!e&&t===this.#ik._pendingBBoxIdx;return this.#ik.recordOperation(t,e,[this.#iS,this.#ik._savesStack,this.#ik._markedContentStack]),i&&this.#iS.clear(),this}recordShowTextOperation(t,e=!1){let i=Array.from(this.#iS);for(let s of(this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t),i))this.recordIncrementalData("sameLineText",s);return this}bboxToClipBoxDropOperation(t,e=!1){let i=!e&&t===this.#ik._pendingBBoxIdx;return this.#ik.bboxToClipBoxDropOperation(t),i&&this.#iS.clear(),this}take(){return this.#iE.clear(),this.#ik.take()}takeDebugMetadata(){return this.#iT}}class t1{#iM;#iP;#iD;#iI=0;#iF=0;constructor(t,e,i){if(t instanceof t1&&!!i===t.#iD)return t;this.#iM=t,this.#iP=e,this.#iD=!!i}get clipBox(){return this.#iM.clipBox}growOperationsCount(){throw Error("Unreachable")}save(t){return this.#iF++,this.#iM.save(this.#iP),this}restore(t){return this.#iF>0&&(this.#iM.restore(this.#iP),this.#iF--),this}recordOpenMarker(t){return this.#iI++,this}getOpenMarker(){return this.#iI>0?this.#iP:this.#iM.getOpenMarker()}recordCloseMarker(t){return this.#iI--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#iM.pushBaseTransform(t),this}popBaseTransform(){return this.#iM.popBaseTransform(),this}recordSimpleData(t,e){return this.#iM.recordSimpleData(t,this.#iP),this}recordIncrementalData(t,e){return this.#iM.recordIncrementalData(t,this.#iP),this}resetIncrementalData(t,e){return this.#iM.resetIncrementalData(t,this.#iP),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this.#iM.recordSimpleDataFromNamed(t,e,this.#iP),this}recordFutureForcedDependency(t,e){return this.#iM.recordFutureForcedDependency(t,this.#iP),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#iM.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#iM.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#iD||this.#iM.resetBBox(this.#iP),this}recordClipBox(t,e,i,s,r,n){return this.#iD||this.#iM.recordClipBox(this.#iP,e,i,s,r,n),this}recordBBox(t,e,i,s,r,n){return this.#iD||this.#iM.recordBBox(this.#iP,e,i,s,r,n),this}recordCharacterBBox(t,e,i,s,r,n,a){return this.#iD||this.#iM.recordCharacterBBox(this.#iP,e,i,s,r,n,a),this}recordFullPageBBox(t){return this.#iD||this.#iM.recordFullPageBBox(this.#iP),this}getSimpleIndex(t){return this.#iM.getSimpleIndex(t)}recordDependencies(t,e){return this.#iM.recordDependencies(this.#iP,e),this}recordNamedDependency(t,e){return this.#iM.recordNamedDependency(this.#iP,e),this}recordOperation(t){return this.#iM.recordOperation(this.#iP,!0),this}recordShowTextOperation(t){return this.#iM.recordShowTextOperation(this.#iP,!0),this}bboxToClipBoxDropOperation(t){return this.#iD||this.#iM.bboxToClipBoxDropOperation(this.#iP,!0),this}take(){throw Error("Unreachable")}takeDebugMetadata(){throw Error("Unreachable")}}let t2=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],t3=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],t5=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],t6=["filter","fillColor","fillAlpha"],t4=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],t8=["transform"],t7=["transform","fillColor"];class t9{#ib;#iy;#iB=4;#iL=0;#iu=new t9.#iR(6*this.#iB);static #iR=O.isFloat16ArraySupported?Float16Array:Float32Array;constructor(t){this.#ib=t.width,this.#iy=t.height}record(t,e,i,s){let r;if(this.#iL===this.#iB){this.#iB*=2;let t=new t9.#iR(6*this.#iB);t.set(this.#iu),this.#iu=t}let a=td(t);if(s[0]!==1/0){let t=n.slice();N.axialAlignedBoundingBox([0,-i,e,0],a,t);let o=N.intersect(s,t);if(!o)return;let[l,h,d,c]=o;if(l!==t[0]||h!==t[1]||d!==t[2]||c!==t[3]){let t=Math.atan2(a[1],a[0]),e=Math.abs(Math.sin(t)),i=Math.abs(Math.cos(t));if(e<1e-6||i<1e-6||1e-6>Math.abs(e-i))r=[l,h,l,c,d,h];else{let t=d-l,s=c-h,n=e*e,a=i*i,o=i*e,u=a-n,p=(s*a-t*o)/u;r=[l+(s*o-t*n)/u,h,l,h+p,d,c-p]}}}r||(r=[0,-i,0,0,e,-i],N.applyTransform(r,a,0),N.applyTransform(r,a,2),N.applyTransform(r,a,4)),r[0]/=this.#ib,r[1]/=this.#iy,r[2]/=this.#ib,r[3]/=this.#iy,r[4]/=this.#ib,r[5]/=this.#iy,this.#iu.set(r,6*this.#iL),this.#iL++}take(){return this.#iu.subarray(0,6*this.#iL)}}class et{#iO=new Set;#iN=null;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){let e=this.#iU();e.insertRule(t,e.cssRules.length)}#iU(){if(this.#iN)return this.#iN;let t=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&t){let{adoptedStyleSheets:e}=this._document;if(e){let i=new t;return e.push(i),this.#iN=i}}return this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)),this.#iN=this.styleElement.sheet}clear(){for(let t of this.nativeFontFaces)this._document.fonts.delete(t);if(this.nativeFontFaces.clear(),this.#iO.clear(),this.#iN){let{adoptedStyleSheets:t}=this._document;t?.includes(this.#iN)&&(this._document.adoptedStyleSheets=t.filter(t=>t!==this.#iN)),this.#iN=null}this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(!(!t||this.#iO.has(t.loadedName))){if(S(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:e,src:s,style:r}=t,n=new FontFace(e,s,r);this.addNativeFontFace(n);try{await n.load(),this.#iO.add(e),i?.(t)}catch{w(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(n)}return}C("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){let e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw w(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}let e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{let i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){return k(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return k(this,"isSyncFontLoadingSupported",r||O.platform.isFirefox)}_queueLoadingCallback(t){let{loadingRequests:e}=this,i={done:!1,complete:function(){for(S(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;)setTimeout(e.shift().callback,0)},callback:t};return e.push(i),i}get _loadTestFont(){return k(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){var i;let s,r;function n(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function a(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let o=this._document.createElement("canvas");o.width=1,o.height=1;let l=o.getContext("2d"),h=0,d=`lt${Date.now()}${this.loadTestFontId++}`,c=this._loadTestFont,u=n(c=a(c,976,d.length,d),16);for(s=0,r=d.length-3;s<r;s+=4)u=u-0x58585858+n(d,s)|0;s<d.length&&(u=u-0x58585858+n(d+"XXX",s)|0),c=a(c,16,4,String.fromCharCode((i=u)>>24&255,i>>16&255,i>>8&255,255&i));let p=`url(data:font/opentype;base64,${btoa(c)});`,g=`@font-face {font-family:"${d}";src:${p}}`;this.insertRule(g);let m=this._document.createElement("div");for(let e of(m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px",[t.loadedName,d])){let t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,m.append(t)}this._document.body.append(m),function t(e,i){if(++h>30){w("Load test font never loaded."),i();return}(l.font="30px "+e,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0)?i():setTimeout(t.bind(null,e,i))}(d,()=>{m.remove(),e.complete()})}}class ee{compiledGlyphs=Object.create(null);#iH;constructor(t,e=null,i,s){this.#iH=t,this._inspectFont=e,i&&(this.charProcOperatorList=i),s&&Object.assign(this,s)}createNativeFontFace(){let t;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){let e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){let t;if(!this.data||this.disableFontFace)return null;let e=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),t}getPathGenerator(t,e){let i;if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let s=this.loadedName+"_path_"+e;try{i=t.get(s)}catch(t){w(`getPathGenerator - ignoring character: "${t}".`)}let r=tE(i?.path);return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}get black(){return this.#iH.black}get bold(){return this.#iH.bold}get disableFontFace(){return this.#iH.disableFontFace}set disableFontFace(t){k(this,"disableFontFace",!!t)}get fontExtraProperties(){return this.#iH.fontExtraProperties}get isInvalidPDFjsFont(){return this.#iH.isInvalidPDFjsFont}get isType3Font(){return this.#iH.isType3Font}get italic(){return this.#iH.italic}get missingFile(){return this.#iH.missingFile}get remeasure(){return this.#iH.remeasure}get vertical(){return this.#iH.vertical}get ascent(){return this.#iH.ascent}get defaultWidth(){return this.#iH.defaultWidth}get descent(){return this.#iH.descent}get bbox(){return this.#iH.bbox}get fontMatrix(){return this.#iH.fontMatrix}get fallbackName(){return this.#iH.fallbackName}get loadedName(){return this.#iH.loadedName}get mimetype(){return this.#iH.mimetype}get name(){return this.#iH.name}get data(){return this.#iH.data}clearData(){this.#iH.clearData()}get cssFontInfo(){return this.#iH.cssFontInfo}get systemFontInfo(){return this.#iH.systemFontInfo}get defaultVMetrics(){return this.#iH.defaultVMetrics}}class ei{static strings=["fontFamily","fontWeight","italicAngle"]}class es{static strings=["css","loadedName","baseFontName","src"]}class er{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static OFFSET_NUMBERS=Math.ceil(2*this.bools.length/8);static OFFSET_BBOX=this.OFFSET_NUMBERS+8*this.numbers.length;static OFFSET_FONT_MATRIX=this.OFFSET_BBOX+1+8;static OFFSET_DEFAULT_VMETRICS=this.OFFSET_FONT_MATRIX+1+48;static OFFSET_STRINGS=this.OFFSET_DEFAULT_VMETRICS+1+6}class en{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 ea{#iz;#iG=new TextDecoder;#i$;constructor(t){this.#iz=t,this.#i$=new DataView(t)}#ij(t){S(t<ei.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=this.#i$.getUint32(e)+4;let i=this.#i$.getUint32(e);return this.#iG.decode(new Uint8Array(this.#iz,e+4,i))}get fontFamily(){return this.#ij(0)}get fontWeight(){return this.#ij(1)}get italicAngle(){return this.#ij(2)}}class eo{#iz;#iG=new TextDecoder;#i$;constructor(t){this.#iz=t,this.#i$=new DataView(t)}get guessFallback(){return 0!==this.#i$.getUint8(0)}#ij(t){S(t<es.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=this.#i$.getUint32(e)+4;let i=this.#i$.getUint32(e);return this.#iG.decode(new Uint8Array(this.#iz,e+4,i))}get css(){return this.#ij(0)}get loadedName(){return this.#ij(1)}get baseFontName(){return this.#ij(2)}get src(){return this.#ij(3)}get style(){let t=1;t+=4+this.#i$.getUint32(t);let e=this.#i$.getUint32(t),i=this.#iG.decode(new Uint8Array(this.#iz,t+4,e));t+=4+e;let s=this.#i$.getUint32(t),r=this.#iG.decode(new Uint8Array(this.#iz,t+4,s));return{style:i,weight:r}}}class el{#iz;#iG=new TextDecoder;#i$;constructor({buffer:t,extra:e}){this.#iz=t,this.#i$=new DataView(t),e&&Object.assign(this,e)}#iV(t){S(t<er.bools.length,"Invalid boolean index");let e=Math.floor(t/4),i=this.#i$.getUint8(e)>>2*t%8&3;return 0===i?void 0:2===i}get black(){return this.#iV(0)}get bold(){return this.#iV(1)}get disableFontFace(){return this.#iV(2)}get fontExtraProperties(){return this.#iV(3)}get isInvalidPDFjsFont(){return this.#iV(4)}get isType3Font(){return this.#iV(5)}get italic(){return this.#iV(6)}get missingFile(){return this.#iV(7)}get remeasure(){return this.#iV(8)}get vertical(){return this.#iV(9)}#iW(t){return S(t<er.numbers.length,"Invalid number index"),this.#i$.getFloat64(er.OFFSET_NUMBERS+8*t)}get ascent(){return this.#iW(0)}get defaultWidth(){return this.#iW(1)}get descent(){return this.#iW(2)}#iK(t,e,i,s){let r=this.#i$.getUint8(t);if(0===r)return;S(r===e,"Invalid array length."),t+=1;let n=Array(r);for(let e=0;e<r;e++)n[e]=this.#i$[i](t,!0),t+=s;return n}get bbox(){return this.#iK(er.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return this.#iK(er.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return this.#iK(er.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}#ij(t){S(t<er.strings.length,"Invalid string index");let e=er.OFFSET_STRINGS+4;for(let i=0;i<t;i++)e+=this.#i$.getUint32(e)+4;let i=this.#i$.getUint32(e);return this.#iG.decode(new Uint8Array(this.#iz,e+4,i))}get fallbackName(){return this.#ij(0)}get loadedName(){return this.#ij(1)}get mimetype(){return this.#ij(2)}get name(){return this.#ij(3)}#iX(){let t=er.OFFSET_STRINGS,e=this.#i$.getUint32(t);t+=4+e;let i=this.#i$.getUint32(t);t+=4+i;let s=this.#i$.getUint32(t);t+=4+s;let r=this.#i$.getUint32(t);return{offset:t,length:r}}get data(){let{offset:t,length:e}=this.#iX();return 0===e?void 0:new Uint8Array(this.#iz,t+4,e)}clearData(){let{offset:t,length:e}=this.#iX();0!==e&&(this.#i$.setUint32(t,0),this.#iz=new Uint8Array(this.#iz,0,t+4).slice().buffer,this.#i$=new DataView(this.#iz))}get cssFontInfo(){let t=er.OFFSET_STRINGS,e=this.#i$.getUint32(t);t+=4+e;let i=this.#i$.getUint32(t);t+=4+i;let s=this.#i$.getUint32(t);if(0===s)return null;let r=new Uint8Array(s);return r.set(new Uint8Array(this.#iz,t+4,s)),new ea(r.buffer)}get systemFontInfo(){let t=er.OFFSET_STRINGS,e=this.#i$.getUint32(t);t+=4+e;let i=this.#i$.getUint32(t);if(0===i)return null;let s=new Uint8Array(i);return s.set(new Uint8Array(this.#iz,t+4,i)),new eo(s.buffer)}}class eh{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}getIR(){let t=this.view,e=this.data[en.KIND],i=!!this.data[en.HAS_BBOX],s=!!this.data[en.HAS_BACKGROUND],r=t.getUint32(en.N_COORD,!0),a=t.getUint32(en.N_COLOR,!0),o=t.getUint32(en.N_STOP,!0),l=20,h=new Float32Array(this.buffer,l,2*r);l+=8*r;let d=new Uint8Array(this.buffer,l,4*a);l+=4*a;let c=[];for(let e=0;e<o;++e){let e=t.getFloat32(l,!0);l+=4;let i=t.getUint32(l,!0);l+=4,c.push([e,`#${i.toString(16).padStart(6,"0")}`])}let u=null;if(i){u=[];for(let e=0;e<4;++e)u.push(t.getFloat32(l,!0)),l+=4}let p=null;if(s&&(p=new Uint8Array(this.buffer,l,3),l+=3),1===e)return["RadialAxial","axial",u,c,Array.from(h.slice(0,2)),Array.from(h.slice(2,4)),null,null];if(2===e)return["RadialAxial","radial",u,c,[h[0],h[1]],[h[3],h[4]],h[2],h[5]];if(3===e){let t=this.data[en.SHADING_TYPE],e=null;if(h.length>0){e=n.slice();for(let t=0,i=h.length;t<i;t+=2)N.pointBoundingBox(h[t],h[t+1],e)}return["Mesh",t,h,d,r,e,u,p]}throw Error(`Unsupported pattern kind: ${e}`)}}class ed{#iz;constructor(t){this.#iz=t}get path(){return O.isFloat16ArraySupported?new Float16Array(this.#iz):new Float32Array(this.#iz)}}function ec(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw Error(`Invalid factory url: "${t}" must include trailing slash.`)}let eu=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,ep=(function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;let[s,r,...n]=i;if(!t(s)&&!Number.isInteger(s)||!e(r))return!1;let a=n.length,o=!0;switch(r.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return 0===a;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(4!==a)return!1;o=!1;break;default:return!1}for(let t of n)if("number"!=typeof t&&(!o||null!==t))return!1;return!0}).bind(null,eu,t=>"object"==typeof t&&"string"==typeof t?.name);class eg{#iq=new Map;#iY=Promise.resolve();postMessage(t,e){let i={data:structuredClone(t,e?{transfer:e}:null)};this.#iY.then(()=>{for(let[t]of this.#iq)t.call(this,i)})}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){let{signal:r}=i;if(r.aborted)return void w("LoopbackPort - cannot use an `aborted` signal.");let n=()=>this.removeEventListener(t,e);s=()=>r.removeEventListener("abort",n),r.addEventListener("abort",n)}this.#iq.set(e,s)}removeEventListener(t,e){let i=this.#iq.get(e);i?.(),this.#iq.delete(e)}terminate(){for(let[,t]of this.#iq)t?.();this.#iq.clear()}}function em(){}function ef(t){if(t instanceof L||t instanceof I||t instanceof P||t instanceof F||t instanceof D)return t;switch(!(t instanceof Error||"object"==typeof t&&null!==t)&&C('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new L(t.message);case"InvalidPDFException":return new I(t.message);case"PasswordException":return new P(t.message,t.code);case"ResponseException":return new F(t.message,t.status,t.missing);case"UnknownErrorException":return new D(t.message,t.details)}return new D(t.message,t.toString())}class eb{#iQ=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),i.addEventListener("message",this.#iJ.bind(this),{signal:this.#iQ.signal})}#iJ({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#iZ(t);if(t.callback){let e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],1===t.callback)i.resolve(t.data);else if(2===t.callback)i.reject(ef(t.reason));else throw Error("Unexpected callback case");return}let e=this.actionHandler[t.action];if(!e)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let i=this.sourceName,s=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(e){r.postMessage({sourceName:i,targetName:s,callback:1,callbackId:t.callbackId,data:e})},function(e){r.postMessage({sourceName:i,targetName:s,callback:2,callbackId:t.callbackId,reason:ef(e)})});return}t.streamId?this.#i0(t):e(t.data)}on(t,e){let i=this.actionHandler;if(i[t])throw Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){let s=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[s]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){r.reject(t)}return r.promise}sendWithStream(t,e,i,s){let r=this.streamId++,n=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{let l=Promise.withResolvers();return this.streamControllers[r]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:n,targetName:a,action:t,streamId:r,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{let e=Promise.withResolvers();return this.streamControllers[r].pullCall=e,o.postMessage({sourceName:n,targetName:a,stream:6,streamId:r,desiredSize:t.desiredSize}),e.promise},cancel:t=>{S(t instanceof Error,"cancel must have a valid reason");let e=Promise.withResolvers();return this.streamControllers[r].cancelCall=e,this.streamControllers[r].isClosed=!0,o.postMessage({sourceName:n,targetName:a,stream:1,streamId:r,reason:ef(t)}),e.promise}},i)}#i0(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,r=this.comObj,n=this,a=this.actionHandler[t.action],o={enqueue(t,n=1,a){if(this.isCancelled)return;let o=this.desiredSize;this.desiredSize-=n,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:i,targetName:s,stream:4,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:s,stream:3,streamId:e}),delete n.streamSinks[e])},error(t){S(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:s,stream:5,streamId:e,reason:ef(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then(function(){r.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:8,streamId:e,reason:ef(t)})})}#iZ(t){let e=t.streamId,i=this.sourceName,s=t.sourceName,r=this.comObj,n=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case 8:t.success?n.startCall.resolve():n.startCall.reject(ef(t.reason));break;case 7:t.success?n.pullCall.resolve():n.pullCall.reject(ef(t.reason));break;case 6:if(!a){r.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||em).then(function(){r.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:7,streamId:e,reason:ef(t)})});break;case 4:if(S(n,"enqueue should have stream controller"),n.isClosed)break;n.controller.enqueue(t.chunk);break;case 3:if(S(n,"close should have stream controller"),n.isClosed)break;n.isClosed=!0,n.controller.close(),this.#i1(n,e);break;case 5:S(n,"error should have stream controller"),n.controller.error(ef(t.reason)),this.#i1(n,e);break;case 2:t.success?n.cancelCall.resolve():n.cancelCall.reject(ef(t.reason)),this.#i1(n,e);break;case 1:if(!a)break;let o=ef(t.reason);Promise.try(a.onCancel||em,o).then(function(){r.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,success:!0})},function(t){r.postMessage({sourceName:i,targetName:s,stream:2,streamId:e,reason:ef(t)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw Error("Unexpected stream case")}}async #i1(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#iQ?.abort(),this.#iQ=null}}class ey{#i2=Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"});constructor({cMapUrl:t=null,standardFontDataUrl:e=null,wasmUrl:i=null}){this.cMapUrl=t,this.standardFontDataUrl=e,this.wasmUrl=i}async fetch({kind:t,filename:e}){switch(t){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:C(`Not implemented: ${t}`)}let i=this[t];if(!i)throw Error(`Ensure that the \`${t}\` API parameter is provided.`);let s=`${i}${e}`;return this._fetch(s,t).catch(e=>{throw Error(`Unable to load ${this.#i2[t]} data at: ${s}`)})}async _fetch(t,e){C("Abstract method `_fetch` called.")}}class ev extends ey{async _fetch(t,e){let i="cMapUrl"!==e||t.endsWith(".bcmap")?"bytes":"text",s=await Q(t,i);return s instanceof Uint8Array?s:R(s)}}class eA{#i3=!1;constructor({enableHWA:t=!1}){this.#i3=t}create(t,e){if(t<=0||e<=0)throw Error("Invalid canvas size");let i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#i3})}}reset({canvas:t},e,i){if(!t)throw Error("Canvas is not specified");if(e<=0||i<=0)throw Error("Invalid canvas size");t.width=e,t.height=i}destroy(t){let{canvas:e}=t;if(!e)throw Error("Canvas is not specified");e.width=e.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){C("Abstract method `_createCanvas` called.")}}class ex extends eA{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){let i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class ew{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,i,s,r){return"none"}addSelectionHCMFilter(t,e){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(t=null){return null}destroy(t=!1){}}class eC extends ew{#i5;#i6;#i4;#i8;#i7;#i9;#T=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#i8=t,this.#i7=e}get #k(){return this.#i6||=new Map}get #st(){return this.#i9||=new Map}get #se(){if(!this.#i4){let t=this.#i7.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;let i=this.#i7.createElementNS(l,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#i4=this.#i7.createElementNS(l,"defs"),t.append(i),i.append(this.#i4),this.#i7.body.append(t)}return this.#i4}#si(t){if(1===t.length){let e=t[0],i=Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;let s=i.join(",");return[s,s,s]}let[e,i,s]=t,r=Array(256),n=Array(256),a=Array(256);for(let t=0;t<256;t++)r[t]=e[t]/255,n[t]=i[t]/255,a[t]=s[t]/255;return[r.join(","),n.join(","),a.join(",")]}#ss(t){if(void 0===this.#i5){this.#i5="";let t=this.#i7.URL;t!==this.#i7.baseURI&&(Z(t)?w('#createUrl: ignore "data:"-URL for performance reasons.'):this.#i5=T(t,""))}return`url(${this.#i5}#${t})`}addFilter(t){if(!t)return"none";let e=this.#k.get(t);if(e)return e;let[i,s,r]=this.#si(t),n=1===t.length?i:`${i}${s}${r}`;if(e=this.#k.get(n))return this.#k.set(t,e),e;let a=`g_${this.#i8}_transfer_map_${this.#T++}`,o=this.#ss(a);this.#k.set(t,o),this.#k.set(n,o);let l=this.#sr(a);return this.#sn(i,s,r,l),o}addHCMFilter(t,e){let i=`${t}-${e}`,s="base",r=this.#st.get(s);if(r?.key===i||(r?(r.filter?.remove(),r.key=i,r.url="none",r.filter=null):(r={key:i,url:"none",filter:null},this.#st.set(s,r)),!t||!e))return r.url;let n=this.#sa(t);t=N.makeHexColor(...n);let a=this.#sa(e);if(e=N.makeHexColor(...a),this.#se.style.color="","#000000"===t&&"#ffffff"===e||t===e)return r.url;let o=Array(256);for(let t=0;t<=255;t++){let e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}let l=o.join(","),h=`g_${this.#i8}_hcm_filter`,d=r.filter=this.#sr(h);this.#sn(l,l,l,d),this.#so(d);let c=(t,e)=>{let i=n[t]/255,s=a[t]/255,r=Array(e+1);for(let t=0;t<=e;t++)r[t]=i+t/e*(s-i);return r.join(",")};return this.#sn(c(0,5),c(1,5),c(2,5),d),r.url=this.#ss(h),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){let e=t?this.addSelectionHCMFilter(t.foreground,t.background):this.addSelectionFilter();return"none"!==e&&O.platform.isFirefox?{"backdrop-filter":e,"background-color":"transparent"}:null}addAlphaFilter(t){let e=this.#k.get(t);if(e)return e;let[i]=this.#si([t]),s=`alpha_${i}`;if(e=this.#k.get(s))return this.#k.set(t,e),e;let r=`g_${this.#i8}_alpha_map_${this.#T++}`,n=this.#ss(r);this.#k.set(t,n),this.#k.set(s,n);let a=this.#sr(r);return this.#sl(i,a),n}addLuminosityFilter(t){let e,i,s=this.#k.get(t||"luminosity");if(s)return s;if(t?([e]=this.#si([t]),i=`luminosity_${e}`):i="luminosity",s=this.#k.get(i))return this.#k.set(t,s),s;let r=`g_${this.#i8}_luminosity_map_${this.#T++}`,n=this.#ss(r);this.#k.set(t,n),this.#k.set(i,n);let a=this.#sr(r);return this.#sh(a),t&&this.#sl(e,a),n}addKnockoutFilter(t=0){let e=t>0?Math.min(1/t,1e6):1e6,i=`knockout_${e}`,s=this.#k.get(i);if(s)return s;let r=`g_${this.#i8}_knockout_filter_${this.#T++}`,n=this.#ss(r);this.#k.set(i,n);let a=this.#sr(r),o=this.#i7.createElementNS(l,"feComponentTransfer");a.append(o);let h=this.#i7.createElementNS(l,"feFuncA");return h.setAttribute("type","linear"),h.setAttribute("slope",`${e}`),h.setAttribute("intercept","0"),o.append(h),n}addHighlightHCMFilter(t,e,i,s,r){let n=`${e}-${i}-${s}-${r}`,a=this.#st.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.#st.set(t,a)),!e||!i))return a.url;let[o,l]=[e,i].map(this.#sa.bind(this)),h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,r].map(this.#sd.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#se.style.color="";let p=(t,e,i)=>{let s=Array(256),r=(d-h)/i,n=t/255,a=(e-t)/(255*i),o=0;for(let t=0;t<=i;t++){let e=Math.round(h+t*r),i=n+t*a;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#i8}_hcm_${t}_filter`,m=a.filter=this.#sr(g);return this.#so(m),this.#sn(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),m),a.url=this.#ss(g),a.url}destroy(t=!1){t&&this.#i9?.size||(this.#i4?.parentNode.parentNode.remove(),this.#i4=null,this.#i6?.clear(),this.#i6=null,this.#i9?.clear(),this.#i9=null,this.#T=0)}#sh(t){let e=this.#i7.createElementNS(l,"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)}#so(t){let e=this.#i7.createElementNS(l,"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)}#sr(t){let e=this.#i7.createElementNS(l,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#se.append(e),e}#sc(t,e,i){let s=this.#i7.createElementNS(l,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#sn(t,e,i,s){let r=this.#i7.createElementNS(l,"feComponentTransfer");s.append(r),this.#sc(r,"feFuncR",t),this.#sc(r,"feFuncG",e),this.#sc(r,"feFuncB",i)}#sl(t,e){let i=this.#i7.createElementNS(l,"feComponentTransfer");e.append(i),this.#sc(i,"feFuncA",t)}#sa(t){return this.#se.style.color=t,th(getComputedStyle(this.#se).getPropertyValue("color"))}#su(t){return this.#se.style.color=t,tl(getComputedStyle(this.#se).getPropertyValue("color"))}#sd(t){let[e,i,s,r]=this.#su(t);if(1===r)return[e,i,s];let[n,a,o]=this.#sa("Canvas");return[eS(e,n,r),eS(i,a,r),eS(s,o,r)]}}function eS(t,e,i){return Math.round(i*t+(1-i)*e)}async function eE(t){let i=e.default.getBuiltinModule("fs/promises");return new Uint8Array(await i.readFile(t))}r&&w("Please use the `legacy` build in Node.js environments.");class eT extends ew{}class e_ extends eA{_createCanvas(t,i){return e.default.getBuiltinModule("module").createRequire(s.url)("@napi-rs/canvas").createCanvas(t,i)}}class ek extends ey{async _fetch(t,e){return eE(t)}}function eM({src:t,srcPos:e=0,dest:i,width:s,height:r,nonBlackColor:n=0xffffffff,inverseDecode:a=!1}){let o=O.isLittleEndian?0xff000000:255,[l,h]=a?[n,o]:[o,n],d=s>>3,c=7&s,u=l^h,p=t.length;i=new Uint32Array(i.buffer);let g=0;for(let s=0;s<r;++s){for(let s=e+d;e<s;++e,g+=8){let s=t[e];i[g]=l^-(s>>7&1)&u,i[g+1]=l^-(s>>6&1)&u,i[g+2]=l^-(s>>5&1)&u,i[g+3]=l^-(s>>4&1)&u,i[g+4]=l^-(s>>3&1)&u,i[g+5]=l^-(s>>2&1)&u,i[g+6]=l^-(s>>1&1)&u,i[g+7]=l^-(1&s)&u}if(0===c)continue;let s=e<p?t[e++]:255;for(let t=0;t<c;++t,++g)i[g]=l^-(s>>7-t&1)&u}return{srcPos:e,destPos:g}}let eP=`
3
+ struct Uniforms {
4
+ offsetX : f32,
5
+ offsetY : f32,
6
+ scaleX : f32,
7
+ scaleY : f32,
8
+ paddedWidth : f32,
9
+ paddedHeight : f32,
10
+ borderSize : f32,
11
+ _pad : f32,
12
+ };
13
+
14
+ @group(0) @binding(0) var<uniform> u : Uniforms;
15
+
16
+ struct VertexInput {
17
+ @location(0) position : vec2<f32>,
18
+ @location(1) color : vec4<f32>,
19
+ };
20
+
21
+ struct VertexOutput {
22
+ @builtin(position) position : vec4<f32>,
23
+ @location(0) color : vec3<f32>,
24
+ };
25
+
26
+ @vertex
27
+ fn vs_main(in : VertexInput) -> VertexOutput {
28
+ var out : VertexOutput;
29
+ let cx = (in.position.x + u.offsetX) * u.scaleX;
30
+ let cy = (in.position.y + u.offsetY) * u.scaleY;
31
+ out.position = vec4<f32>(
32
+ ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,
33
+ 1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,
34
+ 0.0,
35
+ 1.0
36
+ );
37
+ out.color = in.color.rgb;
38
+ return out;
39
+ }
40
+
41
+ @fragment
42
+ fn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {
43
+ return vec4<f32>(in.color, 1.0);
44
+ }
45
+ `,eD=new class{#sp=null;#sg=null;#sm=null;#sf=null;async #sb(){if(!globalThis.navigator?.gpu)return!1;try{let t=await navigator.gpu.requestAdapter();if(!t)return!1;return this.#sf=navigator.gpu.getPreferredCanvasFormat(),this.#sg=await t.requestDevice(),!0}catch{return!1}}init(){return this.#sp||=this.#sb()}get isReady(){return null!==this.#sg}loadMeshShader(){if(!this.#sg||this.#sm)return;let t=this.#sg.createShaderModule({code:eP});this.#sm=this.#sg.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.#sf}]},primitive:{topology:"triangle-list"}})}draw(t,e,i,s,r,n,a,o){this.loadMeshShader();let l=this.#sg,{offsetX:h,offsetY:d,scaleX:c,scaleY:u}=s,p=l.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&l.queue.writeBuffer(p,0,t);let g=l.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&l.queue.writeBuffer(g,0,e);let m=l.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l.queue.writeBuffer(m,0,new Float32Array([h,d,c,u,n,a,o,0]));let f=l.createBindGroup({layout:this.#sm.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:m}}]}),b=new OffscreenCanvas(n,a),y=b.getContext("webgpu");y.configure({device:l,format:this.#sf,alphaMode:r?"opaque":"premultiplied"});let v=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(),x=A.beginRenderPass({colorAttachments:[{view:y.getCurrentTexture().createView(),clearValue:v,loadOp:"clear",storeOp:"store"}]});return i>0&&(x.setPipeline(this.#sm),x.setBindGroup(0,f),x.setVertexBuffer(0,p),x.setVertexBuffer(1,g),x.draw(i)),x.end(),l.queue.submit([A.finish()]),p.destroy(),g.destroy(),m.destroy(),b.transferToImageBitmap()}},eI="Fill",eF="Stroke",eB="Shading";function eL(t,e){if(!e)return;let i=e[2]-e[0],s=e[3]-e[1],r=new Path2D;r.rect(e[0],e[1],i,s),t.clip(r)}class eR{isModifyingCurrentTransform(){return!1}getPattern(){C("Abstract method `getPattern` called.")}}class eO extends eR{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}isOriginBased(){return 0===this._p0[0]&&0===this._p0[1]&&(!this.isRadial()||0===this._p1[0]&&0===this._p1[1])}isRadial(){return"radial"===this._type}areConic(){if(!this.isRadial())return!1;let 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 i,s=this._p0,r=this._p1;if(e&&(s=s.slice(),r=r.slice(),N.applyTransform(s,e),N.applyTransform(r,e)),"axial"===this._type)i=t.createLinearGradient(s[0],s[1],r[0],r[1]);else if("radial"===this._type){let n=this._r0,a=this._r1;if(e){let t=new Float32Array(2);N.singularValueDecompose2dScale(e,t),n*=t[0],a*=t[0]}i=t.createRadialGradient(s[0],s[1],n,r[0],r[1],a)}for(let t of this._colorStops)i.addColorStop(t[0],t[1]);return i}_createReversedGradient(t,e=null){let i=this._p1,s=this._p0;e&&(i=i.slice(),s=s.slice(),N.applyTransform(i,e),N.applyTransform(s,e));let r=this._r1,n=this._r0;if(e){let t=new Float32Array(2);N.singularValueDecompose2dScale(e,t),r*=t[0],n*=t[0]}let a=t.createRadialGradient(i[0],i[1],r,s[0],s[1],n);for(let[t,e]of this._colorStops.map(([t,e])=>[1-t,e]).reverse())a.addColorStop(t,e);return a}getPattern(t,e,i,s){let r;if(s===eF||s===eI){if(this.isOriginBased()){let s=N.transform(i,e.baseTransform);this.matrix&&(s=N.transform(s,this.matrix));let r=Math.hypot(s[0],s[1]),n=Math.hypot(s[2],s[3]);if(.001>Math.abs((s[0]*s[2]+s[1]*s[3])/(r*n))){if(!this.isRadial())return this._createGradient(t,s);else if(.001>Math.abs(r-n))return this._createGradient(t,s)}}let n=e.current.getClippedPathBoundingBox(s,td(t))||[0,0,0,0],a=Math.ceil(n[2]-n[0])||1,o=Math.ceil(n[3]-n[1])||1,l=e.canvasFactory.create(a,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-n[0],-n[1]),i=N.transform(i,[1,0,0,1,n[0],n[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),eL(h,this._bbox),this.areConic()&&(h.fillStyle=this._createReversedGradient(h),h.fill()),h.fillStyle=this._createGradient(h),h.fill(),r=t.createPattern(l.canvas,"no-repeat"),e.canvasFactory.destroy(l);let d=new DOMMatrix(i);r.setTransform(d)}else this.areConic()&&(t.save(),eL(t,this._bbox),t.fillStyle=this._createReversedGradient(t),t.fillRect(-1e10,-1e10,2e10,2e10),t.restore()),eL(t,this._bbox),r=this._createGradient(t);return r}}class eN extends eR{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],this.matrix=null,eD.loadMeshShader()}_createMeshCanvas(t,e,i){let s=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),n=Math.ceil(this._bounds[2])-s,a=Math.ceil(this._bounds[3])-r,o=Math.min(Math.ceil(Math.abs(n*t[0]*1.1)),3e3)||1,l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3)||1,h=n?n/o:1,d=a?a/l:1,c={coords:this._posData,colors:this._colData,offsetX:-s,offsetY:-r,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.create(u,p);if(eD.isReady&&this._vertexCount>48){var m,f,b;g.context.drawImage((m=this._posData,f=this._colData,b=this._vertexCount,eD.draw(m,f,b,c,e,u,p,2)),0,0)}else{let t=g.context.createImageData(o,l);if(e){let i=t.data;for(let t=0,s=i.length;t<s;t+=4)i[t]=e[0],i[t+1]=e[1],i[t+2]=e[2],i[t+3]=255}for(let e=0,i=this._vertexCount;e<i;e+=3)!function(t,e,i,s,r,n,a,o){let l,h,d,c,u,p,g,m,f,b=e.coords,y=e.colors,v=t.data,A=4*t.width;b[2*i+1]>b[2*s+1]&&(l=i,i=s,s=l,l=n,n=a,a=l),b[2*s+1]>b[2*r+1]&&(l=s,s=r,r=l,l=a,a=o,o=l),b[2*i+1]>b[2*s+1]&&(l=i,i=s,s=l,l=n,n=a,a=l);let x=(b[2*i]+e.offsetX)*e.scaleX,w=(b[2*i+1]+e.offsetY)*e.scaleY,C=(b[2*s]+e.offsetX)*e.scaleX,S=(b[2*s+1]+e.offsetY)*e.scaleY,E=(b[2*r]+e.offsetX)*e.scaleX,T=(b[2*r+1]+e.offsetY)*e.scaleY;if(w>=T)return;let _=y[4*n],k=y[4*n+1],M=y[4*n+2],P=y[4*a],D=y[4*a+1],I=y[4*a+2],F=y[4*o],B=y[4*o+1],L=y[4*o+2],R=Math.round(w),O=Math.round(T);for(let t=R;t<=O;t++){let e;if(t<S){let e=t<w?0:(w-t)/(w-S);h=x-(x-C)*e,d=_-(_-P)*e,c=k-(k-D)*e,u=M-(M-I)*e}else{let e;h=C-(C-E)*(e=t>T?1:S===T?0:(S-t)/(S-T)),d=P-(P-F)*e,c=D-(D-B)*e,u=I-(I-L)*e}p=x-(x-E)*(e=t<w?0:t>T?1:(w-t)/(w-T)),g=_-(_-F)*e,m=k-(k-B)*e,f=M-(M-L)*e;let i=Math.round(Math.min(h,p)),s=Math.round(Math.max(h,p)),r=A*t+4*i;for(let t=i;t<=s;t++)(e=(h-t)/(h-p))<0?e=0:e>1&&(e=1),v[r++]=d-(d-g)*e|0,v[r++]=c-(c-m)*e|0,v[r++]=u-(u-f)*e|0,v[r++]=255}}(t,c,e,e+1,e+2,e,e+1,e+2);g.context.putImageData(t,2,2)}return{canvas:g.canvas,offsetX:s-2*h,offsetY:r-2*d,scaleX:h,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,s){eL(t,this._bbox);let r=new Float32Array(2);if(s===eB)N.singularValueDecompose2dScale(td(t),r);else if(this.matrix){N.singularValueDecompose2dScale(this.matrix,r);let[t,i]=r;N.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=t,r[1]*=i}else N.singularValueDecompose2dScale(e.baseTransform,r);let n=this._createMeshCanvas(r,s===eB?null:this._background,e.canvasFactory);s!==eB&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(n.offsetX,n.offsetY),t.scale(n.scaleX,n.scaleY);let a=t.createPattern(n.canvas,"no-repeat");return e.canvasFactory.destroy(n),a}}class eU extends eR{getPattern(){return"hotpink"}}class eH{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.needsIsolation=t[9]??!0,this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=s,this.patternBaseMatrix=this.matrix?N.transform(s,this.matrix):s}canSkipPatternCanvas([t,e,i,s]){let[r,n,a,o]=this.bbox,l=Math.abs(this.xstep),h=Math.abs(this.ystep);if(t>l+1e-6||e>h+1e-6)return null;let d=Math.floor((i-a)/l)+1,c=Math.floor((s-o)/h)+1,u=Math.ceil((s+e-n)/h)-1;return Math.ceil((i+t-r)/l)-1<=d&&u<=c?[d,c]:null}updatePatternDims(t,e){let i=N.inverseTransform(this.patternBaseMatrix),s=[t[0],t[1]],r=[t[2],t[3]];N.applyTransform(s,i),N.applyTransform(r,i),e[0]=Math.abs(r[0]-s[0]),e[1]=Math.abs(r[1]-s[1]),e[2]=Math.min(s[0],r[0]),e[3]=Math.min(s[1],r[1])}_renderTileCanvas(t,e,i,s){let[r,n,a,o]=this.bbox,l=t.canvasFactory.create(i.size,s.size),h=l.context,d=this.canvasGraphicsFactory.createCanvasGraphics(h,e);return d.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(d,this.paintType,this.color),h.translate(-i.scale*r,-s.scale*n),d.transform(0,i.scale,0,0,s.scale,0,0),h.save(),d.dependencyTracker?.save(),this.clipBbox(d,r,n,a,o),d.baseTransform=td(d.ctx),d.executeOperatorList(this.operatorList),d.endDrawing(),d.dependencyTracker?.restore(),h.restore(),l}_getCombinedScales(){let t=new Float32Array(2);N.singularValueDecompose2dScale(this.matrix,t);let[e,i]=t;return N.singularValueDecompose2dScale(this.baseTransform,t),[e*t[0],i*t[1]]}drawPattern(t,e,i=!1,[s,r],n){let[a,o,l,h]=this.bbox,d=t.dependencyTracker;if(d&&(t.dependencyTracker=new t1(d,n)),t.save(),i?t.ctx.clip(e,"evenodd"):t.ctx.clip(e),t.ctx.setTransform(...this.patternBaseMatrix),t.ctx.translate(s*this.xstep,r*this.ystep),this.needsIsolation||1!==t.ctx.globalAlpha||"source-over"!==t.ctx.globalCompositeOperation||t.inSMaskMode){let e=l-a,i=h-o,[s,r]=this._getCombinedScales(),d=this.getSizeAndScale(e,this.ctx.canvas.width,s),c=this.getSizeAndScale(i,this.ctx.canvas.height,r),u=this._renderTileCanvas(t,n,d,c);t.ctx.drawImage(u.canvas,a,o,e,i),t.canvasFactory.destroy(u)}else this.setFillAndStrokeStyleToContext(t,this.paintType,this.color),this.clipBbox(t,a,o,l,h),t.baseTransformStack.push(t.baseTransform),t.baseTransform=td(t.ctx),t.executeOperatorList(this.operatorList),t.baseTransform=t.baseTransformStack.pop();t.restore(),d&&(t.dependencyTracker=d)}createPatternCanvas(t,e){let[i,s,r,n]=this.bbox,a=r-i,o=n-s,{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),x("TilingType: "+this.tilingType);let[d,c]=this._getCombinedScales(),u=a,p=o,g=!1,m=!1;Math.ceil(l*d)>=Math.ceil(a*d)?u=l:g=!0,Math.ceil(h*c)>=Math.ceil(o*c)?p=h:m=!0;let f=this.getSizeAndScale(u,this.ctx.canvas.width,d),b=this.getSizeAndScale(p,this.ctx.canvas.height,c),y=this._renderTileCanvas(t,e,f,b);if(g||m){let e=y.canvas;g&&(u=l),m&&(p=h);let r=this.getSizeAndScale(u,this.ctx.canvas.width,d),n=this.getSizeAndScale(p,this.ctx.canvas.height,c),f=r.size,b=n.size,v=t.canvasFactory.create(f,b),A=v.context,x=g?Math.floor(a/l):0,w=m?Math.floor(o/h):0;for(let t=0;t<=x;t++)for(let i=0;i<=w;i++)A.drawImage(e,f*t,b*i,f,b,0,0,f,b);return t.canvasFactory.destroy(y),{canvas:v.canvas,canvasEntry:v,scaleX:r.scale,scaleY:n.scale,offsetX:i,offsetY:s}}return{canvas:y.canvas,canvasEntry:y,scaleX:f.scale,scaleY:b.scale,offsetX:i,offsetY:s}}getSizeAndScale(t,e,i){let s=Math.max(eH.MAX_PATTERN_SIZE,e),r=Math.ceil(t*i);return r>=s?r=s:i=r/t,{scale:i,size:r}}clipBbox(t,e,i,s,r){let n=s-e,a=r-i,o=new Path2D;o.rect(e,i,n,a),N.axialAlignedBoundingBox([e,i,s,r],td(t.ctx),t.current.minMax),t.ctx.clip(o),t.current.updateClipFromPath()}setFillAndStrokeStyleToContext(t,e,i){let s=t.ctx,r=t.current;switch(r.patternFill=r.patternStroke=!1,e){case 1:let{fillStyle:n,strokeStyle:a}=this.ctx;s.fillStyle=r.fillColor=n,s.strokeStyle=r.strokeColor=a;break;case 2:s.fillStyle=s.strokeStyle=i,r.fillColor=r.strokeColor=i;break;default:throw new B(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,s,r){let n=s!==eB?N.transform(i,this.patternBaseMatrix):i,a=this.createPatternCanvas(e,r),o=new DOMMatrix(n);o=(o=o.translate(a.offsetX,a.offsetY)).scale(1/a.scaleX,1/a.scaleY);let l=t.createPattern(a.canvas,"repeat");return e.canvasFactory.destroy(a.canvasEntry),l.setTransform(o),l}}let ez=new DOMMatrix,eG=new Float32Array(2);function e$(t,e){if(t._removeMirroring)throw Error("Context is already forwarding operations.");let i=new Map;for(let s of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){let r=t[s];"function"==typeof r&&"function"==typeof e[s]&&(i.set(s,r),t[s]=function(...t){return e[s](...t),r.apply(this,t)})}t._removeMirroring=()=>{for(let[e,s]of i)t[e]=s;delete t._removeMirroring}}function ej(t,e,i,s,r,n,a,o,l,h){let[d,c,u,p,g,m]=td(t);if(0===c&&0===u){let f=Math.round(a*d+g),b=Math.round(o*p+m),y=Math.abs(Math.round((a+l)*d+g)-f)||1,v=Math.abs(Math.round((o+h)*p+m)-b)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),f,b),t.drawImage(e,i,s,r,n,0,0,y,v),t.setTransform(d,c,u,p,g,m),[y,v]}if(0===d&&0===p){let f=Math.round(o*u+g),b=Math.round(a*c+m),y=Math.abs(Math.round((o+h)*u+g)-f)||1,v=Math.abs(Math.round((a+l)*c+m)-b)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,f,b),t.drawImage(e,i,s,r,n,0,0,v,y),t.setTransform(d,c,u,p,g,m),[v,y]}return t.drawImage(e,i,s,r,n,a,o,l,h),[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class eV{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=o;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=0;textRise=0;fillColor="#000000";strokeColor="#000000";tilingPatternDims=null;patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";minMax=a.slice();constructor(t,e){this.clipBox=new Float32Array([0,0,t,e])}clone(){let t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t.tilingPatternDims=this.tilingPatternDims?.slice(),t}getPathBoundingBox(t=eI,e=null){let i=this.minMax.slice();if(t===eF){e||C("Stroke bounding box must include transform."),N.singularValueDecompose2dScale(e,eG);let t=eG[0]*this.lineWidth/2,s=eG[1]*this.lineWidth/2;i[0]-=t,i[1]-=s,i[2]+=t,i[3]+=s}return i}updateClipFromPath(){let t=N.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(a,0)}getClippedPathBoundingBox(t=eI,e=null){return N.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function eW(t,e){let i,{width:s,height:r,kind:n}=e,a=r%16,o=(r-a)/16,l=0===a?o:o+1,h=t.createImageData(s,16),d=0,c=e.data,u=h.data;if(n===m.GRAYSCALE_1BPP)for(i=0;i<l;i++)({srcPos:d}=eM({src:c,srcPos:d,dest:u,width:s,height:i<o?16:a})),t.putImageData(h,0,16*i);else if(n===m.RGBA_32BPP){let e=0,r=16*s*4;for(i=0;i<o;i++)u.set(c.subarray(d,d+r)),d+=r,t.putImageData(h,0,e),e+=16;i<l&&(r=s*a*4,u.set(c.subarray(d,d+r)),t.putImageData(h,0,e))}else if(n===m.RGB_24BPP)for(i=0;i<l;i++)({srcPos:d}=function({src:t,srcPos:e=0,dest:i,destPos:s=0,width:r,height:n}){let a=0,o=r*n*3,l=o>>2,h=new Uint32Array(t.buffer,e,l),d=O.isLittleEndian?0xff000000:255;if(O.isLittleEndian){for(;a<l-2;a+=3,s+=4){let t=h[a],e=h[a+1],r=h[a+2];i[s]=t|d,i[s+1]=t>>>24|e<<8|d,i[s+2]=e>>>16|r<<16|d,i[s+3]=r>>>8|d}for(let r=4*a,n=e+o;r<n;r+=3)i[s++]=t[r]|t[r+1]<<8|t[r+2]<<16|d}else{for(;a<l-2;a+=3,s+=4){let t=h[a],e=h[a+1],r=h[a+2];i[s]=t|d,i[s+1]=t<<24|e>>>8|d,i[s+2]=e<<16|r>>>16|d,i[s+3]=r<<8|d}for(let r=4*a,n=e+o;r<n;r+=3)i[s++]=t[r]<<24|t[r+1]<<16|t[r+2]<<8|d}return{srcPos:e+o,destPos:s}}({src:c,srcPos:d,dest:new Uint32Array(u.buffer),width:s,height:i<o?16:a})),t.putImageData(h,0,16*i);else throw Error(`bad image kind: ${n}`)}function eK(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);let{width:i,height:s}=e,r=s%16,n=(s-r)/16,a=0===r?n:n+1,o=t.createImageData(i,16),l=0,h=e.data,d=o.data;for(let e=0;e<a;e++)({srcPos:l}=eM({src:h,srcPos:l,dest:d,width:i,height:e<n?16:r,nonBlackColor:0})),t.putImageData(o,0,16*e)}function eX(t,e){for(let i of["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"])void 0!==t[i]&&(e[i]=t[i]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function eq(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0);let{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function eY(t,e){if(e)return!0;N.singularValueDecompose2dScale(t,eG);let i=Math.fround(tp.pixelRatio*Y.PDF_TO_CSS_UNITS);return eG[0]<=i&&eG[1]<=i}let eQ=["butt","round","square"],eJ=["miter","round","bevel"],eZ={},e0={};class e1{#sy=0;#sv=0;#sA=null;#sx=null;#sw=null;#sC=null;#sS=1;#sE;#sT=null;#s_=[];constructor(t,e,i,s,r,{optionalContentConfig:n,markedContentStack:a=null},o,l,h,d){this.ctx=t,this.current=new eV(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.commonObjs=e,this.objs=i,this.canvasFactory=s,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.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=h??null,this.imagesTracker=d??null}getObject(t,e,i=null){return"string"==typeof e?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){let r=this.ctx.canvas.width,n=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,r,n),this.ctx.fillStyle=a,i){let t=this.transparentCanvasEntry=this.canvasFactory.create(r,n);this.compositeCtx=this.ctx,({canvas:this.transparentCanvas,context:this.ctx}=t),this.ctx.save(),this.ctx.transform(...td(this.compositeCtx))}this.ctx.save(),eq(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=td(this.ctx)}executeOperatorList(t,e,i,s,r){let n,a,o=t.argsArray,l=t.fnArray,h=e||0,d=o.length;if(d===h)return h;let c=d-h>10&&"function"==typeof i,u=c?Date.now()+15:0,p=0,g=this.commonObjs,m=this.objs;for(;;){if(void 0!==s){if(h===s.nextBreakPoint)return s.breakIt(h,i),h;if(s.shouldSkip(h)){if(++h===d)return h;continue}}if(!r||r(h))if(n=l[h],a=o[h]??null,n!==y.dependency)null===a?this[n](h):this[n](h,...a);else for(let t of a){this.dependencyTracker?.recordNamedData(t,h);let e=t.startsWith("g_")?g:m;if(!e.has(t))return e.get(t,i),h}if(++h===d)return h;if(c&&++p>10){if(Date.now()>u)return i(),h;p=0}}}#sk(){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(){for(let t of(this.#sk(),this.smaskGroupCanvases))this.canvasFactory.destroy(t);for(let t of(this.smaskGroupCanvases.length=0,this._clearPreparedSMask(),this.tempSMask=null,this.smaskStack.length=0,this.#s_))this.#sM(t);for(let t of(this.#s_.length=0,this.#sA=null,this.#sx=null,this.#sw=null,this.#sC=null,this.#sS=1,this.#sT=null,this.#sv=0,this.#sy=0,this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(let e of t.values())"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#sP()}#sP(){if(this.pageColors){let t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){let e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){let i=t.width??t.displayWidth,s=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=[],o=r,l=n,h=i,d=s;for(;o>2&&h>1||l>2&&d>1;){let t=h,e=d;o>2&&h>1&&(t=Math.ceil(h/2),o/=h/t),l>2&&d>1&&(e=Math.ceil(d/2),l/=d/e),a.push({newWidth:t,newHeight:e}),h=t,d=e}if(0===a.length)return{img:t,paintWidth:i,paintHeight:s,tmpCanvas:null};if(1===a.length){let{newWidth:e,newHeight:r}=a[0],n=this.canvasFactory.create(e,r);return n.context.drawImage(t,0,0,i,s,0,0,e,r),{img:n.canvas,paintWidth:e,paintHeight:r,tmpCanvas:n}}let c=this.canvasFactory.create(1,1),u=this.canvasFactory.create(1,1),p=i,g=s,m=t;for(let{newWidth:t,newHeight:e}of a)this.canvasFactory.reset(u,t,e),u.context.drawImage(m,0,0,p,g,0,0,t,e),[c,u]=[u,c],m=c.canvas,p=t,g=e;return this.canvasFactory.destroy(u),{img:c.canvas,paintWidth:p,paintHeight:g,tmpCanvas:c}}_createMaskCanvas(t,e){let i,s,r,n,o=this.ctx,{width:l,height:h}=e,d=this.current.fillColor,c=this.current.patternFill,u=td(o);if((e.bitmap||e.data)&&e.count>1){let n=e.bitmap||e.data.buffer;s=JSON.stringify(c?u:[u.slice(0,4),d]);let a=(i=this._cachedBitmapsMap.getOrInsertComputed(n,j)).get(s);if(a&&!c){let e=Math.round(Math.min(u[0],u[2])+u[4]),i=Math.round(Math.min(u[1],u[3])+u[5]);return this.dependencyTracker?.recordDependencies(t,t7),{canvas:a,offsetX:e,offsetY:i}}r=a}r||eK((n=this.canvasFactory.create(l,h)).context,e);let p=N.transform(u,[1/l,0,0,-1/h,0,0]);p=N.transform(p,[1,0,0,1,0,-h]);let g=a.slice();N.axialAlignedBoundingBox([0,0,l,h],p,g);let[m,f,b,y]=g,v=Math.round(b-m)||1,A=Math.round(y-f)||1,x=this.canvasFactory.create(v,A),w=x.context;w.translate(-m,-f),w.transform(...p);let C=null;if(!r){let t=this._scaleImage(n.canvas,tc(w));r=t.img,C=t.tmpCanvas,r!==n.canvas&&(this.canvasFactory.destroy(n),n=null),i&&c&&(i.set(s,r),C=null,n=null)}w.imageSmoothingEnabled=eY(td(w),e.interpolate),ej(w,r,0,0,r.width,r.height,0,0,l,h),C&&this.canvasFactory.destroy(C),n&&this.canvasFactory.destroy(n),w.globalCompositeOperation="source-in";let S=N.transform(tc(w),[1,0,0,1,-m,-f]);return w.fillStyle=c?d.getPattern(o,this,S,eI,t):d,w.fillRect(0,0,l,h),i&&!c&&i.set(s,x.canvas),this.dependencyTracker?.recordDependencies(t,t7),{canvas:x.canvas,canvasEntry:i&&!c?null:x,offsetX:Math.round(m),offsetY:Math.round(f)}}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=eQ[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=eJ[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){this.dependencyTracker?.recordSimpleData("dash",t);let s=this.ctx;void 0!==s.setLineDash&&(s.setLineDash(e),s.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(let[i,s]of e)switch(i){case"LW":this.setLineWidth(t,s);break;case"LC":this.setLineCap(t,s);break;case"LJ":this.setLineJoin(t,s);break;case"ML":this.setMiterLimit(t,s);break;case"D":this.setDash(t,s[0],s[1]);break;case"RI":this.setRenderingIntent(t,s);break;case"FL":this.setFlatness(t,s);break;case"Font":this.setFont(t,s[0],s[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=s;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=s;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=s;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=s?this.tempSMask:null,this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation),this.tempSMask=null,this.checkSMaskState(t);break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s)}}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){let 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){let e,i,s,r,{canvas:n,subtype:a,backdrop:o,transferMap:l}=t,h="Luminosity"===a||"Alpha"===a&&l;if(!h&&!("Luminosity"===a&&o)){this.smaskPreparedFor=t;return}if("Luminosity"===a&&o){let[t,i,s]=tl(o),r=Math.round(.3*t+.59*i+.11*s);e=l?.[r]??r}else e=l?.[0]??0;let{width:d,height:c}=this.ctx.canvas,u=d*c<4*(n.width*n.height),p=h?{url:"Alpha"===a?this.filterFactory.addAlphaFilter(l):this.filterFactory.addLuminosityFilter(l),subtype:a,transferMap:l}:null,g="Luminosity"===a?o:null;u?(i=this._bakeSMaskCanvas(n,t.offsetX,t.offsetY,d,c,g,p),s=0,r=0):(i=this._bakeSMaskCanvas(n,0,0,n.width,n.height,g,p),s=t.offsetX,r=t.offsetY),this.smaskPreparedEntry=i,this.smaskPreparedFor=t,this.smaskPreparedOffsetX=s,this.smaskPreparedOffsetY=r,this.smaskPreparedOOBAlpha=u||0===e?null:e}_bakeSMaskCanvas(t,e,i,s,r,n,a){n||a||C("_bakeSMaskCanvas with neither backdrop nor filter");let o=this.canvasFactory.create(s,r),l=o.context;if(l.drawImage(t,e,i),n&&(l.globalCompositeOperation="destination-atop",l.fillStyle=n,l.fillRect(0,0,s,r)),!a)return o;let h=this.canvasFactory.create(s,r),d=h.context;d.filter=a.url;let c=O.isCanvasFilterSupported&&"none"!==d.filter&&""!==d.filter;if(d.drawImage(o.canvas,0,0),O.isCanvasFilterSupported&&(d.filter="none"),!c){let t=d.getImageData(0,0,s,r),{data:e}=t,{transferMap:i}=a;if("Luminosity"===a.subtype)for(let t=0,s=e.length;t<s;t+=4){let s=.3*e[t]+.59*e[t+1]+.11*e[t+2]+.5|0;e[t]=e[t+1]=e[t+2]=0,e[t+3]=i?.[s]??s}else for(let t=3,s=e.length;t<s;t+=4)e[t]=i[e[t]];d.putImageData(t,0,0)}return this.canvasFactory.destroy(o),h}beginSMaskMode(t){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let{width:e,height:i}=this.ctx.canvas,s=this.canvasFactory.create(e,i);this.smaskScratchCanvas=s,this.suspendedCtx=this.ctx;let r=this.ctx=s.context;r.setTransform(this.suspendedCtx.getTransform()),eX(this.suspendedCtx,r),e$(r,this.suspendedCtx),this._ensurePreparedSMask(this.current.activeSMask),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),eX(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null,this.canvasFactory.destroy(this.smaskScratchCanvas),this.smaskScratchCanvas=null,this._clearPreparedSMask()}#sD(t,e=null,i=1){let{width:s,height:r}=t,n=e??this.canvasFactory.create(s,r),a=n.context,o=(i=Math.round(255*i)/255)<1;o&&void 0===this.#sE&&(this.#sE=O.isCanvasFilterSupported?new Map:"none");let l="none";if(o&&this.#sE instanceof Map&&(l=this.#sE.getOrInsertComputed(i,()=>this.filterFactory.addKnockoutFilter(i))),!o||"none"!==l)return e&&(a.save(),a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,s,r),a.restore()),a.filter=l,a.drawImage(t,0,0),a.filter="none",n;let h=t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,s,r),d=a.createImageData(s,r),c=h.data,u=d.data,p=i>0?1/i:1e6;for(let t=3,e=c.length;t<e;t+=4)u[t]=Math.min(Math.round(c[t]*p),255);return a.putImageData(d,0,0),n}#sI(t,e,i,s){let r=t?.[e]??null;if(r&&(r.canvas.width!==i||r.canvas.height!==s)&&(this.canvasFactory.destroy(r),r=null),!r)return r=this.canvasFactory.create(i,s),t&&(t[e]=r),r;let n=r.context;return n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,i,s),n.restore(),r}#sF(t,e,i={}){let{backdropCanvas:s=null,destTransform:r=[1,0,0,1,0,0],backdropOffset:n=[0,0],reuseMaskEntry:a=null,poolMeta:o=null,sourceAlpha:l=1,sourceFilter:h="none",knockoutAlpha:d=1}=i,{width:c,height:u}=e,p=this.#sD(e,a,d),g=t.globalCompositeOperation;if(t.save(),t.setTransform(...r),t.globalAlpha=1,O.isCanvasFilterSupported&&(t.filter="none"),t.globalCompositeOperation="destination-out",t.drawImage(p.canvas,0,0),s){let[e,i]=n,r=this.#sI(o,"knockoutBackdropEntry",c,u),a=r.context;a.drawImage(s,e,i,c,u,0,0,c,u),a.globalCompositeOperation="destination-in",a.drawImage(p.canvas,0,0),a.globalCompositeOperation="source-over",t.globalCompositeOperation="destination-over",t.drawImage(r.canvas,0,0),o||this.canvasFactory.destroy(r)}t.globalCompositeOperation=g,t.globalAlpha=l,O.isCanvasFilterSupported&&(t.filter=h??"none"),t.drawImage(e,0,0),t.restore(),a||this.canvasFactory.destroy(p)}#sB(t=1){if(0===this.#sy||this.#sv>0||!this.contentVisible)return!1;this.#sv++,this.#sS=t;let e=this.#s_.at(-1),{canvas:i}=this.ctx,s=this.#sI(e,"knockoutTempEntry",i.width,i.height);this.#sA=s;let r=s.context;return r.save(),r.setTransform(this.ctx.getTransform()),eX(this.ctx,r),this.#sC=r.globalCompositeOperation,r.globalCompositeOperation="source-over",e$(r,this.ctx),this.#sT=e,this.#sx=this.ctx,this.#sw=this.suspendedCtx,this.ctx=r,this.inSMaskMode&&(this.suspendedCtx=r),!0}#sL(t){if(!t)return;let e=this.#sA,i=this.#sx,s=this.#sw,r=e.context;this.#sA=null,this.#sx=null,this.#sw=null,this.inSMaskMode&&this.suspendedCtx===r&&this.ctx!==r&&this.endSMaskMode(),this.inSMaskMode&&(this.suspendedCtx=s),this.ctx._removeMirroring(),this.ctx.globalCompositeOperation=this.#sC,this.#sC=null,eX(this.ctx,i),this.ctx=i;let n=this.#sT;this.#sT=null;let a=this.#sS;this.#sS=1;try{this.#sF(s??i,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.#sv--,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];let e=this.current.activeSMask,i=this.suspendedCtx,s=this.#sv>0&&i===this.ctx;this.composeSMask(s?null:i,e,this.ctx,t),s||(this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore())}composeSMask(t,e,i,s){let r=s[0],n=s[1],a=s[2]-r,o=s[3]-n;if(0===a||0===o)return;let l=this.smaskPreparedEntry;if(l){let t=r,s=n,h=a,d=o,c=this.smaskPreparedOOBAlpha,u=null!==c;if(u){t=Math.max(r,e.offsetX),s=Math.max(n,e.offsetY);let i=Math.min(r+a,e.offsetX+e.canvas.width),l=Math.min(n+o,e.offsetY+e.canvas.height);h=i-t,d=l-s}if(h>0&&d>0){let e=t-this.smaskPreparedOffsetX,r=s-this.smaskPreparedOffsetY;i.save(),i.globalAlpha=1,i.setTransform(1,0,0,1,0,0);let n=new Path2D;n.rect(t,s,h,d),i.clip(n),i.globalCompositeOperation="destination-in",i.drawImage(l.canvas,e,r,h,d,t,s,h,d),i.restore()}u&&c<255&&this._applySMaskOOBAlpha(i,r,n,a,o,t,s,t+h,s+d,c)}else this.genericComposeSMask(e,i,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(i.canvas,r,n,a,o,r,n,a,o),t.restore())}_applySMaskOOBAlpha(t,e,i,s,r,n,a,o,l,h){let d=n<o&&a<l;if(d&&n===e&&a===i&&o===e+s&&l===i+r)return;let c=new Path2D;c.rect(e,i,s,r),d&&c.rect(n,a,o-n,l-a),t.save(),t.globalAlpha=h/255,t.setTransform(1,0,0,1,0,0),t.clip(c,"evenodd"),t.globalCompositeOperation="destination-in",t.fillStyle="#000000",t.fillRect(e,i,s,r),t.restore()}genericComposeSMask(t,e,i,s,r,n){let{context:a,offsetX:o,offsetY:l}=t;e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);let h=new Path2D;h.rect(r,n,i,s),e.clip(h),e.globalCompositeOperation="destination-in",e.drawImage(a.canvas,r-o,n-l,i,s,r,n,i,s),e.restore()}save(t){this.inSMaskMode&&eX(this.ctx,this.suspendedCtx),this.ctx.save();let e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){if(this.dependencyTracker?.restore(t),0===this.stateStack.length){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&(eX(this.suspendedCtx,this.ctx),this.ctx.setTransform(this.suspendedCtx.getTransform())),this.checkSMaskState(t),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,i,s,r,n,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,i,s,r,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,s){let[r]=i;if(!s){r||=i[0]=new Path2D,e!==y.stroke&&e!==y.closeStroke&&(this.current.tilingPatternDims=null),this[e](t,r);return}if(null!==this.dependencyTracker){let i=e===y.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,s[0]-i,s[2]+i,s[1]-i,s[3]+i).recordDependencies(t,["transform"])}r instanceof Path2D||(r=i[0]=tE(r)),N.axialAlignedBoundingBox(s,td(this.ctx),this.current.minMax);let n=this.current.tilingPatternDims;if(n&&e!==y.stroke&&e!==y.closeStroke&&this.current.fillColor instanceof eH){let t=N.intersect(this.current.clipBox,this.current.minMax);t?this.current.fillColor.updatePatternDims(t,n):this.current.tilingPatternDims=null}this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){let s=i&&this.#sB(this.current.strokeAlpha),r=this.ctx,n=this.current.strokeColor;if(r.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof n&&n?.getPattern){let i=n.isModifyingCurrentTransform()?r.getTransform():null;if(r.save(),r.strokeStyle=n.getPattern(r,this,tc(r),eF,t),i){let t=new Path2D;t.addPath(e,r.getTransform().invertSelf().multiplySelf(i)),e=t}this.rescaleAndStroke(e,!1),r.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,t2),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(eF,td(this.ctx))),r.globalAlpha=this.current.fillAlpha,this.#sL(s)}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){let s=i&&this.#sB(this.current.fillAlpha),r=this.ctx,n=this.current.fillColor,a=this.current.patternFill,o=!1,l=this.current.getClippedPathBoundingBox();if(this.dependencyTracker?.recordDependencies(t,t3),a){let a=this.current.tilingPatternDims,h=a&&n.canSkipPatternCanvas(a);if(h){n.drawPattern(this,e,this.pendingEOFill,h,t),this.pendingEOFill=!1,i&&this.consumePath(t,e,l),this.current.tilingPatternDims=null,this.#sL(s);return}let d=n.isModifyingCurrentTransform()?r.getTransform():null;if(this.dependencyTracker?.save(t),r.save(),r.fillStyle=n.getPattern(r,this,tc(r),eI,t),d){let t=new Path2D;t.addPath(e,r.getTransform().invertSelf().multiplySelf(d)),e=t}o=!0}this.contentVisible&&null!==l&&(this.pendingEOFill?(r.fill(e,"evenodd"),this.pendingEOFill=!1):r.fill(e)),o&&(r.restore(),this.dependencyTracker?.restore(t)),i&&this.consumePath(t,e,l),this.#sL(s)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){let i=this.#sB(Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e),this.#sL(i)}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){let i=this.#sB(this.current.fillAlpha);this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,t6).recordOperation(t),this.#sL(i)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=eZ}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=e0}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){let e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){let{dependencyTracker:i}=this;void 0!==e&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(void 0!==e){let t=new Path2D,s=i.getTransform().invertSelf();for(let{transform:i,x:r,y:n,fontSize:a,path:o}of e)o&&t.addPath(o,new DOMMatrix(i).preMultiplySelf(s).translate(r,n).scale(a,-a));i.clip(t)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);let s=this.commonObjs.get(e),r=this.current;if(!s)throw Error(`Can't find font for ${e}`);if(r.fontMatrix=s.fontMatrix||o,(0===r.fontMatrix[0]||0===r.fontMatrix[3])&&w("Invalid font matrix for font "+e),i<0?(i=-i,r.fontDirection=-1):r.fontDirection=1,this.current.font=s,this.current.fontSize=i,s.isType3Font)return;let n=s.loadedName||"sans-serif",a=s.systemFontInfo?.css||`"${n}", ${s.fallbackName}`,l="normal";s.black?l="900":s.bold&&(l="bold");let h=s.italic?"italic":"normal",d=W(i,16,100);this.current.fontSizeScale=i/d,this.ctx.font=`${h} ${l} ${d}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,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);let{current:i}=this;i.textMatrix=e,i.textMatrixScale=Math.hypot(e[0],e[1]),i.x=i.lineX=0,i.y=i.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#sR(t,e,i){let s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}paintChar(t,e,i,s,r,n){let a,o=this.ctx,l=this.current,h=l.font,d=l.textRenderingMode,c=l.fontSize/l.fontSizeScale,u=3&d,p=!!(4&d),g=l.patternFill&&!h.missingFile,m=l.patternStroke&&!h.missingFile;if((h.disableFontFace||p||g||m)&&!h.missingFile&&(a=h.getPathGenerator(this.commonObjs,e)),a&&(h.disableFontFace||g||m)){let e;if(o.save(),o.translate(i,s),o.scale(c,-c),this.dependencyTracker?.recordCharacterBBox(t,o,h),0===u||2===u)if(r){e=o.getTransform(),o.setTransform(...r);let t=this.#sR(a,e,r);o.fill(t)}else o.fill(a);if(1===u||2===u)if(n){e||=o.getTransform(),o.setTransform(...n);let{a:t,b:i,c:s,d:r}=e,l=N.inverseTransform(n),h=N.transform([t,i,s,r,0,0],l);N.singularValueDecompose2dScale(h,eG),o.lineWidth*=Math.max(eG[0],eG[1])/c,o.stroke(this.#sR(a,e,n))}else o.lineWidth/=c,o.stroke(a);o.restore()}else(0===u||2===u)&&(o.fillText(e,i,s),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s,()=>o.measureText(e))),(1===u||2===u)&&(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s,()=>o.measureText(e)).recordDependencies(t,t2),o.strokeText(e,i,s));p&&((this.pendingTextPaths||=[]).push({transform:td(o),x:i,y:s,fontSize:c,path:a}),this.dependencyTracker?.recordCharacterBBox(t,o,h,c,i,s))}get isFontSubpixelAAEnabled(){let t=this.canvasFactory.create(10,10),e=t.context;e.scale(1.5,1),e.fillText("I",0,10);let i=e.getImageData(0,0,10,10).data;this.canvasFactory.destroy(t);let s=!1;for(let t=3;t<i.length;t+=4)if(i[t]>0&&i[t]<255){s=!0;break}return k(this,"isFontSubpixelAAEnabled",s)}showText(t,e){let i,s;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,t4).resetBBox(t),4&this.current.textRenderingMode&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());let r=this.current,n=r.font;if(n.isType3Font){let i=this.#sB(r.fillAlpha);this.showType3Text(t,e),this.dependencyTracker?.recordShowTextOperation(t),this.#sL(i);return}let a=r.fontSize;if(0===a)return void this.dependencyTracker?.recordOperation(t);let o=this.#sB(r.fillAlpha),l=this.ctx,h=r.fontSizeScale,d=r.charSpacing,c=r.wordSpacing,u=r.fontDirection,p=r.textHScale*u,g=e.length,m=n.vertical,f=m?1:-1,b=n.defaultVMetrics,y=a*r.fontMatrix[0],v=0===r.textRenderingMode&&!n.disableFontFace&&!r.patternFill;l.save(),r.textMatrix&&l.transform(...r.textMatrix),l.translate(r.x,r.y+r.textRise),u>0?l.scale(p,-1):l.scale(p,1);let A=3&r.textRenderingMode,x=1===A||2===A,w=r.lineWidth,C=r.textMatrixScale;if(0===C||0===w?x&&(w=this.getSinglePixelWidth()):w/=C,1!==h&&(l.scale(h,h),w/=h),l.lineWidth=w,(0===A||2===A)&&r.patternFill){l.save();let e=r.fillColor.getPattern(l,this,tc(l),eI,t);i=td(l),l.restore(),l.fillStyle=e}if(x&&r.patternStroke){l.save();let e=r.strokeColor.getPattern(l,this,tc(l),eF,t);s=td(l),l.restore(),l.strokeStyle=e}if(n.isInvalidPDFjsFont){let i=[],s=0;for(let t of e)i.push(t.unicode),s+=t.width;let n=i.join("");if(l.fillText(n,0,0),null!==this.dependencyTracker){let e=l.measureText(n);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}r.x+=s*y*p,l.restore(),this.compose(),this.#sL(o);return}let S=0,E;for(E=0;E<g;++E){let r,o,p,g=e[E];if("number"==typeof g){S+=f*g*a/1e3;continue}let A=!1,x=(g.isSpace?c:0)+d,w=g.fontChar,C=g.accent,T=g.width;if(m){let t=g.vmetric||b,e=-(g.vmetric?t[1]:.5*T)*y,i=t[2]*y;T=t?-t[0]:T,r=e/h,o=(S+i)/h}else r=S/h,o=0;if(n.remeasure&&T>0){let t=1e3*(p=l.measureText(w)).width/a*h;if(T<t&&this.isFontSubpixelAAEnabled){let e=T/t;A=!0,l.save(),l.scale(e,1),r/=e}else T!==t&&(r+=(T-t)/2e3*a/h)}if(this.contentVisible&&(g.isInFont||n.missingFile)){if(v&&!C)l.fillText(w,r,o),this.dependencyTracker?.recordCharacterBBox(t,l,p?{bbox:null}:n,a/h,r,o,()=>p??l.measureText(w));else if(this.paintChar(t,w,r,o,i,s),C){let e=r+a*C.offset.x/h,n=o-a*C.offset.y/h;this.paintChar(t,C.fontChar,e,n,i,s)}}S+=m?T*y-x*u:T*y+x*u,A&&l.restore()}m?r.y-=S:r.x+=S*p,l.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t),this.#sL(o)}showType3Text(t,e){let i,s,r,n,a=this.ctx,l=this.current,h=l.font,d=l.fontSize,c=l.fontDirection,u=h.vertical?1:-1,p=l.charSpacing,g=l.wordSpacing,m=l.textHScale*c,f=l.fontMatrix||o,b=e.length;if(3===l.textRenderingMode||0===d)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,a.save(),l.textMatrix&&a.transform(...l.textMatrix),a.translate(l.x,l.y+l.textRise),a.scale(m,c);let v=this.dependencyTracker;for(i=0,this.dependencyTracker=v?new t1(v,t):null;i<b;++i){if("number"==typeof(s=e[i])){n=u*s*d/1e3,this.ctx.translate(n,0),l.x+=n*m;continue}let t=(s.isSpace?g:0)+p,o=h.charProcOperatorList[s.operatorListId];o?this.contentVisible&&(this.save(),o.fnArray[0]===y.setCharWidth&&(l.fillAlpha=l.strokeAlpha=1,a.globalAlpha=1),a.scale(d,d),a.transform(...f),this.executeOperatorList(o),this.restore()):w(`Type3 character "${s.operatorListId}" is not available.`);let c=[s.width,0];N.applyTransform(c,f),r=c[0]*d+t,a.translate(r,0),l.x+=r*m}a.restore(),v&&(this.dependencyTracker=v)}setCharWidth(t,e,i){}setCharWidthAndBounds(t,e,i,s,r,n,a){let o=new Path2D;o.rect(s,r,n-s,a-r),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,s,n,r,a).recordClipBox(t,this.ctx,s,n,r,a),this.endPath(t)}getColorN_Pattern(t,e){let i;if("TilingPattern"===e[0]){let t=this.baseTransform||td(this.ctx);i=new eH(e,this.ctx,{createCanvasGraphics:(t,e)=>new e1(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new t1(this.dependencyTracker,e,!0):null)},t)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t);let i=this.current.fillColor=this.getColorN_Pattern(t,e);this.current.patternFill=!0,this.current.tilingPatternDims=i instanceof eH?[0,0,0,0]:null}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1,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,i=null){let s;return this.cachedPatterns.has(e)?s=this.cachedPatterns.get(e):(s=function(t){switch(t[0]){case"RadialAxial":return new eO(t);case"Mesh":return new eN(t);case"Dummy":return new eU}throw Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e)),this.cachedPatterns.set(e,s)),i&&(s.matrix=i),s}shadingFill(t,e){if(!this.contentVisible)return;let i=this.#sB(this.current.fillAlpha),s=this.ctx;this.save(t),s.fillStyle=this._getPattern(t,e).getPattern(s,this,tc(s),eB,t);let r=tc(s);{let{width:t,height:e}=s.canvas,i=a.slice();N.axialAlignedBoundingBox([0,0,t,e],r,i);let[n,o,l,h]=i;this.ctx.fillRect(n,o,l-n,h-o)}this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,t8).recordDependencies(t,t3).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t),this.#sL(i)}beginInlineImage(){C("Should not call beginInlineImage")}beginImageData(){C("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=td(this.ctx),i)){N.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);let[e,s,r,n]=i,a=new Path2D;a.rect(e,s,r-e,n-s),this.ctx.clip(a),this.dependencyTracker?.recordClipBox(t,this.ctx,e,r,s,n),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){let i;if(!this.contentVisible)return;this.save(t);let{inSMaskMode:s}=this;s&&(this.endSMaskMode(),this.current.activeSMask=null);let r=this.ctx;if((!e.needsIsolation||!e.isolated&&!e.hasSoftMask)&&!e.knockout&&!e.isGray&&0===this.#sy&&1===r.globalAlpha&&"source-over"===r.globalCompositeOperation&&!s){if(e.bbox){let t=new Path2D,[i,s,n,a]=e.bbox;if(t.rect(i,s,n-i,a-s),e.matrix){let i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix)),t=i}r.clip(t)}this.groupStack.push(null),this.#s_.push(null),this.groupLevel++;return}e.isolated||e.knockout||0!==this.#sy||x("TODO: Fully support non-isolated non-knockout groups.");let n=td(r);e.matrix&&r.transform(...e.matrix);let o=[0,0,r.canvas.width,r.canvas.height];e.bbox?(i=a.slice(),N.axialAlignedBoundingBox(e.bbox,td(r),i),i=N.intersect(i,o)||[0,0,0,0]):i=o;let l=Math.floor(i[0]),h=Math.floor(i[1]),d=Math.max(Math.ceil(i[2])-l,1),c=Math.max(Math.ceil(i[3])-h,1);this.current.startNewPathAndClipBox([0,0,d,c]);let u=this.canvasFactory.create(d,c);e.smask&&this.smaskGroupCanvases.push(u);let p=u.context,g=e.knockout&&!e.isolated?r:null,m=!e.isolated&&!e.knockout&&!e.smask&&e.needsIsolation&&this.#sy>0,f=e.knockout?this.canvasFactory.create(d,c):null,b=this.#sy;if(e.knockout?this.#sy++:this.#sy=0,p.translate(-l,-h),p.transform(...n),!e.isolated&&!e.smask&&s&&e.needsIsolation&&(p.save(),p.setTransform(1,0,0,1,0,0),p.drawImage(r.canvas,-l,-h),p.restore()),e.bbox){let t=new Path2D,[i,s,r,n]=e.bbox;if(t.rect(i,s,r-i,n-s),e.matrix){let i=new Path2D;i.addPath(t,new DOMMatrix(e.matrix)),t=i}p.clip(t)}e.smask&&this.smaskStack.push({canvas:u.canvas,context:p,offsetX:l,offsetY:h,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null}),(!e.smask||this.dependencyTracker)&&(r.setTransform(1,0,0,1,0,0),r.translate(l,h),r.save()),eX(r,p),this.ctx=p,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(r),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]),this.groupStack.push(r),this.#s_.push({backdropCtx:g,savedKnockoutLevel:b,offsetX:l,offsetY:h,hasInnerBackdrop:m,knockoutMaskEntry:f,knockoutTempEntry:null,knockoutBackdropEntry:null}),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;let i=this.ctx,s=this.groupStack.pop(),r=this.#s_.pop();if(r&&(this.#sy=r.savedKnockoutLevel),null===s)return void this.restore(t);if(e.isGray&&this.#sO(i),this.ctx=s,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&(this.ctx.restore(),this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())),this.#sM(r);else{this.ctx.restore();let e=td(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);let n=a.slice();N.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],e,n);let o=this.#s_.at(-1);if(this.#sy>0)if(r.hasInnerBackdrop){let{width:t,height:n}=i.canvas,a=this.canvasFactory.create(t,n),o=a.context;o.drawImage(s.canvas,r.offsetX,r.offsetY,t,n,0,0,t,n),o.globalCompositeOperation="source-over",o.drawImage(i.canvas,0,0);let l=this.#sD(i.canvas);o.globalCompositeOperation="destination-in",o.drawImage(l.canvas,0,0);let h=this.ctx.globalCompositeOperation,d=this.ctx.globalAlpha,c=this.ctx.filter;this.ctx.save(),this.ctx.setTransform(...e),this.ctx.globalAlpha=1,O.isCanvasFilterSupported&&(this.ctx.filter="none"),this.ctx.globalCompositeOperation="destination-out",this.ctx.drawImage(l.canvas,0,0),this.ctx.globalCompositeOperation=h,this.ctx.globalAlpha=d,O.isCanvasFilterSupported&&(this.ctx.filter=c??"none"),this.ctx.drawImage(a.canvas,0,0),this.ctx.restore(),this.canvasFactory.destroy(l),this.canvasFactory.destroy(a)}else{let t=o?.backdropCtx??null;this.#sF(this.ctx,i.canvas,{backdropCanvas:t?.canvas??null,destTransform:e,backdropOffset:t?[o.offsetX+r.offsetX,o.offsetY+r.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else this.ctx.drawImage(i.canvas,0,0);this.ctx.restore(),this.canvasFactory.destroy({canvas:i.canvas,context:i}),this.#sM(r),this.compose(n)}}#sO(t){let{canvas:e}=t,{width:i,height:s}=e;if(O.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}let r=t.getImageData(0,0,i,s),{data:n}=r;for(let t=0,e=n.length;t<e;t+=4){let e=.2126*n[t]+.7152*n[t+1]+.0722*n[t+2]+.5|0;n[t]=n[t+1]=n[t+2]=e}t.putImageData(r,0,0)}#sM(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,i,s,r,n,a){if(this.#sk(),eq(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){let r=i[2]-i[0],o=i[3]-i[1];if(n&&this.annotationCanvasMap){s=s.slice(),s[4]-=i[0],s[5]-=i[1],(i=i.slice())[0]=i[1]=0,i[2]=r,i[3]=o,N.singularValueDecompose2dScale(td(this.ctx),eG);let{viewportScale:t}=this,n=Math.ceil(r*this.outputScaleX*t),l=Math.ceil(o*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(n,l);let{canvas:h,context:d}=this.annotationCanvas;if(a){let t=this.annotationCanvasMap.getOrInsertComputed(e,$);h.setAttribute("data-canvas-name",a);let i=t.findIndex(t=>t.getAttribute("data-canvas-name")===a);-1===i?t.push(h):t[i]=h}else this.annotationCanvasMap.set(e,h);this.annotationCanvas.savedCtx=this.ctx,this.ctx=d,this.ctx.save(),this.ctx.setTransform(eG[0],0,0,-eG[1],0,o*eG[1]),eq(this.ctx)}else{eq(this.ctx),this.endPath(t);let e=new Path2D;e.rect(i[0],i[1],r,o),this.ctx.clip(e)}}this.current=new eV(this.ctx.canvas.width,this.ctx.canvas.height),this.baseTransformStack.push(this.baseTransform),this.transform(t,...s),this.transform(t,...r),this.baseTransform=td(this.ctx)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#sP(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas),this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(t,e){if(!this.contentVisible)return;let i=e.count;(e=this.getObject(t,e.data,e)).count=i;let s=this.#sB(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.#sL(s)}paintImageMaskXObjectRepeat(t,e,i,s=0,r=0,n,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);let o=this.#sB(this.current.fillAlpha),l=this.ctx;l.save();let h=td(l);l.transform(i,s,r,n,0,0);let d=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,d.offsetX-h[4],d.offsetY-h[5]),this.dependencyTracker?.resetBBox(t);for(let e=0,o=a.length;e<o;e+=2){let o=N.transform(h,[i,s,r,n,a[e],a[e+1]]);l.drawImage(d.canvas,o[4],o[5]),this.dependencyTracker?.recordBBox(t,this.ctx,o[4],o[4]+d.canvas.width,o[5],o[5]+d.canvas.height)}l.restore(),d.canvasEntry&&this.canvasFactory.destroy(d.canvasEntry),this.compose(),this.dependencyTracker?.recordOperation(t),this.#sL(o)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;let i=this.#sB(this.current.fillAlpha),s=this.ctx,r=this.current.fillColor,n=this.current.patternFill;for(let i of(this.dependencyTracker?.resetBBox(t).recordDependencies(t,t7),e)){let{data:e,width:a,height:o,transform:l}=i,h=this.canvasFactory.create(a,o),d=h.context;d.save(),eK(d,this.getObject(t,e,i)),d.globalCompositeOperation="source-in",d.fillStyle=n?r.getPattern(d,this,tc(s),eI,t):r,d.fillRect(0,0,a,o),d.restore(),s.save(),s.transform(...l),s.scale(1,-1),ej(s,h.canvas,0,0,a,o,0,-1,1,1),this.canvasFactory.destroy(h),this.dependencyTracker?.recordBBox(t,s,0,a,0,o),s.restore()}this.compose(),this.dependencyTracker?.recordOperation(t),this.#sL(i)}paintImageXObject(t,e){if(!this.contentVisible)return;let i=this.getObject(t,e);i?this.paintInlineImageXObject(t,i):w("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s,r){if(!this.contentVisible)return;let n=this.getObject(t,e);if(!n)return void w("Dependent image isn't ready yet");let a=n.width,o=n.height,l=[];for(let t=0,e=r.length;t<e;t+=2)l.push({transform:[i,0,0,s,r[t],r[t+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,n,l)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return{img:t.bitmap,canvasEntry:null};let{bitmap:e,width:i,height:s}=t,r=this.canvasFactory.create(i,s),n=r.context;return n.filter=this.current.transferMaps,n.drawImage(e,0,0),n.filter="none",{img:r.canvas,canvasEntry:r}}paintInlineImageXObject(t,e){let i;if(!this.contentVisible)return;let s=e.width,r=e.height,n=this.#sB(this.current.fillAlpha),a=this.ctx;this.save(t);let{filter:o}=a;"none"!==o&&""!==o&&(a.filter="none"),a.scale(1/s,-1/r);let l=null;if(e.bitmap){let t=this.applyTransferMapsToBitmap(e);i=t.img,l=t.canvasEntry}else{let t=this.canvasFactory.create(s,r);eW(t.context,e),i=this.applyTransferMapsToCanvas(t.context),l=t}let h=this._scaleImage(i,tc(a));a.imageSmoothingEnabled=eY(td(a),e.interpolate),this.dependencyTracker&&(this.dependencyTracker.resetBBox(t).recordBBox(t,a,0,s,-r,0).recordDependencies(t,t5).recordOperation(t),this.imagesTracker?.record(a,s,r,this.dependencyTracker.clipBox)),ej(a,h.img,0,0,h.paintWidth,h.paintHeight,0,-r,s,r),h.tmpCanvas&&this.canvasFactory.destroy(h.tmpCanvas),l&&this.canvasFactory.destroy(l),this.compose(),this.restore(t),this.#sL(n)}paintInlineImageXObjectGroup(t,e,i){let s;if(!this.contentVisible)return;let r=this.#sB(this.current.fillAlpha),n=this.ctx,a=null;if(e.bitmap)s=e.bitmap;else{let t=e.width,i=e.height,r=this.canvasFactory.create(t,i);eW(r.context,e),s=this.applyTransferMapsToCanvas(r.context),a=r}for(let e of(this.dependencyTracker?.resetBBox(t),i))n.save(),n.transform(...e.transform),n.scale(1,-1),ej(n,s,e.x,e.y,e.w,e.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,n,0,1,-1,0),n.restore();a&&this.canvasFactory.destroy(a),this.dependencyTracker?.recordOperation(t),this.compose(),this.#sL(r)}paintSolidColorImageMask(t){if(!this.contentVisible)return;let e=this.#sB(this.current.fillAlpha);this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,t3).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose(),this.#sL(e)}markPoint(t,e){}markPointProps(t,e,i){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){this.dependencyTracker?.beginMarkedContent(t),"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){let s=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);let r=this.ctx;this.pendingClip?(s||(this.pendingClip===e0?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(){if(!this._cachedGetSinglePixelWidth){let t=td(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{let e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){let t,e,{lineWidth:i}=this.current,{a:s,b:r,c:n,d:a}=this.ctx.getTransform();if(0===r&&0===n){let r=Math.abs(s),n=Math.abs(a);if(r===n)if(0===i)t=e=1/r;else{let s=r*i;t=e=s<1?1/s:1}else if(0===i)t=1/r,e=1/n;else{let s=r*i,a=n*i;t=s<1?1/s:1,e=a<1?1/a:1}}else{let o=Math.abs(s*a-r*n),l=Math.hypot(s,r),h=Math.hypot(n,a);if(0===i)t=h/o,e=l/o;else{let s=i*o;t=h>s?h/s:1,e=l>s?l/s:1}}this._cachedScaleForStroking[0]=t,this._cachedScaleForStroking[1]=e}return this._cachedScaleForStroking}rescaleAndStroke(t,e){let{ctx:i,current:{lineWidth:s}}=this,[r,n]=this.getScaleForStroking();if(r===n){i.lineWidth=(s||1)*r,i.stroke(t);return}let a=i.getLineDash();e&&i.save(),i.scale(r,n),ez.a=1/r,ez.d=1/n;let o=new Path2D;if(o.addPath(t,ez),a.length>0){let t=Math.max(r,n);i.setLineDash(a.map(e=>e/t)),i.lineDashOffset/=t}i.lineWidth=s||1,i.stroke(o),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(let t in y)void 0!==e1.prototype[t]&&(e1.prototype[y[t]]=e1.prototype[t]);class e2{#sN=null;#sU=null;_fullReader=null;_rangeReaders=new Set;_source=null;constructor(t,e,i){this._source=t,this.#sN=e,this.#sU=i}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){return S(!this._fullReader,"BasePDFStream.getFullReader can only be called once."),this._fullReader=new this.#sN(this)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;let i=new this.#sU(this,t,e);return this._rangeReaders.add(i),i}cancelAllRequests(t){for(let e of(this._fullReader?.cancel(t),new Set(this._rangeReaders)))e.cancel(t)}}class e3{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(){C("Abstract method `read` called")}cancel(t){C("Abstract method `cancel` called")}}class e5{_stream=null;constructor(t,e,i){this._stream=t}async read(){C("Abstract method `read` called")}cancel(t){C("Abstract method `cancel` called")}}function e6(t,e){let i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(let t in e){let s=e[t];void 0!==s&&i.append(t,s)}return i}function e4(t){return URL.parse(t)?.origin??null}function e8({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){let r={contentLength:0,isRangeSupported:!1},n=parseInt(t.get("Content-Length"),10);return Number.isInteger(n)&&(r.contentLength=n,n<=2*i||s||!e||"bytes"!==t.get("Accept-Ranges")||"identity"===(t.get("Content-Encoding")||"identity")&&(r.isRangeSupported=!0)),r}function e7(t){let e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){let t=a(i=i[1]);return n(t=l(t=o(t=unescape(t))))}if(i=function(t){let e,i=[],r=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(e=r.exec(t));){let[,t,s,r]=e;if((t=parseInt(t,10))in i){if(0===t)break;continue}i[t]=[s,r]}let n=[];for(let t=0;t<i.length&&t in i;++t){let[e,s]=i[t];s=a(s),e&&(s=unescape(s),0===t&&(s=o(s))),n.push(s)}return n.join("")}(t))return n(l(i));if(i=s("filename","i").exec(t)){let t=a(i=i[1]);return n(t=l(t))}function s(t,e){return RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function r(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{let s=new TextDecoder(t,{fatal:!0}),r=R(i);i=s.decode(r),e=!1}catch{}}return i}function n(t){return e&&/[\x80-\xff]/.test(t)&&(t=r("utf-8",t),e&&(t=r("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){let e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){let i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){let e=t.indexOf("'");return -1===e?t:r(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(t,e,i,s){if("q"===i||"Q"===i)return r(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-f]{2})/gi,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{s=atob(s)}catch{}return r(e,s)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(tt(t))return t}return null}function e9(t,e){return new F(`Unexpected server response (${t}) while retrieving PDF "${e.href}".`,t,404===t||0===t&&"file:"===e.protocol)}function it(t,e){if(t!==e)throw Error(`Expected range response-origin "${t}" to match "${e}".`)}function ie(t,e,i,s){return fetch(t,{method:"GET",headers:e,signal:s.signal,mode:"cors",credentials:i?"include":"same-origin",redirect:"follow"})}function ii(t,e){if(200!==t&&206!==t)throw e9(t,e)}function is(t){if(t instanceof Uint8Array)return t.buffer;if(t instanceof ArrayBuffer)return t;throw Error(`getArrayBuffer - unexpected data: ${t}`)}class ir extends e2{_responseOrigin=null;constructor(t){super(t,ia,io);const{httpHeaders:e,url:i}=t;S(/https?:/.test(i.protocol),"PDFFetchStream only supports http(s):// URLs."),this.headers=e6(!0,e)}}class ia extends e3{_abortController=new AbortController;_reader=null;constructor(t){super(t);const{disableRange:e,disableStream:i,rangeChunkSize:s,url:r,withCredentials:n}=t._source;this._isStreamingSupported=!i,ie(r,new Headers(t.headers),n,this._abortController).then(i=>{t._responseOrigin=e4(i.url),ii(i.status,r),this._reader=i.body.getReader();let n=i.headers,{contentLength:a,isRangeSupported:o}=e8({responseHeaders:n,isHttp:!0,rangeChunkSize:s,disableRange:e});this._contentLength=a,this._isRangeSupported=o,this._filename=e7(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new L("Streaming is disabled.")),this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:is(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class io extends e5{_abortController=new AbortController;_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const{url:s,withCredentials:r}=t._source,n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`),ie(s,n,r,this._abortController).then(e=>{it(e4(e.url),t._responseOrigin),ii(e.status,s),this._reader=e.body.getReader(),this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:is(t),done:!1}}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}function il(t){return t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer}function ih(){for(let t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}class id extends e2{_progressiveDone=!1;_queuedChunks=[];constructor(t){super(t,ic,iu);const{pdfDataRangeTransport:e}=t,{initialData:i,progressiveDone:s}=e;if(i?.length>0){const t=il(i);this._queuedChunks.push(t)}this._progressiveDone=s;const r=t=>{switch(t.type){case"range":case"progressiveRead":this.#sH(t.begin,t.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone(),this._progressiveDone=!0}};e.transportReady(r)}#sH(t,e){let i=il(e);if(void 0===t)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{let e=this._rangeReaders.keys().find(e=>e._begin===t);S(e,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found."),e._enqueue(i)}}getFullReader(){let t=super.getFullReader();return this._queuedChunks=null,t}getRangeReader(t,e){let i=super.getRangeReader(t,e);return i&&(i.onDone=()=>this._rangeReaders.delete(i),this._source.pdfDataRangeTransport.requestDataRange(t,e)),i}cancelAllRequests(t){super.cancelAllRequests(t),this._source.pdfDataRangeTransport.abort()}}class ic extends e3{#sz=ih.bind(this);_done=!1;_queuedChunks=null;_requests=[];constructor(t){super(t);const{pdfDataRangeTransport:e,disableRange:i,disableStream:s}=t._source,{length:r,contentDispositionFilename:n}=e;for(const e of(this._queuedChunks=t._queuedChunks||[],this._queuedChunks))this._loaded+=e.byteLength;this._done=t._progressiveDone,this._contentLength=r,this._isStreamingSupported=!s,this._isRangeSupported=!i,tt(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};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#sz()}progressiveDone(){this._done||=!0,0===this._queuedChunks.length&&this.#sz()}}class iu extends e5{#sz=ih.bind(this);onDone=null;_begin=-1;_done=!1;_queuedChunk=null;_requests=[];constructor(t,e,i){super(t,e,i),this._begin=e}_enqueue(t){this._done||(0===this._requests.length?this._queuedChunk=t:(this._requests.shift().resolve({value:t,done:!1}),this.#sz()),this._done=!0,this.onDone?.())}async read(){if(this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#sz(),this.onDone?.()}}class ip extends e2{#sG=new WeakMap;_responseOrigin=null;constructor(t){super(t,ig,im);const{httpHeaders:e,url:i}=t;this.url=i,this.isHttp=/https?:/.test(i.protocol),this.headers=e6(this.isHttp,e)}_request(t){let e=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:t.onHeadersReceived,onDone:t.onDone,onError:t.onError,onProgress:t.onProgress};for(let[t,s]of(this.#sG.set(e,i),e.open("GET",this.url),e.withCredentials=this._source.withCredentials,this.headers))e.setRequestHeader(t,s);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.validateStatus=t=>206===t||200===t):i.validateStatus=t=>200===t,e.responseType="arraybuffer",S(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>t.onError(e.status),e.onreadystatechange=this.#s$.bind(this,e),e.onprogress=this.#sj.bind(this,e),e.send(null),e}#sj(t,e){let i=this.#sG.get(t);i?.onProgress?.(e)}#s$(t,e){var i;let s=this.#sG.get(t);if(!s||(t.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),4!==t.readyState||!this.#sG.has(t)))return;if(this.#sG.delete(t),0===t.status&&this.isHttp)return void s.onError(t.status);let r=t.status||200;if(!s.validateStatus(r))return void s.onError(t.status);let n="string"!=typeof(i=t.response)?i:R(i).buffer;if(206===r){let e=t.getResponseHeader("Content-Range");/bytes \d+-\d+\/\d+/.test(e)?s.onDone(n):(w('Missing or invalid "Content-Range" header.'),s.onError(0))}else n?s.onDone(n):s.onError(t.status)}_abortRequest(t){this.#sG.has(t)&&(this.#sG.delete(t),t.abort())}getRangeReader(t,e){let i=super.getRangeReader(t,e);return i&&(i.onClosed=()=>this._rangeReaders.delete(i)),i}}class ig extends e3{#sz=ih.bind(this);_cachedChunks=[];_done=!1;_requests=[];_storedError=null;constructor(t){super(t),this._fullRequestXhr=t._request({onHeadersReceived:this.#sV.bind(this),onDone:this.#sW.bind(this),onError:this.#sK.bind(this),onProgress:this.#sj.bind(this)})}#sV(){let t=this._stream,{disableRange:e,rangeChunkSize:i}=t._source,s=this._fullRequestXhr;t._responseOrigin=e4(s.responseURL);let r=s.getAllResponseHeaders(),n=new Headers(r?r.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{let[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{contentLength:a,isRangeSupported:o}=e8({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:i,disableRange:e});this._contentLength=a,this._isRangeSupported=o,this._filename=e7(n),this._isRangeSupported&&t._abortRequest(s),this._headersCapability.resolve()}#sW(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._cachedChunks.push(t),this._done=!0,0===this._cachedChunks.length&&this.#sz()}#sK(t){for(let e of(this._storedError=e9(t,this._stream.url),this._headersCapability.reject(this._storedError),this._requests))e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}#sj(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t),this.#sz(),this._stream._abortRequest(this._fullRequestXhr),this._fullRequestXhr=null}}class im extends e5{#sz=ih.bind(this);onClosed=null;_done=!1;_queuedChunk=null;_requests=[];_storedError=null;constructor(t,e,i){super(t,e,i),this._requestXhr=t._request({begin:e,end:i,onHeadersReceived:this.#sV.bind(this),onDone:this.#sW.bind(this),onError:this.#sK.bind(this),onProgress:null})}#sV(){let t=e4(this._requestXhr?.responseURL);try{it(t,this._stream._responseOrigin)}catch(t){this._storedError=t,this.#sK(0)}}#sW(t){this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0,this.#sz(),this.onClosed?.()}#sK(t){for(let e of(this._storedError??=e9(t,this._stream.url),this._requests))e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){let t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};let t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this.#sz(),this._stream._abortRequest(this._requestXhr),this.onClosed?.()}}function ib(t,i=null){let s=e.default.getBuiltinModule("fs"),{Readable:r}=e.default.getBuiltinModule("stream"),n=s.createReadStream(t,i);return r.toWeb(n)}class iy extends e2{constructor(t){super(t,iv,iA);const{url:e}=t;S("file:"===e.protocol,"PDFNodeStream only supports file:// URLs.")}}class iv extends e3{_reader=null;constructor(t){super(t);const{disableRange:i,disableStream:s,rangeChunkSize:r,url:n}=t._source;this._isStreamingSupported=!s,e.default.getBuiltinModule("fs/promises").lstat(n).then(t=>{let e=ib(n);this._reader=e.getReader();let{size:s}=t;this._contentLength=s,this._isRangeSupported=!i&&s>2*r,!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new L("Streaming is disabled.")),this._headersCapability.resolve()}).catch(t=>{"ENOENT"===t.code&&(t=e9(0,n)),this._headersCapability.reject(t)})}async read(){await this._headersCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this._callOnProgress(),{value:is(t),done:!1})}cancel(t){this._reader?.cancel(t)}}class iA extends e5{_readCapability=Promise.withResolvers();_reader=null;constructor(t,e,i){super(t,e,i);const{url:s}=t._source;try{const t=ib(s,{start:e,end:i-1});this._reader=t.getReader(),this._readCapability.resolve()}catch(t){this._readCapability.reject(t)}}async read(){await this._readCapability.promise;let{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:{value:is(t),done:!1}}cancel(t){this._reader?.cancel(t)}}class ix{static #sX=null;static #sq="";static get workerPort(){return this.#sX}static set workerPort(t){if(!("u">typeof Worker&&t instanceof Worker)&&null!==t)throw Error("Invalid `workerPort` type.");this.#sX=t}static get workerSrc(){return this.#sq}static set workerSrc(t){if("string"!=typeof t)throw Error("Invalid `workerSrc` type.");this.#sq=t}}class iw{#sY;#sQ;constructor({parsedData:t,rawData:e}){this.#sY=t,this.#sQ=e}getRaw(){return this.#sQ}get(t){return this.#sY.get(t)??null}[Symbol.iterator](){return this.#sY.entries()}}let iC=Symbol("INTERNAL");class iS{#sJ=!1;#sZ=!1;#s0=!1;#s1=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:r}){this.#sJ=!!(2&t),this.#sZ=!!(4&t),this.name=e,this.intent=i,this.usage=s,this.rbGroups=r}get visible(){if(this.#s0)return this.#s1;if(!this.#s1)return!1;let{print:t,view:e}=this.usage;return this.#sJ?e?.viewState!=="OFF":!this.#sZ||t?.printState!=="OFF"}_setVisible(t,e,i=!1){t!==iC&&C("Internal method `_setVisible` called."),this.#s0=i,this.#s1=e}get serializable(){return{userSet:this.#s0,visible:this.#s1}}}class iE{#s2=null;#s3=new Map;#s5=null;#s6=null;#s4;creator=null;name=null;constructor(t,e=2,i=null){if(this.#s4=t,this.renderingIntent=e,null===t)return;for(const i of(this.name=t.name,this.creator=t.creator,this.#s6=t.order,t.groups))this.#s3.set(i.id,new iS(e,i));if(i)for(const[t,e]of(i.size!==this.#s3.size&&C("Incorrect serialized groupState."),i))this.#s3.get(t)._setVisible(iC,e.visible,e.userSet);else{if("OFF"===t.baseState)for(const t of this.#s3.values())t._setVisible(iC,!1);for(const e of t.on)this.#s3.get(e)._setVisible(iC,!0);for(const e of t.off)this.#s3.get(e)._setVisible(iC,!1)}this.#s5=this.getHash()}#s8(t){let e=t.length;if(e<2)return!0;let i=t[0];for(let s=1;s<e;s++){let e,r=t[s];if(Array.isArray(r))e=this.#s8(r);else{if(!this.#s3.has(r))return w(`Optional content group not found: ${r}`),!0;e=this.#s3.get(r).visible}switch(i){case"And":if(!e)return!1;break;case"Or":if(e)return!0;break;case"Not":return!e;default:return!0}}return"And"===i}isVisible(t){if(0===this.#s3.size)return!0;if(!t)return x("Optional content group not defined."),!0;if("OCG"===t.type)return this.#s3.has(t.id)?this.#s3.get(t.id).visible:(w(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#s8(t.expression);if(t.policy&&"AnyOn"!==t.policy){if("AllOn"===t.policy){for(let e of t.ids){if(!this.#s3.has(e)){w(`Optional content group not found: ${e}`);break}if(!this.#s3.get(e).visible)return!1}return!0}else if("AnyOff"===t.policy){for(let e of t.ids){if(!this.#s3.has(e))return w(`Optional content group not found: ${e}`),!0;if(!this.#s3.get(e).visible)return!0}return!1}else if("AllOff"===t.policy){for(let e of t.ids){if(!this.#s3.has(e)){w(`Optional content group not found: ${e}`);break}if(this.#s3.get(e).visible)return!1}return!0}}else{for(let e of t.ids){if(!this.#s3.has(e))return w(`Optional content group not found: ${e}`),!0;if(this.#s3.get(e).visible)return!0}return!1}return w(`Unknown optional content policy ${t.policy}.`),!0}return w(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){let s=this.#s3.get(t);if(!s)return void w(`Optional content group not found: ${t}`);if(i&&e&&s.rbGroups.length)for(let e of s.rbGroups)for(let i of e)i!==t&&this.#s3.get(i)?._setVisible(iC,!1,!0);s._setVisible(iC,!!e,!0),this.#s2=null}setOCGState({state:t,preserveRB:e}){let i;for(let s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}let t=this.#s3.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#s2=null}get hasInitialVisibility(){return null===this.#s5||this.getHash()===this.#s5}getOrder(){return this.#s3.size?this.#s6?this.#s6.slice():[...this.#s3.keys()]:null}getGroup(t){return this.#s3.get(t)||null}getHash(){if(null!==this.#s2)return this.#s2;let t=new tG;for(let[e,i]of this.#s3)t.update(`${e}:${i.visible}`);return this.#s2=t.hexdigest()}[Symbol.iterator](){return this.#s3.entries()}get serializable(){let t=new Map;for(let[e,i]of this.#s3)t.set(e,i.serializable);return{data:this.#s4,renderingIntent:this.renderingIntent,groupState:t}}static fromSerializable({data:t,renderingIntent:e,groupState:i}){return new iE(t,e,i)}}class iT{#s7=null;#s9=null;#rt=0;#re=null;#ri=null;get pagesNumber(){return this.#rt}set pagesNumber(t){this.#rt!==t&&(this.#rt=t,this.#s7=null,this.#s9=null)}#rs(){if(this.#s7)return;let t=this.#rt,e=this.#s7=new Uint32Array(t);for(let i=0;i<t;i++)e[i]=i+1;this.#s9=new Int32Array(e)}#rr(){let t=new Map,e=this.#s7;for(let i=0,s=this.#rt;i<s;i++){let s=e[i],r=t.get(s);r?r.push(i+1):t.set(s,[i+1])}return t}movePages(t,e,i){this.#rs();let s=this.#s7,r=this.#rr(),n=e.length,a=new Uint32Array(n),o=0;for(let t=0;t<n;t++){let r=e[t]-1;a[t]=s[r],r<i&&o++}let l=this.#rt,h=l-n,d=W(i-o,0,h);for(let e=0,i=0;e<l;e++)t.has(e+1)||(s[i++]=s[e]);s.copyWithin(d+n,d,h),s.set(a,d),this.#rn(r),s.every((t,e)=>t===e+1)&&(this.#s7=null)}deletePages(t){this.#rs();let e=this.#s7,i=this.#rr();this.#ri={pageNumberToId:e.slice(),pagesNumber:this.#rt,prevPageNumbers:this.#s9.slice()};let s=this.#rt-t.length;this.#rt=s;let r=this.#s7=new Uint32Array(s);this.#s9=new Int32Array(s);let n=0,a=0;for(let i of t){let t=i-1;t!==n&&(r.set(e.subarray(n,t),a),a+=t-n),n=t+1}n<e.length&&r.set(e.subarray(n),a),this.#rn(i,new Set(t))}cancelDelete(){this.#ri&&(this.#s7=this.#ri.pageNumberToId,this.#rt=this.#ri.pagesNumber,this.#s9=this.#ri.prevPageNumbers,this.#ri=null)}cleanSavedData(){this.#ri=null}copyPages(t){this.#rs(),this.#re={pageNumbers:t,pageIds:t.map(t=>this.#s7[t-1])}}cancelCopy(){this.#re=null}pastePages(t){this.#rs();let e=this.#s7,i=this.#rr(),{pageNumbers:s,pageIds:r}=this.#re,n=this.#rt+s.length;this.#rt=n;let a=this.#s7=new Uint32Array(n);this.#s9=new Int32Array(n),a.set(e.subarray(0,t),0),a.set(r,t),a.set(e.subarray(t),t+s.length),this.#rn(i,null,t,s),this.#re=null}#rn(t,e=null,i=-1,s=null){let r=this.#s9,n=this.#s7,a=i+(s?.length??0),o=new Map;for(let l=0,h=this.#rt;l<h;l++){if(l>=i&&l<a){r[l]=-s[l-i];continue}let h=n[l],d=t.get(h),c=o.get(h)||0;if(e&&d)for(;c<d.length&&e.has(d[c]);)c++;r[l]=d?.[c],o.set(h,c+1)}}hasBeenAltered(){return null!==this.#s7}getPageMappingForSaving(t=null){t??=this.#rr();let e=0;for(let i of t.values())e=Math.max(e,i.length);let i=Array(e);for(let t=0;t<e;t++)i[t]={document:null,pageIndices:[],includePages:[]};for(let[e,s]of t)for(let t=0,r=s.length;t<r;t++)i[t].includePages.push([e-1,s[t]-1]);for(let{includePages:t,pageIndices:e}of i){t.sort((t,e)=>t[0]-e[0]);for(let i=0,s=t.length;i<s;i++)e.push(t[i][1]),t[i]=t[i][0]}return i}extractPages(t){t=Array.from(t).sort((t,e)=>t-e);let e=new Map;for(let i=0,s=t.length;i<s;i++){let s=this.getPageId(t[i]);e.getOrInsertComputed(s,$).push(i+1)}return this.getPageMappingForSaving(e)}getPrevPageNumber(t){return this.#s9?.[t-1]??0}getPageNumber(t){if(!this.#s7)return t;let e=this.#s7;for(let i=0,s=this.#rt;i<s;i++)if(e[i]===t)return i+1;return 0}getPageId(t){return this.#s7?.[t-1]??t}getMapping(){return this.#s7?.subarray(0,this.pagesNumber)}}let i_=Symbol("INITIAL_DATA"),ik=()=>({...Promise.withResolvers(),data:i_});class iM{#ra=new Map;get(t,e=null){if(e){let i=this.#ra.getOrInsertComputed(t,ik);return i.promise.then(()=>e(i.data)),null}let i=this.#ra.get(t);if(!i||i.data===i_)throw Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){let e=this.#ra.get(t);return!!e&&e.data!==i_}delete(t){let e=this.#ra.get(t);return!!e&&e.data!==i_&&(this.#ra.delete(t),!0)}resolve(t,e=null){let i=this.#ra.getOrInsertComputed(t,ik);if(i.data!==i_)throw Error(`Object already resolved ${t}.`);i.data=e,i.resolve()}clear(){for(let{data:t}of this.#ra.values())t?.bitmap?.close();this.#ra.clear()}*[Symbol.iterator](){for(let[t,{data:e}]of this.#ra)e!==i_&&(yield[t,e])}}class iP{#ro=Promise.withResolvers();#tk=null;#rl=!1;#rh=!!globalThis.FontInspector?.enabled;#rd=null;#rc=null;#ru=null;#rp=0;#rg=0;#rm=null;#rf=null;#rb=0;#ry=0;#rv=Object.create(null);#rA=[];#rx=null;#rw=[];#rC=new WeakMap;#rS=null;static #rE=new Map;static #rT=new Map;static #r_=new WeakMap;static #rk=null;static #rM=new Set;constructor({textContentSource:t,images:e,container:i,viewport:s}){if(t instanceof ReadableStream)this.#rx=t;else if("object"==typeof t)this.#rx=new ReadableStream({start(e){e.enqueue(t),e.close()}});else throw Error('No "textContentSource" parameter specified.');this.#tk=this.#rf=i,this.#rd=e,this.#ry=s.scale*tp.pixelRatio,this.#rb=s.rotation,this.#ru={div:null,properties:null,ctx:null};const{pageWidth:r,pageHeight:n,pageX:a,pageY:o}=s.rawDims;this.#rS=[1,0,0,-1,-a,o+n],this.#rg=r,this.#rp=n,iP.#rP(),i.style.setProperty("--min-font-size",iP.#rk),tu(i,s),this.#ro.promise.finally(()=>{iP.#rM.delete(this),this.#ru=null,this.#rv=null}).catch(()=>{})}static get fontFamilyMap(){let{isWindows:t,isFirefox:e}=O.platform;return k(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){this.#rd&&this.#tk.append(this.#rd.render());let t=()=>{this.#rm.read().then(({value:e,done:i})=>{i?this.#ro.resolve():(this.#rc??=e.lang,Object.assign(this.#rv,e.styles),this.#rD(e.items),t())},this.#ro.reject)};return this.#rm=this.#rx.getReader(),iP.#rM.add(this),t(),this.#ro.promise}update({viewport:t,onBefore:e=null}){let i=t.scale*tp.pixelRatio,s=t.rotation;if(s!==this.#rb&&(e?.(),this.#rb=s,tu(this.#rf,{rotation:s})),i!==this.#ry){e?.(),this.#ry=i;let t={div:null,properties:null,ctx:iP.#rI(this.#rc)};for(let e of this.#rw)t.properties=this.#rC.get(e),t.div=e,this.#rF(t)}}cancel(){let t=new L("TextLayer task cancelled.");this.#rm?.cancel(t).catch(()=>{}),this.#rm=null,this.#ro.reject(t)}get textDivs(){return this.#rw}get textContentItemsStr(){return this.#rA}#rD(t){if(this.#rl)return;this.#ru.ctx??=iP.#rI(this.#rc);let e=this.#rw,i=this.#rA;for(let s of t){if(e.length>1e5){w("Ignoring additional textDivs for performance reasons."),this.#rl=!0;return}if(void 0===s.str){if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){let t=this.#tk;this.#tk=document.createElement("span"),this.#tk.classList.add("markedContent"),s.id&&this.#tk.setAttribute("id",`${s.id}`),"Artifact"===s.tag&&(this.#tk.ariaHidden=!0),t.append(this.#tk)}else"endMarkedContent"===s.type&&(this.#tk=this.#tk.parentNode);continue}i.push(s.str),this.#rB(s)}}#rB(t){let e,i,s=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#rw.push(s);let n=N.transform(this.#rS,t.transform),a=Math.atan2(n[1],n[0]),o=this.#rv[t.fontName];o.vertical&&(a+=Math.PI/2);let l=this.#rh&&o.fontSubstitution||o.fontFamily;l=iP.fontFamilyMap.get(l)||l;let h=Math.hypot(n[2],n[3]),d=h*iP.#rL(l,o,this.#rc);0===a?(e=n[4],i=n[5]-d):(e=n[4]+d*Math.sin(a),i=n[5]-d*Math.cos(a));let c=s.style;c.left=`${(100*e/this.#rg).toFixed(2)}%`,c.top=`${(100*i/this.#rp).toFixed(2)}%`,c.setProperty("--font-height",`${h.toFixed(2)}px`),c.fontFamily=l,r.fontSize=h,s.setAttribute("role","presentation"),s.textContent=t.str,s.dir=t.dir,this.#rh&&(s.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),0!==a&&(r.angle=180/Math.PI*a);let u=!1;if(t.str.length>1)u=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){let e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(u=!0)}if(u&&(r.canvasWidth=o.vertical?t.height:t.width),this.#rC.set(s,r),this.#ru.div=s,this.#ru.properties=r,this.#rF(this.#ru),r.hasText&&this.#tk.append(s),r.hasEOL){let t=document.createElement("br");t.setAttribute("role","presentation"),this.#tk.append(t)}}#rF(t){let{div:e,properties:i,ctx:s}=t,{style:r}=e;if(0!==i.canvasWidth&&i.hasText){let{fontFamily:t}=r,{canvasWidth:n,fontSize:a}=i;iP.#rR(s,a*this.#ry,t);let{width:o}=s.measureText(e.textContent);o>0&&r.setProperty("--scale-x",n*this.#ry/o)}0!==i.angle&&r.setProperty("--rotate",`${i.angle}deg`)}static cleanup(){if(!(this.#rM.size>0)){for(let{canvas:t}of(this.#rE.clear(),this.#rT.values()))t.remove();this.#rT.clear()}}static #rI(t=null){let e=this.#rT.get(t||="");if(!e){let i=document.createElement("canvas");i.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#rT.set(t,e),this.#r_.set(e,{size:0,family:""})}return e}static #rR(t,e,i){let s=this.#r_.get(t);(e!==s.size||i!==s.family)&&(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static #rP(){if(null!==this.#rk)return;let t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#rk=t.getBoundingClientRect().height,t.remove()}static #rL(t,e,i){let s=this.#rE.get(t);if(s)return s;let r=this.#rI(i);r.canvas.width=r.canvas.height=30,this.#rR(r,30,t);let n=r.measureText(""),a=n.fontBoundingBoxAscent,o=Math.abs(n.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let l=.8;return a?l=a/(a+o):(O.platform.isFirefox&&w("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.#rE.set(t,l),l}}function iD(t={}){let s=new iI,{docId:n}=s,a=t.url?function(t){if(t instanceof URL)return t;if("string"==typeof t){if(r)return new URL(/^[a-z][a-z0-9\-+.]+:/i.test(t)?t:e.default.getBuiltinModule("url").pathToFileURL(t));let i=URL.parse(t,window.location);if(i)return i}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,o=t.data?function(t){if(r&&void 0!==i.Buffer&&t instanceof i.Buffer)throw Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return R(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,l=t.httpHeaders||null,h=!0===t.withCredentials,d=t.password??null,c=t.range instanceof iF?t.range:null,u=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536,p=t.worker instanceof iR?t.worker:null,g=t.verbosity,m="string"!=typeof t.docBaseUrl||Z(t.docBaseUrl)?null:t.docBaseUrl,f=ec(t.cMapUrl),b=!1!==t.cMapPacked,y=ec(t.iccUrl),v=ec(t.standardFontDataUrl),x=ec(t.wasmUrl),w=!0!==t.stopAtErrors,C=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,S="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!r,E="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!r,T=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,_="boolean"==typeof t.disableFontFace?t.disableFontFace:r,k=!0===t.fontExtraProperties,M=!0===t.enableXfa,P=t.ownerDocument||globalThis.document,D=!0===t.disableRange,I=!0===t.disableStream,F=!0===t.disableAutoFetch,B=!0===t.pdfBug,L=t.CanvasFactory||(r?e_:ex),O=t.FilterFactory||(r?eT:eC),N=t.BinaryDataFactory||(r?ek:ev),U=!0===t.enableHWA,H=!0===t.enableWebGPU?eD.init():Promise.resolve(!1),z=!1!==t.useWasm,G=t.pagesMapper||new iT,$="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!r&&!_,j="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(N===ev&&f&&b&&v&&x&&tr(f,document.baseURI)&&tr(v,document.baseURI)&&tr(x,document.baseURI));Number.isInteger(g)&&(A=g);let V={canvasFactory:new L({ownerDocument:P,enableHWA:U}),filterFactory:new O({docId:n,ownerDocument:P}),binaryDataFactory:j?null:new N({cMapUrl:f,standardFontDataUrl:v,wasmUrl:x})};p||(s._worker=p=iR.create({verbosity:g,port:ix.workerPort}));let W={docId:n,apiVersion:"6.1.200",data:o,password:d,disableAutoFetch:F,rangeChunkSize:u,docBaseUrl:m,enableXfa:M,evaluatorOptions:{maxImageSize:C,disableFontFace:_,ignoreErrors:w,isOffscreenCanvasSupported:S,isImageDecoderSupported:E,canvasMaxAreaInBytes:T,fontExtraProperties:k,useSystemFonts:$,useWasm:z,useWorkerFetch:j,cMapUrl:f,cMapPacked:b,iccUrl:y,standardFontDataUrl:v,wasmUrl:x,hasGPU:!1}},K={ownerDocument:P,pdfBug:B,styleElement:null,enableHWA:U,loadingParams:{disableAutoFetch:F,enableXfa:M}};return Promise.all([p.promise,H]).then(function([,t]){let e;if(p.destroyed)throw Error("Worker was destroyed");W.evaluatorOptions.hasGPU=t;let i=p.messageHandler.sendWithPromise("GetDocRequest",W,o?[o.buffer]:null);if(o);else if(c)e=new id({pdfDataRangeTransport:c,disableRange:D,disableStream:I});else if(a)e=new(tr(a)?ir:r?iy:ip)({url:a,httpHeaders:l,withCredentials:h,rangeChunkSize:u,disableRange:D,disableStream:I});else throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");return i.then(t=>{if(p.destroyed)throw Error("Worker was destroyed");let i=new eb(n,t,p.port),r=new iO(i,s,e,K,V,G);if(s._transport=r,s.destroyed)throw Error("Loading aborted");i.send("Ready",null)})}).catch(s._capability.reject).finally(s._setupCapability.resolve),s}class iI{static #i8=0;_capability=Promise.withResolvers();_setupCapability=Promise.withResolvers();_transport=null;_worker=null;docId=`d${iI.#i8++}`;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}this._transport=null,this._worker?.destroy(),this._worker=null}async getData(){return this._transport.getData()}}class iF{#ro=Promise.withResolvers();#rO=null;constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s}onDataRange(t,e){this.#rO({type:"range",begin:t,chunk:e})}onDataProgressiveRead(t){this.#ro.promise.then(()=>{this.#rO({type:"progressiveRead",chunk:t})})}onDataProgressiveDone(){this.#ro.promise.then(()=>{this.#rO({type:"progressiveDone"})})}transportReady(t){this.#rO=t,this.#ro.resolve()}requestDataRange(t,e){C("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class iB{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 k(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"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(t){return this._transport.extractPages(t)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(t){return this._transport.getRawData(t)}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()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class iL{#rN=!1;#rU=null;constructor(t,e,i,s,r=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=r?new ts:null,this._pdfBug=r,this.commonObjs=i.commonObjs,this.objs=new iM,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null,this.#rU=s,this.imageCoordinates=null}clone(t){let e=new iL(t,this._pageInfo,this._transport,this.#rU,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:i=0,offsetY:s=0,dontFlip:r=!1}={}){return new K({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:r})}getAnnotations({intent:t="display"}={}){let{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return k(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:s="display",annotationMode:r=h.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:d=null,printAnnotationStorage:c=null,isEditing:u=!1,recordImages:p=!1,recordOperations:g=!1,operationsFilter:m=null}){this._stats?.time("Overall");let f=this._transport.getRenderingIntent(s,r,c,u),{renderingIntent:b,cacheKey:y}=f;this.#rN=!1,o||=this._transport.getOptionalContentConfig(b);let v=this._intentStates.getOrInsertComputed(y,V);v.streamReaderCancelTimeout&&(clearTimeout(v.streamReaderCancelTimeout),v.streamReaderCancelTimeout=null);let A=!!(4&b);v.displayReadyCapability||(v.displayReadyCapability=Promise.withResolvers(),v.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(f));let x=!!(this._pdfBug&&globalThis.StepperManager?.enabled),w=!!e&&!this.recordedBBoxes&&(g||x),C=!!e&&!this.imageCoordinates&&p,S=t=>{if(v.renderTasks.delete(_),w){let t=_.gfx?.dependencyTracker.take();t&&(_.stepper?.setOperatorBBoxes(t,_.gfx.dependencyTracker.takeDebugMetadata()),g&&(this.recordedBBoxes=t))}C&&!t&&(this.imageCoordinates=_.gfx?.imagesTracker.take()),A&&(this.#rN=!0),this.#rH(),t?(_.capability.reject(t),this._abortOperatorList({intentState:v,reason:t instanceof Error?t:Error(t)})):_.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},E=null,T=null;(w||C)&&(T=new tZ(e,v.operatorList.length)),w&&(E=new t0(T,x));let _=new iU({callback:S,params:{canvas:e,canvasContext:t,dependencyTracker:E??T,imagesTracker:C?new t9(e):null,viewport:i,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:v.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!A,pdfBug:this._pdfBug,pageColors:d,enableHWA:this._transport.enableHWA,operationsFilter:m});(v.renderTasks||=new Set).add(_);let k=_.task;return Promise.all([v.displayReadyCapability.promise,o]).then(([t,e])=>{if(this.destroyed)return void S();if(this._stats?.time("Rendering"),!(e.renderingIntent&b))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:t,optionalContentConfig:e}),_.operatorListChanged()}).catch(S),k}getOperatorList({intent:t="display",annotationMode:e=h.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){let r,n=this._transport.getRenderingIntent(t,e,i,s,!0),a=this._intentStates.getOrInsertComputed(n.cacheKey,V);return a.opListReadCapability||((r=Object.create(null)).operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(r))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(r),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.#rU.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}async getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>X.textContent(t));let e=this.streamTextContent(t),i={items:[],styles:Object.create(null),lang:null};for await(let t of e)i.lang??=t.lang,Object.assign(i.styles,t.styles),i.items.push(...t.items);return i}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let t=[];for(let e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(let i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#rN=!1,Promise.all(t)}cleanup(t=!1){this.#rN=!0;let e=this.#rH();return t&&e&&(this._stats&&=new ts),e}#rH(){if(!this.#rN||this.destroyed)return!1;for(let{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#rN=!1,!0}_startRenderPage(t,e){let i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);for(let i of(e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots,e.renderTasks))i.operatorListChanged();t.lastChunk&&this.#rH()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){let{map:r,transfer:n}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:this.#rU.getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:s},void 0,n).getReader(),o=this._intentStates.get(e);o.streamReader=a;let l=()=>{a.read().then(({value:t,done:e})=>{if(e){o.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(t,o),l())},t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){for(let t of(o.operatorList.lastChunk=!0,o.renderTasks))t.operatorListChanged();this.#rH()}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else if(o.opListReadCapability)o.opListReadCapability.reject(t);else throw t}})};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof J){let i=100;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new L(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(let[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class iR{#ro=Promise.withResolvers();#rz=null;#sX=null;#rG=null;static #r$=0;static #rj=!1;static #rV=new WeakMap;static{r&&(this.#rj=!0,ix.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;let s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{let e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:t=null,port:e=null,verbosity:i=A}={}){if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(iR.#rV.has(e))throw Error("Cannot use more than one PDFWorker per port.");iR.#rV.set(e,this),this.#rW(e)}else this.#rK()}get promise(){return this.#ro.promise}#rX(){this.#ro.resolve(),this.#rz.send("configure",{verbosity:this.verbosity})}get port(){return this.#sX}get messageHandler(){return this.#rz}#rW(t){this.#sX=t,this.#rz=new eb("main","worker",t),this.#rz.on("ready",()=>{}),this.#rX()}#rK(){if(iR.#rj||iR.#rq)return void this.#rY();let{workerSrc:t}=iR;try{iR._isSameOrigin(window.location,t)||(t=iR._createCDNWrapper(new URL(t,window.location).href));let e=new Worker(t,{type:"module"}),i=new eb("main","worker",e),s=()=>{r.abort(),i.destroy(),e.terminate(),this.destroyed?this.#ro.reject(Error("Worker was destroyed")):this.#rY()},r=new AbortController;e.addEventListener("error",()=>{this.#rG||s()},{signal:r.signal}),i.on("test",t=>{(r.abort(),this.destroyed||!t)?s():(this.#rz=i,this.#sX=e,this.#rG=e,this.#rX())}),i.on("ready",t=>{if(r.abort(),this.destroyed)return void s();try{n()}catch{this.#rY()}});let n=()=>{let t=new Uint8Array;i.send("test",t,[t.buffer])};n();return}catch{x("The worker has been disabled.")}this.#rY()}#rY(){iR.#rj||(w("Setting up fake worker."),iR.#rj=!0),iR._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void this.#ro.reject(Error("Worker was destroyed"));let e=new eg;this.#sX=e;let i=`fake${iR.#r$++}`,s=new eb(i+"_worker",i,e);t.setup(s,e),this.#rz=new eb(i,i+"_worker",e),this.#rX()}).catch(t=>{this.#ro.reject(Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#rG?.terminate(),this.#rG=null,iR.#rV.delete(this.#sX),this.#sX=null,this.#rz?.destroy(),this.#rz=null}static create(t){let e=this.#rV.get(t?.port);if(e){if(e._pendingDestroy)throw Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new iR(t)}static get workerSrc(){if(ix.workerSrc)return ix.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get #rq(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return k(this,"_setupFakeWorkerGlobal",(async()=>this.#rq?this.#rq:(await import(this.workerSrc)).WorkerMessageHandler)())}}class iO{downloadInfoCapability=Promise.withResolvers();#rQ=null;#rJ=new Map;#rZ=null;#r0=new Map;#r1=new Map;#r2=new Map;#r3=null;constructor(t,e,i,s,r,n){this.messageHandler=t,this.loadingTask=e,this.#rZ=i,this.commonObjs=new iM,this.fontLoader=new et({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.enableHWA=s.enableHWA,this.loadingParams=s.loadingParams,this._params=s,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){let{_pageIndex:e}=t;this.#r0.set(e,t),this.#r1.set(e,Promise.resolve(t))}#r5(t,e=null){return this.#rJ.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,e))}#sj({loaded:t,total:e}){this.loadingTask.onProgress?.({loaded:t,total:e,percent:e?W(Math.round(t/e*100),0,100):NaN})}get annotationStorage(){return k(this,"annotationStorage",new tj)}getRenderingIntent(t,e=h.ENABLE,i=null,s=!1,r=!1){let n=2,a=t$;switch(t){case"any":n=1;break;case"display":break;case"print":n=4;break;default:w(`getRenderingIntent - invalid intent: ${t}`)}let o=4&n&&i instanceof tV?i:this.annotationStorage;switch(e){case h.DISABLE:n+=64;break;case h.ENABLE:break;case h.ENABLE_FORMS:n+=16;break;case h.ENABLE_STORAGE:n+=32,a=o.serializable;break;default:w(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(n+=128),r&&(n+=256);let{ids:l,hash:d}=o.modifiedIds,c=[n,a.hash,d];return{renderingIntent:n,cacheKey:c.join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#r3?.reject(Error("Worker was destroyed during onPassword callback"));let t=[];for(let e of this.#r0.values())t.push(e._destroy());this.#r0.clear(),this.#r1.clear(),this.#r2.clear(),Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();let e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#rJ.clear(),this.filterFactory.destroy(),iP.cleanup(),this.#rZ?.cancelAllRequests(new L("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{S(this.#rZ,"GetReader - no `BasePDFStream` instance available."),this.#rQ=this.#rZ.getFullReader(),this.#rQ.onProgress=t=>this.#sj(t),e.onPull=()=>{this.#rQ.read().then(function({value:t,done:i}){i?e.close():(S(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this.#rQ.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{await this.#rQ.headersReady;let{isStreamingSupported:e,isRangeSupported:i,contentLength:s}=this.#rQ;return e&&i&&(this.#rQ.onProgress=null),{isStreamingSupported:e,isRangeSupported:i,contentLength:s}}),t.on("GetRangeReader",(t,e)=>{S(this.#rZ,"GetRangeReader - no `BasePDFStream` instance available.");let i=this.#rZ.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then(function({value:t,done:i}){i?e.close():(S(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{i.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this.pagesMapper.pagesNumber=t.numPages,this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new iB(t,this))}),t.on("DocException",t=>{e._capability.reject(ef(t))}),t.on("PasswordRequest",t=>{this.#r3=Promise.withResolvers();try{if(!e.onPassword)throw ef(t);let i=t=>{t instanceof Error?this.#r3.reject(t):this.#r3.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#r3.reject(t)}return this.#r3.promise}),t.on("DataLoaded",t=>{this.#sj({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{this.destroyed||this.#r0.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,s])=>{if(this.destroyed||this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in s){let t=s.error;w(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}let r=new ee(new el(s),this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,s.charProcOperatorList,s.extra);this.fontLoader.bind(r).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{r.fontExtraProperties||r.clearData(),this.commonObjs.resolve(e,r)});break;case"CopyLocalImage":let{imageRef:n}=s;for(let t of(S(n,"The imageRef must be defined."),this.#r0.values()))for(let[,i]of t.objs){if(i?.ref!==n)continue;if(!i.dataLen)return null;let t=structuredClone(i);return this.commonObjs.resolve(e,t),i.dataLen}break;case"FontPath":this.commonObjs.resolve(e,new ed(s));break;case"Image":this.commonObjs.resolve(e,s);break;case"Pattern":let a=new eh(s);this.commonObjs.resolve(e,a.getIR());break;default:throw Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,s])=>{if(this.destroyed)return;let r=this.#r0.get(e);if(!r.objs.has(t)){if(0===r._intentStates.size)return void s?.bitmap?.close();switch(i){case"Image":case"Pattern":r.objs.resolve(t,s);break;default:throw Error(`Got unknown object type ${i}`)}}}),t.on("DocProgress",t=>{this.destroyed||this.#sj(t)}),t.on("FetchBinaryData",async t=>{if(this.destroyed)throw Error("Worker was destroyed.");if(!this.binaryDataFactory)throw Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&w("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this.#rQ?.filename??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t){let e,i={pageInfos:t},s=globalThis.ImageBitmap;if("function"==typeof s)for(let i of Array.isArray(t)?t:[t])i?.image instanceof s&&(e||=[]).push(i.image);if(this.annotationStorage.size>0){let t=this.annotationStorage.serializable,{map:s}=t;t.transfer?.length&&(e?e.push(...t.transfer):e=t.transfer);let r=this.pagesMapper.getMapping();if(r){let t=new Map;for(let[e,i]of s){if(i?.pageIndex!==void 0&&i.pageIndex>=0&&i.pageIndex<r.length){let s=r[i.pageIndex]-1;if(s!==i.pageIndex){t.set(e,{...i,pageIndex:s});continue}}t.set(e,i)}s=t}i.annotationStorage=s}return this.messageHandler.sendWithPromise("ExtractPages",i,e).finally(()=>{this.annotationStorage.resetModified()})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this.pagesMapper.pagesNumber)return Promise.reject(Error("Invalid page request."));let e=t-1,i=this.pagesMapper.getPageId(t)-1,s=this.#r1.get(e);if(s)return s;let r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:i}).then(t=>{if(this.destroyed)throw Error("Transport destroyed");t.refStr&&this.#r2.set(t.refStr,i);let s=new iL(e,t,this,this.pagesMapper,this._params.pdfBug);return this.#r0.set(e,s),s});return this.#r1.set(e,r),r}async getPageIndex(t){if(!eu(t))throw Error("Invalid pageIndex request.");let e=await this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}),i=this.pagesMapper.getPageNumber(e+1);if(0===i)throw Error("GetPageIndex: page has been removed.");return i-1}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(t+1)-1,intent:e})}getFieldObjects(){return this.#r5("GetFieldObjects")}hasJSActions(){return this.#r5("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAttachmentContent(t){return this.messageHandler.sendWithPromise("GetAttachmentContent",t)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#r5("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){return this.#r5("GetOptionalContentConfig").then(e=>new iE(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let t="GetMetadata";return this.#rJ.getOrInsertComputed(t,()=>this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new iw(t[1]):null,contentDispositionFilename:this.#rQ?.filename??null,contentLength:this.#rQ?.contentLength??null,hasStructTree:t[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(t){return this.messageHandler.sendWithPromise("GetRawData",t)}async startCleanup(t=!1){if(!this.destroyed){for(let t of(await this.messageHandler.sendWithPromise("Cleanup",null),this.#r0.values()))if(!t.cleanup())throw Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),this.#rJ.clear(),this.filterFactory.destroy(!0),iP.cleanup()}}cachedPageNumber(t){if(!eu(t))return null;let e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`,i=this.#r2.get(e);if(i>=0){let t=this.pagesMapper.getPageNumber(i+1);if(0!==t)return t}return null}}class iN{_internalRenderTask=null;onContinue=null;onError=null;constructor(t){this._internalRenderTask=t}get promise(){return this._internalRenderTask.capability.promise}cancel(t=0){this._internalRenderTask.cancel(null,t)}get separateAnnots(){let{separateAnnots:t}=this._internalRenderTask.operatorList;if(!t)return!1;let{annotationCanvasMap:e}=this._internalRenderTask;return t.form||t.canvas&&e?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}class iU{#r6=null;static #r4=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:r,operatorList:n,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null,enableHWA:u=!1,operationsFilter:p=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=n,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"u">typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new iN(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u,this._dependencyTracker=e.dependencyTracker,this._imagesTracker=e.imagesTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(iU.#r4.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");iU.#r4.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());let{viewport:i,transform:s,background:r,dependencyTracker:n,imagesTracker:a}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new e1(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,n,a),this.gfx.beginDrawing({transform:s,viewport:i,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#r6&&(window.cancelAnimationFrame(this.#r6),this.#r6=null),iU.#r4.delete(this._canvas),t||=new J(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#r6=window.requestAnimationFrame(()=>{this.#r6=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){!this.cancelled&&(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),iU.#r4.delete(this._canvas),this.callback())))}}let iH="6.1.200",iz="6353acefe";class iG{#r8=null;#r7=null;#r9;#nt=null;#ne=!1;#ni=!1;#a=null;#ns;#nr=null;#y=null;static #nn=null;static get _keyboardManager(){return k(this,"_keyboardManager",new tB([[["Escape"],iG.prototype._hideDropdownFromKeyboard],[["Space"],iG.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],iG.prototype._moveToNext],[["ArrowUp","ArrowLeft"],iG.prototype._moveToPrevious],[["Home"],iG.prototype._moveToBeginning],[["End"],iG.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){t?(this.#ni=!1,this.#a=t):this.#ni=!0,this.#y=t?._uiManager||e,this.#ns=this.#y._eventBus,this.#r9=t?.color?.toUpperCase()||this.#y?.highlightColors.values().next().value||"#FFFF98",iG.#nn||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){let t=this.#r8=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`);let e=this.#y._signal;t.addEventListener("click",this.#na.bind(this),{signal:e}),t.addEventListener("keydown",this.#no.bind(this),{signal:e});let i=this.#r7=document.createElement("span");return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=this.#r9,t.append(i),t}renderMainDropdown(){let t=this.#nt=this.#nl();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#nl(){let t=document.createElement("div"),e=this.#y._signal;for(let[i,s]of(t.addEventListener("contextmenu",tn,{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`),this.#y.highlightColors)){let r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",s),r.title=i,r.setAttribute("data-l10n-id",iG.#nn[i]);let n=document.createElement("span");r.append(n),n.className="swatch",n.style.backgroundColor=s,r.ariaSelected=s===this.#r9,r.addEventListener("click",this.#nh.bind(this,s),{signal:e}),t.append(r)}return t.addEventListener("keydown",this.#no.bind(this),{signal:e}),t}#nh(t,e){e.stopPropagation(),this.#ns.dispatch("switchannotationeditorparams",{source:this,type:p.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#r8)return void this.#na(t);let e=t.target.getAttribute("data-color");e&&this.#nh(e,t)}_moveToNext(t){this.#nd?t.target===this.#r8?this.#nt.firstElementChild?.focus():t.target.nextSibling?.focus():this.#na(t)}_moveToPrevious(t){if(t.target===this.#nt?.firstElementChild||t.target===this.#r8){this.#nd&&this._hideDropdownFromKeyboard();return}this.#nd||this.#na(t),t.target.previousSibling?.focus()}_moveToBeginning(t){this.#nd?this.#nt.firstElementChild?.focus():this.#na(t)}_moveToEnd(t){this.#nd?this.#nt.lastElementChild?.focus():this.#na(t)}#no(t){iG._keyboardManager.exec(this,t)}#na(t){if(this.#nd)return void this.hideDropdown();if(this.#ne=0===t.detail,this.#nr||(this.#nr=new AbortController,window.addEventListener("pointerdown",this.#p.bind(this),{signal:this.#y.combinedSignal(this.#nr)})),this.#r8.ariaExpanded="true",this.#nt)return void this.#nt.classList.remove("hidden");let e=this.#nt=this.#nl();this.#r8.append(e)}#p(t){this.#nt?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#nt?.classList.add("hidden"),this.#r8.ariaExpanded="false",this.#nr?.abort(),this.#nr=null}get #nd(){return this.#nt&&!this.#nt.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#ni){if(!this.#nd)return void this.#a?.unselect();this.hideDropdown(),this.#r8.focus({preventScroll:!0,focusVisible:this.#ne})}}updateColor(t){if(this.#r7&&(this.#r7.style.backgroundColor=t),!this.#nt)return;let e=this.#y.highlightColors.values();for(let i of this.#nt.children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#r8?.remove(),this.#r8=null,this.#r7=null,this.#nt?.remove(),this.#nt=null}}class i${#nc=null;#nu=!1;#a=null;#y=null;static #nn=null;constructor(t){this.#a=t,this.#y=t._uiManager,i$.#nn||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#nc)return this.#nc;let{editorType:t,colorType:e,colorAndOpacityType:i,opacityType:s,color:r,opacity:n}=this.#a,a=this.#nu=O.isAlphaColorInputSupported&&void 0!==s,o=this.#nc=document.createElement("input");return o.type="color",a?(o.setAttribute("alpha",""),o.value=(r||"#000000")+N.hexNums[Math.round((n??1)*255)]):o.value=r||"#000000",o.className="basicColorPicker",o.tabIndex=0,o.setAttribute("data-l10n-id",i$.#nn[t]),o.addEventListener("input",()=>{if(a){let t=tl(o.value);if(!t)return;let[r,n,a,l]=t,h=N.makeHexColor(r,n,a);void 0!==i?this.#y.updateParams(i,{color:h,opacity:l}):(this.#y.updateParams(e,h),this.#y.updateParams(s,l))}else this.#y.updateParams(e,o.value)},{signal:this.#y._signal}),o}update(t){if(this.#nc)if(this.#nu){let e=N.hexNums[Math.round(255*this.#a.opacity)];this.#nc.value=t+e}else this.#nc.value=t}updateOpacity(t){if(!this.#nc||!this.#nu)return;let e=N.hexNums[Math.round(255*t)];this.#nc.value=this.#a.color+e}destroy(){this.#nc?.remove(),this.#nc=null}hideDropdown(){}}function ij(t){return Math.floor(255*W(t,0,1)).toString(16).padStart(2,"0")}function iV(t){return 255*W(t,0,1)}class iW{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=iV(t),t,t]}static G_HTML([t]){let e=ij(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(iV)}static RGB_HTML(t){return`#${t.map(ij).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[iV(1-Math.min(1,t+s)),iV(1-Math.min(1,i+s)),iV(1-Math.min(1,e+s))]}static CMYK_HTML(t){let e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){let s=1-t,r=1-e,n=1-i,a=Math.min(s,r,n);return["CMYK",s,r,n,a]}}class iK{create(t,e,i=!1){if(t<=0||e<=0)throw Error("Invalid SVG dimensions");let s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){C("Abstract method `_createSVG` called.")}}class iX extends iK{_createSVG(t){return document.createElementNS(l,t)}}let iq=new WeakSet,iY=60*new Date().getTimezoneOffset()*1e3;class iQ{static create(t){switch(t.data.annotationType){case f.LINK:return new i0(t);case f.TEXT:return new i1(t);case f.WIDGET:switch(t.data.fieldType){case"Tx":return new i3(t);case"Btn":if(t.data.radioButton)return new i4(t);if(t.data.checkBox)return new i6(t);return new i8(t);case"Ch":return new i7(t);case"Sig":return new i5(t)}return new i2(t);case f.POPUP:return new i9(t);case f.FREETEXT:return new se(t);case f.LINE:return new si(t);case f.SQUARE:return new ss(t);case f.CIRCLE:return new sr(t);case f.POLYLINE:return new sn(t);case f.CARET:return new so(t);case f.INK:return new sl(t);case f.POLYGON:return new sa(t);case f.HIGHLIGHT:return new sh(t);case f.UNDERLINE:return new sd(t);case f.SQUIGGLY:return new sc(t);case f.STRIKEOUT:return new su(t);case f.STAMP:return new sp(t);case f.FILEATTACHMENT:return new sg(t);case f.RICHMEDIA:case f.SCREEN:return new sm(t);default:return new iJ(t)}}}class iJ{#np=null;#ng=!1;#nm=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t?.str||e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return iJ._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){let{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){let t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;let{quadPoints:e,inkLists:i,rect:s}=this.data,r=-1/0,n=-1/0;if(e?.length>=8){for(let t=0;t<e.length;t+=8)e[t+1]>n?(n=e[t+1],r=e[t+2]):e[t+1]===n&&(r=Math.max(r,e[t+2]));return[r,n]}if(i?.length>=1){for(let t of i)for(let e=0,i=t.length;e<i;e+=2)t[e+1]>n?(n=t[e+1],r=t[e]):t[e+1]===n&&(r=Math.max(r,t[e]));if(r!==1/0)return[r,n]}return s?[s[2],s[3]]:null}_normalizePoint(t){let{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:s,pageX:r,pageY:n}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/i,t[1]=100*(t[1]-n)/s,t}get commentText(){let{data:t}=this;return this.annotationStorage.getRawValue(`${c}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){let{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${c}${e.id}`,{id:e.id,annotationType:e.annotationType,page:this.parent.page,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#nm?.popup||this.popup)?.remove(),this.#nm=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#np||={rect:this.data.rect.slice(0)});let{rect:e,popup:i}=t;e&&this.#nf(e);let s=this.#nm?.popup||this.popup;!s&&i?.text&&(this._createPopup(i),s=this.#nm.popup),s&&(s.updateEdited(t),i?.deleted&&(s.remove(),this.#nm=null,this.popup=null))}resetEdited(){this.#np&&(this.#nf(this.#np.rect),this.#nm?.popup.resetEdited(),this.#np=null)}#nf(t){let{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:n,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=`${100*(t[0]-a)/r}%`,e.top=`${100*(n-t[3]+o)/n}%`,0===s?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/n}%`):this.setRotation(s)}_createContainer(t){let{data:e,parent:{page:i,viewport:s}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),this instanceof i2||this instanceof i0||this instanceof sm||(r.tabIndex=0);let{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 i9){let{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,r),r}let{width:a,height:o}=this;if(!t&&e.borderStyle.width>0){n.borderWidth=`${e.borderStyle.width}px`;let t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;switch((t>0||i>0)&&(n.borderRadius=`calc(${t}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`),e.borderStyle.style){case 1:n.borderStyle="solid";break;case 2:n.borderStyle="dashed";break;case 3:w("Unimplemented border style: beveled");break;case 4:w("Unimplemented border style: inset");break;case 5:n.borderBottomStyle="solid"}let s=e.borderColor||null;s?(this.#ng=!0,n.borderColor=N.makeHexColor(...s)):n.borderWidth=0}let l=N.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:d,pageX:c,pageY:u}=s.rawDims;n.left=`${100*(l[0]-c)/h}%`,n.top=`${100*(l[1]-u)/d}%`;let{rotation:p}=e;return e.hasOwnCanvas||0===p?(n.width=`${100*a/h}%`,n.height=`${100*o/d}%`):this.setRotation(p,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;let{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:r,height:n}=this;t%180!=0&&([r,n]=[n,r]),e.style.width=`${100*r/i}%`,e.style.height=`${100*n/s}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){let t=(t,e,i)=>{let s=i.detail[t],r=s[0],n=s.slice(1);i.target.style[e]=iW[`${r}_HTML`](n),this.annotationStorage.setValue(this.data.id,{[e]:iW[`${r}_rgb`](n)})};return k(this,"_commonActions",{display:t=>{let{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{let{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{let e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){let i=this._commonActions;for(let s of Object.keys(e.detail)){let r=t[s]||i[s];r?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;let e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;let i=this._commonActions;for(let[s,r]of Object.entries(e)){let n=i[s];n&&(n({detail:{[s]:r},target:t}),delete e[s])}}_createQuadrilaterals(){let t;if(!this.container)return;let{quadPoints:e}=this.data;if(!e)return;let[i,s,r,n]=this.data.rect.map(t=>Math.fround(t));if(8===e.length){let[t,a,o,l]=e.subarray(2,6);if(r===t&&n===a&&i===o&&s===l)return}let{style:a}=this.container;if(this.#ng){let{borderColor:e,borderWidth:i}=a;a.borderWidth=0,t=["url('data:image/svg+xml;utf8,",`<svg xmlns="${l}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${e}" stroke-width="${i}">`],this.container.classList.add("hasBorder")}let o=r-i,h=n-s,{svgFactory:d}=this,c=d.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0),c.role="none";let u=d.createElement("defs");c.append(u);let p=d.createElement("clipPath"),g=`clippath_${this.data.id}`;p.setAttribute("id",g),p.setAttribute("clipPathUnits","objectBoundingBox"),u.append(p);for(let s=2,r=e.length;s<r;s+=8){let r=e[s],a=e[s+1],l=e[s+2],c=e[s+3],u=d.createElement("rect"),g=(l-i)/o,m=(n-a)/h,f=(r-l)/o,b=(a-c)/h;u.setAttribute("x",g),u.setAttribute("y",m),u.setAttribute("width",f),u.setAttribute("height",b),p.append(u),t?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${m}" width="${f}" height="${b}"/>`)}this.#ng&&(t.push("</g></svg>')"),a.backgroundImage=t.join("")),this.container.append(c),this.container.style.clipPath=`url(#${g})`}_createPopup(t=null){let e,i,{data:s}=this;t?(e={str:t.text},i=t.date):(e=s.contentsObj,i=s.modificationDate),this.#nm=new i9({data:{color:s.color,titleObj:s.titleObj,modificationDate:i,contentsObj:e,richText:s.richText,parentRect:s.rect,borderStyle:0,id:`popup_${s.id}`,rotation:s.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#nm||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#nm}render(){C("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){let i=[];if(this._fieldObjects){let s=this._fieldObjects[t];if(s)for(let{page:t,id:r,exportValues:n}of s){if(-1===t||r===e)continue;let s="string"==typeof n?n:null,a=document.querySelector(`[data-element-id="${r}"]`);if(a&&!iq.has(a)){w(`_getElementsByName - element not allowed: ${r}`);continue}i.push({id:r,exportValue:s,domElement:a})}return i}for(let s of document.getElementsByName(t)){let{exportValue:t}=s,r=s.getAttribute("data-element-id");r!==e&&iq.has(s)&&i.push({id:r,exportValue:t,domElement:s})}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){let t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(let e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}updateOC(t){this.data.oc&&t&&(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){let e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":N.makeHexColor(...e)}}class iZ extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){let{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class i0 extends iJ{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){let{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action,t.overlaidText),s=!0):t.attachment?(this.#nb(i,t.attachmentId,t.attachment,t.overlaidText,t.attachmentDest),s=!0):t.setOCGState?(this.#ny(i,t.setOCGState,t.overlaidText),s=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&(this.contentElement=i,this.container.append(i)),this.container}#nv(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,i=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#nv(),i&&(t.title=i)}_bindNamedAction(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),i&&(t.title=i),this.#nv()}#nb(t,e,i,s="",r=null){t.href=this.linkService.getAnchorUrl(""),i.description?t.title=i.description:s&&(t.title=s);let n=async()=>{let t=await this.linkService.getAttachmentContent(e);t&&this.downloadManager?.openOrDownloadData(t,i.filename,r)};t.onclick=()=>(n(),!1),this.#nv()}#ny(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),this.#nv()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");let i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let s of Object.keys(e.actions)){let r=i.get(s);r&&(t[r]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),this.#nv()}_bindResetFormAction(t,e){let i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#nv(),!this._fieldObjects){w('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(t.onclick=()=>!1);return}t.onclick=()=>{i?.();let{fields:t,refs:s,include:r}=e,n=[];if(0!==t.length||0!==s.length){let e=new Set(s);for(let i of t)for(let{id:t}of this._fieldObjects[i]||[])e.add(t);for(let t of Object.values(this._fieldObjects))for(let i of t)e.has(i.id)===r&&n.push(i)}else for(let t of Object.values(this._fieldObjects))n.push(...t);let a=this.annotationStorage,o=[];for(let t of n){let{id:e}=t;switch(o.push(e),t.type){case"text":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{let i=t.defaultValue===t.exportValues;a.setValue(e,{value:i});break}case"combobox":case"listbox":{let i=t.defaultValue||"";a.setValue(e,{value:i});break}default:continue}let i=document.querySelector(`[data-element-id="${e}"]`);if(i){if(!iq.has(i)){w(`_bindResetFormAction - element not allowed: ${e}`);continue}i.dispatchEvent(new Event("resetform"))}}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class i1 extends iJ{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}class i2 extends iJ{render(){return this.container}_getKeyModifier(t){return O.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,r){i.includes("mouse")?t.addEventListener(i,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:r(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(i,t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:r(t)}})})}_setEventListeners(t,e,i,s){for(let[r,n]of i)("Action"===n||this.data.actions?.[n])&&(("Focus"===n||"Blur"===n)&&(e||={focused:!1}),this._setEventListener(t,e,r,n,s),"Focus"!==n||this.data.actions?.Blur?"Blur"!==n||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setTextStyle(t){let e,{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,r=t.style,n=t=>Math.round(10*t)/10;if(this.data.multiLine){let t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),i=Math.round(t/(1.35*s))||1;e=Math.min(s,n(t/i/1.35))}else e=Math.min(s,n(Math.abs(this.data.rect[3]-this.data.rect[1]-2)/1.35));r.fontSize=`calc(${e}px * var(--total-scale-factor))`,r.color=N.makeHexColor(...i),null===this.data.textAlignment||this.data.comb||(r.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class i3 extends i2{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,i,s){let r=this.annotationStorage;for(let n of this._getElementsByName(t.name,t.id))n.domElement&&(n.domElement[e]=i),r.setValue(n.id,{[s]:i})}render(){let t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){let s=t.getValue(e,{value:this.data.fieldValue}),r=s.value||"",n=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;n&&r.length>n&&(r=r.slice(0,n));let a=s.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));let o={userValue:r,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((i=document.createElement("textarea")).textContent=a??r,this.data.doNotScroll&&(i.style.overflowY="hidden")):((i=document.createElement("input")).type=this.data.password?"password":"text",i.setAttribute("value",a??r),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(this.container.classList.add("hasOwnCanvas"),t.has(e)&&this.container.classList.add("sandboxModified")),iq.add(i),this.contentElement=i,i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;let{datetimeFormat:l,datetimeType:h,timeStep:d}=this.data,c=!!h&&this.enableScripting;l&&(i.title=l),this._setRequired(i,this.data.required),n&&(i.maxLength=n),i.addEventListener("input",s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null});let u=t=>{let{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",t=>{if(o.focused)return;let{target:e}=t;if(c&&(e.type=h,d&&(e.step=d)),o.userValue){let t=o.userValue;if(c)if("time"===h){let i=new Date(t);e.value=[i.getHours(),i.getMinutes(),i.getSeconds()].map(t=>t.toString().padStart(2,"0")).join(":")}else e.value=new Date(t-iY).toISOString().split("date"===h?"T":".",1)[0];else e.value=t}o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),i.addEventListener("updatefromsandbox",i=>{this.container.classList.add("sandboxModified"),this._dispatchEventFromSandbox({value(i){o.userValue=i.detail.value??"",c||t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){let{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s);let r={formattedValue:s};c&&(r.value=s),t.setValue(e,r)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{let{charLimit:s}=i.detail,{target:r}=i;if(0===s)return void r.removeAttribute("maxLength");r.setAttribute("maxLength",s);let n=o.userValue;n&&!(n.length<=s)&&(r.value=o.userValue=n=n.slice(0,s),t.setValue(e,{value:n}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,willCommit:!0,commitKey:1,selStart:r.selectionStart,selEnd:r.selectionEnd}}))}},i)}),i.addEventListener("keydown",t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;let{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});let s=u;u=null,i.addEventListener("blur",t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);let{target:i}=t,{value:r}=i;if(c){if(r&&"time"===h){let t=r.split(":").map(t=>parseInt(t,10));r=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),i.step=""}else r.includes("T")||(r=`${r}T00:00`),r=new Date(r).valueOf();i.type="text"}o.userValue=r,o.lastCommittedValue!==r&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",t=>{o.lastCommittedValue=null;let{data:i,target:s}=t,{value:r,selectionStart:n,selectionEnd:a}=s,l=n,h=a;switch(t.inputType){case"deleteWordBackward":{let t=r.substring(0,n).match(/\w*\W*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{let t=r.substring(n).match(/^\W*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":n===a&&(l-=1);break;case"deleteContentForward":n===a&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,change:i||"",willCommit:!1,selStart:l,selEnd:h}})}),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(u&&i.addEventListener("blur",u),this.data.comb){let t=(this.data.rect[2]-this.data.rect[0])/n;i.classList.add("comb"),i.style.setProperty("--comb-width",`calc(${t}px * var(--total-scale-factor))`);let e=this.data.textAlignment;if(1===e||2===e){let t=()=>{let t=n-i.value.length;i.style.setProperty("--comb-offset",`${1===e?t>>1:t}`)};for(let e of(t(),["input","blur","resetform","updatefromsandbox"]))i.addEventListener(e,t)}}}else(i=document.createElement("div")).textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class i5 extends i2{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class i6 extends i2{constructor(t){super(t,{isRenderable:t.renderForms})}render(){let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let r=document.createElement("input");return iq.add(r),r.setAttribute("data-element-id",i),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,s&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",s=>{let{name:r,checked:n}=s.target;for(let s of this._getElementsByName(r,i)){let i=n&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:n})}),r.addEventListener("resetform",t=>{let i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}},e)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class i4 extends i2{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let t=this.annotationStorage,e=this.data,i=e.id,s=t.getValue(i,{value:null!==e.buttonValue&&e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(let s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});let r=document.createElement("input");if(iq.add(r),r.setAttribute("data-element-id",i),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,s&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",e=>{let{name:s,checked:r}=e.target;for(let e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:r})}),r.addEventListener("resetform",t=>{let i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){let s=e.buttonValue;r.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({value:e=>{let r=s===e.detail.value;for(let s of this._getElementsByName(e.target.name)){let e=r&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}},e)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}return this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class i8 extends i0{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){let t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");let e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class i7 extends i2{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");iq.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;!this.data.combo&&(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",t=>{let e=this.data.defaultFieldValue;for(let t of s.options)t.selected=t.value===e});let n=(t,e)=>{let i=e.replaceAll(" "," ");t.textContent=i,i!==e&&t.setAttribute("display-value",e)};for(let t of this.data.options){let e=document.createElement("option");n(e,t.displayValue),e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),r=!1),s.append(e)}let a=null;if(r){let t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),a=()=>{t.remove(),s.removeEventListener("input",a),a=null},s.addEventListener("input",a)}let o=t=>{let e=t?"value":"textContent",{options:i,multiple:r}=s;return r?Array.prototype.filter.call(i,t=>t.selected).map(t=>t[e]):-1===i.selectedIndex?null:i[i.selectedIndex][e]},l=o(!1),h=t=>{let e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.getAttribute("display-value")||t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",i=>{this._dispatchEventFromSandbox({value(i){a?.();let r=i.detail.value,n=new Set(Array.isArray(r)?r:[r]);for(let t of s.options)t.selected=n.has(t.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(t){s.multiple=!0},remove(i){let r=s.options,n=i.detail.remove;r[n].selected=!1,s.remove(n),r.length>0&&-1===Array.prototype.findIndex.call(r,t=>t.selected)&&(r[0].selected=!0),t.setValue(e,{value:o(!0),items:h(i)}),l=o(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(i){let{index:r,displayValue:a,exportValue:d}=i.detail.insert,c=s.children[r],u=document.createElement("option");n(u,a),u.value=d,c?c.before(u):s.append(u),t.setValue(e,{value:o(!0),items:h(i)}),l=o(!1)},items(i){let{items:r}=i.detail;for(;0!==s.length;)s.remove(0);for(let t of r){let{displayValue:e,exportValue:i}=t,r=document.createElement("option");n(r,e),r.value=i,s.append(r)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:o(!0),items:h(i)}),l=o(!1)},indices(i){let s=new Set(i.detail.indices);for(let t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(t){t.target.disabled=!t.detail.editable}},i)}),s.addEventListener("input",i=>{let s=o(!0),r=o(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:r,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],t=>t.target.value)):s.addEventListener("input",function(i){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class i9 extends iJ{constructor(t){const{data:e,elements:i,parent:s}=t,r=!!s._commentManager;if(super(t,{isRenderable:!r&&iJ._hasPopupData(e)}),this.elements=i,r&&iJ._hasPopupData(e)){const t=this.popup=this.#nA();for(const e of i)e.popup=t}else this.popup=null}#nA(){return new st({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})}render(){let{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";let e=this.popup=this.#nA(),i=[];for(let t of this.elements)t.popup=e,t.container.ariaHasPopup="dialog",i.push(t.data.id),t.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(t=>`${d}${t}`).join(",")),this.container}}class st{#W=null;#nx=this.#no.bind(this);#nw=this.#nC.bind(this);#nS=this.#nE.bind(this);#nT=this.#n_.bind(this);#nk=null;#tk=null;#nM=null;#nP=null;#nD=null;#nI=null;#nF=null;#nB=!1;#nL=null;#nR=null;#F=null;#nO=null;#nN=null;#ec=null;#nU=null;#eo=null;#nH=null;#np=null;#nz=!1;#nG=null;#n$=null;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:r,contentsObj:n,richText:a,parent:o,rect:l,parentRect:h,open:d,commentManager:c=null}){this.#tk=t,this.#nH=s,this.#nM=n,this.#eo=a,this.#nI=o,this.#nk=e,this.#nU=l,this.#nF=h,this.#nD=i,this.#W=c,this.#nG=i[0],this.#nP=to.toDateObject(r),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),!c&&(this.#nj(),this.#tk.hidden=!0,d&&this.#n_())}#nj(){if(this.#nR)return;this.#nR=new AbortController;let{signal:t}=this.#nR;for(let e of this.trigger)e.addEventListener("click",this.#nT,{signal:t}),e.addEventListener("pointerenter",this.#nS,{signal:t}),e.addEventListener("pointerleave",this.#nw,{signal:t}),e.classList.add("popupTriggerArea");for(let e of this.#nD)e.container?.addEventListener("keydown",this.#nx,{signal:t})}#nV(){let t=this.#nD.find(t=>t.hasCommentButton);t&&(this.#nN=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#nO){this.#nO.parentNode||this.#nG.container.after(this.#nO);return}if(this.#nN||this.#nV(),!this.#nN)return;let{signal:t}=this.#nR=new AbortController,e=this.#nG.hasOwnCommentButton,i=()=>{this.#W.toggleCommentPopup(this,!0,void 0,!e)},s=()=>{this.#W.toggleCommentPopup(this,!1,!0,!e)},r=()=>{this.#W.toggleCommentPopup(this,!1,!1)};if(e)for(let e of(this.#nO=this.#nG.container,this.trigger))e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.addEventListener("keydown",this.#nx,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",r,{signal:t}),e.classList.add("popupTriggerArea");else{let e=this.#nO=document.createElement("button");e.className="annotationCommentButton";let n=this.#nG.container;e.style.zIndex=parseInt(n.style.zIndex,10)+1,e.tabIndex=0,e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#nW(),this.#nK(),e.addEventListener("keydown",this.#nx,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",s,{signal:t}),e.addEventListener("pointerleave",r,{signal:t}),n.after(e)}}#nK(){if(this.#nG.extraPopupElement&&!this.#nG.editor)return;this.#nO||this.renderCommentButton();let[t,e]=this.#nN,{style:i}=this.#nO;i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`}#nW(){this.#nG.extraPopupElement||(this.#nO||this.renderCommentButton(),this.#nO.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){let{color:t,opacity:e}=this.#nG.commentData;return t?this.#nI._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#nO?.focus()},0)}getData(){let{richText:t,color:e,opacity:i,creationDate:s,modificationDate:r}=this.#nG.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:s,modificationDate:r}}get elementBeforePopup(){return this.#nO}get comment(){return this.#n$||=this.#nG.commentText,this.#n$}set comment(t){t!==this.comment&&(this.#nG.commentText=this.#n$=t)}focus(){this.#nG.container?.focus()}get parentBoundingClientRect(){return this.#nG.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#nO&&(this.#nO.classList.toggle("selected",t),this.#nO.ariaExpanded=e)}setSelectedCommentButton(t){this.#nO.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#ec)return this.#ec;let{x:t,y:e,height:i}=this.#nO.getBoundingClientRect(),{x:s,y:r,width:n,height:a}=this.#nG.layer.getBoundingClientRect();return[(t-s)/n,(e+i-r)/a]}set commentPopupPosition(t){this.#ec=t}hasDefaultPopupPosition(){return null===this.#ec}get commentButtonPosition(){return this.#nN}get commentButtonWidth(){return this.#nO.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){let[e,i]=this.#ec||this.commentButtonPosition.map(t=>t/100),s=this.parentBoundingClientRect,{x:r,y:n,width:a,height:o}=s;this.#W.showDialog(null,this,r+e*a,n+i*o,{...t,parentDimensions:s})}render(){if(this.#nL)return;let t=this.#nL=document.createElement("div");if(t.className="popup",this.#nk){let e=t.style.outlineColor=N.makeHexColor(...this.#nk);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}let e=document.createElement("span");if(e.className="header",this.#nH?.str){let t=document.createElement("span");t.className="title",e.append(t),{dir:t.dir,str:t.textContent}=this.#nH}if(t.append(e),this.#nP){let t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#nP.valueOf()})),t.dateTime=this.#nP.toISOString(),e.append(t)}tS({html:this.#nX||this.#nM.str,dir:this.#nM?.dir,className:"popupContent"},t),this.#tk.append(t)}get #nX(){let t=this.#eo,e=this.#nM;return t?.str&&(!e?.str||e.str===t.str)&&this.#eo.html||null}get #nq(){return this.#nX?.attributes?.style?.fontSize||0}get #nY(){return this.#nX?.attributes?.style?.color||null}#nQ(t){let e=[],i={style:{color:this.#nY,fontSize:this.#nq?`calc(${this.#nq}px * var(--total-scale-factor))`:""}};for(let s of t.split("\n"))e.push({name:"span",value:s,attributes:i});return{str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}}}#no(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#nB)&&this.#n_()}updateEdited({rect:t,popup:e,deleted:i}){if(this.#W){i?(this.remove(),this.#n$=null):e&&(e.deleted?this.remove():(this.#nW(),this.#n$=e.text)),t&&(this.#nN=null,this.#nV(),this.#nK());return}i||e?.deleted?this.remove():(this.#nj(),this.#np||={contentsObj:this.#nM,richText:this.#eo},t&&(this.#F=null),e&&e.text&&(this.#eo=this.#nQ(e.text),this.#nP=to.toDateObject(e.date),this.#nM=null),this.#nL?.remove(),this.#nL=null)}resetEdited(){this.#np&&({contentsObj:this.#nM,richText:this.#eo}=this.#np,this.#np=null,this.#nL?.remove(),this.#nL=null,this.#F=null)}remove(){if(this.#nR?.abort(),this.#nR=null,this.#nL?.remove(),this.#nL=null,this.#nz=!1,this.#nB=!1,this.#nO?.remove(),this.#nO=null,this.trigger)for(let t of this.trigger)t.classList.remove("popupTriggerArea")}#nJ(){if(null!==this.#F)return;let{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:r}}}=this.#nI,n=!!this.#nF,a=n?this.#nF:this.#nU;for(let t of this.#nD)if(!a||null!==N.intersect(t.data.rect,a)){a=t.data.rect,n=!0;break}let o=N.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=n?a[2]-a[0]+5:0,h=o[0]+l,d=o[1];this.#F=[100*(h-s)/e,100*(d-r)/i];let{style:c}=this.#tk;c.left=`${this.#F[0]}%`,c.top=`${this.#F[1]}%`}#n_(){this.#W?this.#W.toggleCommentPopup(this,!1):(this.#nB=!this.#nB,this.#nB?(this.#nE(),this.#tk.addEventListener("click",this.#nT),this.#tk.addEventListener("keydown",this.#nx)):(this.#nC(),this.#tk.removeEventListener("click",this.#nT),this.#tk.removeEventListener("keydown",this.#nx)))}#nE(){this.#nL||this.render(),this.isVisible?this.#nB&&this.#tk.classList.add("focused"):(this.#nJ(),this.#tk.hidden=!1,this.#tk.style.zIndex=parseInt(this.#tk.style.zIndex,10)+1e3)}#nC(){this.#tk.classList.remove("focused"),!this.#nB&&this.isVisible&&(this.#tk.hidden=!0,this.#tk.style.zIndex=parseInt(this.#tk.style.zIndex,10)-1e3)}forceHide(){this.#nz=this.isVisible,this.#nz&&(this.#tk.hidden=!0)}maybeShow(){this.#W||(this.#nj(),this.#nz&&(this.#nL||this.#nE(),this.#nz=!1,this.#tk.hidden=!1))}get isVisible(){return!this.#W&&!1===this.#tk.hidden}}class se extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=u.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){let t=this.contentElement=document.createElement("div");for(let e of(t.classList.add("annotationTextContent"),t.setAttribute("role","comment"),this.textContent)){let i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class si extends iJ{#nZ=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),r=this.#nZ=this.svgFactory.createElement("svg:line");return r.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),r.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),r.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),r.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),r.setAttribute("stroke-width",t.borderStyle.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#nZ}addHighlightArea(){this.container.classList.add("highlightArea")}}class ss extends iJ{#n0=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),r=t.borderStyle.width,n=this.#n0=this.svgFactory.createElement("svg:rect");return n.setAttribute("x",r/2),n.setAttribute("y",r/2),n.setAttribute("width",e-r),n.setAttribute("height",i-r),n.setAttribute("stroke-width",r||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#n0}addHighlightArea(){this.container.classList.add("highlightArea")}}class sr extends iJ{#n1=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");let{data:t,width:e,height:i}=this,s=this.svgFactory.create(e,i,!0),r=t.borderStyle.width,n=this.#n1=this.svgFactory.createElement("svg:ellipse");return n.setAttribute("cx",e/2),n.setAttribute("cy",i/2),n.setAttribute("rx",e/2-r/2),n.setAttribute("ry",i/2-r/2),n.setAttribute("stroke-width",r||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#n1}addHighlightArea(){this.container.classList.add("highlightArea")}}class sn extends iJ{#n2=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,vertices:e,borderStyle:i,popupRef:s},width:r,height:n}=this;if(!e)return this.container;let a=this.svgFactory.create(r,n,!0),o=[];for(let i=0,s=e.length;i<s;i+=2){let s=e[i]-t[0],r=t[3]-e[i+1];o.push(`${s},${r}`)}o=o.join(" ");let l=this.#n2=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!s&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#n2}addHighlightArea(){this.container.classList.add("highlightArea")}}class sa extends sn{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class so extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}class sl extends iJ{#n3=null;#n5=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?u.HIGHLIGHT:u.INK}#n6(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);let{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:r}}=this,{transform:n,width:a,height:o}=this.#n6(e,t),l=this.svgFactory.create(a,o,!0),h=this.#n3=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",n);for(let t=0,e=i.length;t<e;t++){let e=this.svgFactory.createElement(this.svgElementName);this.#n5.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!r&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);let{thickness:e,points:i,rect:s}=t,r=this.#n3;if(e>=0&&r.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#n5.length;t<e;t++)this.#n5[t].setAttribute("points",i[t].join(","));if(s){let{transform:t,width:e,height:i}=this.#n6(this.data.rotation,s);r.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),r.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#n5}addHighlightArea(){this.container.classList.add("highlightArea")}}class sh extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=u.HIGHLIGHT}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){let e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class sd extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){let e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class sc extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){let e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class su extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){let{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){let e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class sp extends iJ{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=u.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 sg extends iJ{#n4=null;constructor(t){super(t,{isRenderable:!0});const{fileId:e,file:i}=this.data;this.filename=i.filename,this.content=i.content,this.fileId=e,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...i})}render(){let t;this.container.classList.add("fileAttachmentAnnotation");let{container:e,data:i}=this;i.hasAppearance||0===i.fillAlpha?t=document.createElement("div"):((t=document.createElement("img")).src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(i.name)?"paperclip":"pushpin"}.svg`,i.fillAlpha&&i.fillAlpha<1&&(t.style=`filter: opacity(${Math.round(100*i.fillAlpha)}%);`)),t.addEventListener("dblclick",this.#n8.bind(this)),this.#n4=t;let{isMac:s}=O.platform;return e.addEventListener("keydown",t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#n8()}),!i.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):t.classList.add("popupTriggerArea"),e.append(t),e}getElementsToTriggerPopup(){return this.#n4}addHighlightArea(){this.container.classList.add("highlightArea")}async #n8(){let{fileId:t,filename:e,content:i}=this,s=await this.linkService.getAttachmentContent(t)||i;s&&this.downloadManager?.openOrDownloadData(s,e)}}class sm extends iJ{#R=new AbortController;#n7=null;#n9=null;constructor(t){super(t,{isRenderable:!!t.data.richMedia})}render(){this.container.classList.add("mediaAnnotation");let{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.#at(e),{signal:this.#R.signal}),this.container.append(e),this.container}async #at(t){let e,{fileId:i,filename:s,contentType:r}=this.data.richMedia;t.disabled=!0;try{e=await this.linkService.getAttachmentContent(i)}catch{return}finally{t.disabled=!1}if(!e||!t.isConnected)return;let{signal:n}=this.#R,a=URL.createObjectURL(new Blob([e],{type:r}));this.#n7=a;let o=r.startsWith("audio/"),l=document.createElement(o?"audio":"video");if(this.#n9=l,l.className="mediaContent",this._setBackgroundColor(l),l.src=a,l.title=s,l.controls=!0,l.autoplay=!0,l.tabIndex=0,o){let t=!1,e=!1,i=()=>{l.controls=t||e};this.container.addEventListener("pointerenter",()=>{t=!0,i()},{signal:n}),this.container.addEventListener("pointerleave",()=>{t=!1,i()},{signal:n}),this.container.addEventListener("focusin",()=>{e=!0,i()},{signal:n}),this.container.addEventListener("focusout",()=>{e=!1,i()},{signal:n})}l.addEventListener("emptied",()=>this.#ae(a),{once:!0,signal:n}),t.replaceWith(l),l.play().catch(()=>{})}#ae(t=this.#n7){t&&t===this.#n7&&(URL.revokeObjectURL(t),this.#n7=null)}destroy(){this.#R.abort(),this.#n9&&(this.#n9.pause(),this.#n9.removeAttribute("src"),this.#n9.load(),this.#n9=null),this.#ae()}}class sf{#ai=null;#as=null;#$=null;#ar=new Map;#an=null;#aa=null;#nD=[];#ao=!1;zIndex=0;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:r,viewport:n,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:h}){this.div=t,this.#ai=e,this.#as=i,this.#an=a||null,this.#aa=l||null,this.#$=h||new tj,this.page=r,this.viewport=n,this._annotationEditorUIManager=s,this._commentManager=o||null}hasEditableAnnotations(){return this.#ar.size>0}async render(t){let{annotations:e,optionalContentConfig:i}=t,s=this.div;tu(s,this.viewport);let r=new Map,n=[],a={data:null,layer:s,linkService:this.#aa,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new iX,annotationStorage:this.#$,enableComment:!0===t.enableComment,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(let t of e){if(t.noHTML)continue;let e=t.annotationType===f.POPUP;if(e){let e=r.get(t.id);if(!e)continue;if(!this._commentManager){n.push(t);continue}a.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;a.data=t;let s=iQ.create(a);if(!s.isRenderable)continue;!e&&(this.#nD.push(s),t.popupRef&&r.getOrInsertComputed(t.popupRef,$).push(s));let o=s.render();t.hidden&&(o.style.visibility="hidden"),s.updateOC(i),s._isEditable&&(this.#ar.set(s.data.id,s),this._annotationEditorUIManager?.renderAnnotationElement(s))}for(let t of(await this.#al(),n)){let e=a.elements=r.get(t.id);a.data=t;let i=iQ.create(a);if(!i.isRenderable)continue;let s=i.render();i.contentElement.id=`${d}${t.id}`,t.hidden&&(s.style.visibility="hidden"),e.at(-1).container.after(s)}this.#ah()}async #al(){if(0===this.#nD.length)return;this.div.replaceChildren();let t=[];if(!this.#ao)for(let{contentElement:e,data:{id:i}}of(this.#ao=!0,this.#nD)){let s=e.id=`${d}${i}`;t.push(this.#an?.getAriaAttributes(s).then(t=>{if(t)for(let[i,s]of t)e.setAttribute(i,s)}))}this.#nD.sort(({data:{rect:[t,e,i,s]}},{data:{rect:[r,n,a,o]}})=>{if(t===i&&e===s)return 1;if(r===a&&n===o)return -1;let l=(e+s)/2,h=(n+o)/2;return l>=o&&h<=e?-1:h>=s&&l<=n?1:(t+i)/2-(r+a)/2});let e=document.createDocumentFragment();for(let t of this.#nD)e.append(t.container),this._commentManager?(t.extraPopupElement?.popup||t.popup)?.renderCommentButton():t.extraPopupElement&&e.append(t.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#ai)for(let t of this.#nD)this.#ai.addPointerInTextLayer(t.contentElement,!1)}async addLinkAnnotations(t){let e={data:null,layer:this.div,linkService:this.#aa,svgFactory:new iX,parent:this};for(let i of t){i.borderStyle||=sf._defaultBorderStyle,e.data=i;let t=iQ.create(e);t.isRenderable&&(t.render(),t.contentElement.id=`${d}${i.id}`,this.#nD.push(t))}await this.#al()}update({viewport:t,optionalContentConfig:e}){let i=this.div;for(let s of(this.viewport=t,tu(i,{rotation:t.rotation}),this.#nD))s.updateOC(e);this.#ah(),i.hidden=!1}destroy(){for(let t of this.#nD)t.destroy?.(),this.#ai?.removePointerInTextLayer(t.contentElement);this.#nD.length=0,this.#ar.clear(),this.div.replaceChildren()}#ah(){if(!this.#as)return;let t=this.div;for(let[e,i]of this.#as){let s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;if(Array.isArray(i))for(let t of i)t.className="annotationContent",t.ariaHidden=!0;else i.className="annotationContent",i.ariaHidden=!0;let r=[];for(let t of s.children)"CANVAS"===t.nodeName&&r.push(t);for(let t of r)t.remove();let n=Array.isArray(i)?i[0]:i,{firstChild:a}=s;if(a?a.classList.contains("annotationContent")?a.after(n):a.before(n):s.append(n),Array.isArray(i)){let t=n;for(let e=1,s=i.length;e<s;e++)t.after(i[e]),t=i[e]}this.#as.delete(e);let o=this.#ar.get(e);o&&(o._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,s.id,i),o._hasNoCanvas=!1):o.canvas=i)}}refreshCanvases(){this.#ah()}getEditableAnnotations(){return this.#ar.values()}getEditableAnnotation(t){return this.#ar.get(t)}addFakeAnnotation(t){let{div:e}=this,{id:i,rotation:s}=t,r=new iZ({data:{id:i,rect:t.getPDFRect(),rotation:s},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#aa,annotationStorage:this.#$});return r.render(),r.contentElement.id=`${d}${i}`,r.createOrUpdatePopup(),this.#nD.push(r),r}removeAnnotation(t){let e=this.#nD.findIndex(e=>e.data.id===t);if(e<0)return;let[i]=this.#nD.splice(e,1);this.#ai?.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(t){if(0!==t.length){for(let e of t)e.updateFakeAnnotationElement(this);this.#al()}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return k(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:1,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}let sb=/\r\n?|\n/g;class sy extends tH{#ad="";#ac=`${this.id}-editor`;#au=null;#nq;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let t=sy.prototype,e=t=>t.isEmpty(),i=tR.TRANSLATE_SMALL,s=tR.TRANSLATE_BIG;return k(this,"_keyboardManager",new tB([[["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:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=u.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||sy._defaultColor||tH._defaultLineColor,this.#nq=t.fontSize||sy._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert(tH._l10nAlert.freetext),this.canAddComment=!1}static initialize(t,e){tH.initialize(t,e);let i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case p.FREETEXT_SIZE:sy._defaultFontSize=e;break;case p.FREETEXT_COLOR:sy._defaultColor=e}}updateParams(t,e){switch(t){case p.FREETEXT_SIZE:this.#ap(e);break;case p.FREETEXT_COLOR:this.#nW(e)}}static get defaultPropertiesToUpdate(){return[[p.FREETEXT_SIZE,sy._defaultFontSize],[p.FREETEXT_COLOR,sy._defaultColor||tH._defaultLineColor]]}get propertiesToUpdate(){return[[p.FREETEXT_SIZE,this.#nq],[p.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new i$(this),[["colorPicker",this._colorPicker]]}get colorType(){return p.FREETEXT_COLOR}#ap(t){let e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#nq)*this.parentScale),this.#nq=t,this.#ag()},i=this.#nq;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:p.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#nW(t){let e=t=>{this.color=t,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:p.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){let t=this.parentScale;return[-sy._internalPadding*t,-(sy._internalPadding+this.#nq)*t]}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#au=new AbortController;let t=this._uiManager.combinedSignal(this.#au);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.#ac),this._isDraggable=!0,this.#au?.abort(),this.#au=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#am(){let t=[];this.editorDiv.normalize();let e=null;for(let i of this.editorDiv.childNodes)(e?.nodeType!==Node.TEXT_NODE||"BR"!==i.nodeName)&&(t.push(sy.#af(i)),e=i);return t.join("\n")}#ag(){let t,[e,i]=this.parentDimensions;if(this.isAttachedToDOM)t=this.div.getBoundingClientRect();else{let{currentLayer:e,div:i}=this,s=i.style.display,r=i.classList.contains("hidden");i.classList.remove("hidden"),i.style.display="hidden",e.div.append(this.div),t=i.getBoundingClientRect(),i.remove(),i.style.display=s,i.classList.toggle("hidden",r)}this.rotation%180==this.parentRotation%180?(this.width=t.width/e,this.height=t.height/i):(this.width=t.height/e,this.height=t.width/i),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let t=this.#ad,e=this.#ad=this.#am().trimEnd();if(t===e)return;let i=t=>{(this.#ad=t,t)?(this.#ab(),this._uiManager.rebuild(this),this.#ag()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#ag()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){sy._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){let t,e;if(this.div)return this.div;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#ac),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;let{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#nq}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){let[i,s]=this.parentDimensions;if(this.annotationElementId){let r,n,{position:a}=this._initialData,[o,l]=this.getInitialTranslation();[o,l]=this.pageTranslationToScreen(o,l);let[h,d]=this.pageDimensions,[c,u]=this.pageTranslation;switch(this.rotation){case 0:r=t+(a[0]-c)/h,n=e+this.height-(a[1]-u)/d;break;case 90:r=t+(a[0]-c)/h,n=e-(a[1]-u)/d,[o,l]=[l,-o];break;case 180:r=t-this.width+(a[0]-c)/h,n=e-(a[1]-u)/d,[o,l]=[-o,-l];break;case 270:r=t+(a[0]-c-this.height*d)/h,n=e+(a[1]-u-this.width*h)/d,[o,l]=[-l,o]}this.setAt(r*i,n*s,o,l)}else this._moveAfterPaste(t,e);this.#ab(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static #af(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(sb,"")}editorDivPaste(t){let e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();let s=sy.#ay(e.getData("text")||"").replaceAll(sb,"\n");if(!s)return;let r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();let n=r.getRangeAt(0);if(!s.includes("\n")){n.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),r.collapseToStart();return}let{startContainer:a,startOffset:o}=n,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){let t=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(sb,"")),t!==this.editorDiv){let e=l;for(let i of this.editorDiv.childNodes){if(i===t){e=h;continue}e.push(sy.#af(i))}}l.push(a.nodeValue.slice(0,o).replaceAll(sb,""))}else if(a===this.editorDiv){let t=l,e=0;for(let i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(sy.#af(i))}this.#ad=`${l.join("\n")}${s}${h.join("\n")}`,this.#ab();let d=new Range,c=Math.sumPrecise(l.map(t=>t.length));for(let{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){let e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}r.removeAllRanges(),r.addRange(d)}#ab(){if(this.editorDiv.replaceChildren(),this.#ad)for(let t of this.#ad.split("\n")){let e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#av(){return this.#ad.replaceAll(" "," ")}static #ay(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){let t=sy._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,i){let s=null;if(t instanceof se){let{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:r,rotation:n,id:a,popupRef:o,richText:l,contentsObj:h,creationDate:d,modificationDate:c},textContent:p,textPosition:g,parent:{page:{pageNumber:m}}}=t;if(!p?.length)return null;s=t={annotationType:u.FREETEXT,color:Array.from(i),fontSize:e,value:p.join("\n"),position:g,pageIndex:m-1,rect:r.slice(0),rotation:n,annotationElementId:a,id:a,deleted:!1,popupRef:o,comment:h?.str||null,richText:l,creationDate:d,modificationDate:c}}let r=await super.deserialize(t,e,i);return r.#nq=t.fontSize,r.color=N.makeHexColor(...t.color),r.#ad=sy.#ay(t.value),r._initialData=s,t.comment&&r.setCommentData(t),r}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let e=tH._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:this.#nq,value:this.#av()});return(this.addComment(i),t)?(i.isCopy=!0,i):this.annotationElementId&&!this.#aA(i)?null:(i.id=this.annotationElementId,i)}#aA(t){let{value:e,fontSize:i,color:s,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==s[e])||t.pageIndex!==r}renderAnnotationElement(t){let e=super.renderAnnotationElement(t);if(!e)return null;let{style:i}=e;for(let t of(i.fontSize=`calc(${this.#nq}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren(),this.#ad.split("\n"))){let i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#ad}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class sv{static PRECISION=1e-4;toSVGPath(){C("Abstract method `toSVGPath` must be implemented.")}get box(){C("Abstract getter `box` must be implemented.")}serialize(t,e){C("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a]*s,n[a+1]=i+t[a+1]*r;return n}static _rescaleAndSwap(t,e,i,s,r,n){n||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)n[a]=e+t[a+1]*s,n[a+1]=i+t[a]*r;return n}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let r=0,n=t.length;r<n;r+=2)s[r]=e+t[r],s[r+1]=i+t[r+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,r){switch(r){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static createBezierPoints(t,e,i,s,r,n){return[(t+5*i)/6,(e+5*s)/6,(5*i+r)/6,(5*s+n)/6,(i+r)/2,(s+n)/2]}}class sA{#ax;#aw=[];#aC;#aS;#aE=[];#aT=new Float32Array(18);#a_;#ak;#aM;#aP;#aD;#aI;#aF=[];static #aB=8;static #aL=2;static #aR=sA.#aB+sA.#aL;constructor({x:t,y:e},i,s,r,n,a=0){this.#ax=i,this.#aI=r*s,this.#aS=n,this.#aT.set([NaN,NaN,NaN,NaN,t,e],6),this.#aC=a,this.#aP=sA.#aB*s,this.#aM=sA.#aR*s,this.#aD=s,this.#aF.push(t,e)}isEmpty(){return isNaN(this.#aT[8])}#aO(){let t=this.#aT.subarray(4,6),e=this.#aT.subarray(16,18),[i,s,r,n]=this.#ax;return[(this.#a_+(t[0]-e[0])/2-i)/r,(this.#ak+(t[1]-e[1])/2-s)/n,(this.#a_+(e[0]-t[0])/2-i)/r,(this.#ak+(e[1]-t[1])/2-s)/n]}add({x:t,y:e}){this.#a_=t,this.#ak=e;let[i,s,r,n]=this.#ax,[a,o,l,h]=this.#aT.subarray(8,12),d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#aM)return!1;let p=u-this.#aP,g=p/u,m=g*d,f=g*c,b=a,y=o;a=l,o=h,l+=m,h+=f,this.#aF?.push(t,e);let v=-f/p*this.#aI,A=m/p*this.#aI;return(this.#aT.set(this.#aT.subarray(2,8),0),this.#aT.set([l+v,h+A],4),this.#aT.set(this.#aT.subarray(14,18),12),this.#aT.set([l-v,h-A],16),isNaN(this.#aT[6]))?(0===this.#aE.length&&(this.#aT.set([a+v,o+A],2),this.#aE.push(NaN,NaN,NaN,NaN,(a+v-i)/r,(o+A-s)/n),this.#aT.set([a-v,o-A],14),this.#aw.push(NaN,NaN,NaN,NaN,(a-v-i)/r,(o-A-s)/n)),this.#aT.set([b,y,a,o,l,h],6),!this.isEmpty()):((this.#aT.set([b,y,a,o,l,h],6),Math.abs(Math.atan2(y-o,b-a)-Math.atan2(f,m))<Math.PI/2)?([a,o,l,h]=this.#aT.subarray(2,6),this.#aE.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/r,((o+h)/2-s)/n),[a,o,b,y]=this.#aT.subarray(14,18),this.#aw.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/r,((y+o)/2-s)/n)):([b,y,a,o,l,h]=this.#aT.subarray(0,6),this.#aE.push(((b+5*a)/6-i)/r,((y+5*o)/6-s)/n,((5*a+l)/6-i)/r,((5*o+h)/6-s)/n,((a+l)/2-i)/r,((o+h)/2-s)/n),[l,h,a,o,b,y]=this.#aT.subarray(12,18),this.#aw.push(((b+5*a)/6-i)/r,((y+5*o)/6-s)/n,((5*a+l)/6-i)/r,((5*o+h)/6-s)/n,((a+l)/2-i)/r,((o+h)/2-s)/n)),!0)}toSVGPath(){if(this.isEmpty())return"";let t=this.#aE,e=this.#aw;if(isNaN(this.#aT[6])&&!this.isEmpty())return this.#aN();let i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#aU(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#aH(i),i.join(" ")}#aN(){let[t,e,i,s]=this.#ax,[r,n,a,o]=this.#aO();return`M${(this.#aT[2]-t)/i} ${(this.#aT[3]-e)/s} L${(this.#aT[4]-t)/i} ${(this.#aT[5]-e)/s} L${r} ${n} L${a} ${o} L${(this.#aT[16]-t)/i} ${(this.#aT[17]-e)/s} L${(this.#aT[14]-t)/i} ${(this.#aT[15]-e)/s} Z`}#aH(t){let e=this.#aw;t.push(`L${e[4]} ${e[5]} Z`)}#aU(t){let[e,i,s,r]=this.#ax,n=this.#aT.subarray(4,6),a=this.#aT.subarray(16,18),[o,l,h,d]=this.#aO();t.push(`L${(n[0]-e)/s} ${(n[1]-i)/r} L${o} ${l} L${h} ${d} L${(a[0]-e)/s} ${(a[1]-i)/r}`)}newFreeDrawOutline(t,e,i,s,r,n){return new sx(t,e,i,s,r,n)}getOutlines(){let t=this.#aE,e=this.#aw,i=this.#aT,[s,r,n,a]=this.#ax,o=new Float32Array((this.#aF?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#aF[t]-s)/n,o[t+1]=(this.#aF[t+1]-r)/a;if(o[o.length-2]=(this.#a_-s)/n,o[o.length-1]=(this.#ak-r)/a,isNaN(i[6])&&!this.isEmpty())return this.#az(o);let l=new Float32Array(this.#aE.length+24+this.#aw.length),h=t.length;for(let e=0;e<h;e+=2){if(isNaN(t[e])){l[e]=l[e+1]=NaN;continue}l[e]=t[e],l[e+1]=t[e+1]}h=this.#aG(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2){if(isNaN(e[t+i])){l[h]=l[h+1]=NaN,h+=2;continue}l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2}return this.#a$(l,h),this.newFreeDrawOutline(l,o,this.#ax,this.#aD,this.#aC,this.#aS)}#az(t){let e=this.#aT,[i,s,r,n]=this.#ax,[a,o,l,h]=this.#aO(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/r,(e[3]-s)/n,NaN,NaN,NaN,NaN,(e[4]-i)/r,(e[5]-s)/n,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/r,(e[17]-s)/n,NaN,NaN,NaN,NaN,(e[14]-i)/r,(e[15]-s)/n],0),this.newFreeDrawOutline(d,t,this.#ax,this.#aD,this.#aC,this.#aS)}#a$(t,e){let i=this.#aw;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+=6}#aG(t,e){let i=this.#aT.subarray(4,6),s=this.#aT.subarray(16,18),[r,n,a,o]=this.#ax,[l,h,d,c]=this.#aO();return t.set([NaN,NaN,NaN,NaN,(i[0]-r)/a,(i[1]-n)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-r)/a,(s[1]-n)/o],e),e+=24}}class sx extends sv{#ax;#aj=new Float32Array(4);#aC;#aS;#aF;#aD;#aV;constructor(t,e,i,s,r,n){super(),this.#aV=t,this.#aF=e,this.#ax=i,this.#aD=s,this.#aC=r,this.#aS=n,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#aW(n);const[a,o,l,h]=this.#aj;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-a)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-a)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){let t=[`M${this.#aV[4]} ${this.#aV[5]}`];for(let e=6,i=this.#aV.length;e<i;e+=6){if(isNaN(this.#aV[e])){t.push(`L${this.#aV[e+4]} ${this.#aV[e+5]}`);continue}t.push(`C${this.#aV[e]} ${this.#aV[e+1]} ${this.#aV[e+2]} ${this.#aV[e+3]} ${this.#aV[e+4]} ${this.#aV[e+5]}`)}return t.push("Z"),t.join(" ")}serialize([t,e,i,s],r){let n,a,o=i-t,l=s-e;switch(r){case 0:n=sv._rescale(this.#aV,t,s,o,-l),a=sv._rescale(this.#aF,t,s,o,-l);break;case 90:n=sv._rescaleAndSwap(this.#aV,t,e,o,l),a=sv._rescaleAndSwap(this.#aF,t,e,o,l);break;case 180:n=sv._rescale(this.#aV,i,e,-o,l),a=sv._rescale(this.#aF,i,e,-o,l);break;case 270:n=sv._rescaleAndSwap(this.#aV,i,s,-o,-l),a=sv._rescaleAndSwap(this.#aF,i,s,-o,-l)}return{outline:Array.from(n),points:[Array.from(a)]}}#aW(t){let e=this.#aV,i=e[4],s=e[5],r=[i,s,i,s],a=i,o=s,l=i,h=s,d=t?Math.max:Math.min,c=new Float32Array(4);for(let t=6,u=e.length;t<u;t+=6){let u=e[t+4],p=e[t+5];isNaN(e[t])?(N.pointBoundingBox(u,p,r),o>p?(a=u,o=p):o===p&&(a=d(a,u)),h<p?(l=u,h=p):h===p&&(l=d(l,u))):(c.set(n,0),N.bezierBoundingBox(i,s,...e.slice(t,t+6),c),N.rectBoundingBox(...c,r),o>c[1]?(a=c[0],o=c[1]):o===c[1]&&(a=d(a,c[0])),h<c[3]?(l=c[2],h=c[3]):h===c[3]&&(l=d(l,c[2]))),i=u,s=p}let u=this.#aj;u[0]=r[0]-this.#aC,u[1]=r[1]-this.#aC,u[2]=r[2]-r[0]+2*this.#aC,u[3]=r[3]-r[1]+2*this.#aC,this.firstPoint=[a,o],this.lastPoint=[l,h]}get box(){return this.#aj}newOutliner(t,e,i,s,r,n=0){return new sA(t,e,i,s,r,n)}getNewOutline(t,e){let[i,s,r,n]=this.#aj,[a,o,l,h]=this.#ax,d=r*l,c=n*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:this.#aF[0]*d+u,y:this.#aF[1]*c+p},this.#ax,this.#aD,t,this.#aS,e??this.#aC);for(let t=2;t<this.#aF.length;t+=2)g.add({x:this.#aF[t]*d+u,y:this.#aF[t+1]*c+p});return g.getOutlines()}}class sw{#ax;#aK;#aX;#aq=[];#aY=[];constructor(t,e=0,i=0,s=!0){const r=n.slice();for(const{x:i,y:s,width:n,height:a}of t){const t=1e-4*Math.floor((i-e)/1e-4),o=1e-4*Math.ceil((i+n+e)/1e-4),l=1e-4*Math.floor((s-e)/1e-4),h=1e-4*Math.ceil((s+a+e)/1e-4),d=[t,l,h,!0],c=[o,l,h,!1];this.#aq.push(d,c),N.rectBoundingBox(t,l,o,h,r)}const a=r[2]-r[0]+2*i,o=r[3]-r[1]+2*i,l=r[0]-i,h=r[1]-i;let d=s?-1/0:1/0,c=1/0;const u=this.#aq.at(s?-1:-2),p=[u[0],u[2]];for(const t of this.#aq){const[e,i,r,n]=t;!n&&s?i<c?(c=i,d=e):i===c&&(d=Math.max(d,e)):n&&!s&&(i<c?(c=i,d=e):i===c&&(d=Math.min(d,e))),t[0]=(e-l)/a,t[1]=(i-h)/o,t[2]=(r-h)/o}this.#ax=new Float32Array([l,h,a,o]),this.#aK=[d,c],this.#aX=p}getOutlines(){this.#aq.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);let t=[];for(let e of this.#aq)e[3]?(t.push(...this.#aQ(e)),this.#aJ(e)):(this.#aZ(e),t.push(...this.#aQ(e)));return this.#a0(t)}#a0(t){let e,i=[],s=new Set;for(let e of t){let[t,s,r]=e;i.push([t,s,e],[t,r,e])}i.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,e=i.length;t<e;t+=2){let e=i[t][2],r=i[t+1][2];e.push(r),r.push(e),s.add(e),s.add(r)}let r=[];for(;s.size>0;){let t=s.values().next().value,[i,n,a,o,l]=t;s.delete(t);let h=i,d=n;for(e=[i,a],r.push(e);;){let t;if(s.has(o))t=o;else if(s.has(l))t=l;else break;s.delete(t),[i,n,a,o,l]=t,h!==i&&(e.push(h,d,i,d===n?n:a),h=i),d=d===n?a:n}e.push(h,d)}return new sC(r,this.#ax,this.#aK,this.#aX)}#a1(t){let e=this.#aY,i=0,s=e.length-1;for(;i<=s;){let r=i+s>>1,n=e[r][0];if(n===t)return r;n<t?i=r+1:s=r-1}return s+1}#aJ([,t,e]){let i=this.#a1(t);this.#aY.splice(i,0,[t,e])}#aZ([,t,e]){let i=this.#a1(t);for(let s=i;s<this.#aY.length;s++){let[i,r]=this.#aY[s];if(i!==t)break;if(i===t&&r===e)return void this.#aY.splice(s,1)}for(let s=i-1;s>=0;s--){let[i,r]=this.#aY[s];if(i!==t)break;if(i===t&&r===e)return void this.#aY.splice(s,1)}}#aQ(t){let[e,i,s]=t,r=[[e,i,s]],n=this.#a1(s);for(let t=0;t<n;t++){let[i,s]=this.#aY[t];for(let t=0,n=r.length;t<n;t++){let[,a,o]=r[t];if(!(s<=a)&&!(o<=i)){if(a>=i){if(o>s)r[t][1]=s;else{if(1===n)return[];r.splice(t,1),t--,n--}continue}r[t][2]=i,o>s&&r.push([e,s,o])}}}return r}}class sC extends sv{#ax;#a2;constructor(t,e,i,s){super(),this.#a2=t,this.#ax=e,this.firstPoint=i,this.lastPoint=s}toSVGPath(){let t=[];for(let e of this.#a2){let[i,s]=e;t.push(`M${i} ${s}`);for(let r=2;r<e.length;r+=2){let n=e[r],a=e[r+1];n===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${n}`),i=n)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],r){let n=[],a=i-t,o=s-e;for(let e of this.#a2){let i=Array(e.length);for(let r=0;r<e.length;r+=2)i[r]=t+e[r]*a,i[r+1]=s-e[r+1]*o;n.push(i)}return n}get box(){return this.#ax}}class sS extends sA{newFreeDrawOutline(t,e,i,s,r,n){return new sE(t,e,i,s,r,n)}}class sE extends sx{newOutliner(t,e,i,s,r,n=0){return new sS(t,e,i,s,r,n)}}class sT extends tH{#a3=null;#a5=0;#a6;#a4=null;#n=null;#a8=null;#a7=null;#a9=0;#ot=null;#oe=null;#T=null;#oi=!1;#aK=null;#aX=null;#os=null;#el="";#aI;#or="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=u.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){let t=sT.prototype;return k(this,"_keyboardManager",new tB([[["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.color=t.color||sT._defaultColor,this.#aI=t.thickness||sT._defaultThickness,this.opacity=t.opacity||sT._defaultOpacity,this.#a6=t.boxes||null,this.#or=t.methodOfCreation||"",this.#el=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#oi=!0,this.#on(t),this.#oa()):this.#a6&&(this.#a3=t.anchorNode,this.#a5=t.anchorOffset,this.#a7=t.focusNode,this.#a9=t.focusOffset,this.#oo(),this.#oa(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert(tH._l10nAlert.highlight)}get telemetryInitialData(){return{action:"added",type:this.#oi?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#aI,methodOfCreation:this.#or}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#oo(){let t=new sw(this.#a6,.001);this.#oe=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#oe.box;let e=new sw(this.#a6,.0025,.001,"ltr"===this._uiManager.direction);this.#a8=e.getOutlines();let{firstPoint:i}=this.#oe;this.#aK=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height];let{lastPoint:s}=this.#a8;this.#aX=[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height]}#on({highlightOutlines:t,highlightId:e,clipPathId:i}){if(this.#oe=t,this.#a8=t.getNewOutline(this.#aI/2+1.5,.0025),e>=0)this.#T=e,this.#a4=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#os=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#a8.box,path:{d:this.#a8.toSVGPath()}},!0);else if(this.parent){let e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#T,{bbox:sT.#ol(this.#oe.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#os,{bbox:sT.#ol(this.#a8.box,e),path:{d:this.#a8.toSVGPath()}})}let[s,r,n,a]=t.box;switch(this.rotation){case 0:this.x=s,this.y=r,this.width=n,this.height=a;break;case 90:{let[t,e]=this.parentDimensions;this.x=r,this.y=1-s,this.width=n*e/t,this.height=a*t/e;break}case 180:this.x=1-s,this.y=1-r,this.width=n,this.height=a;break;case 270:{let[t,e]=this.parentDimensions;this.x=1-r,this.y=s,this.width=n*e/t,this.height=a*t/e}}let{firstPoint:o}=t;this.#aK=[(o[0]-s)/n,(o[1]-r)/a];let{lastPoint:l}=this.#a8;this.#aX=[(l[0]-s)/n,(l[1]-r)/a]}static initialize(t,e){tH.initialize(t,e),sT._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case p.HIGHLIGHT_COLOR:sT._defaultColor=e;break;case p.HIGHLIGHT_THICKNESS:sT._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#aX}get commentButtonPosition(){return this.#aK}updateParams(t,e){switch(t){case p.HIGHLIGHT_COLOR:this.#nW(e);break;case p.HIGHLIGHT_THICKNESS:this.#oh(e)}}static get defaultPropertiesToUpdate(){return[[p.HIGHLIGHT_COLOR,sT._defaultColor],[p.HIGHLIGHT_THICKNESS,sT._defaultThickness]]}get propertiesToUpdate(){return[[p.HIGHLIGHT_COLOR,this.color||sT._defaultColor],[p.HIGHLIGHT_THICKNESS,this.#aI||sT._defaultThickness],[p.HIGHLIGHT_FREE,this.#oi]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#T,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#n?.updateColor(this.color),super.onUpdatedColor()}#nW(t){let e=(t,e)=>{this.color=t,this.opacity=e,this.onUpdatedColor()},i=this.color,s=this.opacity;this.addCommands({cmd:e.bind(this,t,sT._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:p.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#oh(t){let e=this.#aI,i=t=>{this.#aI=t,this.#od(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:p.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",this.#n=new iG({editor:this})]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#oc())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#oc())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#ou(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#oa(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#ou():t&&(this.#oa(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#od(t){this.#oi&&(this.#on({highlightOutlines:this.#oe.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims())}#ou(){null!==this.#T&&this.parent&&(this.parent.drawLayer.remove(this.#T),this.#T=null,this.parent.drawLayer.remove(this.#os),this.#os=null)}#oa(t=this.parent){null===this.#T&&({id:this.#T,clipPathId:this.#a4}=t.drawLayer.draw({bbox:this.#oe.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#oi},path:{d:this.#oe.toSVGPath()}},!1,!0),this.#os=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#oi},bbox:this.#a8.box,path:{d:this.#a8.toSVGPath()}},this.#oi),this.#ot&&(this.#ot.style.clipPath=this.#a4))}static #ol([t,e,i,s],r){switch(r){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){let e,{drawLayer:i}=this.parent;this.#oi?(t=(t-this.rotation+360)%360,e=sT.#ol(this.#oe.box,t)):e=sT.#ol([this.x,this.y,this.width,this.height],t),i.updateProperties(this.#T,{bbox:e,root:{"data-main-rotation":t}}),i.updateProperties(this.#os,{bbox:sT.#ol(this.#a8.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;let t=super.render();this.#el&&(t.setAttribute("aria-label",this.#el),t.setAttribute("role","mark")),this.#oi?t.classList.add("free"):this.div.addEventListener("keydown",this.#op.bind(this),{signal:this._uiManager._signal});let e=this.#ot=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#a4,this.setDims(),tM(this,this.#ot,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#os,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#os,{rootClass:{hovered:!1}})}#op(t){sT._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#og(!0);break;case 1:case 3:this.#og(!1)}}#og(t){if(!this.#a3)return;let e=window.getSelection();t?e.setPosition(this.#a3,this.#a5):e.setPosition(this.#a7,this.#a9)}select(){super.select(),this.#os&&this.parent?.drawLayer.updateProperties(this.#os,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#os&&(this.parent?.drawLayer.updateProperties(this.#os,{rootClass:{selected:!1}}),this.#oi||this.#og(!1))}get _mustFixPosition(){return!this.#oi}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#T,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#os,{rootClass:{hidden:!t}}))}#oc(){return this.#oi?this.rotation:0}#om(){if(this.#oi)return null;let[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,r=this.#a6,n=new Float32Array(8*r.length),a=0;for(let{x:o,y:l,width:h,height:d}of r){let r=o*t+i,c=(1-l)*e+s;n[a]=n[a+4]=r,n[a+1]=n[a+3]=c,n[a+2]=n[a+6]=r+h*t,n[a+5]=n[a+7]=c-d*e,a+=8}return n}#of(t){return this.#oe.serialize(t,this.#oc())}static startHighlighting(t,e,{target:i,x:s,y:r}){let{x:n,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#ob(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",ta,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",tn,{signal:d}),i.addEventListener("pointermove",this.#oy.bind(this,t),{signal:d}),this._freeHighlight=new sS({x:s,y:r},[n,a,o,l],t.scale,this._defaultThickness/2,e,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static #oy(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static #ob(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,i){let s=null;if(t instanceof sh){let{data:{quadPoints:e,rect:i,rotation:r,id:n,color:a,opacity:o,popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:p},parent:{page:{pageNumber:g}}}=t;s=t={annotationType:u.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:r,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:p}}else if(t instanceof sl){let{data:{inkLists:e,rect:i,rotation:r,id:n,color:a,borderStyle:{rawWidth:o},popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:p},parent:{page:{pageNumber:g}}}=t;s=t={annotationType:u.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:r,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:p}}let{color:r,quadPoints:n,inkLists:a,outlines:o,opacity:l}=t,h=await super.deserialize(t,e,i);h.color=N.makeHexColor(...r),h.opacity=l||1,a&&(h.#aI=t.thickness),h._initialData=s,t.comment&&h.setCommentData(t);let[d,c]=h.pageDimensions,[p,g]=h.pageTranslation;if(n){let t=h.#a6=[];for(let e=0;e<n.length;e+=8)t.push({x:(n[e]-p)/d,y:1-(n[e+1]-g)/c,width:(n[e+2]-n[e])/d,height:(n[e+1]-n[e+5])/c});h.#oo(),h.#oa(),h.rotate(h.rotation)}else if(a||o){h.#oi=!0;let t=(a||o.points)[0],i={x:t[0]-p,y:c-(t[1]-g)},s=new sS(i,[0,0,d,c],1,h.#aI/2,!0,.001);for(let e=0,r=t.length;e<r;e+=2)i.x=t[e]-p,i.y=c-(t[e+1]-g),s.add(i);let{id:r,clipPathId:n}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:h.color,"fill-opacity":h._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);h.#on({highlightOutlines:s.getOutlines(),highlightId:r,clipPathId:n}),h.#oa(),h.rotate(h.parentRotation)}return h}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();let e=tH._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return(Object.assign(i,{color:e,opacity:this.opacity,thickness:this.#aI,quadPoints:this.#om(),outlines:this.#of(i.rect)}),this.addComment(i),this.annotationElementId&&!this.#aA(i))?null:(i.id=this.annotationElementId,i)}#aA(t){let{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,i)=>t!==e[i])}renderAnnotationElement(t){return this.deleted?t.hide():t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}static canCreateNewEmptyEditor(){return!1}}class s_{#ov=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(let[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#ov[t]=e}toSVGProperties(){let t=this.#ov;return this.#ov=Object.create(null),{root:t}}reset(){this.#ov=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){C("Not implemented")}}class sk extends tH{#oA=null;#ox;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static #ow=null;static #oC=null;static #oS=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#ox=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.#oE(t),this.#oa())}#oE({drawOutlines:t,drawId:e,drawingOptions:i}){this.#oA=t,this._drawingOptions||=i,this.annotationElementId||this._uiManager.a11yAlert(tH._l10nAlert[this.editorType]),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#oT(t,this.parent),this.#o_(t.box)}#oT(t,e){let{id:i}=e.drawLayer.draw(sk._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){let i=new Set(Object.keys(t));for(let[s,r]of Object.entries(e))i.has(s)?Object.assign(t[s],r):t[s]=r;return t}static getDefaultDrawingOptions(t){C("Not implemented")}static get typesMap(){C("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){let i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(sk.#ow.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){let i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){let t=[],e=this._defaultDrawingOptions;for(let[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){let t=[],{_drawingOptions:e}=this;for(let[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){let s=this._drawingOptions,r=s[e],n=i=>{s.updateProperty(e,i);let r=this.#oA.updateProperty(e,i);r&&this.#o_(r),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties()),t===this.colorType?this.onUpdatedColor():t===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:n.bind(this,i),undo:n.bind(this,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(t,e){let i=this.constructor.typesMap.get(this.colorType),s=this.constructor.typesMap.get(this.opacityType),r=this._drawingOptions,n=r[i],a=r[s],o=(t,e)=>{r.updateProperty(i,t),r.updateProperty(s,e),this.#oA.updateProperty(i,t),this.#oA.updateProperty(s,e),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),this.onUpdatedColor(),this.onUpdatedOpacity()};this.addCommands({cmd:o.bind(this,t,e),undo:o.bind(this,n,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:p.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,sk._mergeSVGProperties(this.#oA.getPathResizingSVGProperties(this.#ok()),{bbox:this.#oM()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,sk._mergeSVGProperties(this.#oA.getPathResizedSVGProperties(this.#ok()),{bbox:this.#oM()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#oM()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,sk._mergeSVGProperties(this.#oA.getPathTranslatedSVGProperties(this.#ok(),this.parentDimensions),{bbox:this.#oM()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#ox&&(this.#ox=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#ou(),super.remove()}rebuild(){!this.parent||(super.rebuild(),null!==this.div&&(this.#oa(),this.#o_(this.#oA.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#ou()):t&&(this._uiManager.addShouldRescale(this),this.#oa(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#ou(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#oa(t=this.parent){if(null===this._drawId||this.parent!==t){if(null!==this._drawId)return void this.parent.drawLayer.updateParent(this._drawId,t.drawLayer);this._drawingOptions.updateAll(),this._drawId=this.#oT(this.#oA,t)}}#oP([t,e,i,s]){let{parentDimensions:[r,n],rotation:a}=this;switch(a){case 90:return[e,1-t,n/r*i,r/n*s];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,n/r*i,r/n*s];default:return[t,e,i,s]}}#ok(){let{x:t,y:e,width:i,height:s,parentDimensions:[r,n],rotation:a}=this;switch(a){case 90:return[1-e,t,r/n*i,n/r*s];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,r/n*i,n/r*s];default:return[t,e,i,s]}}#o_(t){[this.x,this.y,this.width,this.height]=this.#oP(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#oM(){let{x:t,y:e,width:i,height:s,rotation:r,parentRotation:n,parentDimensions:[a,o]}=this;switch((4*r+n)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-a/o*i,o/a*s,a/o*i];case 5:return[1-e,t,a/o*i,o/a*s];case 6:return[1-t-o/a*s,1-e,o/a*s,a/o*i];case 7:return[e-a/o*i,1-t-o/a*s,a/o*i,o/a*s];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-o/a*s,e,o/a*s,a/o*i];case 13:return[1-e-a/o*i,t-o/a*s,a/o*i,o/a*s];case 14:return[1-t,1-e-a/o*i,o/a*s,a/o*i];case 15:return[e,1-t,a/o*i,o/a*s];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,sk._mergeSVGProperties({bbox:this.#oM()},this.#oA.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#o_(this.#oA.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){let t,e;if(this.div)return this.div;this._isCopy&&(t=this.x,e=this.y);let i=super.render();i.classList.add("draw");let s=document.createElement("div");return i.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,s,r){C("Not implemented")}static startDrawing(t,e,i,s){let{target:r,offsetX:n,offsetY:a,pointerId:o,pointerType:l}=s;if(tP.isInitializedAndDifferentPointerType(l))return;let{viewport:{rotation:h}}=t,{width:d,height:c}=r.getBoundingClientRect(),u=sk.#oC=new AbortController,p=t.combinedSignal(u);(tP.setPointer(l,o),window.addEventListener("pointerup",t=>{tP.isSamePointerIdOrRemove(t.pointerId)&&this._endDraw(t)},{signal:p}),window.addEventListener("pointercancel",t=>{tP.isSamePointerIdOrRemove(t.pointerId)&&this._currentParent.endDrawingSession()},{signal:p}),window.addEventListener("pointerdown",t=>{tP.isSamePointerType(t.pointerType)&&(tP.initializeAndAddPointerId(t.pointerId),sk.#ow.isCancellable()&&(sk.#ow.removeLastElement(),sk.#ow.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",tn,{signal:p}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),r.addEventListener("touchmove",t=>{tP.isSameTimeStamp(t.timeStamp)&&ta(t)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),sk.#ow)?t.drawLayer.updateProperties(this._currentDrawId,sk.#ow.startNew(n,a,d,c,h)):(e.updateUIForDefaultProperties(this),sk.#ow=this.createDrawerInstance(n,a,d,c,h),sk.#oS=this.getDefaultDrawingOptions(),this._currentParent=t,{id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(sk.#oS.toSVGProperties(),sk.#ow.defaultSVGProperties),!0,!1))}static _drawMove(t){if(tP.isSameTimeStamp(t.timeStamp),!sk.#ow)return;let{offsetX:e,offsetY:i,pointerId:s}=t;if(tP.isSamePointerId(s)){if(tP.isUsingMultiplePointers())return void this._endDraw(t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,sk.#ow.add(e,i)),tP.setTimeStamp(t.timeStamp),ta(t)}}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,sk.#ow=null,sk.#oS=null,tP.clearTimeStamp()),sk.#oC&&(sk.#oC.abort(),sk.#oC=null,tP.clearPointerIds())}static _endDraw(t){let e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,sk.#ow.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){let t=sk.#ow,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:p.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(t){let e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(p.DRAW_STEP),!sk.#ow.isEmpty()){let{pageDimensions:[i,s],scale:r}=e,n=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:sk.#ow.getOutlines(i*r,s*r,r,this._INNER_MARGIN),drawingOptions:sk.#oS,mustBeCommitted:!t});return this._cleanup(!0),n}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,r,n){C("Not implemented")}static async deserialize(t,e,i){let{rawDims:{pageWidth:s,pageHeight:r,pageX:n,pageY:a}}=e.viewport,o=this.deserializeDraw(n,a,s,r,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#oE({drawOutlines:o}),l.#oa(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){let[e,i]=this.pageTranslation,[s,r]=this.pageDimensions;return this.#oA.serialize([e,i,s,r],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class sM{#aT=new Float64Array(6);#nZ;#oD;#rb;#aI;#aF;#oI="";#oF=0;#a2=new sP;#oB;#oL;constructor(t,e,i,s,r,n){this.#oB=i,this.#oL=s,this.#rb=r,this.#aI=n,[t,e]=this.#oR(t,e);const a=this.#nZ=[NaN,NaN,NaN,NaN,t,e];this.#aF=[t,e],this.#oD=[{line:a,points:this.#aF}],this.#aT.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#aI=e)}#oR(t,e){return sv._normalizePoint(t,e,this.#oB,this.#oL,this.#rb)}isEmpty(){return!this.#oD?.length}isCancellable(){return this.#aF.length<=10}add(t,e){[t,e]=this.#oR(t,e);let[i,s,r,n]=this.#aT.subarray(2,6),a=t-r,o=e-n;return 2>=Math.hypot(this.#oB*a,this.#oL*o)?null:((this.#aF.push(t,e),isNaN(i))?(this.#aT.set([r,n,t,e],2),this.#nZ.push(NaN,NaN,NaN,NaN,t,e)):(isNaN(this.#aT[0])&&this.#nZ.splice(6,6),this.#aT.set([i,s,r,n,t,e],0),this.#nZ.push(...sv.createBezierPoints(i,s,r,n,t,e))),{path:{d:this.toSVGPath()}})}end(t,e){let i=this.add(t,e);return i||(2===this.#aF.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,r){this.#oB=i,this.#oL=s,this.#rb=r,[t,e]=this.#oR(t,e);let n=this.#nZ=[NaN,NaN,NaN,NaN,t,e];this.#aF=[t,e];let a=this.#oD.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#oD.push({line:n,points:this.#aF}),this.#aT.set(n,0),this.#oF=0,this.toSVGPath(),null}getLastElement(){return this.#oD.at(-1)}setLastElement(t){return this.#oD?(this.#oD.push(t),this.#nZ=t.line,this.#aF=t.points,this.#oF=0,{path:{d:this.toSVGPath()}}):this.#a2.setLastElement(t)}removeLastElement(){if(!this.#oD)return this.#a2.removeLastElement();this.#oD.pop(),this.#oI="";for(let t=0,e=this.#oD.length;t<e;t++){let{line:e,points:i}=this.#oD[t];this.#nZ=e,this.#aF=i,this.#oF=0,this.toSVGPath()}return{path:{d:this.#oI}}}toSVGPath(){let t=sv.svgRound(this.#nZ[4]),e=sv.svgRound(this.#nZ[5]);if(2===this.#aF.length)return this.#oI=`${this.#oI} M ${t} ${e} Z`,this.#oI;if(this.#aF.length<=6){let i=this.#oI.lastIndexOf("M");this.#oI=`${this.#oI.slice(0,i)} M ${t} ${e}`,this.#oF=6}if(4===this.#aF.length){let t=sv.svgRound(this.#nZ[10]),e=sv.svgRound(this.#nZ[11]);return this.#oI=`${this.#oI} L ${t} ${e}`,this.#oF=12,this.#oI}let i=[];0===this.#oF&&(i.push(`M ${t} ${e}`),this.#oF=6);for(let t=this.#oF,e=this.#nZ.length;t<e;t+=6){let[e,s,r,n,a,o]=this.#nZ.slice(t,t+6).map(sv.svgRound);i.push(`C${e} ${s} ${r} ${n} ${a} ${o}`)}return this.#oI+=i.join(" "),this.#oF=this.#nZ.length,this.#oI}getOutlines(t,e,i,s){let r=this.#oD.at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),this.#a2.build(this.#oD,t,e,i,this.#rb,this.#aI,s),this.#aT=null,this.#nZ=null,this.#oD=null,this.#oI=null,this.#a2}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class sP extends sv{#aj;#oO=0;#aC;#oD;#oB;#oL;#oN;#rb;#aI;build(t,e,i,s,r,n,a){this.#oB=e,this.#oL=i,this.#oN=s,this.#rb=r,this.#aI=n,this.#aC=a??0,this.#oD=t,this.#oU()}get thickness(){return this.#aI}setLastElement(t){return this.#oD.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#oD.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){let t=[];for(let{line:e}of this.#oD){if(t.push(`M${sv.svgRound(e[4])} ${sv.svgRound(e[5])}`),6===e.length){t.push("Z");continue}if(12===e.length&&isNaN(e[6])){t.push(`L${sv.svgRound(e[10])} ${sv.svgRound(e[11])}`);continue}for(let i=6,s=e.length;i<s;i+=6){let[s,r,n,a,o,l]=e.subarray(i,i+6).map(sv.svgRound);t.push(`C${s} ${r} ${n} ${a} ${o} ${l}`)}}return t.join("")}serialize([t,e,i,s],r){let n,a,o,l,h,d,c,u,p,g=[],m=[],[f,b,y,v]=this.#oH();switch(this.#rb){case 0:p=sv._rescale,n=t,a=e+s,o=i,l=-s,h=t+f*i,d=e+(1-b-v)*s,c=t+(f+y)*i,u=e+(1-b)*s;break;case 90:p=sv._rescaleAndSwap,n=t,a=e,o=i,l=s,h=t+b*i,d=e+f*s,c=t+(b+v)*i,u=e+(f+y)*s;break;case 180:p=sv._rescale,n=t+i,a=e,o=-i,l=s,h=t+(1-f-y)*i,d=e+b*s,c=t+(1-f)*i,u=e+(b+v)*s;break;case 270:p=sv._rescaleAndSwap,n=t+i,a=e+s,o=-i,l=-s,h=t+(1-b-v)*i,d=e+(1-f-y)*s,c=t+(1-b)*i,u=e+(1-f)*s}for(let{line:t,points:e}of this.#oD)g.push(p(t,n,a,o,l,r?Array(t.length):null)),m.push(p(e,n,a,o,l,r?Array(e.length):null));return{lines:g,points:m,rect:[h,d,c,u]}}static deserialize(t,e,i,s,r,{paths:{lines:n,points:a},rotation:o,thickness:l}){let h,d,c,u,p,g=[];switch(o){case 0:p=sv._rescale,h=-t/i,d=e/s+1,c=1/i,u=-1/s;break;case 90:p=sv._rescaleAndSwap,h=-e/s,d=-t/i,c=1/s,u=1/i;break;case 180:p=sv._rescale,h=t/i+1,d=-e/s,c=-1/i,u=1/s;break;case 270:p=sv._rescaleAndSwap,h=e/s+1,d=t/i+1,c=-1/s,u=-1/i}if(!n)for(let t of(n=[],a)){let e=t.length;if(2===e){n.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){n.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}let i=new Float32Array(3*(e-2));n.push(i);let[s,r,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,r],0);for(let n=4;n<e;n+=2){let e=t[n],l=t[n+1];i.set(sv.createBezierPoints(s,r,a,o,e,l),(n-2)*3),[s,r,a,o]=[a,o,e,l]}}for(let t=0,e=n.length;t<e;t++)g.push({line:p(n[t].map(t=>t??NaN),h,d,c,u),points:p(a[t].map(t=>t??NaN),h,d,c,u)});let m=new this.prototype.constructor;return m.build(g,i,s,1,o,l,r),m}#oz(t=this.#aI){let e=this.#aC+t/2*this.#oN;return this.#rb%180==0?[e/this.#oB,e/this.#oL]:[e/this.#oL,e/this.#oB]}#oH(){let[t,e,i,s]=this.#aj,[r,n]=this.#oz(0);return[t+r,e+n,i-2*r,s-2*n]}#oU(){let t=this.#aj=a.slice();for(let{line:e}of this.#oD){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6)N.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],s=e[5];for(let r=6,n=e.length;r<n;r+=6){let[n,a,o,l,h,d]=e.subarray(r,r+6);N.bezierBoundingBox(i,s,n,a,o,l,h,d,t),i=h,s=d}}let[e,i]=this.#oz();t[0]=W(t[0]-e,0,1),t[1]=W(t[1]-i,0,1),t[2]=W(t[2]+e,0,1),t[3]=W(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#aj}updateProperty(t,e){return"stroke-width"===t?this.#oh(e):null}#oh(t){let[e,i]=this.#oz();this.#aI=t;let[s,r]=this.#oz(),[n,a]=[s-e,r-i],o=this.#aj;return o[0]-=n,o[1]-=a,o[2]+=2*n,o[3]+=2*a,o}updateParentDimensions([t,e],i){let[s,r]=this.#oz();this.#oB=t,this.#oL=e,this.#oN=i;let[n,a]=this.#oz(),o=n-s,l=a-r,h=this.#aj;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#oO=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#aj.map(sv.svgRound).join(" ")}get defaultProperties(){let[t,e]=this.#aj;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sv.svgRound(t)} ${sv.svgRound(e)}`}}}get rotationTransform(){let[,,t,e]=this.#aj,i=0,s=0,r=0,n=0,a=0,o=0;switch(this.#oO){case 90:s=e/t,r=-t/e,a=t;break;case 180:i=-1,n=-1,a=t,o=e;break;case 270:s=-e/t,r=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${r} ${n} ${sv.svgRound(a)} ${sv.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){let[r,n]=this.#oz(),[a,o,l,h]=this.#aj;if(Math.abs(l-r)<=sv.PRECISION||Math.abs(h-n)<=sv.PRECISION){let r=t+i/2-(a+l/2),n=e+s/2-(o+h/2);return{path:{"transform-origin":`${sv.svgRound(t)} ${sv.svgRound(e)}`,transform:`${this.rotationTransform} translate(${r} ${n})`}}}let d=(i-2*r)/(l-2*r),c=(s-2*n)/(h-2*n);return{path:{"transform-origin":`${sv.svgRound(a)} ${sv.svgRound(o)}`,transform:`${this.rotationTransform} scale(${l/i} ${h/s}) translate(${sv.svgRound(r)} ${sv.svgRound(n)}) scale(${d} ${c}) translate(${sv.svgRound(-r)} ${sv.svgRound(-n)})`}}}getPathResizedSVGProperties([t,e,i,s]){let[r,n]=this.#oz(),a=this.#aj,[o,l,h,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-r)<=sv.PRECISION||Math.abs(d-n)<=sv.PRECISION){let r=t+i/2-(o+h/2),n=e+s/2-(l+d/2);for(let{line:t,points:e}of this.#oD)sv._translate(t,r,n,t),sv._translate(e,r,n,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sv.svgRound(t)} ${sv.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}let c=(i-2*r)/(h-2*r),u=(s-2*n)/(d-2*n),p=-c*(o+r)+t+r,g=-u*(l+n)+e+n;if(1!==c||1!==u||0!==p||0!==g)for(let{line:t,points:e}of this.#oD)sv._rescale(t,p,g,c,u,t),sv._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${sv.svgRound(t)} ${sv.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){let[s,r]=i,n=this.#aj,a=t-n[0],o=e-n[1];if(this.#oB===s&&this.#oL===r)for(let{line:t,points:e}of this.#oD)sv._translate(t,a,o,t),sv._translate(e,a,o,e);else{let t=this.#oB/s,e=this.#oL/r;for(let{line:i,points:n}of(this.#oB=s,this.#oL=r,this.#oD))sv._rescale(i,a,o,t,e,i),sv._rescale(n,a,o,t,e,n);n[2]*=t,n[3]*=e}return n[0]=t,n[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${sv.svgRound(t)} ${sv.svgRound(e)}`}}}get defaultSVGProperties(){let t=this.#aj;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${sv.svgRound(t[0])} ${sv.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class sD extends s_{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:tH._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){let t=new sD(this._viewParameters);return t.updateAll(this),t}}class sI extends sk{static _type="ink";static _editorType=u.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){tH.initialize(t,e),this._defaultDrawingOptions=new sD(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return k(this,"typesMap",new Map([[p.INK_THICKNESS,"stroke-width"],[p.INK_COLOR,"stroke"],[p.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,r){return new sM(t,e,i,s,r,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,r,n){return sP.deserialize(t,e,i,s,r,n)}static async deserialize(t,e,i){let s=null;if(t instanceof sl){let{data:{inkLists:e,rect:i,rotation:r,id:n,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h,richText:d,contentsObj:c,creationDate:p,modificationDate:g},parent:{page:{pageNumber:m}}}=t;s=t={annotationType:u.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:m-1,rect:i.slice(0),rotation:r,annotationElementId:n,id:n,deleted:!1,popupRef:h,richText:d,comment:c?.str||null,creationDate:p,modificationDate:g}}let r=await super.deserialize(t,e,i);return r._initialData=s,t.comment&&r.setCommentData(t),r}get toolbarButtons(){return this._colorPicker||=new i$(this),[["colorPicker",this._colorPicker]]}get colorType(){return p.INK_COLOR}get colorAndOpacityType(){return p.INK_COLOR_AND_OPACITY}get opacityType(){return p.INK_OPACITY}updateParams(t,e){t===p.INK_COLOR_AND_OPACITY?this._updateColorAndOpacity(e.color,e.opacity):super.updateParams(t,e)}static updateDefaultParams(t,e){if(t===p.INK_COLOR_AND_OPACITY){super.updateDefaultParams(p.INK_COLOR,e.color),super.updateDefaultParams(p.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();let{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){let t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=sI.getDefaultDrawingOptions({stroke:N.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{stroke:s,"stroke-opacity":r,"stroke-width":n}}=this,a=Object.assign(super.serialize(t),{color:tH._colorManager.convert(s),opacity:r,thickness:n,paths:{lines:e,points:i}});return(this.addComment(a),t)?(a.isCopy=!0,a):this.annotationElementId&&!this.#aA(a)?null:(a.id=this.annotationElementId,a)}#aA(t){let{color:e,thickness:i,opacity:s,pageIndex:r}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==s||t.pageIndex!==r}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class sF extends sP{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class sB{static #oG={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static #o$(t,e,i,s){return(i-=t,s-=e,0===i)?s>0?0:4:1===i?s+6:2-s}static #oj=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static #oV(t,e,i,s,r,n,a){let o=this.#o$(i,s,r,n);for(let r=0;r<8;r++){let n=(-r+o-a+16)%8;if(0!==t[(i+this.#oj[2*n])*e+(s+this.#oj[2*n+1])])return n}return -1}static #oW(t,e,i,s,r,n,a){let o=this.#o$(i,s,r,n);for(let r=0;r<8;r++){let n=(r+o+a+16)%8;if(0!==t[(i+this.#oj[2*n])*e+(s+this.#oj[2*n+1])])return n}return -1}static #oK(t,e,i,s){let r,n=t.length,a=new Int32Array(n);for(let e=0;e<n;e++)a[e]=+(t[e]<=s);for(let t=1;t<i-1;t++)a[t*e]=a[t*e+e-1]=0;for(let t=0;t<e;t++)a[t]=a[e*i-1-t]=0;let o=1,l=[];for(let t=1;t<i-1;t++){r=1;for(let i=1;i<e-1;i++){let s,n=t*e+i,h=a[n];if(0===h)continue;let d=t,c=i;if(1===h&&0===a[n-1])o+=1,c-=1;else if(h>=1&&0===a[n+1])o+=1,c+=1,h>1&&(r=h);else{1!==h&&(r=Math.abs(h));continue}let u=[i,t],p=c===i+1,g={isHole:p,points:u,id:o,parent:0};for(let t of(l.push(g),l))if(t.id===r){s=t;break}s?s.isHole?g.parent=p?s.parent:r:g.parent=p?r:s.parent:g.parent=p?r:0;let m=this.#oV(a,e,t,i,d,c,0);if(-1===m){a[n]=-o,1!==a[n]&&(r=Math.abs(a[n]));continue}let f=this.#oj[2*m],b=this.#oj[2*m+1],y=t+f,v=i+b;d=y,c=v;let A=t,x=i;for(;;){let s=this.#oW(a,e,A,x,d,c,1);f=this.#oj[2*s],b=this.#oj[2*s+1];let l=A+f,h=x+b;u.push(h,l);let p=A*e+x;if(0===a[p+1]?a[p]=-o:1===a[p]&&(a[p]=o),l===t&&h===i&&A===y&&x===v){1!==a[n]&&(r=Math.abs(a[n]));break}d=A,c=x,A=l,x=h}}}return l}static #oX(t,e,i,s){if(i-e<=4){for(let r=e;r<i-2;r+=2)s.push(t[r],t[r+1]);return}let r=t[e],n=t[e+1],a=t[i-4]-r,o=t[i-3]-n,l=Math.hypot(a,o),h=a/l,d=o/l,c=h*n-d*r,u=1/l,p=Math.atan(o/a),g=Math.cos(p),m=Math.sin(p),f=u*(Math.abs(g)+Math.abs(m)),b=u*(1-f+f**2),y=Math.max(Math.atan(Math.abs(m+g)*b),Math.atan(Math.abs(m-g)*b)),v=0,A=e;for(let s=e+2;s<i-2;s+=2){let e=Math.abs(c-h*t[s+1]+d*t[s]);e>v&&(A=s,v=e)}v>(l*y)**2?(this.#oX(t,e,A+2,s),this.#oX(t,A,i,s)):s.push(r,n)}static #oq(t){let e=[],i=t.length;return this.#oX(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static #oY(t,e,i,s,r,n){let a=new Float32Array(n**2),o=-2*s**2,l=n>>1;for(let t=0;t<n;t++){let e=(t-l)**2;for(let i=0;i<n;i++)a[t*n+i]=Math.exp((e+(i-l)**2)/o)}let h=new Float32Array(256),d=-2*r**2;for(let t=0;t<256;t++)h[t]=Math.exp(t**2/d);let c=new Uint8Array(t.length),u=new Uint32Array(256);for(let s=0;s<i;s++)for(let r=0;r<e;r++){let o=s*e+r,d=t[o],p=0,g=0;for(let o=0;o<n;o++){let c=s+o-l;if(!(c<0)&&!(c>=i))for(let i=0;i<n;i++){let s=r+i-l;if(s<0||s>=e)continue;let u=t[c*e+s],m=a[o*n+i]*h[Math.abs(u-d)];p+=u*m,g+=m}}let m=c[o]=Math.round(p/g);u[m]++}return[c,u]}static #oQ(t){let e=new Uint32Array(256);for(let i of t)e[i]++;return e}static #oJ(t){let e=new Uint8ClampedArray(t.length>>2),i=-1/0,s=1/0;for(let r=0,n=e.length;r<n;r++){let n=e[r]=t[r<<2];i=Math.max(i,n),s=Math.min(s,n)}let r=255/(i-s);for(let t=0,i=e.length;t<i;t++)e[t]=(e[t]-s)*r;return e}static #oZ(t){let e,i=-1/0,s=-1/0,r=t.findIndex(t=>0!==t),n=r,a=r;for(e=r;e<256;e++){let r=t[e];r>i&&(e-n>s&&(s=e-n,a=e-1),i=r,n=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static #o0(t){let e=t,{width:i,height:s}=t,{maxDim:r}=this.#oG,n=i,a=s;if(i>r||s>r){let o=i,l=s,h=Math.log2(Math.max(i,s)/r),d=Math.floor(h);h=h===d?d-1:d;for(let i=0;i<h;i++){let i=new OffscreenCanvas(n=Math.ceil(o/2),a=Math.ceil(l/2));i.getContext("2d").drawImage(t,0,0,o,l,0,0,n,a),o=n,l=a,t!==e&&t.close(),t=i.transferToImageBitmap()}let c=Math.min(r/n,r/a);n=Math.round(n*c),a=Math.round(a*c)}let o=new OffscreenCanvas(n,a).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,n,a),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,n,a);let l=o.getImageData(0,0,n,a).data;return[this.#oJ(l),n,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:s},r,n,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1}),d=h.font=`${i} ${s} 200px ${e}`,{actualBoundingBoxLeft:c,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:m,fontBoundingBoxDescent:f,width:b}=h.measureText(t),y=Math.ceil(1.5*Math.max(Math.abs(c)+Math.abs(u)||0,b)),v=Math.ceil(1.5*Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(m)+Math.abs(f)||200));(h=(l=new OffscreenCanvas(y,v)).getContext("2d",{alpha:!0,willReadFrequently:!0})).font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,y,v),h.fillStyle="black",h.fillText(t,.5*y/2,1.5*v/2);let A=this.#oJ(h.getImageData(0,0,y,v).data),x=this.#oQ(A),w=this.#oZ(x),C=this.#oK(A,y,v,w);return this.processDrawnLines({lines:{curves:C,width:y,height:v},pageWidth:r,pageHeight:n,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,s,r){let[n,a,o]=this.#o0(t),[l,h]=this.#oY(n,a,o,Math.hypot(a,o)*this.#oG.sigmaSFactor,this.#oG.sigmaR,this.#oG.kernelSize),d=this.#oZ(h),c=this.#oK(l,a,o,d);return this.processDrawnLines({lines:{curves:c,width:a,height:o},pageWidth:e,pageHeight:i,rotation:s,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:r,mustSmooth:n,areContours:a}){s%180!=0&&([e,i]=[i,e]);let{curves:o,width:l,height:h}=t,d=t.thickness??0,c=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,m=[];for(let{points:t}of o){let e=n?this.#oq(t):t;if(!e)continue;m.push(e);let i=e.length,s=new Float32Array(i),r=new Float32Array(3*(2===i?2:i-2));if(c.push({line:r,points:s}),2===i){s[0]=e[0]*p,s[1]=e[1]*g,r.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let[a,o,l,h]=e;a*=p,o*=g,l*=p,h*=g,s.set([a,o,l,h],0),r.set([NaN,NaN,NaN,NaN,a,o],0);for(let t=4;t<i;t+=2){let i=s[t]=e[t]*p,n=s[t+1]=e[t+1]*g;r.set(sv.createBezierPoints(a,o,l,h,i,n),(t-2)*3),[a,o,l,h]=[l,h,i,n]}}if(0===c.length)return null;let f=a?new sF:new sP;return f.build(c,e,i,1,s,a?0:d,r),{outline:f,newCurves:m,areContours:a,thickness:d,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:s,height:r}){let n,a=1/0,o=-1/0,l=0;for(let e of t){l+=e.length;for(let t=2,i=e.length;t<i;t++){let i=e[t]-e[t-2];a=Math.min(a,i),o=Math.max(o,i)}}n=a>=-128&&o<=127?Int8Array:a>=-32768&&o<=32767?Int16Array:Int32Array;let h=t.length,d=8+3*h,c=new Uint32Array(d),u=0;for(let a of(c[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*n.BYTES_PER_ELEMENT,c[u++]=0,c[u++]=s,c[u++]=r,c[u++]=+!e,c[u++]=Math.max(0,Math.floor(i??0)),c[u++]=h,c[u++]=n.BYTES_PER_ELEMENT,t))c[u++]=a.length-2,c[u++]=a[0],c[u++]=a[1];let p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(c);let m=n.prototype.constructor;for(let e of t){let t=new m(e.length-2);for(let i=2,s=e.length;i<s;i++)t[i-2]=e[i]-e[i-2];g.write(t)}return g.close(),(await new Response(p.readable).bytes()).toBase64()}static async decompressSignature(t){try{let e,i=Uint8Array.fromBase64(t),{readable:s,writable:r}=new DecompressionStream("deflate-raw"),n=r.getWriter();await n.ready,n.write(i).then(async()=>{await n.ready,await n.close()}).catch(()=>{});let a=null,o=0;for await(let t of s)(a||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0])).set(t,o),o+=t.length;let l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(0!==h)throw Error(`Invalid version: ${h}`);let d=l[2],c=l[3],u=0===l[4],p=l[5],g=l[6],m=l[7],f=[],b=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;switch(m){case Int8Array.BYTES_PER_ELEMENT:e=new Int8Array(a.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:e=new Int16Array(a.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:e=new Int32Array(a.buffer,b)}o=0;for(let t=0;t<g;t++){let i=l[3*t+8],s=new Float32Array(i+2);f.push(s);for(let e=0;e<2;e++)s[e]=l[3*t+8+e+1];for(let t=0;t<i;t++)s[t+2]=s[t]+e[o++]}return{areContours:u,thickness:p,outlines:f,width:d,height:c}}catch(t){return w(`decompressSignature: ${t}`),null}}}class sL extends s_{constructor(){super(),super.updateProperties({fill:tH._defaultLineColor,"stroke-width":0})}clone(){let t=new sL;return t.updateAll(this),t}}class sR extends sD{constructor(t){super(t),super.updateProperties({stroke:tH._defaultLineColor,"stroke-width":1})}clone(){let t=new sR(this._viewParameters);return t.updateAll(this),t}}class sO extends sk{#o1=!1;#o2=null;#o3=null;#o5=null;static _type="signature";static _editorType=u.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#o3=t.signatureData||null,this.#o2=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){tH.initialize(t,e),this._defaultDrawingOptions=new sL,this._defaultDrawnSignatureOptions=new sR(e.viewParameters)}static getDefaultDrawingOptions(t){let e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return k(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#o2}}static computeTelemetryFinalData(t){let e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){let t,e;if(this.div)return this.div;let{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#o3){let{lines:t,mustSmooth:e,areContours:i,description:s,uuid:r,heightInPage:n}=this.#o3,{rawDims:{pageWidth:a,pageHeight:o},rotation:l}=this.parent.viewport,h=sB.processDrawnLines({lines:t,pageWidth:a,pageHeight:o,rotation:l,innerMargin:sO._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(h,n,s,r)}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.#o2||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#o5=t,this.addEditToolbar()}getUuid(){return this.#o5}get description(){return this.#o2}set description(t){this.#o2=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){let{newCurves:t,areContours:e,thickness:i,width:s,height:r}=this.#o3,n=Math.max(s,r),a=sB.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:i,width:s,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,i,s){let r,{x:n,y:a}=this,{outline:o}=this.#o3=t;this.#o1=o instanceof sF,this.description=i,this.#o1?r=sO.getDefaultDrawingOptions():(r=sO._defaultDrawnSignatureOptions.clone()).updateProperties({"stroke-width":o.thickness}),this._addOutlines({drawOutlines:o,drawingOptions:r});let[,l]=this.pageDimensions,h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=n,this.y=a,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(s),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!s,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){let{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return sB.process(t,e,i,s,sO._INNER_MARGIN)}getFromText(t,e){let{rawDims:{pageWidth:i,pageHeight:s},rotation:r}=this.parent.viewport;return sB.extractContoursFromText(t,e,i,s,r,sO._INNER_MARGIN)}getDrawnSignature(t){let{rawDims:{pageWidth:e,pageHeight:i},rotation:s}=this.parent.viewport;return sB.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:s,innerMargin:sO._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=sO.getDefaultDrawingOptions():(this._drawingOptions=sO._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;let{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":s}}=this,r=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#o1,color:[0,0,0],thickness:this.#o1?0:s});return this.addComment(r),t?(r.paths={lines:e,points:i},r.uuid=this.#o5,r.isCopy=!0):r.lines=e,this.#o2&&(r.accessibilityData={type:"Figure",alt:this.#o2}),r}static deserializeDraw(t,e,i,s,r,n){return n.areContours?sF.deserialize(t,e,i,s,r,n):sP.deserialize(t,e,i,s,r,n)}static async deserialize(t,e,i){let s=await super.deserialize(t,e,i);return s.#o1=t.areContours,s.description=t.accessibilityData?.alt||"",s.#o5=t.uuid,s}}class sN extends tH{#o6=null;#o4=null;#o8=null;#o7=null;#o9=null;#lt="";#le=null;#li=!1;#ls=null;#lr=!1;#ln=!1;static _type="stamp";static _editorType=u.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#o7=t.bitmapUrl,this.#o9=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){tH.initialize(t,e)}static isHandlingMimeForPasting(t){return tg.includes(t)}static paste(t,e){e.pasteEditor({mode:u.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){let e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#la(t,e=!1){t?(this.#o6=t.bitmap,e||(this.#o4=t.id,this.#lr=t.isSvg),t.file&&(this.#lt=t.file.name),this.#lo()):this.remove()}#ll(){if(this.#o8=null,this._uiManager.enableWaiting(!1),this.#le){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#o6)return void this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#o6){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;let{mlManager:i}=this._uiManager;if(!i)throw Error("No ML.");if(!await i.isEnabledFor("altText"))throw Error("ML isn't enabled for alt text.");let{data:s,width:r,height:n}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:r,height:n,channels:s.length/(r*n)}});if(!a)throw Error("No response from the AI service.");if(a.error)throw Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw Error("No valid response from the AI service.");let o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#lh(){if(this.#o4){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#o4).then(t=>this.#la(t,!0)).finally(()=>this.#ll());return}if(this.#o7){let t=this.#o7;this.#o7=null,this._uiManager.enableWaiting(!0),this.#o8=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#la(t)).finally(()=>this.#ll());return}if(this.#o9){let t=this.#o9;this.#o9=null,this._uiManager.enableWaiting(!0),this.#o8=this._uiManager.imageManager.getFromFile(t).then(t=>this.#la(t)).finally(()=>this.#ll());return}let t=document.createElement("input");t.type="file",t.accept=tg.join(",");let e=this._uiManager._signal;this.#o8=new Promise(i=>{t.addEventListener("change",async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);let e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#la(e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#ll()),t.click()}remove(){this.#o4&&(this.#o6=null,this._uiManager.imageManager.deleteId(this.#o4),this.#le?.remove(),this.#le=null,this.#ls&&(clearTimeout(this.#ls),this.#ls=null)),super.remove()}rebuild(){if(!this.parent){this.#o4&&this.#lh();return}super.rebuild(),null!==this.div&&(this.#o4&&null===this.#le&&this.#lh(),this.isAttachedToDOM||this.parent.add(this))}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#o8||this.#o6||this.#o7||this.#o9||this.#o4||this.#li)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){let t,e;return this.div||(this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#li||(this.#o6?this.#lo():this.#lh()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this)),this.div}setCanvas(t,e){let{id:i,bitmap:s}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#o4=i,s&&(this.#o6=s),this.#li=!1,this.#lo())}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#ls&&clearTimeout(this.#ls),this.#ls=setTimeout(()=>{this.#ls=null,this.#ld()},200))}#lo(){let{div:t}=this,{width:e,height:i}=this.#o6,[s,r]=this.pageDimensions;if(this.width)e=this.width*s,i=this.height*r;else if(e>.75*s||i>.75*r){let t=Math.min(.75*s/e,.75*r/i);e*=t,i*=t}this._uiManager.enableWaiting(!1);let n=this.#le=document.createElement("canvas");n.setAttribute("role","img"),this.addContainer(n),this.width=e/s,this.height=i/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.#ld(),this.#ln||(this.parent.addUndoableEditor(this),this.#ln=!0),this._reportTelemetry({action:"inserted_image"}),this.#lt&&this.div.setAttribute("aria-description",this.#lt),this.annotationElementId||this._uiManager.a11yAlert(tH._l10nAlert.stamp)}copyCanvas(t,e,i=!1){t||(t=224);let{width:s,height:r}=this.#o6,n=new tp,a=this.#o6,o=s,l=r,h=null;if(e){if(s>e||r>e){let t=Math.min(e/s,e/r);o=Math.floor(s*t),l=Math.floor(r*t)}let t=(h=document.createElement("canvas")).width=Math.ceil(o*n.sx),i=h.height=Math.ceil(l*n.sy);this.#lr||(a=this.#lc(t,i));let d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":tm.isDarkMode&&(c="#8f8f9d",u="#42414d");let p=15*n.sx,g=15*n.sy,m=new OffscreenCanvas(2*p,2*g),f=m.getContext("2d");f.fillStyle=c,f.fillRect(0,0,2*p,2*g),f.fillStyle=u,f.fillRect(0,0,p,g),f.fillRect(p,g,p,g),d.fillStyle=d.createPattern(m,"repeat"),d.fillRect(0,0,t,i),d.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let d=null;if(i){let e,i;if(n.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=this.#o6,s>t||r>t){let n=Math.min(t/s,t/r);e=Math.floor(s*n),i=Math.floor(r*n),this.#lr||(a=this.#lc(e,i))}let o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),d={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:d}}#lc(t,e){let{width:i,height:s}=this.#o6,r=i,n=s,a=this.#o6;for(;r>2*t||n>2*e;){let i=r,s=n;r>2*t&&(r=Math.ceil(r/2)),n>2*e&&(n=Math.ceil(n/2));let o=new OffscreenCanvas(r,n);o.getContext("2d").drawImage(a,0,0,i,s,0,0,r,n),a=o.transferToImageBitmap()}return a}#ld(){let[t,e]=this.parentDimensions,{width:i,height:s}=this,r=new tp,n=Math.ceil(i*t*r.sx),a=Math.ceil(s*e*r.sy),o=this.#le;if(!o||o.width===n&&o.height===a)return;o.width=n,o.height=a;let l=this.#lr?this.#o6:this.#lc(n,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,n,a)}#lu(t){if(t){if(this.#lr){let t=this._uiManager.imageManager.getSvgUrl(this.#o4);if(t)return t}let t=document.createElement("canvas");return{width:t.width,height:t.height}=this.#o6,t.getContext("2d").drawImage(this.#o6,0,0),t.toDataURL()}if(this.#lr){let[t,e]=this.pageDimensions,i=Math.round(this.width*t*Y.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*Y.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(i,s);return r.getContext("2d").drawImage(this.#o6,0,0,this.#o6.width,this.#o6.height,0,0,i,s),r.transferToImageBitmap()}return structuredClone(this.#o6)}static async deserialize(t,e,i){let s=null,r=!1;if(t instanceof sp){let n,a,{data:{rect:o,rotation:l,id:h,structParent:c,popupRef:p,richText:g,contentsObj:m,creationDate:f,modificationDate:b},container:y,parent:{page:{pageNumber:v}},canvas:A}=t;A?(delete t.canvas,{id:n,bitmap:a}=i.imageManager.getFromCanvas(y.id,A),A.remove()):(r=!0,t._hasNoCanvas=!0);let x=(await e._structTree.getAriaAttributes(`${d}${h}`))?.get("aria-label")||"";s=t={annotationType:u.STAMP,bitmapId:n,bitmap:a,pageIndex:v-1,rect:o.slice(0),rotation:l,annotationElementId:h,id:h,deleted:!1,accessibilityData:{decorative:!1,altText:x},isSvg:!1,structParent:c,popupRef:p,richText:g,comment:m?.str||null,creationDate:f,modificationDate:b}}let n=await super.deserialize(t,e,i),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:c,accessibilityData:p}=t;r?(i.addMissingCanvas(t.id,n),n.#li=!0):h&&i.imageManager.isValidId(h)?(n.#o4=h,o&&(n.#o6=o)):n.#o7=l,n.#lr=c;let[g,m]=n.pageDimensions;return n.width=(a[2]-a[0])/g,n.height=(a[3]-a[1])/m,p&&(n.altTextData=p),n._initialData=s,t.comment&&n.setCommentData(t),n.#ln=!!s,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();let i=Object.assign(super.serialize(t),{bitmapId:this.#o4,isSvg:this.#lr});if(this.addComment(i),t)return i.bitmapUrl=this.#lu(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;let{decorative:s,altText:r}=this.serializeAltText(!1);if(!s&&r&&(i.accessibilityData={type:"Figure",alt:r}),this.annotationElementId){let t=this.#aA(i);return t.isSame?null:(t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(null===e)return i;e.stamps||=new Map;let n=this.#lr?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#o4)){if(this.#lr){let t=e.stamps.get(this.#o4);n>t.area&&(t.area=n,t.serialized.bitmap.close(),t.serialized.bitmap=this.#lu(!1))}}else e.stamps.set(this.#o4,{area:n,serialized:i}),i.bitmap=this.#lu(!1);return i}#aA(t){let{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,r=(t.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&s&&r,isSameAltText:r}}renderAnnotationElement(t){return this.deleted?t.hide():t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null}}class sU{#ai;#lp=!1;#lg=null;#lm=null;#lf=null;#lb=new Map;#ly=!1;#lv=!1;#lA=!1;#lx=null;#lw=null;#lC=null;#lS=null;#lE=null;#lT=-1;#y;static _initialized=!1;static #J=new Map([sy,sI,sN,sT,sO].map(t=>[t._editorType,t]));constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:s,accessibilityManager:r,annotationLayer:n,drawLayer:a,textLayer:o,viewport:l,l10n:h}){const d=[...sU.#J.values()];if(!sU._initialized)for(const e of(sU._initialized=!0,d))e.initialize(h,t);t.registerEditorTypes(d),this.#y=t,this.pageIndex=e,this.div=i,this.#ai=r,this.#lg=n,this.viewport=l,this.#lC=o,this.drawLayer=a,this._structTree=s,this.#y.addLayer(this)}get isEmpty(){return 0===this.#lb.size}get isInvisible(){return this.isEmpty&&this.#y.getMode()===u.NONE}updateToolbar(t){this.#y.updateToolbar(t)}updateMode(t=this.#y.getMode()){switch(this.#l_(),t){case u.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case u.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case u.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===u.POPUP)e.toggle("commentEditing",!0);else for(let i of(e.toggle("commentEditing",!1),sU.#J.values()))e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#lC?.div}setEditingState(t){this.#y.setEditingState(t)}addCommands(t){this.#y.addCommands(t)}cleanUndoStack(t){this.#y.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#lg?.togglePointerEvents(t)}get #lk(){return 0!==this.#lb.size?this.#lb.values():this.#y.getEditors(this.pageIndex)}async enable(){this.#lA=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#lE?.abort(),this.#lE=null;let t=new Set;for(let e of this.#lk)e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#y.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));let e=this.#lg;if(e)for(let i of e.getEditableAnnotations()){if(i.hide(),this.#y.isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;let e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#lA=!1,this.#y._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#lv=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#lC&&!this.#lE){this.#lE=new AbortController;let t=this.#y.combinedSignal(this.#lE);this.#lC.div.addEventListener("pointerdown",t=>{let e,{clientX:i,clientY:s,timeStamp:r}=t;if(r-this.#lT>500){this.#lT=r;return}this.#lT=-1;let{classList:n}=this.div;n.toggle("getElements",!0);let a=document.elementsFromPoint(i,s);if(n.toggle("getElements",!1),!this.div.contains(a[0]))return;let o=RegExp(`^${c}[0-9]+$`);for(let t of a)if(o.test(t.id)){e=t.id;break}if(!e)return;let l=this.#lb.get(e);l?.annotationElementId===null&&(ta(t),l.dblclick(t))},{signal:t,capture:!0})}let t=this.#lg,e=[];if(t){let i=new Map,s=new Map;for(let t of this.#lk){if(t.disableEditing(),!t.annotationElementId){e.push(t);continue}if(null!==t.serialize()){i.set(t.annotationElementId,t);continue}s.set(t.annotationElementId,t),this.getEditableAnnotation(t.annotationElementId)?.show(),t.remove()}for(let e of t.getEditableAnnotations()){let{id:t}=e.data;if(this.#y.isDeletedAnnotationElement(t)){e.updateEdited({deleted:!0});continue}let r=s.get(t);if(r){r.resetAnnotationElement(e),r.show(!1),e.show();continue}(r=i.get(t))&&(this.#y.addChangedExistingAnnotation(r),r.renderAnnotationElement(e)&&r.show(!1)),e.show()}}this.#l_(),this.isEmpty&&(this.div.hidden=!0);let{classList:i}=this.div;for(let t of sU.#J.values())i.remove(`${t._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t?.updateFakeAnnotations(e),this.#lv=!1}getEditableAnnotation(t){return this.#lg?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#y.getActive()!==t&&this.#y.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#lC?.div&&!this.#lS){this.#lS=new AbortController;let t=this.#y.combinedSignal(this.#lS);this.#lC.div.addEventListener("pointerdown",this.#lM.bind(this),{signal:t}),this.#lC.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#lC?.div&&this.#lS&&(this.#lS.abort(),this.#lS=null,this.#lC.div.classList.remove("highlighting"))}#lM(t){this.#y.unselectAll();let{target:e}=t;if(e===this.#lC.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent")||e.classList.contains("textLayerImages")||e.classList.contains("textLayerImagePlaceholder"))&&this.#lC.div.contains(e)){let{isMac:e}=O.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#y.showAllEditors("highlight",!0,!0),this.#lC.div.classList.add("free"),this.toggleDrawing(),sT.startHighlighting(this,"ltr"===this.#y.direction,{target:this.#lC.div,x:t.x,y:t.y}),this.#lC.div.addEventListener("pointerup",()=>{this.#lC.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#y._signal}),t.preventDefault()}}enableClick(){if(this.#lm)return;this.#lm=new AbortController;let t=this.#y.combinedSignal(this.#lm);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});let e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#lm?.abort(),this.#lm=null}attach(t){this.#lb.set(t.id,t);let{annotationElementId:e}=t;e&&this.#y.isDeletedAnnotationElement(e)&&this.#y.removeDeletedAnnotationElement(t)}detach(t){this.#lb.delete(t.id),this.#ai?.removePointerInTextLayer(t.contentDiv),!this.#lv&&t.annotationElementId&&this.#y.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#y.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#y.addDeletedAnnotationElement(t),tH.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.#y.addEditor(t),this.attach(t),!t.isAttachedToDOM){let e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#lA),this.#y.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;let{activeElement:e}=document;t.div.contains(e)&&!this.#lf&&(t._focusEventsAllowed=!1,this.#lf=setTimeout(()=>{this.#lf=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#y._signal}),e.focus())},0)),t._structTreeParentId=this.#ai?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getEditorByUID(t){for(let e of this.#lb.values())if(e.uid===t)return e;return null}get #lP(){return sU.#J.get(this.#y.getMode())}combinedSignal(t){return this.#y.combinedSignal(t)}#lD(t){let e=this.#lP;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#lP?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#y.updateMode(t.mode);let{offsetX:i,offsetY:s}=this.#lI(),r=this.#y.getId(),n=this.#lD({parent:this,id:r,x:i,y:s,uiManager:this.#y,isCentered:!0,...e});n&&this.add(n)}async deserialize(t){return await sU.#J.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#y)||null}createAndAddNewEditor(t,e,i={}){let s=this.#y.getId(),r=this.#lD({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#y,isCentered:e,...i});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}#lI(){let{x:t,y:e,width:i,height:s}=this.boundingClientRect,r=Math.max(0,t),n=Math.max(0,e),a=Math.min(window.innerWidth,t+i),o=Math.min(window.innerHeight,e+s),l=(r+a)/2-t,h=(n+o)/2-e,[d,c]=this.viewport.rotation%180==0?[l,h]:[h,l];return{offsetX:d,offsetY:c}}addNewEditor(t={}){this.createAndAddNewEditor(this.#lI(),!0,t)}setSelected(t){this.#y.setSelected(t)}toggleSelected(t){this.#y.toggleSelected(t)}unselect(t){this.#y.unselect(t)}pointerup(t){let{isMac:e}=O.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div||!this.#ly||(this.#ly=!1,this.#lP?.isDrawer&&this.#lP.supportMultipleDrawings))return;if(!this.#lp){this.#lp=!0;return}let i=this.#y.getMode();i===u.STAMP||i===u.POPUP||i===u.SIGNATURE?this.#y.unselectAll():this.createAndAddNewEditor(t,!1)}pointerdown(t){if(this.#y.getMode()===u.HIGHLIGHT&&this.enableTextSelection(),this.#ly){this.#ly=!1;return}let{isMac:e}=O.platform;if(0!==t.button||t.ctrlKey&&e||t.target!==this.div)return;if(this.#ly=!0,this.#lP?.isDrawer)return void this.startDrawingSession(t);let i=this.#y.getActive();this.#lp=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#lx)return void this.#lP.startDrawing(this,this.#y,!1,t);this.#y.setCurrentDrawingSession(this),this.#lx=new AbortController;let e=this.#y.combinedSignal(this.#lx);this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#lw=null,this.commitOrRemove())},{signal:e}),this.#lP.startDrawing(this,this.#y,!1,t)}pause(t){if(t){let{activeElement:t}=document;this.div.contains(t)&&(this.#lw=t);return}this.#lw&&setTimeout(()=>{this.#lw?.focus(),this.#lw=null},0)}endDrawingSession(t=!1){return this.#lx?(this.#y.setCurrentDrawingSession(null),this.#lx.abort(),this.#lx=null,this.#lw=null,this.#lP.endDrawing(t)):null}findNewParent(t,e,i){let s=this.#y.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#lx&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#lx&&this.#lP.onScaleChangingWhenDrawing(this)}destroy(){for(let t of(this.commitOrRemove(),this.#y.getActive()?.parent===this&&(this.#y.commitOrRemove(),this.#y.setActiveEditor(null)),this.#lf&&(clearTimeout(this.#lf),this.#lf=null),this.#lb.values()))this.#ai?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#lb.clear(),this.#y.removeLayer(this)}#l_(){for(let t of this.#lb.values())t.isEmpty()&&t.remove()}async render({viewport:t}){for(let e of(this.viewport=t,tu(this.div,t),this.#y.getEditors(this.pageIndex)))this.add(e),e.rebuild();await this.#y.findClonesForPage(this),this.div.hidden=this.isEmpty,this.updateMode()}update({viewport:t}){this.#y.commitOrRemove(),this.#l_();let e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,tu(this.div,{rotation:i}),e!==i)for(let t of this.#lb.values())t.rotate(i)}get pageDimensions(){let{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#y.viewParameters.realScale}}function sH(t,e){return t===e?0:t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function sz(t){return t?t.nodeType===Node.ELEMENT_NODE?t.closest(".textLayer"):t.parentElement?.closest(".textLayer")||null:null}function sG(t,e,i){if(t.nodeType!==Node.ELEMENT_NODE||!t.classList.contains("textLayer")||e!==t.childNodes.length)return{container:t,offset:e};let s=t.lastChild;return(s?.nodeType===Node.ELEMENT_NODE&&s.classList.contains("endOfContent")&&(s=s.previousSibling),s&&i.contains(s))?s.nodeType===Node.TEXT_NODE?{container:s,offset:s.textContent.length}:{container:s,offset:s.childNodes.length}:null}class s${#nI=null;#lF=new Map;#lC=null;#ts=null;#tw=null;#lB=null;#lL=new Map;static #T=0;static #lR=0;static #lO=null;static #lN=new Set;static #lU=!1;static #lH=new Set;static #lz=new WeakMap;constructor({filterFactory:t=null,pageColors:e=null,pageIndex:i,textLayer:s=null}){if(this.pageIndex=i,this.#ts=t,this.#tw=e,s){const t=s$.#lz.get(s);if(t?.selectionDiv&&(t.selectionDiv.remove(),s$.#lN.delete(t.selectionDiv)),s$.#lz.set(s,{drawLayer:this}),s$.#lH.add(s),this.#lC=s,this.#lB=new MutationObserver(t=>{if(this.#nI&&this.#lC?.isConnected&&s$.#lG()){for(let{addedNodes:e}of t)for(let t of e)if(t.nodeType===Node.ELEMENT_NODE&&t.classList.contains("endOfContent"))return void s$.#tU()}}),this.#lB.observe(s,{childList:!0}),null===s$.#lO){s$.#lO=new AbortController;const{signal:t}=s$.#lO;document.addEventListener("selectionchange",s$.#tU.bind(s$),{signal:t}),document.addEventListener("pointerdown",()=>{s$.#lU=!0},{signal:t}),document.addEventListener("pointerup",()=>{s$.#lU=!1},{signal:t}),window.addEventListener("blur",()=>{s$.#lU=!1},{signal:t})}}}setParent(t){if(!this.#nI){this.#nI=t,this.#lC?.isConnected&&s$.#lG()&&s$.#tU();return}if(this.#nI!==t){if(this.#lF.size>0)for(let e of this.#lF.values())e.remove(),t.append(e);this.#nI=t}}static #l$(t){let e=this.#lz.get(t);e?.selectionDiv&&(e.selectionDiv.remove(),this.#lN.delete(e.selectionDiv),e.selectionDiv=null,e.path=null)}static #lG(){let t=document.getSelection();return!!t&&!t.isCollapsed}static #lj(){return[...this.#lH].filter(t=>t.isConnected).sort(sH)}static #tU(){let t=document.getSelection();if(!t||t.isCollapsed){for(let t of this.#lN)t.remove();this.#lN.clear();return}let e=new WeakMap,i=this.#lj(),s=[];for(let e=0,r=t.rangeCount;e<r;e++){let r=t.getRangeAt(e);if(r.collapsed)continue;let{startContainer:n,startOffset:a,endContainer:o,endOffset:l}=r,h=sz(n),d=sz(o),c=null===h,u=null===d;if(this.#lU&&c!==u)return;if(1===t.rangeCount){let{anchorNode:e,anchorOffset:i,focusNode:s,focusOffset:r}=t,c=sz(e),u=sz(s),p=function(t,e,i,s){if(t===i)return e<=s;let r=t.compareDocumentPosition(i);return!!(r&Node.DOCUMENT_POSITION_FOLLOWING)||!(r&Node.DOCUMENT_POSITION_PRECEDING)&&null}(e,i,s,r);c&&u&&null!==p&&(p?(n=e,a=i,h=c,o=s,l=r,d=u):(n=s,a=r,h=u,o=e,l=i,d=c))}let p=i.filter(t=>r.intersectsNode(t));if(0===p.length)continue;let g=!1;if(h||(n=h=p[0],a=0,g=!0),d||(o=d=p.at(-1),l=d.childNodes.length,g=!0),o.nodeType===Node.ELEMENT_NODE){if(o.classList.contains("endOfContent")){let t=o.previousSibling;if(!t)continue;o=t,l=t.nodeType===Node.TEXT_NODE?t.textContent.length:t.childNodes.length}else if(o.classList.contains("textLayer")&&o.childNodes.length===l){let t=sG(o,l,d);if(!t)continue;o=t.container,l=t.offset}}if(n.nodeType===Node.ELEMENT_NODE){let t=sG(n,a,h);if(!t)continue;n=t.container,a=t.offset}if(h===d&&!g&&p.includes(h)){s.push([r,h]);continue}for(let t of p){let e=t.firstChild;if(!e)continue;let i=document.createRange();if(t===h?i.setStart(n,a):i.setStartBefore(e),t===d)i.setEnd(o,l);else{let e=t.lastChild;if(!e)continue;if(e.nodeType===Node.ELEMENT_NODE&&e.classList.contains("endOfContent")){let t=e.previousSibling;if(!t)continue;i.setEndAfter(t)}else i.setEndAfter(e)}i.collapsed||s.push([i,t])}}let r=new Set(s.map(t=>t[1]));for(let t of this.#lH)r.has(t)||this.#l$(t);for(let[t,i]of s){let s=s$.#lz.get(i);if(!s)continue;let r=e.get(i);if(!r){let t=i.getBoundingClientRect();r=(e,i,s,r)=>({x:(e-t.x)/t.width,y:(i-t.y)/t.height,width:s/t.width,height:r/t.height}),e.set(i,r)}let n=[];for(let{x:e,y:i,width:s,height:a}of t.getClientRects())0!==s&&0!==a&&({x:e,y:i,width:s,height:a}=r(e,i,s,a),(1!==s||1!==a)&&n.push(`M${e} ${i} h${s} v${a} h-${s} Z`));if(0===n.length)continue;let a=s.drawLayer,o=s.selectionDiv,l=s.path;if(!o){let t=`clip_selection_${s$.#lR++}`;(o=document.createElement("div")).className="selection",o.style.clipPath=`url(#${t})`;let e=a.#ts?.createSelectionStyle(a.#tw);if(e)for(let[t,i]of Object.entries(e))o.style.setProperty(t,i);let i=s$._svgFactory.create(1,1,!0);i.setAttribute("aria-hidden","true"),i.setAttribute("width","100%"),i.setAttribute("height","100%");let r=s$._svgFactory.createElement("clipPath");r.setAttribute("id",t),r.setAttribute("clipPathUnits","objectBoundingBox"),l=s$._svgFactory.createElement("path"),r.append(l),i.append(r),o.append(i),s.path=l,s.selectionDiv=o}!o.parentNode&&a.#nI&&(a.#nI.append(o),this.#lN.add(o)),l.setAttribute("d",n.join(" "))}}static get _svgFactory(){return k(this,"_svgFactory",new iX)}static #lV(t,[e,i,s,r]){let{style:n}=t;n.top=`${100*i}%`,n.left=`${100*e}%`,n.width=`${100*s}%`,n.height=`${100*r}%`}#lW(){let t=s$._svgFactory.create(1,1,!0);return this.#nI.append(t),t.setAttribute("aria-hidden","true"),t}#lK(t,e){let i=s$._svgFactory.createElement("clipPath");t.append(i);let s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");let r=s$._svgFactory.createElement("use");return i.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),s}#lX(t,e){for(let[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(t,e=!1,i=!1){let s=s$.#T++,r=this.#lW(),n=s$._svgFactory.createElement("defs");r.append(n);let a=s$._svgFactory.createElement("path");n.append(a);let o=`path_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e&&this.#lL.set(s,a);let l=i?this.#lK(n,o):null,h=s$._svgFactory.createElement("use");return r.append(h),h.setAttribute("href",`#${o}`),this.updateProperties(r,t),this.#lF.set(s,r),{id:s,clipPathId:`url(#${l})`}}drawOutline(t,e){let i,s=s$.#T++,r=this.#lW(),n=s$._svgFactory.createElement("defs");r.append(n);let a=s$._svgFactory.createElement("path");n.append(a);let o=`path_${s}`;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),e){let t=s$._svgFactory.createElement("mask");n.append(t),i=`mask_${s}`,t.setAttribute("id",i),t.setAttribute("maskUnits","objectBoundingBox");let e=s$._svgFactory.createElement("rect");t.append(e),e.setAttribute("width","1"),e.setAttribute("height","1"),e.setAttribute("fill","white");let r=s$._svgFactory.createElement("use");t.append(r),r.setAttribute("href",`#${o}`),r.setAttribute("stroke","none"),r.setAttribute("fill","black"),r.setAttribute("fill-rule","nonzero"),r.classList.add("mask")}let l=s$._svgFactory.createElement("use");r.append(l),l.setAttribute("href",`#${o}`),i&&l.setAttribute("mask",`url(#${i})`);let h=l.cloneNode();return r.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),this.updateProperties(r,t),this.#lF.set(s,r),s}finalizeDraw(t,e){this.#lL.delete(t),this.updateProperties(t,e)}updateProperties(t,e){if(!e)return;let{root:i,bbox:s,rootClass:r,path:n}=e,a="number"==typeof t?this.#lF.get(t):t;if(a){if(i&&this.#lX(a,i),s&&s$.#lV(a,s),r){let{classList:t}=a;for(let[e,i]of Object.entries(r))t.toggle(e,i)}if(n){let t=a.firstElementChild.firstElementChild;this.#lX(t,n)}}}updateParent(t,e){if(e===this)return;let i=this.#lF.get(t);i&&(e.#nI.append(i),this.#lF.delete(t),e.#lF.set(t,i))}remove(t){this.#lL.delete(t),null!==this.#nI&&(this.#lF.get(t).remove(),this.#lF.delete(t))}destroy(){for(let t of(this.#nI=null,this.#lF.values()))t.remove();if(this.#lF.clear(),this.#lL.clear(),this.#lB?.disconnect(),this.#lB=null,this.#lC){let t=s$.#lz.get(this.#lC);t?.drawLayer===this&&(s$.#l$(this.#lC),s$.#lz.delete(this.#lC),s$.#lH.delete(this.#lC),0===s$.#lH.size&&(s$.#lO?.abort(),s$.#lO=null,s$.#lU=!1)),this.#lC=null}}}function sj(t){return`${(100*t).toFixed(2)}%`}class sV{#lq=[];#lY=new Map;#lQ=null;#lJ=0;#rg=0;#rp=0;static #lZ=null;constructor(t,e,i,s){this.#lJ=t,this.#lq=e,this.#rg=i.rawDims.pageWidth,this.#rp=i.rawDims.pageHeight,this.#lQ=s}render(){let t=document.createElement("div");t.className="textLayerImages";for(let e=0;e<this.#lq.length;e+=6){let i=this.#l0(this.#lq.subarray(e,e+6));i&&t.append(i)}return t.addEventListener("contextmenu",t=>{if(!(t.target instanceof HTMLCanvasElement))return;let e=t.target,i=this.#lY.get(e);if(!i)return;let s=sV.#lZ?.deref();if(s===e)return;s&&(s.width=0,s.height=0),sV.#lZ=new WeakRef(e);let{inverseTransform:r,x1:n,y1:a,width:o,height:l}=i,h=this.#lQ(),d=Math.ceil(n*h.width),c=Math.ceil(a*h.height),u=Math.floor((n+o/this.#rg)*h.width),p=Math.floor((a+l/this.#rp)*h.height);e.width=u-d,e.height=p-c;let g=e.getContext("2d");g.setTransform(...r),g.translate(-d,-c),g.drawImage(h,0,0)}),t}#l0([t,e,i,s,r,n]){let a=Math.hypot((r-t)*this.#rg,(n-e)*this.#rp),o=Math.hypot((i-t)*this.#rg,(s-e)*this.#rp);if(a<this.#lJ||o<this.#lJ)return null;let l=[(r-t)*this.#rg/a,(n-e)*this.#rp/a,(i-t)*this.#rg/o,(s-e)*this.#rp/o,0,0],h=N.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:sj(t),top:sj(e),width:sj(a/this.#rg),height:sj(o/this.#rp),transformOrigin:"0% 0%",transform:`matrix(${l.join(",")})`}),this.#lY.set(d,{inverseTransform:h,width:a,height:o,x1:t,y1:e}),d}}globalThis._pdfjsTestingUtils={HighlightOutliner:sw},globalThis.pdfjsLib={AbortException:L,AnnotationEditorLayer:sU,AnnotationEditorParamsType:p,AnnotationEditorType:u,AnnotationEditorUIManager:tR,AnnotationLayer:sf,AnnotationMode:h,AnnotationType:f,applyOpacity:tb,build:iz,ColorPicker:iG,createValidAbsoluteUrl:E,CSSConstants:tf,DOMSVGFactory:iX,DrawLayer:s$,FeatureTest:O,fetchData:Q,findContrastColor:tC,getDocument:iD,getFilenameFromUrl:te,getPdfFilenameFromUrl:ti,getRGB:th,getRGBA:tl,getUuid:G,GlobalWorkerOptions:ix,ImageKind:m,InvalidPDFException:I,isDataScheme:Z,isPdfFile:tt,isValidExplicitDest:ep,makeArr:$,makeMap:j,makeObj:V,MathClamp:W,noContextMenu:tn,normalizeUnicode:z,OPS:y,OutputScale:tp,PasswordException:P,PasswordResponses:v,PDFDataRangeTransport:iF,PDFDateString:to,PDFWorker:iR,PermissionFlag:g,PixelsPerInch:Y,RenderingCancelledException:J,renderRichText:tS,ResponseException:F,setLayerDimensions:tu,shadow:k,SignatureExtractor:sB,stopEvent:ta,SupportedImageMimeTypes:tg,TextLayer:iP,TextLayerImages:sV,TouchManager:tU,updateUrlHash:T,Util:N,VerbosityLevel:b,version:iH,XfaLayer:q},t.s(["AbortException",0,L,"AnnotationEditorLayer",0,sU,"AnnotationEditorParamsType",0,p,"AnnotationEditorType",0,u,"AnnotationEditorUIManager",0,tR,"AnnotationLayer",0,sf,"AnnotationMode",0,h,"AnnotationType",0,f,"CSSConstants",0,tf,"ColorPicker",0,iG,"DOMSVGFactory",0,iX,"DrawLayer",0,s$,"FeatureTest",0,O,"GlobalWorkerOptions",0,ix,"ImageKind",0,m,"InvalidPDFException",0,I,"MathClamp",0,W,"OPS",0,y,"OutputScale",0,tp,"PDFDataRangeTransport",0,iF,"PDFDateString",0,to,"PDFWorker",0,iR,"PasswordException",0,P,"PasswordResponses",0,v,"PermissionFlag",0,g,"PixelsPerInch",0,Y,"RenderingCancelledException",0,J,"ResponseException",0,F,"SignatureExtractor",0,sB,"SupportedImageMimeTypes",0,tg,"TextLayer",0,iP,"TextLayerImages",0,sV,"TouchManager",0,tU,"Util",0,N,"VerbosityLevel",0,b,"XfaLayer",0,q,"applyOpacity",0,tb,"build",0,iz,"createValidAbsoluteUrl",0,E,"fetchData",0,Q,"findContrastColor",0,tC,"getDocument",0,iD,"getFilenameFromUrl",0,te,"getPdfFilenameFromUrl",0,ti,"getRGB",0,th,"getRGBA",0,tl,"getUuid",0,G,"isDataScheme",0,Z,"isPdfFile",0,tt,"isValidExplicitDest",0,ep,"makeArr",0,$,"makeMap",0,j,"makeObj",0,V,"noContextMenu",0,tn,"normalizeUnicode",0,z,"renderRichText",0,tS,"setLayerDimensions",0,tu,"shadow",0,k,"stopEvent",0,ta,"updateUrlHash",0,T,"version",0,iH])}]);