just-bash 2.5.4 → 2.6.0
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/README.md +2 -2
- package/dist/AGENTS.md +2 -2
- package/dist/ast/types.d.ts +100 -11
- package/dist/bin/chunks/alias-EGIS5LUE.js +7 -0
- package/dist/bin/chunks/awk2-GFEJOWML.js +21 -0
- package/dist/bin/chunks/bash-PGDTHIM2.js +6 -0
- package/dist/bin/chunks/chmod-TYLTHXFR.js +9 -0
- package/dist/bin/chunks/chunk-D5WP4CKS.js +3 -0
- package/dist/bin/chunks/chunk-FSAGDARS.js +74 -0
- package/dist/bin/chunks/chunk-FSZWFMB4.js +16 -0
- package/dist/bin/chunks/chunk-IRUD2E3M.js +17 -0
- package/dist/bin/chunks/chunk-K5IXNHO5.js +8 -0
- package/dist/bin/chunks/chunk-KD3EODLB.js +6 -0
- package/dist/bin/{shell/chunks/echo-WSKTON6U.js → chunks/echo-7I42V66Q.js} +2 -2
- package/dist/bin/chunks/env-7A4MH7BJ.js +9 -0
- package/dist/bin/chunks/expansion-BOR3ELLC.js +2 -0
- package/dist/bin/{shell/chunks/find-CBEJ35BR.js → chunks/find-PHDZK64M.js} +1 -1
- package/dist/bin/{shell/chunks/grep-IIVQXFNI.js → chunks/grep-VX7MJMVN.js} +2 -2
- package/dist/bin/chunks/{head-DYK37Z24.js → head-TJHLLIMR.js} +1 -1
- package/dist/bin/{shell/chunks/jq-XXZPU5CA.js → chunks/jq-RGZHJNXC.js} +1 -1
- package/dist/bin/chunks/od-KRKGC2U3.js +5 -0
- package/dist/bin/chunks/printf-YPXD4CRE.js +15 -0
- package/dist/bin/chunks/pwd-L26WH2K4.js +3 -0
- package/dist/bin/{shell/chunks/rg-Q4OTJOEF.js → chunks/rg-RSDLLECO.js} +1 -1
- package/dist/bin/chunks/rmdir-GOODLY5W.js +14 -0
- package/dist/bin/chunks/sed-JPDTWF4W.js +100 -0
- package/dist/bin/{shell/chunks/tail-BES27CZT.js → chunks/tail-YAUIERGN.js} +1 -1
- package/dist/bin/{shell/chunks/tar-C27YYUAS.js → chunks/tar-LFENC54A.js} +7 -7
- package/dist/bin/chunks/time-37F5EBPK.js +14 -0
- package/dist/bin/chunks/touch-IBPHJBM3.js +7 -0
- package/dist/bin/chunks/wc-SAOHEZYP.js +6 -0
- package/dist/bin/chunks/{which-73KOOLC6.js → which-FCDFBOMN.js} +1 -1
- package/dist/bin/chunks/whoami-JVLUNKSG.js +3 -0
- package/dist/bin/{shell/chunks/xan-6K2NGTHM.js → chunks/xan-5HNHTFMB.js} +19 -19
- package/dist/bin/chunks/{yq-MF2SNFGL.js → yq-PFV4T2PV.js} +1 -1
- package/dist/bin/just-bash.js +659 -135
- package/dist/bin/shell/chunks/alias-EGIS5LUE.js +7 -0
- package/dist/bin/shell/chunks/awk2-GFEJOWML.js +21 -0
- package/dist/bin/shell/chunks/bash-PGDTHIM2.js +6 -0
- package/dist/bin/shell/chunks/chmod-TYLTHXFR.js +9 -0
- package/dist/bin/shell/chunks/chunk-D5WP4CKS.js +3 -0
- package/dist/bin/shell/chunks/chunk-FSAGDARS.js +74 -0
- package/dist/bin/shell/chunks/chunk-FSZWFMB4.js +16 -0
- package/dist/bin/shell/chunks/chunk-IRUD2E3M.js +17 -0
- package/dist/bin/shell/chunks/chunk-K5IXNHO5.js +8 -0
- package/dist/bin/shell/chunks/chunk-KD3EODLB.js +6 -0
- package/dist/bin/{chunks/echo-WSKTON6U.js → shell/chunks/echo-7I42V66Q.js} +2 -2
- package/dist/bin/shell/chunks/env-7A4MH7BJ.js +9 -0
- package/dist/bin/shell/chunks/expansion-BOR3ELLC.js +2 -0
- package/dist/bin/{chunks/find-CBEJ35BR.js → shell/chunks/find-PHDZK64M.js} +1 -1
- package/dist/bin/{chunks/grep-IIVQXFNI.js → shell/chunks/grep-VX7MJMVN.js} +2 -2
- package/dist/bin/shell/chunks/{head-DYK37Z24.js → head-TJHLLIMR.js} +1 -1
- package/dist/bin/{chunks/jq-XXZPU5CA.js → shell/chunks/jq-RGZHJNXC.js} +1 -1
- package/dist/bin/shell/chunks/od-KRKGC2U3.js +5 -0
- package/dist/bin/shell/chunks/printf-YPXD4CRE.js +15 -0
- package/dist/bin/shell/chunks/pwd-L26WH2K4.js +3 -0
- package/dist/bin/{chunks/rg-Q4OTJOEF.js → shell/chunks/rg-RSDLLECO.js} +1 -1
- package/dist/bin/shell/chunks/rmdir-GOODLY5W.js +14 -0
- package/dist/bin/shell/chunks/sed-JPDTWF4W.js +100 -0
- package/dist/bin/{chunks/tail-BES27CZT.js → shell/chunks/tail-YAUIERGN.js} +1 -1
- package/dist/bin/{chunks/tar-C27YYUAS.js → shell/chunks/tar-LFENC54A.js} +7 -7
- package/dist/bin/shell/chunks/time-37F5EBPK.js +14 -0
- package/dist/bin/shell/chunks/touch-IBPHJBM3.js +7 -0
- package/dist/bin/shell/chunks/wc-SAOHEZYP.js +6 -0
- package/dist/bin/shell/chunks/{which-73KOOLC6.js → which-FCDFBOMN.js} +1 -1
- package/dist/bin/shell/chunks/whoami-JVLUNKSG.js +3 -0
- package/dist/bin/{chunks/xan-6K2NGTHM.js → shell/chunks/xan-5HNHTFMB.js} +19 -19
- package/dist/bin/shell/chunks/{yq-MF2SNFGL.js → yq-PFV4T2PV.js} +1 -1
- package/dist/bin/shell/shell.js +664 -140
- package/dist/bundle/browser.js +1251 -606
- package/dist/bundle/chunks/alias-ATFBB6D2.js +6 -0
- package/dist/bundle/chunks/awk2-6FBZTP57.js +20 -0
- package/dist/bundle/chunks/bash-OLRNM52U.js +5 -0
- package/dist/bundle/chunks/chmod-ODWUR7E6.js +8 -0
- package/dist/bundle/chunks/chunk-3AWP5CWK.js +73 -0
- package/dist/bundle/chunks/chunk-CXEWLFNE.js +16 -0
- package/dist/bundle/chunks/chunk-CZPA5RBA.js +5 -0
- package/dist/bundle/chunks/chunk-EEXR5ZDP.js +2 -0
- package/dist/bundle/chunks/chunk-HDQ56CKY.js +15 -0
- package/dist/bundle/chunks/chunk-PSW6BMXW.js +7 -0
- package/dist/bundle/chunks/{echo-VUHWYV6L.js → echo-6S7WE7XB.js} +2 -2
- package/dist/bundle/chunks/env-2UI6XINU.js +8 -0
- package/dist/bundle/chunks/expansion-RIGCFEMA.js +1 -0
- package/dist/bundle/chunks/{find-ACOAWALE.js → find-YGMSVGUV.js} +1 -1
- package/dist/bundle/chunks/{grep-ACVE42JK.js → grep-NIC6JNLH.js} +2 -2
- package/dist/bundle/chunks/{head-FZ6IQHYW.js → head-SA7P5NJ7.js} +1 -1
- package/dist/bundle/chunks/{jq-3YU5HRKE.js → jq-RLRYRPOJ.js} +1 -1
- package/dist/bundle/chunks/od-3FPDPLWJ.js +4 -0
- package/dist/bundle/chunks/printf-66XGXFCD.js +14 -0
- package/dist/bundle/chunks/pwd-S4NVAMC4.js +2 -0
- package/dist/bundle/chunks/{rg-YLZJWCEJ.js → rg-SRMB7L6G.js} +1 -1
- package/dist/bundle/chunks/rmdir-XFQE4ZYV.js +13 -0
- package/dist/bundle/chunks/sed-IV6HLDXU.js +99 -0
- package/dist/bundle/chunks/{tail-PD4RZR6J.js → tail-52LRAWXT.js} +1 -1
- package/dist/bundle/chunks/{tar-QWBXMF7K.js → tar-LWIHPMT6.js} +7 -7
- package/dist/bundle/chunks/time-UWXBG6CS.js +13 -0
- package/dist/bundle/chunks/touch-TDTEBHHI.js +6 -0
- package/dist/bundle/chunks/wc-HE5XARI4.js +5 -0
- package/dist/bundle/chunks/{which-M5MQ6QXQ.js → which-UBLRBDHN.js} +1 -1
- package/dist/bundle/chunks/whoami-YUDAIS32.js +2 -0
- package/dist/bundle/chunks/{xan-2R2APJJ4.js → xan-A6VPI4HJ.js} +19 -19
- package/dist/bundle/chunks/{yq-KANM4MD2.js → yq-L665QPQU.js} +1 -1
- package/dist/bundle/index.js +657 -133
- package/dist/commands/awk/ast.d.ts +1 -0
- package/dist/commands/awk/interpreter/context.d.ts +14 -0
- package/dist/commands/awk/interpreter/interpreter.d.ts +2 -0
- package/dist/commands/awk/interpreter/{helpers.d.ts → type-coercion.d.ts} +4 -1
- package/dist/commands/awk/parser2-print.d.ts +35 -0
- package/dist/commands/awk/parser2.d.ts +42 -34
- package/dist/commands/printf/strftime.d.ts +9 -0
- package/dist/commands/query-engine/builtins/array-builtins.d.ts +20 -0
- package/dist/commands/query-engine/builtins/control-builtins.d.ts +18 -0
- package/dist/commands/query-engine/builtins/date-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/format-builtins.d.ts +11 -0
- package/dist/commands/query-engine/builtins/index-builtins.d.ts +16 -0
- package/dist/commands/query-engine/builtins/index.d.ts +17 -0
- package/dist/commands/query-engine/builtins/math-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/navigation-builtins.d.ts +18 -0
- package/dist/commands/query-engine/builtins/object-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/path-builtins.d.ts +20 -0
- package/dist/commands/query-engine/builtins/sql-builtins.d.ts +16 -0
- package/dist/commands/query-engine/builtins/string-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/type-builtins.d.ts +11 -0
- package/dist/commands/query-engine/evaluator.d.ts +10 -2
- package/dist/commands/query-engine/parser-types.d.ts +171 -0
- package/dist/commands/query-engine/parser.d.ts +2 -132
- package/dist/commands/query-engine/path-operations.d.ts +15 -0
- package/dist/commands/query-engine/value-operations.d.ts +39 -0
- package/dist/commands/registry.d.ts +1 -1
- package/dist/commands/rmdir/rmdir.d.ts +2 -0
- package/dist/commands/sed/lexer.d.ts +12 -0
- package/dist/commands/sed/parser.d.ts +9 -0
- package/dist/commands/sed/sed-regex.d.ts +23 -0
- package/dist/commands/sed/types.d.ts +13 -1
- package/dist/commands/tar/tar-options.d.ts +36 -0
- package/dist/commands/time/time.d.ts +25 -0
- package/dist/commands/whoami/whoami.d.ts +9 -0
- package/dist/commands/xan/moonblade-tokenizer.d.ts +25 -0
- package/dist/fs/in-memory-fs/in-memory-fs.d.ts +12 -0
- package/dist/fs/interface.d.ts +16 -0
- package/dist/fs/mountable-fs/mountable-fs.d.ts +12 -0
- package/dist/fs/overlay-fs/overlay-fs.d.ts +13 -1
- package/dist/fs/read-write-fs/read-write-fs.d.ts +13 -1
- package/dist/interpreter/alias-expansion.d.ts +23 -0
- package/dist/interpreter/arithmetic.d.ts +1 -6
- package/dist/interpreter/assignment-expansion.d.ts +24 -0
- package/dist/interpreter/builtin-dispatch.d.ts +39 -0
- package/dist/interpreter/builtins/compgen.d.ts +26 -0
- package/dist/interpreter/builtins/complete.d.ts +17 -0
- package/dist/interpreter/builtins/compopt.d.ts +28 -0
- package/dist/interpreter/builtins/declare-array-parsing.d.ts +14 -0
- package/dist/interpreter/builtins/declare-print.d.ts +39 -0
- package/dist/interpreter/builtins/declare.d.ts +10 -4
- package/dist/interpreter/builtins/dirs.d.ts +29 -0
- package/dist/interpreter/builtins/eval.d.ts +1 -1
- package/dist/interpreter/builtins/export.d.ts +1 -0
- package/dist/interpreter/builtins/getopts.d.ts +18 -0
- package/dist/interpreter/builtins/hash.d.ts +19 -0
- package/dist/interpreter/builtins/help.d.ts +12 -0
- package/dist/interpreter/builtins/index.d.ts +9 -1
- package/dist/interpreter/builtins/local.d.ts +1 -1
- package/dist/interpreter/builtins/read.d.ts +1 -1
- package/dist/interpreter/builtins/set.d.ts +3 -0
- package/dist/interpreter/builtins/shift.d.ts +3 -0
- package/dist/interpreter/builtins/shopt.d.ts +7 -0
- package/dist/interpreter/builtins/unset.d.ts +5 -1
- package/dist/interpreter/builtins/variable-assignment.d.ts +66 -0
- package/dist/interpreter/command-resolution.d.ts +43 -0
- package/dist/interpreter/conditionals.d.ts +1 -1
- package/dist/interpreter/errors.d.ts +36 -1
- package/dist/interpreter/expansion/analysis.d.ts +15 -17
- package/dist/interpreter/expansion/arith-text-expansion.d.ts +20 -0
- package/dist/interpreter/expansion/array-pattern-ops.d.ts +21 -0
- package/dist/interpreter/expansion/array-prefix-suffix.d.ts +46 -0
- package/dist/interpreter/expansion/array-slice-transform.d.ts +36 -0
- package/dist/interpreter/expansion/array-word-expansion.d.ts +39 -0
- package/dist/interpreter/expansion/command-substitution.d.ts +23 -0
- package/dist/interpreter/expansion/glob-escape.d.ts +32 -0
- package/dist/interpreter/expansion/indirect-expansion.d.ts +42 -0
- package/dist/interpreter/expansion/parameter-ops.d.ts +113 -0
- package/dist/interpreter/expansion/pattern-expansion.d.ts +23 -0
- package/dist/interpreter/expansion/pattern-removal.d.ts +18 -0
- package/dist/interpreter/expansion/pattern.d.ts +2 -1
- package/dist/interpreter/expansion/positional-params.d.ts +59 -0
- package/dist/interpreter/expansion/prompt.d.ts +39 -0
- package/dist/interpreter/expansion/quoting.d.ts +13 -0
- package/dist/interpreter/expansion/tilde.d.ts +12 -0
- package/dist/interpreter/expansion/unquoted-expansion.d.ts +76 -0
- package/dist/interpreter/expansion/variable-attrs.d.ts +19 -0
- package/dist/interpreter/expansion/variable.d.ts +10 -1
- package/dist/interpreter/expansion/word-glob-expansion.d.ts +33 -0
- package/dist/interpreter/expansion/word-split.d.ts +11 -6
- package/dist/interpreter/expansion.d.ts +30 -4
- package/dist/interpreter/functions.d.ts +1 -1
- package/dist/interpreter/helpers/array.d.ts +20 -0
- package/dist/interpreter/helpers/ifs.d.ts +66 -5
- package/dist/interpreter/helpers/nameref.d.ts +65 -0
- package/dist/interpreter/helpers/quoting.d.ts +24 -0
- package/dist/interpreter/helpers/readonly.d.ts +28 -4
- package/dist/interpreter/helpers/shell-constants.d.ts +25 -0
- package/dist/interpreter/helpers/shellopts.d.ts +28 -0
- package/dist/interpreter/helpers/string-compare.d.ts +3 -1
- package/dist/interpreter/helpers/tilde.d.ts +13 -0
- package/dist/interpreter/helpers/variable-tests.d.ts +1 -1
- package/dist/interpreter/helpers/word-matching.d.ts +26 -0
- package/dist/interpreter/helpers/xtrace.d.ts +18 -0
- package/dist/interpreter/interpreter.d.ts +13 -14
- package/dist/interpreter/pipeline-execution.d.ts +16 -0
- package/dist/interpreter/redirections.d.ts +38 -1
- package/dist/interpreter/simple-command-assignments.d.ts +29 -0
- package/dist/interpreter/subshell-group.d.ts +32 -0
- package/dist/interpreter/type-command.d.ts +37 -0
- package/dist/interpreter/types.d.ts +255 -21
- package/dist/parser/arithmetic-parser.d.ts +2 -4
- package/dist/parser/arithmetic-primaries.d.ts +45 -0
- package/dist/parser/compound-parser.d.ts +21 -7
- package/dist/parser/expansion-parser.d.ts +7 -1
- package/dist/parser/lexer.d.ts +57 -0
- package/dist/parser/parser-substitution.d.ts +62 -0
- package/dist/parser/parser.d.ts +39 -2
- package/dist/parser/types.d.ts +1 -0
- package/dist/types.d.ts +17 -0
- package/package.json +4 -1
- package/dist/bin/chunks/alias-PCMLRCRW.js +0 -7
- package/dist/bin/chunks/awk2-D2US2LMM.js +0 -20
- package/dist/bin/chunks/bash-UT3MT5UU.js +0 -7
- package/dist/bin/chunks/chmod-3DIKREF7.js +0 -9
- package/dist/bin/chunks/chunk-ACRTDIBO.js +0 -6
- package/dist/bin/chunks/chunk-DV5HL4K2.js +0 -17
- package/dist/bin/chunks/chunk-J7BCMQDI.js +0 -16
- package/dist/bin/chunks/chunk-NWWB2XRE.js +0 -6
- package/dist/bin/chunks/chunk-PM2DS2YW.js +0 -3
- package/dist/bin/chunks/env-YLLSNZZN.js +0 -9
- package/dist/bin/chunks/od-SLM7SRWU.js +0 -7
- package/dist/bin/chunks/printf-HWUQKYUM.js +0 -14
- package/dist/bin/chunks/pwd-53KG2MCJ.js +0 -3
- package/dist/bin/chunks/sed-5LQMJYRJ.js +0 -80
- package/dist/bin/chunks/touch-TSNAXMZ2.js +0 -4
- package/dist/bin/chunks/wc-QSBRKIF5.js +0 -6
- package/dist/bin/shell/chunks/alias-PCMLRCRW.js +0 -7
- package/dist/bin/shell/chunks/awk2-D2US2LMM.js +0 -20
- package/dist/bin/shell/chunks/bash-UT3MT5UU.js +0 -7
- package/dist/bin/shell/chunks/chmod-3DIKREF7.js +0 -9
- package/dist/bin/shell/chunks/chunk-ACRTDIBO.js +0 -6
- package/dist/bin/shell/chunks/chunk-DV5HL4K2.js +0 -17
- package/dist/bin/shell/chunks/chunk-J7BCMQDI.js +0 -16
- package/dist/bin/shell/chunks/chunk-NWWB2XRE.js +0 -6
- package/dist/bin/shell/chunks/chunk-PM2DS2YW.js +0 -3
- package/dist/bin/shell/chunks/env-YLLSNZZN.js +0 -9
- package/dist/bin/shell/chunks/od-SLM7SRWU.js +0 -7
- package/dist/bin/shell/chunks/printf-HWUQKYUM.js +0 -14
- package/dist/bin/shell/chunks/pwd-53KG2MCJ.js +0 -3
- package/dist/bin/shell/chunks/sed-5LQMJYRJ.js +0 -80
- package/dist/bin/shell/chunks/touch-TSNAXMZ2.js +0 -4
- package/dist/bin/shell/chunks/wc-QSBRKIF5.js +0 -6
- package/dist/bundle/chunks/alias-4UGRF4DM.js +0 -6
- package/dist/bundle/chunks/awk2-46RTIZKB.js +0 -19
- package/dist/bundle/chunks/bash-ZILV3VHA.js +0 -6
- package/dist/bundle/chunks/chmod-FBHLEIY6.js +0 -8
- package/dist/bundle/chunks/chunk-4JO5BKO4.js +0 -5
- package/dist/bundle/chunks/chunk-BOJ3OAZB.js +0 -16
- package/dist/bundle/chunks/chunk-CG2HXOFG.js +0 -5
- package/dist/bundle/chunks/chunk-NWEGHOXL.js +0 -2
- package/dist/bundle/chunks/chunk-W2EKKAIL.js +0 -15
- package/dist/bundle/chunks/env-EG5SQSAQ.js +0 -8
- package/dist/bundle/chunks/od-ECWXNUB4.js +0 -6
- package/dist/bundle/chunks/printf-VG2POOXB.js +0 -13
- package/dist/bundle/chunks/pwd-AC4P3JKI.js +0 -2
- package/dist/bundle/chunks/sed-ZKODWZ6F.js +0 -79
- package/dist/bundle/chunks/touch-MVQSKQKT.js +0 -3
- package/dist/bundle/chunks/wc-DFQKWSIZ.js +0 -5
- package/dist/interpreter/builtins/variable-helpers.d.ts +0 -30
- /package/dist/bin/chunks/{curl-LCMREE7R.js → curl-TH7YRBSA.js} +0 -0
- /package/dist/bin/chunks/{file-LNCFDPQZ.js → file-6PCTL3MH.js} +0 -0
- /package/dist/bin/shell/chunks/{curl-LCMREE7R.js → curl-TH7YRBSA.js} +0 -0
- /package/dist/bin/shell/chunks/{file-LNCFDPQZ.js → file-6PCTL3MH.js} +0 -0
- /package/dist/bundle/chunks/{curl-TVZH24MD.js → curl-XLP4VABU.js} +0 -0
- /package/dist/bundle/chunks/{file-XPA6O6H2.js → file-NQP3CKRV.js} +0 -0
- /package/dist/commands/curl/{utils.d.ts → response-formatting.d.ts} +0 -0
- /package/dist/commands/xan/{xan-utils.d.ts → column-selection.d.ts} +0 -0
- /package/dist/fs/{utils.d.ts → encoding.d.ts} +0 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
function N(n,t){return n.replace(/\$(&|\d+|<([^>]+)>)/g,(e,i,s)=>{if(i==="&")return t[0];if(s!==void 0)return t.groups?.[s]??"";let h=parseInt(i,10);return t[h]??""})}function K(n,t,e={}){let{invertMatch:i=!1,showLineNumbers:s=!1,countOnly:h=!1,countMatches:d=!1,filename:a="",onlyMatching:m=!1,beforeContext:b=0,afterContext:R=0,maxCount:S=0,contextSeparator:G="--",showColumn:O=!1,vimgrep:T=!1,showByteOffset:P=!1,replace:k=null,passthru:y=!1,multiline:j=!1,kResetGroup:A}=e;if(j)return D(n,t,{invertMatch:i,showLineNumbers:s,countOnly:h,countMatches:d,filename:a,onlyMatching:m,beforeContext:b,afterContext:R,maxCount:S,contextSeparator:G,showColumn:O,showByteOffset:P,replace:k,kResetGroup:A});let x=n.split(`
|
|
3
|
+
`),Z=x.length,v=Z>0&&x[Z-1]===""?Z-1:Z;if(h||d){let f=0,r=(d||m)&&!i;for(let l=0;l<v;l++)if(t.lastIndex=0,r)for(let u=t.exec(x[l]);u!==null;u=t.exec(x[l]))f++,u[0].length===0&&t.lastIndex++;else t.test(x[l])!==i&&f++;return{output:`${a?`${a}:${f}`:String(f)}
|
|
4
|
+
`,matched:f>0,matchCount:f}}if(b===0&&R===0&&!y){let f=[],r=!1,o=0,l=0;for(let u=0;u<v&&!(S>0&&o>=S);u++){let w=x[u];if(t.lastIndex=0,t.test(w)!==i)if(r=!0,o++,m){t.lastIndex=0;for(let $=t.exec(w);$!==null;$=t.exec(w)){let I=A!==void 0?$[A]??"":$[0],U=k!==null?N(k,$):I,z=a?`${a}:`:"";P&&(z+=`${l+$.index}:`),s&&(z+=`${u+1}:`),O&&(z+=`${$.index+1}:`),f.push(z+U),$[0].length===0&&t.lastIndex++}}else if(T){t.lastIndex=0;for(let $=t.exec(w);$!==null;$=t.exec(w)){let I=a?`${a}:`:"";P&&(I+=`${l+$.index}:`),s&&(I+=`${u+1}:`),O&&(I+=`${$.index+1}:`),f.push(I+w),$[0].length===0&&t.lastIndex++}}else{t.lastIndex=0;let $=t.exec(w),I=$?$.index+1:1,U=w;k!==null&&(t.lastIndex=0,U=w.replace(t,(...M)=>{if(M[0].length===0)return"";let E=M,_=M[M.length-1];return typeof _=="object"&&_!==null?(E.groups=_,E.input=M[M.length-2],E.index=M[M.length-3]):(E.input=M[M.length-1],E.index=M[M.length-2]),N(k,E)}));let z=a?`${a}:`:"";P&&(z+=`${l+($?$.index:0)}:`),s&&(z+=`${u+1}:`),O&&(z+=`${I}:`),f.push(z+U)}l+=w.length+1}return{output:f.length>0?`${f.join(`
|
|
5
|
+
`)}
|
|
6
|
+
`:"",matched:r,matchCount:o}}if(y){let f=[],r=!1,o=0;for(let l=0;l<v;l++){let u=x[l];t.lastIndex=0;let F=t.test(u)!==i;F&&(r=!0,o++);let $=F?":":"-",I=a?`${a}${$}`:"";s&&(I+=`${l+1}${$}`),f.push(I+u)}return{output:f.length>0?`${f.join(`
|
|
7
|
+
`)}
|
|
8
|
+
`:"",matched:r,matchCount:o}}let g=[],L=0,p=new Set,C=-1,c=[];for(let f=0;f<v&&!(S>0&&L>=S);f++)t.lastIndex=0,t.test(x[f])!==i&&(c.push(f),L++);for(let f of c){let r=Math.max(0,f-b);C>=0&&r>C+1&&g.push(G);for(let l=r;l<f;l++)if(!p.has(l)){p.add(l),C=l;let u=x[l];s&&(u=`${l+1}-${u}`),a&&(u=`${a}-${u}`),g.push(u)}if(!p.has(f)){p.add(f),C=f;let l=x[f];if(m){t.lastIndex=0;for(let u=t.exec(l);u!==null;u=t.exec(l)){let w=A!==void 0?u[A]??"":u[0],F=k!==null?k:w,$=a?`${a}:`:"";s&&($+=`${f+1}:`),O&&($+=`${u.index+1}:`),g.push($+F),u[0].length===0&&t.lastIndex++}}else{let u=l;s&&(u=`${f+1}:${u}`),a&&(u=`${a}:${u}`),g.push(u)}}let o=Math.min(v-1,f+R);for(let l=f+1;l<=o;l++)if(!p.has(l)){p.add(l),C=l;let u=x[l];s&&(u=`${l+1}-${u}`),a&&(u=`${a}-${u}`),g.push(u)}}return{output:g.length>0?`${g.join(`
|
|
9
|
+
`)}
|
|
10
|
+
`:"",matched:L>0,matchCount:L}}function D(n,t,e){let{invertMatch:i,showLineNumbers:s,countOnly:h,countMatches:d,filename:a,onlyMatching:m,beforeContext:b,afterContext:R,maxCount:S,contextSeparator:G,showColumn:O,showByteOffset:T,replace:P,kResetGroup:k}=e,y=n.split(`
|
|
11
|
+
`),j=y.length,A=j>0&&y[j-1]===""?j-1:j,x=[0];for(let c=0;c<n.length;c++)n[c]===`
|
|
12
|
+
`&&x.push(c+1);let Z=c=>{let f=0;for(let r=0;r<x.length&&!(x[r]>c);r++)f=r;return f},v=c=>{let f=Z(c);return c-x[f]+1},g=[];t.lastIndex=0;for(let c=t.exec(n);c!==null&&!(S>0&&g.length>=S);c=t.exec(n)){let f=Z(c.index),r=Z(c.index+Math.max(0,c[0].length-1)),o=k!==void 0?c[k]??"":c[0];g.push({startLine:f,endLine:r,byteOffset:c.index,column:v(c.index),matchText:o}),c[0].length===0&&t.lastIndex++}if(h||d){let c;if(d)c=i?0:g.length;else{let r=new Set;for(let o of g)for(let l=o.startLine;l<=o.endLine;l++)r.add(l);c=i?A-r.size:r.size}return{output:`${a?`${a}:${c}`:String(c)}
|
|
13
|
+
`,matched:c>0,matchCount:c}}if(i){let c=new Set;for(let r of g)for(let o=r.startLine;o<=r.endLine;o++)c.add(o);let f=[];for(let r=0;r<A;r++)if(!c.has(r)){let o=y[r];s&&(o=`${r+1}:${o}`),a&&(o=`${a}:${o}`),f.push(o)}return{output:f.length>0?`${f.join(`
|
|
14
|
+
`)}
|
|
15
|
+
`:"",matched:f.length>0,matchCount:f.length}}if(g.length===0)return{output:"",matched:!1,matchCount:0};let L=new Set,p=-1,C=[];for(let c of g){let f=Math.max(0,c.startLine-b),r=Math.min(A-1,c.endLine+R);p>=0&&f>p+1&&C.push(G);for(let o=f;o<c.startLine;o++)if(!L.has(o)){L.add(o),p=o;let l=y[o];s&&(l=`${o+1}-${l}`),a&&(l=`${a}-${l}`),C.push(l)}if(m){let o=P!==null?P:c.matchText,l=a?`${a}:`:"";T&&(l+=`${c.byteOffset}:`),s&&(l+=`${c.startLine+1}:`),O&&(l+=`${c.column}:`),C.push(l+o);for(let u=c.startLine;u<=c.endLine;u++)L.add(u),p=u}else for(let o=c.startLine;o<=c.endLine&&o<A;o++)if(!L.has(o)){L.add(o),p=o;let l=y[o];P!==null&&o===c.startLine&&(t.lastIndex=0,l=l.replace(t,P));let u=a?`${a}:`:"";T&&o===c.startLine&&(u+=`${c.byteOffset}:`),s&&(u+=`${o+1}:`),O&&o===c.startLine&&(u+=`${c.column}:`),C.push(u+l)}for(let o=c.endLine+1;o<=r;o++)if(!L.has(o)){L.add(o),p=o;let l=y[o];s&&(l=`${o+1}-${l}`),a&&(l=`${a}-${l}`),C.push(l)}}return{output:C.length>0?`${C.join(`
|
|
16
|
+
`)}
|
|
17
|
+
`:"",matched:!0,matchCount:g.length}}var Q={alpha:"a-zA-Z",digit:"0-9",alnum:"a-zA-Z0-9",lower:"a-z",upper:"A-Z",xdigit:"0-9A-Fa-f",space:" \\t\\n\\r\\f\\v",blank:" \\t",punct:"!-/:-@\\[-`{-~",graph:"!-~",print:" -~",cntrl:"\\x00-\\x1F\\x7F",ascii:"\\x00-\\x7F",word:"a-zA-Z0-9_"};function B(n){let t="",e=0;for(;e<n.length;){if(n.slice(e,e+7)==="[[:<:]]"){t+="(?<![\\w])",e+=7;continue}if(n.slice(e,e+7)==="[[:>:]]"){t+="(?![\\w])",e+=7;continue}if(n[e]==="["){let i="[";for(e++,e<n.length&&(n[e]==="^"||n[e]==="!")&&(i+="^",e++),e<n.length&&n[e]==="]"&&(i+="\\]",e++);e<n.length&&n[e]!=="]";){if(n[e]==="["&&e+1<n.length&&n[e+1]===":"){let s=n.indexOf(":]",e+2);if(s!==-1){let h=n.slice(e+2,s),d=Q[h];if(d){i+=d,e=s+2;continue}}}if(n[e]==="\\"&&e+1<n.length){i+=n[e]+n[e+1],e+=2;continue}i+=n[e],e++}e<n.length&&n[e]==="]"&&(i+="]",e++),t+=i;continue}if(n[e]==="\\"&&e+1<n.length){t+=n[e]+n[e+1],e+=2;continue}t+=n[e],e++}return t}function q(n,t){let e,i;switch(t.mode){case"fixed":e=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");break;case"extended":case"perl":{if(e=B(n),e=e.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),t.mode==="perl"){e=W(e),e=X(e),e=H(e);let d=ee(e);e=d.pattern,i=d.kResetGroup}break}default:e=B(n),e=le(e);break}t.wholeWord&&(e=`(?<![\\w])(?:${e})(?![\\w])`),t.lineRegexp&&(e=`^${e}$`);let s=/\\u\{[0-9A-Fa-f]+\}/.test(e),h="g"+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.multilineDotall?"s":"")+(s?"u":"");return{regex:new RegExp(e,h),kResetGroup:i}}function W(n){let t="",e=0;for(;e<n.length;)if(n[e]==="\\"&&e+1<n.length&&n[e+1]==="Q"){e+=2;let i="";for(;e<n.length;){if(n[e]==="\\"&&e+1<n.length&&n[e+1]==="E"){e+=2;break}i+=n[e],e++}t+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}else t+=n[e],e++;return t}function X(n){return n.replace(/\\x\{([0-9A-Fa-f]+)\}/g,"\\u{$1}")}function H(n){let t="",e=0;for(;e<n.length;){if(n[e]==="("&&e+1<n.length&&n[e+1]==="?"){let i=n.slice(e).match(/^\(\?([imsx]*)(-[imsx]*)?(:|$|\))/);if(i){let s=i[1]||"",h=i[2]||"",d=i[3];if(d===":"){let a=e+i[0].length-1,m=J(n,e);if(m!==-1){let b=n.slice(a+1,m),R=V(b,s,h);t+=`(?:${R})`,e=m+1;continue}}else if(d===")"||d===""){e+=i[0].length;continue}}}t+=n[e],e++}return t}function J(n,t){let e=0,i=t;for(;i<n.length;){if(n[i]==="\\"){i+=2;continue}if(n[i]==="["){for(i++;i<n.length&&n[i]!=="]";)n[i]==="\\"&&i++,i++;i++;continue}if(n[i]==="(")e++;else if(n[i]===")"&&(e--,e===0))return i;i++}return-1}function V(n,t,e){let i=n;return t.includes("i")&&(i=Y(i)),i}function Y(n){let t="",e=0;for(;e<n.length;){let i=n[e];if(i==="\\"){e+1<n.length?(t+=i+n[e+1],e+=2):(t+=i,e++);continue}if(i==="["){t+=i,e++,e<n.length&&n[e]==="^"&&(t+=n[e],e++);let s=[];for(;e<n.length&&n[e]!=="]";)if(n[e]==="\\")s.push(n[e]),e++,e<n.length&&(s.push(n[e]),e++);else if(n[e]==="-"&&s.length>0&&e+1<n.length&&n[e+1]!=="]"){let h=s[s.length-1],d=n[e+1];s.push("-"),s.push(d),/[a-z]/.test(h)&&/[a-z]/.test(d)?(s.push(h.toUpperCase()),s.push("-"),s.push(d.toUpperCase())):/[A-Z]/.test(h)&&/[A-Z]/.test(d)&&(s.push(h.toLowerCase()),s.push("-"),s.push(d.toLowerCase())),e+=2}else{let h=n[e];if(s.push(h),/[a-zA-Z]/.test(h)){let d=h===h.toLowerCase()?h.toUpperCase():h.toLowerCase();s.includes(d)||s.push(d)}e++}t+=s.join(""),e<n.length&&(t+=n[e],e++);continue}if(/[a-zA-Z]/.test(i)){let s=i.toLowerCase(),h=i.toUpperCase();t+=`[${h}${s}]`}else t+=i;e++}return t}function ee(n){let t=ne(n);if(t===-1)return{pattern:n};let e=n.slice(0,t),i=n.slice(t+2),s=te(e);return{pattern:`(?:${e})(${i})`,kResetGroup:s+1}}function ne(n){let t=0;for(;t<n.length-1;)if(n[t]==="\\"){if(n[t+1]==="K"){let e=0,i=t-1;for(;i>=0&&n[i]==="\\";)e++,i--;if(e%2===0)return t}t+=2}else t++;return-1}function te(n){let t=0,e=0;for(;e<n.length;){if(n[e]==="\\"){e+=2;continue}if(n[e]==="["){for(e++;e<n.length&&n[e]!=="]";)n[e]==="\\"&&e++,e++;e++;continue}if(n[e]==="(")if(e+1<n.length&&n[e+1]==="?"){if(e+2<n.length){let i=n[e+2];if(i===":"||i==="="||i==="!"){e++;continue}if(i==="<"&&e+3<n.length){let s=n[e+3];if(s==="="||s==="!"){e++;continue}t++,e++;continue}}}else t++;e++}return t}function ie(n){let t=n.replace(/\$\{0\}|\$0(?![0-9])/g,"$$&");return t=t.replace(/\$\{([^0-9}][^}]*)\}/g,"$$<$1>"),t=t.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)(?![>0-9])/g,"$$<$1>"),t}function le(n){let t="",e=0,i=!0,s=0;for(;e<n.length;){let h=n[e];if(h==="["){for(t+=h,e++,e<n.length&&(n[e]==="^"||n[e]==="!")&&(t+=n[e],e++),e<n.length&&n[e]==="]"&&(t+=n[e],e++);e<n.length&&n[e]!=="]";)n[e]==="\\"&&e+1<n.length?(t+=n[e]+n[e+1],e+=2):(t+=n[e],e++);e<n.length&&n[e]==="]"&&(t+=n[e],e++),i=!1;continue}if(h==="\\"&&e+1<n.length){let d=n[e+1];if(d==="|"){t+="|",e+=2,i=!0;continue}if(d==="("){t+="(",e+=2,s++,i=!0;continue}if(d===")"){t+=")",e+=2,s=Math.max(0,s-1),i=!1;continue}if(d==="{"){let m=n.slice(e).match(/^\\{(\d+)(,(\d*)?)?\\}/);if(m){let b=m[1],R=m[2]!==void 0,S=m[3]||"";R?t+=`{${b},${S}}`:t+=`{${b}}`,e+=m[0].length,i=!1;continue}t+="\\{",e+=2,i=!1;continue}if(d==="}"){t+="\\}",e+=2,i=!1;continue}t+=h+d,e+=2,i=!1;continue}if(h==="*"&&i){t+="\\*",e++;continue}if(h==="^"){if(i){t+="^",e++;continue}t+="\\^",e++;continue}if(h==="$"){let d=e===n.length-1,a=e+2<n.length&&n[e+1]==="\\"&&n[e+2]===")";d||a?t+="$":t+="\\$",e++,i=!1;continue}h==="+"||h==="?"||h==="|"||h==="("||h===")"||h==="{"||h==="}"?t+=`\\${h}`:t+=h,e++,i=!1}return t}export{K as a,q as b,ie as c};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var n=class extends Error{stdout;stderr;constructor(t,s="",e=""){super(t),this.stdout=s,this.stderr=e}prependOutput(t,s){this.stdout=t+this.stdout,this.stderr=s+this.stderr}},c=class extends n{levels;name="BreakError";constructor(t=1,s="",e=""){super("break",s,e),this.levels=t}},a=class extends n{levels;name="ContinueError";constructor(t=1,s="",e=""){super("continue",s,e),this.levels=t}},i=class extends n{exitCode;name="ReturnError";constructor(t=0,s="",e=""){super("return",s,e),this.exitCode=t}},u=class extends n{exitCode;name="ErrexitError";constructor(t,s="",e=""){super(`errexit: command exited with status ${t}`,s,e),this.exitCode=t}},x=class extends n{varName;name="NounsetError";constructor(t,s=""){super(`${t}: unbound variable`,s,`bash: ${t}: unbound variable
|
|
3
|
+
`),this.varName=t}},d=class extends n{exitCode;name="ExitError";constructor(t,s="",e=""){super("exit",s,e),this.exitCode=t}},p=class extends n{name="ArithmeticError";fatal;constructor(t,s="",e="",o=!1){super(t,s,e),this.stderr=e||`bash: ${t}
|
|
4
|
+
`,this.fatal=o}},h=class extends n{name="BadSubstitutionError";constructor(t,s="",e=""){super(t,s,e),this.stderr=e||`bash: ${t}: bad substitution
|
|
5
|
+
`}},l=class extends n{name="GlobError";constructor(t,s="",e=""){super(`no match: ${t}`,s,e),this.stderr=e||`bash: no match: ${t}
|
|
6
|
+
`}},m=class extends n{name="BraceExpansionError";constructor(t,s="",e=""){super(t,s,e),this.stderr=e||`bash: ${t}
|
|
7
|
+
`}},b=class extends n{limitType;name="ExecutionLimitError";static EXIT_CODE=126;constructor(t,s,e="",o=""){super(t,e,o),this.limitType=s,this.stderr=o||`bash: ${t}
|
|
8
|
+
`}},$=class extends n{name="SubshellExitError";constructor(t="",s=""){super("subshell exit",t,s)}};function C(r){return r instanceof c||r instanceof a||r instanceof i}var f=class extends n{exitCode;name="PosixFatalError";constructor(t,s="",e=""){super("posix fatal error",s,e),this.exitCode=t}};export{c as a,a as b,i as c,u as d,x as e,d as f,p as g,h,l as i,m as j,b as k,$ as l,C as m,f as n};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{k as O}from"./chunk-K5IXNHO5.js";function K(t,r,e,n,p,i,u,f,s,c){switch(r){case"sort":return Array.isArray(t)?[[...t].sort(u)]:[null];case"sort_by":return!Array.isArray(t)||e.length===0?[null]:[[...t].sort((h,y)=>{let a=p(h,e[0],n)[0],l=p(y,e[0],n)[0];return u(a,l)})];case"bsearch":{if(!Array.isArray(t)){let h=t===null?"null":typeof t=="object"?"object":typeof t;throw new Error(`${h} (${JSON.stringify(t)}) cannot be searched from`)}return e.length===0?[null]:p(t,e[0],n).map(h=>{let y=0,a=t.length;for(;y<a;){let l=y+a>>>1;u(t[l],h)<0?y=l+1:a=l}return y<t.length&&u(t[y],h)===0?y:-y-1})}case"unique_by":{if(!Array.isArray(t)||e.length===0)return[null];let o=new Map;for(let y of t){let a=p(y,e[0],n)[0],l=JSON.stringify(a);o.has(l)||o.set(l,{item:y,key:a})}let h=[...o.values()];return h.sort((y,a)=>u(y.key,a.key)),[h.map(y=>y.item)]}case"group_by":{if(!Array.isArray(t)||e.length===0)return[null];let o=new Map;for(let h of t){let y=JSON.stringify(p(h,e[0],n)[0]);o.has(y)||o.set(y,[]),o.get(y)?.push(h)}return[[...o.values()]]}case"max":return Array.isArray(t)&&t.length>0?[t.reduce((o,h)=>u(o,h)>0?o:h)]:[null];case"max_by":return!Array.isArray(t)||t.length===0||e.length===0?[null]:[t.reduce((o,h)=>{let y=p(o,e[0],n)[0],a=p(h,e[0],n)[0];return u(y,a)>0?o:h})];case"min":return Array.isArray(t)&&t.length>0?[t.reduce((o,h)=>u(o,h)<0?o:h)]:[null];case"min_by":return!Array.isArray(t)||t.length===0||e.length===0?[null]:[t.reduce((o,h)=>{let y=p(o,e[0],n)[0],a=p(h,e[0],n)[0];return u(y,a)<0?o:h})];case"add":{let o=h=>{let y=h.filter(a=>a!==null);return y.length===0?null:y.every(a=>typeof a=="number")?y.reduce((a,l)=>a+l,0):y.every(a=>typeof a=="string")?y.join(""):y.every(a=>Array.isArray(a))?y.flat():y.every(a=>a&&typeof a=="object"&&!Array.isArray(a))?Object.assign({},...y):null};if(e.length>=1){let h=p(t,e[0],n);return[o(h)]}return Array.isArray(t)?[o(t)]:[null]}case"any":{if(e.length>=2){try{let o=i(t,e[0],n);for(let h of o)if(p(h,e[1],n).some(f))return[!0]}catch(o){if(o instanceof c)throw o}return[!1]}return e.length===1?Array.isArray(t)?[t.some(o=>f(p(o,e[0],n)[0]))]:[!1]:Array.isArray(t)?[t.some(f)]:[!1]}case"all":{if(e.length>=2){try{let o=i(t,e[0],n);for(let h of o)if(!p(h,e[1],n).some(f))return[!1]}catch(o){if(o instanceof c)throw o}return[!0]}return e.length===1?Array.isArray(t)?[t.every(o=>f(p(o,e[0],n)[0]))]:[!0]:Array.isArray(t)?[t.every(f)]:[!0]}case"select":return e.length===0?[t]:p(t,e[0],n).some(f)?[t]:[];case"map":return e.length===0||!Array.isArray(t)?[null]:[t.flatMap(h=>p(h,e[0],n))];case"map_values":{if(e.length===0)return[null];if(Array.isArray(t))return[t.flatMap(o=>p(o,e[0],n))];if(t&&typeof t=="object"){let o={};for(let[h,y]of Object.entries(t)){let a=p(y,e[0],n);a.length>0&&(o[h]=a[0])}return[o]}return[null]}case"has":{if(e.length===0)return[!1];let h=p(t,e[0],n)[0];return Array.isArray(t)&&typeof h=="number"?[h>=0&&h<t.length]:t&&typeof t=="object"&&typeof h=="string"?[h in t]:[!1]}case"in":{if(e.length===0)return[!1];let h=p(t,e[0],n)[0];return Array.isArray(h)&&typeof t=="number"?[t>=0&&t<h.length]:h&&typeof h=="object"&&typeof t=="string"?[t in h]:[!1]}case"contains":{if(e.length===0)return[!1];let o=p(t,e[0],n);return[s(t,o[0])]}case"inside":{if(e.length===0)return[!1];let o=p(t,e[0],n);return[s(o[0],t)]}default:return null}}function V(t,r,e,n,p,i,u,f){switch(r){case"first":if(e.length>0)try{let s=i(t,e[0],n);return s.length>0?[s[0]]:[]}catch(s){if(s instanceof f)throw s;return[]}return Array.isArray(t)&&t.length>0?[t[0]]:[null];case"last":if(e.length>0){let s=p(t,e[0],n);return s.length>0?[s[s.length-1]]:[]}return Array.isArray(t)&&t.length>0?[t[t.length-1]]:[null];case"nth":{if(e.length<1)return[null];let s=p(t,e[0],n);if(e.length>1){for(let o of s)if(o<0)throw new Error("nth doesn't support negative indices");let c;try{c=i(t,e[1],n)}catch(o){if(o instanceof f)throw o;c=[]}return s.flatMap(o=>{let h=o;return h<c.length?[c[h]]:[]})}return Array.isArray(t)?s.flatMap(c=>{let o=c;if(o<0)throw new Error("nth doesn't support negative indices");return o<t.length?[t[o]]:[null]}):[null]}case"range":{if(e.length===0)return[];let s=p(t,e[0],n);if(e.length===1){let y=[];for(let a of s){let l=a;for(let d=0;d<l;d++)y.push(d)}return y}let c=p(t,e[1],n);if(e.length===2){let y=[];for(let a of s)for(let l of c){let d=a,g=l;for(let A=d;A<g;A++)y.push(A)}return y}let o=p(t,e[2],n),h=[];for(let y of s)for(let a of c)for(let l of o){let d=y,g=a,A=l;if(A!==0)if(A>0)for(let b=d;b<g;b+=A)h.push(b);else for(let b=d;b>g;b+=A)h.push(b)}return h}case"limit":return e.length<2?[]:p(t,e[0],n).flatMap(c=>{let o=c;if(o<0)throw new Error("limit doesn't support negative count");if(o===0)return[];let h;try{h=i(t,e[1],n)}catch(y){if(y instanceof f)throw y;h=[]}return h.slice(0,o)});case"isempty":{if(e.length<1)return[!0];try{return[i(t,e[0],n).length===0]}catch(s){if(s instanceof f)throw s;return[!0]}}case"isvalid":{if(e.length<1)return[!0];try{return[p(t,e[0],n).length>0]}catch(s){if(s instanceof f)throw s;return[!1]}}case"skip":return e.length<2?[]:p(t,e[0],n).flatMap(c=>{let o=c;if(o<0)throw new Error("skip doesn't support negative count");return p(t,e[1],n).slice(o)});case"until":{if(e.length<2)return[t];let s=t,c=n.limits.maxIterations;for(let o=0;o<c;o++){if(p(s,e[0],n).some(u))return[s];let y=p(s,e[1],n);if(y.length===0)return[s];s=y[0]}throw new f(`jq until: too many iterations (${c}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(e.length<2)return[t];let s=[],c=t,o=n.limits.maxIterations;for(let h=0;h<o&&p(c,e[0],n).some(u);h++){s.push(c);let a=p(c,e[1],n);if(a.length===0)break;c=a[0]}if(s.length>=o)throw new f(`jq while: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}case"repeat":{if(e.length===0)return[t];let s=[],c=t,o=n.limits.maxIterations;for(let h=0;h<o;h++){s.push(c);let y=p(c,e[0],n);if(y.length===0)break;c=y[0]}if(s.length>=o)throw new f(`jq repeat: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}default:return null}}function J(t,r,e,n,p){switch(r){case"now":return[Date.now()/1e3];case"gmtime":{if(typeof t!="number")return[null];let i=new Date(t*1e3),u=i.getUTCFullYear(),f=i.getUTCMonth(),s=i.getUTCDate(),c=i.getUTCHours(),o=i.getUTCMinutes(),h=i.getUTCSeconds(),y=i.getUTCDay(),a=Date.UTC(u,0,1),l=Math.floor((i.getTime()-a)/(1440*60*1e3));return[[u,f,s,c,o,h,y,l]]}case"mktime":{if(!Array.isArray(t))throw new Error("mktime requires parsed datetime inputs");let[i,u,f,s=0,c=0,o=0]=t;if(typeof i!="number"||typeof u!="number")throw new Error("mktime requires parsed datetime inputs");let h=Date.UTC(i,u,f??1,s??0,c??0,o??0);return[Math.floor(h/1e3)]}case"strftime":{if(e.length===0)return[null];let u=p(t,e[0],n)[0];if(typeof u!="string")throw new Error("strftime/1 requires a string format");let f;if(typeof t=="number")f=new Date(t*1e3);else if(Array.isArray(t)){let[y,a,l,d=0,g=0,A=0]=t;if(typeof y!="number"||typeof a!="number")throw new Error("strftime/1 requires parsed datetime inputs");f=new Date(Date.UTC(y,a,l??1,d??0,g??0,A??0))}else throw new Error("strftime/1 requires parsed datetime inputs");let s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"],o=(y,a=2)=>String(y).padStart(a,"0");return[u.replace(/%Y/g,String(f.getUTCFullYear())).replace(/%m/g,o(f.getUTCMonth()+1)).replace(/%d/g,o(f.getUTCDate())).replace(/%H/g,o(f.getUTCHours())).replace(/%M/g,o(f.getUTCMinutes())).replace(/%S/g,o(f.getUTCSeconds())).replace(/%A/g,s[f.getUTCDay()]).replace(/%B/g,c[f.getUTCMonth()]).replace(/%Z/g,"UTC").replace(/%%/g,"%")]}case"strptime":{if(e.length===0)return[null];if(typeof t!="string")throw new Error("strptime/1 requires a string input");let u=p(t,e[0],n)[0];if(typeof u!="string")throw new Error("strptime/1 requires a string format");if(u==="%Y-%m-%dT%H:%M:%SZ"){let s=t.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(s){let[,c,o,h,y,a,l]=s.map(Number),d=new Date(Date.UTC(c,o-1,h,y,a,l)),g=d.getUTCDay(),A=Date.UTC(c,0,1),b=Math.floor((d.getTime()-A)/(1440*60*1e3));return[[c,o-1,h,y,a,l,g,b]]}}let f=new Date(t);if(!Number.isNaN(f.getTime())){let s=f.getUTCFullYear(),c=f.getUTCMonth(),o=f.getUTCDate(),h=f.getUTCHours(),y=f.getUTCMinutes(),a=f.getUTCSeconds(),l=f.getUTCDay(),d=Date.UTC(s,0,1),g=Math.floor((f.getTime()-d)/(1440*60*1e3));return[[s,c,o,h,y,a,l,g]]}throw new Error(`Cannot parse date: ${t}`)}case"fromdate":{if(typeof t!="string")throw new Error("fromdate requires a string input");let i=new Date(t);if(Number.isNaN(i.getTime()))throw new Error(`date "${t}" does not match format "%Y-%m-%dT%H:%M:%SZ"`);return[Math.floor(i.getTime()/1e3)]}case"todate":{if(typeof t!="number")throw new Error("todate requires a number input");return[new Date(t*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")]}default:return null}}function E(t){return t!==!1&&t!==null}function S(t,r){return JSON.stringify(t)===JSON.stringify(r)}function M(t,r){return typeof t=="number"&&typeof r=="number"?t-r:typeof t=="string"&&typeof r=="string"?t.localeCompare(r):0}function H(t,r){let e={...t};for(let n of Object.keys(r))n in e&&e[n]&&typeof e[n]=="object"&&!Array.isArray(e[n])&&r[n]&&typeof r[n]=="object"&&!Array.isArray(r[n])?e[n]=H(e[n],r[n]):e[n]=r[n];return e}function T(t,r=3e3){let e=0,n=t;for(;e<r;)if(Array.isArray(n)){if(n.length===0)return e+1;n=n[0],e++}else if(n!==null&&typeof n=="object"){let p=Object.keys(n);if(p.length===0)return e+1;n=n[p[0]],e++}else return e;return e}function j(t,r){let e=i=>i===null?0:typeof i=="boolean"?1:typeof i=="number"?2:typeof i=="string"?3:Array.isArray(i)?4:typeof i=="object"?5:6,n=e(t),p=e(r);if(n!==p)return n-p;if(typeof t=="number"&&typeof r=="number")return t-r;if(typeof t=="string"&&typeof r=="string")return t.localeCompare(r);if(typeof t=="boolean"&&typeof r=="boolean")return(t?1:0)-(r?1:0);if(Array.isArray(t)&&Array.isArray(r)){for(let i=0;i<Math.min(t.length,r.length);i++){let u=j(t[i],r[i]);if(u!==0)return u}return t.length-r.length}if(t&&r&&typeof t=="object"&&typeof r=="object"){let i=t,u=r,f=Object.keys(i).sort(),s=Object.keys(u).sort();for(let c=0;c<Math.min(f.length,s.length);c++){let o=f[c].localeCompare(s[c]);if(o!==0)return o}if(f.length!==s.length)return f.length-s.length;for(let c of f){let o=j(i[c],u[c]);if(o!==0)return o}}return 0}function P(t,r){if(S(t,r))return!0;if(typeof t=="string"&&typeof r=="string")return t.includes(r);if(Array.isArray(t)&&Array.isArray(r))return r.every(e=>t.some(n=>P(n,e)));if(t&&r&&typeof t=="object"&&typeof r=="object"&&!Array.isArray(t)&&!Array.isArray(r)){let e=t,n=r;return Object.keys(n).every(p=>p in e&&P(e[p],n[p]))}return!1}var ut=2e3;function Y(t,r,e){switch(r){case"@base64":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"utf-8").toString("base64")]:[btoa(t)]:[null];case"@base64d":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"base64").toString("utf-8")]:[atob(t)]:[null];case"@uri":return typeof t=="string"?[encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")]:[null];case"@urid":return typeof t=="string"?[decodeURIComponent(t)]:[null];case"@csv":return Array.isArray(t)?[t.map(p=>{if(p===null)return"";if(typeof p=="boolean")return p?"true":"false";if(typeof p=="number")return String(p);let i=String(p);return i.includes(",")||i.includes('"')||i.includes(`
|
|
3
|
+
`)||i.includes("\r")?`"${i.replace(/"/g,'""')}"`:i}).join(",")]:[null];case"@tsv":return Array.isArray(t)?[t.map(n=>String(n??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":{let n=e??ut;return T(t,n+1)>n?[null]:[JSON.stringify(t)]}case"@html":return typeof t=="string"?[t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")]:[null];case"@sh":return typeof t=="string"?[`'${t.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof t=="string"?[t]:t==null?[""]:[String(t)];default:return null}}function q(t,r,e,n,p,i){switch(r){case"index":return e.length===0?[null]:p(t,e[0],n).map(f=>{if(typeof t=="string"&&typeof f=="string"){if(f===""&&t==="")return null;let s=t.indexOf(f);return s>=0?s:null}if(Array.isArray(t)){if(Array.isArray(f)){for(let c=0;c<=t.length-f.length;c++){let o=!0;for(let h=0;h<f.length;h++)if(!i(t[c+h],f[h])){o=!1;break}if(o)return c}return null}let s=t.findIndex(c=>i(c,f));return s>=0?s:null}return null});case"rindex":return e.length===0?[null]:p(t,e[0],n).map(f=>{if(typeof t=="string"&&typeof f=="string"){let s=t.lastIndexOf(f);return s>=0?s:null}if(Array.isArray(t)){if(Array.isArray(f)){for(let s=t.length-f.length;s>=0;s--){let c=!0;for(let o=0;o<f.length;o++)if(!i(t[s+o],f[o])){c=!1;break}if(c)return s}return null}for(let s=t.length-1;s>=0;s--)if(i(t[s],f))return s;return null}return null});case"indices":return e.length===0?[[]]:p(t,e[0],n).map(f=>{let s=[];if(typeof t=="string"&&typeof f=="string"){let c=t.indexOf(f);for(;c!==-1;)s.push(c),c=t.indexOf(f,c+1)}else if(Array.isArray(t))if(Array.isArray(f)){let c=f.length;if(c===0)for(let o=0;o<=t.length;o++)s.push(o);else for(let o=0;o<=t.length-c;o++){let h=!0;for(let y=0;y<c;y++)if(!i(t[o+y],f[y])){h=!1;break}h&&s.push(o)}}else for(let c=0;c<t.length;c++)i(t[c],f)&&s.push(c);return s});default:return null}}function G(t,r,e,n,p){switch(r){case"fabs":case"abs":return typeof t=="number"?[Math.abs(t)]:typeof t=="string"?[t]:[null];case"exp10":return typeof t=="number"?[10**t]:[null];case"exp2":return typeof t=="number"?[2**t]:[null];case"pow":{if(e.length<2)return[null];let i=p(t,e[0],n),u=p(t,e[1],n),f=i[0],s=u[0];return typeof f!="number"||typeof s!="number"?[null]:[f**s]}case"atan2":{if(e.length<2)return[null];let i=p(t,e[0],n),u=p(t,e[1],n),f=i[0],s=u[0];return typeof f!="number"||typeof s!="number"?[null]:[Math.atan2(f,s)]}case"hypot":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.hypot(t,i)]}case"fma":{if(typeof t!="number"||e.length<2)return[null];let i=p(t,e[0],n)[0],u=p(t,e[1],n)[0];return[t*i+u]}case"copysign":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.sign(i)*Math.abs(t)]}case"drem":case"remainder":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[t-Math.round(t/i)*i]}case"fdim":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.max(0,t-i)]}case"fmax":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.max(t,i)]}case"fmin":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[Math.min(t,i)]}case"ldexp":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[t*2**i]}case"scalbn":case"scalbln":{if(typeof t!="number"||e.length===0)return[null];let i=p(t,e[0],n)[0];return[t*2**i]}case"nearbyint":return typeof t=="number"?[Math.round(t)]:[null];case"logb":return typeof t=="number"?[Math.floor(Math.log2(Math.abs(t)))]:[null];case"significand":if(typeof t=="number"){let i=Math.floor(Math.log2(Math.abs(t)));return[t/2**i]}return[null];case"frexp":if(typeof t=="number"){if(t===0)return[[0,0]];let i=Math.floor(Math.log2(Math.abs(t)))+1;return[[t/2**i,i]]}return[null];case"modf":if(typeof t=="number"){let i=Math.trunc(t);return[[t-i,i]]}return[null];default:return null}}function X(t,r,e,n,p,i,u,f){switch(r){case"recurse":{if(e.length===0){let a=[],l=d=>{if(a.push(d),Array.isArray(d))for(let g of d)l(g);else if(d&&typeof d=="object")for(let g of Object.keys(d))l(d[g])};return l(t),a}let s=[],c=e.length>=2?e[1]:null,o=1e4,h=0,y=a=>{if(h++>o||c&&!p(a,c,n).some(i))return;s.push(a);let l=p(a,e[0],n);for(let d of l)d!=null&&y(d)};return y(t),s}case"recurse_down":return f(t,"recurse",e,n);case"walk":{if(e.length===0)return[t];let s=new WeakSet,c=o=>{if(o&&typeof o=="object"){if(s.has(o))return o;s.add(o)}let h;if(Array.isArray(o))h=o.map(c);else if(o&&typeof o=="object"){let a={};for(let[l,d]of Object.entries(o))a[l]=c(d);h=a}else h=o;return p(h,e[0],n)[0]};return[c(t)]}case"transpose":{if(!Array.isArray(t))return[null];if(t.length===0)return[[]];let s=Math.max(...t.map(o=>Array.isArray(o)?o.length:0)),c=[];for(let o=0;o<s;o++)c.push(t.map(h=>Array.isArray(h)?h[o]:null));return[c]}case"combinations":{if(e.length>0){let h=p(t,e[0],n)[0];if(!Array.isArray(t)||h<0)return[];if(h===0)return[[]];let y=[],a=(l,d)=>{if(d===h){y.push([...l]);return}for(let g of t)l.push(g),a(l,d+1),l.pop()};return a([],0),y}if(!Array.isArray(t))return[];if(t.length===0)return[[]];for(let o of t)if(!Array.isArray(o))return[];let s=[],c=(o,h)=>{if(o===t.length){s.push([...h]);return}let y=t[o];for(let a of y)h.push(a),c(o+1,h),h.pop()};return c(0,[]),s}case"parent":{if(n.root===void 0||n.currentPath===void 0)return[];let s=n.currentPath;if(s.length===0)return[];let c=e.length>0?p(t,e[0],n)[0]:1;if(c>=0){if(c>s.length)return[];let o=s.slice(0,s.length-c);return[u(n.root,o)]}else{let o=-c-1;if(o>=s.length)return[t];let h=s.slice(0,o);return[u(n.root,h)]}}case"parents":{if(n.root===void 0||n.currentPath===void 0)return[[]];let s=n.currentPath,c=[];for(let o=s.length-1;o>=0;o--)c.push(u(n.root,s.slice(0,o)));return[c]}case"root":return n.root!==void 0?[n.root]:[];default:return null}}var ht=2e3;function W(t,r,e,n,p){switch(r){case"keys":return Array.isArray(t)?[t.map((i,u)=>u)]:t&&typeof t=="object"?[Object.keys(t).sort()]:[null];case"keys_unsorted":return Array.isArray(t)?[t.map((i,u)=>u)]:t&&typeof t=="object"?[Object.keys(t)]:[null];case"length":return typeof t=="string"?[t.length]:Array.isArray(t)?[t.length]:t&&typeof t=="object"?[Object.keys(t).length]:t===null?[0]:typeof t=="number"?[Math.abs(t)]:[null];case"utf8bytelength":{if(typeof t=="string")return[new TextEncoder().encode(t).length];let i=t===null?"null":Array.isArray(t)?"array":typeof t,u=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${u}) only strings have UTF-8 byte length`)}case"to_entries":return t&&typeof t=="object"&&!Array.isArray(t)?[Object.entries(t).map(([i,u])=>({key:i,value:u}))]:[null];case"from_entries":if(Array.isArray(t)){let i={};for(let u of t)if(u&&typeof u=="object"){let f=u,s=f.key??f.Key??f.name??f.Name??f.k,c=f.value??f.Value??f.v;s!==void 0&&(i[String(s)]=c)}return[i]}return[null];case"with_entries":{if(e.length===0)return[t];if(t&&typeof t=="object"&&!Array.isArray(t)){let u=Object.entries(t).map(([s,c])=>({key:s,value:c})).flatMap(s=>p(s,e[0],n)),f={};for(let s of u)if(s&&typeof s=="object"){let c=s,o=c.key??c.name??c.k,h=c.value??c.v;o!==void 0&&(f[String(o)]=h)}return[f]}return[null]}case"reverse":return Array.isArray(t)?[[...t].reverse()]:typeof t=="string"?[t.split("").reverse().join("")]:[null];case"flatten":return Array.isArray(t)?(e.length>0?p(t,e[0],n):[Number.POSITIVE_INFINITY]).map(u=>{let f=u;if(f<0)throw new Error("flatten depth must not be negative");return t.flat(f)}):[null];case"unique":if(Array.isArray(t)){let i=new Set,u=[];for(let f of t){let s=JSON.stringify(f);i.has(s)||(i.add(s),u.push(f))}return[u]}return[null];case"tojson":case"tojsonstream":{let i=n.limits.maxDepth??ht;return T(t,i+1)>i?[null]:[JSON.stringify(t)]}case"fromjson":{if(typeof t=="string"){let i=t.trim().toLowerCase();if(i==="nan")return[Number.NaN];if(i==="inf"||i==="infinity")return[Number.POSITIVE_INFINITY];if(i==="-inf"||i==="-infinity")return[Number.NEGATIVE_INFINITY];try{return[JSON.parse(t)]}catch{throw new Error(`Invalid JSON: ${t}`)}}return[t]}case"tostring":return typeof t=="string"?[t]:[JSON.stringify(t)];case"tonumber":if(typeof t=="number")return[t];if(typeof t=="string"){let i=Number(t);if(Number.isNaN(i))throw new Error(`${JSON.stringify(t)} cannot be parsed as a number`);return[i]}throw new Error(`${typeof t} cannot be parsed as a number`);case"toboolean":{if(typeof t=="boolean")return[t];if(typeof t=="string"){if(t==="true")return[!0];if(t==="false")return[!1];throw new Error(`string (${JSON.stringify(t)}) cannot be parsed as a boolean`)}let i=t===null?"null":Array.isArray(t)?"array":typeof t,u=i==="array"||i==="object"?JSON.stringify(t):String(t);throw new Error(`${i} (${u}) cannot be parsed as a boolean`)}case"tostream":{let i=[],u=(f,s)=>{if(f===null||typeof f!="object")i.push([s,f]);else if(Array.isArray(f))if(f.length===0)i.push([s,[]]);else for(let c=0;c<f.length;c++)u(f[c],[...s,c]);else{let c=Object.keys(f);if(c.length===0)i.push([s,{}]);else for(let o of c)u(f[o],[...s,o])}};return u(t,[]),i.push([[]]),i}case"fromstream":{if(e.length===0)return[t];let i=p(t,e[0],n),u=null;for(let f of i){if(!Array.isArray(f)||f.length===1&&Array.isArray(f[0])&&f[0].length===0||f.length!==2)continue;let[s,c]=f;if(!Array.isArray(s))continue;if(s.length===0){u=c;continue}u===null&&(u=typeof s[0]=="number"?[]:{});let o=u;for(let y=0;y<s.length-1;y++){let a=s[y],l=s[y+1];if(Array.isArray(o)&&typeof a=="number"){for(;o.length<=a;)o.push(null);o[a]===null&&(o[a]=typeof l=="number"?[]:{}),o=o[a]}else if(o&&typeof o=="object"&&!Array.isArray(o)){let d=o;(d[String(a)]===null||d[String(a)]===void 0)&&(d[String(a)]=typeof l=="number"?[]:{}),o=d[String(a)]}}let h=s[s.length-1];if(Array.isArray(o)&&typeof h=="number"){for(;o.length<=h;)o.push(null);o[h]=c}else o&&typeof o=="object"&&!Array.isArray(o)&&(o[String(h)]=c)}return[u]}case"truncate_stream":{let i=typeof t=="number"?Math.floor(t):0;if(e.length===0)return[];let u=[],f=p(t,e[0],n);for(let s of f)if(Array.isArray(s)){if(s.length===1&&Array.isArray(s[0])){let c=s[0];c.length>i&&u.push([c.slice(i)]);continue}if(s.length===2&&Array.isArray(s[0])){let c=s[0],o=s[1];c.length>i&&u.push([c.slice(i),o])}}return u}default:return null}}function Q(t,r,e,n,p,i,u,f,s,c){switch(r){case"getpath":{if(e.length===0)return[null];let o=p(t,e[0],n),h=[];for(let y of o){let a=y,l=t;for(let d of a){if(l==null){l=null;break}if(Array.isArray(l)&&typeof d=="number")l=l[d];else if(typeof l=="object"&&typeof d=="string")l=l[d];else{l=null;break}}h.push(l)}return h}case"setpath":{if(e.length<2)return[null];let h=p(t,e[0],n)[0],a=p(t,e[1],n)[0];return[u(t,h,a)]}case"delpaths":{if(e.length===0)return[t];let h=p(t,e[0],n)[0],y=t;for(let a of h.sort((l,d)=>d.length-l.length))y=f(y,a);return[y]}case"path":{if(e.length===0)return[[]];let o=[];return c(t,e[0],n,[],o),o}case"del":return e.length===0?[t]:[s(t,e[0],n)];case"pick":{if(e.length===0)return[null];let o=[];for(let y of e)c(t,y,n,[],o);let h=null;for(let y of o){for(let l of y)if(typeof l=="number"&&l<0)throw new Error("Out of bounds negative array index");let a=t;for(let l of y){if(a==null)break;if(Array.isArray(a)&&typeof l=="number")a=a[l];else if(typeof a=="object"&&typeof l=="string")a=a[l];else{a=null;break}}h=u(h,y,a)}return[h]}case"paths":{let o=[],h=(y,a)=>{if(y&&typeof y=="object")if(Array.isArray(y))for(let l=0;l<y.length;l++)o.push([...a,l]),h(y[l],[...a,l]);else for(let l of Object.keys(y))o.push([...a,l]),h(y[l],[...a,l])};return h(t,[]),e.length>0?o.filter(y=>{let a=t;for(let d of y)if(Array.isArray(a)&&typeof d=="number")a=a[d];else if(a&&typeof a=="object"&&typeof d=="string")a=a[d];else return!1;return p(a,e[0],n).some(i)}):o}case"leaf_paths":{let o=[],h=(y,a)=>{if(y===null||typeof y!="object")o.push(a);else if(Array.isArray(y))for(let l=0;l<y.length;l++)h(y[l],[...a,l]);else for(let l of Object.keys(y))h(y[l],[...a,l])};return h(t,[]),o}default:return null}}function Z(t,r,e,n,p,i){switch(r){case"IN":{if(e.length===0)return[!1];if(e.length===1){let c=p(t,e[0],n);for(let o of c)if(i(t,o))return[!0];return[!1]}let u=p(t,e[0],n),f=p(t,e[1],n),s=new Set(f.map(c=>JSON.stringify(c)));for(let c of u)if(s.has(JSON.stringify(c)))return[!0];return[!1]}case"INDEX":{if(e.length===0)return[{}];if(e.length===1){let s=p(t,e[0],n),c={};for(let o of s){let h=String(o);c[h]=o}return[c]}if(e.length===2){let s=p(t,e[0],n),c={};for(let o of s){let h=p(o,e[1],n);if(h.length>0){let y=String(h[0]);c[y]=o}}return[c]}let u=p(t,e[0],n),f={};for(let s of u){let c=p(s,e[1],n),o=p(s,e[2],n);if(c.length>0&&o.length>0){let h=String(c[0]);f[h]=o[0]}}return[f]}case"JOIN":{if(e.length<2)return[null];let u=p(t,e[0],n)[0];if(!u||typeof u!="object"||Array.isArray(u))return[null];let f=u;if(!Array.isArray(t))return[null];let s=[];for(let c of t){let o=p(c,e[1],n),h=o.length>0?String(o[0]):"",y=h in f?f[h]:null;s.push([c,y])}return[s]}default:return null}}function z(t,r,e,n,p){switch(r){case"join":{if(!Array.isArray(t))return[null];let i=e.length>0?p(t,e[0],n):[""];for(let u of t)if(Array.isArray(u)||u!==null&&typeof u=="object")throw new Error("cannot join: contains arrays or objects");return i.map(u=>t.map(f=>f===null?"":typeof f=="string"?f:String(f)).join(String(u)))}case"split":{if(typeof t!="string"||e.length===0)return[null];let i=p(t,e[0],n),u=String(i[0]);return[t.split(u)]}case"splits":{if(typeof t!="string"||e.length===0)return[];let i=p(t,e[0],n),u=String(i[0]);try{let f=e.length>1?String(p(t,e[1],n)[0]):"g",s=new RegExp(u,f.includes("g")?f:`${f}g`);return t.split(s)}catch{return[]}}case"scan":{if(typeof t!="string"||e.length===0)return[];let i=p(t,e[0],n),u=String(i[0]);try{let f=e.length>1?String(p(t,e[1],n)[0]):"",s=new RegExp(u,f.includes("g")?f:`${f}g`);return[...t.matchAll(s)].map(o=>o.length>1?o.slice(1):o[0])}catch{return[]}}case"test":{if(typeof t!="string"||e.length===0)return[!1];let i=p(t,e[0],n),u=String(i[0]);try{let f=e.length>1?String(p(t,e[1],n)[0]):"";return[new RegExp(u,f).test(t)]}catch{return[!1]}}case"match":{if(typeof t!="string"||e.length===0)return[null];let i=p(t,e[0],n),u=String(i[0]);try{let f=e.length>1?String(p(t,e[1],n)[0]):"",c=new RegExp(u,`${f}d`).exec(t);if(!c)return[];let o=c.indices;return[{offset:c.index,length:c[0].length,string:c[0],captures:c.slice(1).map((h,y)=>({offset:o?.[y+1]?.[0]??null,length:h?.length??0,string:h??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof t!="string"||e.length===0)return[null];let i=p(t,e[0],n),u=String(i[0]);try{let f=e.length>1?String(p(t,e[1],n)[0]):"",s=new RegExp(u,f),c=t.match(s);return!c||!c.groups?[{}]:[c.groups]}catch{return[null]}}case"sub":{if(typeof t!="string"||e.length<2)return[null];let i=p(t,e[0],n),u=p(t,e[1],n),f=String(i[0]),s=String(u[0]);try{let c=e.length>2?String(p(t,e[2],n)[0]):"";return[t.replace(new RegExp(f,c),s)]}catch{return[t]}}case"gsub":{if(typeof t!="string"||e.length<2)return[null];let i=p(t,e[0],n),u=p(t,e[1],n),f=String(i[0]),s=String(u[0]);try{let c=e.length>2?String(p(t,e[2],n)[0]):"g",o=c.includes("g")?c:`${c}g`;return[t.replace(new RegExp(f,o),s)]}catch{return[t]}}case"ascii_downcase":return typeof t=="string"?[t.replace(/[A-Z]/g,i=>String.fromCharCode(i.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof t=="string"?[t.replace(/[a-z]/g,i=>String.fromCharCode(i.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof t!="string"||e.length===0)return[t];let i=p(t,e[0],n),u=String(i[0]);return[t.startsWith(u)?t.slice(u.length):t]}case"rtrimstr":{if(typeof t!="string"||e.length===0)return[t];let i=p(t,e[0],n),u=String(i[0]);return u===""?[t]:[t.endsWith(u)?t.slice(0,-u.length):t]}case"trimstr":{if(typeof t!="string"||e.length===0)return[t];let i=p(t,e[0],n),u=String(i[0]);if(u==="")return[t];let f=t;return f.startsWith(u)&&(f=f.slice(u.length)),f.endsWith(u)&&(f=f.slice(0,-u.length)),[f]}case"trim":if(typeof t=="string")return[t.trim()];throw new Error("trim input must be a string");case"ltrim":if(typeof t=="string")return[t.trimStart()];throw new Error("trim input must be a string");case"rtrim":if(typeof t=="string")return[t.trimEnd()];throw new Error("trim input must be a string");case"startswith":{if(typeof t!="string"||e.length===0)return[!1];let i=p(t,e[0],n);return[t.startsWith(String(i[0]))]}case"endswith":{if(typeof t!="string"||e.length===0)return[!1];let i=p(t,e[0],n);return[t.endsWith(String(i[0]))]}case"ascii":return typeof t=="string"&&t.length>0?[t.charCodeAt(0)]:[null];case"explode":return typeof t=="string"?[Array.from(t).map(i=>i.codePointAt(0))]:[null];case"implode":if(!Array.isArray(t))throw new Error("implode input must be an array");return[t.map(f=>{if(typeof f=="string")throw new Error(`string (${JSON.stringify(f)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof f!="number"||Number.isNaN(f))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let s=Math.trunc(f);return s<0||s>1114111||s>=55296&&s<=57343?String.fromCodePoint(65533):String.fromCodePoint(s)}).join("")];default:return null}}function v(t,r){switch(r){case"type":return t===null?["null"]:Array.isArray(t)?["array"]:typeof t=="boolean"?["boolean"]:typeof t=="number"?["number"]:typeof t=="string"?["string"]:typeof t=="object"?["object"]:["null"];case"infinite":return[Number.POSITIVE_INFINITY];case"nan":return[Number.NaN];case"isinfinite":return[typeof t=="number"&&!Number.isFinite(t)];case"isnan":return[typeof t=="number"&&Number.isNaN(t)];case"isnormal":return[typeof t=="number"&&Number.isFinite(t)&&t!==0];case"isfinite":return[typeof t=="number"&&Number.isFinite(t)];case"numbers":return typeof t=="number"?[t]:[];case"strings":return typeof t=="string"?[t]:[];case"booleans":return typeof t=="boolean"?[t]:[];case"nulls":return t===null?[t]:[];case"arrays":return Array.isArray(t)?[t]:[];case"objects":return t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"iterables":return Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"scalars":return!Array.isArray(t)&&!(t&&typeof t=="object")?[t]:[];case"values":return t===null?[]:[t];case"not":return t===!1||t===null?[!0]:[!1];case"null":return[null];case"true":return[!0];case"false":return[!1];case"empty":return[];default:return null}}function D(t,r,e){if(r.length===0)return e;let[n,...p]=r;if(typeof n=="number"){if(t&&typeof t=="object"&&!Array.isArray(t))throw new Error("Cannot index object with number");if(n>536870911)throw new Error("Array index too large");if(n<0)throw new Error("Out of bounds negative array index");let f=Array.isArray(t)?[...t]:[];for(;f.length<=n;)f.push(null);return f[n]=D(f[n],p,e),f}if(Array.isArray(t))throw new Error("Cannot index array with string");let i=t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{};return i[n]=D(i[n],p,e),i}function B(t,r){if(r.length===0)return null;if(r.length===1){let p=r[0];if(Array.isArray(t)&&typeof p=="number"){let i=[...t];return i.splice(p,1),i}if(t&&typeof t=="object"&&!Array.isArray(t)){let i={...t};return delete i[String(p)],i}return t}let[e,...n]=r;if(Array.isArray(t)&&typeof e=="number"){let p=[...t];return p[e]=B(p[e],n),p}if(t&&typeof t=="object"&&!Array.isArray(t)){let p={...t};return p[String(e)]=B(p[String(e)],n),p}return t}var R=class t extends Error{label;partialResults;constructor(r,e=[]){super(`break ${r}`),this.label=r,this.partialResults=e,this.name="BreakError"}withPrependedResults(r){return new t(this.label,[...r,...this.partialResults])}},L=class extends Error{value;constructor(r){super(typeof r=="string"?r:JSON.stringify(r)),this.value=r,this.name="JqError"}},yt=1e4,it=2e3,at={floor:Math.floor,ceil:Math.ceil,round:Math.round,sqrt:Math.sqrt,log:Math.log,log10:Math.log10,log2:Math.log2,exp:Math.exp,sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,sinh:Math.sinh,cosh:Math.cosh,tanh:Math.tanh,asinh:Math.asinh,acosh:Math.acosh,atanh:Math.atanh,cbrt:Math.cbrt,expm1:Math.expm1,log1p:Math.log1p,trunc:Math.trunc};function lt(t){return{vars:new Map,limits:{maxIterations:t?.limits?.maxIterations??yt,maxDepth:t?.limits?.maxDepth??it},env:t?.env}}function _(t,r,e){let n=new Map(t.vars);return n.set(r,e),{vars:n,limits:t.limits,env:t.env,root:t.root,currentPath:t.currentPath,funcs:t.funcs,labels:t.labels}}function I(t,r,e){switch(r.type){case"var":return _(t,r.name,e);case"array":{if(!Array.isArray(e))return null;let n=t;for(let p=0;p<r.elements.length;p++){let i=r.elements[p],u=p<e.length?e[p]:null,f=I(n,i,u);if(f===null)return null;n=f}return n}case"object":{if(e===null||typeof e!="object"||Array.isArray(e))return null;let n=e,p=t;for(let i of r.fields){let u;if(typeof i.key=="string")u=i.key;else{let c=m(e,i.key,t);if(c.length===0)return null;u=String(c[0])}let f=u in n?n[u]:null;i.keyVar&&(p=_(p,i.keyVar,f));let s=I(p,i.pattern,f);if(s===null)return null;p=s}return p}}}function mt(t,r){let e=t;for(let n of r)if(e&&typeof e=="object")e=e[n];else return;return e}function w(t){if(t.type==="Identity")return[];if(t.type==="Field"){let r=t.base?w(t.base):[];return r===null?null:[...r,t.name]}if(t.type==="Index"&&t.index.type==="Literal"){let r=t.base?w(t.base):[];if(r===null)return null;let e=t.index.value;return typeof e=="number"||typeof e=="string"?[...r,e]:null}if(t.type==="Pipe"){let r=w(t.left);return r===null?null:tt(r,t.right)}if(t.type==="Call"){if(t.name==="parent"||t.name==="root")return null;if(t.name==="first"&&t.args.length===0)return[0];if(t.name==="last"&&t.args.length===0)return[-1]}return null}function tt(t,r){if(r.type==="Call"){if(r.name==="parent"){let e=1;if(r.args.length>0&&r.args[0].type==="Literal"){let n=r.args[0].value;typeof n=="number"&&(e=n)}if(e>=0)return t.slice(0,Math.max(0,t.length-e));{let n=-e-1;return t.slice(0,Math.min(n,t.length))}}if(r.name==="root")return[]}if(r.type==="Field"){let e=w(r);if(e!==null)return[...t,...e]}if(r.type==="Index"&&r.index.type==="Literal"){let e=w(r);if(e!==null)return[...t,...e]}if(r.type==="Pipe"){let e=tt(t,r.left);return e===null?null:tt(e,r.right)}return r.type==="Identity"?t:null}function nt(t,r,e){if(r.type==="Comma"){let n=[];try{n.push(...m(t,r.left,e))}catch(p){if(p instanceof O)throw p;if(n.length>0)return n;throw new Error("evaluation failed")}try{n.push(...m(t,r.right,e))}catch(p){if(p instanceof O)throw p;return n}return n}return m(t,r,e)}function m(t,r,e){let n=e&&"vars"in e?e:lt(e);switch(n.root===void 0&&(n={...n,root:t,currentPath:[]}),r.type){case"Identity":return[t];case"Field":return(r.base?m(t,r.base,n):[t]).flatMap(i=>{if(i&&typeof i=="object"&&!Array.isArray(i)){let f=i[r.name];return[f===void 0?null:f]}if(i===null)return[null];let u=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${u} with string "${r.name}"`)});case"Index":return(r.base?m(t,r.base,n):[t]).flatMap(i=>m(i,r.index,n).flatMap(f=>{if(typeof f=="number"&&Array.isArray(i)){if(Number.isNaN(f))return[null];let s=Math.trunc(f),c=s<0?i.length+s:s;return c>=0&&c<i.length?[i[c]]:[null]}return typeof f=="string"&&i&&typeof i=="object"&&!Array.isArray(i)?[i[f]]:[null]}));case"Slice":return(r.base?m(t,r.base,n):[t]).flatMap(i=>{if(i===null)return[null];if(!Array.isArray(i)&&typeof i!="string")throw new Error(`Cannot slice ${typeof i} (${JSON.stringify(i)})`);let u=i.length,f=r.start?m(t,r.start,n):[0],s=r.end?m(t,r.end,n):[u];return f.flatMap(c=>s.map(o=>{let h=c,y=o,a=Number.isNaN(h)?0:Number.isInteger(h)?h:Math.floor(h),l=Number.isNaN(y)?u:Number.isInteger(y)?y:Math.ceil(y),d=st(a,u),g=st(l,u);return Array.isArray(i),i.slice(d,g)}))});case"Iterate":return(r.base?m(t,r.base,n):[t]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let p=m(t,r.left,n),i=w(r.left),u=[];for(let f of p)try{if(i!==null){let s={...n,currentPath:[...n.currentPath??[],...i]};u.push(...m(f,r.right,s))}else u.push(...m(f,r.right,n))}catch(s){throw s instanceof R?s.withPrependedResults(u):s}return u}case"Comma":{let p=m(t,r.left,n),i=m(t,r.right,n);return[...p,...i]}case"Literal":return[r.value];case"Array":return r.elements?[m(t,r.elements,n)]:[[]];case"Object":{let p=[{}];for(let i of r.entries){let u=typeof i.key=="string"?[i.key]:m(t,i.key,n),f=m(t,i.value,n),s=[];for(let c of p)for(let o of u){if(typeof o!="string"){let h=o===null?"null":Array.isArray(o)?"array":typeof o;throw new Error(`Cannot use ${h} (${JSON.stringify(o)}) as object key`)}for(let h of f)s.push({...c,[o]:h})}p.length=0,p.push(...s)}return p}case"Paren":return m(t,r.expr,n);case"BinaryOp":return gt(t,r.op,r.left,r.right,n);case"UnaryOp":return m(t,r.operand,n).map(i=>{if(r.op==="-"){if(typeof i=="number")return-i;if(typeof i=="string"){let u=f=>f.length>5?`"${f.slice(0,3)}...`:JSON.stringify(f);throw new Error(`string (${u(i)}) cannot be negated`)}return null}return r.op==="not"?!E(i):null});case"Cond":return m(t,r.cond,n).flatMap(i=>{if(E(i))return m(t,r.then,n);for(let u of r.elifs)if(m(t,u.cond,n).some(E))return m(t,u.then,n);return r.else?m(t,r.else,n):[t]});case"Try":try{return m(t,r.body,n)}catch(p){if(r.catch){let i=p instanceof L?p.value:p instanceof Error?p.message:String(p);return m(i,r.catch,n)}return[]}case"Call":return ot(t,r.name,r.args,n);case"VarBind":return m(t,r.value,n).flatMap(i=>{let u=null,f=[];r.pattern?f.push(r.pattern):r.name&&f.push({type:"var",name:r.name}),r.alternatives&&f.push(...r.alternatives);for(let s of f)if(u=I(n,s,i),u!==null)break;return u===null?[]:m(t,r.body,u)});case"VarRef":{if(r.name==="$ENV")return[n.env??{}];let p=n.vars.get(r.name);return p!==void 0?[p]:[null]}case"Recurse":{let p=[],i=new WeakSet,u=f=>{if(f&&typeof f=="object"){if(i.has(f))return;i.add(f)}if(p.push(f),Array.isArray(f))for(let s of f)u(s);else if(f&&typeof f=="object")for(let s of Object.keys(f))u(f[s])};return u(t),p}case"Optional":try{return m(t,r.expr,n)}catch{return[]}case"StringInterp":return[r.parts.map(i=>typeof i=="string"?i:m(t,i,n).map(f=>typeof f=="string"?f:JSON.stringify(f)).join("")).join("")];case"UpdateOp":return[dt(t,r.path,r.op,r.value,n)];case"Reduce":{let p=m(t,r.expr,n),i=m(t,r.init,n)[0],u=n.limits.maxDepth??it;for(let f of p){let s;if(r.pattern){if(s=I(n,r.pattern,f),s===null)continue}else s=_(n,r.varName,f);if(i=m(i,r.update,s)[0],T(i,u+1)>u)return[null]}return[i]}case"Foreach":{let p=m(t,r.expr,n),i=m(t,r.init,n)[0],u=[];for(let f of p)try{let s;if(r.pattern){if(s=I(n,r.pattern,f),s===null)continue}else s=_(n,r.varName,f);if(i=m(i,r.update,s)[0],r.extract){let c=m(i,r.extract,s);u.push(...c)}else u.push(i)}catch(s){throw s instanceof R?s.withPrependedResults(u):s}return u}case"Label":try{return m(t,r.body,{...n,labels:new Set([...n.labels??[],r.name])})}catch(p){if(p instanceof R&&p.label===r.name)return p.partialResults;throw p}case"Break":throw new R(r.name);case"Def":{let p=new Map(n.funcs??[]),i=`${r.name}/${r.params.length}`;p.set(i,{params:r.params,body:r.funcBody,closure:new Map(n.funcs??[])});let u={...n,funcs:p};return m(t,r.body,u)}default:{let p=r;throw new Error(`Unknown AST node type: ${p.type}`)}}}function st(t,r){return t<0?Math.max(0,r+t):Math.min(t,r)}function dt(t,r,e,n,p){function i(s,c){switch(e){case"=":return c;case"|=":return m(s,n,p)[0]??null;case"+=":return typeof s=="number"&&typeof c=="number"||typeof s=="string"&&typeof c=="string"?s+c:Array.isArray(s)&&Array.isArray(c)?[...s,...c]:s&&c&&typeof s=="object"&&typeof c=="object"?{...s,...c}:c;case"-=":return typeof s=="number"&&typeof c=="number"?s-c:s;case"*=":return typeof s=="number"&&typeof c=="number"?s*c:s;case"/=":return typeof s=="number"&&typeof c=="number"?s/c:s;case"%=":return typeof s=="number"&&typeof c=="number"?s%c:s;case"//=":return s===null||s===!1?c:s;default:return c}}function u(s,c,o){switch(c.type){case"Identity":return o(s);case"Field":{if(c.base)return u(s,c.base,h=>{if(h&&typeof h=="object"&&!Array.isArray(h)){let y={...h};return y[c.name]=o(y[c.name]),y}return h});if(s&&typeof s=="object"&&!Array.isArray(s)){let h={...s};return h[c.name]=o(h[c.name]),h}return s}case"Index":{let y=m(t,c.index,p)[0];if(typeof y=="number"&&Number.isNaN(y))throw new Error("Cannot set array element at NaN index");if(typeof y=="number"&&!Number.isInteger(y)&&(y=Math.trunc(y)),c.base)return u(s,c.base,a=>{if(typeof y=="number"&&Array.isArray(a)){let l=[...a],d=y<0?l.length+y:y;if(d>=0){for(;l.length<=d;)l.push(null);l[d]=o(l[d])}return l}if(typeof y=="string"&&a&&typeof a=="object"&&!Array.isArray(a)){let l={...a};return l[y]=o(l[y]),l}return a});if(typeof y=="number"){if(y>536870911)throw new Error("Array index too large");if(y<0&&(!s||!Array.isArray(s)))throw new Error("Out of bounds negative array index");if(Array.isArray(s)){let l=[...s],d=y<0?l.length+y:y;if(d>=0){for(;l.length<=d;)l.push(null);l[d]=o(l[d])}return l}if(s==null){let l=[];for(;l.length<=y;)l.push(null);return l[y]=o(null),l}return s}if(typeof y=="string"&&s&&typeof s=="object"&&!Array.isArray(s)){let a={...s};return a[y]=o(a[y]),a}return s}case"Iterate":{let h=y=>{if(Array.isArray(y))return y.map(a=>o(a));if(y&&typeof y=="object"){let a={};for(let[l,d]of Object.entries(y))a[l]=o(d);return a}return y};return c.base?u(s,c.base,h):h(s)}case"Pipe":{let h=u(s,c.left,y=>y);return u(h,c.right,o)}default:return o(s)}}return u(t,r,s=>{if(e==="|=")return i(s,s);let c=m(t,n,p);return i(s,c[0]??null)})}function At(t,r,e){function n(i,u,f){switch(u.type){case"Identity":return f;case"Field":{if(u.base){let s=m(i,u.base,e)[0],c=n(s,{type:"Field",name:u.name},f);return n(i,u.base,c)}return i&&typeof i=="object"&&!Array.isArray(i)?{...i,[u.name]:f}:i}case"Index":{if(u.base){let o=m(i,u.base,e)[0],h=n(o,{type:"Index",index:u.index},f);return n(i,u.base,h)}let c=m(t,u.index,e)[0];if(typeof c=="number"&&Array.isArray(i)){let o=[...i],h=c<0?o.length+c:c;return h>=0&&h<o.length&&(o[h]=f),o}return typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)?{...i,[c]:f}:i}default:return i}}function p(i,u){switch(u.type){case"Identity":return null;case"Field":{if(u.base){let s=m(i,u.base,e)[0];if(s==null)return i;let c=p(s,{type:"Field",name:u.name});return n(i,u.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){let s={...i};return delete s[u.name],s}return i}case"Index":{if(u.base){let o=m(i,u.base,e)[0];if(o==null)return i;let h=p(o,{type:"Index",index:u.index});return n(i,u.base,h)}let c=m(t,u.index,e)[0];if(typeof c=="number"&&Array.isArray(i)){let o=[...i],h=c<0?o.length+c:c;return h>=0&&h<o.length&&o.splice(h,1),o}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){let o={...i};return delete o[c],o}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?{}:i;case"Pipe":{let o=function(a,l,d){switch(l.type){case"Identity":return d;case"Field":return a&&typeof a=="object"&&!Array.isArray(a)?{...a,[l.name]:d}:a;case"Index":{let A=m(t,l.index,e)[0];if(typeof A=="number"&&Array.isArray(a)){let b=[...a],C=A<0?b.length+A:A;return C>=0&&C<b.length&&(b[C]=d),b}return typeof A=="string"&&a&&typeof a=="object"&&!Array.isArray(a)?{...a,[A]:d}:a}case"Pipe":{let g=m(a,l.left,e)[0],A=o(g,l.right,d);return o(a,l.left,A)}default:return a}};var f=o;let s=u.left,c=u.right,h=m(i,s,e)[0];if(h==null)return i;let y=p(h,c);return o(i,s,y)}default:return i}}return p(t,r)}function gt(t,r,e,n,p){if(r==="and")return m(t,e,p).flatMap(s=>E(s)?m(t,n,p).map(o=>E(o)):[!1]);if(r==="or")return m(t,e,p).flatMap(s=>E(s)?[!0]:m(t,n,p).map(o=>E(o)));if(r==="//"){let s=m(t,e,p).filter(c=>c!=null&&c!==!1);return s.length>0?s:m(t,n,p)}let i=m(t,e,p),u=m(t,n,p);return i.flatMap(f=>u.map(s=>{switch(r){case"+":return f===null?s:s===null?f:typeof f=="number"&&typeof s=="number"||typeof f=="string"&&typeof s=="string"?f+s:Array.isArray(f)&&Array.isArray(s)?[...f,...s]:f&&s&&typeof f=="object"&&typeof s=="object"&&!Array.isArray(f)&&!Array.isArray(s)?{...f,...s}:null;case"-":if(typeof f=="number"&&typeof s=="number")return f-s;if(Array.isArray(f)&&Array.isArray(s)){let c=new Set(s.map(o=>JSON.stringify(o)));return f.filter(o=>!c.has(JSON.stringify(o)))}if(typeof f=="string"&&typeof s=="string"){let c=o=>o.length>10?`"${o.slice(0,10)}...`:JSON.stringify(o);throw new Error(`string (${c(f)}) and string (${c(s)}) cannot be subtracted`)}return null;case"*":return typeof f=="number"&&typeof s=="number"?f*s:typeof f=="string"&&typeof s=="number"?f.repeat(s):f&&s&&typeof f=="object"&&typeof s=="object"&&!Array.isArray(f)&&!Array.isArray(s)?H(f,s):null;case"/":if(typeof f=="number"&&typeof s=="number"){if(s===0)throw new Error(`number (${f}) and number (${s}) cannot be divided because the divisor is zero`);return f/s}return typeof f=="string"&&typeof s=="string"?f.split(s):null;case"%":if(typeof f=="number"&&typeof s=="number"){if(s===0)throw new Error(`number (${f}) and number (${s}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(f)&&!Number.isNaN(f)?!Number.isFinite(s)&&!Number.isNaN(s)&&f<0&&s>0?-1:0:f%s}return null;case"==":return S(f,s);case"!=":return!S(f,s);case"<":return M(f,s)<0;case"<=":return M(f,s)<=0;case">":return M(f,s)>0;case">=":return M(f,s)>=0;default:return null}}))}function ot(t,r,e,n){let p=at[r];if(p)return typeof t=="number"?[p(t)]:[null];let i=G(t,r,e,n,m);if(i!==null)return i;let u=z(t,r,e,n,m);if(u!==null)return u;let f=J(t,r,e,n,m);if(f!==null)return f;let s=Y(t,r,n.limits.maxDepth);if(s!==null)return s;let c=v(t,r);if(c!==null)return c;let o=W(t,r,e,n,m);if(o!==null)return o;let h=K(t,r,e,n,m,nt,j,E,P,O);if(h!==null)return h;let y=Q(t,r,e,n,m,E,D,B,At,U);if(y!==null)return y;let a=q(t,r,e,n,m,S);if(a!==null)return a;let l=V(t,r,e,n,m,nt,E,O);if(l!==null)return l;let d=X(t,r,e,n,m,E,mt,ot);if(d!==null)return d;let g=Z(t,r,e,n,m,S);if(g!==null)return g;switch(r){case"builtins":return[["add/0","all/0","all/1","all/2","any/0","any/1","any/2","arrays/0","ascii/0","ascii_downcase/0","ascii_upcase/0","booleans/0","bsearch/1","builtins/0","combinations/0","combinations/1","contains/1","debug/0","del/1","delpaths/1","empty/0","env/0","error/0","error/1","explode/0","first/0","first/1","flatten/0","flatten/1","floor/0","from_entries/0","fromdate/0","fromjson/0","getpath/1","gmtime/0","group_by/1","gsub/2","gsub/3","has/1","implode/0","IN/1","IN/2","INDEX/1","INDEX/2","index/1","indices/1","infinite/0","inside/1","isempty/1","isnan/0","isnormal/0","isvalid/1","iterables/0","join/1","keys/0","keys_unsorted/0","last/0","last/1","length/0","limit/2","ltrimstr/1","map/1","map_values/1","match/1","match/2","max/0","max_by/1","min/0","min_by/1","mktime/0","modulemeta/1","nan/0","not/0","nth/1","nth/2","null/0","nulls/0","numbers/0","objects/0","path/1","paths/0","paths/1","pick/1","range/1","range/2","range/3","recurse/0","recurse/1","recurse_down/0","repeat/1","reverse/0","rindex/1","rtrimstr/1","scalars/0","scan/1","scan/2","select/1","setpath/2","skip/2","sort/0","sort_by/1","split/1","splits/1","splits/2","sqrt/0","startswith/1","strftime/1","strings/0","strptime/1","sub/2","sub/3","test/1","test/2","to_entries/0","toboolean/0","todate/0","tojson/0","tostream/0","fromstream/1","truncate_stream/1","tonumber/0","tostring/0","transpose/0","trim/0","ltrim/0","rtrim/0","type/0","unique/0","unique_by/1","until/2","utf8bytelength/0","values/0","walk/1","while/2","with_entries/1"]];case"error":{let A=e.length>0?m(t,e[0],n)[0]:t;throw new L(A)}case"env":return[n.env??{}];case"debug":return[t];case"input_line_number":return[1];default:{let A=`${r}/${e.length}`,b=n.funcs?.get(A);if(b){let C=b.closure??n.funcs??new Map,$=new Map(C);$.set(A,b);for(let x=0;x<b.params.length;x++){let pt=b.params[x],rt=e[x];if(rt){let k=m(t,rt,n),N;if(k.length===0)N={type:"Call",name:"empty",args:[]};else if(k.length===1)N={type:"Literal",value:k[0]};else{N={type:"Literal",value:k[k.length-1]};for(let F=k.length-2;F>=0;F--)N={type:"Comma",left:{type:"Literal",value:k[F]},right:N}}$.set(`${pt}/0`,{params:[],body:N})}}let ct={...n,funcs:$};return m(t,b.body,ct)}throw new Error(`Unknown function: ${r}`)}}}function U(t,r,e,n,p){if(r.type==="Comma"){let f=r;U(t,f.left,e,n,p),U(t,f.right,e,n,p);return}let i=w(r);if(i!==null){p.push([...n,...i]);return}if(r.type==="Iterate"){if(Array.isArray(t))for(let f=0;f<t.length;f++)p.push([...n,f]);else if(t&&typeof t=="object")for(let f of Object.keys(t))p.push([...n,f]);return}if(r.type==="Recurse"){let f=(s,c)=>{if(p.push([...n,...c]),s&&typeof s=="object")if(Array.isArray(s))for(let o=0;o<s.length;o++)f(s[o],[...c,o]);else for(let o of Object.keys(s))f(s[o],[...c,o])};f(t,[]);return}if(r.type==="Pipe"){let f=w(r.left);if(f!==null){let s=m(t,r.left,e);for(let c of s)U(c,r.right,e,[...n,...f],p);return}}m(t,r,e).length>0&&p.push(n)}var bt={and:"AND",or:"OR",not:"NOT",if:"IF",then:"THEN",elif:"ELIF",else:"ELSE",end:"END",as:"AS",try:"TRY",catch:"CATCH",true:"TRUE",false:"FALSE",null:"NULL",reduce:"REDUCE",foreach:"FOREACH",label:"LABEL",break:"BREAK",def:"DEF"};function ft(t){let r=[],e=0,n=(c=0)=>t[e+c],p=()=>t[e++],i=()=>e>=t.length,u=c=>c>="0"&&c<="9",f=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",s=c=>f(c)||u(c);for(;!i();){let c=e,o=p();if(!(o===" "||o===" "||o===`
|
|
4
|
+
`||o==="\r")){if(o==="#"){for(;!i()&&n()!==`
|
|
5
|
+
`;)p();continue}if(o==="."&&n()==="."){p(),r.push({type:"DOTDOT",pos:c});continue}if(o==="="&&n()==="="){p(),r.push({type:"EQ",pos:c});continue}if(o==="!"&&n()==="="){p(),r.push({type:"NE",pos:c});continue}if(o==="<"&&n()==="="){p(),r.push({type:"LE",pos:c});continue}if(o===">"&&n()==="="){p(),r.push({type:"GE",pos:c});continue}if(o==="/"&&n()==="/"){p(),n()==="="?(p(),r.push({type:"UPDATE_ALT",pos:c})):r.push({type:"ALT",pos:c});continue}if(o==="+"&&n()==="="){p(),r.push({type:"UPDATE_ADD",pos:c});continue}if(o==="-"&&n()==="="){p(),r.push({type:"UPDATE_SUB",pos:c});continue}if(o==="*"&&n()==="="){p(),r.push({type:"UPDATE_MUL",pos:c});continue}if(o==="/"&&n()==="="){p(),r.push({type:"UPDATE_DIV",pos:c});continue}if(o==="%"&&n()==="="){p(),r.push({type:"UPDATE_MOD",pos:c});continue}if(o==="="&&n()!=="="){r.push({type:"ASSIGN",pos:c});continue}if(o==="."){r.push({type:"DOT",pos:c});continue}if(o==="|"){n()==="="?(p(),r.push({type:"UPDATE_PIPE",pos:c})):r.push({type:"PIPE",pos:c});continue}if(o===","){r.push({type:"COMMA",pos:c});continue}if(o===":"){r.push({type:"COLON",pos:c});continue}if(o===";"){r.push({type:"SEMICOLON",pos:c});continue}if(o==="("){r.push({type:"LPAREN",pos:c});continue}if(o===")"){r.push({type:"RPAREN",pos:c});continue}if(o==="["){r.push({type:"LBRACKET",pos:c});continue}if(o==="]"){r.push({type:"RBRACKET",pos:c});continue}if(o==="{"){r.push({type:"LBRACE",pos:c});continue}if(o==="}"){r.push({type:"RBRACE",pos:c});continue}if(o==="?"){r.push({type:"QUESTION",pos:c});continue}if(o==="+"){r.push({type:"PLUS",pos:c});continue}if(o==="-"){r.push({type:"MINUS",pos:c});continue}if(o==="*"){r.push({type:"STAR",pos:c});continue}if(o==="/"){r.push({type:"SLASH",pos:c});continue}if(o==="%"){r.push({type:"PERCENT",pos:c});continue}if(o==="<"){r.push({type:"LT",pos:c});continue}if(o===">"){r.push({type:"GT",pos:c});continue}if(u(o)){let h=o;for(;!i()&&(u(n())||n()==="."||n()==="e"||n()==="E");)(n()==="e"||n()==="E")&&(t[e+1]==="+"||t[e+1]==="-")&&(h+=p()),h+=p();r.push({type:"NUMBER",value:Number(h),pos:c});continue}if(o==='"'){let h="";for(;!i()&&n()!=='"';)if(n()==="\\"){if(p(),i())break;let y=p();switch(y){case"n":h+=`
|
|
6
|
+
`;break;case"r":h+="\r";break;case"t":h+=" ";break;case"\\":h+="\\";break;case'"':h+='"';break;case"(":h+="\\(";break;default:h+=y}}else h+=p();i()||p(),r.push({type:"STRING",value:h,pos:c});continue}if(f(o)||o==="$"||o==="@"){let h=o;for(;!i()&&s(n());)h+=p();let y=bt[h];y?r.push({type:y,pos:c}):r.push({type:"IDENT",value:h,pos:c});continue}throw new Error(`Unexpected character '${o}' at position ${c}`)}}return r.push({type:"EOF",pos:e}),r}var et=class t{tokens;pos=0;constructor(r){this.tokens=r}peek(r=0){return this.tokens[this.pos+r]??{type:"EOF",pos:-1}}advance(){return this.tokens[this.pos++]}check(r){return this.peek().type===r}match(...r){for(let e of r)if(this.check(e))return this.advance();return null}expect(r,e){if(!this.check(r))throw new Error(`${e} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}parse(){let r=this.parseExpr();if(!this.check("EOF"))throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return r}parseExpr(){return this.parsePipe()}parsePattern(){if(this.match("LBRACKET")){let n=[];if(!this.check("RBRACKET"))for(n.push(this.parsePattern());this.match("COMMA")&&!this.check("RBRACKET");)n.push(this.parsePattern());return this.expect("RBRACKET","Expected ']' after array pattern"),{type:"array",elements:n}}if(this.match("LBRACE")){let n=[];if(!this.check("RBRACE"))for(n.push(this.parsePatternField());this.match("COMMA")&&!this.check("RBRACE");)n.push(this.parsePatternField());return this.expect("RBRACE","Expected '}' after object pattern"),{type:"object",fields:n}}let r=this.expect("IDENT","Expected variable name in pattern"),e=r.value;if(!e.startsWith("$"))throw new Error(`Variable name must start with $ at position ${r.pos}`);return{type:"var",name:e}}parsePatternField(){if(this.match("LPAREN")){let e=this.parseExpr();this.expect("RPAREN","Expected ')' after computed key"),this.expect("COLON","Expected ':' after computed key");let n=this.parsePattern();return{key:e,pattern:n}}let r=this.peek();if(r.type==="IDENT"){let e=r.value;if(e.startsWith("$")){if(this.advance(),this.match("COLON")){let n=this.parsePattern();return{key:e.slice(1),pattern:n,keyVar:e}}return{key:e.slice(1),pattern:{type:"var",name:e}}}if(this.advance(),this.match("COLON")){let n=this.parsePattern();return{key:e,pattern:n}}return{key:e,pattern:{type:"var",name:`$${e}`}}}throw new Error(`Expected field name in object pattern at position ${r.pos}`)}parsePipe(){let r=this.parseComma();for(;this.match("PIPE");){let e=this.parseComma();r={type:"Pipe",left:r,right:e}}return r}parseComma(){let r=this.parseVarBind();for(;this.match("COMMA");){let e=this.parseVarBind();r={type:"Comma",left:r,right:e}}return r}parseVarBind(){let r=this.parseUpdate();if(this.match("AS")){let e=this.parsePattern(),n=[];for(;this.check("QUESTION")&&this.peekAhead(1)?.type==="ALT";)this.advance(),this.advance(),n.push(this.parsePattern());this.expect("PIPE","Expected '|' after variable binding");let p=this.parseExpr();return e.type==="var"&&n.length===0?{type:"VarBind",name:e.name,value:r,body:p}:{type:"VarBind",name:e.type==="var"?e.name:"",value:r,body:p,pattern:e.type!=="var"?e:void 0,alternatives:n.length>0?n:void 0}}return r}peekAhead(r){let e=this.pos+r;return e<this.tokens.length?this.tokens[e]:void 0}parseUpdate(){let r=this.parseAlt(),e={ASSIGN:"=",UPDATE_ADD:"+=",UPDATE_SUB:"-=",UPDATE_MUL:"*=",UPDATE_DIV:"/=",UPDATE_MOD:"%=",UPDATE_ALT:"//=",UPDATE_PIPE:"|="},n=this.match("ASSIGN","UPDATE_ADD","UPDATE_SUB","UPDATE_MUL","UPDATE_DIV","UPDATE_MOD","UPDATE_ALT","UPDATE_PIPE");if(n){let p=this.parseVarBind();return{type:"UpdateOp",op:e[n.type],path:r,value:p}}return r}parseAlt(){let r=this.parseOr();for(;this.match("ALT");){let e=this.parseOr();r={type:"BinaryOp",op:"//",left:r,right:e}}return r}parseOr(){let r=this.parseAnd();for(;this.match("OR");){let e=this.parseAnd();r={type:"BinaryOp",op:"or",left:r,right:e}}return r}parseAnd(){let r=this.parseNot();for(;this.match("AND");){let e=this.parseNot();r={type:"BinaryOp",op:"and",left:r,right:e}}return r}parseNot(){return this.parseComparison()}parseComparison(){let r=this.parseAddSub(),e={EQ:"==",NE:"!=",LT:"<",LE:"<=",GT:">",GE:">="},n=this.match("EQ","NE","LT","LE","GT","GE");if(n){let p=this.parseAddSub();r={type:"BinaryOp",op:e[n.type],left:r,right:p}}return r}parseAddSub(){let r=this.parseMulDiv();for(;;)if(this.match("PLUS")){let e=this.parseMulDiv();r={type:"BinaryOp",op:"+",left:r,right:e}}else if(this.match("MINUS")){let e=this.parseMulDiv();r={type:"BinaryOp",op:"-",left:r,right:e}}else break;return r}parseMulDiv(){let r=this.parseUnary();for(;;)if(this.match("STAR")){let e=this.parseUnary();r={type:"BinaryOp",op:"*",left:r,right:e}}else if(this.match("SLASH")){let e=this.parseUnary();r={type:"BinaryOp",op:"/",left:r,right:e}}else if(this.match("PERCENT")){let e=this.parseUnary();r={type:"BinaryOp",op:"%",left:r,right:e}}else break;return r}parseUnary(){return this.match("MINUS")?{type:"UnaryOp",op:"-",operand:this.parseUnary()}:this.parsePostfix()}parsePostfix(){let r=this.parsePrimary();for(;;)if(this.match("QUESTION"))r={type:"Optional",expr:r};else if(this.check("DOT")&&(this.peek(1).type==="IDENT"||this.peek(1).type==="STRING"))this.advance(),r={type:"Field",name:this.advance().value,base:r};else if(this.check("LBRACKET"))if(this.advance(),this.match("RBRACKET"))r={type:"Iterate",base:r};else if(this.check("COLON")){this.advance();let e=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),r={type:"Slice",end:e,base:r}}else{let e=this.parseExpr();if(this.match("COLON")){let n=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),r={type:"Slice",start:e,end:n,base:r}}else this.expect("RBRACKET","Expected ']'"),r={type:"Index",index:e,base:r}}else break;return r}parsePrimary(){if(this.match("DOTDOT"))return{type:"Recurse"};if(this.match("DOT")){if(this.check("LBRACKET")){if(this.advance(),this.match("RBRACKET"))return{type:"Iterate"};if(this.check("COLON")){this.advance();let e=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:e}}let r=this.parseExpr();if(this.match("COLON")){let e=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:r,end:e}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:r}}return this.check("IDENT")||this.check("STRING")?{type:"Field",name:this.advance().value}:{type:"Identity"}}if(this.match("TRUE"))return{type:"Literal",value:!0};if(this.match("FALSE"))return{type:"Literal",value:!1};if(this.match("NULL"))return{type:"Literal",value:null};if(this.check("NUMBER"))return{type:"Literal",value:this.advance().value};if(this.check("STRING")){let e=this.advance().value;return e.includes("\\(")?this.parseStringInterpolation(e):{type:"Literal",value:e}}if(this.match("LBRACKET")){if(this.match("RBRACKET"))return{type:"Array"};let r=this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Array",elements:r}}if(this.match("LBRACE"))return this.parseObjectConstruction();if(this.match("LPAREN")){let r=this.parseExpr();return this.expect("RPAREN","Expected ')'"),{type:"Paren",expr:r}}if(this.match("IF"))return this.parseIf();if(this.match("TRY")){let r=this.parsePostfix(),e;return this.match("CATCH")&&(e=this.parsePostfix()),{type:"Try",body:r,catch:e}}if(this.match("REDUCE")){let r=this.parseAddSub();this.expect("AS","Expected 'as' after reduce expression");let e=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let n=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let p=this.parseExpr();this.expect("RPAREN","Expected ')' after update expression");let i=e.type==="var"?e.name:"";return{type:"Reduce",expr:r,varName:i,init:n,update:p,pattern:e.type!=="var"?e:void 0}}if(this.match("FOREACH")){let r=this.parseAddSub();this.expect("AS","Expected 'as' after foreach expression");let e=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let n=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let p=this.parseExpr(),i;this.match("SEMICOLON")&&(i=this.parseExpr()),this.expect("RPAREN","Expected ')' after expressions");let u=e.type==="var"?e.name:"";return{type:"Foreach",expr:r,varName:u,init:n,update:p,extract:i,pattern:e.type!=="var"?e:void 0}}if(this.match("LABEL")){let r=this.expect("IDENT","Expected label name (e.g., $out)"),e=r.value;if(!e.startsWith("$"))throw new Error(`Label name must start with $ at position ${r.pos}`);this.expect("PIPE","Expected '|' after label name");let n=this.parseExpr();return{type:"Label",name:e,body:n}}if(this.match("BREAK")){let r=this.expect("IDENT","Expected label name to break to"),e=r.value;if(!e.startsWith("$"))throw new Error(`Break label must start with $ at position ${r.pos}`);return{type:"Break",name:e}}if(this.match("DEF")){let e=this.expect("IDENT","Expected function name after def").value,n=[];if(this.match("LPAREN")){if(!this.check("RPAREN")){let u=this.expect("IDENT","Expected parameter name");for(n.push(u.value);this.match("SEMICOLON");){let f=this.expect("IDENT","Expected parameter name");n.push(f.value)}}this.expect("RPAREN","Expected ')' after parameters")}this.expect("COLON","Expected ':' after function name");let p=this.parseExpr();this.expect("SEMICOLON","Expected ';' after function body");let i=this.parseExpr();return{type:"Def",name:e,params:n,funcBody:p,body:i}}if(this.match("NOT"))return{type:"Call",name:"not",args:[]};if(this.check("IDENT")){let e=this.advance().value;if(e.startsWith("$"))return{type:"VarRef",name:e};if(this.match("LPAREN")){let n=[];if(!this.check("RPAREN"))for(n.push(this.parseExpr());this.match("SEMICOLON");)n.push(this.parseExpr());return this.expect("RPAREN","Expected ')'"),{type:"Call",name:e,args:n}}return{type:"Call",name:e,args:[]}}throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){let r=[];if(!this.check("RBRACE"))do{let e,n;if(this.match("LPAREN"))e=this.parseExpr(),this.expect("RPAREN","Expected ')'"),this.expect("COLON","Expected ':'"),n=this.parseObjectValue();else if(this.check("IDENT")){let p=this.advance().value;this.match("COLON")?(e=p,n=this.parseObjectValue()):(e=p,n={type:"Field",name:p})}else if(this.check("STRING"))e=this.advance().value,this.expect("COLON","Expected ':'"),n=this.parseObjectValue();else throw new Error(`Expected object key at position ${this.peek().pos}`);r.push({key:e,value:n})}while(this.match("COMMA"));return this.expect("RBRACE","Expected '}'"),{type:"Object",entries:r}}parseObjectValue(){let r=this.parseVarBind();for(;this.match("PIPE");){let e=this.parseVarBind();r={type:"Pipe",left:r,right:e}}return r}parseIf(){let r=this.parseExpr();this.expect("THEN","Expected 'then'");let e=this.parseExpr(),n=[];for(;this.match("ELIF");){let i=this.parseExpr();this.expect("THEN","Expected 'then' after elif");let u=this.parseExpr();n.push({cond:i,then:u})}let p;return this.match("ELSE")&&(p=this.parseExpr()),this.expect("END","Expected 'end'"),{type:"Cond",cond:r,then:e,elifs:n,else:p}}parseStringInterpolation(r){let e=[],n="",p=0;for(;p<r.length;)if(r[p]==="\\"&&r[p+1]==="("){n&&(e.push(n),n=""),p+=2;let i=1,u="";for(;p<r.length&&i>0;)r[p]==="("?i++:r[p]===")"&&i--,i>0&&(u+=r[p]),p++;let f=ft(u),s=new t(f);e.push(s.parse())}else n+=r[p],p++;return n&&e.push(n),{type:"StringInterp",parts:e}}};function te(t){let r=ft(t);return new et(r).parse()}export{m as a,te as b};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import"./chunk-KGOUQS5A.js";function
|
|
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+=`\\${
|
|
2
|
+
import"./chunk-KGOUQS5A.js";function c(a){let s="",e=0;for(;e<a.length;)if(a[e]==="\\"){if(e+1>=a.length){s+="\\";break}let o=a[e+1];switch(o){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+=`\\${o}`,e+=2}}else s+=a[e],e++;return{output:s,stop:!1}}var n={name:"echo",async execute(a,s){let e=!1,o=s.xpgEcho??!1,r=0;for(;r<a.length;){let l=a[r];if(l==="-n")e=!0,r++;else if(l==="-e")o=!0,r++;else if(l==="-E")o=!1,r++;else if(l==="-ne"||l==="-en")e=!0,o=!0,r++;else break}let t=a.slice(r).join(" ");if(o){let l=c(t);if(t=l.output,l.stop)return{stdout:t,stderr:"",exitCode:0}}return e||(t+=`
|
|
4
4
|
`),{stdout:t,stderr:"",exitCode:0}}};export{n as echoCommand};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as m,b as d,c as f}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var g={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"]},C={name:"env",async execute(s,i){if(d(s))return m(g);let u=!1,o=[],c={},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 f("env",e);if(e.startsWith("-")&&e!=="-"){for(let r of e.slice(1))if(r!=="i"&&r!=="u")return f("env",`-${r}`);e.includes("i")&&(u=!0)}else if(e.includes("=")&&t===-1){let r=e.indexOf("="),O=e.slice(0,r),$=e.slice(r+1);c[O]=$}else{t=n;break}}}let l;if(u)l={...c};else{l={...i.env};for(let n of o)delete l[n];Object.assign(l,c)}if(t===-1){let n=[];for(let[e,r]of Object.entries(l))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 a=s.slice(t),h=a[0],x=a.slice(1).map(n=>/[\s"'\\$`!*?[\]{}|&;<>()]/.test(n)?`'${n.replace(/'/g,"'\\''")}'`:n),p=["command",h,...x].join(" "),v=Object.entries(c).map(([n,e])=>`${n}="${e}"`).join(" "),A=v?`${v} ${p}`:p;return i.exec(A,{cwd:i.cwd})}},j={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},E={name:"printenv",async execute(s,i){if(d(s))return m(j);let u=s.filter(t=>!t.startsWith("-"));if(u.length===0){let t=[];for(let[l,a]of Object.entries(i.env))t.push(`${l}=${a}`);return{stdout:t.join(`
|
|
6
|
+
`)+(t.length>0?`
|
|
7
|
+
`:""),stderr:"",exitCode:0}}let o=[],c=0;for(let t of u)t in i.env?o.push(i.env[t]):c=1;return{stdout:o.join(`
|
|
8
|
+
`)+(o.length>0?`
|
|
9
|
+
`:""),stderr:"",exitCode:c}}};export{C as envCommand,E as printenvCommand};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{A as c,B as d,C as e,I as f,J as g,K as h,L as i,M as j,N as k,O as l,y as a,z as b}from"./chunk-FSAGDARS.js";import"./chunk-K5IXNHO5.js";import"./chunk-OBH7XN5N.js";import"./chunk-KGOUQS5A.js";export{d as escapeGlobChars,e as escapeRegexChars,l as expandRedirectTarget,g as expandWord,i as expandWordForPattern,h as expandWordForRegex,j as expandWordWithGlob,a as getArrayElements,c as getVariable,k as hasQuotedMultiValueAt,b as isArray,f as isWordFullyQuoted};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as Z}from"./chunk-26Q3PZQ6.js";import{a as ae,b as le,c as oe}from"./chunk-
|
|
2
|
+
import{a as Z}from"./chunk-26Q3PZQ6.js";import{a as ae,b as le,c as oe}from"./chunk-D5WP4CKS.js";import{a as re,b as ie}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";function N(e,t){switch(e.type){case"name":{let n=e.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let s=r[1],o=t.name;if(e.ignoreCase){if(!o.toLowerCase().endsWith(s.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!o.endsWith(s))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Z(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=e.pattern,r=t.relativePath,s=n.split("/");for(let a=0;a<s.length-1;a++){let i=s[a];if(i&&i!=="."&&i!==".."&&!i.includes("*")&&!i.includes("?")&&!i.includes("[")){let c=`/${i}/`;if(e.ignoreCase){if(!r.toLowerCase().includes(c.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.includes(c))return{matches:!1,pruned:!1,printed:!1}}}let o=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(o){let a=o[1];if(e.ignoreCase){if(!r.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.endsWith(a))return{matches:!1,pruned:!1,printed:!1}}return{matches:Z(r,n,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:t.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-t.mtime)/(1e3*60*60*24),s;return e.comparison==="more"?s=r>e.days:e.comparison==="less"?s=r<e.days:s=Math.floor(r)===e.days,{matches:s,pruned:!1,printed:!1}}case"newer":{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.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=t.size>n:e.comparison==="less"?r=t.size<n:e.unit==="b"?r=Math.ceil(t.size/512)===e.value:r=t.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=t.mode&511,r=e.mode&511,s;return e.matchType==="exact"?s=n===r:e.matchType==="all"?s=(n&r)===r:s=(n&r)!==0,{matches:s,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=N(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=N(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=N(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=N(e.left,t);if(n.matches)return n;let r=N(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function Y(e){if(!e)return!1;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!0;case"not":return Y(e.expr);case"and":case"or":return Y(e.left)||Y(e.right)}}function _(e){if(!e)return!1;switch(e.type){case"empty":return!0;case"not":return _(e.expr);case"and":case"or":return _(e.left)||_(e.right);default:return!1}}function ce(e){let t={terminalDirName:null,requiredExtension:null};if(!e)return t;let n=Se(e);if(Ee(e)&&n.length===1){let o=n[0].split("/").filter(a=>a.length>0);if(o.length>=2)for(let a=o.length-2;a>=0;a--){let i=o[a];if(!i.includes("*")&&!i.includes("?")&&!i.includes("[")&&i!=="."&&i!==".."){let c=o[a+1];if(c&&(c.includes("*")||c.includes("?"))){t.terminalDirName=i;let l=c.match(/^\*(\.[a-zA-Z0-9]+)$/);l&&(t.requiredExtension=l[1])}break}}}return t}function Se(e){let t=[],n=r=>{r.type==="path"?t.push(r.pattern):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right))};return n(e),t}function Ee(e){let t=n=>n.type==="type"&&n.fileType==="f"?!0:n.type==="not"?t(n.expr):n.type==="and"||n.type==="or"?t(n.left)||t(n.right):!1;return t(e)}function pe(e){let t=[],n=r=>{r&&(r.type==="newer"?t.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(e),t}function V(e){if(!e)return!0;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return V(e.expr);case"and":case"or":return V(e.left)&&V(e.right)}}function O(e,t,n,r,s){switch(e.type){case"name":{let o=e.pattern,a=o.match(/^\*(\.[a-zA-Z0-9]+)$/);if(a){let i=a[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(i.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(i))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:Z(t,o,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let o=e.pattern,a=o.split("/");for(let c=0;c<a.length-1;c++){let l=a[c];if(l&&l!=="."&&l!==".."&&!l.includes("*")&&!l.includes("?")&&!l.includes("[")){let d=`/${l}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(d.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(d))return{matches:!1,pruned:!1,printed:!1}}}let i=o.match(/\*(\.[a-zA-Z0-9]+)$/);if(i){let c=i[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(c.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(c))return{matches:!1,pruned:!1,printed:!1}}return{matches:Z(n,o,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let o=e.ignoreCase?"i":"";return{matches:new RegExp(e.pattern,o).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:r,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s,pruned:!1,printed:!1}:{matches:!1,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 o=O(e.expr,t,n,r,s);return{matches:!o.matches,pruned:o.pruned,printed:!1}}case"and":{let o=O(e.left,t,n,r,s);if(!o.matches)return{matches:!1,pruned:o.pruned,printed:!1};let a=O(e.right,t,n,r,s);return{matches:a.matches,pruned:o.pruned||a.pruned,printed:o.printed||a.printed}}case"or":{let o=O(e.left,t,n,r,s);if(o.matches)return o;let a=O(e.right,t,n,r,s);return{matches:a.matches,pruned:o.pruned||a.pruned,printed:a.printed}}default:return{matches:!1,pruned:!1,printed:!1}}}function J(e){if(!e)return!1;switch(e.type){case"prune":return!0;case"not":return J(e.expr);case"and":case"or":return J(e.left)||J(e.right);default:return!1}}function z(e){switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return z(e.expr);case"and":case"or":return z(e.left)&&z(e.right)}}function fe(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!z(e))return te(e,t);let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:N(e,n).pruned}}function te(e,t){switch(e.type){case"or":{if(z(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(N(e.left,n).pruned)return{shouldPrune:!0}}return te(e.right,t)}case"and":{if(z(e.left)&&z(e.right)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:N(e,n).pruned}}if(z(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return N(e.left,n).matches?te(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}function ue(e,t){let n=[],r=[],s=t;for(;s<e.length;){let a=e[s];if(a==="("||a==="\\("){n.push({type:"lparen"}),s++;continue}if(a===")"||a==="\\)"){n.push({type:"rparen"}),s++;continue}if(a==="-name"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s]}});else if(a==="-iname"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}});else if(a==="-path"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s]}});else if(a==="-ipath"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}});else if(a==="-regex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s]}});else if(a==="-iregex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s],ignoreCase:!0}});else if(a==="-type"&&s+1<e.length){let i=e[++s];if(i==="f"||i==="d")n.push({type:"expr",expr:{type:"type",fileType:i}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${i}
|
|
3
3
|
`,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&s+1<e.length){let i=e[++s],c="exact",l=i;i.startsWith("+")?(c="more",l=i.slice(1)):i.startsWith("-")&&(c="less",l=i.slice(1));let d=parseInt(l,10);Number.isNaN(d)||n.push({type:"expr",expr:{type:"mtime",days:d,comparison:c}})}else if(a==="-newer"&&s+1<e.length){let i=e[++s];n.push({type:"expr",expr:{type:"newer",refPath:i}})}else if(a==="-size"&&s+1<e.length){let i=e[++s],c="exact",l=i;i.startsWith("+")?(c="more",l=i.slice(1)):i.startsWith("-")&&(c="less",l=i.slice(1));let d=l.match(/^(\d+)([ckMGb])?$/);if(d){let B=parseInt(d[1],10),F=d[2]||"b";n.push({type:"expr",expr:{type:"size",value:B,unit:F,comparison:c}})}}else if(a==="-perm"&&s+1<e.length){let i=e[++s],c="exact",l=i;i.startsWith("-")?(c="all",l=i.slice(1)):i.startsWith("/")&&(c="any",l=i.slice(1));let d=parseInt(l,8);Number.isNaN(d)||n.push({type:"expr",expr:{type:"perm",mode:d,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")s++;else if(a!=="-depth")if(a==="-exec"){let i=[];for(s++;s<e.length&&e[s]!==";"&&e[s]!=="+";)i.push(e[s]),s++;if(s>=e.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n",actions:[]};let c=e[s]==="+";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"&&s+1<e.length){let i=e[++s];r.push({type:"printf",format:i})}else if(a==="-delete")r.push({type:"delete"});else{if(a.startsWith("-"))return{expr:null,pathIndex:s,error:`find: unknown predicate '${a}'
|
|
4
4
|
`,actions:[]};if(n.length===0){s++;continue}break}s++}if(n.length===0)return{expr:null,pathIndex:s,actions:r};let o=be(n);return o.error?{expr:null,pathIndex:s,error:o.error,actions:r}:{expr:o.expr,pathIndex:s,actions:r}}function be(e){let t=0;function n(){let i=r();if(!i)return null;for(;t<e.length;){let c=e[t];if(c.type==="op"&&c.op==="or"){t++;let l=r();if(!l)return i;i={type:"or",left:i,right:l}}else break}return i}function r(){let i=s();if(!i)return null;for(;t<e.length;){let c=e[t];if(c.type==="op"&&c.op==="and"){t++;let l=s();if(!l)return i;i={type:"and",left:i,right:l}}else if(c.type==="expr"||c.type==="not"||c.type==="lparen"){let l=s();if(!l)return i;i={type:"and",left:i,right:l}}else break}return i}function s(){if(t<e.length&&e[t].type==="not"){t++;let i=s();return i?{type:"not",expr:i}:null}return o()}function o(){if(t>=e.length)return null;let i=e[t];if(i.type==="lparen"){t++;let c=n();return t<e.length&&e[t].type==="rparen"&&t++,c}return i.type==="expr"?(t++,i.expr):(i.type==="rparen",null)}return{expr:n()}}var he=500;function Me(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function ve(e,t,n){e({category:"find",name:"summary",durationMs:n,details:{readdirCalls:t.readdirCalls,readdirTimeMs:t.readdirTime,statCalls:t.statCalls,statTimeMs:t.statTime,evalCalls:t.evalCalls,evalTimeMs:t.evalTime,nodeCount:t.nodeCount,batchCount:t.batchCount,batchTimeMs:t.batchTime,earlyPrunes:t.earlyPrunes,otherTimeMs:n-t.readdirTime-t.statTime-t.evalTime-t.batchTime}})}var xe={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"]},Ie=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),qe={name:"find",async execute(e,t){if(ie(e))return re(xe);let n=[],r=null,s=null,o=!1,a=!1;for(let p=0;p<e.length;p++){let f=e[p];if(f==="-maxdepth"&&p+1<e.length)a=!0,r=parseInt(e[++p],10);else if(f==="-mindepth"&&p+1<e.length)a=!0,s=parseInt(e[++p],10);else if(f==="-depth")a=!0,o=!0;else if(f==="-exec")for(a=!0,p++;p<e.length&&e[p]!==";"&&e[p]!=="+";)p++;else!f.startsWith("-")&&f!==";"&&f!=="+"&&f!=="("&&f!==")"&&f!=="\\("&&f!=="\\)"&&f!=="!"?a||n.push(f):Ie.has(f)?(a=!0,p++):(f.startsWith("-")||f==="("||f==="\\("||f==="!")&&(a=!0)}n.length===0&&n.push(".");let{expr:i,error:c,actions:l}=ue(e,0);if(c)return{stdout:"",stderr:c,exitCode:1};let d=l.some(p=>p.type==="print"),B=l.length===0,F=[],de=l.some(p=>p.type==="printf"),ne=[],q="",G=0,me=pe(i),K=new Map;for(let p of me){let f=t.fs.resolvePath(t.cwd,p);try{let h=await t.fs.stat(f);K.set(p,h.mtime?.getTime()??Date.now())}catch{}}let ye=l.some(p=>{if(p.type!=="printf")return!1;let f=p.format.replace(/%%/g,"");return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(f)}),ge=Y(i)||ye,we=_(i),U=ce(i),se=J(i),De=V(i),Te=typeof t.fs.readdirWithFileTypes=="function";for(let p of n){let W=function(u){let R=s===null||u.depth>=s,P=!1;if(R&&i!==null){let S=Date.now(),y;if(De)y=O(i,u.name,u.relativePath,u.isFile,u.isDirectory);else{let m={name:u.name,relativePath:u.relativePath,isFile:u.isFile,isDirectory:u.isDirectory,isEmpty:u.isEmpty,mtime:u.stat?.mtime?.getTime()??Date.now(),size:u.stat?.size??0,mode:u.stat?.mode??420,newerRefTimes:K};y=N(i,m)}R=y.matches,P=d?y.printed:R,h.evalCalls++,h.evalTime+=Date.now()-S}else R&&(P=!0);return P?{print:!0,printfData:de?{path:u.relativePath,name:u.name,size:u.stat?.size??0,mtime:u.stat?.mtime?.getTime()??Date.now(),mode:u.stat?.mode??420,isDirectory:u.isDirectory,depth:u.depth,startingPoint:p}:null}:{print:!1,printfData:null}};var Ne=W;p.length>1&&p.endsWith("/")&&(p=p.slice(0,-1));let f=t.fs.resolvePath(t.cwd,p);try{await t.fs.stat(f)}catch{q+=`find: ${p}: No such file or directory
|
|
5
5
|
`,G=1;continue}let h=Me(),$=Date.now();async function E(u){let{path:b,depth:R,typeInfo:P}=u;if(h.nodeCount++,r!==null&&R>r)return null;let M,S,y;if(P&&!ge)M=P.isFile,S=P.isDirectory;else{try{let L=Date.now();y=await t.fs.stat(b),h.statCalls++,h.statTime+=Date.now()-L}catch{return null}if(!y)return null;M=y.isFile,S=y.isDirectory}let m;b===f?m=p.split("/").pop()||p:m=b.split("/").pop()||"";let g=b===f?p:p==="."?`./${b.slice(f==="/"?f.length:f.length+1)}`:p+b.slice(f.length),T=[],C=null,w=null,D=!1;S&&se&&!o&&(D=fe(i,{name:m,relativePath:g,isFile:M,isDirectory:S}).shouldPrune,D&&h.earlyPrunes++);let x=r!==null&&R>=r,I=U.terminalDirName!==null&&m===U.terminalDirName,j=!x&&!I&&!D;if(S&&((j||we||I)&&!D)){let L=Date.now();if(Te&&t.fs.readdirWithFileTypes){if(C=await t.fs.readdirWithFileTypes(b),w=C.map(v=>v.name),h.readdirCalls++,h.readdirTime+=Date.now()-L,j)T=C.map((v,k)=>({path:b==="/"?`/${v.name}`:`${b}/${v.name}`,depth:R+1,typeInfo:{isFile:v.isFile,isDirectory:v.isDirectory},resultIndex:k}));else if(I){let v=U.requiredExtension;T=C.filter(k=>k.isFile&&(!v||k.name.endsWith(v))).map((k,Pe)=>({path:b==="/"?`/${k.name}`:`${b}/${k.name}`,depth:R+1,typeInfo:{isFile:k.isFile,isDirectory:k.isDirectory},resultIndex:Pe}))}}else w=await t.fs.readdir(b),h.readdirCalls++,h.readdirTime+=Date.now()-L,j&&(T=w.map((v,k)=>({path:b==="/"?`/${v}`:`${b}/${v}`,depth:R+1,resultIndex:k})))}let Q=M?(y?.size??0)===0:w!==null&&w.length===0,H=D;if(!o&&i!==null&&!D&&se){let L=Date.now(),v={name:m,relativePath:g,isFile:M,isDirectory:S,isEmpty:Q,mtime:y?.mtime?.getTime()??Date.now(),size:y?.size??0,mode:y?.mode??420,newerRefTimes:K};H=N(i,v).pruned,h.evalCalls++,h.evalTime+=Date.now()-L}return{relativePath:g,name:m,isFile:M,isDirectory:S,isEmpty:Q,stat:y,depth:R,children:H?[]:T,pruned:H}}async function Ce(){let u={paths:[],printfData:[]};if(o){let y=function(m){let g={paths:[],printfData:[]},T=P[m];if(!T)return g;for(let D of T.childIndices){let x=y(D);g.paths.push(...x.paths),g.printfData.push(...x.printfData)}let{print:C,printfData:w}=W(T.node);return C&&(g.paths.push(T.node.relativePath),w&&g.printfData.push(w)),g};var b=y;let P=[],M=[{item:{path:f,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],S=new Map;for(;M.length>0;){let m=Date.now(),g=M.splice(0,he),T=await Promise.all(g.map(C=>E(C.item)));h.batchCount++,h.batchTime+=Date.now()-m;for(let C=0;C<g.length;C++){let w=T[C],D=g[C];if(!w)continue;let x=P.length;if(D.parentIndex>=0){let I=S.get(D.parentIndex)||[];I.push(x),S.set(D.parentIndex,I)}P.push({node:w,parentIndex:D.parentIndex,childIndices:[]});for(let I=0;I<w.children.length;I++)M.push({item:w.children[I],parentIndex:x,childOrderInParent:I})}}for(let[m,g]of S)m>=0&&m<P.length&&(P[m].childIndices=g);if(P.length>0){let m=y(0);u.paths.push(...m.paths),u.printfData.push(...m.printfData)}}else{let m=function(g){let T=P.get(g);T&&(u.paths.push(T.path),T.printfData&&u.printfData.push(T.printfData));let C=y.get(g);if(C)for(let w of C)m(w)};var R=m;let P=new Map,M=0,S=[{item:{path:f,depth:0,resultIndex:0},orderIndex:M++}],y=new Map;for(;S.length>0;){let g=Date.now(),T=S.splice(0,he),C=await Promise.all(T.map(async({item:w,orderIndex:D})=>{let x=await E(w);return x?{node:x,orderIndex:D}:null}));h.batchCount++,h.batchTime+=Date.now()-g;for(let w of C){if(!w)continue;let{node:D,orderIndex:x}=w,{print:I,printfData:j}=W(D);if(I&&P.set(x,{path:D.relativePath,printfData:j}),D.children.length>0){let ee=[];for(let Q of D.children){let H=M++;ee.push(H),S.push({item:Q,orderIndex:H})}y.set(x,ee)}}}m(0)}return u}let X=await Ce();if(F.push(...X.paths),ne.push(...X.printfData),t.trace){let u=Date.now()-$;ve(t.trace,h,u),t.trace({category:"find",name:"searchPath",durationMs:u,details:{path:p,resultsFound:X.paths.length}})}}let A="";if(l.length>0)for(let p of l)switch(p.type){case"print":A+=F.length>0?`${F.join(`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as y}from"./chunk-26Q3PZQ6.js";import{a as S,b as z}from"./chunk-
|
|
2
|
+
import{a as y}from"./chunk-26Q3PZQ6.js";import{a as S,b as z}from"./chunk-IRUD2E3M.js";import{a as _,b as j,c as G}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var te={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-P, --perl-regexp PATTERN is a Perl regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},J={name:"grep",async execute(t,s){if(j(t))return _(te);let o=!1,f=!1,c=!1,h=!1,m=!1,l=!1,i=!1,d=!1,w=!1,u=!1,p=!1,T=!1,x=!1,q=!1,B=!1,M=0,R=0,F=0,W=[],A=[],Q=[],N=null,I=[];for(let r=0;r<t.length;r++){let n=t[r];if(n.startsWith("-")&&n!=="-"){if(n==="-e"&&r+1<t.length){N=t[++r];continue}if(n.startsWith("--include=")){W.push(n.slice(10));continue}if(n.startsWith("--exclude=")){A.push(n.slice(10));continue}if(n.startsWith("--exclude-dir=")){Q.push(n.slice(14));continue}if(n.startsWith("--max-count=")){M=parseInt(n.slice(12),10);continue}let C=n.match(/^-m(\d+)$/);if(C){M=parseInt(C[1],10);continue}if(n==="-m"&&r+1<t.length){M=parseInt(t[++r],10);continue}let a=n.match(/^-([ABC])(\d+)$/);if(a){let e=parseInt(a[2],10);a[1]==="A"?F=e:a[1]==="B"?R=e:a[1]==="C"&&(R=e,F=e);continue}if((n==="-A"||n==="-B"||n==="-C")&&r+1<t.length){let e=parseInt(t[++r],10);n==="-A"?F=e:n==="-B"?R=e:(R=e,F=e);continue}let g=n.startsWith("--")?[n]:n.slice(1).split("");for(let e of g)if(e==="i"||e==="--ignore-case")o=!0;else if(e==="n"||e==="--line-number")f=!0;else if(e==="v"||e==="--invert-match")c=!0;else if(e==="c"||e==="--count")h=!0;else if(e==="l"||e==="--files-with-matches")m=!0;else if(e==="L"||e==="--files-without-match")l=!0;else if(e==="r"||e==="R"||e==="--recursive")i=!0;else if(e==="w"||e==="--word-regexp")d=!0;else if(e==="x"||e==="--line-regexp")w=!0;else if(e==="E"||e==="--extended-regexp")u=!0;else if(e==="P"||e==="--perl-regexp")p=!0;else if(e==="F"||e==="--fixed-strings")T=!0;else if(e==="o"||e==="--only-matching")x=!0;else if(e==="h"||e==="--no-filename")q=!0;else if(e==="q"||e==="--quiet"||e==="--silent")B=!0;else{if(e.startsWith("--"))return G("grep",e);if(e.length===1)return G("grep",`-${e}`)}}else N===null?N=n:I.push(n)}if(N===null)return{stdout:"",stderr:`grep: missing pattern
|
|
3
3
|
`,exitCode:2};let V=T?"fixed":u?"extended":p?"perl":"basic",U,b;try{let r=z(N,{mode:V,ignoreCase:o,wholeWord:d,lineRegexp:w});U=r.regex,b=r.kResetGroup}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${N}
|
|
4
|
-
`,exitCode:2}}if(I.length===0&&s.stdin){let r=S(s.stdin,U,{invertMatch:c,showLineNumbers:f,countOnly:h,filename:"",onlyMatching:x,beforeContext:R,afterContext:F,maxCount:M,kResetGroup:b});return B?{stdout:"",stderr:"",exitCode:r.matched?0:1}:{stdout:r.output,stderr:"",exitCode:r.matched?0:1}}if(I.length===0)return{stdout:"",stderr:`grep: no input files
|
|
4
|
+
`,exitCode:2}}if(I.length===0&&s.stdin!==void 0){let r=S(s.stdin,U,{invertMatch:c,showLineNumbers:f,countOnly:h,filename:"",onlyMatching:x,beforeContext:R,afterContext:F,maxCount:M,kResetGroup:b});return B?{stdout:"",stderr:"",exitCode:r.matched?0:1}:{stdout:r.output,stderr:"",exitCode:r.matched?0:1}}if(I.length===0)return{stdout:"",stderr:`grep: no input files
|
|
5
5
|
`,exitCode:2};let $="",D="",H=!1,k=!1,P=[];for(let r of I)if(r.includes("*")||r.includes("?")||r.includes("[")){let n=await se(r,s);if(i)for(let C of n){let a=await O(C.path,s,W,A,Q,C.isFile);P.push(...a)}else P.push(...n)}else if(i){let n=await O(r,s,W,A,Q);P.push(...n)}else P.push({path:r});let X=(P.length>1||i)&&!q,Z=50;for(let r=0;r<P.length;r+=Z){let n=P.slice(r,r+Z),C=await Promise.all(n.map(async a=>{let g=a.path,e=g.split("/").pop()||g;if(A.length>0&&!i&&A.some(v=>y(e,v,{stripQuotes:!0}))||W.length>0&&!i&&!W.some(v=>y(e,v,{stripQuotes:!0})))return null;try{let v=s.fs.resolvePath(s.cwd,g),L=!1;if(a.isFile===void 0?L=(await s.fs.stat(v)).isDirectory:L=!a.isFile,L)return i?null:{error:`grep: ${g}: Is a directory
|
|
6
6
|
`};let Y=await s.fs.readFile(v),ee=S(Y,U,{invertMatch:c,showLineNumbers:f,countOnly:h,filename:X?g:"",onlyMatching:x,beforeContext:R,afterContext:F,maxCount:M,kResetGroup:b});return{file:g,result:ee}}catch{return{error:`grep: ${g}: No such file or directory
|
|
7
7
|
`}}}));for(let a of C){if(a===null)continue;if("error"in a&&a.error){D+=a.error,a.error.includes("Is a directory")||(k=!0);continue}if(!("file"in a)||!a.result)continue;let{file:g,result:e}=a;if(e.matched){if(H=!0,B)return{stdout:"",stderr:"",exitCode:0};m?$+=`${g}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as i,b as r,c as n}from"./chunk-
|
|
2
|
+
import{a as i,b as r,c as n}from"./chunk-FSZWFMB4.js";import{a as t,b as a}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var h={name:"head",summary:"output the first part of files",usage:"head [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the first NUM bytes","-n, --lines=NUM print the first NUM lines (default 10)","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},u={name:"head",async execute(s,o){if(a(s))return t(h);let e=i(s,"head");if(!e.ok)return e.error;let{lines:p,bytes:l}=e.options;return r(o,e.options,"head",d=>n(d,p,l))}};export{u as headCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as w,b as J}from"./chunk-
|
|
2
|
+
import{a as w,b as J}from"./chunk-KD3EODLB.js";import{k as q}from"./chunk-K5IXNHO5.js";import{a as N}from"./chunk-5WFYIUU2.js";import"./chunk-OBH7XN5N.js";import{a as C,b as E,c as x}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";function I(s){let i=[],t=0,o=s.length;for(;t<o;){for(;t<o&&/\s/.test(s[t]);)t++;if(t>=o)break;let a=t,r=s[t];if(r==="{"||r==="["){let n=r,l=r==="{"?"}":"]",c=1,p=!1,d=!1;for(t++;t<o&&c>0;){let h=s[t];d?d=!1:h==="\\"?d=!0:h==='"'?p=!p:p||(h===n?c++:h===l&&c--),t++}if(c!==0)throw new Error(`Unexpected end of JSON input at position ${t} (unclosed ${n})`);i.push(JSON.parse(s.slice(a,t)))}else if(r==='"'){let n=!1;for(t++;t<o;){let l=s[t];if(n)n=!1;else if(l==="\\")n=!0;else if(l==='"'){t++;break}t++}i.push(JSON.parse(s.slice(a,t)))}else if(r==="-"||r>="0"&&r<="9"){for(;t<o&&/[\d.eE+-]/.test(s[t]);)t++;i.push(JSON.parse(s.slice(a,t)))}else if(s.slice(t,t+4)==="true")i.push(!0),t+=4;else if(s.slice(t,t+5)==="false")i.push(!1),t+=5;else if(s.slice(t,t+4)==="null")i.push(null),t+=4;else{let n=s.slice(t,t+10);throw new Error(`Invalid JSON at position ${a}: unexpected '${n.split(/\s/)[0]}'`)}}return i}var H={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE]",options:["-r, --raw-output output strings without quotes","-c, --compact compact output (no pretty printing)","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]};function g(s,i,t,o,a,r=0){if(s===null||s===void 0)return"null";if(typeof s=="boolean")return String(s);if(typeof s=="number")return Number.isFinite(s)?String(s):"null";if(typeof s=="string")return t?s:JSON.stringify(s);let n=a?" ":" ";if(Array.isArray(s))return s.length===0?"[]":i?`[${s.map(c=>g(c,!0,!1,o,a)).join(",")}]`:`[
|
|
3
3
|
${s.map(c=>n.repeat(r+1)+g(c,!1,!1,o,a,r+1)).join(`,
|
|
4
4
|
`)}
|
|
5
5
|
${n.repeat(r)}]`;if(typeof s=="object"){let l=Object.keys(s);return o&&(l=l.sort()),l.length===0?"{}":i?`{${l.map(p=>`${JSON.stringify(p)}:${g(s[p],!0,!1,o,a)}`).join(",")}}`:`{
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import"./chunk-KGOUQS5A.js";async function x(o,h){let s="octal",e=[],i=[];for(let t=0;t<o.length;t++){let r=o[t];if(r==="-c")e.push("char");else if(r==="-An"||r==="-A"&&o[t+1]==="n")s="none",r==="-A"&&t++;else if(r==="-t"&&o[t+1]){let n=o[++t];n==="x1"?e.push("hex"):n==="c"?e.push("char"):n.startsWith("o")&&e.push("octal")}else(!r.startsWith("-")||r==="-")&&i.push(r)}e.length===0&&e.push("octal");let c=h.stdin;if(i.length>0&&i[0]!=="-"){let t=i[0].startsWith("/")?i[0]:`${h.cwd}/${i[0]}`;try{c=await h.fs.readFile(t)}catch{return{stdout:"",stderr:`od: ${i[0]}: No such file or directory
|
|
3
|
+
`,exitCode:1}}}let m=e.includes("char");function g(t){return t===0?" \\0":t===7?" \\a":t===8?" \\b":t===9?" \\t":t===10?" \\n":t===11?" \\v":t===12?" \\f":t===13?" \\r":t>=32&&t<127?` ${String.fromCharCode(t)}`:` ${t.toString(8).padStart(3,"0")}`}function S(t){return m?` ${t.toString(16).padStart(2,"0")}`:` ${t.toString(16).padStart(2,"0")}`}function $(t){return` ${t.toString(8).padStart(3,"0")}`}let f=[];for(let t of c)f.push(t.charCodeAt(0));let p=16,a=[];for(let t=0;t<f.length;t+=p){let r=f.slice(t,t+p);for(let n=0;n<e.length;n++){let d=e[n],u;d==="char"?u=r.map(g):d==="hex"?u=r.map(S):u=r.map($);let l="";n===0&&s!=="none"?l=`${t.toString(8).padStart(7,"0")} `:(n>0||s==="none")&&(l=s==="none"?"":" "),a.push(l+u.join(""))}}return s!=="none"&&f.length>0&&a.push(f.length.toString(8).padStart(7,"0")),{stdout:a.length>0?`${a.join(`
|
|
4
|
+
`)}
|
|
5
|
+
`:"",stderr:"",exitCode:0}}var y={name:"od",execute:x};export{y as od};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as A,c as W}from"./chunk-D5WP4CKS.js";import{a as D}from"./chunk-4VDEBYW7.js";import{a as T,b as N}from"./chunk-GTNBSMZR.js";import{c as X,e as G}from"./chunk-KGOUQS5A.js";var _=X(C=>{(function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function a(c){return e(n(c),arguments)}function r(c,o){return a.apply(null,[c].concat(o||[]))}function e(c,o){var u=1,l=c.length,i,h="",d,p,f,m,y,k,$,S;for(d=0;d<l;d++)if(typeof c[d]=="string")h+=c[d];else if(typeof c[d]=="object"){if(f=c[d],f.keys)for(i=o[u],p=0;p<f.keys.length;p++){if(i==null)throw new Error(a('[sprintf] Cannot access property "%s" of undefined value "%s"',f.keys[p],f.keys[p-1]));i=i[f.keys[p]]}else f.param_no?i=o[f.param_no]:i=o[u++];if(t.not_type.test(f.type)&&t.not_primitive.test(f.type)&&i instanceof Function&&(i=i()),t.numeric_arg.test(f.type)&&typeof i!="number"&&isNaN(i))throw new TypeError(a("[sprintf] expecting number but found %T",i));switch(t.number.test(f.type)&&($=i>=0),f.type){case"b":i=parseInt(i,10).toString(2);break;case"c":i=String.fromCharCode(parseInt(i,10));break;case"d":case"i":i=parseInt(i,10);break;case"j":i=JSON.stringify(i,null,f.width?parseInt(f.width):0);break;case"e":i=f.precision?parseFloat(i).toExponential(f.precision):parseFloat(i).toExponential();break;case"f":i=f.precision?parseFloat(i).toFixed(f.precision):parseFloat(i);break;case"g":i=f.precision?String(Number(i.toPrecision(f.precision))):parseFloat(i);break;case"o":i=(parseInt(i,10)>>>0).toString(8);break;case"s":i=String(i),i=f.precision?i.substring(0,f.precision):i;break;case"t":i=String(!!i),i=f.precision?i.substring(0,f.precision):i;break;case"T":i=Object.prototype.toString.call(i).slice(8,-1).toLowerCase(),i=f.precision?i.substring(0,f.precision):i;break;case"u":i=parseInt(i,10)>>>0;break;case"v":i=i.valueOf(),i=f.precision?i.substring(0,f.precision):i;break;case"x":i=(parseInt(i,10)>>>0).toString(16);break;case"X":i=(parseInt(i,10)>>>0).toString(16).toUpperCase();break}t.json.test(f.type)?h+=i:(t.number.test(f.type)&&(!$||f.sign)?(S=$?"+":"-",i=i.toString().replace(t.sign,"")):S="",y=f.pad_char?f.pad_char==="0"?"0":f.pad_char.charAt(1):" ",k=f.width-(S+i).length,m=f.width&&k>0?y.repeat(k):"",h+=f.align?S+i+m:y==="0"?S+m+i:m+S+i)}return h}var s=Object.create(null);function n(c){if(s[c])return s[c];for(var o=c,u,l=[],i=0;o;){if((u=t.text.exec(o))!==null)l.push(u[0]);else if((u=t.modulo.exec(o))!==null)l.push("%");else if((u=t.placeholder.exec(o))!==null){if(u[2]){i|=1;var h=[],d=u[2],p=[];if((p=t.key.exec(d))!==null)for(h.push(p[1]);(d=d.substring(p[0].length))!=="";)if((p=t.key_access.exec(d))!==null)h.push(p[1]);else if((p=t.index_access.exec(d))!==null)h.push(p[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");u[2]=h}else i|=2;if(i===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");l.push({placeholder:u[0],param_no:u[1],keys:u[2],sign:u[3],pad_char:u[4],align:u[5],width:u[6],precision:u[7],type:u[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");o=o.substring(u[0].length)}return s[c]=l}typeof C<"u"&&(C.sprintf=a,C.vsprintf=r),typeof window<"u"&&(window.sprintf=a,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:a,vsprintf:r}}))})()});var b=G(_(),1);function P(t,a,r){let e=new Date(a*1e3),s="",n=0;for(;n<t.length;)if(t[n]==="%"&&n+1<t.length){let c=t[n+1],o=R(e,c,r);o!==null?(s+=o,n+=2):(s+=t[n],n++)}else s+=t[n],n++;return s}function H(t,a){let r={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",weekday:"short",hour12:!1,timeZone:a};try{let s=new Intl.DateTimeFormat("en-US",r).formatToParts(t),n=u=>s.find(l=>l.type===u)?.value??"",c={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6},o=n("weekday");return{year:Number.parseInt(n("year"),10)||t.getFullYear(),month:Number.parseInt(n("month"),10)||t.getMonth()+1,day:Number.parseInt(n("day"),10)||t.getDate(),hour:Number.parseInt(n("hour"),10)||t.getHours(),minute:Number.parseInt(n("minute"),10)||t.getMinutes(),second:Number.parseInt(n("second"),10)||t.getSeconds(),weekday:c[o]??t.getDay()}}catch{return{year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes(),second:t.getSeconds(),weekday:t.getDay()}}}function R(t,a,r){let e=H(t,r),s=(u,l=2)=>String(u).padStart(l,"0"),n=z(e.year,e.month,e.day),c=j(e.year,e.month,e.day,e.weekday,0),o=j(e.year,e.month,e.day,e.weekday,1);switch(a){case"a":return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][e.weekday];case"A":return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][e.weekday];case"b":case"h":return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.month-1];case"B":return["January","February","March","April","May","June","July","August","September","October","November","December"][e.month-1];case"c":return`${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][e.weekday]} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.month-1]} ${String(e.day).padStart(2," ")} ${s(e.hour)}:${s(e.minute)}:${s(e.second)} ${e.year}`;case"C":return s(Math.floor(e.year/100));case"d":return s(e.day);case"D":return`${s(e.month)}/${s(e.day)}/${s(e.year%100)}`;case"e":return String(e.day).padStart(2," ");case"F":return`${e.year}-${s(e.month)}-${s(e.day)}`;case"g":return s(O(e.year,e.month,e.day)%100);case"G":return String(O(e.year,e.month,e.day));case"H":return s(e.hour);case"I":return s(e.hour%12||12);case"j":return String(n).padStart(3,"0");case"k":return String(e.hour).padStart(2," ");case"l":return String(e.hour%12||12).padStart(2," ");case"m":return s(e.month);case"M":return s(e.minute);case"n":return`
|
|
3
|
+
`;case"N":return"000000000";case"p":return e.hour<12?"AM":"PM";case"P":return e.hour<12?"am":"pm";case"r":return`${s(e.hour%12||12)}:${s(e.minute)}:${s(e.second)} ${e.hour<12?"AM":"PM"}`;case"R":return`${s(e.hour)}:${s(e.minute)}`;case"s":return String(Math.floor(t.getTime()/1e3));case"S":return s(e.second);case"t":return" ";case"T":return`${s(e.hour)}:${s(e.minute)}:${s(e.second)}`;case"u":return String(e.weekday===0?7:e.weekday);case"U":return s(c);case"V":return s(L(e.year,e.month,e.day));case"w":return String(e.weekday);case"W":return s(o);case"x":return`${s(e.month)}/${s(e.day)}/${s(e.year%100)}`;case"X":return`${s(e.hour)}:${s(e.minute)}:${s(e.second)}`;case"y":return s(e.year%100);case"Y":return String(e.year);case"z":return V(t,r);case"Z":return q(t,r);case"%":return"%";default:return null}}function V(t,a){if(!a){let c=-t.getTimezoneOffset(),o=c>=0?"+":"-",u=Math.floor(Math.abs(c)/60),l=Math.abs(c)%60;return`${o}${String(u).padStart(2,"0")}${String(l).padStart(2,"0")}`}try{let u=new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"longOffset"}).formatToParts(t).find(l=>l.type==="timeZoneName");if(u){let l=u.value.match(/GMT([+-])(\d{2}):(\d{2})/);if(l)return`${l[1]}${l[2]}${l[3]}`;if(u.value==="GMT"||u.value==="UTC")return"+0000"}}catch{}let r=-t.getTimezoneOffset(),e=r>=0?"+":"-",s=Math.floor(Math.abs(r)/60),n=Math.abs(r)%60;return`${e}${String(s).padStart(2,"0")}${String(n).padStart(2,"0")}`}function q(t,a){try{return new Intl.DateTimeFormat("en-US",{timeZone:a,timeZoneName:"short"}).formatToParts(t).find(n=>n.type==="timeZoneName")?.value??"UTC"}catch{return"UTC"}}function z(t,a,r){let e=[31,28,31,30,31,30,31,31,30,31,30,31];(t%4===0&&t%100!==0||t%400===0)&&(e[1]=29);let n=r;for(let c=0;c<a-1;c++)n+=e[c];return n}function j(t,a,r,e,s){let n=z(t,a,r),u=(new Date(t,0,1).getDay()-s+7)%7,l=(e-s+7)%7,i=n-1+u;return Math.floor((i-l+7)/7)}function L(t,a,r){let e=new Date(t,a-1,r,12,0,0);e.setDate(e.getDate()+3-(e.getDay()+6)%7);let s=new Date(e.getFullYear(),0,4);s.setDate(s.getDate()+3-(s.getDay()+6)%7);let n=e.getTime()-s.getTime();return 1+Math.round(n/(10080*60*1e3))}function O(t,a,r){let e=new Date(t,a-1,r,12,0,0);return e.setDate(e.getDate()+3-(e.getDay()+6)%7),e.getFullYear()}function Q(t){let a="",r=0;for(;r<t.length;){let e=t[r];if(e<128){a+=String.fromCharCode(e),r++;continue}if((e&224)===192){if(r+1<t.length&&(t[r+1]&192)===128&&e>=194){let s=(e&31)<<6|t[r+1]&63;a+=String.fromCharCode(s),r+=2;continue}a+=String.fromCharCode(e),r++;continue}if((e&240)===224){if(r+2<t.length&&(t[r+1]&192)===128&&(t[r+2]&192)===128){if(e===224&&t[r+1]<160){a+=String.fromCharCode(e),r++;continue}let s=(e&15)<<12|(t[r+1]&63)<<6|t[r+2]&63;if(s>=55296&&s<=57343){a+=String.fromCharCode(e),r++;continue}a+=String.fromCharCode(s),r+=3;continue}a+=String.fromCharCode(e),r++;continue}if((e&248)===240&&e<=244){if(r+3<t.length&&(t[r+1]&192)===128&&(t[r+2]&192)===128&&(t[r+3]&192)===128){if(e===240&&t[r+1]<144){a+=String.fromCharCode(e),r++;continue}let s=(e&7)<<18|(t[r+1]&63)<<12|(t[r+2]&63)<<6|t[r+3]&63;if(s>1114111){a+=String.fromCharCode(e),r++;continue}a+=String.fromCodePoint(s),r+=4;continue}a+=String.fromCharCode(e),r++;continue}a+=String.fromCharCode(e),r++}return a}var B={name:"printf",summary:"format and print data",usage:"printf [-v var] FORMAT [ARGUMENT...]",options:[" -v var assign the output to shell variable VAR rather than display it"," --help display this help and exit"],notes:["FORMAT controls the output like in C printf.","Escape sequences: \\n (newline), \\t (tab), \\\\ (backslash)","Format specifiers: %s (string), %d (integer), %f (float), %x (hex), %o (octal), %% (literal %)","Width and precision: %10s (width 10), %.2f (2 decimal places), %010d (zero-padded)","Flags: %- (left-justify), %+ (show sign), %0 (zero-pad)"]},he={name:"printf",async execute(t,a){if(N(t))return T(B);if(t.length===0)return{stdout:"",stderr:`printf: usage: printf format [arguments]
|
|
4
|
+
`,exitCode:2};let r=null,e=0;for(;e<t.length;){let c=t[e];if(c==="--"){e++;break}if(c==="-v"){if(e+1>=t.length)return{stdout:"",stderr:`printf: -v: option requires an argument
|
|
5
|
+
`,exitCode:1};if(r=t[e+1],!/^[a-zA-Z_][a-zA-Z0-9_]*(\[[^\]]+\])?$/.test(r))return{stdout:"",stderr:`printf: \`${r}': not a valid identifier
|
|
6
|
+
`,exitCode:2};e+=2}else{if(c.startsWith("-")&&c!=="-")break;break}}if(e>=t.length)return{stdout:"",stderr:`printf: usage: printf format [arguments]
|
|
7
|
+
`,exitCode:1};let s=t[e],n=t.slice(e+1);try{let c=W(s),o="",u=0,l=!1,i="",h=a.env.TZ;do{let{result:d,argsConsumed:p,error:f,errMsg:m,stopped:y}=K(c,n,u,h);if(o+=d,u+=p,f&&(l=!0,m&&(i=m)),y)break}while(u<n.length&&u>0);if(u===0&&n.length>0,r){let d=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(['"]?)(.+?)\2\]$/);if(d){let p=d[1],f=d[3];f=f.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(m,y)=>a.env[y]??""),a.env[`${p}_${f}`]=o}else a.env[r]=o;return{stdout:"",stderr:i,exitCode:l?1:0}}return{stdout:o,stderr:i,exitCode:l?1:0}}catch(c){return{stdout:"",stderr:`printf: ${D(c)}
|
|
8
|
+
`,exitCode:1}}}};function K(t,a,r,e){let s="",n=0,c=0,o=!1,u="";for(;n<t.length;)if(t[n]==="%"&&n+1<t.length){let l=n;if(n++,t[n]==="%"){s+="%",n++;continue}let i=t.slice(l).match(/^%(-?\d*)(?:\.(\d+))?\(([^)]*)\)T/);if(i){let w=i[1]?parseInt(i[1],10):0,E=i[2]?parseInt(i[2],10):-1,J=i[3],Y=i[0],v=a[r+c]||"";c++;let M;v===""||v==="-1"||v==="-2"?M=Math.floor(Date.now()/1e3):M=parseInt(v,10)||0;let x=P(J,M,e);if(E>=0&&x.length>E&&(x=x.slice(0,E)),w!==0){let F=Math.abs(w);x.length<F&&(w<0?x=x.padEnd(F," "):x=x.padStart(F," "))}s+=x,n=l+Y.length;continue}for(;n<t.length&&"+-0 #'".includes(t[n]);)n++;let h=!1;if(t[n]==="*")h=!0,n++;else for(;n<t.length&&/\d/.test(t[n]);)n++;let d=!1;if(t[n]===".")if(n++,t[n]==="*")d=!0,n++;else for(;n<t.length&&/\d/.test(t[n]);)n++;n<t.length&&"hlL".includes(t[n])&&n++;let p=t[n]||"";n++;let m=t.slice(l,n);if(h){let w=parseInt(a[r+c]||"0",10);c++,m=m.replace("*",String(w))}if(d){let w=parseInt(a[r+c]||"0",10);c++,m=m.replace(".*",`.${w}`)}let y=a[r+c]||"";c++;let{value:k,parseError:$,parseErrMsg:S,stopped:U}=ee(m,p,y);if(s+=k,$&&(o=!0,S&&(u=S)),U)return{result:s,argsConsumed:c,error:o,errMsg:u,stopped:!0}}else s+=t[n],n++;return{result:s,argsConsumed:c,error:o,errMsg:u,stopped:!1}}function ee(t,a,r){let e=!1,s="";switch(a){case"d":case"i":{let n=I(r);return e=g,e&&(s=`printf: ${r}: invalid number
|
|
9
|
+
`),{value:Z(t,n),parseError:e,parseErrMsg:s}}case"o":{let n=I(r);return e=g,e&&(s=`printf: ${r}: invalid number
|
|
10
|
+
`),{value:te(t,n),parseError:e,parseErrMsg:s}}case"u":{let n=I(r);e=g,e&&(s=`printf: ${r}: invalid number
|
|
11
|
+
`);let c=n<0?n>>>0:n;return{value:Z(t.replace("u","d"),c),parseError:e,parseErrMsg:s}}case"x":case"X":{let n=I(r);return e=g,e&&(s=`printf: ${r}: invalid number
|
|
12
|
+
`),{value:re(t,n),parseError:e,parseErrMsg:s}}case"e":case"E":case"f":case"F":case"g":case"G":{let n=parseFloat(r)||0;return{value:ie(t,a,n),parseError:!1,parseErrMsg:""}}case"c":{if(r==="")return{value:"",parseError:!1,parseErrMsg:""};let o=new TextEncoder().encode(r)[0];return{value:String.fromCharCode(o),parseError:!1,parseErrMsg:""}}case"s":return{value:se(t,r),parseError:!1,parseErrMsg:""};case"q":return{value:ae(t,r),parseError:!1,parseErrMsg:""};case"b":{let n=oe(r);return{value:n.value,parseError:!1,parseErrMsg:"",stopped:n.stopped}}default:try{return{value:(0,b.sprintf)(t,r),parseError:!1,parseErrMsg:""}}catch{return{value:"",parseError:!0,parseErrMsg:`printf: [sprintf] unexpected placeholder
|
|
13
|
+
`}}}}var g=!1;function I(t){g=!1;let a=t.trimStart(),r=a!==a.trimEnd();if(t=a.trimEnd(),t.startsWith("'")&&t.length>=2||t.startsWith('"')&&t.length>=2)return t.charCodeAt(1);if(t.startsWith("\\'")&&t.length>=3||t.startsWith('\\"')&&t.length>=3)return t.charCodeAt(2);if(t.startsWith("+")&&(t=t.slice(1)),t.startsWith("0x")||t.startsWith("0X")){let e=parseInt(t,16);return Number.isNaN(e)?(g=!0,0):(r&&(g=!0),e)}if(t.startsWith("0")&&t.length>1&&/^-?0[0-7]+$/.test(t))return r&&(g=!0),parseInt(t,8)||0;if(/^\d+#/.test(t)){g=!0;let e=t.match(/^(\d+)#/);return e?parseInt(e[1],10):0}if(t!==""&&!/^-?\d+$/.test(t)){g=!0;let e=parseInt(t,10);return Number.isNaN(e)?0:e}return r&&(g=!0),parseInt(t,10)||0}function Z(t,a){let r=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[diu]$/);if(!r)return(0,b.sprintf)(t.replace(/\.\d*/,""),a);let e=r[1]||"",s=r[2]?parseInt(r[2],10):0,n=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,c=a<0,o=Math.abs(a),u=String(o);n>=0&&(u=u.padStart(n,"0"));let l="";c?l="-":e.includes("+")?l="+":e.includes(" ")&&(l=" ");let i=l+u;return s>i.length&&(e.includes("-")?i=i.padEnd(s," "):e.includes("0")&&n<0?i=l+u.padStart(s-l.length,"0"):i=i.padStart(s," ")),i}function te(t,a){let r=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?o$/);if(!r)return(0,b.sprintf)(t,a);let e=r[1]||"",s=r[2]?parseInt(r[2],10):0,n=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,c=Math.abs(a).toString(8);n>=0&&(c=c.padStart(n,"0")),e.includes("#")&&!c.startsWith("0")&&(c=`0${c}`);let o=c;return s>o.length&&(e.includes("-")?o=o.padEnd(s," "):e.includes("0")&&n<0?o=o.padStart(s,"0"):o=o.padStart(s," ")),o}function re(t,a){let r=t.includes("X"),e=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[xX]$/);if(!e)return(0,b.sprintf)(t,a);let s=e[1]||"",n=e[2]?parseInt(e[2],10):0,c=e[3]!==void 0?e[4]?parseInt(e[4],10):0:-1,o=Math.abs(a).toString(16);r&&(o=o.toUpperCase()),c>=0&&(o=o.padStart(c,"0"));let u="";s.includes("#")&&a!==0&&(u=r?"0X":"0x");let l=u+o;return n>l.length&&(s.includes("-")?l=l.padEnd(n," "):s.includes("0")&&c<0?l=u+o.padStart(n-u.length,"0"):l=l.padStart(n," ")),l}function ne(t){if(t==="")return"''";if(/^[a-zA-Z0-9_./-]+$/.test(t))return t;if(/[\x00-\x1f\x7f-\xff]/.test(t)){let e="$'";for(let s of t){let n=s.charCodeAt(0);s==="'"?e+="\\'":s==="\\"?e+="\\\\":s===`
|
|
14
|
+
`?e+="\\n":s===" "?e+="\\t":s==="\r"?e+="\\r":s==="\x07"?e+="\\a":s==="\b"?e+="\\b":s==="\f"?e+="\\f":s==="\v"?e+="\\v":s==="\x1B"?e+="\\E":n<32||n>=127&&n<=255?e+=`\\${n.toString(8).padStart(3,"0")}`:s==='"'?e+='\\"':e+=s}return e+="'",e}let r="";for(let e of t)" |&;<>()$`\\\"'*?[#~=%!{}".includes(e)?r+=`\\${e}`:r+=e;return r}function se(t,a){let r=t.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!r)return(0,b.sprintf)(t.replace(/0+(?=\d)/,""),a);let e=r[1]==="-",s=r[2]?parseInt(r[2],10):0,n=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,c=e?-s:s;return A(a,c,n)}function ae(t,a){let r=ne(a),e=t.match(/^%(-?)(\d*)q$/);if(!e)return r;let s=e[1]==="-",n=e[2]?parseInt(e[2],10):0,c=r;return n>c.length&&(s?c=c.padEnd(n," "):c=c.padStart(n," ")),c}function ie(t,a,r){let e=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!e)return(0,b.sprintf)(t,r);let s=e[1]||"",n=e[2]?parseInt(e[2],10):0,c=e[3]!==void 0?e[4]?parseInt(e[4],10):0:6,o,u=a.toLowerCase();if(u==="e"?(o=r.toExponential(c),o=o.replace(/e([+-])(\d)$/,"e$10$2"),a==="E"&&(o=o.toUpperCase())):u==="f"?(o=r.toFixed(c),s.includes("#")&&c===0&&!o.includes(".")&&(o+=".")):u==="g"?(o=r.toPrecision(c||1),s.includes("#")||(o=o.replace(/\.?0+$/,""),o=o.replace(/\.?0+e/,"e")),o=o.replace(/e([+-])(\d)$/,"e$10$2"),a==="G"&&(o=o.toUpperCase())):o=r.toString(),r>=0&&(s.includes("+")?o=`+${o}`:s.includes(" ")&&(o=` ${o}`)),n>o.length)if(s.includes("-"))o=o.padEnd(n," ");else if(s.includes("0")){let l=o.match(/^[+ -]/)?.[0]||"",i=l?o.slice(1):o;o=l+i.padStart(n-l.length,"0")}else o=o.padStart(n," ");return o}function oe(t){let a="",r=0;for(;r<t.length;)if(t[r]==="\\"&&r+1<t.length)switch(t[r+1]){case"n":a+=`
|
|
15
|
+
`,r+=2;break;case"t":a+=" ",r+=2;break;case"r":a+="\r",r+=2;break;case"\\":a+="\\",r+=2;break;case"a":a+="\x07",r+=2;break;case"b":a+="\b",r+=2;break;case"f":a+="\f",r+=2;break;case"v":a+="\v",r+=2;break;case"c":return{value:a,stopped:!0};case"x":{let s=[],n=r;for(;n+1<t.length&&t[n]==="\\"&&t[n+1]==="x";){let c="",o=n+2;for(;o<t.length&&o<n+4&&/[0-9a-fA-F]/.test(t[o]);)c+=t[o],o++;if(c)s.push(parseInt(c,16)),n=o;else break}s.length>0?(a+=Q(s),r=n):(a+="\\x",r+=2);break}case"u":{let s="",n=r+2;for(;n<t.length&&n<r+6&&/[0-9a-fA-F]/.test(t[n]);)s+=t[n],n++;s?(a+=String.fromCodePoint(parseInt(s,16)),r=n):(a+="\\u",r+=2);break}case"0":{let s="",n=r+2;for(;n<t.length&&n<r+5&&/[0-7]/.test(t[n]);)s+=t[n],n++;s?a+=String.fromCharCode(parseInt(s,8)):a+="\0",r=n;break}case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",n=r+1;for(;n<t.length&&n<r+4&&/[0-7]/.test(t[n]);)s+=t[n],n++;a+=String.fromCharCode(parseInt(s,8)),r=n;break}default:a+=t[r],r++}else a+=t[r],r++;return{value:a,stopped:!1}}export{he as printfCommand};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import"./chunk-KGOUQS5A.js";var f={name:"pwd",async execute(r,t){let s=!1;for(let e of r)if(e==="-P")s=!0;else if(e==="-L")s=!1;else{if(e==="--")break;e.startsWith("-")}let a=t.cwd;if(s)try{a=await t.fs.realpath(t.cwd)}catch{}return{stdout:`${a}
|
|
3
|
+
`,stderr:"",exitCode:0}}};export{f as pwdCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as E,b as A,c as z}from"./chunk-
|
|
2
|
+
import{a as E,b as A,c as z}from"./chunk-IRUD2E3M.js";import{a as L,b as _,c as j}from"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var B={js:{extensions:[".js",".mjs",".cjs",".jsx"],globs:[]},ts:{extensions:[".ts",".tsx",".mts",".cts"],globs:[]},html:{extensions:[".html",".htm",".xhtml"],globs:[]},css:{extensions:[".css",".scss",".sass",".less"],globs:[]},json:{extensions:[".json",".jsonc",".json5"],globs:[]},xml:{extensions:[".xml",".xsl",".xslt"],globs:[]},c:{extensions:[".c",".h"],globs:[]},cpp:{extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx",".h"],globs:[]},rust:{extensions:[".rs"],globs:[]},go:{extensions:[".go"],globs:[]},zig:{extensions:[".zig"],globs:[]},java:{extensions:[".java"],globs:[]},kotlin:{extensions:[".kt",".kts"],globs:[]},scala:{extensions:[".scala",".sc"],globs:[]},clojure:{extensions:[".clj",".cljc",".cljs",".edn"],globs:[]},py:{extensions:[".py",".pyi",".pyw"],globs:[]},rb:{extensions:[".rb",".rake",".gemspec"],globs:["Rakefile","Gemfile"]},php:{extensions:[".php",".phtml",".php3",".php4",".php5"],globs:[]},perl:{extensions:[".pl",".pm",".pod",".t"],globs:[]},lua:{extensions:[".lua"],globs:[]},sh:{extensions:[".sh",".bash",".zsh",".fish"],globs:[".bashrc",".zshrc",".profile"]},bat:{extensions:[".bat",".cmd"],globs:[]},ps:{extensions:[".ps1",".psm1",".psd1"],globs:[]},yaml:{extensions:[".yaml",".yml"],globs:[]},toml:{extensions:[".toml"],globs:["Cargo.toml","pyproject.toml"]},ini:{extensions:[".ini",".cfg",".conf"],globs:[]},csv:{extensions:[".csv",".tsv"],globs:[]},md:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},markdown:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},rst:{extensions:[".rst"],globs:[]},txt:{extensions:[".txt",".text"],globs:[]},tex:{extensions:[".tex",".ltx",".sty",".cls"],globs:[]},sql:{extensions:[".sql"],globs:[]},graphql:{extensions:[".graphql",".gql"],globs:[]},proto:{extensions:[".proto"],globs:[]},make:{extensions:[".mk",".mak"],globs:["Makefile","GNUmakefile","makefile"]},docker:{extensions:[],globs:["Dockerfile","Dockerfile.*","*.dockerfile"]},tf:{extensions:[".tf",".tfvars"],globs:[]}},$=class{types;constructor(){this.types=new Map(Object.entries(B).map(([t,n])=>[t,{extensions:[...n.extensions],globs:[...n.globs]}]))}addType(t){let n=t.indexOf(":");if(n===-1)return;let s=t.slice(0,n),r=t.slice(n+1);if(r.startsWith("include:")){let l=r.slice(8),i=this.types.get(l);if(i){let o=this.types.get(s)||{extensions:[],globs:[]};o.extensions.push(...i.extensions),o.globs.push(...i.globs),this.types.set(s,o)}}else{let l=this.types.get(s)||{extensions:[],globs:[]};if(r.startsWith("*.")&&!r.slice(2).includes("*")){let i=r.slice(1);l.extensions.includes(i)||l.extensions.push(i)}else l.globs.includes(r)||l.globs.push(r);this.types.set(s,l)}}clearType(t){let n=this.types.get(t);n&&(n.extensions=[],n.globs=[])}getType(t){return this.types.get(t)}getAllTypes(){return this.types}matchesType(t,n){let s=t.toLowerCase();for(let r of n){if(r==="all"){if(this.matchesAnyType(t))return!0;continue}let l=this.types.get(r);if(l){for(let i of l.extensions)if(s.endsWith(i))return!0;for(let i of l.globs)if(i.includes("*")){let o=i.replace(/\./g,"\\.").replace(/\*/g,".*");if(new RegExp(`^${o}$`,"i").test(t))return!0}else if(s===i.toLowerCase())return!0}}return!1}matchesAnyType(t){let n=t.toLowerCase();for(let s of this.types.values()){for(let r of s.extensions)if(n.endsWith(r))return!0;for(let r of s.globs)if(r.includes("*")){let l=r.replace(/\./g,"\\.").replace(/\*/g,".*");if(new RegExp(`^${l}$`,"i").test(t))return!0}else if(n===r.toLowerCase())return!0}return!1}};function G(){let e=[];for(let[t,n]of Object.entries(B).sort()){let s=[];for(let r of n.extensions)s.push(`*${r}`);for(let r of n.globs)s.push(r);e.push(`${t}: ${s.join(", ")}`)}return`${e.join(`
|
|
3
3
|
`)}
|
|
4
4
|
`}function U(){return{ignoreCase:!1,caseSensitive:!1,smartCase:!0,fixedStrings:!1,wordRegexp:!1,lineRegexp:!1,invertMatch:!1,multiline:!1,multilineDotall:!1,patterns:[],patternFiles:[],count:!1,countMatches:!1,files:!1,filesWithMatches:!1,filesWithoutMatch:!1,stats:!1,onlyMatching:!1,maxCount:0,lineNumber:!0,noFilename:!1,withFilename:!1,nullSeparator:!1,byteOffset:!1,column:!1,vimgrep:!1,replace:null,afterContext:0,beforeContext:0,contextSeparator:"--",quiet:!1,heading:!1,passthru:!1,includeZero:!1,sort:"path",json:!1,globs:[],iglobs:[],globCaseInsensitive:!1,types:[],typesNot:[],typeAdd:[],typeClear:[],hidden:!1,noIgnore:!1,noIgnoreDot:!1,noIgnoreVcs:!1,ignoreFiles:[],maxDepth:1/0,maxFilesize:0,followSymlinks:!1,searchZip:!1,searchBinary:!1,preprocessor:null,preprocessorGlobs:[]}}function X(e){let t=e.match(/^(\d+)([KMG])?$/i);if(!t)return 0;let n=parseInt(t[1],10);switch((t[2]||"").toUpperCase()){case"K":return n*1024;case"M":return n*1024*1024;case"G":return n*1024*1024*1024;default:return n}}function Q(e){return/^\d+[KMG]?$/i.test(e)?null:{stdout:"",stderr:`rg: invalid --max-filesize value: ${e}
|
|
5
5
|
`,exitCode:1}}function q(e){return null}var V=[{short:"g",long:"glob",target:"globs",multi:!0},{long:"iglob",target:"iglobs",multi:!0},{short:"t",long:"type",target:"types",multi:!0,validate:q},{short:"T",long:"type-not",target:"typesNot",multi:!0,validate:q},{long:"type-add",target:"typeAdd",multi:!0},{long:"type-clear",target:"typeClear",multi:!0},{short:"m",long:"max-count",target:"maxCount",parse:parseInt},{short:"e",long:"regexp",target:"patterns",multi:!0},{short:"f",long:"file",target:"patternFiles",multi:!0},{short:"r",long:"replace",target:"replace"},{short:"d",long:"max-depth",target:"maxDepth",parse:parseInt},{long:"max-filesize",target:"maxFilesize",parse:X,validate:Q},{long:"context-separator",target:"contextSeparator"},{short:"j",long:"threads",target:"maxDepth",parse:()=>1/0},{long:"ignore-file",target:"ignoreFiles",multi:!0},{long:"pre",target:"preprocessor"},{long:"pre-glob",target:"preprocessorGlobs",multi:!0}],ee={i:e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1},"--ignore-case":e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1},s:e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1},"--case-sensitive":e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1},S:e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1},"--smart-case":e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1},F:e=>{e.fixedStrings=!0},"--fixed-strings":e=>{e.fixedStrings=!0},w:e=>{e.wordRegexp=!0},"--word-regexp":e=>{e.wordRegexp=!0},x:e=>{e.lineRegexp=!0},"--line-regexp":e=>{e.lineRegexp=!0},v:e=>{e.invertMatch=!0},"--invert-match":e=>{e.invertMatch=!0},U:e=>{e.multiline=!0},"--multiline":e=>{e.multiline=!0},"--multiline-dotall":e=>{e.multilineDotall=!0,e.multiline=!0},c:e=>{e.count=!0},"--count":e=>{e.count=!0},"--count-matches":e=>{e.countMatches=!0},l:e=>{e.filesWithMatches=!0},"--files":e=>{e.files=!0},"--files-with-matches":e=>{e.filesWithMatches=!0},"--files-without-match":e=>{e.filesWithoutMatch=!0},"--stats":e=>{e.stats=!0},o:e=>{e.onlyMatching=!0},"--only-matching":e=>{e.onlyMatching=!0},q:e=>{e.quiet=!0},"--quiet":e=>{e.quiet=!0},N:e=>{e.lineNumber=!1},"--no-line-number":e=>{e.lineNumber=!1},H:e=>{e.withFilename=!0},"--with-filename":e=>{e.withFilename=!0},I:e=>{e.noFilename=!0},"--no-filename":e=>{e.noFilename=!0},0:e=>{e.nullSeparator=!0},"--null":e=>{e.nullSeparator=!0},b:e=>{e.byteOffset=!0},"--byte-offset":e=>{e.byteOffset=!0},"--column":e=>{e.column=!0,e.lineNumber=!0},"--no-column":e=>{e.column=!1},"--vimgrep":e=>{e.vimgrep=!0,e.column=!0,e.lineNumber=!0},"--json":e=>{e.json=!0},"--hidden":e=>{e.hidden=!0},"--no-ignore":e=>{e.noIgnore=!0},"--no-ignore-dot":e=>{e.noIgnoreDot=!0},"--no-ignore-vcs":e=>{e.noIgnoreVcs=!0},L:e=>{e.followSymlinks=!0},"--follow":e=>{e.followSymlinks=!0},z:e=>{e.searchZip=!0},"--search-zip":e=>{e.searchZip=!0},a:e=>{e.searchBinary=!0},"--text":e=>{e.searchBinary=!0},"--heading":e=>{e.heading=!0},"--passthru":e=>{e.passthru=!0},"--include-zero":e=>{e.includeZero=!0},"--glob-case-insensitive":e=>{e.globCaseInsensitive=!0}},te=new Set(["n","--line-number"]);function se(e){e.hidden?e.searchBinary=!0:e.noIgnore?e.hidden=!0:e.noIgnore=!0}function ne(e,t,n){let s=e[t];for(let r of V){if(s.startsWith(`--${r.long}=`)){let l=s.slice(`--${r.long}=`.length),i=D(n,r,l);return i?{newIndex:t,error:i}:{newIndex:t}}if(r.short&&s.startsWith(`-${r.short}`)&&s.length>2){let l=s.slice(2),i=D(n,r,l);return i?{newIndex:t,error:i}:{newIndex:t}}if(r.short&&s===`-${r.short}`||s===`--${r.long}`){if(t+1>=e.length)return null;let l=e[t+1],i=D(n,r,l);return i?{newIndex:t+1,error:i}:{newIndex:t+1}}}return null}function re(e){return V.find(t=>t.short===e)}function D(e,t,n){if(t.validate){let r=t.validate(n);if(r)return r}let s=t.parse?t.parse(n):n;t.multi?e[t.target].push(s):e[t.target]=s}function ie(e,t){let n=e[t];if(n==="--sort"&&t+1<e.length){let s=e[t+1];if(s==="path"||s==="none")return{value:s,newIndex:t+1}}if(n.startsWith("--sort=")){let s=n.slice(7);if(s==="path"||s==="none")return{value:s,newIndex:t}}return null}function le(e,t){let n=e[t],s=n.match(/^-([ABC])(\d+)$/);return s?{flag:s[1],value:parseInt(s[2],10),newIndex:t}:(n==="-A"||n==="-B"||n==="-C")&&t+1<e.length?{flag:n[1],value:parseInt(e[t+1],10),newIndex:t+1}:null}function oe(e){let t=e.match(/^-m(\d+)$/);return t?parseInt(t[1],10):null}function Z(e){let t=U(),n=null,s=[],r=-1,l=-1,i=-1,o=!1;for(let c=0;c<e.length;c++){let a=e[c];if(a.startsWith("-")&&a!=="-"){let u=le(e,c);if(u){let{flag:f,value:x,newIndex:b}=u;f==="A"?r=Math.max(r,x):f==="B"?l=Math.max(l,x):i=x,c=b;continue}let m=oe(a);if(m!==null){t.maxCount=m;continue}let p=ne(e,c,t);if(p){if(p.error)return{success:!1,error:p.error};c=p.newIndex;continue}let g=ie(e,c);if(g){t.sort=g.value,c=g.newIndex;continue}let w=a.startsWith("--")?[a]:a.slice(1).split(""),d=!1;for(let f of w){if(te.has(f)){t.lineNumber=!0,o=!0;continue}if(f==="u"||f==="--unrestricted"){se(t);continue}if(f==="P"||f==="--pcre2")return{success:!1,error:{stdout:"",stderr:`rg: PCRE2 is not supported. Use standard regex syntax instead.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as p}from"./chunk-TA7RUHGQ.js";import{a as g}from"./chunk-4VDEBYW7.js";import"./chunk-GTNBSMZR.js";import"./chunk-KGOUQS5A.js";var x=`Usage: rmdir [-pv] DIRECTORY...
|
|
3
|
+
Remove empty directories.
|
|
4
|
+
|
|
5
|
+
Options:
|
|
6
|
+
-p, --parents Remove DIRECTORY and its ancestors
|
|
7
|
+
-v, --verbose Output a diagnostic for every directory processed`,y={parents:{short:"p",long:"parents",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"},help:{long:"help",type:"boolean"}},D={name:"rmdir",async execute(t,r){let e=p("rmdir",t,y);if(!e.ok)return e.error;if(e.result.flags.help)return{stdout:`${x}
|
|
8
|
+
`,stderr:"",exitCode:0};let a=e.result.flags.parents,o=e.result.flags.verbose,s=e.result.positional;if(s.length===0)return{stdout:"",stderr:`rmdir: missing operand
|
|
9
|
+
`,exitCode:1};let f="",n="",i=0;for(let u of s){let d=await b(r,u,a,o);f+=d.stdout,n+=d.stderr,d.exitCode!==0&&(i=d.exitCode)}return{stdout:f,stderr:n,exitCode:i}}};async function b(t,r,e,a){let o="",s="",n=t.fs.resolvePath(t.cwd,r),i=await v(t,n,r,a);if(o+=i.stdout,s+=i.stderr,i.exitCode!==0)return{stdout:o,stderr:s,exitCode:i.exitCode};if(e){let u=n,d=r;for(;;){let c=C(u),l=C(d);if(c===u||c==="/"||c==="."||l==="."||l==="")break;let m=await v(t,c,l,a);if(o+=m.stdout,m.exitCode!==0)break;u=c,d=l}}return{stdout:o,stderr:s,exitCode:0}}async function v(t,r,e,a){try{if(!await t.fs.exists(r))return{stdout:"",stderr:`rmdir: failed to remove '${e}': No such file or directory
|
|
10
|
+
`,exitCode:1};if(!(await t.fs.stat(r)).isDirectory)return{stdout:"",stderr:`rmdir: failed to remove '${e}': Not a directory
|
|
11
|
+
`,exitCode:1};if((await t.fs.readdir(r)).length>0)return{stdout:"",stderr:`rmdir: failed to remove '${e}': Directory not empty
|
|
12
|
+
`,exitCode:1};await t.fs.rm(r,{recursive:!1,force:!1});let n="";return a&&(n=`rmdir: removing directory, '${e}'
|
|
13
|
+
`),{stdout:n,stderr:"",exitCode:0}}catch(o){let s=g(o);return{stdout:"",stderr:`rmdir: failed to remove '${e}': ${s}
|
|
14
|
+
`,exitCode:1}}}function C(t){let r=t.replace(/\/+$/,""),e=r.lastIndexOf("/");return e===-1?".":e===0?"/":r.substring(0,e)}export{D as rmdirCommand};
|