@hussmartinez/pdf-sdk 0.0.0-stage → 0.2.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 (395) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +66 -0
  3. package/README.md +119 -2
  4. package/dist/assets/pdfjs/build/pdf.worker.min.mjs +28 -0
  5. package/dist/assets/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  6. package/dist/assets/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  7. package/dist/assets/pdfjs/cmaps/78-H.bcmap +0 -0
  8. package/dist/assets/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  9. package/dist/assets/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  10. package/dist/assets/pdfjs/cmaps/78-V.bcmap +0 -0
  11. package/dist/assets/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  12. package/dist/assets/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  13. package/dist/assets/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  14. package/dist/assets/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  15. package/dist/assets/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  16. package/dist/assets/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  17. package/dist/assets/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  18. package/dist/assets/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  19. package/dist/assets/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  20. package/dist/assets/pdfjs/cmaps/Add-H.bcmap +0 -0
  21. package/dist/assets/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  22. package/dist/assets/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  23. package/dist/assets/pdfjs/cmaps/Add-V.bcmap +0 -0
  24. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  25. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  26. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  27. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  28. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  29. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  30. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  31. package/dist/assets/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  32. package/dist/assets/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  33. package/dist/assets/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  34. package/dist/assets/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  35. package/dist/assets/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  36. package/dist/assets/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  37. package/dist/assets/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  38. package/dist/assets/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  39. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  40. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  41. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  42. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  43. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  44. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  45. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  46. package/dist/assets/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  47. package/dist/assets/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  48. package/dist/assets/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  49. package/dist/assets/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  50. package/dist/assets/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  51. package/dist/assets/pdfjs/cmaps/B5-H.bcmap +0 -0
  52. package/dist/assets/pdfjs/cmaps/B5-V.bcmap +0 -0
  53. package/dist/assets/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  54. package/dist/assets/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  55. package/dist/assets/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  56. package/dist/assets/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  57. package/dist/assets/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  58. package/dist/assets/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  59. package/dist/assets/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  60. package/dist/assets/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  61. package/dist/assets/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  62. package/dist/assets/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  63. package/dist/assets/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  64. package/dist/assets/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  65. package/dist/assets/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  66. package/dist/assets/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  67. package/dist/assets/pdfjs/cmaps/EUC-H.bcmap +0 -0
  68. package/dist/assets/pdfjs/cmaps/EUC-V.bcmap +0 -0
  69. package/dist/assets/pdfjs/cmaps/Ext-H.bcmap +0 -0
  70. package/dist/assets/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  71. package/dist/assets/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  72. package/dist/assets/pdfjs/cmaps/Ext-V.bcmap +0 -0
  73. package/dist/assets/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  74. package/dist/assets/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  75. package/dist/assets/pdfjs/cmaps/GB-H.bcmap +4 -0
  76. package/dist/assets/pdfjs/cmaps/GB-V.bcmap +0 -0
  77. package/dist/assets/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  78. package/dist/assets/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  79. package/dist/assets/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  80. package/dist/assets/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  81. package/dist/assets/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  82. package/dist/assets/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  83. package/dist/assets/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  84. package/dist/assets/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  85. package/dist/assets/pdfjs/cmaps/GBT-H.bcmap +0 -0
  86. package/dist/assets/pdfjs/cmaps/GBT-V.bcmap +0 -0
  87. package/dist/assets/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  88. package/dist/assets/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  89. package/dist/assets/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  90. package/dist/assets/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  91. package/dist/assets/pdfjs/cmaps/H.bcmap +0 -0
  92. package/dist/assets/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  93. package/dist/assets/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  94. package/dist/assets/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  95. package/dist/assets/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  96. package/dist/assets/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  97. package/dist/assets/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  98. package/dist/assets/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  99. package/dist/assets/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  100. package/dist/assets/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  101. package/dist/assets/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  102. package/dist/assets/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  103. package/dist/assets/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  104. package/dist/assets/pdfjs/cmaps/Hankaku.bcmap +0 -0
  105. package/dist/assets/pdfjs/cmaps/Hiragana.bcmap +0 -0
  106. package/dist/assets/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  107. package/dist/assets/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  108. package/dist/assets/pdfjs/cmaps/KSC-H.bcmap +0 -0
  109. package/dist/assets/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  110. package/dist/assets/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  111. package/dist/assets/pdfjs/cmaps/KSC-V.bcmap +0 -0
  112. package/dist/assets/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  113. package/dist/assets/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  114. package/dist/assets/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  115. package/dist/assets/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  116. package/dist/assets/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  117. package/dist/assets/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  118. package/dist/assets/pdfjs/cmaps/Katakana.bcmap +0 -0
  119. package/dist/assets/pdfjs/cmaps/LICENSE +36 -0
  120. package/dist/assets/pdfjs/cmaps/NWP-H.bcmap +0 -0
  121. package/dist/assets/pdfjs/cmaps/NWP-V.bcmap +0 -0
  122. package/dist/assets/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  123. package/dist/assets/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  124. package/dist/assets/pdfjs/cmaps/Roman.bcmap +0 -0
  125. package/dist/assets/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  126. package/dist/assets/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  127. package/dist/assets/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  128. package/dist/assets/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  129. package/dist/assets/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  130. package/dist/assets/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  131. package/dist/assets/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  132. package/dist/assets/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  133. package/dist/assets/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  134. package/dist/assets/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  135. package/dist/assets/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  136. package/dist/assets/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  137. package/dist/assets/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  138. package/dist/assets/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  139. package/dist/assets/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  140. package/dist/assets/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  141. package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  142. package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  143. package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  144. package/dist/assets/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  145. package/dist/assets/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  146. package/dist/assets/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  147. package/dist/assets/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  148. package/dist/assets/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  149. package/dist/assets/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  150. package/dist/assets/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  151. package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  152. package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  153. package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  154. package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  155. package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  156. package/dist/assets/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  157. package/dist/assets/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  158. package/dist/assets/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  159. package/dist/assets/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  160. package/dist/assets/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  161. package/dist/assets/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  162. package/dist/assets/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  163. package/dist/assets/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  164. package/dist/assets/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  165. package/dist/assets/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  166. package/dist/assets/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  167. package/dist/assets/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  168. package/dist/assets/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  169. package/dist/assets/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  170. package/dist/assets/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  171. package/dist/assets/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  172. package/dist/assets/pdfjs/cmaps/V.bcmap +0 -0
  173. package/dist/assets/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  174. package/dist/assets/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
  175. package/dist/assets/pdfjs/iccs/LICENSE +116 -0
  176. package/dist/assets/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  177. package/dist/assets/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  178. package/dist/assets/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  179. package/dist/assets/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  180. package/dist/assets/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  181. package/dist/assets/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  182. package/dist/assets/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  183. package/dist/assets/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  184. package/dist/assets/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  185. package/dist/assets/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  186. package/dist/assets/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  187. package/dist/assets/pdfjs/wasm/LICENSE_JBIG2 +196 -0
  188. package/dist/assets/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
  189. package/dist/assets/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  190. package/dist/assets/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  191. package/dist/assets/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
  192. package/dist/assets/pdfjs/wasm/LICENSE_QCMS +21 -0
  193. package/dist/assets/pdfjs/wasm/jbig2.wasm +0 -0
  194. package/dist/assets/pdfjs/wasm/openjpeg.wasm +0 -0
  195. package/dist/assets/pdfjs/wasm/qcms_bg.wasm +0 -0
  196. package/dist/assets/processing/processing.worker.js +57 -0
  197. package/dist/assets/processing/qpdf.wasm +0 -0
  198. package/dist/element.d.ts +12 -0
  199. package/dist/element.js +0 -0
  200. package/dist/index.d.ts +1304 -0
  201. package/dist/index.js +1 -0
  202. package/dist/lazy/78-EUC-H.bcmap-sYP3SMNV.js +3 -0
  203. package/dist/lazy/78-EUC-V.bcmap-w3SY_Y_q.js +3 -0
  204. package/dist/lazy/78-H.bcmap-CeA2DrtT.js +3 -0
  205. package/dist/lazy/78-RKSJ-H.bcmap-D4cLhL3_.js +3 -0
  206. package/dist/lazy/78-RKSJ-V.bcmap-DdK1ZiTU.js +3 -0
  207. package/dist/lazy/78-V.bcmap-CVoLO4i0.js +3 -0
  208. package/dist/lazy/78ms-RKSJ-H.bcmap-B20DW4UH.js +3 -0
  209. package/dist/lazy/78ms-RKSJ-V.bcmap-CLnY5REh.js +3 -0
  210. package/dist/lazy/83pv-RKSJ-H.bcmap-Ck3Sc38p.js +3 -0
  211. package/dist/lazy/90ms-RKSJ-H.bcmap-C-vgp7Oe.js +3 -0
  212. package/dist/lazy/90ms-RKSJ-V.bcmap-CnYvCBfH.js +3 -0
  213. package/dist/lazy/90msp-RKSJ-H.bcmap-BIx2U_Lw.js +3 -0
  214. package/dist/lazy/90msp-RKSJ-V.bcmap-LSpKnFnA.js +3 -0
  215. package/dist/lazy/90pv-RKSJ-H.bcmap-ohvXiazb.js +3 -0
  216. package/dist/lazy/90pv-RKSJ-V.bcmap-DiMSuPqu.js +3 -0
  217. package/dist/lazy/Add-H.bcmap-D50q_cPt.js +3 -0
  218. package/dist/lazy/Add-RKSJ-H.bcmap-DLQ79XiS.js +3 -0
  219. package/dist/lazy/Add-RKSJ-V.bcmap-DgMvx1Yl.js +3 -0
  220. package/dist/lazy/Add-V.bcmap-njFd39xE.js +3 -0
  221. package/dist/lazy/Adobe-CNS1-0.bcmap-DC9aIYc6.js +3 -0
  222. package/dist/lazy/Adobe-CNS1-1.bcmap-CjXhkA0W.js +3 -0
  223. package/dist/lazy/Adobe-CNS1-2.bcmap-BfDCyJYh.js +3 -0
  224. package/dist/lazy/Adobe-CNS1-3.bcmap-C5_dNXD-.js +3 -0
  225. package/dist/lazy/Adobe-CNS1-4.bcmap-DkB6y9PJ.js +3 -0
  226. package/dist/lazy/Adobe-CNS1-5.bcmap-13hTC0vp.js +3 -0
  227. package/dist/lazy/Adobe-CNS1-6.bcmap-CcQ66yT1.js +3 -0
  228. package/dist/lazy/Adobe-CNS1-UCS2.bcmap-jD7ZNdHN.js +3 -0
  229. package/dist/lazy/Adobe-GB1-0.bcmap-CwfHCw6h.js +3 -0
  230. package/dist/lazy/Adobe-GB1-1.bcmap-DRWrCran.js +3 -0
  231. package/dist/lazy/Adobe-GB1-2.bcmap-0nedEhcq.js +3 -0
  232. package/dist/lazy/Adobe-GB1-3.bcmap-Cq3lCVsW.js +3 -0
  233. package/dist/lazy/Adobe-GB1-4.bcmap-BzTb6Nsg.js +3 -0
  234. package/dist/lazy/Adobe-GB1-5.bcmap-BUHSmz5c.js +3 -0
  235. package/dist/lazy/Adobe-GB1-UCS2.bcmap-DUfIxWQW.js +3 -0
  236. package/dist/lazy/Adobe-Japan1-0.bcmap-BjG9GiRM.js +3 -0
  237. package/dist/lazy/Adobe-Japan1-1.bcmap-DQTj-iQt.js +3 -0
  238. package/dist/lazy/Adobe-Japan1-2.bcmap-BOsCSmmm.js +3 -0
  239. package/dist/lazy/Adobe-Japan1-3.bcmap-ChGf7g8t.js +3 -0
  240. package/dist/lazy/Adobe-Japan1-4.bcmap-CI6iUMgQ.js +3 -0
  241. package/dist/lazy/Adobe-Japan1-5.bcmap-kbwPceJO.js +3 -0
  242. package/dist/lazy/Adobe-Japan1-6.bcmap-CAvvqYpW.js +3 -0
  243. package/dist/lazy/Adobe-Japan1-UCS2.bcmap-DbZiEgfC.js +3 -0
  244. package/dist/lazy/Adobe-Korea1-0.bcmap-Der5jvBG.js +3 -0
  245. package/dist/lazy/Adobe-Korea1-1.bcmap-DafpcUyn.js +3 -0
  246. package/dist/lazy/Adobe-Korea1-2.bcmap-D1nh75yR.js +3 -0
  247. package/dist/lazy/Adobe-Korea1-UCS2.bcmap-CNeMfPHO.js +3 -0
  248. package/dist/lazy/B5-H.bcmap-gyhuoKf7.js +3 -0
  249. package/dist/lazy/B5-V.bcmap-BGqDqEjZ.js +3 -0
  250. package/dist/lazy/B5pc-H.bcmap-C8B_dVbb.js +3 -0
  251. package/dist/lazy/B5pc-V.bcmap-ETo7py2B.js +3 -0
  252. package/dist/lazy/CNS-EUC-H.bcmap-BgwyrNdN.js +3 -0
  253. package/dist/lazy/CNS-EUC-V.bcmap-BbC68G9k.js +3 -0
  254. package/dist/lazy/CNS1-H.bcmap-DZIguuvp.js +3 -0
  255. package/dist/lazy/CNS1-V.bcmap-DjthPwLF.js +3 -0
  256. package/dist/lazy/CNS2-H.bcmap-CTuiQP8Z.js +3 -0
  257. package/dist/lazy/CNS2-V.bcmap-BU5ZzL4C.js +3 -0
  258. package/dist/lazy/ETHK-B5-H.bcmap-AYx-kODg.js +3 -0
  259. package/dist/lazy/ETHK-B5-V.bcmap-C_2Sxwdm.js +3 -0
  260. package/dist/lazy/ETen-B5-H.bcmap-BAKuplan.js +3 -0
  261. package/dist/lazy/ETen-B5-V.bcmap-Dnm6aXlS.js +3 -0
  262. package/dist/lazy/ETenms-B5-H.bcmap-DZ8Y3Rnc.js +3 -0
  263. package/dist/lazy/ETenms-B5-V.bcmap-DPnnTEiA.js +3 -0
  264. package/dist/lazy/EUC-H.bcmap-B1COGDXX.js +3 -0
  265. package/dist/lazy/EUC-V.bcmap-BRvFq5yx.js +3 -0
  266. package/dist/lazy/Ext-H.bcmap-CNU3PCfs.js +3 -0
  267. package/dist/lazy/Ext-RKSJ-H.bcmap-T22CGXk4.js +3 -0
  268. package/dist/lazy/Ext-RKSJ-V.bcmap-K2DXeZ3P.js +3 -0
  269. package/dist/lazy/Ext-V.bcmap-3sNuPEfV.js +3 -0
  270. package/dist/lazy/FoxitDingbats.pfb-DVieKaw5.js +3 -0
  271. package/dist/lazy/FoxitFixed.pfb-Cxgpn9hN.js +3 -0
  272. package/dist/lazy/FoxitFixedBold.pfb-SBojmP3G.js +3 -0
  273. package/dist/lazy/FoxitFixedBoldItalic.pfb-DhsbZ2IP.js +3 -0
  274. package/dist/lazy/FoxitFixedItalic.pfb-Dm09mdyI.js +3 -0
  275. package/dist/lazy/FoxitSerif.pfb-DyMzSE_0.js +3 -0
  276. package/dist/lazy/FoxitSerifBold.pfb-DTzLt76W.js +3 -0
  277. package/dist/lazy/FoxitSerifBoldItalic.pfb-X3fHgghe.js +3 -0
  278. package/dist/lazy/FoxitSerifItalic.pfb-Nz1cnSKc.js +3 -0
  279. package/dist/lazy/FoxitSymbol.pfb-BL-rU8nS.js +3 -0
  280. package/dist/lazy/GB-EUC-H.bcmap-CsgH6-Rh.js +3 -0
  281. package/dist/lazy/GB-EUC-V.bcmap-DUouvrJu.js +3 -0
  282. package/dist/lazy/GB-H.bcmap-CuVli79K.js +3 -0
  283. package/dist/lazy/GB-V.bcmap-C3uPsDRC.js +3 -0
  284. package/dist/lazy/GBK-EUC-H.bcmap-BBDA5YUr.js +3 -0
  285. package/dist/lazy/GBK-EUC-V.bcmap-CjEpjWSW.js +3 -0
  286. package/dist/lazy/GBK2K-H.bcmap-DEJkj1gN.js +3 -0
  287. package/dist/lazy/GBK2K-V.bcmap-NYgNeNsu.js +3 -0
  288. package/dist/lazy/GBKp-EUC-H.bcmap-BIQuHkue.js +3 -0
  289. package/dist/lazy/GBKp-EUC-V.bcmap-BNBPmQ4v.js +3 -0
  290. package/dist/lazy/GBT-EUC-H.bcmap-D7OWs_0J.js +3 -0
  291. package/dist/lazy/GBT-EUC-V.bcmap-D_rNNyCu.js +3 -0
  292. package/dist/lazy/GBT-H.bcmap-B4SLNj_c.js +3 -0
  293. package/dist/lazy/GBT-V.bcmap-Cq6Niv8e.js +3 -0
  294. package/dist/lazy/GBTpc-EUC-H.bcmap-CX8SXrun.js +3 -0
  295. package/dist/lazy/GBTpc-EUC-V.bcmap-hM7BhuwC.js +3 -0
  296. package/dist/lazy/GBpc-EUC-H.bcmap-BIEXt7KG.js +3 -0
  297. package/dist/lazy/GBpc-EUC-V.bcmap-DWeqNOzl.js +3 -0
  298. package/dist/lazy/H.bcmap-DsMNeuh7.js +3 -0
  299. package/dist/lazy/HKdla-B5-H.bcmap-CI5u0d4T.js +3 -0
  300. package/dist/lazy/HKdla-B5-V.bcmap-yk9YM4CN.js +3 -0
  301. package/dist/lazy/HKdlb-B5-H.bcmap-DenLwP2C.js +3 -0
  302. package/dist/lazy/HKdlb-B5-V.bcmap-BKFxIrzq.js +3 -0
  303. package/dist/lazy/HKgccs-B5-H.bcmap-i607pEmt.js +3 -0
  304. package/dist/lazy/HKgccs-B5-V.bcmap-BA9Nvcnu.js +3 -0
  305. package/dist/lazy/HKm314-B5-H.bcmap-BamdAWrg.js +3 -0
  306. package/dist/lazy/HKm314-B5-V.bcmap-JIFeW7D_.js +3 -0
  307. package/dist/lazy/HKm471-B5-H.bcmap-CIOwD0zn.js +3 -0
  308. package/dist/lazy/HKm471-B5-V.bcmap-BkDoTPME.js +3 -0
  309. package/dist/lazy/HKscs-B5-H.bcmap--SdxOf4z.js +3 -0
  310. package/dist/lazy/HKscs-B5-V.bcmap-DmqMO-Th.js +3 -0
  311. package/dist/lazy/Hankaku.bcmap-B2fyvO8A.js +3 -0
  312. package/dist/lazy/Hiragana.bcmap-DP3YLVOE.js +3 -0
  313. package/dist/lazy/KSC-EUC-H.bcmap-DQ5YvjA7.js +3 -0
  314. package/dist/lazy/KSC-EUC-V.bcmap-BNvwGfQX.js +3 -0
  315. package/dist/lazy/KSC-H.bcmap-Ca-HYPS4.js +3 -0
  316. package/dist/lazy/KSC-Johab-H.bcmap-CfF2UvBc.js +3 -0
  317. package/dist/lazy/KSC-Johab-V.bcmap-LBN9I8dg.js +3 -0
  318. package/dist/lazy/KSC-V.bcmap-5U7FPho3.js +3 -0
  319. package/dist/lazy/KSCms-UHC-H.bcmap-CmoPtsRN.js +3 -0
  320. package/dist/lazy/KSCms-UHC-HW-H.bcmap-CVBsfTPV.js +3 -0
  321. package/dist/lazy/KSCms-UHC-HW-V.bcmap-Dv90XUw-.js +3 -0
  322. package/dist/lazy/KSCms-UHC-V.bcmap-BlaojGc1.js +3 -0
  323. package/dist/lazy/KSCpc-EUC-H.bcmap-FrupvwaV.js +3 -0
  324. package/dist/lazy/KSCpc-EUC-V.bcmap-MG3GiZE4.js +3 -0
  325. package/dist/lazy/Katakana.bcmap-C8Bmgyhi.js +3 -0
  326. package/dist/lazy/NWP-H.bcmap-CAdIwPDs.js +3 -0
  327. package/dist/lazy/NWP-V.bcmap-DJ8FpnB4.js +3 -0
  328. package/dist/lazy/RKSJ-H.bcmap-qGRAHcEF.js +3 -0
  329. package/dist/lazy/RKSJ-V.bcmap-Dg3ddxaN.js +3 -0
  330. package/dist/lazy/Roman.bcmap-D4SBc9em.js +3 -0
  331. package/dist/lazy/UniCNS-UCS2-H.bcmap-CAjdESaO.js +3 -0
  332. package/dist/lazy/UniCNS-UCS2-V.bcmap-BHZM4Vzw.js +3 -0
  333. package/dist/lazy/UniCNS-UTF16-H.bcmap-Cm4ZnlrX.js +3 -0
  334. package/dist/lazy/UniCNS-UTF16-V.bcmap-BP1BFVyb.js +3 -0
  335. package/dist/lazy/UniCNS-UTF32-H.bcmap-DGLG7zQ_.js +3 -0
  336. package/dist/lazy/UniCNS-UTF32-V.bcmap-C6v0CIVn.js +3 -0
  337. package/dist/lazy/UniCNS-UTF8-H.bcmap-97YD5l2o.js +3 -0
  338. package/dist/lazy/UniCNS-UTF8-V.bcmap-B_zdNm-u.js +3 -0
  339. package/dist/lazy/UniGB-UCS2-H.bcmap-BcioIbCK.js +3 -0
  340. package/dist/lazy/UniGB-UCS2-V.bcmap-Cu-XDS3_.js +3 -0
  341. package/dist/lazy/UniGB-UTF16-H.bcmap-DPDBbQj_.js +3 -0
  342. package/dist/lazy/UniGB-UTF16-V.bcmap-Bwwxp3b7.js +3 -0
  343. package/dist/lazy/UniGB-UTF32-H.bcmap-D-uBJmmw.js +3 -0
  344. package/dist/lazy/UniGB-UTF32-V.bcmap-CLe_N_q5.js +3 -0
  345. package/dist/lazy/UniGB-UTF8-H.bcmap-CadVYdlJ.js +3 -0
  346. package/dist/lazy/UniGB-UTF8-V.bcmap-B9mD6Kt7.js +3 -0
  347. package/dist/lazy/UniJIS-UCS2-H.bcmap-BaCSu9QA.js +3 -0
  348. package/dist/lazy/UniJIS-UCS2-HW-H.bcmap-CYQj9xSp.js +3 -0
  349. package/dist/lazy/UniJIS-UCS2-HW-V.bcmap-CDzIwh-J.js +3 -0
  350. package/dist/lazy/UniJIS-UCS2-V.bcmap-DqCxM_EZ.js +3 -0
  351. package/dist/lazy/UniJIS-UTF16-H.bcmap-9TPLuUCU.js +3 -0
  352. package/dist/lazy/UniJIS-UTF16-V.bcmap-D6-nIWTQ.js +3 -0
  353. package/dist/lazy/UniJIS-UTF32-H.bcmap-CzmUWSLA.js +3 -0
  354. package/dist/lazy/UniJIS-UTF32-V.bcmap--KhJJEJE.js +3 -0
  355. package/dist/lazy/UniJIS-UTF8-H.bcmap-BwrhFSFd.js +3 -0
  356. package/dist/lazy/UniJIS-UTF8-V.bcmap-DGwbFkaL.js +3 -0
  357. package/dist/lazy/UniJIS2004-UTF16-H.bcmap-CdsS_d3_.js +3 -0
  358. package/dist/lazy/UniJIS2004-UTF16-V.bcmap-BnlV29Vf.js +3 -0
  359. package/dist/lazy/UniJIS2004-UTF32-H.bcmap-DSULVyIs.js +3 -0
  360. package/dist/lazy/UniJIS2004-UTF32-V.bcmap-CzBB970E.js +3 -0
  361. package/dist/lazy/UniJIS2004-UTF8-H.bcmap-BBuoGqhC.js +3 -0
  362. package/dist/lazy/UniJIS2004-UTF8-V.bcmap-dXgQhdTV.js +3 -0
  363. package/dist/lazy/UniJISPro-UCS2-HW-V.bcmap-ePVViljk.js +3 -0
  364. package/dist/lazy/UniJISPro-UCS2-V.bcmap-b2Oljrl4.js +3 -0
  365. package/dist/lazy/UniJISPro-UTF8-V.bcmap-CbPXe9gt.js +3 -0
  366. package/dist/lazy/UniJISX0213-UTF32-H.bcmap-Blmknifg.js +3 -0
  367. package/dist/lazy/UniJISX0213-UTF32-V.bcmap-Dtggmq9y.js +3 -0
  368. package/dist/lazy/UniJISX02132004-UTF32-H.bcmap-3YBd8tyQ.js +3 -0
  369. package/dist/lazy/UniJISX02132004-UTF32-V.bcmap-B8VdB9qS.js +3 -0
  370. package/dist/lazy/UniKS-UCS2-H.bcmap-CIhkpKgh.js +3 -0
  371. package/dist/lazy/UniKS-UCS2-V.bcmap-Cg-GDuqq.js +3 -0
  372. package/dist/lazy/UniKS-UTF16-H.bcmap-EZHb2IFq.js +3 -0
  373. package/dist/lazy/UniKS-UTF16-V.bcmap-BhqhAhYP.js +3 -0
  374. package/dist/lazy/UniKS-UTF32-H.bcmap-Cgay0dIp.js +3 -0
  375. package/dist/lazy/UniKS-UTF32-V.bcmap-DYXyatLV.js +3 -0
  376. package/dist/lazy/UniKS-UTF8-H.bcmap-BvHYimUT.js +3 -0
  377. package/dist/lazy/UniKS-UTF8-V.bcmap-DStcP2w0.js +3 -0
  378. package/dist/lazy/V.bcmap-DuWGSyNm.js +3 -0
  379. package/dist/lazy/WP-Symbol.bcmap-GltcyRl-.js +3 -0
  380. package/dist/lazy/_virtual_hm-pdfjs-data-BSzhlxyq.js +194 -0
  381. package/dist/lazy/jbig2.wasm-CUnHTdWi.js +3 -0
  382. package/dist/lazy/openjpeg.wasm-bdyxAnqz.js +3 -0
  383. package/dist/lazy/processing-worker-DU8GEYFs.js +30 -0
  384. package/dist/lazy/processing-worker-DU8GEYFs.js.map +1 -0
  385. package/dist/lazy/render-worker-WgnZ-czI.js +30 -0
  386. package/dist/lazy/render-worker-WgnZ-czI.js.map +1 -0
  387. package/dist/lazy/runtime-G4hlayVF.js +22652 -0
  388. package/dist/lazy/runtime-G4hlayVF.js.map +1 -0
  389. package/dist/react.d.ts +1587 -0
  390. package/dist/react.js +1157 -0
  391. package/dist/react.js.map +1 -0
  392. package/dist/shared/en-BYB_GHqG.js +1265 -0
  393. package/dist/shared/en-BYB_GHqG.js.map +1 -0
  394. package/dist/styles.css +337 -0
  395. package/package.json +111 -3
