@poe-platform/safe-bash 0.1.815 → 0.1.816

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 (585) hide show
  1. package/dist/image-ast/index.js +1 -1
  2. package/dist/mp4-ast/codecs.d.ts +3 -0
  3. package/dist/mp4-ast/esds-source.d.ts +7 -0
  4. package/dist/mp4-ast/index.d.ts +5 -1
  5. package/dist/mp4-ast/mp4-codec-metadata.d.ts +48 -0
  6. package/dist/mp4-ast/mp4-codec-source.d.ts +8 -0
  7. package/dist/mp4-ast/mp4-packets-source.d.ts +11 -0
  8. package/dist/pdf-ast/ast.d.ts +6 -0
  9. package/dist/pdf-ast/content/evaluator.d.ts +4 -1
  10. package/dist/pdf-ast/content/stored-dictionary.d.ts +15 -1
  11. package/dist/pdf-ast/content/stored-record.d.ts +6 -0
  12. package/dist/pdf-ast/cos/retained-writer.d.ts +1 -0
  13. package/dist/pdf-ast/cos/value-parser.d.ts +5 -0
  14. package/dist/pdf-ast/edit/retained-graph.d.ts +1 -0
  15. package/dist/pdf-ast/edit/retained-page-copy.d.ts +10 -0
  16. package/dist/pdf-ast/extract/images.d.ts +2 -1
  17. package/dist/pdf-ast/fonts/resolve.d.ts +1 -0
  18. package/dist/pdf-ast/index.d.ts +2 -0
  19. package/dist/pdf-ast/index.js +1091 -322
  20. package/dist/pdf-ast/render/raster.d.ts +14 -0
  21. package/dist/pdf-ast/render/svg-image-stream.d.ts +6 -0
  22. package/dist/pdf-ast/render/svg-path-stream.d.ts +15 -0
  23. package/dist/pdf-ast/retained-document.d.ts +1 -1
  24. package/dist/safe-bash/chunks/{chunk-I6ECNJMR.js → chunk-AXGI5JVL.js} +1 -1
  25. package/dist/safe-bash/chunks/{chunk-TPG55BAQ.js → chunk-FQRI5AS5.js} +1 -1
  26. package/dist/safe-bash/chunks/{chunk-TWWGAW4M.js → chunk-HD6DWOAC.js} +1 -1
  27. package/dist/safe-bash/chunks/{chunk-5JCZEXEM.js → chunk-SXSEF5E2.js} +12 -7
  28. package/dist/safe-bash/command-chunks/biff-UBP2BZLK-JPODPKS3.js +5448 -0
  29. package/dist/safe-bash/command-chunks/{chunk-S7HIOT7Z.js → chunk-26JE5JEB.js} +4 -4
  30. package/dist/safe-bash/command-chunks/{chunk-AG2SNMP5.js → chunk-2ALHVXEM.js} +2 -2
  31. package/dist/safe-bash/command-chunks/{chunk-4YLACJHE.js → chunk-2IMIKROX.js} +6 -6
  32. package/dist/safe-bash/command-chunks/{chunk-MYZ46FQL.js → chunk-2QZUAZTH.js} +1 -1
  33. package/dist/safe-bash/command-chunks/{chunk-YAD7EV4N.js → chunk-2TWXRJPB.js} +11 -11
  34. package/dist/safe-bash/command-chunks/{chunk-NYFYTL5G.js → chunk-345YBIHP.js} +27 -27
  35. package/dist/safe-bash/command-chunks/{chunk-3MG5EAMX.js → chunk-35DU6I2M.js} +5 -5
  36. package/dist/safe-bash/command-chunks/{chunk-FSVJ67G5.js → chunk-3DWFXESW.js} +2 -2
  37. package/dist/safe-bash/command-chunks/{chunk-TKCUGMRZ.js → chunk-3K5CVXUV.js} +18 -18
  38. package/dist/safe-bash/command-chunks/{chunk-6LPSKLLD.js → chunk-3MUFXGA2.js} +3 -3
  39. package/dist/safe-bash/command-chunks/{chunk-44F5TOHZ.js → chunk-3PM46VWH.js} +15 -15
  40. package/dist/safe-bash/command-chunks/{chunk-6QYSF7I2.js → chunk-3ZWFE4CK.js} +7 -7
  41. package/dist/safe-bash/command-chunks/{chunk-NEYITAAO.js → chunk-45DKGZYO.js} +744 -328
  42. package/dist/safe-bash/command-chunks/{chunk-U3C6IT2C.js → chunk-4772DJKS.js} +14 -10
  43. package/dist/safe-bash/command-chunks/{chunk-FOONI6BD.js → chunk-4ABR3KGK.js} +7 -7
  44. package/dist/safe-bash/command-chunks/{chunk-7KZ5LWV2.js → chunk-4IDV763L.js} +1 -1
  45. package/dist/safe-bash/command-chunks/{chunk-FGGHYUWR.js → chunk-4QEJPP3K.js} +102 -7
  46. package/dist/safe-bash/command-chunks/{chunk-RV5AGXOV.js → chunk-4X2MPZXW.js} +2 -2
  47. package/dist/safe-bash/command-chunks/{chunk-LNTEV56A.js → chunk-4YFTJS5U.js} +2 -2
  48. package/dist/safe-bash/command-chunks/{chunk-6XES7Z4G.js → chunk-57PK2QFX.js} +12 -12
  49. package/dist/safe-bash/command-chunks/{chunk-42MEXZBJ.js → chunk-5GDF5FAS.js} +1 -1
  50. package/dist/safe-bash/command-chunks/{chunk-BS3ZEQGT.js → chunk-5KZMR6AJ.js} +18 -16
  51. package/dist/safe-bash/command-chunks/{chunk-ZU2KJMXO.js → chunk-5MNQTHED.js} +10 -10
  52. package/dist/safe-bash/command-chunks/{chunk-W25EIKDJ.js → chunk-5NC2IQMQ.js} +1 -1
  53. package/dist/safe-bash/command-chunks/{chunk-KY4LCHUF.js → chunk-5O45KGW5.js} +1 -1
  54. package/dist/safe-bash/command-chunks/{chunk-GYM5ICK4.js → chunk-5V7WIQ2D.js} +7 -7
  55. package/dist/safe-bash/command-chunks/{chunk-GPGLTWNR.js → chunk-5XUWGUGN.js} +16 -11
  56. package/dist/safe-bash/command-chunks/{chunk-SUTHGUD3.js → chunk-5YL453ZF.js} +34 -34
  57. package/dist/safe-bash/command-chunks/{chunk-IHXZMAMY.js → chunk-62RG3GHF.js} +6 -6
  58. package/dist/safe-bash/command-chunks/{chunk-P2LT6TGR.js → chunk-6EZWG56T.js} +9 -9
  59. package/dist/safe-bash/command-chunks/{chunk-CCMAHM3I.js → chunk-6JGICYHP.js} +2 -2
  60. package/dist/safe-bash/command-chunks/{chunk-AWPI4DZR.js → chunk-6KJDTKE4.js} +3 -3
  61. package/dist/safe-bash/command-chunks/{chunk-FUQMEUAT.js → chunk-6M3JTPKE.js} +8 -8
  62. package/dist/safe-bash/command-chunks/{chunk-H33D4R26.js → chunk-6RLWPB44.js} +4 -4
  63. package/dist/safe-bash/command-chunks/{chunk-3GRMU7TM.js → chunk-6W4RMBFH.js} +6 -6
  64. package/dist/safe-bash/command-chunks/{chunk-RIVKF77R.js → chunk-6YF2QADH.js} +6 -6
  65. package/dist/safe-bash/command-chunks/{chunk-LEO4VRIN.js → chunk-77ROD2TR.js} +5 -5
  66. package/dist/safe-bash/command-chunks/{chunk-XNGM3W5R.js → chunk-7B2MHKIW.js} +1 -1
  67. package/dist/safe-bash/command-chunks/{chunk-RFMHNTTF.js → chunk-7OCTMVYJ.js} +1 -1
  68. package/dist/safe-bash/command-chunks/{chunk-DBLQUZGN.js → chunk-7PYDVQPB.js} +2 -2
  69. package/dist/safe-bash/command-chunks/{chunk-AM5LANIE.js → chunk-A2L3U7DW.js} +7 -7
  70. package/dist/safe-bash/command-chunks/{chunk-UYGQEQIP.js → chunk-A4P37F3P.js} +5 -5
  71. package/dist/safe-bash/command-chunks/{chunk-ADHFF2IM.js → chunk-A5SPMSKD.js} +9 -9
  72. package/dist/safe-bash/command-chunks/{chunk-ENEIE44W.js → chunk-A6OTPNNI.js} +3 -3
  73. package/dist/safe-bash/command-chunks/chunk-AF2IO57Q.js +733 -0
  74. package/dist/safe-bash/command-chunks/{chunk-AFPXADZG.js → chunk-AHD3CGAY.js} +4 -4
  75. package/dist/safe-bash/command-chunks/{chunk-YW2VYN4V.js → chunk-ALD53QFL.js} +74 -27
  76. package/dist/safe-bash/command-chunks/{chunk-4B2ZUGLT.js → chunk-ARE267HR.js} +5 -5
  77. package/dist/safe-bash/command-chunks/{chunk-OTF2AJ5M.js → chunk-AYQPJQJR.js} +6 -6
  78. package/dist/safe-bash/command-chunks/{chunk-2VVJRVYM.js → chunk-B6XTAKKQ.js} +1 -1
  79. package/dist/safe-bash/command-chunks/{chunk-GCHB7VNX.js → chunk-BIJW6QWB.js} +17 -17
  80. package/dist/safe-bash/command-chunks/{chunk-OVEPYULA.js → chunk-BKK4MS3V.js} +1 -1
  81. package/dist/safe-bash/command-chunks/{chunk-3EB2FSAN.js → chunk-BOVDUJ3A.js} +7 -7
  82. package/dist/safe-bash/command-chunks/{chunk-SEPUP6TZ.js → chunk-BSTABZIK.js} +1 -1
  83. package/dist/safe-bash/command-chunks/{chunk-ATHHWPSE.js → chunk-BZRWZ6GO.js} +1 -1
  84. package/dist/safe-bash/command-chunks/{chunk-BZMNC7Q5.js → chunk-CGJ7GMHO.js} +7 -7
  85. package/dist/safe-bash/command-chunks/{chunk-RGDOYWOD.js → chunk-CHZE6FNT.js} +2 -2
  86. package/dist/safe-bash/command-chunks/{chunk-V7E3PZOK.js → chunk-CKA7ZROU.js} +7 -7
  87. package/dist/safe-bash/command-chunks/{chunk-MEM2ZPMI.js → chunk-CKIXC7AO.js} +3 -3
  88. package/dist/safe-bash/command-chunks/{chunk-Y54L4P4J.js → chunk-CORUUCS2.js} +5 -5
  89. package/dist/safe-bash/command-chunks/{chunk-QDVDBN2N.js → chunk-DBZCTL7C.js} +150 -35
  90. package/dist/safe-bash/command-chunks/{chunk-6ZGCKUAM.js → chunk-DIRK47GT.js} +1 -1
  91. package/dist/safe-bash/command-chunks/{chunk-WYZG3DRR.js → chunk-DM5WURQL.js} +2 -2
  92. package/dist/safe-bash/command-chunks/{chunk-EBHOZIBS.js → chunk-DOVWHVHI.js} +6 -6
  93. package/dist/safe-bash/command-chunks/{chunk-ZIGENXGC.js → chunk-DXOXUKQB.js} +8 -8
  94. package/dist/safe-bash/command-chunks/{chunk-JR3Q6QNL.js → chunk-DZOKH5BL.js} +7 -7
  95. package/dist/safe-bash/command-chunks/{chunk-6EINUY5G.js → chunk-E22EAYJN.js} +54 -12
  96. package/dist/safe-bash/command-chunks/{chunk-3EASXF5D.js → chunk-E4TF5W6O.js} +2 -2
  97. package/dist/safe-bash/command-chunks/{chunk-MLOYUXUV.js → chunk-EJ4UP7DA.js} +31 -9
  98. package/dist/safe-bash/command-chunks/{chunk-USGZN2KE.js → chunk-ENMJHB2C.js} +5 -5
  99. package/dist/safe-bash/command-chunks/{chunk-ZSQZHFWS.js → chunk-ERWIJYCS.js} +7 -7
  100. package/dist/safe-bash/command-chunks/{chunk-S2QNBAN6.js → chunk-ET6LMDEX.js} +12 -12
  101. package/dist/safe-bash/command-chunks/{chunk-6XGDWFNQ.js → chunk-EWC56JNI.js} +5 -5
  102. package/dist/safe-bash/command-chunks/{chunk-EQWFKNHJ.js → chunk-EZDWPTYB.js} +19 -19
  103. package/dist/safe-bash/command-chunks/{chunk-CQBACD2V.js → chunk-F2NF6FHV.js} +2 -2
  104. package/dist/safe-bash/command-chunks/{chunk-NFII726L.js → chunk-FAU2KL6I.js} +2 -2
  105. package/dist/safe-bash/command-chunks/{chunk-4EHY6J2Z.js → chunk-FB2WPI3M.js} +5 -5
  106. package/dist/safe-bash/command-chunks/{chunk-2PKBXGXD.js → chunk-FEBTT5NH.js} +5 -5
  107. package/dist/safe-bash/command-chunks/chunk-FGARVKAX.js +704 -0
  108. package/dist/safe-bash/command-chunks/{chunk-N4MUBJCT.js → chunk-FGHSE3RZ.js} +1 -1
  109. package/dist/safe-bash/command-chunks/{chunk-WBKB7HBZ.js → chunk-FHQOFEQK.js} +8 -8
  110. package/dist/safe-bash/command-chunks/{chunk-3ZRCL756.js → chunk-FJLSYX5P.js} +7 -7
  111. package/dist/safe-bash/command-chunks/{chunk-PMWW7KSB.js → chunk-FJSD43VF.js} +1 -1
  112. package/dist/safe-bash/command-chunks/{chunk-XKAUKLF7.js → chunk-FLSXHLJG.js} +9 -9
  113. package/dist/safe-bash/command-chunks/{chunk-3EW7GYHM.js → chunk-FR63MJSO.js} +7 -7
  114. package/dist/safe-bash/command-chunks/{chunk-NRFTYZ2R.js → chunk-FUYZUETI.js} +6 -6
  115. package/dist/safe-bash/command-chunks/{chunk-JUHOL5KB.js → chunk-G3FK5VVG.js} +1 -1
  116. package/dist/safe-bash/command-chunks/{chunk-4UPKVQWH.js → chunk-G3LUT475.js} +6 -6
  117. package/dist/safe-bash/command-chunks/{chunk-Q7UZTMF4.js → chunk-GAROGIVU.js} +1 -1
  118. package/dist/safe-bash/command-chunks/{chunk-4RRYWHED.js → chunk-GMBUOYTN.js} +4 -4
  119. package/dist/safe-bash/command-chunks/{chunk-FYYFV6PW.js → chunk-GR4ONCQ5.js} +6 -6
  120. package/dist/safe-bash/command-chunks/{chunk-XTEIT5CI.js → chunk-GTOMW4VV.js} +1 -1
  121. package/dist/safe-bash/command-chunks/{chunk-OVQP6KH5.js → chunk-H56BSMFQ.js} +6 -6
  122. package/dist/safe-bash/command-chunks/{chunk-RQYPFLZJ.js → chunk-HOJ7WDTS.js} +6 -6
  123. package/dist/safe-bash/command-chunks/{chunk-BLIFGBIO.js → chunk-HOKPYTHQ.js} +2 -2
  124. package/dist/safe-bash/command-chunks/chunk-HQEYSSZV.js +152 -0
  125. package/dist/safe-bash/command-chunks/{chunk-NEMUPUUB.js → chunk-ICJH6A73.js} +7 -7
  126. package/dist/safe-bash/command-chunks/{chunk-CSE4VQKG.js → chunk-IJE65P52.js} +3 -3
  127. package/dist/safe-bash/command-chunks/{chunk-MKOIPOXX.js → chunk-IOXMGD2H.js} +3 -3
  128. package/dist/safe-bash/command-chunks/{chunk-LDW3RF7Y.js → chunk-ISFGPCED.js} +12 -12
  129. package/dist/safe-bash/command-chunks/{chunk-S43QRKDC.js → chunk-IVKAFEPO.js} +7 -7
  130. package/dist/safe-bash/command-chunks/{chunk-A347DLRB.js → chunk-IWVANZWH.js} +3 -3
  131. package/dist/safe-bash/command-chunks/{chunk-ZXELXF2H.js → chunk-IZ3SD5S2.js} +4 -4
  132. package/dist/safe-bash/command-chunks/{chunk-HGIMFVI2.js → chunk-J6FNSVHT.js} +5 -5
  133. package/dist/safe-bash/command-chunks/{chunk-GLAF45M7.js → chunk-JA36YOZI.js} +1 -1
  134. package/dist/safe-bash/command-chunks/{chunk-WHNYT34N.js → chunk-K2R7H3KO.js} +1 -1
  135. package/dist/safe-bash/command-chunks/{chunk-HQ2UN2L2.js → chunk-K7VDCBXW.js} +21 -21
  136. package/dist/safe-bash/command-chunks/{chunk-CKEMZUE3.js → chunk-KDBU5Q2N.js} +6 -6
  137. package/dist/safe-bash/command-chunks/{chunk-6VBDJC6V.js → chunk-KDDXLHN7.js} +6 -6
  138. package/dist/safe-bash/command-chunks/{chunk-NEVQWOU6.js → chunk-KLAC2MIZ.js} +10 -10
  139. package/dist/safe-bash/command-chunks/{chunk-QGD64UHJ.js → chunk-KLCHCSIV.js} +1 -1
  140. package/dist/safe-bash/command-chunks/{chunk-CXME4YHU.js → chunk-KM2SMMXZ.js} +59 -201
  141. package/dist/safe-bash/command-chunks/{chunk-RHU44OMN.js → chunk-KXM3HTAF.js} +1 -1
  142. package/dist/safe-bash/command-chunks/{chunk-AVOGFREX.js → chunk-KYIGYYEY.js} +3 -3
  143. package/dist/safe-bash/command-chunks/{chunk-5OM3UIK3.js → chunk-L2VLASZ4.js} +3 -3
  144. package/dist/safe-bash/command-chunks/{chunk-Z7QOSXQC.js → chunk-LECGQSQW.js} +7 -7
  145. package/dist/safe-bash/command-chunks/{chunk-RXQ2G2YK.js → chunk-LFSWLJPR.js} +9 -9
  146. package/dist/safe-bash/command-chunks/{chunk-OSYY6E23.js → chunk-LJ3UYESS.js} +1 -1
  147. package/dist/safe-bash/command-chunks/{chunk-MVLVIMJ6.js → chunk-LMLBQSAM.js} +6 -6
  148. package/dist/safe-bash/command-chunks/{chunk-MGMTRGKM.js → chunk-LNAZ3E4Q.js} +4 -4
  149. package/dist/safe-bash/command-chunks/{chunk-WJ2ERUCQ.js → chunk-LNKZVU5V.js} +1 -1
  150. package/dist/safe-bash/command-chunks/{chunk-WWHMI4S3.js → chunk-LQDANF2B.js} +8 -8
  151. package/dist/safe-bash/command-chunks/{chunk-CIRDVCAZ.js → chunk-LQX7RAF7.js} +7 -7
  152. package/dist/safe-bash/command-chunks/{chunk-SWAKALDJ.js → chunk-LT2YCGC5.js} +10 -10
  153. package/dist/safe-bash/command-chunks/{chunk-Y7AXMCFV.js → chunk-LZY46GYY.js} +8 -8
  154. package/dist/safe-bash/command-chunks/{chunk-VT2PHQ63.js → chunk-MDFNUNK5.js} +15 -15
  155. package/dist/safe-bash/command-chunks/{chunk-YP3WWV5N.js → chunk-MN3BB4WW.js} +4 -4
  156. package/dist/safe-bash/command-chunks/{chunk-WTVJLHMG.js → chunk-MOUCMZZP.js} +1 -1
  157. package/dist/safe-bash/command-chunks/{chunk-IB5QP4LF.js → chunk-MQE77MEQ.js} +3 -3
  158. package/dist/safe-bash/command-chunks/{chunk-FSYMSWJU.js → chunk-MUTARE5I.js} +6 -6
  159. package/dist/safe-bash/command-chunks/{chunk-F762XDNG.js → chunk-MZYQKH26.js} +3 -3
  160. package/dist/safe-bash/command-chunks/{chunk-N6G3345Q.js → chunk-N32AP43V.js} +7 -7
  161. package/dist/safe-bash/command-chunks/{chunk-XU6S3XUZ.js → chunk-N35IJXBK.js} +9 -9
  162. package/dist/safe-bash/command-chunks/{chunk-EVYKV3QI.js → chunk-N3ZH4YYH.js} +3 -3
  163. package/dist/safe-bash/command-chunks/{chunk-VUWXLH3E.js → chunk-N4HWOLGZ.js} +2 -2
  164. package/dist/safe-bash/command-chunks/{chunk-WAT2562G.js → chunk-N5J3IZZK.js} +8042 -7189
  165. package/dist/safe-bash/command-chunks/{chunk-W3ZSWK76.js → chunk-NCNHJRIY.js} +8 -8
  166. package/dist/safe-bash/command-chunks/{chunk-FXCSPPYE.js → chunk-NDALIHKK.js} +20 -20
  167. package/dist/safe-bash/command-chunks/{chunk-BS5JEUEW.js → chunk-NKK76B4V.js} +8 -8
  168. package/dist/safe-bash/command-chunks/{chunk-4EZJV4FZ.js → chunk-NLCUQD7Y.js} +1 -1
  169. package/dist/safe-bash/command-chunks/{chunk-RHDERFMR.js → chunk-O2HNOQQG.js} +5 -5
  170. package/dist/safe-bash/command-chunks/{chunk-G2COZLXX.js → chunk-OBIXFO25.js} +10 -10
  171. package/dist/safe-bash/command-chunks/{chunk-47IAU25U.js → chunk-OCV5ZU35.js} +3 -3
  172. package/dist/safe-bash/command-chunks/{chunk-3YEQI5B7.js → chunk-OFDJJRAD.js} +9 -9
  173. package/dist/safe-bash/command-chunks/{chunk-VDTFVRYX.js → chunk-OFONWWEZ.js} +2 -2
  174. package/dist/safe-bash/command-chunks/{chunk-F4YFTO2K.js → chunk-OHEZQ4QA.js} +9 -9
  175. package/dist/safe-bash/command-chunks/{chunk-JW6WVNTM.js → chunk-OIHQXURE.js} +1 -1
  176. package/dist/safe-bash/command-chunks/{chunk-ZTMZO4IT.js → chunk-ONQP4FNV.js} +1 -1
  177. package/dist/safe-bash/command-chunks/{chunk-K2WOMJOQ.js → chunk-OVUY46QF.js} +1 -1
  178. package/dist/safe-bash/command-chunks/{chunk-DGBQ7QDE.js → chunk-OWCBX5M2.js} +1 -1
  179. package/dist/safe-bash/command-chunks/{chunk-LKGTH2Q7.js → chunk-P462JTNT.js} +5 -5
  180. package/dist/safe-bash/command-chunks/{chunk-5LFGXN3D.js → chunk-P4OWVKMD.js} +6 -6
  181. package/dist/safe-bash/command-chunks/{chunk-46AMTJPE.js → chunk-POGVOCOB.js} +8 -8
  182. package/dist/safe-bash/command-chunks/{chunk-PLMF35XK.js → chunk-PPN53PX3.js} +4 -4
  183. package/dist/safe-bash/command-chunks/{chunk-V5XC43BX.js → chunk-PRO7JOIH.js} +8 -8
  184. package/dist/safe-bash/command-chunks/{chunk-UJERQEJB.js → chunk-PU5DMQGG.js} +1 -1
  185. package/dist/safe-bash/command-chunks/{chunk-IWHNRYER.js → chunk-Q65GWGQR.js} +3 -3
  186. package/dist/safe-bash/command-chunks/{chunk-BLGGAHQW.js → chunk-QCIAX6HZ.js} +1 -1
  187. package/dist/safe-bash/command-chunks/{chunk-ET5SFGRH.js → chunk-QDV2NIFR.js} +1 -1
  188. package/dist/safe-bash/command-chunks/{chunk-Y42KSX63.js → chunk-QMBMZSJF.js} +6 -6
  189. package/dist/safe-bash/command-chunks/{chunk-KUOCGGEU.js → chunk-QNETPOMH.js} +6 -5
  190. package/dist/safe-bash/command-chunks/{chunk-QB72X7FF.js → chunk-QNX5LZBK.js} +7 -7
  191. package/dist/safe-bash/command-chunks/{chunk-LZ2JFMKT.js → chunk-QOKFSYD5.js} +9 -9
  192. package/dist/safe-bash/command-chunks/{chunk-7DOLY7IV.js → chunk-R7LF4XQV.js} +2 -2
  193. package/dist/safe-bash/command-chunks/{chunk-6CDDKNNA.js → chunk-RINR7XPR.js} +36 -10
  194. package/dist/safe-bash/command-chunks/{chunk-MPXMRTMY.js → chunk-ROQ3VNVX.js} +8 -8
  195. package/dist/safe-bash/command-chunks/{chunk-6WNVGCXD.js → chunk-RRAQII52.js} +5 -5
  196. package/dist/safe-bash/command-chunks/{chunk-2BNGPR6Z.js → chunk-RTHYAGKI.js} +2 -2
  197. package/dist/safe-bash/command-chunks/chunk-RTKDZBJS.js +816 -0
  198. package/dist/safe-bash/command-chunks/{chunk-JVKE7YZN.js → chunk-RVWIEXR7.js} +4 -4
  199. package/dist/safe-bash/command-chunks/{chunk-XM5QJCPD.js → chunk-S5ER73EA.js} +8 -8
  200. package/dist/safe-bash/command-chunks/{chunk-YRPXBGRX.js → chunk-SBXS4S6Y.js} +3 -3
  201. package/dist/safe-bash/command-chunks/{chunk-HI6ZYH3W.js → chunk-SHLT5R64.js} +9 -9
  202. package/dist/safe-bash/command-chunks/{chunk-Q5PWYPQV.js → chunk-SICTBSLW.js} +7 -7
  203. package/dist/safe-bash/command-chunks/{chunk-AXXZNB7U.js → chunk-SL4LD25A.js} +9 -9
  204. package/dist/safe-bash/command-chunks/{chunk-JGKSWDGP.js → chunk-SNA2LVBX.js} +1 -1
  205. package/dist/safe-bash/command-chunks/{chunk-TXPDKEGY.js → chunk-SWIF6BBY.js} +8 -8
  206. package/dist/safe-bash/command-chunks/{chunk-PS5GDFIP.js → chunk-T2FRXSQT.js} +2 -2
  207. package/dist/safe-bash/command-chunks/{chunk-HELAVGZH.js → chunk-T4SEQU66.js} +3 -3
  208. package/dist/safe-bash/command-chunks/{chunk-3SPLP2DB.js → chunk-T5OQ53XS.js} +1 -1
  209. package/dist/safe-bash/command-chunks/{chunk-KBAQHE5Y.js → chunk-TG2RVQLP.js} +2 -2
  210. package/dist/safe-bash/command-chunks/{chunk-CZ5K2YPU.js → chunk-TXU7MMHN.js} +24 -24
  211. package/dist/safe-bash/command-chunks/{chunk-TYPS5MOU.js → chunk-TXWDR2P4.js} +1 -1
  212. package/dist/safe-bash/command-chunks/{chunk-ETXPMVR6.js → chunk-TY7JXEWI.js} +11 -11
  213. package/dist/safe-bash/command-chunks/{chunk-X6OHFKBL.js → chunk-U42WHQRH.js} +8 -8
  214. package/dist/safe-bash/command-chunks/{chunk-Z2WNYEPD.js → chunk-UFLMOU3B.js} +4 -4
  215. package/dist/safe-bash/command-chunks/{chunk-2BLTUQNK.js → chunk-UJYXSLM6.js} +2 -2
  216. package/dist/safe-bash/command-chunks/{chunk-Q7TVCBU2.js → chunk-UKAGRRLZ.js} +1 -1
  217. package/dist/safe-bash/command-chunks/{chunk-4GQKCUS5.js → chunk-UPWLHHZ2.js} +13 -13
  218. package/dist/safe-bash/command-chunks/{chunk-5L4YGRQU.js → chunk-URQSUMMJ.js} +4 -4
  219. package/dist/safe-bash/command-chunks/{chunk-KPHLESD4.js → chunk-UT5X6QRU.js} +5 -5
  220. package/dist/safe-bash/command-chunks/{chunk-T5S4SJGO.js → chunk-V6JPIZUW.js} +7 -7
  221. package/dist/safe-bash/command-chunks/{chunk-MKK6FM5H.js → chunk-VMZIAFVJ.js} +11 -11
  222. package/dist/safe-bash/command-chunks/{chunk-HK6MSB7Z.js → chunk-VNNNVT4C.js} +5 -5
  223. package/dist/safe-bash/command-chunks/{chunk-ROL5AEX6.js → chunk-VVV45NLY.js} +1 -1
  224. package/dist/safe-bash/command-chunks/chunk-VVWHFNHD.js +502 -0
  225. package/dist/safe-bash/command-chunks/{chunk-KCLJGRU7.js → chunk-VZTVR3JI.js} +12 -12
  226. package/dist/safe-bash/command-chunks/{chunk-PLR5IULU.js → chunk-WDVPHDBH.js} +5 -5
  227. package/dist/safe-bash/command-chunks/{chunk-MNK3DDH6.js → chunk-WH624PKJ.js} +2 -2
  228. package/dist/safe-bash/command-chunks/{chunk-TJLXSENN.js → chunk-WHZ6XK7Y.js} +1 -1
  229. package/dist/safe-bash/command-chunks/{chunk-DN6MSXY7.js → chunk-WIW3KDBS.js} +2 -2
  230. package/dist/safe-bash/command-chunks/{chunk-GXMPXMDP.js → chunk-WMBELKPP.js} +11 -11
  231. package/dist/safe-bash/command-chunks/{chunk-NHNZYWPW.js → chunk-WMV5224N.js} +3 -3
  232. package/dist/safe-bash/command-chunks/{chunk-RTNI47C5.js → chunk-WOL3LBXE.js} +4 -4
  233. package/dist/safe-bash/command-chunks/{chunk-7SOE7XIS.js → chunk-WVD5WZXD.js} +5 -5
  234. package/dist/safe-bash/command-chunks/{chunk-XMTR7QGL.js → chunk-X42MJT2J.js} +4 -4
  235. package/dist/safe-bash/command-chunks/{chunk-XUJAQA3S.js → chunk-XBWD6SI3.js} +33 -33
  236. package/dist/safe-bash/command-chunks/{chunk-ZQM37BGE.js → chunk-XFIDOCYH.js} +2 -2
  237. package/dist/safe-bash/command-chunks/{chunk-IBYMPAUW.js → chunk-XPQUUFQD.js} +2 -2
  238. package/dist/safe-bash/command-chunks/{chunk-NQINS4XY.js → chunk-XVEI4HZL.js} +1 -1
  239. package/dist/safe-bash/command-chunks/{chunk-KSBNZTAZ.js → chunk-YKODRSGT.js} +6 -6
  240. package/dist/safe-bash/command-chunks/{chunk-WZRFS5OY.js → chunk-YXR4JE4U.js} +4 -4
  241. package/dist/safe-bash/command-chunks/{chunk-DCMSPMMD.js → chunk-Z7UIOPHJ.js} +1 -1
  242. package/dist/safe-bash/command-chunks/{chunk-AY3KQ4EN.js → chunk-ZAYTFXUX.js} +7 -7
  243. package/dist/safe-bash/command-chunks/{chunk-DZH54L3F.js → chunk-ZM7HMBAJ.js} +10 -10
  244. package/dist/safe-bash/command-chunks/{chunk-NFGCBQN3.js → chunk-ZNCPIZCN.js} +2 -2
  245. package/dist/safe-bash/command-chunks/{chunk-HKGNBH7Z.js → chunk-ZRHKXN6W.js} +4 -4
  246. package/dist/safe-bash/command-chunks/{chunk-A45UG4KT.js → chunk-ZZERSKAR.js} +5 -5
  247. package/dist/safe-bash/command-chunks/{clipboard-BBDK33GP-QZ4ERNQX.js → clipboard-BBDK33GP-VB22F7GI.js} +2 -2
  248. package/dist/safe-bash/command-chunks/{command-engine-M7S4QIXV.js → command-engine-GHE6QUHU.js} +53 -21
  249. package/dist/safe-bash/command-chunks/{engine-YUYZJIB4-NZUDFEHL.js → engine-RG6HQCCB-FXYZS264.js} +1 -1
  250. package/dist/safe-bash/command-chunks/{gnumeric-UJPXWBVR-7VOHQAPM.js → gnumeric-UJPXWBVR-YPXTNEDZ.js} +2 -2
  251. package/dist/safe-bash/command-chunks/model-store-I7YAWL5V.js +54 -0
  252. package/dist/safe-bash/command-chunks/{xlsx-RE54MFCS-DI3F765V.js → xlsx-RE54MFCS-IQ6OXXKK.js} +1 -1
  253. package/dist/safe-bash/commands/bc/index.browser.js +1 -1
  254. package/dist/safe-bash/full-core.browser.js +4 -4
  255. package/dist/safe-bash/plugins/index.browser.js +3 -3
  256. package/dist/safe-bash/registry-entry.browser.js +2 -2
  257. package/dist/safe-bash/search.browser.js +1 -1
  258. package/dist/safe-bash/shell/runtime.d.ts +1 -0
  259. package/dist/safe-bash/shell/runtime.js +12 -3
  260. package/dist/safe-bash/shell/sync-extra-evaluators.js +7 -4
  261. package/dist/safe-bash/shell-entry.browser.js +2 -2
  262. package/dist/safe-bash-command-awk/awk-runtime.js +3 -3
  263. package/dist/safe-bash-command-awk/awk.js +4 -4
  264. package/dist/safe-bash-command-awk/index.js +4 -4
  265. package/dist/safe-bash-command-cp/index.js +3 -3
  266. package/dist/safe-bash-command-csvkit/index.js +1 -1
  267. package/dist/safe-bash-command-diff/diff.js +2 -2
  268. package/dist/safe-bash-command-diff/index.js +3 -3
  269. package/dist/safe-bash-command-diff/sync.js +2 -2
  270. package/dist/safe-bash-command-factor/command.js +2 -2
  271. package/dist/safe-bash-command-factor/index.js +2 -2
  272. package/dist/safe-bash-command-ffmpeg/index.js +1 -1
  273. package/dist/safe-bash-command-ffprobe/index.js +2 -2
  274. package/dist/safe-bash-command-ffprobe/media.d.ts +5 -1
  275. package/dist/safe-bash-command-ffprobe/media.js +2 -2
  276. package/dist/safe-bash-command-getopt/command.js +2 -2
  277. package/dist/safe-bash-command-getopt/index.js +2 -2
  278. package/dist/safe-bash-command-html-to-markdown/index.js +51 -813
  279. package/dist/safe-bash-command-html-to-markdown/stored-destination.d.ts +8 -0
  280. package/dist/safe-bash-command-html-to-markdown/stored-destination.js +10 -0
  281. package/dist/safe-bash-command-html-to-markdown/stored-text.d.ts +4 -1
  282. package/dist/safe-bash-command-html-to-markdown/stored-text.js +1 -1
  283. package/dist/safe-bash-command-htmlq/index.js +1280 -419
  284. package/dist/safe-bash-command-iconv/command.js +2 -2
  285. package/dist/safe-bash-command-iconv/index.js +2 -2
  286. package/dist/safe-bash-command-llm/index.js +2 -2
  287. package/dist/safe-bash-command-llm/openai.js +2 -2
  288. package/dist/safe-bash-command-llm/providers/index.js +2 -2
  289. package/dist/safe-bash-command-llm/providers/openai.js +2 -2
  290. package/dist/safe-bash-command-node/commands/node/browser.js +4 -4
  291. package/dist/safe-bash-command-node/commands/node/default-runtime.js +4 -4
  292. package/dist/safe-bash-command-node/commands/node/safejs.js +4 -4
  293. package/dist/safe-bash-command-pandoc/command.js +10 -9
  294. package/dist/safe-bash-command-pandoc/index.js +60 -59
  295. package/dist/safe-bash-command-patch/index.js +6 -6
  296. package/dist/safe-bash-command-patch/patch-formats.js +3 -3
  297. package/dist/safe-bash-command-patch/patch-gnu-reject.js +1 -1
  298. package/dist/safe-bash-command-patch/patch.js +6 -6
  299. package/dist/safe-bash-command-patch/stored-patch.d.ts +7 -6
  300. package/dist/safe-bash-command-patch/unified.d.ts +5 -5
  301. package/dist/safe-bash-command-patch/unified.js +2 -2
  302. package/dist/safe-bash-command-pdftk/index.js +21 -108
  303. package/dist/safe-bash-command-pdftoppm/index.js +131 -27
  304. package/dist/safe-bash-command-playwright-cli/index.js +12 -12
  305. package/dist/safe-bash-command-playwright-cli/playwright/abilities.js +1 -1
  306. package/dist/safe-bash-command-playwright-cli/playwright/capability-events.js +1 -1
  307. package/dist/safe-bash-command-playwright-cli/playwright/capability-result.js +1 -1
  308. package/dist/safe-bash-command-playwright-cli/playwright/controller.js +7 -7
  309. package/dist/safe-bash-command-playwright-cli/playwright/download-capabilities.js +1 -1
  310. package/dist/safe-bash-command-playwright-cli/playwright/drop-capability.js +1 -1
  311. package/dist/safe-bash-command-playwright-cli/playwright/index.js +12 -12
  312. package/dist/safe-bash-command-playwright-cli/playwright/modal-capabilities.js +1 -1
  313. package/dist/safe-bash-command-playwright-cli/playwright/native-evaluation.js +1 -1
  314. package/dist/safe-bash-command-playwright-cli/playwright/native-json-snapshot.js +1 -1
  315. package/dist/safe-bash-command-playwright-cli/playwright/native-snapshot.js +1 -1
  316. package/dist/safe-bash-command-playwright-cli/playwright/open-options.js +2 -2
  317. package/dist/safe-bash-command-playwright-cli/playwright/profile.js +3 -3
  318. package/dist/safe-bash-command-playwright-cli/playwright/recording-capabilities.js +1 -1
  319. package/dist/safe-bash-command-playwright-cli/playwright/route-capabilities.js +1 -1
  320. package/dist/safe-bash-command-playwright-cli/playwright/snapshot.js +3 -3
  321. package/dist/safe-bash-command-playwright-cli/playwright/standard-capabilities.js +1 -1
  322. package/dist/safe-bash-command-playwright-cli/playwright/storage-capabilities.js +1 -1
  323. package/dist/safe-bash-command-playwright-cli/playwright/tracing-capabilities.js +1 -1
  324. package/dist/safe-bash-command-playwright-cli/playwright/webmcp-capabilities.js +1 -1
  325. package/dist/safe-bash-command-pptx/engine.js +1 -1
  326. package/dist/safe-bash-command-python/executor.js +11 -11
  327. package/dist/safe-bash-command-python/index.js +11 -11
  328. package/dist/safe-bash-command-python/jspi.js +2 -2
  329. package/dist/safe-bash-command-rg/index.js +3 -3
  330. package/dist/safe-bash-command-rg/rg-command.js +3 -3
  331. package/dist/safe-bash-command-safejs/index.js +4 -4
  332. package/dist/safe-bash-command-safejs/io.js +3 -3
  333. package/dist/safe-bash-command-safejs/render.js +2 -2
  334. package/dist/safe-bash-command-safejs/runtime.js +4 -4
  335. package/dist/safe-bash-command-soffice/index.js +5 -4
  336. package/dist/safe-bash-command-sort/index.js +3 -3
  337. package/dist/safe-bash-command-ssconvert/index.js +13 -13
  338. package/dist/safe-bash-command-tar/create.js +3 -3
  339. package/dist/safe-bash-command-tar/extract.js +3 -3
  340. package/dist/safe-bash-command-tar/index.js +7 -7
  341. package/dist/safe-bash-command-tar/modes.js +5 -5
  342. package/dist/safe-bash-command-unzip/index.js +2 -2
  343. package/dist/safe-bash-command-unzip/unzip.js +2 -2
  344. package/dist/safe-bash-command-xmllint/index.js +1 -1
  345. package/dist/safe-bash-command-xz/index.js +5 -5
  346. package/dist/safe-bash-compression-engine/files.js +5 -5
  347. package/dist/safe-bash-compression-engine/index.js +3 -3
  348. package/dist/safe-bash-compression-engine/operand.js +6 -6
  349. package/dist/safe-bash-compression-engine/stream.js +3 -3
  350. package/dist/safe-bash-compression-engine/zstd-decode.js +2 -2
  351. package/dist/safe-bash-contracts/escaping.js +3 -3
  352. package/dist/safe-bash-contracts/filesystem-output.js +3 -3
  353. package/dist/safe-bash-contracts/index.js +10 -10
  354. package/dist/safe-bash-docx-engine/ancillary-resources.js +9 -9
  355. package/dist/safe-bash-docx-engine/batch-operations.js +66 -66
  356. package/dist/safe-bash-docx-engine/batch-result-schema.js +78 -78
  357. package/dist/safe-bash-docx-engine/batch.js +77 -77
  358. package/dist/safe-bash-docx-engine/bookmarks.js +17 -17
  359. package/dist/safe-bash-docx-engine/charts.js +10 -10
  360. package/dist/safe-bash-docx-engine/command-option-rules.js +5 -5
  361. package/dist/safe-bash-docx-engine/command-properties.js +3 -3
  362. package/dist/safe-bash-docx-engine/comments.js +25 -25
  363. package/dist/safe-bash-docx-engine/control-bindings.js +20 -20
  364. package/dist/safe-bash-docx-engine/control-repeat.js +20 -20
  365. package/dist/safe-bash-docx-engine/controls.js +18 -18
  366. package/dist/safe-bash-docx-engine/create.js +10 -10
  367. package/dist/safe-bash-docx-engine/diagrams.js +10 -10
  368. package/dist/safe-bash-docx-engine/diff.js +12 -12
  369. package/dist/safe-bash-docx-engine/document-properties.js +15 -15
  370. package/dist/safe-bash-docx-engine/equations.js +16 -16
  371. package/dist/safe-bash-docx-engine/extract.js +13 -13
  372. package/dist/safe-bash-docx-engine/fields.js +22 -22
  373. package/dist/safe-bash-docx-engine/font-inventory.js +17 -17
  374. package/dist/safe-bash-docx-engine/font-resources.js +5 -5
  375. package/dist/safe-bash-docx-engine/image-batch-operations.js +13 -13
  376. package/dist/safe-bash-docx-engine/image-insertion.js +20 -20
  377. package/dist/safe-bash-docx-engine/image-layout.js +18 -18
  378. package/dist/safe-bash-docx-engine/image-replacement.js +21 -21
  379. package/dist/safe-bash-docx-engine/images.js +18 -18
  380. package/dist/safe-bash-docx-engine/index.js +113 -113
  381. package/dist/safe-bash-docx-engine/inspection.js +19 -19
  382. package/dist/safe-bash-docx-engine/invocation.js +8 -8
  383. package/dist/safe-bash-docx-engine/io.js +8 -8
  384. package/dist/safe-bash-docx-engine/links.js +20 -20
  385. package/dist/safe-bash-docx-engine/lists.js +19 -19
  386. package/dist/safe-bash-docx-engine/locations.js +14 -14
  387. package/dist/safe-bash-docx-engine/notes.js +21 -21
  388. package/dist/safe-bash-docx-engine/objects.js +18 -18
  389. package/dist/safe-bash-docx-engine/operation-json-schema.js +3 -3
  390. package/dist/safe-bash-docx-engine/operation-schema.js +2 -2
  391. package/dist/safe-bash-docx-engine/pack.js +13 -13
  392. package/dist/safe-bash-docx-engine/package-view-batch-operations.js +21 -21
  393. package/dist/safe-bash-docx-engine/pandoc-adapter.js +28 -28
  394. package/dist/safe-bash-docx-engine/paragraph-edit.js +24 -24
  395. package/dist/safe-bash-docx-engine/part-provider.js +3 -3
  396. package/dist/safe-bash-docx-engine/property-values.js +3 -3
  397. package/dist/safe-bash-docx-engine/publication.js +8 -8
  398. package/dist/safe-bash-docx-engine/removal.js +20 -20
  399. package/dist/safe-bash-docx-engine/revision-decisions.js +21 -21
  400. package/dist/safe-bash-docx-engine/revision-edit.js +19 -19
  401. package/dist/safe-bash-docx-engine/revisions.js +17 -17
  402. package/dist/safe-bash-docx-engine/run-format.js +19 -19
  403. package/dist/safe-bash-docx-engine/sanitize.js +33 -33
  404. package/dist/safe-bash-docx-engine/sections.js +18 -18
  405. package/dist/safe-bash-docx-engine/settings.js +10 -10
  406. package/dist/safe-bash-docx-engine/shape-edit.js +20 -20
  407. package/dist/safe-bash-docx-engine/signatures.js +14 -14
  408. package/dist/safe-bash-docx-engine/stories.js +21 -21
  409. package/dist/safe-bash-docx-engine/structure-model-batch-operations.js +37 -37
  410. package/dist/safe-bash-docx-engine/style-model-batch-operations.js +26 -26
  411. package/dist/safe-bash-docx-engine/style-model-result-schema.js +43 -43
  412. package/dist/safe-bash-docx-engine/styles.js +17 -17
  413. package/dist/safe-bash-docx-engine/table-edit.js +26 -26
  414. package/dist/safe-bash-docx-engine/table-read.js +15 -15
  415. package/dist/safe-bash-docx-engine/template.js +21 -21
  416. package/dist/safe-bash-docx-engine/text-replace.js +19 -19
  417. package/dist/safe-bash-docx-engine/text-resource-read.js +15 -15
  418. package/dist/safe-bash-docx-engine/text.js +15 -15
  419. package/dist/safe-bash-docx-engine/validation.js +6 -6
  420. package/dist/safe-bash-docx-engine/xml-parts.js +21 -21
  421. package/dist/safe-bash-line-ending-engine/command.js +4 -4
  422. package/dist/safe-bash-line-ending-engine/index.js +7 -7
  423. package/dist/safe-bash-markdown-engine/commonmark-blocks.js +3 -3
  424. package/dist/safe-bash-markdown-engine/commonmark-inlines.js +3 -3
  425. package/dist/safe-bash-markdown-engine/gfm-syntax.js +2 -2
  426. package/dist/safe-bash-markdown-engine/index.js +4 -4
  427. package/dist/safe-bash-network-engine/aggregate.js +3 -3
  428. package/dist/safe-bash-network-engine/args.js +3 -3
  429. package/dist/safe-bash-network-engine/body.js +4 -4
  430. package/dist/safe-bash-network-engine/decode.js +3 -3
  431. package/dist/safe-bash-network-engine/fetch-transport.js +3 -3
  432. package/dist/safe-bash-network-engine/index.js +3 -3
  433. package/dist/safe-bash-network-engine/output.js +3 -3
  434. package/dist/safe-bash-network-engine/platform-portable.js +3 -3
  435. package/dist/safe-bash-network-engine/shared.js +2 -2
  436. package/dist/safe-bash-network-engine/transfer.js +9 -9
  437. package/dist/safe-bash-presentation-engine/accessibility.js +31 -30
  438. package/dist/safe-bash-presentation-engine/animation-editing.js +16 -15
  439. package/dist/safe-bash-presentation-engine/animations.js +16 -15
  440. package/dist/safe-bash-presentation-engine/backgrounds.js +17 -16
  441. package/dist/safe-bash-presentation-engine/bytes.js +4 -3
  442. package/dist/safe-bash-presentation-engine/chart-editing.js +34 -33
  443. package/dist/safe-bash-presentation-engine/chart-object-operations.js +25 -24
  444. package/dist/safe-bash-presentation-engine/charts.js +31 -30
  445. package/dist/safe-bash-presentation-engine/command-placeholder.js +60 -58
  446. package/dist/safe-bash-presentation-engine/comments.js +17 -16
  447. package/dist/safe-bash-presentation-engine/connector-operations.js +32 -31
  448. package/dist/safe-bash-presentation-engine/connectors.js +29 -28
  449. package/dist/safe-bash-presentation-engine/content-types.js +5 -4
  450. package/dist/safe-bash-presentation-engine/creation.js +7 -6
  451. package/dist/safe-bash-presentation-engine/diff.d.ts +1 -0
  452. package/dist/safe-bash-presentation-engine/diff.js +44 -33
  453. package/dist/safe-bash-presentation-engine/drawing-format.js +20 -19
  454. package/dist/safe-bash-presentation-engine/drawing-operations.js +31 -30
  455. package/dist/safe-bash-presentation-engine/drawing-schema.js +21 -20
  456. package/dist/safe-bash-presentation-engine/equations.js +17 -16
  457. package/dist/safe-bash-presentation-engine/errors.js +3 -2
  458. package/dist/safe-bash-presentation-engine/fields.js +17 -16
  459. package/dist/safe-bash-presentation-engine/font-metrics.js +4 -3
  460. package/dist/safe-bash-presentation-engine/image-extraction.js +20 -19
  461. package/dist/safe-bash-presentation-engine/image-formatting.js +32 -31
  462. package/dist/safe-bash-presentation-engine/image-insertion.js +18 -17
  463. package/dist/safe-bash-presentation-engine/image-replacement.js +21 -20
  464. package/dist/safe-bash-presentation-engine/image-value.js +5 -4
  465. package/dist/safe-bash-presentation-engine/images.js +19 -18
  466. package/dist/safe-bash-presentation-engine/index.js +135 -132
  467. package/dist/safe-bash-presentation-engine/layouts.js +16 -15
  468. package/dist/safe-bash-presentation-engine/length.js +4 -3
  469. package/dist/safe-bash-presentation-engine/links.js +16 -15
  470. package/dist/safe-bash-presentation-engine/masters.js +15 -14
  471. package/dist/safe-bash-presentation-engine/media-editing.js +24 -23
  472. package/dist/safe-bash-presentation-engine/media-extraction.js +17 -16
  473. package/dist/safe-bash-presentation-engine/media.js +16 -15
  474. package/dist/safe-bash-presentation-engine/memberships.js +15 -14
  475. package/dist/safe-bash-presentation-engine/notes.js +18 -17
  476. package/dist/safe-bash-presentation-engine/ole-enum.js +5 -4
  477. package/dist/safe-bash-presentation-engine/ole-insertion.js +20 -19
  478. package/dist/safe-bash-presentation-engine/opaque-objects.js +10 -9
  479. package/dist/safe-bash-presentation-engine/package-reader.js +6 -5
  480. package/dist/safe-bash-presentation-engine/package-tools.js +19 -18
  481. package/dist/safe-bash-presentation-engine/package-uri.js +4 -3
  482. package/dist/safe-bash-presentation-engine/package-writer.js +5 -4
  483. package/dist/safe-bash-presentation-engine/presentation-model.js +59 -57
  484. package/dist/safe-bash-presentation-engine/presentation-settings.js +14 -13
  485. package/dist/safe-bash-presentation-engine/properties.d.ts +2 -1
  486. package/dist/safe-bash-presentation-engine/properties.js +25 -15
  487. package/dist/safe-bash-presentation-engine/relationships.js +5 -4
  488. package/dist/safe-bash-presentation-engine/resource-limits.js +2 -1
  489. package/dist/safe-bash-presentation-engine/retained-diff.d.ts +56 -0
  490. package/dist/safe-bash-presentation-engine/retained-inspection.js +14 -13
  491. package/dist/safe-bash-presentation-engine/retained-package.js +6 -5
  492. package/dist/safe-bash-presentation-engine/retained-properties.d.ts +26 -0
  493. package/dist/safe-bash-presentation-engine/retained-text.js +33 -517
  494. package/dist/safe-bash-presentation-engine/sanitize.js +20 -16
  495. package/dist/safe-bash-presentation-engine/selectors.js +11 -10
  496. package/dist/safe-bash-presentation-engine/shape-groups.js +31 -30
  497. package/dist/safe-bash-presentation-engine/shape-operations.js +30 -29
  498. package/dist/safe-bash-presentation-engine/shape-path-operations.js +32 -31
  499. package/dist/safe-bash-presentation-engine/shape-paths.js +16 -15
  500. package/dist/safe-bash-presentation-engine/shape-presets.js +4 -3
  501. package/dist/safe-bash-presentation-engine/shape-selection.js +31 -30
  502. package/dist/safe-bash-presentation-engine/shape-transforms.js +18 -17
  503. package/dist/safe-bash-presentation-engine/shapes.js +27 -26
  504. package/dist/safe-bash-presentation-engine/slide-copy.js +17 -16
  505. package/dist/safe-bash-presentation-engine/slide-import.js +18 -17
  506. package/dist/safe-bash-presentation-engine/slide-merge-split.js +20 -19
  507. package/dist/safe-bash-presentation-engine/slide-model.js +43 -42
  508. package/dist/safe-bash-presentation-engine/slide-removal.js +18 -17
  509. package/dist/safe-bash-presentation-engine/slide-transfer-budget.js +10 -9
  510. package/dist/safe-bash-presentation-engine/slides.js +19 -18
  511. package/dist/safe-bash-presentation-engine/table-operations.js +33 -32
  512. package/dist/safe-bash-presentation-engine/table-spans.js +32 -31
  513. package/dist/safe-bash-presentation-engine/tables.js +31 -30
  514. package/dist/safe-bash-presentation-engine/tags.js +16 -15
  515. package/dist/safe-bash-presentation-engine/template-bindings.js +33 -32
  516. package/dist/safe-bash-presentation-engine/template-repeat.js +40 -39
  517. package/dist/safe-bash-presentation-engine/text-fitting.js +27 -26
  518. package/dist/safe-bash-presentation-engine/text-frames.js +27 -26
  519. package/dist/safe-bash-presentation-engine/text-paragraphs.js +27 -26
  520. package/dist/safe-bash-presentation-engine/text-reading.js +12 -11
  521. package/dist/safe-bash-presentation-engine/text-replacement.js +17 -16
  522. package/dist/safe-bash-presentation-engine/text-runs.js +20 -19
  523. package/dist/safe-bash-presentation-engine/themes.js +16 -15
  524. package/dist/safe-bash-presentation-engine/transitions.js +16 -15
  525. package/dist/safe-bash-presentation-engine/validation.js +10 -9
  526. package/dist/safe-bash-presentation-engine/xml-parts.js +19 -18
  527. package/dist/safe-bash-presentation-engine/xml-view.js +4 -3
  528. package/dist/safe-bash-presentation-engine/xml.js +4 -3
  529. package/dist/safe-bash-query-engine/index.js +3 -3
  530. package/dist/safe-bash-query-engine/interpreter.js +2 -2
  531. package/dist/safe-bash-query-engine/query-core.js +3 -3
  532. package/dist/safe-bash-regex-engine/ere/matcher.js +3 -3
  533. package/dist/safe-bash-xml-engine/document.js +3 -3
  534. package/dist/safe-bash-xml-engine/evaluate.js +1 -1
  535. package/dist/safe-bash-xml-engine/index.js +4 -4
  536. package/dist/safe-bash-xml-engine/json.js +14 -10
  537. package/dist/safe-bash-xml-engine/query.js +2 -2
  538. package/dist/safe-bash-xml-engine/stored-document.d.ts +4 -0
  539. package/dist/safe-bash-xml-engine/stored-document.js +1 -1
  540. package/dist/safe-bash-xml-engine/stored-evaluate.js +3 -3
  541. package/dist/safe-bash-zip-engine/index.js +2 -2
  542. package/dist/safe-bash-zip-engine/zip/repair.js +2 -2
  543. package/dist/safe-bash-zip-engine/zip/sfx.js +2 -2
  544. package/dist/safe-bash-zip-engine/zip-format.js +2 -2
  545. package/dist/spreadsheet-format-xls/biff-properties-merge.js +63 -67
  546. package/dist/spreadsheet-format-xls/biff-properties.js +3 -3
  547. package/dist/spreadsheet-format-xls/biff-property-transcode.d.ts +6 -1
  548. package/dist/spreadsheet-format-xls/biff-property-transcode.js +15 -4
  549. package/dist/spreadsheet-format-xls/biff-property-values.d.ts +6 -1
  550. package/dist/spreadsheet-format-xls/biff-property-values.js +81 -12
  551. package/dist/xlsx-ast/comment-geometry.d.ts +12 -0
  552. package/dist/xlsx-ast/comment-geometry.js +71 -0
  553. package/dist/xlsx-ast/xlsx-metadata.d.ts +1 -1
  554. package/dist/xlsx-ast/xlsx-metadata.js +27 -2
  555. package/dist/xlsx-ast/xlsx-write-metadata.js +9 -1
  556. package/dist/xlsx-ast/xlsx.js +9 -4
  557. package/package.json +5 -3
  558. package/dist/safe-bash/command-chunks/biff-A7XPBWAK-DCLG5QKF.js +0 -5417
  559. package/dist/safe-bash/command-chunks/chunk-DBNJEXHK.js +0 -387
  560. package/dist/safe-bash/command-chunks/chunk-EV5G535P.js +0 -240
  561. package/dist/safe-bash/command-chunks/model-store-UB5DWMAP.js +0 -54
  562. package/dist/safe-bash/command-chunks/{chunk-NGSO645G.js → chunk-3ZVK2OAY.js} +6 -6
  563. package/dist/safe-bash/command-chunks/{chunk-W2FKFEVY.js → chunk-4YSBUQPV.js} +3 -3
  564. package/dist/safe-bash/command-chunks/{chunk-UJSLBBQ7.js → chunk-5MFRN3CB.js} +4 -4
  565. package/dist/safe-bash/command-chunks/{chunk-AW4Q3GZW.js → chunk-5QXRIZSS.js} +3 -3
  566. package/dist/safe-bash/command-chunks/{chunk-KUGV3SSL.js → chunk-CZXYWGVO.js} +3 -3
  567. package/dist/safe-bash/command-chunks/{chunk-JWORWL72.js → chunk-DX7KU6YU.js} +3 -3
  568. package/dist/safe-bash/command-chunks/{chunk-Z37OM247.js → chunk-E3BL7W5C.js} +3 -3
  569. package/dist/safe-bash/command-chunks/{chunk-RIKNMBLZ.js → chunk-FEKECRJP.js} +3 -3
  570. package/dist/safe-bash/command-chunks/{chunk-D3HW7R2N.js → chunk-FTZFCMVI.js} +9 -9
  571. package/dist/safe-bash/command-chunks/{chunk-KRRG4MGH.js → chunk-GEDO5V32.js} +3 -3
  572. package/dist/safe-bash/command-chunks/{chunk-NBRXQUK7.js → chunk-M3OXQXCU.js} +3 -3
  573. package/dist/safe-bash/command-chunks/{chunk-JRSZ5IGD.js → chunk-OAM2SUUI.js} +6 -6
  574. package/dist/safe-bash/command-chunks/{chunk-HFKS6AET.js → chunk-OCOJMKDP.js} +4 -4
  575. package/dist/safe-bash/command-chunks/{chunk-FMJKCVSQ.js → chunk-OOB7YCFQ.js} +3 -3
  576. package/dist/safe-bash/command-chunks/{chunk-GGH376XQ.js → chunk-OU4VE5CR.js} +6 -6
  577. package/dist/safe-bash/command-chunks/{chunk-DYERIXPU.js → chunk-QGTQJCKW.js} +3 -3
  578. package/dist/safe-bash/command-chunks/{chunk-ZSQCROFE.js → chunk-RXXNLH7A.js} +3 -3
  579. package/dist/safe-bash/command-chunks/{chunk-TI52LKLL.js → chunk-UVM6QG2H.js} +3 -3
  580. package/dist/safe-bash/command-chunks/{chunk-BJXADHRT.js → chunk-WKU65Z3Q.js} +6 -6
  581. package/dist/safe-bash/command-chunks/{chunk-KGKF5NM2.js → chunk-WOXLPDO6.js} +3 -3
  582. package/dist/safe-bash/command-chunks/{chunk-Y5ADXWBQ.js → chunk-WXW665TV.js} +4 -4
  583. package/dist/safe-bash/command-chunks/{chunk-FWCUEZ3K.js → chunk-WYBCSJFG.js} +3 -3
  584. package/dist/safe-bash/command-chunks/{chunk-BXU5Y7I5.js → chunk-XI2LETBJ.js} +3 -3
  585. package/dist/safe-bash/command-chunks/{chunk-LNLACEAN.js → chunk-Y3ZRIZL7.js} +3 -3
