@poe-platform/safe-bash 0.1.813 → 0.1.814

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 (516) hide show
  1. package/dist/image-ast/index.js +1 -1
  2. package/dist/mp4-ast/index.d.ts +2 -0
  3. package/dist/mp4-ast/mp4-sample-source.d.ts +52 -0
  4. package/dist/mp4-ast/mp4-source.d.ts +32 -0
  5. package/dist/office-xml/retained-xml-document.d.ts +6 -0
  6. package/dist/pdf-ast/content/evaluator.d.ts +4 -0
  7. package/dist/pdf-ast/cos/object-reader.d.ts +7 -0
  8. package/dist/pdf-ast/cos/value-parser.d.ts +1 -0
  9. package/dist/pdf-ast/edit/retained-form-appearances.d.ts +10 -0
  10. package/dist/pdf-ast/edit/retained-graph.d.ts +6 -0
  11. package/dist/pdf-ast/edit/retained-info-updates.d.ts +33 -0
  12. package/dist/pdf-ast/index.d.ts +1 -1
  13. package/dist/pdf-ast/index.js +460 -125
  14. package/dist/pdf-ast/retained-document.d.ts +5 -0
  15. package/dist/safe-bash/command-chunks/biff-KRHJ63K3-VQPJCVIL.js +5309 -0
  16. package/dist/safe-bash/command-chunks/{chunk-34G2SQX2.js → chunk-2BLTUQNK.js} +2 -2
  17. package/dist/safe-bash/command-chunks/{chunk-LLU2IQEJ.js → chunk-2BNGPR6Z.js} +2 -2
  18. package/dist/safe-bash/command-chunks/{chunk-IHSOOSNC.js → chunk-2ETEJOYX.js} +17 -17
  19. package/dist/safe-bash/command-chunks/{chunk-XIDGHIGB.js → chunk-2PKBXGXD.js} +5 -5
  20. package/dist/safe-bash/command-chunks/{chunk-6SRHWVEB.js → chunk-2VVJRVYM.js} +1 -1
  21. package/dist/safe-bash/command-chunks/{chunk-G5QVZQCO.js → chunk-3EASXF5D.js} +5 -5
  22. package/dist/safe-bash/command-chunks/{chunk-U3SBHEKH.js → chunk-3EB2FSAN.js} +9 -9
  23. package/dist/safe-bash/command-chunks/{chunk-VB2TUPO2.js → chunk-3EW7GYHM.js} +9 -9
  24. package/dist/safe-bash/command-chunks/{chunk-GVWVRPG6.js → chunk-3GRMU7TM.js} +6 -6
  25. package/dist/safe-bash/command-chunks/{chunk-63EMPQ7Z.js → chunk-3JM7E42I.js} +94 -12
  26. package/dist/safe-bash/command-chunks/{chunk-6L4IYQAT.js → chunk-3MG5EAMX.js} +4 -4
  27. package/dist/safe-bash/command-chunks/{chunk-RASQPOSV.js → chunk-3SPLP2DB.js} +1 -1
  28. package/dist/safe-bash/command-chunks/{chunk-K5COUQAQ.js → chunk-3VGQTLO6.js} +1 -1
  29. package/dist/safe-bash/command-chunks/{chunk-K7CV55K5.js → chunk-3YEQI5B7.js} +10 -10
  30. package/dist/safe-bash/command-chunks/{chunk-KCE5D4Z4.js → chunk-3ZRCL756.js} +3 -3
  31. package/dist/safe-bash/command-chunks/{chunk-SOFM3GPG.js → chunk-42MEXZBJ.js} +1 -1
  32. package/dist/safe-bash/command-chunks/{chunk-GQ2ZSPZ3.js → chunk-46AMTJPE.js} +10 -10
  33. package/dist/safe-bash/command-chunks/{chunk-MTWZEPAR.js → chunk-47IAU25U.js} +2 -2
  34. package/dist/safe-bash/command-chunks/{chunk-6GI3NTCW.js → chunk-4B2ZUGLT.js} +4 -4
  35. package/dist/safe-bash/command-chunks/{chunk-X64XGIXZ.js → chunk-4EHY6J2Z.js} +5 -5
  36. package/dist/safe-bash/command-chunks/{chunk-QQVACHZA.js → chunk-4EZJV4FZ.js} +1 -1
  37. package/dist/safe-bash/command-chunks/{chunk-SSKMPDN4.js → chunk-4GQKCUS5.js} +15 -15
  38. package/dist/safe-bash/command-chunks/{chunk-UOBW5K3M.js → chunk-4RRYWHED.js} +7 -7
  39. package/dist/safe-bash/command-chunks/{chunk-PINR7QET.js → chunk-4UPKVQWH.js} +8 -8
  40. package/dist/safe-bash/command-chunks/{chunk-I4GMCWAT.js → chunk-4YLACJHE.js} +6 -6
  41. package/dist/safe-bash/command-chunks/{chunk-PK36TVXB.js → chunk-5BIQWWLB.js} +1 -1
  42. package/dist/safe-bash/command-chunks/{chunk-P3WU3PSL.js → chunk-5L4YGRQU.js} +3 -3
  43. package/dist/safe-bash/command-chunks/{chunk-WPVBUVFK.js → chunk-5LFGXN3D.js} +6 -6
  44. package/dist/safe-bash/command-chunks/{chunk-YXD6VGVG.js → chunk-5OM3UIK3.js} +3 -3
  45. package/dist/safe-bash/command-chunks/{chunk-C5QDEB3I.js → chunk-6LPSKLLD.js} +3 -3
  46. package/dist/safe-bash/command-chunks/{chunk-XLYIVBAR.js → chunk-6QYSF7I2.js} +7 -7
  47. package/dist/safe-bash/command-chunks/{chunk-6IWE7PTK.js → chunk-6VBDJC6V.js} +6 -6
  48. package/dist/safe-bash/command-chunks/{chunk-6N5GHM72.js → chunk-6WNVGCXD.js} +8 -8
  49. package/dist/safe-bash/command-chunks/{chunk-PSCOXGCA.js → chunk-6XES7Z4G.js} +12 -12
  50. package/dist/safe-bash/command-chunks/{chunk-AFROLW6S.js → chunk-6XGDWFNQ.js} +4 -4
  51. package/dist/safe-bash/command-chunks/{chunk-WTE23QXN.js → chunk-6ZGCKUAM.js} +3 -3
  52. package/dist/safe-bash/command-chunks/{chunk-RIV6XN7K.js → chunk-7DOLY7IV.js} +2 -2
  53. package/dist/safe-bash/command-chunks/{chunk-ET2VPDUA.js → chunk-7KZ5LWV2.js} +1 -1
  54. package/dist/safe-bash/command-chunks/{chunk-NGR5KOPQ.js → chunk-A347DLRB.js} +3 -3
  55. package/dist/safe-bash/command-chunks/{chunk-ZM2Y4Z3C.js → chunk-A45UG4KT.js} +4 -4
  56. package/dist/safe-bash/command-chunks/{chunk-2Z3WRRFT.js → chunk-ADHFF2IM.js} +9 -9
  57. package/dist/safe-bash/command-chunks/{chunk-ATI464W3.js → chunk-AG2SNMP5.js} +1 -1
  58. package/dist/safe-bash/command-chunks/{chunk-HCKYUQ3L.js → chunk-AM5LANIE.js} +7 -7
  59. package/dist/safe-bash/command-chunks/{chunk-PKLJRB7W.js → chunk-AVGXFWEB.js} +48 -40
  60. package/dist/safe-bash/command-chunks/{chunk-RBTC7OFT.js → chunk-AVOGFREX.js} +5 -5
  61. package/dist/safe-bash/command-chunks/{chunk-G3RUXKVY.js → chunk-AWPI4DZR.js} +3 -3
  62. package/dist/safe-bash/command-chunks/{chunk-FYMNHG7R.js → chunk-AXXZNB7U.js} +13 -13
  63. package/dist/safe-bash/command-chunks/{chunk-2E2H7MBH.js → chunk-AY3KQ4EN.js} +7 -7
  64. package/dist/safe-bash/command-chunks/{chunk-DMCI6T6N.js → chunk-BLGGAHQW.js} +1 -1
  65. package/dist/safe-bash/command-chunks/{chunk-CU4DLVME.js → chunk-BLIFGBIO.js} +2 -2
  66. package/dist/safe-bash/command-chunks/{chunk-2V6FOLXV.js → chunk-BS3ZEQGT.js} +14 -14
  67. package/dist/safe-bash/command-chunks/{chunk-WFVSUXJL.js → chunk-BS5JEUEW.js} +8 -8
  68. package/dist/safe-bash/command-chunks/{chunk-X53AEG36.js → chunk-BZMNC7Q5.js} +7 -7
  69. package/dist/safe-bash/command-chunks/{chunk-5KGEZ3RW.js → chunk-CCMAHM3I.js} +2 -2
  70. package/dist/safe-bash/command-chunks/{chunk-3LJAXFH5.js → chunk-CIRDVCAZ.js} +7 -7
  71. package/dist/safe-bash/command-chunks/{chunk-73NYFNAS.js → chunk-CK2WFJZN.js} +5 -0
  72. package/dist/safe-bash/command-chunks/{chunk-UZL7G57V.js → chunk-CKEMZUE3.js} +7 -7
  73. package/dist/safe-bash/command-chunks/{chunk-S2N2V5U4.js → chunk-CQBACD2V.js} +2 -2
  74. package/dist/safe-bash/command-chunks/{chunk-G7NENPYV.js → chunk-CSE4VQKG.js} +12 -1
  75. package/dist/safe-bash/command-chunks/{chunk-X6RHJ6YN.js → chunk-CXME4YHU.js} +23 -0
  76. package/dist/safe-bash/command-chunks/{chunk-FTLDRH47.js → chunk-CZ5K2YPU.js} +16 -16
  77. package/dist/safe-bash/command-chunks/{chunk-7PRL6RJ6.js → chunk-DBLQUZGN.js} +2 -2
  78. package/dist/safe-bash/command-chunks/{chunk-5VQVZPP3.js → chunk-DBNJEXHK.js} +3 -3
  79. package/dist/safe-bash/command-chunks/{chunk-ZO5WBWLL.js → chunk-DN6MSXY7.js} +2 -2
  80. package/dist/safe-bash/command-chunks/{chunk-GXLXWZWH.js → chunk-DZH54L3F.js} +3 -3
  81. package/dist/safe-bash/command-chunks/{chunk-6CY5BHBS.js → chunk-EBHOZIBS.js} +6 -6
  82. package/dist/safe-bash/command-chunks/{chunk-3Y5EME26.js → chunk-ENEIE44W.js} +2 -2
  83. package/dist/safe-bash/command-chunks/{chunk-TKRLZIFI.js → chunk-EQWFKNHJ.js} +17 -17
  84. package/dist/safe-bash/command-chunks/{chunk-YV72XQKL.js → chunk-ETXPMVR6.js} +13 -13
  85. package/dist/safe-bash/command-chunks/{chunk-4Z6W5EOC.js → chunk-EV5G535P.js} +8 -8
  86. package/dist/safe-bash/command-chunks/{chunk-PZMU3Z4L.js → chunk-EVYKV3QI.js} +5 -5
  87. package/dist/safe-bash/command-chunks/{chunk-D6UMSC45.js → chunk-F4YFTO2K.js} +11 -11
  88. package/dist/safe-bash/command-chunks/{chunk-QM2HZJSJ.js → chunk-F762XDNG.js} +3 -3
  89. package/dist/safe-bash/command-chunks/{chunk-GOBUDKZ3.js → chunk-FF7UGJWS.js} +4 -4
  90. package/dist/safe-bash/command-chunks/{chunk-SGPCXAG7.js → chunk-FOONI6BD.js} +7 -7
  91. package/dist/safe-bash/command-chunks/{chunk-DYLNU57U.js → chunk-FSVJ67G5.js} +1 -1
  92. package/dist/safe-bash/command-chunks/{chunk-CLKOGAR3.js → chunk-FSYMSWJU.js} +8 -8
  93. package/dist/safe-bash/command-chunks/{chunk-FWPVQGYK.js → chunk-FUQMEUAT.js} +6 -6
  94. package/dist/safe-bash/command-chunks/{chunk-KXPCSVAT.js → chunk-FXCSPPYE.js} +20 -20
  95. package/dist/safe-bash/command-chunks/{chunk-7QZ2HP2F.js → chunk-FYYFV6PW.js} +6 -6
  96. package/dist/safe-bash/command-chunks/{chunk-3OETVNJA.js → chunk-G2COZLXX.js} +9 -9
  97. package/dist/safe-bash/command-chunks/{chunk-T6C5QP7T.js → chunk-G3TAX3CV.js} +5963 -5953
  98. package/dist/safe-bash/command-chunks/{chunk-MKX4JAZ6.js → chunk-GCHB7VNX.js} +17 -17
  99. package/dist/safe-bash/command-chunks/{chunk-4Y6O2K35.js → chunk-GLAF45M7.js} +1 -1
  100. package/dist/safe-bash/command-chunks/{chunk-7UC2Q6Z6.js → chunk-GQGMQMIM.js} +5 -5
  101. package/dist/safe-bash/command-chunks/{chunk-PI6MOMHA.js → chunk-GXMPXMDP.js} +11 -11
  102. package/dist/safe-bash/command-chunks/{chunk-57DDYKE5.js → chunk-GYM5ICK4.js} +7 -7
  103. package/dist/safe-bash/command-chunks/{chunk-5MFDRSGG.js → chunk-H33D4R26.js} +4 -4
  104. package/dist/safe-bash/command-chunks/{chunk-3ZDANXIC.js → chunk-HELAVGZH.js} +3 -3
  105. package/dist/safe-bash/command-chunks/{chunk-S4QH5BXZ.js → chunk-HGIMFVI2.js} +4 -4
  106. package/dist/safe-bash/command-chunks/{chunk-35IPOBWL.js → chunk-HI6ZYH3W.js} +10 -10
  107. package/dist/safe-bash/command-chunks/{chunk-RGOQKIG6.js → chunk-HK6MSB7Z.js} +5 -5
  108. package/dist/safe-bash/command-chunks/{chunk-7ZE3VIAN.js → chunk-IB5QP4LF.js} +2 -2
  109. package/dist/safe-bash/command-chunks/{chunk-UCR5YDV3.js → chunk-IBYMPAUW.js} +1 -1
  110. package/dist/safe-bash/command-chunks/{chunk-LABOWPFB.js → chunk-IHXZMAMY.js} +9 -9
  111. package/dist/safe-bash/command-chunks/{chunk-PVGZMLC6.js → chunk-IWHNRYER.js} +3 -3
  112. package/dist/safe-bash/command-chunks/{chunk-PPO7YUZF.js → chunk-JGKSWDGP.js} +1 -1
  113. package/dist/safe-bash/command-chunks/{chunk-GKILM4HZ.js → chunk-JR3Q6QNL.js} +7 -7
  114. package/dist/safe-bash/command-chunks/{chunk-D55REQA3.js → chunk-JUHOL5KB.js} +1 -1
  115. package/dist/safe-bash/command-chunks/{chunk-3O2YEI47.js → chunk-JVKE7YZN.js} +3 -3
  116. package/dist/safe-bash/command-chunks/{chunk-6NATRKUJ.js → chunk-JW6WVNTM.js} +1 -1
  117. package/dist/safe-bash/command-chunks/{chunk-IK6K2HCG.js → chunk-JWORWL72.js} +1 -1
  118. package/dist/safe-bash/command-chunks/{chunk-N32GSM3J.js → chunk-K2WOMJOQ.js} +1 -1
  119. package/dist/safe-bash/command-chunks/{chunk-TQEB4DH4.js → chunk-K4XNUJVJ.js} +1 -1
  120. package/dist/safe-bash/command-chunks/{chunk-HKOMXGJS.js → chunk-KBAQHE5Y.js} +2 -2
  121. package/dist/safe-bash/command-chunks/{chunk-T3E5RV3U.js → chunk-KCLJGRU7.js} +12 -12
  122. package/dist/safe-bash/command-chunks/{chunk-TUDFMNPP.js → chunk-KINIV2SV.js} +1 -1
  123. package/dist/safe-bash/command-chunks/{chunk-43TRBJ2N.js → chunk-KPHLESD4.js} +4 -4
  124. package/dist/safe-bash/command-chunks/{chunk-C5KLFZGT.js → chunk-KSBNZTAZ.js} +6 -6
  125. package/dist/safe-bash/command-chunks/{chunk-4Y34ZG4T.js → chunk-KUOCGGEU.js} +11 -11
  126. package/dist/safe-bash/command-chunks/{chunk-ML5R5JML.js → chunk-KY4LCHUF.js} +1 -1
  127. package/dist/safe-bash/command-chunks/{chunk-7NXTEWPR.js → chunk-LAPOMHGY.js} +132 -195
  128. package/dist/safe-bash/command-chunks/{chunk-KBUBSMCQ.js → chunk-LDW3RF7Y.js} +12 -12
  129. package/dist/safe-bash/command-chunks/{chunk-U27XPNLP.js → chunk-LEO4VRIN.js} +2 -2
  130. package/dist/safe-bash/command-chunks/{chunk-GZ3VIWNN.js → chunk-LKGTH2Q7.js} +7 -7
  131. package/dist/safe-bash/command-chunks/{chunk-TODWFDYB.js → chunk-LNTEV56A.js} +2 -2
  132. package/dist/safe-bash/command-chunks/{chunk-DVGXLBUW.js → chunk-LZ2JFMKT.js} +10 -10
  133. package/dist/safe-bash/command-chunks/{chunk-6D2BMAF4.js → chunk-MEM2ZPMI.js} +2 -2
  134. package/dist/safe-bash/command-chunks/{chunk-GNXTMSYN.js → chunk-MGMTRGKM.js} +4 -4
  135. package/dist/safe-bash/command-chunks/{chunk-B3NLITWP.js → chunk-MKK6FM5H.js} +7 -7
  136. package/dist/safe-bash/command-chunks/{chunk-BK7ISUJL.js → chunk-MKOIPOXX.js} +3 -3
  137. package/dist/safe-bash/command-chunks/chunk-MLOYUXUV.js +244 -0
  138. package/dist/safe-bash/command-chunks/{chunk-CBNKHBLD.js → chunk-MNK3DDH6.js} +2 -2
  139. package/dist/safe-bash/command-chunks/{chunk-JVGUVHWI.js → chunk-MPXMRTMY.js} +10 -10
  140. package/dist/safe-bash/command-chunks/{chunk-EJTNVXWF.js → chunk-MVLVIMJ6.js} +6 -6
  141. package/dist/safe-bash/command-chunks/{chunk-TY4WDAHM.js → chunk-MYZ46FQL.js} +1 -1
  142. package/dist/safe-bash/command-chunks/{chunk-TBAIMDGL.js → chunk-N4MUBJCT.js} +1 -1
  143. package/dist/safe-bash/command-chunks/{chunk-NPLVFAD6.js → chunk-N6G3345Q.js} +8 -8
  144. package/dist/safe-bash/command-chunks/{chunk-4PBNMKAT.js → chunk-NEMUPUUB.js} +7 -7
  145. package/dist/safe-bash/command-chunks/{chunk-MUUWBZIC.js → chunk-NEVQWOU6.js} +10 -10
  146. package/dist/safe-bash/command-chunks/{chunk-KZ5ODST6.js → chunk-NFGCBQN3.js} +2 -2
  147. package/dist/safe-bash/command-chunks/{chunk-LD7BONZY.js → chunk-NFII726L.js} +2 -2
  148. package/dist/safe-bash/command-chunks/{chunk-JQPNA77Y.js → chunk-NHNZYWPW.js} +2 -2
  149. package/dist/safe-bash/command-chunks/{chunk-ZYLGNIGA.js → chunk-NQINS4XY.js} +1 -1
  150. package/dist/safe-bash/command-chunks/{chunk-UAF4IX5H.js → chunk-NRFTYZ2R.js} +6 -6
  151. package/dist/safe-bash/command-chunks/{chunk-THMZLJQD.js → chunk-NYFYTL5G.js} +18 -18
  152. package/dist/safe-bash/command-chunks/{chunk-SMSGLRIH.js → chunk-OTF2AJ5M.js} +6 -6
  153. package/dist/safe-bash/command-chunks/{chunk-NPFHUS4X.js → chunk-OVQP6KH5.js} +6 -6
  154. package/dist/safe-bash/command-chunks/{chunk-QFF5KBOM.js → chunk-P2LT6TGR.js} +9 -9
  155. package/dist/safe-bash/command-chunks/{chunk-RLCQ7BN3.js → chunk-PIVH35EQ.js} +3 -3
  156. package/dist/safe-bash/command-chunks/{chunk-BEHUSUOY.js → chunk-PLMF35XK.js} +4 -4
  157. package/dist/safe-bash/command-chunks/{chunk-PXWS3Q7L.js → chunk-PLR5IULU.js} +5 -5
  158. package/dist/safe-bash/command-chunks/{chunk-DBLHCJJU.js → chunk-PS5GDFIP.js} +2 -2
  159. package/dist/safe-bash/command-chunks/{chunk-P7EL2FWW.js → chunk-Q5PWYPQV.js} +7 -7
  160. package/dist/safe-bash/command-chunks/{chunk-AJI55RS7.js → chunk-Q7TVCBU2.js} +1 -1
  161. package/dist/safe-bash/command-chunks/{chunk-EHTOHOTR.js → chunk-QB72X7FF.js} +9 -9
  162. package/dist/safe-bash/command-chunks/{chunk-F3GP3EXE.js → chunk-RGDOYWOD.js} +2 -2
  163. package/dist/safe-bash/command-chunks/{chunk-MNHBQBF6.js → chunk-RHDERFMR.js} +5 -5
  164. package/dist/safe-bash/command-chunks/{chunk-3KMOXEGH.js → chunk-RHU44OMN.js} +2 -2
  165. package/dist/safe-bash/command-chunks/{chunk-XG6UWQV5.js → chunk-RIVKF77R.js} +6 -6
  166. package/dist/safe-bash/command-chunks/{chunk-UOR6PXZZ.js → chunk-ROL5AEX6.js} +1 -1
  167. package/dist/safe-bash/command-chunks/{chunk-3TYDSGAH.js → chunk-RQYPFLZJ.js} +6 -6
  168. package/dist/safe-bash/command-chunks/{chunk-3Y4XZB24.js → chunk-RTNI47C5.js} +4 -4
  169. package/dist/safe-bash/command-chunks/{chunk-W5LLKV5H.js → chunk-RV5AGXOV.js} +2 -2
  170. package/dist/safe-bash/command-chunks/{chunk-JUJHYPYL.js → chunk-RXQ2G2YK.js} +9 -9
  171. package/dist/safe-bash/command-chunks/{chunk-EVU7FLDA.js → chunk-S2QNBAN6.js} +7 -7
  172. package/dist/safe-bash/command-chunks/{chunk-YE6OAKK7.js → chunk-S43QRKDC.js} +7 -7
  173. package/dist/safe-bash/command-chunks/{chunk-774GLJAO.js → chunk-S7HIOT7Z.js} +4 -4
  174. package/dist/safe-bash/command-chunks/{chunk-3D24WDND.js → chunk-SEPUP6TZ.js} +1 -1
  175. package/dist/safe-bash/command-chunks/{chunk-JPMYPOYZ.js → chunk-SUTHGUD3.js} +28 -28
  176. package/dist/safe-bash/command-chunks/{chunk-CTDC4LJT.js → chunk-SW37YCBW.js} +15 -10
  177. package/dist/safe-bash/command-chunks/{chunk-D6WJY6QO.js → chunk-SWAKALDJ.js} +10 -10
  178. package/dist/safe-bash/command-chunks/{chunk-WGH3RLJY.js → chunk-T5S4SJGO.js} +9 -9
  179. package/dist/safe-bash/command-chunks/{chunk-7JEIWA3A.js → chunk-TID5TSQW.js} +5 -5
  180. package/dist/safe-bash/command-chunks/{chunk-EZ4NQIPL.js → chunk-TJLXSENN.js} +1 -1
  181. package/dist/safe-bash/command-chunks/{chunk-HVW53ARH.js → chunk-TKCUGMRZ.js} +24 -20
  182. package/dist/safe-bash/command-chunks/{chunk-5P6I2T63.js → chunk-TXPDKEGY.js} +8 -8
  183. package/dist/safe-bash/command-chunks/{chunk-MPKY37QR.js → chunk-UJERQEJB.js} +1 -1
  184. package/dist/safe-bash/command-chunks/{chunk-V37D6AHO.js → chunk-USGZN2KE.js} +5 -5
  185. package/dist/safe-bash/command-chunks/{chunk-JAHJWVGF.js → chunk-UYGQEQIP.js} +5 -5
  186. package/dist/safe-bash/command-chunks/{chunk-MPORWUTU.js → chunk-V5XC43BX.js} +8 -8
  187. package/dist/safe-bash/command-chunks/{chunk-AIMSZBWP.js → chunk-V7E3PZOK.js} +9 -9
  188. package/dist/safe-bash/command-chunks/{chunk-CNHRVUHA.js → chunk-VDTFVRYX.js} +1 -1
  189. package/dist/safe-bash/command-chunks/{chunk-M3Z5PU2M.js → chunk-VT2PHQ63.js} +15 -15
  190. package/dist/safe-bash/command-chunks/{chunk-JORIVUPM.js → chunk-VT7UBPAE.js} +15 -8
  191. package/dist/safe-bash/command-chunks/{chunk-QDVI2YB6.js → chunk-VUWXLH3E.js} +2 -2
  192. package/dist/safe-bash/command-chunks/{chunk-O675URF4.js → chunk-W3ZSWK76.js} +8 -8
  193. package/dist/safe-bash/command-chunks/{chunk-JPA2PUYI.js → chunk-WBKB7HBZ.js} +8 -8
  194. package/dist/safe-bash/command-chunks/{chunk-6244HYJY.js → chunk-WJ2ERUCQ.js} +1 -1
  195. package/dist/safe-bash/command-chunks/{chunk-U5TWQFZY.js → chunk-WTVJLHMG.js} +1 -1
  196. package/dist/safe-bash/command-chunks/{chunk-SLQWQKXP.js → chunk-WWHMI4S3.js} +9 -9
  197. package/dist/safe-bash/command-chunks/{chunk-2UBZALAK.js → chunk-WYZG3DRR.js} +1 -1
  198. package/dist/safe-bash/command-chunks/{chunk-T5ERNELL.js → chunk-WZRFS5OY.js} +4 -4
  199. package/dist/safe-bash/command-chunks/{chunk-2DGJOOXM.js → chunk-X6OHFKBL.js} +8 -8
  200. package/dist/safe-bash/command-chunks/{chunk-S6ZTBXYO.js → chunk-XKAUKLF7.js} +13 -13
  201. package/dist/safe-bash/command-chunks/{chunk-NKTULXVD.js → chunk-XM5QJCPD.js} +8 -8
  202. package/dist/safe-bash/command-chunks/{chunk-BBAB7LC4.js → chunk-XMTR7QGL.js} +4 -4
  203. package/dist/safe-bash/command-chunks/{chunk-5IFRAI7Y.js → chunk-XNGM3W5R.js} +1 -1
  204. package/dist/safe-bash/command-chunks/{chunk-Z5BIM5B7.js → chunk-XTEIT5CI.js} +1 -1
  205. package/dist/safe-bash/command-chunks/{chunk-4DLIUTQV.js → chunk-XU6S3XUZ.js} +11 -11
  206. package/dist/safe-bash/command-chunks/{chunk-EXOQGXEU.js → chunk-XUJAQA3S.js} +30 -30
  207. package/dist/safe-bash/command-chunks/{chunk-VVWXY6IA.js → chunk-Y42KSX63.js} +6 -6
  208. package/dist/safe-bash/command-chunks/{chunk-R2BMZAHG.js → chunk-Y54L4P4J.js} +5 -5
  209. package/dist/safe-bash/command-chunks/{chunk-6WQD7LRA.js → chunk-YAD7EV4N.js} +14 -14
  210. package/dist/safe-bash/command-chunks/{chunk-YUXTK3XA.js → chunk-YRPXBGRX.js} +3 -3
  211. package/dist/safe-bash/command-chunks/{chunk-NMPED6L5.js → chunk-Z2WNYEPD.js} +4 -4
  212. package/dist/safe-bash/command-chunks/{chunk-7PZHWMK6.js → chunk-Z7QOSXQC.js} +7 -7
  213. package/dist/safe-bash/command-chunks/{chunk-VQOINPVF.js → chunk-ZQM37BGE.js} +2 -2
  214. package/dist/safe-bash/command-chunks/{chunk-W3HV45CI.js → chunk-ZSQZHFWS.js} +9 -9
  215. package/dist/safe-bash/command-chunks/{chunk-IDJQP3A6.js → chunk-ZTMZO4IT.js} +1 -1
  216. package/dist/safe-bash/command-chunks/{chunk-V6XBEYPC.js → chunk-ZU2KJMXO.js} +8 -8
  217. package/dist/safe-bash/command-chunks/{chunk-YXKNJ6EM.js → chunk-ZXELXF2H.js} +5 -5
  218. package/dist/safe-bash/command-chunks/{clipboard-BBDK33GP-VB22F7GI.js → clipboard-BBDK33GP-QZ4ERNQX.js} +2 -2
  219. package/dist/safe-bash/command-chunks/{command-engine-X3OLN7N6.js → command-engine-7V6PZR7G.js} +931 -680
  220. package/dist/safe-bash/command-chunks/{engine-XUCIFZ7V-LJFGZM6O.js → engine-UYJENSWK-VSCGKSQV.js} +1 -1
  221. package/dist/safe-bash/command-chunks/{gnumeric-UJPXWBVR-YPXTNEDZ.js → gnumeric-UJPXWBVR-7VOHQAPM.js} +2 -2
  222. package/dist/safe-bash/command-chunks/{model-store-E7BHBFJC.js → model-store-UB5DWMAP.js} +24 -24
  223. package/dist/safe-bash-command-awk/awk-runtime.js +3 -3
  224. package/dist/safe-bash-command-awk/awk.js +4 -4
  225. package/dist/safe-bash-command-awk/index.js +4 -4
  226. package/dist/safe-bash-command-diff/diff.js +2 -2
  227. package/dist/safe-bash-command-diff/index.js +3 -3
  228. package/dist/safe-bash-command-diff/sync.js +2 -2
  229. package/dist/safe-bash-command-du/du.js +2 -2
  230. package/dist/safe-bash-command-du/index.js +2 -2
  231. package/dist/safe-bash-command-ffmpeg/index.js +1 -1
  232. package/dist/safe-bash-command-ffprobe/index.js +2 -2
  233. package/dist/safe-bash-command-ffprobe/media.js +2 -2
  234. package/dist/safe-bash-command-html-to-markdown/index.js +3 -234
  235. package/dist/safe-bash-command-html-to-markdown/stored-text.d.ts +50 -0
  236. package/dist/safe-bash-command-html-to-markdown/stored-text.js +12 -0
  237. package/dist/safe-bash-command-htmlq/contracts.d.ts +5 -0
  238. package/dist/safe-bash-command-htmlq/index.js +1715 -292
  239. package/dist/safe-bash-command-htmlq/selectors.d.ts +38 -1
  240. package/dist/safe-bash-command-htmlq/serializer.d.ts +1 -0
  241. package/dist/safe-bash-command-htmlq/tree.d.ts +1 -0
  242. package/dist/safe-bash-command-iconv/command.js +2 -2
  243. package/dist/safe-bash-command-iconv/index.js +2 -2
  244. package/dist/safe-bash-command-llm/command.js +3 -3
  245. package/dist/safe-bash-command-llm/index.js +9 -9
  246. package/dist/safe-bash-command-llm/openai.js +2 -2
  247. package/dist/safe-bash-command-llm/providers/index.js +2 -2
  248. package/dist/safe-bash-command-llm/providers/openai.js +2 -2
  249. package/dist/safe-bash-command-node/commands/node/browser.js +2 -2
  250. package/dist/safe-bash-command-node/commands/node/default-runtime.js +2 -2
  251. package/dist/safe-bash-command-node/commands/node/safejs.js +2 -2
  252. package/dist/safe-bash-command-pandoc/command.js +4 -4
  253. package/dist/safe-bash-command-pandoc/index.js +39 -39
  254. package/dist/safe-bash-command-patch/index.js +6 -6
  255. package/dist/safe-bash-command-patch/patch-formats.d.ts +6 -1
  256. package/dist/safe-bash-command-patch/patch-formats.js +6 -4
  257. package/dist/safe-bash-command-patch/patch-gnu-paths.d.ts +7 -7
  258. package/dist/safe-bash-command-patch/patch-gnu-reject.d.ts +2 -2
  259. package/dist/safe-bash-command-patch/patch-gnu-reject.js +2 -2
  260. package/dist/safe-bash-command-patch/patch-publication.js +2 -2
  261. package/dist/safe-bash-command-patch/patch.js +6 -6
  262. package/dist/safe-bash-command-patch/stored-patch.d.ts +26 -0
  263. package/dist/safe-bash-command-patch/stored-target.d.ts +40 -0
  264. package/dist/safe-bash-command-patch/unified.d.ts +13 -8
  265. package/dist/safe-bash-command-patch/unified.js +3 -1
  266. package/dist/safe-bash-command-pdftk/index.js +741 -426
  267. package/dist/safe-bash-command-playwright-cli/index.js +26 -26
  268. package/dist/safe-bash-command-playwright-cli/playwright/abilities.js +10 -10
  269. package/dist/safe-bash-command-playwright-cli/playwright/controller.js +14 -14
  270. package/dist/safe-bash-command-playwright-cli/playwright/index.js +23 -23
  271. package/dist/safe-bash-command-playwright-cli/playwright/snapshot.js +2 -2
  272. package/dist/safe-bash-command-playwright-cli/playwright/standard-capabilities.js +6 -6
  273. package/dist/safe-bash-command-playwright-cli/playwright/storage-capabilities.js +4 -4
  274. package/dist/safe-bash-command-pptx/command-engine.d.ts +2 -1
  275. package/dist/safe-bash-command-pptx/engine.js +1 -1
  276. package/dist/safe-bash-command-pptx/index.d.ts +1 -1
  277. package/dist/safe-bash-command-pptx/index.js +163 -17
  278. package/dist/safe-bash-command-pptx/streaming-inputs.d.ts +7 -2
  279. package/dist/safe-bash-command-python/executor.js +5 -5
  280. package/dist/safe-bash-command-python/index.js +5 -5
  281. package/dist/safe-bash-command-python/jspi.js +2 -2
  282. package/dist/safe-bash-command-soffice/index.js +1 -1
  283. package/dist/safe-bash-command-sort/index.js +3 -3
  284. package/dist/safe-bash-command-ssconvert/index.js +2 -2
  285. package/dist/safe-bash-command-tar/create.js +2 -2
  286. package/dist/safe-bash-command-tar/extract.js +2 -2
  287. package/dist/safe-bash-command-tar/index.js +8 -8
  288. package/dist/safe-bash-command-tar/modes.js +4 -4
  289. package/dist/safe-bash-command-timeout/index.js +3 -3
  290. package/dist/safe-bash-command-tree/index.js +2 -2
  291. package/dist/safe-bash-command-tree/tree.js +2 -2
  292. package/dist/safe-bash-command-xz/index.js +5 -5
  293. package/dist/safe-bash-compression-engine/files.js +2 -2
  294. package/dist/safe-bash-compression-engine/operand.js +4 -4
  295. package/dist/safe-bash-contracts/diagnostics.js +3 -3
  296. package/dist/safe-bash-contracts/escaping.js +10 -10
  297. package/dist/safe-bash-contracts/filesystem-descriptor.js +1 -1
  298. package/dist/safe-bash-contracts/filesystem-output.js +6 -6
  299. package/dist/safe-bash-contracts/index.js +33 -33
  300. package/dist/safe-bash-contracts/io.js +2 -2
  301. package/dist/safe-bash-contracts/output.js +3 -3
  302. package/dist/safe-bash-docx-engine/ancillary-resources.js +5 -5
  303. package/dist/safe-bash-docx-engine/batch-operations.js +63 -63
  304. package/dist/safe-bash-docx-engine/batch-result-schema.js +74 -74
  305. package/dist/safe-bash-docx-engine/batch.js +74 -74
  306. package/dist/safe-bash-docx-engine/bookmarks.js +13 -13
  307. package/dist/safe-bash-docx-engine/charts.js +6 -6
  308. package/dist/safe-bash-docx-engine/command-option-rules.js +3 -3
  309. package/dist/safe-bash-docx-engine/comments.js +21 -21
  310. package/dist/safe-bash-docx-engine/control-bindings.js +16 -16
  311. package/dist/safe-bash-docx-engine/control-repeat.js +16 -16
  312. package/dist/safe-bash-docx-engine/controls.js +14 -14
  313. package/dist/safe-bash-docx-engine/create.js +8 -8
  314. package/dist/safe-bash-docx-engine/diagrams.js +6 -6
  315. package/dist/safe-bash-docx-engine/diff.js +8 -8
  316. package/dist/safe-bash-docx-engine/document-properties.js +12 -12
  317. package/dist/safe-bash-docx-engine/equations.js +12 -12
  318. package/dist/safe-bash-docx-engine/extract.js +9 -9
  319. package/dist/safe-bash-docx-engine/fields.js +18 -18
  320. package/dist/safe-bash-docx-engine/font-inventory.js +13 -13
  321. package/dist/safe-bash-docx-engine/font-resources.js +3 -3
  322. package/dist/safe-bash-docx-engine/image-batch-operations.js +11 -11
  323. package/dist/safe-bash-docx-engine/image-insertion.js +17 -17
  324. package/dist/safe-bash-docx-engine/image-layout.js +14 -14
  325. package/dist/safe-bash-docx-engine/image-replacement.js +19 -19
  326. package/dist/safe-bash-docx-engine/images.js +14 -14
  327. package/dist/safe-bash-docx-engine/index.js +102 -102
  328. package/dist/safe-bash-docx-engine/inspection.js +15 -15
  329. package/dist/safe-bash-docx-engine/invocation.js +4 -4
  330. package/dist/safe-bash-docx-engine/io.js +6 -6
  331. package/dist/safe-bash-docx-engine/links.js +17 -17
  332. package/dist/safe-bash-docx-engine/lists.js +16 -16
  333. package/dist/safe-bash-docx-engine/locations.js +10 -10
  334. package/dist/safe-bash-docx-engine/notes.js +18 -18
  335. package/dist/safe-bash-docx-engine/objects.js +14 -14
  336. package/dist/safe-bash-docx-engine/pack.js +9 -9
  337. package/dist/safe-bash-docx-engine/package-view-batch-operations.js +19 -19
  338. package/dist/safe-bash-docx-engine/pandoc-adapter.js +25 -25
  339. package/dist/safe-bash-docx-engine/paragraph-edit.js +21 -21
  340. package/dist/safe-bash-docx-engine/publication.js +6 -6
  341. package/dist/safe-bash-docx-engine/removal.js +16 -16
  342. package/dist/safe-bash-docx-engine/revision-decisions.js +16 -16
  343. package/dist/safe-bash-docx-engine/revision-edit.js +15 -15
  344. package/dist/safe-bash-docx-engine/revisions.js +12 -12
  345. package/dist/safe-bash-docx-engine/run-format.js +15 -15
  346. package/dist/safe-bash-docx-engine/sanitize.js +29 -29
  347. package/dist/safe-bash-docx-engine/sections.js +15 -15
  348. package/dist/safe-bash-docx-engine/settings.js +6 -6
  349. package/dist/safe-bash-docx-engine/shape-edit.js +16 -16
  350. package/dist/safe-bash-docx-engine/signatures.js +11 -11
  351. package/dist/safe-bash-docx-engine/stories.js +18 -18
  352. package/dist/safe-bash-docx-engine/structure-model-batch-operations.js +34 -34
  353. package/dist/safe-bash-docx-engine/style-model-batch-operations.js +24 -24
  354. package/dist/safe-bash-docx-engine/style-model-result-schema.js +39 -39
  355. package/dist/safe-bash-docx-engine/styles.js +14 -14
  356. package/dist/safe-bash-docx-engine/table-edit.js +23 -23
  357. package/dist/safe-bash-docx-engine/table-read.js +11 -11
  358. package/dist/safe-bash-docx-engine/template.js +17 -17
  359. package/dist/safe-bash-docx-engine/text-replace.js +15 -15
  360. package/dist/safe-bash-docx-engine/text-resource-read.js +11 -11
  361. package/dist/safe-bash-docx-engine/text.js +11 -11
  362. package/dist/safe-bash-docx-engine/validation.js +4 -4
  363. package/dist/safe-bash-docx-engine/xml-parts.js +17 -17
  364. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +4 -4
  365. package/dist/safe-bash-line-ending-engine/command.js +3 -3
  366. package/dist/safe-bash-line-ending-engine/convert.js +2 -2
  367. package/dist/safe-bash-line-ending-engine/index.js +6 -6
  368. package/dist/safe-bash-line-ending-engine/info.js +2 -2
  369. package/dist/safe-bash-markdown-engine/commonmark-blocks.js +4 -4
  370. package/dist/safe-bash-markdown-engine/commonmark-inlines.js +4 -4
  371. package/dist/safe-bash-markdown-engine/commonmark-syntax.js +2 -2
  372. package/dist/safe-bash-markdown-engine/gfm-syntax.js +3 -3
  373. package/dist/safe-bash-markdown-engine/index.js +5 -5
  374. package/dist/safe-bash-network-engine/transfer.js +3 -3
  375. package/dist/safe-bash-presentation-engine/accessibility.js +30 -30
  376. package/dist/safe-bash-presentation-engine/animation-editing.js +15 -15
  377. package/dist/safe-bash-presentation-engine/animations.js +15 -15
  378. package/dist/safe-bash-presentation-engine/backgrounds.js +16 -16
  379. package/dist/safe-bash-presentation-engine/bytes.js +3 -3
  380. package/dist/safe-bash-presentation-engine/chart-editing.js +33 -33
  381. package/dist/safe-bash-presentation-engine/chart-object-operations.js +24 -24
  382. package/dist/safe-bash-presentation-engine/charts.js +30 -30
  383. package/dist/safe-bash-presentation-engine/command-placeholder.js +58 -58
  384. package/dist/safe-bash-presentation-engine/comments.js +16 -16
  385. package/dist/safe-bash-presentation-engine/connector-operations.js +31 -31
  386. package/dist/safe-bash-presentation-engine/connectors.js +28 -28
  387. package/dist/safe-bash-presentation-engine/content-types.js +4 -4
  388. package/dist/safe-bash-presentation-engine/creation.js +6 -6
  389. package/dist/safe-bash-presentation-engine/diff.js +31 -31
  390. package/dist/safe-bash-presentation-engine/drawing-format.js +19 -19
  391. package/dist/safe-bash-presentation-engine/drawing-operations.js +30 -30
  392. package/dist/safe-bash-presentation-engine/drawing-schema.js +20 -20
  393. package/dist/safe-bash-presentation-engine/equations.js +16 -16
  394. package/dist/safe-bash-presentation-engine/errors.js +2 -2
  395. package/dist/safe-bash-presentation-engine/fields.js +16 -16
  396. package/dist/safe-bash-presentation-engine/font-metrics.js +3 -3
  397. package/dist/safe-bash-presentation-engine/image-extraction.js +19 -19
  398. package/dist/safe-bash-presentation-engine/image-formatting.js +31 -31
  399. package/dist/safe-bash-presentation-engine/image-insertion.js +17 -17
  400. package/dist/safe-bash-presentation-engine/image-replacement.js +20 -20
  401. package/dist/safe-bash-presentation-engine/image-value.js +4 -4
  402. package/dist/safe-bash-presentation-engine/images.js +18 -18
  403. package/dist/safe-bash-presentation-engine/index.js +114 -114
  404. package/dist/safe-bash-presentation-engine/layouts.js +15 -15
  405. package/dist/safe-bash-presentation-engine/length.js +3 -3
  406. package/dist/safe-bash-presentation-engine/links.js +15 -15
  407. package/dist/safe-bash-presentation-engine/masters.js +14 -14
  408. package/dist/safe-bash-presentation-engine/media-editing.js +23 -23
  409. package/dist/safe-bash-presentation-engine/media-extraction.js +16 -16
  410. package/dist/safe-bash-presentation-engine/media.js +15 -15
  411. package/dist/safe-bash-presentation-engine/memberships.js +14 -14
  412. package/dist/safe-bash-presentation-engine/notes.js +15 -15
  413. package/dist/safe-bash-presentation-engine/ole-enum.js +4 -4
  414. package/dist/safe-bash-presentation-engine/ole-insertion.js +19 -19
  415. package/dist/safe-bash-presentation-engine/opaque-objects.js +9 -9
  416. package/dist/safe-bash-presentation-engine/package-reader.js +5 -5
  417. package/dist/safe-bash-presentation-engine/package-tools.js +18 -18
  418. package/dist/safe-bash-presentation-engine/package-uri.js +3 -3
  419. package/dist/safe-bash-presentation-engine/package-writer.js +4 -4
  420. package/dist/safe-bash-presentation-engine/presentation-model.js +57 -57
  421. package/dist/safe-bash-presentation-engine/presentation-settings.js +13 -13
  422. package/dist/safe-bash-presentation-engine/properties.js +15 -15
  423. package/dist/safe-bash-presentation-engine/relationships.js +4 -4
  424. package/dist/safe-bash-presentation-engine/resource-limits.js +1 -1
  425. package/dist/safe-bash-presentation-engine/retained-frame-formatting.d.ts +14 -0
  426. package/dist/safe-bash-presentation-engine/retained-inspection.js +13 -13
  427. package/dist/safe-bash-presentation-engine/retained-package.js +5 -5
  428. package/dist/safe-bash-presentation-engine/retained-text.d.ts +9 -2
  429. package/dist/safe-bash-presentation-engine/retained-text.js +130 -31
  430. package/dist/safe-bash-presentation-engine/retained-xml-document.d.ts +1 -0
  431. package/dist/safe-bash-presentation-engine/sanitize.js +16 -16
  432. package/dist/safe-bash-presentation-engine/selectors.js +10 -10
  433. package/dist/safe-bash-presentation-engine/shape-groups.js +30 -30
  434. package/dist/safe-bash-presentation-engine/shape-operations.js +29 -29
  435. package/dist/safe-bash-presentation-engine/shape-path-operations.js +31 -31
  436. package/dist/safe-bash-presentation-engine/shape-paths.js +15 -15
  437. package/dist/safe-bash-presentation-engine/shape-presets.js +3 -3
  438. package/dist/safe-bash-presentation-engine/shape-selection.js +30 -30
  439. package/dist/safe-bash-presentation-engine/shape-transforms.js +17 -17
  440. package/dist/safe-bash-presentation-engine/shapes.js +26 -26
  441. package/dist/safe-bash-presentation-engine/slide-copy.js +16 -16
  442. package/dist/safe-bash-presentation-engine/slide-import.js +17 -17
  443. package/dist/safe-bash-presentation-engine/slide-merge-split.js +19 -19
  444. package/dist/safe-bash-presentation-engine/slide-model.js +42 -42
  445. package/dist/safe-bash-presentation-engine/slide-removal.js +17 -17
  446. package/dist/safe-bash-presentation-engine/slide-transfer-budget.js +9 -9
  447. package/dist/safe-bash-presentation-engine/slides.js +18 -18
  448. package/dist/safe-bash-presentation-engine/table-operations.js +32 -32
  449. package/dist/safe-bash-presentation-engine/table-spans.js +31 -31
  450. package/dist/safe-bash-presentation-engine/tables.js +30 -30
  451. package/dist/safe-bash-presentation-engine/tags.js +15 -15
  452. package/dist/safe-bash-presentation-engine/template-bindings.js +32 -32
  453. package/dist/safe-bash-presentation-engine/template-repeat.js +39 -39
  454. package/dist/safe-bash-presentation-engine/text-fitting.js +26 -26
  455. package/dist/safe-bash-presentation-engine/text-frames.d.ts +13 -0
  456. package/dist/safe-bash-presentation-engine/text-frames.js +28 -26
  457. package/dist/safe-bash-presentation-engine/text-paragraphs.js +26 -26
  458. package/dist/safe-bash-presentation-engine/text-reading.js +11 -11
  459. package/dist/safe-bash-presentation-engine/text-replacement.js +16 -16
  460. package/dist/safe-bash-presentation-engine/text-runs.js +19 -19
  461. package/dist/safe-bash-presentation-engine/themes.js +15 -15
  462. package/dist/safe-bash-presentation-engine/transitions.js +15 -15
  463. package/dist/safe-bash-presentation-engine/validation.js +9 -9
  464. package/dist/safe-bash-presentation-engine/xml-parts.js +18 -18
  465. package/dist/safe-bash-presentation-engine/xml-view.js +3 -3
  466. package/dist/safe-bash-presentation-engine/xml.js +3 -3
  467. package/dist/safe-bash-query-engine/index.js +4 -4
  468. package/dist/safe-bash-query-engine/interpreter.js +2 -2
  469. package/dist/safe-bash-query-engine/query-core.js +4 -4
  470. package/dist/safe-bash-xml-engine/document.js +3 -3
  471. package/dist/safe-bash-xml-engine/evaluate.js +1 -1
  472. package/dist/safe-bash-xml-engine/index.js +6 -6
  473. package/dist/safe-bash-xml-engine/query.js +2 -2
  474. package/dist/safe-bash-xml-engine/stored-document.d.ts +2 -2
  475. package/dist/safe-bash-xml-engine/stored-document.js +1 -1
  476. package/dist/safe-bash-xml-engine/stored-evaluate.js +1 -1
  477. package/dist/safe-bash-zip-engine/zip/repair.js +3 -3
  478. package/dist/safe-bash-zip-engine/zip/volumes.js +3 -3
  479. package/dist/spreadsheet-engine/datasource.js +16 -2
  480. package/dist/spreadsheet-engine/formulas/diagnostics.d.ts +2 -1
  481. package/dist/spreadsheet-engine/formulas/diagnostics.js +2 -2
  482. package/dist/spreadsheet-engine/formulas/evaluator.d.ts +1 -1
  483. package/dist/spreadsheet-engine/formulas/evaluator.js +2 -1
  484. package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +7 -6
  485. package/dist/spreadsheet-format-xls/biff-properties-merge.js +2 -2
  486. package/dist/spreadsheet-format-xls/biff-properties.js +94 -109
  487. package/dist/spreadsheet-format-xls/biff-property-dictionary.d.ts +5 -0
  488. package/dist/spreadsheet-format-xls/biff-property-dictionary.js +75 -0
  489. package/dist/spreadsheet-format-xls/biff-property-range.d.ts +17 -3
  490. package/dist/spreadsheet-format-xls/biff-property-range.js +178 -37
  491. package/package.json +4 -2
  492. package/dist/safe-bash/command-chunks/biff-4ALVARRF-7SRX6R6N.js +0 -5192
  493. package/dist/safe-bash/command-chunks/{chunk-X2HVVMTW.js → chunk-AW4Q3GZW.js} +6 -6
  494. package/dist/safe-bash/command-chunks/{chunk-JC2EV66U.js → chunk-BJXADHRT.js} +3 -3
  495. package/dist/safe-bash/command-chunks/{chunk-XI2LETBJ.js → chunk-BXU5Y7I5.js} +3 -3
  496. package/dist/safe-bash/command-chunks/{chunk-PVLPWVRH.js → chunk-D3HW7R2N.js} +3 -3
  497. package/dist/safe-bash/command-chunks/{chunk-OLK3DCJD.js → chunk-DYERIXPU.js} +3 -3
  498. package/dist/safe-bash/command-chunks/{chunk-WYBCSJFG.js → chunk-FWCUEZ3K.js} +3 -3
  499. package/dist/safe-bash/command-chunks/{chunk-FF2SQ2GP.js → chunk-GGH376XQ.js} +3 -3
  500. package/dist/safe-bash/command-chunks/{chunk-D66Q7QJ3.js → chunk-JRSZ5IGD.js} +6 -6
  501. package/dist/safe-bash/command-chunks/{chunk-3JST2Q7G.js → chunk-KRRG4MGH.js} +3 -3
  502. package/dist/safe-bash/command-chunks/{chunk-Z3YB4EVE.js → chunk-KSM5CCHT.js} +8 -8
  503. package/dist/safe-bash/command-chunks/{chunk-NJ4NTTCR.js → chunk-LNLACEAN.js} +8 -8
  504. package/dist/safe-bash/command-chunks/{chunk-NBTG6NF6.js → chunk-LTJRUMK6.js} +3 -3
  505. package/dist/safe-bash/command-chunks/{chunk-XCYTG7CR.js → chunk-NJGL5JQ6.js} +3 -3
  506. package/dist/safe-bash/command-chunks/{chunk-SZ66JC25.js → chunk-Q7J2NTH2.js} +3 -3
  507. package/dist/safe-bash/command-chunks/{chunk-MDV7W5AS.js → chunk-SKNI2XQA.js} +3 -3
  508. package/dist/safe-bash/command-chunks/{chunk-7ZWACKCG.js → chunk-T6OXG7QQ.js} +3 -3
  509. package/dist/safe-bash/command-chunks/{chunk-ECDEPKKW.js → chunk-W25EIKDJ.js} +3 -3
  510. package/dist/safe-bash/command-chunks/{chunk-4YSBUQPV.js → chunk-W2FKFEVY.js} +3 -3
  511. package/dist/safe-bash/command-chunks/{chunk-2CIDPOUV.js → chunk-WSNHJZQ5.js} +3 -3
  512. package/dist/safe-bash/command-chunks/{chunk-4H3TYOVC.js → chunk-Y7AXMCFV.js} +3 -3
  513. package/dist/safe-bash/command-chunks/{chunk-U6IEK2CI.js → chunk-YPG55QTP.js} +7 -7
  514. package/dist/safe-bash/command-chunks/{chunk-252L5YC5.js → chunk-Z37OM247.js} +6 -6
  515. package/dist/safe-bash/command-chunks/{pln-DFS7VLVS-JATX6FS7.js → pln-DFS7VLVS-OVOBS4QX.js} +3 -3
  516. 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,34 @@ 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 { editRetainedDocument as editRetainedDocument2, PdfFileSource as PdfFileSource3, PdfMutableObjectStore as PdfMutableObjectStore4, PdfRetainedDocument, cosBool, 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) {
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) {
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, ...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
894
  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;
895
+ const reference = input.crossReference;
896
+ const chosenId = info?.useUpdatedId ? reference.idArray : selectedId;
897
+ const idArray = options.keepFinalId || options.keepFirstId ? chosenId ?? reference.idArray : reference.idArray ?? chosenId;
455
898
  document = await PdfRetainedDocument.openStore(store, storage, { rootRef: reference.rootRef, version: reference.version, ...pageReferences, ...reference.infoRef ? { infoRef: reference.infoRef } : {}, ...idArray ? { idArray } : {}, signal });
456
899
  const root = await document.lookup(reference.rootRef);
457
900
  if (root?.value.kind === "dict" && !root.stream && root.reference) {
458
- const form = await document.lookup(dictGet2(root.value, "AcroForm"));
901
+ const form = await document.lookup(dictGet4(root.value, "AcroForm"));
459
902
  if (form?.value.kind === "dict" && !form.stream) {
460
903
  if (options.dropXfa) dictDelete(form.value, "XFA");
461
- if (options.needAppearances) dictSet(form.value, "NeedAppearances", cosBool(true));
904
+ if (options.needAppearances) dictSet2(form.value, "NeedAppearances", cosBool(true));
462
905
  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);
906
+ else dictSet2(root.value, "AcroForm", form.value);
464
907
  }
465
908
  await store.set({ objectNumber: root.reference.objectNumber, generationNumber: root.reference.generationNumber, value: root.value });
466
909
  }
