@poe-platform/safe-bash 0.1.813 → 0.1.815

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 (528) hide show
  1. package/dist/image-ast/index.js +1 -1
  2. package/dist/mp4-ast/index.d.ts +3 -0
  3. package/dist/mp4-ast/mp4-fragment-source.d.ts +35 -0
  4. package/dist/mp4-ast/mp4-sample-source.d.ts +55 -0
  5. package/dist/mp4-ast/mp4-source.d.ts +32 -0
  6. package/dist/mp4-ast/types.d.ts +11 -0
  7. package/dist/office-xml/retained-xml-document.d.ts +6 -0
  8. package/dist/pdf-ast/content/evaluator.d.ts +4 -0
  9. package/dist/pdf-ast/cos/object-reader.d.ts +8 -0
  10. package/dist/pdf-ast/cos/value-parser.d.ts +1 -0
  11. package/dist/pdf-ast/edit/forms.d.ts +1 -0
  12. package/dist/pdf-ast/edit/retained-form-appearances.d.ts +10 -0
  13. package/dist/pdf-ast/edit/retained-form-data.d.ts +9 -0
  14. package/dist/pdf-ast/edit/retained-graph.d.ts +6 -0
  15. package/dist/pdf-ast/edit/retained-info-updates.d.ts +33 -0
  16. package/dist/pdf-ast/index.d.ts +2 -1
  17. package/dist/pdf-ast/index.js +895 -139
  18. package/dist/pdf-ast/retained-document.d.ts +5 -0
  19. package/dist/safe-bash/command-chunks/biff-A7XPBWAK-DCLG5QKF.js +5417 -0
  20. package/dist/safe-bash/command-chunks/{chunk-34G2SQX2.js → chunk-2BLTUQNK.js} +2 -2
  21. package/dist/safe-bash/command-chunks/{chunk-LLU2IQEJ.js → chunk-2BNGPR6Z.js} +2 -2
  22. package/dist/safe-bash/command-chunks/{chunk-XIDGHIGB.js → chunk-2PKBXGXD.js} +5 -5
  23. package/dist/safe-bash/command-chunks/{chunk-6SRHWVEB.js → chunk-2VVJRVYM.js} +1 -1
  24. package/dist/safe-bash/command-chunks/{chunk-G5QVZQCO.js → chunk-3EASXF5D.js} +5 -5
  25. package/dist/safe-bash/command-chunks/{chunk-U3SBHEKH.js → chunk-3EB2FSAN.js} +9 -9
  26. package/dist/safe-bash/command-chunks/{chunk-VB2TUPO2.js → chunk-3EW7GYHM.js} +9 -9
  27. package/dist/safe-bash/command-chunks/{chunk-GVWVRPG6.js → chunk-3GRMU7TM.js} +6 -6
  28. package/dist/safe-bash/command-chunks/{chunk-6L4IYQAT.js → chunk-3MG5EAMX.js} +4 -4
  29. package/dist/safe-bash/command-chunks/{chunk-RASQPOSV.js → chunk-3SPLP2DB.js} +1 -1
  30. package/dist/safe-bash/command-chunks/{chunk-K5COUQAQ.js → chunk-3VGQTLO6.js} +1 -1
  31. package/dist/safe-bash/command-chunks/{chunk-K7CV55K5.js → chunk-3YEQI5B7.js} +10 -10
  32. package/dist/safe-bash/command-chunks/{chunk-KCE5D4Z4.js → chunk-3ZRCL756.js} +3 -3
  33. package/dist/safe-bash/command-chunks/{chunk-SOFM3GPG.js → chunk-42MEXZBJ.js} +1 -1
  34. package/dist/safe-bash/command-chunks/{chunk-PKLJRB7W.js → chunk-44F5TOHZ.js} +219 -90
  35. package/dist/safe-bash/command-chunks/{chunk-GQ2ZSPZ3.js → chunk-46AMTJPE.js} +10 -10
  36. package/dist/safe-bash/command-chunks/{chunk-MTWZEPAR.js → chunk-47IAU25U.js} +2 -2
  37. package/dist/safe-bash/command-chunks/{chunk-6GI3NTCW.js → chunk-4B2ZUGLT.js} +4 -4
  38. package/dist/safe-bash/command-chunks/{chunk-X64XGIXZ.js → chunk-4EHY6J2Z.js} +5 -5
  39. package/dist/safe-bash/command-chunks/{chunk-QQVACHZA.js → chunk-4EZJV4FZ.js} +1 -1
  40. package/dist/safe-bash/command-chunks/{chunk-SSKMPDN4.js → chunk-4GQKCUS5.js} +15 -15
  41. package/dist/safe-bash/command-chunks/{chunk-UOBW5K3M.js → chunk-4RRYWHED.js} +7 -7
  42. package/dist/safe-bash/command-chunks/{chunk-PINR7QET.js → chunk-4UPKVQWH.js} +8 -8
  43. package/dist/safe-bash/command-chunks/{chunk-I4GMCWAT.js → chunk-4YLACJHE.js} +6 -6
  44. package/dist/safe-bash/command-chunks/{chunk-P3WU3PSL.js → chunk-5L4YGRQU.js} +3 -3
  45. package/dist/safe-bash/command-chunks/{chunk-WPVBUVFK.js → chunk-5LFGXN3D.js} +6 -6
  46. package/dist/safe-bash/command-chunks/{chunk-YXD6VGVG.js → chunk-5OM3UIK3.js} +3 -3
  47. package/dist/safe-bash/command-chunks/{chunk-RLCQ7BN3.js → chunk-6CDDKNNA.js} +4 -3
  48. package/dist/safe-bash/command-chunks/{chunk-TQEB4DH4.js → chunk-6EINUY5G.js} +149 -165
  49. package/dist/safe-bash/command-chunks/{chunk-C5QDEB3I.js → chunk-6LPSKLLD.js} +3 -3
  50. package/dist/safe-bash/command-chunks/{chunk-XLYIVBAR.js → chunk-6QYSF7I2.js} +7 -7
  51. package/dist/safe-bash/command-chunks/{chunk-6IWE7PTK.js → chunk-6VBDJC6V.js} +6 -6
  52. package/dist/safe-bash/command-chunks/{chunk-6N5GHM72.js → chunk-6WNVGCXD.js} +8 -8
  53. package/dist/safe-bash/command-chunks/{chunk-PSCOXGCA.js → chunk-6XES7Z4G.js} +12 -12
  54. package/dist/safe-bash/command-chunks/{chunk-AFROLW6S.js → chunk-6XGDWFNQ.js} +4 -4
  55. package/dist/safe-bash/command-chunks/{chunk-WTE23QXN.js → chunk-6ZGCKUAM.js} +3 -3
  56. package/dist/safe-bash/command-chunks/{chunk-RIV6XN7K.js → chunk-7DOLY7IV.js} +2 -2
  57. package/dist/safe-bash/command-chunks/{chunk-ET2VPDUA.js → chunk-7KZ5LWV2.js} +1 -1
  58. package/dist/safe-bash/command-chunks/{chunk-NGR5KOPQ.js → chunk-A347DLRB.js} +3 -3
  59. package/dist/safe-bash/command-chunks/{chunk-ZM2Y4Z3C.js → chunk-A45UG4KT.js} +4 -4
  60. package/dist/safe-bash/command-chunks/{chunk-2Z3WRRFT.js → chunk-ADHFF2IM.js} +9 -9
  61. package/dist/safe-bash/command-chunks/{chunk-ATI464W3.js → chunk-AG2SNMP5.js} +1 -1
  62. package/dist/safe-bash/command-chunks/{chunk-HCKYUQ3L.js → chunk-AM5LANIE.js} +7 -7
  63. package/dist/safe-bash/command-chunks/{chunk-RBTC7OFT.js → chunk-AVOGFREX.js} +5 -5
  64. package/dist/safe-bash/command-chunks/{chunk-G3RUXKVY.js → chunk-AWPI4DZR.js} +3 -3
  65. package/dist/safe-bash/command-chunks/{chunk-FYMNHG7R.js → chunk-AXXZNB7U.js} +13 -13
  66. package/dist/safe-bash/command-chunks/{chunk-2E2H7MBH.js → chunk-AY3KQ4EN.js} +7 -7
  67. package/dist/safe-bash/command-chunks/{chunk-DMCI6T6N.js → chunk-BLGGAHQW.js} +1 -1
  68. package/dist/safe-bash/command-chunks/{chunk-CU4DLVME.js → chunk-BLIFGBIO.js} +2 -2
  69. package/dist/safe-bash/command-chunks/{chunk-2V6FOLXV.js → chunk-BS3ZEQGT.js} +14 -14
  70. package/dist/safe-bash/command-chunks/{chunk-WFVSUXJL.js → chunk-BS5JEUEW.js} +8 -8
  71. package/dist/safe-bash/command-chunks/{chunk-X53AEG36.js → chunk-BZMNC7Q5.js} +7 -7
  72. package/dist/safe-bash/command-chunks/{chunk-5KGEZ3RW.js → chunk-CCMAHM3I.js} +2 -2
  73. package/dist/safe-bash/command-chunks/{chunk-PK36TVXB.js → chunk-CFMJXJS5.js} +1 -1
  74. package/dist/safe-bash/command-chunks/{chunk-3LJAXFH5.js → chunk-CIRDVCAZ.js} +7 -7
  75. package/dist/safe-bash/command-chunks/{chunk-UZL7G57V.js → chunk-CKEMZUE3.js} +7 -7
  76. package/dist/safe-bash/command-chunks/{chunk-S2N2V5U4.js → chunk-CQBACD2V.js} +2 -2
  77. package/dist/safe-bash/command-chunks/{chunk-G7NENPYV.js → chunk-CSE4VQKG.js} +12 -1
  78. package/dist/safe-bash/command-chunks/{chunk-X6RHJ6YN.js → chunk-CXME4YHU.js} +23 -0
  79. package/dist/safe-bash/command-chunks/{chunk-FTLDRH47.js → chunk-CZ5K2YPU.js} +16 -16
  80. package/dist/safe-bash/command-chunks/{chunk-7PRL6RJ6.js → chunk-DBLQUZGN.js} +2 -2
  81. package/dist/safe-bash/command-chunks/{chunk-5VQVZPP3.js → chunk-DBNJEXHK.js} +3 -3
  82. package/dist/safe-bash/command-chunks/{chunk-ZO5WBWLL.js → chunk-DN6MSXY7.js} +2 -2
  83. package/dist/safe-bash/command-chunks/{chunk-GXLXWZWH.js → chunk-DZH54L3F.js} +3 -3
  84. package/dist/safe-bash/command-chunks/{chunk-6CY5BHBS.js → chunk-EBHOZIBS.js} +6 -6
  85. package/dist/safe-bash/command-chunks/{chunk-3Y5EME26.js → chunk-ENEIE44W.js} +2 -2
  86. package/dist/safe-bash/command-chunks/{chunk-TKRLZIFI.js → chunk-EQWFKNHJ.js} +17 -17
  87. package/dist/safe-bash/command-chunks/{chunk-YV72XQKL.js → chunk-ETXPMVR6.js} +13 -13
  88. package/dist/safe-bash/command-chunks/{chunk-4Z6W5EOC.js → chunk-EV5G535P.js} +8 -8
  89. package/dist/safe-bash/command-chunks/{chunk-PZMU3Z4L.js → chunk-EVYKV3QI.js} +5 -5
  90. package/dist/safe-bash/command-chunks/{chunk-D6UMSC45.js → chunk-F4YFTO2K.js} +11 -11
  91. package/dist/safe-bash/command-chunks/{chunk-QM2HZJSJ.js → chunk-F762XDNG.js} +3 -3
  92. package/dist/safe-bash/command-chunks/{chunk-SGPCXAG7.js → chunk-FOONI6BD.js} +7 -7
  93. package/dist/safe-bash/command-chunks/{chunk-DYLNU57U.js → chunk-FSVJ67G5.js} +1 -1
  94. package/dist/safe-bash/command-chunks/{chunk-CLKOGAR3.js → chunk-FSYMSWJU.js} +8 -8
  95. package/dist/safe-bash/command-chunks/{chunk-FWPVQGYK.js → chunk-FUQMEUAT.js} +6 -6
  96. package/dist/safe-bash/command-chunks/{chunk-KXPCSVAT.js → chunk-FXCSPPYE.js} +20 -20
  97. package/dist/safe-bash/command-chunks/{chunk-7QZ2HP2F.js → chunk-FYYFV6PW.js} +6 -6
  98. package/dist/safe-bash/command-chunks/{chunk-3OETVNJA.js → chunk-G2COZLXX.js} +9 -9
  99. package/dist/safe-bash/command-chunks/{chunk-MKX4JAZ6.js → chunk-GCHB7VNX.js} +17 -17
  100. package/dist/safe-bash/command-chunks/{chunk-4Y6O2K35.js → chunk-GLAF45M7.js} +1 -1
  101. package/dist/safe-bash/command-chunks/chunk-GPGLTWNR.js +271 -0
  102. package/dist/safe-bash/command-chunks/{chunk-PI6MOMHA.js → chunk-GXMPXMDP.js} +11 -11
  103. package/dist/safe-bash/command-chunks/{chunk-57DDYKE5.js → chunk-GYM5ICK4.js} +7 -7
  104. package/dist/safe-bash/command-chunks/{chunk-5MFDRSGG.js → chunk-H33D4R26.js} +4 -4
  105. package/dist/safe-bash/command-chunks/{chunk-3ZDANXIC.js → chunk-HELAVGZH.js} +3 -3
  106. package/dist/safe-bash/command-chunks/{chunk-S4QH5BXZ.js → chunk-HGIMFVI2.js} +4 -4
  107. package/dist/safe-bash/command-chunks/{chunk-35IPOBWL.js → chunk-HI6ZYH3W.js} +10 -10
  108. package/dist/safe-bash/command-chunks/{chunk-RGOQKIG6.js → chunk-HK6MSB7Z.js} +5 -5
  109. package/dist/safe-bash/command-chunks/{chunk-IHSOOSNC.js → chunk-HQ2UN2L2.js} +17 -17
  110. package/dist/safe-bash/command-chunks/{chunk-7ZE3VIAN.js → chunk-IB5QP4LF.js} +2 -2
  111. package/dist/safe-bash/command-chunks/{chunk-UCR5YDV3.js → chunk-IBYMPAUW.js} +1 -1
  112. package/dist/safe-bash/command-chunks/{chunk-LABOWPFB.js → chunk-IHXZMAMY.js} +9 -9
  113. package/dist/safe-bash/command-chunks/{chunk-PVGZMLC6.js → chunk-IWHNRYER.js} +3 -3
  114. package/dist/safe-bash/command-chunks/{chunk-PPO7YUZF.js → chunk-JGKSWDGP.js} +1 -1
  115. package/dist/safe-bash/command-chunks/{chunk-GKILM4HZ.js → chunk-JR3Q6QNL.js} +7 -7
  116. package/dist/safe-bash/command-chunks/{chunk-D55REQA3.js → chunk-JUHOL5KB.js} +1 -1
  117. package/dist/safe-bash/command-chunks/{chunk-3O2YEI47.js → chunk-JVKE7YZN.js} +3 -3
  118. package/dist/safe-bash/command-chunks/{chunk-6NATRKUJ.js → chunk-JW6WVNTM.js} +1 -1
  119. package/dist/safe-bash/command-chunks/{chunk-IK6K2HCG.js → chunk-JWORWL72.js} +1 -1
  120. package/dist/safe-bash/command-chunks/{chunk-N32GSM3J.js → chunk-K2WOMJOQ.js} +1 -1
  121. package/dist/safe-bash/command-chunks/{chunk-73NYFNAS.js → chunk-KASXIRKD.js} +12 -9
  122. package/dist/safe-bash/command-chunks/{chunk-HKOMXGJS.js → chunk-KBAQHE5Y.js} +2 -2
  123. package/dist/safe-bash/command-chunks/{chunk-T3E5RV3U.js → chunk-KCLJGRU7.js} +12 -12
  124. package/dist/safe-bash/command-chunks/chunk-KHUT7BB5.js +65 -0
  125. package/dist/safe-bash/command-chunks/{chunk-TUDFMNPP.js → chunk-KINIV2SV.js} +1 -1
  126. package/dist/safe-bash/command-chunks/{chunk-43TRBJ2N.js → chunk-KPHLESD4.js} +4 -4
  127. package/dist/safe-bash/command-chunks/{chunk-C5KLFZGT.js → chunk-KSBNZTAZ.js} +6 -6
  128. package/dist/safe-bash/command-chunks/{chunk-4Y34ZG4T.js → chunk-KUOCGGEU.js} +11 -11
  129. package/dist/safe-bash/command-chunks/{chunk-ML5R5JML.js → chunk-KY4LCHUF.js} +1 -1
  130. package/dist/safe-bash/command-chunks/{chunk-KBUBSMCQ.js → chunk-LDW3RF7Y.js} +12 -12
  131. package/dist/safe-bash/command-chunks/{chunk-U27XPNLP.js → chunk-LEO4VRIN.js} +2 -2
  132. package/dist/safe-bash/command-chunks/{chunk-GZ3VIWNN.js → chunk-LKGTH2Q7.js} +7 -7
  133. package/dist/safe-bash/command-chunks/{chunk-TODWFDYB.js → chunk-LNTEV56A.js} +2 -2
  134. package/dist/safe-bash/command-chunks/{chunk-DVGXLBUW.js → chunk-LZ2JFMKT.js} +10 -10
  135. package/dist/safe-bash/command-chunks/{chunk-6D2BMAF4.js → chunk-MEM2ZPMI.js} +2 -2
  136. package/dist/safe-bash/command-chunks/{chunk-GNXTMSYN.js → chunk-MGMTRGKM.js} +4 -4
  137. package/dist/safe-bash/command-chunks/{chunk-B3NLITWP.js → chunk-MKK6FM5H.js} +7 -7
  138. package/dist/safe-bash/command-chunks/{chunk-BK7ISUJL.js → chunk-MKOIPOXX.js} +3 -3
  139. package/dist/safe-bash/command-chunks/chunk-MLOYUXUV.js +244 -0
  140. package/dist/safe-bash/command-chunks/{chunk-CBNKHBLD.js → chunk-MNK3DDH6.js} +2 -2
  141. package/dist/safe-bash/command-chunks/{chunk-JVGUVHWI.js → chunk-MPXMRTMY.js} +10 -10
  142. package/dist/safe-bash/command-chunks/{chunk-EJTNVXWF.js → chunk-MVLVIMJ6.js} +6 -6
  143. package/dist/safe-bash/command-chunks/{chunk-TY4WDAHM.js → chunk-MYZ46FQL.js} +1 -1
  144. package/dist/safe-bash/command-chunks/{chunk-TBAIMDGL.js → chunk-N4MUBJCT.js} +1 -1
  145. package/dist/safe-bash/command-chunks/{chunk-NPLVFAD6.js → chunk-N6G3345Q.js} +8 -8
  146. package/dist/safe-bash/command-chunks/{chunk-4PBNMKAT.js → chunk-NEMUPUUB.js} +7 -7
  147. package/dist/safe-bash/command-chunks/{chunk-MUUWBZIC.js → chunk-NEVQWOU6.js} +10 -10
  148. package/dist/safe-bash/command-chunks/{chunk-7NXTEWPR.js → chunk-NEYITAAO.js} +208 -254
  149. package/dist/safe-bash/command-chunks/{chunk-KZ5ODST6.js → chunk-NFGCBQN3.js} +2 -2
  150. package/dist/safe-bash/command-chunks/{chunk-LD7BONZY.js → chunk-NFII726L.js} +2 -2
  151. package/dist/safe-bash/command-chunks/{chunk-JQPNA77Y.js → chunk-NHNZYWPW.js} +2 -2
  152. package/dist/safe-bash/command-chunks/{chunk-ZYLGNIGA.js → chunk-NQINS4XY.js} +1 -1
  153. package/dist/safe-bash/command-chunks/{chunk-UAF4IX5H.js → chunk-NRFTYZ2R.js} +6 -6
  154. package/dist/safe-bash/command-chunks/{chunk-THMZLJQD.js → chunk-NYFYTL5G.js} +18 -18
  155. package/dist/safe-bash/command-chunks/{chunk-SMSGLRIH.js → chunk-OTF2AJ5M.js} +6 -6
  156. package/dist/safe-bash/command-chunks/{chunk-NPFHUS4X.js → chunk-OVQP6KH5.js} +6 -6
  157. package/dist/safe-bash/command-chunks/{chunk-QFF5KBOM.js → chunk-P2LT6TGR.js} +9 -9
  158. package/dist/safe-bash/command-chunks/{chunk-BEHUSUOY.js → chunk-PLMF35XK.js} +4 -4
  159. package/dist/safe-bash/command-chunks/{chunk-PXWS3Q7L.js → chunk-PLR5IULU.js} +5 -5
  160. package/dist/safe-bash/command-chunks/{chunk-DBLHCJJU.js → chunk-PS5GDFIP.js} +2 -2
  161. package/dist/safe-bash/command-chunks/{chunk-P7EL2FWW.js → chunk-Q5PWYPQV.js} +7 -7
  162. package/dist/safe-bash/command-chunks/{chunk-AJI55RS7.js → chunk-Q7TVCBU2.js} +1 -1
  163. package/dist/safe-bash/command-chunks/{chunk-EHTOHOTR.js → chunk-QB72X7FF.js} +9 -9
  164. package/dist/safe-bash/command-chunks/{chunk-GOBUDKZ3.js → chunk-QDVDBN2N.js} +4 -4
  165. package/dist/safe-bash/command-chunks/{chunk-F3GP3EXE.js → chunk-RGDOYWOD.js} +2 -2
  166. package/dist/safe-bash/command-chunks/{chunk-MNHBQBF6.js → chunk-RHDERFMR.js} +5 -5
  167. package/dist/safe-bash/command-chunks/{chunk-3KMOXEGH.js → chunk-RHU44OMN.js} +2 -2
  168. package/dist/safe-bash/command-chunks/{chunk-XG6UWQV5.js → chunk-RIVKF77R.js} +6 -6
  169. package/dist/safe-bash/command-chunks/{chunk-UOR6PXZZ.js → chunk-ROL5AEX6.js} +1 -1
  170. package/dist/safe-bash/command-chunks/{chunk-3TYDSGAH.js → chunk-RQYPFLZJ.js} +6 -6
  171. package/dist/safe-bash/command-chunks/{chunk-3Y4XZB24.js → chunk-RTNI47C5.js} +4 -4
  172. package/dist/safe-bash/command-chunks/{chunk-W5LLKV5H.js → chunk-RV5AGXOV.js} +2 -2
  173. package/dist/safe-bash/command-chunks/{chunk-JUJHYPYL.js → chunk-RXQ2G2YK.js} +9 -9
  174. package/dist/safe-bash/command-chunks/{chunk-EVU7FLDA.js → chunk-S2QNBAN6.js} +7 -7
  175. package/dist/safe-bash/command-chunks/{chunk-YE6OAKK7.js → chunk-S43QRKDC.js} +7 -7
  176. package/dist/safe-bash/command-chunks/{chunk-774GLJAO.js → chunk-S7HIOT7Z.js} +4 -4
  177. package/dist/safe-bash/command-chunks/{chunk-3D24WDND.js → chunk-SEPUP6TZ.js} +1 -1
  178. package/dist/safe-bash/command-chunks/{chunk-JPMYPOYZ.js → chunk-SUTHGUD3.js} +28 -28
  179. package/dist/safe-bash/command-chunks/{chunk-D6WJY6QO.js → chunk-SWAKALDJ.js} +10 -10
  180. package/dist/safe-bash/command-chunks/{chunk-WGH3RLJY.js → chunk-T5S4SJGO.js} +9 -9
  181. package/dist/safe-bash/command-chunks/{chunk-7JEIWA3A.js → chunk-TID5TSQW.js} +5 -5
  182. package/dist/safe-bash/command-chunks/{chunk-EZ4NQIPL.js → chunk-TJLXSENN.js} +1 -1
  183. package/dist/safe-bash/command-chunks/{chunk-HVW53ARH.js → chunk-TKCUGMRZ.js} +24 -20
  184. package/dist/safe-bash/command-chunks/{chunk-5P6I2T63.js → chunk-TXPDKEGY.js} +8 -8
  185. package/dist/safe-bash/command-chunks/{chunk-CTDC4LJT.js → chunk-U3C6IT2C.js} +55 -36
  186. package/dist/safe-bash/command-chunks/{chunk-MPKY37QR.js → chunk-UJERQEJB.js} +1 -1
  187. package/dist/safe-bash/command-chunks/{chunk-V37D6AHO.js → chunk-USGZN2KE.js} +5 -5
  188. package/dist/safe-bash/command-chunks/{chunk-JAHJWVGF.js → chunk-UYGQEQIP.js} +5 -5
  189. package/dist/safe-bash/command-chunks/{chunk-MPORWUTU.js → chunk-V5XC43BX.js} +8 -8
  190. package/dist/safe-bash/command-chunks/{chunk-AIMSZBWP.js → chunk-V7E3PZOK.js} +9 -9
  191. package/dist/safe-bash/command-chunks/{chunk-CNHRVUHA.js → chunk-VDTFVRYX.js} +1 -1
  192. package/dist/safe-bash/command-chunks/{chunk-M3Z5PU2M.js → chunk-VT2PHQ63.js} +15 -15
  193. package/dist/safe-bash/command-chunks/{chunk-QDVI2YB6.js → chunk-VUWXLH3E.js} +2 -2
  194. package/dist/safe-bash/command-chunks/{chunk-O675URF4.js → chunk-W3ZSWK76.js} +8 -8
  195. package/dist/safe-bash/command-chunks/{chunk-T6C5QP7T.js → chunk-WAT2562G.js} +6039 -5958
  196. package/dist/safe-bash/command-chunks/{chunk-JPA2PUYI.js → chunk-WBKB7HBZ.js} +8 -8
  197. package/dist/safe-bash/command-chunks/{chunk-6244HYJY.js → chunk-WJ2ERUCQ.js} +1 -1
  198. package/dist/safe-bash/command-chunks/{chunk-U5TWQFZY.js → chunk-WTVJLHMG.js} +1 -1
  199. package/dist/safe-bash/command-chunks/{chunk-SLQWQKXP.js → chunk-WWHMI4S3.js} +9 -9
  200. package/dist/safe-bash/command-chunks/{chunk-2UBZALAK.js → chunk-WYZG3DRR.js} +1 -1
  201. package/dist/safe-bash/command-chunks/{chunk-T5ERNELL.js → chunk-WZRFS5OY.js} +4 -4
  202. package/dist/safe-bash/command-chunks/{chunk-2DGJOOXM.js → chunk-X6OHFKBL.js} +8 -8
  203. package/dist/safe-bash/command-chunks/{chunk-S6ZTBXYO.js → chunk-XKAUKLF7.js} +13 -13
  204. package/dist/safe-bash/command-chunks/{chunk-NKTULXVD.js → chunk-XM5QJCPD.js} +8 -8
  205. package/dist/safe-bash/command-chunks/{chunk-BBAB7LC4.js → chunk-XMTR7QGL.js} +4 -4
  206. package/dist/safe-bash/command-chunks/{chunk-5IFRAI7Y.js → chunk-XNGM3W5R.js} +1 -1
  207. package/dist/safe-bash/command-chunks/{chunk-Z5BIM5B7.js → chunk-XTEIT5CI.js} +1 -1
  208. package/dist/safe-bash/command-chunks/{chunk-4DLIUTQV.js → chunk-XU6S3XUZ.js} +11 -11
  209. package/dist/safe-bash/command-chunks/{chunk-EXOQGXEU.js → chunk-XUJAQA3S.js} +30 -30
  210. package/dist/safe-bash/command-chunks/{chunk-VVWXY6IA.js → chunk-Y42KSX63.js} +6 -6
  211. package/dist/safe-bash/command-chunks/{chunk-R2BMZAHG.js → chunk-Y54L4P4J.js} +5 -5
  212. package/dist/safe-bash/command-chunks/{chunk-6WQD7LRA.js → chunk-YAD7EV4N.js} +14 -14
  213. package/dist/safe-bash/command-chunks/{chunk-YUXTK3XA.js → chunk-YRPXBGRX.js} +3 -3
  214. package/dist/safe-bash/command-chunks/{chunk-JORIVUPM.js → chunk-YW2VYN4V.js} +34 -15
  215. package/dist/safe-bash/command-chunks/{chunk-NMPED6L5.js → chunk-Z2WNYEPD.js} +4 -4
  216. package/dist/safe-bash/command-chunks/{chunk-7PZHWMK6.js → chunk-Z7QOSXQC.js} +7 -7
  217. package/dist/safe-bash/command-chunks/{chunk-7UC2Q6Z6.js → chunk-ZIGENXGC.js} +248 -6
  218. package/dist/safe-bash/command-chunks/{chunk-VQOINPVF.js → chunk-ZQM37BGE.js} +2 -2
  219. package/dist/safe-bash/command-chunks/{chunk-W3HV45CI.js → chunk-ZSQZHFWS.js} +9 -9
  220. package/dist/safe-bash/command-chunks/{chunk-IDJQP3A6.js → chunk-ZTMZO4IT.js} +1 -1
  221. package/dist/safe-bash/command-chunks/{chunk-V6XBEYPC.js → chunk-ZU2KJMXO.js} +8 -8
  222. package/dist/safe-bash/command-chunks/{chunk-YXKNJ6EM.js → chunk-ZXELXF2H.js} +5 -5
  223. package/dist/safe-bash/command-chunks/{clipboard-BBDK33GP-VB22F7GI.js → clipboard-BBDK33GP-QZ4ERNQX.js} +2 -2
  224. package/dist/safe-bash/command-chunks/{command-engine-X3OLN7N6.js → command-engine-M7S4QIXV.js} +942 -683
  225. package/dist/safe-bash/command-chunks/{engine-XUCIFZ7V-LJFGZM6O.js → engine-YUYZJIB4-NZUDFEHL.js} +1 -1
  226. package/dist/safe-bash/command-chunks/{gnumeric-UJPXWBVR-YPXTNEDZ.js → gnumeric-UJPXWBVR-7VOHQAPM.js} +2 -2
  227. package/dist/safe-bash/command-chunks/{model-store-E7BHBFJC.js → model-store-UB5DWMAP.js} +24 -24
  228. package/dist/safe-bash-command-awk/awk-runtime.js +3 -3
  229. package/dist/safe-bash-command-awk/awk.js +4 -4
  230. package/dist/safe-bash-command-awk/index.js +4 -4
  231. package/dist/safe-bash-command-diff/diff.js +2 -2
  232. package/dist/safe-bash-command-diff/index.js +3 -3
  233. package/dist/safe-bash-command-diff/sync.js +2 -2
  234. package/dist/safe-bash-command-du/du.js +2 -2
  235. package/dist/safe-bash-command-du/index.js +2 -2
  236. package/dist/safe-bash-command-ffmpeg/index.js +1 -1
  237. package/dist/safe-bash-command-ffprobe/index.js +2 -2
  238. package/dist/safe-bash-command-ffprobe/media.d.ts +8 -2
  239. package/dist/safe-bash-command-ffprobe/media.js +4 -2
  240. package/dist/safe-bash-command-html-to-markdown/index.js +3 -234
  241. package/dist/safe-bash-command-html-to-markdown/stored-text.d.ts +50 -0
  242. package/dist/safe-bash-command-html-to-markdown/stored-text.js +12 -0
  243. package/dist/safe-bash-command-htmlq/contracts.d.ts +5 -0
  244. package/dist/safe-bash-command-htmlq/index.js +1715 -292
  245. package/dist/safe-bash-command-htmlq/selectors.d.ts +38 -1
  246. package/dist/safe-bash-command-htmlq/serializer.d.ts +1 -0
  247. package/dist/safe-bash-command-htmlq/tree.d.ts +1 -0
  248. package/dist/safe-bash-command-iconv/command.js +2 -2
  249. package/dist/safe-bash-command-iconv/index.js +2 -2
  250. package/dist/safe-bash-command-llm/command.js +3 -3
  251. package/dist/safe-bash-command-llm/index.js +9 -9
  252. package/dist/safe-bash-command-llm/openai.js +2 -2
  253. package/dist/safe-bash-command-llm/providers/index.js +2 -2
  254. package/dist/safe-bash-command-llm/providers/openai.js +2 -2
  255. package/dist/safe-bash-command-node/commands/node/browser.js +2 -2
  256. package/dist/safe-bash-command-node/commands/node/default-runtime.js +2 -2
  257. package/dist/safe-bash-command-node/commands/node/safejs.js +2 -2
  258. package/dist/safe-bash-command-pandoc/command.js +4 -4
  259. package/dist/safe-bash-command-pandoc/index.js +40 -40
  260. package/dist/safe-bash-command-patch/index.js +7 -6
  261. package/dist/safe-bash-command-patch/patch-formats.d.ts +7 -1
  262. package/dist/safe-bash-command-patch/patch-formats.js +7 -4
  263. package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +7 -7
  264. package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +2 -2
  265. package/dist/safe-bash-command-patch/patch-gnu-reject.js +3 -2
  266. package/dist/safe-bash-command-patch/patch-publication.js +3 -2
  267. package/dist/safe-bash-command-patch/patch-text.d.ts +13 -0
  268. package/dist/safe-bash-command-patch/patch.js +7 -6
  269. package/dist/safe-bash-command-patch/stored-patch.d.ts +51 -0
  270. package/dist/safe-bash-command-patch/stored-target.d.ts +41 -0
  271. package/dist/safe-bash-command-patch/unified.d.ts +28 -9
  272. package/dist/safe-bash-command-patch/unified.js +4 -1
  273. package/dist/safe-bash-command-pdftk/index.js +758 -433
  274. package/dist/safe-bash-command-playwright-cli/index.js +26 -26
  275. package/dist/safe-bash-command-playwright-cli/playwright/abilities.js +10 -10
  276. package/dist/safe-bash-command-playwright-cli/playwright/controller.js +14 -14
  277. package/dist/safe-bash-command-playwright-cli/playwright/index.js +23 -23
  278. package/dist/safe-bash-command-playwright-cli/playwright/snapshot.js +2 -2
  279. package/dist/safe-bash-command-playwright-cli/playwright/standard-capabilities.js +6 -6
  280. package/dist/safe-bash-command-playwright-cli/playwright/storage-capabilities.js +4 -4
  281. package/dist/safe-bash-command-pptx/command-engine.d.ts +2 -1
  282. package/dist/safe-bash-command-pptx/engine.js +1 -1
  283. package/dist/safe-bash-command-pptx/index.d.ts +1 -1
  284. package/dist/safe-bash-command-pptx/index.js +163 -17
  285. package/dist/safe-bash-command-pptx/streaming-inputs.d.ts +7 -2
  286. package/dist/safe-bash-command-python/executor.js +5 -5
  287. package/dist/safe-bash-command-python/index.js +5 -5
  288. package/dist/safe-bash-command-python/jspi.js +2 -2
  289. package/dist/safe-bash-command-soffice/index.js +1 -1
  290. package/dist/safe-bash-command-sort/index.js +3 -3
  291. package/dist/safe-bash-command-ssconvert/index.js +2 -2
  292. package/dist/safe-bash-command-tar/create.js +2 -2
  293. package/dist/safe-bash-command-tar/extract.js +2 -2
  294. package/dist/safe-bash-command-tar/index.js +8 -8
  295. package/dist/safe-bash-command-tar/modes.js +4 -4
  296. package/dist/safe-bash-command-timeout/index.js +3 -3
  297. package/dist/safe-bash-command-tree/index.js +2 -2
  298. package/dist/safe-bash-command-tree/tree.js +2 -2
  299. package/dist/safe-bash-command-xz/index.js +5 -5
  300. package/dist/safe-bash-compression-engine/files.js +2 -2
  301. package/dist/safe-bash-compression-engine/operand.js +4 -4
  302. package/dist/safe-bash-contracts/diagnostics.js +3 -3
  303. package/dist/safe-bash-contracts/escaping.js +10 -10
  304. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  305. package/dist/safe-bash-contracts/filesystem-output.js +6 -6
  306. package/dist/safe-bash-contracts/index.js +33 -33
  307. package/dist/safe-bash-contracts/io.js +2 -2
  308. package/dist/safe-bash-contracts/output.js +3 -3
  309. package/dist/safe-bash-docx-engine/ancillary-resources.js +5 -5
  310. package/dist/safe-bash-docx-engine/batch-operations.js +63 -63
  311. package/dist/safe-bash-docx-engine/batch-result-schema.js +74 -74
  312. package/dist/safe-bash-docx-engine/batch.js +74 -74
  313. package/dist/safe-bash-docx-engine/bookmarks.js +13 -13
  314. package/dist/safe-bash-docx-engine/charts.js +6 -6
  315. package/dist/safe-bash-docx-engine/command-option-rules.js +3 -3
  316. package/dist/safe-bash-docx-engine/comments.js +21 -21
  317. package/dist/safe-bash-docx-engine/control-bindings.js +16 -16
  318. package/dist/safe-bash-docx-engine/control-repeat.js +16 -16
  319. package/dist/safe-bash-docx-engine/controls.js +14 -14
  320. package/dist/safe-bash-docx-engine/create.js +8 -8
  321. package/dist/safe-bash-docx-engine/diagrams.js +6 -6
  322. package/dist/safe-bash-docx-engine/diff.js +8 -8
  323. package/dist/safe-bash-docx-engine/document-properties.js +12 -12
  324. package/dist/safe-bash-docx-engine/equations.js +12 -12
  325. package/dist/safe-bash-docx-engine/extract.js +9 -9
  326. package/dist/safe-bash-docx-engine/fields.js +18 -18
  327. package/dist/safe-bash-docx-engine/font-inventory.js +13 -13
  328. package/dist/safe-bash-docx-engine/font-resources.js +3 -3
  329. package/dist/safe-bash-docx-engine/image-batch-operations.js +11 -11
  330. package/dist/safe-bash-docx-engine/image-insertion.js +17 -17
  331. package/dist/safe-bash-docx-engine/image-layout.js +14 -14
  332. package/dist/safe-bash-docx-engine/image-replacement.js +19 -19
  333. package/dist/safe-bash-docx-engine/images.js +14 -14
  334. package/dist/safe-bash-docx-engine/index.js +102 -102
  335. package/dist/safe-bash-docx-engine/inspection.js +15 -15
  336. package/dist/safe-bash-docx-engine/invocation.js +4 -4
  337. package/dist/safe-bash-docx-engine/io.js +6 -6
  338. package/dist/safe-bash-docx-engine/links.js +17 -17
  339. package/dist/safe-bash-docx-engine/lists.js +16 -16
  340. package/dist/safe-bash-docx-engine/locations.js +10 -10
  341. package/dist/safe-bash-docx-engine/notes.js +18 -18
  342. package/dist/safe-bash-docx-engine/objects.js +14 -14
  343. package/dist/safe-bash-docx-engine/pack.js +9 -9
  344. package/dist/safe-bash-docx-engine/package-view-batch-operations.js +19 -19
  345. package/dist/safe-bash-docx-engine/pandoc-adapter.js +25 -25
  346. package/dist/safe-bash-docx-engine/paragraph-edit.js +21 -21
  347. package/dist/safe-bash-docx-engine/publication.js +6 -6
  348. package/dist/safe-bash-docx-engine/removal.js +16 -16
  349. package/dist/safe-bash-docx-engine/revision-decisions.js +16 -16
  350. package/dist/safe-bash-docx-engine/revision-edit.js +15 -15
  351. package/dist/safe-bash-docx-engine/revisions.js +12 -12
  352. package/dist/safe-bash-docx-engine/run-format.js +15 -15
  353. package/dist/safe-bash-docx-engine/sanitize.js +29 -29
  354. package/dist/safe-bash-docx-engine/sections.js +15 -15
  355. package/dist/safe-bash-docx-engine/settings.js +6 -6
  356. package/dist/safe-bash-docx-engine/shape-edit.js +16 -16
  357. package/dist/safe-bash-docx-engine/signatures.js +11 -11
  358. package/dist/safe-bash-docx-engine/stories.js +18 -18
  359. package/dist/safe-bash-docx-engine/structure-model-batch-operations.js +34 -34
  360. package/dist/safe-bash-docx-engine/style-model-batch-operations.js +24 -24
  361. package/dist/safe-bash-docx-engine/style-model-result-schema.js +39 -39
  362. package/dist/safe-bash-docx-engine/styles.js +14 -14
  363. package/dist/safe-bash-docx-engine/table-edit.js +23 -23
  364. package/dist/safe-bash-docx-engine/table-read.js +11 -11
  365. package/dist/safe-bash-docx-engine/template.js +17 -17
  366. package/dist/safe-bash-docx-engine/text-replace.js +15 -15
  367. package/dist/safe-bash-docx-engine/text-resource-read.js +11 -11
  368. package/dist/safe-bash-docx-engine/text.js +11 -11
  369. package/dist/safe-bash-docx-engine/validation.js +4 -4
  370. package/dist/safe-bash-docx-engine/xml-parts.js +17 -17
  371. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +4 -4
  372. package/dist/safe-bash-line-ending-engine/command.js +3 -3
  373. package/dist/safe-bash-line-ending-engine/convert.js +2 -2
  374. package/dist/safe-bash-line-ending-engine/index.js +6 -6
  375. package/dist/safe-bash-line-ending-engine/info.js +2 -2
  376. package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
  377. package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
  378. package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
  379. package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
  380. package/dist/safe-bash-markdown-engine/index.js +5 -5
  381. package/dist/safe-bash-network-engine/transfer.js +3 -3
  382. package/dist/safe-bash-presentation-engine/accessibility.js +30 -30
  383. package/dist/safe-bash-presentation-engine/animation-editing.js +15 -15
  384. package/dist/safe-bash-presentation-engine/animations.js +15 -15
  385. package/dist/safe-bash-presentation-engine/backgrounds.js +16 -16
  386. package/dist/safe-bash-presentation-engine/bytes.js +3 -3
  387. package/dist/safe-bash-presentation-engine/chart-editing.js +33 -33
  388. package/dist/safe-bash-presentation-engine/chart-object-operations.js +24 -24
  389. package/dist/safe-bash-presentation-engine/charts.js +30 -30
  390. package/dist/safe-bash-presentation-engine/command-placeholder.js +58 -58
  391. package/dist/safe-bash-presentation-engine/comments.js +16 -16
  392. package/dist/safe-bash-presentation-engine/connector-operations.js +31 -31
  393. package/dist/safe-bash-presentation-engine/connectors.js +28 -28
  394. package/dist/safe-bash-presentation-engine/content-types.js +4 -4
  395. package/dist/safe-bash-presentation-engine/creation.js +6 -6
  396. package/dist/safe-bash-presentation-engine/diff.js +31 -31
  397. package/dist/safe-bash-presentation-engine/drawing-format.js +19 -19
  398. package/dist/safe-bash-presentation-engine/drawing-operations.js +30 -30
  399. package/dist/safe-bash-presentation-engine/drawing-schema.js +20 -20
  400. package/dist/safe-bash-presentation-engine/equations.js +16 -16
  401. package/dist/safe-bash-presentation-engine/errors.js +2 -2
  402. package/dist/safe-bash-presentation-engine/fields.js +16 -16
  403. package/dist/safe-bash-presentation-engine/font-metrics.js +3 -3
  404. package/dist/safe-bash-presentation-engine/image-extraction.js +19 -19
  405. package/dist/safe-bash-presentation-engine/image-formatting.js +31 -31
  406. package/dist/safe-bash-presentation-engine/image-insertion.js +17 -17
  407. package/dist/safe-bash-presentation-engine/image-replacement.js +20 -20
  408. package/dist/safe-bash-presentation-engine/image-value.js +4 -4
  409. package/dist/safe-bash-presentation-engine/images.js +18 -18
  410. package/dist/safe-bash-presentation-engine/index.js +114 -114
  411. package/dist/safe-bash-presentation-engine/layouts.js +15 -15
  412. package/dist/safe-bash-presentation-engine/length.js +3 -3
  413. package/dist/safe-bash-presentation-engine/links.js +15 -15
  414. package/dist/safe-bash-presentation-engine/masters.js +14 -14
  415. package/dist/safe-bash-presentation-engine/media-editing.js +23 -23
  416. package/dist/safe-bash-presentation-engine/media-extraction.js +16 -16
  417. package/dist/safe-bash-presentation-engine/media.js +15 -15
  418. package/dist/safe-bash-presentation-engine/memberships.js +14 -14
  419. package/dist/safe-bash-presentation-engine/notes.d.ts +1 -0
  420. package/dist/safe-bash-presentation-engine/notes.js +21 -15
  421. package/dist/safe-bash-presentation-engine/ole-enum.js +4 -4
  422. package/dist/safe-bash-presentation-engine/ole-insertion.js +19 -19
  423. package/dist/safe-bash-presentation-engine/opaque-objects.js +9 -9
  424. package/dist/safe-bash-presentation-engine/package-reader.js +5 -5
  425. package/dist/safe-bash-presentation-engine/package-tools.js +18 -18
  426. package/dist/safe-bash-presentation-engine/package-uri.js +3 -3
  427. package/dist/safe-bash-presentation-engine/package-writer.js +4 -4
  428. package/dist/safe-bash-presentation-engine/presentation-model.js +57 -57
  429. package/dist/safe-bash-presentation-engine/presentation-settings.js +13 -13
  430. package/dist/safe-bash-presentation-engine/properties.js +15 -15
  431. package/dist/safe-bash-presentation-engine/relationships.js +4 -4
  432. package/dist/safe-bash-presentation-engine/resource-limits.js +1 -1
  433. package/dist/safe-bash-presentation-engine/retained-frame-formatting.d.ts +14 -0
  434. package/dist/safe-bash-presentation-engine/retained-inspection.js +13 -13
  435. package/dist/safe-bash-presentation-engine/retained-notes.d.ts +27 -0
  436. package/dist/safe-bash-presentation-engine/retained-package.js +5 -5
  437. package/dist/safe-bash-presentation-engine/retained-text.d.ts +9 -2
  438. package/dist/safe-bash-presentation-engine/retained-text.js +130 -31
  439. package/dist/safe-bash-presentation-engine/retained-xml-document.d.ts +1 -0
  440. package/dist/safe-bash-presentation-engine/sanitize.js +16 -16
  441. package/dist/safe-bash-presentation-engine/selectors.js +10 -10
  442. package/dist/safe-bash-presentation-engine/shape-groups.js +30 -30
  443. package/dist/safe-bash-presentation-engine/shape-operations.js +29 -29
  444. package/dist/safe-bash-presentation-engine/shape-path-operations.js +31 -31
  445. package/dist/safe-bash-presentation-engine/shape-paths.js +15 -15
  446. package/dist/safe-bash-presentation-engine/shape-presets.js +3 -3
  447. package/dist/safe-bash-presentation-engine/shape-selection.js +30 -30
  448. package/dist/safe-bash-presentation-engine/shape-transforms.js +17 -17
  449. package/dist/safe-bash-presentation-engine/shapes.js +26 -26
  450. package/dist/safe-bash-presentation-engine/slide-copy.js +16 -16
  451. package/dist/safe-bash-presentation-engine/slide-import.js +17 -17
  452. package/dist/safe-bash-presentation-engine/slide-merge-split.js +19 -19
  453. package/dist/safe-bash-presentation-engine/slide-model.js +42 -42
  454. package/dist/safe-bash-presentation-engine/slide-removal.js +17 -17
  455. package/dist/safe-bash-presentation-engine/slide-transfer-budget.js +9 -9
  456. package/dist/safe-bash-presentation-engine/slides.js +18 -18
  457. package/dist/safe-bash-presentation-engine/table-operations.js +32 -32
  458. package/dist/safe-bash-presentation-engine/table-spans.js +31 -31
  459. package/dist/safe-bash-presentation-engine/tables.js +30 -30
  460. package/dist/safe-bash-presentation-engine/tags.js +15 -15
  461. package/dist/safe-bash-presentation-engine/template-bindings.js +32 -32
  462. package/dist/safe-bash-presentation-engine/template-repeat.js +39 -39
  463. package/dist/safe-bash-presentation-engine/text-fitting.js +26 -26
  464. package/dist/safe-bash-presentation-engine/text-frames.d.ts +13 -0
  465. package/dist/safe-bash-presentation-engine/text-frames.js +28 -26
  466. package/dist/safe-bash-presentation-engine/text-paragraphs.js +26 -26
  467. package/dist/safe-bash-presentation-engine/text-reading.js +11 -11
  468. package/dist/safe-bash-presentation-engine/text-replacement.js +16 -16
  469. package/dist/safe-bash-presentation-engine/text-runs.js +19 -19
  470. package/dist/safe-bash-presentation-engine/themes.js +15 -15
  471. package/dist/safe-bash-presentation-engine/transitions.js +15 -15
  472. package/dist/safe-bash-presentation-engine/validation.js +9 -9
  473. package/dist/safe-bash-presentation-engine/xml-parts.js +18 -18
  474. package/dist/safe-bash-presentation-engine/xml-view.js +3 -3
  475. package/dist/safe-bash-presentation-engine/xml.js +3 -3
  476. package/dist/safe-bash-query-engine/index.js +4 -4
  477. package/dist/safe-bash-query-engine/interpreter.js +2 -2
  478. package/dist/safe-bash-query-engine/query-core.js +4 -4
  479. package/dist/safe-bash-xml-engine/document.js +3 -3
  480. package/dist/safe-bash-xml-engine/evaluate.js +1 -1
  481. package/dist/safe-bash-xml-engine/index.js +6 -6
  482. package/dist/safe-bash-xml-engine/query.js +2 -2
  483. package/dist/safe-bash-xml-engine/stored-document.d.ts +2 -2
  484. package/dist/safe-bash-xml-engine/stored-document.js +1 -1
  485. package/dist/safe-bash-xml-engine/stored-evaluate.js +1 -1
  486. package/dist/safe-bash-zip-engine/zip/repair.js +3 -3
  487. package/dist/safe-bash-zip-engine/zip/volumes.js +3 -3
  488. package/dist/spreadsheet-engine/datasource.js +16 -2
  489. package/dist/spreadsheet-engine/formulas/diagnostics.d.ts +2 -1
  490. package/dist/spreadsheet-engine/formulas/diagnostics.js +2 -2
  491. package/dist/spreadsheet-engine/formulas/evaluator.d.ts +1 -1
  492. package/dist/spreadsheet-engine/formulas/evaluator.js +2 -1
  493. package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +7 -6
  494. package/dist/spreadsheet-format-xls/biff-properties-merge.js +41 -22
  495. package/dist/spreadsheet-format-xls/biff-properties.js +94 -109
  496. package/dist/spreadsheet-format-xls/biff-property-dictionary.d.ts +5 -0
  497. package/dist/spreadsheet-format-xls/biff-property-dictionary.js +75 -0
  498. package/dist/spreadsheet-format-xls/biff-property-range.d.ts +17 -3
  499. package/dist/spreadsheet-format-xls/biff-property-range.js +178 -37
  500. package/dist/spreadsheet-format-xls/biff-property-values.d.ts +31 -0
  501. package/dist/spreadsheet-format-xls/biff-property-values.js +158 -0
  502. package/package.json +5 -2
  503. package/dist/safe-bash/command-chunks/biff-4ALVARRF-7SRX6R6N.js +0 -5192
  504. package/dist/safe-bash/command-chunks/chunk-63EMPQ7Z.js +0 -115
  505. package/dist/safe-bash/command-chunks/{chunk-X2HVVMTW.js → chunk-AW4Q3GZW.js} +6 -6
  506. package/dist/safe-bash/command-chunks/{chunk-JC2EV66U.js → chunk-BJXADHRT.js} +3 -3
  507. package/dist/safe-bash/command-chunks/{chunk-XI2LETBJ.js → chunk-BXU5Y7I5.js} +3 -3
  508. package/dist/safe-bash/command-chunks/{chunk-PVLPWVRH.js → chunk-D3HW7R2N.js} +3 -3
  509. package/dist/safe-bash/command-chunks/{chunk-OLK3DCJD.js → chunk-DYERIXPU.js} +3 -3
  510. package/dist/safe-bash/command-chunks/{chunk-WYBCSJFG.js → chunk-FWCUEZ3K.js} +3 -3
  511. package/dist/safe-bash/command-chunks/{chunk-FF2SQ2GP.js → chunk-GGH376XQ.js} +3 -3
  512. package/dist/safe-bash/command-chunks/{chunk-D66Q7QJ3.js → chunk-JRSZ5IGD.js} +6 -6
  513. package/dist/safe-bash/command-chunks/{chunk-3JST2Q7G.js → chunk-KRRG4MGH.js} +3 -3
  514. package/dist/safe-bash/command-chunks/{chunk-Z3YB4EVE.js → chunk-KSM5CCHT.js} +8 -8
  515. package/dist/safe-bash/command-chunks/{chunk-NJ4NTTCR.js → chunk-LNLACEAN.js} +8 -8
  516. package/dist/safe-bash/command-chunks/{chunk-NBTG6NF6.js → chunk-LTJRUMK6.js} +3 -3
  517. package/dist/safe-bash/command-chunks/{chunk-XCYTG7CR.js → chunk-NJGL5JQ6.js} +3 -3
  518. package/dist/safe-bash/command-chunks/{chunk-SZ66JC25.js → chunk-Q7J2NTH2.js} +3 -3
  519. package/dist/safe-bash/command-chunks/{chunk-MDV7W5AS.js → chunk-SKNI2XQA.js} +3 -3
  520. package/dist/safe-bash/command-chunks/{chunk-7ZWACKCG.js → chunk-T6OXG7QQ.js} +3 -3
  521. package/dist/safe-bash/command-chunks/{chunk-ECDEPKKW.js → chunk-W25EIKDJ.js} +3 -3
  522. package/dist/safe-bash/command-chunks/{chunk-4YSBUQPV.js → chunk-W2FKFEVY.js} +3 -3
  523. package/dist/safe-bash/command-chunks/{chunk-2CIDPOUV.js → chunk-WSNHJZQ5.js} +3 -3
  524. package/dist/safe-bash/command-chunks/{chunk-4H3TYOVC.js → chunk-Y7AXMCFV.js} +3 -3
  525. package/dist/safe-bash/command-chunks/{chunk-U6IEK2CI.js → chunk-YPG55QTP.js} +7 -7
  526. package/dist/safe-bash/command-chunks/{chunk-252L5YC5.js → chunk-Z37OM247.js} +6 -6
  527. package/dist/safe-bash/command-chunks/{pln-DFS7VLVS-JATX6FS7.js → pln-DFS7VLVS-OVOBS4QX.js} +3 -3
  528. package/dist/safe-bash/command-chunks/{psion-YBI6JEQI-6OMC2PGC.js → psion-YBI6JEQI-GY4S6ZLC.js} +3 -3