@@ -402,16 +402,23 @@ var HtmlTokenizer = class {
402
402
  }
403
403
  };
404
404
 
405
- // packages/safe-bash-command-htmlq/src/streaming-tokenizer.ts
406
- var StreamingHtmlTokenizer = class {
407
- constructor(source, budget) {
405
+ // packages/safe-bash-command-htmlq/src/token-framer.ts
406
+ var HtmlTokenFramer = class {
407
+ constructor(source, budget, createFrame, decode2) {
408
408
  this.budget = budget;
409
+ this.createFrame = createFrame;
410
+ this.decode = decode2;
409
411
  this.input = source[Symbol.asyncIterator]();
410
412
  }
411
413
  budget;
414
+ createFrame;
415
+ decode;
412
416
  buffer = "";
413
417
  ended = false;
414
418
  input;
419
+ get residentInputUnits() {
420
+ return this.buffer.length;
421
+ }
415
422
  async peek(length = 1) {
416
423
  while (!this.ended && this.buffer.length < length) {
417
424
  const next = await this.input.next();
@@ -426,20 +433,23 @@ var StreamingHtmlTokenizer = class {
426
433
  }
427
434
  async next(raw, foreign = false) {
428
435
  if (!await this.peek()) return void 0;
429
- let frame = "";
436
+ const frame = this.createFrame();
437
+ let size = 0;
430
438
  const take = async (length = 1) => {
431
439
  const value = await this.peek(length);
432
- this.budget.bound("tokenBytes", (frame.length + value.length) * 2);
433
- frame += value;
440
+ this.budget.bound("tokenBytes", (size + value.length) * 2);
441
+ await frame.write(value);
442
+ size += value.length;
434
443
  this.buffer = this.buffer.slice(value.length);
435
444
  };
436
445
  const until = async (delimiter2) => {
437
- while (await this.peek()) {
438
- if (await this.peek(delimiter2.length) === delimiter2) {
439
- await take(delimiter2.length);
446
+ while (await this.peek(delimiter2.length)) {
447
+ const at = this.buffer.indexOf(delimiter2);
448
+ if (at >= 0) {
449
+ await take(at + delimiter2.length);
440
450
  break;
441
451
  }
442
- await take();
452
+ await take(Math.max(1, this.buffer.length - delimiter2.length + 1));
443
453
  }
444
454
  };
445
455
  if (raw) {
@@ -487,7 +497,7 @@ var StreamingHtmlTokenizer = class {
487
497
  }
488
498
  await take();
489
499
  }
490
- if (frame) return new HtmlTokenizer(frame, this.budget).next(raw, foreign);
500
+ if (size) return this.decode(await frame.finish(), raw, foreign);
491
501
  }
492
502
  if (await this.peek() !== "<") {
493
503
  while (await this.peek() && this.buffer[0] !== "<") {
@@ -501,6 +511,13 @@ var StreamingHtmlTokenizer = class {
501
511
  await take(4);
502
512
  let state = "start";
503
513
  while (await this.peek()) {
514
+ if (state === "data") {
515
+ const end = this.buffer.indexOf("-");
516
+ if (end !== 0) {
517
+ await take(end < 0 ? this.buffer.length : end);
518
+ continue;
519
+ }
520
+ }
504
521
  const c = await this.peek();
505
522
  await take();
506
523
  if (state === "start" || state === "startDash") {
@@ -528,14 +545,32 @@ var StreamingHtmlTokenizer = class {
528
545
  if (!asciiLetter(first)) {
529
546
  if (closing || first === "!" || first === "?") await until(">");
530
547
  } else {
531
- while (await this.peek() && !delimiter(await this.peek())) await take();
548
+ while (await this.peek() && !delimiter(await this.peek())) {
549
+ let end = 0;
550
+ while (end < this.buffer.length && !delimiter(this.buffer[end])) end++;
551
+ await take(end);
552
+ }
532
553
  let state = "before";
533
554
  let quote = "";
534
555
  while (await this.peek()) {
535
556
  const c = await this.peek();
536
557
  if (state === "quoted") {
537
- await take();
538
- if (c === quote) state = "before";
558
+ const end = this.buffer.indexOf(quote);
559
+ await take(end < 0 ? this.buffer.length : end + 1);
560
+ if (end >= 0) state = "before";
561
+ continue;
562
+ }
563
+ if (state === "name" || state === "unquoted") {
564
+ let end = 0;
565
+ while (end < this.buffer.length && !(0, entities_exports.htmlSpace)(this.buffer[end]) && this.buffer[end] !== ">" && (state === "unquoted" || this.buffer[end] !== "=" && this.buffer[end] !== "/")) end++;
566
+ if (end) {
567
+ await take(end);
568
+ continue;
569
+ }
570
+ } else if ((0, entities_exports.htmlSpace)(c) || state === "before" && c === "/") {
571
+ let end = 0;
572
+ while (end < this.buffer.length && ((0, entities_exports.htmlSpace)(this.buffer[end]) || state === "before" && this.buffer[end] === "/")) end++;
573
+ await take(end);
539
574
  continue;
540
575
  }
541
576
  if (c === ">") {
@@ -572,7 +607,7 @@ var StreamingHtmlTokenizer = class {
572
607
  }
573
608
  }
574
609
  }
575
- return new HtmlTokenizer(frame, this.budget).next(void 0, foreign);
610
+ return this.decode(await frame.finish(), void 0, foreign);
576
611
  }
577
612
  };
578
613
  function delimiter(c) {
@@ -582,6 +617,20 @@ function asciiLetter(c) {
582
617
  return c >= "A" && c <= "Z" || c >= "a" && c <= "z";
583
618
  }
584
619
 
620
+ // packages/safe-bash-command-htmlq/src/streaming-tokenizer.ts
621
+ var StreamingHtmlTokenizer = class extends HtmlTokenFramer {
622
+ constructor(source, budget) {
623
+ super(source, budget, () => {
624
+ let value = "";
625
+ return { write(chunk) {
626
+ value += chunk;
627
+ }, finish() {
628
+ return value;
629
+ } };
630
+ }, (frame, raw, foreign) => new HtmlTokenizer(frame, budget).next(raw, foreign));
631
+ }
632
+ };
633
+
585
634
  // packages/safe-bash-command-htmlq/src/tree-rules.ts
586
635
  var formatting = /* @__PURE__ */ new Set([
587
636
  "a",
@@ -2718,6 +2767,10 @@ var DocumentStore = class {
2718
2767
  }
2719
2768
  storage;
2720
2769
  cooperate;
2770
+ mutations = 0;
2771
+ get revision() {
2772
+ return this.mutations;
2773
+ }
2721
2774
  nodes = /* @__PURE__ */ new Map();
2722
2775
  get residentNodes() {
2723
2776
  return this.nodes.size;
@@ -2756,6 +2809,7 @@ var DocumentStore = class {
2756
2809
  view.setFloat64(8, namespaces.indexOf(node.namespace), true);
2757
2810
  for (const [index, field] of fields.entries()) view.setFloat64(16 + index * 8, node[field], true);
2758
2811
  this.nodes.delete(id);
2812
+ this.mutations++;
2759
2813
  await this.storage.write(id, bytes);
2760
2814
  this.retain(node);
2761
2815
  }
@@ -2818,6 +2872,13 @@ var DocumentStore = class {
2818
2872
  id = next;
2819
2873
  }
2820
2874
  }
2875
+ async patchAttribute(id, name, namespace) {
2876
+ const bytes = new Uint8Array(8), view = new DataView(bytes.buffer);
2877
+ view.setFloat64(0, name, true);
2878
+ await this.storage.write(id + 8, bytes);
2879
+ view.setFloat64(0, attributeNamespaces.indexOf(namespace), true);
2880
+ await this.storage.write(id + 24, bytes);
2881
+ }
2821
2882
  async replaceAttribute(id, value) {
2822
2883
  const bytes = new Uint8Array(8);
2823
2884
  new DataView(bytes.buffer).setFloat64(0, value, true);
@@ -2916,132 +2977,808 @@ var StoredSequence = class {
2916
2977
  }
2917
2978
  };
2918
2979
 
2919
- // packages/safe-bash-command-htmlq/src/stored-parser.ts
2920
- function allSpace2(value) {
2921
- for (const c of value)
2922
- if (!(0, entities_exports.htmlSpace)(c))
2923
- return false;
2924
- return true;
2980
+ // packages/safe-bash-command-htmlq/src/stored-tokenizer.ts
2981
+ import { IntegerTable as IntegerTable2 } from "@poe-platform/safe-fs/storage";
2982
+
2983
+ // packages/safe-bash-command-htmlq/src/entity-data.ts
2984
+ var entity_data_exports = {};
2985
+ __reExport(entity_data_exports, entity_data_star);
2986
+ import * as entity_data_star from "../safe-bash-markdown-engine/entity-data.js";
2987
+
2988
+ // packages/safe-bash-command-htmlq/src/stored-selectors.ts
2989
+ import { IntegerTable } from "@poe-platform/safe-fs/storage";
2990
+ function lower(value) {
2991
+ let result = "";
2992
+ for (const c of value) result += c >= "A" && c <= "Z" ? String.fromCharCode(c.charCodeAt(0) + 32) : c;
2993
+ return result;
2925
2994
  }
2926
- async function parseStoredHtml(source, tree, strings, storage, options) {
2927
- const budget = new HtmlBudget(options);
2928
- async function* normalized() {
2929
- let first = true, carriage = false;
2930
- for await (const original of decodedHtml(source, options)) {
2931
- let result2 = "";
2932
- for (const c of original) {
2933
- budget.charge("work", 1);
2934
- if (first) {
2935
- first = false;
2936
- if (c === "\uFEFF")
2937
- continue;
2995
+ var StoredQueries = class {
2996
+ constructor(tree, text, storage, budget) {
2997
+ this.tree = tree;
2998
+ this.text = text;
2999
+ this.storage = storage;
3000
+ this.budget = budget;
3001
+ this.pending = new StoredSequence(storage);
3002
+ this.ranks = new IntegerTable(storage, 64);
3003
+ this.rankParents = new IntegerTable(storage, 64);
3004
+ }
3005
+ tree;
3006
+ text;
3007
+ storage;
3008
+ budget;
3009
+ pending;
3010
+ revision = -1;
3011
+ ranks;
3012
+ rankParents;
3013
+ async literal(root, expected, insensitive = false, prefix = false) {
3014
+ const length = (await this.text.info(root)).length;
3015
+ this.budget.charge("work", length + expected.length);
3016
+ if (prefix ? length < expected.length : length !== expected.length) return false;
3017
+ let at = 0;
3018
+ if (insensitive) expected = lower(expected);
3019
+ for await (const original of this.text.chunks(root)) {
3020
+ const chunk = insensitive ? lower(original) : original;
3021
+ for (let i = 0; i < chunk.length && at < expected.length; i++, at++) if (chunk[i] !== expected[at]) return false;
3022
+ if (at === expected.length) return true;
3023
+ }
3024
+ return at === expected.length;
3025
+ }
3026
+ async equal(left, right) {
3027
+ if (left === right) return true;
3028
+ if ((await this.text.info(left)).length !== (await this.text.info(right)).length) return false;
3029
+ const a = this.text.chunks(left), b = this.text.chunks(right);
3030
+ let x = "", y = "", ax = 0, by = 0;
3031
+ try {
3032
+ for (; ; ) {
3033
+ if (ax === x.length) {
3034
+ x = (await a.next()).value ?? "";
3035
+ ax = 0;
2938
3036
  }
2939
- if (carriage && c === "\n") {
2940
- carriage = false;
2941
- continue;
3037
+ if (by === y.length) {
3038
+ y = (await b.next()).value ?? "";
3039
+ by = 0;
2942
3040
  }
2943
- carriage = c === "\r";
2944
- result2 += carriage ? "\n" : c;
3041
+ if (!x || !y) return x === y;
3042
+ const length = Math.min(x.length - ax, y.length - by);
3043
+ this.budget.charge("work", length);
3044
+ if (x.slice(ax, ax + length) !== y.slice(by, by + length)) return false;
3045
+ ax += length;
3046
+ by += length;
2945
3047
  }
2946
- yield result2;
3048
+ } finally {
3049
+ await a.return(void 0);
3050
+ await b.return(void 0);
2947
3051
  }
2948
3052
  }
2949
- const tokenizer = new StreamingHtmlTokenizer(normalized(), budget);
2950
- let result = 0, failure;
2951
- try {
2952
- result = await buildStoredTree(tree, strings, storage, tokenizer, budget);
2953
- } catch (error) {
2954
- failure = { error };
3053
+ async attribute(node, name) {
3054
+ this.budget.charge("work", name.length);
3055
+ this.budget.charge("retainedBytes", name.length * 2);
3056
+ const expected = node.namespace === "html" ? lower(name) : name;
3057
+ for await (const a of this.tree.attributes(node.id)) {
3058
+ this.budget.charge("work", 1);
3059
+ if (a.namespace === "none" && await this.literal(a.name, expected)) return a.value;
3060
+ }
3061
+ return void 0;
2955
3062
  }
2956
- try {
2957
- await tokenizer.close();
2958
- } catch (error) {
2959
- if (failure)
2960
- throw new AggregateError([failure.error, error], "HTML parsing and input cleanup failed");
2961
- throw error;
3063
+ async word(root, expected, insensitive = false) {
3064
+ if (!expected) return false;
3065
+ for (const c of expected) if (cssSpace(c)) return false;
3066
+ if (insensitive) expected = lower(expected);
3067
+ let at = 0, matching = true;
3068
+ for await (const original of this.text.chunks(root)) {
3069
+ const chunk = insensitive ? lower(original) : original;
3070
+ this.budget.charge("work", chunk.length);
3071
+ for (let i = 0; i < chunk.length; i++) {
3072
+ const c = chunk[i];
3073
+ if (cssSpace(c)) {
3074
+ if (matching && at === expected.length) return true;
3075
+ at = 0;
3076
+ matching = true;
3077
+ } else {
3078
+ if (c !== expected[at]) matching = false;
3079
+ at++;
3080
+ }
3081
+ }
3082
+ }
3083
+ return matching && at === expected.length;
2962
3084
  }
2963
- if (failure)
2964
- throw failure.error;
2965
- return result;
2966
- }
2967
- async function buildStoredTree(tree, strings, storage, tokenizer, budget) {
2968
- const labels = /* @__PURE__ */ new Map();
2969
- const names = /* @__PURE__ */ new Map();
2970
- const value = async (id) => {
2971
- const cached = labels.get(id);
2972
- if (cached !== void 0) return cached;
2973
- let value2 = "";
2974
- for await (const chunk of strings.chunks(id)) value2 += chunk;
2975
- if (value2.length <= 64) {
2976
- if (labels.size === 256) labels.delete(labels.keys().next().value);
2977
- labels.set(id, value2);
3085
+ async contains(root, expected, insensitive) {
3086
+ if (!expected) return false;
3087
+ if (insensitive) expected = lower(expected);
3088
+ let tail = "";
3089
+ for await (const original of this.text.chunks(root)) {
3090
+ const chunk = tail + (insensitive ? lower(original) : original);
3091
+ this.budget.charge("work", chunk.length);
3092
+ if (chunk.includes(expected)) return true;
3093
+ tail = expected.length === 1 ? "" : chunk.slice(-(expected.length - 1));
2978
3094
  }
2979
- return value2;
2980
- };
2981
- const nameRef = async (name) => {
2982
- const cached = names.get(name);
2983
- if (cached !== void 0) return cached;
2984
- const id = await strings.from(name);
2985
- if (name.length <= 64) {
2986
- if (names.size === 256) names.delete(names.keys().next().value);
2987
- names.set(name, id);
2988
- if (labels.size === 256) labels.delete(labels.keys().next().value);
2989
- labels.set(id, name);
3095
+ return false;
3096
+ }
3097
+ /** Build sibling ordinals once per parent; type totals are shared stored
3098
+ * counters. Mutation invalidates indexes, while both resident caches stay fixed. */
3099
+ async rank(node, typed) {
3100
+ if (!node.parent) return [0, 0];
3101
+ if (this.revision !== this.tree.revision) {
3102
+ this.ranks = new IntegerTable(this.storage, 64);
3103
+ this.rankParents = new IntegerTable(this.storage, 64);
3104
+ this.revision = this.tree.revision;
3105
+ }
3106
+ const flag = BigInt(Number(typed)), parentKey = BigInt(node.parent) * 2n + flag;
3107
+ let total = await this.rankParents.get(parentKey);
3108
+ if (total === void 0) {
3109
+ let count2 = 0;
3110
+ const families = new IntegerTable(this.storage, 64);
3111
+ for await (const id of this.tree.children(node.parent)) {
3112
+ this.budget.charge("work", 1);
3113
+ const child = await this.tree.read(id);
3114
+ if (child.kind !== "element") continue;
3115
+ count2++;
3116
+ let position2 = count2;
3117
+ if (typed) {
3118
+ let hash = 2166136261;
3119
+ for await (const chunk of this.text.chunks(child.name)) {
3120
+ this.budget.charge("work", chunk.length);
3121
+ for (let i = 0; i < chunk.length; i++) hash = Math.imul(hash ^ chunk.charCodeAt(i), 16777619) >>> 0;
3122
+ }
3123
+ const key = BigInt(hash) * 4n + BigInt(child.namespace === "html" ? 0 : child.namespace === "svg" ? 1 : 2);
3124
+ const first = Number(await families.get(key) ?? 0n);
3125
+ let counter = first, ordinal = 1;
3126
+ while (counter) {
3127
+ const bytes3 = await this.storage.read(counter, 24), view3 = new DataView(bytes3.buffer, bytes3.byteOffset, bytes3.byteLength);
3128
+ if (await this.equal(child.name, view3.getFloat64(8, true))) {
3129
+ ordinal = view3.getFloat64(16, true) + 1;
3130
+ break;
3131
+ }
3132
+ counter = view3.getFloat64(0, true);
3133
+ }
3134
+ if (!counter) {
3135
+ const bytes3 = new Uint8Array(24), view3 = new DataView(bytes3.buffer);
3136
+ view3.setFloat64(0, first, true);
3137
+ view3.setFloat64(8, child.name, true);
3138
+ view3.setFloat64(16, 1, true);
3139
+ counter = await this.storage.append(bytes3);
3140
+ await families.set(key, BigInt(counter));
3141
+ } else {
3142
+ const bytes3 = new Uint8Array(8);
3143
+ new DataView(bytes3.buffer).setFloat64(0, ordinal, true);
3144
+ await this.storage.write(counter + 16, bytes3);
3145
+ }
3146
+ const bytes2 = new Uint8Array(16), view2 = new DataView(bytes2.buffer);
3147
+ view2.setFloat64(0, ordinal, true);
3148
+ view2.setFloat64(8, counter + 16, true);
3149
+ position2 = await this.storage.append(bytes2);
3150
+ }
3151
+ this.budget.charge("retainedBytes", typed ? 48 : 16);
3152
+ await this.ranks.set(BigInt(id) * 2n + flag, BigInt(position2));
3153
+ }
3154
+ total = BigInt(count2);
3155
+ await this.rankParents.set(parentKey, total);
3156
+ }
3157
+ const position = await this.ranks.get(BigInt(node.id) * 2n + flag);
3158
+ if (position === void 0) return [0, 0];
3159
+ if (!typed) return [Number(position), Number(total)];
3160
+ const bytes = await this.storage.read(Number(position), 16), view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
3161
+ const count = await this.storage.read(view.getFloat64(8, true), 8);
3162
+ return [view.getFloat64(0, true), new DataView(count.buffer, count.byteOffset, count.byteLength).getFloat64(0, true)];
3163
+ }
3164
+ async previous(id) {
3165
+ let n = (await this.tree.read(id)).previous;
3166
+ while (n) {
3167
+ const node = await this.tree.read(n);
3168
+ if (node.kind === "element") return n;
3169
+ this.budget.charge("work", 1);
3170
+ n = node.previous;
2990
3171
  }
2991
- return id;
2992
- };
2993
- const meta = async (id) => {
2994
- const node = await tree.read(id);
2995
- return { ...node, name: await value(node.name) };
2996
- };
2997
- const make = async (kind, name = "", data = "", namespace = "html") => {
2998
- budget.charge("nodes", 1);
2999
- budget.charge("retainedBytes", 128 + (name.length + data.length) * 2);
3000
- return tree.create(kind, { name: await nameRef(name), data: await strings.from(data), namespace });
3001
- };
3002
- const append = async (parent, node, before = 0) => {
3003
- const previous2 = (await tree.read(node)).parent;
3004
- budget.charge("work", (previous2 ? (await tree.read(previous2)).childCount : 0) + (before ? (await tree.read(parent)).childCount : 1));
3005
- await tree.attach(parent, node, before);
3006
- };
3007
- const document = await make("document"), html = await make("element", "html"), head = await make("element", "head"), body = await make("element", "body");
3008
- await append(document, html);
3009
- await append(html, head);
3010
- await append(html, body);
3011
- const stack = new StoredSequence(storage), active = new StoredSequence(storage);
3012
- await stack.push(html);
3013
- let form = 0;
3014
- let mode = "beforeHead";
3015
- const current = async () => await stack.get(stack.length - 1);
3016
- const target = async (node) => {
3017
- node ??= await current();
3018
- return (await tree.read(node)).templateContents || node;
3019
- };
3020
- const push = async (node) => {
3021
- budget.bound("depth", stack.length + 1);
3022
- await stack.push(node);
3023
- };
3024
- const find = async (name) => {
3025
- for (let i = stack.length - 1; i >= 0; i--) {
3026
- budget.charge("work", 1);
3027
- if ((await meta(await stack.get(i))).name.toLowerCase() === name)
3028
- return i;
3172
+ return 0;
3173
+ }
3174
+ async test(node, test) {
3175
+ const budget = this.budget;
3176
+ budget.charge("work", 1);
3177
+ if (test.kind === "type") {
3178
+ budget.charge("retainedBytes", test.value.length * 2);
3179
+ return test.namespace !== "none" && (test.value === "*" || await this.literal(node.name, node.namespace === "html" ? lower(test.value) : test.value));
3029
3180
  }
3030
- return -1;
3031
- };
3032
- const pop = async (name) => {
3033
- const i = await find(name);
3034
- if (i > 0)
3035
- await stack.truncate(i);
3036
- };
3037
- const inScope = async (names2, extra = []) => {
3038
- for (let i = stack.length - 1; i >= 0; i--) {
3039
- budget.charge("work", 1);
3040
- const node = await meta(await stack.get(i));
3041
- if (node.namespace === "html" && names2.includes(node.name))
3042
- return i;
3043
- if (node.namespace === "html" && (htmlScopeBarriers.has(node.name) || extra.includes(node.name)) || node.namespace === "mathml" && mathmlScopeBarriers.has(node.name) || node.namespace === "svg" && svgScopeBarriers.has(node.name))
3044
- return -1;
3181
+ if (test.kind === "id") {
3182
+ const value = await this.attribute(node, "id");
3183
+ return value !== void 0 && this.literal(value, test.value);
3184
+ }
3185
+ if (test.kind === "class") return this.word(await this.attribute(node, "class") ?? 0, test.value);
3186
+ if (test.kind === "attribute") {
3187
+ const value = await this.attribute(node, test.value), expected = test.expected;
3188
+ if (value === void 0) return false;
3189
+ switch (test.operator) {
3190
+ case "":
3191
+ return true;
3192
+ case "=":
3193
+ return this.literal(value, expected, test.insensitive);
3194
+ case "^=":
3195
+ return !!expected && this.literal(value, expected, test.insensitive, true);
3196
+ case "$=": {
3197
+ const length = (await this.text.info(value)).length;
3198
+ return !!expected && length >= expected.length && this.literal(await this.text.slice(value, length - expected.length), expected, test.insensitive);
3199
+ }
3200
+ case "*=":
3201
+ return this.contains(value, expected, test.insensitive);
3202
+ case "|=":
3203
+ return await this.literal(value, expected, test.insensitive) || this.literal(value, expected + "-", test.insensitive, true);
3204
+ case "~=":
3205
+ return this.word(value, expected, test.insensitive);
3206
+ default:
3207
+ return false;
3208
+ }
3209
+ }
3210
+ if (test.kind !== "pseudo") return false;
3211
+ const p = test.value;
3212
+ if (p === "not") return !await this.matches(node.id, test.negated);
3213
+ if (p === "root" || p === "scope") return !!node.parent && (await this.tree.read(node.parent)).kind === "document";
3214
+ if (p === "any-link" || p === "link") return node.namespace === "html" && (await this.literal(node.name, "a") || await this.literal(node.name, "area") || await this.literal(node.name, "link")) && await this.attribute(node, "href") !== void 0;
3215
+ if (p === "empty") {
3216
+ for await (const child of this.tree.children(node.id)) {
3217
+ budget.charge("work", 1);
3218
+ const n = await this.tree.read(child);
3219
+ if (n.kind === "element" || n.kind === "text" && (await this.text.info(n.data)).length > 0) return false;
3220
+ }
3221
+ return true;
3222
+ }
3223
+ if (["visited", "active", "focus", "hover", "enabled", "disabled", "checked", "indeterminate"].includes(p)) return false;
3224
+ if (!p.includes("of-type") && (p.startsWith("first-") || p.startsWith("last-") || p.startsWith("only-"))) {
3225
+ if (!node.parent) return false;
3226
+ const sibling = async (direction) => {
3227
+ for (let id = node[direction]; id; ) {
3228
+ budget.charge("work", 1);
3229
+ const other = await this.tree.read(id);
3230
+ if (other.kind === "element") return true;
3231
+ id = other[direction];
3232
+ }
3233
+ return false;
3234
+ };
3235
+ if (p.startsWith("first-")) return !await sibling("previous");
3236
+ if (p.startsWith("last-")) return !await sibling("next");
3237
+ return !await sibling("previous") && !await sibling("next");
3238
+ }
3239
+ const [ordinal, count] = await this.rank(node, p.includes("of-type"));
3240
+ let index = ordinal;
3241
+ if (!index) return false;
3242
+ if (p.startsWith("first-")) return index === 1;
3243
+ if (p.startsWith("last-")) return index === count;
3244
+ if (p.startsWith("only-")) return count === 1;
3245
+ if (p.includes("last")) index = count - index + 1;
3246
+ const delta = index - test.b;
3247
+ return test.a === 0 ? delta === 0 : delta / test.a >= 0 && delta % test.a === 0;
3248
+ }
3249
+ async matches(id, program) {
3250
+ const marker = this.pending.length;
3251
+ const push = async (node, at, depth, axis) => {
3252
+ await this.pending.push(node);
3253
+ await this.pending.push(at);
3254
+ await this.pending.push(depth);
3255
+ await this.pending.push(axis);
3256
+ };
3257
+ try {
3258
+ for (const parts of program) {
3259
+ await push(id, parts.length - 1, 0, 0);
3260
+ while (this.pending.length > marker) {
3261
+ const axis = await this.pending.pop(), depth = await this.pending.pop(), at = await this.pending.pop();
3262
+ const node = await this.tree.read(await this.pending.pop());
3263
+ if (axis < 0) {
3264
+ const next2 = axis === -2 ? await this.previous(node.id) : node.parent;
3265
+ if (next2) await push(next2, at, depth, -axis);
3266
+ continue;
3267
+ }
3268
+ if (axis > 0) await push(node.id, at, depth, -axis);
3269
+ if (axis === 1) this.budget.charge("work", 1);
3270
+ this.budget.bound("depth", depth);
3271
+ this.budget.charge("work", 1);
3272
+ if (node.kind !== "element") continue;
3273
+ let matches = true;
3274
+ for (const test of parts[at].tests) if (!await this.test(node, test)) {
3275
+ matches = false;
3276
+ break;
3277
+ }
3278
+ if (!matches) continue;
3279
+ if (!at) return true;
3280
+ const relation = parts[at].relation;
3281
+ const next = relation === "+" || relation === "~" ? await this.previous(node.id) : node.parent;
3282
+ if (next) await push(next, at - 1, depth + 1, relation === "~" ? 2 : relation === ">" || relation === "+" ? 0 : 1);
3283
+ }
3284
+ }
3285
+ return false;
3286
+ } finally {
3287
+ await this.pending.truncate(marker);
3288
+ }
3289
+ }
3290
+ };
3291
+ function selectStoredHtml(root, selector, tree, text, storage, options) {
3292
+ const budget = new HtmlBudget(options), program = new SelectorParser(selector, budget).list();
3293
+ const query = new StoredQueries(tree, text, storage, budget);
3294
+ return (async function* () {
3295
+ let id = root, start = true, depth = 0;
3296
+ while (id) {
3297
+ budget.charge("work", 1);
3298
+ budget.bound("depth", depth);
3299
+ const node = await tree.read(id), entering = start;
3300
+ if (start) {
3301
+ if (node.first) {
3302
+ id = node.first;
3303
+ depth++;
3304
+ } else start = false;
3305
+ } else {
3306
+ if (id === root) return;
3307
+ if (node.next) {
3308
+ id = node.next;
3309
+ start = true;
3310
+ } else {
3311
+ id = node.parent;
3312
+ depth = Math.max(0, depth - 1);
3313
+ }
3314
+ }
3315
+ if (entering) {
3316
+ budget.charge("work", 1);
3317
+ if (node.kind === "element" && await query.matches(node.id, program)) yield node.id;
3318
+ }
3319
+ }
3320
+ })();
3321
+ }
3322
+
3323
+ // packages/safe-bash-command-htmlq/src/stored-tokenizer.ts
3324
+ var Cursor = class {
3325
+ constructor(source) {
3326
+ this.source = source;
3327
+ }
3328
+ source;
3329
+ buffer = "";
3330
+ ended = false;
3331
+ position = 0;
3332
+ async peek(count = 1) {
3333
+ while (!this.ended && this.buffer.length < count) {
3334
+ const next = await this.source.next();
3335
+ if (next.done) this.ended = true;
3336
+ else this.buffer += next.value;
3337
+ }
3338
+ return this.buffer.slice(0, count);
3339
+ }
3340
+ async window() {
3341
+ await this.peek();
3342
+ return this.buffer;
3343
+ }
3344
+ advance(count) {
3345
+ this.buffer = this.buffer.slice(count);
3346
+ this.position += count;
3347
+ }
3348
+ async skip(test) {
3349
+ for (; ; ) {
3350
+ const window = await this.window();
3351
+ let end = 0;
3352
+ while (end < window.length && test(window[end])) end++;
3353
+ this.advance(end);
3354
+ if (end < window.length || !window) return;
3355
+ }
3356
+ }
3357
+ };
3358
+ var StoredNames = class {
3359
+ constructor(storage, text, queries) {
3360
+ this.storage = storage;
3361
+ this.text = text;
3362
+ this.queries = queries;
3363
+ this.table = new IntegerTable2(storage, 64);
3364
+ }
3365
+ storage;
3366
+ text;
3367
+ queries;
3368
+ table;
3369
+ async add(name) {
3370
+ let hash = 2166136261;
3371
+ for await (const chunk of this.text.chunks(name)) {
3372
+ this.queries.budget.charge("work", chunk.length);
3373
+ for (let i = 0; i < chunk.length; i++) hash = Math.imul(hash ^ chunk.charCodeAt(i), 16777619) >>> 0;
3374
+ }
3375
+ const key = BigInt(hash), first = Number(await this.table.get(key) ?? 0n);
3376
+ for (let id = first; id; ) {
3377
+ const bytes2 = await this.storage.read(id, 16), view2 = new DataView(bytes2.buffer, bytes2.byteOffset, bytes2.byteLength);
3378
+ if (await this.queries.equal(name, view2.getFloat64(8, true))) return false;
3379
+ id = view2.getFloat64(0, true);
3380
+ }
3381
+ const bytes = new Uint8Array(16), view = new DataView(bytes.buffer);
3382
+ view.setFloat64(0, first, true);
3383
+ view.setFloat64(8, name, true);
3384
+ await this.table.set(key, BigInt(await this.storage.append(bytes)));
3385
+ return true;
3386
+ }
3387
+ };
3388
+ var StoredHtmlTokenizer = class extends HtmlTokenFramer {
3389
+ constructor(source, budget, tree, text, storage) {
3390
+ super(source, budget, () => text.builder(), (root, raw, foreign) => decode(root, raw, foreign, budget, tree, text, storage));
3391
+ }
3392
+ };
3393
+ async function decode(root, raw, foreign, budget, tree, text, storage) {
3394
+ const length = (await text.info(root)).length;
3395
+ budget.charge("work", length * 2);
3396
+ const cursor = new Cursor(text.chunks(root));
3397
+ const queries = new StoredQueries(tree, text, storage, budget);
3398
+ const finish = (token) => {
3399
+ budget.bound("tokenBytes", length * 2);
3400
+ budget.charge("work", length + 1);
3401
+ return token;
3402
+ };
3403
+ const transformed = async (start2, end, replacement, lower2 = false, entities = false, attribute2 = false) => {
3404
+ budget.charge("work", (end - start2) * 33);
3405
+ async function* chunks() {
3406
+ for await (const chunk of text.chunks(await text.slice(root, start2, end))) {
3407
+ const clean = chunk.replaceAll("\0", replacement);
3408
+ yield lower2 ? (0, entities_exports.asciiLower)(clean) : clean;
3409
+ }
3410
+ }
3411
+ const builder = text.builder();
3412
+ if (!entities) {
3413
+ for await (const chunk of chunks()) await builder.write(chunk);
3414
+ } else {
3415
+ const input = new Cursor(chunks());
3416
+ while (await input.peek()) {
3417
+ const window = await input.window(), amp = window.indexOf("&");
3418
+ if (amp !== 0) {
3419
+ const count = amp < 0 ? window.length : amp;
3420
+ await builder.write(window.slice(0, count));
3421
+ input.advance(count);
3422
+ continue;
3423
+ }
3424
+ const look = await input.peek(34);
3425
+ if (look[1] === "#") {
3426
+ const hex = (0, entities_exports.asciiLower)(look[2] ?? "") === "x", prefix2 = hex ? 3 : 2;
3427
+ const digit2 = (c) => {
3428
+ const n = c.charCodeAt(0);
3429
+ return n >= 48 && n <= 57 ? n - 48 : hex && n >= 65 && n <= 70 ? n - 55 : hex && n >= 97 && n <= 102 ? n - 87 : -1;
3430
+ };
3431
+ if (digit2(look[prefix2] ?? "") >= 0) {
3432
+ input.advance(prefix2);
3433
+ let n = 0;
3434
+ for (; ; ) {
3435
+ const part = await input.window();
3436
+ let at = 0;
3437
+ while (at < part.length && digit2(part[at]) >= 0) {
3438
+ n = Math.min(1114112, n * (hex ? 16 : 10) + digit2(part[at]));
3439
+ at++;
3440
+ }
3441
+ input.advance(at);
3442
+ if (!part || at < part.length) break;
3443
+ }
3444
+ if (await input.peek() === ";") input.advance(1);
3445
+ await builder.write((0, entities_exports.decodeEntities)(`&#${n};`, false));
3446
+ continue;
3447
+ }
3448
+ } else {
3449
+ let found = "";
3450
+ for (let end2 = 2; end2 <= Math.min(33, look.length); end2++) {
3451
+ const key = look.slice(1, end2);
3452
+ if (Object.hasOwn(entity_data_exports.namedEntities, key)) found = key;
3453
+ }
3454
+ const next = look[found.length + 1] ?? "", code2 = next.charCodeAt(0);
3455
+ if (found && !(attribute2 && !found.endsWith(";") && (next === "=" || code2 >= 48 && code2 <= 57 || code2 >= 65 && code2 <= 90 || code2 >= 97 && code2 <= 122))) {
3456
+ await builder.write(entity_data_exports.namedEntities[found]);
3457
+ input.advance(found.length + 1);
3458
+ continue;
3459
+ }
3460
+ }
3461
+ await builder.write("&");
3462
+ input.advance(1);
3463
+ }
3464
+ }
3465
+ return builder.finish();
3466
+ };
3467
+ const prefix = await cursor.peek(10);
3468
+ if (raw)
3469
+ return finish({ kind: "text", data: await transformed(0, length, "\uFFFD", false, raw === "title" || raw === "textarea") });
3470
+ if (!prefix.startsWith("<")) return finish({ kind: "text", data: await transformed(0, length, foreign ? "\uFFFD" : "", false, true) });
3471
+ if (foreign && prefix.startsWith("<![CDATA[")) {
3472
+ let suffix = "";
3473
+ for await (const part of text.chunks(await text.slice(root, Math.max(0, length - 3)))) suffix += part;
3474
+ return finish({ kind: "text", data: await transformed(9, suffix === "]]>" ? length - 3 : length, "\uFFFD") });
3475
+ }
3476
+ if (prefix.startsWith("<!--")) {
3477
+ cursor.advance(4);
3478
+ const builder = text.builder();
3479
+ let state = "start";
3480
+ while (await cursor.peek()) {
3481
+ if (state === "data") {
3482
+ const window = await cursor.window(), dash = window.indexOf("-");
3483
+ if (dash !== 0) {
3484
+ const count = dash < 0 ? window.length : dash;
3485
+ budget.charge("work", count);
3486
+ await builder.write(window.slice(0, count).replaceAll("\0", "\uFFFD"));
3487
+ cursor.advance(count);
3488
+ continue;
3489
+ }
3490
+ }
3491
+ const c = await cursor.peek();
3492
+ cursor.advance(1);
3493
+ budget.charge("work", 1);
3494
+ const clean = c === "\0" ? "\uFFFD" : c;
3495
+ if (state === "start") {
3496
+ if (c === "-") state = "startDash";
3497
+ else if (c === ">") break;
3498
+ else {
3499
+ await builder.write(clean);
3500
+ state = "data";
3501
+ }
3502
+ } else if (state === "startDash" || state === "dash") {
3503
+ if (c === "-") state = "end";
3504
+ else if (c === ">" && state === "startDash") break;
3505
+ else {
3506
+ await builder.write("-" + clean);
3507
+ state = "data";
3508
+ }
3509
+ } else if (state === "data") state = "dash";
3510
+ else if (state === "end") {
3511
+ if (c === ">") break;
3512
+ else if (c === "!") state = "bang";
3513
+ else if (c === "-") await builder.write("-");
3514
+ else {
3515
+ await builder.write("--" + clean);
3516
+ state = "data";
3517
+ }
3518
+ } else {
3519
+ if (c === ">") break;
3520
+ if (c === "-") {
3521
+ await builder.write("--!");
3522
+ state = "dash";
3523
+ } else {
3524
+ await builder.write("--!" + clean);
3525
+ state = "data";
3526
+ }
3527
+ }
3528
+ }
3529
+ return finish({ kind: "comment", data: await builder.finish() });
3530
+ }
3531
+ if ((0, entities_exports.asciiLower)(prefix.slice(0, 9)) === "<!doctype") {
3532
+ cursor.advance(9);
3533
+ await cursor.skip((c) => c.trim() === "");
3534
+ const start2 = cursor.position;
3535
+ let nameEnd = length, trimmedEnd = start2;
3536
+ while (await cursor.peek() && await cursor.peek() !== ">") {
3537
+ const window = await cursor.window();
3538
+ let at = 0;
3539
+ while (at < window.length && window[at] !== ">") {
3540
+ const c = window[at];
3541
+ if ((0, entities_exports.htmlSpace)(c) && nameEnd === length) nameEnd = cursor.position + at;
3542
+ if (c.trim() !== "") trimmedEnd = cursor.position + at + 1;
3543
+ at++;
3544
+ }
3545
+ budget.charge("work", at);
3546
+ cursor.advance(at);
3547
+ }
3548
+ return finish({ kind: "doctype", data: await transformed(start2, Math.min(nameEnd, trimmedEnd), "\0", true) });
3549
+ }
3550
+ cursor.advance(1);
3551
+ const closing = await cursor.peek() === "/";
3552
+ if (closing) cursor.advance(1);
3553
+ const initial = await cursor.peek(), code = initial.charCodeAt(0);
3554
+ if (closing && !initial) return finish({ kind: "text", data: await text.from("</") });
3555
+ if (closing && initial === ">") return finish({ kind: "text", data: 0 });
3556
+ if (!(code >= 65 && code <= 90 || code >= 97 && code <= 122)) {
3557
+ if (initial === "!" || initial === "?" || closing) {
3558
+ await cursor.skip((c) => c !== ">");
3559
+ return finish({ kind: "comment", data: await transformed(initial === "?" ? 1 : 2, cursor.position, "\uFFFD") });
3560
+ }
3561
+ return finish({ kind: "text", data: await text.from("<") });
3562
+ }
3563
+ const start = cursor.position;
3564
+ await cursor.skip((c) => !(0, entities_exports.htmlSpace)(c) && c !== "/" && c !== ">");
3565
+ const name = await transformed(start, cursor.position, "\uFFFD", true);
3566
+ const attributes = await tree.create("fragment"), names = new StoredNames(storage, text, queries);
3567
+ let selfClosing = false, terminated = false;
3568
+ while (await cursor.peek()) {
3569
+ await cursor.skip(entities_exports.htmlSpace);
3570
+ const look = await cursor.peek(2);
3571
+ if (look.startsWith(">")) {
3572
+ terminated = true;
3573
+ cursor.advance(1);
3574
+ break;
3575
+ }
3576
+ if (look === "/>") {
3577
+ selfClosing = true;
3578
+ terminated = true;
3579
+ cursor.advance(2);
3580
+ break;
3581
+ }
3582
+ if (look.startsWith("/")) {
3583
+ cursor.advance(1);
3584
+ continue;
3585
+ }
3586
+ const start2 = cursor.position;
3587
+ if (look.startsWith("=")) cursor.advance(1);
3588
+ await cursor.skip((c) => !(0, entities_exports.htmlSpace)(c) && c !== "=" && c !== ">" && c !== "/");
3589
+ const attr = await transformed(start2, cursor.position, "\uFFFD", true);
3590
+ await cursor.skip(entities_exports.htmlSpace);
3591
+ let value = 0;
3592
+ if (await cursor.peek() === "=") {
3593
+ cursor.advance(1);
3594
+ await cursor.skip(entities_exports.htmlSpace);
3595
+ const quote = await cursor.peek();
3596
+ if (quote === '"' || quote === "'") {
3597
+ cursor.advance(1);
3598
+ const start3 = cursor.position;
3599
+ await cursor.skip((c) => c !== quote);
3600
+ value = await transformed(start3, cursor.position, "\uFFFD", false, true, true);
3601
+ if (await cursor.peek()) cursor.advance(1);
3602
+ } else {
3603
+ const start3 = cursor.position;
3604
+ await cursor.skip((c) => !(0, entities_exports.htmlSpace)(c) && c !== ">");
3605
+ value = await transformed(start3, cursor.position, "\uFFFD", false, true, true);
3606
+ }
3607
+ }
3608
+ if (attr && !closing && await names.add(attr)) {
3609
+ budget.charge("attributes", 1);
3610
+ await tree.attribute(attributes, attr, value, "none");
3611
+ }
3612
+ if (cursor.position === start2 && await cursor.peek()) cursor.advance(1);
3613
+ }
3614
+ if (!terminated) return void 0;
3615
+ return finish({ kind: closing ? "end" : "start", name, attributes, selfClosing });
3616
+ }
3617
+
3618
+ // packages/safe-bash-command-htmlq/src/stored-name.ts
3619
+ async function lowerStoredName(text, root, budget) {
3620
+ const builder = text.builder();
3621
+ let precedingCased = false, offset = 0;
3622
+ for await (const chunk of text.chunks(root)) {
3623
+ let result = "";
3624
+ for (const c of chunk) {
3625
+ offset += c.length;
3626
+ budget.charge("work", c.length);
3627
+ let lowered = c.toLowerCase();
3628
+ if (c === "\u03A3" && precedingCased) {
3629
+ let followingCased = false;
3630
+ for await (const next of text.characters(await text.slice(root, offset))) {
3631
+ budget.charge("work", next.length);
3632
+ if (/\p{Case_Ignorable}/u.test(next)) continue;
3633
+ followingCased = /\p{Cased}/u.test(next);
3634
+ break;
3635
+ }
3636
+ if (!followingCased) lowered = "\u03C2";
3637
+ }
3638
+ result += lowered;
3639
+ if (!/\p{Case_Ignorable}/u.test(c)) precedingCased = /\p{Cased}/u.test(c);
3640
+ }
3641
+ await builder.write(result);
3642
+ }
3643
+ return builder.finish();
3644
+ }
3645
+
3646
+ // packages/safe-bash-command-htmlq/src/stored-parser.ts
3647
+ async function parseStoredHtml(source, tree, strings, storage, options) {
3648
+ const budget = new HtmlBudget(options);
3649
+ async function* normalized() {
3650
+ let first = true, carriage = false;
3651
+ for await (const original of decodedHtml(source, options)) {
3652
+ let result2 = "";
3653
+ for (const c of original) {
3654
+ budget.charge("work", 1);
3655
+ if (first) {
3656
+ first = false;
3657
+ if (c === "\uFEFF")
3658
+ continue;
3659
+ }
3660
+ if (carriage && c === "\n") {
3661
+ carriage = false;
3662
+ continue;
3663
+ }
3664
+ carriage = c === "\r";
3665
+ result2 += carriage ? "\n" : c;
3666
+ }
3667
+ yield result2;
3668
+ }
3669
+ }
3670
+ const tokenizer = new StoredHtmlTokenizer(normalized(), budget, tree, strings, storage);
3671
+ let result = 0, failure;
3672
+ try {
3673
+ result = await buildStoredTree(tree, strings, storage, tokenizer, budget);
3674
+ } catch (error) {
3675
+ failure = { error };
3676
+ }
3677
+ try {
3678
+ await tokenizer.close();
3679
+ } catch (error) {
3680
+ if (failure)
3681
+ throw new AggregateError([failure.error, error], "HTML parsing and input cleanup failed");
3682
+ throw error;
3683
+ }
3684
+ if (failure)
3685
+ throw failure.error;
3686
+ return result;
3687
+ }
3688
+ async function buildStoredTree(tree, strings, storage, tokenizer, budget) {
3689
+ const queries = new StoredQueries(tree, strings, storage, budget);
3690
+ const whitespacePrefix = async (root) => {
3691
+ let offset = 0;
3692
+ for await (const chunk of strings.chunks(root)) {
3693
+ budget.charge("work", chunk.length);
3694
+ for (const c of chunk) {
3695
+ if (!(0, entities_exports.htmlSpace)(c)) return offset;
3696
+ offset++;
3697
+ }
3698
+ }
3699
+ return offset;
3700
+ };
3701
+ const allSpace2 = async (root) => await whitespacePrefix(root) === (await strings.info(root)).length;
3702
+ const labels = /* @__PURE__ */ new Map();
3703
+ const names = /* @__PURE__ */ new Map();
3704
+ const value = async (id) => {
3705
+ const cached = labels.get(id);
3706
+ if (cached !== void 0) return cached;
3707
+ if ((await strings.info(id)).length > 64) return "";
3708
+ let value2 = "";
3709
+ for await (const chunk of strings.chunks(id)) value2 += chunk;
3710
+ if (value2.length <= 64) {
3711
+ if (labels.size === 256) labels.delete(labels.keys().next().value);
3712
+ labels.set(id, value2);
3713
+ }
3714
+ return value2;
3715
+ };
3716
+ const nameRef = async (name) => {
3717
+ const cached = names.get(name);
3718
+ if (cached !== void 0) return cached;
3719
+ const id = await strings.from(name);
3720
+ if (name.length <= 64) {
3721
+ if (names.size === 256) names.delete(names.keys().next().value);
3722
+ names.set(name, id);
3723
+ if (labels.size === 256) labels.delete(labels.keys().next().value);
3724
+ labels.set(id, name);
3725
+ }
3726
+ return id;
3727
+ };
3728
+ const meta = async (id) => {
3729
+ const node = await tree.read(id);
3730
+ return { ...node, name: await value(node.name) };
3731
+ };
3732
+ const make = async (kind, name = "", data = "", namespace = "html") => {
3733
+ budget.charge("nodes", 1);
3734
+ const nameId = typeof name === "string" ? await nameRef(name) : name;
3735
+ const dataId = typeof data === "string" ? await strings.from(data) : data;
3736
+ budget.charge("retainedBytes", 128 + ((await strings.info(nameId)).length + (await strings.info(dataId)).length) * 2);
3737
+ return tree.create(kind, { name: nameId, data: dataId, namespace });
3738
+ };
3739
+ const append = async (parent, node, before = 0) => {
3740
+ const previous2 = (await tree.read(node)).parent;
3741
+ budget.charge("work", (previous2 ? (await tree.read(previous2)).childCount : 0) + (before ? (await tree.read(parent)).childCount : 1));
3742
+ await tree.attach(parent, node, before);
3743
+ };
3744
+ const document = await make("document"), html = await make("element", "html"), head = await make("element", "head"), body = await make("element", "body");
3745
+ await append(document, html);
3746
+ await append(html, head);
3747
+ await append(html, body);
3748
+ const stack = new StoredSequence(storage), active = new StoredSequence(storage);
3749
+ await stack.push(html);
3750
+ let form = 0;
3751
+ let mode = "beforeHead";
3752
+ const current = async () => await stack.get(stack.length - 1);
3753
+ const target = async (node) => {
3754
+ node ??= await current();
3755
+ return (await tree.read(node)).templateContents || node;
3756
+ };
3757
+ const push = async (node) => {
3758
+ budget.bound("depth", stack.length + 1);
3759
+ await stack.push(node);
3760
+ };
3761
+ const find = async (name) => {
3762
+ for (let i = stack.length - 1; i >= 0; i--) {
3763
+ budget.charge("work", 1);
3764
+ if ((await meta(await stack.get(i))).name.toLowerCase() === name)
3765
+ return i;
3766
+ }
3767
+ return -1;
3768
+ };
3769
+ const pop = async (name) => {
3770
+ const i = await find(name);
3771
+ if (i > 0)
3772
+ await stack.truncate(i);
3773
+ };
3774
+ const inScope = async (names2, extra = []) => {
3775
+ for (let i = stack.length - 1; i >= 0; i--) {
3776
+ budget.charge("work", 1);
3777
+ const node = await meta(await stack.get(i));
3778
+ if (node.namespace === "html" && names2.includes(node.name))
3779
+ return i;
3780
+ if (node.namespace === "html" && (htmlScopeBarriers.has(node.name) || extra.includes(node.name)) || node.namespace === "mathml" && mathmlScopeBarriers.has(node.name) || node.namespace === "svg" && svgScopeBarriers.has(node.name))
3781
+ return -1;
3045
3782
  }
3046
3783
  return -1;
3047
3784
  };
@@ -3061,21 +3798,16 @@ async function buildStoredTree(tree, strings, storage, tokenizer, budget) {
3061
3798
  }
3062
3799
  };
3063
3800
  const setAttributes = async (node, attributes) => {
3064
- for (const a of attributes)
3065
- await tree.attribute(node, await strings.from(a.name), await strings.from(a.value), a.namespace);
3801
+ const source = await tree.read(attributes);
3802
+ await tree.patch(node, { firstAttribute: source.firstAttribute, lastAttribute: source.lastAttribute, attributeCount: source.attributeCount });
3066
3803
  };
3067
3804
  const mergeAttributes = async (node, attributes) => {
3068
- budget.charge("work", (await tree.read(node)).attributeCount + attributes.length);
3069
- for (const a of attributes) {
3070
- let exists = false;
3071
- for await (const old of tree.attributes(node))
3072
- if (await value(old.name) === a.name) {
3073
- exists = true;
3074
- break;
3075
- }
3076
- if (!exists) {
3077
- budget.charge("retainedBytes", 64 + (a.name.length + a.value.length) * 2);
3078
- await setAttributes(node, [a]);
3805
+ const names2 = new StoredNames(storage, strings, queries);
3806
+ for await (const old of tree.attributes(node)) await names2.add(old.name);
3807
+ for await (const a of tree.attributes(attributes)) {
3808
+ if (await names2.add(a.name)) {
3809
+ budget.charge("retainedBytes", 64 + ((await strings.info(a.name)).length + (await strings.info(a.value)).length) * 2);
3810
+ await tree.attribute(node, a.name, a.value, a.namespace);
3079
3811
  }
3080
3812
  }
3081
3813
  };
@@ -3201,11 +3933,11 @@ async function buildStoredTree(tree, strings, storage, tokenizer, budget) {
3201
3933
  if (!data)
3202
3934
  return;
3203
3935
  await reconstruct();
3204
- const [parent, before] = allSpace2(data) ? [await target(), void 0] : await location();
3936
+ const [parent, before] = await allSpace2(data) ? [await target(), void 0] : await location();
3205
3937
  const last = before ? (await tree.read(before)).previous : (await tree.read(parent)).last;
3206
3938
  if (last && (await tree.read(last)).kind === "text") {
3207
- budget.charge("retainedBytes", data.length * 2);
3208
- await tree.patch(last, { data: await strings.concat((await tree.read(last)).data, await strings.from(data)) });
3939
+ budget.charge("retainedBytes", (await strings.info(data)).length * 2);
3940
+ await tree.patch(last, { data: await strings.concat((await tree.read(last)).data, data) });
3209
3941
  } else
3210
3942
  await append(parent, await make("text", "", data), before);
3211
3943
  };
@@ -3239,37 +3971,30 @@ async function buildStoredTree(tree, strings, storage, tokenizer, budget) {
3239
3971
  }
3240
3972
  if (token.kind === "text") {
3241
3973
  if (mode === "beforeHead") {
3242
- if (allSpace2(token.data))
3974
+ if (await allSpace2(token.data))
3243
3975
  continue;
3244
3976
  mode = "body";
3245
3977
  await stack.push(body);
3246
3978
  }
3247
- if (mode === "head" && await current() === head && !allSpace2(token.data)) {
3979
+ if (mode === "head" && await current() === head && !await allSpace2(token.data)) {
3248
3980
  mode = "body";
3249
3981
  await stack.truncate(1);
3250
3982
  await stack.push(body);
3251
3983
  }
3252
3984
  let data = token.data;
3253
- if ((await meta(await current())).name === "colgroup" && !allSpace2(data)) {
3254
- let prefix = 0;
3255
- while ((0, entities_exports.htmlSpace)(data[prefix] ?? "")) {
3256
- budget.charge("work", 1);
3257
- prefix++;
3258
- }
3259
- if (prefix)
3260
- await text(data.slice(0, prefix));
3261
- data = data.slice(prefix);
3985
+ if ((await meta(await current())).name === "colgroup" && !await allSpace2(data)) {
3986
+ const prefix = await whitespacePrefix(data);
3987
+ if (prefix) await text(await strings.slice(data, 0, prefix));
3988
+ data = await strings.slice(data, prefix);
3262
3989
  await stack.pop();
3263
3990
  }
3264
- if (((await meta(await current())).name === "pre" || (await meta(await current())).name === "textarea" || (await meta(await current())).name === "listing") && (await tree.read(await current())).childCount === 0 && data.startsWith("\n"))
3265
- data = data.slice(1);
3266
- if ((await meta(await current())).namespace === "html" && !rawElements.has((await meta(await current())).name))
3267
- data = data.includes("\0") ? data.replaceAll("\0", "") : data;
3991
+ if (((await meta(await current())).name === "pre" || (await meta(await current())).name === "textarea" || (await meta(await current())).name === "listing") && (await tree.read(await current())).childCount === 0 && await strings.at(data, 0) === "\n")
3992
+ data = await strings.slice(data, 1);
3268
3993
  await text(data);
3269
3994
  continue;
3270
3995
  }
3271
3996
  let t = token;
3272
- const name = t.name;
3997
+ const name = await value(t.name);
3273
3998
  if ((await meta(await current())).namespace === "html" && (await meta(await current())).name === "colgroup" && name !== "col" && name !== "template" && name !== "colgroup")
3274
3999
  await stack.pop();
3275
4000
  if (t.kind === "start" && captionBreakingElements.has(name)) {
@@ -3381,7 +4106,7 @@ async function buildStoredTree(tree, strings, storage, tokenizer, budget) {
3381
4106
  } else {
3382
4107
  for (let i = stack.length - 1; i > 0; i--) {
3383
4108
  budget.charge("work", 1);
3384
- if ((await meta(await stack.get(i))).name.toLowerCase() === name) {
4109
+ if (await queries.equal(await lowerStoredName(strings, (await tree.read(await stack.get(i))).name, budget), t.name)) {
3385
4110
  await stack.truncate(i);
3386
4111
  break;
3387
4112
  }
@@ -3521,22 +4246,20 @@ async function buildStoredTree(tree, strings, storage, tokenizer, budget) {
3521
4246
  if (formatting.has(name))
3522
4247
  await reconstruct();
3523
4248
  }
3524
- const node = await make("element", ns === "svg" ? svgNames[name] ?? name : name, "", ns);
4249
+ const node = await make("element", ns === "svg" ? svgNames[name] ?? t.name : t.name, "", ns);
3525
4250
  const attributes = t.attributes;
3526
- budget.charge("retainedBytes", attributes.reduce((sum, a) => sum + 64 + (a.name.length + a.value.length) * 2, 0));
3527
- if (ns !== "html")
3528
- for (const a of attributes) {
3529
- if (ns === "svg")
3530
- a.name = svgAttributes[a.name] ?? a.name;
3531
- if (ns === "mathml" && a.name === "definitionurl")
3532
- a.name = "definitionURL";
3533
- const colon = a.name.indexOf(":");
3534
- const prefix = a.name.slice(0, colon);
3535
- if (colon > 0 && ["xml", "xmlns", "xlink"].includes(prefix))
3536
- a.namespace = prefix;
3537
- else if (a.name === "xmlns")
3538
- a.namespace = "xmlns";
4251
+ for await (const a of tree.attributes(attributes)) {
4252
+ budget.charge("retainedBytes", 64 + ((await strings.info(a.name)).length + (await strings.info(a.value)).length) * 2);
4253
+ if (ns !== "html") {
4254
+ const label = await value(a.name);
4255
+ const adjusted = ns === "svg" ? svgAttributes[label] : label === "definitionurl" ? "definitionURL" : void 0;
4256
+ let namespace = a.namespace;
4257
+ for (const prefix of ["xml", "xmlns", "xlink"])
4258
+ if (await queries.literal(a.name, prefix + ":", false, true)) namespace = prefix;
4259
+ if (label === "xmlns") namespace = "xmlns";
4260
+ await tree.patchAttribute(a.id, adjusted ? await nameRef(adjusted) : a.name, namespace);
3539
4261
  }
4262
+ }
3540
4263
  await setAttributes(node, attributes);
3541
4264
  const [parent, before] = ns === "html" && !tableAllowedElements.has(name) ? await location() : [await target(), void 0];
3542
4265
  await append(parent, node, before);
@@ -3557,256 +4280,402 @@ async function buildStoredTree(tree, strings, storage, tokenizer, budget) {
3557
4280
  return document;
3558
4281
  }
3559
4282
 
3560
- // packages/safe-bash-command-htmlq/src/stored-selectors.ts
3561
- function lower(value) {
3562
- let result = "";
3563
- for (const c of value) result += c >= "A" && c <= "Z" ? String.fromCharCode(c.charCodeAt(0) + 32) : c;
3564
- return result;
3565
- }
3566
- var StoredQueries = class {
3567
- constructor(tree, text, storage, budget) {
3568
- this.tree = tree;
4283
+ // packages/safe-bash-command-htmlq/src/stored-url.ts
4284
+ import { normalizeStoredHostname } from "../safe-bash-command-html-to-markdown/stored-destination.js";
4285
+ var ports = { ftp: "21", file: "", http: "80", https: "443", ws: "80", wss: "443" };
4286
+ var alpha = (c) => c >= "a" && c <= "z" || c >= "A" && c <= "Z";
4287
+ var digit = (c) => c >= "0" && c <= "9";
4288
+ var StoredUrls = class {
4289
+ constructor(text, storage, budget) {
3569
4290
  this.text = text;
4291
+ this.storage = storage;
3570
4292
  this.budget = budget;
3571
- this.pending = new StoredSequence(storage);
3572
4293
  }
3573
- tree;
3574
- text;
3575
- budget;
3576
- pending;
3577
- async literal(root, expected, insensitive = false, prefix = false) {
3578
- const length = (await this.text.info(root)).length;
3579
- this.budget.charge("work", length + expected.length);
3580
- if (prefix ? length < expected.length : length !== expected.length) return false;
3581
- let at = 0;
3582
- if (insensitive) expected = lower(expected);
3583
- for await (const original of this.text.chunks(root)) {
3584
- const chunk = insensitive ? lower(original) : original;
3585
- for (let i = 0; i < chunk.length && at < expected.length; i++, at++) if (chunk[i] !== expected[at]) return false;
3586
- if (at === expected.length) return true;
3587
- }
3588
- return at === expected.length;
3589
- }
3590
- async equal(left, right) {
3591
- if (left === right) return true;
3592
- if ((await this.text.info(left)).length !== (await this.text.info(right)).length) return false;
3593
- const a = this.text.chunks(left), b = this.text.chunks(right);
3594
- let x = "", y = "", ax = 0, by = 0;
4294
+ text;
4295
+ storage;
4296
+ budget;
4297
+ legacyOpaqueRelative = (() => {
3595
4298
  try {
3596
- for (; ; ) {
3597
- if (ax === x.length) {
3598
- x = (await a.next()).value ?? "";
3599
- ax = 0;
3600
- }
3601
- if (by === y.length) {
3602
- y = (await b.next()).value ?? "";
3603
- by = 0;
3604
- }
3605
- if (!x || !y) return x === y;
3606
- const length = Math.min(x.length - ax, y.length - by);
3607
- this.budget.charge("work", length);
3608
- if (x.slice(ax, ax + length) !== y.slice(by, by + length)) return false;
3609
- ax += length;
3610
- by += length;
4299
+ new URL("a#f", "z:b");
4300
+ return true;
4301
+ } catch {
4302
+ return false;
4303
+ }
4304
+ })();
4305
+ emptyParentKeepsSlash = new URL("z:/..").pathname === "/";
4306
+ async *characters(root, start = 0, end) {
4307
+ let offset = start;
4308
+ for await (const chunk of this.text.chunks(await this.text.slice(root, start, end))) {
4309
+ this.budget.charge("work", chunk.length);
4310
+ for (const c of chunk) {
4311
+ yield [c, offset];
4312
+ offset += c.length;
3611
4313
  }
3612
- } finally {
3613
- await a.return(void 0);
3614
- await b.return(void 0);
3615
4314
  }
3616
4315
  }
3617
- async attribute(node, name) {
3618
- this.budget.charge("work", name.length);
3619
- this.budget.charge("retainedBytes", name.length * 2);
3620
- const expected = node.namespace === "html" ? lower(name) : name;
3621
- for await (const a of this.tree.attributes(node.id)) {
3622
- this.budget.charge("work", 1);
3623
- if (a.namespace === "none" && await this.literal(a.name, expected)) return a.value;
4316
+ async small(root, maximum = 16) {
4317
+ if ((await this.text.info(root)).length > maximum) return void 0;
4318
+ let value = "";
4319
+ for await (const chunk of this.text.chunks(root)) value += chunk;
4320
+ return value;
4321
+ }
4322
+ async equal(a, b) {
4323
+ if ((await this.text.info(a)).length !== (await this.text.info(b)).length) return false;
4324
+ const right = this.text.characters(b);
4325
+ try {
4326
+ for await (const [c] of this.characters(a)) if (c !== (await right.next()).value) return false;
4327
+ return true;
4328
+ } finally {
4329
+ await right.return(void 0);
3624
4330
  }
3625
- return void 0;
3626
4331
  }
3627
- async word(root, expected, insensitive = false) {
3628
- if (!expected) return false;
3629
- for (const c of expected) if (cssSpace(c)) return false;
3630
- if (insensitive) expected = lower(expected);
3631
- let at = 0, matching = true;
3632
- for await (const original of this.text.chunks(root)) {
3633
- const chunk = insensitive ? lower(original) : original;
3634
- this.budget.charge("work", chunk.length);
3635
- for (let i = 0; i < chunk.length; i++) {
3636
- const c = chunk[i];
3637
- if (cssSpace(c)) {
3638
- if (matching && at === expected.length) return true;
3639
- at = 0;
3640
- matching = true;
3641
- } else {
3642
- if (c !== expected[at]) matching = false;
3643
- at++;
4332
+ async clean(root) {
4333
+ const builder = this.text.builder();
4334
+ let start = -1, end = 0, offset = 0;
4335
+ for await (const chunk of this.text.chunks(root)) {
4336
+ let clean = "";
4337
+ for (const c of chunk) {
4338
+ this.budget.charge("work", c.length);
4339
+ if (c === " " || c === "\n" || c === "\r") continue;
4340
+ if (c.codePointAt(0) > 32) {
4341
+ if (start < 0) start = offset;
4342
+ end = offset + c.length;
3644
4343
  }
4344
+ clean += c;
4345
+ offset += c.length;
3645
4346
  }
4347
+ await builder.write(clean);
3646
4348
  }
3647
- return matching && at === expected.length;
4349
+ const result = await builder.finish();
4350
+ return start < 0 ? 0 : this.text.slice(result, start, end);
3648
4351
  }
3649
- async contains(root, expected, insensitive) {
3650
- if (!expected) return false;
3651
- if (insensitive) expected = lower(expected);
3652
- let tail = "";
3653
- for await (const original of this.text.chunks(root)) {
3654
- const chunk = tail + (insensitive ? lower(original) : original);
4352
+ async encode(root, kind, special = false) {
4353
+ const result = this.text.builder();
4354
+ for await (const chunk of this.text.chunks(root)) {
3655
4355
  this.budget.charge("work", chunk.length);
3656
- if (chunk.includes(expected)) return true;
3657
- tail = expected.length === 1 ? "" : chunk.slice(-(expected.length - 1));
3658
- }
3659
- return false;
4356
+ const probe = new URL(special ? "http://x/" : "z://x/");
4357
+ let value;
4358
+ if (kind === "query") {
4359
+ probe.search = "?x" + chunk;
4360
+ value = probe.search.slice(2);
4361
+ } else if (kind === "fragment") {
4362
+ probe.hash = "#x" + chunk;
4363
+ value = probe.hash.slice(2);
4364
+ } else if (kind === "user") {
4365
+ probe.username = chunk;
4366
+ value = probe.username;
4367
+ } else if (kind === "password") {
4368
+ probe.password = chunk;
4369
+ value = probe.password;
4370
+ } else if (kind === "path") {
4371
+ probe.pathname = "/x" + chunk + "x";
4372
+ value = probe.pathname.slice(2, -1);
4373
+ } else if (kind === "host") value = new URL("z://x" + chunk + "x/").hostname.slice(1, -1);
4374
+ else value = new URL("z:x" + chunk + "x").pathname.slice(1, -1);
4375
+ await result.write(value);
4376
+ }
4377
+ return result.finish();
3660
4378
  }
3661
- async previous(id) {
3662
- let n = (await this.tree.read(id)).previous;
3663
- while (n) {
3664
- const node = await this.tree.read(n);
3665
- if (node.kind === "element") return n;
3666
- this.budget.charge("work", 1);
3667
- n = node.previous;
4379
+ async pathNode(id) {
4380
+ if (!id) return [0, 0];
4381
+ const bytes = await this.storage.read(id, 16), view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
4382
+ return [view.getFloat64(0, true), view.getFloat64(8, true)];
4383
+ }
4384
+ async push(url, segment) {
4385
+ const bytes = new Uint8Array(16), view = new DataView(bytes.buffer);
4386
+ view.setFloat64(0, url.path, true);
4387
+ view.setFloat64(8, segment, true);
4388
+ url.path = await this.storage.append(bytes);
4389
+ }
4390
+ async drive(root) {
4391
+ const value = await this.small(root, 2);
4392
+ return value !== void 0 && value.length === 2 && alpha(value[0]) && (value[1] === ":" || value[1] === "|");
4393
+ }
4394
+ async shorten(url) {
4395
+ const [parent, segment] = await this.pathNode(url.path);
4396
+ if (url.special === "file" && !parent && await this.drive(segment)) return;
4397
+ url.path = parent;
4398
+ }
4399
+ async firstDrive(url) {
4400
+ let id = url.path;
4401
+ while (id) {
4402
+ const [parent, segment] = await this.pathNode(id);
4403
+ if (!parent) return await this.drive(segment) ? segment : 0;
4404
+ id = parent;
3668
4405
  }
3669
4406
  return 0;
3670
4407
  }
3671
- async test(node, test) {
3672
- const budget = this.budget;
3673
- budget.charge("work", 1);
3674
- if (test.kind === "type") {
3675
- budget.charge("retainedBytes", test.value.length * 2);
3676
- return test.namespace !== "none" && (test.value === "*" || await this.literal(node.name, node.namespace === "html" ? lower(test.value) : test.value));
4408
+ async beginsDrive(root, start, end) {
4409
+ if (end - start < 2 || !await this.drive(await this.text.slice(root, start, start + 2))) return false;
4410
+ const next = await this.text.at(root, start + 2);
4411
+ return start + 2 === end || next === "/" || next === "\\";
4412
+ }
4413
+ async path(url, root, start, end) {
4414
+ let first = start;
4415
+ const segment = async (last, final) => {
4416
+ let part = await this.text.slice(root, first, last);
4417
+ const small = (await this.small(part, 6))?.toLowerCase();
4418
+ if (small === ".." || small === ".%2e" || small === "%2e." || small === "%2e%2e") {
4419
+ const hadPath = Boolean(url.path);
4420
+ await this.shorten(url);
4421
+ if (final && (url.special !== void 0 || hadPath || this.emptyParentKeepsSlash)) await this.push(url, 0);
4422
+ } else if (small === "." || small === "%2e") {
4423
+ if (final) await this.push(url, 0);
4424
+ } else {
4425
+ if (url.special === "file" && !url.path && await this.drive(part)) {
4426
+ part = await this.text.from((await this.small(part, 2))[0] + ":");
4427
+ }
4428
+ await this.push(url, await this.encode(part, "path"));
4429
+ }
4430
+ };
4431
+ for await (const [c, offset] of this.characters(root, start, end)) {
4432
+ if (c === "/" || url.special !== void 0 && c === "\\") {
4433
+ await segment(offset, false);
4434
+ first = offset + 1;
4435
+ }
3677
4436
  }
3678
- if (test.kind === "id") {
3679
- const value = await this.attribute(node, "id");
3680
- return value !== void 0 && this.literal(value, test.value);
4437
+ await segment(end, true);
4438
+ }
4439
+ async authority(url, root) {
4440
+ const length = (await this.text.info(root)).length;
4441
+ let at = -1;
4442
+ for await (const [c, offset] of this.characters(root)) if (c === "@") at = offset;
4443
+ if (at >= 0) {
4444
+ if (url.special === "file") return false;
4445
+ let colon = at;
4446
+ for await (const [c, offset] of this.characters(root, 0, at)) if (c === ":") {
4447
+ colon = offset;
4448
+ break;
4449
+ }
4450
+ url.user = await this.encode(await this.text.slice(root, 0, colon), "user");
4451
+ if (colon < at) url.password = await this.encode(await this.text.slice(root, colon + 1, at), "password");
3681
4452
  }
3682
- if (test.kind === "class") return this.word(await this.attribute(node, "class") ?? 0, test.value);
3683
- if (test.kind === "attribute") {
3684
- const value = await this.attribute(node, test.value), expected = test.expected;
3685
- if (value === void 0) return false;
3686
- switch (test.operator) {
3687
- case "":
3688
- return true;
3689
- case "=":
3690
- return this.literal(value, expected, test.insensitive);
3691
- case "^=":
3692
- return !!expected && this.literal(value, expected, test.insensitive, true);
3693
- case "$=": {
3694
- const length = (await this.text.info(value)).length;
3695
- return !!expected && length >= expected.length && this.literal(await this.text.slice(value, length - expected.length), expected, test.insensitive);
3696
- }
3697
- case "*=":
3698
- return this.contains(value, expected, test.insensitive);
3699
- case "|=":
3700
- return await this.literal(value, expected, test.insensitive) || this.literal(value, expected + "-", test.insensitive, true);
3701
- case "~=":
3702
- return this.word(value, expected, test.insensitive);
3703
- default:
3704
- return false;
4453
+ const start = at + 1;
4454
+ let end = length, bracket = false;
4455
+ for await (const [c, offset] of this.characters(root, start)) {
4456
+ if (c === "[") bracket = true;
4457
+ if (c === "]") bracket = false;
4458
+ if (c === ":" && !bracket) {
4459
+ end = offset;
4460
+ break;
3705
4461
  }
3706
4462
  }
3707
- if (test.kind !== "pseudo") return false;
3708
- const p = test.value;
3709
- if (p === "not") return !await this.matches(node.id, test.negated);
3710
- if (p === "root" || p === "scope") return !!node.parent && (await this.tree.read(node.parent)).kind === "document";
3711
- if (p === "any-link" || p === "link") return node.namespace === "html" && (await this.literal(node.name, "a") || await this.literal(node.name, "area") || await this.literal(node.name, "link")) && await this.attribute(node, "href") !== void 0;
3712
- if (p === "empty") {
3713
- for await (const child of this.tree.children(node.id)) {
3714
- budget.charge("work", 1);
3715
- const n = await this.tree.read(child);
3716
- if (n.kind === "element" || n.kind === "text" && (await this.text.info(n.data)).length > 0) return false;
4463
+ if (end < length) {
4464
+ if (url.special === "file") return false;
4465
+ let port = 0;
4466
+ for await (const [c] of this.characters(root, end + 1)) {
4467
+ if (!digit(c)) return false;
4468
+ port = port * 10 + Number(c);
4469
+ if (port > 65535) return false;
3717
4470
  }
4471
+ if (end + 1 < length && String(port) !== ports[url.special ?? ""]) url.port = String(port);
4472
+ }
4473
+ const host = await this.text.slice(root, start, end);
4474
+ if (!host) {
4475
+ if (at >= 0 || end < length || url.special !== void 0 && url.special !== "file") return false;
4476
+ url.host = 0;
3718
4477
  return true;
3719
4478
  }
3720
- if (["visited", "active", "focus", "hover", "enabled", "disabled", "checked", "indeterminate"].includes(p)) return false;
3721
- let index = 0, count = 0;
3722
- if (node.parent) for await (const child of this.tree.children(node.parent)) {
3723
- budget.charge("work", 1);
3724
- const n = await this.tree.read(child);
3725
- if (n.kind !== "element" || p.includes("of-type") && (n.namespace !== node.namespace || !await this.equal(n.name, node.name))) continue;
3726
- count++;
3727
- if (child === node.id) index = count;
4479
+ if (url.special !== void 0 || await this.text.at(host, 0) === "[") {
4480
+ url.host = await normalizeStoredHostname(this.text, host, { work: (n) => this.budget.charge("work", n), checkpoint: () => this.budget.check() });
4481
+ if (url.host === void 0) return false;
4482
+ if (url.special === "file" && await this.small(url.host) === "localhost") url.host = 0;
4483
+ } else {
4484
+ for await (const [c] of this.characters(host)) if (c === "\0" || " #/:<>?@[\\]^|".includes(c)) return false;
4485
+ url.host = await this.encode(host, "host");
3728
4486
  }
3729
- if (!index) return false;
3730
- if (p.startsWith("first-")) return index === 1;
3731
- if (p.startsWith("last-")) return index === count;
3732
- if (p.startsWith("only-")) return count === 1;
3733
- if (p.includes("last")) index = count - index + 1;
3734
- const delta = index - test.b;
3735
- return test.a === 0 ? delta === 0 : delta / test.a >= 0 && delta % test.a === 0;
4487
+ return true;
3736
4488
  }
3737
- async matches(id, program) {
3738
- const marker = this.pending.length;
3739
- const push = async (node, at, depth, axis) => {
3740
- await this.pending.push(node);
3741
- await this.pending.push(at);
3742
- await this.pending.push(depth);
3743
- await this.pending.push(axis);
3744
- };
3745
- try {
3746
- for (const parts of program) {
3747
- await push(id, parts.length - 1, 0, 0);
3748
- while (this.pending.length > marker) {
3749
- const axis = await this.pending.pop(), depth = await this.pending.pop(), at = await this.pending.pop();
3750
- const node = await this.tree.read(await this.pending.pop());
3751
- if (axis < 0) {
3752
- const next2 = axis === -2 ? await this.previous(node.id) : node.parent;
3753
- if (next2) await push(next2, at, depth, -axis);
3754
- continue;
3755
- }
3756
- if (axis > 0) await push(node.id, at, depth, -axis);
3757
- if (axis === 1) this.budget.charge("work", 1);
3758
- this.budget.bound("depth", depth);
3759
- this.budget.charge("work", 1);
3760
- if (node.kind !== "element") continue;
3761
- let matches = true;
3762
- for (const test of parts[at].tests) if (!await this.test(node, test)) {
3763
- matches = false;
3764
- break;
4489
+ async parse(original, base) {
4490
+ const root = await this.clean(original), length = (await this.text.info(root)).length;
4491
+ let fragmentAt = length, queryAt = length;
4492
+ for await (const [c, offset] of this.characters(root)) {
4493
+ if (c === "#") {
4494
+ fragmentAt = offset;
4495
+ break;
4496
+ }
4497
+ if (c === "?" && queryAt === length) queryAt = offset;
4498
+ }
4499
+ const end = Math.min(queryAt, fragmentAt);
4500
+ let schemeEnd = -1;
4501
+ for await (const [c, offset] of this.characters(root, 0, end)) {
4502
+ if (offset > 0 && c === ":") {
4503
+ schemeEnd = offset;
4504
+ break;
4505
+ }
4506
+ if (!(alpha(c) || offset > 0 && (digit(c) || c === "+" || c === "-" || c === "."))) break;
4507
+ }
4508
+ let scheme = 0, special;
4509
+ if (schemeEnd >= 0) {
4510
+ const builder = this.text.builder();
4511
+ for await (const chunk of this.text.chunks(await this.text.slice(root, 0, schemeEnd))) await builder.write(chunk.toLowerCase());
4512
+ scheme = await builder.finish();
4513
+ const name = await this.small(scheme);
4514
+ if (name !== void 0 && Object.hasOwn(ports, name)) special = name;
4515
+ } else {
4516
+ if (!base) return void 0;
4517
+ scheme = base.scheme;
4518
+ special = base.special;
4519
+ }
4520
+ let url = { scheme, special, host: void 0, user: 0, password: 0, port: "", path: 0, opaque: false, opaqueRoot: void 0, query: void 0, fragment: void 0 };
4521
+ let start = schemeEnd < 0 ? 0 : schemeEnd + 1;
4522
+ const slash = (c) => c === "/" || special !== void 0 && c === "\\";
4523
+ const first = await this.text.at(root, start), second = await this.text.at(root, start + 1);
4524
+ const sameSpecial = schemeEnd >= 0 && special !== void 0 && base && await this.equal(scheme, base.scheme);
4525
+ let relative = schemeEnd < 0 || Boolean(sameSpecial && special !== "file" && !(first === "/" && second === "/"));
4526
+ let authority = false, fileDriveAuthority = false, pathStarted = false;
4527
+ if (special === "file") {
4528
+ url.host = 0;
4529
+ if (slash(first) && slash(second)) {
4530
+ authority = true;
4531
+ start += 2;
4532
+ } else {
4533
+ if (base?.special === "file") {
4534
+ url.host = base.host;
4535
+ url.path = base.path;
4536
+ url.query = base.query;
4537
+ }
4538
+ if (slash(first)) {
4539
+ start++;
4540
+ pathStarted = true;
4541
+ const drive = base?.special === "file" ? await this.firstDrive(base) : 0;
4542
+ url.path = 0;
4543
+ if (drive && !await this.beginsDrive(root, start, end)) await this.push(url, drive);
4544
+ } else if (start < end) {
4545
+ if (await this.beginsDrive(root, start, end)) url.path = 0;
4546
+ else await this.shorten(url);
4547
+ }
4548
+ }
4549
+ relative = false;
4550
+ } else if (relative) {
4551
+ if (!base) return void 0;
4552
+ url = { ...base, fragment: void 0 };
4553
+ if (base.opaque && await this.text.at(root, 0) !== "#") {
4554
+ if (!this.legacyOpaqueRelative || fragmentAt === length || schemeEnd >= 0) return void 0;
4555
+ if (start < end) {
4556
+ url.opaque = false;
4557
+ url.path = 0;
4558
+ let part = 0;
4559
+ for await (const [c, offset] of this.characters(base.path)) if (c === "/") {
4560
+ const segment = await this.text.slice(base.path, part, offset);
4561
+ if (url.opaqueRoot === void 0) url.opaqueRoot = segment;
4562
+ else await this.push(url, segment);
4563
+ part = offset + 1;
3765
4564
  }
3766
- if (!matches) continue;
3767
- if (!at) return true;
3768
- const relation = parts[at].relation;
3769
- const next = relation === "+" || relation === "~" ? await this.previous(node.id) : node.parent;
3770
- if (next) await push(next, at - 1, depth + 1, relation === "~" ? 2 : relation === ">" || relation === "+" ? 0 : 1);
4565
+ const last = await this.text.slice(base.path, part);
4566
+ if (url.opaqueRoot === void 0) url.opaqueRoot = last;
4567
+ else await this.push(url, last);
4568
+ }
4569
+ }
4570
+ if (!url.opaque) {
4571
+ if (slash(first) && slash(second)) {
4572
+ authority = true;
4573
+ start += 2;
4574
+ url = { ...url, host: void 0, user: 0, password: 0, port: "", path: 0, opaqueRoot: void 0, query: void 0 };
4575
+ } else if (slash(first)) {
4576
+ url.path = 0;
4577
+ url.opaqueRoot = void 0;
4578
+ url.query = void 0;
4579
+ start++;
4580
+ pathStarted = true;
4581
+ } else if (start < end) {
4582
+ await this.shorten(url);
4583
+ url.query = void 0;
4584
+ }
4585
+ }
4586
+ } else if (special !== void 0) {
4587
+ authority = true;
4588
+ } else if (first === "/" && second === "/") {
4589
+ authority = true;
4590
+ start += 2;
4591
+ } else if (first === "/") {
4592
+ start++;
4593
+ pathStarted = true;
4594
+ } else url.opaque = true;
4595
+ if (authority) {
4596
+ if (special !== void 0 && special !== "file") {
4597
+ for await (const [c, offset] of this.characters(root, start, end)) {
4598
+ if (!slash(c)) break;
4599
+ start = offset + 1;
4600
+ }
4601
+ }
4602
+ let stop = end;
4603
+ for await (const [c, offset] of this.characters(root, start, end)) if (slash(c)) {
4604
+ stop = offset;
4605
+ break;
4606
+ }
4607
+ const host = await this.text.slice(root, start, stop);
4608
+ if (special === "file" && await this.drive(host)) {
4609
+ fileDriveAuthority = true;
4610
+ url.host = 0;
4611
+ } else {
4612
+ if (!await this.authority(url, host)) return void 0;
4613
+ start = stop;
4614
+ if (start < end && slash(await this.text.at(root, start))) {
4615
+ start++;
4616
+ pathStarted = true;
3771
4617
  }
3772
4618
  }
3773
- return false;
3774
- } finally {
3775
- await this.pending.truncate(marker);
3776
4619
  }
4620
+ if (url.opaque) {
4621
+ if (!relative) {
4622
+ const trailingSpace = end < length && await this.text.at(root, end - 1) === " ";
4623
+ url.path = await this.encode(await this.text.slice(root, start, trailingSpace ? end - 1 : end), "opaque");
4624
+ if (trailingSpace) url.path = await this.text.concat(url.path, await this.text.from(new URL("z:x " + (queryAt < fragmentAt ? "?q" : "#f")).pathname.slice(1)));
4625
+ }
4626
+ } else if (start < end || pathStarted || authority || !url.path && special !== void 0) {
4627
+ if (!(authority && special === void 0 && start === end && !pathStarted))
4628
+ await this.path(url, root, start, end);
4629
+ if (fileDriveAuthority) url.host = 0;
4630
+ url.query = void 0;
4631
+ }
4632
+ if (queryAt < fragmentAt) url.query = await this.encode(await this.text.slice(root, queryAt + 1, fragmentAt), "query", special !== void 0);
4633
+ if (fragmentAt < length) url.fragment = await this.encode(await this.text.slice(root, fragmentAt + 1), "fragment");
4634
+ return url;
3777
4635
  }
3778
- };
3779
- function selectStoredHtml(root, selector, tree, text, storage, options) {
3780
- const budget = new HtmlBudget(options), program = new SelectorParser(selector, budget).list();
3781
- const query = new StoredQueries(tree, text, storage, budget);
3782
- return (async function* () {
3783
- let id = root, start = true, depth = 0;
3784
- while (id) {
3785
- budget.charge("work", 1);
3786
- budget.bound("depth", depth);
3787
- const node = await tree.read(id), entering = start;
3788
- if (start) {
3789
- if (node.first) {
3790
- id = node.first;
3791
- depth++;
3792
- } else start = false;
3793
- } else {
3794
- if (id === root) return;
3795
- if (node.next) {
3796
- id = node.next;
3797
- start = true;
3798
- } else {
3799
- id = node.parent;
3800
- depth = Math.max(0, depth - 1);
4636
+ async serialize(url) {
4637
+ const result = this.text.builder();
4638
+ await result.append(url.scheme);
4639
+ await result.write(":");
4640
+ if (url.host !== void 0) {
4641
+ await result.write("//");
4642
+ if (url.user || url.password) {
4643
+ await result.append(url.user);
4644
+ if (url.password) {
4645
+ await result.write(":");
4646
+ await result.append(url.password);
3801
4647
  }
4648
+ await result.write("@");
3802
4649
  }
3803
- if (entering) {
3804
- budget.charge("work", 1);
3805
- if (node.kind === "element" && await query.matches(node.id, program)) yield node.id;
4650
+ await result.append(url.host);
4651
+ if (url.port) await result.write(":" + url.port);
4652
+ }
4653
+ if (url.opaque) await result.append(url.path);
4654
+ else {
4655
+ const segments = new StoredSequence(this.storage);
4656
+ for (let id = url.path; id; ) {
4657
+ const [parent, segment] = await this.pathNode(id);
4658
+ await segments.push(segment);
4659
+ id = parent;
4660
+ }
4661
+ if (url.opaqueRoot !== void 0) await result.append(url.opaqueRoot);
4662
+ if (url.opaqueRoot === void 0 && url.host === void 0 && segments.length > 1 && await segments.get(segments.length - 1) === 0) await result.write("/.");
4663
+ while (segments.length) {
4664
+ await result.write("/");
4665
+ await result.append(await segments.pop());
3806
4666
  }
3807
4667
  }
3808
- })();
3809
- }
4668
+ if (url.query !== void 0) {
4669
+ await result.write("?");
4670
+ await result.append(url.query);
4671
+ }
4672
+ if (url.fragment !== void 0) {
4673
+ await result.write("#");
4674
+ await result.append(url.fragment);
4675
+ }
4676
+ return result.finish();
4677
+ }
4678
+ };
3810
4679
 
3811
4680
  // packages/safe-bash-command-htmlq/src/stored-serializer.ts
3812
4681
  async function knownName(text, name) {
@@ -3919,13 +4788,6 @@ async function* serializeStoredHtml(root, tree, text, options, mode = "normalize
3919
4788
  }
3920
4789
 
3921
4790
  // packages/safe-bash-command-htmlq/src/stored-project.ts
3922
- function baseUrl2(value) {
3923
- try {
3924
- return new URL(value);
3925
- } catch {
3926
- return void 0;
3927
- }
3928
- }
3929
4791
  async function* projectStoredHtmlq(source, args, options, storage) {
3930
4792
  const budget = new HtmlBudget(options);
3931
4793
  let operations = 0, characters = 0;
@@ -3943,18 +4805,15 @@ async function* projectStoredHtmlq(source, args, options, storage) {
3943
4805
  });
3944
4806
  const document = await parseStoredHtml(source, tree, text, storage, options);
3945
4807
  const query = new StoredQueries(tree, text, storage, budget);
3946
- const string = async (id) => {
3947
- let result = "";
3948
- for await (const chunk of text.chunks(id)) result += chunk;
3949
- return result;
3950
- };
3951
- let base = baseUrl2(args.base);
4808
+ const urls = new StoredUrls(text, storage, budget);
4809
+ let base = await urls.parse(await text.from(args.base));
3952
4810
  if (args.detectBase) {
3953
4811
  for await (const first of selectStoredHtml(document, "base", tree, text, storage, options)) {
3954
- base = baseUrl2(await string(await query.attribute(await tree.read(first), "href") ?? 0)) ?? base;
4812
+ base = await urls.parse(await query.attribute(await tree.read(first), "href") ?? 0) ?? base;
3955
4813
  break;
3956
4814
  }
3957
4815
  }
4816
+ const baseHref = base ? await urls.serialize(base) : 0;
3958
4817
  const selected = selectStoredHtml(document, args.selector, tree, text, storage, options);
3959
4818
  let removal = "";
3960
4819
  if (args.removeNodes.length) {
@@ -4058,23 +4917,25 @@ async function* projectStoredHtmlq(source, args, options, storage) {
4058
4917
  if (base && node.namespace === "html" && ["a", "area", "link"].includes(await knownName(text, node.name))) {
4059
4918
  for await (const a of tree.attributes(id)) {
4060
4919
  if (a.namespace !== "none" || !await query.literal(a.name, "href")) continue;
4061
- const href = await string(a.value);
4062
- budget.charge("work", href.length + base.href.length);
4920
+ const hrefLength = (await text.info(a.value)).length;
4921
+ budget.charge("work", hrefLength + (await text.info(baseHref)).length);
4063
4922
  let value;
4064
- if (href.startsWith("////")) {
4065
- let i = 0;
4066
- while (href[i] === "/") i++;
4067
- value = href.slice(i);
4068
- } else {
4069
- try {
4070
- value = new URL(href, base).href;
4071
- } catch {
4072
- value = base.href;
4923
+ if (await query.literal(a.value, "////", false, true)) {
4924
+ let offset = 0;
4925
+ for await (const c of text.characters(a.value)) {
4926
+ budget.charge("work", 1);
4927
+ if (c !== "/") break;
4928
+ offset++;
4073
4929
  }
4930
+ value = await text.slice(a.value, offset);
4931
+ } else {
4932
+ const resolved = await urls.parse(a.value, base);
4933
+ value = resolved ? await urls.serialize(resolved) : baseHref;
4074
4934
  }
4075
- budget.charge("work", node.attributeCount + value.length);
4076
- budget.charge("retainedBytes", node.attributeCount * 64 + value.length * 2);
4077
- await tree.replaceAttribute(a.id, await text.from(value));
4935
+ const valueLength = (await text.info(value)).length;
4936
+ budget.charge("work", node.attributeCount + valueLength);
4937
+ budget.charge("retainedBytes", node.attributeCount * 64 + valueLength * 2);
4938
+ await tree.replaceAttribute(a.id, value);
4078
4939
  break;
4079
4940
  }
4080
4941
  }