@genai-fi/nanogpt 1.4.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. package/dist/{DatasetBuilder-DU1G1OKX.js → DatasetBuilder-DRDW8tcM.js} +85 -86
  2. package/dist/Generator-BcR_14Cj.js +316 -0
  3. package/dist/{RealDiv-CSnvtN2E.js → RealDiv-Cl8k3YTx.js} +54 -62
  4. package/dist/{Reshape-BlylqwWy.js → Reshape-CKxKPKqi.js} +9 -12
  5. package/dist/Reshape-H5zZRgr9.js +16 -0
  6. package/dist/RoPECache-dYscFINl.js +722 -0
  7. package/dist/TeachableLLM.js +29 -34
  8. package/dist/api/beamer.d.ts +1 -0
  9. package/dist/api/beamer.js +19 -10
  10. package/dist/api/responses.js +11 -12
  11. package/dist/api/training.js +12 -14
  12. package/dist/axis_util-rF9RnwKE.js +37 -0
  13. package/dist/backend.js +5 -6
  14. package/dist/{backend_util-DAV0I34P.js → backend_util-Cpp0Gwlp.js} +180 -185
  15. package/dist/{binary_op_util-CrYk9LXL.js → binary_op_util-WY9YIl0q.js} +3 -7
  16. package/dist/broadcast_to-CGvLNiQ0.js +20 -0
  17. package/dist/checks/appendCache.js +7 -7
  18. package/dist/checks/attentionMask.js +9 -8
  19. package/dist/checks/check.js +1 -2
  20. package/dist/checks/gelu.js +6 -6
  21. package/dist/checks/index.js +24 -25
  22. package/dist/checks/matMulGelu.js +7 -7
  23. package/dist/checks/normRMS.js +14 -12
  24. package/dist/checks/normRMSGrad.js +9 -8
  25. package/dist/checks/packUnpack.js +7 -7
  26. package/dist/checks/qkv.js +1 -34
  27. package/dist/checks/rope.js +6 -6
  28. package/dist/checks/weights.js +1 -2
  29. package/dist/clip_by_value-D-UX9am5.js +13 -0
  30. package/dist/complex-Cl904TqN.js +13 -0
  31. package/dist/{complex_util-CkazZsaH.js → complex_util-BBlPAm-s.js} +1 -2
  32. package/dist/concat-Oip5acVY.js +14 -0
  33. package/dist/{concat_util-CWzvQQlK.js → concat_util-CY45Hf4F.js} +2 -3
  34. package/dist/data/docx.js +3 -4
  35. package/dist/data/pdf.js +11 -14
  36. package/dist/data/stream.js +1 -2
  37. package/dist/data/textLoader.js +16 -15
  38. package/dist/data-CV_i_H6B.js +11 -0
  39. package/dist/data.js +5 -12
  40. package/dist/dist-CMMLi-qO.js +2675 -0
  41. package/dist/{dist-BGVm64AY.js → dist-DeVH1nGn.js} +1465 -1573
  42. package/dist/{dist-CwK5S7Ls.js → dist-DyL7qSLJ.js} +2664 -2400
  43. package/dist/dropout16-CA31Ud5a.js +20 -0
  44. package/dist/dropout_util-SiFMbFXz.js +22 -0
  45. package/dist/{eventemitter3-D_qV3Lof.js → eventemitter3-wmfmOP_f.js} +2 -3
  46. package/dist/expand_dims-Dh3Fulyn.js +10 -0
  47. package/dist/floor-BwjmUb7X.js +8 -0
  48. package/dist/gather-B5Z1RFt5.js +14 -0
  49. package/dist/gatherSub-CRUfUzBa.js +22 -0
  50. package/dist/gelu-Xx9-ohH9.js +25 -0
  51. package/dist/{gpgpu_math-20tPK8LM.js → gpgpu_math-48m8q3jI.js} +265 -286
  52. package/dist/inference/Beamer.d.ts +14 -2
  53. package/dist/inference/Beamer.js +170 -105
  54. package/dist/inference/Generator.js +1 -259
  55. package/dist/inference/tokenisePrompt.d.ts +2 -1
  56. package/dist/inference/tokenisePrompt.js +15 -11
  57. package/dist/inference/types.d.ts +7 -0
  58. package/dist/inference/utilities.js +1 -2
  59. package/dist/{jszip.min-DKa1Rjyn.js → jszip.min-Btv48m44.js} +68 -64
  60. package/dist/{kernel_funcs_utils-ql8Y8qPn.js → kernel_funcs_utils-BYRpSfV_.js} +39 -42
  61. package/dist/layers/BaseLayer.js +9 -10
  62. package/dist/layers/{CausalSelfAttention.d.ts → GQA.d.ts} +8 -3
  63. package/dist/layers/GQA.js +102 -0
  64. package/dist/layers/HeadLayer.d.ts +12 -0
  65. package/dist/layers/HeadLayer.js +28 -0
  66. package/dist/layers/LoRA.js +17 -20
  67. package/dist/layers/MHA.d.ts +43 -0
  68. package/dist/layers/MHA.js +102 -0
  69. package/dist/layers/MLP.d.ts +5 -1
  70. package/dist/layers/MLP.js +33 -20
  71. package/dist/layers/PositionEmbedding.js +14 -13
  72. package/dist/layers/RMSNorm.d.ts +2 -0
  73. package/dist/layers/RMSNorm.js +16 -11
  74. package/dist/layers/RoPECache.js +1 -337
  75. package/dist/layers/TiedEmbedding.js +15 -14
  76. package/dist/layers/TransformerBlock.d.ts +4 -10
  77. package/dist/layers/TransformerBlock.js +29 -30
  78. package/dist/layers/WeightStore.js +4 -5
  79. package/dist/layers-CFqEip3s.js +13 -0
  80. package/dist/layers.d.ts +1 -1
  81. package/dist/layers.js +4 -12
  82. package/dist/loader/load.js +27 -24
  83. package/dist/loader/loadHF.js +3 -3
  84. package/dist/loader/loadTransformers.js +22 -7
  85. package/dist/loader/loadZipMeta.js +1 -2
  86. package/dist/loader/newZipLoad.js +1 -2
  87. package/dist/loader/oldZipLoad.js +8 -9
  88. package/dist/loader/save.js +31 -17
  89. package/dist/loader/types.d.ts +8 -2
  90. package/dist/main.js +3281 -3463
  91. package/dist/matMul16-tE26fnhf.js +87 -0
  92. package/dist/{matMulGelu-CBoqTZM7.js → matMulGelu-ASUWlKqu.js} +33 -33
  93. package/dist/mat_mul-R9_DWmIT.js +16 -0
  94. package/dist/models/Llama.d.ts +16 -0
  95. package/dist/models/Llama.js +88 -0
  96. package/dist/models/NanoGPTV1.js +53 -54
  97. package/dist/models/NanoGPTV2.js +48 -49
  98. package/dist/models/Qwen3.d.ts +16 -0
  99. package/dist/models/Qwen3.js +88 -0
  100. package/dist/models/config.d.ts +18 -1
  101. package/dist/models/config.js +3 -8
  102. package/dist/models/factory.js +14 -11
  103. package/dist/models/model.d.ts +5 -7
  104. package/dist/models/model.js +1 -2
  105. package/dist/models-DyBpJJwM.js +13 -0
  106. package/dist/models.js +6 -14
  107. package/dist/mul16-C7sqgqik.js +41 -0
  108. package/dist/non_max_suppression_impl-B0H318rb.js +72 -0
  109. package/dist/not_equal-Bu3O8rh_.js +67 -0
  110. package/dist/one_hot-TEMPumJj.js +14 -0
  111. package/dist/ones-DpPXWa6A.js +13 -0
  112. package/dist/ops/adamAdjust.js +2 -3
  113. package/dist/ops/adamMoments.js +2 -3
  114. package/dist/ops/add16.js +2 -3
  115. package/dist/ops/appendCache.js +9 -8
  116. package/dist/ops/attentionMask.d.ts +1 -1
  117. package/dist/ops/attentionMask.js +8 -5
  118. package/dist/ops/concat16.js +5 -5
  119. package/dist/ops/cpu/adamAdjust.js +7 -8
  120. package/dist/ops/cpu/adamMoments.js +5 -5
  121. package/dist/ops/cpu/appendCache.js +3 -3
  122. package/dist/ops/cpu/attentionMask.js +12 -8
  123. package/dist/ops/cpu/fusedSoftmax.js +3 -3
  124. package/dist/ops/cpu/gatherSub.js +1 -12
  125. package/dist/ops/cpu/gelu.js +12 -13
  126. package/dist/ops/cpu/matMul16.js +7 -7
  127. package/dist/ops/cpu/matMulGelu.js +21 -18
  128. package/dist/ops/cpu/matMulMul.js +8 -9
  129. package/dist/ops/cpu/mulDropout.js +8 -9
  130. package/dist/ops/cpu/normRMS.js +12 -13
  131. package/dist/ops/cpu/qkv.js +14 -13
  132. package/dist/ops/cpu/rope.js +11 -8
  133. package/dist/ops/cpu/scatterSub.js +1 -12
  134. package/dist/ops/dot16.js +16 -17
  135. package/dist/ops/dropout.js +9 -8
  136. package/dist/ops/dropout16.js +1 -22
  137. package/dist/ops/gatherSub.js +3 -4
  138. package/dist/ops/gelu.js +1 -2
  139. package/dist/ops/globalNorm.js +14 -14
  140. package/dist/ops/grads/add16.js +16 -17
  141. package/dist/ops/grads/attentionMask.js +6 -7
  142. package/dist/ops/grads/dropout16.js +1 -1
  143. package/dist/ops/grads/gelu.js +1 -2
  144. package/dist/ops/grads/matMul16.js +1 -2
  145. package/dist/ops/grads/matMulGelu.js +6 -7
  146. package/dist/ops/grads/mul16.js +1 -1
  147. package/dist/ops/grads/normRMS.js +8 -9
  148. package/dist/ops/grads/pack16.js +1 -2
  149. package/dist/ops/grads/qkv.js +10 -10
  150. package/dist/ops/grads/rope.js +1 -2
  151. package/dist/ops/grads/silu.d.ts +2 -0
  152. package/dist/ops/grads/silu.js +1 -0
  153. package/dist/ops/grads/softmax16.js +6 -7
  154. package/dist/ops/grads/unpack16.js +1 -2
  155. package/dist/ops/grads/utils.js +1 -2
  156. package/dist/ops/matMul16.d.ts +2 -2
  157. package/dist/ops/matMul16.js +1 -2
  158. package/dist/ops/matMulGelu.js +3 -4
  159. package/dist/ops/matMulMul.js +2 -3
  160. package/dist/ops/mul16.js +1 -43
  161. package/dist/ops/mulDrop.js +2 -3
  162. package/dist/ops/normRMS.d.ts +1 -1
  163. package/dist/ops/normRMS.js +10 -11
  164. package/dist/ops/pack16.js +1 -2
  165. package/dist/ops/qkv.js +2 -3
  166. package/dist/ops/reshape16.js +11 -11
  167. package/dist/ops/rope.d.ts +1 -1
  168. package/dist/ops/rope.js +1 -2
  169. package/dist/ops/scatterSub.js +3 -4
  170. package/dist/ops/silu.d.ts +3 -0
  171. package/dist/ops/silu.js +1 -0
  172. package/dist/ops/slice16.js +5 -5
  173. package/dist/ops/softmax16.js +3 -4
  174. package/dist/ops/sub16.js +3 -4
  175. package/dist/ops/sum16.js +3 -3
  176. package/dist/ops/transpose16.js +16 -15
  177. package/dist/ops/unpack16.js +1 -2
  178. package/dist/ops/webgl/adamAdjust.js +8 -9
  179. package/dist/ops/webgl/adamMoments.js +2 -3
  180. package/dist/ops/webgl/appendCache.js +2 -3
  181. package/dist/ops/webgl/attentionMask.js +2 -3
  182. package/dist/ops/webgl/dropout16.js +2 -3
  183. package/dist/ops/webgl/fusedSoftmax.js +13 -13
  184. package/dist/ops/webgl/gatherSub.js +2 -3
  185. package/dist/ops/webgl/gelu.js +11 -12
  186. package/dist/ops/webgl/log.js +10 -10
  187. package/dist/ops/webgl/matMul16.js +31 -24
  188. package/dist/ops/webgl/matMulGelu.js +1 -2
  189. package/dist/ops/webgl/matMulMul.js +3 -4
  190. package/dist/ops/webgl/mulDropout.js +2 -3
  191. package/dist/ops/webgl/normRMS.js +11 -10
  192. package/dist/ops/webgl/qkv.js +2 -3
  193. package/dist/ops/webgl/rope.js +10 -9
  194. package/dist/ops/webgl/scatterSub.js +2 -3
  195. package/dist/ops/webgpu/adamAdjust.js +13 -14
  196. package/dist/ops/webgpu/adamMoments.js +13 -14
  197. package/dist/ops/webgpu/add16.js +3 -4
  198. package/dist/ops/webgpu/appendCache.js +20 -21
  199. package/dist/ops/webgpu/attentionMask.js +18 -19
  200. package/dist/ops/webgpu/attentionMask32_program.js +7 -8
  201. package/dist/ops/webgpu/clipScale.js +11 -12
  202. package/dist/ops/webgpu/concat16.js +17 -18
  203. package/dist/ops/webgpu/dropout16.js +6 -7
  204. package/dist/ops/webgpu/gatherSub.js +11 -12
  205. package/dist/ops/webgpu/gelu.js +10 -11
  206. package/dist/ops/webgpu/index.js +17 -16
  207. package/dist/ops/webgpu/matMul16.js +74 -57
  208. package/dist/ops/webgpu/matMul16_program.d.ts +4 -3
  209. package/dist/ops/webgpu/matMul16_program.js +30 -22
  210. package/dist/ops/webgpu/mul16.js +3 -4
  211. package/dist/ops/webgpu/norm2.js +9 -10
  212. package/dist/ops/webgpu/normRMS.js +13 -14
  213. package/dist/ops/webgpu/normRMS16_program.d.ts +2 -1
  214. package/dist/ops/webgpu/normRMS16_program.js +5 -5
  215. package/dist/ops/webgpu/normRMS32_program.d.ts +2 -1
  216. package/dist/ops/webgpu/normRMS32_program.js +5 -5
  217. package/dist/ops/webgpu/normRMSGrad.js +30 -30
  218. package/dist/ops/webgpu/pack16.js +2 -3
  219. package/dist/ops/webgpu/pack16_program.js +3 -4
  220. package/dist/ops/webgpu/qkv.js +10 -11
  221. package/dist/ops/webgpu/rope.js +113 -49
  222. package/dist/ops/webgpu/scatterSub.js +12 -13
  223. package/dist/ops/webgpu/silu.d.ts +14 -0
  224. package/dist/ops/webgpu/silu.js +117 -0
  225. package/dist/ops/webgpu/slice16.js +17 -18
  226. package/dist/ops/webgpu/softmax16.js +9 -9
  227. package/dist/ops/webgpu/softmax16_program.js +9 -10
  228. package/dist/ops/webgpu/softmax16_subgroup_program.js +11 -12
  229. package/dist/ops/webgpu/softmax16grad.js +8 -9
  230. package/dist/ops/webgpu/sub16.js +3 -4
  231. package/dist/ops/webgpu/sum16.js +16 -15
  232. package/dist/ops/webgpu/transpose16.js +13 -12
  233. package/dist/ops/webgpu/transpose16_program.js +3 -4
  234. package/dist/ops/webgpu/transpose16_shared_program.js +17 -18
  235. package/dist/ops/webgpu/unpack16.js +8 -9
  236. package/dist/ops/webgpu/utils/binary_op.js +20 -21
  237. package/dist/ops/webgpu/utils/deviceInfo.js +1 -2
  238. package/dist/ops/webgpu/utils/reductions.js +21 -20
  239. package/dist/ops-Be5ACU5R.js +13 -0
  240. package/dist/ops-C1UpdEYM.js +509 -0
  241. package/dist/{pack16-BhuXNUS7.js → pack16-BHO4t1-M.js} +14 -17
  242. package/dist/pad-Dy-1IP3A.js +13 -0
  243. package/dist/patches/webgpu_backend.js +18 -19
  244. package/dist/patches/webgpu_base.js +2 -3
  245. package/dist/patches/webgpu_program.js +21 -22
  246. package/dist/{pdf-Bzuk68Vy.js → pdf-CbnQ75VG.js} +380 -701
  247. package/dist/{picomatch-BO4HbNfo.js → picomatch--TW6gyBJ.js} +229 -291
  248. package/dist/qkv-BQfNPucX.js +42 -0
  249. package/dist/rand_util-_vCY93Uw.js +44 -0
  250. package/dist/random_normal-DUIT8kyC.js +11 -0
  251. package/dist/range-CYvQC3fW.js +13 -0
  252. package/dist/relu-C4XULT8A.js +8 -0
  253. package/dist/reshape-DJb1jgMt.js +8 -0
  254. package/dist/resize_nearest_neighbor-DAqcTYUe.js +188 -0
  255. package/dist/{chunk-CWhphoD1.js → rolldown-runtime-CwxnZyOB.js} +4 -5
  256. package/dist/rope-JjBVufF_.js +24 -0
  257. package/dist/scatterSub-BOnqk-uY.js +27 -0
  258. package/dist/scatter_nd_util-BepMCpLY.js +34 -0
  259. package/dist/seedrandom-SHEGFK6H.js +282 -0
  260. package/dist/selu_util-DeOTf-sc.js +27 -0
  261. package/dist/shared-BIDMUBCs.js +1864 -0
  262. package/dist/{shared-CfTzpULd.js → shared-CX_iPI5K.js} +2 -3
  263. package/dist/silu-DsAE2cJ5.js +23 -0
  264. package/dist/slice-Dlb1FlzG.js +13 -0
  265. package/dist/{slice_util-Dve4TkDn.js → slice_util-BVgPRoij.js} +3 -4
  266. package/dist/softmax-Dpav_dWw.js +10 -0
  267. package/dist/split-DYnT8chz.js +11 -0
  268. package/dist/squeeze-B3XYGAlg.js +9 -0
  269. package/dist/stack-Dbbt9mIk.js +10 -0
  270. package/dist/step-DA-5DNu9.js +348 -0
  271. package/dist/{stream-BpAwcvHz.js → stream-BBe2apn4.js} +68 -88
  272. package/dist/sum-C8qNbFNp.js +13 -0
  273. package/dist/tensor-ALxWZfmz.js +7 -0
  274. package/dist/tensor1d-BHgkkhTE.js +9 -0
  275. package/dist/tensor2d-ARItvqVn.js +10 -0
  276. package/dist/tensor4d-D1zRBipJ.js +10 -0
  277. package/dist/tfjs_backend-CsXOum0h.js +685 -0
  278. package/dist/tile-DfyQ0KX-.js +10 -0
  279. package/dist/tokenise-DbS2Ea-T.js +14 -0
  280. package/dist/tokenise.js +6 -15
  281. package/dist/tokeniser/BaseTokeniser.js +5 -9
  282. package/dist/tokeniser/CharTokeniser.js +1 -2
  283. package/dist/tokeniser/bpe.js +19 -20
  284. package/dist/topk-BrU2pkrR.js +19 -0
  285. package/dist/training/AdamW.js +35 -31
  286. package/dist/training/BasicTrainer.js +56 -56
  287. package/dist/training/DatasetBuilder.js +1 -2
  288. package/dist/training/Evaluator.js +8 -5
  289. package/dist/training/LRScheduler.js +1 -2
  290. package/dist/training/PreTrainer.js +7 -8
  291. package/dist/training/SFTTrainer.js +7 -8
  292. package/dist/training/configure.js +16 -15
  293. package/dist/training/factory.js +1 -2
  294. package/dist/training/loss.js +1 -2
  295. package/dist/training/orthoGrad.js +2 -3
  296. package/dist/training/prepareData.js +18 -17
  297. package/dist/training/sparseCrossEntropy.js +38 -32
  298. package/dist/training/tasks/TokenStore.js +21 -22
  299. package/dist/training/tasks/tokenStream.js +1 -2
  300. package/dist/training/validateOptions.js +1 -2
  301. package/dist/training/validation.js +1 -2
  302. package/dist/transpose-BC-M_OoT.js +34 -0
  303. package/dist/unsorted_segment_sum-BelC7R-q.js +408 -0
  304. package/dist/utilities/arrayClose.js +5 -4
  305. package/dist/utilities/arrayShape.js +1 -2
  306. package/dist/utilities/datasetID.js +1 -2
  307. package/dist/utilities/dummy.js +15 -15
  308. package/dist/utilities/float16.js +10 -10
  309. package/dist/utilities/maxHeap.d.ts +16 -0
  310. package/dist/utilities/maxHeap.js +54 -0
  311. package/dist/utilities/multinomialCPU.d.ts +1 -2
  312. package/dist/utilities/multinomialCPU.js +6 -8
  313. package/dist/utilities/packed.js +2 -3
  314. package/dist/utilities/parameters.js +34 -19
  315. package/dist/utilities/performance.js +2 -3
  316. package/dist/utilities/profile.js +3 -4
  317. package/dist/utilities/random.js +1 -2
  318. package/dist/utilities/safetensors.js +14 -14
  319. package/dist/utilities/sentences.js +16 -13
  320. package/dist/utilities/tokenParse.js +1 -2
  321. package/dist/utilities/tokens.js +5 -6
  322. package/dist/utilities/topP.d.ts +1 -0
  323. package/dist/utilities/topP.js +20 -13
  324. package/dist/utilities/waitForModel.js +1 -2
  325. package/dist/utilities/weights.js +4 -4
  326. package/dist/utilities/yielder.js +1 -2
  327. package/dist/{v4-BK7K-jy_.js → v4-YCkfo8OR.js} +4 -7
  328. package/dist/{webgpu-IAn9VotJ.js → webgpu-BHX-uBym.js} +156 -163
  329. package/dist/{webgpu_program-B0PokuRJ.js → webgpu_program-DvkFqRlR.js} +28 -29
  330. package/dist/{webgpu_util-DfODg6XI.js → webgpu_util-5QTyovaf.js} +2 -3
  331. package/dist/zeros-hxKGkRfl.js +12 -0
  332. package/package.json +3 -3
  333. package/dist/Reshape-CwxdaU8n.js +0 -17
  334. package/dist/dist-Da20xy8E.js +0 -6375
  335. package/dist/gelu-B6637MKa.js +0 -27
  336. package/dist/layers/CausalSelfAttention.js +0 -99
  337. package/dist/matMul16-DGtlziMn.js +0 -81
  338. package/dist/rope-C8EAiSGY.js +0 -25
  339. package/dist/selu_util-B_AFEfoz.js +0 -24
  340. package/dist/shared-24EoeHJl.js +0 -1314
  341. package/dist/tfjs_backend-h5weiy1O.js +0 -614