@@ -1,5 +1,38 @@
1
1
  import "../safe-bash/command-chunks/chunk-65DS4IOB.js";
2
2
 
3
+ // packages/safe-bash-command-pdftk/src/info-text.ts
4
+ function decodePdftkEntities(str) {
5
+ let out = "";
6
+ let i = 0;
7
+ while (i < str.length) {
8
+ if (str[i] === "&" && str[i + 1] === "#") {
9
+ const semi = str.indexOf(";", i + 2);
10
+ if (semi !== -1) {
11
+ const body = str.slice(i + 2, semi);
12
+ const cp = body.startsWith("x") || body.startsWith("X") ? Number.parseInt(body.slice(1), 16) : Number.parseInt(body, 10);
13
+ if (Number.isFinite(cp) && cp >= 0) {
14
+ out += String.fromCodePoint(cp);
15
+ i = semi + 1;
16
+ continue;
17
+ }
18
+ }
19
+ }
20
+ out += str[i];
21
+ i++;
22
+ }
23
+ return out;
24
+ }
25
+ function hexToBytes(hex) {
26
+ const clean = hex.trim();
27
+ const len = Math.floor(clean.length / 2);
28
+ const out = new Uint8Array(len);
29
+ for (let i = 0; i < len; i++) {
30
+ const byteVal = Number.parseInt(clean.slice(i * 2, i * 2 + 2), 16);
31
+ out[i] = Number.isNaN(byteVal) ? 0 : byteVal;
32
+ }
33
+ return out;
34
+ }
35
+
3
36
  // packages/safe-bash-command-pdftk/src/burst-filename.ts
