@poe-platform/safe-bash 0.1.803 → 0.1.804

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 (696) hide show
  1. package/README.md +56 -31
  2. package/dist/image-ast/ast.d.ts +1 -0
  3. package/dist/image-ast/browser/ast.d.ts +1 -0
  4. package/dist/image-ast/browser/codecs/jpeg.d.ts +2 -2
  5. package/dist/image-ast/codecs/jpeg.d.ts +2 -2
  6. package/dist/image-ast/index.browser.js +692 -8364
  7. package/dist/image-ast/index.js +692 -8364
  8. package/dist/mp4-ast/codecs.d.ts +7 -2
  9. package/dist/safe-bash/chunks/{chunk-CHYGPFVM.js → chunk-22SX3F2R.js} +1 -1
  10. package/dist/safe-bash/chunks/{chunk-FBUCWVTE.js → chunk-2IVBJTBD.js} +1 -1
  11. package/dist/safe-bash/chunks/chunk-2POETUMB.js +190 -0
  12. package/dist/safe-bash/chunks/{chunk-XVOSKJE2.js → chunk-47D7WBJK.js} +1 -1
  13. package/dist/safe-bash/chunks/{chunk-VKNVHEX3.js → chunk-4ESI236Y.js} +1 -1
  14. package/dist/safe-bash/chunks/{chunk-74GHTNJA.js → chunk-4KTMKD5W.js} +1 -1
  15. package/dist/safe-bash/chunks/{chunk-55YJASTN.js → chunk-4T53AERN.js} +1 -1
  16. package/dist/safe-bash/chunks/{chunk-DQP3VHSB.js → chunk-5XIFJVOO.js} +1 -1
  17. package/dist/safe-bash/chunks/{chunk-5OHX7C2V.js → chunk-62BOHHJT.js} +1 -1
  18. package/dist/safe-bash/chunks/{chunk-HZAMGT5I.js → chunk-67WIFM3N.js} +17 -6
  19. package/dist/safe-bash/chunks/{chunk-4D4N7IU2.js → chunk-6LNFRPW5.js} +2 -2
  20. package/dist/safe-bash/chunks/{chunk-6O77NL2S.js → chunk-6SMICPI3.js} +1 -1
  21. package/dist/safe-bash/chunks/{chunk-4BSJLKNM.js → chunk-7O76UFQD.js} +1 -1
  22. package/dist/safe-bash/chunks/{chunk-PNBBUWSM.js → chunk-AW5KIT6V.js} +3488 -39
  23. package/dist/safe-bash/chunks/{chunk-JMMEIDPF.js → chunk-B2Z73HTZ.js} +52 -28
  24. package/dist/safe-bash/chunks/chunk-B3ZMOJVM.js +319 -0
  25. package/dist/safe-bash/chunks/{chunk-7ZBU7KYV.js → chunk-CFAWS3O4.js} +1 -1
  26. package/dist/safe-bash/chunks/{chunk-I5HZ4FGE.js → chunk-CL2FCTTO.js} +1 -1
  27. package/dist/safe-bash/chunks/{chunk-2LSAMQER.js → chunk-CTXNARJH.js} +1 -1
  28. package/dist/safe-bash/chunks/{chunk-TFIBK2GI.js → chunk-D5Q7NFWI.js} +1 -1
  29. package/dist/safe-bash/chunks/{chunk-OQRVVGR6.js → chunk-DSOOVZ6Q.js} +1 -1
  30. package/dist/safe-bash/chunks/{chunk-VTH3MLDU.js → chunk-DUTAG6ZD.js} +1 -1
  31. package/dist/safe-bash/chunks/{chunk-XAQMU6OY.js → chunk-EE5YGFIZ.js} +1 -1
  32. package/dist/safe-bash/chunks/{chunk-FZE4HW6G.js → chunk-EJOYT2ME.js} +1 -1
  33. package/dist/safe-bash/chunks/chunk-FAAIR6EJ.js +887 -0
  34. package/dist/safe-bash/chunks/{chunk-OV6IHKO6.js → chunk-FOB2FZR4.js} +2 -2
  35. package/dist/safe-bash/chunks/chunk-G6V4RRSQ.js +14 -0
  36. package/dist/safe-bash/chunks/{chunk-UTBUUFDM.js → chunk-GGQAGQXQ.js} +1 -1
  37. package/dist/safe-bash/chunks/{chunk-K6VCD7IY.js → chunk-HIIYIJ5G.js} +2 -4
  38. package/dist/safe-bash/chunks/{chunk-VBTDHOWC.js → chunk-IOHH2GTI.js} +4 -3
  39. package/dist/safe-bash/chunks/{chunk-CTVWDACF.js → chunk-IQW34XQT.js} +1 -1
  40. package/dist/safe-bash/chunks/{chunk-HZ7BWKQ3.js → chunk-IS572AAT.js} +1 -1
  41. package/dist/safe-bash/chunks/{chunk-AUSNDQTJ.js → chunk-JPSUHHOA.js} +1 -1
  42. package/dist/safe-bash/chunks/{chunk-ZVD5IS4V.js → chunk-KBZ4UB2O.js} +2 -2
  43. package/dist/safe-bash/chunks/{chunk-AM5ESLPH.js → chunk-KU5CVWKA.js} +1 -1
  44. package/dist/safe-bash/chunks/{chunk-RYFQ3LZG.js → chunk-LPOVNKNB.js} +173 -153
  45. package/dist/safe-bash/chunks/{chunk-46Z5E5EV.js → chunk-MBOC3LZ4.js} +1 -1
  46. package/dist/safe-bash/chunks/{chunk-6PAVEFT3.js → chunk-N4BQFD3P.js} +1 -1
  47. package/dist/safe-bash/chunks/{chunk-CS4MNM6I.js → chunk-NGKCVNWS.js} +1 -1
  48. package/dist/safe-bash/chunks/{chunk-7R5BDCG7.js → chunk-OHML2BEU.js} +1 -1
  49. package/dist/safe-bash/chunks/{chunk-C5OWC2TL.js → chunk-OQ3AGYCZ.js} +1 -1
  50. package/dist/safe-bash/chunks/{chunk-B7TAL7S5.js → chunk-PTAEWLSE.js} +0 -2
  51. package/dist/safe-bash/chunks/{chunk-LVOBFF4D.js → chunk-Q4FNLOTI.js} +1 -1
  52. package/dist/safe-bash/chunks/chunk-Q5XO3NAS.js +1036 -0
  53. package/dist/safe-bash/chunks/{chunk-GEG3BWGE.js → chunk-RHFRJIWQ.js} +1 -1
  54. package/dist/safe-bash/chunks/chunk-RUR6J33T.js +11 -0
  55. package/dist/safe-bash/chunks/{chunk-EEEWOYEG.js → chunk-S4RFUUXO.js} +839 -24
  56. package/dist/safe-bash/chunks/{chunk-RRR7AQ24.js → chunk-SD2ISU5L.js} +1 -1
  57. package/dist/safe-bash/chunks/{chunk-3NDIFSNM.js → chunk-SUJ3NTMH.js} +3 -3
  58. package/dist/safe-bash/chunks/{chunk-R3NAKOED.js → chunk-SZRUU5HS.js} +2 -2
  59. package/dist/safe-bash/chunks/{chunk-PH63PLPZ.js → chunk-TC3F4UFF.js} +1 -1
  60. package/dist/safe-bash/chunks/{chunk-3R3AANOR.js → chunk-TCKYOLUE.js} +1 -1
  61. package/dist/safe-bash/chunks/{chunk-D3ANYGMC.js → chunk-UV4X32QU.js} +1 -1
  62. package/dist/safe-bash/chunks/{chunk-E7OYNDGL.js → chunk-V7QT2RWC.js} +1 -1
  63. package/dist/safe-bash/chunks/{chunk-B7PIL77G.js → chunk-W2IYOVHK.js} +804 -1195
  64. package/dist/safe-bash/chunks/{chunk-3HQU4OJO.js → chunk-XNGVOSGI.js} +1 -1
  65. package/dist/safe-bash/chunks/{chunk-J42RIHHJ.js → chunk-XQWCQSRN.js} +1 -1
  66. package/dist/safe-bash/chunks/{chunk-A7XEHALN.js → chunk-Y7FW6GLT.js} +6 -6
  67. package/dist/safe-bash/chunks/{chunk-QGUV42T5.js → chunk-YL3GBUG4.js} +1 -1
  68. package/dist/safe-bash/chunks/chunk-YOXUCJER.js +389 -0
  69. package/dist/safe-bash/chunks/{chunk-HBCN24ZA.js → chunk-Z2AAYYJN.js} +2 -2
  70. package/dist/safe-bash/chunks/chunk-ZKYKJCZZ.js +30 -0
  71. package/dist/safe-bash/chunks/core-IE3AFIDX.js +85806 -0
  72. package/dist/safe-bash/chunks/{ffmpeg-WTC3TEFI.js → ffmpeg-YANDK6HU.js} +2 -2
  73. package/dist/safe-bash/chunks/{gh-6WU6PXL4.js → gh-4MBJ2S5V.js} +2 -2
  74. package/dist/safe-bash/chunks/{git-EFZIGJW4.js → git-2QONJNRQ.js} +2 -2
  75. package/dist/safe-bash/chunks/{imagemagick-EIEYGWPF.js → imagemagick-JLEHGYSN.js} +2 -2
  76. package/dist/safe-bash/chunks/{mmdc-ROQJT5HQ.js → mmdc-6LD7A6ND.js} +2 -2
  77. package/dist/safe-bash/chunks/{pdfimages-DW7LWXFI.js → pdfimages-RSHL7LOP.js} +2 -2
  78. package/dist/safe-bash/chunks/{pdfinfo-TIP6XLUQ.js → pdfinfo-L3SGWPNG.js} +2 -2
  79. package/dist/safe-bash/chunks/{pdftk-DMG22ITZ.js → pdftk-LFBJNU5A.js} +2 -2
  80. package/dist/safe-bash/chunks/{pdftoppm-WNDYR72T.js → pdftoppm-NXXFUIHG.js} +2 -2
  81. package/dist/safe-bash/chunks/{pdftotext-5IPZ4NI7.js → pdftotext-4IHNWT6F.js} +2 -2
  82. package/dist/safe-bash/chunks/{qpdf-TTX2DIUA.js → qpdf-ZEIREV63.js} +2 -2
  83. package/dist/safe-bash/chunks/read-builtin-A4QKAT45.js +9 -0
  84. package/dist/safe-bash/chunks/{sips-XYS46JPJ.js → sips-D5YBG2V3.js} +2 -2
  85. package/dist/safe-bash/chunks/{soffice-TU73E5KL.js → soffice-RAJU3JUT.js} +2 -2
  86. package/dist/safe-bash/chunks/source-files-3XWRRHFA.js +7 -0
  87. package/dist/safe-bash/chunks/{wkhtmltopdf-FSZ2CHGE.js → wkhtmltopdf-7UE4FORZ.js} +2 -2
  88. package/dist/safe-bash/command-chunks/{chunk-7KWZXKY6.js → chunk-26RTBV2I.js} +1 -0
  89. package/dist/safe-bash/command-chunks/{chunk-AQJ2ROJO.js → chunk-2WYNMZR2.js} +10 -8
  90. package/dist/safe-bash/command-chunks/{chunk-BDSMROQZ.js → chunk-36GFRF2N.js} +2 -1
  91. package/dist/safe-bash/command-chunks/{chunk-GC5TJZOF.js → chunk-3VIA2IA7.js} +114 -31
  92. package/dist/safe-bash/command-chunks/{chunk-NKFYQSES.js → chunk-4CTI3ZTX.js} +1 -0
  93. package/dist/safe-bash/command-chunks/{chunk-WH627NJL.js → chunk-4MYP2FX4.js} +2 -1
  94. package/dist/safe-bash/command-chunks/{chunk-ZDN7MJE6.js → chunk-4R5ADJM5.js} +11 -1
  95. package/dist/safe-bash/command-chunks/{chunk-P2N33UMN.js → chunk-5MIKM54M.js} +4 -4
  96. package/dist/safe-bash/command-chunks/{chunk-DB453IE6.js → chunk-6FZQUOSJ.js} +1 -1
  97. package/dist/safe-bash/command-chunks/{chunk-PICVQ6B5.js → chunk-6GKYHPJG.js} +1 -1
  98. package/dist/safe-bash/command-chunks/{chunk-7K6JYKPJ.js → chunk-6M2ELGEN.js} +17 -15
  99. package/dist/safe-bash/command-chunks/{chunk-PXEIT2O4.js → chunk-6UR7V3ET.js} +8 -1
  100. package/dist/safe-bash/command-chunks/{chunk-6KJ3LPI2.js → chunk-6XBS5B46.js} +26 -3
  101. package/dist/safe-bash/command-chunks/{chunk-5PWJG2UK.js → chunk-6YXLZX7L.js} +2 -2
  102. package/dist/safe-bash/command-chunks/{chunk-EK6YNAXT.js → chunk-753YOR54.js} +31 -5
  103. package/dist/safe-bash/command-chunks/{chunk-RMWQAAO5.js → chunk-7IR4NRNE.js} +2 -2
  104. package/dist/safe-bash/command-chunks/{chunk-FZTK4MFI.js → chunk-7NM73SVK.js} +8 -8
  105. package/dist/safe-bash/command-chunks/{chunk-NXEQ3ESQ.js → chunk-7QD5YY4F.js} +6 -11
  106. package/dist/safe-bash/command-chunks/{chunk-EMPU65ZK.js → chunk-A5LBSJGH.js} +1 -0
  107. package/dist/safe-bash/command-chunks/{chunk-4FEVBOL5.js → chunk-ARZMP2L2.js} +2 -2
  108. package/dist/safe-bash/command-chunks/{chunk-NKIELG7Y.js → chunk-BAKFZ477.js} +40 -19
  109. package/dist/safe-bash/command-chunks/{chunk-QRRYN2KO.js → chunk-BC7BK6R6.js} +0 -2424
  110. package/dist/safe-bash/command-chunks/{chunk-CQHP3I66.js → chunk-BOEOJS2Q.js} +1 -1
  111. package/dist/safe-bash/command-chunks/{chunk-XS72HTMA.js → chunk-BWGGLYEB.js} +5 -22
  112. package/dist/safe-bash/command-chunks/{chunk-PMBFZXTK.js → chunk-C5ZZKP7V.js} +1 -1
  113. package/dist/safe-bash/command-chunks/{chunk-LHIOAFWW.js → chunk-C7SEB6WU.js} +1 -1
  114. package/dist/safe-bash/command-chunks/{chunk-XPT2UGBF.js → chunk-CHJKFRT7.js} +1 -1
  115. package/dist/safe-bash/command-chunks/{chunk-TIOCQVUQ.js → chunk-CON26Q2O.js} +1 -1
  116. package/dist/safe-bash/command-chunks/{chunk-E55UKBIE.js → chunk-DBAT3IK2.js} +1 -1
  117. package/dist/safe-bash/command-chunks/{chunk-Z45N42QC.js → chunk-DPAYAVMS.js} +15 -1
  118. package/dist/safe-bash/command-chunks/chunk-DS3NXVUM.js +368 -0
  119. package/dist/safe-bash/command-chunks/{chunk-5ZMZ573Q.js → chunk-DSJ3VRL3.js} +16 -4
  120. package/dist/safe-bash/command-chunks/{chunk-K2GDEMEU.js → chunk-EFRCFWVR.js} +4 -4
  121. package/dist/safe-bash/command-chunks/{chunk-DZCY63VJ.js → chunk-EV6HIJ5H.js} +6 -5
  122. package/dist/safe-bash/command-chunks/{chunk-JDYXY44P.js → chunk-FJURV46Y.js} +3 -3
  123. package/dist/safe-bash/command-chunks/{chunk-TZZ4WUKH.js → chunk-FZAWGKSE.js} +6 -4
  124. package/dist/safe-bash/command-chunks/{chunk-YHFXOX6U.js → chunk-GOCFQ6XV.js} +4 -4
  125. package/dist/safe-bash/command-chunks/{chunk-QVOS4YXL.js → chunk-HH5O7DJI.js} +1 -1
  126. package/dist/safe-bash/command-chunks/{chunk-3HHCU5YU.js → chunk-HK7F5SDC.js} +13 -0
  127. package/dist/safe-bash/command-chunks/{chunk-JNZ3CVAE.js → chunk-HQBXIZC7.js} +8 -3
  128. package/dist/safe-bash/command-chunks/{chunk-V4K2JDYU.js → chunk-I63DBZXZ.js} +2 -2
  129. package/dist/safe-bash/command-chunks/{chunk-WNE7FPVR.js → chunk-I64TLTIW.js} +24 -16
  130. package/dist/safe-bash/command-chunks/{chunk-GFC2NTDG.js → chunk-ICANWOXH.js} +5 -29
  131. package/dist/safe-bash/command-chunks/{chunk-SQRQW3CT.js → chunk-IJ6LGLXM.js} +1 -1
  132. package/dist/safe-bash/command-chunks/{chunk-TGSNCQSR.js → chunk-JT4RYCA6.js} +1771 -1663
  133. package/dist/safe-bash/command-chunks/{chunk-II77KPZN.js → chunk-JWW6FYBN.js} +2 -2
  134. package/dist/safe-bash/command-chunks/{chunk-ZYXH3B66.js → chunk-LCJWKTCJ.js} +250 -203
  135. package/dist/safe-bash/command-chunks/chunk-LU4HBPP2.js +97 -0
  136. package/dist/safe-bash/command-chunks/{chunk-XJXU3VVH.js → chunk-LWOE65OE.js} +20 -5
  137. package/dist/safe-bash/command-chunks/{chunk-GMIHJYDG.js → chunk-M32HFSX7.js} +22 -6
  138. package/dist/safe-bash/command-chunks/{chunk-YG4EPFWC.js → chunk-M3NINRDU.js} +2880 -172
  139. package/dist/safe-bash/command-chunks/chunk-MQREDAL6.js +164 -0
  140. package/dist/safe-bash/command-chunks/{chunk-LWS62ISU.js → chunk-N6DIASO2.js} +1 -1
  141. package/dist/safe-bash/command-chunks/chunk-NGL7YK7O.js +188 -0
  142. package/dist/safe-bash/command-chunks/{chunk-EARHPPPJ.js → chunk-NJYHWKIL.js} +39 -9
  143. package/dist/safe-bash/command-chunks/{chunk-6JSIFWYT.js → chunk-OJQRSCBP.js} +1 -1
  144. package/dist/safe-bash/command-chunks/{chunk-OQU6UT6X.js → chunk-OV3XREFN.js} +11 -0
  145. package/dist/safe-bash/command-chunks/{chunk-MIXBO6U7.js → chunk-PTZLF456.js} +2 -2
  146. package/dist/safe-bash/command-chunks/{chunk-ALDC4XP4.js → chunk-QILLRNES.js} +34 -10
  147. package/dist/safe-bash/command-chunks/{chunk-L22T3H7L.js → chunk-QR25JLKO.js} +1 -1
  148. package/dist/safe-bash/command-chunks/{chunk-NASVPT6F.js → chunk-R7C4MGZ5.js} +17 -224
  149. package/dist/safe-bash/command-chunks/{chunk-LCF3OB7P.js → chunk-RBME3JEH.js} +1 -1
  150. package/dist/safe-bash/command-chunks/{chunk-2KG2QLJE.js → chunk-RFWGYT7G.js} +3 -0
  151. package/dist/safe-bash/command-chunks/{chunk-5TBUOBDE.js → chunk-RZMVRT26.js} +27 -13
  152. package/dist/safe-bash/command-chunks/chunk-TFR6B3WB.js +44 -0
  153. package/dist/safe-bash/command-chunks/chunk-TOH3OF3O.js +179 -0
  154. package/dist/safe-bash/command-chunks/chunk-TT4DAFBT.js +13621 -0
  155. package/dist/safe-bash/command-chunks/{chunk-LWSBAWLT.js → chunk-TXI64OAG.js} +1 -1
  156. package/dist/safe-bash/command-chunks/{chunk-GIRNFXP3.js → chunk-TZRI7BJZ.js} +45 -15
  157. package/dist/safe-bash/command-chunks/{chunk-QOKBZFFD.js → chunk-U3MMODA5.js} +2 -7
  158. package/dist/safe-bash/command-chunks/{chunk-ZYHTWNAE.js → chunk-UAW423ZL.js} +11 -11
  159. package/dist/safe-bash/command-chunks/{chunk-C5YYCQHW.js → chunk-UXEEUGOV.js} +222 -12
  160. package/dist/safe-bash/command-chunks/{chunk-GY3BWK7K.js → chunk-VOZPMJRX.js} +87 -80
  161. package/dist/safe-bash/command-chunks/{chunk-ILX2NOLF.js → chunk-WPANOB4A.js} +20 -20
  162. package/dist/safe-bash/command-chunks/{chunk-Y2WBSJG6.js → chunk-X4QZQI5Q.js} +65 -64
  163. package/dist/safe-bash/command-chunks/{chunk-HDCNKOIX.js → chunk-XGI57GCN.js} +1 -1
  164. package/dist/safe-bash/command-chunks/{chunk-5UBXNSFZ.js → chunk-XUCU7QQT.js} +1281 -1278
  165. package/dist/safe-bash/command-chunks/chunk-Y22VXJBD.js +296 -0
  166. package/dist/safe-bash/command-chunks/{chunk-WVHONVZ4.js → chunk-YMFUUPDX.js} +5 -3
  167. package/dist/safe-bash/command-chunks/{chunk-IR2BY7EL.js → chunk-YYGIBXFZ.js} +2 -2
  168. package/dist/safe-bash/command-chunks/{chunk-MSFXC3OC.js → chunk-Z4FO6OHE.js} +2 -2
  169. package/dist/safe-bash/command-chunks/{chunk-WWIBP2ET.js → chunk-Z5ZZVDUD.js} +143 -22
  170. package/dist/safe-bash/command-chunks/{chunk-LOICUCHG.js → chunk-ZHN3QDCI.js} +1 -1
  171. package/dist/safe-bash/commands/alias/index.d.ts +2 -0
  172. package/dist/safe-bash/commands/alias/index.js +2 -0
  173. package/dist/safe-bash/commands/apply-patch/index.browser.js +2 -3
  174. package/dist/safe-bash/commands/apply-patch/index.d.ts +0 -1
  175. package/dist/safe-bash/commands/apply-patch/index.js +0 -1
  176. package/dist/safe-bash/commands/archive/index.browser.js +2 -3
  177. package/dist/safe-bash/commands/archive/index.d.ts +0 -1
  178. package/dist/safe-bash/commands/archive/index.js +0 -1
  179. package/dist/safe-bash/commands/bytes/index.js +2 -1
  180. package/dist/safe-bash/commands/chmod/index.browser.js +1 -1
  181. package/dist/safe-bash/commands/column/index.browser.js +2 -3
  182. package/dist/safe-bash/commands/column/index.d.ts +0 -1
  183. package/dist/safe-bash/commands/column/index.js +0 -1
  184. package/dist/safe-bash/commands/copy-source.js +1 -0
  185. package/dist/safe-bash/commands/csplit/index.browser.js +2 -2
  186. package/dist/safe-bash/commands/csvkit/index.browser.js +72 -0
  187. package/dist/safe-bash/commands/csvkit/index.d.ts +0 -5
  188. package/dist/safe-bash/commands/csvkit/index.js +0 -50
  189. package/dist/safe-bash/commands/docx/index.browser.js +5 -7
  190. package/dist/safe-bash/commands/du/index.browser.js +2 -3
  191. package/dist/safe-bash/commands/du/index.d.ts +0 -1
  192. package/dist/safe-bash/commands/du/index.js +0 -1
  193. package/dist/safe-bash/commands/expr/index.browser.js +2 -3
  194. package/dist/safe-bash/commands/expr/index.d.ts +0 -1
  195. package/dist/safe-bash/commands/expr/index.js +0 -1
  196. package/dist/safe-bash/commands/factor/index.browser.js +2 -2
  197. package/dist/safe-bash/commands/file/index.browser.js +2 -3
  198. package/dist/safe-bash/commands/file/index.d.ts +0 -1
  199. package/dist/safe-bash/commands/file/index.js +0 -1
  200. package/dist/safe-bash/commands/filesystem.js +1 -1
  201. package/dist/safe-bash/commands/getopt/index.browser.js +2 -2
  202. package/dist/safe-bash/commands/grep-aliases/index.browser.js +3 -3
  203. package/dist/safe-bash/commands/hexdump/index.browser.js +2 -2
  204. package/dist/safe-bash/commands/html-to-markdown/index.browser.js +2 -3
  205. package/dist/safe-bash/commands/html-to-markdown/index.d.ts +0 -1
  206. package/dist/safe-bash/commands/html-to-markdown/index.js +0 -1
  207. package/dist/safe-bash/commands/htmlq/index.d.ts +1 -5
  208. package/dist/safe-bash/commands/htmlq/index.js +1 -143
  209. package/dist/safe-bash/commands/iconv/index.browser.js +2 -2
  210. package/dist/safe-bash/commands/line-endings/index.browser.js +2 -2
  211. package/dist/safe-bash/commands/llm/index.browser.js +2 -2
  212. package/dist/safe-bash/commands/llm/providers/index.browser.js +1 -1
  213. package/dist/safe-bash/commands/mdq/index.browser.js +3 -3
  214. package/dist/safe-bash/commands/media/index.browser.js +4 -16314
  215. package/dist/safe-bash/commands/media/index.d.ts +1 -5
  216. package/dist/safe-bash/commands/media/index.js +1 -3
  217. package/dist/safe-bash/commands/media/plugin.d.ts +1 -18
  218. package/dist/safe-bash/commands/media/plugin.js +1 -90
  219. package/dist/safe-bash/commands/media/remote.d.ts +1 -63
  220. package/dist/safe-bash/commands/media/remote.js +1 -405
  221. package/dist/safe-bash/commands/media/settings.d.ts +1 -4
  222. package/dist/safe-bash/commands/media/settings.js +1 -26
  223. package/dist/safe-bash/commands/metadata/index.browser.js +3 -4
  224. package/dist/safe-bash/commands/metadata/index.d.ts +0 -1
  225. package/dist/safe-bash/commands/metadata/index.js +2 -2
  226. package/dist/safe-bash/commands/mktemp/index.browser.js +1 -1
  227. package/dist/safe-bash/commands/network/curl.js +1 -3
  228. package/dist/safe-bash/commands/network/index.browser.js +3 -4
  229. package/dist/safe-bash/commands/network/public.d.ts +0 -1
  230. package/dist/safe-bash/commands/network/public.js +0 -1
  231. package/dist/safe-bash/commands/network/transport.js +2 -1
  232. package/dist/safe-bash/commands/network/wget.js +1 -3
  233. package/dist/safe-bash/commands/node/browser.d.ts +0 -1
  234. package/dist/safe-bash/commands/node/browser.js +0 -1
  235. package/dist/safe-bash/commands/node/default-runtime.d.ts +3 -0
  236. package/dist/safe-bash/commands/node/default-runtime.js +15 -0
  237. package/dist/safe-bash/commands/node/index.browser.js +7 -8
  238. package/dist/safe-bash/commands/node/index.js +3 -3
  239. package/dist/safe-bash/commands/node/path.js +1 -1
  240. package/dist/safe-bash/commands/node/preload.d.ts +1 -1
  241. package/dist/safe-bash/commands/node/preload.js +4 -1
  242. package/dist/safe-bash/commands/node/quickjs.d.ts +2 -0
  243. package/dist/safe-bash/commands/node/quickjs.js +2 -0
  244. package/dist/safe-bash/commands/node/safejs.js +26 -12
  245. package/dist/safe-bash/commands/op/index.browser.js +2 -3
  246. package/dist/safe-bash/commands/op/index.d.ts +0 -11
  247. package/dist/safe-bash/commands/op/index.js +0 -84
  248. package/dist/safe-bash/commands/pandoc/index.browser.js +44 -0
  249. package/dist/safe-bash/commands/pandoc/index.d.ts +0 -1
  250. package/dist/safe-bash/commands/pandoc/index.js +0 -1
  251. package/dist/safe-bash/commands/pr/index.browser.js +2 -2
  252. package/dist/safe-bash/commands/python/docker-runner.js +4 -3
  253. package/dist/safe-bash/commands/python/docker.d.ts +1 -0
  254. package/dist/safe-bash/commands/python/docker.js +5 -2
  255. package/dist/safe-bash/commands/python/index.browser.js +17 -13
  256. package/dist/safe-bash/commands/python/index.d.ts +2 -1
  257. package/dist/safe-bash/commands/python/index.js +10 -8
  258. package/dist/safe-bash/commands/python/llm-capability.js +65 -2
  259. package/dist/safe-bash/commands/python/llm-dependencies.d.ts +27 -0
  260. package/dist/safe-bash/commands/python/llm-dependencies.js +66 -0
  261. package/dist/safe-bash/commands/python/llm-module.js +6 -4
  262. package/dist/safe-bash/commands/python/llm-reference-module.d.ts +3 -0
  263. package/dist/safe-bash/commands/python/llm-reference-module.js +690 -0
  264. package/dist/safe-bash/commands/python/worker.browser.js +2 -3
  265. package/dist/safe-bash/commands/python/worker.d.ts +0 -1
  266. package/dist/safe-bash/commands/python/worker.js +0 -1
  267. package/dist/safe-bash/commands/regex-execution/ere/transport/wire-engine.d.ts +1 -1
  268. package/dist/safe-bash/commands/regex-execution/ere/transport/wire-engine.js +3 -3
  269. package/dist/safe-bash/commands/regex-execution/public.browser.js +7 -7
  270. package/dist/safe-bash/commands/safejs/options.js +5 -1
  271. package/dist/safe-bash/commands/safejs/runtime.d.ts +1 -0
  272. package/dist/safe-bash/commands/safejs/runtime.js +1 -1
  273. package/dist/safe-bash/commands/split/index.browser.js +2 -3
  274. package/dist/safe-bash/commands/split/index.d.ts +0 -1
  275. package/dist/safe-bash/commands/split/index.js +0 -1
  276. package/dist/safe-bash/commands/ssconvert/index.browser.js +98 -0
  277. package/dist/safe-bash/commands/stat/index.browser.js +1 -1
  278. package/dist/safe-bash/commands/stream-format/index.browser.js +3 -4
  279. package/dist/safe-bash/commands/stream-format/index.d.ts +0 -1
  280. package/dist/safe-bash/commands/stream-format/index.js +0 -1
  281. package/dist/safe-bash/commands/stream-inspection/index.browser.js +3 -4
  282. package/dist/safe-bash/commands/stream-inspection/index.d.ts +0 -1
  283. package/dist/safe-bash/commands/stream-inspection/index.js +0 -1
  284. package/dist/safe-bash/commands/streams.js +2 -1
  285. package/dist/safe-bash/commands/table-text/index.browser.js +3 -4
  286. package/dist/safe-bash/commands/table-text/index.d.ts +0 -1
  287. package/dist/safe-bash/commands/table-text/index.js +0 -1
  288. package/dist/safe-bash/commands/text.js +28 -24
  289. package/dist/safe-bash/commands/time-env/index.browser.js +3 -4
  290. package/dist/safe-bash/commands/time-env/index.d.ts +0 -1
  291. package/dist/safe-bash/commands/time-env/index.js +0 -1
  292. package/dist/safe-bash/commands/tree/index.browser.js +2 -3
  293. package/dist/safe-bash/commands/tree/index.d.ts +0 -1
  294. package/dist/safe-bash/commands/tree/index.js +0 -1
  295. package/dist/safe-bash/commands/tsort/index.browser.js +2 -2
  296. package/dist/safe-bash/commands/unalias/index.d.ts +2 -0
  297. package/dist/safe-bash/commands/unalias/index.js +2 -0
  298. package/dist/safe-bash/commands/xml/index.browser.js +2 -2
  299. package/dist/safe-bash/commands/yq/index.browser.js +2 -2
  300. package/dist/safe-bash/core.browser.js +2 -2
  301. package/dist/safe-bash/core.d.ts +7 -1
  302. package/dist/safe-bash/core.js +7 -1
  303. package/dist/safe-bash/execution-runtime.js +2 -1
  304. package/dist/safe-bash/fs/s3/http/index.d.ts +2 -2
  305. package/dist/safe-bash/fs/s3/http/index.js +1 -1
  306. package/dist/safe-bash/full-core.browser.js +283 -945
  307. package/dist/safe-bash/internal/op/types.d.ts +1 -0
  308. package/dist/safe-bash/jobs.browser.js +5 -5
  309. package/dist/safe-bash/lazy-optional.d.ts +3 -3
  310. package/dist/safe-bash/lazy-optional.js +1 -1
  311. package/dist/safe-bash/opt-in/commands/cmp/index.js +7 -6
  312. package/dist/safe-bash/opt-in/commands/dd/index.js +1 -1
  313. package/dist/safe-bash/opt-in/commands/dd/io.js +51 -5
  314. package/dist/safe-bash/opt-in/commands/truncate/index.js +2 -2
  315. package/dist/safe-bash/opt-in/commands/yq/native-work.js +2 -0
  316. package/dist/safe-bash/opt-in/optional/commands/shuf/input.js +2 -1
  317. package/dist/safe-bash/opt-in/optional/commands/shuf/shuf.js +4 -2
  318. package/dist/safe-bash/opt-in/optional.d.ts +1 -1
  319. package/dist/safe-bash/opt-in/optional.js +1 -1
  320. package/dist/safe-bash/opt-in/shell/extensions/read/index.js +2 -344
  321. package/dist/safe-bash/optional-host.browser.js +23 -18
  322. package/dist/safe-bash/optional-host.d.ts +1 -0
  323. package/dist/safe-bash/optional-host.js +1 -0
  324. package/dist/safe-bash/playwright/controller.js +41 -3
  325. package/dist/safe-bash/playwright/native-storage-targets.js +4 -2
  326. package/dist/safe-bash/plugins/base.d.ts +1 -1
  327. package/dist/safe-bash/plugins/base.js +3 -3
  328. package/dist/safe-bash/plugins/composition.d.ts +5 -2
  329. package/dist/safe-bash/plugins/composition.js +10 -7
  330. package/dist/safe-bash/plugins/index.browser.js +44 -41
  331. package/dist/safe-bash/plugins/index.js +3 -2
  332. package/dist/safe-bash/plugins/portable-commands.d.ts +3 -0
  333. package/dist/safe-bash/plugins/portable-commands.js +31 -0
  334. package/dist/safe-bash/registry-entry.browser.js +41 -42
  335. package/dist/safe-bash/search.browser.js +32 -33
  336. package/dist/safe-bash/shell/arithmetic.js +19 -6
  337. package/dist/safe-bash/shell/arrays/state.js +1 -1
  338. package/dist/safe-bash/shell/arrays/syntax.js +4 -3
  339. package/dist/safe-bash/shell/index.d.ts +0 -1
  340. package/dist/safe-bash/shell/index.js +0 -1
  341. package/dist/safe-bash/shell/parser.d.ts +2 -2
  342. package/dist/safe-bash/shell/parser.js +268 -64
  343. package/dist/safe-bash/shell/read-builtin.d.ts +3 -0
  344. package/dist/safe-bash/shell/read-builtin.js +344 -0
  345. package/dist/safe-bash/shell/runtime.d.ts +21 -4
  346. package/dist/safe-bash/shell/runtime.js +373 -412
  347. package/dist/safe-bash/shell/session-state.js +25 -0
  348. package/dist/safe-bash/shell/shell.js +76 -154
  349. package/dist/safe-bash/shell/tilde-expansion.d.ts +1 -1
  350. package/dist/safe-bash/shell/tilde-expansion.js +2 -2
  351. package/dist/safe-bash/shell/types.d.ts +5 -0
  352. package/dist/safe-bash/shell/value-state.js +1 -1
  353. package/dist/safe-bash/shell-entry.browser.js +32 -33
  354. package/dist/safe-bash/trap.browser.js +4 -4
  355. package/dist/safe-bash/yq-browser/index.js +1 -1
  356. package/dist/safe-bash-calendar-engine/time-env/calendar.d.ts +1 -1
  357. package/dist/safe-bash-calendar-engine/time-env/calendar.js +1 -1
  358. package/dist/safe-bash-calendar-engine/time-env/format.js +1 -1
  359. package/dist/safe-bash-command-alias/index.d.ts +13 -0
  360. package/dist/safe-bash-command-alias/index.js +88 -0
  361. package/dist/safe-bash-command-apply-patch/apply.js +3 -3
  362. package/dist/safe-bash-command-apply-patch/index.js +3 -3
  363. package/dist/safe-bash-command-apply-patch/matcher.js +1 -1
  364. package/dist/safe-bash-command-apply-patch/parser.js +1 -1
  365. package/dist/safe-bash-command-awk/awk-pipes.js +2 -2
  366. package/dist/safe-bash-command-awk/awk-reader.js +1 -1
  367. package/dist/safe-bash-command-awk/awk-runtime.js +3 -3
  368. package/dist/safe-bash-command-awk/awk.js +5 -5
  369. package/dist/safe-bash-command-awk/index.js +5 -5
  370. package/dist/safe-bash-command-bc/index.js +206 -60
  371. package/dist/safe-bash-command-cmp/index.js +7 -6
  372. package/dist/safe-bash-command-column/column.js +3 -3
  373. package/dist/safe-bash-command-column/index.js +3 -3
  374. package/dist/safe-bash-command-column/layout.js +2 -2
  375. package/dist/safe-bash-command-csvkit/index.d.ts +1 -0
  376. package/dist/safe-bash-command-csvkit/index.js +1505 -7
  377. package/dist/safe-bash-command-csvkit/sync-support.js +2 -7
  378. package/dist/safe-bash-command-curl/curl.js +1 -1
  379. package/dist/safe-bash-command-curl/index.js +1 -1
  380. package/dist/safe-bash-command-date/date.js +1 -1
  381. package/dist/safe-bash-command-date/index.js +1 -1
  382. package/dist/safe-bash-command-dd/index.js +1 -1
  383. package/dist/safe-bash-command-dd/io.js +51 -5
  384. package/dist/safe-bash-command-diff/diff.js +1 -1
  385. package/dist/safe-bash-command-diff/index.js +1 -1
  386. package/dist/safe-bash-command-diff3/index.js +10 -13
  387. package/dist/safe-bash-command-exiftool/index.js +278 -50
  388. package/dist/safe-bash-command-exiftool/registry.d.ts +4 -2
  389. package/dist/safe-bash-command-factor/command.js +2 -2
  390. package/dist/safe-bash-command-factor/index.js +2 -2
  391. package/dist/safe-bash-command-fd/arguments.d.ts +2 -0
  392. package/dist/safe-bash-command-fd/index.js +42 -12
  393. package/dist/safe-bash-command-ffmpeg/index.js +356 -66
  394. package/dist/safe-bash-command-find/find-format.d.ts +3 -0
  395. package/dist/safe-bash-command-find/find-format.js +1 -1
  396. package/dist/safe-bash-command-find/find.js +2 -2
  397. package/dist/safe-bash-command-find/index.js +2 -2
  398. package/dist/safe-bash-command-fmt/index.js +1 -4
  399. package/dist/safe-bash-command-fold/engine.d.ts +1 -1
  400. package/dist/safe-bash-command-fold/family.js +2 -2
  401. package/dist/safe-bash-command-fold/index.js +1 -1
  402. package/dist/safe-bash-command-hexdump/command.js +2 -2
  403. package/dist/safe-bash-command-hexdump/index.js +2 -2
  404. package/dist/safe-bash-command-html-to-markdown/entities.js +1 -1
  405. package/dist/safe-bash-command-html-to-markdown/index.js +4 -4
  406. package/dist/safe-bash-command-html-to-markdown/input.js +3 -3
  407. package/dist/safe-bash-command-html-to-markdown/parser.js +2 -2
  408. package/dist/safe-bash-command-html-to-markdown/render.js +3 -3
  409. package/dist/safe-bash-command-htmlq/contracts.d.ts +5 -2
  410. package/dist/safe-bash-command-htmlq/index.d.ts +2 -1
  411. package/dist/safe-bash-command-htmlq/index.js +175 -49
  412. package/dist/safe-bash-command-htmlq/sync.d.ts +1 -0
  413. package/dist/safe-bash-command-imagemagick/index.js +56 -6
  414. package/dist/safe-bash-command-install/arguments.d.ts +27 -0
  415. package/dist/safe-bash-command-install/arguments.js +224 -0
  416. package/dist/safe-bash-command-install/index.d.ts +7 -0
  417. package/dist/safe-bash-command-install/index.js +942 -0
  418. package/dist/safe-bash-command-install/mode.d.ts +6 -0
  419. package/dist/safe-bash-command-install/mode.js +71 -0
  420. package/dist/safe-bash-command-install/options.d.ts +40 -0
  421. package/dist/safe-bash-command-install/options.js +27 -0
  422. package/dist/safe-bash-command-jq/index.js +1 -1
  423. package/dist/safe-bash-command-jq/jq.js +1 -1
  424. package/dist/safe-bash-command-less/index.js +37 -61
  425. package/dist/safe-bash-command-llm/command.js +1 -1
  426. package/dist/safe-bash-command-llm/elevenlabs.js +2 -2
  427. package/dist/safe-bash-command-llm/index.js +4 -4
  428. package/dist/safe-bash-command-llm/openai.js +2 -2
  429. package/dist/safe-bash-command-llm/providers/elevenlabs.js +2 -2
  430. package/dist/safe-bash-command-llm/providers/index.js +3 -3
  431. package/dist/safe-bash-command-llm/providers/openai.js +2 -2
  432. package/dist/safe-bash-command-llm/providers/shared.js +1 -1
  433. package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.browser.d.ts +463 -46
  434. package/dist/safe-bash-command-mcp/index.browser.js +19308 -0
  435. package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.d.ts +15 -6
  436. package/dist/{safe-bash-mcp → safe-bash-command-mcp}/index.js +2804 -2771
  437. package/dist/safe-bash-command-media/LICENSE +21 -0
  438. package/dist/safe-bash-command-media/index.d.ts +6 -0
  439. package/dist/safe-bash-command-media/index.js +30 -0
  440. package/dist/safe-bash-command-media/plugin.d.ts +18 -0
  441. package/dist/safe-bash-command-media/plugin.js +11 -0
  442. package/dist/safe-bash-command-media/remote.d.ts +63 -0
  443. package/dist/safe-bash-command-media/remote.js +11 -0
  444. package/dist/safe-bash-command-media/settings.d.ts +4 -0
  445. package/dist/safe-bash-command-media/settings.js +41 -0
  446. package/dist/safe-bash-command-mktemp/command.js +1 -1
  447. package/dist/safe-bash-command-mktemp/index.js +1 -1
  448. package/dist/safe-bash-command-mmdc/arguments.d.ts +1 -0
  449. package/dist/safe-bash-command-mmdc/command.d.ts +2 -0
  450. package/dist/safe-bash-command-mmdc/contracts.d.ts +8 -1
  451. package/dist/safe-bash-command-mmdc/index.js +359 -7
  452. package/dist/safe-bash-command-nl/index.js +1 -1
  453. package/dist/safe-bash-command-nl/nl.js +1 -1
  454. package/dist/safe-bash-command-node/LICENSE +21 -0
  455. package/dist/safe-bash-command-node/index.d.ts +17 -0
  456. package/dist/safe-bash-command-node/index.js +328 -0
  457. package/dist/safe-bash-command-numfmt/index.js +1 -0
  458. package/dist/safe-bash-command-od/index.js +10 -6
  459. package/dist/safe-bash-command-op/index.js +39 -32
  460. package/dist/safe-bash-command-op/types.d.ts +1 -0
  461. package/dist/safe-bash-command-pandoc/command.js +3 -3
  462. package/dist/safe-bash-command-pandoc/index.d.ts +1 -0
  463. package/dist/safe-bash-command-pandoc/index.js +5 -3
  464. package/dist/safe-bash-command-pandoc/sync.d.ts +1 -0
  465. package/dist/safe-bash-command-patch/index.js +4 -4
  466. package/dist/safe-bash-command-patch/patch.js +4 -4
  467. package/dist/safe-bash-command-pdfimages/index.js +1 -1
  468. package/dist/safe-bash-command-pdfinfo/index.js +30 -5
  469. package/dist/safe-bash-command-pdftk/index.js +21 -23
  470. package/dist/safe-bash-command-pdftoppm/index.js +17 -4
  471. package/dist/safe-bash-command-pdftotext/index.js +11 -14
  472. package/dist/safe-bash-command-qpdf/index.d.ts +1 -0
  473. package/dist/safe-bash-command-qpdf/index.js +9 -6
  474. package/dist/safe-bash-command-rg/index.js +1 -1
  475. package/dist/safe-bash-command-rg/rg-command.js +1 -1
  476. package/dist/safe-bash-command-sed/index.js +1 -1
  477. package/dist/safe-bash-command-sed/sed.js +1 -1
  478. package/dist/safe-bash-command-shuf/input.d.ts +2 -2
  479. package/dist/safe-bash-command-shuf/input.js +2 -1
  480. package/dist/safe-bash-command-shuf/shuf.js +4 -2
  481. package/dist/safe-bash-command-sips/index.js +2 -2
  482. package/dist/safe-bash-command-soffice/index.js +97 -12
  483. package/dist/safe-bash-command-sponge/index.js +4 -1
  484. package/dist/safe-bash-command-sqlite3/engine.d.ts +1 -0
  485. package/dist/safe-bash-command-sqlite3/index.js +510 -70
  486. package/dist/safe-bash-command-ssconvert/formats/xlsx.js +2 -2
  487. package/dist/safe-bash-command-ssconvert/index.js +44 -22
  488. package/dist/safe-bash-command-stat/command.js +1 -1
  489. package/dist/safe-bash-command-stat/index.js +1 -1
  490. package/dist/safe-bash-command-tar/create.d.ts +1 -0
  491. package/dist/safe-bash-command-tar/create.js +2 -2
  492. package/dist/safe-bash-command-tar/extract.js +2 -2
  493. package/dist/safe-bash-command-tar/index.js +4 -4
  494. package/dist/safe-bash-command-tar/modes.js +4 -4
  495. package/dist/safe-bash-command-tar/options.js +1 -1
  496. package/dist/safe-bash-command-truncate/index.js +2 -2
  497. package/dist/safe-bash-command-tsort/command.js +2 -2
  498. package/dist/safe-bash-command-tsort/index.js +2 -2
  499. package/dist/safe-bash-command-unalias/index.d.ts +12 -0
  500. package/dist/safe-bash-command-unalias/index.js +67 -0
  501. package/dist/safe-bash-command-unrtf/index.js +26 -4
  502. package/dist/safe-bash-command-xan/argv.d.ts +1 -1
  503. package/dist/safe-bash-command-xan/argv.js +2 -2
  504. package/dist/safe-bash-command-xan/budget.d.ts +0 -1
  505. package/dist/safe-bash-command-xan/budget.js +1 -1
  506. package/dist/safe-bash-command-xan/commands.js +6 -6
  507. package/dist/safe-bash-command-xan/csv.js +2 -2
  508. package/dist/safe-bash-command-xan/index.js +8 -9
  509. package/dist/safe-bash-command-xan/io.js +4 -4
  510. package/dist/safe-bash-command-xan/options.js +1 -1
  511. package/dist/safe-bash-command-xan/selector.js +2 -2
  512. package/dist/safe-bash-command-xmllint/index.js +45 -23
  513. package/dist/safe-bash-command-xxd/index.js +41 -10
  514. package/dist/safe-bash-command-yq/accounting.js +1 -1
  515. package/dist/safe-bash-command-yq/index.js +3 -2
  516. package/dist/safe-bash-command-yq/native-work.js +2 -0
  517. package/dist/safe-bash-command-yq/parser.js +2 -2
  518. package/dist/safe-bash-command-yq/query.js +5 -5
  519. package/dist/safe-bash-command-yq/toml.js +2 -2
  520. package/dist/safe-bash-command-zip/index.js +3 -3
  521. package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
  522. package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
  523. package/dist/safe-bash-compression-engine/files.js +5 -5
  524. package/dist/safe-bash-compression-engine/index.js +4 -4
  525. package/dist/safe-bash-compression-engine/operand.js +5 -5
  526. package/dist/safe-bash-compression-engine/stream.js +4 -4
  527. package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
  528. package/dist/safe-bash-contracts/command.js +3 -3
  529. package/dist/safe-bash-contracts/default-executor.js +2 -2
  530. package/dist/safe-bash-contracts/diagnostics.js +3 -3
  531. package/dist/safe-bash-contracts/escaping.js +6 -6
  532. package/dist/safe-bash-contracts/filesystem-descriptor.js +3 -3
  533. package/dist/safe-bash-contracts/filesystem-output.js +5 -5
  534. package/dist/safe-bash-contracts/http.d.ts +7 -0
  535. package/dist/safe-bash-contracts/index.js +8 -8
  536. package/dist/safe-bash-contracts/io.js +2 -2
  537. package/dist/safe-bash-contracts/output.js +3 -3
  538. package/dist/safe-bash-contracts/runtime-control.d.ts +2 -2
  539. package/dist/safe-bash-contracts/runtime-control.js +4 -2
  540. package/dist/safe-bash-contracts/signals.d.ts +2 -0
  541. package/dist/safe-bash-contracts/signals.js +3 -1
  542. package/dist/safe-bash-contracts/yield.js +1 -1
  543. package/dist/safe-bash-csv-engine/index.d.ts +2 -1
  544. package/dist/safe-bash-csv-engine/index.js +21 -15
  545. package/dist/safe-bash-io-engine/commands/search/requirements.js +2 -2
  546. package/dist/safe-bash-io-engine/commands/text-programs/shared.js +6 -6
  547. package/dist/safe-bash-io-engine/internal.js +1 -1
  548. package/dist/safe-bash-io-engine/shell/pattern.js +38 -18
  549. package/dist/safe-bash-line-ending-engine/convert.js +9 -204
  550. package/dist/safe-bash-line-ending-engine/encoding.js +9 -42
  551. package/dist/safe-bash-line-ending-engine/index.js +48 -0
  552. package/dist/safe-bash-line-ending-engine/info.js +9 -90
  553. package/dist/safe-bash-line-ending-engine/internal.js +15 -160
  554. package/dist/safe-bash-line-ending-engine/io.js +12 -289
  555. package/dist/safe-bash-line-ending-engine/stage.js +10 -160
  556. package/dist/safe-bash-markdown-engine/index.js +3 -3
  557. package/dist/safe-bash-network-engine/args.d.ts +6 -0
  558. package/dist/safe-bash-network-engine/args.js +4 -2
  559. package/dist/safe-bash-network-engine/body.js +1 -1
  560. package/dist/safe-bash-network-engine/fetch-transport.js +3 -1
  561. package/dist/safe-bash-network-engine/index.js +3 -1
  562. package/dist/safe-bash-network-engine/input.js +2 -2
  563. package/dist/safe-bash-network-engine/platform-portable.js +3 -1
  564. package/dist/safe-bash-query-engine/dates.d.ts +1 -1
  565. package/dist/safe-bash-query-engine/dates.js +1 -1
  566. package/dist/safe-bash-query-engine/index.js +6 -6
  567. package/dist/safe-bash-query-engine/interpreter.js +4 -4
  568. package/dist/safe-bash-query-engine/parser.js +1 -1
  569. package/dist/safe-bash-query-engine/query-core.js +6 -6
  570. package/dist/safe-bash-regex-engine/execution/bounded-provider.js +10 -0
  571. package/dist/safe-bash-regex-engine/index.js +1 -1
  572. package/dist/safe-bash-regex-engine/text/regex.d.ts +1 -1
  573. package/dist/safe-bash-regex-engine/text/regex.js +1 -1
  574. package/dist/safe-bash-search-engine/ergonomic-regex.d.ts +1 -0
  575. package/dist/safe-bash-search-engine/ergonomic-regex.js +1 -1
  576. package/dist/safe-bash-search-engine/grep.js +16 -9
  577. package/dist/safe-bash-search-engine/matcher.d.ts +2 -2
  578. package/dist/safe-bash-search-engine/matcher.js +12 -8
  579. package/dist/safe-bash-search-engine/shared.js +1 -1
  580. package/dist/safe-bash-search-engine/walk.js +13 -1
  581. package/dist/safe-bash-text-stream-engine/stream-format/shared.d.ts +1 -1
  582. package/dist/safe-bash-text-stream-engine/stream-format/shared.js +2 -1
  583. package/dist/safe-bash-xml-engine/document.js +3 -3
  584. package/dist/safe-bash-xml-engine/evaluate.js +2 -2
  585. package/dist/safe-bash-xml-engine/index.js +4 -4
  586. package/dist/safe-bash-xml-engine/io.js +7 -2
  587. package/dist/safe-bash-xml-engine/limits.d.ts +0 -2
  588. package/dist/safe-bash-xml-engine/limits.js +1 -1
  589. package/dist/safe-bash-xml-engine/query.js +3 -3
  590. package/dist/safe-bash-zip-engine/index.js +3 -3
  591. package/dist/safe-bash-zip-engine/zip/repair.js +3 -3
  592. package/dist/safe-bash-zip-engine/zip/safety.js +1 -1
  593. package/dist/safe-bash-zip-engine/zip/sfx.js +3 -3
  594. package/dist/safe-bash-zip-engine/zip/volumes.js +1 -1
  595. package/dist/safe-bash-zip-engine/zip-format.js +3 -3
  596. package/dist/safe-playwright-cloudflare/browser-socket-closure.js +18 -3
  597. package/dist/safe-playwright-cloudflare/shell-browser-resource.js +1 -1
  598. package/dist/xlsx-ast/xlsx.js +6 -5
  599. package/package.json +86 -98
  600. package/dist/media-cli/bytes.d.ts +0 -8
  601. package/dist/media-cli/bytes.js +0 -40
  602. package/dist/media-cli/concat.d.ts +0 -30
  603. package/dist/media-cli/concat.js +0 -197
  604. package/dist/media-cli/content.js +0 -66
  605. package/dist/media-cli/dependency-grammars.d.ts +0 -12
  606. package/dist/media-cli/dependency-grammars.js +0 -557
  607. package/dist/media-cli/discover.js +0 -286
  608. package/dist/media-cli/engine.js +0 -190
  609. package/dist/media-cli/filename-expression.js +0 -147
  610. package/dist/media-cli/filesystem.js +0 -35
  611. package/dist/media-cli/frontend-contract.js +0 -8
  612. package/dist/media-cli/frontend-issues.d.ts +0 -6
  613. package/dist/media-cli/frontend-issues.js +0 -9
  614. package/dist/media-cli/imagemagick-operand.d.ts +0 -42
  615. package/dist/media-cli/imagemagick-operand.js +0 -229
  616. package/dist/media-cli/imagemagick-references.d.ts +0 -7
  617. package/dist/media-cli/imagemagick-references.js +0 -42
  618. package/dist/media-cli/imagemagick.generated.js +0 -3254
  619. package/dist/media-cli/imagemagick.js +0 -615
  620. package/dist/media-cli/index.js +0 -12
  621. package/dist/media-cli/mvg.d.ts +0 -10
  622. package/dist/media-cli/mvg.js +0 -102
  623. package/dist/media-cli/network.js +0 -78
  624. package/dist/media-cli/options.generated.js +0 -3312
  625. package/dist/media-cli/preset.d.ts +0 -11
  626. package/dist/media-cli/preset.js +0 -57
  627. package/dist/media-cli/resolution-path.d.ts +0 -23
  628. package/dist/media-cli/resolution-path.js +0 -217
  629. package/dist/media-cli/resolver.js +0 -494
  630. package/dist/media-cli/resources.d.ts +0 -16
  631. package/dist/media-cli/resources.js +0 -187
  632. package/dist/media-cli/shim.js +0 -52
  633. package/dist/media-cli/tee.d.ts +0 -6
  634. package/dist/media-cli/tee.js +0 -38
  635. package/dist/office-package/zip-sync.js +0 -111
  636. package/dist/remote-execution/binary.js +0 -178
  637. package/dist/remote-execution/callback-result.js +0 -26
  638. package/dist/remote-execution/canonical-capabilities.d.ts +0 -5
  639. package/dist/remote-execution/canonical-capabilities.js +0 -45
  640. package/dist/remote-execution/canonical-metadata.d.ts +0 -4
  641. package/dist/remote-execution/canonical-metadata.js +0 -32
  642. package/dist/remote-execution/client.js +0 -824
  643. package/dist/remote-execution/deployment.js +0 -131
  644. package/dist/remote-execution/descriptors.js +0 -267
  645. package/dist/remote-execution/effects.js +0 -357
  646. package/dist/remote-execution/endpoint.js +0 -224
  647. package/dist/remote-execution/files.js +0 -291
  648. package/dist/remote-execution/hosting-operation.js +0 -26
  649. package/dist/remote-execution/hosting-request.d.ts +0 -4
  650. package/dist/remote-execution/hosting-request.js +0 -12
  651. package/dist/remote-execution/hosting-stream.d.ts +0 -8
  652. package/dist/remote-execution/hosting-stream.js +0 -64
  653. package/dist/remote-execution/index.js +0 -18
  654. package/dist/remote-execution/invocation-admission.d.ts +0 -3
  655. package/dist/remote-execution/invocation-admission.js +0 -17
  656. package/dist/remote-execution/job-binding.js +0 -1269
  657. package/dist/remote-execution/materializations.js +0 -284
  658. package/dist/remote-execution/modal-driver.js +0 -90
  659. package/dist/remote-execution/native-result.d.ts +0 -3
  660. package/dist/remote-execution/native-result.js +0 -16
  661. package/dist/remote-execution/output-freshness.d.ts +0 -4
  662. package/dist/remote-execution/output-freshness.js +0 -19
  663. package/dist/remote-execution/output-retrieval.js +0 -474
  664. package/dist/remote-execution/process-http.js +0 -607
  665. package/dist/remote-execution/process.js +0 -577
  666. package/dist/remote-execution/protocol.js +0 -208
  667. package/dist/remote-execution/relay.js +0 -91
  668. package/dist/remote-execution/rest-driver.js +0 -93
  669. package/dist/remote-execution/upload-descriptor.js +0 -201
  670. package/dist/remote-execution/upload-protocol.js +0 -62
  671. package/dist/remote-execution/uploads.js +0 -324
  672. package/dist/remote-execution/wire-json.d.ts +0 -4
  673. package/dist/remote-execution/wire-json.js +0 -44
  674. package/dist/remote-execution/wire-validation.js +0 -131
  675. package/dist/remote-execution/wire.generated.js +0 -4224
  676. package/dist/safe-bash/chunks/chunk-GDYNCWRV.js +0 -161
  677. package/dist/safe-bash/chunks/chunk-IWDICZVK.js +0 -20
  678. package/dist/safe-bash/chunks/chunk-MHMMRCYC.js +0 -3464
  679. package/dist/safe-bash/chunks/chunk-UE5KZDEK.js +0 -77
  680. package/dist/safe-bash/chunks/csvkit-TACDU7FC.js +0 -1618
  681. package/dist/safe-bash/chunks/implementation-MLFHUQ5M.js +0 -133
  682. package/dist/safe-bash/commands/csvkit/sync.js +0 -1639
  683. package/dist/safe-bash/commands/node/unconfigured.d.ts +0 -3
  684. package/dist/safe-bash/commands/node/unconfigured.js +0 -10
  685. package/dist/safe-bash/commands/pandoc/implementation.d.ts +0 -8
  686. package/dist/safe-bash/commands/pandoc/implementation.js +0 -94
  687. package/dist/safe-bash-mcp/index.browser.js +0 -9167
  688. package/dist/safe-bash/command-chunks/{chunk-ZRRBXU3M.js → chunk-GIN5GUDP.js} +4 -4
  689. package/dist/safe-bash/command-chunks/{chunk-LAOM65EE.js → chunk-IEO4XVN6.js} +3 -3
  690. package/dist/safe-bash/command-chunks/{chunk-BXCXRYVU.js → chunk-JNANXVJV.js} +0 -0
  691. package/dist/safe-bash/command-chunks/{chunk-364TMWBT.js → chunk-MWREVL44.js} +6 -6
  692. package/dist/safe-bash/command-chunks/{chunk-464RVBGB.js → chunk-Q5TDKFHK.js} +3 -3
  693. package/dist/safe-bash/command-chunks/{chunk-AJR3AQYA.js → chunk-UKX3LZHR.js} +0 -0
  694. package/dist/safe-bash/command-chunks/{chunk-XIIBTGC5.js → chunk-XPXEQKRW.js} +9 -9
  695. package/dist/safe-bash/command-chunks/{chunk-FDBUV4HJ.js → chunk-Y4HGTG3E.js} +3 -3
  696. /package/dist/{safe-bash/commands/csvkit → safe-bash-command-csvkit}/sync.d.ts +0 -0