@@ -1,4 +1,4 @@
1
- //#region node_modules/pdfjs-dist/legacy/build/pdf.mjs
1
+ // node_modules/pdfjs-dist/legacy/build/pdf.mjs
2
2
  var e = {
3
3
  9306(e, t, n) {
4
4
  var r = n(4901), i = n(6823), a = TypeError;
@@ -657,7 +657,7 @@ var e = {
657
657
  8646(e, t, n) {
658
658
  var r = n(9565), i = n(8551), a = n(1767), o = n(851);
659
659
  e.exports = function(e, t) {
660
- (!t || typeof e != "string") && i(e);
660
+ t && typeof e == "string" || i(e);
661
661
  var n = o(e);
662
662
  return a(i(n === void 0 ? e : r(n, e)));
663
663
  };
@@ -1870,7 +1870,7 @@ var e = {
1870
1870
  var r = n(6518), i = n(9565), a = n(9306), o = n(8551), s = n(1767), c = n(8646), l = n(9462), u = n(9539), d = n(6395), f = n(684), p = n(4549);
1871
1871
  function m() {
1872
1872
  try {
1873
- var e = Iterator.prototype.flatMap.call(new Map([[4, 5]]).entries(), function(e) {
1873
+ var e = Iterator.prototype.flatMap.call((/* @__PURE__ */ new Map([[4, 5]])).entries(), function(e) {
1874
1874
  return e;
1875
1875
  });
1876
1876
  e.next(), e.return();
@@ -2151,7 +2151,7 @@ var e = {
2151
2151
  return x("\udf06\ud834") !== "\"\\udf06\\ud834\"" || x("\udead") !== "\"\\udead\"";
2152
2152
  }), I = P ? function(e, t) {
2153
2153
  var n = h(arguments), r = R(t);
2154
- if (!(!u(r) && (e === void 0 || f(e)))) return n[1] = function(e, t) {
2154
+ if (u(r) || e !== void 0 && !f(e)) return n[1] = function(e, t) {
2155
2155
  if (u(r) && (t = o(r, this, b(e), t)), !f(t)) return t;
2156
2156
  }, a(x, null, n);
2157
2157
  } : x, L = function(e, t, n) {
@@ -2235,7 +2235,7 @@ var e = {
2235
2235
  switch (a(e, function(e) {
2236
2236
  if (++n > m) throw new o("Maximum allowed index exceeded");
2237
2237
  if (typeof e != "number") throw new s("Value is not a number");
2238
- r !== _ && (e === e ? e === c ? r = r === v ? _ : y : e === -c ? r = r === y ? _ : v : (e !== 0 || 1 / e === c) && (r === b || r === x) && (r = x, f(t, e)) : r = _);
2238
+ r !== _ && (e === e ? e === c ? r = r === v ? _ : y : e === -c ? r = r === y ? _ : v : e === 0 && 1 / e !== c || r !== b && r !== x || (r = x, f(t, e)) : r = _);
2239
2239
  }), r) {
2240
2240
  case _: return l;
2241
2241
  case v: return -c;
@@ -2319,7 +2319,7 @@ var e = {
2319
2319
  };
2320
2320
  } };
2321
2321
  }
2322
- }, t = new Set([
2322
+ }, t = /* @__PURE__ */ new Set([
2323
2323
  1,
2324
2324
  2,
2325
2325
  3,
@@ -2338,11 +2338,11 @@ var e = {
2338
2338
  forced: !n(4916)("intersection", function(e) {
2339
2339
  return e.size === 2 && e.has(1) && e.has(2);
2340
2340
  }) || i(function() {
2341
- return String(Array.from(new Set([
2341
+ return String(Array.from((/* @__PURE__ */ new Set([
2342
2342
  1,
2343
2343
  2,
2344
2344
  3
2345
- ]).intersection(new Set([3, 2])))) !== "3,2";
2345
+ ])).intersection(/* @__PURE__ */ new Set([3, 2])))) !== "3,2";
2346
2346
  })
2347
2347
  }, { intersection: a });
2348
2348
  },
@@ -2400,7 +2400,7 @@ var e = {
2400
2400
  9577(e, t, n) {
2401
2401
  var r = n(4644), i = n(1108), a = n(6198), o = n(1291), s = n(5854), c = r.aTypedArray, l = r.getTypedArrayConstructor, u = r.exportTypedArrayMethod, d = RangeError, f = function() {
2402
2402
  try {
2403
- new Int8Array(1).with(2, { valueOf: function() {
2403
+ (/* @__PURE__ */ new Int8Array(1)).with(2, { valueOf: function() {
2404
2404
  throw 8;
2405
2405
  } });
2406
2406
  } catch (e) {
@@ -2408,7 +2408,7 @@ var e = {
2408
2408
  }
2409
2409
  }(), p = f && function() {
2410
2410
  try {
2411
- new Int8Array(1).with(-.5, 1);
2411
+ (/* @__PURE__ */ new Int8Array(1)).with(-.5, 1);
2412
2412
  } catch {
2413
2413
  return !0;
2414
2414
  }
@@ -2954,7 +2954,7 @@ function re(e) {
2954
2954
  }
2955
2955
  var B = class {
2956
2956
  static get isLittleEndian() {
2957
- let e = new Uint8Array(4);
2957
+ let e = /* @__PURE__ */ new Uint8Array(4);
2958
2958
  e[0] = 1;
2959
2959
  let t = new Uint32Array(e.buffer, 0, 1);
2960
2960
  return P(this, "isLittleEndian", t[0] === 1);
@@ -3103,11 +3103,11 @@ function ie(e) {
3103
3103
  }
3104
3104
  var ae = null, oe = null;
3105
3105
  function se(e) {
3106
- return ae || (ae = /([\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, oe = new Map([["ſt", "ſt"]])), e.replaceAll(ae, (e, t, n) => t ? t.normalize("NFKC") : oe.get(n));
3106
+ return ae || (ae = /([\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, oe = /* @__PURE__ */ new Map([["ſt", "ſt"]])), e.replaceAll(ae, (e, t, n) => t ? t.normalize("NFKC") : oe.get(n));
3107
3107
  }
3108
3108
  function ce() {
3109
3109
  if (typeof crypto.randomUUID == "function") return crypto.randomUUID();
3110
- let e = new Uint8Array(32);
3110
+ let e = /* @__PURE__ */ new Uint8Array(32);
3111
3111
  return crypto.getRandomValues(e), ne(e);
3112
3112
  }
3113
3113
  function le(e, t, n) {
@@ -3222,11 +3222,11 @@ var me = class e {
3222
3222
  return i(t), r;
3223
3223
  }
3224
3224
  static shouldBuildText(e) {
3225
- return !(e === "textarea" || e === "input" || e === "option" || e === "select");
3225
+ return e !== "textarea" && e !== "input" && e !== "option" && e !== "select";
3226
3226
  }
3227
3227
  }, ge = /url\(|image-set\(/i, _e = /^on/i, ve = class {
3228
3228
  static get _allowedHtmlElements() {
3229
- return P(this, "_allowedHtmlElements", new Set([
3229
+ return P(this, "_allowedHtmlElements", /* @__PURE__ */ new Set([
3230
3230
  "a",
3231
3231
  "b",
3232
3232
  "br",
@@ -3249,7 +3249,7 @@ var me = class e {
3249
3249
  ]));
3250
3250
  }
3251
3251
  static get _allowedSvgElements() {
3252
- return P(this, "_allowedSvgElements", new Set([
3252
+ return P(this, "_allowedSvgElements", /* @__PURE__ */ new Set([
3253
3253
  "ellipse",
3254
3254
  "line",
3255
3255
  "path",
@@ -3258,7 +3258,7 @@ var me = class e {
3258
3258
  ]));
3259
3259
  }
3260
3260
  static get _allowedRichTextElements() {
3261
- return P(this, "_allowedRichTextElements", new Set([
3261
+ return P(this, "_allowedRichTextElements", /* @__PURE__ */ new Set([
3262
3262
  "a",
3263
3263
  "b",
3264
3264
  "br",
@@ -3274,14 +3274,14 @@ var me = class e {
3274
3274
  ]));
3275
3275
  }
3276
3276
  static get _allowedRichTextAttributes() {
3277
- return P(this, "_allowedRichTextAttributes", new Set([
3277
+ return P(this, "_allowedRichTextAttributes", /* @__PURE__ */ new Set([
3278
3278
  "class",
3279
3279
  "dir",
3280
3280
  "style"
3281
3281
  ]));
3282
3282
  }
3283
3283
  static get _allowedRichTextStyles() {
3284
- return P(this, "_allowedRichTextStyles", new Set(/* @__PURE__ */ "color.font.fontFamily.fontSize.fontStretch.fontStyle.fontWeight.kerningMode.letterSpacing.lineHeight.margin.marginBottom.marginLeft.marginRight.marginTop.orphans.paddingLeft.paddingRight.breakAfter.breakBefore.breakInside.tabInterval.tabStop.textAlign.textDecoration.textIndent.transform.verticalAlign.widows".split(".")));
3284
+ return P(this, "_allowedRichTextStyles", /* @__PURE__ */ new Set(/* @__PURE__ */ "color.font.fontFamily.fontSize.fontStretch.fontStyle.fontWeight.kerningMode.letterSpacing.lineHeight.margin.marginBottom.marginLeft.marginRight.marginTop.orphans.paddingLeft.paddingRight.breakAfter.breakBefore.breakInside.tabInterval.tabStop.textAlign.textDecoration.textIndent.transform.verticalAlign.widows".split(".")));
3285
3285
  }
3286
3286
  static setupStorage(e, t, n, r, i) {
3287
3287
  let a = r.getValue(t, { value: null });
@@ -3314,13 +3314,12 @@ var me = class e {
3314
3314
  let n = e.target.options, i = n.selectedIndex === -1 ? "" : n[n.selectedIndex].value;
3315
3315
  r.setValue(t, { value: i });
3316
3316
  });
3317
- break;
3318
3317
  }
3319
3318
  }
3320
3319
  static setAttributes({ html: e, element: t, storage: n = null, intent: r, linkService: i }) {
3321
3320
  let { attributes: a } = t, o = e instanceof HTMLAnchorElement;
3322
3321
  a.type === "radio" && (a.name = `${a.name}-${r}`);
3323
- for (let [t, n] of Object.entries(a)) if (n != null && !_e.test(t) && !(r === "richText" && !this._allowedRichTextAttributes.has(t))) switch (t) {
3322
+ for (let [t, n] of Object.entries(a)) if (n != null && !_e.test(t) && (r !== "richText" || this._allowedRichTextAttributes.has(t))) switch (t) {
3324
3323
  case "class":
3325
3324
  n.length && e.setAttribute(t, n.join(" "));
3326
3325
  break;
@@ -3456,9 +3455,7 @@ async function be(e, t = "text") {
3456
3455
  return;
3457
3456
  }
3458
3457
  n(i.responseText);
3459
- return;
3460
- }
3461
- r(Error(i.statusText));
3458
+ } else r(Error(i.statusText));
3462
3459
  }
3463
3460
  }, i.send(null);
3464
3461
  });
@@ -3720,9 +3717,7 @@ function Be(e, t) {
3720
3717
  case r:
3721
3718
  t[0] = ((i - n) / e + 2) * 60;
3722
3719
  break;
3723
- case i:
3724
- t[0] = ((n - r) / e + 4) * 60;
3725
- break;
3720
+ case i: t[0] = ((n - r) / e + 4) * 60;
3726
3721
  }
3727
3722
  }
3728
3723
  t[2] = s;
@@ -3746,9 +3741,7 @@ function Ve(e, t) {
3746
3741
  t[0] = o + s, t[1] = s, t[2] = a + s;
3747
3742
  break;
3748
3743
  case 5:
3749
- case 6:
3750
- t[0] = a + s, t[1] = s, t[2] = o + s;
3751
- break;
3744
+ case 6: t[0] = a + s, t[1] = s, t[2] = o + s;
3752
3745
  }
3753
3746
  }
3754
3747
  function He(e) {
@@ -3765,7 +3758,7 @@ var We = /* @__PURE__ */ new Map();
3765
3758
  function Ge(e, t) {
3766
3759
  let n = e[0] + e[1] * 256 + e[2] * 65536 + t[0] * 16777216 + t[1] * 4294967296 + t[2] * 1099511627776, r = We.get(n);
3767
3760
  if (r) return r;
3768
- let i = new Float32Array(9), a = i.subarray(0, 3), o = i.subarray(3, 6);
3761
+ let i = /* @__PURE__ */ new Float32Array(9), a = i.subarray(0, 3), o = i.subarray(3, 6);
3769
3762
  Be(e, o);
3770
3763
  let s = i.subarray(6, 9);
3771
3764
  Be(t, s);
@@ -3817,9 +3810,7 @@ function qe(e) {
3817
3810
  case x.closePath:
3818
3811
  t.closePath();
3819
3812
  break;
3820
- default:
3821
- D(`Unrecognized drawing path operator: ${e[n - 1]}`);
3822
- break;
3813
+ default: D(`Unrecognized drawing path operator: ${e[n - 1]}`);
3823
3814
  }
3824
3815
  return t;
3825
3816
  }
@@ -3918,11 +3909,7 @@ var Je = class e {
3918
3909
  this.#f(t), this.#r.append(t, this.#p);
3919
3910
  }
3920
3911
  removeButton(e) {
3921
- switch (e) {
3922
- case "comment":
3923
- this.#a?.removeToolbarCommentButton(), this.#a = null, this.#o?.remove(), this.#o = null;
3924
- break;
3925
- }
3912
+ e === "comment" && (this.#a?.removeToolbarCommentButton(), this.#a = null, this.#o?.remove(), this.#o = null);
3926
3913
  }
3927
3914
  async addButton(e, t) {
3928
3915
  switch (e) {
@@ -3938,9 +3925,7 @@ var Je = class e {
3938
3925
  case "delete":
3939
3926
  this.addDeleteButton();
3940
3927
  break;
3941
- case "comment":
3942
- t && this.addComment(t);
3943
- break;
3928
+ case "comment": t && this.addComment(t);
3944
3929
  }
3945
3930
  }
3946
3931
  async addButtonBefore(e, t, n) {
@@ -3979,11 +3964,7 @@ var Je = class e {
3979
3964
  let e = i.y + i.height;
3980
3965
  if (e < n) continue;
3981
3966
  let a = i.x + (t ? i.width : 0);
3982
- if (e > n) {
3983
- r = a, n = e;
3984
- continue;
3985
- }
3986
- t ? a > r && (r = a) : a < r && (r = a);
3967
+ e > n ? (r = a, n = e) : t ? a > r && (r = a) : a < r && (r = a);
3987
3968
  }
3988
3969
  return [t ? 1 - r : r, n];
3989
3970
  }
@@ -4024,7 +4005,7 @@ var G = class e {
4024
4005
  return e.#e === t;
4025
4006
  }
4026
4007
  static isSamePointerIdOrRemove(t) {
4027
- return e.#e === t ? !0 : (e.#t?.delete(t), !1);
4008
+ return e.#e === t || (e.#t?.delete(t), !1);
4028
4009
  }
4029
4010
  static isSamePointerType(t) {
4030
4011
  return e.#r === t;
@@ -4234,15 +4215,14 @@ var G = class e {
4234
4215
  for (let i of t.split("+")) {
4235
4216
  if (i = i.trim(), !i) continue;
4236
4217
  let a = i.toUpperCase(), o = e[a];
4237
- if (o) {
4238
- r |= o;
4239
- continue;
4240
- }
4241
- if (n !== null) {
4242
- D(`KeyboardManager: multiple keys in shortcut "${t}"`);
4243
- break;
4218
+ if (o) r |= o;
4219
+ else {
4220
+ if (n !== null) {
4221
+ D(`KeyboardManager: multiple keys in shortcut "${t}"`);
4222
+ break;
4223
+ }
4224
+ n = a === "SPACE" ? " " : i;
4244
4225
  }
4245
- n = a === "SPACE" ? " " : i;
4246
4226
  }
4247
4227
  return n === null && D(`KeyboardManager: no key found in shortcut "${t}"`), [n, r];
4248
4228
  }
@@ -4260,10 +4240,10 @@ var G = class e {
4260
4240
  let i = (n.altKey ? e.ALT : 0) | (n.ctrlKey ? e.CTRL : 0) | (n.metaKey ? e.META : 0) | (n.shiftKey ? e.SHIFT : 0), a = r.find((e) => e.modifiers === i);
4261
4241
  if (!a) return;
4262
4242
  let { callback: o, options: { bubbles: s = !1, args: c = [], checker: l = null } } = a;
4263
- l && !l(t, n) || (o.bind(t, ...c, n)(), s || U(n));
4243
+ (!l || l(t, n)) && (o.bind(t, ...c, n)(), s || U(n));
4264
4244
  }
4265
4245
  }, nt = class e {
4266
- static _colorsMapping = new Map([["CanvasText", [
4246
+ static _colorsMapping = /* @__PURE__ */ new Map([["CanvasText", [
4267
4247
  0,
4268
4248
  0,
4269
4249
  0
@@ -4273,7 +4253,7 @@ var G = class e {
4273
4253
  255
4274
4254
  ]]]);
4275
4255
  get _colors() {
4276
- let e = new Map([["CanvasText", null], ["Canvas", null]]);
4256
+ let e = /* @__PURE__ */ new Map([["CanvasText", null], ["Canvas", null]]);
4277
4257
  return Me(e), P(this, "_colors", e);
4278
4258
  }
4279
4259
  convert(t) {
@@ -4528,11 +4508,7 @@ var G = class e {
4528
4508
  let t = /* @__PURE__ */ new Map(), n = !!this.#B;
4529
4509
  for (let [r, i] of e) {
4530
4510
  let e = r.endsWith("_HCM");
4531
- if (n && e) {
4532
- t.set(r.replace("_HCM", ""), i);
4533
- continue;
4534
- }
4535
- !n && !e && t.set(r, i);
4511
+ n && e ? t.set(r.replace("_HCM", ""), i) : !n && !e && t.set(r, i);
4536
4512
  }
4537
4513
  return P(this, "highlightColors", t);
4538
4514
  }
@@ -4629,11 +4605,7 @@ var G = class e {
4629
4605
  });
4630
4606
  }
4631
4607
  onSetPreference({ name: e, value: t }) {
4632
- switch (e) {
4633
- case "enableNewAltTextWhenAddingImage":
4634
- this.#b = t;
4635
- break;
4636
- }
4608
+ e === "enableNewAltTextWhenAddingImage" && (this.#b = t);
4637
4609
  }
4638
4610
  onPageChanging({ pageNumber: e }) {
4639
4611
  this.#p = e - 1;
@@ -4699,11 +4671,7 @@ var G = class e {
4699
4671
  });
4700
4672
  d && this.showAllEditors("highlight", !0, !0), t && n?.editComment();
4701
4673
  };
4702
- if (d) {
4703
- this.switchToMode(f.HIGHLIGHT, p);
4704
- return;
4705
- }
4706
- p();
4674
+ d ? this.switchToMode(f.HIGHLIGHT, p) : p();
4707
4675
  }
4708
4676
  commentSelection(e = "") {
4709
4677
  this.highlightSelection(e, !0);
@@ -4738,15 +4706,12 @@ var G = class e {
4738
4706
  let { anchorNode: t } = e;
4739
4707
  if (t === this.#R) return;
4740
4708
  let n = this.#X(e).closest(".textLayer");
4741
- if (!n) {
4742
- this.#R && (this.#E?.hide(), this.#R = null, this.#le({ hasSelectedText: !1 }));
4743
- return;
4744
- }
4745
- if (this.#E?.hide(), this.#R = t, this.#le({ hasSelectedText: !0 }), !(this.#I !== f.HIGHLIGHT && this.#I !== f.NONE) && (this.#I === f.HIGHLIGHT && this.showAllEditors("highlight", !0, !0), this.#T = this.isShiftKeyDown, !this.isShiftKeyDown)) {
4709
+ if (!n) this.#R && (this.#E?.hide(), this.#R = null, this.#le({ hasSelectedText: !1 }));
4710
+ else if (this.#E?.hide(), this.#R = t, this.#le({ hasSelectedText: !0 }), (this.#I === f.HIGHLIGHT || this.#I === f.NONE) && (this.#I === f.HIGHLIGHT && this.showAllEditors("highlight", !0, !0), this.#T = this.isShiftKeyDown, !this.isShiftKeyDown)) {
4746
4711
  let e = this.#I === f.HIGHLIGHT ? this.#Z(n) : null;
4747
4712
  if (e?.toggleDrawing(), this.#k) {
4748
4713
  let t = new AbortController(), n = this.combinedSignal(t), r = (n) => {
4749
- n.type === "pointerup" && n.button !== 0 || (t.abort(), e?.toggleDrawing(!0), n.type === "pointerup" && this.#ee("main_toolbar"));
4714
+ (n.type !== "pointerup" || n.button === 0) && (t.abort(), e?.toggleDrawing(!0), n.type === "pointerup" && this.#ee("main_toolbar"));
4750
4715
  };
4751
4716
  window.addEventListener("pointerup", r, { signal: n }), window.addEventListener("blur", r, { signal: n });
4752
4717
  } else e?.toggleDrawing(!0), this.#ee("main_toolbar");
@@ -4893,9 +4858,7 @@ var G = class e {
4893
4858
  case "highlightSelection":
4894
4859
  this.highlightSelection("context_menu");
4895
4860
  break;
4896
- case "commentSelection":
4897
- this.commentSelection("context_menu");
4898
- break;
4861
+ case "commentSelection": this.commentSelection("context_menu");
4899
4862
  }
4900
4863
  }
4901
4864
  updatePageIndex(e, t) {
@@ -4973,30 +4936,29 @@ var G = class e {
4973
4936
  this.setEditingState(!1), this.#fe();
4974
4937
  for (let e of this.#r.values()) e.hideStandaloneCommentButton();
4975
4938
  this._editorUndoBar?.hide(), this.toggleComment(null), this.#Y.resolve();
4976
- return;
4977
- }
4978
- for (let e of this.#r.values()) e.addStandaloneCommentButton();
4979
- e === f.SIGNATURE && await this.#z?.loadSignatures(), n && G.clearPointerType(), this.setEditingState(!0), await this.#de(), this.unselectAll();
4980
- for (let t of this.#i.values()) t.updateMode(e);
4981
- if (e === f.POPUP) {
4982
- this.#n ||= await this.#H.getAnnotationsByType(new Set(this.#g.map((e) => e._editorType)));
4983
- let e = /* @__PURE__ */ new Set(), t = [];
4984
- for (let n of this.#r.values()) {
4985
- let { annotationElementId: r, hasComment: i, deleted: a } = n;
4986
- r && e.add(r), i && !a && t.push(n.getData());
4939
+ } else {
4940
+ for (let e of this.#r.values()) e.addStandaloneCommentButton();
4941
+ e === f.SIGNATURE && await this.#z?.loadSignatures(), n && G.clearPointerType(), this.setEditingState(!0), await this.#de(), this.unselectAll();
4942
+ for (let t of this.#i.values()) t.updateMode(e);
4943
+ if (e === f.POPUP) {
4944
+ this.#n ||= await this.#H.getAnnotationsByType(new Set(this.#g.map((e) => e._editorType)));
4945
+ let e = /* @__PURE__ */ new Set(), t = [];
4946
+ for (let n of this.#r.values()) {
4947
+ let { annotationElementId: r, hasComment: i, deleted: a } = n;
4948
+ r && e.add(r), i && !a && t.push(n.getData());
4949
+ }
4950
+ for (let n of this.#n) {
4951
+ let { id: r, popupRef: i, contentsObj: a } = n;
4952
+ i && a?.str && !e.has(r) && !this.#m.has(r) && t.push(n);
4953
+ }
4954
+ this.#u?.showSidebar(t);
4987
4955
  }
4988
- for (let n of this.#n) {
4989
- let { id: r, popupRef: i, contentsObj: a } = n;
4990
- i && a?.str && !e.has(r) && !this.#m.has(r) && t.push(n);
4956
+ if (!t) r && this.addNewEditorFromKeyboard(), this.#Y.resolve();
4957
+ else {
4958
+ for (let e of this.#r.values()) e.uid === t ? (this.setSelected(e), a ? e.editComment() : i ? e.enterInEditMode() : e.focus()) : e.unselect();
4959
+ this.#Y.resolve();
4991
4960
  }
4992
- this.#u?.showSidebar(t);
4993
4961
  }
4994
- if (!t) {
4995
- r && this.addNewEditorFromKeyboard(), this.#Y.resolve();
4996
- return;
4997
- }
4998
- for (let e of this.#r.values()) e.uid === t ? (this.setSelected(e), a ? e.editComment() : i ? e.enterInEditMode() : e.focus()) : e.unselect();
4999
- this.#Y.resolve();
5000
4962
  }
5001
4963
  }
5002
4964
  addNewEditorFromKeyboard() {
@@ -5014,18 +4976,16 @@ var G = class e {
5014
4976
  case p.CREATE:
5015
4977
  this.currentLayer.addNewEditor(t);
5016
4978
  return;
5017
- case p.HIGHLIGHT_SHOW_ALL:
5018
- this._eventBus.dispatch("reporttelemetry", {
5019
- source: this,
5020
- details: {
5021
- type: "editing",
5022
- data: {
5023
- type: "highlight",
5024
- action: "toggle_visibility"
5025
- }
4979
+ case p.HIGHLIGHT_SHOW_ALL: this._eventBus.dispatch("reporttelemetry", {
4980
+ source: this,
4981
+ details: {
4982
+ type: "editing",
4983
+ data: {
4984
+ type: "highlight",
4985
+ action: "toggle_visibility"
5026
4986
  }
5027
- }), (this.#V ||= /* @__PURE__ */ new Map()).set(e, t), this.showAllEditors("highlight", t);
5028
- break;
4987
+ }
4988
+ }), (this.#V ||= /* @__PURE__ */ new Map()).set(e, t), this.showAllEditors("highlight", t);
5029
4989
  }
5030
4990
  if (this.hasSelection) for (let n of this.#L) n.updateParams(e, t);
5031
4991
  else for (let n of this.#g) n.updateDefaultParams(e, t);
@@ -5069,7 +5029,7 @@ var G = class e {
5069
5029
  removeEditor(e) {
5070
5030
  e.div.contains(document.activeElement) && (this.#S && clearTimeout(this.#S), this.#S = setTimeout(() => {
5071
5031
  this.focusMainContainer(), this.#S = null;
5072
- }, 0)), this.#r.delete(e.id), e.annotationElementId && this.#P?.delete(e.annotationElementId), this.unselect(e), (!e.annotationElementId || !this.#m.has(e.annotationElementId)) && this.#s?.remove(e.id);
5032
+ }, 0)), this.#r.delete(e.id), e.annotationElementId && this.#P?.delete(e.annotationElementId), this.unselect(e), e.annotationElementId && this.#m.has(e.annotationElementId) || this.#s?.remove(e.id);
5073
5033
  }
5074
5034
  addDeletedAnnotationElement(e) {
5075
5035
  this.#m.add(e.annotationElementId), this.addChangedExistingAnnotation(e), e.deleted = !0;
@@ -5099,11 +5059,7 @@ var G = class e {
5099
5059
  this.#ue(e.defaultPropertiesToUpdate);
5100
5060
  }
5101
5061
  toggleSelected(e) {
5102
- if (this.#L.has(e)) {
5103
- this.#L.delete(e), e.unselect(), this.#le({ hasSelectedEditor: this.hasSelection });
5104
- return;
5105
- }
5106
- this.#L.add(e), e.select(), this.#ue(e.propertiesToUpdate), this.#le({ hasSelectedEditor: !0 });
5062
+ this.#L.has(e) ? (this.#L.delete(e), e.unselect(), this.#le({ hasSelectedEditor: this.hasSelection })) : (this.#L.add(e), e.select(), this.#ue(e.propertiesToUpdate), this.#le({ hasSelectedEditor: !0 }));
5107
5063
  }
5108
5064
  setSelected(e) {
5109
5065
  this.updateToolbar({
@@ -5303,19 +5259,17 @@ var G = class e {
5303
5259
  height: o / i
5304
5260
  });
5305
5261
  break;
5306
- default:
5307
- o = (e, t, o, s) => ({
5308
- x: (e - n) / i,
5309
- y: (t - r) / a,
5310
- width: o / i,
5311
- height: s / a
5312
- });
5313
- break;
5262
+ default: o = (e, t, o, s) => ({
5263
+ x: (e - n) / i,
5264
+ y: (t - r) / a,
5265
+ width: o / i,
5266
+ height: s / a
5267
+ });
5314
5268
  }
5315
5269
  let s = [];
5316
5270
  for (let e = 0, n = t.rangeCount; e < n; e++) {
5317
5271
  let n = t.getRangeAt(e);
5318
- if (!n.collapsed) for (let { x: e, y: t, width: r, height: i } of n.getClientRects()) r === 0 || i === 0 || s.push(o(e, t, r, i));
5272
+ if (!n.collapsed) for (let { x: e, y: t, width: r, height: i } of n.getClientRects()) r !== 0 && i !== 0 && s.push(o(e, t, r, i));
5319
5273
  }
5320
5274
  return s.length === 0 ? null : s;
5321
5275
  }
@@ -5329,7 +5283,7 @@ var G = class e {
5329
5283
  let t = this.#c?.get(e.data.id);
5330
5284
  if (!t) return;
5331
5285
  let n = this.#s.getRawValue(t);
5332
- n && (this.#I === f.NONE && !n.hasBeenModified || n.renderAnnotationElement(e));
5286
+ n && (this.#I !== f.NONE || n.hasBeenModified) && n.renderAnnotationElement(e);
5333
5287
  }
5334
5288
  setMissingCanvas(e, t, n) {
5335
5289
  let r = this.#P?.get(e);
@@ -5405,15 +5359,14 @@ var G = class e {
5405
5359
  this.#e === null && (this.#l = t, this.#u = await e._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer", { generatedAltText: t }), this.#m());
5406
5360
  }
5407
5361
  toggleAltTextBadge(e = !1) {
5408
- if (!this.#d || this.#e) {
5409
- this.#s?.remove(), this.#s = null;
5410
- return;
5411
- }
5412
- if (!this.#s) {
5413
- let e = this.#s = document.createElement("div");
5414
- e.className = "noAltTextBadge", this.#c.div.append(e);
5362
+ if (!this.#d || this.#e) this.#s?.remove(), this.#s = null;
5363
+ else {
5364
+ if (!this.#s) {
5365
+ let e = this.#s = document.createElement("div");
5366
+ e.className = "noAltTextBadge", this.#c.div.append(e);
5367
+ }
5368
+ this.#s.classList.toggle("hidden", !e);
5415
5369
  }
5416
- this.#s.classList.toggle("hidden", !e);
5417
5370
  }
5418
5371
  serialize(e) {
5419
5372
  let t = this.#e;
@@ -5431,7 +5384,7 @@ var G = class e {
5431
5384
  };
5432
5385
  }
5433
5386
  set data({ altText: e, decorative: t, guessedText: n, textWithDisclaimer: r, cancel: i = !1 }) {
5434
- n && (this.#l = n, this.#u = r), !(this.#e === e && this.#t === t) && (i || (this.#e = e, this.#t = t), this.#m());
5387
+ n && (this.#l = n, this.#u = r), (this.#e !== e || this.#t !== t) && (i || (this.#e = e, this.#t = t), this.#m());
5435
5388
  }
5436
5389
  toggle(e = !1) {
5437
5390
  this.#n && (!e && this.#a && (clearTimeout(this.#a), this.#a = null), this.#n.disabled = !e);
@@ -5608,11 +5561,7 @@ var G = class e {
5608
5561
  };
5609
5562
  }
5610
5563
  set data(e) {
5611
- if (e !== this.#o && (this.#a = null), e === null) {
5612
- this.#o = "", this.#c = !0;
5613
- return;
5614
- }
5615
- this.#o = e, this.#s = /* @__PURE__ */ new Date(), this.#c = !1;
5564
+ e !== this.#o && (this.#a = null), e === null ? (this.#o = "", this.#c = !0) : (this.#o = e, this.#s = /* @__PURE__ */ new Date(), this.#c = !1);
5616
5565
  }
5617
5566
  restoreData({ text: e, richText: t, date: n }) {
5618
5567
  this.#o = e, this.#a = t, this.#s = n, this.#c = !1;
@@ -5880,9 +5829,7 @@ var G = class e {
5880
5829
  case 270:
5881
5830
  this.x += this.height * t / (e * 2), this.y -= this.width * e / (t * 2);
5882
5831
  break;
5883
- default:
5884
- this.x -= this.width / 2, this.y -= this.height / 2;
5885
- break;
5832
+ default: this.x -= this.width / 2, this.y -= this.height / 2;
5886
5833
  }
5887
5834
  this.fixAndSetPosition();
5888
5835
  }
@@ -5994,9 +5941,7 @@ var G = class e {
5994
5941
  case 180:
5995
5942
  i = H(i, o, n), a = H(a, s, r);
5996
5943
  break;
5997
- case 270:
5998
- i = H(i, s, n), a = H(a, 0, r - o);
5999
- break;
5944
+ case 270: i = H(i, s, n), a = H(a, 0, r - o);
6000
5945
  }
6001
5946
  this.x = i /= n, this.y = a /= r;
6002
5947
  let [c, l] = this.getBaseTranslation();
@@ -6128,7 +6073,7 @@ var G = class e {
6128
6073
  let { savedX: e, savedY: t, savedWidth: n, savedHeight: r } = this.#u;
6129
6074
  this.#u = null;
6130
6075
  let i = this.x, a = this.y, o = this.width, s = this.height;
6131
- i === e && a === t && o === n && s === r || this.addCommands({
6076
+ (i !== e || a !== t || o !== n || s !== r) && this.addCommands({
6132
6077
  cmd: this.#j.bind(this, i, a, o, s),
6133
6078
  undo: this.#j.bind(this, e, t, n, r),
6134
6079
  mustExec: !0
@@ -6161,9 +6106,7 @@ var G = class e {
6161
6106
  case "bottomLeft":
6162
6107
  _ = !0, h = (e, t) => [0, t], g = (e, t) => [e, 0];
6163
6108
  break;
6164
- case "middleLeft":
6165
- v = !0, h = (e, t) => [0, t / 2], g = (e, t) => [e, t / 2];
6166
- break;
6109
+ case "middleLeft": v = !0, h = (e, t) => [0, t / 2], g = (e, t) => [e, t / 2];
6167
6110
  }
6168
6111
  let y = h(s, c), b = g(s, c), x = f(...b), S = e._round(a + x[0]), C = e._round(o + x[1]), w = 1, T = 1, E, D;
6169
6112
  if (n.fromKeyboard) ({deltaX: E, deltaY: D} = n);
@@ -6246,13 +6189,7 @@ var G = class e {
6246
6189
  return this.canAddComment ? this.#r ||= new at(this) : null;
6247
6190
  }
6248
6191
  addStandaloneCommentButton() {
6249
- if (this._uiManager.hasCommentManager()) {
6250
- if (this.#i) {
6251
- this._uiManager.isEditingMode() && this.#i.classList.remove("hidden");
6252
- return;
6253
- }
6254
- this.hasComment && (this.#i = this.#r.renderForStandalone(), this.div.append(this.#i));
6255
- }
6192
+ this._uiManager.hasCommentManager() && (this.#i ? this._uiManager.isEditingMode() && this.#i.classList.remove("hidden") : this.hasComment && (this.#i = this.#r.renderForStandalone(), this.div.append(this.#i)));
6256
6193
  }
6257
6194
  removeStandaloneCommentButton() {
6258
6195
  this.#r.removeStandaloneCommentButton(), this.#i = null;
@@ -6367,15 +6304,7 @@ var G = class e {
6367
6304
  }
6368
6305
  pointerdown(e) {
6369
6306
  let { isMac: t } = B.platform;
6370
- if (e.button !== 0 || e.ctrlKey && t) {
6371
- e.preventDefault();
6372
- return;
6373
- }
6374
- if (this.#m = !0, this._isDraggable) {
6375
- this.#R(e);
6376
- return;
6377
- }
6378
- this.#L(e);
6307
+ e.button !== 0 || e.ctrlKey && t ? e.preventDefault() : (this.#m = !0, this._isDraggable ? this.#R(e) : this.#L(e));
6379
6308
  }
6380
6309
  #L(e) {
6381
6310
  let { isMac: t } = B.platform;
@@ -6404,11 +6333,7 @@ var G = class e {
6404
6333
  e.pointerType === this.#s && (this.#C || e.isPrimary) && o(e), U(e);
6405
6334
  }, a));
6406
6335
  let s = (e) => {
6407
- if (!this.#o || this.#o === e.pointerId) {
6408
- o(e);
6409
- return;
6410
- }
6411
- U(e);
6336
+ !this.#o || this.#o === e.pointerId ? o(e) : U(e);
6412
6337
  };
6413
6338
  window.addEventListener("pointerup", s, { signal: i }), window.addEventListener("blur", s, { signal: i });
6414
6339
  }
@@ -6511,7 +6436,7 @@ var G = class e {
6511
6436
  return !1;
6512
6437
  }
6513
6438
  enableEditMode() {
6514
- return this.isInEditMode() ? !1 : (this.parent.setEditingState(!1), this.#_ = !0, !0);
6439
+ return !this.isInEditMode() && (this.parent.setEditingState(!1), this.#_ = !0, !0);
6515
6440
  }
6516
6441
  disableEditMode() {
6517
6442
  return this.isInEditMode() ? (this.parent.setEditingState(!0), this.#_ = !1, !0) : !1;
@@ -6678,17 +6603,9 @@ var G = class e {
6678
6603
  this.#W(), this.div.focus();
6679
6604
  }
6680
6605
  select() {
6681
- if (this.isSelected && this._editToolbar) {
6682
- this._editToolbar.show();
6683
- return;
6684
- }
6685
- if (this.isSelected = !0, this.makeResizable(), this.div?.classList.add("selectedEditor"), !this._editToolbar) {
6686
- this.addEditToolbar().then(() => {
6687
- this.div?.classList.contains("selectedEditor") && this._editToolbar?.show();
6688
- });
6689
- return;
6690
- }
6691
- this._editToolbar?.show(), this.#n?.toggleAltTextBadge(!1);
6606
+ this.isSelected && this._editToolbar ? this._editToolbar.show() : (this.isSelected = !0, this.makeResizable(), this.div?.classList.add("selectedEditor"), this._editToolbar ? (this._editToolbar?.show(), this.#n?.toggleAltTextBadge(!1)) : this.addEditToolbar().then(() => {
6607
+ this.div?.classList.contains("selectedEditor") && this._editToolbar?.show();
6608
+ }));
6692
6609
  }
6693
6610
  focus() {
6694
6611
  this.div && !this.div.contains(document.activeElement) && setTimeout(() => this.div?.focus({ preventScroll: !0 }), 0);
@@ -6745,9 +6662,7 @@ var G = class e {
6745
6662
  r && clearTimeout(r), r = setTimeout(() => {
6746
6663
  this._reportTelemetry(t), this.#S.delete(n), this.#S.size === 0 && (this.#S = null);
6747
6664
  }, e._telemetryTimeout), this.#S.set(n, r);
6748
- return;
6749
- }
6750
- t.type ||= this.editorType, this._uiManager._eventBus.dispatch("reporttelemetry", {
6665
+ } else t.type ||= this.editorType, this._uiManager._eventBus.dispatch("reporttelemetry", {
6751
6666
  source: this,
6752
6667
  details: {
6753
6668
  type: "editing",
@@ -6765,15 +6680,7 @@ var G = class e {
6765
6680
  this.div && (this.div.tabIndex = -1), this.#a = !0;
6766
6681
  }
6767
6682
  updateFakeAnnotationElement(e) {
6768
- if (!this.#d && !this.deleted) {
6769
- this.#d = e.addFakeAnnotation(this);
6770
- return;
6771
- }
6772
- if (this.deleted) {
6773
- this.#d.remove(), this.#d = null;
6774
- return;
6775
- }
6776
- (this.hasEditedComment || this._hasBeenMoved || this._hasBeenResized) && this.#d.updateEdited({
6683
+ !this.#d && !this.deleted ? this.#d = e.addFakeAnnotation(this) : this.deleted ? (this.#d.remove(), this.#d = null) : (this.hasEditedComment || this._hasBeenMoved || this._hasBeenResized) && this.#d.updateEdited({
6777
6684
  rect: this.getPDFRect(),
6778
6685
  popup: this.comment
6779
6686
  });
@@ -6801,7 +6708,7 @@ var G = class e {
6801
6708
  }
6802
6709
  }, ct = 3285377520, lt = 4294901760, ut = 65535, dt = class {
6803
6710
  constructor(e) {
6804
- this.h1 = e ? e & 4294967295 : ct, this.h2 = e ? e & 4294967295 : ct;
6711
+ this.h1 = e ? e | 0 : ct, this.h2 = e ? e | 0 : ct;
6805
6712
  }
6806
6713
  update(e) {
6807
6714
  let t, n;
@@ -6847,7 +6754,7 @@ var G = class e {
6847
6754
  }
6848
6755
  remove(e) {
6849
6756
  let t = this.#r.get(e);
6850
- t !== void 0 && (t instanceof K && this.#n.delete(t.annotationElementId), this.#r.delete(e), this.#r.size === 0 && this.resetModified(), !this.#r.values().some((e) => e instanceof K) && this.onAnnotationEditor?.(null));
6757
+ t !== void 0 && (t instanceof K && this.#n.delete(t.annotationElementId), this.#r.delete(e), this.#r.size === 0 && this.resetModified(), this.#r.values().some((e) => e instanceof K) || this.onAnnotationEditor?.(null));
6851
6758
  }
6852
6759
  setValue(e, t) {
6853
6760
  let n = this.#r.get(e), r = !1;
@@ -7198,7 +7105,7 @@ var bt = new Uint32Array(new Uint8Array([
7198
7105
  restore(e) {
7199
7106
  this.#s.restore(e, this.#o);
7200
7107
  let t = Object.getPrototypeOf(this.#e);
7201
- return t === null ? this : (this.#e = t, this.#t = Object.getPrototypeOf(this.#t), this);
7108
+ return t === null || (this.#e = t, this.#t = Object.getPrototypeOf(this.#t)), this;
7202
7109
  }
7203
7110
  recordOpenMarker(e) {
7204
7111
  return this.#s.recordOpenMarker(e, this.#o), this;
@@ -7573,7 +7480,7 @@ var bt = new Uint32Array(new Uint8Array([
7573
7480
  this.styleElement &&= (this.styleElement.remove(), null);
7574
7481
  }
7575
7482
  async loadSystemFont({ systemFontInfo: e, disableFontFace: t, _inspectFont: n }) {
7576
- if (!(!e || this.#e.has(e.loadedName))) {
7483
+ if (e && !this.#e.has(e.loadedName)) {
7577
7484
  if (k(!t, "loadSystemFont shouldn't be called when `disableFontFace` is set."), this.isFontLoadingAPISupported) {
7578
7485
  let { loadedName: t, src: r, style: i } = e, a = new FontFace(t, r, i);
7579
7486
  this.addNativeFontFace(a);
@@ -7582,9 +7489,7 @@ var bt = new Uint32Array(new Uint8Array([
7582
7489
  } catch {
7583
7490
  D(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`), this.removeNativeFontFace(a);
7584
7491
  }
7585
- return;
7586
- }
7587
- O("Not implemented: loadSystemFont without the Font Loading API.");
7492
+ } else O("Not implemented: loadSystemFont without the Font Loading API.");
7588
7493
  }
7589
7494
  }
7590
7495
  async bind(e) {
@@ -7654,15 +7559,7 @@ var bt = new Uint32Array(new Uint8Array([
7654
7559
  s.width = 1, s.height = 1;
7655
7560
  let c = s.getContext("2d"), l = 0;
7656
7561
  function u(e, t) {
7657
- if (++l > 30) {
7658
- D("Load test font never loaded."), t();
7659
- return;
7660
- }
7661
- if (c.font = "30px " + e, c.fillText(".", 0, 20), c.getImageData(0, 0, 1, 1).data[3] > 0) {
7662
- t();
7663
- return;
7664
- }
7665
- setTimeout(u.bind(null, e, t));
7562
+ ++l > 30 ? (D("Load test font never loaded."), t()) : (c.font = "30px " + e, c.fillText(".", 0, 20), c.getImageData(0, 0, 1, 1).data[3] > 0 ? t() : setTimeout(u.bind(null, e, t)));
7666
7563
  }
7667
7564
  let d = `lt${Date.now()}${this.loadTestFontId++}`, f = this._loadTestFont;
7668
7565
  f = i(f, 976, d.length, d);
@@ -8227,13 +8124,7 @@ var qt = class {
8227
8124
  reason: J(t)
8228
8125
  });
8229
8126
  });
8230
- return;
8231
- }
8232
- if (e.streamId) {
8233
- this.#n(e);
8234
- return;
8235
- }
8236
- t(e.data);
8127
+ } else e.streamId ? this.#n(e) : t(e.data);
8237
8128
  }
8238
8129
  on(e, t) {
8239
8130
  let n = this.actionHandler;
@@ -8329,7 +8220,7 @@ var qt = class {
8329
8220
  }), delete a.streamSinks[t]);
8330
8221
  },
8331
8222
  error(e) {
8332
- k(e instanceof Error, "error must have a valid reason"), !this.isCancelled && (this.isCancelled = !0, i.postMessage({
8223
+ k(e instanceof Error, "error must have a valid reason"), this.isCancelled || (this.isCancelled = !0, i.postMessage({
8333
8224
  sourceName: n,
8334
8225
  targetName: r,
8335
8226
  stream: q.ERROR,
@@ -8983,7 +8874,7 @@ var hn = class {
8983
8874
  else if (this._type === "radial") {
8984
8875
  let a = this._r0, o = this._r1;
8985
8876
  if (t) {
8986
- let e = new Float32Array(2);
8877
+ let e = /* @__PURE__ */ new Float32Array(2);
8987
8878
  V.singularValueDecompose2dScale(t, e), a *= e[0], o *= e[0];
8988
8879
  }
8989
8880
  n = e.createRadialGradient(r[0], r[1], a, i[0], i[1], o);
@@ -8996,7 +8887,7 @@ var hn = class {
8996
8887
  t && (n = n.slice(), r = r.slice(), V.applyTransform(n, t), V.applyTransform(r, t));
8997
8888
  let i = this._r1, a = this._r0;
8998
8889
  if (t) {
8999
- let e = new Float32Array(2);
8890
+ let e = /* @__PURE__ */ new Float32Array(2);
9000
8891
  V.singularValueDecompose2dScale(t, e), i *= e[0], a *= e[0];
9001
8892
  }
9002
8893
  let o = e.createRadialGradient(n[0], n[1], i, r[0], r[1], a), s = this._colorStops.map(([e, t]) => [1 - e, t]).reverse();
@@ -9010,9 +8901,11 @@ var hn = class {
9010
8901
  let r = V.transform(n, t.baseTransform);
9011
8902
  this.matrix && (r = V.transform(r, this.matrix));
9012
8903
  let i = .001, a = Math.hypot(r[0], r[1]), o = Math.hypot(r[2], r[3]), s = (r[0] * r[2] + r[1] * r[3]) / (a * o);
9013
- if (Math.abs(s) < i) if (this.isRadial()) {
9014
- if (Math.abs(a - o) < i) return this._createGradient(e, r);
9015
- } else return this._createGradient(e, r);
8904
+ if (Math.abs(s) < i) {
8905
+ if (this.isRadial()) {
8906
+ if (Math.abs(a - o) < i) return this._createGradient(e, r);
8907
+ } else return this._createGradient(e, r);
8908
+ }
9016
8909
  }
9017
8910
  let a = t.current.getClippedPathBoundingBox(r, W(e)) || [
9018
8911
  0,
@@ -9090,7 +8983,7 @@ var vn = class extends hn {
9090
8983
  }
9091
8984
  getPattern(e, t, n, r) {
9092
8985
  mn(e, this._bbox);
9093
- let i = new Float32Array(2);
8986
+ let i = /* @__PURE__ */ new Float32Array(2);
9094
8987
  if (r === Y.SHADING) V.singularValueDecompose2dScale(W(e), i);
9095
8988
  else if (this.matrix) {
9096
8989
  V.singularValueDecompose2dScale(this.matrix, i);
@@ -9138,7 +9031,7 @@ var xn = {
9138
9031
  return u.groupLevel = e.groupLevel, this.setFillAndStrokeStyleToContext(u, this.paintType, this.color), l.translate(-n.scale * i, -r.scale * a), u.transform(0, n.scale, 0, 0, r.scale, 0, 0), l.save(), u.dependencyTracker?.save(), this.clipBbox(u, i, a, o, s), u.baseTransform = W(u.ctx), u.executeOperatorList(this.operatorList), u.endDrawing(), u.dependencyTracker?.restore(), l.restore(), c;
9139
9032
  }
9140
9033
  _getCombinedScales() {
9141
- let e = new Float32Array(2);
9034
+ let e = /* @__PURE__ */ new Float32Array(2);
9142
9035
  V.singularValueDecompose2dScale(this.matrix, e);
9143
9036
  let [t, n] = e;
9144
9037
  return V.singularValueDecompose2dScale(this.baseTransform, e), [t * e[0], n * e[1]];
@@ -9218,7 +9111,7 @@ var xn = {
9218
9111
  let c = e.createPattern(o.canvas, "repeat");
9219
9112
  return t.canvasFactory.destroy(o.canvasEntry), c.setTransform(s), c;
9220
9113
  }
9221
- }, Cn = 16, wn = 100, Tn = 15, En = 10, X = 16, Dn = new DOMMatrix(), Z = new Float32Array(2);
9114
+ }, Cn = 16, wn = 100, Tn = 15, En = 10, X = 16, Dn = new DOMMatrix(), Z = /* @__PURE__ */ new Float32Array(2);
9222
9115
  function On(e, t) {
9223
9116
  if (e._removeMirroring) throw Error("Context is already forwarding operations.");
9224
9117
  let n = /* @__PURE__ */ new Map();
@@ -9245,7 +9138,7 @@ function On(e, t) {
9245
9138
  "beginPath"
9246
9139
  ]) {
9247
9140
  let i = e[r];
9248
- typeof i != "function" || typeof t[r] != "function" || (n.set(r, i), e[r] = function(...e) {
9141
+ typeof i == "function" && typeof t[r] == "function" && (n.set(r, i), e[r] = function(...e) {
9249
9142
  return t[r](...e), i.apply(this, e);
9250
9143
  });
9251
9144
  }
@@ -9445,11 +9338,13 @@ var In = [
9445
9338
  continue;
9446
9339
  }
9447
9340
  }
9448
- if (!i || i(s)) if (m = o[s], h = a[s] ?? null, m !== b.dependency) h === null ? this[m](s) : this[m](s, ...h);
9449
- else for (let e of h) {
9450
- this.dependencyTracker?.recordNamedData(e, s);
9451
- let t = e.startsWith("g_") ? f : p;
9452
- if (!t.has(e)) return t.get(e, n), s;
9341
+ if (!i || i(s)) {
9342
+ if (m = o[s], h = a[s] ?? null, m !== b.dependency) h === null ? this[m](s) : this[m](s, ...h);
9343
+ else for (let e of h) {
9344
+ this.dependencyTracker?.recordNamedData(e, s);
9345
+ let t = e.startsWith("g_") ? f : p;
9346
+ if (!t.has(e)) return t.get(e, n), s;
9347
+ }
9453
9348
  }
9454
9349
  if (s++, s === c) return s;
9455
9350
  if (l && ++d > En) {
@@ -9636,9 +9531,7 @@ var In = [
9636
9531
  case "SMask":
9637
9532
  this.dependencyTracker?.recordSimpleData("SMask", e), this.current.activeSMask = r ? this.tempSMask : null, this.current.activeSMask && (this.current.activeSMask.blendMode = this.ctx.globalCompositeOperation), this.tempSMask = null, this.checkSMaskState(e);
9638
9533
  break;
9639
- case "TR":
9640
- this.dependencyTracker?.recordSimpleData("filter", e), this.ctx.filter = this.current.transferMaps = this.filterFactory.addFilter(r);
9641
- break;
9534
+ case "TR": this.dependencyTracker?.recordSimpleData("filter", e), this.ctx.filter = this.current.transferMaps = this.filterFactory.addFilter(r);
9642
9535
  }
9643
9536
  }
9644
9537
  get inSMaskMode() {
@@ -9775,7 +9668,7 @@ var In = [
9775
9668
  this.ctx.canvas.height
9776
9669
  ];
9777
9670
  let t = this.current.activeSMask, n = this.suspendedCtx, r = this.#t > 0 && n === this.ctx;
9778
- this.composeSMask(r ? null : n, t, this.ctx, e), !r && (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());
9671
+ this.composeSMask(r ? null : n, t, this.ctx, e), r || (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());
9779
9672
  }
9780
9673
  composeSMask(e, t, n, r) {
9781
9674
  let i = r[0], a = r[1], o = r[2] - i, s = r[3] - a;
@@ -9816,11 +9709,7 @@ var In = [
9816
9709
  this.stateStack.push(t), this.current = t.clone(), this.dependencyTracker?.save(e);
9817
9710
  }
9818
9711
  restore(e) {
9819
- if (this.dependencyTracker?.restore(e), this.stateStack.length === 0) {
9820
- this.inSMaskMode && this.endSMaskMode();
9821
- return;
9822
- }
9823
- this.current = this.stateStack.pop(), this.ctx.restore(), this.inSMaskMode && (Nn(this.suspendedCtx, this.ctx), this.ctx.setTransform(this.suspendedCtx.getTransform())), this.checkSMaskState(e), this.pendingClip = null, this._cachedScaleForStroking[0] = -1, this._cachedGetSinglePixelWidth = null;
9712
+ this.dependencyTracker?.restore(e), this.stateStack.length === 0 ? this.inSMaskMode && this.endSMaskMode() : (this.current = this.stateStack.pop(), this.ctx.restore(), this.inSMaskMode && (Nn(this.suspendedCtx, this.ctx), this.ctx.setTransform(this.suspendedCtx.getTransform())), this.checkSMaskState(e), this.pendingClip = null, this._cachedScaleForStroking[0] = -1, this._cachedGetSinglePixelWidth = null);
9824
9713
  }
9825
9714
  transform(e, t, n, r, i, a, o) {
9826
9715
  this.dependencyTracker?.recordIncrementalData("transform", e), this.ctx.transform(t, n, r, i, a, o), this._cachedScaleForStroking[0] = -1, this._cachedGetSinglePixelWidth = null;
@@ -9848,14 +9737,16 @@ var In = [
9848
9737
  }
9849
9738
  stroke(e, t, n = !0) {
9850
9739
  let r = n && this.#h(this.current.strokeAlpha), i = this.ctx, a = this.current.strokeColor;
9851
- if (i.globalAlpha = this.current.strokeAlpha, this.contentVisible) if (typeof a == "object" && a?.getPattern) {
9852
- let n = a.isModifyingCurrentTransform() ? i.getTransform() : null;
9853
- if (i.save(), i.strokeStyle = a.getPattern(i, this, Ne(i), Y.STROKE, e), n) {
9854
- let e = new Path2D();
9855
- e.addPath(t, i.getTransform().invertSelf().multiplySelf(n)), t = e;
9856
- }
9857
- this.rescaleAndStroke(t, !1), i.restore();
9858
- } else this.rescaleAndStroke(t, !0);
9740
+ if (i.globalAlpha = this.current.strokeAlpha, this.contentVisible) {
9741
+ if (typeof a == "object" && a?.getPattern) {
9742
+ let n = a.isModifyingCurrentTransform() ? i.getTransform() : null;
9743
+ if (i.save(), i.strokeStyle = a.getPattern(i, this, Ne(i), Y.STROKE, e), n) {
9744
+ let e = new Path2D();
9745
+ e.addPath(t, i.getTransform().invertSelf().multiplySelf(n)), t = e;
9746
+ }
9747
+ this.rescaleAndStroke(t, !1), i.restore();
9748
+ } else this.rescaleAndStroke(t, !0);
9749
+ }
9859
9750
  this.dependencyTracker?.recordDependencies(e, Et.stroke), n && this.consumePath(e, t, this.current.getClippedPathBoundingBox(Y.STROKE, W(this.ctx))), i.globalAlpha = this.current.fillAlpha, this.#g(r);
9860
9751
  }
9861
9752
  closeStroke(e, t) {
@@ -9974,23 +9865,27 @@ var In = [
9974
9865
  if ((c.disableFontFace || f || p || m) && !c.missingFile && (g = c.getPathGenerator(this.commonObjs, t)), g && (c.disableFontFace || p || m)) {
9975
9866
  o.save(), o.translate(n, r), o.scale(u, -u), this.dependencyTracker?.recordCharacterBBox(e, o, c);
9976
9867
  let t;
9977
- if (d === h.FILL || d === h.FILL_STROKE) if (i) {
9978
- t = o.getTransform(), o.setTransform(...i);
9979
- let e = this.#_(g, t, i);
9980
- o.fill(e);
9981
- } else o.fill(g);
9982
- if (d === h.STROKE || d === h.FILL_STROKE) if (a) {
9983
- t ||= o.getTransform(), o.setTransform(...a);
9984
- let { a: e, b: n, c: r, d: i } = t, s = V.inverseTransform(a), c = V.transform([
9985
- e,
9986
- n,
9987
- r,
9988
- i,
9989
- 0,
9990
- 0
9991
- ], s);
9992
- V.singularValueDecompose2dScale(c, Z), o.lineWidth *= Math.max(Z[0], Z[1]) / u, o.stroke(this.#_(g, t, a));
9993
- } else o.lineWidth /= u, o.stroke(g);
9868
+ if (d === h.FILL || d === h.FILL_STROKE) {
9869
+ if (i) {
9870
+ t = o.getTransform(), o.setTransform(...i);
9871
+ let e = this.#_(g, t, i);
9872
+ o.fill(e);
9873
+ } else o.fill(g);
9874
+ }
9875
+ if (d === h.STROKE || d === h.FILL_STROKE) {
9876
+ if (a) {
9877
+ t ||= o.getTransform(), o.setTransform(...a);
9878
+ let { a: e, b: n, c: r, d: i } = t, s = V.inverseTransform(a), c = V.transform([
9879
+ e,
9880
+ n,
9881
+ r,
9882
+ i,
9883
+ 0,
9884
+ 0
9885
+ ], s);
9886
+ V.singularValueDecompose2dScale(c, Z), o.lineWidth *= Math.max(Z[0], Z[1]) / u, o.stroke(this.#_(g, t, a));
9887
+ } else o.lineWidth /= u, o.stroke(g);
9888
+ }
9994
9889
  o.restore();
9995
9890
  } else (d === h.FILL || d === h.FILL_STROKE) && (o.fillText(t, n, r), this.dependencyTracker?.recordCharacterBBox(e, o, c, u, n, r, () => o.measureText(t))), (d === h.STROKE || d === h.FILL_STROKE) && (this.dependencyTracker && this.dependencyTracker?.recordCharacterBBox(e, o, c, u, n, r, () => o.measureText(t)).recordDependencies(e, Et.stroke), o.strokeText(t, n, r));
9996
9891
  f && ((this.pendingTextPaths ||= []).push({
@@ -10050,8 +9945,8 @@ var In = [
10050
9945
  n.x += i * _ * d, o.restore(), this.compose(), this.#g(a);
10051
9946
  return;
10052
9947
  }
10053
- let E = 0, D;
10054
- for (D = 0; D < f; ++D) {
9948
+ let E = 0, D = 0;
9949
+ for (; D < f; ++D) {
10055
9950
  let n = t[D];
10056
9951
  if (typeof n == "number") {
10057
9952
  E += m * n * i / 1e3;
@@ -10265,11 +10160,8 @@ var In = [
10265
10160
  if (!this.contentVisible) return;
10266
10161
  this.groupLevel--;
10267
10162
  let n = this.ctx, r = this.groupStack.pop(), i = this.#l.pop();
10268
- if (i && (this.#e = i.savedKnockoutLevel), r === null) {
10269
- this.restore(e);
10270
- return;
10271
- }
10272
- if (t.isGray && this.#v(n), this.ctx = r, this.ctx.imageSmoothingEnabled = !1, this.dependencyTracker?.popBaseTransform(), t.smask) this.tempSMask = this.smaskStack.pop(), this.restore(e), this.dependencyTracker && (this.ctx.restore(), this.inSMaskMode && this.ctx.setTransform(this.suspendedCtx.getTransform())), this.#y(i);
10163
+ if (i && (this.#e = i.savedKnockoutLevel), r === null) this.restore(e);
10164
+ else if (t.isGray && this.#v(n), this.ctx = r, this.ctx.imageSmoothingEnabled = !1, this.dependencyTracker?.popBaseTransform(), t.smask) this.tempSMask = this.smaskStack.pop(), this.restore(e), this.dependencyTracker && (this.ctx.restore(), this.inSMaskMode && this.ctx.setTransform(this.suspendedCtx.getTransform())), this.#y(i);
10273
10165
  else {
10274
10166
  this.ctx.restore();
10275
10167
  let t = W(this.ctx);
@@ -10282,24 +10174,25 @@ var In = [
10282
10174
  n.canvas.height
10283
10175
  ], t, o);
10284
10176
  let s = this.#l.at(-1);
10285
- if (this.#e > 0) if (i.hasInnerBackdrop) {
10286
- let { width: e, height: a } = n.canvas, o = this.canvasFactory.create(e, a), s = o.context;
10287
- s.drawImage(r.canvas, i.offsetX, i.offsetY, e, a, 0, 0, e, a), s.globalCompositeOperation = "source-over", s.drawImage(n.canvas, 0, 0);
10288
- let c = this.#f(n.canvas);
10289
- s.globalCompositeOperation = "destination-in", s.drawImage(c.canvas, 0, 0);
10290
- let l = this.ctx.globalCompositeOperation, u = this.ctx.globalAlpha, d = this.ctx.filter;
10291
- this.ctx.save(), this.ctx.setTransform(...t), this.ctx.globalAlpha = 1, B.isCanvasFilterSupported && (this.ctx.filter = "none"), this.ctx.globalCompositeOperation = "destination-out", this.ctx.drawImage(c.canvas, 0, 0), this.ctx.globalCompositeOperation = l, this.ctx.globalAlpha = u, B.isCanvasFilterSupported && (this.ctx.filter = d ?? "none"), this.ctx.drawImage(o.canvas, 0, 0), this.ctx.restore(), this.canvasFactory.destroy(c), this.canvasFactory.destroy(o);
10177
+ if (this.#e > 0) {
10178
+ if (i.hasInnerBackdrop) {
10179
+ let { width: e, height: a } = n.canvas, o = this.canvasFactory.create(e, a), s = o.context;
10180
+ s.drawImage(r.canvas, i.offsetX, i.offsetY, e, a, 0, 0, e, a), s.globalCompositeOperation = "source-over", s.drawImage(n.canvas, 0, 0);
10181
+ let c = this.#f(n.canvas);
10182
+ s.globalCompositeOperation = "destination-in", s.drawImage(c.canvas, 0, 0);
10183
+ let l = this.ctx.globalCompositeOperation, u = this.ctx.globalAlpha, d = this.ctx.filter;
10184
+ this.ctx.save(), this.ctx.setTransform(...t), this.ctx.globalAlpha = 1, B.isCanvasFilterSupported && (this.ctx.filter = "none"), this.ctx.globalCompositeOperation = "destination-out", this.ctx.drawImage(c.canvas, 0, 0), this.ctx.globalCompositeOperation = l, this.ctx.globalAlpha = u, B.isCanvasFilterSupported && (this.ctx.filter = d ?? "none"), this.ctx.drawImage(o.canvas, 0, 0), this.ctx.restore(), this.canvasFactory.destroy(c), this.canvasFactory.destroy(o);
10185
+ } else {
10186
+ let e = s?.backdropCtx ?? null;
10187
+ this.#m(this.ctx, n.canvas, {
10188
+ backdropCanvas: e?.canvas ?? null,
10189
+ destTransform: t,
10190
+ backdropOffset: e ? [s.offsetX + i.offsetX, s.offsetY + i.offsetY] : [0, 0],
10191
+ sourceAlpha: this.ctx.globalAlpha,
10192
+ sourceFilter: this.ctx.filter
10193
+ });
10194
+ }
10292
10195
  } else {
10293
- let e = s?.backdropCtx ?? null;
10294
- this.#m(this.ctx, n.canvas, {
10295
- backdropCanvas: e?.canvas ?? null,
10296
- destTransform: t,
10297
- backdropOffset: e ? [s.offsetX + i.offsetX, s.offsetY + i.offsetY] : [0, 0],
10298
- sourceAlpha: this.ctx.globalAlpha,
10299
- sourceFilter: this.ctx.filter
10300
- });
10301
- }
10302
- else {
10303
10196
  if (i.replaceBackdrop) {
10304
10197
  let e = new Path2D();
10305
10198
  e.rect(0, 0, n.canvas.width, n.canvas.height), this.ctx.clip(e), this.ctx.globalCompositeOperation = "copy";
@@ -10396,11 +10289,7 @@ var In = [
10396
10289
  paintImageXObject(e, t) {
10397
10290
  if (!this.contentVisible) return;
10398
10291
  let n = this.getObject(e, t);
10399
- if (!n) {
10400
- D("Dependent image isn't ready yet");
10401
- return;
10402
- }
10403
- this.paintInlineImageXObject(e, n);
10292
+ n ? this.paintInlineImageXObject(e, n) : D("Dependent image isn't ready yet");
10404
10293
  }
10405
10294
  paintImageXObjectRepeat(e, t, n, r, i) {
10406
10295
  if (!this.contentVisible) return;
@@ -10509,12 +10398,13 @@ var In = [
10509
10398
  let { lineWidth: e } = this.current, { a: t, b: n, c: r, d: i } = this.ctx.getTransform(), a, o;
10510
10399
  if (n === 0 && r === 0) {
10511
10400
  let n = Math.abs(t), r = Math.abs(i);
10512
- if (n === r) if (e === 0) a = o = 1 / n;
10513
- else {
10514
- let t = n * e;
10515
- a = o = t < 1 ? 1 / t : 1;
10516
- }
10517
- else if (e === 0) a = 1 / n, o = 1 / r;
10401
+ if (n === r) {
10402
+ if (e === 0) a = o = 1 / n;
10403
+ else {
10404
+ let t = n * e;
10405
+ a = o = t < 1 ? 1 / t : 1;
10406
+ }
10407
+ } else if (e === 0) a = 1 / n, o = 1 / r;
10518
10408
  else {
10519
10409
  let t = n * e, i = r * e;
10520
10410
  a = t < 1 ? 1 / t : 1, o = i < 1 ? 1 / i : 1;
@@ -10662,9 +10552,7 @@ function Wn(e) {
10662
10552
  let [, e, r, i] = n;
10663
10553
  if (e = parseInt(e, 10), e in t) {
10664
10554
  if (e === 0) break;
10665
- continue;
10666
- }
10667
- t[e] = [r, i];
10555
+ } else t[e] = [r, i];
10668
10556
  }
10669
10557
  let a = [];
10670
10558
  for (let e = 0; e < t.length && e in t; ++e) {
@@ -10845,9 +10733,7 @@ var ar = class extends Vn {
10845
10733
  case "progressiveRead":
10846
10734
  this.#e(e.begin, e.chunk);
10847
10735
  break;
10848
- case "progressiveDone":
10849
- this._fullReader?.progressiveDone(), this._progressiveDone = !0;
10850
- break;
10736
+ case "progressiveDone": this._fullReader?.progressiveDone(), this._progressiveDone = !0;
10851
10737
  }
10852
10738
  });
10853
10739
  }
@@ -11229,7 +11115,7 @@ var yr = class {
11229
11115
  if (this.#n) return this.#r;
11230
11116
  if (!this.#r) return !1;
11231
11117
  let { print: e, view: t } = this.usage;
11232
- return this.#e ? t?.viewState !== "OFF" : this.#t ? e?.printState !== "OFF" : !0;
11118
+ return this.#e ? t?.viewState !== "OFF" : !this.#t || e?.printState !== "OFF";
11233
11119
  }
11234
11120
  _setVisible(e, t, n = !1) {
11235
11121
  e !== xr && O("Internal method `_setVisible` called."), this.#n = n, this.#r = t;
@@ -11297,19 +11183,22 @@ var yr = class {
11297
11183
  if (this.#t.get(t).visible) return !0;
11298
11184
  }
11299
11185
  return !1;
11300
- } else if (e.policy === "AllOn") {
11186
+ }
11187
+ if (e.policy === "AllOn") {
11301
11188
  for (let t of e.ids) {
11302
11189
  if (!this.#t.has(t)) return D(`Optional content group not found: ${t}`), !0;
11303
11190
  if (!this.#t.get(t).visible) return !1;
11304
11191
  }
11305
11192
  return !0;
11306
- } else if (e.policy === "AnyOff") {
11193
+ }
11194
+ if (e.policy === "AnyOff") {
11307
11195
  for (let t of e.ids) {
11308
11196
  if (!this.#t.has(t)) return D(`Optional content group not found: ${t}`), !0;
11309
11197
  if (!this.#t.get(t).visible) return !0;
11310
11198
  }
11311
11199
  return !1;
11312
- } else if (e.policy === "AllOff") {
11200
+ }
11201
+ if (e.policy === "AllOff") {
11313
11202
  for (let t of e.ids) {
11314
11203
  if (!this.#t.has(t)) return D(`Optional content group not found: ${t}`), !0;
11315
11204
  if (this.#t.get(t).visible) return !1;
@@ -11322,12 +11211,11 @@ var yr = class {
11322
11211
  }
11323
11212
  setVisibility(e, t = !0, n = !0) {
11324
11213
  let r = this.#t.get(e);
11325
- if (!r) {
11326
- D(`Optional content group not found: ${e}`);
11327
- return;
11214
+ if (!r) D(`Optional content group not found: ${e}`);
11215
+ else {
11216
+ if (n && t && r.rbGroups.length) for (let t of r.rbGroups) for (let n of t) n !== e && this.#t.get(n)?._setVisible(xr, !1, !0);
11217
+ r._setVisible(xr, !!t, !0), this.#e = null;
11328
11218
  }
11329
- if (n && t && r.rbGroups.length) for (let t of r.rbGroups) for (let n of t) n !== e && this.#t.get(n)?._setVisible(xr, !1, !0);
11330
- r._setVisible(xr, !!t, !0), this.#e = null;
11331
11219
  }
11332
11220
  setOCGState({ state: e, preserveRB: t }) {
11333
11221
  let n;
@@ -11347,9 +11235,7 @@ var yr = class {
11347
11235
  case "OFF":
11348
11236
  this.setVisibility(r, !1, t);
11349
11237
  break;
11350
- case "Toggle":
11351
- this.setVisibility(r, !e.visible, t);
11352
- break;
11238
+ case "Toggle": this.setVisibility(r, !e.visible, t);
11353
11239
  }
11354
11240
  }
11355
11241
  this.#e = null;
@@ -11602,17 +11488,13 @@ var yr = class {
11602
11488
  }
11603
11489
  static get fontFamilyMap() {
11604
11490
  let { isWindows: e, isFirefox: t } = B.platform;
11605
- return P(this, "fontFamilyMap", new Map([["sans-serif", `${e && t ? "Calibri, " : ""}sans-serif`], ["monospace", `${e && t ? "Lucida Console, " : ""}monospace`]]));
11491
+ return P(this, "fontFamilyMap", /* @__PURE__ */ new Map([["sans-serif", `${e && t ? "Calibri, " : ""}sans-serif`], ["monospace", `${e && t ? "Lucida Console, " : ""}monospace`]]));
11606
11492
  }
11607
11493
  render() {
11608
11494
  this.#i && this.#t.append(this.#i.render());
11609
11495
  let t = () => {
11610
11496
  this.#l.read().then(({ value: e, done: n }) => {
11611
- if (n) {
11612
- this.#e.resolve();
11613
- return;
11614
- }
11615
- this.#a ??= e.lang, Object.assign(this.#p, e.styles), this.#w(e.items), t();
11497
+ n ? this.#e.resolve() : (this.#a ??= e.lang, Object.assign(this.#p, e.styles), this.#w(e.items), t());
11616
11498
  }, this.#e.reject);
11617
11499
  };
11618
11500
  return this.#l = this.#h.getReader(), e.#C.add(this), t(), this.#e.promise;
@@ -11653,9 +11535,7 @@ var yr = class {
11653
11535
  let t = this.#t;
11654
11536
  this.#t = document.createElement("span"), this.#t.classList.add("markedContent"), e.id && this.#t.setAttribute("id", e.id), e.tag === "Artifact" && (this.#t.ariaHidden = !0), t.append(this.#t);
11655
11537
  } else e.type === "endMarkedContent" && (this.#t = this.#t.parentNode);
11656
- continue;
11657
- }
11658
- r.push(e.str), this.#T(e);
11538
+ } else r.push(e.str), this.#T(e);
11659
11539
  }
11660
11540
  }
11661
11541
  #T(t) {
@@ -11719,7 +11599,7 @@ var yr = class {
11719
11599
  }
11720
11600
  static #O(e, t, n) {
11721
11601
  let r = this.#x.get(e);
11722
- t === r.size && n === r.family || (e.font = `${t}px ${n}`, r.size = t, r.family = n);
11602
+ (t !== r.size || n !== r.family) && (e.font = `${t}px ${n}`, r.size = t, r.family = n);
11723
11603
  }
11724
11604
  static #k() {
11725
11605
  if (this.#S !== null) return;
@@ -11800,24 +11680,26 @@ function Mr(e = {}) {
11800
11680
  if (d.destroyed) throw Error("Worker was destroyed");
11801
11681
  re.evaluatorOptions.hasGPU = e;
11802
11682
  let r = d.messageHandler.sendWithPromise("GetDocRequest", re, a ? [a.buffer] : null), c;
11803
- if (!a) if (l) c = new ar({
11804
- pdfDataRangeTransport: l,
11805
- disableRange: k,
11806
- disableStream: A
11807
- });
11808
- else if (i) c = new (vr(i))({
11809
- url: i,
11810
- httpHeaders: o,
11811
- withCredentials: s,
11812
- rangeChunkSize: u,
11813
- disableRange: k,
11814
- disableStream: A
11815
- });
11816
- else throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");
11683
+ if (!a) {
11684
+ if (l) c = new ar({
11685
+ pdfDataRangeTransport: l,
11686
+ disableRange: k,
11687
+ disableStream: A
11688
+ });
11689
+ else if (i) c = new (vr(i))({
11690
+ url: i,
11691
+ httpHeaders: o,
11692
+ withCredentials: s,
11693
+ rangeChunkSize: u,
11694
+ disableRange: k,
11695
+ disableStream: A
11696
+ });
11697
+ else throw Error("getDocument - expected either `data`, `range`, or `url` parameter.");
11698
+ }
11817
11699
  return r.then((e) => {
11818
11700
  if (d.destroyed) throw Error("Worker was destroyed");
11819
- let r = new qt(n, e, d.port);
11820
- if (t._transport = new Rr(r, t, c, B, ne, ee), t.destroyed) throw Error("Loading aborted");
11701
+ let r = new qt(n, e, d.port), i = new Rr(r, t, c, B, ne, ee);
11702
+ if (t._transport = i, t.destroyed) throw Error("Loading aborted");
11821
11703
  r.send("Ready", null);
11822
11704
  });
11823
11705
  }).catch(t._capability.reject).finally(t._setupCapability.resolve), t;
@@ -12111,15 +11993,14 @@ var Nr = class e {
12111
11993
  (b.renderTasks ||= /* @__PURE__ */ new Set()).add(O);
12112
11994
  let k = O.task;
12113
11995
  return Promise.all([b.displayReadyCapability.promise, s]).then(([e, t]) => {
12114
- if (this.destroyed) {
12115
- T();
12116
- return;
11996
+ if (this.destroyed) T();
11997
+ else {
11998
+ if (this._stats?.time("Rendering"), !(t.renderingIntent & v)) throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");
11999
+ O.initializeGraphics({
12000
+ transparency: e,
12001
+ optionalContentConfig: t
12002
+ }), O.operatorListChanged();
12117
12003
  }
12118
- if (this._stats?.time("Rendering"), !(t.renderingIntent & v)) throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");
12119
- O.initializeGraphics({
12120
- transparency: e,
12121
- optionalContentConfig: t
12122
- }), O.operatorListChanged();
12123
12004
  }).catch(T), k;
12124
12005
  }
12125
12006
  getOperatorList({ intent: e = "display", annotationMode: t = l.ENABLE, printAnnotationStorage: n = null, isEditing: r = !1 } = {}) {
@@ -12202,11 +12083,7 @@ var Nr = class e {
12202
12083
  s.streamReader = o;
12203
12084
  let c = () => {
12204
12085
  o.read().then(({ value: e, done: t }) => {
12205
- if (t) {
12206
- s.streamReader = null;
12207
- return;
12208
- }
12209
- this._transport.destroyed || (this._renderPageChunk(e, s), c());
12086
+ t ? s.streamReader = null : this._transport.destroyed || (this._renderPageChunk(e, s), c());
12210
12087
  }, (e) => {
12211
12088
  if (s.streamReader = null, !this._transport.destroyed) {
12212
12089
  if (s.operatorList) {
@@ -12304,24 +12181,17 @@ var Nr = class e {
12304
12181
  n.addEventListener("error", () => {
12305
12182
  this.#r || i();
12306
12183
  }, { signal: a.signal }), r.on("test", (e) => {
12307
- if (a.abort(), this.destroyed || !e) {
12308
- i();
12309
- return;
12310
- }
12311
- this.#t = r, this.#n = n, this.#r = n, this.#s();
12184
+ a.abort(), this.destroyed || !e ? i() : (this.#t = r, this.#n = n, this.#r = n, this.#s());
12312
12185
  }), r.on("ready", (e) => {
12313
- if (a.abort(), this.destroyed) {
12314
- i();
12315
- return;
12316
- }
12317
- try {
12186
+ if (a.abort(), this.destroyed) i();
12187
+ else try {
12318
12188
  o();
12319
12189
  } catch {
12320
12190
  this.#u();
12321
12191
  }
12322
12192
  });
12323
12193
  let o = () => {
12324
- let e = new Uint8Array();
12194
+ let e = /* @__PURE__ */ new Uint8Array();
12325
12195
  r.send("test", e, [e.buffer]);
12326
12196
  };
12327
12197
  o();
@@ -12461,11 +12331,7 @@ var Nr = class e {
12461
12331
  e.on("GetReader", (e, t) => {
12462
12332
  k(this.#n, "GetReader - no `BasePDFStream` instance available."), this.#e = this.#n.getFullReader(), this.#e.onProgress = (e) => this.#c(e), t.onPull = () => {
12463
12333
  this.#e.read().then(function({ value: e, done: n }) {
12464
- if (n) {
12465
- t.close();
12466
- return;
12467
- }
12468
- k(e instanceof ArrayBuffer, "GetReader - expected an ArrayBuffer."), t.enqueue(new Uint8Array(e), 1, [e]);
12334
+ n ? t.close() : (k(e instanceof ArrayBuffer, "GetReader - expected an ArrayBuffer."), t.enqueue(new Uint8Array(e), 1, [e]));
12469
12335
  }).catch((e) => {
12470
12336
  t.error(e);
12471
12337
  });
@@ -12485,17 +12351,9 @@ var Nr = class e {
12485
12351
  }), e.on("GetRangeReader", (e, t) => {
12486
12352
  k(this.#n, "GetRangeReader - no `BasePDFStream` instance available.");
12487
12353
  let n = this.#n.getRangeReader(e.begin, e.end);
12488
- if (!n) {
12489
- t.close();
12490
- return;
12491
- }
12492
- t.onPull = () => {
12354
+ n ? (t.onPull = () => {
12493
12355
  n.read().then(function({ value: e, done: n }) {
12494
- if (n) {
12495
- t.close();
12496
- return;
12497
- }
12498
- k(e instanceof ArrayBuffer, "GetRangeReader - expected an ArrayBuffer."), t.enqueue(new Uint8Array(e), 1, [e]);
12356
+ n ? t.close() : (k(e instanceof ArrayBuffer, "GetRangeReader - expected an ArrayBuffer."), t.enqueue(new Uint8Array(e), 1, [e]));
12499
12357
  }).catch((e) => {
12500
12358
  t.error(e);
12501
12359
  });
@@ -12503,7 +12361,7 @@ var Nr = class e {
12503
12361
  n.cancel(e), t.ready.catch((e) => {
12504
12362
  if (!this.destroyed) throw e;
12505
12363
  });
12506
- };
12364
+ }) : t.close();
12507
12365
  }), e.on("GetDoc", ({ pdfInfo: e }) => {
12508
12366
  this.pagesMapper.pagesNumber = e.numPages, this._numPages = e.numPages, this._htmlForXfa = e.htmlForXfa, delete e.htmlForXfa, t._capability.resolve(new Fr(e, this));
12509
12367
  }), e.on("DocException", (e) => {
@@ -12567,11 +12425,8 @@ var Nr = class e {
12567
12425
  if (this.destroyed) return;
12568
12426
  let i = this.#r.get(t);
12569
12427
  if (!i.objs.has(e)) {
12570
- if (i._intentStates.size === 0) {
12571
- r?.bitmap?.close();
12572
- return;
12573
- }
12574
- switch (n) {
12428
+ if (i._intentStates.size === 0) r?.bitmap?.close();
12429
+ else switch (n) {
12575
12430
  case "Image":
12576
12431
  case "Pattern":
12577
12432
  i.objs.resolve(e, r);
@@ -12813,14 +12668,10 @@ var Nr = class e {
12813
12668
  this.running = !1, this.cancelled = !0, this.gfx?.endDrawing(), this.#e &&= (window.cancelAnimationFrame(this.#e), null), e.#t.delete(this._canvas), t ||= new xe(`Rendering cancelled, page ${this._pageIndex + 1}`, n), this.callback(t), this.task.onError?.(t);
12814
12669
  }
12815
12670
  operatorListChanged() {
12816
- if (!this.graphicsReady) {
12817
- this.graphicsReadyCallback ||= this._continueBound;
12818
- return;
12819
- }
12820
- this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length), this.stepper?.updateOperatorList(this.operatorList), !this.running && this._continue();
12671
+ this.graphicsReady ? (this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length), this.stepper?.updateOperatorList(this.operatorList), this.running || this._continue()) : this.graphicsReadyCallback ||= this._continueBound;
12821
12672
  }
12822
12673
  _continue() {
12823
- this.running = !0, !this.cancelled && (this.task.onContinue ? this.task.onContinue(this._scheduleNextBound) : this._scheduleNext());
12674
+ this.running = !0, this.cancelled || (this.task.onContinue ? this.task.onContinue(this._scheduleNextBound) : this._scheduleNext());
12824
12675
  }
12825
12676
  _scheduleNext() {
12826
12677
  this._useRequestAnimationFrame ? this.#e = window.requestAnimationFrame(() => {
@@ -12902,36 +12753,16 @@ var Ur = class e {
12902
12753
  t && this.#f(t, e);
12903
12754
  }
12904
12755
  _moveToNext(e) {
12905
- if (!this.#g) {
12906
- this.#m(e);
12907
- return;
12908
- }
12909
- if (e.target === this.#e) {
12910
- this.#r.firstElementChild?.focus();
12911
- return;
12912
- }
12913
- e.target.nextSibling?.focus();
12756
+ this.#g ? e.target === this.#e ? this.#r.firstElementChild?.focus() : e.target.nextSibling?.focus() : this.#m(e);
12914
12757
  }
12915
12758
  _moveToPrevious(e) {
12916
- if (e.target === this.#r?.firstElementChild || e.target === this.#e) {
12917
- this.#g && this._hideDropdownFromKeyboard();
12918
- return;
12919
- }
12920
- this.#g || this.#m(e), e.target.previousSibling?.focus();
12759
+ e.target === this.#r?.firstElementChild || e.target === this.#e ? this.#g && this._hideDropdownFromKeyboard() : (this.#g || this.#m(e), e.target.previousSibling?.focus());
12921
12760
  }
12922
12761
  _moveToBeginning(e) {
12923
- if (!this.#g) {
12924
- this.#m(e);
12925
- return;
12926
- }
12927
- this.#r.firstElementChild?.focus();
12762
+ this.#g ? this.#r.firstElementChild?.focus() : this.#m(e);
12928
12763
  }
12929
12764
  _moveToEnd(e) {
12930
- if (!this.#g) {
12931
- this.#m(e);
12932
- return;
12933
- }
12934
- this.#r.lastElementChild?.focus();
12765
+ this.#g ? this.#r.lastElementChild?.focus() : this.#m(e);
12935
12766
  }
12936
12767
  #p(t) {
12937
12768
  e._keyboardManager.exec(this, t);
@@ -12958,16 +12789,10 @@ var Ur = class e {
12958
12789
  return this.#r && !this.#r.classList.contains("hidden");
12959
12790
  }
12960
12791
  _hideDropdownFromKeyboard() {
12961
- if (!this.#a) {
12962
- if (!this.#g) {
12963
- this.#o?.unselect();
12964
- return;
12965
- }
12966
- this.hideDropdown(), this.#e.focus({
12967
- preventScroll: !0,
12968
- focusVisible: this.#i
12969
- });
12970
- }
12792
+ this.#a || (this.#g ? (this.hideDropdown(), this.#e.focus({
12793
+ preventScroll: !0,
12794
+ focusVisible: this.#i
12795
+ })) : this.#o?.unselect());
12971
12796
  }
12972
12797
  updateColor(e) {
12973
12798
  if (this.#t && (this.#t.style.backgroundColor = e), !this.#r) return;
@@ -13010,10 +12835,12 @@ var Ur = class e {
13010
12835
  }, { signal: this.#r._signal }), c;
13011
12836
  }
13012
12837
  update(e) {
13013
- if (this.#e) if (this.#t) {
13014
- let t = V.hexNums[Math.round(this.#n.opacity * 255)];
13015
- this.#e.value = e + t;
13016
- } else this.#e.value = e;
12838
+ if (this.#e) {
12839
+ if (this.#t) {
12840
+ let t = V.hexNums[Math.round(this.#n.opacity * 255)];
12841
+ this.#e.value = e + t;
12842
+ } else this.#e.value = e;
12843
+ }
13017
12844
  }
13018
12845
  updateOpacity(e) {
13019
12846
  if (!this.#e || !this.#t) return;
@@ -13238,7 +13065,7 @@ var qr = class {
13238
13065
  }
13239
13066
  _createContainer(e) {
13240
13067
  let { data: t, parent: { page: n, viewport: r } } = this, i = document.createElement("section");
13241
- i.setAttribute("data-annotation-id", t.id), !(this instanceof ri) && !(this instanceof ti) && !(this instanceof Ei) && (i.tabIndex = 0);
13068
+ i.setAttribute("data-annotation-id", t.id), this instanceof ri || this instanceof ti || this instanceof Ei || (i.tabIndex = 0);
13242
13069
  let { style: a } = i;
13243
13070
  if (a.zIndex = this.parent.zIndex, this.parent.zIndex += 2, t.alternativeText && (i.title = t.alternativeText), t.noRotate && i.classList.add("norotate"), !t.rect || this instanceof ui) {
13244
13071
  let { rotation: e } = t;
@@ -13261,10 +13088,7 @@ var qr = class {
13261
13088
  case v.INSET:
13262
13089
  D("Unimplemented border style: inset");
13263
13090
  break;
13264
- case v.UNDERLINE:
13265
- a.borderBottomStyle = "solid";
13266
- break;
13267
- default: break;
13091
+ case v.UNDERLINE: a.borderBottomStyle = "solid";
13268
13092
  }
13269
13093
  let r = t.borderColor || null;
13270
13094
  r ? (this.#t = !0, a.borderColor = V.makeHexColor(...r)) : a.borderWidth = 0;
@@ -13426,11 +13250,7 @@ var qr = class {
13426
13250
  for (let { page: e, id: i, exportValues: a } of r) {
13427
13251
  if (e === -1 || i === t) continue;
13428
13252
  let r = typeof a == "string" ? a : null, o = document.querySelector(`[data-element-id="${i}"]`);
13429
- if (o && !Zr.has(o)) {
13430
- D(`_getElementsByName - element not allowed: ${i}`);
13431
- continue;
13432
- }
13433
- n.push({
13253
+ o && !Zr.has(o) ? D(`_getElementsByName - element not allowed: ${i}`) : n.push({
13434
13254
  id: i,
13435
13255
  exportValue: r,
13436
13256
  domElement: o
@@ -13475,7 +13295,7 @@ var qr = class {
13475
13295
  });
13476
13296
  }
13477
13297
  updateOC(e) {
13478
- !this.data.oc || !e || (e.isVisible(this.data.oc) ? this.show() : this.hide());
13298
+ this.data.oc && e && (e.isVisible(this.data.oc) ? this.show() : this.hide());
13479
13299
  }
13480
13300
  get width() {
13481
13301
  return this.data.rect[2] - this.data.rect[0];
@@ -13555,7 +13375,7 @@ var qr = class {
13555
13375
  }
13556
13376
  _bindJSAction(e, t) {
13557
13377
  e.href = this.linkService.getAnchorUrl("");
13558
- let n = new Map([
13378
+ let n = /* @__PURE__ */ new Map([
13559
13379
  ["Action", "onclick"],
13560
13380
  ["Mouse Up", "onmouseup"],
13561
13381
  ["Mouse Down", "onmousedown"]
@@ -13574,11 +13394,7 @@ var qr = class {
13574
13394
  }
13575
13395
  _bindResetFormAction(e, t) {
13576
13396
  let n = e.onclick;
13577
- if (n || (e.href = this.linkService.getAnchorUrl("")), this.#e(), !this._fieldObjects) {
13578
- D("_bindResetFormAction - \"resetForm\" action not supported, ensure that the `fieldObjects` parameter is provided."), n || (e.onclick = () => !1);
13579
- return;
13580
- }
13581
- e.onclick = () => {
13397
+ n || (e.href = this.linkService.getAnchorUrl("")), this.#e(), this._fieldObjects ? e.onclick = () => {
13582
13398
  n?.();
13583
13399
  let { fields: e, refs: r, include: i } = t, a = [];
13584
13400
  if (e.length !== 0 || r.length !== 0) {
@@ -13613,13 +13429,7 @@ var qr = class {
13613
13429
  default: continue;
13614
13430
  }
13615
13431
  let n = document.querySelector(`[data-element-id="${t}"]`);
13616
- if (n) {
13617
- if (!Zr.has(n)) {
13618
- D(`_bindResetFormAction - element not allowed: ${t}`);
13619
- continue;
13620
- }
13621
- n.dispatchEvent(new Event("resetform"));
13622
- }
13432
+ n && (Zr.has(n) ? n.dispatchEvent(new Event("resetform")) : D(`_bindResetFormAction - element not allowed: ${t}`));
13623
13433
  }
13624
13434
  return this.enableScripting && this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
13625
13435
  source: this,
@@ -13629,7 +13439,7 @@ var qr = class {
13629
13439
  name: "ResetForm"
13630
13440
  }
13631
13441
  }), !1;
13632
- };
13442
+ } : (D("_bindResetFormAction - \"resetForm\" action not supported, ensure that the `fieldObjects` parameter is provided."), n || (e.onclick = () => !1));
13633
13443
  }
13634
13444
  }, ni = class extends Q {
13635
13445
  constructor(e) {
@@ -13741,15 +13551,16 @@ var qr = class {
13741
13551
  let { target: t } = e;
13742
13552
  if (d && (t.type = l, u && (t.step = u)), s.userValue) {
13743
13553
  let e = s.userValue;
13744
- if (d) if (l === "time") {
13745
- let n = new Date(e);
13746
- t.value = [
13747
- n.getHours(),
13748
- n.getMinutes(),
13749
- n.getSeconds()
13750
- ].map((e) => e.toString().padStart(2, "0")).join(":");
13751
- } else t.value = new Date(e - Qr).toISOString().split(l === "date" ? "T" : ".", 1)[0];
13752
- else t.value = e;
13554
+ if (d) {
13555
+ if (l === "time") {
13556
+ let n = new Date(e);
13557
+ t.value = [
13558
+ n.getHours(),
13559
+ n.getMinutes(),
13560
+ n.getSeconds()
13561
+ ].map((e) => e.toString().padStart(2, "0")).join(":");
13562
+ } else t.value = new Date(e - Qr).toISOString().split(l === "date" ? "T" : ".", 1)[0];
13563
+ } else t.value = e;
13753
13564
  }
13754
13565
  s.lastCommittedValue = t.value, s.commitKey = 1, this.data.actions?.Focus || (s.focused = !0);
13755
13566
  }), n.addEventListener("updatefromsandbox", (n) => {
@@ -13847,9 +13658,7 @@ var qr = class {
13847
13658
  case "deleteContentBackward":
13848
13659
  a === o && --c;
13849
13660
  break;
13850
- case "deleteContentForward":
13851
- a === o && (l += 1);
13852
- break;
13661
+ case "deleteContentForward": a === o && (l += 1);
13853
13662
  }
13854
13663
  e.preventDefault(), this.linkService.eventBus?.dispatch("dispatcheventinsandbox", {
13855
13664
  source: this,
@@ -14327,18 +14136,10 @@ var qr = class {
14327
14136
  e.altKey || e.shiftKey || e.ctrlKey || e.metaKey || (e.key === "Enter" || e.key === "Escape" && this.#f) && this.#I();
14328
14137
  }
14329
14138
  updateEdited({ rect: e, popup: t, deleted: n }) {
14330
- if (this.#e) {
14331
- n ? (this.remove(), this.#T = null) : t && (t.deleted ? this.remove() : (this.#k(), this.#T = t.text)), e && (this.#_ = null, this.#D(), this.#O());
14332
- return;
14333
- }
14334
- if (n || t?.deleted) {
14335
- this.remove();
14336
- return;
14337
- }
14338
- this.#E(), this.#S ||= {
14139
+ this.#e ? (n ? (this.remove(), this.#T = null) : t && (t.deleted ? this.remove() : (this.#k(), this.#T = t.text)), e && (this.#_ = null, this.#D(), this.#O())) : n || t?.deleted ? this.remove() : (this.#E(), this.#S ||= {
14339
14140
  contentsObj: this.#s,
14340
14141
  richText: this.#b
14341
- }, e && (this.#h = null), t && t.text && (this.#b = this.#N(t.text), this.#c = ke.toDateObject(t.date), this.#s = null), this.#p?.remove(), this.#p = null;
14142
+ }, e && (this.#h = null), t && t.text && (this.#b = this.#N(t.text), this.#c = ke.toDateObject(t.date), this.#s = null), this.#p?.remove(), this.#p = null);
14342
14143
  }
14343
14144
  resetEdited() {
14344
14145
  this.#S && ({contentsObj: this.#s, richText: this.#b} = this.#S, this.#S = null, this.#p?.remove(), this.#p = null, this.#h = null);
@@ -14364,17 +14165,13 @@ var qr = class {
14364
14165
  d.left = `${this.#h[0]}%`, d.top = `${this.#h[1]}%`;
14365
14166
  }
14366
14167
  #I() {
14367
- if (this.#e) {
14368
- this.#e.toggleCommentPopup(this, !1);
14369
- return;
14370
- }
14371
- this.#f = !this.#f, this.#f ? (this.#L(), this.#o.addEventListener("click", this.#i), this.#o.addEventListener("keydown", this.#t)) : (this.#R(), this.#o.removeEventListener("click", this.#i), this.#o.removeEventListener("keydown", this.#t));
14168
+ this.#e ? this.#e.toggleCommentPopup(this, !1) : (this.#f = !this.#f, this.#f ? (this.#L(), this.#o.addEventListener("click", this.#i), this.#o.addEventListener("keydown", this.#t)) : (this.#R(), this.#o.removeEventListener("click", this.#i), this.#o.removeEventListener("keydown", this.#t)));
14372
14169
  }
14373
14170
  #L() {
14374
14171
  this.#p || this.render(), this.isVisible ? this.#f && this.#o.classList.add("focused") : (this.#F(), this.#o.hidden = !1, this.#o.style.zIndex = parseInt(this.#o.style.zIndex, 10) + 1e3);
14375
14172
  }
14376
14173
  #R() {
14377
- this.#o.classList.remove("focused"), !(this.#f || !this.isVisible) && (this.#o.hidden = !0, this.#o.style.zIndex = parseInt(this.#o.style.zIndex, 10) - 1e3);
14174
+ this.#o.classList.remove("focused"), this.#f || !this.isVisible || (this.#o.hidden = !0, this.#o.style.zIndex = parseInt(this.#o.style.zIndex, 10) - 1e3);
14378
14175
  }
14379
14176
  forceHide() {
14380
14177
  this.#C = this.isVisible, this.#C && (this.#o.hidden = !0);
@@ -14383,7 +14180,7 @@ var qr = class {
14383
14180
  this.#e || (this.#E(), this.#C && (this.#p || this.#L(), this.#C = !1, this.#o.hidden = !1));
14384
14181
  }
14385
14182
  get isVisible() {
14386
- return this.#e ? !1 : this.#o.hidden === !1;
14183
+ return !this.#e && this.#o.hidden === !1;
14387
14184
  }
14388
14185
  }, fi = class extends Q {
14389
14186
  constructor(e) {
@@ -15009,9 +14806,7 @@ var qr = class {
15009
14806
  case p.FREETEXT_SIZE:
15010
14807
  e._defaultFontSize = n;
15011
14808
  break;
15012
- case p.FREETEXT_COLOR:
15013
- e._defaultColor = n;
15014
- break;
14809
+ case p.FREETEXT_COLOR: e._defaultColor = n;
15015
14810
  }
15016
14811
  }
15017
14812
  updateParams(e, t) {
@@ -15019,9 +14814,7 @@ var qr = class {
15019
14814
  case p.FREETEXT_SIZE:
15020
14815
  this.#i(t);
15021
14816
  break;
15022
- case p.FREETEXT_COLOR:
15023
- this.#a(t);
15024
- break;
14817
+ case p.FREETEXT_COLOR: this.#a(t);
15025
14818
  }
15026
14819
  }
15027
14820
  static get defaultPropertiesToUpdate() {
@@ -15102,7 +14895,7 @@ var qr = class {
15102
14895
  let t = [];
15103
14896
  this.editorDiv.normalize();
15104
14897
  let n = null;
15105
- for (let r of this.editorDiv.childNodes) n?.nodeType === Node.TEXT_NODE && r.nodeName === "BR" || (t.push(e.#c(r)), n = r);
14898
+ for (let r of this.editorDiv.childNodes) (n?.nodeType !== Node.TEXT_NODE || r.nodeName !== "BR") && (t.push(e.#c(r)), n = r);
15106
14899
  return t.join("\n");
15107
14900
  }
15108
14901
  #s() {
@@ -15120,11 +14913,7 @@ var qr = class {
15120
14913
  let e = this.#e, t = this.#e = this.#o().trimEnd();
15121
14914
  if (e === t) return;
15122
14915
  let n = (e) => {
15123
- if (this.#e = e, !e) {
15124
- this.remove();
15125
- return;
15126
- }
15127
- this.#l(), this._uiManager.rebuild(this), this.#s();
14916
+ this.#e = e, e ? (this.#l(), this._uiManager.rebuild(this), this.#s()) : this.remove();
15128
14917
  };
15129
14918
  this.addCommands({
15130
14919
  cmd: () => {
@@ -15187,9 +14976,7 @@ var qr = class {
15187
14976
  case 180:
15188
14977
  d = e - this.width + (i[0] - l) / s, f = t - (i[1] - u) / c, [a, o] = [-a, -o];
15189
14978
  break;
15190
- case 270:
15191
- d = e + (i[0] - l - this.height * c) / s, f = t + (i[1] - u - this.width * s) / c, [a, o] = [-o, a];
15192
- break;
14979
+ case 270: d = e + (i[0] - l - this.height * c) / s, f = t + (i[1] - u - this.width * s) / c, [a, o] = [-o, a];
15193
14980
  }
15194
14981
  this.setAt(d * n, f * r, a, o);
15195
14982
  } else this._moveAfterPaste(e, t);
@@ -15219,13 +15006,7 @@ var qr = class {
15219
15006
  let t = s.parentElement;
15220
15007
  if (u.push(s.nodeValue.slice(c).replaceAll(Oi, "")), t !== this.editorDiv) {
15221
15008
  let n = l;
15222
- for (let r of this.editorDiv.childNodes) {
15223
- if (r === t) {
15224
- n = u;
15225
- continue;
15226
- }
15227
- n.push(e.#c(r));
15228
- }
15009
+ for (let r of this.editorDiv.childNodes) r === t ? n = u : n.push(e.#c(r));
15229
15010
  }
15230
15011
  l.push(s.nodeValue.slice(0, c).replaceAll(Oi, ""));
15231
15012
  } else if (s === this.editorDiv) {
@@ -15374,7 +15155,7 @@ var qr = class {
15374
15155
  #n;
15375
15156
  #r;
15376
15157
  #i = [];
15377
- #a = new Float32Array(18);
15158
+ #a = /* @__PURE__ */ new Float32Array(18);
15378
15159
  #o;
15379
15160
  #s;
15380
15161
  #c;
@@ -15461,25 +15242,13 @@ var qr = class {
15461
15242
  for (let e = 0, t = s.length - 2; e < t; e += 2) s[e] = (this.#f[e] - r) / a, s[e + 1] = (this.#f[e + 1] - i) / o;
15462
15243
  if (s[s.length - 2] = (this.#o - r) / a, s[s.length - 1] = (this.#s - i) / o, isNaN(n[6]) && !this.isEmpty()) return this.#b(s);
15463
15244
  let c = new Float32Array(this.#i.length + 24 + this.#t.length), l = e.length;
15464
- for (let t = 0; t < l; t += 2) {
15465
- if (isNaN(e[t])) {
15466
- c[t] = c[t + 1] = NaN;
15467
- continue;
15468
- }
15469
- c[t] = e[t], c[t + 1] = e[t + 1];
15470
- }
15245
+ for (let t = 0; t < l; t += 2) isNaN(e[t]) ? c[t] = c[t + 1] = NaN : (c[t] = e[t], c[t + 1] = e[t + 1]);
15471
15246
  l = this.#S(c, l);
15472
- for (let e = t.length - 6; e >= 6; e -= 6) for (let n = 0; n < 6; n += 2) {
15473
- if (isNaN(t[e + n])) {
15474
- c[l] = c[l + 1] = NaN, l += 2;
15475
- continue;
15476
- }
15477
- c[l] = t[e + n], c[l + 1] = t[e + n + 1], l += 2;
15478
- }
15247
+ for (let e = t.length - 6; e >= 6; e -= 6) for (let n = 0; n < 6; n += 2) isNaN(t[e + n]) ? (c[l] = c[l + 1] = NaN, l += 2) : (c[l] = t[e + n], c[l + 1] = t[e + n + 1], l += 2);
15479
15248
  return this.#x(c, l), this.newFreeDrawOutline(c, s, this.#e, this.#u, this.#n, this.#r);
15480
15249
  }
15481
15250
  #b(e) {
15482
- let t = this.#a, [n, r, i, a] = this.#e, [o, s, c, l] = this.#g(), u = new Float32Array(36);
15251
+ let t = this.#a, [n, r, i, a] = this.#e, [o, s, c, l] = this.#g(), u = /* @__PURE__ */ new Float32Array(36);
15483
15252
  return u.set([
15484
15253
  NaN,
15485
15254
  NaN,
@@ -15561,7 +15330,7 @@ var qr = class {
15561
15330
  }
15562
15331
  }, ji = class extends $ {
15563
15332
  #e;
15564
- #t = new Float32Array(4);
15333
+ #t = /* @__PURE__ */ new Float32Array(4);
15565
15334
  #n;
15566
15335
  #r;
15567
15336
  #i;
@@ -15575,13 +15344,7 @@ var qr = class {
15575
15344
  }
15576
15345
  toSVGPath() {
15577
15346
  let e = [`M${this.#o[4]} ${this.#o[5]}`];
15578
- for (let t = 6, n = this.#o.length; t < n; t += 6) {
15579
- if (isNaN(this.#o[t])) {
15580
- e.push(`L${this.#o[t + 4]} ${this.#o[t + 5]}`);
15581
- continue;
15582
- }
15583
- e.push(`C${this.#o[t]} ${this.#o[t + 1]} ${this.#o[t + 2]} ${this.#o[t + 3]} ${this.#o[t + 4]} ${this.#o[t + 5]}`);
15584
- }
15347
+ for (let t = 6, n = this.#o.length; t < n; t += 6) isNaN(this.#o[t]) ? e.push(`L${this.#o[t + 4]} ${this.#o[t + 5]}`) : e.push(`C${this.#o[t]} ${this.#o[t + 1]} ${this.#o[t + 2]} ${this.#o[t + 3]} ${this.#o[t + 4]} ${this.#o[t + 5]}`);
15585
15348
  return e.push("Z"), e.join(" ");
15586
15349
  }
15587
15350
  serialize([e, t, n, r], i) {
@@ -15596,9 +15359,7 @@ var qr = class {
15596
15359
  case 180:
15597
15360
  s = $._rescale(this.#o, n, t, -a, o), c = $._rescale(this.#i, n, t, -a, o);
15598
15361
  break;
15599
- case 270:
15600
- s = $._rescaleAndSwap(this.#o, n, r, -a, -o), c = $._rescaleAndSwap(this.#i, n, r, -a, -o);
15601
- break;
15362
+ case 270: s = $._rescaleAndSwap(this.#o, n, r, -a, -o), c = $._rescaleAndSwap(this.#i, n, r, -a, -o);
15602
15363
  }
15603
15364
  return {
15604
15365
  outline: Array.from(s),
@@ -15611,7 +15372,7 @@ var qr = class {
15611
15372
  r,
15612
15373
  n,
15613
15374
  r
15614
- ], o = n, s = r, c = n, l = r, u = e ? Math.max : Math.min, d = new Float32Array(4);
15375
+ ], o = n, s = r, c = n, l = r, u = e ? Math.max : Math.min, d = /* @__PURE__ */ new Float32Array(4);
15615
15376
  for (let e = 6, f = t.length; e < f; e += 6) {
15616
15377
  let f = t[e + 4], p = t[e + 5];
15617
15378
  isNaN(t[e]) ? (V.pointBoundingBox(f, p, a), s > p ? (o = f, s = p) : s === p && (o = u(o, f)), l < p ? (c = f, l = p) : l === p && (c = u(c, f))) : (d.set(i, 0), V.bezierBoundingBox(n, r, ...t.slice(e, e + 6), d), V.rectBoundingBox(...d, a), s > d[1] ? (o = d[0], s = d[1]) : s === d[1] && (o = u(o, d[0])), l < d[3] ? (c = d[2], l = d[3]) : l === d[3] && (c = u(c, d[2]))), n = f, r = p;
@@ -15760,9 +15521,7 @@ var qr = class {
15760
15521
  if (a === 1) return [];
15761
15522
  i.splice(e, 1), e--, a--;
15762
15523
  }
15763
- continue;
15764
- }
15765
- i[e][2] = n, s > r && i.push([
15524
+ } else i[e][2] = n, s > r && i.push([
15766
15525
  t,
15767
15526
  r,
15768
15527
  s
@@ -15951,9 +15710,7 @@ var qr = class {
15951
15710
  case p.HIGHLIGHT_COLOR:
15952
15711
  e._defaultColor = n;
15953
15712
  break;
15954
- case p.HIGHLIGHT_THICKNESS:
15955
- e._defaultThickness = n;
15956
- break;
15713
+ case p.HIGHLIGHT_THICKNESS: e._defaultThickness = n;
15957
15714
  }
15958
15715
  }
15959
15716
  translateInPage(e, t) {}
@@ -15968,9 +15725,7 @@ var qr = class {
15968
15725
  case p.HIGHLIGHT_COLOR:
15969
15726
  this.#b(t);
15970
15727
  break;
15971
- case p.HIGHLIGHT_THICKNESS:
15972
- this.#x(t);
15973
- break;
15728
+ case p.HIGHLIGHT_THICKNESS: this.#x(t);
15974
15729
  }
15975
15730
  }
15976
15731
  static get defaultPropertiesToUpdate() {
@@ -16058,7 +15813,7 @@ var qr = class {
16058
15813
  this.#d && (this.#y({ highlightOutlines: this.#l.getNewOutline(e / 2) }), this.fixAndSetPosition(), this.setDims());
16059
15814
  }
16060
15815
  #C() {
16061
- this.#u === null || !this.parent || (this.parent.drawLayer.remove(this.#u), this.#u = null, this.parent.drawLayer.remove(this.#m), this.#m = null);
15816
+ this.#u !== null && this.parent && (this.parent.drawLayer.remove(this.#u), this.#u = null, this.parent.drawLayer.remove(this.#m), this.#m = null);
16062
15817
  }
16063
15818
  #w(e = this.parent) {
16064
15819
  this.#u === null && ({id: this.#u, clipPathId: this.#r} = e.drawLayer.draw({
@@ -16148,9 +15903,7 @@ var qr = class {
16148
15903
  this.#D(!0);
16149
15904
  break;
16150
15905
  case 1:
16151
- case 3:
16152
- this.#D(!1);
16153
- break;
15906
+ case 3: this.#D(!1);
16154
15907
  }
16155
15908
  }
16156
15909
  #D(e) {
@@ -16518,16 +16271,10 @@ var qr = class {
16518
16271
  this.parent && !e ? (this._uiManager.removeShouldRescale(this), this.#s()) : e && (this._uiManager.addShouldRescale(this), this.#c(e), t = !this.parent && this.div?.classList.contains("selectedEditor")), super.setParent(e), t && this.select();
16519
16272
  }
16520
16273
  #s() {
16521
- this._drawId === null || !this.parent || (this.parent.drawLayer.remove(this._drawId), this._drawId = null, this._drawingOptions.reset());
16274
+ this._drawId !== null && this.parent && (this.parent.drawLayer.remove(this._drawId), this._drawId = null, this._drawingOptions.reset());
16522
16275
  }
16523
16276
  #c(e = this.parent) {
16524
- if (!(this._drawId !== null && this.parent === e)) {
16525
- if (this._drawId !== null) {
16526
- this.parent.drawLayer.updateParent(this._drawId, e.drawLayer);
16527
- return;
16528
- }
16529
- this._drawingOptions.updateAll(), this._drawId = this.#o(this.#e, e);
16530
- }
16277
+ (this._drawId === null || this.parent !== e) && (this._drawId === null ? (this._drawingOptions.updateAll(), this._drawId = this.#o(this.#e, e)) : this.parent.drawLayer.updateParent(this._drawId, e.drawLayer));
16531
16278
  }
16532
16279
  #l([e, t, n, r]) {
16533
16280
  let { parentDimensions: [i, a], rotation: o } = this;
@@ -16714,7 +16461,7 @@ var qr = class {
16714
16461
  let { target: a, offsetX: o, offsetY: s, pointerId: c, pointerType: l } = i;
16715
16462
  if (G.isInitializedAndDifferentPointerType(l)) return;
16716
16463
  let { viewport: { rotation: u } } = t, { width: d, height: f } = a.getBoundingClientRect(), p = e.#r = new AbortController(), m = t.combinedSignal(p);
16717
- if (G.setPointer(l, c), window.addEventListener("pointerup", (e) => {
16464
+ G.setPointer(l, c), window.addEventListener("pointerup", (e) => {
16718
16465
  G.isSamePointerIdOrRemove(e.pointerId) && this._endDraw(e);
16719
16466
  }, { signal: m }), window.addEventListener("pointercancel", (e) => {
16720
16467
  G.isSamePointerIdOrRemove(e.pointerId) && this._currentParent.endDrawingSession();
@@ -16726,22 +16473,12 @@ var qr = class {
16726
16473
  signal: m
16727
16474
  }), window.addEventListener("contextmenu", Oe, { signal: m }), a.addEventListener("pointermove", this._drawMove.bind(this), { signal: m }), a.addEventListener("touchmove", (e) => {
16728
16475
  G.isSameTimeStamp(e.timeStamp) && U(e);
16729
- }, { signal: m }), t.toggleDrawing(), n._editorUndoBar?.hide(), e.#n) {
16730
- t.drawLayer.updateProperties(this._currentDrawId, e.#n.startNew(o, s, d, f, u));
16731
- return;
16732
- }
16733
- n.updateUIForDefaultProperties(this), e.#n = this.createDrawerInstance(o, s, d, f, u), e.#i = this.getDefaultDrawingOptions(), this._currentParent = t, {id: this._currentDrawId} = t.drawLayer.draw(this._mergeSVGProperties(e.#i.toSVGProperties(), e.#n.defaultSVGProperties), !0, !1);
16476
+ }, { signal: m }), t.toggleDrawing(), n._editorUndoBar?.hide(), e.#n ? t.drawLayer.updateProperties(this._currentDrawId, e.#n.startNew(o, s, d, f, u)) : (n.updateUIForDefaultProperties(this), e.#n = this.createDrawerInstance(o, s, d, f, u), e.#i = this.getDefaultDrawingOptions(), this._currentParent = t, {id: this._currentDrawId} = t.drawLayer.draw(this._mergeSVGProperties(e.#i.toSVGProperties(), e.#n.defaultSVGProperties), !0, !1));
16734
16477
  }
16735
16478
  static _drawMove(t) {
16736
16479
  if (G.isSameTimeStamp(t.timeStamp), !e.#n) return;
16737
16480
  let { offsetX: n, offsetY: r, pointerId: i } = t;
16738
- if (G.isSamePointerId(i)) {
16739
- if (G.isUsingMultiplePointers()) {
16740
- this._endDraw(t);
16741
- return;
16742
- }
16743
- this._currentParent.drawLayer.updateProperties(this._currentDrawId, e.#n.add(n, r)), G.setTimeStamp(t.timeStamp), U(t);
16744
- }
16481
+ G.isSamePointerId(i) && (G.isUsingMultiplePointers() ? this._endDraw(t) : (this._currentParent.drawLayer.updateProperties(this._currentDrawId, e.#n.add(n, r)), G.setTimeStamp(t.timeStamp), U(t)));
16745
16482
  }
16746
16483
  static _cleanup(t) {
16747
16484
  t && (this._currentDrawId = -1, this._currentParent = null, e.#n = null, e.#i = null, G.clearTimeStamp()), e.#r && (e.#r.abort(), e.#r = null, G.clearPointerIds());
@@ -16761,9 +16498,7 @@ var qr = class {
16761
16498
  mustExec: !1,
16762
16499
  type: p.DRAW_STEP
16763
16500
  });
16764
- return;
16765
- }
16766
- this.endDrawing(!1);
16501
+ } else this.endDrawing(!1);
16767
16502
  }
16768
16503
  }
16769
16504
  static endDrawing(t) {
@@ -16807,7 +16542,7 @@ var qr = class {
16807
16542
  return !1;
16808
16543
  }
16809
16544
  }, zi = class {
16810
- #e = new Float64Array(6);
16545
+ #e = /* @__PURE__ */ new Float64Array(6);
16811
16546
  #t;
16812
16547
  #n;
16813
16548
  #r;
@@ -16956,19 +16691,11 @@ var qr = class {
16956
16691
  }
16957
16692
  toSVGPath() {
16958
16693
  let e = [];
16959
- for (let { line: t } of this.#r) {
16960
- if (e.push(`M${$.svgRound(t[4])} ${$.svgRound(t[5])}`), t.length === 6) {
16961
- e.push("Z");
16962
- continue;
16963
- }
16964
- if (t.length === 12 && isNaN(t[6])) {
16965
- e.push(`L${$.svgRound(t[10])} ${$.svgRound(t[11])}`);
16966
- continue;
16967
- }
16968
- for (let n = 6, r = t.length; n < r; n += 6) {
16969
- let [r, i, a, o, s, c] = t.subarray(n, n + 6).map($.svgRound);
16970
- e.push(`C${r} ${i} ${a} ${o} ${s} ${c}`);
16971
- }
16694
+ for (let { line: t } of this.#r) if (e.push(`M${$.svgRound(t[4])} ${$.svgRound(t[5])}`), t.length === 6) e.push("Z");
16695
+ else if (t.length === 12 && isNaN(t[6])) e.push(`L${$.svgRound(t[10])} ${$.svgRound(t[11])}`);
16696
+ else for (let n = 6, r = t.length; n < r; n += 6) {
16697
+ let [r, i, a, o, s, c] = t.subarray(n, n + 6).map($.svgRound);
16698
+ e.push(`C${r} ${i} ${a} ${o} ${s} ${c}`);
16972
16699
  }
16973
16700
  return e.join("");
16974
16701
  }
@@ -16984,9 +16711,7 @@ var qr = class {
16984
16711
  case 180:
16985
16712
  y = $._rescale, d = e + n, f = t, p = -n, m = r, h = e + (1 - s - l) * n, g = t + c * r, _ = e + (1 - s) * n, v = t + (c + u) * r;
16986
16713
  break;
16987
- case 270:
16988
- y = $._rescaleAndSwap, d = e + n, f = t + r, p = -n, m = -r, h = e + (1 - c - u) * n, g = t + (1 - s - l) * r, _ = e + (1 - c) * n, v = t + (1 - s) * r;
16989
- break;
16714
+ case 270: y = $._rescaleAndSwap, d = e + n, f = t + r, p = -n, m = -r, h = e + (1 - c - u) * n, g = t + (1 - s - l) * r, _ = e + (1 - c) * n, v = t + (1 - s) * r;
16990
16715
  }
16991
16716
  for (let { line: e, points: t } of this.#r) a.push(y(e, d, f, p, m, i ? Array(e.length) : null)), o.push(y(t, d, f, p, m, i ? Array(t.length) : null));
16992
16717
  return {
@@ -17012,9 +16737,7 @@ var qr = class {
17012
16737
  case 180:
17013
16738
  m = $._rescale, u = e / n + 1, d = -t / r, f = -1 / n, p = 1 / r;
17014
16739
  break;
17015
- case 270:
17016
- m = $._rescaleAndSwap, u = t / r + 1, d = e / n + 1, f = -1 / r, p = -1 / n;
17017
- break;
16740
+ case 270: m = $._rescaleAndSwap, u = t / r + 1, d = e / n + 1, f = -1 / r, p = -1 / n;
17018
16741
  }
17019
16742
  if (!a) {
17020
16743
  a = [];
@@ -17263,7 +16986,7 @@ var qr = class {
17263
16986
  return !0;
17264
16987
  }
17265
16988
  static get typesMap() {
17266
- return P(this, "typesMap", new Map([
16989
+ return P(this, "typesMap", /* @__PURE__ */ new Map([
17267
16990
  [p.INK_THICKNESS, "stroke-width"],
17268
16991
  [p.INK_COLOR, "stroke"],
17269
16992
  [p.INK_OPACITY, "stroke-opacity"]
@@ -17315,18 +17038,10 @@ var qr = class {
17315
17038
  return p.INK_OPACITY;
17316
17039
  }
17317
17040
  updateParams(e, t) {
17318
- if (e === p.INK_COLOR_AND_OPACITY) {
17319
- this._updateColorAndOpacity(t.color, t.opacity);
17320
- return;
17321
- }
17322
- super.updateParams(e, t);
17041
+ e === p.INK_COLOR_AND_OPACITY ? this._updateColorAndOpacity(t.color, t.opacity) : super.updateParams(e, t);
17323
17042
  }
17324
17043
  static updateDefaultParams(e, t) {
17325
- if (e === p.INK_COLOR_AND_OPACITY) {
17326
- super.updateDefaultParams(p.INK_COLOR, t.color), super.updateDefaultParams(p.INK_OPACITY, t.opacity);
17327
- return;
17328
- }
17329
- super.updateDefaultParams(e, t);
17044
+ e === p.INK_COLOR_AND_OPACITY ? (super.updateDefaultParams(p.INK_COLOR, t.color), super.updateDefaultParams(p.INK_OPACITY, t.opacity)) : super.updateDefaultParams(e, t);
17330
17045
  }
17331
17046
  get color() {
17332
17047
  return this._drawingOptions.stroke;
@@ -17460,7 +17175,7 @@ var Wi = 8, Gi = 3, Ki = class {
17460
17175
  m = e;
17461
17176
  break;
17462
17177
  }
17463
- m ? m.isHole ? p.parent = f ? m.parent : s : p.parent = f ? s : m.parent : p.parent = f ? s : 0;
17178
+ p.parent = m ? m.isHole ? f ? m.parent : s : f ? s : m.parent : f ? s : 0;
17464
17179
  let h = this.#r(a, t, e, n, l, u, 0);
17465
17180
  if (h === -1) {
17466
17181
  a[r] = -o, a[r] !== 1 && (s = Math.abs(a[r]));
@@ -17478,7 +17193,8 @@ var Wi = 8, Gi = 3, Ki = class {
17478
17193
  if (a[p + 1] === 0 ? a[p] = -o : a[p] === 1 && (a[p] = o), c === e && f === n && b === v && x === y) {
17479
17194
  a[r] !== 1 && (s = Math.abs(a[r]));
17480
17195
  break;
17481
- } else l = b, u = x, b = c, x = f;
17196
+ }
17197
+ l = b, u = x, b = c, x = f;
17482
17198
  }
17483
17199
  }
17484
17200
  }
@@ -17506,9 +17222,9 @@ var Wi = 8, Gi = 3, Ki = class {
17506
17222
  let t = (e - c) ** 2;
17507
17223
  for (let n = 0; n < a; n++) o[e * a + n] = Math.exp((t + (n - c) ** 2) / s);
17508
17224
  }
17509
- let l = new Float32Array(256), u = -2 * i ** 2;
17225
+ let l = /* @__PURE__ */ new Float32Array(256), u = -2 * i ** 2;
17510
17226
  for (let e = 0; e < 256; e++) l[e] = Math.exp(e ** 2 / u);
17511
- let d = e.length, f = new Uint8Array(d), p = new Uint32Array(256);
17227
+ let d = e.length, f = new Uint8Array(d), p = /* @__PURE__ */ new Uint32Array(256);
17512
17228
  for (let r = 0; r < n; r++) for (let i = 0; i < t; i++) {
17513
17229
  let s = r * t + i, u = e[s], d = 0, m = 0;
17514
17230
  for (let s = 0; s < a; s++) {
@@ -17526,7 +17242,7 @@ var Wi = 8, Gi = 3, Ki = class {
17526
17242
  return [f, p];
17527
17243
  }
17528
17244
  static #l(e) {
17529
- let t = new Uint32Array(256);
17245
+ let t = /* @__PURE__ */ new Uint32Array(256);
17530
17246
  for (let n of e) t[n]++;
17531
17247
  return t;
17532
17248
  }
@@ -17576,7 +17292,7 @@ var Wi = 8, Gi = 3, Ki = class {
17576
17292
  c = new OffscreenCanvas(y, b), l = c.getContext("2d", {
17577
17293
  alpha: !0,
17578
17294
  willReadFrequently: !0
17579
- }), l.font = u, l.filter = "grayscale(1)", l.fillStyle = "white", l.fillRect(0, 0, y, b), l.fillStyle = "black", l.fillText(e, y * (v - 1) / 2, b * (3 - v) / 2);
17295
+ }), l.font = u, l.filter = "grayscale(1)", l.fillStyle = "white", l.fillRect(0, 0, y, b), l.fillStyle = "black", l.fillText(e, y * .5 / 2, b * 1.5 / 2);
17580
17296
  let x = this.#u(l.getImageData(0, 0, y, b).data), S = this.#l(x), C = this.#d(S), w = this.#a(x, y, b, C);
17581
17297
  return this.processDrawnLines({
17582
17298
  lines: {
@@ -17707,15 +17423,13 @@ var Wi = 8, Gi = 3, Ki = class {
17707
17423
  case Int16Array.BYTES_PER_ELEMENT:
17708
17424
  _ = new Int16Array(a.buffer, g);
17709
17425
  break;
17710
- case Int32Array.BYTES_PER_ELEMENT:
17711
- _ = new Int32Array(a.buffer, g);
17712
- break;
17426
+ case Int32Array.BYTES_PER_ELEMENT: _ = new Int32Array(a.buffer, g);
17713
17427
  }
17714
17428
  o = 0;
17715
17429
  for (let e = 0; e < p; e++) {
17716
17430
  let t = s[Gi * e + Wi], n = new Float32Array(t + 2);
17717
17431
  h.push(n);
17718
- for (let t = 0; t < Gi - 1; t++) n[t] = s[Gi * e + Wi + t + 1];
17432
+ for (let t = 0; t < 2; t++) n[t] = s[Gi * e + Wi + t + 1];
17719
17433
  for (let e = 0; e < t; e++) n[e + 2] = n[e] + _[o++];
17720
17434
  }
17721
17435
  return {
@@ -17804,19 +17518,20 @@ var Wi = 8, Gi = 3, Ki = class {
17804
17518
  render() {
17805
17519
  if (this.div) return this.div;
17806
17520
  let t, n, { _isCopy: r } = this;
17807
- if (r && (this._isCopy = !1, t = this.x, n = this.y), super.render(), this._drawId === null) if (this.#n) {
17808
- let { lines: t, mustSmooth: n, areContours: r, description: i, uuid: a, heightInPage: o } = this.#n, { rawDims: { pageWidth: s, pageHeight: c }, rotation: l } = this.parent.viewport, u = Ki.processDrawnLines({
17809
- lines: t,
17810
- pageWidth: s,
17811
- pageHeight: c,
17812
- rotation: l,
17813
- innerMargin: e._INNER_MARGIN,
17814
- mustSmooth: n,
17815
- areContours: r
17816
- });
17817
- this.addSignature(u, o, i, a);
17818
- } else this.div.setAttribute("data-l10n-args", JSON.stringify({ description: "" })), this.div.hidden = !0, this._uiManager.getSignature(this);
17819
- else this.div.setAttribute("data-l10n-args", JSON.stringify({ description: this.#t || "" }));
17521
+ if (r && (this._isCopy = !1, t = this.x, n = this.y), super.render(), this._drawId === null) {
17522
+ if (this.#n) {
17523
+ let { lines: t, mustSmooth: n, areContours: r, description: i, uuid: a, heightInPage: o } = this.#n, { rawDims: { pageWidth: s, pageHeight: c }, rotation: l } = this.parent.viewport, u = Ki.processDrawnLines({
17524
+ lines: t,
17525
+ pageWidth: s,
17526
+ pageHeight: c,
17527
+ rotation: l,
17528
+ innerMargin: e._INNER_MARGIN,
17529
+ mustSmooth: n,
17530
+ areContours: r
17531
+ });
17532
+ this.addSignature(u, o, i, a);
17533
+ } else this.div.setAttribute("data-l10n-args", JSON.stringify({ description: "" })), this.div.hidden = !0, this._uiManager.getSignature(this);
17534
+ } else this.div.setAttribute("data-l10n-args", JSON.stringify({ description: this.#t || "" }));
17820
17535
  return r && (this._isCopy = !0, this._moveAfterPaste(t, n)), this.div;
17821
17536
  }
17822
17537
  setUuid(e) {
@@ -17969,33 +17684,28 @@ var Wi = 8, Gi = 3, Ki = class {
17969
17684
  };
17970
17685
  }
17971
17686
  #d(e, t = !1) {
17972
- if (!e) {
17973
- this.remove();
17974
- return;
17975
- }
17976
- this.#e = e.bitmap, t || (this.#t = e.id, this.#l = e.isSvg), e.file && (this.#a = e.file.name), this.#m();
17687
+ e ? (this.#e = e.bitmap, t || (this.#t = e.id, this.#l = e.isSvg), e.file && (this.#a = e.file.name), this.#m()) : this.remove();
17977
17688
  }
17978
17689
  #f() {
17979
17690
  if (this.#n = null, this._uiManager.enableWaiting(!1), this.#o) {
17980
- if (this._uiManager.useNewAltTextWhenAddingImage && this._uiManager.useNewAltTextFlow && this.#e) {
17981
- this.addEditToolbar().then(() => {
17982
- this._editToolbar.hide(), this._uiManager.editAltText(this, !0);
17983
- });
17984
- return;
17985
- }
17986
- if (!this._uiManager.useNewAltTextWhenAddingImage && this._uiManager.useNewAltTextFlow && this.#e) {
17987
- this._reportTelemetry({
17988
- action: "pdfjs.image.image_added",
17989
- data: {
17990
- alt_text_modal: !1,
17991
- alt_text_type: "empty"
17992
- }
17993
- });
17994
- try {
17995
- this.mlGuessAltText();
17996
- } catch {}
17691
+ if (this._uiManager.useNewAltTextWhenAddingImage && this._uiManager.useNewAltTextFlow && this.#e) this.addEditToolbar().then(() => {
17692
+ this._editToolbar.hide(), this._uiManager.editAltText(this, !0);
17693
+ });
17694
+ else {
17695
+ if (!this._uiManager.useNewAltTextWhenAddingImage && this._uiManager.useNewAltTextFlow && this.#e) {
17696
+ this._reportTelemetry({
17697
+ action: "pdfjs.image.image_added",
17698
+ data: {
17699
+ alt_text_modal: !1,
17700
+ alt_text_type: "empty"
17701
+ }
17702
+ });
17703
+ try {
17704
+ this.mlGuessAltText();
17705
+ } catch {}
17706
+ }
17707
+ this.div.focus();
17997
17708
  }
17998
- this.div.focus();
17999
17709
  }
18000
17710
  }
18001
17711
  async mlGuessAltText(e = null, t = !0) {
@@ -18061,11 +17771,7 @@ var Wi = 8, Gi = 3, Ki = class {
18061
17771
  this.#t && (this.#e = null, this._uiManager.imageManager.deleteId(this.#t), this.#o?.remove(), this.#o = null, this.#c &&= (clearTimeout(this.#c), null)), super.remove();
18062
17772
  }
18063
17773
  rebuild() {
18064
- if (!this.parent) {
18065
- this.#t && this.#p();
18066
- return;
18067
- }
18068
- super.rebuild(), this.div !== null && (this.#t && this.#o === null && this.#p(), this.isAttachedToDOM || this.parent.add(this));
17774
+ this.parent ? (super.rebuild(), this.div !== null && (this.#t && this.#o === null && this.#p(), this.isAttachedToDOM || this.parent.add(this))) : this.#t && this.#p();
18069
17775
  }
18070
17776
  onceAdded(e) {
18071
17777
  this._isDraggable = !0, e && this.div.focus();
@@ -18105,7 +17811,7 @@ var Wi = 8, Gi = 3, Ki = class {
18105
17811
  }
18106
17812
  this._uiManager.enableWaiting(!1);
18107
17813
  let o = this.#o = document.createElement("canvas");
18108
- o.setAttribute("role", "img"), this.addContainer(o), this.width = t / r, this.height = n / i, this.setDims(), this._initialOptions?.isCentered ? this.center() : this.fixAndSetPosition(), this._initialOptions = null, (!this._uiManager.useNewAltTextWhenAddingImage || !this._uiManager.useNewAltTextFlow || this.annotationElementId) && (e.hidden = !1), this.#g(), this.#u ||= (this.parent.addUndoableEditor(this), !0), this._reportTelemetry({ action: "inserted_image" }), this.#a && this.div.setAttribute("aria-description", this.#a), this.annotationElementId || this._uiManager.a11yAlert(K._l10nAlert.stamp);
17814
+ o.setAttribute("role", "img"), this.addContainer(o), this.width = t / r, this.height = n / i, this.setDims(), this._initialOptions?.isCentered ? this.center() : this.fixAndSetPosition(), this._initialOptions = null, this._uiManager.useNewAltTextWhenAddingImage && this._uiManager.useNewAltTextFlow && !this.annotationElementId || (e.hidden = !1), this.#g(), this.#u ||= (this.parent.addUndoableEditor(this), !0), this._reportTelemetry({ action: "inserted_image" }), this.#a && this.div.setAttribute("aria-description", this.#a), this.annotationElementId || this._uiManager.a11yAlert(K._l10nAlert.stamp);
18109
17815
  }
18110
17816
  copyCanvas(e, t, n = !1) {
18111
17817
  e ||= 224;
@@ -18389,17 +18095,7 @@ var Wi = 8, Gi = 3, Ki = class {
18389
18095
  let t = this.#n, n = [];
18390
18096
  if (t) {
18391
18097
  let e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
18392
- for (let t of this.#_) {
18393
- if (t.disableEditing(), !t.annotationElementId) {
18394
- n.push(t);
18395
- continue;
18396
- }
18397
- if (t.serialize() !== null) {
18398
- e.set(t.annotationElementId, t);
18399
- continue;
18400
- } else r.set(t.annotationElementId, t);
18401
- this.getEditableAnnotation(t.annotationElementId)?.show(), t.remove();
18402
- }
18098
+ for (let t of this.#_) t.disableEditing(), t.annotationElementId ? t.serialize() === null ? (r.set(t.annotationElementId, t), this.getEditableAnnotation(t.annotationElementId)?.show(), t.remove()) : e.set(t.annotationElementId, t) : n.push(t);
18403
18099
  for (let n of t.getEditableAnnotations()) {
18404
18100
  let { id: t } = n.data;
18405
18101
  if (this.#h.isDeletedAnnotationElement(t)) {
@@ -18407,11 +18103,7 @@ var Wi = 8, Gi = 3, Ki = class {
18407
18103
  continue;
18408
18104
  }
18409
18105
  let i = r.get(t);
18410
- if (i) {
18411
- i.resetAnnotationElement(n), i.show(!1), n.show();
18412
- continue;
18413
- }
18414
- i = e.get(t), i && (this.#h.addChangedExistingAnnotation(i), i.renderAnnotationElement(n) && i.show(!1)), n.show();
18106
+ i ? (i.resetAnnotationElement(n), i.show(!1), n.show()) : (i = e.get(t), i && (this.#h.addChangedExistingAnnotation(i), i.renderAnnotationElement(n) && i.show(!1)), n.show());
18415
18107
  }
18416
18108
  }
18417
18109
  this.#S(), this.isEmpty && (this.div.hidden = !0);
@@ -18586,11 +18278,7 @@ var Wi = 8, Gi = 3, Ki = class {
18586
18278
  return;
18587
18279
  }
18588
18280
  let n = this.#h.getMode();
18589
- if (n === f.STAMP || n === f.POPUP || n === f.SIGNATURE) {
18590
- this.#h.unselectAll();
18591
- return;
18592
- }
18593
- this.createAndAddNewEditor(e, !1);
18281
+ n === f.STAMP || n === f.POPUP || n === f.SIGNATURE ? this.#h.unselectAll() : this.createAndAddNewEditor(e, !1);
18594
18282
  }
18595
18283
  pointerdown(e) {
18596
18284
  if (this.#h.getMode() === f.HIGHLIGHT && this.enableTextSelection(), this.#o) {
@@ -18621,9 +18309,7 @@ var Wi = 8, Gi = 3, Ki = class {
18621
18309
  if (e) {
18622
18310
  let { activeElement: e } = document;
18623
18311
  this.div.contains(e) && (this.#u = e);
18624
- return;
18625
- }
18626
- this.#u && setTimeout(() => {
18312
+ } else this.#u && setTimeout(() => {
18627
18313
  this.#u?.focus(), this.#u = null;
18628
18314
  }, 0);
18629
18315
  }
@@ -18711,7 +18397,7 @@ var na = class e {
18711
18397
  if (this.pageIndex = r, this.#r = t, this.#i = n, i) {
18712
18398
  let t = e.#p.get(i);
18713
18399
  if (t?.selectionDiv && (t.selectionDiv.remove(), e.#u.delete(t.selectionDiv)), e.#p.set(i, { drawLayer: this }), e.#f.add(i), this.#n = i, this.#a = new MutationObserver((t) => {
18714
- if (!(!this.#e || !this.#n?.isConnected || !e.#h())) {
18400
+ if (this.#e && this.#n?.isConnected && e.#h()) {
18715
18401
  for (let { addedNodes: n } of t) for (let t of n) if (t.nodeType === Node.ELEMENT_NODE && t.classList.contains("endOfContent")) {
18716
18402
  e.#_();
18717
18403
  return;
@@ -18731,11 +18417,8 @@ var na = class e {
18731
18417
  }
18732
18418
  }
18733
18419
  setParent(t) {
18734
- if (!this.#e) {
18735
- this.#e = t, this.#n?.isConnected && e.#h() && e.#_();
18736
- return;
18737
- }
18738
- if (this.#e !== t) {
18420
+ if (!this.#e) this.#e = t, this.#n?.isConnected && e.#h() && e.#_();
18421
+ else if (this.#e !== t) {
18739
18422
  if (this.#t.size > 0) for (let e of this.#t.values()) e.remove(), t.append(e);
18740
18423
  this.#e = t;
18741
18424
  }
@@ -18787,11 +18470,8 @@ var na = class e {
18787
18470
  if (!e) continue;
18788
18471
  a = e.container, o = e.offset;
18789
18472
  }
18790
- if (l === u && !m && p.includes(l)) {
18791
- i.push([n, l]);
18792
- continue;
18793
- }
18794
- for (let e of p) {
18473
+ if (l === u && !m && p.includes(l)) i.push([n, l]);
18474
+ else for (let e of p) {
18795
18475
  let t = e.firstChild;
18796
18476
  if (!t) continue;
18797
18477
  let n = document.createRange();
@@ -18824,7 +18504,7 @@ var na = class e {
18824
18504
  }), n.set(r, a);
18825
18505
  }
18826
18506
  let o = [];
18827
- for (let { x: e, y: n, width: r, height: i } of t.getClientRects()) r === 0 || i === 0 || ({x: e, y: n, width: r, height: i} = a(e, n, r, i), !(r === 1 && i === 1) && o.push(`M${e} ${n} h${r} v${i} h-${r} Z`));
18507
+ for (let { x: e, y: n, width: r, height: i } of t.getClientRects()) r !== 0 && i !== 0 && ({x: e, y: n, width: r, height: i} = a(e, n, r, i), (r !== 1 || i !== 1) && o.push(`M${e} ${n} h${r} v${i} h-${r} Z`));
18828
18508
  if (o.length === 0) continue;
18829
18509
  let s = i.drawLayer, c = i.selectionDiv, l = i.path;
18830
18510
  if (!c) {
@@ -19054,5 +18734,4 @@ globalThis._pdfjsTestingUtils = { HighlightOutliner: Mi }, globalThis.pdfjsLib =
19054
18734
  version: Vr,
19055
18735
  XfaLayer: ve
19056
18736
  };
19057
- //#endregion
19058
18737
  export { yr as GlobalWorkerOptions, Mr as getDocument };