@@ -0,0 +1,1265 @@
1
+ import { SdkError, checkFile, coreLimits, createErrorHelpers, createWorkerClient, defineLimits, defineMessages, isSdkError, plural, resolveAssetsBase, sdkCoreMessages, withProcessingTime } from "@hussmartinez/sdk-core";
2
+ // src/core/errors/pdf-error.ts
3
+ var PdfError = class extends SdkError {
4
+ name = "PdfError";
5
+ };
6
+ function isPdfError(value, code) {
7
+ return isSdkError(value, code) && value.name === "PdfError";
8
+ }
9
+ // src/core/errors/abort.ts
10
+ var helpers = /* @__PURE__ */ createErrorHelpers(PdfError, {
11
+ fallbackCode: "PROCESSING_FAILED",
12
+ fallbackMessage: "PDF processing failed."
13
+ });
14
+ var asPdfError = helpers.adapt;
15
+ var abortError = helpers.abortError;
16
+ var throwIfAborted = helpers.throwIfAborted;
17
+ // src/core/errors/pdf-limits.ts
18
+ var pdfLimitDefinitions = {
19
+ ...coreLimits,
20
+ maxPages: {
21
+ code: "TOO_MANY_PAGES",
22
+ unit: "count",
23
+ default: 5e3,
24
+ warning: 1e3
25
+ },
26
+ maxSessionSize: {
27
+ code: "SESSION_TOO_LARGE",
28
+ unit: "bytes",
29
+ default: 3e8,
30
+ warning: 15e7
31
+ },
32
+ maxImagePixels: {
33
+ code: "IMAGE_TOO_LARGE",
34
+ unit: "pixels",
35
+ default: 1e8
36
+ }
37
+ };
38
+ var pdfLimits = /* @__PURE__ */ defineLimits(pdfLimitDefinitions, { errorClass: PdfError });
39
+ // src/core/model/bytes.ts
40
+ function copyBytes(source) {
41
+ const view = source instanceof Uint8Array ? source : new Uint8Array(source);
42
+ return new Uint8Array(view);
43
+ }
44
+ function assertPageIndex(pageIndex, pageCount) {
45
+ if (!Number.isInteger(pageIndex) || pageIndex < 0 || pageIndex >= pageCount) throw new RangeError(`Page index ${pageIndex} is outside the document, which has ${pageCount} pages.`);
46
+ }
47
+ // src/core/model/geometry.ts
48
+ function addRotation(rotation, angle) {
49
+ if (!Number.isInteger(angle) || angle % 90 !== 0) throw new RangeError(`A rotation must be a multiple of 90 degrees, received ${angle}.`);
50
+ return ((rotation + angle) % 360 + 360) % 360;
51
+ }
52
+ // src/core/model/links.ts
53
+ var SAFE_PROTOCOLS = /* @__PURE__ */ new Set([
54
+ "http:",
55
+ "https:",
56
+ "mailto:"
57
+ ]);
58
+ function safeLinkUrl(url) {
59
+ if (typeof url !== "string" || url.length > 2048) return void 0;
60
+ let parsed;
61
+ try {
62
+ parsed = new URL(url);
63
+ } catch {
64
+ return;
65
+ }
66
+ if (!SAFE_PROTOCOLS.has(parsed.protocol)) return void 0;
67
+ if (parsed.username !== "" || parsed.password !== "") return void 0;
68
+ return parsed.href;
69
+ }
70
+ function linkDestination(url) {
71
+ const safe = safeLinkUrl(url);
72
+ if (!safe) return void 0;
73
+ const parsed = new URL(safe);
74
+ if (parsed.protocol === "mailto:") return decodeURIComponent(parsed.pathname) || void 0;
75
+ return parsed.hostname.replace(/^www\./, "");
76
+ }
77
+ // src/core/ports/pdf-engine.ts
78
+ var PDF_MAX_CANVAS_PIXELS = 16777216;
79
+ // src/adapters/pdfjs/binary-data.ts
80
+ var NO_NETWORK_URL = "hm-pdf-no-network:/";
81
+ function decodeBase64(base64) {
82
+ const binary = atob(base64);
83
+ const bytes = new Uint8Array(binary.length);
84
+ for (let index = 0; index < binary.length; index += 1) bytes[index] = binary.charCodeAt(index);
85
+ return bytes;
86
+ }
87
+ function createInlineDataFactory(listener) {
88
+ return class InlineDataFactory {
89
+ async fetch({ kind, filename }) {
90
+ listener?.(kind, filename);
91
+ const { pdfJsData } = await import("../lazy/_virtual_hm-pdfjs-data-BSzhlxyq.js");
92
+ const files = Object.hasOwn(pdfJsData, kind) ? pdfJsData[kind] : void 0;
93
+ const load = files && Object.hasOwn(files, filename) ? files[filename] : void 0;
94
+ if (!load) throw new Error(`The PDF SDK doesn't serve ${kind} data named ${filename}.`);
95
+ return decodeBase64(await load());
96
+ }
97
+ };
98
+ }
99
+ // src/adapters/pdfjs/errors.ts
100
+ var INVALID = /* @__PURE__ */ new Set([
101
+ "InvalidPDFException",
102
+ "FormatError",
103
+ "MissingPDFException"
104
+ ]);
105
+ function fromPdfJsError(reason, message) {
106
+ if (isPdfError(reason) || reason instanceof RangeError) return reason;
107
+ const name = typeof reason === "object" && reason !== null ? reason.name : void 0;
108
+ if (name === "PasswordException") return new PdfError("PASSWORD_REQUIRED", "The PDF is encrypted.", { cause: reason });
109
+ if (name !== void 0 && INVALID.has(name)) return new PdfError("INVALID_PDF", "The file isn't a readable PDF.", { cause: reason });
110
+ return new PdfError("PROCESSING_FAILED", message, { cause: reason });
111
+ }
112
+ // src/adapters/pdfjs/pdfjs-engine.ts
113
+ function toPageRect(viewport, box) {
114
+ const [x1 = 0, y1 = 0, x2 = 0, y2 = 0] = box;
115
+ const [ax = 0, ay = 0] = viewport.convertToViewportPoint(x1, y1);
116
+ const [bx = 0, by = 0] = viewport.convertToViewportPoint(x2, y2);
117
+ const left = clamp(Math.min(ax, bx) / viewport.width);
118
+ const top = clamp(Math.min(ay, by) / viewport.height);
119
+ return {
120
+ x: left,
121
+ y: top,
122
+ width: clamp(Math.max(ax, bx) / viewport.width) - left,
123
+ height: clamp(Math.max(ay, by) / viewport.height) - top
124
+ };
125
+ }
126
+ var CANCEL_TIMEOUT = 1e3;
127
+ function createPdfJsEngine(options = {}) {
128
+ return new PdfJsEngine(options);
129
+ }
130
+ var WorkerHost = class {
131
+ pdfWorker;
132
+ #worker;
133
+ #waiting = /* @__PURE__ */ new Set();
134
+ #failure;
135
+ constructor(worker, pdfWorker) {
136
+ this.#worker = worker;
137
+ this.pdfWorker = pdfWorker;
138
+ const crash = (event) => {
139
+ event.preventDefault();
140
+ this.fail(new PdfError("WORKER_CRASHED", "The PDF render worker failed."));
141
+ };
142
+ worker.addEventListener("error", crash);
143
+ worker.addEventListener("messageerror", crash);
144
+ }
145
+ get failure() {
146
+ return this.#failure;
147
+ }
148
+ watch(reject) {
149
+ if (this.#failure) {
150
+ reject(this.#failure);
151
+ return () => {};
152
+ }
153
+ this.#waiting.add(reject);
154
+ return () => this.#waiting.delete(reject);
155
+ }
156
+ fail(error) {
157
+ if (this.#failure) return;
158
+ this.#failure = error;
159
+ this.#worker.terminate();
160
+ this.pdfWorker.destroy();
161
+ for (const reject of this.#waiting) reject(error);
162
+ this.#waiting.clear();
163
+ }
164
+ };
165
+ function settle(host, promise, options) {
166
+ const { signal } = options;
167
+ return new Promise((resolve, reject) => {
168
+ if (signal?.aborted) {
169
+ options.onAbort?.();
170
+ reject(abortError(signal));
171
+ return;
172
+ }
173
+ const abort = () => {
174
+ options.onAbort?.();
175
+ reject(abortError(signal));
176
+ };
177
+ signal?.addEventListener("abort", abort, { once: true });
178
+ const unwatch = host.watch(reject);
179
+ promise.then(resolve, (reason) => reject(fromPdfJsError(reason, options.message)));
180
+ promise.catch(() => {}).finally(() => {
181
+ signal?.removeEventListener("abort", abort);
182
+ unwatch();
183
+ });
184
+ });
185
+ }
186
+ var VERSION_MISMATCH = /The API version "([^"]+)" does not match the Worker version "([^"]+)"/;
187
+ function workerVersionMismatch(error, base) {
188
+ for (let reason = error; reason instanceof Error; reason = reason.cause) {
189
+ const match = VERSION_MISMATCH.exec(reason.message);
190
+ if (match) return new PdfError("WORKER_START_FAILED", "The PDF render worker is another version.", {
191
+ details: {
192
+ asset: base === void 0 ? null : `${base}build/pdf.worker.min.mjs`,
193
+ expected: match[1] ?? null,
194
+ actual: match[2] ?? null
195
+ },
196
+ cause: error
197
+ });
198
+ }
199
+ }
200
+ function takeBytes(source, transfer) {
201
+ if (transfer) {
202
+ const view = source instanceof Uint8Array ? source : new Uint8Array(source);
203
+ if (view.byteOffset === 0 && view.byteLength === view.buffer.byteLength && view.buffer instanceof ArrayBuffer) return view;
204
+ }
205
+ return copyBytes(source);
206
+ }
207
+ function normalizeRotation(rotation) {
208
+ return addRotation(0, Number.isInteger(rotation) && rotation % 90 === 0 ? rotation : 0);
209
+ }
210
+ var clamp = (value) => Math.min(1, Math.max(0, value));
211
+ var PdfJsEngine = class {
212
+ #options;
213
+ #pdfJsBase;
214
+ #runtime;
215
+ #host;
216
+ #documents = /* @__PURE__ */ new Set();
217
+ #destroyed = false;
218
+ constructor(options) {
219
+ this.#options = options;
220
+ this.#pdfJsBase = options.assetsUrl === void 0 ? void 0 : `${resolveAssetsBase(options.assetsUrl)}pdfjs/`;
221
+ }
222
+ async open(source, options = {}) {
223
+ if (this.#destroyed) throw new PdfError("WORKER_TERMINATED", "The PDF engine was destroyed.");
224
+ throwIfAborted(options.signal);
225
+ const data = takeBytes(source, options.transfer);
226
+ this.#runtime ??= import("../lazy/runtime-G4hlayVF.js").then((module) => module.pdfjs);
227
+ const pdfjs = await this.#runtime;
228
+ throwIfAborted(options.signal);
229
+ const host = await this.#ensureHost(pdfjs);
230
+ const base = this.#assetsBase();
231
+ const task = pdfjs.getDocument({
232
+ data,
233
+ worker: host.pdfWorker,
234
+ enableXfa: false,
235
+ maxImageSize: this.#options.maxImagePixels ?? pdfLimitDefinitions.maxImagePixels.default,
236
+ stopAtErrors: false,
237
+ verbosity: pdfjs.VerbosityLevel.ERRORS,
238
+ useWasm: true,
239
+ ...base ? {
240
+ useWorkerFetch: true,
241
+ cMapUrl: `${base}cmaps/`,
242
+ standardFontDataUrl: `${base}standard_fonts/`,
243
+ wasmUrl: `${base}wasm/`,
244
+ iccUrl: `${base}iccs/`
245
+ } : {
246
+ useWorkerFetch: false,
247
+ BinaryDataFactory: createInlineDataFactory(this.#options._onDataRequest),
248
+ wasmUrl: NO_NETWORK_URL
249
+ }
250
+ });
251
+ try {
252
+ const document = new PdfJsDocument(pdfjs, await settle(host, task.promise, {
253
+ signal: options.signal,
254
+ onAbort: () => this.#cancel(task, host),
255
+ message: "The PDF couldn't be opened."
256
+ }), task, host, () => this.#documents.delete(document));
257
+ this.#documents.add(document);
258
+ return document;
259
+ } catch (error) {
260
+ task.destroy().catch(() => {});
261
+ const mismatch = workerVersionMismatch(error, base);
262
+ if (mismatch) {
263
+ host.fail(mismatch);
264
+ throw mismatch;
265
+ }
266
+ throw error;
267
+ }
268
+ }
269
+ async destroy() {
270
+ if (this.#destroyed) return;
271
+ this.#destroyed = true;
272
+ await Promise.all([...this.#documents].map((document) => document.destroy()));
273
+ this.#host?.fail(new PdfError("WORKER_TERMINATED", "The PDF engine was destroyed."));
274
+ this.#host = void 0;
275
+ }
276
+ async #ensureHost(pdfjs) {
277
+ if (this.#host && !this.#host.failure) return this.#host;
278
+ let worker;
279
+ try {
280
+ const base = this.#assetsBase();
281
+ worker = base ? new Worker(`${base}build/pdf.worker.min.mjs`, {
282
+ type: "module",
283
+ name: "hm-pdf-render"
284
+ }) : (await import("../lazy/render-worker-WgnZ-czI.js")).createInlineWorker();
285
+ } catch (cause) {
286
+ throw new PdfError("WORKER_START_FAILED", "The PDF render worker couldn't start.", { cause });
287
+ }
288
+ this.#host = new WorkerHost(worker, pdfjs.PDFWorker.create({ port: worker }));
289
+ return this.#host;
290
+ }
291
+ #assetsBase() {
292
+ return this.#pdfJsBase;
293
+ }
294
+ #cancel(task, host) {
295
+ const timer = setTimeout(() => host.fail(new PdfError("WORKER_TERMINATED", "The worker was stopped to cancel an operation.")), CANCEL_TIMEOUT);
296
+ task.destroy().catch(() => {}).finally(() => clearTimeout(timer));
297
+ }
298
+ };
299
+ var PdfJsDocument = class {
300
+ pageCount;
301
+ #pdfjs;
302
+ #proxy;
303
+ #task;
304
+ #host;
305
+ #onDestroy;
306
+ #destroyed = false;
307
+ constructor(pdfjs, proxy, task, host, onDestroy) {
308
+ this.#pdfjs = pdfjs;
309
+ this.#proxy = proxy;
310
+ this.#task = task;
311
+ this.#host = host;
312
+ this.#onDestroy = onDestroy;
313
+ this.pageCount = proxy.numPages;
314
+ }
315
+ async getPage(pageIndex, options = {}) {
316
+ const page = await this.#page(pageIndex, options);
317
+ const { width, height } = page.getViewport({
318
+ scale: 1,
319
+ rotation: 0
320
+ });
321
+ return {
322
+ width,
323
+ height,
324
+ rotation: normalizeRotation(page.rotate)
325
+ };
326
+ }
327
+ async renderPage(pageIndex, canvas, options) {
328
+ if (!(options.scale > 0) || !Number.isFinite(options.scale)) throw new RangeError(`The render scale must be a positive number, received ${options.scale}.`);
329
+ const page = await this.#page(pageIndex, options);
330
+ const rotation = addRotation(normalizeRotation(page.rotate), options.rotation ?? 0);
331
+ const viewport = page.getViewport({
332
+ scale: options.scale,
333
+ rotation
334
+ });
335
+ const area = viewport.width * viewport.height;
336
+ const wanted = Math.max(options.pixelRatio ?? 1, Number.MIN_VALUE);
337
+ const ratio = Math.min(wanted, Math.sqrt(PDF_MAX_CANVAS_PIXELS / Math.max(area, 1)));
338
+ canvas.width = Math.max(1, Math.floor(viewport.width * ratio));
339
+ canvas.height = Math.max(1, Math.floor(viewport.height * ratio));
340
+ canvas.style.width = `${viewport.width}px`;
341
+ canvas.style.height = `${viewport.height}px`;
342
+ const context = canvas.getContext("2d", { alpha: false });
343
+ if (!context) throw new PdfError("UNSUPPORTED_ENVIRONMENT", "The browser can't draw on a canvas.", { details: { feature: "CanvasRenderingContext2D" } });
344
+ const task = page.render({
345
+ canvas,
346
+ canvasContext: context,
347
+ viewport,
348
+ transform: [
349
+ canvas.width / viewport.width,
350
+ 0,
351
+ 0,
352
+ canvas.height / viewport.height,
353
+ 0,
354
+ 0
355
+ ],
356
+ annotationMode: this.#pdfjs.AnnotationMode.ENABLE
357
+ });
358
+ try {
359
+ await settle(this.#host, task.promise, {
360
+ signal: options.signal,
361
+ onAbort: () => task.cancel(),
362
+ message: "The page couldn't be drawn."
363
+ });
364
+ } finally {
365
+ page.cleanup();
366
+ }
367
+ }
368
+ async getTextContent(pageIndex, options = {}) {
369
+ const page = await this.#page(pageIndex, options);
370
+ const content = await settle(this.#host, page.getTextContent(), {
371
+ signal: options.signal,
372
+ message: "The page's text couldn't be read."
373
+ });
374
+ const viewport = page.getViewport({
375
+ scale: 1,
376
+ rotation: 0
377
+ });
378
+ const items = [];
379
+ for (const item of content.items) {
380
+ if (!("str" in item)) continue;
381
+ const { str, transform, width, hasEOL } = item;
382
+ const [a = 1, b = 0, c = 0, d = 1, e = 0, f = 0] = transform;
383
+ const fontHeight = Math.hypot(c, d);
384
+ items.push({
385
+ text: str,
386
+ rect: toPageRect(viewport, [
387
+ e,
388
+ f,
389
+ e + width,
390
+ f + fontHeight
391
+ ]),
392
+ angle: Math.atan2(b, a) * 180 / Math.PI,
393
+ endOfLine: hasEOL
394
+ });
395
+ }
396
+ return { items };
397
+ }
398
+ async getFormFields(pageIndex, options = {}) {
399
+ const page = await this.#page(pageIndex, options);
400
+ const annotations = await settle(this.#host, page.getAnnotations({ intent: "display" }), {
401
+ signal: options.signal,
402
+ message: "The page's form fields couldn't be read."
403
+ });
404
+ const viewport = page.getViewport({
405
+ scale: 1,
406
+ rotation: 0
407
+ });
408
+ const fields = /* @__PURE__ */ new Map();
409
+ for (const annotation of annotations) {
410
+ const name = annotation["fieldName"];
411
+ if (annotation["subtype"] !== "Widget" || typeof name !== "string" || fields.has(name)) continue;
412
+ const value = annotation["fieldValue"];
413
+ const type = annotation["fieldType"] === "Tx" ? "text" : annotation["fieldType"] === "Btn" && annotation["checkBox"] ? "checkbox" : void 0;
414
+ if (!type) continue;
415
+ fields.set(name, {
416
+ name,
417
+ type,
418
+ rect: toPageRect(viewport, annotation["rect"]),
419
+ value: type === "text" ? typeof value === "string" ? value : "" : typeof value === "string" && value !== "" && value !== "Off",
420
+ readOnly: annotation["readOnly"] === true
421
+ });
422
+ }
423
+ return [...fields.values()];
424
+ }
425
+ async getLinks(pageIndex, options = {}) {
426
+ const page = await this.#page(pageIndex, options);
427
+ const annotations = await settle(this.#host, page.getAnnotations({ intent: "display" }), {
428
+ signal: options.signal,
429
+ message: "The page's links couldn't be read."
430
+ });
431
+ const viewport = page.getViewport({
432
+ scale: 1,
433
+ rotation: 0
434
+ });
435
+ const links = [];
436
+ for (const annotation of annotations) {
437
+ if (annotation["subtype"] !== "Link" || typeof annotation["url"] !== "string") continue;
438
+ const url = safeLinkUrl(annotation["url"]);
439
+ if (url) links.push({
440
+ rect: toPageRect(viewport, annotation["rect"]),
441
+ url
442
+ });
443
+ }
444
+ return links;
445
+ }
446
+ async destroy() {
447
+ if (this.#destroyed) return;
448
+ this.#destroyed = true;
449
+ this.#onDestroy();
450
+ await this.#task.destroy().catch(() => {});
451
+ }
452
+ async #page(pageIndex, options) {
453
+ if (this.#destroyed) throw new PdfError("WORKER_TERMINATED", "The document was destroyed.");
454
+ assertPageIndex(pageIndex, this.pageCount);
455
+ throwIfAborted(options.signal);
456
+ return settle(this.#host, this.#proxy.getPage(pageIndex + 1), {
457
+ signal: options.signal,
458
+ message: "The page couldn't be read."
459
+ });
460
+ }
461
+ };
462
+ // src/adapters/qpdf/qpdf-processor.ts
463
+ function createPdfProcessor(options = {}) {
464
+ const base = options.assetsUrl === void 0 ? void 0 : resolveAssetsBase(options.assetsUrl);
465
+ let client;
466
+ let destroyed = false;
467
+ const start = () => {
468
+ client ??= createWorkerClient({
469
+ createWorker: () => {
470
+ if (base) return new Worker(`${base}processing/processing.worker.js`, {
471
+ type: "module",
472
+ name: "hm-pdf-processing"
473
+ });
474
+ if (!inlineWorker) throw new PdfError("WORKER_START_FAILED", "The processing worker hasn't loaded.");
475
+ return inlineWorker();
476
+ },
477
+ errorClasses: { PdfError },
478
+ packageVersion: "0.2.0",
479
+ ...base ? { workerAsset: `${base}processing/processing.worker.js` } : {}
480
+ });
481
+ return client;
482
+ };
483
+ let inlineWorker;
484
+ return {
485
+ async build(job, options = {}) {
486
+ if (destroyed) throw new PdfError("WORKER_TERMINATED", "The PDF processor was destroyed.");
487
+ if (!base) inlineWorker ??= (await import("../lazy/processing-worker-DU8GEYFs.js")).createInlineWorker;
488
+ let outcome;
489
+ try {
490
+ outcome = await start().call("build", job, {
491
+ ...options.signal ? { signal: options.signal } : {},
492
+ ...options.onProgress ? { onProgress: options.onProgress } : {},
493
+ ...options.transfer ? { transfer: true } : {}
494
+ });
495
+ } catch (error) {
496
+ throw asPdfError(error, "The PDF couldn't be built.");
497
+ }
498
+ if (!outcome.ok) throw outcome.error === "RangeError" ? new RangeError(outcome.message) : new TypeError(outcome.message);
499
+ return outcome.bytes;
500
+ },
501
+ async destroy() {
502
+ destroyed = true;
503
+ client?.destroy();
504
+ client = void 0;
505
+ }
506
+ };
507
+ }
508
+ // src/core/model/plan.ts
509
+ var EMPTY_PLAN = Object.freeze({
510
+ pages: Object.freeze([]),
511
+ formValues: Object.freeze({})
512
+ });
513
+ // src/core/operations/commands.ts
514
+ function positions(plan, keys) {
515
+ if (keys.length === 0) throw new TypeError("A command needs at least one page.");
516
+ const wanted = new Set(keys);
517
+ if (wanted.size !== keys.length) throw new TypeError("A page appears twice in the command.");
518
+ const found = plan.pages.flatMap((page, index) => wanted.has(page.key) ? [index] : []);
519
+ if (found.length !== wanted.size) {
520
+ const known = new Set(plan.pages.map((page) => page.key));
521
+ const missing = keys.filter((key) => !known.has(key));
522
+ throw new TypeError(`The plan has no page ${missing.join(", ")}.`);
523
+ }
524
+ return found;
525
+ }
526
+ function withPages(plan, pages) {
527
+ return {
528
+ pages,
529
+ formValues: plan.formValues
530
+ };
531
+ }
532
+ function updatePage(plan, key, update) {
533
+ const [index] = positions(plan, [key]);
534
+ const pages = [...plan.pages];
535
+ pages[index] = update(plan.pages[index]);
536
+ return withPages(plan, pages);
537
+ }
538
+ function applyCommand(plan, command) {
539
+ switch (command.type) {
540
+ case "pdf.rotatePages": {
541
+ const at = new Set(positions(plan, command.pages));
542
+ addRotation(0, command.angle);
543
+ return {
544
+ plan: withPages(plan, plan.pages.map((page, index) => at.has(index) ? {
545
+ ...page,
546
+ rotation: addRotation(page.rotation, command.angle)
547
+ } : page)),
548
+ inverse: {
549
+ type: "pdf.rotatePages",
550
+ pages: command.pages,
551
+ angle: -command.angle
552
+ }
553
+ };
554
+ }
555
+ case "pdf.deletePages": {
556
+ const at = positions(plan, command.pages);
557
+ if (at.length === plan.pages.length) throw new RangeError("A document needs at least one page.");
558
+ const removed = new Set(at);
559
+ return {
560
+ plan: withPages(plan, plan.pages.filter((_, index) => !removed.has(index))),
561
+ inverse: {
562
+ type: "pdf.restorePages",
563
+ entries: at.map((index) => ({
564
+ index,
565
+ page: plan.pages[index]
566
+ }))
567
+ }
568
+ };
569
+ }
570
+ case "pdf.restorePages": {
571
+ const known = new Set(plan.pages.map((page) => page.key));
572
+ const pages = [...plan.pages];
573
+ let previous = -1;
574
+ for (const { index, page } of command.entries) {
575
+ if (known.has(page.key)) throw new TypeError(`The plan already has page ${page.key}.`);
576
+ if (!Number.isInteger(index) || index <= previous || index > pages.length) throw new RangeError(`Page ${page.key} can't be restored at position ${index}.`);
577
+ pages.splice(index, 0, page);
578
+ known.add(page.key);
579
+ previous = index;
580
+ }
581
+ if (command.entries.length === 0) throw new TypeError("A command needs at least one page.");
582
+ return {
583
+ plan: withPages(plan, pages),
584
+ inverse: {
585
+ type: "pdf.deletePages",
586
+ pages: command.entries.map(({ page }) => page.key)
587
+ }
588
+ };
589
+ }
590
+ case "pdf.movePages": {
591
+ const moved = new Set(positions(plan, command.pages));
592
+ const block = plan.pages.filter((_, index) => moved.has(index));
593
+ const rest = plan.pages.filter((_, index) => !moved.has(index));
594
+ if (!Number.isInteger(command.to) || command.to < 0 || command.to > rest.length) throw new RangeError(`Pages can't be moved to position ${command.to}.`);
595
+ return {
596
+ plan: withPages(plan, [
597
+ ...rest.slice(0, command.to),
598
+ ...block,
599
+ ...rest.slice(command.to)
600
+ ]),
601
+ inverse: {
602
+ type: "pdf.reorderPages",
603
+ order: plan.pages.map((page) => page.key)
604
+ }
605
+ };
606
+ }
607
+ case "pdf.reorderPages": {
608
+ const byKey = new Map(plan.pages.map((page) => [page.key, page]));
609
+ if (command.order.length !== plan.pages.length || new Set(command.order).size !== command.order.length || command.order.some((key) => !byKey.has(key))) throw new TypeError("A new order must list every page of the plan exactly once.");
610
+ return {
611
+ plan: withPages(plan, command.order.map((key) => byKey.get(key))),
612
+ inverse: {
613
+ type: "pdf.reorderPages",
614
+ order: plan.pages.map((page) => page.key)
615
+ }
616
+ };
617
+ }
618
+ case "pdf.insertPages": {
619
+ const { pageIndexes, keys, at } = command;
620
+ if (pageIndexes.length === 0 || keys.length !== pageIndexes.length) throw new TypeError("An insert needs one key for each of at least one page.");
621
+ if (!Number.isInteger(at) || at < 0 || at > plan.pages.length) throw new RangeError(`Pages can't be inserted at position ${at}.`);
622
+ const known = new Set(plan.pages.map((page) => page.key));
623
+ if (new Set(keys).size !== keys.length || keys.some((key) => known.has(key))) throw new TypeError("Inserted pages need keys the plan doesn't have.");
624
+ const inserted = pageIndexes.map((pageIndex, index) => ({
625
+ key: keys[index],
626
+ source: command.source,
627
+ pageIndex,
628
+ rotation: 0,
629
+ annotations: []
630
+ }));
631
+ return {
632
+ plan: withPages(plan, [
633
+ ...plan.pages.slice(0, at),
634
+ ...inserted,
635
+ ...plan.pages.slice(at)
636
+ ]),
637
+ inverse: {
638
+ type: "pdf.deletePages",
639
+ pages: keys
640
+ }
641
+ };
642
+ }
643
+ case "pdf.setFieldValue": {
644
+ const { source, field, value } = command;
645
+ const current = plan.formValues[source] ?? {};
646
+ const previous = Object.hasOwn(current, field) ? current[field] : null;
647
+ const next = { ...current };
648
+ if (value === null) delete next[field];
649
+ else next[field] = value;
650
+ const formValues = {
651
+ ...plan.formValues,
652
+ [source]: next
653
+ };
654
+ if (Object.keys(next).length === 0) delete formValues[source];
655
+ return {
656
+ plan: {
657
+ pages: plan.pages,
658
+ formValues
659
+ },
660
+ inverse: {
661
+ type: "pdf.setFieldValue",
662
+ source,
663
+ field,
664
+ value: previous
665
+ }
666
+ };
667
+ }
668
+ case "pdf.addAnnotation": {
669
+ const { annotation } = command;
670
+ return {
671
+ plan: updatePage(plan, command.page, (page) => {
672
+ if (page.annotations.some((existing) => existing.id === annotation.id)) throw new TypeError(`Page ${page.key} already has annotation ${annotation.id}.`);
673
+ const index = command.index ?? page.annotations.length;
674
+ if (!Number.isInteger(index) || index < 0 || index > page.annotations.length) throw new RangeError(`The annotation can't go at position ${index}.`);
675
+ const annotations = [...page.annotations];
676
+ annotations.splice(index, 0, annotation);
677
+ return {
678
+ ...page,
679
+ annotations
680
+ };
681
+ }),
682
+ inverse: {
683
+ type: "pdf.removeAnnotation",
684
+ page: command.page,
685
+ id: annotation.id
686
+ }
687
+ };
688
+ }
689
+ case "pdf.removeAnnotation": {
690
+ let removed;
691
+ const next = updatePage(plan, command.page, (page) => {
692
+ const index = page.annotations.findIndex((annotation) => annotation.id === command.id);
693
+ if (index < 0) throw new TypeError(`Page ${page.key} has no annotation ${command.id}.`);
694
+ removed = {
695
+ annotation: page.annotations[index],
696
+ index
697
+ };
698
+ return {
699
+ ...page,
700
+ annotations: page.annotations.filter((_, at) => at !== index)
701
+ };
702
+ });
703
+ const { annotation, index } = removed;
704
+ return {
705
+ plan: next,
706
+ inverse: {
707
+ type: "pdf.addAnnotation",
708
+ page: command.page,
709
+ annotation,
710
+ index
711
+ }
712
+ };
713
+ }
714
+ default: throw new TypeError(`Unknown command ${command.type}.`);
715
+ }
716
+ }
717
+ function applyCommands(plan, commands) {
718
+ let current = plan;
719
+ const inverses = [];
720
+ for (const command of commands) {
721
+ const applied = applyCommand(current, command);
722
+ current = applied.plan;
723
+ inverses.unshift(applied.inverse);
724
+ }
725
+ return {
726
+ plan: current,
727
+ inverses
728
+ };
729
+ }
730
+ // src/core/session/history.ts
731
+ var History = class {
732
+ #past = [];
733
+ #future = [];
734
+ #trimmed = false;
735
+ get canUndo() {
736
+ return this.#past.length > 0;
737
+ }
738
+ get canRedo() {
739
+ return this.#future.length > 0;
740
+ }
741
+ get trimmed() {
742
+ return this.#trimmed;
743
+ }
744
+ get steps() {
745
+ return [...this.#past, ...this.#future];
746
+ }
747
+ get dropOrder() {
748
+ return [...this.#future, ...this.#past];
749
+ }
750
+ push(step) {
751
+ this.#past.push(step);
752
+ this.#future = [];
753
+ }
754
+ undo() {
755
+ const step = this.#past.pop();
756
+ if (step) this.#future.push(step);
757
+ return step;
758
+ }
759
+ redo() {
760
+ const step = this.#future.pop();
761
+ if (step) this.#past.push(step);
762
+ return step;
763
+ }
764
+ restore(direction) {
765
+ if (direction === "undo") {
766
+ const step = this.#future.pop();
767
+ if (step) this.#past.push(step);
768
+ } else {
769
+ const step = this.#past.pop();
770
+ if (step) this.#future.push(step);
771
+ }
772
+ }
773
+ drop(count) {
774
+ if (count <= 0) return;
775
+ const fromFuture = Math.min(count, this.#future.length);
776
+ this.#future.splice(0, fromFuture);
777
+ this.#past.splice(0, count - fromFuture);
778
+ this.#trimmed = true;
779
+ }
780
+ clear() {
781
+ this.#past = [];
782
+ this.#future = [];
783
+ this.#trimmed = false;
784
+ }
785
+ };
786
+ // src/core/session/session.ts
787
+ function createPdfSession(options) {
788
+ const { engine } = options;
789
+ const policy = pdfLimits.resolve(options.filePolicy);
790
+ const history = new History();
791
+ const listeners = /* @__PURE__ */ new Set();
792
+ const sources = /* @__PURE__ */ new Map();
793
+ let plan = EMPTY_PLAN;
794
+ let status = "empty";
795
+ let error;
796
+ let warnings = [];
797
+ let busy = 0;
798
+ let selection = [];
799
+ let currentPage;
800
+ let navigation;
801
+ let nextKey = 0;
802
+ let nextSource = 0;
803
+ let loading;
804
+ const heldBytes = () => [...sources.values()].reduce((total, source) => total + source.byteLength, 0);
805
+ function referenced(steps) {
806
+ const ids = new Set(plan.pages.map((page) => page.source));
807
+ for (const { commands, inverses } of steps) for (const command of [...commands, ...inverses]) {
808
+ if (command.type === "pdf.insertPages") ids.add(command.source);
809
+ if (command.type === "pdf.restorePages") for (const { page } of command.entries) ids.add(page.source);
810
+ }
811
+ return ids;
812
+ }
813
+ function collect() {
814
+ const keep = referenced(history.steps);
815
+ for (const [id, source] of sources) {
816
+ if (keep.has(id)) continue;
817
+ sources.delete(id);
818
+ source.document.destroy().catch(() => {});
819
+ }
820
+ }
821
+ function stepsToDrop(extra) {
822
+ const { maximum } = policy.limits.maxSessionSize;
823
+ const order = history.dropOrder;
824
+ for (let count = 0; count <= order.length; count += 1) {
825
+ const kept = new Set(order.slice(count));
826
+ if ([...referenced(history.steps.filter((entry) => kept.has(entry)))].reduce((sum, id) => sum + (sources.get(id)?.byteLength ?? 0), 0) + extra <= maximum) return count;
827
+ }
828
+ }
829
+ let snapshot = makeSnapshot();
830
+ function sessionWarnings() {
831
+ const bytes = heldBytes();
832
+ const sessionWarning = bytes > 0 && bytes >= policy.limits.maxSessionSize.warning ? [{
833
+ limit: "maxSessionSize",
834
+ actual: bytes
835
+ }] : [];
836
+ return [...warnings, ...sessionWarning];
837
+ }
838
+ function makeSnapshot() {
839
+ return Object.freeze({
840
+ status,
841
+ plan,
842
+ sources: Object.freeze([...sources.values()].map(({ id, pageCount, byteLength }) => Object.freeze({
843
+ id,
844
+ pageCount,
845
+ byteLength
846
+ }))),
847
+ canUndo: history.canUndo,
848
+ canRedo: history.canRedo,
849
+ busy: busy > 0,
850
+ error,
851
+ warnings: Object.freeze(sessionWarnings()),
852
+ sessionBytes: heldBytes(),
853
+ historyTrimmed: history.trimmed,
854
+ selection: Object.freeze([...selection]),
855
+ currentPage,
856
+ navigation: navigation ? Object.freeze({ ...navigation }) : void 0
857
+ });
858
+ }
859
+ function changed() {
860
+ const keys = new Set(plan.pages.map((page) => page.key));
861
+ if (selection.some((key) => !keys.has(key))) selection = selection.filter((key) => keys.has(key));
862
+ if (currentPage !== void 0 && !keys.has(currentPage)) currentPage = plan.pages[0]?.key;
863
+ if (currentPage === void 0 && plan.pages.length > 0) currentPage = plan.pages[0]?.key;
864
+ if (navigation && !keys.has(navigation.page)) navigation = void 0;
865
+ snapshot = makeSnapshot();
866
+ for (const listener of [...listeners]) listener();
867
+ }
868
+ function emit(event) {
869
+ try {
870
+ options.onEvent?.(event);
871
+ } catch {}
872
+ }
873
+ async function load(file, signal) {
874
+ const found = [];
875
+ const warnAt = (limit, actual) => {
876
+ if (policy.check(limit, actual) === "warning") found.push({
877
+ limit,
878
+ actual
879
+ });
880
+ };
881
+ if (file instanceof Blob) {
882
+ if (checkFile(policy, file) === "warning") found.push({
883
+ limit: "maxFileSize",
884
+ actual: file.size
885
+ });
886
+ } else warnAt("maxFileSize", file.byteLength);
887
+ const bytes = file instanceof Blob ? new Uint8Array(await file.arrayBuffer()) : copyBytes(file);
888
+ throwIfAborted(signal);
889
+ const document = await withProcessingTime(policy, (limited) => engine.open(bytes, { signal: limited }), { signal }).catch((reason) => {
890
+ throw asPdfError(reason, "The PDF couldn't be opened.");
891
+ });
892
+ try {
893
+ throwIfAborted(signal);
894
+ warnAt("maxPages", document.pageCount);
895
+ } catch (reason) {
896
+ await document.destroy();
897
+ throw reason;
898
+ }
899
+ warnings = [...warnings.filter((warning) => warning.limit !== "maxFileSize"), ...found];
900
+ nextSource += 1;
901
+ return {
902
+ id: `s${nextSource}`,
903
+ pageCount: document.pageCount,
904
+ byteLength: bytes.byteLength,
905
+ bytes,
906
+ document
907
+ };
908
+ }
909
+ async function track(signal, replaces, run) {
910
+ if (replaces) loading?.abort(new PdfError("ABORTED", "A newer document replaced this one."));
911
+ const controller = new AbortController();
912
+ if (replaces) loading = controller;
913
+ const combined = signal ? AbortSignal.any([signal, controller.signal]) : controller.signal;
914
+ busy += 1;
915
+ changed();
916
+ try {
917
+ return await run(combined);
918
+ } finally {
919
+ busy -= 1;
920
+ if (loading === controller) loading = void 0;
921
+ changed();
922
+ }
923
+ }
924
+ async function release() {
925
+ const documents = [...sources.values()].map((source) => source.document);
926
+ sources.clear();
927
+ await Promise.all(documents.map((document) => document.destroy().catch(() => {})));
928
+ }
929
+ function pageFor(key) {
930
+ const page = plan.pages.find((entry) => entry.key === key);
931
+ const source = page && sources.get(page.source);
932
+ if (!page || !source) throw new TypeError(`The plan has no page ${key}.`);
933
+ return {
934
+ page,
935
+ source
936
+ };
937
+ }
938
+ function step(commands) {
939
+ const result = applyCommands(plan, commands);
940
+ plan = result.plan;
941
+ history.push({
942
+ commands,
943
+ inverses: result.inverses
944
+ });
945
+ collect();
946
+ }
947
+ return {
948
+ getSnapshot: () => snapshot,
949
+ subscribe(listener) {
950
+ listeners.add(listener);
951
+ return () => listeners.delete(listener);
952
+ },
953
+ async open(file, callOptions = {}) {
954
+ status = "opening";
955
+ error = void 0;
956
+ try {
957
+ const source = await track(callOptions.signal, true, async (signal) => {
958
+ policy.check("maxSessionSize", file instanceof Blob ? file.size : file.byteLength);
959
+ return load(file, signal);
960
+ });
961
+ await release();
962
+ sources.set(source.id, source);
963
+ history.clear();
964
+ plan = {
965
+ pages: Array.from({ length: source.pageCount }, (_, pageIndex) => {
966
+ nextKey += 1;
967
+ return {
968
+ key: `p${nextKey}`,
969
+ source: source.id,
970
+ pageIndex,
971
+ rotation: 0,
972
+ annotations: []
973
+ };
974
+ }),
975
+ formValues: {}
976
+ };
977
+ status = "ready";
978
+ changed();
979
+ emit({
980
+ type: "document_opened",
981
+ pageCount: source.pageCount
982
+ });
983
+ } catch (reason) {
984
+ const failure = asPdfError(reason, "The PDF couldn't be opened.");
985
+ if (failure.code === "ABORTED" && loading !== void 0) throw failure;
986
+ status = sources.size > 0 ? "ready" : "error";
987
+ error = failure;
988
+ changed();
989
+ emit({
990
+ type: "failed",
991
+ operation: "open",
992
+ code: failure.code
993
+ });
994
+ throw failure;
995
+ }
996
+ },
997
+ async insert(file, insertOptions = {}) {
998
+ if (status !== "ready") throw new PdfError("PROCESSING_FAILED", "Open a document before inserting another.");
999
+ error = void 0;
1000
+ try {
1001
+ const source = await track(insertOptions.signal, false, async (signal) => {
1002
+ policy.check("maxFiles", sources.size + 1);
1003
+ return load(file, signal);
1004
+ });
1005
+ try {
1006
+ const pageIndexes = insertOptions.pageIndexes ?? Array.from({ length: source.pageCount }, (_, index) => index);
1007
+ for (const index of pageIndexes) if (!Number.isInteger(index) || index < 0 || index >= source.pageCount) throw new RangeError(`The inserted document has no page index ${index}.`);
1008
+ if (policy.check("maxPages", plan.pages.length + pageIndexes.length) === "warning") warnings = [...warnings.filter((warning) => warning.limit !== "maxPages"), {
1009
+ limit: "maxPages",
1010
+ actual: plan.pages.length + pageIndexes.length
1011
+ }];
1012
+ const keys = pageIndexes.map(() => {
1013
+ nextKey += 1;
1014
+ return `p${nextKey}`;
1015
+ });
1016
+ const drop = stepsToDrop(source.byteLength);
1017
+ if (drop === void 0) throw policy.error("maxSessionSize", heldBytes() + source.byteLength);
1018
+ history.drop(drop);
1019
+ collect();
1020
+ sources.set(source.id, source);
1021
+ step([{
1022
+ type: "pdf.insertPages",
1023
+ source: source.id,
1024
+ pageIndexes,
1025
+ at: insertOptions.at ?? plan.pages.length,
1026
+ keys
1027
+ }]);
1028
+ changed();
1029
+ emit({
1030
+ type: "pages_inserted",
1031
+ pageCount: pageIndexes.length
1032
+ });
1033
+ } catch (reason) {
1034
+ sources.delete(source.id);
1035
+ await source.document.destroy().catch(() => {});
1036
+ throw reason;
1037
+ }
1038
+ } catch (reason) {
1039
+ if (reason instanceof TypeError || reason instanceof RangeError) throw reason;
1040
+ const failure = asPdfError(reason, "The PDF couldn't be inserted.");
1041
+ error = failure;
1042
+ changed();
1043
+ emit({
1044
+ type: "failed",
1045
+ operation: "insert",
1046
+ code: failure.code
1047
+ });
1048
+ throw failure;
1049
+ }
1050
+ },
1051
+ execute(commands) {
1052
+ const list = Array.isArray(commands) ? commands : [commands];
1053
+ if (list.length === 0) return;
1054
+ step(list);
1055
+ changed();
1056
+ emit({
1057
+ type: "command",
1058
+ commands: list.map((command) => command.type)
1059
+ });
1060
+ },
1061
+ undo() {
1062
+ const entry = history.undo();
1063
+ if (!entry) return;
1064
+ try {
1065
+ plan = applyCommands(plan, entry.inverses).plan;
1066
+ } catch (reason) {
1067
+ history.restore("undo");
1068
+ throw reason;
1069
+ }
1070
+ changed();
1071
+ emit({ type: "undo" });
1072
+ },
1073
+ redo() {
1074
+ const entry = history.redo();
1075
+ if (!entry) return;
1076
+ try {
1077
+ plan = applyCommands(plan, entry.commands).plan;
1078
+ } catch (reason) {
1079
+ history.restore("redo");
1080
+ throw reason;
1081
+ }
1082
+ changed();
1083
+ emit({ type: "redo" });
1084
+ },
1085
+ async getPage(key, callOptions) {
1086
+ const { page, source } = pageFor(key);
1087
+ const info = await source.document.getPage(page.pageIndex, callOptions);
1088
+ return {
1089
+ ...info,
1090
+ rotation: addRotation(info.rotation, page.rotation)
1091
+ };
1092
+ },
1093
+ async renderPage(key, canvas, renderOptions) {
1094
+ const { page, source } = pageFor(key);
1095
+ await source.document.renderPage(page.pageIndex, canvas, {
1096
+ ...renderOptions,
1097
+ rotation: page.rotation
1098
+ });
1099
+ },
1100
+ async getTextContent(key, callOptions) {
1101
+ const { page, source } = pageFor(key);
1102
+ return source.document.getTextContent(page.pageIndex, callOptions);
1103
+ },
1104
+ async getFormFields(key, callOptions) {
1105
+ const { page, source } = pageFor(key);
1106
+ const fields = await source.document.getFormFields(page.pageIndex, callOptions);
1107
+ const values = plan.formValues[source.id] ?? {};
1108
+ return fields.map((field) => Object.hasOwn(values, field.name) ? {
1109
+ ...field,
1110
+ value: values[field.name]
1111
+ } : field);
1112
+ },
1113
+ async getLinks(key, callOptions) {
1114
+ const { page, source } = pageFor(key);
1115
+ return source.document.getLinks(page.pageIndex, callOptions);
1116
+ },
1117
+ async export(exportOptions = {}) {
1118
+ if (status !== "ready" && sources.size === 0) throw new PdfError("PROCESSING_FAILED", "Open a document before exporting it.");
1119
+ const pages = plan.pages;
1120
+ const job = {
1121
+ sources: [...new Set(pages.map((page) => page.source))].map((id) => {
1122
+ const values = plan.formValues[id];
1123
+ return {
1124
+ id,
1125
+ bytes: sources.get(id).bytes,
1126
+ ...values && Object.keys(values).length > 0 ? { formValues: values } : {}
1127
+ };
1128
+ }),
1129
+ pages: pages.map((page) => ({
1130
+ source: page.source,
1131
+ pageIndex: page.pageIndex,
1132
+ ...page.rotation === 0 ? {} : { rotation: page.rotation },
1133
+ ...page.annotations.length === 0 ? {} : { annotations: page.annotations }
1134
+ })),
1135
+ ...exportOptions.compress ? { compress: exportOptions.compress } : {},
1136
+ ...exportOptions.encrypt ? { encrypt: exportOptions.encrypt } : {}
1137
+ };
1138
+ const done = () => emit({
1139
+ type: "document_exported",
1140
+ pageCount: pages.length,
1141
+ compressed: Boolean(exportOptions.compress),
1142
+ encrypted: Boolean(exportOptions.encrypt)
1143
+ });
1144
+ const [only] = job.sources;
1145
+ const source = only && sources.get(only.id);
1146
+ if (job.sources.length === 1 && !only?.formValues && !job.compress && !job.encrypt && source && job.pages.length === source.pageCount && job.pages.every((page, index) => page.pageIndex === index && !page.rotation && !page.annotations)) {
1147
+ throwIfAborted(exportOptions.signal);
1148
+ done();
1149
+ return copyBytes(source.bytes);
1150
+ }
1151
+ const { processor } = options;
1152
+ if (!processor) throw new TypeError("Exporting an edited document needs a processor in createPdfSession.");
1153
+ busy += 1;
1154
+ changed();
1155
+ try {
1156
+ const output = await withProcessingTime(policy, (signal) => processor.build(job, {
1157
+ signal,
1158
+ ...exportOptions.onProgress ? { onProgress: exportOptions.onProgress } : {}
1159
+ }), exportOptions.signal ? { signal: exportOptions.signal } : {});
1160
+ done();
1161
+ return output;
1162
+ } catch (reason) {
1163
+ if (reason instanceof TypeError || reason instanceof RangeError) throw reason;
1164
+ const failure = asPdfError(reason, "The PDF couldn't be exported.");
1165
+ emit({
1166
+ type: "failed",
1167
+ operation: "export",
1168
+ code: failure.code
1169
+ });
1170
+ throw failure;
1171
+ } finally {
1172
+ busy -= 1;
1173
+ changed();
1174
+ }
1175
+ },
1176
+ select(keys) {
1177
+ const wanted = new Set(keys);
1178
+ const next = plan.pages.filter((page) => wanted.has(page.key)).map((page) => page.key);
1179
+ if (next.length === selection.length && next.every((key, index) => key === selection[index])) return;
1180
+ selection = next;
1181
+ changed();
1182
+ },
1183
+ setCurrentPage(key) {
1184
+ if (key === currentPage || !plan.pages.some((page) => page.key === key)) return;
1185
+ currentPage = key;
1186
+ changed();
1187
+ },
1188
+ goToPage(key) {
1189
+ if (!plan.pages.some((page) => page.key === key)) throw new TypeError(`The plan has no page ${key}.`);
1190
+ currentPage = key;
1191
+ navigation = {
1192
+ page: key,
1193
+ sequence: (navigation?.sequence ?? 0) + 1
1194
+ };
1195
+ changed();
1196
+ },
1197
+ async close() {
1198
+ loading?.abort(new PdfError("ABORTED", "The document was closed."));
1199
+ const hadDocument = status === "ready";
1200
+ await release();
1201
+ plan = EMPTY_PLAN;
1202
+ history.clear();
1203
+ warnings = [];
1204
+ error = void 0;
1205
+ status = "empty";
1206
+ changed();
1207
+ if (hadDocument) emit({ type: "document_closed" });
1208
+ }
1209
+ };
1210
+ }
1211
+ // src/messages/en.ts
1212
+ var pdfMessages = /* @__PURE__ */ defineMessages({
1213
+ ...sdkCoreMessages,
1214
+ "errors.INVALID_PDF": "This file isn't a PDF, or it's too damaged to open.",
1215
+ "errors.PASSWORD_REQUIRED": "This PDF is protected with a password.",
1216
+ "errors.PROCESSING_FAILED": "Something went wrong while processing this PDF. Please try again.",
1217
+ "errors.TOO_MANY_PAGES": "This document has {actual, number} pages, which is over the {maximum, number}-page limit.",
1218
+ "errors.SESSION_TOO_LARGE": "The open documents would use {actual, fileSize}, which is over the {maximum, fileSize} limit. Close a document, or clear the undo history, and try again.",
1219
+ "errors.IMAGE_TOO_LARGE": "Some images are too large to show. They're kept unchanged in the document.",
1220
+ "warnings.maxPages": /* @__PURE__ */ plural("actual", {
1221
+ one: "This document has {actual} page. Large documents may be slow.",
1222
+ other: "This document has {actual} pages. Large documents may be slow."
1223
+ }),
1224
+ "warnings.maxSessionSize": "The open documents use {actual, fileSize}. Clearing the undo history frees memory.",
1225
+ "warnings.maxImagePixels": "Some images are very large and may be slow to show.",
1226
+ "viewer.label": "Document",
1227
+ "viewer.empty": "No document is open.",
1228
+ "viewer.page": "Page {page} of {count}",
1229
+ "viewer.webLink": "Link to {destination}, opens in a new tab",
1230
+ "viewer.emailLink": "Email {destination}",
1231
+ "thumbnails.label": "Pages",
1232
+ "thumbnails.page": "Page {page} of {count}",
1233
+ "thumbnails.number": "{page}",
1234
+ "editor.label": "PDF editor",
1235
+ "editor.start.title": "Open a PDF to get started",
1236
+ "editor.start.retryTitle": "Try another PDF",
1237
+ "editor.start.choose": "Choose a PDF",
1238
+ "editor.start.retry": "Choose another PDF",
1239
+ "editor.start.hint": "Or drop one here. Your file stays on this device and is never uploaded.",
1240
+ "editor.opening": "Opening the PDF…",
1241
+ "editor.opened": /* @__PURE__ */ plural("count", {
1242
+ one: "Opened a PDF with {count} page.",
1243
+ other: "Opened a PDF with {count} pages."
1244
+ }),
1245
+ "editor.closed": "The PDF was closed.",
1246
+ "editor.undone": "Undone.",
1247
+ "editor.redone": "Redone.",
1248
+ "editor.rotated": /* @__PURE__ */ plural("count", {
1249
+ one: "Rotated {count} page.",
1250
+ other: "Rotated {count} pages."
1251
+ }),
1252
+ "toolbar.label": "PDF tools",
1253
+ "toolbar.groups.file": "File",
1254
+ "toolbar.groups.history": "History",
1255
+ "toolbar.groups.pages": "Pages",
1256
+ "toolbar.groups.other": "More tools",
1257
+ "tools.open": "Open a PDF",
1258
+ "tools.undo": "Undo",
1259
+ "tools.redo": "Redo",
1260
+ "tools.rotate-left": "Rotate left",
1261
+ "tools.rotate-right": "Rotate right"
1262
+ });
1263
+ export { PDF_MAX_CANVAS_PIXELS as a, addRotation as c, PdfError as d, isPdfError as f, createPdfJsEngine as i, pdfLimitDefinitions as l, createPdfSession as n, linkDestination as o, createPdfProcessor as r, safeLinkUrl as s, pdfMessages as t, pdfLimits as u };
1264
+
1265
+ //# sourceMappingURL=en-BYB_GHqG.js.map