4
37
  function formatBurstFilename(pattern, pageNum) {
5
38
  let out = "";
@@ -39,14 +72,422 @@ function formatBurstFilename(pattern, pageNum) {
39
72
  return out;
40
73
  }
41
74
 
75
+ // packages/safe-bash-command-pdftk/src/retained-assembly.ts
76
+ import { IntegerTable as IntegerTable2, PagedStorage as PagedStorage2 } from "@poe-platform/safe-fs/storage";
77
+ import { PdfMutableObjectStore as PdfMutableObjectStore2, PdfNameIndex as PdfNameIndex2, PdfFileSource as PdfFileSource2, createRetainedPageCopy, editRetainedDocument, cosArray, cosDict as cosDict2, cosNumber, cosString as cosString2, decodePdfString as decodePdfString2, dictGet as dictGet2, dictSet } from "../pdf-ast/index.js";
78
+
79
+ // packages/safe-bash-command-pdftk/src/retained-unpack.ts
80
+ import { IntegerTable, PagedStorage } from "@poe-platform/safe-fs/storage";
81
+ import { PdfFileSource, PdfMutableObjectStore, PdfNameIndex, cosDict, cosString, decodePdfString, dictGet } from "../pdf-ast/index.js";
82
+ async function* retainedUnpack(document, storage, directory, inputNames, signal, includeSentinel = false) {
83
+ const names = new PdfNameIndex(storage, Infinity, signal), outputs = new PdfMutableObjectStore(storage, { signal });
84
+ const stack = new PdfMutableObjectStore(storage, { signal }), backing = new PagedStorage({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), seen = new IntegerTable(backing, 64);
85
+ const cleanDir = directory.endsWith("/") ? directory.slice(0, -1) : directory;
86
+ let pending = 0, work = 0, failed = false;
87
+ async function checkpoint() {
88
+ signal.throwIfAborted();
89
+ if (++work % 64 === 0) await new Promise((resolve2) => setTimeout(resolve2, 0));
90
+ signal.throwIfAborted();
91
+ }
92
+ async function resolve(node) {
93
+ await checkpoint();
94
+ const found = await document.lookup(node);
95
+ return found?.stream ? void 0 : found?.value;
96
+ }
97
+ async function spec(raw, fallback = "attachment.bin") {
98
+ const dict = await resolve(raw);
99
+ if (dict?.kind !== "dict") return;
100
+ const filename = await resolve(dictGet(dict, "UF") ?? dictGet(dict, "F"));
101
+ const name = filename?.kind === "string" ? decodePdfString(filename) : fallback;
102
+ const leaf = name.slice(Math.max(name.lastIndexOf("/"), name.lastIndexOf("\\")) + 1);
103
+ if (!leaf || leaf === "." || leaf === ".." || leaf.includes("\0")) throw new Error("Invalid embedded attachment filename");
104
+ const ef = await resolve(dictGet(dict, "EF"));
105
+ if (ef?.kind !== "dict") return;
106
+ const data = await document.lookup(dictGet(ef, "UF") ?? dictGet(ef, "F") ?? dictGet(ef, "DOS") ?? dictGet(ef, "Mac") ?? dictGet(ef, "Unix"));
107
+ if (!data?.stream || !data.reference) return;
108
+ const path = cleanDir && cleanDir !== "." ? `${cleanDir}/${leaf}` : leaf;
109
+ const nameIndex = await names.intern(path);
110
+ const staged = await PdfFileSource.fromStream(storage.fs, storage.directory, document.objects.decodeStream(data.reference.objectNumber, data.reference.generationNumber), { signal });
111
+ let failed2 = false;
112
+ try {
113
+ await outputs.set({ objectNumber: nameIndex.index + 1, generationNumber: 0, value: cosDict({ Path: cosString(path) }), stream: { length: staged.size, chunks: staged.stream(0, staged.size, signal) } });
114
+ } catch (error) {
115
+ failed2 = true;
116
+ throw error;
117
+ } finally {
118
+ await staged.close().catch((error) => {
119
+ if (!failed2) throw error;
120
+ });
121
+ }
122
+ }
123
+ const push = async (value) => {
124
+ await checkpoint();
125
+ await stack.set({ objectNumber: ++pending, generationNumber: 0, value });
126
+ };
127
+ async function associated(raw) {
128
+ const array = await resolve(raw);
129
+ if (array?.kind === "array") for (const item of array.items) await spec(item);
130
+ }
131
+ try {
132
+ for (const name of inputNames) await names.intern(name);
133
+ const root = await resolve(document.crossReference.rootRef);
134
+ if (root?.kind === "dict") {
135
+ const dictionary = await resolve(dictGet(root, "Names")), tree = dictionary?.kind === "dict" ? dictGet(dictionary, "EmbeddedFiles") : void 0;
136
+ if (tree) await push(tree);
137
+ while (pending) {
138
+ await checkpoint();
139
+ const raw = (await stack.get(pending--)).value;
140
+ if (raw.kind === "ref") {
141
+ if (await seen.get(BigInt(raw.objectNumber))) continue;
142
+ await seen.set(BigInt(raw.objectNumber), 1n);
143
+ }
144
+ const branch = await resolve(raw);
145
+ if (branch?.kind !== "dict") continue;
146
+ const pairs = await resolve(dictGet(branch, "Names"));
147
+ if (pairs?.kind === "array") for (let i = 0; i + 1 < pairs.items.length; i += 2) {
148
+ const name = await resolve(pairs.items[i]);
149
+ await spec(pairs.items[i + 1], name?.kind === "string" ? decodePdfString(name) : "attachment.bin");
150
+ }
151
+ const kids = await resolve(dictGet(branch, "Kids"));
152
+ if (kids?.kind === "array") for (let i = kids.items.length - 1; i >= 0; i--) await push(kids.items[i]);
153
+ }
154
+ await associated(dictGet(root, "AF"));
155
+ }
156
+ for await (const page of document.pages()) {
157
+ await associated(dictGet(page.dict, "AF"));
158
+ const annotations = await resolve(dictGet(page.dict, "Annots"));
159
+ if (annotations?.kind === "array") for (const raw of annotations.items) {
160
+ const annotation = await resolve(raw);
161
+ if (annotation?.kind !== "dict") continue;
162
+ const type = await resolve(dictGet(annotation, "Subtype"));
163
+ if (type?.kind === "name" && type.decoded === "FileAttachment") await spec(dictGet(annotation, "FS"));
164
+ }
165
+ }
166
+ for await (const output of outputs.objects()) {
167
+ const path = output.value.kind === "dict" ? dictGet(output.value, "Path") : void 0;
168
+ if (path?.kind === "string" && output.stream) {
169
+ const name = decodePdfString(path);
170
+ if (includeSentinel || name !== "-") yield { path: name, chunks: output.stream.chunks };
171
+ }
172
+ }
173
+ } catch (error) {
174
+ failed = true;
175
+ throw error;
176
+ } finally {
177
+ const results = await Promise.allSettled([names.close(), outputs.close(), stack.close(), backing.close()]);
178
+ if (!failed) {
179
+ for (const result of results) if (result.status === "rejected") await Promise.reject(result.reason);
180
+ }
181
+ }
182
+ }
183
+
184
+ // packages/safe-bash-command-pdftk/src/retained-assembly.ts
185
+ async function assembleRetainedPdftk(primary, storage, options, counts, handles, open, signal) {
186
+ const backing = new PagedStorage2({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
187
+ const sourceBookmarks = new PdfMutableObjectStore2(storage, { signal }), outputBookmarks = new PdfMutableObjectStore2(storage, { signal }), rotations = new PdfMutableObjectStore2(storage, { signal }), attachments = new PdfMutableObjectStore2(storage, { signal });
188
+ const names = new PdfNameIndex2(storage, Infinity, signal);
189
+ const states = /* @__PURE__ */ new Map();
190
+ const used = /* @__PURE__ */ new Set(), rangeHandles = new Map([...handles].map(([handle, input]) => [handle, { pageCount: counts.get(input) }]));
191
+ let current, currentInput, copy, edited;
192
+ let work = 0, attachmentCount = 0, failed = false;
193
+ async function checkpoint() {
194
+ signal.throwIfAborted();
195
+ if (++work % 64 === 0) await new Promise((resolve) => setTimeout(resolve, 0));
196
+ signal.throwIfAborted();
197
+ }
198
+ async function document(input) {
199
+ if (currentInput !== input) {
200
+ await current?.close();
201
+ current = void 0;
202
+ currentInput = void 0;
203
+ current = await open(input);
204
+ currentInput = input;
205
+ }
206
+ return current;
207
+ }
208
+ function* selections() {
209
+ if (!options.opArgs.length) {
210
+ for (const input of options.inputs) for (let pageNumber = 1; pageNumber <= counts.get(input); pageNumber++) yield { handle: input.handle, pageNumber };
211
+ } else if (options.operation === "shuffle") {
212
+ const iterators = options.opArgs.map((arg) => iteratePdftkRangeToken(arg, rangeHandles, options.inputs[0].handle));
213
+ try {
214
+ let pending = true;
215
+ while (pending) {
216
+ pending = false;
217
+ for (const iterator of iterators) {
218
+ const next = iterator.next();
219
+ if (!next.done) {
220
+ pending = true;
221
+ yield next.value;
222
+ }
223
+ }
224
+ }
225
+ } finally {
226
+ for (const iterator of iterators) iterator.return(void 0);
227
+ }
228
+ } else for (const arg of options.opArgs) yield* iteratePdftkRangeToken(arg, rangeHandles, options.inputs[0].handle);
229
+ }
230
+ async function state(input, source) {
231
+ let result = states.get(input);
232
+ if (result) return result;
233
+ result = { bookmarks: new IntegerTable2(backing, 64), resources: new IntegerTable2(backing, 64) };
234
+ states.set(input, result);
235
+ for await (const bookmark of source.outlineDetails()) {
236
+ await checkpoint();
237
+ const key = BigInt(bookmark.pageIndex) * 2n, previous = await result.bookmarks.get(key + 1n);
238
+ const ref = await sourceBookmarks.allocate(cosDict2({ Title: cosString2(bookmark.title), Level: cosNumber(bookmark.level), Next: cosNumber(0) }));
239
+ if (previous) {
240
+ const row = await sourceBookmarks.get(Number(previous));
241
+ if (row.value.kind === "dict") {
242
+ dictSet(row.value, "Next", cosNumber(ref.objectNumber));
243
+ await sourceBookmarks.set(row);
244
+ }
245
+ } else await result.bookmarks.set(key, BigInt(ref.objectNumber));
246
+ await result.bookmarks.set(key + 1n, BigInt(ref.objectNumber));
247
+ }
248
+ return result;
249
+ }
250
+ async function* sources() {
251
+ let ordinal = 0, pageIndex = 0;
252
+ for (const selection of selections()) {
253
+ await checkpoint();
254
+ ordinal++;
255
+ const input = handles.get(selection.handle) ?? options.inputs[0], source = await document(input), record = await state(input, source);
256
+ used.add(input);
257
+ yield { document: source, indices: [selection.pageNumber - 1], resourceState: { has: async (index) => Boolean(await record.resources.get(BigInt(index))), add: async (index) => {
258
+ await record.resources.set(BigInt(index), 1n);
259
+ } } };
260
+ if (selection.rotation) await rotations.allocate(cosArray([cosNumber(pageIndex), cosNumber(selection.rotation.degrees), cosNumber(selection.rotation.kind === "relative" ? 1 : 0)]));
261
+ pageIndex++;
262
+ let item = Number(await record.bookmarks.get(BigInt(selection.pageNumber - 1) * 2n) ?? 0n);
263
+ while (item) {
264
+ await checkpoint();
265
+ const row = (await sourceBookmarks.get(item)).value;
266
+ if (row.kind !== "dict") throw new Error("Invalid bookmark record");
267
+ await outputBookmarks.allocate(cosArray([dictGet2(row, "Title"), dictGet2(row, "Level"), cosNumber(ordinal)]));
268
+ const next = dictGet2(row, "Next");
269
+ item = next?.kind === "number" ? next.value : 0;
270
+ }
271
+ }
272
+ }
273
+ async function* bookmarkEdits() {
274
+ for await (const object of outputBookmarks.objects()) {
275
+ await checkpoint();
276
+ const value = object.value;
277
+ if (value.kind !== "array" || value.items[0]?.kind !== "string" || value.items[1]?.kind !== "number" || value.items[2]?.kind !== "number") throw new Error("Invalid output bookmark");
278
+ yield { title: decodePdfString2(value.items[0]), level: value.items[1].value, pageNumber: value.items[2].value };
279
+ }
280
+ }
281
+ async function* rotationEdits() {
282
+ for await (const object of rotations.objects()) {
283
+ await checkpoint();
284
+ const value = object.value;
285
+ if (value.kind !== "array" || value.items[0]?.kind !== "number" || value.items[1]?.kind !== "number" || value.items[2]?.kind !== "number") throw new Error("Invalid output rotation");
286
+ yield { pageIndex: value.items[0].value, degrees: value.items[1].value, relative: value.items[2].value === 1 };
287
+ }
288
+ }
289
+ async function* attachmentEdits() {
290
+ for await (const object of attachments.objects()) {
291
+ await checkpoint();
292
+ const name = object.value.kind === "dict" ? dictGet2(object.value, "Filename") : void 0, filename = name?.kind === "string" ? decodePdfString2(name) : "";
293
+ if (object.stream) yield { filename, chunks: (async function* () {
294
+ yield* object.stream.chunks;
295
+ })() };
296
+ }
297
+ }
298
+ try {
299
+ copy = await createRetainedPageCopy(sources(), storage, { signal, metadata: await primary.info() });
300
+ for (const input of used) {
301
+ await checkpoint();
302
+ const source = await document(input);
303
+ for await (const file of retainedUnpack(source, storage, ".", [], signal, true)) {
304
+ const name = await names.intern(file.path);
305
+ if (name.added) attachmentCount++;
306
+ const payload = await PdfFileSource2.fromStream(storage.fs, storage.directory, file.chunks, { signal });
307
+ let failed2 = false;
308
+ try {
309
+ await attachments.set({ objectNumber: name.index + 1, generationNumber: 0, value: cosDict2({ Filename: cosString2(file.path) }), stream: { length: payload.size, chunks: payload.stream(0, payload.size, signal) } });
310
+ } catch (error) {
311
+ failed2 = true;
312
+ throw error;
313
+ } finally {
314
+ await payload.close().catch((error) => {
315
+ if (!failed2) throw error;
316
+ });
317
+ }
318
+ }
319
+ }
320
+ edited = await editRetainedDocument(await copy.openDocument(), storage, { signal, rotations: rotationEdits(), bookmarks: bookmarkEdits(), ...attachmentCount ? { appendAttachments: attachmentEdits() } : {} });
321
+ const result = edited, pages = copy;
322
+ return { document: result.document, async close() {
323
+ const results = await Promise.allSettled([result.close(), pages.close()]);
324
+ for (const outcome of results) if (outcome.status === "rejected") throw outcome.reason;
325
+ } };
326
+ } catch (error) {
327
+ failed = true;
328
+ await Promise.allSettled([edited?.close(), copy?.close()]);
329
+ throw error;
330
+ } finally {
331
+ const results = await Promise.allSettled([current?.close(), sourceBookmarks.close(), outputBookmarks.close(), rotations.close(), attachments.close(), names.close(), backing.close()]);
332
+ if (!failed) {
333
+ for (const outcome of results) if (outcome.status === "rejected") {
334
+ await Promise.allSettled([edited?.close(), copy?.close()]);
335
+ await Promise.reject(outcome.reason);
336
+ }
337
+ }
338
+ }
339
+ }
340
+
341
+ // packages/safe-bash-command-pdftk/src/retained-info-updates.ts
342
+ var styles = { DecimalArabicNumerals: "D", UppercaseRomanNumerals: "R", LowercaseRomanNumerals: "r", UppercaseLetters: "A", LowercaseLetters: "a" };
343
+ async function* lines(chunks, signal) {
344
+ const decoder = new TextDecoder();
345
+ let pending = "", work = 0;
346
+ for await (const bytes of chunks) {
347
+ signal.throwIfAborted();
348
+ pending += decoder.decode(bytes, { stream: true });
349
+ let offset = 0, end;
350
+ while ((end = pending.indexOf("\n", offset)) >= 0) {
351
+ if (++work % 64 === 0) {
352
+ await new Promise((resolve) => setTimeout(resolve, 0));
353
+ signal.throwIfAborted();
354
+ }
355
+ yield pending.slice(offset, end);
356
+ offset = end + 1;
357
+ }
358
+ pending = pending.slice(offset);
359
+ }
360
+ pending += decoder.decode();
361
+ if (pending) yield pending;
362
+ }
363
+ async function* retainedInfoUpdates(chunks, signal) {
364
+ let mode = "none";
365
+ let curKey = "";
366
+ let bmTitle = "";
367
+ let bmLevel = 1;
368
+ let bmPage = 1;
369
+ const pending = [];
370
+ let plNewIndex = 1;
371
+ let plStart = 1;
372
+ let plPrefix = "";
373
+ let plStyle = "DecimalArabicNumerals";
374
+ let pmNumber = 0;
375
+ let pmRotation;
376
+ let pmMediaRect;
377
+ let pmDimensions;
378
+ let pmCropBox;
379
+ const flushStanza = () => {
380
+ if (mode === "bookmark" && bmTitle) {
381
+ pending.push({ kind: "bookmark", title: bmTitle, level: Math.min(Number.MAX_SAFE_INTEGER, Math.max(1, bmLevel)), pageNumber: Math.min(Number.MAX_SAFE_INTEGER, Math.max(1, bmPage)) });
382
+ } else if (mode === "pagelabel") {
383
+ pending.push({
384
+ kind: "label",
385
+ index: Math.max(0, plNewIndex - 1),
386
+ start: Math.max(1, plStart),
387
+ prefix: plPrefix,
388
+ ...styles[plStyle] ? { style: styles[plStyle] } : {}
389
+ });
390
+ } else if (mode === "pagemedia" && pmNumber >= 1) {
391
+ if (pmRotation !== void 0) pending.push({ kind: "page", pageNumber: pmNumber, property: "rotation", values: [Number.isFinite(pmRotation) ? pmRotation : 0] });
392
+ if (pmMediaRect !== void 0) pending.push({ kind: "page", pageNumber: pmNumber, property: "media", values: pmMediaRect });
393
+ if (pmDimensions !== void 0) pending.push({ kind: "page", pageNumber: pmNumber, property: "dimensions", values: pmDimensions });
394
+ if (pmCropBox !== void 0) pending.push({ kind: "page", pageNumber: pmNumber, property: "crop", values: pmCropBox });
395
+ }
396
+ bmTitle = "";
397
+ bmLevel = 1;
398
+ bmPage = 1;
399
+ plNewIndex = 1;
400
+ plStart = 1;
401
+ plPrefix = "";
402
+ plStyle = "DecimalArabicNumerals";
403
+ pmNumber = 0;
404
+ pmRotation = void 0;
405
+ pmMediaRect = void 0;
406
+ pmDimensions = void 0;
407
+ pmCropBox = void 0;
408
+ };
409
+ for await (const raw of lines(chunks, signal)) {
410
+ const line = raw.trim();
411
+ if (line === "InfoBegin") {
412
+ flushStanza();
413
+ yield* pending;
414
+ pending.length = 0;
415
+ mode = "info";
416
+ curKey = "";
417
+ } else if (line === "BookmarkBegin") {
418
+ flushStanza();
419
+ yield* pending;
420
+ pending.length = 0;
421
+ mode = "bookmark";
422
+ } else if (line === "PageLabelBegin") {
423
+ flushStanza();
424
+ yield* pending;
425
+ pending.length = 0;
426
+ mode = "pagelabel";
427
+ } else if (line === "PageMediaBegin") {
428
+ flushStanza();
429
+ yield* pending;
430
+ pending.length = 0;
431
+ mode = "pagemedia";
432
+ } else if (line.startsWith("PdfID0:")) {
433
+ yield { kind: "id", index: 0, bytes: hexToBytes(line.slice("PdfID0:".length)) };
434
+ } else if (line.startsWith("PdfID1:")) {
435
+ yield { kind: "id", index: 1, bytes: hexToBytes(line.slice("PdfID1:".length)) };
436
+ } else if (mode === "info" && line.startsWith("InfoKey:")) {
437
+ curKey = decodePdftkEntities(line.slice("InfoKey:".length).trim());
438
+ } else if (mode === "info" && line.startsWith("InfoValue:") && curKey) {
439
+ const val = decodePdftkEntities(line.slice("InfoValue:".length).trim());
440
+ yield { kind: "info", key: curKey, value: val };
441
+ mode = "none";
442
+ curKey = "";
443
+ } else if (mode === "bookmark" && line.startsWith("BookmarkTitle:")) {
444
+ bmTitle = decodePdftkEntities(line.slice("BookmarkTitle:".length).trim());
445
+ } else if (mode === "bookmark" && line.startsWith("BookmarkLevel:")) {
446
+ bmLevel = Number.parseInt(line.slice("BookmarkLevel:".length).trim(), 10) || 1;
447
+ } else if (mode === "bookmark" && line.startsWith("BookmarkPageNumber:")) {
448
+ bmPage = Number.parseInt(line.slice("BookmarkPageNumber:".length).trim(), 10) || 1;
449
+ } else if (mode === "pagelabel" && line.startsWith("PageLabelNewIndex:")) {
450
+ plNewIndex = Number.parseInt(line.slice("PageLabelNewIndex:".length).trim(), 10) || 1;
451
+ } else if (mode === "pagelabel" && line.startsWith("PageLabelStart:")) {
452
+ plStart = Number.parseInt(line.slice("PageLabelStart:".length).trim(), 10) || 1;
453
+ } else if (mode === "pagelabel" && line.startsWith("PageLabelPrefix:")) {
454
+ plPrefix = decodePdftkEntities(line.slice("PageLabelPrefix:".length).trim());
455
+ } else if (mode === "pagelabel" && line.startsWith("PageLabelNumStyle:")) {
456
+ plStyle = line.slice("PageLabelNumStyle:".length).trim();
457
+ } else if (mode === "pagemedia" && line.startsWith("PageMediaNumber:")) {
458
+ pmNumber = Number.parseInt(line.slice("PageMediaNumber:".length).trim(), 10) || 0;
459
+ } else if (mode === "pagemedia" && line.startsWith("PageMediaRotation:")) {
460
+ pmRotation = Number.parseInt(line.slice("PageMediaRotation:".length).trim(), 10) || 0;
461
+ } else if (mode === "pagemedia" && line.startsWith("PageMediaRect:")) {
462
+ const parts = line.slice("PageMediaRect:".length).trim().split(" ").filter(Boolean).map(Number);
463
+ if (parts.length >= 4 && parts.every(Number.isFinite)) {
464
+ pmMediaRect = [parts[0], parts[1], parts[2], parts[3]];
465
+ }
466
+ } else if (mode === "pagemedia" && line.startsWith("PageMediaDimensions:")) {
467
+ const parts = line.slice("PageMediaDimensions:".length).trim().split(" ").filter(Boolean).map(Number);
468
+ if (parts.length >= 2 && Number.isFinite(parts[0]) && Number.isFinite(parts[1])) {
469
+ pmDimensions = [parts[0], parts[1]];
470
+ }
471
+ } else if (mode === "pagemedia" && (line.startsWith("PageMediaCropBox:") || line.startsWith("PageMediaCropRect:"))) {
472
+ const prefix = line.startsWith("PageMediaCropRect:") ? "PageMediaCropRect:" : "PageMediaCropBox:";
473
+ const parts = line.slice(prefix.length).trim().split(" ").filter(Boolean).map(Number);
474
+ if (parts.length >= 4 && parts.every(Number.isFinite)) {
475
+ pmCropBox = [parts[0], parts[1], parts[2], parts[3]];
476
+ }
477
+ }
478
+ }
479
+ flushStanza();
480
+ yield* pending;
481
+ }
482
+
42
483
  // packages/safe-bash-command-pdftk/src/retained-burst.ts
43
- import { createRetainedPageCopy, saveRetainedDocumentChunks } from "../pdf-ast/index.js";
484
+ import { createRetainedPageCopy as createRetainedPageCopy2, saveRetainedDocumentChunks } from "../pdf-ast/index.js";
44
485
 
45
486
  // packages/safe-bash-command-pdftk/src/retained-inspection.ts
46
- import { IntegerTable, PagedStorage } from "@poe-platform/safe-fs/storage";
47
- import { PdfMutableObjectStore, PdfNameIndex, cosArray, cosNumber, decodePdfString, dictGet } from "../pdf-ast/index.js";
487
+ import { IntegerTable as IntegerTable3, PagedStorage as PagedStorage3 } from "@poe-platform/safe-fs/storage";
488
+ import { PdfMutableObjectStore as PdfMutableObjectStore3, PdfNameIndex as PdfNameIndex3, cosArray as cosArray2, cosNumber as cosNumber2, decodePdfString as decodePdfString3, dictGet as dictGet3 } from "../pdf-ast/index.js";
48
489
  async function* retainedInspectionReport(document, storage, utf8, signal, kind) {
49
- const backing = new PagedStorage({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), pages = new IntegerTable(backing, 64);
490
+ const backing = new PagedStorage3({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), pages = new IntegerTable3(backing, 64);
50
491
  let pageCount = 0, work = 0, failed = false;
51
492
  const encoder = new TextEncoder();
52
493
  async function checkpoint() {
@@ -74,11 +515,11 @@ async function* retainedInspectionReport(document, storage, utf8, signal, kind)
74
515
  }
75
516
  async function* walk(start, key) {
76
517
  if (!start) return;
77
- const stack = new PdfMutableObjectStore(storage, { signal }), seen = new IntegerTable(backing, 64);
518
+ const stack = new PdfMutableObjectStore3(storage, { signal }), seen = new IntegerTable3(backing, 64);
78
519
  let pending = 0, failed2 = false;
79
520
  const push = async (value, level = 1) => {
80
521
  await checkpoint();
81
- await stack.set({ objectNumber: ++pending, generationNumber: 0, value: cosArray([value, cosNumber(level)]) });
522
+ await stack.set({ objectNumber: ++pending, generationNumber: 0, value: cosArray2([value, cosNumber2(level)]) });
82
523
  };
83
524
  try {
84
525
  await push(start);
@@ -99,12 +540,12 @@ async function* retainedInspectionReport(document, storage, utf8, signal, kind)
99
540
  if (value?.kind !== "dict") continue;
100
541
  yield { dict: value, level };
101
542
  if (key === "Outlines") {
102
- const next = dictGet(value, "Next"), first = dictGet(value, "First");
543
+ const next = dictGet3(value, "Next"), first = dictGet3(value, "First");
103
544
  if (next) await push(next, level);
104
545
  if (first) await push(first, level + 1);
105
546
  continue;
106
547
  }
107
- const child = dictGet(value, key);
548
+ const child = dictGet3(value, key);
108
549
  if (key === "Next") {
109
550
  if (child) await push(child);
110
551
  } else {
@@ -124,23 +565,23 @@ async function* retainedInspectionReport(document, storage, utf8, signal, kind)
124
565
  async function destinationIndex(raw) {
125
566
  let node = await resolve(raw);
126
567
  if (node?.kind === "dict") {
127
- const target = dictGet(node, "D") ?? dictGet(node, "Dest");
568
+ const target = dictGet3(node, "D") ?? dictGet3(node, "Dest");
128
569
  if (target) node = await resolve(target);
129
570
  }
130
571
  if (node?.kind === "string" || node?.kind === "name") {
131
- const name = node.kind === "string" ? decodePdfString(node) : node.decoded;
572
+ const name = node.kind === "string" ? decodePdfString3(node) : node.decoded;
132
573
  const root = await resolve(document.crossReference.rootRef);
133
574
  let target;
134
575
  if (root?.kind === "dict") {
135
- const legacy = await resolve(dictGet(root, "Dests"));
136
- if (legacy?.kind === "dict") target = dictGet(legacy, name);
576
+ const legacy = await resolve(dictGet3(root, "Dests"));
577
+ if (legacy?.kind === "dict") target = dictGet3(legacy, name);
137
578
  if (!target) {
138
- const names = await resolve(dictGet(root, "Names"));
139
- if (names?.kind === "dict") for await (const { dict: branch } of walk(dictGet(names, "Dests"), "Kids")) {
140
- const pairs = await resolve(dictGet(branch, "Names"));
579
+ const names = await resolve(dictGet3(root, "Names"));
580
+ if (names?.kind === "dict") for await (const { dict: branch } of walk(dictGet3(names, "Dests"), "Kids")) {
581
+ const pairs = await resolve(dictGet3(branch, "Names"));
141
582
  if (pairs?.kind === "array") for (let i = 0; i + 1 < pairs.items.length; i += 2) {
142
583
  const key = await resolve(pairs.items[i]);
143
- if ((key?.kind === "string" ? decodePdfString(key) : key?.kind === "name" ? key.decoded : "") === name) {
584
+ if ((key?.kind === "string" ? decodePdfString3(key) : key?.kind === "name" ? key.decoded : "") === name) {
144
585
  target = pairs.items[i + 1];
145
586
  break;
146
587
  }
@@ -151,7 +592,7 @@ async function* retainedInspectionReport(document, storage, utf8, signal, kind)
151
592
  }
152
593
  node = await resolve(target);
153
594
  if (node?.kind === "dict") {
154
- const inner = dictGet(node, "D");
595
+ const inner = dictGet3(node, "D");
155
596
  if (inner) node = await resolve(inner);
156
597
  }
157
598
  }
@@ -166,7 +607,7 @@ async function* retainedInspectionReport(document, storage, utf8, signal, kind)
166
607
  }
167
608
  async function destinationText(raw) {
168
609
  const node = await resolve(raw);
169
- if (node?.kind === "string") return decodePdfString(node);
610
+ if (node?.kind === "string") return decodePdfString3(node);
170
611
  if (node?.kind === "name") return node.decoded;
171
612
  if (node?.kind === "array") {
172
613
  const first = node.items[0];
@@ -182,8 +623,8 @@ async function* retainedInspectionReport(document, storage, utf8, signal, kind)
182
623
  return;
183
624
  }
184
625
  async function* stringField(dict, key, label) {
185
- const node = await resolve(dictGet(dict, key));
186
- if (node?.kind === "string") yield* line(label, decodePdfString(node), true);
626
+ const node = await resolve(dictGet3(dict, key));
627
+ if (node?.kind === "string") yield* line(label, decodePdfString3(node), true);
187
628
  }
188
629
  try {
189
630
  for await (const page of document.pages()) {
@@ -191,14 +632,14 @@ async function* retainedInspectionReport(document, storage, utf8, signal, kind)
191
632
  if (page.reference && !await pages.get(BigInt(page.reference.objectNumber))) await pages.set(BigInt(page.reference.objectNumber), BigInt(page.index + 1));
192
633
  }
193
634
  if (kind === "document") {
194
- const emitted = new PdfNameIndex(storage, Infinity, signal);
635
+ const emitted = new PdfNameIndex3(storage, Infinity, signal);
195
636
  let failed2 = false;
196
637
  try {
197
638
  const info = await resolve(document.crossReference.infoRef);
198
639
  if (info?.kind === "dict") {
199
640
  for (const key of ["Title", "Author", "Subject", "Keywords", "Creator", "Producer"]) {
200
- const node = await resolve(dictGet(info, key));
201
- const value = node?.kind === "string" ? decodePdfString(node) : node?.kind === "name" ? node.decoded : "";
641
+ const node = await resolve(dictGet3(info, key));
642
+ const value = node?.kind === "string" ? decodePdfString3(node) : node?.kind === "name" ? node.decoded : "";
202
643
  if (value) {
203
644
  await emitted.intern(key);
204
645
  yield* line("", "InfoBegin");
@@ -207,7 +648,7 @@ async function* retainedInspectionReport(document, storage, utf8, signal, kind)
207
648
  }
208
649
  }
209
650
  for (const entry of info.entries) {
210
- const node = await resolve(entry.value), value = node?.kind === "string" ? decodePdfString(node) : "";
651
+ const node = await resolve(entry.value), value = node?.kind === "string" ? decodePdfString3(node) : "";
211
652
  if (value && (await emitted.intern(entry.key.decoded)).added) {
212
653
  yield* line("", "InfoBegin");
213
654
  yield* line("InfoKey: ", entry.key.decoded, true);
@@ -241,11 +682,11 @@ async function* retainedInspectionReport(document, storage, utf8, signal, kind)
241
682
  yield* line("NumberOfPages: ", pageCount);
242
683
  if (kind === "document") {
243
684
  const catalog = await resolve(document.crossReference.rootRef);
244
- const outlines = catalog?.kind === "dict" ? await resolve(dictGet(catalog, "Outlines")) : void 0;
245
- if (outlines?.kind === "dict") for await (const { dict, level } of walk(dictGet(outlines, "First"), "Outlines")) {
246
- const titleNode = await resolve(dictGet(dict, "Title"));
247
- const title = titleNode?.kind === "string" ? decodePdfString(titleNode) : titleNode?.kind === "name" ? titleNode.decoded : "";
248
- const index = await destinationIndex(dictGet(dict, "Dest") ?? dictGet(dict, "A"));
685
+ const outlines = catalog?.kind === "dict" ? await resolve(dictGet3(catalog, "Outlines")) : void 0;
686
+ if (outlines?.kind === "dict") for await (const { dict, level } of walk(dictGet3(outlines, "First"), "Outlines")) {
687
+ const titleNode = await resolve(dictGet3(dict, "Title"));
688
+ const title = titleNode?.kind === "string" ? decodePdfString3(titleNode) : titleNode?.kind === "name" ? titleNode.decoded : "";
689
+ const index = await destinationIndex(dictGet3(dict, "Dest") ?? dictGet3(dict, "A"));
249
690
  if (title) {
250
691
  yield* line("", "BookmarkBegin");
251
692
  yield* line("BookmarkTitle: ", title, true);
@@ -267,54 +708,54 @@ async function* retainedInspectionReport(document, storage, utf8, signal, kind)
267
708
  for await (const page of document.pages()) {
268
709
  let media, rotate, hasMedia = false, hasRotate = false;
269
710
  for await (const parent of document.pageAncestors(page.dict)) {
270
- if (!hasMedia && dictGet(parent, "MediaBox")) {
711
+ if (!hasMedia && dictGet3(parent, "MediaBox")) {
271
712
  hasMedia = true;
272
- media = dictGet(parent, "MediaBox");
713
+ media = dictGet3(parent, "MediaBox");
273
714
  }
274
- if (!hasRotate && dictGet(parent, "Rotate")) {
715
+ if (!hasRotate && dictGet3(parent, "Rotate")) {
275
716
  hasRotate = true;
276
- rotate = dictGet(parent, "Rotate");
717
+ rotate = dictGet3(parent, "Rotate");
277
718
  }
278
719
  if (hasMedia && hasRotate) break;
279
720
  }
280
721
  const box = await rectangle(media, true) ?? [0, 0, 612, 792], width = Math.abs(box[2] - box[0]), height = Math.abs(box[3] - box[1]);
281
722
  const rotation = await resolve(rotate), norm = rotation?.kind === "number" ? (rotation.value % 360 + 360) % 360 : 0;
282
- const direct = await rectangle(dictGet(page.dict, "MediaBox"), false) ?? [0, 0, width, height];
723
+ const direct = await rectangle(dictGet3(page.dict, "MediaBox"), false) ?? [0, 0, width, height];
283
724
  yield* line("", "PageMediaBegin");
284
725
  yield* line("PageMediaNumber: ", page.index + 1);
285
726
  yield* line("PageMediaRotation: ", norm === 90 || norm === 180 || norm === 270 ? norm : 0);
286
727
  yield* line("PageMediaRect: ", direct.join(" "));
287
728
  yield* line("PageMediaDimensions: ", `${width} ${height}`);
288
- const crop = await rectangle(dictGet(page.dict, "CropBox"), false);
729
+ const crop = await rectangle(dictGet3(page.dict, "CropBox"), false);
289
730
  if (crop) {
290
731
  yield* line("PageMediaCropBox: ", crop.join(" "));
291
732
  yield* line("PageMediaCropRect: ", crop.join(" "));
292
733
  }
293
734
  }
294
- const styles = { D: "DecimalArabicNumerals", R: "UppercaseRomanNumerals", r: "LowercaseRomanNumerals", A: "UppercaseLetters", a: "LowercaseLetters" };
295
- if (catalog?.kind === "dict") for await (const { dict } of walk(dictGet(catalog, "PageLabels"), "Kids")) {
296
- const pairs = await resolve(dictGet(dict, "Nums"));
735
+ const styles2 = { D: "DecimalArabicNumerals", R: "UppercaseRomanNumerals", r: "LowercaseRomanNumerals", A: "UppercaseLetters", a: "LowercaseLetters" };
736
+ if (catalog?.kind === "dict") for await (const { dict } of walk(dictGet3(catalog, "PageLabels"), "Kids")) {
737
+ const pairs = await resolve(dictGet3(dict, "Nums"));
297
738
  if (pairs?.kind !== "array") continue;
298
739
  for (let i = 0; i + 1 < pairs.items.length; i += 2) {
299
740
  const number = await resolve(pairs.items[i]), label = await resolve(pairs.items[i + 1]);
300
741
  if (number?.kind !== "number" || label?.kind !== "dict") continue;
301
- const start = await resolve(dictGet(label, "St")), prefix = await resolve(dictGet(label, "P")), style = await resolve(dictGet(label, "S"));
742
+ const start = await resolve(dictGet3(label, "St")), prefix = await resolve(dictGet3(label, "P")), style = await resolve(dictGet3(label, "S"));
302
743
  yield* line("", "PageLabelBegin");
303
744
  yield* line("PageLabelNewIndex: ", Math.max(1, number.value + 1));
304
745
  yield* line("PageLabelStart: ", start?.kind === "number" ? start.value : 1);
305
- if (prefix?.kind === "string" && decodePdfString(prefix)) yield* line("PageLabelPrefix: ", decodePdfString(prefix), true);
306
- yield* line("PageLabelNumStyle: ", style?.kind === "name" ? styles[style.decoded] ?? "NoNumber" : "NoNumber");
746
+ if (prefix?.kind === "string" && decodePdfString3(prefix)) yield* line("PageLabelPrefix: ", decodePdfString3(prefix), true);
747
+ yield* line("PageLabelNumStyle: ", style?.kind === "name" ? styles2[style.decoded] ?? "NoNumber" : "NoNumber");
307
748
  }
308
749
  }
309
750
  return;
310
751
  }
311
752
  for await (const page of document.pages()) {
312
- const annotations = await resolve(dictGet(page.dict, "Annots"));
753
+ const annotations = await resolve(dictGet3(page.dict, "Annots"));
313
754
  if (annotations?.kind !== "array") continue;
314
755
  for (const item of annotations.items) {
315
756
  const annotation = await resolve(item);
316
757
  if (annotation?.kind !== "dict") continue;
317
- const subtype = await resolve(dictGet(annotation, "Subtype")), rect = await resolve(dictGet(annotation, "Rect"));
758
+ const subtype = await resolve(dictGet3(annotation, "Subtype")), rect = await resolve(dictGet3(annotation, "Rect"));
318
759
  const numbers = [];
319
760
  if (rect?.kind === "array") for (const value of rect.items) {
320
761
  const number = await resolve(value);
@@ -325,7 +766,7 @@ async function* retainedInspectionReport(document, storage, utf8, signal, kind)
325
766
  yield* line("AnnotSubtype: ", subtype?.kind === "name" ? subtype.decoded : "Annot");
326
767
  yield* line("AnnotRect: ", numbers.join(" "));
327
768
  for (const [key, label] of [["NM", "Name"], ["T", "Title"], ["Subj", "Subj"], ["Contents", "Contents"]]) yield* stringField(annotation, key, `Annot${label}: `);
328
- const color = await resolve(dictGet(annotation, "C"));
769
+ const color = await resolve(dictGet3(annotation, "C"));
329
770
  if (color?.kind === "array" && color.items.length >= 3) {
330
771
  const channels = [];
331
772
  for (const value of color.items.slice(0, 3)) {
@@ -334,31 +775,31 @@ async function* retainedInspectionReport(document, storage, utf8, signal, kind)
334
775
  }
335
776
  yield* line("AnnotColor: ", channels.join(" "));
336
777
  }
337
- const open = await resolve(dictGet(annotation, "Open"));
778
+ const open = await resolve(dictGet3(annotation, "Open"));
338
779
  if (open?.kind === "boolean") yield* line("AnnotOpen: ", open.value);
339
780
  yield* stringField(annotation, "M", "AnnotModificationDate: ");
340
- const flags = await resolve(dictGet(annotation, "F"));
781
+ const flags = await resolve(dictGet3(annotation, "F"));
341
782
  yield* line("AnnotFlags: ", flags?.kind === "number" ? flags.value : 0);
342
783
  yield* line("AnnotPageNumber: ", page.index + 1);
343
- const action = dictGet(annotation, "A");
784
+ const action = dictGet3(annotation, "A");
344
785
  if (action) for await (const { dict } of walk(action, "Next")) {
345
- const type = await resolve(dictGet(dict, "S"));
786
+ const type = await resolve(dictGet3(dict, "S"));
346
787
  if (type?.kind === "name" && type.decoded) yield* line("AnnotActionType: ", type.decoded);
347
788
  yield* stringField(dict, "URI", "AnnotActionURI: ");
348
- const dest = dictGet(dict, "D"), text = await destinationText(dest);
789
+ const dest = dictGet3(dict, "D"), text = await destinationText(dest);
349
790
  if (text) yield* line("AnnotActionDest: ", text, true);
350
791
  const index = await destinationIndex(dest ?? dict);
351
792
  if (index !== void 0) yield* line("AnnotActionPageNumber: ", index + 1);
352
- const file = await resolve(dictGet(dict, "F"));
353
- if (file?.kind === "string") yield* line("AnnotActionFile: ", decodePdfString(file), true);
793
+ const file = await resolve(dictGet3(dict, "F"));
794
+ if (file?.kind === "string") yield* line("AnnotActionFile: ", decodePdfString3(file), true);
354
795
  else if (file?.kind === "dict") {
355
- const name = await resolve(dictGet(file, "UF") ?? dictGet(file, "F"));
356
- if (name?.kind === "string") yield* line("AnnotActionFile: ", decodePdfString(name), true);
796
+ const name = await resolve(dictGet3(file, "UF") ?? dictGet3(file, "F"));
797
+ if (name?.kind === "string") yield* line("AnnotActionFile: ", decodePdfString3(name), true);
357
798
  }
358
799
  }
359
- else if (dictGet(annotation, "Dest")) {
800
+ else if (dictGet3(annotation, "Dest")) {
360
801
  yield* line("AnnotActionType: ", "GoTo");
361
- const dest = dictGet(annotation, "Dest"), text = await destinationText(dest);
802
+ const dest = dictGet3(annotation, "Dest"), text = await destinationText(dest);
362
803
  if (text) yield* line("AnnotActionDest: ", text, true);
363
804
  const index = await destinationIndex(dest);
364
805
  if (index !== void 0) yield* line("AnnotActionPageNumber: ", index + 1);
@@ -385,7 +826,7 @@ async function* retainedBurst(document, storage, options, pageCount, signal) {
385
826
  signal.throwIfAborted();
386
827
  const path = formatBurstFilename(pattern, index + 1);
387
828
  if (path === "-" || path === report) continue;
388
- const copy = await createRetainedPageCopy(document, [index], storage, { signal });
829
+ const copy = await createRetainedPageCopy2(document, [index], storage, { signal });
389
830
  let failed = false;
390
831
  try {
391
832
  const chunks = options.compressStreams || options.uncompressStreams ? saveRetainedDocumentChunks(await copy.openDocument(), storage, { signal, streamMode: options.uncompressStreams ? "uncompress" : "compress" }) : copy.chunks();
@@ -403,9 +844,9 @@ async function* retainedBurst(document, storage, options, pageCount, signal) {
403
844
  }
404
845
 
405
846
  // packages/safe-bash-command-pdftk/src/retained-rotate.ts
406
- import { PagedStorage as PagedStorage2 } from "@poe-platform/safe-fs/storage";
847
+ import { PagedStorage as PagedStorage4 } from "@poe-platform/safe-fs/storage";
407
848
  async function* retainedRotations(args, handles, primaryHandle, pageCount, storage, signal) {
408
- const records = new PagedStorage2({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
849
+ const records = new PagedStorage4({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4);
409
850
  const base = records.allocate(pageCount * 16);
410
851
  let failed = false, work = 0;
411
852
  try {
@@ -435,32 +876,40 @@ async function* retainedRotations(args, handles, primaryHandle, pageCount, stora
435
876
  }
436
877
 
437
878
  // packages/safe-bash-command-pdftk/src/retained-output.ts
438
- import { editRetainedDocument, PdfFileSource, PdfMutableObjectStore as PdfMutableObjectStore2, PdfRetainedDocument, cosBool, dictDelete, dictGet as dictGet2, dictSet, encryptRetainedPdfChunks, retainedCosObjects, saveRetainedDocumentChunks as saveRetainedDocumentChunks2 } from "../pdf-ast/index.js";
439
- async function* retainedOutput(source, storage, options, selectedId, signal, handles, pageCount, attachments, attachmentPage, stamps) {
440
- const store = new PdfMutableObjectStore2(storage, { signal });
879
+ import { parseRetainedFormData, editRetainedDocument as editRetainedDocument2, PdfFileSource as PdfFileSource3, PdfMutableObjectStore as PdfMutableObjectStore4, PdfRetainedDocument, cosBool, cosName, dictDelete, dictGet as dictGet4, dictSet as dictSet2, encryptRetainedPdfChunks, retainedCosObjects, saveRetainedDocumentChunks as saveRetainedDocumentChunks2 } from "../pdf-ast/index.js";
880
+ async function* retainedOutput(source, storage, options, selectedId, signal, handles, pageCount, attachments, attachmentPage, stamps, info, formData) {
881
+ const infoUpdates = info?.updates;
882
+ const store = new PdfMutableObjectStore4(storage, { signal });
441
883
  let edited;
442
884
  let document, plaintext, failed = false;
443
885
  try {
444
- if (options.operation === "attach_files" || stamps) {
886
+ if (options.operation === "attach_files" || stamps || infoUpdates || formData) {
445
887
  const pageIndex = attachmentPage !== void 0 && pageCount > 0 ? attachmentPage.toLowerCase() === "end" ? pageCount - 1 : Math.max(0, Math.min(pageCount - 1, (Number.parseInt(attachmentPage, 10) || 1) - 1)) : void 0;
446
- edited = await editRetainedDocument(source, storage, { signal, ...options.operation === "attach_files" ? { appendAttachments: attachments } : {}, ...stamps ? { stamps } : {}, ...pageIndex !== void 0 ? { attachmentPageIndex: pageIndex } : {} });
888
+ edited = await editRetainedDocument2(source, storage, { signal, ...formData ? { formUpdates: parseRetainedFormData(formData, storage, { signal }) } : {}, ...infoUpdates ? { infoUpdates } : {}, ...options.operation === "attach_files" ? { appendAttachments: attachments } : {}, ...stamps ? { stamps } : {}, ...pageIndex !== void 0 ? { attachmentPageIndex: pageIndex } : {} });
447
889
  }
448
890
  const input = edited?.document ?? source;
449
891
  const pageReferences = edited ? { pageReferences: async function* () {
450
892
  for await (const page of input.pages()) if (page.reference) yield page.reference;
451
893
  } } : {};
452
- for await (const object of retainedCosObjects(input, storage, { signal })) await store.set(object);
453
- const reference = source.crossReference;
454
- const idArray = options.keepFinalId || options.keepFirstId ? selectedId ?? reference.idArray : reference.idArray ?? selectedId;
894
+ for await (const object of retainedCosObjects(input, storage, { signal })) {
895
+ if (formData && options.replacementFont && object.value.kind === "dict") {
896
+ const subtype = dictGet4(object.value, "Subtype"), font = dictGet4(object.value, "BaseFont");
897
+ if (subtype?.kind === "name" && subtype.decoded === "Type1" && font?.kind === "name" && font.decoded === "Helvetica") dictSet2(object.value, "BaseFont", cosName(options.replacementFont.startsWith("/") ? options.replacementFont.slice(1) : options.replacementFont));
898
+ }
899
+ await store.set(object);
900
+ }
901
+ const reference = input.crossReference;
902
+ const chosenId = info?.useUpdatedId ? reference.idArray : selectedId;
903
+ const idArray = options.keepFinalId || options.keepFirstId ? chosenId ?? reference.idArray : reference.idArray ?? chosenId;
455
904
  document = await PdfRetainedDocument.openStore(store, storage, { rootRef: reference.rootRef, version: reference.version, ...pageReferences, ...reference.infoRef ? { infoRef: reference.infoRef } : {}, ...idArray ? { idArray } : {}, signal });
456
905
  const root = await document.lookup(reference.rootRef);
457
906
  if (root?.value.kind === "dict" && !root.stream && root.reference) {
458
- const form = await document.lookup(dictGet2(root.value, "AcroForm"));
907
+ const form = await document.lookup(dictGet4(root.value, "AcroForm"));
459
908
  if (form?.value.kind === "dict" && !form.stream) {
460
909
  if (options.dropXfa) dictDelete(form.value, "XFA");
461
- if (options.needAppearances) dictSet(form.value, "NeedAppearances", cosBool(true));
910
+ if (formData || options.needAppearances) dictSet2(form.value, "NeedAppearances", cosBool(options.needAppearances));
462
911
  if (form.reference) await store.set({ objectNumber: form.reference.objectNumber, generationNumber: form.reference.generationNumber, value: form.value });
463
- else dictSet(root.value, "AcroForm", form.value);
912
+ else dictSet2(root.value, "AcroForm", form.value);
464
913
  }
465
914
  await store.set({ objectNumber: root.reference.objectNumber, generationNumber: root.reference.generationNumber, value: root.value });
466
915
  }
@@ -469,7 +918,7 @@ async function* retainedOutput(source, storage, options, selectedId, signal, han
469
918
  yield* chunks;
470
919
  return;
471
920
  }
472
- plaintext = await PdfFileSource.fromStream(storage.fs, storage.directory, chunks, { signal });
921
+ plaintext = await PdfFileSource3.fromStream(storage.fs, storage.directory, chunks, { signal });
473
922
  const allow = options.allowPermissions, all = allow.has("allfeatures");
474
923
  yield* encryptRetainedPdfChunks(plaintext, storage, {
475
924
  userPassword: options.userPassword ?? "",
@@ -489,117 +938,12 @@ async function* retainedOutput(source, storage, options, selectedId, signal, han
489
938
  }
490
939
  }
491
940
 
492
- // packages/safe-bash-command-pdftk/src/retained-unpack.ts
493
- import { IntegerTable as IntegerTable2, PagedStorage as PagedStorage3 } from "@poe-platform/safe-fs/storage";
494
- import { PdfFileSource as PdfFileSource2, PdfMutableObjectStore as PdfMutableObjectStore3, PdfNameIndex as PdfNameIndex2, cosDict, cosString, decodePdfString as decodePdfString2, dictGet as dictGet3 } from "../pdf-ast/index.js";
495
- async function* retainedUnpack(document, storage, directory, inputNames, signal) {
496
- const names = new PdfNameIndex2(storage, Infinity, signal), outputs = new PdfMutableObjectStore3(storage, { signal });
497
- const stack = new PdfMutableObjectStore3(storage, { signal }), backing = new PagedStorage3({ fs: storage.fs, cwd: storage.directory, env: {}, signal }, 4), seen = new IntegerTable2(backing, 64);
498
- const cleanDir = directory.endsWith("/") ? directory.slice(0, -1) : directory;
499
- let pending = 0, work = 0, failed = false;
500
- async function checkpoint() {
501
- signal.throwIfAborted();
502
- if (++work % 64 === 0) await new Promise((resolve2) => setTimeout(resolve2, 0));
503
- signal.throwIfAborted();
504
- }
505
- async function resolve(node) {
506
- await checkpoint();
507
- const found = await document.lookup(node);
508
- return found?.stream ? void 0 : found?.value;
509
- }
510
- async function spec(raw, fallback = "attachment.bin") {
511
- const dict = await resolve(raw);
512
- if (dict?.kind !== "dict") return;
513
- const filename = await resolve(dictGet3(dict, "UF") ?? dictGet3(dict, "F"));
514
- const name = filename?.kind === "string" ? decodePdfString2(filename) : fallback;
515
- const leaf = name.slice(Math.max(name.lastIndexOf("/"), name.lastIndexOf("\\")) + 1);
516
- if (!leaf || leaf === "." || leaf === ".." || leaf.includes("\0")) throw new Error("Invalid embedded attachment filename");
517
- const ef = await resolve(dictGet3(dict, "EF"));
518
- if (ef?.kind !== "dict") return;
519
- const data = await document.lookup(dictGet3(ef, "UF") ?? dictGet3(ef, "F") ?? dictGet3(ef, "DOS") ?? dictGet3(ef, "Mac") ?? dictGet3(ef, "Unix"));
520
- if (!data?.stream || !data.reference) return;
521
- const path = cleanDir && cleanDir !== "." ? `${cleanDir}/${leaf}` : leaf;
522
- const nameIndex = await names.intern(path);
523
- const staged = await PdfFileSource2.fromStream(storage.fs, storage.directory, document.objects.decodeStream(data.reference.objectNumber, data.reference.generationNumber), { signal });
524
- let failed2 = false;
525
- try {
526
- await outputs.set({ objectNumber: nameIndex.index + 1, generationNumber: 0, value: cosDict({ Path: cosString(path) }), stream: { length: staged.size, chunks: staged.stream(0, staged.size, signal) } });
527
- } catch (error) {
528
- failed2 = true;
529
- throw error;
530
- } finally {
531
- await staged.close().catch((error) => {
532
- if (!failed2) throw error;
533
- });
534
- }
535
- }
536
- const push = async (value) => {
537
- await checkpoint();
538
- await stack.set({ objectNumber: ++pending, generationNumber: 0, value });
539
- };
540
- async function associated(raw) {
541
- const array = await resolve(raw);
542
- if (array?.kind === "array") for (const item of array.items) await spec(item);
543
- }
544
- try {
545
- for (const name of inputNames) await names.intern(name);
546
- const root = await resolve(document.crossReference.rootRef);
547
- if (root?.kind === "dict") {
548
- const dictionary = await resolve(dictGet3(root, "Names")), tree = dictionary?.kind === "dict" ? dictGet3(dictionary, "EmbeddedFiles") : void 0;
549
- if (tree) await push(tree);
550
- while (pending) {
551
- await checkpoint();
552
- const raw = (await stack.get(pending--)).value;
553
- if (raw.kind === "ref") {
554
- if (await seen.get(BigInt(raw.objectNumber))) continue;
555
- await seen.set(BigInt(raw.objectNumber), 1n);
556
- }
557
- const branch = await resolve(raw);
558
- if (branch?.kind !== "dict") continue;
559
- const pairs = await resolve(dictGet3(branch, "Names"));
560
- if (pairs?.kind === "array") for (let i = 0; i + 1 < pairs.items.length; i += 2) {
561
- const name = await resolve(pairs.items[i]);
562
- await spec(pairs.items[i + 1], name?.kind === "string" ? decodePdfString2(name) : "attachment.bin");
563
- }
564
- const kids = await resolve(dictGet3(branch, "Kids"));
565
- if (kids?.kind === "array") for (let i = kids.items.length - 1; i >= 0; i--) await push(kids.items[i]);
566
- }
567
- await associated(dictGet3(root, "AF"));
568
- }
569
- for await (const page of document.pages()) {
570
- await associated(dictGet3(page.dict, "AF"));
571
- const annotations = await resolve(dictGet3(page.dict, "Annots"));
572
- if (annotations?.kind === "array") for (const raw of annotations.items) {
573
- const annotation = await resolve(raw);
574
- if (annotation?.kind !== "dict") continue;
575
- const type = await resolve(dictGet3(annotation, "Subtype"));
576
- if (type?.kind === "name" && type.decoded === "FileAttachment") await spec(dictGet3(annotation, "FS"));
577
- }
578
- }
579
- for await (const output of outputs.objects()) {
580
- const path = output.value.kind === "dict" ? dictGet3(output.value, "Path") : void 0;
581
- if (path?.kind === "string" && output.stream) {
582
- const name = decodePdfString2(path);
583
- if (name !== "-") yield { path: name, chunks: output.stream.chunks };
584
- }
585
- }
586
- } catch (error) {
587
- failed = true;
588
- throw error;
589
- } finally {
590
- const results = await Promise.allSettled([names.close(), outputs.close(), stack.close(), backing.close()]);
591
- if (!failed) {
592
- for (const result of results) if (result.status === "rejected") await Promise.reject(result.reason);
593
- }
594
- }
595
- }
596
-
597
941
  // packages/safe-bash-command-pdftk/src/retained-fdf.ts
598
- import { PdfError, PdfFileSource as PdfFileSource3, PdfMutableObjectStore as PdfMutableObjectStore4, PdfNameIndex as PdfNameIndex3, cosArray as cosArray2, cosDict as cosDict2, cosNumber as cosNumber2, cosString as cosString2, decodePdfString as decodePdfString3, dictGet as dictGet4 } from "../pdf-ast/index.js";
942
+ import { PdfError, PdfFileSource as PdfFileSource4, PdfMutableObjectStore as PdfMutableObjectStore5, PdfNameIndex as PdfNameIndex4, cosArray as cosArray3, cosDict as cosDict3, cosNumber as cosNumber3, cosString as cosString3, decodePdfString as decodePdfString4, dictGet as dictGet5 } from "../pdf-ast/index.js";
599
943
  async function* retainedFdf(document, storage, signal) {
600
- const names = new PdfNameIndex3(storage, Infinity, signal);
601
- const values = new PdfMutableObjectStore4(storage, { signal });
602
- const tree = new PdfMutableObjectStore4(storage, { signal });
944
+ const names = new PdfNameIndex4(storage, Infinity, signal);
945
+ const values = new PdfMutableObjectStore5(storage, { signal });
946
+ const tree = new PdfMutableObjectStore5(storage, { signal });
603
947
  const encoder = new TextEncoder();
604
948
  let work = 0, failed = false;
605
949
  async function checkpoint() {
@@ -661,17 +1005,17 @@ async function* retainedFdf(document, storage, signal) {
661
1005
  const string = (items, at) => {
662
1006
  const node = items[at];
663
1007
  if (node?.kind !== "string") throw new PdfError("E_PARSE", "Invalid FDF traversal name");
664
- return decodePdfString3(node);
1008
+ return decodePdfString4(node);
665
1009
  };
666
- const save = async (id, items) => tree.set({ objectNumber: id, generationNumber: 0, value: cosArray2(items) });
1010
+ const save = async (id, items) => tree.set({ objectNumber: id, generationNumber: 0, value: cosArray3(items) });
667
1011
  try {
668
1012
  for await (const field of document.formFieldDetails()) {
669
1013
  for await (const ignored of field.options()) void ignored;
670
1014
  const name = await names.intern(field.name);
671
- const staged = await PdfFileSource3.fromStream(storage.fs, storage.directory, fieldValue(field), { signal });
1015
+ const staged = await PdfFileSource4.fromStream(storage.fs, storage.directory, fieldValue(field), { signal });
672
1016
  let valueFailed = false;
673
1017
  try {
674
- await values.set({ objectNumber: name.index + 1, generationNumber: 0, value: cosDict2({}), stream: { length: staged.size, chunks: staged.stream(0, staged.size, signal) } });
1018
+ await values.set({ objectNumber: name.index + 1, generationNumber: 0, value: cosDict3({}), stream: { length: staged.size, chunks: staged.stream(0, staged.size, signal) } });
675
1019
  } catch (error) {
676
1020
  valueFailed = true;
677
1021
  throw error;
@@ -682,25 +1026,25 @@ async function* retainedFdf(document, storage, signal) {
682
1026
  }
683
1027
  }
684
1028
  const catalog = await resolve(document.crossReference.rootRef);
685
- const form = catalog?.kind === "dict" ? await resolve(dictGet4(catalog, "AcroForm")) : void 0;
686
- const roots = form?.kind === "dict" ? await resolve(dictGet4(form, "Fields")) : void 0;
687
- await save(1, [cosDict2({}), cosString2(""), cosString2(""), ...Array.from({ length: 6 }, () => cosNumber2(0))]);
1029
+ const form = catalog?.kind === "dict" ? await resolve(dictGet5(catalog, "AcroForm")) : void 0;
1030
+ const roots = form?.kind === "dict" ? await resolve(dictGet5(form, "Fields")) : void 0;
1031
+ await save(1, [cosDict3({}), cosString3(""), cosString3(""), ...Array.from({ length: 6 }, () => cosNumber3(0))]);
688
1032
  let top = 1, next = 1;
689
1033
  while (top) {
690
1034
  await checkpoint();
691
1035
  const frame = await record(top), node = await resolve(frame[0]);
692
- const kids = top === 1 ? roots : node?.kind === "dict" ? await resolve(dictGet4(node, "Kids")) : void 0;
1036
+ const kids = top === 1 ? roots : node?.kind === "dict" ? await resolve(dictGet5(node, "Kids")) : void 0;
693
1037
  let descended = false, cursor = number(frame, 3);
694
1038
  while (kids?.kind === "array" && cursor < kids.items.length) {
695
1039
  const childNode = kids.items[cursor++], child = await resolve(childNode);
696
- if (child?.kind !== "dict" || top !== 1 && !dictGet4(child, "T")) continue;
697
- const name = await resolve(dictGet4(child, "T")), partial = name?.kind === "string" ? decodePdfString3(name) : "";
1040
+ if (child?.kind !== "dict" || top !== 1 && !dictGet5(child, "T")) continue;
1041
+ const name = await resolve(dictGet5(child, "T")), partial = name?.kind === "string" ? decodePdfString4(name) : "";
698
1042
  const prefix = string(frame, 1), full = prefix && partial ? `${prefix}.${partial}` : partial || prefix;
699
1043
  const depth = number(frame, 8) + 1;
700
1044
  if (depth > document.depthLimit) throw new PdfError("E_LIMIT", "PDF FDF field depth limit exceeded");
701
- frame[3] = cosNumber2(cursor);
1045
+ frame[3] = cosNumber3(cursor);
702
1046
  await save(top, frame);
703
- await save(++next, [childNode, cosString2(full), cosString2(partial), cosNumber2(0), cosNumber2(0), cosNumber2(0), cosNumber2(0), cosNumber2(top), cosNumber2(depth)]);
1047
+ await save(++next, [childNode, cosString3(full), cosString3(partial), cosNumber3(0), cosNumber3(0), cosNumber3(0), cosNumber3(0), cosNumber3(top), cosNumber3(depth)]);
704
1048
  top = next;
705
1049
  descended = true;
706
1050
  break;
@@ -711,10 +1055,10 @@ async function* retainedFdf(document, storage, signal) {
711
1055
  const owner = await record(parent), last = number(owner, 5);
712
1056
  if (last) {
713
1057
  const sibling = await record(last);
714
- sibling[6] = cosNumber2(top);
1058
+ sibling[6] = cosNumber3(top);
715
1059
  await save(last, sibling);
716
- } else owner[4] = cosNumber2(top);
717
- owner[5] = cosNumber2(top);
1060
+ } else owner[4] = cosNumber3(top);
1061
+ owner[5] = cosNumber3(top);
718
1062
  await save(parent, owner);
719
1063
  }
720
1064
  top = parent;
@@ -737,11 +1081,11 @@ async function* retainedFdf(document, storage, signal) {
737
1081
  const name = await names.intern(string(frame, 1)), value = name.added ? void 0 : await values.get(name.index + 1);
738
1082
  if (value?.stream) yield* value.stream.chunks;
739
1083
  else {
740
- const dict = await resolve(frame[0]), raw = dict?.kind === "dict" ? await resolve(dictGet4(dict, "V")) : void 0;
1084
+ const dict = await resolve(frame[0]), raw = dict?.kind === "dict" ? await resolve(dictGet5(dict, "V")) : void 0;
741
1085
  if (raw?.kind === "name") yield* text(`/${raw.decoded}`);
742
1086
  else {
743
1087
  yield* text("(");
744
- if (raw?.kind === "string") yield* text(decodePdfString3(raw), true);
1088
+ if (raw?.kind === "string") yield* text(decodePdfString4(raw), true);
745
1089
  yield* text(")");
746
1090
  }
747
1091
  }
@@ -803,7 +1147,7 @@ async function* retainedFieldReport(document, utf8, signal) {
803
1147
  }
804
1148
 
805
1149
  // packages/safe-bash-command-pdftk/src/retained.ts
806
- import { PdfError as PdfError2, PdfFileSource as PdfFileSource4, PdfRetainedDocument as PdfRetainedDocument2, retainedCosObjects as retainedCosObjects2 } from "../pdf-ast/index.js";
1150
+ import { PdfError as PdfError2, PdfFileSource as PdfFileSource5, PdfRetainedDocument as PdfRetainedDocument2, retainedCosObjects as retainedCosObjects2 } from "../pdf-ast/index.js";
807
1151
  import { FsError } from "../safe-bash-contracts/errors.js";
808
1152
  import { writeBytes } from "../safe-bash-contracts/io.js";
809
1153
  import { resolvePath } from "../safe-bash-contracts/path.js";
@@ -821,6 +1165,8 @@ async function executeRetainedPdftk(context, options) {
821
1165
  let selectedId;
822
1166
  const counts = /* @__PURE__ */ new Map();
823
1167
  const inputs = /* @__PURE__ */ new Map();
1168
+ const formPath = options.operation === "fill_form" ? options.opArgs[0] ?? "-" : void 0;
1169
+ const infoPath = options.operation === "update_info" || options.operation === "update_info_utf8" ? options.opArgs[0] ?? "-" : void 0;
824
1170
  const overlayPath = ["stamp", "multistamp", "background", "multibackground"].includes(options.operation) ? options.opArgs[0] ?? "-" : void 0;
825
1171
  const attachmentPaths = [];
826
1172
  let attachmentPage;
@@ -834,6 +1180,7 @@ async function executeRetainedPdftk(context, options) {
834
1180
  if (source) yield { filename: path.slice(path.lastIndexOf("/") + 1), chunks: source.stream(0, source.size, signal) };
835
1181
  }
836
1182
  }
1183
+ let assembled;
837
1184
  let overlayDocument;
838
1185
  let document, output, total = 0, failed = false;
839
1186
  const diagnostic = async (message) => {
@@ -843,17 +1190,17 @@ async function executeRetainedPdftk(context, options) {
843
1190
  try {
844
1191
  await context.fs.mkdir(storage.directory, { recursive: true, signal });
845
1192
  const maximum = context.inputBudget?.maxBytes ?? Infinity;
846
- if (options.inputs.some((input) => input.file === "-") || attachmentPaths.includes("-") || overlayPath === "-") {
847
- const source = await PdfFileSource4.fromStream(context.fs, storage.directory, context.stdin, { signal, maxInputBytes: maximum });
1193
+ if (options.inputs.some((input) => input.file === "-") || attachmentPaths.includes("-") || overlayPath === "-" || infoPath === "-" || formPath === "-") {
1194
+ const source = await PdfFileSource5.fromStream(context.fs, storage.directory, context.stdin, { signal, maxInputBytes: maximum });
848
1195
  inputs.set("-", source);
849
1196
  total += source.size;
850
1197
  context.inputBudget?.check(total);
851
1198
  }
852
- for (const input of [...options.inputs, ...attachmentPaths.map((file) => ({ file })), ...overlayPath !== void 0 ? [{ file: overlayPath }] : []]) {
1199
+ for (const input of [...options.inputs, ...attachmentPaths.map((file) => ({ file })), ...overlayPath !== void 0 ? [{ file: overlayPath }] : [], ...infoPath !== void 0 ? [{ file: infoPath }] : [], ...formPath !== void 0 ? [{ file: formPath }] : []]) {
853
1200
  if (inputs.has(input.file)) continue;
854
1201
  let source;
855
1202
  try {
856
- source = await PdfFileSource4.open(context.fs, resolvePath(context.cwd, input.file), { signal, maxInputBytes: maximum - total });
1203
+ source = await PdfFileSource5.open(context.fs, resolvePath(context.cwd, input.file), { signal, maxInputBytes: maximum - total });
857
1204
  } catch (error) {
858
1205
  signal.throwIfAborted();
859
1206
  if (error instanceof Error && "code" in error && ["ENOENT", "ENOTDIR", "EACCES", "EISDIR"].includes(String(error.code)) || error instanceof PdfError2 && error.message === "PDF source must be a regular file") {
@@ -891,6 +1238,12 @@ async function executeRetainedPdftk(context, options) {
891
1238
  await source.releaseCache();
892
1239
  }
893
1240
  document = await PdfRetainedDocument2.open(inputs.get(primary.file), storage, { signal, recovery: "strict", ...primary.password ? { password: primary.password } : {} });
1241
+ const formSource = formPath === void 0 ? void 0 : inputs.get(formPath);
1242
+ if (formPath !== void 0 && !formSource) return await diagnostic(`Error: Unable to open form data file '${formPath}'
1243
+ `);
1244
+ const infoSource = infoPath === void 0 ? void 0 : inputs.get(infoPath);
1245
+ if (infoPath !== void 0 && !infoSource) return await diagnostic(`Error: Unable to open info file '${infoPath}'
1246
+ `);
894
1247
  let overlayPages = 0;
895
1248
  if (overlayPath !== void 0) {
896
1249
  const source = inputs.get(overlayPath);
@@ -920,7 +1273,10 @@ async function executeRetainedPdftk(context, options) {
920
1273
  }
921
1274
  return { exitCode: 0 };
922
1275
  }
923
- output = await PdfFileSource4.fromStream(context.fs, storage.directory, ["output", "rotate", "attach_files", "stamp", "multistamp", "background", "multibackground"].includes(options.operation) ? retainedOutput(document, storage, options, selectedId, signal, new Map([...handles].map(([handle, input]) => [handle, { pageCount: counts.get(input) }])), counts.get(primary), attachments(), attachmentPage, overlayDocument ? [{ source: overlayDocument, mode: options.operation.includes("background") ? "underlay" : "overlay", preserveStreams: true, pages: stampPages() }] : void 0) : options.operation === "generate_fdf" ? retainedFdf(document, storage, signal) : options.operation === "dump_data_fields" || options.operation === "dump_data_fields_utf8" ? retainedFieldReport(document, options.operation.endsWith("_utf8"), signal) : retainedInspectionReport(document, storage, options.operation.endsWith("_utf8"), signal, options.operation === "dump_data" || options.operation === "dump_data_utf8" ? "document" : "annotations"), { signal });
1276
+ if (options.operation === "cat" || options.operation === "shuffle") {
1277
+ assembled = await assembleRetainedPdftk(document, storage, options, counts, handles, async (input) => PdfRetainedDocument2.open(inputs.get(input.file), storage, { signal, recovery: "strict", ...input.password ? { password: input.password } : {} }), signal);
1278
+ }
1279
+ output = await PdfFileSource5.fromStream(context.fs, storage.directory, ["output", "rotate", "attach_files", "stamp", "multistamp", "background", "multibackground", "update_info", "update_info_utf8", "cat", "shuffle", "fill_form"].includes(options.operation) ? retainedOutput(assembled?.document ?? document, storage, options, selectedId, signal, new Map([...handles].map(([handle, input]) => [handle, { pageCount: counts.get(input) }])), counts.get(primary), attachments(), attachmentPage, overlayDocument ? [{ source: overlayDocument, mode: options.operation.includes("background") ? "underlay" : "overlay", preserveStreams: true, pages: stampPages() }] : void 0, infoSource ? { updates: retainedInfoUpdates(infoSource.stream(0, infoSource.size, signal), signal), useUpdatedId: idInput === primary } : void 0, formSource) : options.operation === "generate_fdf" ? retainedFdf(document, storage, signal) : options.operation === "dump_data_fields" || options.operation === "dump_data_fields_utf8" ? retainedFieldReport(document, options.operation.endsWith("_utf8"), signal) : retainedInspectionReport(document, storage, options.operation.endsWith("_utf8"), signal, options.operation === "dump_data" || options.operation === "dump_data_utf8" ? "document" : "annotations"), { signal });
924
1280
  const destination = options.outputTarget;
925
1281
  if (!destination || destination === "-") for await (const bytes of output.stream(0, output.size, signal)) await writeBytes(context.stdout, bytes, signal);
926
1282
  else {
@@ -938,7 +1294,7 @@ async function executeRetainedPdftk(context, options) {
938
1294
  failed = true;
939
1295
  throw error;
940
1296
  } finally {
941
- const results = await Promise.allSettled([document?.close(), overlayDocument?.close(), output?.close(), ...[...inputs.values()].map((source) => source?.close())]);
1297
+ const results = await Promise.allSettled([assembled?.close(), document?.close(), overlayDocument?.close(), output?.close(), ...[...inputs.values()].map((source) => source?.close())]);
942
1298
  if (!failed) {
943
1299
  for (const result of results) if (result.status === "rejected") await Promise.reject(result.reason);
944
1300
  }
@@ -1151,17 +1507,17 @@ import { readBytes, writeBytes as writeBytes2 } from "../safe-bash-contracts/io.
1151
1507
  import { createOutputOperation } from "../safe-bash-contracts/output.js";
1152
1508
  import {
1153
1509
  PdfDocument,
1154
- cosArray as cosArray3,
1155
- cosDict as cosDict3,
1510
+ cosArray as cosArray4,
1511
+ cosDict as cosDict4,
1156
1512
  cosHexString,
1157
- cosName,
1158
- cosNumber as cosNumber3,
1513
+ cosName as cosName2,
1514
+ cosNumber as cosNumber4,
1159
1515
  cosStream,
1160
- cosString as cosString3,
1161
- decodePdfString as decodePdfString4,
1516
+ cosString as cosString4,
1517
+ decodePdfString as decodePdfString5,
1162
1518
  dictDelete as dictDelete2,
1163
- dictGet as dictGet5,
1164
- dictSet as dictSet2,
1519
+ dictGet as dictGet6,
1520
+ dictSet as dictSet3,
1165
1521
  flattenDocumentFormFields,
1166
1522
  getDocumentFormFields,
1167
1523
  parseFormDataBytes,
@@ -1286,27 +1642,6 @@ function encodePdftkText(str, utf8) {
1286
1642
  }
1287
1643
  return out;
1288
1644
  }
1289
- function decodePdftkEntities(str) {
1290
- let out = "";
1291
- let i = 0;
1292
- while (i < str.length) {
1293
- if (str[i] === "&" && str[i + 1] === "#") {
1294
- const semi = str.indexOf(";", i + 2);
1295
- if (semi !== -1) {
1296
- const body = str.slice(i + 2, semi);
1297
- const cp = body.startsWith("x") || body.startsWith("X") ? Number.parseInt(body.slice(1), 16) : Number.parseInt(body, 10);
1298
- if (Number.isFinite(cp) && cp >= 0) {
1299
- out += String.fromCodePoint(cp);
1300
- i = semi + 1;
1301
- continue;
1302
- }
1303
- }
1304
- }
1305
- out += str[i];
1306
- i++;
1307
- }
1308
- return out;
1309
- }
1310
1645
  function escapeFdfString(str) {
1311
1646
  return str.replaceAll("\\", "\\\\").replaceAll("(", "\\(").replaceAll(")", "\\)").replaceAll("\r", "\\r").replaceAll("\n", "\\n");
1312
1647
  }
@@ -1327,102 +1662,102 @@ function formatDumpDataFields(doc, utf8 = true) {
1327
1662
  } else {
1328
1663
  valStr = String(field.value ?? "");
1329
1664
  }
1330
- const lines = [
1665
+ const lines2 = [
1331
1666
  "---",
1332
1667
  `FieldType: ${fieldType}`,
1333
1668
  `FieldName: ${encodePdftkText(field.name, utf8)}`
1334
1669
  ];
1335
1670
  if (field.altName) {
1336
- lines.push(`FieldNameAlt: ${encodePdftkText(field.altName, utf8)}`);
1671
+ lines2.push(`FieldNameAlt: ${encodePdftkText(field.altName, utf8)}`);
1337
1672
  }
1338
- lines.push(`FieldFlags: ${flags}`);
1673
+ lines2.push(`FieldFlags: ${flags}`);
1339
1674
  if (field.selectedValues && field.selectedValues.length > 0) {
1340
1675
  for (const sv of field.selectedValues) {
1341
- lines.push(`FieldValue: ${encodePdftkText(sv, utf8)}`);
1676
+ lines2.push(`FieldValue: ${encodePdftkText(sv, utf8)}`);
1342
1677
  }
1343
1678
  } else {
1344
- lines.push(`FieldValue: ${encodePdftkText(valStr, utf8)}`);
1679
+ lines2.push(`FieldValue: ${encodePdftkText(valStr, utf8)}`);
1345
1680
  }
1346
1681
  if (field.defaultValue !== void 0 && field.defaultValue !== "") {
1347
- lines.push(`FieldValueDefault: ${encodePdftkText(field.defaultValue, utf8)}`);
1682
+ lines2.push(`FieldValueDefault: ${encodePdftkText(field.defaultValue, utf8)}`);
1348
1683
  }
1349
- lines.push(`FieldJustification: ${field.justification ?? "Left"}`);
1684
+ lines2.push(`FieldJustification: ${field.justification ?? "Left"}`);
1350
1685
  for (const opt of options) {
1351
- lines.push(`FieldStateOption: ${encodePdftkText(opt, utf8)}`);
1686
+ lines2.push(`FieldStateOption: ${encodePdftkText(opt, utf8)}`);
1352
1687
  }
1353
1688
  if (field.maxLength !== void 0) {
1354
- lines.push(`FieldMaxLength: ${field.maxLength}`);
1689
+ lines2.push(`FieldMaxLength: ${field.maxLength}`);
1355
1690
  }
1356
- stanzas.push(lines.join("\n"));
1691
+ stanzas.push(lines2.join("\n"));
1357
1692
  }
1358
1693
  return stanzas.join("\n") + "\n";
1359
1694
  }
1360
1695
  function formatDumpDataAnnots(doc, utf8 = false) {
1361
- const lines = [];
1696
+ const lines2 = [];
1362
1697
  const id0Node = doc.cos.idArray?.items[0] ? doc.cos.resolve(doc.cos.idArray.items[0]) : void 0;
1363
1698
  const id1Node = doc.cos.idArray?.items[1] ? doc.cos.resolve(doc.cos.idArray.items[1]) : void 0;
1364
1699
  const id0Hex = id0Node?.kind === "string" ? bytesToHexLower(id0Node.bytes) : "00000000000000000000000000000000";
1365
1700
  const id1Hex = id1Node?.kind === "string" ? bytesToHexLower(id1Node.bytes) : "00000000000000000000000000000000";
1366
- lines.push(`PdfID0: ${id0Hex}`);
1367
- lines.push(`PdfID1: ${id1Hex}`);
1368
- lines.push(`NumberOfPages: ${doc.pageCount}`);
1701
+ lines2.push(`PdfID0: ${id0Hex}`);
1702
+ lines2.push(`PdfID1: ${id1Hex}`);
1703
+ lines2.push(`NumberOfPages: ${doc.pageCount}`);
1369
1704
  for (let p = 0; p < doc.pageCount; p++) {
1370
1705
  const pageDict = doc.getPage(p).pageDict;
1371
- const annotsArr = doc.cos.resolveArray(dictGet5(pageDict, "Annots"));
1706
+ const annotsArr = doc.cos.resolveArray(dictGet6(pageDict, "Annots"));
1372
1707
  if (!annotsArr) continue;
1373
1708
  for (const item of annotsArr.items) {
1374
1709
  const annotDict = doc.cos.resolveDict(item);
1375
1710
  if (!annotDict) continue;
1376
- const subNode = doc.cos.resolve(dictGet5(annotDict, "Subtype"));
1711
+ const subNode = doc.cos.resolve(dictGet6(annotDict, "Subtype"));
1377
1712
  const subtype = subNode?.kind === "name" ? subNode.decoded : "Annot";
1378
- const rectArr = doc.cos.resolveArray(dictGet5(annotDict, "Rect"));
1713
+ const rectArr = doc.cos.resolveArray(dictGet6(annotDict, "Rect"));
1379
1714
  const rectNums = rectArr ? rectArr.items.map((it) => {
1380
1715
  const r = doc.cos.resolve(it);
1381
1716
  return r?.kind === "number" ? r.value : 0;
1382
1717
  }) : [0, 0, 0, 0];
1383
- const flagsNode = doc.cos.resolve(dictGet5(annotDict, "F"));
1718
+ const flagsNode = doc.cos.resolve(dictGet6(annotDict, "F"));
1384
1719
  const flags = flagsNode?.kind === "number" ? flagsNode.value : 0;
1385
- lines.push("---");
1386
- lines.push(`AnnotSubtype: ${subtype}`);
1387
- lines.push(`AnnotRect: ${rectNums.slice(0, 4).join(" ")}`);
1388
- const nmNode = doc.cos.resolve(dictGet5(annotDict, "NM"));
1720
+ lines2.push("---");
1721
+ lines2.push(`AnnotSubtype: ${subtype}`);
1722
+ lines2.push(`AnnotRect: ${rectNums.slice(0, 4).join(" ")}`);
1723
+ const nmNode = doc.cos.resolve(dictGet6(annotDict, "NM"));
1389
1724
  if (nmNode?.kind === "string") {
1390
- lines.push(`AnnotName: ${encodePdftkText(decodePdfString4(nmNode), utf8)}`);
1725
+ lines2.push(`AnnotName: ${encodePdftkText(decodePdfString5(nmNode), utf8)}`);
1391
1726
  }
1392
- const tNode = doc.cos.resolve(dictGet5(annotDict, "T"));
1727
+ const tNode = doc.cos.resolve(dictGet6(annotDict, "T"));
1393
1728
  if (tNode?.kind === "string") {
1394
- lines.push(`AnnotTitle: ${encodePdftkText(decodePdfString4(tNode), utf8)}`);
1729
+ lines2.push(`AnnotTitle: ${encodePdftkText(decodePdfString5(tNode), utf8)}`);
1395
1730
  }
1396
- const subjNode = doc.cos.resolve(dictGet5(annotDict, "Subj"));
1731
+ const subjNode = doc.cos.resolve(dictGet6(annotDict, "Subj"));
1397
1732
  if (subjNode?.kind === "string") {
1398
- lines.push(`AnnotSubj: ${encodePdftkText(decodePdfString4(subjNode), utf8)}`);
1733
+ lines2.push(`AnnotSubj: ${encodePdftkText(decodePdfString5(subjNode), utf8)}`);
1399
1734
  }
1400
- const cNode = doc.cos.resolve(dictGet5(annotDict, "Contents"));
1735
+ const cNode = doc.cos.resolve(dictGet6(annotDict, "Contents"));
1401
1736
  if (cNode?.kind === "string") {
1402
- lines.push(`AnnotContents: ${encodePdftkText(decodePdfString4(cNode), utf8)}`);
1737
+ lines2.push(`AnnotContents: ${encodePdftkText(decodePdfString5(cNode), utf8)}`);
1403
1738
  }
1404
- const colArr = doc.cos.resolveArray(dictGet5(annotDict, "C"));
1739
+ const colArr = doc.cos.resolveArray(dictGet6(annotDict, "C"));
1405
1740
  if (colArr && colArr.items.length >= 3) {
1406
1741
  const colNums = colArr.items.slice(0, 3).map((it) => {
1407
1742
  const r = doc.cos.resolve(it);
1408
1743
  return r?.kind === "number" ? r.value : 0;
1409
1744
  });
1410
- lines.push(`AnnotColor: ${colNums.join(" ")}`);
1745
+ lines2.push(`AnnotColor: ${colNums.join(" ")}`);
1411
1746
  }
1412
- const openNode = doc.cos.resolve(dictGet5(annotDict, "Open"));
1747
+ const openNode = doc.cos.resolve(dictGet6(annotDict, "Open"));
1413
1748
  if (openNode?.kind === "boolean") {
1414
- lines.push(`AnnotOpen: ${openNode.value}`);
1749
+ lines2.push(`AnnotOpen: ${openNode.value}`);
1415
1750
  }
1416
- const mNode = doc.cos.resolve(dictGet5(annotDict, "M"));
1751
+ const mNode = doc.cos.resolve(dictGet6(annotDict, "M"));
1417
1752
  if (mNode?.kind === "string") {
1418
- lines.push(`AnnotModificationDate: ${encodePdftkText(decodePdfString4(mNode), utf8)}`);
1753
+ lines2.push(`AnnotModificationDate: ${encodePdftkText(decodePdfString5(mNode), utf8)}`);
1419
1754
  }
1420
- lines.push(`AnnotFlags: ${flags}`);
1421
- lines.push(`AnnotPageNumber: ${p + 1}`);
1755
+ lines2.push(`AnnotFlags: ${flags}`);
1756
+ lines2.push(`AnnotPageNumber: ${p + 1}`);
1422
1757
  const formatDestTarget = (dRaw) => {
1423
1758
  if (!dRaw) return void 0;
1424
1759
  const resolved = doc.cos.resolve(dRaw);
1425
- if (resolved?.kind === "string") return decodePdfString4(resolved);
1760
+ if (resolved?.kind === "string") return decodePdfString5(resolved);
1426
1761
  if (resolved?.kind === "name") return resolved.decoded;
1427
1762
  if (resolved?.kind === "array" && resolved.items.length > 0) {
1428
1763
  const first = resolved.items[0];
@@ -1455,53 +1790,53 @@ function formatDumpDataAnnots(doc, utf8 = false) {
1455
1790
  }
1456
1791
  const actionDict = doc.cos.resolveDict(aNode);
1457
1792
  if (!actionDict) return;
1458
- const sNode = doc.cos.resolve(dictGet5(actionDict, "S"));
1793
+ const sNode = doc.cos.resolve(dictGet6(actionDict, "S"));
1459
1794
  const sType = sNode?.kind === "name" ? sNode.decoded : "";
1460
1795
  if (sType) {
1461
- lines.push(`AnnotActionType: ${sType}`);
1796
+ lines2.push(`AnnotActionType: ${sType}`);
1462
1797
  }
1463
- const uriNode = doc.cos.resolve(dictGet5(actionDict, "URI"));
1798
+ const uriNode = doc.cos.resolve(dictGet6(actionDict, "URI"));
1464
1799
  if (uriNode?.kind === "string") {
1465
- lines.push(`AnnotActionURI: ${encodePdftkText(decodePdfString4(uriNode), utf8)}`);
1800
+ lines2.push(`AnnotActionURI: ${encodePdftkText(decodePdfString5(uriNode), utf8)}`);
1466
1801
  }
1467
- const dNode = dictGet5(actionDict, "D");
1802
+ const dNode = dictGet6(actionDict, "D");
1468
1803
  const destTarget = formatDestTarget(dNode);
1469
1804
  if (destTarget) {
1470
- lines.push(`AnnotActionDest: ${encodePdftkText(destTarget, utf8)}`);
1805
+ lines2.push(`AnnotActionDest: ${encodePdftkText(destTarget, utf8)}`);
1471
1806
  }
1472
1807
  const resolvedIdx = resolveDestinationPageIndex(doc, dNode ?? actionDict);
1473
1808
  if (resolvedIdx !== void 0) {
1474
- lines.push(`AnnotActionPageNumber: ${resolvedIdx + 1}`);
1809
+ lines2.push(`AnnotActionPageNumber: ${resolvedIdx + 1}`);
1475
1810
  }
1476
- const fRaw = doc.cos.resolve(dictGet5(actionDict, "F"));
1811
+ const fRaw = doc.cos.resolve(dictGet6(actionDict, "F"));
1477
1812
  if (fRaw?.kind === "string") {
1478
- lines.push(`AnnotActionFile: ${encodePdftkText(decodePdfString4(fRaw), utf8)}`);
1813
+ lines2.push(`AnnotActionFile: ${encodePdftkText(decodePdfString5(fRaw), utf8)}`);
1479
1814
  } else if (fRaw?.kind === "dict") {
1480
- const ufNode = doc.cos.resolve(dictGet5(fRaw, "UF") ?? dictGet5(fRaw, "F"));
1815
+ const ufNode = doc.cos.resolve(dictGet6(fRaw, "UF") ?? dictGet6(fRaw, "F"));
1481
1816
  if (ufNode?.kind === "string") {
1482
- lines.push(`AnnotActionFile: ${encodePdftkText(decodePdfString4(ufNode), utf8)}`);
1817
+ lines2.push(`AnnotActionFile: ${encodePdftkText(decodePdfString5(ufNode), utf8)}`);
1483
1818
  }
1484
1819
  }
1485
- emitActionChain(dictGet5(actionDict, "Next"), visited);
1820
+ emitActionChain(dictGet6(actionDict, "Next"), visited);
1486
1821
  };
1487
- const rawA = dictGet5(annotDict, "A");
1822
+ const rawA = dictGet6(annotDict, "A");
1488
1823
  if (rawA) {
1489
1824
  emitActionChain(rawA);
1490
- } else if (dictGet5(annotDict, "Dest")) {
1491
- lines.push("AnnotActionType: GoTo");
1492
- const dNode = dictGet5(annotDict, "Dest");
1825
+ } else if (dictGet6(annotDict, "Dest")) {
1826
+ lines2.push("AnnotActionType: GoTo");
1827
+ const dNode = dictGet6(annotDict, "Dest");
1493
1828
  const destTarget = formatDestTarget(dNode);
1494
1829
  if (destTarget) {
1495
- lines.push(`AnnotActionDest: ${encodePdftkText(destTarget, utf8)}`);
1830
+ lines2.push(`AnnotActionDest: ${encodePdftkText(destTarget, utf8)}`);
1496
1831
  }
1497
1832
  const resolvedIdx = resolveDestinationPageIndex(doc, dNode);
1498
1833
  if (resolvedIdx !== void 0) {
1499
- lines.push(`AnnotActionPageNumber: ${resolvedIdx + 1}`);
1834
+ lines2.push(`AnnotActionPageNumber: ${resolvedIdx + 1}`);
1500
1835
  }
1501
1836
  }
1502
1837
  }
1503
1838
  }
1504
- return lines.join("\n") + "\n";
1839
+ return lines2.join("\n") + "\n";
1505
1840
  }
1506
1841
  function copyPrimaryMetadata(srcDoc, dstDoc) {
1507
1842
  const meta = srcDoc.getMetadata();
@@ -1535,18 +1870,18 @@ function collectOutlineBookmarks(doc, firstNode, level, out, visited = /* @__PUR
1535
1870
  }
1536
1871
  const dict = doc.cos.resolveDict(curr);
1537
1872
  if (!dict) break;
1538
- const titleNode = doc.cos.resolve(dictGet5(dict, "Title"));
1539
- const title = titleNode?.kind === "string" ? decodePdfString4(titleNode) : titleNode?.kind === "name" ? titleNode.decoded : "";
1540
- const resolvedIdx = resolveDestinationPageIndex(doc, dictGet5(dict, "Dest") ?? dictGet5(dict, "A"));
1873
+ const titleNode = doc.cos.resolve(dictGet6(dict, "Title"));
1874
+ const title = titleNode?.kind === "string" ? decodePdfString5(titleNode) : titleNode?.kind === "name" ? titleNode.decoded : "";
1875
+ const resolvedIdx = resolveDestinationPageIndex(doc, dictGet6(dict, "Dest") ?? dictGet6(dict, "A"));
1541
1876
  const pageNumber = resolvedIdx !== void 0 ? resolvedIdx + 1 : 1;
1542
1877
  if (title) {
1543
1878
  out.push({ title, level, pageNumber });
1544
1879
  }
1545
- const childFirst = dictGet5(dict, "First");
1880
+ const childFirst = dictGet6(dict, "First");
1546
1881
  if (childFirst) {
1547
1882
  collectOutlineBookmarks(doc, childFirst, level + 1, out, visited);
1548
1883
  }
1549
- curr = dictGet5(dict, "Next");
1884
+ curr = dictGet6(dict, "Next");
1550
1885
  }
1551
1886
  }
1552
1887
  function collectNameTreePairs(doc, nodeOrRef, out, visited = /* @__PURE__ */ new Set()) {
@@ -1557,16 +1892,16 @@ function collectNameTreePairs(doc, nodeOrRef, out, visited = /* @__PURE__ */ new
1557
1892
  }
1558
1893
  const dict = doc.cos.resolveDict(nodeOrRef);
1559
1894
  if (!dict) return;
1560
- const namesArr = doc.cos.resolveArray(dictGet5(dict, "Names"));
1895
+ const namesArr = doc.cos.resolveArray(dictGet6(dict, "Names"));
1561
1896
  if (namesArr) {
1562
1897
  for (let i = 0; i + 1 < namesArr.items.length; i += 2) {
1563
1898
  const k = doc.cos.resolve(namesArr.items[i]);
1564
1899
  const v = namesArr.items[i + 1];
1565
- const name = k?.kind === "string" ? decodePdfString4(k) : "attachment.bin";
1900
+ const name = k?.kind === "string" ? decodePdfString5(k) : "attachment.bin";
1566
1901
  out.push({ name, value: v });
1567
1902
  }
1568
1903
  }
1569
- const kidsArr = doc.cos.resolveArray(dictGet5(dict, "Kids"));
1904
+ const kidsArr = doc.cos.resolveArray(dictGet6(dict, "Kids"));
1570
1905
  if (kidsArr) {
1571
1906
  for (const kid of kidsArr.items) {
1572
1907
  collectNameTreePairs(doc, kid, out, visited);
@@ -1581,7 +1916,7 @@ function collectNumberTreePairs(doc, nodeOrRef, out, visited = /* @__PURE__ */ n
1581
1916
  }
1582
1917
  const dict = doc.cos.resolveDict(nodeOrRef);
1583
1918
  if (!dict) return;
1584
- const numsArr = doc.cos.resolveArray(dictGet5(dict, "Nums"));
1919
+ const numsArr = doc.cos.resolveArray(dictGet6(dict, "Nums"));
1585
1920
  if (numsArr) {
1586
1921
  for (let i = 0; i + 1 < numsArr.items.length; i += 2) {
1587
1922
  const k = doc.cos.resolve(numsArr.items[i]);
@@ -1591,7 +1926,7 @@ function collectNumberTreePairs(doc, nodeOrRef, out, visited = /* @__PURE__ */ n
1591
1926
  }
1592
1927
  }
1593
1928
  }
1594
- const kidsArr = doc.cos.resolveArray(dictGet5(dict, "Kids"));
1929
+ const kidsArr = doc.cos.resolveArray(dictGet6(dict, "Kids"));
1595
1930
  if (kidsArr) {
1596
1931
  for (const kid of kidsArr.items) {
1597
1932
  collectNumberTreePairs(doc, kid, out, visited);
@@ -1605,19 +1940,9 @@ function bytesToHexLower(bytes) {
1605
1940
  }
1606
1941
  return hex;
1607
1942
  }
1608
- function hexToBytes(hex) {
1609
- const clean = hex.trim();
1610
- const len = Math.floor(clean.length / 2);
1611
- const out = new Uint8Array(len);
1612
- for (let i = 0; i < len; i++) {
1613
- const byteVal = Number.parseInt(clean.slice(i * 2, i * 2 + 2), 16);
1614
- out[i] = Number.isNaN(byteVal) ? 0 : byteVal;
1615
- }
1616
- return out;
1617
- }
1618
1943
  function formatDumpData(doc, utf8 = true) {
1619
1944
  const meta = doc.getMetadata();
1620
- const lines = [];
1945
+ const lines2 = [];
1621
1946
  const emittedKeys = /* @__PURE__ */ new Set();
1622
1947
  const infoEntries = [
1623
1948
  ["Title", meta.title],
@@ -1630,7 +1955,7 @@ function formatDumpData(doc, utf8 = true) {
1630
1955
  for (const [key, val] of infoEntries) {
1631
1956
  if (val !== void 0 && val !== "") {
1632
1957
  emittedKeys.add(key);
1633
- lines.push(
1958
+ lines2.push(
1634
1959
  "InfoBegin",
1635
1960
  `InfoKey: ${encodePdftkText(key, utf8)}`,
1636
1961
  `InfoValue: ${encodePdftkText(val, utf8)}`
@@ -1645,10 +1970,10 @@ function formatDumpData(doc, utf8 = true) {
1645
1970
  if (emittedKeys.has(k)) continue;
1646
1971
  const r = doc.cos.resolve(entry.value);
1647
1972
  if (r?.kind === "string") {
1648
- const val = decodePdfString4(r);
1973
+ const val = decodePdfString5(r);
1649
1974
  if (val) {
1650
1975
  emittedKeys.add(k);
1651
- lines.push(
1976
+ lines2.push(
1652
1977
  "InfoBegin",
1653
1978
  `InfoKey: ${encodePdftkText(k, utf8)}`,
1654
1979
  `InfoValue: ${encodePdftkText(val, utf8)}`
@@ -1662,16 +1987,16 @@ function formatDumpData(doc, utf8 = true) {
1662
1987
  const id1Node = doc.cos.idArray?.items[1] ? doc.cos.resolve(doc.cos.idArray.items[1]) : void 0;
1663
1988
  const id0Hex = id0Node?.kind === "string" ? bytesToHexLower(id0Node.bytes) : "00000000000000000000000000000000";
1664
1989
  const id1Hex = id1Node?.kind === "string" ? bytesToHexLower(id1Node.bytes) : "00000000000000000000000000000000";
1665
- lines.push(`PdfID0: ${id0Hex}`);
1666
- lines.push(`PdfID1: ${id1Hex}`);
1667
- lines.push(`NumberOfPages: ${doc.pageCount}`);
1990
+ lines2.push(`PdfID0: ${id0Hex}`);
1991
+ lines2.push(`PdfID1: ${id1Hex}`);
1992
+ lines2.push(`NumberOfPages: ${doc.pageCount}`);
1668
1993
  const catalog = doc.cos.resolveDict(doc.cos.rootRef);
1669
- const outlinesDict = catalog ? doc.cos.resolveDict(dictGet5(catalog, "Outlines")) : void 0;
1994
+ const outlinesDict = catalog ? doc.cos.resolveDict(dictGet6(catalog, "Outlines")) : void 0;
1670
1995
  if (outlinesDict) {
1671
1996
  const bookmarks = [];
1672
- collectOutlineBookmarks(doc, dictGet5(outlinesDict, "First"), 1, bookmarks);
1997
+ collectOutlineBookmarks(doc, dictGet6(outlinesDict, "First"), 1, bookmarks);
1673
1998
  for (const bm of bookmarks) {
1674
- lines.push(
1999
+ lines2.push(
1675
2000
  "BookmarkBegin",
1676
2001
  `BookmarkTitle: ${encodePdftkText(bm.title, utf8)}`,
1677
2002
  `BookmarkLevel: ${bm.level}`,
@@ -1683,7 +2008,7 @@ function formatDumpData(doc, utf8 = true) {
1683
2008
  const page = doc.getPage(i);
1684
2009
  const { width, height } = page.getSize();
1685
2010
  const rot = page.getRotation();
1686
- const mbArr = doc.cos.resolveArray(dictGet5(page.pageDict, "MediaBox"));
2011
+ const mbArr = doc.cos.resolveArray(dictGet6(page.pageDict, "MediaBox"));
1687
2012
  let mbRectStr = `0 0 ${width} ${height}`;
1688
2013
  if (mbArr && mbArr.items.length >= 4) {
1689
2014
  const mbNums = mbArr.items.slice(0, 4).map((item) => {
@@ -1692,50 +2017,50 @@ function formatDumpData(doc, utf8 = true) {
1692
2017
  });
1693
2018
  mbRectStr = `${mbNums[0]} ${mbNums[1]} ${mbNums[2]} ${mbNums[3]}`;
1694
2019
  }
1695
- lines.push(
2020
+ lines2.push(
1696
2021
  "PageMediaBegin",
1697
2022
  `PageMediaNumber: ${i + 1}`,
1698
2023
  `PageMediaRotation: ${rot}`,
1699
2024
  `PageMediaRect: ${mbRectStr}`,
1700
2025
  `PageMediaDimensions: ${width} ${height}`
1701
2026
  );
1702
- const cbArr = doc.cos.resolveArray(dictGet5(page.pageDict, "CropBox"));
2027
+ const cbArr = doc.cos.resolveArray(dictGet6(page.pageDict, "CropBox"));
1703
2028
  if (cbArr && cbArr.items.length >= 4) {
1704
2029
  const nums = cbArr.items.slice(0, 4).map((item) => {
1705
2030
  const r = doc.cos.resolve(item);
1706
2031
  return r?.kind === "number" ? r.value : 0;
1707
2032
  });
1708
- lines.push(`PageMediaCropBox: ${nums[0]} ${nums[1]} ${nums[2]} ${nums[3]}`);
1709
- lines.push(`PageMediaCropRect: ${nums[0]} ${nums[1]} ${nums[2]} ${nums[3]}`);
2033
+ lines2.push(`PageMediaCropBox: ${nums[0]} ${nums[1]} ${nums[2]} ${nums[3]}`);
2034
+ lines2.push(`PageMediaCropRect: ${nums[0]} ${nums[1]} ${nums[2]} ${nums[3]}`);
1710
2035
  }
1711
2036
  }
1712
2037
  const pageLabelsPairs = [];
1713
2038
  if (catalog) {
1714
- collectNumberTreePairs(doc, dictGet5(catalog, "PageLabels"), pageLabelsPairs);
2039
+ collectNumberTreePairs(doc, dictGet6(catalog, "PageLabels"), pageLabelsPairs);
1715
2040
  }
1716
2041
  for (const pair of pageLabelsPairs) {
1717
2042
  const lblDict = doc.cos.resolveDict(pair.value);
1718
2043
  if (lblDict) {
1719
2044
  const newIndex = Math.max(1, pair.num + 1);
1720
- const stNode = doc.cos.resolve(dictGet5(lblDict, "St"));
2045
+ const stNode = doc.cos.resolve(dictGet6(lblDict, "St"));
1721
2046
  const startNum = stNode?.kind === "number" ? stNode.value : 1;
1722
- const pNode = doc.cos.resolve(dictGet5(lblDict, "P"));
1723
- const prefix = pNode?.kind === "string" ? decodePdfString4(pNode) : void 0;
1724
- const sNode = doc.cos.resolve(dictGet5(lblDict, "S"));
2047
+ const pNode = doc.cos.resolve(dictGet6(lblDict, "P"));
2048
+ const prefix = pNode?.kind === "string" ? decodePdfString5(pNode) : void 0;
2049
+ const sNode = doc.cos.resolve(dictGet6(lblDict, "S"));
1725
2050
  const styleCode = sNode?.kind === "name" ? sNode.decoded : "";
1726
2051
  const numStyle = PDF_TO_PAGE_LABEL_STYLE[styleCode] ?? "NoNumber";
1727
- lines.push(
2052
+ lines2.push(
1728
2053
  "PageLabelBegin",
1729
2054
  `PageLabelNewIndex: ${newIndex}`,
1730
2055
  `PageLabelStart: ${startNum}`
1731
2056
  );
1732
2057
  if (prefix !== void 0 && prefix !== "") {
1733
- lines.push(`PageLabelPrefix: ${encodePdftkText(prefix, utf8)}`);
2058
+ lines2.push(`PageLabelPrefix: ${encodePdftkText(prefix, utf8)}`);
1734
2059
  }
1735
- lines.push(`PageLabelNumStyle: ${numStyle}`);
2060
+ lines2.push(`PageLabelNumStyle: ${numStyle}`);
1736
2061
  }
1737
2062
  }
1738
- return lines.join("\n") + "\n";
2063
+ return lines2.join("\n") + "\n";
1739
2064
  }
1740
2065
  function formatGenerateFdf(doc) {
1741
2066
  const fields = getDocumentFormFields(doc.cos);
@@ -1752,23 +2077,23 @@ function formatGenerateFdf(doc) {
1752
2077
  }
1753
2078
  return `(${escapeFdfString(String(f.value ?? ""))})`;
1754
2079
  }
1755
- const vNode = doc.cos.resolve(dictGet5(dict, "V"));
2080
+ const vNode = doc.cos.resolve(dictGet6(dict, "V"));
1756
2081
  if (vNode?.kind === "name") return `/${vNode.decoded}`;
1757
- if (vNode?.kind === "string") return `(${escapeFdfString(decodePdfString4(vNode))})`;
2082
+ if (vNode?.kind === "string") return `(${escapeFdfString(decodePdfString5(vNode))})`;
1758
2083
  return "()";
1759
2084
  };
1760
2085
  const serializeCosFieldNode = (nodeOrRef, prefix) => {
1761
2086
  const dict = doc.cos.resolveDict(nodeOrRef);
1762
2087
  if (!dict) return void 0;
1763
- const tNode = doc.cos.resolve(dictGet5(dict, "T"));
1764
- const partialName = tNode?.kind === "string" ? decodePdfString4(tNode) : "";
2088
+ const tNode = doc.cos.resolve(dictGet6(dict, "T"));
2089
+ const partialName = tNode?.kind === "string" ? decodePdfString5(tNode) : "";
1765
2090
  const fullName = prefix && partialName ? `${prefix}.${partialName}` : partialName || prefix;
1766
- const kidsArr = doc.cos.resolveArray(dictGet5(dict, "Kids"));
2091
+ const kidsArr = doc.cos.resolveArray(dictGet6(dict, "Kids"));
1767
2092
  const namedKids = [];
1768
2093
  if (kidsArr) {
1769
2094
  for (const k of kidsArr.items) {
1770
2095
  const kDict = doc.cos.resolveDict(k);
1771
- if (kDict && dictGet5(kDict, "T")) {
2096
+ if (kDict && dictGet6(kDict, "T")) {
1772
2097
  const serializedKid = serializeCosFieldNode(k, fullName);
1773
2098
  if (serializedKid) namedKids.push(serializedKid);
1774
2099
  }
@@ -1782,8 +2107,8 @@ function formatGenerateFdf(doc) {
1782
2107
  };
1783
2108
  const entries = [];
1784
2109
  const catalog = doc.cos.resolveDict(doc.cos.rootRef);
1785
- const acroForm = catalog ? doc.cos.resolveDict(dictGet5(catalog, "AcroForm")) : void 0;
1786
- const fieldsArr = acroForm ? doc.cos.resolveArray(dictGet5(acroForm, "Fields")) : void 0;
2110
+ const acroForm = catalog ? doc.cos.resolveDict(dictGet6(catalog, "AcroForm")) : void 0;
2111
+ const fieldsArr = acroForm ? doc.cos.resolveArray(dictGet6(acroForm, "Fields")) : void 0;
1787
2112
  if (fieldsArr && fieldsArr.items.length > 0) {
1788
2113
  for (const item of fieldsArr.items) {
1789
2114
  const s = serializeCosFieldNode(item, "");
@@ -1791,7 +2116,7 @@ function formatGenerateFdf(doc) {
1791
2116
  }
1792
2117
  } else {
1793
2118
  for (const f of fields) {
1794
- entries.push(`<< /T (${escapeFdfString(f.name)}) /V ${formatFieldVal(f.name, cosDict3({}))} >>`);
2119
+ entries.push(`<< /T (${escapeFdfString(f.name)}) /V ${formatFieldVal(f.name, cosDict4({}))} >>`);
1795
2120
  }
1796
2121
  }
1797
2122
  return `%FDF-1.2
@@ -1809,9 +2134,9 @@ function setDocumentBookmarks(doc, bookmarks) {
1809
2134
  if (bookmarks.length === 0 || doc.pageCount === 0) return;
1810
2135
  const catalog = doc.cos.resolveDict(doc.cos.rootRef);
1811
2136
  if (!catalog) return;
1812
- const outlinesDict = cosDict3({ Type: cosName("Outlines") });
2137
+ const outlinesDict = cosDict4({ Type: cosName2("Outlines") });
1813
2138
  const outlinesRef = doc.cos.allocateObject(outlinesDict);
1814
- dictSet2(catalog, "Outlines", outlinesRef);
2139
+ dictSet3(catalog, "Outlines", outlinesRef);
1815
2140
  const stack = [{ ref: outlinesRef, dict: outlinesDict, children: [] }];
1816
2141
  for (const bm of bookmarks) {
1817
2142
  const targetLevel = Math.max(1, bm.level);
@@ -1830,26 +2155,26 @@ function setDocumentBookmarks(doc, bookmarks) {
1830
2155
  const parentState = stack[stack.length - 1];
1831
2156
  const pageIdx = Math.max(0, Math.min(doc.pageCount - 1, bm.pageNumber - 1));
1832
2157
  const pageRef = doc.getPage(pageIdx).ref;
1833
- const itemDict = cosDict3({
1834
- Title: cosString3(bm.title),
2158
+ const itemDict = cosDict4({
2159
+ Title: cosString4(bm.title),
1835
2160
  Parent: parentState.ref,
1836
- Dest: cosArray3([pageRef, cosName("XYZ"), { kind: "null" }, { kind: "null" }, { kind: "null" }])
2161
+ Dest: cosArray4([pageRef, cosName2("XYZ"), { kind: "null" }, { kind: "null" }, { kind: "null" }])
1837
2162
  });
1838
2163
  const itemRef = doc.cos.allocateObject(itemDict);
1839
2164
  const prevSibling = parentState.children[parentState.children.length - 1];
1840
2165
  if (prevSibling) {
1841
- dictSet2(prevSibling.dict, "Next", itemRef);
1842
- dictSet2(itemDict, "Prev", prevSibling.ref);
2166
+ dictSet3(prevSibling.dict, "Next", itemRef);
2167
+ dictSet3(itemDict, "Prev", prevSibling.ref);
1843
2168
  } else {
1844
- dictSet2(parentState.dict, "First", itemRef);
2169
+ dictSet3(parentState.dict, "First", itemRef);
1845
2170
  }
1846
- dictSet2(parentState.dict, "Last", itemRef);
2171
+ dictSet3(parentState.dict, "Last", itemRef);
1847
2172
  parentState.children.push({ ref: itemRef, dict: itemDict });
1848
- dictSet2(parentState.dict, "Count", cosNumber3(parentState.children.length));
2173
+ dictSet3(parentState.dict, "Count", cosNumber4(parentState.children.length));
1849
2174
  }
1850
2175
  }
1851
2176
  function applyUpdateInfoText(doc, text) {
1852
- const lines = text.replaceAll("\r\n", "\n").split("\n");
2177
+ const lines2 = text.replaceAll("\r\n", "\n").split("\n");
1853
2178
  let mode = "none";
1854
2179
  let curKey = "";
1855
2180
  let bmTitle = "";
@@ -1901,7 +2226,7 @@ function applyUpdateInfoText(doc, text) {
1901
2226
  pmDimensions = void 0;
1902
2227
  pmCropBox = void 0;
1903
2228
  };
1904
- for (const raw of lines) {
2229
+ for (const raw of lines2) {
1905
2230
  const line = raw.trim();
1906
2231
  if (line === "InfoBegin") {
1907
2232
  flushStanza();
@@ -1936,7 +2261,7 @@ function applyUpdateInfoText(doc, text) {
1936
2261
  }
1937
2262
  const infoDict = doc.cos.infoRef ? doc.cos.resolveDict(doc.cos.infoRef) : void 0;
1938
2263
  if (infoDict) {
1939
- dictSet2(infoDict, curKey, cosString3(val));
2264
+ dictSet3(infoDict, curKey, cosString4(val));
1940
2265
  }
1941
2266
  }
1942
2267
  mode = "none";
@@ -1983,7 +2308,7 @@ function applyUpdateInfoText(doc, text) {
1983
2308
  const existing1 = doc.cos.idArray?.items[1] && doc.cos.resolve(doc.cos.idArray.items[1])?.kind === "string" ? doc.cos.resolve(doc.cos.idArray.items[1]).bytes : existing0;
1984
2309
  const b0 = pdfId0Hex !== void 0 ? hexToBytes(pdfId0Hex) : existing0;
1985
2310
  const b1 = pdfId1Hex !== void 0 ? hexToBytes(pdfId1Hex) : existing1;
1986
- doc.cos.idArray = cosArray3([cosHexString(b0), cosHexString(b1)]);
2311
+ doc.cos.idArray = cosArray4([cosHexString(b0), cosHexString(b1)]);
1987
2312
  }
1988
2313
  for (const [pageNum, rot] of pageRotations.entries()) {
1989
2314
  if (pageNum >= 1 && pageNum <= doc.pageCount) {
@@ -1992,28 +2317,28 @@ function applyUpdateInfoText(doc, text) {
1992
2317
  }
1993
2318
  for (const [pageNum, [w, h]] of pageDimensions.entries()) {
1994
2319
  if (pageNum >= 1 && pageNum <= doc.pageCount) {
1995
- dictSet2(
2320
+ dictSet3(
1996
2321
  doc.getPage(pageNum - 1).pageDict,
1997
2322
  "MediaBox",
1998
- cosArray3([cosNumber3(0), cosNumber3(0), cosNumber3(w), cosNumber3(h)])
2323
+ cosArray4([cosNumber4(0), cosNumber4(0), cosNumber4(w), cosNumber4(h)])
1999
2324
  );
2000
2325
  }
2001
2326
  }
2002
2327
  for (const [pageNum, [x0, y0, x1, y1]] of pageMediaRects.entries()) {
2003
2328
  if (pageNum >= 1 && pageNum <= doc.pageCount) {
2004
- dictSet2(
2329
+ dictSet3(
2005
2330
  doc.getPage(pageNum - 1).pageDict,
2006
2331
  "MediaBox",
2007
- cosArray3([cosNumber3(x0), cosNumber3(y0), cosNumber3(x1), cosNumber3(y1)])
2332
+ cosArray4([cosNumber4(x0), cosNumber4(y0), cosNumber4(x1), cosNumber4(y1)])
2008
2333
  );
2009
2334
  }
2010
2335
  }
2011
2336
  for (const [pageNum, [x0, y0, x1, y1]] of pageCropBoxes.entries()) {
2012
2337
  if (pageNum >= 1 && pageNum <= doc.pageCount) {
2013
- dictSet2(
2338
+ dictSet3(
2014
2339
  doc.getPage(pageNum - 1).pageDict,
2015
2340
  "CropBox",
2016
- cosArray3([cosNumber3(x0), cosNumber3(y0), cosNumber3(x1), cosNumber3(y1)])
2341
+ cosArray4([cosNumber4(x0), cosNumber4(y0), cosNumber4(x1), cosNumber4(y1)])
2017
2342
  );
2018
2343
  }
2019
2344
  }
@@ -2022,21 +2347,21 @@ function applyUpdateInfoText(doc, text) {
2022
2347
  if (catalog) {
2023
2348
  const numsItems = [];
2024
2349
  for (const pl of pageLabels) {
2025
- numsItems.push(cosNumber3(Math.max(0, pl.newIndex - 1)));
2350
+ numsItems.push(cosNumber4(Math.max(0, pl.newIndex - 1)));
2026
2351
  const lblEntries = {
2027
- St: cosNumber3(pl.start)
2352
+ St: cosNumber4(pl.start)
2028
2353
  };
2029
2354
  if (pl.prefix) {
2030
- lblEntries.P = cosString3(pl.prefix);
2355
+ lblEntries.P = cosString4(pl.prefix);
2031
2356
  }
2032
2357
  const pdfStyle = PAGE_LABEL_STYLE_TO_PDF[pl.style];
2033
2358
  if (pdfStyle) {
2034
- lblEntries.S = cosName(pdfStyle);
2359
+ lblEntries.S = cosName2(pdfStyle);
2035
2360
  }
2036
- numsItems.push(cosDict3(lblEntries));
2361
+ numsItems.push(cosDict4(lblEntries));
2037
2362
  }
2038
- const plDict = cosDict3({ Nums: cosArray3(numsItems) });
2039
- dictSet2(catalog, "PageLabels", doc.cos.allocateObject(plDict));
2363
+ const plDict = cosDict4({ Nums: cosArray4(numsItems) });
2364
+ dictSet3(catalog, "PageLabels", doc.cos.allocateObject(plDict));
2040
2365
  }
2041
2366
  }
2042
2367
  setDocumentBookmarks(doc, bookmarks);
@@ -2044,20 +2369,20 @@ function applyUpdateInfoText(doc, text) {
2044
2369
  function attachFilesToDocument(doc, filePaths, files, toPageSpec) {
2045
2370
  const catalog = doc.cos.resolveDict(doc.cos.rootRef);
2046
2371
  if (!catalog) return;
2047
- let namesDict = doc.cos.resolveDict(dictGet5(catalog, "Names"));
2372
+ let namesDict = doc.cos.resolveDict(dictGet6(catalog, "Names"));
2048
2373
  if (!namesDict) {
2049
- namesDict = cosDict3({});
2050
- dictSet2(catalog, "Names", doc.cos.allocateObject(namesDict));
2374
+ namesDict = cosDict4({});
2375
+ dictSet3(catalog, "Names", doc.cos.allocateObject(namesDict));
2051
2376
  }
2052
- let efTree = doc.cos.resolveDict(dictGet5(namesDict, "EmbeddedFiles"));
2377
+ let efTree = doc.cos.resolveDict(dictGet6(namesDict, "EmbeddedFiles"));
2053
2378
  if (!efTree) {
2054
- efTree = cosDict3({ Names: cosArray3([]) });
2055
- dictSet2(namesDict, "EmbeddedFiles", doc.cos.allocateObject(efTree));
2379
+ efTree = cosDict4({ Names: cosArray4([]) });
2380
+ dictSet3(namesDict, "EmbeddedFiles", doc.cos.allocateObject(efTree));
2056
2381
  }
2057
- let namesArr = doc.cos.resolveArray(dictGet5(efTree, "Names"));
2382
+ let namesArr = doc.cos.resolveArray(dictGet6(efTree, "Names"));
2058
2383
  if (!namesArr) {
2059
- namesArr = cosArray3([]);
2060
- dictSet2(efTree, "Names", namesArr);
2384
+ namesArr = cosArray4([]);
2385
+ dictSet3(efTree, "Names", namesArr);
2061
2386
  }
2062
2387
  const targetPageIdx = toPageSpec !== void 0 && doc.pageCount > 0 ? toPageSpec.toLowerCase() === "end" ? doc.pageCount - 1 : Math.max(0, Math.min(doc.pageCount - 1, (Number.parseInt(toPageSpec, 10) || 1) - 1)) : void 0;
2063
2388
  for (const fp of filePaths) {
@@ -2066,34 +2391,34 @@ function attachFilesToDocument(doc, filePaths, files, toPageSpec) {
2066
2391
  const baseName = fp.slice(fp.lastIndexOf("/") + 1);
2067
2392
  const efStreamRef = doc.cos.allocateObject(
2068
2393
  cosStream(bytes, {
2069
- dict: cosDict3({ Type: cosName("EmbeddedFile") }),
2394
+ dict: cosDict4({ Type: cosName2("EmbeddedFile") }),
2070
2395
  compress: true
2071
2396
  })
2072
2397
  );
2073
2398
  const filespecRef = doc.cos.allocateObject(
2074
- cosDict3({
2075
- Type: cosName("Filespec"),
2076
- F: cosString3(baseName),
2077
- UF: cosString3(baseName),
2078
- EF: cosDict3({ F: efStreamRef })
2399
+ cosDict4({
2400
+ Type: cosName2("Filespec"),
2401
+ F: cosString4(baseName),
2402
+ UF: cosString4(baseName),
2403
+ EF: cosDict4({ F: efStreamRef })
2079
2404
  })
2080
2405
  );
2081
- namesArr.items.push(cosString3(baseName), filespecRef);
2406
+ namesArr.items.push(cosString4(baseName), filespecRef);
2082
2407
  if (targetPageIdx !== void 0) {
2083
2408
  const pageDict = doc.getPage(targetPageIdx).pageDict;
2084
- let annotsArr = doc.cos.resolveArray(dictGet5(pageDict, "Annots"));
2409
+ let annotsArr = doc.cos.resolveArray(dictGet6(pageDict, "Annots"));
2085
2410
  if (!annotsArr) {
2086
- annotsArr = cosArray3([]);
2087
- dictSet2(pageDict, "Annots", annotsArr);
2411
+ annotsArr = cosArray4([]);
2412
+ dictSet3(pageDict, "Annots", annotsArr);
2088
2413
  }
2089
2414
  const annotRef = doc.cos.allocateObject(
2090
- cosDict3({
2091
- Type: cosName("Annot"),
2092
- Subtype: cosName("FileAttachment"),
2093
- Name: cosName("PushPin"),
2094
- Contents: cosString3(baseName),
2415
+ cosDict4({
2416
+ Type: cosName2("Annot"),
2417
+ Subtype: cosName2("FileAttachment"),
2418
+ Name: cosName2("PushPin"),
2419
+ Contents: cosString4(baseName),
2095
2420
  FS: filespecRef,
2096
- Rect: cosArray3([cosNumber3(20), cosNumber3(20), cosNumber3(40), cosNumber3(40)])
2421
+ Rect: cosArray4([cosNumber4(20), cosNumber4(20), cosNumber4(40), cosNumber4(40)])
2097
2422
  })
2098
2423
  );
2099
2424
  annotsArr.items.push(annotRef);
@@ -2110,11 +2435,11 @@ function attachmentBasename(name) {
2110
2435
  function unpackFilesFromDocument(doc, outDir, files) {
2111
2436
  const cleanDir = outDir.endsWith("/") ? outDir.slice(0, -1) : outDir;
2112
2437
  const writeSpecDict = (specDict, fallbackName = "attachment.bin") => {
2113
- const ufNode = doc.cos.resolve(dictGet5(specDict, "UF") ?? dictGet5(specDict, "F"));
2114
- const fileName = attachmentBasename(ufNode?.kind === "string" ? decodePdfString4(ufNode) : fallbackName);
2115
- const efDict = doc.cos.resolveDict(dictGet5(specDict, "EF"));
2438
+ const ufNode = doc.cos.resolve(dictGet6(specDict, "UF") ?? dictGet6(specDict, "F"));
2439
+ const fileName = attachmentBasename(ufNode?.kind === "string" ? decodePdfString5(ufNode) : fallbackName);
2440
+ const efDict = doc.cos.resolveDict(dictGet6(specDict, "EF"));
2116
2441
  const fStream = efDict ? doc.cos.resolve(
2117
- dictGet5(efDict, "UF") ?? dictGet5(efDict, "F") ?? dictGet5(efDict, "DOS") ?? dictGet5(efDict, "Mac") ?? dictGet5(efDict, "Unix")
2442
+ dictGet6(efDict, "UF") ?? dictGet6(efDict, "F") ?? dictGet6(efDict, "DOS") ?? dictGet6(efDict, "Mac") ?? dictGet6(efDict, "Unix")
2118
2443
  ) : void 0;
2119
2444
  if (fStream?.kind === "stream") {
2120
2445
  const decoded = doc.cos.decodeStream(fStream);
@@ -2124,10 +2449,10 @@ function unpackFilesFromDocument(doc, outDir, files) {
2124
2449
  };
2125
2450
  const catalog = doc.cos.resolveDict(doc.cos.rootRef);
2126
2451
  if (catalog) {
2127
- const namesDict = doc.cos.resolveDict(dictGet5(catalog, "Names"));
2452
+ const namesDict = doc.cos.resolveDict(dictGet6(catalog, "Names"));
2128
2453
  const efPairs = [];
2129
2454
  if (namesDict) {
2130
- collectNameTreePairs(doc, dictGet5(namesDict, "EmbeddedFiles"), efPairs);
2455
+ collectNameTreePairs(doc, dictGet6(namesDict, "EmbeddedFiles"), efPairs);
2131
2456
  }
2132
2457
  for (const pair of efPairs) {
2133
2458
  const specDict = doc.cos.resolveDict(pair.value);
@@ -2135,7 +2460,7 @@ function unpackFilesFromDocument(doc, outDir, files) {
2135
2460
  writeSpecDict(specDict, pair.name);
2136
2461
  }
2137
2462
  }
2138
- const rootAfArr = doc.cos.resolveArray(dictGet5(catalog, "AF"));
2463
+ const rootAfArr = doc.cos.resolveArray(dictGet6(catalog, "AF"));
2139
2464
  if (rootAfArr) {
2140
2465
  for (const item of rootAfArr.items) {
2141
2466
  const specDict = doc.cos.resolveDict(item);
@@ -2144,21 +2469,21 @@ function unpackFilesFromDocument(doc, outDir, files) {
2144
2469
  }
2145
2470
  }
2146
2471
  for (let p = 0; p < doc.pageCount; p++) {
2147
- const pageAfArr = doc.cos.resolveArray(dictGet5(doc.getPage(p).pageDict, "AF"));
2472
+ const pageAfArr = doc.cos.resolveArray(dictGet6(doc.getPage(p).pageDict, "AF"));
2148
2473
  if (pageAfArr) {
2149
2474
  for (const item of pageAfArr.items) {
2150
2475
  const specDict = doc.cos.resolveDict(item);
2151
2476
  if (specDict) writeSpecDict(specDict);
2152
2477
  }
2153
2478
  }
2154
- const annotsArr = doc.cos.resolveArray(dictGet5(doc.getPage(p).pageDict, "Annots"));
2479
+ const annotsArr = doc.cos.resolveArray(dictGet6(doc.getPage(p).pageDict, "Annots"));
2155
2480
  if (!annotsArr) continue;
2156
2481
  for (const item of annotsArr.items) {
2157
2482
  const annotDict = doc.cos.resolveDict(item);
2158
2483
  if (!annotDict) continue;
2159
- const subNode = doc.cos.resolve(dictGet5(annotDict, "Subtype"));
2484
+ const subNode = doc.cos.resolve(dictGet6(annotDict, "Subtype"));
2160
2485
  if (subNode?.kind === "name" && subNode.decoded === "FileAttachment") {
2161
- const specDict = doc.cos.resolveDict(dictGet5(annotDict, "FS"));
2486
+ const specDict = doc.cos.resolveDict(dictGet6(annotDict, "FS"));
2162
2487
  if (specDict) writeSpecDict(specDict);
2163
2488
  }
2164
2489
  }
@@ -2169,7 +2494,7 @@ function cloneCosSubgraphInto(srcDoc, dstDoc, node, memo = /* @__PURE__ */ new M
2169
2494
  if (node.kind === "ref") {
2170
2495
  const cached = memo.get(node.objectNumber);
2171
2496
  if (cached) return cached;
2172
- const placeholder = dstDoc.cos.allocateObject(cosDict3({}));
2497
+ const placeholder = dstDoc.cos.allocateObject(cosDict4({}));
2173
2498
  memo.set(node.objectNumber, placeholder);
2174
2499
  const resolved = srcDoc.cos.resolve(node);
2175
2500
  const cloned = cloneCosSubgraphInto(srcDoc, dstDoc, resolved, memo);
@@ -2183,14 +2508,14 @@ function cloneCosSubgraphInto(srcDoc, dstDoc, node, memo = /* @__PURE__ */ new M
2183
2508
  return placeholder;
2184
2509
  }
2185
2510
  if (node.kind === "array") {
2186
- return cosArray3(node.items.map((it) => cloneCosSubgraphInto(srcDoc, dstDoc, it, memo)).filter(Boolean));
2511
+ return cosArray4(node.items.map((it) => cloneCosSubgraphInto(srcDoc, dstDoc, it, memo)).filter(Boolean));
2187
2512
  }
2188
2513
  if (node.kind === "dict") {
2189
- const next = cosDict3({});
2514
+ const next = cosDict4({});
2190
2515
  for (const entry of node.entries) {
2191
2516
  if (entry.key.decoded === "Parent") continue;
2192
2517
  const clonedVal = cloneCosSubgraphInto(srcDoc, dstDoc, entry.value, memo);
2193
- if (clonedVal) dictSet2(next, entry.key.decoded, clonedVal);
2518
+ if (clonedVal) dictSet3(next, entry.key.decoded, clonedVal);
2194
2519
  }
2195
2520
  return next;
2196
2521
  }
@@ -2255,31 +2580,31 @@ function applyOverlayToDocument(targetDoc, overlayDoc, mode, multi) {
2255
2580
  const srcRes = srcPage.getResourcesDict();
2256
2581
  const renamedResources = /* @__PURE__ */ new Map();
2257
2582
  for (const subKey of ["Font", "XObject", "ExtGState", "ColorSpace", "Pattern", "Shading", "Properties"]) {
2258
- const srcSub = overlayDoc.cos.resolveDict(dictGet5(srcRes, subKey));
2583
+ const srcSub = overlayDoc.cos.resolveDict(dictGet6(srcRes, subKey));
2259
2584
  if (!srcSub) continue;
2260
- let dstSub = targetDoc.cos.resolveDict(dictGet5(dstRes, subKey));
2585
+ let dstSub = targetDoc.cos.resolveDict(dictGet6(dstRes, subKey));
2261
2586
  if (!dstSub) {
2262
- dstSub = cosDict3({});
2263
- dictSet2(dstRes, subKey, dstSub);
2587
+ dstSub = cosDict4({});
2588
+ dictSet3(dstRes, subKey, dstSub);
2264
2589
  }
2265
2590
  for (const entry of srcSub.entries) {
2266
2591
  const origKey = entry.key.decoded;
2267
2592
  const cloned = cloneCosSubgraphInto(overlayDoc, targetDoc, entry.value, memo);
2268
2593
  if (!cloned) continue;
2269
- if (!dictGet5(dstSub, origKey)) {
2270
- dictSet2(dstSub, origKey, cloned);
2594
+ if (!dictGet6(dstSub, origKey)) {
2595
+ dictSet3(dstSub, origKey, cloned);
2271
2596
  } else {
2272
2597
  let newKey = `Ov_${i}_${origKey}`;
2273
2598
  let suffix = 1;
2274
- while (dictGet5(dstSub, newKey)) {
2599
+ while (dictGet6(dstSub, newKey)) {
2275
2600
  newKey = `Ov_${i}_${suffix++}_${origKey}`;
2276
2601
  }
2277
- dictSet2(dstSub, newKey, cloned);
2602
+ dictSet3(dstSub, newKey, cloned);
2278
2603
  renamedResources.set(origKey, newKey);
2279
2604
  }
2280
2605
  }
2281
2606
  }
2282
- const srcContents = dictGet5(srcPage.pageDict, "Contents");
2607
+ const srcContents = dictGet6(srcPage.pageDict, "Contents");
2283
2608
  if (!srcContents) continue;
2284
2609
  const rawSrcNodes = [];
2285
2610
  const resolvedSrcContents = overlayDoc.cos.resolve(srcContents);
@@ -2305,7 +2630,7 @@ function applyOverlayToDocument(targetDoc, overlayDoc, mode, multi) {
2305
2630
  }
2306
2631
  }
2307
2632
  if (srcList.length === 0) continue;
2308
- const dstContents = dictGet5(dstPage.pageDict, "Contents");
2633
+ const dstContents = dictGet6(dstPage.pageDict, "Contents");
2309
2634
  const toStreamList = (c) => {
2310
2635
  if (!c) return [];
2311
2636
  const r = targetDoc.cos.resolve(c);
@@ -2354,7 +2679,7 @@ ${fmt6(s)} 0 0 ${fmt6(s)} ${fmt4(tx)} ${fmt4(ty)} cm
2354
2679
  const qOpenSrc = targetDoc.cos.allocateObject(cosStream(new TextEncoder().encode(srcOpenCmd), { compress: false }));
2355
2680
  const qClose = targetDoc.cos.allocateObject(cosStream(new TextEncoder().encode("\nQ\n"), { compress: false }));
2356
2681
  const combined = mode === "background" ? [qOpenSrc, ...srcList, qClose, qOpenDst, ...dstList, qClose] : [qOpenDst, ...dstList, qClose, qOpenSrc, ...srcList, qClose];
2357
- dictSet2(dstPage.pageDict, "Contents", cosArray3(combined));
2682
+ dictSet3(dstPage.pageDict, "Contents", cosArray4(combined));
2358
2683
  }
2359
2684
  }
2360
2685
  function normalizeQuarterTurn(degrees) {
@@ -2538,9 +2863,9 @@ function* runPdftkCliSteps(argv, files, signal) {
2538
2863
  if (!cached) {
2539
2864
  cached = [];
2540
2865
  const cat = d.cos.resolveDict(d.cos.rootRef);
2541
- const outDict = cat ? d.cos.resolveDict(dictGet5(cat, "Outlines")) : void 0;
2866
+ const outDict = cat ? d.cos.resolveDict(dictGet6(cat, "Outlines")) : void 0;
2542
2867
  if (outDict) {
2543
- collectOutlineBookmarks(d, dictGet5(outDict, "First"), 1, cached);
2868
+ collectOutlineBookmarks(d, dictGet6(outDict, "First"), 1, cached);
2544
2869
  }
2545
2870
  bookmarksByDoc.set(d, cached);
2546
2871
  }
@@ -2630,7 +2955,7 @@ function* runPdftkCliSteps(argv, files, signal) {
2630
2955
  }
2631
2956
  if (dropXfa) {
2632
2957
  const root = resultDoc.cos.resolveDict(resultDoc.cos.rootRef);
2633
- const acroForm = root ? resultDoc.cos.resolveDict(dictGet5(root, "AcroForm")) : void 0;
2958
+ const acroForm = root ? resultDoc.cos.resolveDict(dictGet6(root, "AcroForm")) : void 0;
2634
2959
  if (acroForm)
2635
2960
  dictDelete2(acroForm, "XFA");
2636
2961
  }
@@ -2645,28 +2970,28 @@ function* runPdftkCliSteps(argv, files, signal) {
2645
2970
  if (++cooperativeWork % 64 === 0)
2646
2971
  yield;
2647
2972
  if (obj.value.kind === "dict") {
2648
- const stNode = dictGet5(obj.value, "Subtype");
2649
- const bfNode = dictGet5(obj.value, "BaseFont");
2973
+ const stNode = dictGet6(obj.value, "Subtype");
2974
+ const bfNode = dictGet6(obj.value, "BaseFont");
2650
2975
  const subtype = stNode?.kind === "name" ? stNode.decoded : void 0;
2651
2976
  const baseFont = bfNode?.kind === "name" ? bfNode.decoded : void 0;
2652
2977
  if (subtype === "Type1" && baseFont === "Helvetica") {
2653
- dictSet2(obj.value, "BaseFont", cosName(cleanFontName));
2978
+ dictSet3(obj.value, "BaseFont", cosName2(cleanFontName));
2654
2979
  }
2655
2980
  }
2656
2981
  }
2657
2982
  }
2658
2983
  if (operation === "fill_form" && !shouldFlatten) {
2659
2984
  const root = resultDoc.cos.resolveDict(resultDoc.cos.rootRef);
2660
- const acroForm = root ? resultDoc.cos.resolveDict(dictGet5(root, "AcroForm")) : void 0;
2985
+ const acroForm = root ? resultDoc.cos.resolveDict(dictGet6(root, "AcroForm")) : void 0;
2661
2986
  if (acroForm) {
2662
- dictSet2(acroForm, "NeedAppearances", { kind: "boolean", value: needAppearances });
2987
+ dictSet3(acroForm, "NeedAppearances", { kind: "boolean", value: needAppearances });
2663
2988
  }
2664
2989
  } else if (needAppearances && !shouldFlatten) {
2665
2990
  const root = resultDoc.cos.resolveDict(resultDoc.cos.rootRef);
2666
2991
  if (root) {
2667
- const acroForm = resultDoc.cos.resolveDict(dictGet5(root, "AcroForm"));
2992
+ const acroForm = resultDoc.cos.resolveDict(dictGet6(root, "AcroForm"));
2668
2993
  if (acroForm) {
2669
- dictSet2(acroForm, "NeedAppearances", { kind: "boolean", value: true });
2994
+ dictSet3(acroForm, "NeedAppearances", { kind: "boolean", value: true });
2670
2995
  }
2671
2996
  }
2672
2997
  }
@@ -2674,12 +2999,12 @@ function* runPdftkCliSteps(argv, files, signal) {
2674
2999
  if (keepFinalId) {
2675
3000
  const lastInput = handleDocs[handleDocs.length - 1];
2676
3001
  if (lastInput?.cos.idArray) {
2677
- resultDoc.cos.idArray = cosArray3([...lastInput.cos.idArray.items]);
3002
+ resultDoc.cos.idArray = cosArray4([...lastInput.cos.idArray.items]);
2678
3003
  }
2679
3004
  } else if (keepFirstId || !resultDoc.cos.idArray) {
2680
3005
  const firstInput = handleDocs[0];
2681
3006
  if (firstInput?.cos.idArray) {
2682
- resultDoc.cos.idArray = cosArray3([...firstInput.cos.idArray.items]);
3007
+ resultDoc.cos.idArray = cosArray4([...firstInput.cos.idArray.items]);
2683
3008
  }
2684
3009
  }
2685
3010
  if (uncompressStreams || compressStreams) {
@@ -2746,7 +3071,7 @@ async function executePdftk(context, retainedContext = context) {
2746
3071
  const carrier = getCommandArguments(context);
2747
3072
  const argv = [...carrier.args];
2748
3073
  const parsed = await drainSteps(parsePdftkArgumentsSteps(argv), invocation.signal);
2749
- if (parsed.options && (["output", "rotate", "attach_files", "stamp", "multistamp", "background", "multibackground", "burst"].includes(parsed.options.operation) && !parsed.options.shouldFlatten || ["dump_data", "dump_data_utf8", "dump_data_annots", "dump_data_annots_utf8", "dump_data_fields", "dump_data_fields_utf8", "generate_fdf", "unpack_files"].includes(parsed.options.operation))) {
3074
+ if (parsed.options && (["output", "rotate", "attach_files", "stamp", "multistamp", "background", "multibackground", "burst", "update_info", "update_info_utf8", "cat", "shuffle", "fill_form"].includes(parsed.options.operation) && !parsed.options.shouldFlatten || ["dump_data", "dump_data_utf8", "dump_data_annots", "dump_data_annots_utf8", "dump_data_fields", "dump_data_fields_utf8", "generate_fdf", "unpack_files"].includes(parsed.options.operation))) {
2750
3075
  return await executeRetainedPdftk({ ...retainedContext, signal: invocation.signal, stdout: invocation.child(context.stdout).output }, parsed.options);
2751
3076
  }
2752
3077
  const vfsFiles = /* @__PURE__ */ new Map();