@@ -469,7 +912,7 @@ async function* retainedOutput(source, storage, options, selectedId, signal, han
469
912
  yield* chunks;
470
913
  return;
471
914
  }
472
- plaintext = await PdfFileSource.fromStream(storage.fs, storage.directory, chunks, { signal });
915
+ plaintext = await PdfFileSource3.fromStream(storage.fs, storage.directory, chunks, { signal });
473
916
  const allow = options.allowPermissions, all = allow.has("allfeatures");
474
917
  yield* encryptRetainedPdfChunks(plaintext, storage, {
475
918
  userPassword: options.userPassword ?? "",
@@ -489,117 +932,12 @@ async function* retainedOutput(source, storage, options, selectedId, signal, han
489
932
  }
490
933
  }
491
934
 
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
935
  // 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";
936
+ 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
937
  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 });
938
+ const names = new PdfNameIndex4(storage, Infinity, signal);
939
+ const values = new PdfMutableObjectStore5(storage, { signal });
940
+ const tree = new PdfMutableObjectStore5(storage, { signal });
603
941
  const encoder = new TextEncoder();
604
942
  let work = 0, failed = false;
605
943
  async function checkpoint() {
@@ -661,17 +999,17 @@ async function* retainedFdf(document, storage, signal) {
661
999
  const string = (items, at) => {
662
1000
  const node = items[at];
663
1001
  if (node?.kind !== "string") throw new PdfError("E_PARSE", "Invalid FDF traversal name");
664
- return decodePdfString3(node);
1002
+ return decodePdfString4(node);
665
1003
  };
666
- const save = async (id, items) => tree.set({ objectNumber: id, generationNumber: 0, value: cosArray2(items) });
1004
+ const save = async (id, items) => tree.set({ objectNumber: id, generationNumber: 0, value: cosArray3(items) });
667
1005
  try {
668
1006
  for await (const field of document.formFieldDetails()) {
669
1007
  for await (const ignored of field.options()) void ignored;
670
1008
  const name = await names.intern(field.name);
671
- const staged = await PdfFileSource3.fromStream(storage.fs, storage.directory, fieldValue(field), { signal });
1009
+ const staged = await PdfFileSource4.fromStream(storage.fs, storage.directory, fieldValue(field), { signal });
672
1010
  let valueFailed = false;
673
1011
  try {
674
- await values.set({ objectNumber: name.index + 1, generationNumber: 0, value: cosDict2({}), stream: { length: staged.size, chunks: staged.stream(0, staged.size, signal) } });
1012
+ await values.set({ objectNumber: name.index + 1, generationNumber: 0, value: cosDict3({}), stream: { length: staged.size, chunks: staged.stream(0, staged.size, signal) } });
675
1013
  } catch (error) {
676
1014
  valueFailed = true;
677
1015
  throw error;
@@ -682,25 +1020,25 @@ async function* retainedFdf(document, storage, signal) {
682
1020
  }
683
1021
  }
684
1022
  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))]);
