just-bash 1.3.0 → 1.3.1
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.
- package/dist/ast/types.d.ts +2 -0
- package/dist/bin/just-bash.js +124 -116
- package/dist/bin/shell/shell.js +107 -99
- package/dist/bundle/ai/index.js +394 -386
- package/dist/bundle/index.js +120 -112
- package/dist/interpreter/types.d.ts +6 -0
- package/dist/shell-metadata.d.ts +28 -0
- package/package.json +1 -1
- package/dist/bin/chunks/alias-74DFXE2E.js +0 -7
- package/dist/bin/chunks/awk-S63F6IYK.js +0 -15
- package/dist/bin/chunks/awk2-4DKPX43H.js +0 -20
- package/dist/bin/chunks/awk2-6XCE67AX.js +0 -20
- package/dist/bin/chunks/awk2-DKAZ7LPG.js +0 -20
- package/dist/bin/chunks/awk2-GAJ72X3Z.js +0 -20
- package/dist/bin/chunks/awk2-HJAPWU2N.js +0 -18
- package/dist/bin/chunks/awk2-LVXC5OAC.js +0 -20
- package/dist/bin/chunks/awk2-T6HR4EYO.js +0 -20
- package/dist/bin/chunks/awk2-UYU2UYZ2.js +0 -20
- package/dist/bin/chunks/awk2-W64AZN7P.js +0 -20
- package/dist/bin/chunks/base64-KNBBHA5Y.js +0 -5
- package/dist/bin/chunks/base64-NC7HTKLZ.js +0 -5
- package/dist/bin/chunks/basename-Y7JDBYHN.js +0 -6
- package/dist/bin/chunks/bash-5IWSVGHN.js +0 -7
- package/dist/bin/chunks/bash-TQGTNXAE.js +0 -7
- package/dist/bin/chunks/cat-YZXBF5YF.js +0 -6
- package/dist/bin/chunks/chmod-3G4LK462.js +0 -9
- package/dist/bin/chunks/chunk-5KNEBKYN.js +0 -2
- package/dist/bin/chunks/chunk-6QUZ7QML.js +0 -3
- package/dist/bin/chunks/chunk-7Q4WQLOS.js +0 -9
- package/dist/bin/chunks/chunk-LV662IGP.js +0 -6
- package/dist/bin/chunks/clear-GTCFHSB2.js +0 -2
- package/dist/bin/chunks/cp-77UY7PGN.js +0 -8
- package/dist/bin/chunks/curl-NE7XEWMN.js +0 -26
- package/dist/bin/chunks/cut-UYV3FM7R.js +0 -6
- package/dist/bin/chunks/date-7NBRXV2Z.js +0 -5
- package/dist/bin/chunks/diff-TG2NXCX2.js +0 -19
- package/dist/bin/chunks/dirname-VLHP44TU.js +0 -5
- package/dist/bin/chunks/du-4FZ7WF2P.js +0 -8
- package/dist/bin/chunks/echo-DEUIS5JO.js +0 -4
- package/dist/bin/chunks/env-AKGX6HSG.js +0 -9
- package/dist/bin/chunks/env-FVITWNHG.js +0 -9
- package/dist/bin/chunks/expr-HA2ZNL6S.js +0 -5
- package/dist/bin/chunks/file-Q4UOC4J2.js +0 -23
- package/dist/bin/chunks/find-4B67H4RP.js +0 -11
- package/dist/bin/chunks/find-7BUNQZX4.js +0 -11
- package/dist/bin/chunks/find-AMA6ABN5.js +0 -11
- package/dist/bin/chunks/find-HW2TUO6B.js +0 -11
- package/dist/bin/chunks/find-JADNFF7V.js +0 -11
- package/dist/bin/chunks/find-NCI6KGUI.js +0 -11
- package/dist/bin/chunks/find-QEYP42JQ.js +0 -11
- package/dist/bin/chunks/find-WJV3FM6L.js +0 -11
- package/dist/bin/chunks/find-YATLECXJ.js +0 -11
- package/dist/bin/chunks/grep-OVWU4WCZ.js +0 -15
- package/dist/bin/chunks/grep-PHBFGJCV.js +0 -15
- package/dist/bin/chunks/head-VGXR3WWL.js +0 -2
- package/dist/bin/chunks/help-5V3MPCYQ.js +0 -16
- package/dist/bin/chunks/help-YQGNAT2T.js +0 -16
- package/dist/bin/chunks/history-PRQ4B6N2.js +0 -3
- package/dist/bin/chunks/html-to-markdown-L4UWMK4S.js +0 -84
- package/dist/bin/chunks/jq-EYSXBSCP.js +0 -14
- package/dist/bin/chunks/ln-DB7J2W5X.js +0 -10
- package/dist/bin/chunks/ls-C4MPAF3H.js +0 -26
- package/dist/bin/chunks/md5sum-KZ4MRIXM.js +0 -2
- package/dist/bin/chunks/mkdir-LWULWDHP.js +0 -7
- package/dist/bin/chunks/mv-TDYCNSIQ.js +0 -7
- package/dist/bin/chunks/paste-R36J3G4K.js +0 -8
- package/dist/bin/chunks/printf-ASOYDPIK.js +0 -14
- package/dist/bin/chunks/printf-BOFQVMMK.js +0 -15
- package/dist/bin/chunks/printf-WM4X6IZ6.js +0 -14
- package/dist/bin/chunks/pwd-X4MWD4JP.js +0 -3
- package/dist/bin/chunks/readlink-DPNOQY67.js +0 -7
- package/dist/bin/chunks/rm-W6CCBEMG.js +0 -8
- package/dist/bin/chunks/sed-7IS44XON.js +0 -48
- package/dist/bin/chunks/sed-B6FXUN7R.js +0 -80
- package/dist/bin/chunks/sed-LTCVBSRV.js +0 -80
- package/dist/bin/chunks/sed-RHLDIXPL.js +0 -76
- package/dist/bin/chunks/sed-SYSATJXR.js +0 -75
- package/dist/bin/chunks/seq-DGJILX2Q.js +0 -7
- package/dist/bin/chunks/sha1sum-XLRE72T4.js +0 -2
- package/dist/bin/chunks/sha256sum-BBKWFA43.js +0 -2
- package/dist/bin/chunks/sleep-E4DIYGTT.js +0 -10
- package/dist/bin/chunks/sort-NCQNGVCX.js +0 -16
- package/dist/bin/chunks/sort-UJP353TM.js +0 -15
- package/dist/bin/chunks/sort-WGKQ3WYR.js +0 -15
- package/dist/bin/chunks/stat-3PHITCPO.js +0 -9
- package/dist/bin/chunks/tail-YSVKBQ77.js +0 -2
- package/dist/bin/chunks/tee-UU2VS3OM.js +0 -3
- package/dist/bin/chunks/timeout-OZVAGW2H.js +0 -12
- package/dist/bin/chunks/timeout-RP2AJGMV.js +0 -12
- package/dist/bin/chunks/touch-XCIAYF5I.js +0 -4
- package/dist/bin/chunks/tr-2EEKHHO6.js +0 -20
- package/dist/bin/chunks/tree-4247W67O.js +0 -12
- package/dist/bin/chunks/true-JCX733LK.js +0 -2
- package/dist/bin/chunks/uniq-W4HF6YSB.js +0 -5
- package/dist/bin/chunks/wc-CNJ3QDRA.js +0 -6
- package/dist/bin/chunks/which-HX2NMOP3.js +0 -3
- package/dist/bin/chunks/xargs-DKUAYNEK.js +0 -4
- package/dist/bin/chunks/xargs-XAZFX5J3.js +0 -4
- package/dist/bin/chunks/xargs-YNLVLPOF.js +0 -4
- package/dist/bin/shell/chunks/alias-74DFXE2E.js +0 -7
- package/dist/bin/shell/chunks/awk-S63F6IYK.js +0 -15
- package/dist/bin/shell/chunks/awk2-4DKPX43H.js +0 -20
- package/dist/bin/shell/chunks/awk2-6XCE67AX.js +0 -20
- package/dist/bin/shell/chunks/awk2-DKAZ7LPG.js +0 -20
- package/dist/bin/shell/chunks/awk2-GAJ72X3Z.js +0 -20
- package/dist/bin/shell/chunks/awk2-HJAPWU2N.js +0 -18
- package/dist/bin/shell/chunks/awk2-LVXC5OAC.js +0 -20
- package/dist/bin/shell/chunks/awk2-T6HR4EYO.js +0 -20
- package/dist/bin/shell/chunks/awk2-UYU2UYZ2.js +0 -20
- package/dist/bin/shell/chunks/awk2-W64AZN7P.js +0 -20
- package/dist/bin/shell/chunks/base64-KNBBHA5Y.js +0 -5
- package/dist/bin/shell/chunks/base64-NC7HTKLZ.js +0 -5
- package/dist/bin/shell/chunks/basename-Y7JDBYHN.js +0 -6
- package/dist/bin/shell/chunks/bash-5IWSVGHN.js +0 -7
- package/dist/bin/shell/chunks/bash-TQGTNXAE.js +0 -7
- package/dist/bin/shell/chunks/cat-YZXBF5YF.js +0 -6
- package/dist/bin/shell/chunks/chmod-3G4LK462.js +0 -9
- package/dist/bin/shell/chunks/chunk-5KNEBKYN.js +0 -2
- package/dist/bin/shell/chunks/chunk-6QUZ7QML.js +0 -3
- package/dist/bin/shell/chunks/chunk-7Q4WQLOS.js +0 -9
- package/dist/bin/shell/chunks/chunk-LV662IGP.js +0 -6
- package/dist/bin/shell/chunks/clear-GTCFHSB2.js +0 -2
- package/dist/bin/shell/chunks/cp-77UY7PGN.js +0 -8
- package/dist/bin/shell/chunks/curl-NE7XEWMN.js +0 -26
- package/dist/bin/shell/chunks/cut-UYV3FM7R.js +0 -6
- package/dist/bin/shell/chunks/date-7NBRXV2Z.js +0 -5
- package/dist/bin/shell/chunks/diff-TG2NXCX2.js +0 -19
- package/dist/bin/shell/chunks/dirname-VLHP44TU.js +0 -5
- package/dist/bin/shell/chunks/du-4FZ7WF2P.js +0 -8
- package/dist/bin/shell/chunks/echo-DEUIS5JO.js +0 -4
- package/dist/bin/shell/chunks/env-AKGX6HSG.js +0 -9
- package/dist/bin/shell/chunks/env-FVITWNHG.js +0 -9
- package/dist/bin/shell/chunks/expr-HA2ZNL6S.js +0 -5
- package/dist/bin/shell/chunks/file-Q4UOC4J2.js +0 -23
- package/dist/bin/shell/chunks/find-4B67H4RP.js +0 -11
- package/dist/bin/shell/chunks/find-7BUNQZX4.js +0 -11
- package/dist/bin/shell/chunks/find-AMA6ABN5.js +0 -11
- package/dist/bin/shell/chunks/find-HW2TUO6B.js +0 -11
- package/dist/bin/shell/chunks/find-JADNFF7V.js +0 -11
- package/dist/bin/shell/chunks/find-NCI6KGUI.js +0 -11
- package/dist/bin/shell/chunks/find-QEYP42JQ.js +0 -11
- package/dist/bin/shell/chunks/find-WJV3FM6L.js +0 -11
- package/dist/bin/shell/chunks/find-YATLECXJ.js +0 -11
- package/dist/bin/shell/chunks/grep-OVWU4WCZ.js +0 -15
- package/dist/bin/shell/chunks/grep-PHBFGJCV.js +0 -15
- package/dist/bin/shell/chunks/head-VGXR3WWL.js +0 -2
- package/dist/bin/shell/chunks/help-5V3MPCYQ.js +0 -16
- package/dist/bin/shell/chunks/help-YQGNAT2T.js +0 -16
- package/dist/bin/shell/chunks/history-PRQ4B6N2.js +0 -3
- package/dist/bin/shell/chunks/html-to-markdown-L4UWMK4S.js +0 -84
- package/dist/bin/shell/chunks/jq-EYSXBSCP.js +0 -14
- package/dist/bin/shell/chunks/ln-DB7J2W5X.js +0 -10
- package/dist/bin/shell/chunks/ls-C4MPAF3H.js +0 -26
- package/dist/bin/shell/chunks/md5sum-KZ4MRIXM.js +0 -2
- package/dist/bin/shell/chunks/mkdir-LWULWDHP.js +0 -7
- package/dist/bin/shell/chunks/mv-TDYCNSIQ.js +0 -7
- package/dist/bin/shell/chunks/paste-R36J3G4K.js +0 -8
- package/dist/bin/shell/chunks/printf-ASOYDPIK.js +0 -14
- package/dist/bin/shell/chunks/printf-BOFQVMMK.js +0 -15
- package/dist/bin/shell/chunks/printf-WM4X6IZ6.js +0 -14
- package/dist/bin/shell/chunks/pwd-X4MWD4JP.js +0 -3
- package/dist/bin/shell/chunks/readlink-DPNOQY67.js +0 -7
- package/dist/bin/shell/chunks/rm-W6CCBEMG.js +0 -8
- package/dist/bin/shell/chunks/sed-7IS44XON.js +0 -48
- package/dist/bin/shell/chunks/sed-B6FXUN7R.js +0 -80
- package/dist/bin/shell/chunks/sed-LTCVBSRV.js +0 -80
- package/dist/bin/shell/chunks/sed-RHLDIXPL.js +0 -76
- package/dist/bin/shell/chunks/sed-SYSATJXR.js +0 -75
- package/dist/bin/shell/chunks/seq-DGJILX2Q.js +0 -7
- package/dist/bin/shell/chunks/sha1sum-XLRE72T4.js +0 -2
- package/dist/bin/shell/chunks/sha256sum-BBKWFA43.js +0 -2
- package/dist/bin/shell/chunks/sleep-E4DIYGTT.js +0 -10
- package/dist/bin/shell/chunks/sort-NCQNGVCX.js +0 -16
- package/dist/bin/shell/chunks/sort-UJP353TM.js +0 -15
- package/dist/bin/shell/chunks/sort-WGKQ3WYR.js +0 -15
- package/dist/bin/shell/chunks/stat-3PHITCPO.js +0 -9
- package/dist/bin/shell/chunks/tail-YSVKBQ77.js +0 -2
- package/dist/bin/shell/chunks/tee-UU2VS3OM.js +0 -3
- package/dist/bin/shell/chunks/timeout-OZVAGW2H.js +0 -12
- package/dist/bin/shell/chunks/timeout-RP2AJGMV.js +0 -12
- package/dist/bin/shell/chunks/touch-XCIAYF5I.js +0 -4
- package/dist/bin/shell/chunks/tr-2EEKHHO6.js +0 -20
- package/dist/bin/shell/chunks/tree-4247W67O.js +0 -12
- package/dist/bin/shell/chunks/true-JCX733LK.js +0 -2
- package/dist/bin/shell/chunks/uniq-W4HF6YSB.js +0 -5
- package/dist/bin/shell/chunks/wc-CNJ3QDRA.js +0 -6
- package/dist/bin/shell/chunks/which-HX2NMOP3.js +0 -3
- package/dist/bin/shell/chunks/xargs-DKUAYNEK.js +0 -4
- package/dist/bin/shell/chunks/xargs-XAZFX5J3.js +0 -4
- package/dist/bin/shell/chunks/xargs-YNLVLPOF.js +0 -4
- package/dist/bundle/chunks/alias-7ZSTROM7.js +0 -6
- package/dist/bundle/chunks/awk-V4C3GTJI.js +0 -14
- package/dist/bundle/chunks/awk2-365HINHI.js +0 -19
- package/dist/bundle/chunks/awk2-4YCQ6UCB.js +0 -19
- package/dist/bundle/chunks/awk2-7YCFY7D2.js +0 -19
- package/dist/bundle/chunks/awk2-7YL3P4KU.js +0 -19
- package/dist/bundle/chunks/awk2-ETXZHQQ4.js +0 -19
- package/dist/bundle/chunks/awk2-FMEL7ESV.js +0 -19
- package/dist/bundle/chunks/awk2-LE4QUFGK.js +0 -19
- package/dist/bundle/chunks/awk2-MGHA6JPJ.js +0 -17
- package/dist/bundle/chunks/awk2-XEAK5PBN.js +0 -19
- package/dist/bundle/chunks/base64-JN6XXTIG.js +0 -4
- package/dist/bundle/chunks/base64-WATI5PWI.js +0 -4
- package/dist/bundle/chunks/basename-SB5JXIY3.js +0 -5
- package/dist/bundle/chunks/bash-5WG5RD6L.js +0 -6
- package/dist/bundle/chunks/bash-T4PXVRYX.js +0 -6
- package/dist/bundle/chunks/cat-5KESXK2M.js +0 -5
- package/dist/bundle/chunks/chmod-VLKWIL3N.js +0 -8
- package/dist/bundle/chunks/chunk-4HEWHW5W.js +0 -8
- package/dist/bundle/chunks/chunk-JYYFSUWP.js +0 -5
- package/dist/bundle/chunks/chunk-TDJNT32M.js +0 -2
- package/dist/bundle/chunks/clear-ZBD2DMXN.js +0 -1
- package/dist/bundle/chunks/cp-BLHAPLQZ.js +0 -7
- package/dist/bundle/chunks/curl-PA2MWGKN.js +0 -25
- package/dist/bundle/chunks/cut-7RHEYJ7Y.js +0 -5
- package/dist/bundle/chunks/date-YOOSNZVA.js +0 -4
- package/dist/bundle/chunks/diff-IVJFQANX.js +0 -6
- package/dist/bundle/chunks/dirname-Q5HDZLH2.js +0 -4
- package/dist/bundle/chunks/du-I5HYAKTQ.js +0 -7
- package/dist/bundle/chunks/echo-W2TA2N7Y.js +0 -3
- package/dist/bundle/chunks/env-2F2VHNYS.js +0 -8
- package/dist/bundle/chunks/env-OORA5GFS.js +0 -8
- package/dist/bundle/chunks/expr-A4LJAGVP.js +0 -4
- package/dist/bundle/chunks/file-JMDIXLHY.js +0 -22
- package/dist/bundle/chunks/find-3O5V74IR.js +0 -10
- package/dist/bundle/chunks/find-4QUN2ATO.js +0 -10
- package/dist/bundle/chunks/find-522XP4ZY.js +0 -10
- package/dist/bundle/chunks/find-5UN24ZV7.js +0 -10
- package/dist/bundle/chunks/find-JXG2HF6L.js +0 -10
- package/dist/bundle/chunks/find-K3NO35MZ.js +0 -10
- package/dist/bundle/chunks/find-K7D4PKHS.js +0 -10
- package/dist/bundle/chunks/find-KP4M5DWC.js +0 -10
- package/dist/bundle/chunks/find-WM6ZETA7.js +0 -10
- package/dist/bundle/chunks/grep-3D2INI4S.js +0 -14
- package/dist/bundle/chunks/grep-CZTYKNEE.js +0 -14
- package/dist/bundle/chunks/head-7H5R4WKO.js +0 -1
- package/dist/bundle/chunks/help-SDCRRU2F.js +0 -15
- package/dist/bundle/chunks/help-XHGUXTV3.js +0 -15
- package/dist/bundle/chunks/history-7Z2STZ6Y.js +0 -2
- package/dist/bundle/chunks/html-to-markdown-XMBYO6FD.js +0 -4
- package/dist/bundle/chunks/jq-7R2XGLLH.js +0 -13
- package/dist/bundle/chunks/ln-UTUVIAFP.js +0 -9
- package/dist/bundle/chunks/ls-B7C35UDO.js +0 -23
- package/dist/bundle/chunks/md5sum-3BXZVFKC.js +0 -1
- package/dist/bundle/chunks/mkdir-WYI2LJ6H.js +0 -6
- package/dist/bundle/chunks/mv-GN23UIZU.js +0 -6
- package/dist/bundle/chunks/paste-L4TYPVSP.js +0 -7
- package/dist/bundle/chunks/printf-3ZT5XOIZ.js +0 -14
- package/dist/bundle/chunks/printf-G2SBUNW3.js +0 -13
- package/dist/bundle/chunks/printf-O2UW73XK.js +0 -13
- package/dist/bundle/chunks/pwd-ZVX5RTL4.js +0 -2
- package/dist/bundle/chunks/readlink-HHC33N5C.js +0 -6
- package/dist/bundle/chunks/rm-5X2XSQQ6.js +0 -7
- package/dist/bundle/chunks/sed-2WWCANZT.js +0 -79
- package/dist/bundle/chunks/sed-5LZHAGFR.js +0 -74
- package/dist/bundle/chunks/sed-IGVS3UIY.js +0 -79
- package/dist/bundle/chunks/sed-UZJSXYQZ.js +0 -47
- package/dist/bundle/chunks/sed-V7XSBPTD.js +0 -75
- package/dist/bundle/chunks/seq-TFPZQZPJ.js +0 -6
- package/dist/bundle/chunks/sha1sum-MSBXCB4N.js +0 -1
- package/dist/bundle/chunks/sha256sum-YMKJMSTW.js +0 -1
- package/dist/bundle/chunks/sleep-QJBQD6VS.js +0 -9
- package/dist/bundle/chunks/sort-LHMQWYH2.js +0 -14
- package/dist/bundle/chunks/sort-R3YWDMTV.js +0 -14
- package/dist/bundle/chunks/sort-TEXV7CUR.js +0 -15
- package/dist/bundle/chunks/stat-TM5F5YO4.js +0 -8
- package/dist/bundle/chunks/tail-BLGGG2VX.js +0 -1
- package/dist/bundle/chunks/tee-VCNOG5VI.js +0 -2
- package/dist/bundle/chunks/timeout-THAT7IOO.js +0 -11
- package/dist/bundle/chunks/timeout-VG2N46UR.js +0 -11
- package/dist/bundle/chunks/touch-Z5XRYFYY.js +0 -3
- package/dist/bundle/chunks/tr-UV4V27RJ.js +0 -19
- package/dist/bundle/chunks/tree-75UXQ4XJ.js +0 -11
- package/dist/bundle/chunks/true-OD7ZXH3O.js +0 -1
- package/dist/bundle/chunks/uniq-IIOQKNTS.js +0 -4
- package/dist/bundle/chunks/wc-OXLYBRUE.js +0 -5
- package/dist/bundle/chunks/which-ONWH3TNF.js +0 -2
- package/dist/bundle/chunks/xargs-752VENJT.js +0 -3
- package/dist/bundle/chunks/xargs-7KV5F66T.js +0 -3
- package/dist/bundle/chunks/xargs-E5JPQL24.js +0 -3
- package/dist/commands/awk/awk.d.ts +0 -2
- package/dist/commands/awk/executor.d.ts +0 -3
- package/dist/commands/awk/expressions.d.ts +0 -3
- package/dist/commands/awk/functions.d.ts +0 -12
- package/dist/commands/awk/interpreter2.d.ts +0 -90
- package/dist/commands/awk/parser.d.ts +0 -3
- package/dist/commands/awk/types.d.ts +0 -44
- package/dist/fs-interface.d.ts +0 -186
- package/dist/fs.d.ts +0 -39
- package/dist/overlay-fs/OverlayFs.d.ts +0 -87
- package/dist/overlay-fs/index.d.ts +0 -1
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as b}from"./chunk-4VDEBYW7.js";import{a as T,b as y,c as f}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function u(s){let t=s.indexOf("=");if(t>=0){let r=s.slice(0,t),e=s.slice(t+1);return r?`${encodeURIComponent(r)}=${encodeURIComponent(e)}`:encodeURIComponent(e)}return encodeURIComponent(s)}function c(s){let t=s.indexOf("=");if(t<0)return null;let r=s.slice(0,t),e=s.slice(t+1),i,a,o=e.match(/;type=([^;]+)$/);o&&(a=o[1],e=e.slice(0,-o[0].length));let n=e.match(/;filename=([^;]+)/);return n&&(i=n[1],e=e.replace(n[0],"")),(e.startsWith("@")||e.startsWith("<"))&&(i=i??e.slice(1).split("/").pop()),{name:r,value:e,filename:i,contentType:a}}function w(s,t){let r=`----CurlFormBoundary${Date.now().toString(36)}`,e=[];for(let i of s){let a=i.value;if(a.startsWith("@")||a.startsWith("<")){let n=a.slice(1);a=t.get(n)??""}let o=`--${r}\r
|
|
3
|
-
`;i.filename?(o+=`Content-Disposition: form-data; name="${i.name}"; filename="${i.filename}"\r
|
|
4
|
-
`,i.contentType&&(o+=`Content-Type: ${i.contentType}\r
|
|
5
|
-
`)):o+=`Content-Disposition: form-data; name="${i.name}"\r
|
|
6
|
-
`,o+=`\r
|
|
7
|
-
${a}\r
|
|
8
|
-
`,e.push(o)}return e.push(`--${r}--\r
|
|
9
|
-
`),{body:e.join(""),boundary:r}}var O={name:"curl",summary:"transfer a URL",usage:"curl [OPTIONS] URL",options:["-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)","-H, --header HEADER Add header (can be used multiple times)","-d, --data DATA HTTP POST data"," --data-raw DATA HTTP POST data (no @ interpretation)"," --data-binary DATA HTTP POST binary data"," --data-urlencode DATA URL-encode and POST data","-F, --form NAME=VALUE Multipart form data","-u, --user USER:PASS HTTP authentication","-A, --user-agent STR Set User-Agent header","-e, --referer URL Set Referer header","-b, --cookie DATA Send cookies (name=value or @file)","-c, --cookie-jar FILE Save cookies to file","-T, --upload-file FILE Upload file (PUT)","-o, --output FILE Write output to file","-O, --remote-name Write to file named from URL","-I, --head Show headers only (HEAD request)","-i, --include Include response headers in output","-s, --silent Silent mode (no progress)","-S, --show-error Show errors even when silent","-f, --fail Fail silently on HTTP errors (no output)","-L, --location Follow redirects (default)"," --max-redirs NUM Maximum redirects (default: 20)","-m, --max-time SECS Maximum time for request"," --connect-timeout SECS Connection timeout","-w, --write-out FMT Output format after completion","-v, --verbose Verbose output"," --help Display this help and exit","","Note: Network access must be configured via BashEnv network option."," curl is not available by default for security reasons."]};function S(s){let t={method:"GET",headers:{},dataBinary:!1,formFields:[],useRemoteName:!1,headOnly:!1,includeHeaders:!1,silent:!1,showError:!1,failSilently:!1,followRedirects:!0,verbose:!1};for(let r=0;r<s.length;r++){let e=s[r];if(e==="-X"||e==="--request")t.method=s[++r]??"GET";else if(e.startsWith("-X"))t.method=e.slice(2);else if(e.startsWith("--request="))t.method=e.slice(10);else if(e==="-H"||e==="--header"){let i=s[++r];if(i){let a=i.indexOf(":");if(a>0){let o=i.slice(0,a).trim(),n=i.slice(a+1).trim();t.headers[o]=n}}}else if(e.startsWith("--header=")){let i=e.slice(9),a=i.indexOf(":");if(a>0){let o=i.slice(0,a).trim(),n=i.slice(a+1).trim();t.headers[o]=n}}else if(e==="-d"||e==="--data"||e==="--data-raw")t.data=s[++r]??"",t.method==="GET"&&(t.method="POST");else if(e.startsWith("-d"))t.data=e.slice(2),t.method==="GET"&&(t.method="POST");else if(e.startsWith("--data="))t.data=e.slice(7),t.method==="GET"&&(t.method="POST");else if(e.startsWith("--data-raw="))t.data=e.slice(11),t.method==="GET"&&(t.method="POST");else if(e==="--data-binary")t.data=s[++r]??"",t.dataBinary=!0,t.method==="GET"&&(t.method="POST");else if(e.startsWith("--data-binary="))t.data=e.slice(14),t.dataBinary=!0,t.method==="GET"&&(t.method="POST");else if(e==="--data-urlencode"){let i=s[++r]??"";t.data=(t.data?`${t.data}&`:"")+u(i),t.method==="GET"&&(t.method="POST")}else if(e.startsWith("--data-urlencode=")){let i=e.slice(17);t.data=(t.data?`${t.data}&`:"")+u(i),t.method==="GET"&&(t.method="POST")}else if(e==="-F"||e==="--form"){let i=s[++r]??"",a=c(i);a&&t.formFields.push(a),t.method==="GET"&&(t.method="POST")}else if(e.startsWith("--form=")){let i=e.slice(7),a=c(i);a&&t.formFields.push(a),t.method==="GET"&&(t.method="POST")}else if(e==="-u"||e==="--user")t.user=s[++r];else if(e.startsWith("-u"))t.user=e.slice(2);else if(e.startsWith("--user="))t.user=e.slice(7);else if(e==="-A"||e==="--user-agent")t.headers["User-Agent"]=s[++r]??"";else if(e.startsWith("-A"))t.headers["User-Agent"]=e.slice(2);else if(e.startsWith("--user-agent="))t.headers["User-Agent"]=e.slice(13);else if(e==="-e"||e==="--referer")t.headers.Referer=s[++r]??"";else if(e.startsWith("-e"))t.headers.Referer=e.slice(2);else if(e.startsWith("--referer="))t.headers.Referer=e.slice(10);else if(e==="-b"||e==="--cookie")t.headers.Cookie=s[++r]??"";else if(e.startsWith("-b"))t.headers.Cookie=e.slice(2);else if(e.startsWith("--cookie="))t.headers.Cookie=e.slice(9);else if(e==="-c"||e==="--cookie-jar")t.cookieJar=s[++r];else if(e.startsWith("--cookie-jar="))t.cookieJar=e.slice(13);else if(e==="-T"||e==="--upload-file")t.uploadFile=s[++r],t.method==="GET"&&(t.method="PUT");else if(e.startsWith("--upload-file="))t.uploadFile=e.slice(14),t.method==="GET"&&(t.method="PUT");else if(e==="-m"||e==="--max-time"){let i=parseFloat(s[++r]??"0");!Number.isNaN(i)&&i>0&&(t.timeoutMs=i*1e3)}else if(e.startsWith("--max-time=")){let i=parseFloat(e.slice(11));!Number.isNaN(i)&&i>0&&(t.timeoutMs=i*1e3)}else if(e==="--connect-timeout"){let i=parseFloat(s[++r]??"0");!Number.isNaN(i)&&i>0&&t.timeoutMs===void 0&&(t.timeoutMs=i*1e3)}else if(e.startsWith("--connect-timeout=")){let i=parseFloat(e.slice(18));!Number.isNaN(i)&&i>0&&t.timeoutMs===void 0&&(t.timeoutMs=i*1e3)}else if(e==="-o"||e==="--output")t.outputFile=s[++r];else if(e.startsWith("--output="))t.outputFile=e.slice(9);else if(e==="-O"||e==="--remote-name")t.useRemoteName=!0;else if(e==="-I"||e==="--head")t.headOnly=!0,t.method="HEAD";else if(e==="-i"||e==="--include")t.includeHeaders=!0;else if(e==="-s"||e==="--silent")t.silent=!0;else if(e==="-S"||e==="--show-error")t.showError=!0;else if(e==="-f"||e==="--fail")t.failSilently=!0;else if(e==="-L"||e==="--location")t.followRedirects=!0;else if(e==="--max-redirs")r++;else if(!e.startsWith("--max-redirs="))if(e==="-w"||e==="--write-out")t.writeOut=s[++r];else if(e.startsWith("--write-out="))t.writeOut=e.slice(12);else if(e==="-v"||e==="--verbose")t.verbose=!0;else{if(e.startsWith("--")&&e!=="--")return f("curl",e);if(e.startsWith("-")&&e!=="-")for(let i of e.slice(1))switch(i){case"s":t.silent=!0;break;case"S":t.showError=!0;break;case"f":t.failSilently=!0;break;case"L":t.followRedirects=!0;break;case"I":t.headOnly=!0,t.method="HEAD";break;case"i":t.includeHeaders=!0;break;case"O":t.useRemoteName=!0;break;case"v":t.verbose=!0;break;default:return f("curl",`-${i}`)}else e.startsWith("-")||(t.url=e)}}return t}function h(s){return Object.entries(s).map(([t,r])=>`${t}: ${r}`).join(`\r
|
|
10
|
-
`)}function E(s){try{return new URL(s).pathname.split("/").pop()||"index.html"}catch{return"index.html"}}function m(s,t){let r=s;return r=r.replace(/%\{http_code\}/g,String(t.status)),r=r.replace(/%\{content_type\}/g,t.headers["content-type"]||""),r=r.replace(/%\{url_effective\}/g,t.url),r=r.replace(/%\{size_download\}/g,String(t.bodyLength)),r=r.replace(/\\n/g,`
|
|
11
|
-
`),r}async function F(s,t){if(s.uploadFile){let r=t.fs.resolvePath(t.cwd,s.uploadFile);return{body:await t.fs.readFile(r)}}if(s.formFields.length>0){let r=new Map;for(let a of s.formFields)if(a.value.startsWith("@")||a.value.startsWith("<")){let o=t.fs.resolvePath(t.cwd,a.value.slice(1));try{let n=await t.fs.readFile(o);r.set(a.value.slice(1),n)}catch{r.set(a.value.slice(1),"")}}let{body:e,boundary:i}=w(s.formFields,r);return{body:e,contentType:`multipart/form-data; boundary=${i}`}}return s.data!==void 0?{body:s.data}:{}}function P(s,t){let r={...s.headers};if(s.user){let e=Buffer.from(s.user).toString("base64");r.Authorization=`Basic ${e}`}return t&&!r["Content-Type"]&&(r["Content-Type"]=t),r}async function W(s,t,r){if(!s.cookieJar)return;let e=t["set-cookie"];if(!e)return;let i=r.fs.resolvePath(r.cwd,s.cookieJar);await r.fs.writeFile(i,e)}function $(s,t,r){let e="";if(s.verbose){e+=`> ${s.method} ${r}
|
|
12
|
-
`;for(let[i,a]of Object.entries(s.headers))e+=`> ${i}: ${a}
|
|
13
|
-
`;e+=`>
|
|
14
|
-
`,e+=`< HTTP/1.1 ${t.status} ${t.statusText}
|
|
15
|
-
`;for(let[i,a]of Object.entries(t.headers))e+=`< ${i}: ${a}
|
|
16
|
-
`;e+=`<
|
|
17
|
-
`}return s.includeHeaders&&!s.verbose&&(e+=`HTTP/1.1 ${t.status} ${t.statusText}\r
|
|
18
|
-
`,e+=h(t.headers),e+=`\r
|
|
19
|
-
\r
|
|
20
|
-
`),s.headOnly?s.includeHeaders||s.verbose||(e+=`HTTP/1.1 ${t.status} ${t.statusText}\r
|
|
21
|
-
`,e+=h(t.headers),e+=`\r
|
|
22
|
-
`):e+=t.body,s.writeOut&&(e+=m(s.writeOut,{status:t.status,headers:t.headers,url:t.url,bodyLength:t.body.length})),e}var I={name:"curl",async execute(s,t){if(y(s))return T(O);let r=S(s);if("exitCode"in r)return r;let e=r;if(!e.url)return{stdout:"",stderr:`curl: no URL specified
|
|
23
|
-
`,exitCode:2};if(!t.fetch)return{stdout:"",stderr:`curl: internal error: fetch not available
|
|
24
|
-
`,exitCode:1};let i=e.url;i.match(/^https?:\/\//)||(i=`https://${i}`);try{let{body:a,contentType:o}=await F(e,t),n=P(e,o),l=await t.fetch(i,{method:e.method,headers:Object.keys(n).length>0?n:void 0,body:a,followRedirects:e.followRedirects,timeoutMs:e.timeoutMs});if(await W(e,l.headers,t),e.failSilently&&l.status>=400)return{stdout:"",stderr:e.showError||!e.silent?`curl: (22) The requested URL returned error: ${l.status}
|
|
25
|
-
`:"",exitCode:22};let d=$(e,l,i);if(e.outputFile||e.useRemoteName){let p=e.outputFile||E(i),v=t.fs.resolvePath(t.cwd,p);await t.fs.writeFile(v,e.headOnly?"":l.body),e.verbose||(d=""),e.writeOut&&(d=m(e.writeOut,{status:l.status,headers:l.headers,url:l.url,bodyLength:l.body.length}))}return{stdout:d,stderr:"",exitCode:0}}catch(a){let o=b(a),n=1;return o.includes("Network access denied")?n=7:o.includes("HTTP method")&&o.includes("not allowed")?n=3:o.includes("Redirect target not in allow-list")||o.includes("Too many redirects")?n=47:o.includes("aborted")&&(n=28),{stdout:"",stderr:!e.silent||e.showError?`curl: (${n}) ${o}
|
|
26
|
-
`:"",exitCode:n}}}};export{I as curlCommand};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{b as x}from"./chunk-J7MJV6WO.js";import{a as y,b as I,c as m}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";var W={name:"cut",summary:"remove sections from each line of files",usage:"cut [OPTION]... [FILE]...",options:["-c LIST select only these characters","-d DELIM use DELIM instead of TAB for field delimiter","-f LIST select only these fields","-s, --only-delimited do not print lines without delimiters"," --help display this help and exit"]};function k(t){let c=[],l=t.split(",");for(let n of l)if(n.includes("-")){let[s,r]=n.split("-");c.push({start:s?parseInt(s,10):1,end:r?parseInt(r,10):null})}else{let s=parseInt(n,10);c.push({start:s,end:s})}return c}function C(t,c){let l=[];for(let n of c){let s=n.start-1,r=n.end===null?t.length:n.end;for(let i=s;i<r&&i<t.length;i++)i>=0&&!l.includes(t[i])&&l.push(t[i])}return l}var E={name:"cut",async execute(t,c){if(I(t))return y(W);let l=" ",n=null,s=null,r=!1,i=[];for(let o=0;o<t.length;o++){let e=t[o];if(e==="-d")l=t[++o]||" ";else if(e.startsWith("-d"))l=e.slice(2);else if(e==="-f")n=t[++o];else if(e.startsWith("-f"))n=e.slice(2);else if(e==="-c")s=t[++o];else if(e.startsWith("-c"))s=e.slice(2);else if(e==="-s"||e==="--only-delimited")r=!0;else{if(e.startsWith("--"))return m("cut",e);if(e.startsWith("-")){let f=!1;for(let u of e.slice(1))if(u==="s")r=!0;else if(!"dfc".includes(u)){f=!0;break}if(f)return m("cut",e)}else i.push(e)}}if(!n&&!s)return{stdout:"",stderr:`cut: you must specify a list of bytes, characters, or fields
|
|
3
|
-
`,exitCode:1};let p=await x(c,i,{cmdName:"cut"});if(!p.ok)return p.error;let a=p.content.split(`
|
|
4
|
-
`);a.length>0&&a[a.length-1]===""&&a.pop();let g=k(n||s||"1"),h="";for(let o of a)if(s){let e=o.split(""),f=[];for(let u of g){let w=u.start-1,L=u.end===null?e.length:u.end;for(let d=w;d<L&&d<e.length;d++)d>=0&&f.push(e[d])}h+=`${f.join("")}
|
|
5
|
-
`}else{if(r&&!o.includes(l))continue;let e=o.split(l),f=C(e,g);h+=`${f.join(l)}
|
|
6
|
-
`}return{stdout:h,stderr:"",exitCode:0}}};export{E as cutCommand};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as g,b as k,c as m}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";var p={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING display time described by STRING","-u, --utc print Coordinated Universal Time (UTC)","-I, --iso-8601 output date/time in ISO 8601 format","-R, --rfc-email output RFC 5322 date format"," --help display this help and exit"]},M=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function n(t,i=2){return String(t).padStart(i,"0")}function T(t){let i=-t.getTimezoneOffset();return`${i>=0?"+":"-"}${n(Math.floor(Math.abs(i)/60))}${n(Math.abs(i)%60)}`}function d(t,i,r){let a=r?{Y:t.getUTCFullYear(),m:t.getUTCMonth(),D:t.getUTCDate(),H:t.getUTCHours(),M:t.getUTCMinutes(),S:t.getUTCSeconds(),w:t.getUTCDay()}:{Y:t.getFullYear(),m:t.getMonth(),D:t.getDate(),H:t.getHours(),M:t.getMinutes(),S:t.getSeconds(),w:t.getDay()},e="",o=0;for(;o<i.length;){if(i[o]==="%"&&o+1<i.length){let c=i[++o];switch(c){case"%":e+="%";break;case"a":e+=M[a.w];break;case"b":case"h":e+=h[a.m];break;case"d":e+=n(a.D);break;case"e":e+=String(a.D).padStart(2," ");break;case"F":e+=`${a.Y}-${n(a.m+1)}-${n(a.D)}`;break;case"H":e+=n(a.H);break;case"I":e+=n(a.H%12||12);break;case"m":e+=n(a.m+1);break;case"M":e+=n(a.M);break;case"n":e+=`
|
|
3
|
-
`;break;case"p":e+=a.H<12?"AM":"PM";break;case"P":e+=a.H<12?"am":"pm";break;case"R":e+=`${n(a.H)}:${n(a.M)}`;break;case"s":e+=Math.floor(t.getTime()/1e3);break;case"S":e+=n(a.S);break;case"t":e+=" ";break;case"T":e+=`${n(a.H)}:${n(a.M)}:${n(a.S)}`;break;case"u":e+=a.w||7;break;case"w":e+=a.w;break;case"y":e+=n(a.Y%100);break;case"Y":e+=a.Y;break;case"z":e+=r?"+0000":T(t);break;case"Z":e+=r?"UTC":Intl.DateTimeFormat().resolvedOptions().timeZone;break;default:e+=`%${c}`}}else e+=i[o];o++}return e}function S(t){let i=new Date(t);if(!Number.isNaN(i.getTime()))return i;if(/^\d+$/.test(t))return new Date(Number.parseInt(t,10)*1e3);let r=t.toLowerCase();return r==="now"||r==="today"?new Date:r==="yesterday"?new Date(Date.now()-864e5):r==="tomorrow"?new Date(Date.now()+864e5):null}var w={name:"date",async execute(t,i){if(k(t))return g(p);let r=!1,a=null,e=null,o=!1,c=!1;for(let f=0;f<t.length;f++){let s=t[f];if(s==="-u"||s==="--utc")r=!0;else if(s==="-d"||s==="--date")a=t[++f]??"";else if(s.startsWith("--date="))a=s.slice(7);else if(s==="-I"||s==="--iso-8601")o=!0;else if(s==="-R"||s==="--rfc-email")c=!0;else if(s.startsWith("+"))e=s.slice(1);else{if(s.startsWith("--"))return m("date",s);if(s.startsWith("-"))for(let b of s.slice(1))if(b==="u")r=!0;else if(b==="I")o=!0;else if(b==="R")c=!0;else return m("date",`-${b}`)}}let l=a!==null?S(a):new Date;if(!l)return{stdout:"",stderr:`date: invalid date '${a}'
|
|
4
|
-
`,exitCode:1};let u;return e?u=d(l,e,r):o?u=d(l,"%Y-%m-%dT%H:%M:%S%z",r):c?u=d(l,"%a, %d %b %Y %H:%M:%S %z",r):u=d(l,"%a %b %e %H:%M:%S %Z %Y",r),{stdout:`${u}
|
|
5
|
-
`,stderr:"",exitCode:0}}};export{w as dateCommand};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as N}from"./chunk-TA7RUHGQ.js";import{a as S,b as E}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";var v=class{diff(e,t,n={}){let s;typeof n=="function"?(s=n,n={}):"callback"in n&&(s=n.callback);let u=this.castInput(e,n),f=this.castInput(t,n),i=this.removeEmpty(this.tokenize(u,n)),a=this.removeEmpty(this.tokenize(f,n));return this.diffWithOptionsObj(i,a,n,s)}diffWithOptionsObj(e,t,n,s){var u;let f=r=>{if(r=this.postProcess(r,n),s){setTimeout(function(){s(r)},0);return}else return r},i=t.length,a=e.length,d=1,o=i+a;n.maxEditLength!=null&&(o=Math.min(o,n.maxEditLength));let g=(u=n.timeout)!==null&&u!==void 0?u:1/0,w=Date.now()+g,m=[{oldPos:-1,lastComponent:void 0}],P=this.extractCommon(m[0],t,e,0,n);if(m[0].oldPos+1>=a&&P+1>=i)return f(this.buildValues(m[0].lastComponent,t,e));let C=-1/0,x=1/0,L=()=>{for(let r=Math.max(C,-d);r<=Math.min(x,d);r+=2){let c,h=m[r-1],p=m[r+1];h&&(m[r-1]=void 0);let y=!1;if(p){let I=p.oldPos-r;y=p&&0<=I&&I<i}let b=h&&h.oldPos+1<a;if(!y&&!b){m[r]=void 0;continue}if(!b||y&&h.oldPos<p.oldPos?c=this.addToPath(p,!0,!1,0,n):c=this.addToPath(h,!1,!0,1,n),P=this.extractCommon(c,t,e,r,n),c.oldPos+1>=a&&P+1>=i)return f(this.buildValues(c.lastComponent,t,e))||!0;m[r]=c,c.oldPos+1>=a&&(x=Math.min(x,r-1)),P+1>=i&&(C=Math.max(C,r+1))}d++};if(s)(function r(){setTimeout(function(){if(d>o||Date.now()>w)return s(void 0);L()||r()},0)})();else for(;d<=o&&Date.now()<=w;){let r=L();if(r)return r}}addToPath(e,t,n,s,u){let f=e.lastComponent;return f&&!u.oneChangePerToken&&f.added===t&&f.removed===n?{oldPos:e.oldPos+s,lastComponent:{count:f.count+1,added:t,removed:n,previousComponent:f.previousComponent}}:{oldPos:e.oldPos+s,lastComponent:{count:1,added:t,removed:n,previousComponent:f}}}extractCommon(e,t,n,s,u){let f=t.length,i=n.length,a=e.oldPos,d=a-s,o=0;for(;d+1<f&&a+1<i&&this.equals(n[a+1],t[d+1],u);)d++,a++,o++,u.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return o&&!u.oneChangePerToken&&(e.lastComponent={count:o,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=a,d}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join("")}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let s=[],u;for(;e;)s.push(e),u=e.previousComponent,delete e.previousComponent,e=u;s.reverse();let f=s.length,i=0,a=0,d=0;for(;i<f;i++){let o=s[i];if(o.removed)o.value=this.join(n.slice(d,d+o.count)),d+=o.count;else{if(!o.added&&this.useLongestToken){let g=t.slice(a,a+o.count);g=g.map(function(w,m){let P=n[d+m];return P.length>w.length?P:w}),o.value=this.join(g)}else o.value=this.join(t.slice(a,a+o.count));a+=o.count,o.added||(d+=o.count)}}return s}};var T=class extends v{constructor(){super(...arguments),this.tokenize=W}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
3
|
-
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
4
|
-
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
5
|
-
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
6
|
-
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}},O=new T;function D(l,e,t){return O.diff(l,e,t)}function W(l,e){e.stripTrailingCr&&(l=l.replace(/\r\n/g,`
|
|
7
|
-
`));let t=[],n=l.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(let s=0;s<n.length;s++){let u=n[s];s%2&&!e.newlineIsToken?t[t.length-1]+=u:t.push(u)}return t}function j(l,e,t,n,s,u,f){let i;f?typeof f=="function"?i={callback:f}:i=f:i={},typeof i.context>"u"&&(i.context=4);let a=i.context;if(i.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(i.callback){let{callback:o}=i;D(t,n,Object.assign(Object.assign({},i),{callback:g=>{let w=d(g);o(w)}}))}else return d(D(t,n,i));function d(o){if(!o)return;o.push({value:"",lines:[]});function g(r){return r.map(function(c){return" "+c})}let w=[],m=0,P=0,C=[],x=1,L=1;for(let r=0;r<o.length;r++){let c=o[r],h=c.lines||A(c.value);if(c.lines=h,c.added||c.removed){if(!m){let p=o[r-1];m=x,P=L,p&&(C=a>0?g(p.lines.slice(-a)):[],m-=C.length,P-=C.length)}for(let p of h)C.push((c.added?"+":"-")+p);c.added?L+=h.length:x+=h.length}else{if(m)if(h.length<=a*2&&r<o.length-2)for(let p of g(h))C.push(p);else{let p=Math.min(h.length,a);for(let b of g(h.slice(0,p)))C.push(b);let y={oldStart:m,oldLines:x-m+p,newStart:P,newLines:L-P+p,lines:C};w.push(y),m=0,P=0,C=[]}x+=h.length,L+=h.length}}for(let r of w)for(let c=0;c<r.lines.length;c++)r.lines[c].endsWith(`
|
|
8
|
-
`)?r.lines[c]=r.lines[c].slice(0,-1):(r.lines.splice(c+1,0,"\"),c++);return{oldFileName:l,newFileName:e,oldHeader:s,newHeader:u,hunks:w}}}function k(l){if(Array.isArray(l))return l.map(k).join(`
|
|
9
|
-
`);let e=[];l.oldFileName==l.newFileName&&e.push("Index: "+l.oldFileName),e.push("==================================================================="),e.push("--- "+l.oldFileName+(typeof l.oldHeader>"u"?"":" "+l.oldHeader)),e.push("+++ "+l.newFileName+(typeof l.newHeader>"u"?"":" "+l.newHeader));for(let t=0;t<l.hunks.length;t++){let n=l.hunks[t];n.oldLines===0&&(n.oldStart-=1),n.newLines===0&&(n.newStart-=1),e.push("@@ -"+n.oldStart+","+n.oldLines+" +"+n.newStart+","+n.newLines+" @@");for(let s of n.lines)e.push(s)}return e.join(`
|
|
10
|
-
`)+`
|
|
11
|
-
`}function F(l,e,t,n,s,u,f){if(typeof f=="function"&&(f={callback:f}),f?.callback){let{callback:i}=f;j(l,e,t,n,s,u,Object.assign(Object.assign({},f),{callback:a=>{i(a?k(a):void 0)}}))}else{let i=j(l,e,t,n,s,u,f);return i?k(i):void 0}}function A(l){let e=l.endsWith(`
|
|
12
|
-
`),t=l.split(`
|
|
13
|
-
`).map(n=>n+`
|
|
14
|
-
`);return e?t.pop():t.push(t.pop().slice(0,-1)),t}var z={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},H={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},K={name:"diff",async execute(l,e){if(E(l))return S(z);let t=N("diff",l,H);if(!t.ok)return t.error;let n=t.result.flags.brief,s=t.result.flags.reportSame,u=t.result.flags.ignoreCase,f=t.result.positional;if(t.result.flags.unified,f.length<2)return{stdout:"",stderr:`diff: missing operand
|
|
15
|
-
`,exitCode:2};let i,a,[d,o]=f;try{i=d==="-"?e.stdin:await e.fs.readFile(e.fs.resolvePath(e.cwd,d))}catch{return{stdout:"",stderr:`diff: ${d}: No such file or directory
|
|
16
|
-
`,exitCode:2}}try{a=o==="-"?e.stdin:await e.fs.readFile(e.fs.resolvePath(e.cwd,o))}catch{return{stdout:"",stderr:`diff: ${o}: No such file or directory
|
|
17
|
-
`,exitCode:2}}let g=i,w=a;return u&&(g=g.toLowerCase(),w=w.toLowerCase()),g===w?s?{stdout:`Files ${d} and ${o} are identical
|
|
18
|
-
`,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:n?{stdout:`Files ${d} and ${o} differ
|
|
19
|
-
`,stderr:"",exitCode:1}:{stdout:F(d,o,i,a,"","",{context:3}),stderr:"",exitCode:1}}};export{K as diffCommand};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as i,b as o}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";var m={name:"dirname",summary:"strip last component from file name",usage:"dirname [OPTION] NAME...",options:[" --help display this help and exit"]},p={name:"dirname",async execute(t,l){if(o(t))return i(m);let a=t.filter(n=>!n.startsWith("-"));if(a.length===0)return{stdout:"",stderr:`dirname: missing operand
|
|
3
|
-
`,exitCode:1};let e=[];for(let n of a){let r=n.replace(/\/+$/,""),s=r.lastIndexOf("/");s===-1?e.push("."):s===0?e.push("/"):e.push(r.slice(0,s))}return{stdout:`${e.join(`
|
|
4
|
-
`)}
|
|
5
|
-
`,stderr:"",exitCode:0}}};export{p as dirnameCommand};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as z}from"./chunk-TA7RUHGQ.js";import{a as p,b as g}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";var $={name:"du",summary:"estimate file space usage",usage:"du [OPTION]... [FILE]...",options:["-a write counts for all files, not just directories","-h print sizes in human readable format","-s display only a total for each argument","-c produce a grand total","--max-depth=N print total for directory only if N or fewer levels deep"," --help display this help and exit"]},D={allFiles:{short:"a",type:"boolean"},humanReadable:{short:"h",type:"boolean"},summarize:{short:"s",type:"boolean"},grandTotal:{short:"c",type:"boolean"},maxDepth:{long:"max-depth",type:"number"}},F={name:"du",async execute(t,l){if(g(t))return p($);let a=z("du",t,D);if(!a.ok)return a.error;let e={allFiles:a.result.flags.allFiles,humanReadable:a.result.flags.humanReadable,summarize:a.result.flags.summarize,grandTotal:a.result.flags.grandTotal,maxDepth:a.result.flags.maxDepth??null},s=a.result.positional;s.length===0&&s.push(".");let r="",n="",m=0;for(let o of s){let i=l.fs.resolvePath(l.cwd,o);try{await l.fs.stat(i);let u=await y(l,i,o,e,0);r+=u.output,m+=u.totalSize,n+=u.stderr}catch{n+=`du: cannot access '${o}': No such file or directory
|
|
3
|
-
`}}return e.grandTotal&&s.length>0&&(r+=`${d(m,e.humanReadable)} total
|
|
4
|
-
`),{stdout:r,stderr:n,exitCode:n?1:0}}};async function y(t,l,a,e,s){let r={output:"",totalSize:0,stderr:""};try{let n=await t.fs.stat(l);if(!n.isDirectory)return r.totalSize=n.size,(e.allFiles||s===0)&&(r.output=d(n.size,e.humanReadable)+" "+a+`
|
|
5
|
-
`),r;let m=await t.fs.readdir(l),o=0;for(let i of m){let u=l==="/"?`/${i}`:`${l}/${i}`,f=a==="."?i:`${a}/${i}`;try{let c=await t.fs.stat(u);if(c.isDirectory){let h=await y(t,u,f,e,s+1);o+=h.totalSize,e.summarize||(e.maxDepth===null||s+1<=e.maxDepth?r.output+=h.output:o+=0)}else o+=c.size,e.allFiles&&!e.summarize&&(r.output+=d(c.size,e.humanReadable)+" "+f+`
|
|
6
|
-
`)}catch{}}r.totalSize=o,(e.summarize||e.maxDepth===null||s<=e.maxDepth)&&(r.output+=`${d(o,e.humanReadable)} ${a}
|
|
7
|
-
`)}catch{r.stderr=`du: cannot read directory '${a}': Permission denied
|
|
8
|
-
`}return r}function d(t,l){return l?t<1024?`${t}`:t<1024*1024?`${(t/1024).toFixed(1)}K`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)}M`:`${(t/(1024*1024*1024)).toFixed(1)}G`:String(Math.ceil(t/1024)||1)}export{F as duCommand};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import"./chunk-5KNEBKYN.js";function o(a){let s="",e=0;for(;e<a.length;)if(a[e]==="\\"){if(e+1>=a.length){s+="\\";break}let c=a[e+1];switch(c){case"\\":s+="\\",e+=2;break;case"n":s+=`
|
|
3
|
-
`,e+=2;break;case"t":s+=" ",e+=2;break;case"r":s+="\r",e+=2;break;case"a":s+="\x07",e+=2;break;case"b":s+="\b",e+=2;break;case"f":s+="\f",e+=2;break;case"v":s+="\v",e+=2;break;case"e":case"E":s+="\x1B",e+=2;break;case"c":return{output:s,stop:!0};case"0":{let r="",t=e+2;for(;t<a.length&&t<e+5&&/[0-7]/.test(a[t]);)r+=a[t],t++;if(r.length===0)s+="\0";else{let l=parseInt(r,8)%256;s+=String.fromCharCode(l)}e=t;break}case"x":{let r="",t=e+2;for(;t<a.length&&t<e+4&&/[0-9a-fA-F]/.test(a[t]);)r+=a[t],t++;if(r.length===0)s+="\\x",e+=2;else{let l=parseInt(r,16);s+=String.fromCharCode(l),e=t}break}case"u":{let r="",t=e+2;for(;t<a.length&&t<e+6&&/[0-9a-fA-F]/.test(a[t]);)r+=a[t],t++;if(r.length===0)s+="\\u",e+=2;else{let l=parseInt(r,16);s+=String.fromCodePoint(l),e=t}break}case"U":{let r="",t=e+2;for(;t<a.length&&t<e+10&&/[0-9a-fA-F]/.test(a[t]);)r+=a[t],t++;if(r.length===0)s+="\\U",e+=2;else{let l=parseInt(r,16);try{s+=String.fromCodePoint(l)}catch{s+=`\\U${r}`}e=t}break}default:s+=`\\${c}`,e+=2}}else s+=a[e],e++;return{output:s,stop:!1}}var n={name:"echo",async execute(a,s){let e=!1,c=!1,r=0;for(;r<a.length;){let l=a[r];if(l==="-n")e=!0,r++;else if(l==="-e")c=!0,r++;else if(l==="-E")c=!1,r++;else if(l==="-ne"||l==="-en")e=!0,c=!0,r++;else break}let t=a.slice(r).join(" ");if(c){let l=o(t);if(t=l.output,l.stop)return{stdout:t,stderr:"",exitCode:0}}return e||(t+=`
|
|
4
|
-
`),{stdout:t,stderr:"",exitCode:0}}};export{n as echoCommand};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as m,b as f,c as p}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";var O={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},y={name:"env",async execute(s,i){if(f(s))return m(O);let u=!1,o=[],l={},t=-1;for(let n=0;n<s.length;n++){let e=s[n];if(e==="-i"||e==="--ignore-environment")u=!0;else if(e==="-u"&&n+1<s.length)o.push(s[++n]);else if(e.startsWith("-u"))o.push(e.slice(2));else if(e.startsWith("--unset="))o.push(e.slice(8));else{if(e.startsWith("--")&&e!=="--")return p("env",e);if(e.startsWith("-")&&e!=="-"){for(let r of e.slice(1))if(r!=="i"&&r!=="u")return p("env",`-${r}`);e.includes("i")&&(u=!0)}else if(e.includes("=")&&t===-1){let r=e.indexOf("="),h=e.slice(0,r),x=e.slice(r+1);l[h]=x}else{t=n;break}}}let a;if(u)a={...l};else{a={...i.env};for(let n of o)delete a[n];Object.assign(a,l)}if(t===-1){let n=[];for(let[e,r]of Object.entries(a))n.push(`${e}=${r}`);return{stdout:n.join(`
|
|
3
|
-
`)+(n.length>0?`
|
|
4
|
-
`:""),stderr:"",exitCode:0}}if(!i.exec)return{stdout:"",stderr:`env: command execution not supported in this context
|
|
5
|
-
`,exitCode:1};let c=s.slice(t).join(" "),d=Object.entries(l).map(([n,e])=>`${n}="${e}"`).join(" "),v=d?`${d} ${c}`:c;return i.exec(v,{cwd:i.cwd})}},g={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},A={name:"printenv",async execute(s,i){if(f(s))return m(g);let u=s.filter(t=>!t.startsWith("-"));if(u.length===0){let t=[];for(let[a,c]of Object.entries(i.env))t.push(`${a}=${c}`);return{stdout:t.join(`
|
|
6
|
-
`)+(t.length>0?`
|
|
7
|
-
`:""),stderr:"",exitCode:0}}let o=[],l=0;for(let t of u)t in i.env?o.push(i.env[t]):l=1;return{stdout:o.join(`
|
|
8
|
-
`)+(o.length>0?`
|
|
9
|
-
`:""),stderr:"",exitCode:l}}};export{y as envCommand,A as printenvCommand};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as m,b as f,c as p}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";var O={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},y={name:"env",async execute(s,r){if(f(s))return m(O);let u=!1,i=[],l={},t=-1;for(let n=0;n<s.length;n++){let e=s[n];if(e==="-i"||e==="--ignore-environment")u=!0;else if(e==="-u"&&n+1<s.length)i.push(s[++n]);else if(e.startsWith("-u"))i.push(e.slice(2));else if(e.startsWith("--unset="))i.push(e.slice(8));else{if(e.startsWith("--")&&e!=="--")return p("env",e);if(e.startsWith("-")&&e!=="-"){for(let o of e.slice(1))if(o!=="i"&&o!=="u")return p("env",`-${o}`);e.includes("i")&&(u=!0)}else if(e.includes("=")&&t===-1){let o=e.indexOf("="),h=e.slice(0,o),x=e.slice(o+1);l[h]=x}else{t=n;break}}}let a;if(u)a={...l};else{a={...r.env};for(let n of i)delete a[n];Object.assign(a,l)}if(t===-1){let n=[];for(let[e,o]of Object.entries(a))n.push(`${e}=${o}`);return{stdout:n.join(`
|
|
3
|
-
`)+(n.length>0?`
|
|
4
|
-
`:""),stderr:"",exitCode:0}}if(!r.exec)return{stdout:"",stderr:`env: command execution not supported in this context
|
|
5
|
-
`,exitCode:1};let c=s.slice(t).join(" "),v=Object.entries(l).map(([n,e])=>`${n}="${e}"`).join(" "),d=v?`${v} ${c}`:c;return r.exec(d)}},g={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},A={name:"printenv",async execute(s,r){if(f(s))return m(g);let u=s.filter(t=>!t.startsWith("-"));if(u.length===0){let t=[];for(let[a,c]of Object.entries(r.env))t.push(`${a}=${c}`);return{stdout:t.join(`
|
|
6
|
-
`)+(t.length>0?`
|
|
7
|
-
`:""),stderr:"",exitCode:0}}let i=[],l=0;for(let t of u)t in r.env?i.push(r.env[t]):l=1;return{stdout:i.join(`
|
|
8
|
-
`)+(i.length>0?`
|
|
9
|
-
`:""),stderr:"",exitCode:l}}};export{y as envCommand,A as printenvCommand};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import"./chunk-5KNEBKYN.js";var d={name:"expr",async execute(s,r){if(s.length===0)return{stdout:"",stderr:`expr: missing operand
|
|
3
|
-
`,exitCode:2};try{let l=g(s),h=l==="0"||l===""?1:0;return{stdout:`${l}
|
|
4
|
-
`,stderr:"",exitCode:h}}catch(l){return{stdout:"",stderr:`expr: ${l.message}
|
|
5
|
-
`,exitCode:2}}}};function g(s){if(s.length===1)return s[0];let r=0;function l(){let e=h();for(;r<s.length&&s[r]==="|";){r++;let t=h();if(e!=="0"&&e!=="")return e;e=t}return e}function h(){let e=a();for(;r<s.length&&s[r]==="&";){r++;let t=a();(e==="0"||e===""||t==="0"||t==="")&&(e="0")}return e}function a(){let e=p();for(;r<s.length;){let t=s[r];if(["=","!=","<",">","<=",">="].includes(t)){r++;let o=p(),n=parseInt(e,10),i=parseInt(o,10),f=!Number.isNaN(n)&&!Number.isNaN(i),c;t==="="?c=f?n===i:e===o:t==="!="?c=f?n!==i:e!==o:t==="<"?c=f?n<i:e<o:t===">"?c=f?n>i:e>o:t==="<="?c=f?n<=i:e<=o:c=f?n>=i:e>=o,e=c?"1":"0"}else break}return e}function p(){let e=N();for(;r<s.length;){let t=s[r];if(t==="+"||t==="-"){r++;let o=N(),n=parseInt(e,10),i=parseInt(o,10);if(Number.isNaN(n)||Number.isNaN(i))throw new Error("non-integer argument");e=String(t==="+"?n+i:n-i)}else break}return e}function N(){let e=m();for(;r<s.length;){let t=s[r];if(t==="*"||t==="/"||t==="%"){r++;let o=m(),n=parseInt(e,10),i=parseInt(o,10);if(Number.isNaN(n)||Number.isNaN(i))throw new Error("non-integer argument");if((t==="/"||t==="%")&&i===0)throw new Error("division by zero");t==="*"?e=String(n*i):t==="/"?e=String(Math.trunc(n/i)):e=String(n%i)}else break}return e}function m(){let e=u();for(;r<s.length&&s[r]===":";){r++;let t=u(),o=new RegExp(`^${t}`),n=e.match(o);n?e=n[1]!==void 0?n[1]:String(n[0].length):e="0"}return e}function u(){if(r>=s.length)throw new Error("syntax error");let e=s[r];if(e==="match"){r++;let t=u(),o=u(),n=new RegExp(o),i=t.match(n);return i?i[1]!==void 0?i[1]:String(i[0].length):"0"}if(e==="substr"){r++;let t=u(),o=parseInt(u(),10),n=parseInt(u(),10);if(Number.isNaN(o)||Number.isNaN(n))throw new Error("non-integer argument");return t.substring(o-1,o-1+n)}if(e==="index"){r++;let t=u(),o=u();for(let n=0;n<t.length;n++)if(o.includes(t[n]))return String(n+1);return"0"}if(e==="length"){r++;let t=u();return String(t.length)}if(e==="("){r++;let t=l();if(r>=s.length||s[r]!==")")throw new Error("syntax error");return r++,t}return r++,e}return l()}export{d as exprCommand};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as ge,b as we,c as te}from"./chunk-GTNBSMZR.js";import{a as ee,b as O,c as he}from"./chunk-SJXDWN5X.js";var be=O(ne=>{ne.read=function(i,e,t,r,n){var o,s,p=n*8-r-1,a=(1<<p)-1,m=a>>1,c=-7,f=t?n-1:0,l=t?-1:1,x=i[e+f];for(f+=l,o=x&(1<<-c)-1,x>>=-c,c+=p;c>0;o=o*256+i[e+f],f+=l,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=r;c>0;s=s*256+i[e+f],f+=l,c-=8);if(o===0)o=1-m;else{if(o===a)return s?NaN:(x?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-m}return(x?-1:1)*s*Math.pow(2,o-r)};ne.write=function(i,e,t,r,n,o){var s,p,a,m=o*8-n-1,c=(1<<m)-1,f=c>>1,l=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=r?0:o-1,v=r?1:-1,w=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(p=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),s+f>=1?e+=l/a:e+=l*Math.pow(2,1-f),e*a>=2&&(s++,a/=2),s+f>=c?(p=0,s=c):s+f>=1?(p=(e*a-1)*Math.pow(2,n),s=s+f):(p=e*Math.pow(2,f-1)*Math.pow(2,n),s=0));n>=8;i[t+x]=p&255,x+=v,p/=256,n-=8);for(s=s<<n|p,m+=n;m>0;i[t+x]=s&255,x+=v,s/=256,m-=8);i[t+x-v]|=w*128}});var Be=O((_i,Ee)=>{var M=1e3,L=M*60,j=L*60,I=j*24,ft=I*7,mt=I*365.25;Ee.exports=function(i,e){e=e||{};var t=typeof i;if(t==="string"&&i.length>0)return lt(i);if(t==="number"&&isFinite(i))return e.long?ut(i):xt(i);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(i))};function lt(i){if(i=String(i),!(i.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(i);if(e){var t=parseFloat(e[1]),r=(e[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return t*mt;case"weeks":case"week":case"w":return t*ft;case"days":case"day":case"d":return t*I;case"hours":case"hour":case"hrs":case"hr":case"h":return t*j;case"minutes":case"minute":case"mins":case"min":case"m":return t*L;case"seconds":case"second":case"secs":case"sec":case"s":return t*M;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function xt(i){var e=Math.abs(i);return e>=I?Math.round(i/I)+"d":e>=j?Math.round(i/j)+"h":e>=L?Math.round(i/L)+"m":e>=M?Math.round(i/M)+"s":i+"ms"}function ut(i){var e=Math.abs(i);return e>=I?J(i,e,I,"day"):e>=j?J(i,e,j,"hour"):e>=L?J(i,e,L,"minute"):e>=M?J(i,e,M,"second"):i+" ms"}function J(i,e,t,r){var n=e>=t*1.5;return Math.round(i/t)+" "+r+(n?"s":"")}});var se=O(($i,Ie)=>{function dt(i){t.debug=t,t.default=t,t.coerce=a,t.disable=s,t.enable=n,t.enabled=p,t.humanize=Be(),t.destroy=m,Object.keys(i).forEach(c=>{t[c]=i[c]}),t.names=[],t.skips=[],t.formatters={};function e(c){let f=0;for(let l=0;l<c.length;l++)f=(f<<5)-f+c.charCodeAt(l),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(c){let f,l=null,x,v;function w(...C){if(!w.enabled)return;let A=w,$=Number(new Date),Ge=$-(f||$);A.diff=Ge,A.prev=f,A.curr=$,f=$,C[0]=t.coerce(C[0]),typeof C[0]!="string"&&C.unshift("%O");let H=0;C[0]=C[0].replace(/%([a-zA-Z%])/g,(K,Je)=>{if(K==="%%")return"%";H++;let de=t.formatters[Je];if(typeof de=="function"){let Xe=C[H];K=de.call(A,Xe),C.splice(H,1),H--}return K}),t.formatArgs.call(A,C),(A.log||t.log).apply(A,C)}return w.namespace=c,w.useColors=t.useColors(),w.color=t.selectColor(c),w.extend=r,w.destroy=t.destroy,Object.defineProperty(w,"enabled",{enumerable:!0,configurable:!1,get:()=>l!==null?l:(x!==t.namespaces&&(x=t.namespaces,v=t.enabled(c)),v),set:C=>{l=C}}),typeof t.init=="function"&&t.init(w),w}function r(c,f){let l=t(this.namespace+(typeof f>"u"?":":f)+c);return l.log=this.log,l}function n(c){t.save(c),t.namespaces=c,t.names=[],t.skips=[];let f=(typeof c=="string"?c:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let l of f)l[0]==="-"?t.skips.push(l.slice(1)):t.names.push(l)}function o(c,f){let l=0,x=0,v=-1,w=0;for(;l<c.length;)if(x<f.length&&(f[x]===c[l]||f[x]==="*"))f[x]==="*"?(v=x,w=l,x++):(l++,x++);else if(v!==-1)x=v+1,w++,l=w;else return!1;for(;x<f.length&&f[x]==="*";)x++;return x===f.length}function s(){let c=[...t.names,...t.skips.map(f=>"-"+f)].join(",");return t.enable(""),c}function p(c){for(let f of t.skips)if(o(c,f))return!1;for(let f of t.names)if(o(c,f))return!0;return!1}function a(c){return c instanceof Error?c.stack||c.message:c}function m(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}Ie.exports=dt});var De=O((b,X)=>{b.formatArgs=gt;b.save=wt;b.load=kt;b.useColors=ht;b.storage=yt();b.destroy=(()=>{let i=!1;return()=>{i||(i=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();b.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function ht(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let i;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(i=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(i[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function gt(i){if(i[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+i[0]+(this.useColors?"%c ":" ")+"+"+X.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;i.splice(1,0,e,"color: inherit");let t=0,r=0;i[0].replace(/%[a-zA-Z%]/g,n=>{n!=="%%"&&(t++,n==="%c"&&(r=t))}),i.splice(r,0,e)}b.log=console.debug||console.log||(()=>{});function wt(i){try{i?b.storage.setItem("debug",i):b.storage.removeItem("debug")}catch{}}function kt(){let i;try{i=b.storage.getItem("debug")||b.storage.getItem("DEBUG")}catch{}return!i&&typeof process<"u"&&"env"in process&&(i=process.env.DEBUG),i}function yt(){try{return localStorage}catch{}}X.exports=se()(b);var{formatters:bt}=X.exports;bt.j=function(i){try{return JSON.stringify(i)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var ze=O((g,Q)=>{var Ct=ee("tty"),Z=ee("util");g.init=Bt;g.log=Tt;g.formatArgs=vt;g.save=At;g.load=Et;g.useColors=Ft;g.destroy=Z.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");g.colors=[6,2,3,4,5,1];try{let i=ee("supports-color");i&&(i.stderr||i).level>=2&&(g.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}g.inspectOpts=Object.keys(process.env).filter(i=>/^debug_/i.test(i)).reduce((i,e)=>{let t=e.substring(6).toLowerCase().replace(/_([a-z])/g,(n,o)=>o.toUpperCase()),r=process.env[e];return/^(yes|on|true|enabled)$/i.test(r)?r=!0:/^(no|off|false|disabled)$/i.test(r)?r=!1:r==="null"?r=null:r=Number(r),i[t]=r,i},{});function Ft(){return"colors"in g.inspectOpts?!!g.inspectOpts.colors:Ct.isatty(process.stderr.fd)}function vt(i){let{namespace:e,useColors:t}=this;if(t){let r=this.color,n="\x1B[3"+(r<8?r:"8;5;"+r),o=` ${n};1m${e} \x1B[0m`;i[0]=o+i[0].split(`
|
|
3
|
-
`).join(`
|
|
4
|
-
`+o),i.push(n+"m+"+Q.exports.humanize(this.diff)+"\x1B[0m")}else i[0]=St()+e+" "+i[0]}function St(){return g.inspectOpts.hideDate?"":new Date().toISOString()+" "}function Tt(...i){return process.stderr.write(Z.formatWithOptions(g.inspectOpts,...i)+`
|
|
5
|
-
`)}function At(i){i?process.env.DEBUG=i:delete process.env.DEBUG}function Et(){return process.env.DEBUG}function Bt(i){i.inspectOpts={};let e=Object.keys(g.inspectOpts);for(let t=0;t<e.length;t++)i.inspectOpts[e[t]]=g.inspectOpts[e[t]]}Q.exports=se()(g);var{formatters:Oe}=Q.exports;Oe.o=function(i){return this.inspectOpts.colors=this.useColors,Z.inspect(i,this.inspectOpts).split(`
|
|
6
|
-
`).map(e=>e.trim()).join(" ")};Oe.O=function(i){return this.inspectOpts.colors=this.useColors,Z.inspect(i,this.inspectOpts)}});var Ue=O((Hi,ae)=>{typeof process>"u"||process.type==="renderer"||process.browser===!0||process.__nwjs?ae.exports=De():ae.exports=ze()});var Ze="End-Of-Stream",u=class extends Error{constructor(){super(Ze),this.name="EndOfStreamError"}},E=class extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var B=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){let r=await this.read(e,t);return this.peekQueue.push(e.subarray(0,r)),r}async read(e,t=!1){if(e.length===0)return 0;let r=this.readFromPeekBuffer(e);if(this.endOfStream||(r+=await this.readRemainderFromStream(e.subarray(r),t)),r===0&&!t)throw new u;return r}readFromPeekBuffer(e){let t=e.length,r=0;for(;this.peekQueue.length>0&&t>0;){let n=this.peekQueue.pop();if(!n)throw new Error("peekData should be defined");let o=Math.min(n.length,t);e.set(n.subarray(0,o),r),r+=o,t-=o,o<n.length&&this.peekQueue.push(n.subarray(o))}return r}async readRemainderFromStream(e,t){let r=0;for(;r<e.length&&!this.endOfStream;){if(this.interrupted)throw new E;let n=await this.readFromStream(e.subarray(r),t);if(n===0)break;r+=n}if(!t&&r<e.length)throw new u;return r}};var W=class extends B{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}};var R=class extends W{async readFromStream(e,t){if(e.length===0)return 0;let r=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return r.done&&(this.endOfStream=r.done),r.value?(e.set(r.value),r.value.length):0}};var z=class extends B{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){let r=Math.min(t.length,e.length);return e.set(t.subarray(0,r)),r<t.length?this.buffer=t.subarray(r):this.buffer=null,r}async readFromStream(e,t){if(e.length===0)return 0;let r=0;for(this.buffer&&(r+=this.writeChunk(e,this.buffer));r<e.length&&!this.endOfStream;){let n=await this.reader.read();if(n.done){this.endOfStream=!0;break}n.value&&(r+=this.writeChunk(e.subarray(r),n.value))}if(!t&&r===0&&this.endOfStream)throw new u;return r}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function ie(i){try{let e=i.getReader({mode:"byob"});return e instanceof ReadableStreamDefaultReader?new z(e):new R(e)}catch(e){if(e instanceof TypeError)return new z(i.getReader());throw e}}var F=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,t=this.position){let r=new Uint8Array(e.len);if(await this.readBuffer(r,{position:t})<e.len)throw new u;return e.get(r,0)}async peekToken(e,t=this.position){let r=new Uint8Array(e.len);if(await this.peekBuffer(r,{position:t})<e.len)throw new u;return e.get(r,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new u;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new u;return e.get(this.numBuffer,0)}async ignore(e){if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}};var Ye=256e3,V=class extends F{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){let r=this.normalizeOptions(e,t),n=r.position-this.position;if(n>0)return await this.ignore(n),this.readBuffer(e,t);if(n<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(r.length===0)return 0;let o=await this.streamReader.read(e.subarray(0,r.length),r.mayBeLess);if(this.position+=o,(!t||!t.mayBeLess)&&o<r.length)throw new u;return o}async peekBuffer(e,t){let r=this.normalizeOptions(e,t),n=0;if(r.position){let o=r.position-this.position;if(o>0){let s=new Uint8Array(r.length+o);return n=await this.peekBuffer(s,{mayBeLess:r.mayBeLess}),e.set(s.subarray(o)),n-o}if(o<0)throw new Error("Cannot peek from a negative offset in a stream")}if(r.length>0){try{n=await this.streamReader.peek(e.subarray(0,r.length),r.mayBeLess)}catch(o){if(t?.mayBeLess&&o instanceof u)return 0;throw o}if(!r.mayBeLess&&n<r.length)throw new u}return n}async ignore(e){let t=Math.min(Ye,e),r=new Uint8Array(t),n=0;for(;n<e;){let o=e-n,s=await this.readBuffer(r,{length:Math.min(t,o)});if(s<0)return s;n+=s}return n}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}};var q=class extends F{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);let r=await this.peekBuffer(e,t);return this.position+=r,r}async peekBuffer(e,t){let r=this.normalizeOptions(e,t),n=Math.min(this.uint8Array.length-r.position,r.length);if(!r.mayBeLess&&n<r.length)throw new u;return e.set(this.uint8Array.subarray(r.position,r.position+n)),n}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}};var G=class extends F{constructor(e,t){super(t),this.blob=e,this.fileInfo={...t?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,t){t?.position&&(this.position=t.position);let r=await this.peekBuffer(e,t);return this.position+=r,r}async peekBuffer(e,t){let r=this.normalizeOptions(e,t),n=Math.min(this.blob.size-r.position,r.length);if(!r.mayBeLess&&n<r.length)throw new u;let o=await this.blob.slice(r.position,r.position+n).arrayBuffer();return e.set(new Uint8Array(o)),n}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}};function re(i,e){let t=ie(i),r=e??{},n=r.onClose;return r.onClose=async()=>{if(await t.close(),n)return n()},new V(t,r)}function ke(i,e){return new q(i,e)}function ye(i,e){return new G(i,e)}import{open as et}from"node:fs/promises";var P=class i extends F{static async fromFile(e){let t=await et(e,"r"),r=await t.stat();return new i(t,{fileInfo:{path:e,size:r.size}})}constructor(e,t){super(t),this.fileHandle=e,this.fileInfo=t.fileInfo}async readBuffer(e,t){let r=this.normalizeOptions(e,t);if(this.position=r.position,r.length===0)return 0;let n=await this.fileHandle.read(e,0,r.length,r.position);if(this.position+=n.bytesRead,n.bytesRead<r.length&&(!t||!t.mayBeLess))throw new u;return n.bytesRead}async peekBuffer(e,t){let r=this.normalizeOptions(e,t),n=await this.fileHandle.read(e,0,r.length,r.position);if(!r.mayBeLess&&n.bytesRead<r.length)throw new u;return n.bytesRead}async close(){return await this.fileHandle.close(),super.close()}setPosition(e){this.position=e}supportsRandomAccess(){return!0}};var tt=P.fromFile;var Fe=he(be(),1);var oe={128:"\u20AC",130:"\u201A",131:"\u0192",132:"\u201E",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02C6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017D",145:"\u2018",146:"\u2019",147:"\u201C",148:"\u201D",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02DC",153:"\u2122",154:"\u0161",155:"\u203A",156:"\u0153",158:"\u017E",159:"\u0178"},rt={};for(let[i,e]of Object.entries(oe))rt[e]=Number.parseInt(i);function Ce(i,e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(i):nt(i);case"utf-16le":return ot(i);case"ascii":return st(i);case"latin1":case"iso-8859-1":return at(i);case"windows-1252":return ct(i);default:throw new RangeError(`Encoding '${e}' not supported`)}}function nt(i){let e="",t=0;for(;t<i.length;){let r=i[t++];if(r<128)e+=String.fromCharCode(r);else if(r<224){let n=i[t++]&63;e+=String.fromCharCode((r&31)<<6|n)}else if(r<240){let n=i[t++]&63,o=i[t++]&63;e+=String.fromCharCode((r&15)<<12|n<<6|o)}else{let n=i[t++]&63,o=i[t++]&63,s=i[t++]&63,p=(r&7)<<18|n<<12|o<<6|s;p-=65536,e+=String.fromCharCode(55296+(p>>10&1023),56320+(p&1023))}}return e}function ot(i){let e="";for(let t=0;t<i.length;t+=2)e+=String.fromCharCode(i[t]|i[t+1]<<8);return e}function st(i){return String.fromCharCode(...i.map(e=>e&127))}function at(i){return String.fromCharCode(...i)}function ct(i){let e="";for(let t of i)t>=128&&t<=159&&oe[t]?e+=oe[t]:e+=String.fromCharCode(t);return e}function k(i){return new DataView(i.buffer,i.byteOffset)}var ve={len:1,get(i,e){return k(i).getUint8(e)},put(i,e,t){return k(i).setUint8(e,t),e+1}},d={len:2,get(i,e){return k(i).getUint16(e,!0)},put(i,e,t){return k(i).setUint16(e,t,!0),e+2}},U={len:2,get(i,e){return k(i).getUint16(e)},put(i,e,t){return k(i).setUint16(e,t),e+2}};var h={len:4,get(i,e){return k(i).getUint32(e,!0)},put(i,e,t){return k(i).setUint32(e,t,!0),e+4}},Se={len:4,get(i,e){return k(i).getUint32(e)},put(i,e,t){return k(i).setUint32(e,t),e+4}};var Te={len:4,get(i,e){return k(i).getInt32(e)},put(i,e,t){return k(i).setInt32(e,t),e+4}};var Ae={len:8,get(i,e){return k(i).getBigUint64(e,!0)},put(i,e,t){return k(i).setBigUint64(e,t,!0),e+8}};var y=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){let r=e.subarray(t,t+this.len);return Ce(r,this.encoding)}};var Re=he(Ue(),1);var D={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},ce={get(i){return{signature:h.get(i,0),compressedSize:h.get(i,8),uncompressedSize:h.get(i,12)}},len:16},Me={get(i){let e=d.get(i,6);return{signature:h.get(i,0),minVersion:d.get(i,4),dataDescriptor:!!(e&8),compressedMethod:d.get(i,8),compressedSize:h.get(i,18),uncompressedSize:h.get(i,22),filenameLength:d.get(i,26),extraFieldLength:d.get(i,28),filename:null}},len:30},Le={get(i){return{signature:h.get(i,0),nrOfThisDisk:d.get(i,4),nrOfThisDiskWithTheStart:d.get(i,6),nrOfEntriesOnThisDisk:d.get(i,8),nrOfEntriesOfSize:d.get(i,10),sizeOfCd:h.get(i,12),offsetOfStartOfCd:h.get(i,16),zipFileCommentLength:d.get(i,20)}},len:22},je={get(i){let e=d.get(i,8);return{signature:h.get(i,0),minVersion:d.get(i,6),dataDescriptor:!!(e&8),compressedMethod:d.get(i,10),compressedSize:h.get(i,20),uncompressedSize:h.get(i,24),filenameLength:d.get(i,28),extraFieldLength:d.get(i,30),fileCommentLength:d.get(i,32),relativeOffsetOfLocalHeader:h.get(i,42),filename:null}},len:46};function Pe(i){let e=new Uint8Array(h.len);return h.put(e,0,i),e}var S=(0,Re.default)("tokenizer:inflate"),pe=256*1024,It=Pe(D.DataDescriptor),Y=Pe(D.EndOfCentralDirectory),N=class i{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(pe)}async isZip(){return await this.peekSignature()===D.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(h)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,t=Math.min(16*1024,e.fileInfo.size),r=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(r,{position:e.fileInfo.size-t});for(let n=r.length-4;n>=0;n--)if(r[n]===Y[0]&&r[n+1]===Y[1]&&r[n+2]===Y[2]&&r[n+3]===Y[3])return e.fileInfo.size-t+n;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){S("Cannot reading central-directory without random-read support");return}S("Reading central-directory...");let e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){S("Central-directory 32-bit signature found");let r=await this.tokenizer.readToken(Le,t),n=[];this.tokenizer.setPosition(r.offsetOfStartOfCd);for(let o=0;o<r.nrOfEntriesOfSize;++o){let s=await this.tokenizer.readToken(je);if(s.signature!==D.CentralFileHeader)throw new Error("Expected Central-File-Header signature");s.filename=await this.tokenizer.readToken(new y(s.filenameLength,"utf-8")),await this.tokenizer.ignore(s.extraFieldLength),await this.tokenizer.ignore(s.fileCommentLength),n.push(s),S(`Add central-directory file-entry: n=${o+1}/${n.length}: filename=${n[o].filename}`)}return this.tokenizer.setPosition(e),n}this.tokenizer.setPosition(e)}async unzip(e){let t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,e);let r=!1;do{let n=await this.readLocalFileHeader();if(!n)break;let o=e(n);r=!!o.stop;let s;if(await this.tokenizer.ignore(n.extraFieldLength),n.dataDescriptor&&n.compressedSize===0){let p=[],a=pe;S("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let m=-1;for(;m<0&&a===pe;){a=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),m=Dt(this.syncBuffer.subarray(0,a),It);let c=m>=0?m:a;if(o.handler){let f=new Uint8Array(c);await this.tokenizer.readBuffer(f),p.push(f)}else await this.tokenizer.ignore(c)}S(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),o.handler&&await this.inflate(n,Ot(p),o.handler)}else o.handler?(S(`Reading compressed-file-data: ${n.compressedSize} bytes`),s=new Uint8Array(n.compressedSize),await this.tokenizer.readBuffer(s),await this.inflate(n,s,o.handler)):(S(`Ignoring compressed-file-data: ${n.compressedSize} bytes`),await this.tokenizer.ignore(n.compressedSize));if(S(`Reading data-descriptor at pos=${this.tokenizer.position}`),n.dataDescriptor&&(await this.tokenizer.readToken(ce)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-ce.len}`)}while(!r)}async iterateOverCentralDirectory(e,t){for(let r of e){let n=t(r);if(n.handler){this.tokenizer.setPosition(r.relativeOffsetOfLocalHeader);let o=await this.readLocalFileHeader();if(o){await this.tokenizer.ignore(o.extraFieldLength);let s=new Uint8Array(r.compressedSize);await this.tokenizer.readBuffer(s),await this.inflate(o,s,n.handler)}}if(n.stop)break}}async inflate(e,t,r){if(e.compressedMethod===0)return r(t);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);S(`Decompress filename=${e.filename}, compressed-size=${t.length}`);let n=await i.decompressDeflateRaw(t);return r(n)}static async decompressDeflateRaw(e){let t=new ReadableStream({start(o){o.enqueue(e),o.close()}}),r=new DecompressionStream("deflate-raw"),n=t.pipeThrough(r);try{let s=await new Response(n).arrayBuffer();return new Uint8Array(s)}catch(o){let s=o instanceof Error?`Failed to deflate ZIP entry: ${o.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(s)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(h);if(e===D.LocalFileHeader){let t=await this.tokenizer.readToken(Me);return t.filename=await this.tokenizer.readToken(new y(t.filenameLength,"utf-8")),t}if(e===D.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}};function Dt(i,e){let t=i.length,r=e.length;if(r>t)return-1;for(let n=0;n<=t-r;n++){let o=!0;for(let s=0;s<r;s++)if(i[n+s]!==e[s]){o=!1;break}if(o)return n}return-1}function Ot(i){let e=i.reduce((n,o)=>n+o.length,0),t=new Uint8Array(e),r=0;for(let n of i)t.set(n,r),r+=n.length;return t}var _=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(t){let r=new Uint8Array(1024),n=await e.readBuffer(r,{mayBeLess:!0});if(n===0){t.close();return}t.enqueue(r.subarray(0,n))}}).pipeThrough(new DecompressionStream("gzip"))}};var Ki={utf8:new globalThis.TextDecoder("utf8")};var er=new globalThis.TextEncoder;var tr=Array.from({length:256},(i,e)=>e.toString(16).padStart(2,"0"));function fe(i){let{byteLength:e}=i;if(e===6)return i.getUint16(0)*2**32+i.getUint32(2);if(e===5)return i.getUint8(0)*2**32+i.getUint32(1);if(e===4)return i.getUint32(0);if(e===3)return i.getUint8(0)*2**16+i.getUint16(1);if(e===2)return i.getUint16(0);if(e===1)return i.getUint8(0)}function Ne(i,e){if(e==="utf-16le"){let t=[];for(let r=0;r<i.length;r++){let n=i.charCodeAt(r);t.push(n&255,n>>8&255)}return t}if(e==="utf-16be"){let t=[];for(let r=0;r<i.length;r++){let n=i.charCodeAt(r);t.push(n>>8&255,n&255)}return t}return[...i].map(t=>t.charCodeAt(0))}function _e(i,e=0){let t=Number.parseInt(new y(6).get(i,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(t))return!1;let r=256;for(let n=e;n<e+148;n++)r+=i[n];for(let n=e+156;n<e+512;n++)r+=i[n];return t===r}var $e={get:(i,e)=>i[e+3]&127|i[e+2]<<7|i[e+1]<<14|i[e]<<21,len:4};var He=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],We=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"];var me=4100;async function ue(i,e){return new xe(e).fromBuffer(i)}function le(i){switch(i=i.toLowerCase(),i){case"application/epub+zip":return{ext:"epub",mime:i};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:i};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:i};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:i};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:i};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:i};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:i};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:i};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:i};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:i};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:i};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:i};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:i};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:i};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:i};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:i};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"};default:}}function T(i,e,t){t={offset:0,...t};for(let[r,n]of e.entries())if(t.mask){if(n!==(t.mask[r]&i[r+t.offset]))return!1}else if(n!==i[r+t.offset])return!1;return!0}var xe=class{constructor(e){this.options={mpegOffsetTolerance:0,...e},this.detectors=[...e?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:e?.signal}}async fromTokenizer(e){let t=e.position;for(let r of this.detectors){let n=await r.detect(e);if(n)return n;if(t!==e.position)return}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t?.length>1)return this.fromTokenizer(ke(t,this.tokenizerOptions))}async fromBlob(e){let t=ye(e,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async fromStream(e){let t=re(e,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async toDetectionStream(e,t){let{sampleSize:r=me}=t,n,o,s=e.getReader({mode:"byob"});try{let{value:m,done:c}=await s.read(new Uint8Array(r));if(o=m,!c&&m)try{n=await this.fromBuffer(m.subarray(0,r))}catch(f){if(!(f instanceof u))throw f;n=void 0}o=m}finally{s.releaseLock()}let p=new TransformStream({async start(m){m.enqueue(o)},transform(m,c){c.enqueue(m)}}),a=e.pipeThrough(p);return a.fileType=n,a}check(e,t){return T(this.buffer,e,t)}checkString(e,t){return this.check(Ne(e,t?.encoding),t)}detectConfident=async e=>{if(this.buffer=new Uint8Array(me),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.detectConfident(e);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8])){let r=new _(e).inflate(),n=!0;try{let o;try{o=await this.fromStream(r)}catch{n=!1}if(o&&o.ext==="tar")return{ext:"tar.gz",mime:"application/gzip"}}finally{n&&await r.cancel()}return{ext:"gz",mime:"application/gzip"}}if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await e.ignore(6);let t=await e.readToken($e);return e.position+t>e.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await e.ignore(t),this.fromTokenizer(e))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let t;return await new N(e).unzip(r=>{switch(r.filename){case"META-INF/mozilla.rsa":return t={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return t={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return{async handler(n){let o=new TextDecoder("utf-8").decode(n).trim();t=le(o)},stop:!0};case"[Content_Types].xml":return{async handler(n){let o=new TextDecoder("utf-8").decode(n),s=o.indexOf('.main+xml"');if(s===-1){let p="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";o.includes(`ContentType="${p}"`)&&(t=le(p))}else{o=o.slice(0,Math.max(0,s));let p=o.lastIndexOf('"'),a=o.slice(Math.max(0,p+1));t=le(a)}},stop:!0};default:return/classes\d*\.dex/.test(r.filename)?(t={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}).catch(r=>{if(!(r instanceof u))throw r}),t??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);let t=new Uint8Array(8);return await e.readBuffer(t),T(t,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:T(t,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:T(t,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:T(t,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:T(t,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:T(t,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let t=await this.readTiffHeader(!1);if(t)return t}if(this.check([77,77])){let t=await this.readTiffHeader(!0);if(t)return t}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function t(){let p=await e.peekNumber(ve),a=128,m=0;for(;(p&a)===0&&a!==0;)++m,a>>=1;let c=new Uint8Array(m+1);return await e.readBuffer(c),c}async function r(){let p=await t(),a=await t();a[0]^=128>>a.length-1;let m=Math.min(6,a.length),c=new DataView(p.buffer),f=new DataView(a.buffer,a.length-m,m);return{id:fe(c),len:fe(f)}}async function n(p){for(;p>0;){let a=await r();if(a.id===17026)return(await e.readToken(new y(a.len))).replaceAll(/\00.*$/g,"");await e.ignore(a.len),--p}}let o=await r();switch(await n(o.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let t=new y(4,"latin1").get(this.buffer,2);if(t.match("^d*")&&t>=1e3&&t<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new y(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
|
|
7
|
-
`,"\r"," "," ","\0"].some(t=>this.checkString(t,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){await e.ignore(8);async function t(){return{length:await e.readToken(Te),type:await e.readToken(new y(4,"latin1"))}}do{let r=await t();if(r.length<0)return;switch(r.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await e.ignore(r.length+4)}}while(e.position+8<e.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&(this.buffer[8]&96)!==0){let t=new y(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(t){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return t.startsWith("3g")?t.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
|
|
8
|
-
`))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function t(){let r=new Uint8Array(16);return await e.readBuffer(r),{id:r,size:Number(await e.readToken(Ae))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){let r=await t(),n=r.size-24;if(T(r.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let o=new Uint8Array(16);if(n-=await e.readBuffer(o),T(o,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(T(o,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await e.ignore(n)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new y(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let t=new DataView(this.buffer.buffer).getUint32(12,!0);if(t>12&&this.buffer.length>=t+16)try{let r=new TextDecoder().decode(this.buffer.subarray(16,t+16));if(JSON.parse(r).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&_e(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){let t="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:t})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:t})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
|
|
9
|
-
`,{offset:2,encoding:t})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async e=>{if(this.buffer=new Uint8Array(me),await e.peekBuffer(this.buffer,{length:Math.min(8,e.fileInfo.size),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,e.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let t=0;t<=this.options.mpegOffsetTolerance;++t){let r=this.scanMpeg(t);if(r)return r}};async readTiffTag(e){let t=await this.tokenizer.readToken(e?U:d);switch(this.tokenizer.ignore(10),t){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(e){let t=await this.tokenizer.readToken(e?U:d);for(let r=0;r<t;++r){let n=await this.readTiffTag(e);if(n)return n}}async readTiffHeader(e){let t=(e?U:d).get(this.buffer,2),r=(e?Se:h).get(this.buffer,4);if(t===42){if(r>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(r>=8){let o=(e?U:d).get(this.buffer,8),s=(e?U:d).get(this.buffer,10);if(o===28&&s===254||o===31&&s===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}return await this.tokenizer.ignore(r),await this.readTiffIFD(e)??{ext:"tif",mime:"image/tiff"}}if(t===43)return{ext:"tif",mime:"image/tiff"}}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},zt=new Set(He),Ut=new Set(We);var Mt={name:"file",summary:"determine file type",usage:"file [OPTION]... FILE...",options:["-b, --brief do not prepend filenames to output","-i, --mime output MIME type strings","-L, --dereference follow symlinks"," --help display this help and exit"]},Ve={".js":{description:"JavaScript source",mime:"text/javascript"},".mjs":{description:"JavaScript module",mime:"text/javascript"},".cjs":{description:"CommonJS module",mime:"text/javascript"},".ts":{description:"TypeScript source",mime:"text/typescript"},".tsx":{description:"TypeScript JSX source",mime:"text/typescript"},".jsx":{description:"JavaScript JSX source",mime:"text/javascript"},".py":{description:"Python script",mime:"text/x-python"},".rb":{description:"Ruby script",mime:"text/x-ruby"},".go":{description:"Go source",mime:"text/x-go"},".rs":{description:"Rust source",mime:"text/x-rust"},".c":{description:"C source",mime:"text/x-c"},".h":{description:"C header",mime:"text/x-c"},".cpp":{description:"C++ source",mime:"text/x-c++"},".hpp":{description:"C++ header",mime:"text/x-c++"},".java":{description:"Java source",mime:"text/x-java"},".sh":{description:"Bourne-Again shell script",mime:"text/x-shellscript"},".bash":{description:"Bourne-Again shell script",mime:"text/x-shellscript"},".zsh":{description:"Zsh shell script",mime:"text/x-shellscript"},".json":{description:"JSON data",mime:"application/json"},".yaml":{description:"YAML data",mime:"text/yaml"},".yml":{description:"YAML data",mime:"text/yaml"},".xml":{description:"XML document",mime:"application/xml"},".csv":{description:"CSV text",mime:"text/csv"},".toml":{description:"TOML data",mime:"text/toml"},".html":{description:"HTML document",mime:"text/html"},".htm":{description:"HTML document",mime:"text/html"},".css":{description:"CSS stylesheet",mime:"text/css"},".svg":{description:"SVG image",mime:"image/svg+xml"},".md":{description:"Markdown document",mime:"text/markdown"},".markdown":{description:"Markdown document",mime:"text/markdown"},".txt":{description:"ASCII text",mime:"text/plain"},".rst":{description:"reStructuredText",mime:"text/x-rst"},".env":{description:"ASCII text",mime:"text/plain"},".gitignore":{description:"ASCII text",mime:"text/plain"},".dockerignore":{description:"ASCII text",mime:"text/plain"}},qe={jpg:"JPEG image data",jpeg:"JPEG image data",png:"PNG image data",gif:"GIF image data",webp:"WebP image data",bmp:"PC bitmap",ico:"MS Windows icon resource",tif:"TIFF image data",tiff:"TIFF image data",psd:"Adobe Photoshop Document",avif:"AVIF image",heic:"HEIC image",heif:"HEIF image",jxl:"JPEG XL image",icns:"Mac OS X icon",svg:"SVG Scalable Vector Graphics image",pdf:"PDF document",epub:"EPUB document",mobi:"Mobipocket E-book",djvu:"DjVu document",zip:"Zip archive data",gz:"gzip compressed data",gzip:"gzip compressed data",bz2:"bzip2 compressed data",xz:"XZ compressed data",tar:"POSIX tar archive",rar:"RAR archive data","7z":"7-zip archive data",lz:"lzip compressed data",lzma:"LZMA compressed data",zst:"Zstandard compressed data",cab:"Microsoft Cabinet archive",ar:"Unix ar archive",rpm:"RPM package",deb:"Debian binary package",apk:"Android Package",dmg:"Apple disk image",iso:"ISO 9660 CD-ROM filesystem data",vhd:"Microsoft Virtual Hard Disk",vhdx:"Microsoft Virtual Hard Disk (new format)",qcow2:"QEMU QCOW Image",mp3:"Audio file with ID3",m4a:"MPEG-4 audio",aac:"AAC audio",wav:"RIFF (little-endian) data, WAVE audio",flac:"FLAC audio bitstream data",ogg:"Ogg data",oga:"Ogg audio",opus:"Ogg Opus audio",aiff:"AIFF audio",wma:"Windows Media Audio",amr:"AMR audio",mid:"MIDI audio",midi:"MIDI audio",ape:"Monkey's Audio",mp4:"ISO Media, MPEG-4",m4v:"MPEG-4 video",webm:"WebM",avi:"RIFF (little-endian) data, AVI",mov:"ISO Media, Apple QuickTime movie",mkv:"Matroska data",wmv:"Windows Media Video",flv:"Flash Video","3gp":"3GPP multimedia","3g2":"3GPP2 multimedia",ogv:"Ogg video",mts:"MPEG transport stream",m2ts:"MPEG transport stream",ts:"MPEG transport stream",mpg:"MPEG video",mpeg:"MPEG video",exe:"PE32 executable",dll:"PE32 DLL",elf:"ELF executable",mach:"Mach-O executable",wasm:"WebAssembly (wasm) binary module",dex:"Android Dalvik executable",class:"Java class file",swf:"Adobe Flash",doc:"Microsoft Word Document",docx:"Microsoft Word 2007+ Document",xls:"Microsoft Excel Spreadsheet",xlsx:"Microsoft Excel 2007+ Spreadsheet",ppt:"Microsoft PowerPoint Presentation",pptx:"Microsoft PowerPoint 2007+ Presentation",odt:"OpenDocument Text",ods:"OpenDocument Spreadsheet",odp:"OpenDocument Presentation",ttf:"TrueType Font",otf:"OpenType Font",woff:"Web Open Font Format",woff2:"Web Open Font Format 2",eot:"Embedded OpenType font",stl:"Stereolithography CAD",obj:"Wavefront 3D Object",gltf:"GL Transmission Format",glb:"GL Transmission Format (binary)",sqlite:"SQLite 3.x database",mdb:"Microsoft Access Database",xml:"XML document",json:"JSON data",macho:"Mach-O binary",ics:"iCalendar data",vcf:"vCard data",msi:"Microsoft Installer",ps:"PostScript",ai:"Adobe Illustrator",indd:"Adobe InDesign",sketch:"Sketch design file",fig:"Figma design file",xd:"Adobe XD",blend:"Blender",fbx:"Autodesk FBX",lnk:"MS Windows shortcut",alias:"Mac OS alias",torrent:"BitTorrent file",pcap:"pcap capture file",arrow:"Apache Arrow",parquet:"Apache Parquet"};function Lt(i,e){if(qe[i])return qe[i];let[t,r]=e.split("/"),n=r?.split("+")[0]?.replace(/-/g," ")||i;switch(t){case"image":return`${n.toUpperCase()} image data`;case"audio":return`${n.toUpperCase()} audio`;case"video":return`${n.toUpperCase()} video`;case"font":return`${n} font`;case"model":return`${n} 3D model`;case"application":return r?.includes("zip")||r?.includes("compressed")?`${n} archive data`:r?.includes("executable")?`${n} executable`:`${i.toUpperCase()} data`;default:return`${i.toUpperCase()} data`}}function jt(i){let e=i.split("/").pop()||i;if(e.startsWith(".")&&!e.includes(".",1))return e;let t=e.lastIndexOf(".");return t===-1||t===0?"":e.slice(t).toLowerCase()}function Rt(i,e){if(i.startsWith("#!")){let a=i.split(`
|
|
10
|
-
`)[0];return a.includes("python")?{description:"Python script, ASCII text executable",mime:"text/x-python"}:a.includes("node")||a.includes("bun")||a.includes("deno")?{description:"JavaScript script, ASCII text executable",mime:"text/javascript"}:a.includes("bash")?{description:"Bourne-Again shell script, ASCII text executable",mime:"text/x-shellscript"}:a.includes("sh")?{description:"POSIX shell script, ASCII text executable",mime:"text/x-shellscript"}:a.includes("ruby")?{description:"Ruby script, ASCII text executable",mime:"text/x-ruby"}:a.includes("perl")?{description:"Perl script, ASCII text executable",mime:"text/x-perl"}:{description:"script, ASCII text executable",mime:"text/plain"}}let t=i.trimStart();if(t.startsWith("<?xml"))return{description:"XML document",mime:"application/xml"};if(t.startsWith("<!DOCTYPE html")||t.toLowerCase().startsWith("<html"))return{description:"HTML document",mime:"text/html"};let r=i.includes(`\r
|
|
11
|
-
`),n=i.includes("\r")&&!r,o="";r?o=", with CRLF line terminators":n&&(o=", with CR line terminators");let s=jt(e);if(s&&Ve[s]){let a=Ve[s];return a.mime.startsWith("text/")&&o?{description:`${a.description}${o}`,mime:a.mime}:a}let p=!1;for(let a=0;a<Math.min(i.length,8192);a++)if(i.charCodeAt(a)>127){p=!0;break}return p?{description:`UTF-8 Unicode text${o}`,mime:"text/plain; charset=utf-8"}:{description:`ASCII text${o}`,mime:"text/plain"}}async function Pt(i,e){if(e.length===0)return{description:"empty",mime:"inode/x-empty"};let t=Buffer.from(e,"binary"),r=await ue(t);return r?{description:Lt(r.ext,r.mime),mime:r.mime}:Rt(e,i)}var wr={name:"file",async execute(i,e){if(we(i))return ge(Mt);let t=!1,r=!1,n=[];for(let p of i)if(p.startsWith("--")){if(p==="--brief")t=!0;else if(p==="--mime"||p==="--mime-type")r=!0;else if(p!=="--dereference")return te("file",p)}else if(p.startsWith("-")&&p!=="-"){for(let a of p.slice(1))if(a==="b")t=!0;else if(a==="i")r=!0;else if(a!=="L")return te("file",`-${a}`)}else n.push(p);if(n.length===0)return{stdout:"",stderr:`Usage: file [-bLi] FILE...
|
|
12
|
-
`,exitCode:1};let o="",s=0;for(let p of n)try{let a=e.fs.resolvePath(e.cwd,p);if((await e.fs.stat(a)).isDirectory){let x=r?"inode/directory":"directory";o+=t?`${x}
|
|
13
|
-
`:`${p}: ${x}
|
|
14
|
-
`;continue}let c=await e.fs.readFile(a),f=await Pt(p,c),l=r?f.mime:f.description;o+=t?`${l}
|
|
15
|
-
`:`${p}: ${l}
|
|
16
|
-
`}catch{o+=t?`cannot open
|
|
17
|
-
`:`${p}: cannot open (No such file or directory)
|
|
18
|
-
`,s=1}return{stdout:o,stderr:"",exitCode:s}}};export{wr as fileCommand};
|
|
19
|
-
/*! Bundled license information:
|
|
20
|
-
|
|
21
|
-
ieee754/index.js:
|
|
22
|
-
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
23
|
-
*/
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as v}from"./chunk-26Q3PZQ6.js";import{a as N,b as C}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function b(e,o){switch(e.type){case"name":return v(o.name,e.pattern,e.ignoreCase);case"path":return v(o.relativePath,e.pattern,e.ignoreCase);case"type":return e.fileType==="f"?o.isFile:e.fileType==="d"?o.isDirectory:!1;case"empty":return o.isEmpty;case"mtime":{let r=(Date.now()-o.mtime)/(1e3*60*60*24);return e.comparison==="more"?r>e.days:e.comparison==="less"?r<e.days:Math.floor(r)===e.days}case"newer":{let s=o.newerRefTimes.get(e.refPath);return s===void 0?!1:o.mtime>s}case"size":{let s=e.value;switch(e.unit){case"c":s=e.value;break;case"k":s=e.value*1024;break;case"M":s=e.value*1024*1024;break;case"G":s=e.value*1024*1024*1024;break;case"b":s=e.value*512;break}return e.comparison==="more"?o.size>s:e.comparison==="less"?o.size<s:e.unit==="b"?Math.ceil(o.size/512)===e.value:o.size===s}case"perm":{let s=o.mode&511,r=e.mode&511;return e.matchType==="exact"?s===r:e.matchType==="all"?(s&r)===r:(s&r)!==0}case"not":return!b(e.expr,o);case"and":return b(e.left,o)&&b(e.right,o);case"or":return b(e.left,o)||b(e.right,o)}}function P(e){let o=[],s=r=>{r&&(r.type==="newer"?o.push(r.refPath):r.type==="not"?s(r.expr):(r.type==="and"||r.type==="or")&&(s(r.left),s(r.right)))};return s(e),o}function R(e,o){let s=[],r=[],i=o;for(;i<e.length;){let t=e[i];if(t==="-name"&&i+1<e.length)s.push({type:"expr",expr:{type:"name",pattern:e[++i]}});else if(t==="-iname"&&i+1<e.length)s.push({type:"expr",expr:{type:"name",pattern:e[++i],ignoreCase:!0}});else if(t==="-path"&&i+1<e.length)s.push({type:"expr",expr:{type:"path",pattern:e[++i]}});else if(t==="-ipath"&&i+1<e.length)s.push({type:"expr",expr:{type:"path",pattern:e[++i],ignoreCase:!0}});else if(t==="-type"&&i+1<e.length){let n=e[++i];if(n==="f"||n==="d")s.push({type:"expr",expr:{type:"type",fileType:n}});else return{expr:null,pathIndex:i,error:`find: Unknown argument to -type: ${n}
|
|
3
|
-
`,actions:[]}}else if(t==="-empty")s.push({type:"expr",expr:{type:"empty"}});else if(t==="-mtime"&&i+1<e.length){let n=e[++i],p="exact",h=n;n.startsWith("+")?(p="more",h=n.slice(1)):n.startsWith("-")&&(p="less",h=n.slice(1));let u=parseInt(h,10);Number.isNaN(u)||s.push({type:"expr",expr:{type:"mtime",days:u,comparison:p}})}else if(t==="-newer"&&i+1<e.length){let n=e[++i];s.push({type:"expr",expr:{type:"newer",refPath:n}})}else if(t==="-size"&&i+1<e.length){let n=e[++i],p="exact",h=n;n.startsWith("+")?(p="more",h=n.slice(1)):n.startsWith("-")&&(p="less",h=n.slice(1));let u=h.match(/^(\d+)([ckMGb])?$/);if(u){let w=parseInt(u[1],10),x=u[2]||"b";s.push({type:"expr",expr:{type:"size",value:w,unit:x,comparison:p}})}}else if(t==="-perm"&&i+1<e.length){let n=e[++i],p="exact",h=n;n.startsWith("-")?(p="all",h=n.slice(1)):n.startsWith("/")&&(p="any",h=n.slice(1));let u=parseInt(h,8);Number.isNaN(u)||s.push({type:"expr",expr:{type:"perm",mode:u,matchType:p}})}else if(t==="-not"||t==="!")s.push({type:"not"});else if(t==="-o"||t==="-or")s.push({type:"op",op:"or"});else if(t==="-a"||t==="-and")s.push({type:"op",op:"and"});else if(t==="-maxdepth"||t==="-mindepth")i++;else if(t==="-exec"){let n=[];for(i++;i<e.length&&e[i]!==";"&&e[i]!=="+";)n.push(e[i]),i++;if(i>=e.length)return{expr:null,pathIndex:i,error:"find: missing argument to `-exec'\n",actions:[]};let p=e[i]==="+";r.push({type:"exec",command:n,batchMode:p})}else if(t==="-print")r.push({type:"print"});else if(t==="-print0")r.push({type:"print0"});else if(t==="-delete")r.push({type:"delete"});else{if(t.startsWith("-"))return{expr:null,pathIndex:i,error:`find: unknown predicate '${t}'
|
|
4
|
-
`,actions:[]};if(s.length===0){i++;continue}break}i++}if(s.length===0)return{expr:null,pathIndex:i,actions:r};let g=[];for(let t=0;t<s.length;t++){let n=s[t];if(n.type==="not"){if(t+1<s.length&&s[t+1].type==="expr"){let p=s[t+1].expr;g.push({type:"expr",expr:{type:"not",expr:p}}),t++}}else(n.type==="expr"||n.type==="op")&&g.push(n)}let E=[[]];for(let t of g)t.type==="op"&&t.op==="or"?E.push([]):t.type==="expr"&&E[E.length-1].push(t.expr);let y=[];for(let t of E){if(t.length===0)continue;let n=t[0];for(let p=1;p<t.length;p++)n={type:"and",left:n,right:t[p]};y.push(n)}if(y.length===0)return{expr:null,pathIndex:i,actions:r};let T=y[0];for(let t=1;t<y.length;t++)T={type:"or",left:T,right:y[t]};return{expr:T,pathIndex:i,actions:r}}var $={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-delete delete found files/directories"," --help display this help and exit"]},A=new Set(["-name","-iname","-path","-ipath","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),G={name:"find",async execute(e,o){if(C(e))return N($);let s=".",r=null,i=null;for(let l=0;l<e.length;l++){let a=e[l];if(a==="-maxdepth"&&l+1<e.length)r=parseInt(e[++l],10);else if(a==="-mindepth"&&l+1<e.length)i=parseInt(e[++l],10);else if(a==="-exec")for(l++;l<e.length&&e[l]!==";"&&e[l]!=="+";)l++;else!a.startsWith("-")&&a!==";"&&a!=="+"?s=a:A.has(a)&&l++}let{expr:g,error:E,actions:y}=R(e,0);if(E)return{stdout:"",stderr:E,exitCode:1};let T=y.length===0,t=o.fs.resolvePath(o.cwd,s);try{await o.fs.stat(t)}catch{return{stdout:"",stderr:`find: ${s}: No such file or directory
|
|
5
|
-
`,exitCode:1}}let n=[],p=P(g),h=new Map;for(let l of p){let a=o.fs.resolvePath(o.cwd,l);try{let f=await o.fs.stat(a);h.set(l,f.mtime?.getTime()??Date.now())}catch{}}async function u(l,a){if(r!==null&&a>r)return;let f;try{f=await o.fs.stat(l)}catch{return}if(!f)return;let m;l===t?m=s.split("/").pop()||s:m=l.split("/").pop()||"";let c=l===t?s:s==="."?`./${l.slice(t.length+1)}`:s+l.slice(t.length),d=null;f.isDirectory&&(d=await o.fs.readdir(l));let z=f.isFile?f.size===0:d!==null&&d.length===0,D=i===null||a>=i;if(D&&g!==null){let k={name:m,relativePath:c,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:z,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:h};D=b(g,k)}if(D&&n.push(c),d!==null)for(let k of d){let I=l==="/"?`/${k}`:`${l}/${k}`;await u(I,a+1)}}await u(t,0);let w="",x="",M=0;if(y.length>0)for(let l of y)switch(l.type){case"print":w+=n.length>0?`${n.join(`
|
|
6
|
-
`)}
|
|
7
|
-
`:"";break;case"print0":w+=n.length>0?`${n.join("\0")}\0`:"";break;case"delete":{let a=[...n].sort((f,m)=>m.length-f.length);for(let f of a){let m=o.fs.resolvePath(o.cwd,f);try{await o.fs.rm(m,{recursive:!1})}catch(c){let d=c instanceof Error?c.message:String(c);x+=`find: cannot delete '${f}': ${d}
|
|
8
|
-
`,M=1}}break}case"exec":if(!o.exec)return{stdout:"",stderr:`find: -exec not supported in this context
|
|
9
|
-
`,exitCode:1};if(l.batchMode){let a=[];for(let c of l.command)c==="{}"?a.push(...n):a.push(c);let f=a.map(c=>`"${c}"`).join(" "),m=await o.exec(f);w+=m.stdout,x+=m.stderr,m.exitCode!==0&&(M=m.exitCode)}else for(let a of n){let m=l.command.map(d=>d==="{}"?a:d).map(d=>`"${d}"`).join(" "),c=await o.exec(m);w+=c.stdout,x+=c.stderr,c.exitCode!==0&&(M=c.exitCode)}break}else T&&(w=n.length>0?`${n.join(`
|
|
10
|
-
`)}
|
|
11
|
-
`:"");return{stdout:w,stderr:x,exitCode:M}}};export{G as findCommand};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as v}from"./chunk-26Q3PZQ6.js";import{a as C,b as k}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function w(e,t){switch(e.type){case"name":return v(t.name,e.pattern,e.ignoreCase);case"path":return v(t.relativePath,e.pattern,e.ignoreCase);case"type":return e.fileType==="f"?t.isFile:e.fileType==="d"?t.isDirectory:!1;case"empty":return t.isEmpty;case"mtime":{let r=(Date.now()-t.mtime)/(1e3*60*60*24);return e.comparison==="more"?r>e.days:e.comparison==="less"?r<e.days:Math.floor(r)===e.days}case"newer":{let i=t.newerRefTimes.get(e.refPath);return i===void 0?!1:t.mtime>i}case"size":{let i=e.value;switch(e.unit){case"c":i=e.value;break;case"k":i=e.value*1024;break;case"M":i=e.value*1024*1024;break;case"G":i=e.value*1024*1024*1024;break;case"b":i=e.value*512;break}return e.comparison==="more"?t.size>i:e.comparison==="less"?t.size<i:e.unit==="b"?Math.ceil(t.size/512)===e.value:t.size===i}case"perm":{let i=t.mode&511,r=e.mode&511;return e.matchType==="exact"?i===r:e.matchType==="all"?(i&r)===r:(i&r)!==0}case"not":return!w(e.expr,t);case"and":return w(e.left,t)&&w(e.right,t);case"or":return w(e.left,t)||w(e.right,t)}}function P(e){let t=[],i=r=>{r&&(r.type==="newer"?t.push(r.refPath):r.type==="not"?i(r.expr):(r.type==="and"||r.type==="or")&&(i(r.left),i(r.right)))};return i(e),t}function z(e,t){let i=[],r=[],s=t;for(;s<e.length;){let l=e[s];if(l==="("||l==="\\("){i.push({type:"lparen"}),s++;continue}if(l===")"||l==="\\)"){i.push({type:"rparen"}),s++;continue}if(l==="-name"&&s+1<e.length)i.push({type:"expr",expr:{type:"name",pattern:e[++s]}});else if(l==="-iname"&&s+1<e.length)i.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}});else if(l==="-path"&&s+1<e.length)i.push({type:"expr",expr:{type:"path",pattern:e[++s]}});else if(l==="-ipath"&&s+1<e.length)i.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}});else if(l==="-type"&&s+1<e.length){let n=e[++s];if(n==="f"||n==="d")i.push({type:"expr",expr:{type:"type",fileType:n}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${n}
|
|
3
|
-
`,actions:[]}}else if(l==="-empty")i.push({type:"expr",expr:{type:"empty"}});else if(l==="-mtime"&&s+1<e.length){let n=e[++s],p="exact",a=n;n.startsWith("+")?(p="more",a=n.slice(1)):n.startsWith("-")&&(p="less",a=n.slice(1));let c=parseInt(a,10);Number.isNaN(c)||i.push({type:"expr",expr:{type:"mtime",days:c,comparison:p}})}else if(l==="-newer"&&s+1<e.length){let n=e[++s];i.push({type:"expr",expr:{type:"newer",refPath:n}})}else if(l==="-size"&&s+1<e.length){let n=e[++s],p="exact",a=n;n.startsWith("+")?(p="more",a=n.slice(1)):n.startsWith("-")&&(p="less",a=n.slice(1));let c=a.match(/^(\d+)([ckMGb])?$/);if(c){let M=parseInt(c[1],10),E=c[2]||"b";i.push({type:"expr",expr:{type:"size",value:M,unit:E,comparison:p}})}}else if(l==="-perm"&&s+1<e.length){let n=e[++s],p="exact",a=n;n.startsWith("-")?(p="all",a=n.slice(1)):n.startsWith("/")&&(p="any",a=n.slice(1));let c=parseInt(a,8);Number.isNaN(c)||i.push({type:"expr",expr:{type:"perm",mode:c,matchType:p}})}else if(l==="-not"||l==="!")i.push({type:"not"});else if(l==="-o"||l==="-or")i.push({type:"op",op:"or"});else if(l==="-a"||l==="-and")i.push({type:"op",op:"and"});else if(l==="-maxdepth"||l==="-mindepth")s++;else if(l==="-exec"){let n=[];for(s++;s<e.length&&e[s]!==";"&&e[s]!=="+";)n.push(e[s]),s++;if(s>=e.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n",actions:[]};let p=e[s]==="+";r.push({type:"exec",command:n,batchMode:p})}else if(l==="-print")r.push({type:"print"});else if(l==="-print0")r.push({type:"print0"});else if(l==="-delete")r.push({type:"delete"});else{if(l.startsWith("-"))return{expr:null,pathIndex:s,error:`find: unknown predicate '${l}'
|
|
4
|
-
`,actions:[]};if(i.length===0){s++;continue}break}s++}if(i.length===0)return{expr:null,pathIndex:s,actions:r};let y=$(i);return y.error?{expr:null,pathIndex:s,error:y.error,actions:r}:{expr:y.expr,pathIndex:s,actions:r}}function $(e){let t=0;function i(){let n=r();if(!n)return null;for(;t<e.length;){let p=e[t];if(p.type==="op"&&p.op==="or"){t++;let a=r();if(!a)return n;n={type:"or",left:n,right:a}}else break}return n}function r(){let n=s();if(!n)return null;for(;t<e.length;){let p=e[t];if(p.type==="op"&&p.op==="and"){t++;let a=s();if(!a)return n;n={type:"and",left:n,right:a}}else if(p.type==="expr"||p.type==="not"||p.type==="lparen"){let a=s();if(!a)return n;n={type:"and",left:n,right:a}}else break}return n}function s(){if(t<e.length&&e[t].type==="not"){t++;let n=s();return n?{type:"not",expr:n}:null}return y()}function y(){if(t>=e.length)return null;let n=e[t];if(n.type==="lparen"){t++;let p=i();return t<e.length&&e[t].type==="rparen"&&t++,p}return n.type==="expr"?(t++,n.expr):(n.type==="rparen",null)}return{expr:i()}}var A={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-delete delete found files/directories"," --help display this help and exit"]},S=new Set(["-name","-iname","-path","-ipath","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),H={name:"find",async execute(e,t){if(k(e))return C(A);let i=".",r=null,s=null;for(let o=0;o<e.length;o++){let f=e[o];if(f==="-maxdepth"&&o+1<e.length)r=parseInt(e[++o],10);else if(f==="-mindepth"&&o+1<e.length)s=parseInt(e[++o],10);else if(f==="-exec")for(o++;o<e.length&&e[o]!==";"&&e[o]!=="+";)o++;else!f.startsWith("-")&&f!==";"&&f!=="+"&&f!=="("&&f!==")"&&f!=="\\("&&f!=="\\)"?i=f:S.has(f)&&o++}let{expr:y,error:l,actions:n}=z(e,0);if(l)return{stdout:"",stderr:l,exitCode:1};let p=n.length===0,a=t.fs.resolvePath(t.cwd,i);try{await t.fs.stat(a)}catch{return{stdout:"",stderr:`find: ${i}: No such file or directory
|
|
5
|
-
`,exitCode:1}}let c=[],M=P(y),E=new Map;for(let o of M){let f=t.fs.resolvePath(t.cwd,o);try{let h=await t.fs.stat(f);E.set(o,h.mtime?.getTime()??Date.now())}catch{}}async function N(o,f){if(r!==null&&f>r)return;let h;try{h=await t.fs.stat(o)}catch{return}if(!h)return;let m;o===a?m=i.split("/").pop()||i:m=o.split("/").pop()||"";let u=o===a?i:i==="."?`./${o.slice(a.length+1)}`:i+o.slice(a.length),d=null;h.isDirectory&&(d=await t.fs.readdir(o));let I=h.isFile?h.size===0:d!==null&&d.length===0,D=s===null||f>=s;if(D&&y!==null){let T={name:m,relativePath:u,isFile:h.isFile,isDirectory:h.isDirectory,isEmpty:I,mtime:h.mtime?.getTime()??Date.now(),size:h.size??0,mode:h.mode??420,newerRefTimes:E};D=w(y,T)}if(D&&c.push(u),d!==null)for(let T of d){let R=o==="/"?`/${T}`:`${o}/${T}`;await N(R,f+1)}}await N(a,0);let b="",g="",x=0;if(n.length>0)for(let o of n)switch(o.type){case"print":b+=c.length>0?`${c.join(`
|
|
6
|
-
`)}
|
|
7
|
-
`:"";break;case"print0":b+=c.length>0?`${c.join("\0")}\0`:"";break;case"delete":{let f=[...c].sort((h,m)=>m.length-h.length);for(let h of f){let m=t.fs.resolvePath(t.cwd,h);try{await t.fs.rm(m,{recursive:!1})}catch(u){let d=u instanceof Error?u.message:String(u);g+=`find: cannot delete '${h}': ${d}
|
|
8
|
-
`,x=1}}break}case"exec":if(!t.exec)return{stdout:"",stderr:`find: -exec not supported in this context
|
|
9
|
-
`,exitCode:1};if(o.batchMode){let f=[];for(let u of o.command)u==="{}"?f.push(...c):f.push(u);let h=f.map(u=>`"${u}"`).join(" "),m=await t.exec(h);b+=m.stdout,g+=m.stderr,m.exitCode!==0&&(x=m.exitCode)}else for(let f of c){let m=o.command.map(d=>d==="{}"?f:d).map(d=>`"${d}"`).join(" "),u=await t.exec(m);b+=u.stdout,g+=u.stderr,u.exitCode!==0&&(x=u.exitCode)}break}else p&&(b=c.length>0?`${c.join(`
|
|
10
|
-
`)}
|
|
11
|
-
`:"");return{stdout:b,stderr:g,exitCode:x}}};export{H as findCommand};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as N}from"./chunk-26Q3PZQ6.js";import{a as L,b as B,c as H}from"./chunk-6QUZ7QML.js";import{a as I,b as O}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function w(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-s.mtime)/(1e3*60*60*24),t;return e.comparison==="more"?t=r>e.days:e.comparison==="less"?t=r<e.days:t=Math.floor(r)===e.days,{matches:t,pruned:!1,printed:!1}}case"newer":{let n=s.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let r;return e.comparison==="more"?r=s.size>n:e.comparison==="less"?r=s.size<n:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=s.mode&511,r=e.mode&511,t;return e.matchType==="exact"?t=n===r:e.matchType==="all"?t=(n&r)===r:t=(n&r)!==0,{matches:t,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let n=w(e.expr,s);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=w(e.left,s);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=w(e.right,s);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=w(e.left,s);if(n.matches)return n;let r=w(e.right,s);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function G(e){let s=[],n=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(e),s}function j(e,s){let n=[],r=[],t=s;for(;t<e.length;){let a=e[t];if(a==="("||a==="\\("){n.push({type:"lparen"}),t++;continue}if(a===")"||a==="\\)"){n.push({type:"rparen"}),t++;continue}if(a==="-name"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t]}});else if(a==="-iname"&&t+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++t],ignoreCase:!0}});else if(a==="-path"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t]}});else if(a==="-ipath"&&t+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++t],ignoreCase:!0}});else if(a==="-regex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t]}});else if(a==="-iregex"&&t+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++t],ignoreCase:!0}});else if(a==="-type"&&t+1<e.length){let i=e[++t];if(i==="f"||i==="d")n.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:t,error:`find: Unknown argument to -type: ${i}
|
|
3
|
-
`,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("+")?(c="more",o=i.slice(1)):i.startsWith("-")&&(c="less",o=i.slice(1));let h=parseInt(o,10);Number.isNaN(h)||n.push({type:"expr",expr:{type:"mtime",days:h,comparison:c}})}else if(a==="-newer"&&t+1<e.length){let i=e[++t];n.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(a==="-size"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("+")?(c="more",o=i.slice(1)):i.startsWith("-")&&(c="less",o=i.slice(1));let h=o.match(/^(\d+)([ckMGb])?$/);if(h){let b=parseInt(h[1],10),y=h[2]||"b";n.push({type:"expr",expr:{type:"size",value:b,unit:y,comparison:c}})}}else if(a==="-perm"&&t+1<e.length){let i=e[++t],c="exact",o=i;i.startsWith("-")?(c="all",o=i.slice(1)):i.startsWith("/")&&(c="any",o=i.slice(1));let h=parseInt(o,8);Number.isNaN(h)||n.push({type:"expr",expr:{type:"perm",mode:h,matchType:c}})}else if(a==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(a==="-not"||a==="!")n.push({type:"not"});else if(a==="-o"||a==="-or")n.push({type:"op",op:"or"});else if(a==="-a"||a==="-and")n.push({type:"op",op:"and"});else if(a==="-maxdepth"||a==="-mindepth")t++;else if(a!=="-depth")if(a==="-exec"){let i=[];for(t++;t<e.length&&e[t]!==";"&&e[t]!=="+";)i.push(e[t]),t++;if(t>=e.length)return{expr:null,pathIndex:t,error:"find: missing argument to `-exec'\n",actions:[]};let c=e[t]==="+";r.push({type:"exec",command:i,batchMode:c})}else if(a==="-print")n.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(a==="-print0")r.push({type:"print0"});else if(a==="-printf"&&t+1<e.length){let i=e[++t];r.push({type:"printf",format:i})}else if(a==="-delete")r.push({type:"delete"});else{if(a.startsWith("-"))return{expr:null,pathIndex:t,error:`find: unknown predicate '${a}'
|
|
4
|
-
`,actions:[]};if(n.length===0){t++;continue}break}t++}if(n.length===0)return{expr:null,pathIndex:t,actions:r};let m=_(n);return m.error?{expr:null,pathIndex:t,error:m.error,actions:r}:{expr:m.expr,pathIndex:t,actions:r}}function _(e){let s=0;function n(){let i=r();if(!i)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="or"){s++;let o=r();if(!o)return i;i={type:"or",left:i,right:o}}else break}return i}function r(){let i=t();if(!i)return null;for(;s<e.length;){let c=e[s];if(c.type==="op"&&c.op==="and"){s++;let o=t();if(!o)return i;i={type:"and",left:i,right:o}}else if(c.type==="expr"||c.type==="not"||c.type==="lparen"){let o=t();if(!o)return i;i={type:"and",left:i,right:o}}else break}return i}function t(){if(s<e.length&&e[s].type==="not"){s++;let i=t();return i?{type:"not",expr:i}:null}return m()}function m(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let c=n();return s<e.length&&e[s].type==="rparen"&&s++,c}return i.type==="expr"?(s++,i.expr):(i.type==="rparen",null)}return{expr:n()}}var K={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},U=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),oe={name:"find",async execute(e,s){if(O(e))return I(K);let n=[],r=null,t=null,m=!1,a=!1;for(let p=0;p<e.length;p++){let l=e[p];if(l==="-maxdepth"&&p+1<e.length)a=!0,r=parseInt(e[++p],10);else if(l==="-mindepth"&&p+1<e.length)a=!0,t=parseInt(e[++p],10);else if(l==="-depth")a=!0,m=!0;else if(l==="-exec")for(a=!0,p++;p<e.length&&e[p]!==";"&&e[p]!=="+";)p++;else!l.startsWith("-")&&l!==";"&&l!=="+"&&l!=="("&&l!==")"&&l!=="\\("&&l!=="\\)"&&l!=="!"?a||n.push(l):U.has(l)?(a=!0,p++):(l.startsWith("-")||l==="("||l==="\\("||l==="!")&&(a=!0)}n.length===0&&n.push(".");let{expr:i,error:c,actions:o}=j(e,0);if(c)return{stdout:"",stderr:c,exitCode:1};let h=o.some(p=>p.type==="print"),b=o.length===0,y=[],Y=o.some(p=>p.type==="printf"),F=[],T="",D=0,V=G(i),k=new Map;for(let p of V){let l=s.fs.resolvePath(s.cwd,p);try{let g=await s.fs.stat(l);k.set(p,g.mtime?.getTime()??Date.now())}catch{}}for(let p of n){let l=s.fs.resolvePath(s.cwd,p);try{await s.fs.stat(l)}catch{T+=`find: ${p}: No such file or directory
|
|
5
|
-
`,D=1;continue}async function g(u,d){if(r!==null&&d>r)return;let f;try{f=await s.fs.stat(u)}catch{return}if(!f)return;let E;u===l?E=p.split("/").pop()||p:E=u.split("/").pop()||"";let v=u===l?p:p==="."?`./${u.slice(l.length+1)}`:p+u.slice(l.length),M=null;f.isDirectory&&(M=await s.fs.readdir(u));let R=f.isFile?f.size===0:M!==null&&M.length===0,C=()=>{let x=t===null||d>=t,$=!1;if(x&&i!==null){let J={name:E,relativePath:v,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k},W=w(i,J);x=W.matches,h?$=W.printed:$=x}else x&&($=!0);$&&(y.push(v),Y&&F.push({path:v,name:E,size:f.size??0,mtime:f.mtime?.getTime()??Date.now(),mode:f.mode??420,isDirectory:f.isDirectory,depth:d,startingPoint:p}))},A=async()=>{if(M!==null)for(let P of M){let x=u==="/"?`/${P}`:`${u}/${P}`;await g(x,d+1)}},z=!1;if(!m&&i!==null){let P={name:E,relativePath:v,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:R,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:k};z=w(i,P).pruned}m?(await A(),C()):(C(),z||await A())}await g(l,0)}let S="";if(o.length>0)for(let p of o)switch(p.type){case"print":S+=y.length>0?`${y.join(`
|
|
6
|
-
`)}
|
|
7
|
-
`:"";break;case"print0":S+=y.length>0?`${y.join("\0")}\0`:"";break;case"delete":{let l=[...y].sort((g,u)=>u.length-g.length);for(let g of l){let u=s.fs.resolvePath(s.cwd,g);try{await s.fs.rm(u,{recursive:!1})}catch(d){let f=d instanceof Error?d.message:String(d);T+=`find: cannot delete '${g}': ${f}
|
|
8
|
-
`,D=1}}break}case"printf":for(let l of F)S+=q(p.format,l);break;case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
|
|
9
|
-
`,exitCode:1};if(p.batchMode){let l=[];for(let d of p.command)d==="{}"?l.push(...y):l.push(d);let g=l.map(d=>`"${d}"`).join(" "),u=await s.exec(g,{cwd:s.cwd});S+=u.stdout,T+=u.stderr,u.exitCode!==0&&(D=u.exitCode)}else for(let l of y){let u=p.command.map(f=>f==="{}"?l:f).map(f=>`"${f}"`).join(" "),d=await s.exec(u,{cwd:s.cwd});S+=d.stdout,T+=d.stderr,d.exitCode!==0&&(D=d.exitCode)}break}else b&&(S=y.length>0?`${y.join(`
|
|
10
|
-
`)}
|
|
11
|
-
`:"");return{stdout:S,stderr:T,exitCode:D}}};function q(e,s){let n=H(e),r="",t=0;for(;t<n.length;)if(n[t]==="%"&&t+1<n.length){if(t++,n[t]==="%"){r+="%",t++;continue}let[m,a,i]=B(n,t);if(t+=i,t>=n.length){r+="%";break}let c=n[t],o;switch(c){case"f":o=s.name,t++;break;case"h":{let h=s.path.lastIndexOf("/");o=h>0?s.path.slice(0,h):".",t++;break}case"p":o=s.path,t++;break;case"P":{let h=s.startingPoint;s.path===h?o="":s.path.startsWith(`${h}/`)?o=s.path.slice(h.length+1):h==="."&&s.path.startsWith("./")?o=s.path.slice(2):o=s.path,t++;break}case"s":o=String(s.size),t++;break;case"d":o=String(s.depth),t++;break;case"m":o=(s.mode&511).toString(8),t++;break;case"M":o=Q(s.mode,s.isDirectory),t++;break;case"t":{let h=new Date(s.mtime);o=X(h),t++;break}case"T":{if(t+1<n.length){let h=n[t+1],b=new Date(s.mtime);o=Z(b,h),t+=2}else o="%T",t++;break}default:r+="%"+(m!==0||a!==-1?`${m}.${a}`:"")+c,t++;continue}r+=L(o,m,a)}else r+=n[t],t++;return r}function Q(e,s){let n=e&511,r=s?"d":"-";return r+=n&256?"r":"-",r+=n&128?"w":"-",r+=n&64?"x":"-",r+=n&32?"r":"-",r+=n&16?"w":"-",r+=n&8?"x":"-",r+=n&4?"r":"-",r+=n&2?"w":"-",r+=n&1?"x":"-",r}function X(e){let s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=s[e.getDay()],t=n[e.getMonth()],m=String(e.getDate()).padStart(2," "),a=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),c=String(e.getSeconds()).padStart(2,"0"),o=e.getFullYear();return`${r} ${t} ${m} ${a}:${i}:${c} ${o}`}function Z(e,s){switch(s){case"@":return String(e.getTime()/1e3);case"Y":return String(e.getFullYear());case"m":return String(e.getMonth()+1).padStart(2,"0");case"d":return String(e.getDate()).padStart(2,"0");case"H":return String(e.getHours()).padStart(2,"0");case"M":return String(e.getMinutes()).padStart(2,"0");case"S":return String(e.getSeconds()).padStart(2,"0");case"T":return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`;case"F":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;default:return`%T${s}`}}export{oe as findCommand};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as N}from"./chunk-26Q3PZQ6.js";import{a as A,b as z}from"./chunk-GTNBSMZR.js";import"./chunk-5KNEBKYN.js";function g(e,s){switch(e.type){case"name":return{matches:N(s.name,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:N(s.relativePath,e.pattern,e.ignoreCase),pruned:!1,printed:!1};case"regex":try{let t=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,t).test(s.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:s.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:s.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-s.mtime)/(1e3*60*60*24),n;return e.comparison==="more"?n=r>e.days:e.comparison==="less"?n=r<e.days:n=Math.floor(r)===e.days,{matches:n,pruned:!1,printed:!1}}case"newer":{let t=s.newerRefTimes.get(e.refPath);return t===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:s.mtime>t,pruned:!1,printed:!1}}case"size":{let t=e.value;switch(e.unit){case"c":t=e.value;break;case"k":t=e.value*1024;break;case"M":t=e.value*1024*1024;break;case"G":t=e.value*1024*1024*1024;break;case"b":t=e.value*512;break}let r;return e.comparison==="more"?r=s.size>t:e.comparison==="less"?r=s.size<t:e.unit==="b"?r=Math.ceil(s.size/512)===e.value:r=s.size===t,{matches:r,pruned:!1,printed:!1}}case"perm":{let t=s.mode&511,r=e.mode&511,n;return e.matchType==="exact"?n=t===r:e.matchType==="all"?n=(t&r)===r:n=(t&r)!==0,{matches:n,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let t=g(e.expr,s);return{matches:!t.matches,pruned:t.pruned,printed:!1}}case"and":{let t=g(e.left,s);if(!t.matches)return{matches:!1,pruned:t.pruned,printed:!1};let r=g(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:t.printed||r.printed}}case"or":{let t=g(e.left,s);if(t.matches)return t;let r=g(e.right,s);return{matches:r.matches,pruned:t.pruned||r.pruned,printed:r.printed}}}}function I(e){let s=[],t=r=>{r&&(r.type==="newer"?s.push(r.refPath):r.type==="not"?t(r.expr):(r.type==="and"||r.type==="or")&&(t(r.left),t(r.right)))};return t(e),s}function $(e,s){let t=[],r=[],n=s;for(;n<e.length;){let l=e[n];if(l==="("||l==="\\("){t.push({type:"lparen"}),n++;continue}if(l===")"||l==="\\)"){t.push({type:"rparen"}),n++;continue}if(l==="-name"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n]}});else if(l==="-iname"&&n+1<e.length)t.push({type:"expr",expr:{type:"name",pattern:e[++n],ignoreCase:!0}});else if(l==="-path"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n]}});else if(l==="-ipath"&&n+1<e.length)t.push({type:"expr",expr:{type:"path",pattern:e[++n],ignoreCase:!0}});else if(l==="-regex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n]}});else if(l==="-iregex"&&n+1<e.length)t.push({type:"expr",expr:{type:"regex",pattern:e[++n],ignoreCase:!0}});else if(l==="-type"&&n+1<e.length){let i=e[++n];if(i==="f"||i==="d")t.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:n,error:`find: Unknown argument to -type: ${i}
|
|
3
|
-
`,actions:[]}}else if(l==="-empty")t.push({type:"expr",expr:{type:"empty"}});else if(l==="-mtime"&&n+1<e.length){let i=e[++n],o="exact",f=i;i.startsWith("+")?(o="more",f=i.slice(1)):i.startsWith("-")&&(o="less",f=i.slice(1));let u=parseInt(f,10);Number.isNaN(u)||t.push({type:"expr",expr:{type:"mtime",days:u,comparison:o}})}else if(l==="-newer"&&n+1<e.length){let i=e[++n];t.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(l==="-size"&&n+1<e.length){let i=e[++n],o="exact",f=i;i.startsWith("+")?(o="more",f=i.slice(1)):i.startsWith("-")&&(o="less",f=i.slice(1));let u=f.match(/^(\d+)([ckMGb])?$/);if(u){let m=parseInt(u[1],10),v=u[2]||"b";t.push({type:"expr",expr:{type:"size",value:m,unit:v,comparison:o}})}}else if(l==="-perm"&&n+1<e.length){let i=e[++n],o="exact",f=i;i.startsWith("-")?(o="all",f=i.slice(1)):i.startsWith("/")&&(o="any",f=i.slice(1));let u=parseInt(f,8);Number.isNaN(u)||t.push({type:"expr",expr:{type:"perm",mode:u,matchType:o}})}else if(l==="-prune")t.push({type:"expr",expr:{type:"prune"}});else if(l==="-not"||l==="!")t.push({type:"not"});else if(l==="-o"||l==="-or")t.push({type:"op",op:"or"});else if(l==="-a"||l==="-and")t.push({type:"op",op:"and"});else if(l==="-maxdepth"||l==="-mindepth")n++;else if(l==="-exec"){let i=[];for(n++;n<e.length&&e[n]!==";"&&e[n]!=="+";)i.push(e[n]),n++;if(n>=e.length)return{expr:null,pathIndex:n,error:"find: missing argument to `-exec'\n",actions:[]};let o=e[n]==="+";r.push({type:"exec",command:i,batchMode:o})}else if(l==="-print")t.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(l==="-print0")r.push({type:"print0"});else if(l==="-delete")r.push({type:"delete"});else{if(l.startsWith("-"))return{expr:null,pathIndex:n,error:`find: unknown predicate '${l}'
|
|
4
|
-
`,actions:[]};if(t.length===0){n++;continue}break}n++}if(t.length===0)return{expr:null,pathIndex:n,actions:r};let w=S(t);return w.error?{expr:null,pathIndex:n,error:w.error,actions:r}:{expr:w.expr,pathIndex:n,actions:r}}function S(e){let s=0;function t(){let i=r();if(!i)return null;for(;s<e.length;){let o=e[s];if(o.type==="op"&&o.op==="or"){s++;let f=r();if(!f)return i;i={type:"or",left:i,right:f}}else break}return i}function r(){let i=n();if(!i)return null;for(;s<e.length;){let o=e[s];if(o.type==="op"&&o.op==="and"){s++;let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else if(o.type==="expr"||o.type==="not"||o.type==="lparen"){let f=n();if(!f)return i;i={type:"and",left:i,right:f}}else break}return i}function n(){if(s<e.length&&e[s].type==="not"){s++;let i=n();return i?{type:"not",expr:i}:null}return w()}function w(){if(s>=e.length)return null;let i=e[s];if(i.type==="lparen"){s++;let o=t();return s<e.length&&e[s].type==="rparen"&&s++,o}return i.type==="expr"?(s++,i.expr):(i.type==="rparen",null)}return{expr:t()}}var F={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-delete delete found files/directories"," --help display this help and exit"]},L=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),K={name:"find",async execute(e,s){if(z(e))return A(F);let t=".",r=null,n=null;for(let a=0;a<e.length;a++){let p=e[a];if(p==="-maxdepth"&&a+1<e.length)r=parseInt(e[++a],10);else if(p==="-mindepth"&&a+1<e.length)n=parseInt(e[++a],10);else if(p==="-exec")for(a++;a<e.length&&e[a]!==";"&&e[a]!=="+";)a++;else!p.startsWith("-")&&p!==";"&&p!=="+"&&p!=="("&&p!==")"&&p!=="\\("&&p!=="\\)"&&p!=="!"?t=p:L.has(p)&&a++}let{expr:w,error:l,actions:i}=$(e,0);if(l)return{stdout:"",stderr:l,exitCode:1};let o=i.some(a=>a.type==="print"),f=i.length===0,u=s.fs.resolvePath(s.cwd,t);try{await s.fs.stat(u)}catch{return{stdout:"",stderr:`find: ${t}: No such file or directory
|
|
5
|
-
`,exitCode:1}}let m=[],v=I(w),C=new Map;for(let a of v){let p=s.fs.resolvePath(s.cwd,a);try{let c=await s.fs.stat(p);C.set(a,c.mtime?.getTime()??Date.now())}catch{}}async function R(a,p){if(r!==null&&p>r)return;let c;try{c=await s.fs.stat(a)}catch{return}if(!c)return;let d;a===u?d=t.split("/").pop()||t:d=a.split("/").pop()||"";let h=a===u?t:t==="."?`./${a.slice(u.length+1)}`:t+a.slice(u.length),y=null;c.isDirectory&&(y=await s.fs.readdir(a));let W=c.isFile?c.size===0:y!==null&&y.length===0,P=n===null||p>=n,k=!1,D=!1;if(P&&w!==null){let M={name:d,relativePath:h,isFile:c.isFile,isDirectory:c.isDirectory,isEmpty:W,mtime:c.mtime?.getTime()??Date.now(),size:c.size??0,mode:c.mode??420,newerRefTimes:C},E=g(w,M);P=E.matches,k=E.pruned,o?D=E.printed:D=P}else P&&(D=!0);if(D&&m.push(h),y!==null&&!k)for(let M of y){let E=a==="/"?`/${M}`:`${a}/${M}`;await R(E,p+1)}}await R(u,0);let x="",b="",T=0;if(i.length>0)for(let a of i)switch(a.type){case"print":x+=m.length>0?`${m.join(`
|
|
6
|
-
`)}
|
|
7
|
-
`:"";break;case"print0":x+=m.length>0?`${m.join("\0")}\0`:"";break;case"delete":{let p=[...m].sort((c,d)=>d.length-c.length);for(let c of p){let d=s.fs.resolvePath(s.cwd,c);try{await s.fs.rm(d,{recursive:!1})}catch(h){let y=h instanceof Error?h.message:String(h);b+=`find: cannot delete '${c}': ${y}
|
|
8
|
-
`,T=1}}break}case"exec":if(!s.exec)return{stdout:"",stderr:`find: -exec not supported in this context
|
|
9
|
-
`,exitCode:1};if(a.batchMode){let p=[];for(let h of a.command)h==="{}"?p.push(...m):p.push(h);let c=p.map(h=>`"${h}"`).join(" "),d=await s.exec(c,{cwd:s.cwd});x+=d.stdout,b+=d.stderr,d.exitCode!==0&&(T=d.exitCode)}else for(let p of m){let d=a.command.map(y=>y==="{}"?p:y).map(y=>`"${y}"`).join(" "),h=await s.exec(d,{cwd:s.cwd});x+=h.stdout,b+=h.stderr,h.exitCode!==0&&(T=h.exitCode)}break}else f&&(x=m.length>0?`${m.join(`
|
|
10
|
-
`)}
|
|
11
|
-
`:"");return{stdout:x,stderr:b,exitCode:T}}};export{K as findCommand};
|