@@ -1,4 +1,7 @@
1
- import "../safe-bash/command-chunks/chunk-DZCY63VJ.js";
1
+ import {
2
+ readZipArchiveEntries
3
+ } from "../safe-bash/command-chunks/chunk-WSTQRWOC.js";
4
+ import "../safe-bash/command-chunks/chunk-EV6HIJ5H.js";
2
5
  import "../safe-bash/command-chunks/chunk-75OFBY5R.js";
3
6
  import "../safe-bash/command-chunks/chunk-6X2OX6IJ.js";
4
7
  import {
@@ -63,7 +66,7 @@ import {
63
66
  upperText,
64
67
  warningText,
65
68
  writeCsvRow
66
- } from "../safe-bash/command-chunks/chunk-5UBXNSFZ.js";
69
+ } from "../safe-bash/command-chunks/chunk-XUCU7QQT.js";
67
70
  import {
68
71
  PythonException
69
72
  } from "../safe-bash/command-chunks/chunk-JLZPB7NB.js";
@@ -9205,7 +9208,7 @@ function compare(a, b, runtime2) {
9205
9208
  function format2(value, runtime2) {
9206
9209
  if (typeof value !== "object" || !value || value.kind !== "decimal" || Decimal.parse(value.value).special) return value;
9207
9210
  let result = runtime2.context.locale.formatNumber(value.value, runtime2.context.locale.profile, String(runtime2.options.decimal_format), !runtime2.options.no_grouping_separator);
9208
- while (result.endsWith("0")) {
9211
+ while (result.includes(".") && result.endsWith("0")) {
9209
9212
  runtime2.step();
9210
9213
  result = result.slice(0, -1);
9211
9214
  }
@@ -15667,14 +15670,45 @@ function createDefaultSqliteDatabaseProvider(clock, limits = {}) {
15667
15670
 
15668
15671
  // packages/safe-bash-command-csvkit/src/portable-locale.ts
15669
15672
  init_buffer();
15673
+ function groupInteger(value, grouping) {
15674
+ if (!grouping) return value;
15675
+ const start = value.startsWith("-") ? 1 : 0;
15676
+ let result = value.slice(0, start);
15677
+ for (let index = start; index < value.length; index++) {
15678
+ if (index > start && (value.length - index) % 3 === 0) result += ",";
15679
+ result += value[index];
15680
+ }
15681
+ return result;
15682
+ }
15670
15683
  var portableLocale = Object.freeze({
15671
15684
  profile: "C",
15672
15685
  timezone: "UTC",
15673
- formatNumber(value, _locale, format3) {
15686
+ formatNumber(value, _locale, format3, grouping) {
15687
+ if (format3 === "#,##0.###") {
15688
+ const decimal = Decimal.parse(value);
15689
+ if (decimal.special) return decimal.toString();
15690
+ let coefficient = decimal.coefficient;
15691
+ const shift = decimal.exponent + 3;
15692
+ if (shift >= 0) coefficient *= 10n ** BigInt(shift);
15693
+ else if (-shift > coefficient.toString().length) coefficient = 0n;
15694
+ else {
15695
+ const divisor = 10n ** BigInt(-shift);
15696
+ const remainder = coefficient % divisor;
15697
+ coefficient /= divisor;
15698
+ if (remainder * 2n > divisor || remainder * 2n === divisor && coefficient % 2n !== 0n) coefficient++;
15699
+ }
15700
+ const digits3 = coefficient.toString().padStart(4, "0");
15701
+ const whole = digits3.slice(0, -3);
15702
+ let fraction = digits3.slice(-3);
15703
+ while (fraction.endsWith("0")) fraction = fraction.slice(0, -1);
15704
+ return (decimal.negative ? "-" : "") + groupInteger(whole, grouping) + (fraction ? "." + fraction : "");
15705
+ }
15706
+ if (format3 === "%s") return value;
15707
+ if (format3.startsWith("%,")) format3 = "%" + format3.slice(2);
15674
15708
  const number2 = Number(value);
15675
15709
  if (format3 === "%d" || format3 === "%i") {
15676
15710
  if (!Number.isFinite(number2)) throw new CsvkitBlocked("non-finite integer formatting");
15677
- return BigInt(Math.trunc(number2)).toString();
15711
+ return groupInteger(BigInt(Math.trunc(number2)).toString(), grouping);
15678
15712
  }
15679
15713
  if (format3 === "%f") format3 = "%.6f";
15680
15714
  const precisionText = format3.slice(2, -1);
@@ -15697,7 +15731,7 @@ var portableLocale = Object.freeze({
15697
15731
  if (remainder * 2n > divisor || remainder * 2n === divisor && scaled % 2n !== 0n) scaled++;
15698
15732
  }
15699
15733
  const digits2 = scaled.toString().padStart(precision2 + 1, "0");
15700
- const fixed2 = precision2 ? digits2.slice(0, -precision2) + "." + digits2.slice(-precision2) : digits2;
15734
+ const fixed2 = precision2 ? groupInteger(digits2.slice(0, -precision2), grouping) + "." + digits2.slice(-precision2) : groupInteger(digits2, grouping);
15701
15735
  return (number2 < 0 || Object.is(number2, -0) ? "-" : "") + fixed2;
15702
15736
  }
15703
15737
  });
@@ -15707,6 +15741,1457 @@ import { createOutputOperation, getCommandArguments } from "../safe-bash-contrac
15707
15741
  import { writeFileOutput, openFileOutput } from "../safe-bash-contracts/filesystem-output.js";
15708
15742
  import { FsError, isFsError } from "../safe-bash-contracts/errors.js";
15709
15743
  import { shellValueByteLength } from "../safe-bash-contracts/value.js";
15744
+
15745
+ // packages/safe-bash-command-csvkit/src/sync.ts
15746
+ init_buffer();
15747
+ var syncUtf8Decoder = new TextDecoder("utf-8", { fatal: true });
15748
+ function parseSyncCsvkitCommon(opArgs, mode) {
15749
+ const res = {
15750
+ tabs: false,
15751
+ noDoublequote: false,
15752
+ skipInitialSpace: false,
15753
+ noHeaderRow: false,
15754
+ skipLines: 0,
15755
+ lineNumbers: false,
15756
+ addBom: false,
15757
+ noInference: false,
15758
+ blanks: false,
15759
+ noLeadingZeroes: false,
15760
+ sniffLimit: 1024,
15761
+ noNumberEllipsis: false,
15762
+ indent: null,
15763
+ key: null,
15764
+ streamOutput: false
15765
+ };
15766
+ let positionalDone = false;
15767
+ for (let i = 0; i < opArgs.length; i++) {
15768
+ const a = opArgs[i];
15769
+ if (!positionalDone && a === "--") {
15770
+ positionalDone = true;
15771
+ continue;
15772
+ }
15773
+ if (!positionalDone && a.startsWith("-") && a !== "-") {
15774
+ if (a === "-t" || a === "--tabs") {
15775
+ res.tabs = true;
15776
+ continue;
15777
+ }
15778
+ if (a === "-b" || a === "--no-doublequote") {
15779
+ res.noDoublequote = true;
15780
+ continue;
15781
+ }
15782
+ if (a === "-S" || a === "--skipinitialspace") {
15783
+ res.skipInitialSpace = true;
15784
+ continue;
15785
+ }
15786
+ if (a === "-H" || a === "--no-header-row") {
15787
+ res.noHeaderRow = true;
15788
+ continue;
15789
+ }
15790
+ if (a === "-l" || a === "--linenumbers") {
15791
+ res.lineNumbers = true;
15792
+ continue;
15793
+ }
15794
+ if (a === "--add-bom") {
15795
+ res.addBom = true;
15796
+ continue;
15797
+ }
15798
+ if (a === "-I" || a === "--no-inference") {
15799
+ res.noInference = true;
15800
+ continue;
15801
+ }
15802
+ if (a === "--blanks") {
15803
+ res.blanks = true;
15804
+ continue;
15805
+ }
15806
+ if (a === "--no-leading-zeroes") {
15807
+ res.noLeadingZeroes = true;
15808
+ continue;
15809
+ }
15810
+ if (a === "-d" || a.startsWith("-d") || a === "--delimiter" || a.startsWith("--delimiter=")) {
15811
+ const v = a.startsWith("--delimiter=") ? a.slice(12) : a.startsWith("-d=") ? a.slice(3) : a.length > 2 && a.startsWith("-d") ? a.slice(2) : opArgs[++i];
15812
+ if (!v || Array.from(v).length !== 1) return void 0;
15813
+ res.delimiter = v;
15814
+ continue;
15815
+ }
15816
+ if (a === "-q" || a.startsWith("-q") || a === "--quotechar" || a.startsWith("--quotechar=")) {
15817
+ const v = a.startsWith("--quotechar=") ? a.slice(12) : a.startsWith("-q=") ? a.slice(3) : a.length > 2 && a.startsWith("-q") ? a.slice(2) : opArgs[++i];
15818
+ if (!v || Array.from(v).length !== 1) return void 0;
15819
+ res.quotechar = v;
15820
+ continue;
15821
+ }
15822
+ if (a === "-p" || a === "--escapechar") {
15823
+ const v = opArgs[++i];
15824
+ if (!v || Array.from(v).length !== 1) return void 0;
15825
+ res.escapechar = v;
15826
+ continue;
15827
+ }
15828
+ if (a === "-K" || a.startsWith("-K") || a === "--skip-lines" || a.startsWith("--skip-lines=")) {
15829
+ const v = a.startsWith("--skip-lines=") ? a.slice(13) : a.startsWith("-K=") ? a.slice(3) : a.length > 2 && a.startsWith("-K") ? a.slice(2) : opArgs[++i];
15830
+ if (v === void 0 || !/^[0-9]+$/.test(v)) return void 0;
15831
+ res.skipLines = Number(v);
15832
+ continue;
15833
+ }
15834
+ if (a === "-y" || a === "--snifflimit") {
15835
+ const v = opArgs[++i];
15836
+ if (v === void 0 || !/^-?[0-9]+$/.test(v)) return void 0;
15837
+ res.sniffLimit = Number(v);
15838
+ continue;
15839
+ }
15840
+ if (mode === "csvlook") {
15841
+ if (a === "--no-number-ellipsis") {
15842
+ res.noNumberEllipsis = true;
15843
+ continue;
15844
+ }
15845
+ if (a === "--max-rows" || a === "--max-columns" || a === "--max-column-width" || a === "--max-precision") {
15846
+ const v = opArgs[++i];
15847
+ if (v === void 0 || !/^[0-9]+$/.test(v)) return void 0;
15848
+ const n = Number(v);
15849
+ if (a === "--max-rows") res.maxRows = n;
15850
+ else if (a === "--max-columns") res.maxColumns = n;
15851
+ else if (a === "--max-column-width") res.maxColumnWidth = n;
15852
+ else res.maxPrecision = n;
15853
+ continue;
15854
+ }
15855
+ } else {
15856
+ if (a === "--stream") {
15857
+ res.streamOutput = true;
15858
+ continue;
15859
+ }
15860
+ if (a === "-i" || a.startsWith("-i") || a === "--indent" || a.startsWith("--indent=")) {
15861
+ const v = a.startsWith("--indent=") ? a.slice(9) : a.startsWith("-i=") ? a.slice(3) : a.length > 2 && a.startsWith("-i") ? a.slice(2) : opArgs[++i];
15862
+ if (v === void 0 || !/^[0-9]+$/.test(v)) return void 0;
15863
+ res.indent = Number(v);
15864
+ continue;
15865
+ }
15866
+ if (a === "-k" || a.startsWith("-k") || a === "--key" || a.startsWith("--key=")) {
15867
+ const v = a.startsWith("--key=") ? a.slice(6) : a.startsWith("-k=") ? a.slice(3) : a.length > 2 && a.startsWith("-k") ? a.slice(2) : opArgs[++i];
15868
+ if (v === void 0) return void 0;
15869
+ res.key = v;
15870
+ continue;
15871
+ }
15872
+ }
15873
+ if (!a.startsWith("--") && a.length > 2) {
15874
+ let ok = true;
15875
+ for (let j = 1; j < a.length; j++) {
15876
+ const ch = a[j];
15877
+ if (ch === "t") res.tabs = true;
15878
+ else if (ch === "b") res.noDoublequote = true;
15879
+ else if (ch === "S") res.skipInitialSpace = true;
15880
+ else if (ch === "H") res.noHeaderRow = true;
15881
+ else if (ch === "l") res.lineNumbers = true;
15882
+ else if (ch === "I") res.noInference = true;
15883
+ else {
15884
+ ok = false;
15885
+ break;
15886
+ }
15887
+ }
15888
+ if (ok) continue;
15889
+ }
15890
+ return void 0;
15891
+ }
15892
+ if (res.filePath !== void 0) return void 0;
15893
+ res.filePath = a;
15894
+ }
15895
+ return res;
15896
+ }
15897
+ function loadSyncTypedTable(inBytes, opts, readFileSync) {
15898
+ let sourceBytes = inBytes;
15899
+ if (opts.filePath !== void 0 && opts.filePath !== "-") {
15900
+ if (!readFileSync) return void 0;
15901
+ sourceBytes = readFileSync(opts.filePath);
15902
+ }
15903
+ if (!sourceBytes || sourceBytes.byteLength > 16384) return void 0;
15904
+ let text2;
15905
+ try {
15906
+ text2 = syncUtf8Decoder.decode(sourceBytes);
15907
+ } catch {
15908
+ return void 0;
15909
+ }
15910
+ if (text2.charCodeAt(0) === 65279) text2 = text2.slice(1);
15911
+ if (opts.skipLines > 0) {
15912
+ let linesLeft = opts.skipLines;
15913
+ let pos = 0;
15914
+ while (pos < text2.length && linesLeft > 0) {
15915
+ const ch = text2[pos++];
15916
+ if (ch === "\r") {
15917
+ if (text2[pos] === "\n") pos++;
15918
+ linesLeft--;
15919
+ } else if (ch === "\n") {
15920
+ linesLeft--;
15921
+ }
15922
+ }
15923
+ text2 = text2.slice(pos);
15924
+ }
15925
+ const explicitDelimiter = opts.tabs ? " " : opts.delimiter;
15926
+ let dialect = {
15927
+ ...explicitDelimiter !== void 0 ? { delimiter: explicitDelimiter } : {},
15928
+ ...opts.quotechar !== void 0 ? { quotechar: opts.quotechar } : {},
15929
+ ...opts.escapechar !== void 0 ? { escapechar: opts.escapechar } : {},
15930
+ doublequote: !opts.noDoublequote,
15931
+ skipinitialspace: opts.skipInitialSpace
15932
+ };
15933
+ if (!opts.tabs && opts.delimiter === void 0 && opts.quotechar === void 0 && opts.escapechar === void 0 && !opts.noDoublequote && !opts.skipInitialSpace && opts.sniffLimit !== 0 && text2.length > 0) {
15934
+ const sample = opts.sniffLimit > 0 ? text2.slice(0, opts.sniffLimit) : text2;
15935
+ if (sample.includes(",") && !/[\t;|:\x27]/.test(sample)) {
15936
+ dialect = { delimiter: ",", quotechar: '"', doublequote: true, skipinitialspace: false };
15937
+ } else {
15938
+ const sniffed = sniff(sample);
15939
+ if (sniffed) dialect = sniffed;
15940
+ }
15941
+ }
15942
+ let headers;
15943
+ const rows = [];
15944
+ const rowLimit = opts.maxRows;
15945
+ for (const record of readCsv(text2, dialect)) {
15946
+ const values = record.cells.map((c) => pythonValueText(c));
15947
+ const cells = opts.lineNumbers ? [!opts.noHeaderRow && record.line === 1 ? "line_numbers" : String(record.line - (opts.noHeaderRow ? 0 : 1)), ...values] : values;
15948
+ if (headers === void 0) {
15949
+ headers = opts.noHeaderRow ? defaultHeaders(cells.length) : cells;
15950
+ if (headers.some((name) => !name) || new Set(headers).size !== headers.length) return void 0;
15951
+ if (!opts.noHeaderRow) {
15952
+ if (rowLimit === 0) break;
15953
+ continue;
15954
+ }
15955
+ }
15956
+ rows.push(cells);
15957
+ if (rowLimit !== void 0 && rows.length >= rowLimit) break;
15958
+ }
15959
+ const inferenceOpts = {
15960
+ now: Date.now(),
15961
+ timezone: "UTC",
15962
+ noInference: opts.noInference,
15963
+ numberTextOnly: false,
15964
+ blanks: opts.blanks,
15965
+ nullValues: [],
15966
+ noLeadingZeroes: opts.noLeadingZeroes,
15967
+ maxDecimalDigits: Infinity,
15968
+ maxDecimalExponent: Infinity
15969
+ };
15970
+ return inferTable(headers ?? [], rows, inferenceOpts);
15971
+ }
15972
+ function syncPrecision(values) {
15973
+ let whole = 1;
15974
+ let places = 0;
15975
+ for (const value of values) {
15976
+ if (value === null || typeof value !== "object" || value.kind !== "decimal") continue;
15977
+ const d = Decimal.parse(value.value).normalized();
15978
+ if (d.special || Math.abs(Number(d.toString())) === Infinity) continue;
15979
+ places = Math.max(places, -d.exponent);
15980
+ whole = Math.max(whole, d.coefficient.toString().length + d.exponent);
15981
+ }
15982
+ return Math.min(places, 28 - whole);
15983
+ }
15984
+ function syncNumberText(value, places, ellipsis) {
15985
+ const d = Decimal.parse(value);
15986
+ if (d.special === "Infinity" || Math.abs(Number(d.toString())) === Infinity) return value;
15987
+ places = Math.max(0, places);
15988
+ if (d.special) {
15989
+ const digits3 = "NaN" + d.payload;
15990
+ let grouped2 = "";
15991
+ for (let i = 0; i < digits3.length; i++) {
15992
+ if (i && (digits3.length - i) % 3 === 0) grouped2 += ",";
15993
+ grouped2 += digits3[i];
15994
+ }
15995
+ return grouped2 + (places ? "." + "0".repeat(places) : "") + ellipsis;
15996
+ }
15997
+ let coefficient = d.coefficient;
15998
+ const shift = d.exponent + places;
15999
+ if (shift >= 0) coefficient *= 10n ** BigInt(shift);
16000
+ else {
16001
+ const divisor = 10n ** BigInt(-shift);
16002
+ const rest = coefficient % divisor;
16003
+ coefficient /= divisor;
16004
+ if (rest * 2n > divisor || rest * 2n === divisor && coefficient % 2n !== 0n) coefficient++;
16005
+ }
16006
+ if (coefficient.toString().length > 28) throw new Error("InvalidOperation");
16007
+ const digits2 = coefficient.toString().padStart(places + 1, "0");
16008
+ const whole = digits2.slice(0, digits2.length - places);
16009
+ let grouped = "";
16010
+ for (let i = 0; i < whole.length; i++) {
16011
+ if (i && (whole.length - i) % 3 === 0) grouped += ",";
16012
+ grouped += whole[i];
16013
+ }
16014
+ return (d.negative ? "-" : "") + grouped + (places ? "." + digits2.slice(-places) : "") + ellipsis;
16015
+ }
16016
+ function evalSyncCsvlook(inBytes, opArgs, readFileSync) {
16017
+ try {
16018
+ const opts = parseSyncCsvkitCommon(opArgs, "csvlook");
16019
+ if (!opts) return void 0;
16020
+ const table = loadSyncTypedTable(inBytes, opts, readFileSync);
16021
+ if (!table) return void 0;
16022
+ const maxColumns = opts.maxColumns ?? table.headers.length;
16023
+ const width = opts.maxColumnWidth;
16024
+ const maxPrecision = opts.maxPrecision ?? 3;
16025
+ const cpLen = (v) => Array.from(v).length;
16026
+ const truncate = (v) => {
16027
+ const chars = Array.from(v);
16028
+ return width !== void 0 && chars.length > width ? chars.slice(0, width - 3).join("") + "..." : v;
16029
+ };
16030
+ const names = table.headers.slice(0, maxColumns).map(truncate);
16031
+ if (maxColumns < table.headers.length) names.push("...");
16032
+ const widths = names.map(cpLen);
16033
+ const formats2 = table.columns.map((column, index) => {
16034
+ if (index >= maxColumns || column.type !== "Number") return void 0;
16035
+ const places = syncPrecision(table.rows.map((row) => row[index]));
16036
+ return { places: Math.min(places, maxPrecision), ellipsis: places > maxPrecision && !opts.noNumberEllipsis ? "\u2026" : "" };
16037
+ });
16038
+ const renderedRows = table.rows.map((row) => {
16039
+ const cells = [];
16040
+ for (const [j, value] of row.entries()) {
16041
+ const format3 = formats2[j];
16042
+ let text2 = j >= maxColumns ? "..." : value === null ? "" : format3 && typeof value === "object" && value.kind === "decimal" ? syncNumberText(value.value, format3.places, format3.ellipsis) : pythonValueText(value).replaceAll("\n", "\u21B5");
16043
+ text2 = truncate(text2);
16044
+ widths[j] = Math.max(widths[j], cpLen(text2));
16045
+ cells.push(text2);
16046
+ if (j >= maxColumns) break;
16047
+ }
16048
+ return cells;
16049
+ });
16050
+ const formatRow = (cells) => {
16051
+ const fields = cells.map((cell2, j) => {
16052
+ const col = table.columns[j];
16053
+ if (!col) throw new Error("IndexError");
16054
+ const spaces = widths[j] - cpLen(cell2);
16055
+ const padding = " ".repeat(Math.max(0, spaces));
16056
+ return col.type === "Text" ? " " + cell2 + padding + " " : " " + padding + cell2 + " ";
16057
+ });
16058
+ return "|" + fields.join("|") + "|\n";
16059
+ };
16060
+ let out = opts.addBom ? "\uFEFF" : "";
16061
+ out += formatRow(names);
16062
+ out += "| " + widths.map((size) => "-".repeat(size)).join(" | ") + " |\n";
16063
+ for (const row of renderedRows) out += formatRow(row);
16064
+ return out;
16065
+ } catch {
16066
+ return void 0;
16067
+ }
16068
+ }
16069
+ function syncFloatText(value) {
16070
+ if (Number.isNaN(value)) return "NaN";
16071
+ if (!Number.isFinite(value)) return value < 0 ? "-Infinity" : "Infinity";
16072
+ if (Object.is(value, -0)) return "-0.0";
16073
+ const exponent = Number(value.toExponential().split("e")[1]);
16074
+ if (value !== 0 && (exponent < -4 || exponent >= 16)) {
16075
+ const [digits2, power] = value.toExponential().split("e");
16076
+ const exp = Number(power);
16077
+ return digits2 + "e" + (exp < 0 ? "-" : "+") + String(Math.abs(exp)).padStart(2, "0");
16078
+ }
16079
+ return String(value) + (Number.isInteger(value) ? ".0" : "");
16080
+ }
16081
+ function emitSyncJson(cur, indent, d = 0) {
16082
+ if (typeof cur === "number") return syncFloatText(cur);
16083
+ if (cur === null || typeof cur === "string" || typeof cur === "boolean") return JSON.stringify(cur);
16084
+ if (cur instanceof Map) {
16085
+ let buf2 = "{";
16086
+ let index = 0;
16087
+ const childPad2 = indent !== null ? "\n" + " ".repeat(indent * (d + 1)) : "";
16088
+ for (const [key, child2] of cur.entries()) {
16089
+ if (index++) buf2 += indent === null ? ", " : ",";
16090
+ if (indent !== null) buf2 += childPad2;
16091
+ buf2 += JSON.stringify(key) + ": " + emitSyncJson(child2, indent, d + 1);
16092
+ }
16093
+ if (cur.size && indent !== null) buf2 += "\n" + " ".repeat(indent * d);
16094
+ buf2 += "}";
16095
+ return buf2;
16096
+ }
16097
+ const arr = cur;
16098
+ let buf = "[";
16099
+ const childPad = indent !== null ? "\n" + " ".repeat(indent * (d + 1)) : "";
16100
+ for (let index = 0; index < arr.length; index++) {
16101
+ if (index) buf += indent === null ? ", " : ",";
16102
+ if (indent !== null) buf += childPad;
16103
+ buf += emitSyncJson(arr[index], indent, d + 1);
16104
+ }
16105
+ if (arr.length && indent !== null) buf += "\n" + " ".repeat(indent * d);
16106
+ buf += "]";
16107
+ return buf;
16108
+ }
16109
+ function evalSyncCsvjson(inBytes, opArgs, readFileSync) {
16110
+ try {
16111
+ const opts = parseSyncCsvkitCommon(opArgs, "csvjson");
16112
+ if (!opts) return void 0;
16113
+ if (opts.streamOutput && opts.key !== null) return void 0;
16114
+ if (opts.streamOutput && opts.indent !== null) return void 0;
16115
+ const table = loadSyncTypedTable(inBytes, opts, readFileSync);
16116
+ if (!table) return void 0;
16117
+ const jsonify = (value) => {
16118
+ if (typeof value !== "object" || value === null) return value;
16119
+ if (value.kind === "decimal") return value.value.includes("NaN") ? NaN : Number(value.value);
16120
+ if (value.kind === "datetime") return value.value.replace(" ", "T");
16121
+ return pythonValueText(value);
16122
+ };
16123
+ const rows = table.rows.map(
16124
+ (row) => new Map(table.headers.map((name, index) => [name, jsonify(row[index])]))
16125
+ );
16126
+ let output = rows;
16127
+ if (opts.key !== null) {
16128
+ const column = table.headers.indexOf(opts.key);
16129
+ if (column < 0 && rows.length) return void 0;
16130
+ const keyed = /* @__PURE__ */ new Map();
16131
+ for (const [index, row] of table.rows.entries()) {
16132
+ const cell2 = row[column];
16133
+ const value = cell2 === null ? "None" : typeof cell2 === "object" && cell2.kind === "decimal" ? Decimal.parse(cell2.value).normalized().toString() : pythonValueText(cell2);
16134
+ if (keyed.has(value)) return void 0;
16135
+ keyed.set(value, rows[index]);
16136
+ }
16137
+ output = keyed;
16138
+ }
16139
+ let out = opts.addBom ? "\uFEFF" : "";
16140
+ if (opts.streamOutput) {
16141
+ for (const row of rows) {
16142
+ out += emitSyncJson(row, opts.indent) + "\n";
16143
+ }
16144
+ return out;
16145
+ }
16146
+ out += emitSyncJson(output, opts.indent);
16147
+ return out;
16148
+ } catch {
16149
+ return void 0;
16150
+ }
16151
+ }
16152
+ function evalSyncCsvsort(inBytes, opArgs, readFileSync) {
16153
+ try {
16154
+ let columnsSpec = null;
16155
+ let reverse = false;
16156
+ let ignoreCase = false;
16157
+ let namesOnly = false;
16158
+ let zeroBased = false;
16159
+ const filteredArgs = [];
16160
+ let posDone = false;
16161
+ for (let i = 0; i < opArgs.length; i++) {
16162
+ const a = opArgs[i];
16163
+ if (!posDone && a === "--") {
16164
+ posDone = true;
16165
+ filteredArgs.push(a);
16166
+ continue;
16167
+ }
16168
+ if (!posDone && a.startsWith("-") && a !== "-") {
16169
+ if (a === "-r" || a === "--reverse") {
16170
+ reverse = true;
16171
+ continue;
16172
+ }
16173
+ if (a === "-i" || a === "--ignore-case") {
16174
+ ignoreCase = true;
16175
+ continue;
16176
+ }
16177
+ if (a === "-n" || a === "--names") {
16178
+ namesOnly = true;
16179
+ continue;
16180
+ }
16181
+ if (a === "--zero") {
16182
+ zeroBased = true;
16183
+ continue;
16184
+ }
16185
+ if (a === "-ri" || a === "-ir") {
16186
+ reverse = true;
16187
+ ignoreCase = true;
16188
+ continue;
16189
+ }
16190
+ if (a === "-c" || a.startsWith("-c") || a === "--columns" || a.startsWith("--columns=")) {
16191
+ const v = a.startsWith("--columns=") ? a.slice(10) : a.startsWith("-c=") ? a.slice(3) : a.length > 2 && a.startsWith("-c") ? a.slice(2) : opArgs[++i];
16192
+ if (v === void 0) return void 0;
16193
+ columnsSpec = v;
16194
+ continue;
16195
+ }
16196
+ }
16197
+ filteredArgs.push(a);
16198
+ }
16199
+ const opts = parseSyncCsvkitCommon(filteredArgs, "csvlook");
16200
+ if (!opts) return void 0;
16201
+ const table = loadSyncTypedTable(inBytes, opts, readFileSync);
16202
+ if (!table) return void 0;
16203
+ let out = opts.addBom ? "\uFEFF" : "";
16204
+ if (namesOnly) {
16205
+ if (opts.noHeaderRow) return void 0;
16206
+ for (let i = 0; i < table.headers.length; i++) {
16207
+ out += `${String(i + (zeroBased ? 0 : 1)).padStart(3, " ")}: ${table.headers[i]}
16208
+ `;
16209
+ }
16210
+ return out;
16211
+ }
16212
+ const columns = parseColumnIdentifiers(columnsSpec, table.headers, zeroBased ? 0 : 1, null, () => {
16213
+ }, true);
16214
+ const rows = [...table.rows];
16215
+ const keyed = rows.map(
16216
+ (row) => columns.map((idx) => {
16217
+ const val = row[idx];
16218
+ return ignoreCase && typeof val === "string" ? val.toUpperCase() : val;
16219
+ })
16220
+ );
16221
+ const indices = rows.map((_, i) => i);
16222
+ indices.sort((a, b) => {
16223
+ for (let c = 0; c < columns.length; c++) {
16224
+ const x = keyed[a][c];
16225
+ const y = keyed[b][c];
16226
+ let order = 0;
16227
+ if (x === null || y === null) order = x === null ? y === null ? 0 : 1 : -1;
16228
+ else if (typeof x === "string" && typeof y === "string") {
16229
+ order = x < y ? -1 : x > y ? 1 : 0;
16230
+ } else if (typeof x === "boolean" && typeof y === "boolean") {
16231
+ order = Number(x) - Number(y);
16232
+ } else if (typeof x === "object" && typeof y === "object" && x.kind === "decimal" && y.kind === "decimal") {
16233
+ if (x.value.includes("NaN") || y.value.includes("NaN")) throw new Error("NaN");
16234
+ order = Decimal.parse(x.value).compare(Decimal.parse(y.value));
16235
+ } else if (typeof x === "object" && typeof y === "object" && (x.kind === "date" || x.kind === "datetime") && (y.kind === "date" || y.kind === "datetime") && x.kind === y.kind) {
16236
+ order = x.value < y.value ? -1 : x.value > y.value ? 1 : 0;
16237
+ } else if (typeof x === "object" && typeof y === "object" && x.kind === "timedelta" && y.kind === "timedelta") {
16238
+ order = x.microseconds < y.microseconds ? -1 : x.microseconds > y.microseconds ? 1 : 0;
16239
+ } else {
16240
+ throw new Error("unsupported type");
16241
+ }
16242
+ if (order !== 0) return reverse ? -order : order;
16243
+ }
16244
+ return 0;
16245
+ });
16246
+ const outDialect = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
16247
+ out += writeCsvRow(table.headers, outDialect);
16248
+ for (const idx of indices) {
16249
+ const formattedCells = rows[idx].map((v) => {
16250
+ if (v === null) return "";
16251
+ if (typeof v === "object" && v.kind === "datetime") return v.value.replace(" ", "T");
16252
+ return pythonValueText(v);
16253
+ });
16254
+ out += writeCsvRow(formattedCells, outDialect);
16255
+ }
16256
+ return out;
16257
+ } catch {
16258
+ return void 0;
16259
+ }
16260
+ }
16261
+ function evalSyncCsvformat(inBytes, opArgs, readFileSync) {
16262
+ try {
16263
+ let outDelimiter = ",";
16264
+ let outTabs = false;
16265
+ let outAsv = false;
16266
+ let outQuotechar = '"';
16267
+ let outQuoting = 0;
16268
+ let outNoDoublequote = false;
16269
+ let outEscapechar;
16270
+ let outLineterminator = "\n";
16271
+ let skipHeader = false;
16272
+ const filteredArgs = [];
16273
+ let posDone = false;
16274
+ for (let i = 0; i < opArgs.length; i++) {
16275
+ const a = opArgs[i];
16276
+ if (!posDone && a === "--") {
16277
+ posDone = true;
16278
+ filteredArgs.push(a);
16279
+ continue;
16280
+ }
16281
+ if (!posDone && a.startsWith("-") && a !== "-") {
16282
+ if (a === "-E" || a === "--skip-header") {
16283
+ skipHeader = true;
16284
+ continue;
16285
+ }
16286
+ if (a === "-T" || a === "--out-tabs") {
16287
+ outTabs = true;
16288
+ continue;
16289
+ }
16290
+ if (a === "-A" || a === "--out-asv") {
16291
+ outAsv = true;
16292
+ continue;
16293
+ }
16294
+ if (a === "-B" || a === "--out-no-doublequote") {
16295
+ outNoDoublequote = true;
16296
+ continue;
16297
+ }
16298
+ if (a === "-D" || a.startsWith("-D") || a === "--out-delimiter" || a.startsWith("--out-delimiter=")) {
16299
+ const v = a.startsWith("--out-delimiter=") ? a.slice(16) : a.startsWith("-D=") ? a.slice(3) : a.length > 2 && a.startsWith("-D") ? a.slice(2) : opArgs[++i];
16300
+ if (!v || Array.from(v).length !== 1) return void 0;
16301
+ outDelimiter = v;
16302
+ continue;
16303
+ }
16304
+ if (a === "-Q" || a.startsWith("-Q") || a === "--out-quotechar" || a.startsWith("--out-quotechar=")) {
16305
+ const v = a.startsWith("--out-quotechar=") ? a.slice(16) : a.startsWith("-Q=") ? a.slice(3) : a.length > 2 && a.startsWith("-Q") ? a.slice(2) : opArgs[++i];
16306
+ if (!v || Array.from(v).length !== 1) return void 0;
16307
+ outQuotechar = v;
16308
+ continue;
16309
+ }
16310
+ if (a === "-P" || a === "--out-escapechar") {
16311
+ const v = opArgs[++i];
16312
+ if (!v || Array.from(v).length !== 1) return void 0;
16313
+ outEscapechar = v;
16314
+ continue;
16315
+ }
16316
+ if (a === "-M" || a.startsWith("-M") || a === "--out-lineterminator" || a.startsWith("--out-lineterminator=")) {
16317
+ const v = a.startsWith("--out-lineterminator=") ? a.slice(21) : a.startsWith("-M=") ? a.slice(3) : a.length > 2 && a.startsWith("-M") ? a.slice(2) : opArgs[++i];
16318
+ if (v === void 0) return void 0;
16319
+ outLineterminator = v;
16320
+ continue;
16321
+ }
16322
+ if (a === "-U" || a.startsWith("-U") || a === "--out-quoting" || a.startsWith("--out-quoting=")) {
16323
+ const v = a.startsWith("--out-quoting=") ? a.slice(14) : a.startsWith("-U=") ? a.slice(3) : a.length > 2 && a.startsWith("-U") ? a.slice(2) : opArgs[++i];
16324
+ if (v === void 0 || !/^[0123]$/.test(v)) return void 0;
16325
+ outQuoting = Number(v);
16326
+ continue;
16327
+ }
16328
+ }
16329
+ filteredArgs.push(a);
16330
+ }
16331
+ const opts = parseSyncCsvkitCommon(filteredArgs, "csvlook");
16332
+ if (!opts) return void 0;
16333
+ let sourceBytes = inBytes;
16334
+ if (opts.filePath !== void 0 && opts.filePath !== "-") {
16335
+ if (!readFileSync) return void 0;
16336
+ sourceBytes = readFileSync(opts.filePath);
16337
+ }
16338
+ if (!sourceBytes || sourceBytes.byteLength > 16384) return void 0;
16339
+ let text2 = syncUtf8Decoder.decode(sourceBytes);
16340
+ if (text2.charCodeAt(0) === 65279) text2 = text2.slice(1);
16341
+ if (opts.skipLines > 0) {
16342
+ let linesLeft = opts.skipLines;
16343
+ let pos = 0;
16344
+ while (pos < text2.length && linesLeft > 0) {
16345
+ const ch = text2[pos++];
16346
+ if (ch === "\r") {
16347
+ if (text2[pos] === "\n") pos++;
16348
+ linesLeft--;
16349
+ } else if (ch === "\n") linesLeft--;
16350
+ }
16351
+ text2 = text2.slice(pos);
16352
+ }
16353
+ const explicitInDelimiter = opts.tabs ? " " : opts.delimiter;
16354
+ let inDialect = {
16355
+ ...explicitInDelimiter !== void 0 ? { delimiter: explicitInDelimiter } : {},
16356
+ ...opts.quotechar !== void 0 ? { quotechar: opts.quotechar } : {},
16357
+ ...opts.escapechar !== void 0 ? { escapechar: opts.escapechar } : {},
16358
+ doublequote: !opts.noDoublequote,
16359
+ skipinitialspace: opts.skipInitialSpace
16360
+ };
16361
+ if (!opts.tabs && opts.delimiter === void 0 && opts.quotechar === void 0 && opts.escapechar === void 0 && !opts.noDoublequote && !opts.skipInitialSpace && opts.sniffLimit !== 0 && text2.length > 0) {
16362
+ const sample = opts.sniffLimit > 0 ? text2.slice(0, opts.sniffLimit) : text2;
16363
+ if (sample.includes(",") && !/[\t;|:\x27]/.test(sample)) {
16364
+ inDialect = { delimiter: ",", quotechar: '"', doublequote: true, skipinitialspace: false };
16365
+ } else {
16366
+ const sniffed = sniff(sample);
16367
+ if (sniffed) inDialect = sniffed;
16368
+ }
16369
+ }
16370
+ const outDialect = {
16371
+ delimiter: outAsv ? "" : outTabs ? " " : outDelimiter,
16372
+ lineterminator: outAsv ? "" : outLineterminator,
16373
+ quotechar: outQuotechar,
16374
+ quoting: outQuoting,
16375
+ doublequote: !outNoDoublequote,
16376
+ ...outEscapechar !== void 0 ? { escapechar: outEscapechar } : {}
16377
+ };
16378
+ writeCsvRow([], outDialect);
16379
+ let out = opts.addBom ? "\uFEFF" : "";
16380
+ let first = true;
16381
+ for (const record of readCsv(text2, inDialect)) {
16382
+ const values = record.cells.map((c) => pythonValueText(c));
16383
+ if (first) {
16384
+ first = false;
16385
+ if (opts.noHeaderRow) {
16386
+ if (!skipHeader) {
16387
+ const hdr = defaultHeaders(values.length);
16388
+ out += writeCsvRow(opts.lineNumbers ? ["line_number", ...hdr] : hdr, outDialect);
16389
+ }
16390
+ } else {
16391
+ if (!skipHeader) {
16392
+ out += writeCsvRow(opts.lineNumbers ? ["line_number", ...values] : values, outDialect);
16393
+ }
16394
+ continue;
16395
+ }
16396
+ }
16397
+ const rowCells = opts.lineNumbers ? [String(record.line - (opts.noHeaderRow ? 0 : 1)), ...values] : values;
16398
+ out += writeCsvRow(rowCells, outDialect);
16399
+ }
16400
+ return out;
16401
+ } catch {
16402
+ return void 0;
16403
+ }
16404
+ }
16405
+ function evalSyncCsvstat(inBytes, opArgs, readFileSync) {
16406
+ try {
16407
+ let countOnly = false;
16408
+ let namesOnly = false;
16409
+ let zeroBased = false;
16410
+ let noGrouping = false;
16411
+ let columnsSpec = null;
16412
+ let metricOp;
16413
+ const filteredArgs = [];
16414
+ let posDone = false;
16415
+ for (let i = 0; i < opArgs.length; i++) {
16416
+ const a = opArgs[i];
16417
+ if (!posDone && a === "--") {
16418
+ posDone = true;
16419
+ filteredArgs.push(a);
16420
+ continue;
16421
+ }
16422
+ if (!posDone && a.startsWith("-") && a !== "-") {
16423
+ if (a === "--count") {
16424
+ countOnly = true;
16425
+ continue;
16426
+ }
16427
+ if (a === "-n" || a === "--names") {
16428
+ namesOnly = true;
16429
+ continue;
16430
+ }
16431
+ if (a === "--zero") {
16432
+ zeroBased = true;
16433
+ continue;
16434
+ }
16435
+ if (a === "-G" || a === "--no-grouping-separator") {
16436
+ noGrouping = true;
16437
+ continue;
16438
+ }
16439
+ if (a === "-c" || a.startsWith("-c") || a === "--columns" || a.startsWith("--columns=")) {
16440
+ const v = a.startsWith("--columns=") ? a.slice(10) : a.startsWith("-c=") ? a.slice(3) : a.length > 2 && a.startsWith("-c") ? a.slice(2) : opArgs[++i];
16441
+ if (!v) return void 0;
16442
+ columnsSpec = v;
16443
+ continue;
16444
+ }
16445
+ const mMap = {
16446
+ "--type": "type",
16447
+ "--nulls": "nulls",
16448
+ "--non-nulls": "nonnulls",
16449
+ "--unique": "unique",
16450
+ "--min": "min",
16451
+ "--max": "max",
16452
+ "--sum": "sum",
16453
+ "--mean": "mean",
16454
+ "--median": "median",
16455
+ "--stdev": "stdev",
16456
+ "--max-precision": "max_precision",
16457
+ "--len": "len"
16458
+ };
16459
+ if (mMap[a]) {
16460
+ if (metricOp !== void 0) return void 0;
16461
+ metricOp = mMap[a];
16462
+ continue;
16463
+ }
16464
+ }
16465
+ filteredArgs.push(a);
16466
+ }
16467
+ const modeCount = (countOnly ? 1 : 0) + (namesOnly ? 1 : 0) + (metricOp ? 1 : 0);
16468
+ if (modeCount !== 1) return void 0;
16469
+ const opts = parseSyncCsvkitCommon(filteredArgs, "csvlook");
16470
+ if (!opts) return void 0;
16471
+ const table = loadSyncTypedTable(inBytes, opts, readFileSync);
16472
+ if (!table) return void 0;
16473
+ let out = opts.addBom ? "\uFEFF" : "";
16474
+ if (namesOnly) {
16475
+ if (opts.noHeaderRow) return void 0;
16476
+ for (let i = 0; i < table.headers.length; i++) {
16477
+ out += `${String(i + (zeroBased ? 0 : 1)).padStart(3, " ")}: ${table.headers[i]}
16478
+ `;
16479
+ }
16480
+ return out;
16481
+ }
16482
+ if (countOnly) {
16483
+ return out + `${table.rows.length}
16484
+ `;
16485
+ }
16486
+ const ids = parseColumnIdentifiers(columnsSpec, table.headers, zeroBased ? 0 : 1, void 0, () => {
16487
+ }, true);
16488
+ const fmtDec = (d) => {
16489
+ const num = Number(d.toString());
16490
+ if (!Number.isFinite(num)) return d.toString();
16491
+ let s = num.toFixed(3);
16492
+ while (s.endsWith("0")) s = s.slice(0, -1);
16493
+ if (s.endsWith(".")) s = s.slice(0, -1);
16494
+ if (!noGrouping) {
16495
+ const [intPart = "", fracPart] = s.split(".");
16496
+ const sign = intPart.startsWith("-") ? "-" : "";
16497
+ const digits2 = sign ? intPart.slice(1) : intPart;
16498
+ const grouped = digits2.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
16499
+ s = sign + grouped + (fracPart !== void 0 ? "." + fracPart : "");
16500
+ }
16501
+ return s;
16502
+ };
16503
+ for (const id of ids) {
16504
+ const colType = table.columns[id].type;
16505
+ const values = table.rows.map((r) => r[id]);
16506
+ const nonNull = values.filter((v) => v !== null);
16507
+ let valStr = "None";
16508
+ if (metricOp === "type") valStr = colType;
16509
+ else if (metricOp === "nulls") valStr = nonNull.length !== values.length ? "True" : "False";
16510
+ else if (metricOp === "nonnulls") valStr = String(nonNull.length);
16511
+ else if (metricOp === "unique") {
16512
+ const seen = new Set(values.map((v) => v === null ? "null" : typeof v === "object" && v.kind === "decimal" ? "d:" + Decimal.parse(v.value).normalized().toString() : typeof v + ":" + pythonValueText(v)));
16513
+ valStr = String(seen.size);
16514
+ } else if (metricOp === "len" && colType === "Text") {
16515
+ let maxLen = 0;
16516
+ for (const v of nonNull) maxLen = Math.max(maxLen, Array.from(String(v)).length);
16517
+ valStr = fmtDec(Decimal.parse(String(maxLen)));
16518
+ } else if ((metricOp === "min" || metricOp === "max") && colType !== "Number") {
16519
+ if (nonNull.length > 0) {
16520
+ const strs = nonNull.map((v) => typeof v === "object" && v !== null && "value" in v ? String(v.value) : pythonValueText(v));
16521
+ let best = strs[0];
16522
+ for (let k = 1; k < strs.length; k++) {
16523
+ if (metricOp === "min" ? strs[k] < best : strs[k] > best) best = strs[k];
16524
+ }
16525
+ valStr = best;
16526
+ }
16527
+ } else if ((metricOp === "min" || metricOp === "max" || metricOp === "sum" || metricOp === "mean" || metricOp === "median" || metricOp === "stdev" || metricOp === "max_precision") && colType === "Number") {
16528
+ if (nonNull.length > 0) {
16529
+ const decs = nonNull.map((v) => Decimal.parse(v.value));
16530
+ if (metricOp === "min" || metricOp === "max") {
16531
+ let best = decs[0];
16532
+ for (let k = 1; k < decs.length; k++) {
16533
+ if (metricOp === "min" ? decs[k].compare(best) < 0 : decs[k].compare(best) > 0) best = decs[k];
16534
+ }
16535
+ valStr = fmtDec(best);
16536
+ } else if (metricOp === "max_precision") {
16537
+ let maxP = 0;
16538
+ for (const d of decs) {
16539
+ const norm = d.normalized();
16540
+ if (!norm.special && -norm.exponent > maxP) maxP = -norm.exponent;
16541
+ }
16542
+ valStr = fmtDec(Decimal.parse(String(maxP)));
16543
+ } else if (metricOp === "median") {
16544
+ const sorted = [...decs].sort((a, b) => a.compare(b));
16545
+ const mid = Math.floor(sorted.length / 2);
16546
+ const med = sorted.length % 2 === 1 ? sorted[mid] : sorted[mid - 1].add(sorted[mid]).divide(Decimal.parse("2"));
16547
+ valStr = fmtDec(med);
16548
+ } else if (metricOp === "stdev") {
16549
+ if (decs.length >= 2) {
16550
+ const nums = decs.map((d) => Number(d.toString()));
16551
+ if (nums.some((n) => !Number.isFinite(n))) return void 0;
16552
+ const mean = nums.reduce((a, b) => a + b, 0) / nums.length;
16553
+ const variance = nums.reduce((acc, n) => acc + (n - mean) * (n - mean), 0) / (nums.length - 1);
16554
+ valStr = fmtDec(Decimal.parse(String(Math.sqrt(variance))));
16555
+ }
16556
+ } else {
16557
+ let sum = Decimal.parse("0");
16558
+ for (const d of decs) sum = sum.add(d);
16559
+ valStr = fmtDec(metricOp === "sum" ? sum : sum.divide(Decimal.parse(String(decs.length))));
16560
+ }
16561
+ }
16562
+ } else {
16563
+ return void 0;
16564
+ }
16565
+ out += (ids.length === 1 ? "" : `${String(id + 1).padStart(3)}. ${table.headers[id]}: `) + valStr + "\n";
16566
+ }
16567
+ return out;
16568
+ } catch {
16569
+ return void 0;
16570
+ }
16571
+ }
16572
+ function evalSyncIn2csv(inBytes, opArgs, readFileSync) {
16573
+ try {
16574
+ let formatSpec;
16575
+ let keySpec;
16576
+ let schemaSpec;
16577
+ let sheetSpec;
16578
+ let namesOnly = false;
16579
+ const filteredArgs = [];
16580
+ let posDone = false;
16581
+ for (let i = 0; i < opArgs.length; i++) {
16582
+ const a = opArgs[i];
16583
+ if (!posDone && a === "--") {
16584
+ posDone = true;
16585
+ filteredArgs.push(a);
16586
+ continue;
16587
+ }
16588
+ if (!posDone && a.startsWith("-") && a !== "-") {
16589
+ if (a === "-n" || a === "--names") {
16590
+ namesOnly = true;
16591
+ continue;
16592
+ }
16593
+ if (a === "-f" || a.startsWith("-f") || a === "--format" || a.startsWith("--format=")) {
16594
+ const v = a.startsWith("--format=") ? a.slice(9) : a.startsWith("-f=") ? a.slice(3) : a.length > 2 && a.startsWith("-f") ? a.slice(2) : opArgs[++i];
16595
+ if (!v) return void 0;
16596
+ formatSpec = v.toLowerCase();
16597
+ continue;
16598
+ }
16599
+ if (a === "-k" || a.startsWith("-k") || a === "--key" || a.startsWith("--key=")) {
16600
+ const v = a.startsWith("--key=") ? a.slice(6) : a.startsWith("-k=") ? a.slice(3) : a.length > 2 && a.startsWith("-k") ? a.slice(2) : opArgs[++i];
16601
+ if (!v) return void 0;
16602
+ keySpec = v;
16603
+ continue;
16604
+ }
16605
+ if (a === "--sheet" || a.startsWith("--sheet=")) {
16606
+ const v = a.startsWith("--sheet=") ? a.slice(8) : opArgs[++i];
16607
+ if (!v) return void 0;
16608
+ sheetSpec = v;
16609
+ continue;
16610
+ }
16611
+ if (a === "-s" || a.startsWith("-s") || a === "--schema" || a.startsWith("--schema=")) {
16612
+ const v = a.startsWith("--schema=") ? a.slice(9) : a.startsWith("-s=") ? a.slice(3) : a.length > 2 && a.startsWith("-s") ? a.slice(2) : opArgs[++i];
16613
+ if (!v) return void 0;
16614
+ schemaSpec = v;
16615
+ continue;
16616
+ }
16617
+ }
16618
+ filteredArgs.push(a);
16619
+ }
16620
+ const opts = parseSyncCsvkitCommon(filteredArgs, "csvlook");
16621
+ if (!opts) return void 0;
16622
+ let sourceBytes = inBytes;
16623
+ if (opts.filePath !== void 0 && opts.filePath !== "-") {
16624
+ if (!readFileSync) return void 0;
16625
+ sourceBytes = readFileSync(opts.filePath);
16626
+ }
16627
+ if (!sourceBytes || sourceBytes.byteLength > 16384) return void 0;
16628
+ let fmt = formatSpec;
16629
+ if (!fmt && opts.filePath && opts.filePath !== "-") {
16630
+ const lower = opts.filePath.toLowerCase();
16631
+ if (lower.endsWith(".geojson")) fmt = "geojson";
16632
+ else if (lower.endsWith(".xlsx")) fmt = "xlsx";
16633
+ else if (lower.endsWith(".json") || lower.endsWith(".js")) fmt = "json";
16634
+ else if (lower.endsWith(".ndjson") || lower.endsWith(".jsonl")) fmt = "ndjson";
16635
+ else if (lower.endsWith(".csv") || lower.endsWith(".tsv")) fmt = "csv";
16636
+ }
16637
+ if (!fmt && schemaSpec !== void 0) fmt = "fixed";
16638
+ if (!fmt && keySpec !== void 0) fmt = "json";
16639
+ if (fmt === "geojson") {
16640
+ if (namesOnly) return void 0;
16641
+ let text3 = syncUtf8Decoder.decode(sourceBytes);
16642
+ if (text3.charCodeAt(0) === 65279) text3 = text3.slice(1);
16643
+ const doc = JSON.parse(text3);
16644
+ if (!doc || typeof doc !== "object" || Array.isArray(doc) || doc.type !== "FeatureCollection" || !Array.isArray(doc.features)) {
16645
+ return void 0;
16646
+ }
16647
+ const propKeys = [];
16648
+ const seenProps = /* @__PURE__ */ new Set();
16649
+ for (const feat of doc.features) {
16650
+ if (!feat || typeof feat !== "object" || Array.isArray(feat)) return void 0;
16651
+ const props = feat.properties && typeof feat.properties === "object" && !Array.isArray(feat.properties) ? feat.properties : {};
16652
+ for (const k of Object.keys(props)) {
16653
+ if (!seenProps.has(k)) {
16654
+ seenProps.add(k);
16655
+ propKeys.push(k);
16656
+ }
16657
+ }
16658
+ }
16659
+ const outDialect2 = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
16660
+ let out2 = writeCsvRow(["id", ...propKeys, "geojson", "type", "longitude", "latitude"], outDialect2);
16661
+ for (const feat of doc.features) {
16662
+ const props = feat.properties && typeof feat.properties === "object" && !Array.isArray(feat.properties) ? feat.properties : {};
16663
+ const geom = feat.geometry && typeof feat.geometry === "object" && !Array.isArray(feat.geometry) ? feat.geometry : null;
16664
+ const gType = geom ? String(geom.type ?? "") : "";
16665
+ const coords = gType === "Point" && Array.isArray(geom?.coordinates) && geom.coordinates.length >= 2 ? geom.coordinates : void 0;
16666
+ const fmtVal = (v, isProp = false) => {
16667
+ if (v === void 0 || v === null) return "";
16668
+ if (typeof v === "boolean") return v ? "True" : "False";
16669
+ if (typeof v === "object") return isProp ? JSON.stringify(v) : "";
16670
+ return String(v);
16671
+ };
16672
+ const geomJson = JSON.stringify(geom).replace(/":/g, '": ').replace(/,"/g, ', "');
16673
+ const rowCells = [
16674
+ fmtVal(feat.id),
16675
+ ...propKeys.map((k) => fmtVal(props[k], true)),
16676
+ geomJson,
16677
+ gType,
16678
+ coords ? fmtVal(coords[0]) : "",
16679
+ coords ? fmtVal(coords[1]) : ""
16680
+ ];
16681
+ out2 += writeCsvRow(rowCells, outDialect2);
16682
+ }
16683
+ return out2;
16684
+ }
16685
+ if (fmt === "xlsx") {
16686
+ if (sourceBytes[0] !== 80 || sourceBytes[1] !== 75) return void 0;
16687
+ const entries = readZipArchiveEntries(sourceBytes);
16688
+ if (entries.has("EncryptionInfo") || entries.has("EncryptedPackage")) return void 0;
16689
+ const wbXmlBytes = entries.get("xl/workbook.xml");
16690
+ if (!wbXmlBytes) return void 0;
16691
+ const wbXml = syncUtf8Decoder.decode(wbXmlBytes);
16692
+ const sheetNames = [];
16693
+ for (const m of wbXml.matchAll(/<sheet\b[^>]*\bname="([^"]+)"/g)) {
16694
+ sheetNames.push(m[1]);
16695
+ }
16696
+ if (sheetNames.length === 0) return void 0;
16697
+ if (namesOnly) {
16698
+ return sheetNames.map((n) => n + "\n").join("");
16699
+ }
16700
+ const targetIdx = sheetSpec ? sheetNames.indexOf(sheetSpec) : 0;
16701
+ if (targetIdx < 0) return void 0;
16702
+ const sheetBytes = entries.get(`xl/worksheets/sheet${targetIdx + 1}.xml`);
16703
+ if (!sheetBytes) return void 0;
16704
+ const sheetXml = syncUtf8Decoder.decode(sheetBytes);
16705
+ if (/<f(?:\s|>)/u.test(sheetXml)) return void 0;
16706
+ const sharedStrings = [];
16707
+ const sstBytes = entries.get("xl/sharedStrings.xml");
16708
+ if (sstBytes) {
16709
+ const sstXml = syncUtf8Decoder.decode(sstBytes);
16710
+ for (const si of sstXml.matchAll(/<si\b[\s\S]*?<\/si>/g)) {
16711
+ const parts = [...si[0].matchAll(/<t(?:\s[^>]*)?>([\s\S]*?)<\/t>/g)].map(
16712
+ (t) => (t[1] ?? "").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&")
16713
+ );
16714
+ sharedStrings.push(parts.join(""));
16715
+ }
16716
+ }
16717
+ const csvRows = [];
16718
+ for (const rm of sheetXml.matchAll(/<row\b[\s\S]*?<\/row>/g)) {
16719
+ const cells = [];
16720
+ for (const cm of rm[0].matchAll(/<c\b([^>]*?)(?:\/>|>([\s\S]*?)<\/c>)/g)) {
16721
+ const attrs = cm[1] ?? "";
16722
+ const body = cm[2] ?? "";
16723
+ const refM = /\br="([A-Z]+)\d+"/i.exec(attrs);
16724
+ if (refM?.[1]) {
16725
+ let col = 0;
16726
+ for (const ch of refM[1].toUpperCase()) col = col * 26 + (ch.charCodeAt(0) - 64);
16727
+ col -= 1;
16728
+ while (cells.length < col) cells.push("");
16729
+ }
16730
+ if (cm[2] === void 0) {
16731
+ cells.push("");
16732
+ continue;
16733
+ }
16734
+ const tM = /\bt="([^"]+)"/.exec(attrs);
16735
+ const cType = tM?.[1] ?? "n";
16736
+ if (cType === "inlineStr") {
16737
+ const tv = /<t(?:\s[^>]*)?>([\s\S]*?)<\/t>/.exec(body);
16738
+ cells.push((tv?.[1] ?? "").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&"));
16739
+ } else {
16740
+ const vv = /<v>([\s\S]*?)<\/v>/.exec(body);
16741
+ const raw = (vv?.[1] ?? "").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&");
16742
+ cells.push(cType === "s" ? sharedStrings[Number.parseInt(raw, 10)] ?? "" : raw);
16743
+ }
16744
+ }
16745
+ csvRows.push(cells);
16746
+ }
16747
+ const synthDialect = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
16748
+ const synthCsv = csvRows.map((r) => writeCsvRow(r, synthDialect)).join("");
16749
+ const synthBytes = new TextEncoder().encode(synthCsv);
16750
+ const table2 = loadSyncTypedTable(synthBytes, { ...opts, filePath: "-" }, void 0);
16751
+ if (!table2) return void 0;
16752
+ let out2 = opts.addBom ? "\uFEFF" : "";
16753
+ out2 += writeCsvRow(table2.headers, synthDialect);
16754
+ for (const row of table2.rows) {
16755
+ out2 += writeCsvRow(
16756
+ row.map((v) => v === null ? "" : typeof v === "object" && v.kind === "datetime" ? v.value.replace(" ", "T") : pythonValueText(v)),
16757
+ synthDialect
16758
+ );
16759
+ }
16760
+ return out2;
16761
+ }
16762
+ if (fmt === "fixed") {
16763
+ if (!schemaSpec || !readFileSync) return void 0;
16764
+ const schemaBytes = readFileSync(schemaSpec);
16765
+ if (!schemaBytes || schemaBytes.byteLength > 16384) return void 0;
16766
+ let schemaText = syncUtf8Decoder.decode(schemaBytes);
16767
+ if (schemaText.charCodeAt(0) === 65279) schemaText = schemaText.slice(1);
16768
+ const schemaRows = Array.from(readCsv(schemaText, { delimiter: ",", quotechar: '"', doublequote: true }), (record) => record.cells);
16769
+ if (schemaRows.length < 2) return void 0;
16770
+ const sHead = schemaRows[0];
16771
+ const colIdx = sHead.indexOf("column");
16772
+ const startIdx = sHead.indexOf("start");
16773
+ const lenIdx = sHead.indexOf("length");
16774
+ if (colIdx < 0 || startIdx < 0 || lenIdx < 0) return void 0;
16775
+ let oneBased;
16776
+ const fields = [];
16777
+ for (let r = 1; r < schemaRows.length; r++) {
16778
+ const row = schemaRows[r];
16779
+ if (row.length === 0 || row.length === 1 && row[0] === "") continue;
16780
+ const stNum = Number(row[startIdx]);
16781
+ const lnNum = Number(row[lenIdx]);
16782
+ if (!Number.isSafeInteger(stNum) || !Number.isSafeInteger(lnNum) || stNum < 0 || lnNum < 0) return void 0;
16783
+ oneBased ??= stNum === 1;
16784
+ fields.push({ name: row[colIdx], start: stNum - (oneBased ? 1 : 0), length: lnNum });
16785
+ }
16786
+ let inText = syncUtf8Decoder.decode(sourceBytes);
16787
+ if (inText.charCodeAt(0) === 65279) inText = inText.slice(1);
16788
+ const rawLines = inText.split(/\r?\n/);
16789
+ if (rawLines.length > 0 && rawLines[rawLines.length - 1] === "") rawLines.pop();
16790
+ const outDialect2 = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
16791
+ let out2 = opts.addBom ? "\uFEFF" : "";
16792
+ out2 += writeCsvRow(fields.map((f) => f.name), outDialect2);
16793
+ for (let idx = opts.skipLines; idx < rawLines.length; idx++) {
16794
+ const chars = Array.from(rawLines[idx]);
16795
+ const cells = fields.map((f) => chars.slice(f.start, f.start + f.length).join("").trim());
16796
+ out2 += writeCsvRow(cells, outDialect2);
16797
+ }
16798
+ return out2;
16799
+ }
16800
+ if (namesOnly) {
16801
+ if (fmt !== "json") return void 0;
16802
+ let text3 = syncUtf8Decoder.decode(sourceBytes);
16803
+ if (text3.charCodeAt(0) === 65279) text3 = text3.slice(1);
16804
+ const root = JSON.parse(text3);
16805
+ if (!root || typeof root !== "object" || Array.isArray(root)) return void 0;
16806
+ return Object.keys(root).map((k) => k + "\n").join("");
16807
+ }
16808
+ if (fmt === "csv") {
16809
+ const table2 = loadSyncTypedTable(inBytes, opts, readFileSync);
16810
+ if (!table2) return void 0;
16811
+ const outDialect2 = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
16812
+ let out2 = opts.addBom ? "\uFEFF" : "";
16813
+ out2 += writeCsvRow(table2.headers, outDialect2);
16814
+ for (const row of table2.rows) {
16815
+ out2 += writeCsvRow(
16816
+ row.map((v) => v === null ? "" : typeof v === "object" && v.kind === "datetime" ? v.value.replace(" ", "T") : pythonValueText(v)),
16817
+ outDialect2
16818
+ );
16819
+ }
16820
+ return out2;
16821
+ }
16822
+ if (fmt !== "json" && fmt !== "ndjson") return void 0;
16823
+ if (fmt === "ndjson" && keySpec !== void 0) return void 0;
16824
+ let text2 = syncUtf8Decoder.decode(sourceBytes);
16825
+ if (text2.charCodeAt(0) === 65279) text2 = text2.slice(1);
16826
+ let parsedItems;
16827
+ if (fmt === "ndjson") {
16828
+ parsedItems = [];
16829
+ for (const line of text2.split(/\r?\n/)) {
16830
+ const trimmed = line.trim();
16831
+ if (!trimmed) continue;
16832
+ parsedItems.push(JSON.parse(trimmed));
16833
+ }
16834
+ } else {
16835
+ let root = JSON.parse(text2);
16836
+ if (root && typeof root === "object" && !Array.isArray(root)) {
16837
+ if (!keySpec || !(keySpec in root)) return void 0;
16838
+ root = root[keySpec];
16839
+ }
16840
+ if (!Array.isArray(root)) return void 0;
16841
+ parsedItems = root;
16842
+ }
16843
+ const headers = [];
16844
+ const known = /* @__PURE__ */ new Set();
16845
+ const rawMaps = [];
16846
+ const flatten = (val, path, row) => {
16847
+ if (val !== null && typeof val === "object") {
16848
+ if (Array.isArray(val)) {
16849
+ for (let idx = 0; idx < val.length; idx++) flatten(val[idx], path + String(idx) + "/", row);
16850
+ } else {
16851
+ for (const [k, child2] of Object.entries(val)) flatten(child2, path + k + "/", row);
16852
+ }
16853
+ return;
16854
+ }
16855
+ let start = 0;
16856
+ let end = path.length;
16857
+ while (path[start] === "/") start++;
16858
+ while (end > start && path[end - 1] === "/") end--;
16859
+ const name = path.slice(start, end);
16860
+ if (!name) throw new Error("empty header");
16861
+ const cell2 = val === null || val === void 0 ? null : typeof val === "boolean" ? val ? "True" : "False" : String(val);
16862
+ row.set(name, cell2);
16863
+ };
16864
+ for (const item of parsedItems) {
16865
+ if (item === null || typeof item !== "object" || Array.isArray(item)) return void 0;
16866
+ const row = /* @__PURE__ */ new Map();
16867
+ flatten(item, "", row);
16868
+ for (const name of row.keys()) {
16869
+ if (!known.has(name)) {
16870
+ known.add(name);
16871
+ headers.push(name);
16872
+ }
16873
+ }
16874
+ rawMaps.push(row);
16875
+ }
16876
+ if (headers.length === 0) return void 0;
16877
+ const stringRows = rawMaps.map((m, rIdx) => {
16878
+ const cells = headers.map((h) => m.get(h) ?? "");
16879
+ return opts.lineNumbers ? [String(rIdx + 1), ...cells] : cells;
16880
+ });
16881
+ const finalHeaders = opts.lineNumbers ? ["line_number", ...headers] : headers;
16882
+ const inferenceOpts = {
16883
+ now: Date.now(),
16884
+ timezone: "UTC",
16885
+ noInference: opts.noInference,
16886
+ numberTextOnly: false,
16887
+ blanks: opts.blanks,
16888
+ nullValues: [],
16889
+ noLeadingZeroes: opts.noLeadingZeroes,
16890
+ maxDecimalDigits: Infinity,
16891
+ maxDecimalExponent: Infinity
16892
+ };
16893
+ const table = inferTable(finalHeaders, stringRows, inferenceOpts);
16894
+ const outDialect = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
16895
+ let out = opts.addBom ? "\uFEFF" : "";
16896
+ out += writeCsvRow(table.headers, outDialect);
16897
+ for (const row of table.rows) {
16898
+ out += writeCsvRow(
16899
+ row.map((v) => v === null ? "" : typeof v === "object" && v.kind === "datetime" ? v.value.replace(" ", "T") : pythonValueText(v)),
16900
+ outDialect
16901
+ );
16902
+ }
16903
+ return out;
16904
+ } catch {
16905
+ return void 0;
16906
+ }
16907
+ }
16908
+ function evalSyncCsvstack(inBytes, opArgs, readFileSync) {
16909
+ try {
16910
+ let groupsSpec;
16911
+ let groupName = "group";
16912
+ let groupByFilenames = false;
16913
+ let noHeaderRow = false;
16914
+ let lineNumbers = false;
16915
+ let addBom = false;
16916
+ let delimiter = ",";
16917
+ let tabs = false;
16918
+ const files = [];
16919
+ let posDone = false;
16920
+ for (let i = 0; i < opArgs.length; i++) {
16921
+ const a = opArgs[i];
16922
+ if (!posDone && a === "--") {
16923
+ posDone = true;
16924
+ continue;
16925
+ }
16926
+ if (!posDone && a.startsWith("-") && a !== "-") {
16927
+ if (a === "-H" || a === "--no-header-row") {
16928
+ noHeaderRow = true;
16929
+ continue;
16930
+ }
16931
+ if (a === "-l" || a === "--linenumbers") {
16932
+ lineNumbers = true;
16933
+ continue;
16934
+ }
16935
+ if (a === "--add-bom") {
16936
+ addBom = true;
16937
+ continue;
16938
+ }
16939
+ if (a === "-t" || a === "--tabs") {
16940
+ tabs = true;
16941
+ continue;
16942
+ }
16943
+ if (a === "-d" || a === "--delimiter" || a.startsWith("--delimiter=")) {
16944
+ const v = a.startsWith("--delimiter=") ? a.slice(12) : opArgs[++i];
16945
+ if (!v || Array.from(v).length !== 1) return void 0;
16946
+ delimiter = v;
16947
+ continue;
16948
+ }
16949
+ if (a === "--filenames") {
16950
+ groupByFilenames = true;
16951
+ continue;
16952
+ }
16953
+ if (a === "-g" || a === "--groups") {
16954
+ const v = opArgs[++i];
16955
+ if (v === void 0) return void 0;
16956
+ groupsSpec = v;
16957
+ continue;
16958
+ }
16959
+ if (a === "-n" || a === "--group-name") {
16960
+ const v = opArgs[++i];
16961
+ if (v === void 0) return void 0;
16962
+ groupName = v;
16963
+ continue;
16964
+ }
16965
+ return void 0;
16966
+ }
16967
+ files.push(a);
16968
+ }
16969
+ if (files.length === 0) files.push("-");
16970
+ if (noHeaderRow) return void 0;
16971
+ const groups = groupsSpec !== void 0 && !groupByFilenames ? groupsSpec.split(",") : void 0;
16972
+ if (groups && groups.length !== files.length) return void 0;
16973
+ const grouped = groupsSpec !== void 0 || groupByFilenames;
16974
+ const parsedFiles = [];
16975
+ const unionHeaders = [];
16976
+ const seen = /* @__PURE__ */ new Set();
16977
+ for (let idx = 0; idx < files.length; idx++) {
16978
+ const f = files[idx];
16979
+ const bytes = f === "-" ? inBytes : readFileSync ? readFileSync(f) : void 0;
16980
+ if (!bytes || bytes.byteLength > 16384) return void 0;
16981
+ let text2 = syncUtf8Decoder.decode(bytes);
16982
+ if (text2.charCodeAt(0) === 65279) text2 = text2.slice(1);
16983
+ const recs = [...readCsv(text2, { delimiter: tabs ? " " : delimiter, quotechar: '"', doublequote: true, skipinitialspace: false })];
16984
+ const hdr = recs[0] ? recs[0].cells.map((c) => pythonValueText(c)) : [];
16985
+ for (const h of hdr) {
16986
+ if (!seen.has(h)) {
16987
+ seen.add(h);
16988
+ unionHeaders.push(h);
16989
+ }
16990
+ }
16991
+ const groupVal = groups ? groups[idx] : f.split("/").at(-1);
16992
+ parsedFiles.push({
16993
+ group: groupVal,
16994
+ headers: hdr,
16995
+ rows: recs.slice(1).map((r) => r.cells.map((c) => pythonValueText(c)))
16996
+ });
16997
+ }
16998
+ const outHeaders = grouped ? [groupName, ...unionHeaders] : [...unionHeaders];
16999
+ const outDialect = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
17000
+ let out = addBom ? "\uFEFF" : "";
17001
+ out += writeCsvRow(lineNumbers ? ["line_number", ...outHeaders] : outHeaders, outDialect);
17002
+ let lineNum = 1;
17003
+ for (const pf of parsedFiles) {
17004
+ for (const r of pf.rows) {
17005
+ const rowMap = /* @__PURE__ */ new Map();
17006
+ for (let c = 0; c < pf.headers.length; c++) rowMap.set(pf.headers[c], r[c] ?? "");
17007
+ const cells = unionHeaders.map((h) => rowMap.get(h) ?? "");
17008
+ if (grouped) cells.unshift(pf.group);
17009
+ if (lineNumbers) cells.unshift(String(lineNum++));
17010
+ out += writeCsvRow(cells, outDialect);
17011
+ }
17012
+ }
17013
+ return out;
17014
+ } catch {
17015
+ return void 0;
17016
+ }
17017
+ }
17018
+ function evalSyncCsvjoin(inBytes, opArgs, readFileSync) {
17019
+ try {
17020
+ let columnsSpec;
17021
+ let joinMode = "inner";
17022
+ let noInference = false;
17023
+ let addBom = false;
17024
+ let delimiter;
17025
+ let tabs = false;
17026
+ const files = [];
17027
+ let posDone = false;
17028
+ for (let i = 0; i < opArgs.length; i++) {
17029
+ const a = opArgs[i];
17030
+ if (!posDone && a === "--") {
17031
+ posDone = true;
17032
+ continue;
17033
+ }
17034
+ if (!posDone && a.startsWith("-") && a !== "-") {
17035
+ if (a === "--left") {
17036
+ joinMode = "left";
17037
+ continue;
17038
+ }
17039
+ if (a === "--right") {
17040
+ joinMode = "right";
17041
+ continue;
17042
+ }
17043
+ if (a === "--outer") {
17044
+ joinMode = "outer";
17045
+ continue;
17046
+ }
17047
+ if (a === "-I" || a === "--no-inference") {
17048
+ noInference = true;
17049
+ continue;
17050
+ }
17051
+ if (a === "--add-bom") {
17052
+ addBom = true;
17053
+ continue;
17054
+ }
17055
+ if (a === "-t" || a === "--tabs") {
17056
+ tabs = true;
17057
+ continue;
17058
+ }
17059
+ if (a === "-d" || a === "--delimiter" || a.startsWith("--delimiter=")) {
17060
+ const v = a.startsWith("--delimiter=") ? a.slice(12) : opArgs[++i];
17061
+ if (!v || Array.from(v).length !== 1) return void 0;
17062
+ delimiter = v;
17063
+ continue;
17064
+ }
17065
+ if (a === "-c" || a === "--columns") {
17066
+ const v = opArgs[++i];
17067
+ if (v === void 0) return void 0;
17068
+ columnsSpec = v;
17069
+ continue;
17070
+ }
17071
+ return void 0;
17072
+ }
17073
+ files.push(a);
17074
+ }
17075
+ if (files.length !== 2) return void 0;
17076
+ const leftOpts = {
17077
+ ...delimiter === void 0 ? {} : { delimiter },
17078
+ tabs,
17079
+ noDoublequote: false,
17080
+ skipInitialSpace: false,
17081
+ noHeaderRow: false,
17082
+ skipLines: 0,
17083
+ lineNumbers: false,
17084
+ addBom: false,
17085
+ noInference,
17086
+ blanks: false,
17087
+ noLeadingZeroes: false,
17088
+ sniffLimit: 1024,
17089
+ noNumberEllipsis: false,
17090
+ indent: null,
17091
+ key: null,
17092
+ streamOutput: false,
17093
+ filePath: files[0]
17094
+ };
17095
+ const rightOpts = { ...leftOpts, filePath: files[1] };
17096
+ const leftTable = loadSyncTypedTable(inBytes, leftOpts, readFileSync);
17097
+ const rightTable = loadSyncTypedTable(inBytes, rightOpts, readFileSync);
17098
+ if (!leftTable || !rightTable) return void 0;
17099
+ if (!columnsSpec) {
17100
+ if (joinMode !== "inner") return void 0;
17101
+ const outHeaders2 = [
17102
+ ...leftTable.headers,
17103
+ ...rightTable.headers.map((h) => leftTable.headers.includes(h) ? h + "2" : h)
17104
+ ];
17105
+ if (new Set(outHeaders2).size !== outHeaders2.length) return void 0;
17106
+ const maxRows = Math.max(leftTable.rows.length, rightTable.rows.length);
17107
+ const outDialect2 = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
17108
+ let out2 = addBom ? "\uFEFF" : "";
17109
+ out2 += writeCsvRow(outHeaders2, outDialect2);
17110
+ for (let r = 0; r < maxRows; r++) {
17111
+ const lRow = leftTable.rows[r] ?? leftTable.headers.map(() => null);
17112
+ const rRow = rightTable.rows[r] ?? rightTable.headers.map(() => null);
17113
+ out2 += writeCsvRow(
17114
+ [...lRow, ...rRow].map((v) => v === null ? "" : typeof v === "object" && v.kind === "datetime" ? v.value.replace(" ", "T") : pythonValueText(v)),
17115
+ outDialect2
17116
+ );
17117
+ }
17118
+ return out2;
17119
+ }
17120
+ const colParts = columnsSpec.split(",");
17121
+ if (colParts.length !== 1 && colParts.length !== 2) return void 0;
17122
+ const leftKey = match(leftTable.headers, colParts[0], 1);
17123
+ const rightKey = match(rightTable.headers, colParts[1] ?? colParts[0], 1);
17124
+ const full = joinMode === "outer" || joinMode === "right";
17125
+ const inner = joinMode === "inner";
17126
+ const keyVal = (v) => {
17127
+ if (v === null) return "null";
17128
+ if (typeof v === "string") return "text:" + v;
17129
+ if (typeof v === "boolean") return v ? "number:1:0" : "number:0";
17130
+ if (v.kind === "decimal") {
17131
+ const d = Decimal.parse(v.value).normalized();
17132
+ return "number:" + d.toString();
17133
+ }
17134
+ return "other:" + pythonValueText(v);
17135
+ };
17136
+ const includedRight = rightTable.headers.map((_, idx) => idx).filter((idx) => full || idx !== rightKey);
17137
+ const outHeaders = [
17138
+ ...leftTable.headers,
17139
+ ...includedRight.map((idx) => leftTable.headers.includes(rightTable.headers[idx]) ? rightTable.headers[idx] + "2" : rightTable.headers[idx])
17140
+ ];
17141
+ if (new Set(outHeaders).size !== outHeaders.length) return void 0;
17142
+ const rightHash = /* @__PURE__ */ new Map();
17143
+ const rightKeys = [];
17144
+ for (const row of rightTable.rows) {
17145
+ const k = keyVal(row[rightKey]);
17146
+ rightKeys.push(k);
17147
+ const list = rightHash.get(k);
17148
+ if (list) list.push(row);
17149
+ else rightHash.set(k, [row]);
17150
+ }
17151
+ const joinedRows = [];
17152
+ const seenKeys = /* @__PURE__ */ new Set();
17153
+ for (const lRow of leftTable.rows) {
17154
+ const k = keyVal(lRow[leftKey]);
17155
+ const matches = k === "null" ? void 0 : rightHash.get(k);
17156
+ if (matches) {
17157
+ seenKeys.add(k);
17158
+ for (const rRow of matches) {
17159
+ joinedRows.push([...lRow, ...includedRight.map((idx) => rRow[idx])]);
17160
+ }
17161
+ } else if (!inner && joinMode !== "right") {
17162
+ joinedRows.push([...lRow, ...includedRight.map(() => null)]);
17163
+ }
17164
+ }
17165
+ if (full) {
17166
+ for (let i = 0; i < rightTable.rows.length; i++) {
17167
+ const k = rightKeys[i];
17168
+ if (k === "null" || !seenKeys.has(k)) {
17169
+ const rRow = rightTable.rows[i];
17170
+ joinedRows.push([...leftTable.headers.map(() => null), ...includedRight.map((idx) => rRow[idx])]);
17171
+ }
17172
+ }
17173
+ }
17174
+ const outDialect = { delimiter: ",", quotechar: '"', doublequote: true, lineterminator: "\n" };
17175
+ let out = addBom ? "\uFEFF" : "";
17176
+ out += writeCsvRow(outHeaders, outDialect);
17177
+ for (const row of joinedRows) {
17178
+ out += writeCsvRow(
17179
+ row.map((v) => v === null ? "" : typeof v === "object" && v.kind === "datetime" ? v.value.replace(" ", "T") : pythonValueText(v)),
17180
+ outDialect
17181
+ );
17182
+ }
17183
+ return out;
17184
+ } catch {
17185
+ return void 0;
17186
+ }
17187
+ }
17188
+
17189
+ // packages/safe-bash-command-csvkit/src/command.ts
17190
+ import { builtInDirectContextExecutors, syncCommandEvaluators } from "../safe-bash-contracts/runtime-control.js";
17191
+ function isDefaultCsvkitOptions(options) {
17192
+ if (!options) return true;
17193
+ return options.limits === void 0 && options.codecs === void 0 && options.locale === void 0 && options.clock === void 0 && options.terminal === void 0 && options.compression === void 0 && options.databases === void 0 && options.sqlDialects === void 0 && options.interpreter === void 0 && options.openMatchFile === void 0 && options.sniffing === void 0 && options.columnWarnings === void 0 && options.probeInputOpen === void 0;
17194
+ }
15710
17195
  function createCsvkitCommands(options = {}) {
15711
17196
  if (options.replace !== void 0 && typeof options.replace !== "boolean") throw new TypeError("csvkit replace must be boolean");
15712
17197
  const limits = Object.freeze({ ...defaultLimits, ...options.limits });
@@ -15724,7 +17209,7 @@ function createCsvkitCommands(options = {}) {
15724
17209
  });
15725
17210
  const columnWarnings = options.columnWarnings === void 0 ? Object.freeze({ suppressWarnings: true }) : Object.freeze({ ...options.columnWarnings });
15726
17211
  const probeInputOpen = options.probeInputOpen;
15727
- return Object.freeze(commands.map((descriptor) => ({
17212
+ const definitions = Object.freeze(commands.map((descriptor) => ({
15728
17213
  name: descriptor.name,
15729
17214
  ...descriptor.name === "csvcut" || descriptor.name === "csvgrep" ? { fallback: true } : {},
15730
17215
  description: `csvkit 2.2.0 ${descriptor.name}; compatibility gaps return status 78`,
@@ -15963,6 +17448,11 @@ function createCsvkitCommands(options = {}) {
15963
17448
  return { exitCode: result };
15964
17449
  }
15965
17450
  })));
17451
+ Object.assign(syncCommandEvaluators, { evalSyncCsvlook, evalSyncCsvjson, evalSyncCsvsort, evalSyncCsvformat, evalSyncCsvstat, evalSyncIn2csv, evalSyncCsvstack, evalSyncCsvjoin });
17452
+ if (isDefaultCsvkitOptions(options)) {
17453
+ for (const definition of definitions) builtInDirectContextExecutors.add(definition.execute);
17454
+ }
17455
+ return definitions;
15966
17456
  }
15967
17457
  function csvkitCommands(options = {}) {
15968
17458
  const definitions = createCsvkitCommands(options);
@@ -16014,6 +17504,14 @@ export {
16014
17504
  defaultSniffStreamProfile,
16015
17505
  deriveSchema,
16016
17506
  diagnosticReport,
17507
+ evalSyncCsvformat,
17508
+ evalSyncCsvjoin,
17509
+ evalSyncCsvjson,
17510
+ evalSyncCsvlook,
17511
+ evalSyncCsvsort,
17512
+ evalSyncCsvstack,
17513
+ evalSyncCsvstat,
17514
+ evalSyncIn2csv,
16017
17515
  execute,
16018
17516
  inferTable,
16019
17517
  match as matchColumnIdentifier,