1023
+ const form = catalog?.kind === "dict" ? await resolve(dictGet5(catalog, "AcroForm")) : void 0;
1024
+ const roots = form?.kind === "dict" ? await resolve(dictGet5(form, "Fields")) : void 0;
1025
+ await save(1, [cosDict3({}), cosString3(""), cosString3(""), ...Array.from({ length: 6 }, () => cosNumber3(0))]);
688
1026
  let top = 1, next = 1;
689
1027
  while (top) {
690
1028
  await checkpoint();
691
1029
  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;
1030
+ const kids = top === 1 ? roots : node?.kind === "dict" ? await resolve(dictGet5(node, "Kids")) : void 0;
693
1031
  let descended = false, cursor = number(frame, 3);
694
1032
  while (kids?.kind === "array" && cursor < kids.items.length) {
695
1033
  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) : "";
1034
+ if (child?.kind !== "dict" || top !== 1 && !dictGet5(child, "T")) continue;
1035
+ const name = await resolve(dictGet5(child, "T")), partial = name?.kind === "string" ? decodePdfString4(name) : "";
698
1036
  const prefix = string(frame, 1), full = prefix && partial ? `${prefix}.${partial}` : partial || prefix;
699
1037
  const depth = number(frame, 8) + 1;
700
1038
  if (depth > document.depthLimit) throw new PdfError("E_LIMIT", "PDF FDF field depth limit exceeded");
701
- frame[3] = cosNumber2(cursor);
1039
+ frame[3] = cosNumber3(cursor);
702
1040
  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)]);
1041
+ await save(++next, [childNode, cosString3(full), cosString3(partial), cosNumber3(0), cosNumber3(0), cosNumber3(0), cosNumber3(0), cosNumber3(top), cosNumber3(depth)]);
704
1042
  top = next;
705
1043
  descended = true;
706
1044
  break;
@@ -711,10 +1049,10 @@ async function* retainedFdf(document, storage, signal) {
711
1049
  const owner = await record(parent), last = number(owner, 5);
712
1050
  if (last) {
713
1051
  const sibling = await record(last);
714
- sibling[6] = cosNumber2(top);
1052
+ sibling[6] = cosNumber3(top);
715
1053
  await save(last, sibling);
716
- } else owner[4] = cosNumber2(top);
717
- owner[5] = cosNumber2(top);
1054
+ } else owner[4] = cosNumber3(top);
1055
+ owner[5] = cosNumber3(top);
718
1056
  await save(parent, owner);
719
1057
  }
720
1058
  top = parent;
@@ -737,11 +1075,11 @@ async function* retainedFdf(document, storage, signal) {
737
1075
  const name = await names.intern(string(frame, 1)), value = name.added ? void 0 : await values.get(name.index + 1);
738
1076
  if (value?.stream) yield* value.stream.chunks;
739
1077
  else {
740
- const dict = await resolve(frame[0]), raw = dict?.kind === "dict" ? await resolve(dictGet4(dict, "V")) : void 0;
1078
+ const dict = await resolve(frame[0]), raw = dict?.kind === "dict" ? await resolve(dictGet5(dict, "V")) : void 0;
741
1079
  if (raw?.kind === "name") yield* text(`/${raw.decoded}`);
742
1080
  else {
743
1081
  yield* text("(");
744
- if (raw?.kind === "string") yield* text(decodePdfString3(raw), true);
1082
+ if (raw?.kind === "string") yield* text(decodePdfString4(raw), true);
745
1083
  yield* text(")");
746
1084
  }
747
1085
  }
@@ -803,7 +1141,7 @@ async function* retainedFieldReport(document, utf8, signal) {
803
1141
  }
804
1142
 
805
1143
  // 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";
1144
+ import { PdfError as PdfError2, PdfFileSource as PdfFileSource5, PdfRetainedDocument as PdfRetainedDocument2, retainedCosObjects as retainedCosObjects2 } from "../pdf-ast/index.js";
807
1145
  import { FsError } from "../safe-bash-contracts/errors.js";
808
1146
  import { writeBytes } from "../safe-bash-contracts/io.js";
809
1147
  import { resolvePath } from "../safe-bash-contracts/path.js";
@@ -821,6 +1159,7 @@ async function executeRetainedPdftk(context, options) {
821
1159
  let selectedId;
822
1160
  const counts = /* @__PURE__ */ new Map();
823
1161
  const inputs = /* @__PURE__ */ new Map();
1162
+ const infoPath = options.operation === "update_info" || options.operation === "update_info_utf8" ? options.opArgs[0] ?? "-" : void 0;
824
1163
  const overlayPath = ["stamp", "multistamp", "background", "multibackground"].includes(options.operation) ? options.opArgs[0] ?? "-" : void 0;
825
1164
  const attachmentPaths = [];
826
1165
  let attachmentPage;
@@ -834,6 +1173,7 @@ async function executeRetainedPdftk(context, options) {
834
1173
  if (source) yield { filename: path.slice(path.lastIndexOf("/") + 1), chunks: source.stream(0, source.size, signal) };
835
1174
  }
836
1175
  }
1176
+ let assembled;
837
1177
  let overlayDocument;
838
1178
  let document, output, total = 0, failed = false;
839
1179
  const diagnostic = async (message) => {
@@ -843,17 +1183,17 @@ async function executeRetainedPdftk(context, options) {
843
1183
  try {
844
1184
  await context.fs.mkdir(storage.directory, { recursive: true, signal });
845
1185
  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 });
1186
+ if (options.inputs.some((input) => input.file === "-") || attachmentPaths.includes("-") || overlayPath === "-" || infoPath === "-") {
1187
+ const source = await PdfFileSource5.fromStream(context.fs, storage.directory, context.stdin, { signal, maxInputBytes: maximum });
848
1188
  inputs.set("-", source);
849
1189
  total += source.size;
850
1190
  context.inputBudget?.check(total);
851
1191
  }
852
- for (const input of [...options.inputs, ...attachmentPaths.map((file) => ({ file })), ...overlayPath !== void 0 ? [{ file: overlayPath }] : []]) {
1192
+ for (const input of [...options.inputs, ...attachmentPaths.map((file) => ({ file })), ...overlayPath !== void 0 ? [{ file: overlayPath }] : [], ...infoPath !== void 0 ? [{ file: infoPath }] : []]) {
853
1193
  if (inputs.has(input.file)) continue;
854
1194
  let source;
855
1195
  try {
856
- source = await PdfFileSource4.open(context.fs, resolvePath(context.cwd, input.file), { signal, maxInputBytes: maximum - total });
1196
+ source = await PdfFileSource5.open(context.fs, resolvePath(context.cwd, input.file), { signal, maxInputBytes: maximum - total });
857
1197
  } catch (error) {
858
1198
  signal.throwIfAborted();
859
1199
  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 +1231,9 @@ async function executeRetainedPdftk(context, options) {
891
1231
  await source.releaseCache();
892
1232
  }
893
1233
  document = await PdfRetainedDocument2.open(inputs.get(primary.file), storage, { signal, recovery: "strict", ...primary.password ? { password: primary.password } : {} });
1234
+ const infoSource = infoPath === void 0 ? void 0 : inputs.get(infoPath);
1235
+ if (infoPath !== void 0 && !infoSource) return await diagnostic(`Error: Unable to open info file '${infoPath}'
1236
+ `);
894
1237
  let overlayPages = 0;
895
1238
  if (overlayPath !== void 0) {
896
1239
  const source = inputs.get(overlayPath);
@@ -920,7 +1263,10 @@ async function executeRetainedPdftk(context, options) {
920
1263
  }
921
1264
  return { exitCode: 0 };
922
1265
  }
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 });
1266
+ if (options.operation === "cat" || options.operation === "shuffle") {
1267
+ 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);
1268
+ }
1269
+ output = await PdfFileSource5.fromStream(context.fs, storage.directory, ["output", "rotate", "attach_files", "stamp", "multistamp", "background", "multibackground", "update_info", "update_info_utf8", "cat", "shuffle"].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) : 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
1270
  const destination = options.outputTarget;
925
1271
  if (!destination || destination === "-") for await (const bytes of output.stream(0, output.size, signal)) await writeBytes(context.stdout, bytes, signal);
926
1272
  else {
@@ -938,7 +1284,7 @@ async function executeRetainedPdftk(context, options) {
938
1284
  failed = true;
939
1285
  throw error;
940
1286
  } finally {
941
- const results = await Promise.allSettled([document?.close(), overlayDocument?.close(), output?.close(), ...[...inputs.values()].map((source) => source?.close())]);
1287
+ const results = await Promise.allSettled([assembled?.close(), document?.close(), overlayDocument?.close(), output?.close(), ...[...inputs.values()].map((source) => source?.close())]);
942
1288
  if (!failed) {
943
1289
  for (const result of results) if (result.status === "rejected") await Promise.reject(result.reason);
944
1290
  }
@@ -1151,17 +1497,17 @@ import { readBytes, writeBytes as writeBytes2 } from "../safe-bash-contracts/io.
1151
1497
  import { createOutputOperation } from "../safe-bash-contracts/output.js";
1152
1498
  import {
1153
1499
  PdfDocument,
1154
- cosArray as cosArray3,
1155
- cosDict as cosDict3,
1500
+ cosArray as cosArray4,
1501
+ cosDict as cosDict4,
1156
1502
  cosHexString,
1157
1503
  cosName,
1158
- cosNumber as cosNumber3,
1504
+ cosNumber as cosNumber4,
1159
1505
  cosStream,
1160
- cosString as cosString3,
1161
- decodePdfString as decodePdfString4,
1506
+ cosString as cosString4,
1507
+ decodePdfString as decodePdfString5,
1162
1508
  dictDelete as dictDelete2,
1163
- dictGet as dictGet5,
1164
- dictSet as dictSet2,
1509
+ dictGet as dictGet6,
1510
+ dictSet as dictSet3,
1165
1511
  flattenDocumentFormFields,
1166
1512
  getDocumentFormFields,
1167
1513
  parseFormDataBytes,
@@ -1286,27 +1632,6 @@ function encodePdftkText(str, utf8) {
1286
1632
  }
1287
1633
  return out;
1288
1634
  }
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
1635
  function escapeFdfString(str) {
1311
1636
  return str.replaceAll("\\", "\\\\").replaceAll("(", "\\(").replaceAll(")", "\\)").replaceAll("\r", "\\r").replaceAll("\n", "\\n");
1312
1637
  }
@@ -1327,102 +1652,102 @@ function formatDumpDataFields(doc, utf8 = true) {
1327
1652
  } else {
1328
1653
  valStr = String(field.value ?? "");
1329
1654
  }
1330
- const lines = [
1655
+ const lines2 = [
1331
1656
  "---",
1332
1657
  `FieldType: ${fieldType}`,
1333
1658
  `FieldName: ${encodePdftkText(field.name, utf8)}`
1334
1659
  ];
1335
1660
  if (field.altName) {
1336
- lines.push(`FieldNameAlt: ${encodePdftkText(field.altName, utf8)}`);
1661
+ lines2.push(`FieldNameAlt: ${encodePdftkText(field.altName, utf8)}`);
1337
1662
  }
1338
- lines.push(`FieldFlags: ${flags}`);
1663
+ lines2.push(`FieldFlags: ${flags}`);
1339
1664
  if (field.selectedValues && field.selectedValues.length > 0) {
1340
1665
  for (const sv of field.selectedValues) {
1341
- lines.push(`FieldValue: ${encodePdftkText(sv, utf8)}`);
1666
+ lines2.push(`FieldValue: ${encodePdftkText(sv, utf8)}`);
1342
1667
  }
1343
1668
  } else {
1344
- lines.push(`FieldValue: ${encodePdftkText(valStr, utf8)}`);
1669
+ lines2.push(`FieldValue: ${encodePdftkText(valStr, utf8)}`);
1345
1670
  }
1346
1671
  if (field.defaultValue !== void 0 && field.defaultValue !== "") {
1347
- lines.push(`FieldValueDefault: ${encodePdftkText(field.defaultValue, utf8)}`);
1672
+ lines2.push(`FieldValueDefault: ${encodePdftkText(field.defaultValue, utf8)}`);
1348
1673
  }
1349
- lines.push(`FieldJustification: ${field.justification ?? "Left"}`);
1674
+ lines2.push(`FieldJustification: ${field.justification ?? "Left"}`);
1350
1675
  for (const opt of options) {
1351
- lines.push(`FieldStateOption: ${encodePdftkText(opt, utf8)}`);
1676
+ lines2.push(`FieldStateOption: ${encodePdftkText(opt, utf8)}`);
1352
1677
  }
1353
1678
  if (field.maxLength !== void 0) {
1354
- lines.push(`FieldMaxLength: ${field.maxLength}`);
1679
+ lines2.push(`FieldMaxLength: ${field.maxLength}`);
1355
1680
  }
1356
- stanzas.push(lines.join("\n"));
1681
+ stanzas.push(lines2.join("\n"));
1357
1682
  }
1358
1683
  return stanzas.join("\n") + "\n";
1359
1684
  }
1360
1685
  function formatDumpDataAnnots(doc, utf8 = false) {
1361
- const lines = [];
1686
+ const lines2 = [];
1362
1687
  const id0Node = doc.cos.idArray?.items[0] ? doc.cos.resolve(doc.cos.idArray.items[0]) : void 0;
1363
1688
  const id1Node = doc.cos.idArray?.items[1] ? doc.cos.resolve(doc.cos.idArray.items[1]) : void 0;
1364
1689
  const id0Hex = id0Node?.kind === "string" ? bytesToHexLower(id0Node.bytes) : "00000000000000000000000000000000";
1365
1690
  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}`);
1691
+ lines2.push(`PdfID0: ${id0Hex}`);
1692
+ lines2.push(`PdfID1: ${id1Hex}`);
1693
+ lines2.push(`NumberOfPages: ${doc.pageCount}`);
1369
1694
  for (let p = 0; p < doc.pageCount; p++) {
1370
1695
  const pageDict = doc.getPage(p).pageDict;
1371
- const annotsArr = doc.cos.resolveArray(dictGet5(pageDict, "Annots"));
1696
+ const annotsArr = doc.cos.resolveArray(dictGet6(pageDict, "Annots"));
1372
1697
  if (!annotsArr) continue;
1373
1698
  for (const item of annotsArr.items) {
1374
1699
  const annotDict = doc.cos.resolveDict(item);
1375
1700
  if (!annotDict) continue;
1376
- const subNode = doc.cos.resolve(dictGet5(annotDict, "Subtype"));
1701
+ const subNode = doc.cos.resolve(dictGet6(annotDict, "Subtype"));
1377
1702
  const subtype = subNode?.kind === "name" ? subNode.decoded : "Annot";
1378
- const rectArr = doc.cos.resolveArray(dictGet5(annotDict, "Rect"));
1703
+ const rectArr = doc.cos.resolveArray(dictGet6(annotDict, "Rect"));
1379
1704
  const rectNums = rectArr ? rectArr.items.map((it) => {
1380
1705
  const r = doc.cos.resolve(it);
1381
1706
  return r?.kind === "number" ? r.value : 0;
1382
1707
  }) : [0, 0, 0, 0];
1383
- const flagsNode = doc.cos.resolve(dictGet5(annotDict, "F"));
1708
+ const flagsNode = doc.cos.resolve(dictGet6(annotDict, "F"));
1384
1709
  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"));
1710
+ lines2.push("---");
1711
+ lines2.push(`AnnotSubtype: ${subtype}`);
1712
+ lines2.push(`AnnotRect: ${rectNums.slice(0, 4).join(" ")}`);
1713
+ const nmNode = doc.cos.resolve(dictGet6(annotDict, "NM"));
1389
1714
  if (nmNode?.kind === "string") {
1390
- lines.push(`AnnotName: ${encodePdftkText(decodePdfString4(nmNode), utf8)}`);
1715
+ lines2.push(`AnnotName: ${encodePdftkText(decodePdfString5(nmNode), utf8)}`);
1391
1716
  }
1392
- const tNode = doc.cos.resolve(dictGet5(annotDict, "T"));
1717
+ const tNode = doc.cos.resolve(dictGet6(annotDict, "T"));
1393
1718
  if (tNode?.kind === "string") {
1394
- lines.push(`AnnotTitle: ${encodePdftkText(decodePdfString4(tNode), utf8)}`);
1719
+ lines2.push(`AnnotTitle: ${encodePdftkText(decodePdfString5(tNode), utf8)}`);
1395
1720
  }
1396
- const subjNode = doc.cos.resolve(dictGet5(annotDict, "Subj"));
1721
+ const subjNode = doc.cos.resolve(dictGet6(annotDict, "Subj"));
1397
1722
  if (subjNode?.kind === "string") {
1398
- lines.push(`AnnotSubj: ${encodePdftkText(decodePdfString4(subjNode), utf8)}`);
1723
+ lines2.push(`AnnotSubj: ${encodePdftkText(decodePdfString5(subjNode), utf8)}`);
1399
1724
  }
1400
- const cNode = doc.cos.resolve(dictGet5(annotDict, "Contents"));
1725
+ const cNode = doc.cos.resolve(dictGet6(annotDict, "Contents"));
1401
1726
  if (cNode?.kind === "string") {
1402
- lines.push(`AnnotContents: ${encodePdftkText(decodePdfString4(cNode), utf8)}`);
1727
+ lines2.push(`AnnotContents: ${encodePdftkText(decodePdfString5(cNode), utf8)}`);
1403
1728
  }
1404
- const colArr = doc.cos.resolveArray(dictGet5(annotDict, "C"));
1729
+ const colArr = doc.cos.resolveArray(dictGet6(annotDict, "C"));
1405
1730
  if (colArr && colArr.items.length >= 3) {
1406
1731
  const colNums = colArr.items.slice(0, 3).map((it) => {
1407
1732
  const r = doc.cos.resolve(it);
1408
1733
  return r?.kind === "number" ? r.value : 0;
1409
1734
  });
1410
- lines.push(`AnnotColor: ${colNums.join(" ")}`);
1735
+ lines2.push(`AnnotColor: ${colNums.join(" ")}`);
1411
1736
  }
1412
- const openNode = doc.cos.resolve(dictGet5(annotDict, "Open"));
1737
+ const openNode = doc.cos.resolve(dictGet6(annotDict, "Open"));
1413
1738
  if (openNode?.kind === "boolean") {
1414
- lines.push(`AnnotOpen: ${openNode.value}`);
1739
+ lines2.push(`AnnotOpen: ${openNode.value}`);
1415
1740
  }
1416
- const mNode = doc.cos.resolve(dictGet5(annotDict, "M"));
1741
+ const mNode = doc.cos.resolve(dictGet6(annotDict, "M"));
1417
1742
  if (mNode?.kind === "string") {
1418
- lines.push(`AnnotModificationDate: ${encodePdftkText(decodePdfString4(mNode), utf8)}`);
1743
+ lines2.push(`AnnotModificationDate: ${encodePdftkText(decodePdfString5(mNode), utf8)}`);
1419
1744
  }
1420
- lines.push(`AnnotFlags: ${flags}`);
1421
- lines.push(`AnnotPageNumber: ${p + 1}`);
1745
+ lines2.push(`AnnotFlags: ${flags}`);
1746
+ lines2.push(`AnnotPageNumber: ${p + 1}`);
1422
1747
  const formatDestTarget = (dRaw) => {
1423
1748
  if (!dRaw) return void 0;
1424
1749
  const resolved = doc.cos.resolve(dRaw);
1425
- if (resolved?.kind === "string") return decodePdfString4(resolved);
1750
+ if (resolved?.kind === "string") return decodePdfString5(resolved);
1426
1751
  if (resolved?.kind === "name") return resolved.decoded;
1427
1752
  if (resolved?.kind === "array" && resolved.items.length > 0) {
1428
1753
  const first = resolved.items[0];
@@ -1455,53 +1780,53 @@ function formatDumpDataAnnots(doc, utf8 = false) {
1455
1780
  }
1456
1781
  const actionDict = doc.cos.resolveDict(aNode);
1457
1782
  if (!actionDict) return;
1458
- const sNode = doc.cos.resolve(dictGet5(actionDict, "S"));
1783
+ const sNode = doc.cos.resolve(dictGet6(actionDict, "S"));
1459
1784
  const sType = sNode?.kind === "name" ? sNode.decoded : "";
1460
1785
  if (sType) {
1461
- lines.push(`AnnotActionType: ${sType}`);
1786
+ lines2.push(`AnnotActionType: ${sType}`);
1462
1787
  }
1463
- const uriNode = doc.cos.resolve(dictGet5(actionDict, "URI"));
1788
+ const uriNode = doc.cos.resolve(dictGet6(actionDict, "URI"));
1464
1789
  if (uriNode?.kind === "string") {
1465
- lines.push(`AnnotActionURI: ${encodePdftkText(decodePdfString4(uriNode), utf8)}`);
1790
+ lines2.push(`AnnotActionURI: ${encodePdftkText(decodePdfString5(uriNode), utf8)}`);
1466
1791
  }
1467
- const dNode = dictGet5(actionDict, "D");
1792
+ const dNode = dictGet6(actionDict, "D");
1468
1793
  const destTarget = formatDestTarget(dNode);
1469
1794
  if (destTarget) {
1470
- lines.push(`AnnotActionDest: ${encodePdftkText(destTarget, utf8)}`);
1795
+ lines2.push(`AnnotActionDest: ${encodePdftkText(destTarget, utf8)}`);
1471
1796
  }
1472
1797
  const resolvedIdx = resolveDestinationPageIndex(doc, dNode ?? actionDict);
1473
1798
  if (resolvedIdx !== void 0) {
1474
- lines.push(`AnnotActionPageNumber: ${resolvedIdx + 1}`);
1799
+ lines2.push(`AnnotActionPageNumber: ${resolvedIdx + 1}`);
1475
1800
  }
1476
- const fRaw = doc.cos.resolve(dictGet5(actionDict, "F"));
1801
+ const fRaw = doc.cos.resolve(dictGet6(actionDict, "F"));
1477
1802
  if (fRaw?.kind === "string") {
1478
- lines.push(`AnnotActionFile: ${encodePdftkText(decodePdfString4(fRaw), utf8)}`);
1803
+ lines2.push(`AnnotActionFile: ${encodePdftkText(decodePdfString5(fRaw), utf8)}`);
1479
1804
  } else if (fRaw?.kind === "dict") {
1480
- const ufNode = doc.cos.resolve(dictGet5(fRaw, "UF") ?? dictGet5(fRaw, "F"));
1805
+ const ufNode = doc.cos.resolve(dictGet6(fRaw, "UF") ?? dictGet6(fRaw, "F"));
1481
1806
  if (ufNode?.kind === "string") {
1482
- lines.push(`AnnotActionFile: ${encodePdftkText(decodePdfString4(ufNode), utf8)}`);
1807
+ lines2.push(`AnnotActionFile: ${encodePdftkText(decodePdfString5(ufNode), utf8)}`);
1483
1808
  }
1484
1809
  }
1485
- emitActionChain(dictGet5(actionDict, "Next"), visited);
1810
+ emitActionChain(dictGet6(actionDict, "Next"), visited);
1486
1811
  };
1487
- const rawA = dictGet5(annotDict, "A");
1812
+ const rawA = dictGet6(annotDict, "A");
1488
1813
  if (rawA) {
1489
1814
  emitActionChain(rawA);
1490
- } else if (dictGet5(annotDict, "Dest")) {
1491
- lines.push("AnnotActionType: GoTo");
1492
- const dNode = dictGet5(annotDict, "Dest");
1815
+ } else if (dictGet6(annotDict, "Dest")) {
1816
+ lines2.push("AnnotActionType: GoTo");
1817
+ const dNode = dictGet6(annotDict, "Dest");
1493
1818
  const destTarget = formatDestTarget(dNode);
1494
1819
  if (destTarget) {
1495
- lines.push(`AnnotActionDest: ${encodePdftkText(destTarget, utf8)}`);
1820
+ lines2.push(`AnnotActionDest: ${encodePdftkText(destTarget, utf8)}`);
1496
1821
  }
1497
1822
  const resolvedIdx = resolveDestinationPageIndex(doc, dNode);
1498
1823
  if (resolvedIdx !== void 0) {
1499
- lines.push(`AnnotActionPageNumber: ${resolvedIdx + 1}`);
1824
+ lines2.push(`AnnotActionPageNumber: ${resolvedIdx + 1}`);
1500
1825
  }
1501
1826
  }
1502
1827
  }
1503
1828
  }
1504
- return lines.join("\n") + "\n";
1829
+ return lines2.join("\n") + "\n";
1505
1830
  }
1506
1831
  function copyPrimaryMetadata(srcDoc, dstDoc) {
1507
1832
  const meta = srcDoc.getMetadata();
@@ -1535,18 +1860,18 @@ function collectOutlineBookmarks(doc, firstNode, level, out, visited = /* @__PUR
1535
1860
  }
1536
1861
  const dict = doc.cos.resolveDict(curr);
1537
1862
  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"));
1863
+ const titleNode = doc.cos.resolve(dictGet6(dict, "Title"));
1864
+ const title = titleNode?.kind === "string" ? decodePdfString5(titleNode) : titleNode?.kind === "name" ? titleNode.decoded : "";
1865
+ const resolvedIdx = resolveDestinationPageIndex(doc, dictGet6(dict, "Dest") ?? dictGet6(dict, "A"));
1541
1866
  const pageNumber = resolvedIdx !== void 0 ? resolvedIdx + 1 : 1;
1542
1867
  if (title) {
1543
1868
  out.push({ title, level, pageNumber });
1544
1869
  }
1545
- const childFirst = dictGet5(dict, "First");
1870
+ const childFirst = dictGet6(dict, "First");
1546
1871
  if (childFirst) {
1547
1872
  collectOutlineBookmarks(doc, childFirst, level + 1, out, visited);
1548
1873
  }
1549
- curr = dictGet5(dict, "Next");
1874
+ curr = dictGet6(dict, "Next");
1550
1875
  }
1551
1876
  }
1552
1877
  function collectNameTreePairs(doc, nodeOrRef, out, visited = /* @__PURE__ */ new Set()) {
@@ -1557,16 +1882,16 @@ function collectNameTreePairs(doc, nodeOrRef, out, visited = /* @__PURE__ */ new
1557
1882
  }
1558
1883
  const dict = doc.cos.resolveDict(nodeOrRef);
1559
1884
  if (!dict) return;
1560
- const namesArr = doc.cos.resolveArray(dictGet5(dict, "Names"));
1885
+ const namesArr = doc.cos.resolveArray(dictGet6(dict, "Names"));
1561
1886
  if (namesArr) {
1562
1887
  for (let i = 0; i + 1 < namesArr.items.length; i += 2) {
1563
1888
  const k = doc.cos.resolve(namesArr.items[i]);
1564
1889
  const v = namesArr.items[i + 1];
1565
- const name = k?.kind === "string" ? decodePdfString4(k) : "attachment.bin";
1890
+ const name = k?.kind === "string" ? decodePdfString5(k) : "attachment.bin";
1566
1891
  out.push({ name, value: v });
1567
1892
  }
1568
1893
  }
1569
- const kidsArr = doc.cos.resolveArray(dictGet5(dict, "Kids"));
1894
+ const kidsArr = doc.cos.resolveArray(dictGet6(dict, "Kids"));
1570
1895
  if (kidsArr) {
1571
1896
  for (const kid of kidsArr.items) {
1572
1897
  collectNameTreePairs(doc, kid, out, visited);
@@ -1581,7 +1906,7 @@ function collectNumberTreePairs(doc, nodeOrRef, out, visited = /* @__PURE__ */ n
1581
1906
  }
1582
1907
  const dict = doc.cos.resolveDict(nodeOrRef);
1583
1908
  if (!dict) return;
1584
- const numsArr = doc.cos.resolveArray(dictGet5(dict, "Nums"));
1909
+ const numsArr = doc.cos.resolveArray(dictGet6(dict, "Nums"));
1585
1910
  if (numsArr) {
1586
1911
  for (let i = 0; i + 1 < numsArr.items.length; i += 2) {
1587
1912
  const k = doc.cos.resolve(numsArr.items[i]);
@@ -1591,7 +1916,7 @@ function collectNumberTreePairs(doc, nodeOrRef, out, visited = /* @__PURE__ */ n
1591
1916
  }
1592
1917
  }
1593
1918
  }
1594
- const kidsArr = doc.cos.resolveArray(dictGet5(dict, "Kids"));
1919
+ const kidsArr = doc.cos.resolveArray(dictGet6(dict, "Kids"));
1595
1920
  if (kidsArr) {
1596
1921
  for (const kid of kidsArr.items) {
1597
1922
  collectNumberTreePairs(doc, kid, out, visited);
@@ -1605,19 +1930,9 @@ function bytesToHexLower(bytes) {
1605
1930
  }
1606
1931
  return hex;
1607
1932
  }
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
1933
  function formatDumpData(doc, utf8 = true) {
1619
1934
  const meta = doc.getMetadata();
1620
- const lines = [];
1935
+ const lines2 = [];
1621
1936
  const emittedKeys = /* @__PURE__ */ new Set();
1622
1937
  const infoEntries = [
1623
1938
  ["Title", meta.title],
@@ -1630,7 +1945,7 @@ function formatDumpData(doc, utf8 = true) {
1630
1945
  for (const [key, val] of infoEntries) {
1631
1946
  if (val !== void 0 && val !== "") {
1632
1947
  emittedKeys.add(key);
1633
- lines.push(
1948
+ lines2.push(
1634
1949
  "InfoBegin",
1635
1950
  `InfoKey: ${encodePdftkText(key, utf8)}`,
1636
1951
  `InfoValue: ${encodePdftkText(val, utf8)}`
@@ -1645,10 +1960,10 @@ function formatDumpData(doc, utf8 = true) {
1645
1960
  if (emittedKeys.has(k)) continue;
1646
1961
  const r = doc.cos.resolve(entry.value);
1647
1962
  if (r?.kind === "string") {
1648
- const val = decodePdfString4(r);
1963
+ const val = decodePdfString5(r);
1649
1964
  if (val) {
1650
1965
  emittedKeys.add(k);
1651
- lines.push(
1966
+ lines2.push(
1652
1967
  "InfoBegin",
1653
1968
  `InfoKey: ${encodePdftkText(k, utf8)}`,
1654
1969
  `InfoValue: ${encodePdftkText(val, utf8)}`
@@ -1662,16 +1977,16 @@ function formatDumpData(doc, utf8 = true) {
1662
1977
  const id1Node = doc.cos.idArray?.items[1] ? doc.cos.resolve(doc.cos.idArray.items[1]) : void 0;
1663
1978
  const id0Hex = id0Node?.kind === "string" ? bytesToHexLower(id0Node.bytes) : "00000000000000000000000000000000";
1664
1979
  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}`);
1980
+ lines2.push(`PdfID0: ${id0Hex}`);
1981
+ lines2.push(`PdfID1: ${id1Hex}`);
1982
+ lines2.push(`NumberOfPages: ${doc.pageCount}`);
1668
1983
  const catalog = doc.cos.resolveDict(doc.cos.rootRef);
1669
- const outlinesDict = catalog ? doc.cos.resolveDict(dictGet5(catalog, "Outlines")) : void 0;
1984
+ const outlinesDict = catalog ? doc.cos.resolveDict(dictGet6(catalog, "Outlines")) : void 0;
1670
1985
  if (outlinesDict) {
1671
1986
  const bookmarks = [];
1672
- collectOutlineBookmarks(doc, dictGet5(outlinesDict, "First"), 1, bookmarks);
1987
+ collectOutlineBookmarks(doc, dictGet6(outlinesDict, "First"), 1, bookmarks);
1673
1988
  for (const bm of bookmarks) {
1674
- lines.push(
1989
+ lines2.push(
1675
1990
  "BookmarkBegin",
1676
1991
  `BookmarkTitle: ${encodePdftkText(bm.title, utf8)}`,
1677
1992
  `BookmarkLevel: ${bm.level}`,
@@ -1683,7 +1998,7 @@ function formatDumpData(doc, utf8 = true) {
1683
1998
  const page = doc.getPage(i);
1684
1999
  const { width, height } = page.getSize();
1685
2000
  const rot = page.getRotation();
1686
- const mbArr = doc.cos.resolveArray(dictGet5(page.pageDict, "MediaBox"));
2001
+ const mbArr = doc.cos.resolveArray(dictGet6(page.pageDict, "MediaBox"));
1687
2002
  let mbRectStr = `0 0 ${width} ${height}`;
1688
2003
  if (mbArr && mbArr.items.length >= 4) {
1689
2004
  const mbNums = mbArr.items.slice(0, 4).map((item) => {
@@ -1692,50 +2007,50 @@ function formatDumpData(doc, utf8 = true) {
1692
2007
  });
1693
2008
  mbRectStr = `${mbNums[0]} ${mbNums[1]} ${mbNums[2]} ${mbNums[3]}`;
1694
2009
  }
1695
- lines.push(
2010
+ lines2.push(
1696
2011
  "PageMediaBegin",
1697
2012
  `PageMediaNumber: ${i + 1}`,
1698
2013
  `PageMediaRotation: ${rot}`,
1699
2014
  `PageMediaRect: ${mbRectStr}`,
1700
2015
  `PageMediaDimensions: ${width} ${height}`
1701
2016
  );
1702
- const cbArr = doc.cos.resolveArray(dictGet5(page.pageDict, "CropBox"));
2017
+ const cbArr = doc.cos.resolveArray(dictGet6(page.pageDict, "CropBox"));
1703
2018
  if (cbArr && cbArr.items.length >= 4) {
1704
2019
  const nums = cbArr.items.slice(0, 4).map((item) => {
1705
2020
  const r = doc.cos.resolve(item);
1706
2021
  return r?.kind === "number" ? r.value : 0;
1707
2022
  });
1708
- lines.push(`PageMediaCropBox: ${nums[0]} ${nums[1]} ${nums[2]} ${nums[3]}`);
1709
- lines.push(`PageMediaCropRect: ${nums[0]} ${nums[1]} ${nums[2]} ${nums[3]}`);
2023
+ lines2.push(`PageMediaCropBox: ${nums[0]} ${nums[1]} ${nums[2]} ${nums[3]}`);
2024
+ lines2.push(`PageMediaCropRect: ${nums[0]} ${nums[1]} ${nums[2]} ${nums[3]}`);
1710
2025
  }
1711
2026
  }
1712
2027
  const pageLabelsPairs = [];
1713
2028
  if (catalog) {
1714
- collectNumberTreePairs(doc, dictGet5(catalog, "PageLabels"), pageLabelsPairs);
2029
+ collectNumberTreePairs(doc, dictGet6(catalog, "PageLabels"), pageLabelsPairs);
1715
2030
  }
1716
2031
  for (const pair of pageLabelsPairs) {
1717
2032
  const lblDict = doc.cos.resolveDict(pair.value);
1718
2033
  if (lblDict) {
1719
2034
  const newIndex = Math.max(1, pair.num + 1);
1720
- const stNode = doc.cos.resolve(dictGet5(lblDict, "St"));
2035
+ const stNode = doc.cos.resolve(dictGet6(lblDict, "St"));
1721
2036
  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"));
2037
+ const pNode = doc.cos.resolve(dictGet6(lblDict, "P"));
2038
+ const prefix = pNode?.kind === "string" ? decodePdfString5(pNode) : void 0;
2039
+ const sNode = doc.cos.resolve(dictGet6(lblDict, "S"));
1725
2040
  const styleCode = sNode?.kind === "name" ? sNode.decoded : "";
1726
2041
  const numStyle = PDF_TO_PAGE_LABEL_STYLE[styleCode] ?? "NoNumber";
1727
- lines.push(
2042
+ lines2.push(
1728
2043
  "PageLabelBegin",
1729
2044
  `PageLabelNewIndex: ${newIndex}`,
1730
2045
  `PageLabelStart: ${startNum}`
1731
2046
  );
1732
2047
  if (prefix !== void 0 && prefix !== "") {
1733
- lines.push(`PageLabelPrefix: ${encodePdftkText(prefix, utf8)}`);
2048
+ lines2.push(`PageLabelPrefix: ${encodePdftkText(prefix, utf8)}`);
1734
2049
  }
1735
- lines.push(`PageLabelNumStyle: ${numStyle}`);
2050
+ lines2.push(`PageLabelNumStyle: ${numStyle}`);
1736
2051
  }
1737
2052
  }
1738
- return lines.join("\n") + "\n";
2053
+ return lines2.join("\n") + "\n";
1739
2054
  }
1740
2055
  function formatGenerateFdf(doc) {
1741
2056
  const fields = getDocumentFormFields(doc.cos);
@@ -1752,23 +2067,23 @@ function formatGenerateFdf(doc) {
1752
2067
  }
1753
2068
  return `(${escapeFdfString(String(f.value ?? ""))})`;
1754
2069
  }
1755
- const vNode = doc.cos.resolve(dictGet5(dict, "V"));
2070
+ const vNode = doc.cos.resolve(dictGet6(dict, "V"));
1756
2071
  if (vNode?.kind === "name") return `/${vNode.decoded}`;
1757
- if (vNode?.kind === "string") return `(${escapeFdfString(decodePdfString4(vNode))})`;
2072
+ if (vNode?.kind === "string") return `(${escapeFdfString(decodePdfString5(vNode))})`;
1758
2073
  return "()";
1759
2074
  };
1760
2075
  const serializeCosFieldNode = (nodeOrRef, prefix) => {
1761
2076
  const dict = doc.cos.resolveDict(nodeOrRef);
1762
2077
  if (!dict) return void 0;
1763
- const tNode = doc.cos.resolve(dictGet5(dict, "T"));
1764
- const partialName = tNode?.kind === "string" ? decodePdfString4(tNode) : "";
2078
+ const tNode = doc.cos.resolve(dictGet6(dict, "T"));
2079
+ const partialName = tNode?.kind === "string" ? decodePdfString5(tNode) : "";
1765
2080
  const fullName = prefix && partialName ? `${prefix}.${partialName}` : partialName || prefix;
1766
- const kidsArr = doc.cos.resolveArray(dictGet5(dict, "Kids"));
2081
+ const kidsArr = doc.cos.resolveArray(dictGet6(dict, "Kids"));
1767
2082
  const namedKids = [];
1768
2083
  if (kidsArr) {
1769
2084
  for (const k of kidsArr.items) {
1770
2085
  const kDict = doc.cos.resolveDict(k);
1771
- if (kDict && dictGet5(kDict, "T")) {
2086
+ if (kDict && dictGet6(kDict, "T")) {
1772
2087
  const serializedKid = serializeCosFieldNode(k, fullName);
1773
2088
  if (serializedKid) namedKids.push(serializedKid);
1774
2089
  }
@@ -1782,8 +2097,8 @@ function formatGenerateFdf(doc) {
1782
2097
  };
1783
2098
  const entries = [];
1784
2099
  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;
2100
+ const acroForm = catalog ? doc.cos.resolveDict(dictGet6(catalog, "AcroForm")) : void 0;
2101
+ const fieldsArr = acroForm ? doc.cos.resolveArray(dictGet6(acroForm, "Fields")) : void 0;
1787
2102
  if (fieldsArr && fieldsArr.items.length > 0) {
1788
2103
  for (const item of fieldsArr.items) {
1789
2104
  const s = serializeCosFieldNode(item, "");
@@ -1791,7 +2106,7 @@ function formatGenerateFdf(doc) {
1791
2106
  }
1792
2107
  } else {
1793
2108
  for (const f of fields) {
1794
- entries.push(`<< /T (${escapeFdfString(f.name)}) /V ${formatFieldVal(f.name, cosDict3({}))} >>`);
2109
+ entries.push(`<< /T (${escapeFdfString(f.name)}) /V ${formatFieldVal(f.name, cosDict4({}))} >>`);
1795
2110
  }
1796
2111
  }
1797
2112
  return `%FDF-1.2
@@ -1809,9 +2124,9 @@ function setDocumentBookmarks(doc, bookmarks) {
1809
2124
  if (bookmarks.length === 0 || doc.pageCount === 0) return;
1810
2125
  const catalog = doc.cos.resolveDict(doc.cos.rootRef);
1811
2126
  if (!catalog) return;
1812
- const outlinesDict = cosDict3({ Type: cosName("Outlines") });
2127
+ const outlinesDict = cosDict4({ Type: cosName("Outlines") });
1813
2128
  const outlinesRef = doc.cos.allocateObject(outlinesDict);
1814
- dictSet2(catalog, "Outlines", outlinesRef);
2129
+ dictSet3(catalog, "Outlines", outlinesRef);
1815
2130
  const stack = [{ ref: outlinesRef, dict: outlinesDict, children: [] }];
1816
2131
  for (const bm of bookmarks) {
1817
2132
  const targetLevel = Math.max(1, bm.level);
@@ -1830,26 +2145,26 @@ function setDocumentBookmarks(doc, bookmarks) {
1830
2145
  const parentState = stack[stack.length - 1];
1831
2146
  const pageIdx = Math.max(0, Math.min(doc.pageCount - 1, bm.pageNumber - 1));
1832
2147
  const pageRef = doc.getPage(pageIdx).ref;
1833
- const itemDict = cosDict3({
1834
- Title: cosString3(bm.title),
2148
+ const itemDict = cosDict4({
2149
+ Title: cosString4(bm.title),
1835
2150
  Parent: parentState.ref,
1836
- Dest: cosArray3([pageRef, cosName("XYZ"), { kind: "null" }, { kind: "null" }, { kind: "null" }])
2151
+ Dest: cosArray4([pageRef, cosName("XYZ"), { kind: "null" }, { kind: "null" }, { kind: "null" }])
1837
2152
  });
1838
2153
  const itemRef = doc.cos.allocateObject(itemDict);
1839
2154
  const prevSibling = parentState.children[parentState.children.length - 1];
1840
2155
  if (prevSibling) {
1841
- dictSet2(prevSibling.dict, "Next", itemRef);
1842
- dictSet2(itemDict, "Prev", prevSibling.ref);
2156
+ dictSet3(prevSibling.dict, "Next", itemRef);
2157
+ dictSet3(itemDict, "Prev", prevSibling.ref);
1843
2158
  } else {
1844
- dictSet2(parentState.dict, "First", itemRef);
2159
+ dictSet3(parentState.dict, "First", itemRef);
1845
2160
  }
1846
- dictSet2(parentState.dict, "Last", itemRef);
2161
+ dictSet3(parentState.dict, "Last", itemRef);
1847
2162
  parentState.children.push({ ref: itemRef, dict: itemDict });
1848
- dictSet2(parentState.dict, "Count", cosNumber3(parentState.children.length));
2163
+ dictSet3(parentState.dict, "Count", cosNumber4(parentState.children.length));
1849
2164
  }
1850
2165
  }
1851
2166
  function applyUpdateInfoText(doc, text) {
1852
- const lines = text.replaceAll("\r\n", "\n").split("\n");
2167
+ const lines2 = text.replaceAll("\r\n", "\n").split("\n");
1853
2168
  let mode = "none";
1854
2169
  let curKey = "";
1855
2170
  let bmTitle = "";
@@ -1901,7 +2216,7 @@ function applyUpdateInfoText(doc, text) {
1901
2216
  pmDimensions = void 0;
1902
2217
  pmCropBox = void 0;
1903
2218
  };
1904
- for (const raw of lines) {
2219
+ for (const raw of lines2) {
1905
2220
  const line = raw.trim();
1906
2221
  if (line === "InfoBegin") {
1907
2222
  flushStanza();
@@ -1936,7 +2251,7 @@ function applyUpdateInfoText(doc, text) {
1936
2251
  }
1937
2252
  const infoDict = doc.cos.infoRef ? doc.cos.resolveDict(doc.cos.infoRef) : void 0;
1938
2253
  if (infoDict) {
1939
- dictSet2(infoDict, curKey, cosString3(val));
2254
+ dictSet3(infoDict, curKey, cosString4(val));
1940
2255
  }
1941
2256
  }
1942
2257
  mode = "none";
@@ -1983,7 +2298,7 @@ function applyUpdateInfoText(doc, text) {
1983
2298
  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
2299
  const b0 = pdfId0Hex !== void 0 ? hexToBytes(pdfId0Hex) : existing0;
1985
2300
  const b1 = pdfId1Hex !== void 0 ? hexToBytes(pdfId1Hex) : existing1;
1986
- doc.cos.idArray = cosArray3([cosHexString(b0), cosHexString(b1)]);
2301
+ doc.cos.idArray = cosArray4([cosHexString(b0), cosHexString(b1)]);
1987
2302
  }
1988
2303
  for (const [pageNum, rot] of pageRotations.entries()) {
1989
2304
  if (pageNum >= 1 && pageNum <= doc.pageCount) {
@@ -1992,28 +2307,28 @@ function applyUpdateInfoText(doc, text) {
1992
2307
  }
1993
2308
  for (const [pageNum, [w, h]] of pageDimensions.entries()) {
1994
2309
  if (pageNum >= 1 && pageNum <= doc.pageCount) {
1995
- dictSet2(
2310
+ dictSet3(
1996
2311
  doc.getPage(pageNum - 1).pageDict,
1997
2312
  "MediaBox",
1998
- cosArray3([cosNumber3(0), cosNumber3(0), cosNumber3(w), cosNumber3(h)])
2313
+ cosArray4([cosNumber4(0), cosNumber4(0), cosNumber4(w), cosNumber4(h)])
1999
2314
  );
2000
2315
  }
2001
2316
  }
2002
2317
  for (const [pageNum, [x0, y0, x1, y1]] of pageMediaRects.entries()) {
2003
2318
  if (pageNum >= 1 && pageNum <= doc.pageCount) {
2004
- dictSet2(
2319
+ dictSet3(
2005
2320
  doc.getPage(pageNum - 1).pageDict,
2006
2321
  "MediaBox",
2007
- cosArray3([cosNumber3(x0), cosNumber3(y0), cosNumber3(x1), cosNumber3(y1)])
2322
+ cosArray4([cosNumber4(x0), cosNumber4(y0), cosNumber4(x1), cosNumber4(y1)])
2008
2323
  );
2009
2324
  }
2010
2325
  }
2011
2326
  for (const [pageNum, [x0, y0, x1, y1]] of pageCropBoxes.entries()) {
2012
2327
  if (pageNum >= 1 && pageNum <= doc.pageCount) {
2013
- dictSet2(
2328
+ dictSet3(
2014
2329
  doc.getPage(pageNum - 1).pageDict,
2015
2330
  "CropBox",
2016
- cosArray3([cosNumber3(x0), cosNumber3(y0), cosNumber3(x1), cosNumber3(y1)])
2331
+ cosArray4([cosNumber4(x0), cosNumber4(y0), cosNumber4(x1), cosNumber4(y1)])
2017
2332
  );
2018
2333
  }
2019
2334
  }
@@ -2022,21 +2337,21 @@ function applyUpdateInfoText(doc, text) {
2022
2337
  if (catalog) {
2023
2338
  const numsItems = [];
2024
2339
  for (const pl of pageLabels) {
2025
- numsItems.push(cosNumber3(Math.max(0, pl.newIndex - 1)));
2340
+ numsItems.push(cosNumber4(Math.max(0, pl.newIndex - 1)));
2026
2341
  const lblEntries = {
2027
- St: cosNumber3(pl.start)
2342
+ St: cosNumber4(pl.start)
2028
2343
  };
2029
2344
  if (pl.prefix) {
2030
- lblEntries.P = cosString3(pl.prefix);
2345
+ lblEntries.P = cosString4(pl.prefix);
2031
2346
  }
2032
2347
  const pdfStyle = PAGE_LABEL_STYLE_TO_PDF[pl.style];
2033
2348
  if (pdfStyle) {
2034
2349
  lblEntries.S = cosName(pdfStyle);
2035
2350
  }
2036
- numsItems.push(cosDict3(lblEntries));
2351
+ numsItems.push(cosDict4(lblEntries));
2037
2352
  }
2038
- const plDict = cosDict3({ Nums: cosArray3(numsItems) });
2039
- dictSet2(catalog, "PageLabels", doc.cos.allocateObject(plDict));
2353
+ const plDict = cosDict4({ Nums: cosArray4(numsItems) });
2354
+ dictSet3(catalog, "PageLabels", doc.cos.allocateObject(plDict));
2040
2355
  }
2041
2356
  }
2042
2357
  setDocumentBookmarks(doc, bookmarks);
@@ -2044,20 +2359,20 @@ function applyUpdateInfoText(doc, text) {
2044
2359
  function attachFilesToDocument(doc, filePaths, files, toPageSpec) {
2045
2360
  const catalog = doc.cos.resolveDict(doc.cos.rootRef);
2046
2361
  if (!catalog) return;
2047
- let namesDict = doc.cos.resolveDict(dictGet5(catalog, "Names"));
2362
+ let namesDict = doc.cos.resolveDict(dictGet6(catalog, "Names"));
2048
2363
  if (!namesDict) {
2049
- namesDict = cosDict3({});
2050
- dictSet2(catalog, "Names", doc.cos.allocateObject(namesDict));
2364
+ namesDict = cosDict4({});
2365
+ dictSet3(catalog, "Names", doc.cos.allocateObject(namesDict));
2051
2366
  }
2052
- let efTree = doc.cos.resolveDict(dictGet5(namesDict, "EmbeddedFiles"));
2367
+ let efTree = doc.cos.resolveDict(dictGet6(namesDict, "EmbeddedFiles"));
2053
2368
  if (!efTree) {
2054
- efTree = cosDict3({ Names: cosArray3([]) });
2055
- dictSet2(namesDict, "EmbeddedFiles", doc.cos.allocateObject(efTree));
2369
+ efTree = cosDict4({ Names: cosArray4([]) });
2370
+ dictSet3(namesDict, "EmbeddedFiles", doc.cos.allocateObject(efTree));
2056
2371
  }
2057
- let namesArr = doc.cos.resolveArray(dictGet5(efTree, "Names"));
2372
+ let namesArr = doc.cos.resolveArray(dictGet6(efTree, "Names"));
2058
2373
  if (!namesArr) {
2059
- namesArr = cosArray3([]);
2060
- dictSet2(efTree, "Names", namesArr);
2374
+ namesArr = cosArray4([]);
2375
+ dictSet3(efTree, "Names", namesArr);
2061
2376
  }
2062
2377
  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
2378
  for (const fp of filePaths) {
@@ -2066,34 +2381,34 @@ function attachFilesToDocument(doc, filePaths, files, toPageSpec) {
2066
2381
  const baseName = fp.slice(fp.lastIndexOf("/") + 1);
2067
2382
  const efStreamRef = doc.cos.allocateObject(
2068
2383
  cosStream(bytes, {
2069
- dict: cosDict3({ Type: cosName("EmbeddedFile") }),
2384
+ dict: cosDict4({ Type: cosName("EmbeddedFile") }),
2070
2385
  compress: true
2071
2386
  })
2072
2387
  );
2073
2388
  const filespecRef = doc.cos.allocateObject(
2074
- cosDict3({
2389
+ cosDict4({
2075
2390
  Type: cosName("Filespec"),
2076
- F: cosString3(baseName),
2077
- UF: cosString3(baseName),
2078
- EF: cosDict3({ F: efStreamRef })
2391
+ F: cosString4(baseName),
2392
+ UF: cosString4(baseName),
2393
+ EF: cosDict4({ F: efStreamRef })
2079
2394
  })
2080
2395
  );
2081
- namesArr.items.push(cosString3(baseName), filespecRef);
2396
+ namesArr.items.push(cosString4(baseName), filespecRef);
2082
2397
  if (targetPageIdx !== void 0) {
2083
2398
  const pageDict = doc.getPage(targetPageIdx).pageDict;
2084
- let annotsArr = doc.cos.resolveArray(dictGet5(pageDict, "Annots"));
2399
+ let annotsArr = doc.cos.resolveArray(dictGet6(pageDict, "Annots"));
2085
2400
  if (!annotsArr) {
2086
- annotsArr = cosArray3([]);
2087
- dictSet2(pageDict, "Annots", annotsArr);
2401
+ annotsArr = cosArray4([]);
2402
+ dictSet3(pageDict, "Annots", annotsArr);
2088
2403
  }
2089
2404
  const annotRef = doc.cos.allocateObject(
2090
- cosDict3({
2405
+ cosDict4({
2091
2406
  Type: cosName("Annot"),
2092
2407
  Subtype: cosName("FileAttachment"),
2093
2408
  Name: cosName("PushPin"),
2094
- Contents: cosString3(baseName),
2409
+ Contents: cosString4(baseName),
2095
2410
  FS: filespecRef,
2096
- Rect: cosArray3([cosNumber3(20), cosNumber3(20), cosNumber3(40), cosNumber3(40)])
2411
+ Rect: cosArray4([cosNumber4(20), cosNumber4(20), cosNumber4(40), cosNumber4(40)])
2097
2412
  })
2098
2413
  );
2099
2414
  annotsArr.items.push(annotRef);
@@ -2110,11 +2425,11 @@ function attachmentBasename(name) {
2110
2425
  function unpackFilesFromDocument(doc, outDir, files) {
2111
2426
  const cleanDir = outDir.endsWith("/") ? outDir.slice(0, -1) : outDir;
2112
2427
  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"));
2428
+ const ufNode = doc.cos.resolve(dictGet6(specDict, "UF") ?? dictGet6(specDict, "F"));
2429
+ const fileName = attachmentBasename(ufNode?.kind === "string" ? decodePdfString5(ufNode) : fallbackName);
2430
+ const efDict = doc.cos.resolveDict(dictGet6(specDict, "EF"));
2116
2431
  const fStream = efDict ? doc.cos.resolve(
2117
- dictGet5(efDict, "UF") ?? dictGet5(efDict, "F") ?? dictGet5(efDict, "DOS") ?? dictGet5(efDict, "Mac") ?? dictGet5(efDict, "Unix")
2432
+ dictGet6(efDict, "UF") ?? dictGet6(efDict, "F") ?? dictGet6(efDict, "DOS") ?? dictGet6(efDict, "Mac") ?? dictGet6(efDict, "Unix")
2118
2433
  ) : void 0;
2119
2434
  if (fStream?.kind === "stream") {
2120
2435
  const decoded = doc.cos.decodeStream(fStream);
@@ -2124,10 +2439,10 @@ function unpackFilesFromDocument(doc, outDir, files) {
2124
2439
  };
2125
2440
  const catalog = doc.cos.resolveDict(doc.cos.rootRef);
2126
2441
  if (catalog) {
2127
- const namesDict = doc.cos.resolveDict(dictGet5(catalog, "Names"));
2442
+ const namesDict = doc.cos.resolveDict(dictGet6(catalog, "Names"));
2128
2443
  const efPairs = [];
2129
2444
  if (namesDict) {
2130
- collectNameTreePairs(doc, dictGet5(namesDict, "EmbeddedFiles"), efPairs);
2445
+ collectNameTreePairs(doc, dictGet6(namesDict, "EmbeddedFiles"), efPairs);
2131
2446
  }
2132
2447
  for (const pair of efPairs) {
2133
2448
  const specDict = doc.cos.resolveDict(pair.value);
@@ -2135,7 +2450,7 @@ function unpackFilesFromDocument(doc, outDir, files) {
2135
2450
  writeSpecDict(specDict, pair.name);
2136
2451
  }
2137
2452
  }
2138
- const rootAfArr = doc.cos.resolveArray(dictGet5(catalog, "AF"));
2453
+ const rootAfArr = doc.cos.resolveArray(dictGet6(catalog, "AF"));
2139
2454
  if (rootAfArr) {
2140
2455
  for (const item of rootAfArr.items) {
2141
2456
  const specDict = doc.cos.resolveDict(item);
@@ -2144,21 +2459,21 @@ function unpackFilesFromDocument(doc, outDir, files) {
2144
2459
  }
2145
2460
  }
2146
2461
  for (let p = 0; p < doc.pageCount; p++) {
2147
- const pageAfArr = doc.cos.resolveArray(dictGet5(doc.getPage(p).pageDict, "AF"));
2462
+ const pageAfArr = doc.cos.resolveArray(dictGet6(doc.getPage(p).pageDict, "AF"));
2148
2463
  if (pageAfArr) {
2149
2464
  for (const item of pageAfArr.items) {
2150
2465
  const specDict = doc.cos.resolveDict(item);
2151
2466
  if (specDict) writeSpecDict(specDict);
2152
2467
  }
2153
2468
  }
2154
- const annotsArr = doc.cos.resolveArray(dictGet5(doc.getPage(p).pageDict, "Annots"));
2469
+ const annotsArr = doc.cos.resolveArray(dictGet6(doc.getPage(p).pageDict, "Annots"));
2155
2470
  if (!annotsArr) continue;
2156
2471
  for (const item of annotsArr.items) {
2157
2472
  const annotDict = doc.cos.resolveDict(item);
2158
2473
  if (!annotDict) continue;
2159
- const subNode = doc.cos.resolve(dictGet5(annotDict, "Subtype"));
2474
+ const subNode = doc.cos.resolve(dictGet6(annotDict, "Subtype"));
2160
2475
  if (subNode?.kind === "name" && subNode.decoded === "FileAttachment") {
2161
- const specDict = doc.cos.resolveDict(dictGet5(annotDict, "FS"));
2476
+ const specDict = doc.cos.resolveDict(dictGet6(annotDict, "FS"));
2162
2477
  if (specDict) writeSpecDict(specDict);
2163
2478
  }
2164
2479
  }
@@ -2169,7 +2484,7 @@ function cloneCosSubgraphInto(srcDoc, dstDoc, node, memo = /* @__PURE__ */ new M
2169
2484
  if (node.kind === "ref") {
2170
2485
  const cached = memo.get(node.objectNumber);
2171
2486
  if (cached) return cached;
2172
- const placeholder = dstDoc.cos.allocateObject(cosDict3({}));
2487
+ const placeholder = dstDoc.cos.allocateObject(cosDict4({}));
2173
2488
  memo.set(node.objectNumber, placeholder);
2174
2489
  const resolved = srcDoc.cos.resolve(node);
2175
2490
  const cloned = cloneCosSubgraphInto(srcDoc, dstDoc, resolved, memo);
@@ -2183,14 +2498,14 @@ function cloneCosSubgraphInto(srcDoc, dstDoc, node, memo = /* @__PURE__ */ new M
2183
2498
  return placeholder;
2184
2499
  }
2185
2500
  if (node.kind === "array") {
2186
- return cosArray3(node.items.map((it) => cloneCosSubgraphInto(srcDoc, dstDoc, it, memo)).filter(Boolean));
2501
+ return cosArray4(node.items.map((it) => cloneCosSubgraphInto(srcDoc, dstDoc, it, memo)).filter(Boolean));
2187
2502
  }
2188
2503
  if (node.kind === "dict") {
2189
- const next = cosDict3({});
2504
+ const next = cosDict4({});
2190
2505
  for (const entry of node.entries) {
2191
2506
  if (entry.key.decoded === "Parent") continue;
2192
2507
  const clonedVal = cloneCosSubgraphInto(srcDoc, dstDoc, entry.value, memo);
2193
- if (clonedVal) dictSet2(next, entry.key.decoded, clonedVal);
2508
+ if (clonedVal) dictSet3(next, entry.key.decoded, clonedVal);
2194
2509
  }
2195
2510
  return next;
2196
2511
  }
@@ -2255,31 +2570,31 @@ function applyOverlayToDocument(targetDoc, overlayDoc, mode, multi) {
2255
2570
  const srcRes = srcPage.getResourcesDict();
2256
2571
  const renamedResources = /* @__PURE__ */ new Map();
2257
2572
  for (const subKey of ["Font", "XObject", "ExtGState", "ColorSpace", "Pattern", "Shading", "Properties"]) {
2258
- const srcSub = overlayDoc.cos.resolveDict(dictGet5(srcRes, subKey));
2573
+ const srcSub = overlayDoc.cos.resolveDict(dictGet6(srcRes, subKey));
2259
2574
  if (!srcSub) continue;
2260
- let dstSub = targetDoc.cos.resolveDict(dictGet5(dstRes, subKey));
2575
+ let dstSub = targetDoc.cos.resolveDict(dictGet6(dstRes, subKey));
2261
2576
  if (!dstSub) {
2262
- dstSub = cosDict3({});
2263
- dictSet2(dstRes, subKey, dstSub);
2577
+ dstSub = cosDict4({});
2578
+ dictSet3(dstRes, subKey, dstSub);
2264
2579
  }
2265
2580
  for (const entry of srcSub.entries) {
2266
2581
  const origKey = entry.key.decoded;
2267
2582
  const cloned = cloneCosSubgraphInto(overlayDoc, targetDoc, entry.value, memo);
2268
2583
  if (!cloned) continue;
2269
- if (!dictGet5(dstSub, origKey)) {
2270
- dictSet2(dstSub, origKey, cloned);
2584
+ if (!dictGet6(dstSub, origKey)) {
2585
+ dictSet3(dstSub, origKey, cloned);
2271
2586
  } else {
2272
2587
  let newKey = `Ov_${i}_${origKey}`;
2273
2588
  let suffix = 1;
2274
- while (dictGet5(dstSub, newKey)) {
2589
+ while (dictGet6(dstSub, newKey)) {
2275
2590
  newKey = `Ov_${i}_${suffix++}_${origKey}`;
2276
2591
  }
2277
- dictSet2(dstSub, newKey, cloned);
2592
+ dictSet3(dstSub, newKey, cloned);
2278
2593
  renamedResources.set(origKey, newKey);
2279
2594
  }
2280
2595
  }
2281
2596
  }
2282
- const srcContents = dictGet5(srcPage.pageDict, "Contents");
2597
+ const srcContents = dictGet6(srcPage.pageDict, "Contents");
2283
2598
  if (!srcContents) continue;
2284
2599
  const rawSrcNodes = [];
2285
2600
  const resolvedSrcContents = overlayDoc.cos.resolve(srcContents);
@@ -2305,7 +2620,7 @@ function applyOverlayToDocument(targetDoc, overlayDoc, mode, multi) {
2305
2620
  }
2306
2621
  }
2307
2622
  if (srcList.length === 0) continue;
2308
- const dstContents = dictGet5(dstPage.pageDict, "Contents");
2623
+ const dstContents = dictGet6(dstPage.pageDict, "Contents");
2309
2624
  const toStreamList = (c) => {
2310
2625
  if (!c) return [];
2311
2626
  const r = targetDoc.cos.resolve(c);
@@ -2354,7 +2669,7 @@ ${fmt6(s)} 0 0 ${fmt6(s)} ${fmt4(tx)} ${fmt4(ty)} cm
2354
2669
  const qOpenSrc = targetDoc.cos.allocateObject(cosStream(new TextEncoder().encode(srcOpenCmd), { compress: false }));
2355
2670
  const qClose = targetDoc.cos.allocateObject(cosStream(new TextEncoder().encode("\nQ\n"), { compress: false }));
2356
2671
  const combined = mode === "background" ? [qOpenSrc, ...srcList, qClose, qOpenDst, ...dstList, qClose] : [qOpenDst, ...dstList, qClose, qOpenSrc, ...srcList, qClose];
2357
- dictSet2(dstPage.pageDict, "Contents", cosArray3(combined));
2672
+ dictSet3(dstPage.pageDict, "Contents", cosArray4(combined));
2358
2673
  }
2359
2674
  }
2360
2675
  function normalizeQuarterTurn(degrees) {
@@ -2538,9 +2853,9 @@ function* runPdftkCliSteps(argv, files, signal) {
2538
2853
  if (!cached) {
2539
2854
  cached = [];
2540
2855
  const cat = d.cos.resolveDict(d.cos.rootRef);
2541
- const outDict = cat ? d.cos.resolveDict(dictGet5(cat, "Outlines")) : void 0;
2856
+ const outDict = cat ? d.cos.resolveDict(dictGet6(cat, "Outlines")) : void 0;
2542
2857
  if (outDict) {
2543
- collectOutlineBookmarks(d, dictGet5(outDict, "First"), 1, cached);
2858
+ collectOutlineBookmarks(d, dictGet6(outDict, "First"), 1, cached);
2544
2859
  }
2545
2860
  bookmarksByDoc.set(d, cached);
2546
2861
  }
@@ -2630,7 +2945,7 @@ function* runPdftkCliSteps(argv, files, signal) {
2630
2945
  }
2631
2946
  if (dropXfa) {
2632
2947
  const root = resultDoc.cos.resolveDict(resultDoc.cos.rootRef);
2633
- const acroForm = root ? resultDoc.cos.resolveDict(dictGet5(root, "AcroForm")) : void 0;
2948
+ const acroForm = root ? resultDoc.cos.resolveDict(dictGet6(root, "AcroForm")) : void 0;
2634
2949
  if (acroForm)
2635
2950
  dictDelete2(acroForm, "XFA");
2636
2951
  }
@@ -2645,28 +2960,28 @@ function* runPdftkCliSteps(argv, files, signal) {
2645
2960
  if (++cooperativeWork % 64 === 0)
2646
2961
  yield;
2647
2962
  if (obj.value.kind === "dict") {
2648
- const stNode = dictGet5(obj.value, "Subtype");
2649
- const bfNode = dictGet5(obj.value, "BaseFont");
2963
+ const stNode = dictGet6(obj.value, "Subtype");
2964
+ const bfNode = dictGet6(obj.value, "BaseFont");
2650
2965
  const subtype = stNode?.kind === "name" ? stNode.decoded : void 0;
2651
2966
  const baseFont = bfNode?.kind === "name" ? bfNode.decoded : void 0;
2652
2967
  if (subtype === "Type1" && baseFont === "Helvetica") {
2653
- dictSet2(obj.value, "BaseFont", cosName(cleanFontName));
2968
+ dictSet3(obj.value, "BaseFont", cosName(cleanFontName));
2654
2969
  }
2655
2970
  }
2656
2971
  }
2657
2972
  }
2658
2973
  if (operation === "fill_form" && !shouldFlatten) {
2659
2974
  const root = resultDoc.cos.resolveDict(resultDoc.cos.rootRef);
2660
- const acroForm = root ? resultDoc.cos.resolveDict(dictGet5(root, "AcroForm")) : void 0;
2975
+ const acroForm = root ? resultDoc.cos.resolveDict(dictGet6(root, "AcroForm")) : void 0;
2661
2976
  if (acroForm) {
2662
- dictSet2(acroForm, "NeedAppearances", { kind: "boolean", value: needAppearances });
2977
+ dictSet3(acroForm, "NeedAppearances", { kind: "boolean", value: needAppearances });
2663
2978
  }
2664
2979
  } else if (needAppearances && !shouldFlatten) {
2665
2980
  const root = resultDoc.cos.resolveDict(resultDoc.cos.rootRef);
2666
2981
  if (root) {
2667
- const acroForm = resultDoc.cos.resolveDict(dictGet5(root, "AcroForm"));
2982
+ const acroForm = resultDoc.cos.resolveDict(dictGet6(root, "AcroForm"));
2668
2983
  if (acroForm) {
2669
- dictSet2(acroForm, "NeedAppearances", { kind: "boolean", value: true });
2984
+ dictSet3(acroForm, "NeedAppearances", { kind: "boolean", value: true });
2670
2985
  }
2671
2986
  }
2672
2987
  }
@@ -2674,12 +2989,12 @@ function* runPdftkCliSteps(argv, files, signal) {
2674
2989
  if (keepFinalId) {
2675
2990
  const lastInput = handleDocs[handleDocs.length - 1];
2676
2991
  if (lastInput?.cos.idArray) {
2677
- resultDoc.cos.idArray = cosArray3([...lastInput.cos.idArray.items]);
2992
+ resultDoc.cos.idArray = cosArray4([...lastInput.cos.idArray.items]);
2678
2993
  }
2679
2994
  } else if (keepFirstId || !resultDoc.cos.idArray) {
2680
2995
  const firstInput = handleDocs[0];
2681
2996
  if (firstInput?.cos.idArray) {
2682
- resultDoc.cos.idArray = cosArray3([...firstInput.cos.idArray.items]);
2997
+ resultDoc.cos.idArray = cosArray4([...firstInput.cos.idArray.items]);
2683
2998
  }
2684
2999
  }
2685
3000
  if (uncompressStreams || compressStreams) {
@@ -2746,7 +3061,7 @@ async function executePdftk(context, retainedContext = context) {
2746
3061
  const carrier = getCommandArguments(context);
2747
3062
  const argv = [...carrier.args];
2748
3063
  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))) {
3064
+ if (parsed.options && (["output", "rotate", "attach_files", "stamp", "multistamp", "background", "multibackground", "burst", "update_info", "update_info_utf8", "cat", "shuffle"].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
3065
  return await executeRetainedPdftk({ ...retainedContext, signal: invocation.signal, stdout: invocation.child(context.stdout).output }, parsed.options);
2751
3066
  }
2752
3067
  const vfsFiles = /* @__PURE__ */ new Map();