just-bash 3.0.3 → 3.1.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/CHANGELOG.md +26 -0
- package/dist/bin/chunks/{chunk-4J4UC7OD.js → chunk-63LSI3D6.js} +1 -1
- package/dist/bin/chunks/chunk-BKQLXMS6.js +36 -0
- package/dist/bin/{shell/chunks/chunk-J7XTZ47D.js → chunks/chunk-HZR3FOJM.js} +1 -1
- package/dist/bin/chunks/chunk-ISLENKSH.js +7 -0
- package/dist/bin/chunks/{chunk-FJABJBIW.js → chunk-RO3XCUVQ.js} +1 -1
- package/dist/bin/chunks/{flag-coverage-H6NG6ZQL.js → flag-coverage-CAST5CDE.js} +1 -1
- package/dist/bin/chunks/{jq-33GJJXTL.js → jq-3V5HDGLJ.js} +1 -1
- package/dist/bin/{shell/chunks/rg-2YWJS6TE.js → chunks/rg-DZKA632H.js} +1 -1
- package/dist/bin/{shell/chunks/xan-TSDTZVY3.js → chunks/xan-TCTFON2Q.js} +1 -1
- package/dist/bin/{shell/chunks/yq-KU5YTNAK.js → chunks/yq-OB6PB5GY.js} +1 -1
- package/dist/bin/just-bash.js +1 -1
- package/dist/bin/shell/chunks/{chunk-4J4UC7OD.js → chunk-63LSI3D6.js} +1 -1
- package/dist/bin/shell/chunks/chunk-BKQLXMS6.js +36 -0
- package/dist/bin/{chunks/chunk-J7XTZ47D.js → shell/chunks/chunk-HZR3FOJM.js} +1 -1
- package/dist/bin/shell/chunks/chunk-ISLENKSH.js +7 -0
- package/dist/bin/shell/chunks/{chunk-FJABJBIW.js → chunk-RO3XCUVQ.js} +1 -1
- package/dist/bin/shell/chunks/{flag-coverage-H6NG6ZQL.js → flag-coverage-CAST5CDE.js} +1 -1
- package/dist/bin/shell/chunks/{jq-33GJJXTL.js → jq-3V5HDGLJ.js} +1 -1
- package/dist/bin/{chunks/rg-2YWJS6TE.js → shell/chunks/rg-DZKA632H.js} +1 -1
- package/dist/bin/{chunks/xan-TSDTZVY3.js → shell/chunks/xan-TCTFON2Q.js} +1 -1
- package/dist/bin/{chunks/yq-KU5YTNAK.js → shell/chunks/yq-OB6PB5GY.js} +1 -1
- package/dist/bin/shell/shell.js +1 -1
- package/dist/bundle/browser.js +184 -182
- package/dist/bundle/chunks/{chunk-DJ7QC6LC.js → chunk-6Y4TGEZL.js} +1 -1
- package/dist/bundle/chunks/chunk-J3LJZWL2.js +6 -0
- package/dist/bundle/chunks/{chunk-AFQAPVZ3.js → chunk-JA7M2FXG.js} +1 -1
- package/dist/bundle/chunks/chunk-JNYYVLEL.js +35 -0
- package/dist/bundle/chunks/{chunk-EUCNMMRD.js → chunk-QM4DZQWX.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-TRYUZMPS.js → flag-coverage-OHLSWDU5.js} +1 -1
- package/dist/bundle/chunks/{jq-3FAAQVR6.js → jq-OPEF5OPR.js} +1 -1
- package/dist/bundle/chunks/{rg-N5WLPMSA.js → rg-EBMD72T4.js} +1 -1
- package/dist/bundle/chunks/{xan-U6654PZR.js → xan-LKYWG2QQ.js} +1 -1
- package/dist/bundle/chunks/{yq-ZBXLBSXV.js → yq-TVZ7R3O7.js} +1 -1
- package/dist/bundle/index.cjs +274 -272
- package/dist/bundle/index.js +2 -2
- package/dist/sandbox/Sandbox.d.ts +33 -2
- package/package.json +1 -1
- package/dist/bin/chunks/chunk-GXX3QUMM.js +0 -34
- package/dist/bin/chunks/chunk-LMA4D2KK.js +0 -7
- package/dist/bin/shell/chunks/chunk-GXX3QUMM.js +0 -34
- package/dist/bin/shell/chunks/chunk-LMA4D2KK.js +0 -7
- package/dist/bundle/chunks/chunk-LZUPLYFM.js +0 -6
- package/dist/bundle/chunks/chunk-Z3KJQD7F.js +0 -33
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{a as F,b,c as M,d as He,e as w,f as v,g as Y,h as Z}from"./chunk-WKPK7M56.js";import{a as st}from"./chunk-4I3HOE5Z.js";import{a as $}from"./chunk-
|
|
2
|
+
import{a as F,b,c as M,d as He,e as w,f as v,g as Y,h as Z}from"./chunk-WKPK7M56.js";import{a as st}from"./chunk-4I3HOE5Z.js";import{a as $}from"./chunk-J3LJZWL2.js";import{f as qe,g as X}from"./chunk-4WKZNNJK.js";import{a as J}from"./chunk-7CSMHFIJ.js";import{a as _e}from"./chunk-KTPCYKBB.js";import{c as _}from"./chunk-XEKXHOPO.js";import{a as D,b as G}from"./chunk-QAYAQNCG.js";import{b as We,d as et,e as tt,f as nt}from"./chunk-BZUGFHVS.js";var q,Je=We(()=>{"use strict";q=class{input;pos=0;tokens=[];constructor(n){this.input=n}tokenize(){for(;this.pos<this.input.length&&(this.skipWhitespace(),!(this.pos>=this.input.length));){let n=this.nextToken();n&&this.tokens.push(n)}return this.tokens.push({type:"eof",value:"",pos:this.pos}),this.tokens}skipWhitespace(){for(;this.pos<this.input.length;){let n=this.input[this.pos];if(n===" "||n===" "||n===`
|
|
3
3
|
`||n==="\r")this.pos++;else if(n==="#")for(;this.pos<this.input.length&&this.input[this.pos]!==`
|
|
4
4
|
`;)this.pos++;else break}}nextToken(){let n=this.pos,t=this.input[this.pos];if(t>="0"&&t<="9")return this.readNumber();if(t==='"'||t==="'"||t==="`")return this.readString(t);if(t==="b"&&this.pos+1<this.input.length){let o=this.input[this.pos+1];if(o==='"'||o==="'"||o==="`")return this.pos++,this.readString(o)}if(t==="/"){let o=this.tokens[this.tokens.length-1];return o&&(o.type==="int"||o.type==="float"||o.type==="string"||o.type==="ident"||o.type===")"||o.type==="]")?this.input[this.pos+1]==="/"?(this.pos+=2,{type:"//",value:"//",pos:n}):(this.pos++,{type:"/",value:"/",pos:n}):this.readRegex()}if(this.match("not in"))return{type:"not in",value:"not in",pos:n};if(this.match("=>"))return{type:"=>",value:"=>",pos:n};if(this.match("**"))return{type:"**",value:"**",pos:n};if(this.match("++"))return{type:"++",value:"++",pos:n};if(this.match("//"))return{type:"//",value:"//",pos:n};if(this.match("=="))return{type:"==",value:"==",pos:n};if(this.match("!="))return{type:"!=",value:"!=",pos:n};if(this.match("<="))return{type:"<=",value:"<=",pos:n};if(this.match(">="))return{type:">=",value:">=",pos:n};if(this.match("&&"))return{type:"&&",value:"&&",pos:n};if(this.match("||"))return{type:"||",value:"||",pos:n};let r=new Map([["(","("],[")",")"],["[","["],["]","]"],["{","{"],["}","}"],[",",","],[":",":"],[";",";"],["+","+"],["-","-"],["*","*"],["%","%"],["<","<"],[">",">"],["!","!"],[".","."],["|","|"],["=","="]]).get(t);if(r!==void 0)return this.pos++,{type:r,value:t,pos:n};if(this.isIdentStart(t))return this.readIdentifier();throw new Error(`Unexpected character '${t}' at position ${this.pos}`)}match(n){if(this.input.slice(this.pos,this.pos+n.length)===n){if(/^[a-zA-Z]/.test(n)){let t=this.input[this.pos+n.length];if(t&&this.isIdentChar(t))return!1}return this.pos+=n.length,!0}return!1}isIdentStart(n){return n>="a"&&n<="z"||n>="A"&&n<="Z"||n==="_"}isIdentChar(n){return this.isIdentStart(n)||n>="0"&&n<="9"}readNumber(){let n=this.pos,t=!1,s=!1;for(;this.pos<this.input.length;){let o=this.input[this.pos];if(o>="0"&&o<="9")this.pos++;else if(o==="_")this.pos++;else if(o==="."&&!t&&!s)t=!0,this.pos++;else if((o==="e"||o==="E")&&!s)s=!0,t=!0,this.pos++,this.pos<this.input.length&&(this.input[this.pos]==="+"||this.input[this.pos]==="-")&&this.pos++;else break}let r=this.input.slice(n,this.pos).replace(/_/g,"");return{type:t?"float":"int",value:r,pos:n}}readString(n){let t=this.pos;this.pos++;let s="";for(;this.pos<this.input.length;){let r=this.input[this.pos];if(r===n)return this.pos++,{type:"string",value:s,pos:t};if(r==="\\"){if(this.pos++,this.pos<this.input.length){let o=this.input[this.pos];switch(o){case"n":s+=`
|
|
5
5
|
`;break;case"r":s+="\r";break;case"t":s+=" ";break;case"\\":s+="\\";break;case'"':s+='"';break;case"'":s+="'";break;case"`":s+="`";break;case"0":s+="\0";break;default:s+=o}this.pos++}}else s+=r,this.pos++}throw new Error(`Unterminated string starting at position ${t}`)}readRegex(){let n=this.pos;this.pos++;let t="",s="";for(;this.pos<this.input.length;){let r=this.input[this.pos];if(r==="/"){for(this.pos++;this.pos<this.input.length&&this.input[this.pos]==="i";)s+=this.input[this.pos],this.pos++;return{type:"regex",value:t+(s?`/${s}`:""),pos:n}}r==="\\"?(t+=r,this.pos++,this.pos<this.input.length&&(t+=this.input[this.pos],this.pos++)):(t+=r,this.pos++)}throw new Error(`Unterminated regex starting at position ${n}`)}readIdentifier(){let n=this.pos;for(;this.pos<this.input.length&&this.isIdentChar(this.input[this.pos]);)this.pos++;let t=!1;this.pos<this.input.length&&this.input[this.pos]==="?"&&(t=!0,this.pos++);let s=this.input.slice(n,t?this.pos-1:this.pos);t&&(s+="?");let r=new Map([["true","true"],["false","false"],["null","null"],["and","and"],["or","or"],["eq","eq"],["ne","ne"],["lt","lt"],["le","le"],["gt","gt"],["ge","ge"],["in","in"],["as","as"],["_","_"]]),o=s.replace(/\?$/,""),a=r.get(o);return a!==void 0&&!t?{type:a,value:o,pos:n}:{type:"ident",value:s,pos:n}}}});var ze={};et(ze,{parseMoonblade:()=>H,parseNamedExpressions:()=>U});function U(e){let n=[],s=new q(e).tokenize(),r=0,o=()=>s[r]||{type:"eof",value:"",pos:0},a=()=>s[r++];for(;o().type!=="eof";){if(o().type===","&&n.length>0){a();continue}let d=[],u=0,p=r;for(;o().type!=="eof";){let i=o();if((i.type===","||i.type==="as")&&u===0)break;(i.type==="("||i.type==="["||i.type==="{")&&u++,(i.type===")"||i.type==="]"||i.type==="}")&&u--,d.push(a())}d.push({type:"eof",value:"",pos:0});let h=new z(d).parse(),l;if(o().type==="as")if(a(),o().type==="("){a();let i=[];for(;o().type!==")"&&o().type!=="eof";)(o().type==="ident"||o().type==="string")&&(i.push(o().value),a()),o().type===","&&a();o().type===")"&&a(),l=i}else if(o().type==="ident"||o().type==="string")l=o().value,a();else throw new Error(`Expected name after 'as', got ${o().type}`);else l=e.slice(s[p].pos,s[r-1]?.pos||e.length).trim(),h.type==="identifier"&&(l=h.name);n.push({expr:h,name:l})}return n}function H(e){let t=new q(e).tokenize();return new z(t).parse()}var R,z,V=We(()=>{"use strict";Je();R={PIPE:1,OR:2,AND:3,EQUALITY:4,COMPARISON:5,ADDITIVE:6,MULTIPLICATIVE:7,POWER:8,UNARY:9,POSTFIX:10},z=class{pos=0;tokens;constructor(n){this.tokens=n}parse(){let n=this.parseExpr(0);if(this.peek().type!=="eof")throw new Error(`Unexpected token: ${this.peek().value}`);return n}parseExpr(n){let t=this.parsePrefix();for(;;){let s=this.peek(),r=this.getInfixPrec(s.type);if(r<n)break;t=this.parseInfix(t,r)}return t}parsePrefix(){let n=this.peek();switch(n.type){case"int":return this.advance(),{type:"int",value:Number.parseInt(n.value,10)};case"float":return this.advance(),{type:"float",value:Number.parseFloat(n.value)};case"string":return this.advance(),{type:"string",value:n.value};case"regex":{this.advance();let t=n.value.split("/"),s=t.length>1?t[t.length-1]:"";return{type:"regex",pattern:t.slice(0,-1).join("/")||n.value,caseInsensitive:s.includes("i")}}case"true":return this.advance(),{type:"bool",value:!0};case"false":return this.advance(),{type:"bool",value:!1};case"null":return this.advance(),{type:"null"};case"_":return this.advance(),{type:"underscore"};case"ident":{let t=n.value,s=t.endsWith("?"),r=s?t.slice(0,-1):t;if(this.advance(),this.peek().type==="(")return this.parseFunctionCall(r);if(this.peek().type==="=>"){this.advance();let o=this.parseExpr(0);return this.bindLambdaArgs({type:"lambda",params:[r],body:o},[r])}return{type:"identifier",name:r,unsure:s}}case"(":{this.advance();let t=this.pos;if(this.peek().type===")"){if(this.advance(),this.peek().type==="=>"){this.advance();let r=this.parseExpr(0);return{type:"lambda",params:[],body:r}}throw new Error("Empty parentheses not allowed")}if(this.peek().type==="ident"){let r=[this.peek().value];this.advance();let o=!0;for(;this.peek().type===",";)if(this.advance(),this.peek().type==="ident")r.push(this.peek().value),this.advance();else{o=!1;break}if(o&&this.peek().type===")"&&this.peekAt(1).type==="=>"){this.advance(),this.advance();let a=this.parseExpr(0);return this.bindLambdaArgs({type:"lambda",params:r,body:a},r)}this.pos=t}let s=this.parseExpr(0);return this.expect(")"),s}case"[":return this.parseList();case"{":return this.parseMap();case"-":{this.advance();let t=this.parseExpr(R.UNARY);return t.type==="int"?{type:"int",value:-t.value}:t.type==="float"?{type:"float",value:-t.value}:{type:"func",name:"neg",args:[{expr:t}]}}case"!":return this.advance(),{type:"func",name:"not",args:[{expr:this.parseExpr(R.UNARY)}]};default:throw new Error(`Unexpected token: ${n.type} (${n.value})`)}}parseFunctionCall(n){this.expect("(");let t=[];if(this.peek().type!==")")do{t.length>0&&this.peek().type===","&&this.advance();let s;if(this.peek().type==="ident"){let o=this.peek().value,a=this.pos+1;a<this.tokens.length&&this.tokens[a].type==="="&&(s=o,this.advance(),this.advance())}let r=this.parseExpr(0);t.push({name:s,expr:r})}while(this.peek().type===",");return this.expect(")"),{type:"func",name:n.toLowerCase(),args:t}}parseList(){this.expect("[");let n=[];if(this.peek().type!=="]")do n.length>0&&this.peek().type===","&&this.advance(),n.push(this.parseExpr(0));while(this.peek().type===",");return this.expect("]"),{type:"list",elements:n}}parseMap(){this.expect("{");let n=[];if(this.peek().type!=="}")do{n.length>0&&this.peek().type===","&&this.advance();let t;if(this.peek().type==="ident")t=this.peek().value,this.advance();else if(this.peek().type==="string")t=this.peek().value,this.advance();else throw new Error(`Expected map key, got ${this.peek().type}`);this.expect(":");let s=this.parseExpr(0);n.push({key:t,value:s})}while(this.peek().type===",");return this.expect("}"),{type:"map",entries:n}}parseInfix(n,t){let s=this.peek(),o=new Map([["+","add"],["-","sub"],["*","mul"],["/","div"],["//","idiv"],["%","mod"],["**","pow"],["++","concat"],["==","=="],["!=","!="],["<","<"],["<=","<="],[">",">"],[">=",">="],["eq","eq"],["ne","ne"],["lt","lt"],["le","le"],["gt","gt"],["ge","ge"],["&&","and"],["and","and"],["||","or"],["or","or"]]).get(s.type);if(o!==void 0){this.advance();let a=this.parseExpr(t+(this.isRightAssoc(s.type)?0:1));return{type:"func",name:o,args:[{expr:n},{expr:a}]}}if(s.type==="|"){this.advance();let a=this.parseExpr(t);return this.handlePipe(n,a)}if(s.type===".")return this.advance(),this.handleDot(n);if(s.type==="[")return this.advance(),this.handleIndexing(n);if(s.type==="in")return this.advance(),{type:"func",name:"contains",args:[{expr:this.parseExpr(t+1)},{expr:n}]};if(s.type==="not in")return this.advance(),{type:"func",name:"not",args:[{expr:{type:"func",name:"contains",args:[{expr:this.parseExpr(t+1)},{expr:n}]}}]};throw new Error(`Unexpected infix token: ${s.type}`)}handlePipe(n,t){if(t.type==="identifier")return{type:"func",name:t.name,args:[{expr:n}]};if(t.type==="func"){let s=this.countUnderscores(t);return s===0?t:s===1?this.fillUnderscore(t,n):{type:"pipeline",exprs:[n,t]}}return this.countUnderscores(t)===1?this.fillUnderscore(t,n):t}handleDot(n){let t=this.peek();if(t.type==="ident"){let s=t.value;if(this.advance(),this.peek().type==="("){let r=this.parseFunctionCall(s);return r.type==="func"&&r.args.unshift({expr:n}),r}return{type:"func",name:"get",args:[{expr:n},{expr:{type:"string",value:s}}]}}if(t.type==="int"){let s=Number.parseInt(t.value,10);return this.advance(),{type:"func",name:"get",args:[{expr:n},{expr:{type:"int",value:s}}]}}if(t.type==="string"){let s=t.value;return this.advance(),{type:"func",name:"get",args:[{expr:n},{expr:{type:"string",value:s}}]}}throw new Error(`Expected identifier, number, or string after dot, got ${t.type}`)}handleIndexing(n){if(this.peek().type===":"){if(this.advance(),this.peek().type==="]")return this.advance(),{type:"func",name:"slice",args:[{expr:n}]};let s=this.parseExpr(0);return this.expect("]"),{type:"func",name:"slice",args:[{expr:n},{expr:{type:"int",value:0}},{expr:s}]}}let t=this.parseExpr(0);if(this.peek().type===":"){if(this.advance(),this.peek().type==="]")return this.advance(),{type:"func",name:"slice",args:[{expr:n},{expr:t}]};let s=this.parseExpr(0);return this.expect("]"),{type:"func",name:"slice",args:[{expr:n},{expr:t},{expr:s}]}}return this.expect("]"),{type:"func",name:"get",args:[{expr:n},{expr:t}]}}countUnderscores(n){return n.type==="underscore"?1:n.type==="func"?n.args.reduce((t,s)=>t+this.countUnderscores(s.expr),0):n.type==="list"?n.elements.reduce((t,s)=>t+this.countUnderscores(s),0):n.type==="map"?n.entries.reduce((t,s)=>t+this.countUnderscores(s.value),0):0}fillUnderscore(n,t){return n.type==="underscore"?t:n.type==="func"?{...n,args:n.args.map(s=>({...s,expr:this.fillUnderscore(s.expr,t)}))}:n.type==="list"?{...n,elements:n.elements.map(s=>this.fillUnderscore(s,t))}:n.type==="map"?{...n,entries:n.entries.map(s=>({...s,value:this.fillUnderscore(s.value,t)}))}:n}bindLambdaArgs(n,t){return{...n,body:this.bindLambdaArgsInExpr(n.body,t)}}bindLambdaArgsInExpr(n,t){return n.type==="identifier"&&t.includes(n.name)?{type:"lambdaBinding",name:n.name}:n.type==="func"?{...n,args:n.args.map(s=>({...s,expr:this.bindLambdaArgsInExpr(s.expr,t)}))}:n.type==="list"?{...n,elements:n.elements.map(s=>this.bindLambdaArgsInExpr(s,t))}:n.type==="map"?{...n,entries:n.entries.map(s=>({...s,value:this.bindLambdaArgsInExpr(s.value,t)}))}:n}getInfixPrec(n){switch(n){case"|":return R.PIPE;case"||":case"or":return R.OR;case"&&":case"and":return R.AND;case"==":case"!=":case"eq":case"ne":return R.EQUALITY;case"<":case"<=":case">":case">=":case"lt":case"le":case"gt":case"ge":case"in":case"not in":return R.COMPARISON;case"+":case"-":case"++":return R.ADDITIVE;case"*":case"/":case"//":case"%":return R.MULTIPLICATIVE;case"**":return R.POWER;case".":case"[":return R.POSTFIX;default:return-1}}isRightAssoc(n){return n==="**"}peek(){return this.tokens[this.pos]||{type:"eof",value:"",pos:0}}peekAt(n){return this.tokens[this.pos+n]||{type:"eof",value:"",pos:0}}advance(){return this.tokens[this.pos++]}expect(n){let t=this.peek();if(t.type!==n)throw new Error(`Expected ${n}, got ${t.type}`);return this.advance()}}});V();function E(e,n){return n.length===0?I(e,[]):n.length===1?{type:"Pipe",left:n[0],right:I(e,[])}:{type:"Pipe",left:n[0],right:I(e,n.slice(1))}}var K={add:e=>S("+",e[0],e[1]),sub:e=>S("-",e[0],e[1]),mul:e=>S("*",e[0],e[1]),div:e=>S("/",e[0],e[1]),mod:e=>S("%",e[0],e[1]),idiv:e=>I("floor",[S("/",e[0],e[1])]),pow:e=>E("pow",e),neg:e=>({type:"UnaryOp",op:"-",operand:e[0]}),"==":e=>S("==",e[0],e[1]),"!=":e=>S("!=",e[0],e[1]),"<":e=>S("<",e[0],e[1]),"<=":e=>S("<=",e[0],e[1]),">":e=>S(">",e[0],e[1]),">=":e=>S(">=",e[0],e[1]),eq:e=>S("==",P(e[0]),P(e[1])),ne:e=>S("!=",P(e[0]),P(e[1])),lt:e=>S("<",P(e[0]),P(e[1])),le:e=>S("<=",P(e[0]),P(e[1])),gt:e=>S(">",P(e[0]),P(e[1])),ge:e=>S(">=",P(e[0]),P(e[1])),and:e=>S("and",e[0],e[1]),or:e=>S("or",e[0],e[1]),not:e=>({type:"UnaryOp",op:"not",operand:e[0]}),len:e=>E("length",e),length:e=>E("length",e),upper:e=>E("ascii_upcase",e),lower:e=>E("ascii_downcase",e),trim:e=>E("trim",e),ltrim:e=>e.length===0?I("ltrimstr",[{type:"Literal",value:" "}]):{type:"Pipe",left:e[0],right:I("ltrimstr",[{type:"Literal",value:" "}])},rtrim:e=>e.length===0?I("rtrimstr",[{type:"Literal",value:" "}]):{type:"Pipe",left:e[0],right:I("rtrimstr",[{type:"Literal",value:" "}])},split:e=>E("split",e),join:e=>e.length===1?I("join",[{type:"Literal",value:""}]):E("join",e),concat:e=>S("+",e[0],e[1]),startswith:e=>E("startswith",e),endswith:e=>E("endswith",e),contains:e=>E("contains",e),replace:e=>E("gsub",e),substr:e=>e.length===2?{type:"Slice",base:e[0],start:e[1]}:{type:"Slice",base:e[0],start:e[1],end:S("+",e[1],e[2])},abs:e=>E("fabs",e),floor:e=>E("floor",e),ceil:e=>E("ceil",e),round:e=>E("round",e),sqrt:e=>E("sqrt",e),log:e=>E("log",e),log10:e=>E("log10",e),log2:e=>E("log2",e),exp:e=>E("exp",e),sin:e=>E("sin",e),cos:e=>E("cos",e),tan:e=>E("tan",e),asin:e=>E("asin",e),acos:e=>E("acos",e),atan:e=>E("atan",e),min:e=>E("min",e),max:e=>E("max",e),first:e=>e.length===0?{type:"Index",index:{type:"Literal",value:0}}:{type:"Index",index:{type:"Literal",value:0},base:e[0]},last:e=>e.length===0?{type:"Index",index:{type:"Literal",value:-1}}:{type:"Index",index:{type:"Literal",value:-1},base:e[0]},get:e=>e.length===1?{type:"Index",index:e[0]}:{type:"Index",index:e[1],base:e[0]},slice:e=>e.length===1?{type:"Slice",base:e[0]}:e.length===2?{type:"Slice",base:e[0],start:e[1]}:{type:"Slice",base:e[0],start:e[1],end:e[2]},keys:"keys",values:"values",entries:e=>I("to_entries",e),from_entries:"from_entries",reverse:"reverse",sort:"sort",sort_by:"sort_by",group_by:"group_by",unique:"unique",unique_by:"unique_by",flatten:"flatten",map:e=>({type:"Pipe",left:e[0],right:{type:"Array",elements:e[1]}}),select:e=>I("select",e),empty:()=>I("empty",[]),count:()=>I("length",[]),sum:e=>e.length===0?I("add",[]):{type:"Pipe",left:{type:"Array",elements:e[0]},right:I("add",[])},mean:e=>e.length===0?{type:"Pipe",left:{type:"Identity"},right:S("/",I("add",[]),I("length",[]))}:{type:"Pipe",left:{type:"Array",elements:e[0]},right:S("/",I("add",[]),I("length",[]))},avg:e=>e.length===0?{type:"Pipe",left:{type:"Identity"},right:S("/",I("add",[]),I("length",[]))}:{type:"Pipe",left:{type:"Array",elements:e[0]},right:S("/",I("add",[]),I("length",[]))},type:"type",isnull:e=>e.length===0?S("==",{type:"Identity"},{type:"Literal",value:null}):S("==",e[0],{type:"Literal",value:null}),isempty:e=>e.length===0?S("==",{type:"Identity"},{type:"Literal",value:""}):S("==",e[0],{type:"Literal",value:""}),tonumber:e=>e.length===0?I("tonumber",[]):I("tonumber",e),tostring:e=>e.length===0?I("tostring",[]):I("tostring",e),if:e=>Ke(e[0],e[1],e[2]),coalesce:e=>{if(e.length===0)return{type:"Literal",value:null};if(e.length===1)return e[0];let[n,...t]=e,s=S("and",S("!=",n,{type:"Literal",value:null}),S("!=",n,{type:"Literal",value:""}));return Ke(s,n,t.length===1?t[0]:K.coalesce(t))},index:()=>({type:"Field",name:"_row_index"}),now:()=>I("now",[]),fmt:e=>I("tostring",e),format:e=>I("tostring",e)};Object.setPrototypeOf(K,null);function S(e,n,t){return{type:"BinaryOp",op:e,left:n,right:t}}function I(e,n){return{type:"Call",name:e,args:n}}var rt="then";function Ke(e,n,t){let s=qe({type:"Cond",cond:e,elifs:[],else:t||{type:"Literal",value:null}});return s[rt]=n,s}function P(e){return{type:"Pipe",left:e,right:{type:"Call",name:"tostring",args:[]}}}function O(e,n=!0){switch(e.type){case"int":case"float":return{type:"Literal",value:e.value};case"string":return{type:"Literal",value:e.value};case"bool":return{type:"Literal",value:e.value};case"null":return{type:"Literal",value:null};case"underscore":return{type:"Index",base:{type:"Identity"},index:{type:"Literal",value:"_"}};case"identifier":return n?{type:"Field",name:e.name}:{type:"VarRef",name:e.name};case"lambdaBinding":return{type:"VarRef",name:e.name};case"func":{let t=e.args.map(r=>O(r.expr,n)),s=Object.hasOwn(K,e.name)?K[e.name]:void 0;return typeof s=="function"?s(t):I(typeof s=="string"?s:e.name,t)}case"list":return e.elements.length===0?{type:"Array"}:{type:"Array",elements:e.elements.reduce((t,s,r)=>{let o=O(s,n);return r===0?o:{type:"Comma",left:t,right:o}},null)};case"map":return{type:"Object",entries:e.entries.map(t=>({key:t.key,value:O(t.value,n)}))};case"regex":return{type:"Literal",value:e.pattern};case"slice":return{type:"Slice",start:e.start?O(e.start,n):void 0,end:e.end?O(e.end,n):void 0};case"lambda":return O(e.body,n);case"pipeline":return{type:"Identity"};default:throw new Error(`Unknown moonblade expression type: ${e.type}`)}}function ee(e){let n=[],t=0;for(;t<e.length;){for(;t<e.length&&(e[t]===" "||e[t]===",");)t++;if(t>=e.length)break;let s=t;for(;t<e.length&&/\w/.test(e[t]);)t++;let r=e.slice(s,t);for(;t<e.length&&e[t]===" ";)t++;if(e[t]!=="(")break;t++;let o=1,a=t;for(;t<e.length&&o>0;)e[t]==="("?o++:e[t]===")"&&o--,o>0&&t++;let d=e.slice(a,t).trim();for(t++;t<e.length&&e[t]===" ";)t++;let u="";if(e.slice(t,t+3).toLowerCase()==="as "){for(t+=3;t<e.length&&e[t]===" ";)t++;let p=t;for(;t<e.length&&/\w/.test(e[t]);)t++;u=e.slice(p,t)}u||(u=d?`${r}(${d})`:`${r}()`),n.push({func:r,expr:d,alias:u})}return n}function Be(e){return/^\w+$/.test(e)}function Q(e,n,t){let s=O(H(n)),r=$(e,s,t);return r.length>0?r[0]:null}function te(e,n,t={}){let{func:s,expr:r}=n;if(s==="count"&&!r)return e.length;let o;switch(Be(r)?o=e.map(a=>a[r]).filter(a=>a!=null):o=e.map(a=>Q(a,r,t)).filter(a=>a!=null),s){case"count":return Be(r)?o.length:o.filter(a=>!!a).length;case"sum":return o.map(d=>typeof d=="number"?d:Number.parseFloat(String(d))).reduce((d,u)=>d+u,0);case"mean":case"avg":{let a=o.map(d=>typeof d=="number"?d:Number.parseFloat(String(d)));return a.length>0?a.reduce((d,u)=>d+u,0)/a.length:0}case"min":{let a=o.map(d=>typeof d=="number"?d:Number.parseFloat(String(d)));return a.length>0?Math.min(...a):null}case"max":{let a=o.map(d=>typeof d=="number"?d:Number.parseFloat(String(d)));return a.length>0?Math.max(...a):null}case"first":return o.length>0?o[0]:null;case"last":return o.length>0?o[o.length-1]:null;case"median":{let a=o.map(u=>typeof u=="number"?u:Number.parseFloat(String(u))).filter(u=>!Number.isNaN(u)).sort((u,p)=>u-p);if(a.length===0)return null;let d=Math.floor(a.length/2);return a.length%2===0?(a[d-1]+a[d])/2:a[d]}case"mode":{let a=new Map;for(let p of o){let c=String(p);a.set(c,(a.get(c)||0)+1)}let d=0,u=null;for(let[p,c]of a)c>d&&(d=c,u=p);return u}case"cardinality":return new Set(o.map(d=>String(d))).size;case"values":return o.map(a=>String(a)).join("|");case"distinct_values":return[...new Set(o.map(d=>String(d)))].sort().join("|");case"all":{if(e.length===0)return!0;for(let a of e)if(!Q(a,r,t))return!1;return!0}case"any":{for(let a of e)if(Q(a,r,t))return!0;return!1}default:return null}}function Ge(e,n,t={}){let s=F();for(let r of n)b(s,r.alias,te(e,r,t));return s}async function ne(e,n){let t="",s=[];for(let c of e)c.startsWith("-")||(t?s.push(c):t=c);if(!t)return{stdout:"",stderr:`xan agg: no aggregation expression
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
+
import{a as g,b as A,c as T,d as at,e as E,g as O,h as G}from"./chunk-4WKZNNJK.js";import{a as X,c as lt}from"./chunk-DLL7UR66.js";import{a as yt}from"./chunk-KAPG5ONA.js";import{a as R}from"./chunk-7CSMHFIJ.js";import{k as B}from"./chunk-SAI2SPQQ.js";function W(t,r,e,n,c,o,u,p,s,f){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,a)=>{let y=c(h,e[0],n)[0],l=c(a,e[0],n)[0];return u(y,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]:c(t,e[0],n).map(h=>{let a=0,y=t.length;for(;a<y;){let l=a+y>>>1;u(t[l],h)<0?a=l+1:y=l}return a<t.length&&u(t[a],h)===0?a:-a-1})}case"unique_by":{if(!Array.isArray(t)||e.length===0)return[null];let i=new Map;for(let a of t){let y=c(a,e[0],n)[0],l=JSON.stringify(y);i.has(l)||i.set(l,{item:a,key:y})}let h=[...i.values()];return h.sort((a,y)=>u(a.key,y.key)),[h.map(a=>a.item)]}case"group_by":{if(!Array.isArray(t)||e.length===0)return[null];let i=new Map;for(let h of t){let a=JSON.stringify(c(h,e[0],n)[0]);i.has(a)||i.set(a,[]),i.get(a)?.push(h)}return[[...i.values()]]}case"max":return Array.isArray(t)&&t.length>0?[t.reduce((i,h)=>u(i,h)>0?i:h)]:[null];case"max_by":return!Array.isArray(t)||t.length===0||e.length===0?[null]:[t.reduce((i,h)=>{let a=c(i,e[0],n)[0],y=c(h,e[0],n)[0];return u(a,y)>0?i:h})];case"min":return Array.isArray(t)&&t.length>0?[t.reduce((i,h)=>u(i,h)<0?i:h)]:[null];case"min_by":return!Array.isArray(t)||t.length===0||e.length===0?[null]:[t.reduce((i,h)=>{let a=c(i,e[0],n)[0],y=c(h,e[0],n)[0];return u(a,y)<0?i:h})];case"add":{let i=h=>{let a=h.filter(y=>y!==null);return a.length===0?null:a.every(y=>typeof y=="number")?a.reduce((y,l)=>y+l,0):a.every(y=>typeof y=="string")?a.join(""):a.every(y=>Array.isArray(y))?a.flat():a.every(y=>y&&typeof y=="object"&&!Array.isArray(y))?lt(...a):null};if(e.length>=1){let h=c(t,e[0],n);return[i(h)]}return Array.isArray(t)?[i(t)]:[null]}case"any":{if(e.length>=2){try{let i=o(t,e[0],n);for(let h of i)if(c(h,e[1],n).some(p))return[!0]}catch(i){if(i instanceof f)throw i}return[!1]}return e.length===1?Array.isArray(t)?[t.some(i=>p(c(i,e[0],n)[0]))]:[!1]:Array.isArray(t)?[t.some(p)]:[!1]}case"all":{if(e.length>=2){try{let i=o(t,e[0],n);for(let h of i)if(!c(h,e[1],n).some(p))return[!1]}catch(i){if(i instanceof f)throw i}return[!0]}return e.length===1?Array.isArray(t)?[t.every(i=>p(c(i,e[0],n)[0]))]:[!0]:Array.isArray(t)?[t.every(p)]:[!0]}case"select":return e.length===0?[t]:c(t,e[0],n).some(p)?[t]:[];case"map":return e.length===0||!Array.isArray(t)?[null]:[t.flatMap(h=>c(h,e[0],n))];case"map_values":{if(e.length===0)return[null];if(Array.isArray(t))return[t.flatMap(i=>c(i,e[0],n))];if(t&&typeof t=="object"){let i=Object.create(null);for(let[h,a]of Object.entries(t)){if(!g(h))continue;let y=c(a,e[0],n);y.length>0&&A(i,h,y[0])}return[i]}return[null]}case"has":{if(e.length===0)return[!1];let h=c(t,e[0],n)[0];return Array.isArray(t)&&typeof h=="number"?[h>=0&&h<t.length]:t&&typeof t=="object"&&typeof h=="string"?[T(t,h)]:[!1]}case"in":{if(e.length===0)return[!1];let h=c(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(h,t)]:[!1]}case"contains":{if(e.length===0)return[!1];let i=c(t,e[0],n);return[s(t,i[0])]}case"inside":{if(e.length===0)return[!1];let i=c(t,e[0],n);return[s(i[0],t)]}default:return null}}function z(t,r,e,n,c,o,u,p){switch(r){case"first":if(e.length>0)try{let s=o(t,e[0],n);return s.length>0?[s[0]]:[]}catch(s){if(s instanceof p)throw s;return[]}return Array.isArray(t)&&t.length>0?[t[0]]:[null];case"last":if(e.length>0){let s=c(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=c(t,e[0],n);if(e.length>1){for(let i of s)if(i<0)throw new Error("nth doesn't support negative indices");let f;try{f=o(t,e[1],n)}catch(i){if(i instanceof p)throw i;f=[]}return s.flatMap(i=>{let h=i;return h<f.length?[f[h]]:[]})}return Array.isArray(t)?s.flatMap(f=>{let i=f;if(i<0)throw new Error("nth doesn't support negative indices");return i<t.length?[t[i]]:[null]}):[null]}case"range":{if(e.length===0)return[];let s=Math.max(n.limits.maxIterations*100,1e6),f=l=>l.length>=s,i=c(t,e[0],n);if(e.length===1){let l=[];for(let m of i){let b=m;for(let w=0;w<b;w++)if(l.push(w),f(l))return l}return l}let h=c(t,e[1],n);if(e.length===2){let l=[];for(let m of i)for(let b of h){let w=m,k=b;for(let N=w;N<k;N++)if(l.push(N),f(l))return l}return l}let a=c(t,e[2],n),y=[];for(let l of i)for(let m of h)for(let b of a){let w=l,k=m,N=b;if(N!==0){if(N>0){for(let C=w;C<k;C+=N)if(y.push(C),f(y))return y}else for(let C=w;C>k;C+=N)if(y.push(C),f(y))return y}}return y}case"limit":return e.length<2?[]:c(t,e[0],n).flatMap(f=>{let i=f;if(i<0)throw new Error("limit doesn't support negative count");if(i===0)return[];let h;try{h=o(t,e[1],n)}catch(a){if(a instanceof p)throw a;h=[]}return h.slice(0,i)});case"isempty":{if(e.length<1)return[!0];try{return[o(t,e[0],n).length===0]}catch(s){if(s instanceof p)throw s;return[!0]}}case"isvalid":{if(e.length<1)return[!0];try{return[c(t,e[0],n).length>0]}catch(s){if(s instanceof p)throw s;return[!1]}}case"skip":return e.length<2?[]:c(t,e[0],n).flatMap(f=>{let i=f;if(i<0)throw new Error("skip doesn't support negative count");return c(t,e[1],n).slice(i)});case"until":{if(e.length<2)return[t];let s=t,f=n.limits.maxIterations;for(let i=0;i<f;i++){if(c(s,e[0],n).some(u))return[s];let a=c(s,e[1],n);if(a.length===0)return[s];s=a[0]}throw new p(`jq until: too many iterations (${f}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(e.length<2)return[t];let s=[],f=t,i=n.limits.maxIterations;for(let h=0;h<i&&c(f,e[0],n).some(u);h++){s.push(f);let y=c(f,e[1],n);if(y.length===0)break;f=y[0]}if(s.length>=i)throw new p(`jq while: too many iterations (${i}), increase executionLimits.maxJqIterations`,"iterations");return s}case"repeat":{if(e.length===0)return[t];let s=[],f=t,i=n.limits.maxIterations;for(let h=0;h<i;h++){s.push(f);let a=c(f,e[0],n);if(a.length===0)break;f=a[0]}if(s.length>=i)throw new p(`jq repeat: too many iterations (${i}), increase executionLimits.maxJqIterations`,"iterations");return s}default:return null}}function Z(t,r,e,n,c){switch(r){case"now":return[Date.now()/1e3];case"gmtime":{if(typeof t!="number")return[null];let o=new Date(t*1e3),u=o.getUTCFullYear(),p=o.getUTCMonth(),s=o.getUTCDate(),f=o.getUTCHours(),i=o.getUTCMinutes(),h=o.getUTCSeconds(),a=o.getUTCDay(),y=Date.UTC(u,0,1),l=Math.floor((o.getTime()-y)/(1440*60*1e3));return[[u,p,s,f,i,h,a,l]]}case"mktime":{if(!Array.isArray(t))throw new Error("mktime requires parsed datetime inputs");let[o,u,p,s=0,f=0,i=0]=t;if(typeof o!="number"||typeof u!="number")throw new Error("mktime requires parsed datetime inputs");let h=Date.UTC(o,u,p??1,s??0,f??0,i??0);return[Math.floor(h/1e3)]}case"strftime":{if(e.length===0)return[null];let u=c(t,e[0],n)[0];if(typeof u!="string")throw new Error("strftime/1 requires a string format");let p;if(typeof t=="number")p=new Date(t*1e3);else if(Array.isArray(t)){let[a,y,l,m=0,b=0,w=0]=t;if(typeof a!="number"||typeof y!="number")throw new Error("strftime/1 requires parsed datetime inputs");p=new Date(Date.UTC(a,y,l??1,m??0,b??0,w??0))}else throw new Error("strftime/1 requires parsed datetime inputs");let s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],f=["January","February","March","April","May","June","July","August","September","October","November","December"],i=(a,y=2)=>String(a).padStart(y,"0");return[u.replace(/%Y/g,String(p.getUTCFullYear())).replace(/%m/g,i(p.getUTCMonth()+1)).replace(/%d/g,i(p.getUTCDate())).replace(/%H/g,i(p.getUTCHours())).replace(/%M/g,i(p.getUTCMinutes())).replace(/%S/g,i(p.getUTCSeconds())).replace(/%A/g,s[p.getUTCDay()]).replace(/%B/g,f[p.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=c(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[,f,i,h,a,y,l]=s.map(Number),m=new Date(Date.UTC(f,i-1,h,a,y,l)),b=m.getUTCDay(),w=Date.UTC(f,0,1),k=Math.floor((m.getTime()-w)/(1440*60*1e3));return[[f,i-1,h,a,y,l,b,k]]}}let p=new Date(t);if(!Number.isNaN(p.getTime())){let s=p.getUTCFullYear(),f=p.getUTCMonth(),i=p.getUTCDate(),h=p.getUTCHours(),a=p.getUTCMinutes(),y=p.getUTCSeconds(),l=p.getUTCDay(),m=Date.UTC(s,0,1),b=Math.floor((p.getTime()-m)/(1440*60*1e3));return[[s,f,i,h,a,y,l,b]]}throw new Error(`Cannot parse date: ${t}`)}case"fromdate":{if(typeof t!="string")throw new Error("fromdate requires a string input");let o=new Date(t);if(Number.isNaN(o.getTime()))throw new Error(`date "${t}" does not match format "%Y-%m-%dT%H:%M:%SZ"`);return[Math.floor(o.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 S(t){return t!==!1&&t!==null}function I(t,r){return JSON.stringify(t)===JSON.stringify(r)}function U(t,r){return typeof t=="number"&&typeof r=="number"?t-r:typeof t=="string"&&typeof r=="string"?t.localeCompare(r):0}function v(t,r){let e=O(t);for(let n of Object.keys(r)){if(!g(n))continue;let c=T(e,n)?E(e[n]):null,o=E(r[n]);c&&o?A(e,n,v(c,o)):A(e,n,r[n])}return e}function D(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 c=Object.keys(n);if(c.length===0)return e+1;n=n[c[0]],e++}else return e;return e}function $(t,r){let e=p=>p===null?0:typeof p=="boolean"?1:typeof p=="number"?2:typeof p=="string"?3:Array.isArray(p)?4:typeof p=="object"?5:6,n=e(t),c=e(r);if(n!==c)return n-c;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 p=0;p<Math.min(t.length,r.length);p++){let s=$(t[p],r[p]);if(s!==0)return s}return t.length-r.length}let o=E(t),u=E(r);if(o&&u){let p=Object.keys(o).sort(),s=Object.keys(u).sort();for(let f=0;f<Math.min(p.length,s.length);f++){let i=p[f].localeCompare(s[f]);if(i!==0)return i}if(p.length!==s.length)return p.length-s.length;for(let f of p){let i=$(o[f],u[f]);if(i!==0)return i}}return 0}function F(t,r){if(I(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(c=>t.some(o=>F(o,c)));let e=E(t),n=E(r);return e&&n?Object.keys(n).every(c=>T(e,c)&&F(e[c],n[c])):!1}var Ot=2e3;function tt(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(c=>{if(c===null)return"";if(typeof c=="boolean")return c?"true":"false";if(typeof c=="number")return String(c);let o=String(c);return o.includes(",")||o.includes('"')||o.includes(`
|
|
3
|
+
`)||o.includes("\r")?`"${o.replace(/"/g,'""')}"`:o}).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??Ot;return D(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 et(t,r,e,n,c,o){switch(r){case"index":return e.length===0?[null]:c(t,e[0],n).map(p=>{if(typeof t=="string"&&typeof p=="string"){if(p===""&&t==="")return null;let s=t.indexOf(p);return s>=0?s:null}if(Array.isArray(t)){if(Array.isArray(p)){for(let f=0;f<=t.length-p.length;f++){let i=!0;for(let h=0;h<p.length;h++)if(!o(t[f+h],p[h])){i=!1;break}if(i)return f}return null}let s=t.findIndex(f=>o(f,p));return s>=0?s:null}return null});case"rindex":return e.length===0?[null]:c(t,e[0],n).map(p=>{if(typeof t=="string"&&typeof p=="string"){let s=t.lastIndexOf(p);return s>=0?s:null}if(Array.isArray(t)){if(Array.isArray(p)){for(let s=t.length-p.length;s>=0;s--){let f=!0;for(let i=0;i<p.length;i++)if(!o(t[s+i],p[i])){f=!1;break}if(f)return s}return null}for(let s=t.length-1;s>=0;s--)if(o(t[s],p))return s;return null}return null});case"indices":return e.length===0?[[]]:c(t,e[0],n).map(p=>{let s=[];if(typeof t=="string"&&typeof p=="string"){let f=t.indexOf(p);for(;f!==-1;)s.push(f),f=t.indexOf(p,f+1)}else if(Array.isArray(t))if(Array.isArray(p)){let f=p.length;if(f===0)for(let i=0;i<=t.length;i++)s.push(i);else for(let i=0;i<=t.length-f;i++){let h=!0;for(let a=0;a<f;a++)if(!o(t[i+a],p[a])){h=!1;break}h&&s.push(i)}}else for(let f=0;f<t.length;f++)o(t[f],p)&&s.push(f);return s});default:return null}}function rt(t,r,e,n,c){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 o=c(t,e[0],n),u=c(t,e[1],n),p=o[0],s=u[0];return typeof p!="number"||typeof s!="number"?[null]:[p**s]}case"atan2":{if(e.length<2)return[null];let o=c(t,e[0],n),u=c(t,e[1],n),p=o[0],s=u[0];return typeof p!="number"||typeof s!="number"?[null]:[Math.atan2(p,s)]}case"hypot":{if(typeof t!="number"||e.length===0)return[null];let o=c(t,e[0],n)[0];return[Math.hypot(t,o)]}case"fma":{if(typeof t!="number"||e.length<2)return[null];let o=c(t,e[0],n)[0],u=c(t,e[1],n)[0];return[t*o+u]}case"copysign":{if(typeof t!="number"||e.length===0)return[null];let o=c(t,e[0],n)[0];return[Math.sign(o)*Math.abs(t)]}case"drem":case"remainder":{if(typeof t!="number"||e.length===0)return[null];let o=c(t,e[0],n)[0];return[t-Math.round(t/o)*o]}case"fdim":{if(typeof t!="number"||e.length===0)return[null];let o=c(t,e[0],n)[0];return[Math.max(0,t-o)]}case"fmax":{if(typeof t!="number"||e.length===0)return[null];let o=c(t,e[0],n)[0];return[Math.max(t,o)]}case"fmin":{if(typeof t!="number"||e.length===0)return[null];let o=c(t,e[0],n)[0];return[Math.min(t,o)]}case"ldexp":{if(typeof t!="number"||e.length===0)return[null];let o=c(t,e[0],n)[0];return[t*2**o]}case"scalbn":case"scalbln":{if(typeof t!="number"||e.length===0)return[null];let o=c(t,e[0],n)[0];return[t*2**o]}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 o=Math.floor(Math.log2(Math.abs(t)));return[t/2**o]}return[null];case"frexp":if(typeof t=="number"){if(t===0)return[[0,0]];let o=Math.floor(Math.log2(Math.abs(t)))+1;return[[t/2**o,o]]}return[null];case"modf":if(typeof t=="number"){let o=Math.trunc(t);return[[t-o,o]]}return[null];default:return null}}function nt(t,r,e,n,c,o,u,p){switch(r){case"recurse":{if(e.length===0){let y=[],l=m=>{if(y.push(m),Array.isArray(m))for(let b of m)l(b);else if(m&&typeof m=="object")for(let b of Object.keys(m))l(m[b])};return l(t),y}let s=[],f=e.length>=2?e[1]:null,i=1e4,h=0,a=y=>{if(h++>i||f&&!c(y,f,n).some(o))return;s.push(y);let l=c(y,e[0],n);for(let m of l)m!=null&&a(m)};return a(t),s}case"recurse_down":return p(t,"recurse",e,n);case"walk":{if(e.length===0)return[t];let s=new WeakSet,f=i=>{if(i&&typeof i=="object"){if(s.has(i))return i;s.add(i)}let h;if(Array.isArray(i))h=i.map(f);else if(i&&typeof i=="object"){let y=Object.create(null);for(let[l,m]of Object.entries(i))g(l)&&A(y,l,f(m));h=y}else h=i;return c(h,e[0],n)[0]};return[f(t)]}case"transpose":{if(!Array.isArray(t))return[null];if(t.length===0)return[[]];let s=Math.max(...t.map(i=>Array.isArray(i)?i.length:0)),f=[];for(let i=0;i<s;i++)f.push(t.map(h=>Array.isArray(h)?h[i]:null));return[f]}case"combinations":{if(e.length>0){let h=c(t,e[0],n)[0];if(!Array.isArray(t)||h<0)return[];if(h===0)return[[]];let a=[],y=(l,m)=>{if(m===h){a.push([...l]);return}for(let b of t)l.push(b),y(l,m+1),l.pop()};return y([],0),a}if(!Array.isArray(t))return[];if(t.length===0)return[[]];for(let i of t)if(!Array.isArray(i))return[];let s=[],f=(i,h)=>{if(i===t.length){s.push([...h]);return}let a=t[i];for(let y of a)h.push(y),f(i+1,h),h.pop()};return f(0,[]),s}case"parent":{if(n.root===void 0||n.currentPath===void 0)return[];let s=n.currentPath;if(s.length===0)return[];let f=e.length>0?c(t,e[0],n)[0]:1;if(f>=0){if(f>s.length)return[];let i=s.slice(0,s.length-f);return[u(n.root,i)]}else{let i=-f-1;if(i>=s.length)return[t];let h=s.slice(0,i);return[u(n.root,h)]}}case"parents":{if(n.root===void 0||n.currentPath===void 0)return[[]];let s=n.currentPath,f=[];for(let i=s.length-1;i>=0;i--)f.push(u(n.root,s.slice(0,i)));return[f]}case"root":return n.root!==void 0?[n.root]:[];default:return null}}var Nt=2e3;function st(t,r,e,n,c){switch(r){case"keys":return Array.isArray(t)?[t.map((o,u)=>u)]:t&&typeof t=="object"?[Object.keys(t).sort()]:[null];case"keys_unsorted":return Array.isArray(t)?[t.map((o,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 o=t===null?"null":Array.isArray(t)?"array":typeof t,u=o==="array"||o==="object"?JSON.stringify(t):String(t);throw new Error(`${o} (${u}) only strings have UTF-8 byte length`)}case"to_entries":{let o=E(t);return o?[Object.entries(o).map(([u,p])=>({key:u,value:p}))]:[null]}case"from_entries":if(Array.isArray(t)){let o=Object.create(null);for(let u of t){let p=E(u);if(p){let s=p.key??p.Key??p.name??p.Name??p.k,f=p.value??p.Value??p.v;if(s!==void 0){let i=String(s);g(i)&&A(o,i,f)}}}return[o]}return[null];case"with_entries":{if(e.length===0)return[t];let o=E(t);if(o){let p=Object.entries(o).map(([f,i])=>({key:f,value:i})).flatMap(f=>c(f,e[0],n)),s=Object.create(null);for(let f of p){let i=E(f);if(i){let h=i.key??i.name??i.k,a=i.value??i.v;if(h!==void 0){let y=String(h);g(y)&&A(s,y,a)}}}return[s]}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?c(t,e[0],n):[Number.POSITIVE_INFINITY]).map(u=>{let p=u;if(p<0)throw new Error("flatten depth must not be negative");return t.flat(p)}):[null];case"unique":if(Array.isArray(t)){let o=new Set,u=[];for(let p of t){let s=JSON.stringify(p);o.has(s)||(o.add(s),u.push(p))}return[u]}return[null];case"tojson":case"tojsonstream":{let o=n.limits.maxDepth??Nt;return D(t,o+1)>o?[null]:[JSON.stringify(t)]}case"fromjson":{if(typeof t=="string"){let o=t.trim().toLowerCase();if(o==="nan")return[Number.NaN];if(o==="inf"||o==="infinity")return[Number.POSITIVE_INFINITY];if(o==="-inf"||o==="-infinity")return[Number.NEGATIVE_INFINITY];try{return[at(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 o=Number(t);if(Number.isNaN(o))throw new Error(`${JSON.stringify(t)} cannot be parsed as a number`);return[o]}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 o=t===null?"null":Array.isArray(t)?"array":typeof t,u=o==="array"||o==="object"?JSON.stringify(t):String(t);throw new Error(`${o} (${u}) cannot be parsed as a boolean`)}case"tostream":{let o=[],u=(p,s)=>{if(p===null||typeof p!="object")o.push([s,p]);else if(Array.isArray(p))if(p.length===0)o.push([s,[]]);else for(let f=0;f<p.length;f++)u(p[f],[...s,f]);else{let f=Object.keys(p);if(f.length===0)o.push([s,Object.create(null)]);else for(let i of f)u(p[i],[...s,i])}};return u(t,[]),o.push([[]]),o}case"fromstream":{if(e.length===0)return[t];let o=c(t,e[0],n),u=null;for(let p of o){if(!Array.isArray(p)||p.length===1&&Array.isArray(p[0])&&p[0].length===0||p.length!==2)continue;let[s,f]=p;if(!Array.isArray(s))continue;if(s.length===0){u=f;continue}u===null&&(u=typeof s[0]=="number"?[]:Object.create(null));let i=u;for(let a=0;a<s.length-1;a++){let y=s[a],l=s[a+1];if(Array.isArray(i)&&typeof y=="number"){for(;i.length<=y;)i.push(null);i[y]===null&&(i[y]=typeof l=="number"?[]:Object.create(null)),i=i[y]}else{let m=E(i);if(m){let b=String(y);if(!g(b))continue;(m[b]===null||m[b]===void 0)&&A(m,b,typeof l=="number"?[]:Object.create(null)),i=m[b]}}}let h=s[s.length-1];if(Array.isArray(i)&&typeof h=="number"){for(;i.length<=h;)i.push(null);i[h]=f}else{let a=E(i);if(a){let y=String(h);g(y)&&A(a,y,f)}}}return[u]}case"truncate_stream":{let o=typeof t=="number"?Math.floor(t):0;if(e.length===0)return[];let u=[],p=c(t,e[0],n);for(let s of p)if(Array.isArray(s)){if(s.length===1&&Array.isArray(s[0])){let f=s[0];f.length>o&&u.push([f.slice(o)]);continue}if(s.length===2&&Array.isArray(s[0])){let f=s[0],i=s[1];f.length>o&&u.push([f.slice(o),i])}}return u}default:return null}}function it(t,r,e,n,c,o,u,p,s,f){switch(r){case"getpath":{if(e.length===0)return[null];let i=c(t,e[0],n),h=[];for(let a of i){let y=a,l=t;for(let m of y){if(l==null){l=null;break}if(Array.isArray(l)&&typeof m=="number")l=l[m];else if(typeof m=="string"){let b=E(l);if(!b||!Object.hasOwn(b,m)){l=null;break}l=b[m]}else{l=null;break}}h.push(l)}return h}case"setpath":{if(e.length<2)return[null];let h=c(t,e[0],n)[0],y=c(t,e[1],n)[0];return[u(t,h,y)]}case"delpaths":{if(e.length===0)return[t];let h=c(t,e[0],n)[0],a=t;for(let y of h.sort((l,m)=>m.length-l.length))a=p(a,y);return[a]}case"path":{if(e.length===0)return[[]];let i=[];return f(t,e[0],n,[],i),i}case"del":return e.length===0?[t]:[s(t,e[0],n)];case"pick":{if(e.length===0)return[null];let i=[];for(let a of e)f(t,a,n,[],i);let h=null;for(let a of i){for(let l of a)if(typeof l=="number"&&l<0)throw new Error("Out of bounds negative array index");let y=t;for(let l of a){if(y==null)break;if(Array.isArray(y)&&typeof l=="number")y=y[l];else if(typeof l=="string"){let m=E(y);if(!m||!Object.hasOwn(m,l)){y=null;break}y=m[l]}else{y=null;break}}h=u(h,a,y)}return[h]}case"paths":{let i=[],h=(a,y)=>{if(a&&typeof a=="object")if(Array.isArray(a))for(let l=0;l<a.length;l++)i.push([...y,l]),h(a[l],[...y,l]);else for(let l of Object.keys(a))i.push([...y,l]),h(a[l],[...y,l])};return h(t,[]),e.length>0?i.filter(a=>{let y=t;for(let m of a)if(Array.isArray(y)&&typeof m=="number")y=y[m];else if(typeof m=="string"){let b=E(y);if(!b||!Object.hasOwn(b,m))return!1;y=b[m]}else return!1;return c(y,e[0],n).some(o)}):i}case"leaf_paths":{let i=[],h=(a,y)=>{if(a===null||typeof a!="object")i.push(y);else if(Array.isArray(a))for(let l=0;l<a.length;l++)h(a[l],[...y,l]);else for(let l of Object.keys(a))h(a[l],[...y,l])};return h(t,[]),i}default:return null}}function ot(t,r,e,n,c,o){switch(r){case"IN":{if(e.length===0)return[!1];if(e.length===1){let f=c(t,e[0],n);for(let i of f)if(o(t,i))return[!0];return[!1]}let u=c(t,e[0],n),p=c(t,e[1],n),s=new Set(p.map(f=>JSON.stringify(f)));for(let f of u)if(s.has(JSON.stringify(f)))return[!0];return[!1]}case"INDEX":{if(e.length===0)return[Object.create(null)];if(e.length===1){let s=c(t,e[0],n),f=Object.create(null);for(let i of s){let h=String(i);g(h)&&A(f,h,i)}return[f]}if(e.length===2){let s=c(t,e[0],n),f=Object.create(null);for(let i of s){let h=c(i,e[1],n);if(h.length>0){let a=String(h[0]);g(a)&&A(f,a,i)}}return[f]}let u=c(t,e[0],n),p=Object.create(null);for(let s of u){let f=c(s,e[1],n),i=c(s,e[2],n);if(f.length>0&&i.length>0){let h=String(f[0]);g(h)&&A(p,h,i[0])}}return[p]}case"JOIN":{if(e.length<2)return[null];let u=E(c(t,e[0],n)[0]);if(!u)return[null];if(!Array.isArray(t))return[null];let p=[];for(let s of t){let f=c(s,e[1],n),i=f.length>0?String(f[0]):"",h=T(u,i)?u[i]:null;p.push([s,h])}return[p]}default:return null}}function ft(t,r,e,n,c){switch(r){case"join":{if(!Array.isArray(t))return[null];let o=e.length>0?c(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 o.map(u=>t.map(p=>p===null?"":typeof p=="string"?p:String(p)).join(String(u)))}case"split":{if(typeof t!="string"||e.length===0)return[null];let o=c(t,e[0],n),u=String(o[0]);return[t.split(u)]}case"splits":{if(typeof t!="string"||e.length===0)return[];let o=c(t,e[0],n),u=String(o[0]);try{let p=e.length>1?String(c(t,e[1],n)[0]):"g";return R(u,p.includes("g")?p:`${p}g`).split(t)}catch{return[]}}case"scan":{if(typeof t!="string"||e.length===0)return[];let o=c(t,e[0],n),u=String(o[0]);try{let p=e.length>1?String(c(t,e[1],n)[0]):"";return[...R(u,p.includes("g")?p:`${p}g`).matchAll(t)].map(i=>i.length>1?i.slice(1):i[0])}catch{return[]}}case"test":{if(typeof t!="string"||e.length===0)return[!1];let o=c(t,e[0],n),u=String(o[0]);try{let p=e.length>1?String(c(t,e[1],n)[0]):"";return[R(u,p).test(t)]}catch{return[!1]}}case"match":{if(typeof t!="string"||e.length===0)return[null];let o=c(t,e[0],n),u=String(o[0]);try{let p=e.length>1?String(c(t,e[1],n)[0]):"",f=R(u,`${p}d`).exec(t);if(!f)return[];let i=f.indices;return[{offset:f.index,length:f[0].length,string:f[0],captures:f.slice(1).map((h,a)=>({offset:i?.[a+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 o=c(t,e[0],n),u=String(o[0]);try{let p=e.length>1?String(c(t,e[1],n)[0]):"",f=R(u,p).match(t);return!f||!f.groups?[Object.create(null)]:[f.groups]}catch{return[null]}}case"sub":{if(typeof t!="string"||e.length<2)return[null];let o=c(t,e[0],n),u=c(t,e[1],n),p=String(o[0]),s=String(u[0]);try{let f=e.length>2?String(c(t,e[2],n)[0]):"";return[R(p,f).replace(t,s)]}catch{return[t]}}case"gsub":{if(typeof t!="string"||e.length<2)return[null];let o=c(t,e[0],n),u=c(t,e[1],n),p=String(o[0]),s=String(u[0]);try{let f=e.length>2?String(c(t,e[2],n)[0]):"g",i=f.includes("g")?f:`${f}g`;return[R(p,i).replace(t,s)]}catch{return[t]}}case"ascii_downcase":return typeof t=="string"?[t.replace(/[A-Z]/g,o=>String.fromCharCode(o.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof t=="string"?[t.replace(/[a-z]/g,o=>String.fromCharCode(o.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof t!="string"||e.length===0)return[t];let o=c(t,e[0],n),u=String(o[0]);return[t.startsWith(u)?t.slice(u.length):t]}case"rtrimstr":{if(typeof t!="string"||e.length===0)return[t];let o=c(t,e[0],n),u=String(o[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 o=c(t,e[0],n),u=String(o[0]);if(u==="")return[t];let p=t;return p.startsWith(u)&&(p=p.slice(u.length)),p.endsWith(u)&&(p=p.slice(0,-u.length)),[p]}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 o=c(t,e[0],n);return[t.startsWith(String(o[0]))]}case"endswith":{if(typeof t!="string"||e.length===0)return[!1];let o=c(t,e[0],n);return[t.endsWith(String(o[0]))]}case"ascii":return typeof t=="string"&&t.length>0?[t.charCodeAt(0)]:[null];case"explode":return typeof t=="string"?[Array.from(t).map(o=>o.codePointAt(0))]:[null];case"implode":if(!Array.isArray(t))throw new Error("implode input must be an array");return[t.map(p=>{if(typeof p=="string")throw new Error(`string (${JSON.stringify(p)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof p!="number"||Number.isNaN(p))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let s=Math.trunc(p);return s<0||s>1114111||s>=55296&&s<=57343?String.fromCodePoint(65533):String.fromCodePoint(s)}).join("")];default:return null}}function ct(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 K(t,r,e){if(r.length===0)return e;let[n,...c]=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]=K(f[n],c,e),f}if(Array.isArray(t))throw new Error("Cannot index array with string");if(!g(n))return t??Object.create(null);let o=E(t),u=o?O(o):Object.create(null),p=Object.hasOwn(u,n)?u[n]:void 0;return A(u,n,K(p,c,e)),u}function V(t,r){if(r.length===0)return null;if(r.length===1){let c=r[0];if(Array.isArray(t)&&typeof c=="number"){let o=[...t];return o.splice(c,1),o}if(t&&typeof t=="object"&&!Array.isArray(t)){let o=String(c);if(!g(o))return t;let u=O(t);return delete u[o],u}return t}let[e,...n]=r;if(Array.isArray(t)&&typeof e=="number"){let c=[...t];return c[e]=V(c[e],n),c}if(t&&typeof t=="object"&&!Array.isArray(t)){let c=String(e);if(!g(c))return t;let o=O(t);return Object.hasOwn(o,c)&&A(o,c,V(o[c],n)),o}return t}var P=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])}},H=class extends Error{value;constructor(r){super(typeof r=="string"?r:JSON.stringify(r)),this.value=r,this.name="JqError"}},St=1e4,bt=2e3,Ct=new Map([["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 Tt(t){return{vars:new Map,limits:{maxIterations:t?.limits?.maxIterations??St,maxDepth:t?.limits?.maxDepth??bt},env:t?.env,coverage:t?.coverage,requireDefenseContext:t?.requireDefenseContext,defenseContextChecked:!1}}function q(t,r,e){let n=new Map(t.vars);return n.set(r,e),{vars:n,limits:t.limits,env:t.env,requireDefenseContext:t.requireDefenseContext,defenseContextChecked:t.defenseContextChecked,root:t.root,currentPath:t.currentPath,funcs:t.funcs,labels:t.labels,coverage:t.coverage}}function L(t,r,e){switch(r.type){case"var":return q(t,r.name,e);case"array":{if(!Array.isArray(e))return null;let n=t;for(let c=0;c<r.elements.length;c++){let o=r.elements[c],u=c<e.length?e[c]:null,p=L(n,o,u);if(p===null)return null;n=p}return n}case"object":{let n=E(e);if(!n)return null;let c=t;for(let o of r.fields){let u;if(typeof o.key=="string")u=o.key;else{let f=d(e,o.key,t);if(f.length===0)return null;u=String(f[0])}let p=T(n,u)?n[u]:null;o.keyVar&&(c=q(c,o.keyVar,p));let s=L(c,o.pattern,p);if(s===null)return null;c=s}return c}}}function Rt(t,r){let e=t;for(let n of r)if(e&&typeof e=="object")if(Array.isArray(e))if(typeof n=="number")e=e[n];else return;else{let c=E(e);if(c&&typeof n=="string"&&Object.hasOwn(c,n))e=c[n];else return}else return;return e}function M(t){if(t.type==="Identity")return[];if(t.type==="Field"){let r=t.base?M(t.base):[];return r===null?null:[...r,t.name]}if(t.type==="Index"&&t.index.type==="Literal"){let r=t.base?M(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=M(t.left);return r===null?null:pt(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 pt(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=M(r);if(e!==null)return[...t,...e]}if(r.type==="Index"&&r.index.type==="Literal"){let e=M(r);if(e!==null)return[...t,...e]}if(r.type==="Pipe"){let e=pt(t,r.left);return e===null?null:pt(e,r.right)}return r.type==="Identity"?t:null}function mt(t,r,e){if(r.type==="Comma"){let n=[];try{n.push(...d(t,r.left,e))}catch(c){if(c instanceof B)throw c;if(n.length>0)return n;throw new Error("evaluation failed")}try{n.push(...d(t,r.right,e))}catch(c){if(c instanceof B)throw c;return n}return n}return d(t,r,e)}function d(t,r,e){let n=e&&"vars"in e?e:Tt(e);switch(n.defenseContextChecked||(yt(n.requireDefenseContext,"query-engine","evaluation"),n={...n,defenseContextChecked:!0}),n.root===void 0&&(n={...n,root:t,currentPath:[]}),n.coverage?.hit(`jq:node:${r.type}`),r.type){case"Identity":return[t];case"Field":return(r.base?d(t,r.base,n):[t]).flatMap(o=>{let u=E(o);if(u){if(!Object.hasOwn(u,r.name))return[null];let s=u[r.name];return[s===void 0?null:s]}if(o===null)return[null];let p=Array.isArray(o)?"array":typeof o;throw new Error(`Cannot index ${p} with string "${r.name}"`)});case"Index":return(r.base?d(t,r.base,n):[t]).flatMap(o=>d(o,r.index,n).flatMap(p=>{if(typeof p=="number"&&Array.isArray(o)){if(Number.isNaN(p))return[null];let s=Math.trunc(p),f=s<0?o.length+s:s;return f>=0&&f<o.length?[o[f]]:[null]}if(typeof p=="string"){let s=E(o);return!s||!Object.hasOwn(s,p)?[null]:[s[p]]}return[null]}));case"Slice":return(r.base?d(t,r.base,n):[t]).flatMap(o=>{if(o===null)return[null];if(!Array.isArray(o)&&typeof o!="string")throw new Error(`Cannot slice ${typeof o} (${JSON.stringify(o)})`);let u=o.length,p=r.start?d(t,r.start,n):[0],s=r.end?d(t,r.end,n):[u];return p.flatMap(f=>s.map(i=>{let h=f,a=i,y=Number.isNaN(h)?0:Number.isInteger(h)?h:Math.floor(h),l=Number.isNaN(a)?u:Number.isInteger(a)?a:Math.ceil(a),m=dt(y,u),b=dt(l,u);return Array.isArray(o),o.slice(m,b)}))});case"Iterate":return(r.base?d(t,r.base,n):[t]).flatMap(o=>Array.isArray(o)?o:o&&typeof o=="object"?Object.values(o):[]);case"Pipe":{let c=d(t,r.left,n),o=M(r.left),u=[];for(let p of c)try{if(o!==null){let s={...n,currentPath:[...n.currentPath??[],...o]};u.push(...d(p,r.right,s))}else u.push(...d(p,r.right,n))}catch(s){throw s instanceof P?s.withPrependedResults(u):s}return u}case"Comma":{let c=d(t,r.left,n),o=d(t,r.right,n);return[...c,...o]}case"Literal":return[r.value];case"Array":return r.elements?[d(t,r.elements,n)]:[[]];case"Object":{let c=[Object.create(null)];for(let o of r.entries){let u=typeof o.key=="string"?[o.key]:d(t,o.key,n),p=d(t,o.value,n),s=[];for(let f of c)for(let i of u){if(typeof i!="string"){let h=i===null?"null":Array.isArray(i)?"array":typeof i;throw new Error(`Cannot use ${h} (${JSON.stringify(i)}) as object key`)}if(!g(i)){for(let h of p)s.push(O(f));continue}for(let h of p){let a=O(f);A(a,i,h),s.push(a)}}c.length=0,c.push(...s)}return c}case"Paren":return d(t,r.expr,n);case"BinaryOp":return xt(t,r.op,r.left,r.right,n);case"UnaryOp":return d(t,r.operand,n).map(o=>{if(r.op==="-"){if(typeof o=="number")return-o;if(typeof o=="string"){let u=p=>p.length>5?`"${p.slice(0,3)}...`:JSON.stringify(p);throw new Error(`string (${u(o)}) cannot be negated`)}return null}return r.op==="not"?!S(o):null});case"Cond":return d(t,r.cond,n).flatMap(o=>{if(S(o))return d(t,r.then,n);for(let u of r.elifs)if(d(t,u.cond,n).some(S))return d(t,u.then,n);return r.else?d(t,r.else,n):[t]});case"Try":try{return d(t,r.body,n)}catch(c){if(r.catch){let o=c instanceof H?c.value:c instanceof Error?c.message:String(c);return d(o,r.catch,n)}return[]}case"Call":return gt(t,r.name,r.args,n);case"VarBind":return d(t,r.value,n).flatMap(o=>{let u=null,p=[];r.pattern?p.push(r.pattern):r.name&&p.push({type:"var",name:r.name}),r.alternatives&&p.push(...r.alternatives);for(let s of p)if(u=L(n,s,o),u!==null)break;return u===null?[]:d(t,r.body,u)});case"VarRef":{if(r.name==="$ENV")return[n.env?X(n.env):Object.create(null)];let c=n.vars.get(r.name);return c!==void 0?[c]:[null]}case"Recurse":{let c=[],o=new WeakSet,u=p=>{if(p&&typeof p=="object"){if(o.has(p))return;o.add(p)}if(c.push(p),Array.isArray(p))for(let s of p)u(s);else if(p&&typeof p=="object")for(let s of Object.keys(p))u(p[s])};return u(t),c}case"Optional":try{return d(t,r.expr,n)}catch{return[]}case"StringInterp":return[r.parts.map(o=>typeof o=="string"?o:d(t,o,n).map(p=>typeof p=="string"?p:JSON.stringify(p)).join("")).join("")];case"UpdateOp":return[Mt(t,r.path,r.op,r.value,n)];case"Reduce":{let c=d(t,r.expr,n),o=d(t,r.init,n)[0],u=n.limits.maxDepth??bt;for(let p of c){let s;if(r.pattern){if(s=L(n,r.pattern,p),s===null)continue}else s=q(n,r.varName,p);if(o=d(o,r.update,s)[0],D(o,u+1)>u)return[null]}return[o]}case"Foreach":{let c=d(t,r.expr,n),o=d(t,r.init,n)[0],u=[];for(let p of c)try{let s;if(r.pattern){if(s=L(n,r.pattern,p),s===null)continue}else s=q(n,r.varName,p);if(o=d(o,r.update,s)[0],r.extract){let f=d(o,r.extract,s);u.push(...f)}else u.push(o)}catch(s){throw s instanceof P?s.withPrependedResults(u):s}return u}case"Label":try{return d(t,r.body,{...n,labels:new Set([...n.labels??[],r.name])})}catch(c){if(c instanceof P&&c.label===r.name)return c.partialResults;throw c}case"Break":throw new P(r.name);case"Def":{let c=new Map(n.funcs??[]),o=`${r.name}/${r.params.length}`;c.set(o,{params:r.params,body:r.funcBody,closure:new Map(n.funcs??[])});let u={...n,funcs:c};return d(t,r.body,u)}default:{let c=r;throw new Error(`Unknown AST node type: ${c.type}`)}}}function dt(t,r){return t<0?Math.max(0,r+t):Math.min(t,r)}function Mt(t,r,e,n,c){function o(s,f){switch(e){case"=":return f;case"|=":return d(s,n,c)[0]??null;case"+=":return typeof s=="number"&&typeof f=="number"||typeof s=="string"&&typeof f=="string"?s+f:Array.isArray(s)&&Array.isArray(f)?[...s,...f]:s&&f&&typeof s=="object"&&typeof f=="object"?G(s,f):f;case"-=":return typeof s=="number"&&typeof f=="number"?s-f:s;case"*=":return typeof s=="number"&&typeof f=="number"?s*f:s;case"/=":return typeof s=="number"&&typeof f=="number"?s/f:s;case"%=":return typeof s=="number"&&typeof f=="number"?s%f:s;case"//=":return s===null||s===!1?f:s;default:return f}}function u(s,f,i){switch(f.type){case"Identity":return i(s);case"Field":{if(!g(f.name))return s;if(f.base)return u(s,f.base,h=>{if(h&&typeof h=="object"&&!Array.isArray(h)){let a=O(h),y=Object.hasOwn(a,f.name)?a[f.name]:void 0;return A(a,f.name,i(y)),a}return h});if(s&&typeof s=="object"&&!Array.isArray(s)){let h=O(s),a=Object.hasOwn(h,f.name)?h[f.name]:void 0;return A(h,f.name,i(a)),h}return s}case"Index":{let a=d(t,f.index,c)[0];if(typeof a=="number"&&Number.isNaN(a))throw new Error("Cannot set array element at NaN index");if(typeof a=="number"&&!Number.isInteger(a)&&(a=Math.trunc(a)),f.base)return u(s,f.base,y=>{if(typeof a=="number"&&Array.isArray(y)){let l=[...y],m=a<0?l.length+a:a;if(m>=0){for(;l.length<=m;)l.push(null);l[m]=i(l[m])}return l}if(typeof a=="string"&&y&&typeof y=="object"&&!Array.isArray(y)){if(!g(a))return y;let l=O(y),m=Object.hasOwn(l,a)?l[a]:void 0;return A(l,a,i(m)),l}return y});if(typeof a=="number"){if(a>536870911)throw new Error("Array index too large");if(a<0&&(!s||!Array.isArray(s)))throw new Error("Out of bounds negative array index");if(Array.isArray(s)){let l=[...s],m=a<0?l.length+a:a;if(m>=0){for(;l.length<=m;)l.push(null);l[m]=i(l[m])}return l}if(s==null){let l=[];for(;l.length<=a;)l.push(null);return l[a]=i(null),l}return s}if(typeof a=="string"&&s&&typeof s=="object"&&!Array.isArray(s)){if(!g(a))return s;let y=O(s),l=Object.hasOwn(y,a)?y[a]:void 0;return A(y,a,i(l)),y}return s}case"Iterate":{let h=a=>{if(Array.isArray(a))return a.map(y=>i(y));if(a&&typeof a=="object"){let y=Object.create(null);for(let[l,m]of Object.entries(a))g(l)&&A(y,l,i(m));return y}return a};return f.base?u(s,f.base,h):h(s)}case"Pipe":{let h=u(s,f.left,a=>a);return u(h,f.right,i)}default:return i(s)}}return u(t,r,s=>{if(e==="|=")return o(s,s);let f=d(t,n,c);return o(s,f[0]??null)})}function jt(t,r,e){function n(o,u,p){switch(u.type){case"Identity":return p;case"Field":{if(!g(u.name))return o;if(u.base){let s=d(o,u.base,e)[0],f=n(s,{type:"Field",name:u.name},p);return n(o,u.base,f)}if(o&&typeof o=="object"&&!Array.isArray(o)){let s=O(o);return A(s,u.name,p),s}return o}case"Index":{if(u.base){let i=d(o,u.base,e)[0],h=n(i,{type:"Index",index:u.index},p);return n(o,u.base,h)}let f=d(t,u.index,e)[0];if(typeof f=="number"&&Array.isArray(o)){let i=[...o],h=f<0?i.length+f:f;return h>=0&&h<i.length&&(i[h]=p),i}if(typeof f=="string"&&o&&typeof o=="object"&&!Array.isArray(o)){if(!g(f))return o;let i=O(o);return A(i,f,p),i}return o}default:return o}}function c(o,u){switch(u.type){case"Identity":return null;case"Field":{if(!g(u.name))return o;if(u.base){let s=d(o,u.base,e)[0];if(s==null)return o;let f=c(s,{type:"Field",name:u.name});return n(o,u.base,f)}if(o&&typeof o=="object"&&!Array.isArray(o)){if(!g(u.name))return o;let s=O(o);return delete s[u.name],s}return o}case"Index":{if(u.base){let i=d(o,u.base,e)[0];if(i==null)return o;let h=c(i,{type:"Index",index:u.index});return n(o,u.base,h)}let f=d(t,u.index,e)[0];if(typeof f=="number"&&Array.isArray(o)){let i=[...o],h=f<0?i.length+f:f;return h>=0&&h<i.length&&i.splice(h,1),i}if(typeof f=="string"&&o&&typeof o=="object"&&!Array.isArray(o)){if(!g(f))return o;let i=O(o);return delete i[f],i}return o}case"Iterate":return Array.isArray(o)?[]:o&&typeof o=="object"?Object.create(null):o;case"Pipe":{let i=function(y,l,m){switch(l.type){case"Identity":return m;case"Field":{if(!g(l.name))return y;if(y&&typeof y=="object"&&!Array.isArray(y)){let b=O(y);return A(b,l.name,m),b}return y}case"Index":{let w=d(t,l.index,e)[0];if(typeof w=="number"&&Array.isArray(y)){let k=[...y],N=w<0?k.length+w:w;return N>=0&&N<k.length&&(k[N]=m),k}if(typeof w=="string"&&y&&typeof y=="object"&&!Array.isArray(y)){if(!g(w))return y;let k=O(y);return A(k,w,m),k}return y}case"Pipe":{let b=d(y,l.left,e)[0],w=i(b,l.right,m);return i(y,l.left,w)}default:return y}};var p=i;let s=u.left,f=u.right,h=d(o,s,e)[0];if(h==null)return o;let a=c(h,f);return i(o,s,a)}default:return o}}return c(t,r)}function xt(t,r,e,n,c){if(r==="and")return d(t,e,c).flatMap(s=>S(s)?d(t,n,c).map(i=>S(i)):[!1]);if(r==="or")return d(t,e,c).flatMap(s=>S(s)?[!0]:d(t,n,c).map(i=>S(i)));if(r==="//"){let s=d(t,e,c).filter(f=>f!=null&&f!==!1);return s.length>0?s:d(t,n,c)}let o=d(t,e,c),u=d(t,n,c);return o.flatMap(p=>u.map(s=>{switch(r){case"+":return p===null?s:s===null?p:typeof p=="number"&&typeof s=="number"||typeof p=="string"&&typeof s=="string"?p+s:Array.isArray(p)&&Array.isArray(s)?[...p,...s]:p&&s&&typeof p=="object"&&typeof s=="object"&&!Array.isArray(p)&&!Array.isArray(s)?G(p,s):null;case"-":if(typeof p=="number"&&typeof s=="number")return p-s;if(Array.isArray(p)&&Array.isArray(s)){let f=new Set(s.map(i=>JSON.stringify(i)));return p.filter(i=>!f.has(JSON.stringify(i)))}if(typeof p=="string"&&typeof s=="string"){let f=i=>i.length>10?`"${i.slice(0,10)}...`:JSON.stringify(i);throw new Error(`string (${f(p)}) and string (${f(s)}) cannot be subtracted`)}return null;case"*":if(typeof p=="number"&&typeof s=="number")return p*s;if(typeof p=="string"&&typeof s=="number")return p.repeat(s);{let f=E(p),i=E(s);if(f&&i)return v(f,i)}return null;case"/":if(typeof p=="number"&&typeof s=="number"){if(s===0)throw new Error(`number (${p}) and number (${s}) cannot be divided because the divisor is zero`);return p/s}return typeof p=="string"&&typeof s=="string"?p.split(s):null;case"%":if(typeof p=="number"&&typeof s=="number"){if(s===0)throw new Error(`number (${p}) and number (${s}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(p)&&!Number.isNaN(p)?!Number.isFinite(s)&&!Number.isNaN(s)&&p<0&&s>0?-1:0:p%s}return null;case"==":return I(p,s);case"!=":return!I(p,s);case"<":return U(p,s)<0;case"<=":return U(p,s)<=0;case">":return U(p,s)>0;case">=":return U(p,s)>=0;default:return null}}))}function gt(t,r,e,n){let c=Ct.get(r);if(c)return typeof t=="number"?[c(t)]:[null];let o=rt(t,r,e,n,d);if(o!==null)return o;let u=ft(t,r,e,n,d);if(u!==null)return u;let p=Z(t,r,e,n,d);if(p!==null)return p;let s=tt(t,r,n.limits.maxDepth);if(s!==null)return s;let f=ct(t,r);if(f!==null)return f;let i=st(t,r,e,n,d);if(i!==null)return i;let h=W(t,r,e,n,d,mt,$,S,F,B);if(h!==null)return h;let a=it(t,r,e,n,d,S,K,V,jt,J);if(a!==null)return a;let y=et(t,r,e,n,d,I);if(y!==null)return y;let l=z(t,r,e,n,d,mt,S,B);if(l!==null)return l;let m=nt(t,r,e,n,d,S,Rt,gt);if(m!==null)return m;let b=ot(t,r,e,n,d,I);if(b!==null)return b;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 w=e.length>0?d(t,e[0],n)[0]:t;throw new H(w)}case"env":return[n.env?X(n.env):Object.create(null)];case"debug":return[t];case"input_line_number":return[1];default:{let w=`${r}/${e.length}`,k=n.funcs?.get(w);if(k){let N=k.closure??n.funcs??new Map,C=new Map(N);C.set(w,k);for(let _=0;_<k.params.length;_++){let kt=k.params[_],ht=e[_];if(ht){let j=d(t,ht,n),x;if(j.length===0)x={type:"Call",name:"empty",args:[]};else if(j.length===1)x={type:"Literal",value:j[0]};else{x={type:"Literal",value:j[j.length-1]};for(let Q=j.length-2;Q>=0;Q--)x={type:"Comma",left:{type:"Literal",value:j[Q]},right:x}}C.set(`${kt}/0`,{params:[],body:x})}}let wt={...n,funcs:C};return d(t,k.body,wt)}throw new Error(`Unknown function: ${r}`)}}}function J(t,r,e,n,c){if(r.type==="Comma"){let p=r;J(t,p.left,e,n,c),J(t,p.right,e,n,c);return}let o=M(r);if(o!==null){c.push([...n,...o]);return}if(r.type==="Iterate"){if(Array.isArray(t))for(let p=0;p<t.length;p++)c.push([...n,p]);else if(t&&typeof t=="object")for(let p of Object.keys(t))c.push([...n,p]);return}if(r.type==="Recurse"){let p=(s,f)=>{if(c.push([...n,...f]),s&&typeof s=="object")if(Array.isArray(s))for(let i=0;i<s.length;i++)p(s[i],[...f,i]);else for(let i of Object.keys(s))p(s[i],[...f,i])};p(t,[]);return}if(r.type==="Pipe"){let p=M(r.left);if(p!==null){let s=d(t,r.left,e);for(let f of s)J(f,r.right,e,[...n,...p],c);return}}d(t,r,e).length>0&&c.push(n)}var At=new Map([["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"]]),Y=new Set(At.values());function Et(t){let r=[],e=0,n=(f=0)=>t[e+f],c=()=>t[e++],o=()=>e>=t.length,u=f=>f>="0"&&f<="9",p=f=>f>="a"&&f<="z"||f>="A"&&f<="Z"||f==="_",s=f=>p(f)||u(f);for(;!o();){let f=e,i=c();if(!(i===" "||i===" "||i===`
|
|
4
|
+
`||i==="\r")){if(i==="#"){for(;!o()&&n()!==`
|
|
5
|
+
`;)c();continue}if(i==="."&&n()==="."){c(),r.push({type:"DOTDOT",pos:f});continue}if(i==="="&&n()==="="){c(),r.push({type:"EQ",pos:f});continue}if(i==="!"&&n()==="="){c(),r.push({type:"NE",pos:f});continue}if(i==="<"&&n()==="="){c(),r.push({type:"LE",pos:f});continue}if(i===">"&&n()==="="){c(),r.push({type:"GE",pos:f});continue}if(i==="/"&&n()==="/"){c(),n()==="="?(c(),r.push({type:"UPDATE_ALT",pos:f})):r.push({type:"ALT",pos:f});continue}if(i==="+"&&n()==="="){c(),r.push({type:"UPDATE_ADD",pos:f});continue}if(i==="-"&&n()==="="){c(),r.push({type:"UPDATE_SUB",pos:f});continue}if(i==="*"&&n()==="="){c(),r.push({type:"UPDATE_MUL",pos:f});continue}if(i==="/"&&n()==="="){c(),r.push({type:"UPDATE_DIV",pos:f});continue}if(i==="%"&&n()==="="){c(),r.push({type:"UPDATE_MOD",pos:f});continue}if(i==="="&&n()!=="="){r.push({type:"ASSIGN",pos:f});continue}if(i==="."){r.push({type:"DOT",pos:f});continue}if(i==="|"){n()==="="?(c(),r.push({type:"UPDATE_PIPE",pos:f})):r.push({type:"PIPE",pos:f});continue}if(i===","){r.push({type:"COMMA",pos:f});continue}if(i===":"){r.push({type:"COLON",pos:f});continue}if(i===";"){r.push({type:"SEMICOLON",pos:f});continue}if(i==="("){r.push({type:"LPAREN",pos:f});continue}if(i===")"){r.push({type:"RPAREN",pos:f});continue}if(i==="["){r.push({type:"LBRACKET",pos:f});continue}if(i==="]"){r.push({type:"RBRACKET",pos:f});continue}if(i==="{"){r.push({type:"LBRACE",pos:f});continue}if(i==="}"){r.push({type:"RBRACE",pos:f});continue}if(i==="?"){r.push({type:"QUESTION",pos:f});continue}if(i==="+"){r.push({type:"PLUS",pos:f});continue}if(i==="-"){r.push({type:"MINUS",pos:f});continue}if(i==="*"){r.push({type:"STAR",pos:f});continue}if(i==="/"){r.push({type:"SLASH",pos:f});continue}if(i==="%"){r.push({type:"PERCENT",pos:f});continue}if(i==="<"){r.push({type:"LT",pos:f});continue}if(i===">"){r.push({type:"GT",pos:f});continue}if(u(i)){let h=i;for(;!o()&&(u(n())||n()==="."||n()==="e"||n()==="E");)(n()==="e"||n()==="E")&&(t[e+1]==="+"||t[e+1]==="-")&&(h+=c()),h+=c();r.push({type:"NUMBER",value:Number(h),pos:f});continue}if(i==='"'){let h="",a=0;for(;!o();){let y=n();if(a===0&&y==='"')break;if(a===0&&y==="\\"){if(c(),o())break;let l=c();switch(l){case"n":h+=`
|
|
6
|
+
`;break;case"r":h+="\r";break;case"t":h+=" ";break;case"\\":h+="\\";break;case'"':h+='"';break;case"(":h+="\\(",a=1;break;default:h+=l}continue}if(a>0){if(y==='"'){for(h+=c();!o();){let l=n();if(l==="\\"){h+=c(),o()||(h+=c());continue}if(h+=c(),l==='"')break}continue}y==="("?a++:y===")"&&a--,h+=c();continue}h+=c()}o()||c(),r.push({type:"STRING",value:h,pos:f});continue}if(p(i)||i==="$"||i==="@"){let h=i;for(;!o()&&s(n());)h+=c();let a=At.get(h);a?r.push({type:a,value:h,pos:f}):r.push({type:"IDENT",value:h,pos:f});continue}throw new Error(`Unexpected character '${i}' at position ${f}`)}}return r.push({type:"EOF",pos:e}),r}var ut=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()}isFieldNameAfterDot(r=0){let e=this.peek(r),n=this.peek(r+1);return n.type==="STRING"?!0:n.type==="IDENT"||Y.has(n.type)?n.pos===e.pos+1:!1}isIdentLike(){let r=this.peek().type;return r==="IDENT"||Y.has(r)}consumeFieldNameAfterDot(r){let e=this.peek();return e.type==="STRING"?this.advance().value:(e.type==="IDENT"||Y.has(e.type))&&e.pos===r.pos+1?this.advance().value:null}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"||Y.has(r.type)){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 c=this.parseExpr();return e.type==="var"&&n.length===0?{type:"VarBind",name:e.name,value:r,body:c}:{type:"VarBind",name:e.type==="var"?e.name:"",value:r,body:c,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=new Map([["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 c=this.parseVarBind(),o=e.get(n.type);if(o)return{type:"UpdateOp",op:o,path:r,value:c}}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=new Map([["EQ","=="],["NE","!="],["LT","<"],["LE","<="],["GT",">"],["GE",">="]]),n=this.match("EQ","NE","LT","LE","GT","GE");if(n){let c=e.get(n.type);if(c){let o=this.parseAddSub();r={type:"BinaryOp",op:c,left:r,right:o}}}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.isFieldNameAfterDot())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.check("DOT")){let r=this.advance();if(this.check("LBRACKET")){if(this.advance(),this.match("RBRACKET"))return{type:"Iterate"};if(this.check("COLON")){this.advance();let c=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:c}}let n=this.parseExpr();if(this.match("COLON")){let c=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:n,end:c}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:n}}let e=this.consumeFieldNameAfterDot(r);return e!==null?{type:"Field",name:e}:{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 c=this.parseExpr();this.expect("RPAREN","Expected ')' after update expression");let o=e.type==="var"?e.name:"";return{type:"Reduce",expr:r,varName:o,init:n,update:c,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 c=this.parseExpr(),o;this.match("SEMICOLON")&&(o=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:c,extract:o,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 p=this.expect("IDENT","Expected parameter name");n.push(p.value)}}this.expect("RPAREN","Expected ')' after parameters")}this.expect("COLON","Expected ':' after function name");let c=this.parseExpr();this.expect("SEMICOLON","Expected ';' after function body");let o=this.parseExpr();return{type:"Def",name:e,params:n,funcBody:c,body:o}}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.isIdentLike()){let c=this.advance().value;this.match("COLON")?(e=c,n=this.parseObjectValue()):(e=c,n={type:"Field",name:c})}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 o=this.parseExpr();this.expect("THEN","Expected 'then' after elif");let u=this.parseExpr();n.push({cond:o,then:u})}let c;return this.match("ELSE")&&(c=this.parseExpr()),this.expect("END","Expected 'end'"),{type:"Cond",cond:r,then:e,elifs:n,else:c}}parseStringInterpolation(r){let e=[],n="",c=0;for(;c<r.length;)if(r[c]==="\\"&&r[c+1]==="("){n&&(e.push(n),n=""),c+=2;let o=1,u="";for(;c<r.length&&o>0;){let f=r[c];if(f==='"'){for(u+=f,c++;c<r.length;){let i=r[c];if(i==="\\"){u+=i,c++,c<r.length&&(u+=r[c],c++);continue}if(u+=i,c++,i==='"')break}continue}f==="("?o++:f===")"&&o--,o>0&&(u+=f),c++}let p=Et(u),s=new t(p);e.push(s.parse())}else n+=r[c],c++;return n&&e.push(n),{type:"StringInterp",parts:e}}};function Ne(t){let r=Et(t);return new ut(r).parse()}export{d as a,Ne as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{a as w,b as V}from"./chunk-
|
|
2
|
+
import{a as w,b as V}from"./chunk-J3LJZWL2.js";import{d as E}from"./chunk-4WKZNNJK.js";import{a as T,b as M}from"./chunk-KAPG5ONA.js";import{a as F}from"./chunk-VACKIICN.js";import{a as R}from"./chunk-KTPCYKBB.js";import{c as J}from"./chunk-XEKXHOPO.js";import{k as O}from"./chunk-SAI2SPQQ.js";import{a as N}from"./chunk-FOCWZZDE.js";import{a as A,b as L,c as I}from"./chunk-QAYAQNCG.js";function W(t){switch(t){case"\b":return"\\b";case"\f":return"\\f";case`
|
|
3
3
|
`:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`}}function _(t){let n="",s=!1,i=!1;for(let a=0;a<t.length;a++){let r=t[a];if(i){n+=r,i=!1;continue}if(r==="\\"){n+=r,i=!0;continue}if(r==='"'){n+=r,s=!s;continue}if(s&&r.charCodeAt(0)<=31){n+=W(r);continue}n+=r}return n}function k(t,n,s){return JSON.parse(_(t.slice(n,s)))}function B(t){let n=[],s=0,i=t.length;for(;s<i;){for(;s<i&&/\s/.test(t[s]);)s++;if(s>=i)break;let a=s,r=t[s];if(r==="{"||r==="["){let f=r,c=r==="{"?"}":"]",p=1,m=!1,d=!1;for(s++;s<i&&p>0;){let j=t[s];d?d=!1:j==="\\"?d=!0:j==='"'?m=!m:m||(j===f?p++:j===c&&p--),s++}if(p!==0)throw new Error(`Unexpected end of JSON input at position ${s} (unclosed ${f})`);n.push(E(k(t,a,s)))}else if(r==='"'){let f=!1;for(s++;s<i;){let c=t[s];if(f)f=!1;else if(c==="\\")f=!0;else if(c==='"'){s++;break}s++}n.push(E(k(t,a,s)))}else if(r==="-"||r>="0"&&r<="9"){for(;s<i&&/[\d.eE+-]/.test(t[s]);)s++;n.push(E(k(t,a,s)))}else if(t.slice(s,s+4)==="true")n.push(!0),s+=4;else if(t.slice(s,s+5)==="false")n.push(!1),s+=5;else if(t.slice(s,s+4)==="null")n.push(null),s+=4;else{let f=t.slice(s,s+10);throw new Error(`Invalid JSON at position ${a}: unexpected '${f.split(/\s/)[0]}'`)}}return n}var X={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE...]",options:["-R, --raw-input read each line as string instead of JSON","-r, --raw-output output strings without quotes","-c, --compact-output compact instead of pretty-printed output","-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 C(t,n,s,i,a,r=0){if(t===null||t===void 0)return"null";if(typeof t=="boolean")return String(t);if(typeof t=="number")return Number.isFinite(t)?String(t):"null";if(typeof t=="string")return s?t:JSON.stringify(t);let f=a?" ":" ";if(Array.isArray(t))return t.length===0?"[]":n?`[${t.map(p=>C(p,!0,!1,i,a)).join(",")}]`:`[
|
|
4
4
|
${t.map(p=>f.repeat(r+1)+C(p,!1,!1,i,a,r+1)).join(`,
|
|
5
5
|
`)}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
+
import{f as G}from"./chunk-4WKZNNJK.js";import{a as B,b as U,c as A}from"./chunk-KSBHIW2H.js";import{a as q}from"./chunk-L2UW7DWF.js";import{a as M}from"./chunk-7CSMHFIJ.js";import{c as D}from"./chunk-XEKXHOPO.js";import{a as z,b as E,c as O}from"./chunk-QAYAQNCG.js";var H=G({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(H).map(([t,s])=>[t,{extensions:[...s.extensions],globs:[...s.globs]}]))}addType(t){let s=t.indexOf(":");if(s===-1)return;let n=t.slice(0,s),r=t.slice(s+1);if(r.startsWith("include:")){let l=r.slice(8),i=this.types.get(l);if(i){let o=this.types.get(n)||{extensions:[],globs:[]};o.extensions.push(...i.extensions),o.globs.push(...i.globs),this.types.set(n,o)}}else{let l=this.types.get(n)||{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(n,l)}}clearType(t){let s=this.types.get(t);s&&(s.extensions=[],s.globs=[])}getType(t){return this.types.get(t)}getAllTypes(){return this.types}matchesType(t,s){let n=t.toLowerCase();for(let r of s){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(n.endsWith(i))return!0;for(let i of l.globs)if(i.includes("*")){let o=i.replace(/\./g,"\\.").replace(/\*/g,".*");if(M(`^${o}$`,"i").test(t))return!0}else if(n===i.toLowerCase())return!0}}return!1}matchesAnyType(t){let s=t.toLowerCase();for(let n of this.types.values()){for(let r of n.extensions)if(s.endsWith(r))return!0;for(let r of n.globs)if(r.includes("*")){let l=r.replace(/\./g,"\\.").replace(/\*/g,".*");if(M(`^${l}$`,"i").test(t))return!0}else if(s===r.toLowerCase())return!0}return!1}};function V(){let e=[];for(let[t,s]of Object.entries(H).sort()){let n=[];for(let r of s.extensions)n.push(`*${r}`);for(let r of s.globs)n.push(r);e.push(`${t}: ${n.join(", ")}`)}return`${e.join(`
|
|
3
|
+
`)}
|
|
4
|
+
`}function Z(){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:256,maxFilesize:0,followSymlinks:!1,searchZip:!1,searchBinary:!1,preprocessor:null,preprocessorGlobs:[]}}function se(e){let t=e.match(/^(\d+)([KMG])?$/i);if(!t)return 0;let s=parseInt(t[1],10);switch((t[2]||"").toUpperCase()){case"K":return s*1024;case"M":return s*1024*1024;case"G":return s*1024*1024*1024;default:return s}}function ne(e){return/^\d+[KMG]?$/i.test(e)?null:{stdout:"",stderr:`rg: invalid --max-filesize value: ${e}
|
|
5
|
+
`,exitCode:1}}function J(e){return null}var Y=[{short:"g",long:"glob",target:"globs",multi:!0},{long:"iglob",target:"iglobs",multi:!0},{short:"t",long:"type",target:"types",multi:!0,validate:J},{short:"T",long:"type-not",target:"typesNot",multi:!0,validate:J},{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:se,validate:ne},{long:"context-separator",target:"contextSeparator"},{short:"j",long:"threads",ignored:!0},{long:"ignore-file",target:"ignoreFiles",multi:!0},{long:"pre",target:"preprocessor"},{long:"pre-glob",target:"preprocessorGlobs",multi:!0}],re=new Map([["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}]]),ie=new Set(["n","--line-number"]);function le(e){e.hidden?e.searchBinary=!0:e.noIgnore?e.hidden=!0:e.noIgnore=!0}function oe(e,t,s){let n=e[t];for(let r of Y){if(n.startsWith(`--${r.long}=`)){let l=n.slice(`--${r.long}=`.length),i=P(s,r,l);return i?{newIndex:t,error:i}:{newIndex:t}}if(r.short&&n.startsWith(`-${r.short}`)&&n.length>2){let l=n.slice(2),i=P(s,r,l);return i?{newIndex:t,error:i}:{newIndex:t}}if(r.short&&n===`-${r.short}`||n===`--${r.long}`){if(t+1>=e.length)return null;let l=e[t+1],i=P(s,r,l);return i?{newIndex:t+1,error:i}:{newIndex:t+1}}}return null}function ae(e){return Y.find(t=>t.short===e)}function P(e,t,s){if(t.validate){let r=t.validate(s);if(r)return r}if(t.ignored||!t.target)return;let n=t.parse?t.parse(s):s;t.multi?e[t.target].push(n):e[t.target]=n}function ce(e,t){let s=e[t];if(s==="--sort"&&t+1<e.length){let n=e[t+1];if(n==="path"||n==="none")return{value:n,newIndex:t+1}}if(s.startsWith("--sort=")){let n=s.slice(7);if(n==="path"||n==="none")return{value:n,newIndex:t}}return null}function fe(e,t){let s=e[t],n=s.match(/^-([ABC])(\d+)$/);return n?{flag:n[1],value:parseInt(n[2],10),newIndex:t}:(s==="-A"||s==="-B"||s==="-C")&&t+1<e.length?{flag:s[1],value:parseInt(e[t+1],10),newIndex:t+1}:null}function ue(e){let t=e.match(/^-m(\d+)$/);return t?parseInt(t[1],10):null}function K(e){let t=Z(),s=null,n=[],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 h=fe(e,c);if(h){let{flag:u,value:w,newIndex:g}=h;u==="A"?r=Math.max(r,w):u==="B"?l=Math.max(l,w):i=w,c=g;continue}let y=ue(a);if(y!==null){t.maxCount=y;continue}let x=oe(e,c,t);if(x){if(x.error)return{success:!1,error:x.error};c=x.newIndex;continue}let p=ce(e,c);if(p){t.sort=p.value,c=p.newIndex;continue}let b=a.startsWith("--")?[a]:a.slice(1).split(""),m=!1;for(let u of b){if(ie.has(u)){t.lineNumber=!0,o=!0;continue}if(u==="u"||u==="--unrestricted"){le(t);continue}if(u==="P"||u==="--pcre2")return{success:!1,error:{stdout:"",stderr:`rg: PCRE2 is not supported. Use standard regex syntax instead.
|
|
6
|
+
`,exitCode:1}};if(u.length===1){let g=ae(u);if(g){if(c+1>=e.length)return{success:!1,error:O("rg",`-${u}`)};let f=P(t,g,e[c+1]);if(f)return{success:!1,error:f};c++,m=!0;continue}}let w=re.get(u);if(w){w(t);continue}if(u.startsWith("--"))return{success:!1,error:O("rg",u)};if(u.length===1)return{success:!1,error:O("rg",`-${u}`)}}}else s===null&&t.patterns.length===0&&t.patternFiles.length===0?s=a:n.push(a)}return(r>=0||i>=0)&&(t.afterContext=Math.max(r>=0?r:0,i>=0?i:0)),(l>=0||i>=0)&&(t.beforeContext=Math.max(l>=0?l:0,i>=0?i:0)),s!==null&&t.patterns.push(s),(t.column||t.vimgrep)&&(o=!0),{success:!0,options:t,paths:n,explicitLineNumbers:o}}import{gunzipSync as he}from"node:zlib";var T=class{patterns=[];basePath;constructor(t="/"){this.basePath=t}parse(t){let s=t.split(`
|
|
7
|
+
`);for(let n of s){let r=n.replace(/\s+$/,"");if(!r||r.startsWith("#"))continue;let l=!1;r.startsWith("!")&&(l=!0,r=r.slice(1));let i=!1;r.endsWith("/")&&(i=!0,r=r.slice(0,-1));let o=!1;r.startsWith("/")?(o=!0,r=r.slice(1)):r.includes("/")&&!r.startsWith("**/")&&(o=!0);let c=this.patternToRegex(r,o);this.patterns.push({pattern:n,regex:c,negated:l,directoryOnly:i,rooted:o})}}patternToRegex(t,s){let n="";s?n="^":n="(?:^|/)";let r=0;for(;r<t.length;){let l=t[r];if(l==="*")t[r+1]==="*"?t[r+2]==="/"?(n+="(?:.*/)?",r+=3):(r+2>=t.length,n+=".*",r+=2):(n+="[^/]*",r++);else if(l==="?")n+="[^/]",r++;else if(l==="["){let i=r+1;for(i<t.length&&t[i]==="!"&&i++,i<t.length&&t[i]==="]"&&i++;i<t.length&&t[i]!=="]";)i++;if(i<t.length){let o=t.slice(r,i+1);o.startsWith("[!")&&(o=`[^${o.slice(2)}`),n+=o,r=i+1}else n+="\\[",r++}else l==="/"?(n+="/",r++):(n+=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r++)}return n+="(?:/.*)?$",M(n)}matches(t,s){let n=t.replace(/^\.\//,"");n=n.replace(/^\//,"");let r=!1;for(let l of this.patterns)l.directoryOnly&&!s||l.regex.test(n)&&(r=!l.negated);return r}isWhitelisted(t,s){let n=t.replace(/^\.\//,"");n=n.replace(/^\//,"");for(let r of this.patterns)if(!(r.directoryOnly&&!s)&&r.negated&&r.regex.test(n))return!0;return!1}getBasePath(){return this.basePath}},N=class{parsers=[];fs;skipDotIgnore;skipVcsIgnore;loadedDirs=new Set;constructor(t,s,n=!1,r=!1){this.fs=t,this.skipDotIgnore=n,this.skipVcsIgnore=r}async load(t){let s=[],n=t;for(;;){s.unshift(n);let l=this.fs.resolvePath(n,"..");if(l===n)break;n=l}let r=[];this.skipVcsIgnore||r.push(".gitignore"),this.skipDotIgnore||r.push(".rgignore",".ignore");for(let l of s){this.loadedDirs.add(l);for(let i of r){let o=this.fs.resolvePath(l,i);try{let c=await this.fs.readFile(o),a=new T(l);a.parse(c),this.parsers.push(a)}catch{}}}}async loadForDirectory(t){if(this.loadedDirs.has(t))return;this.loadedDirs.add(t);let s=[];this.skipVcsIgnore||s.push(".gitignore"),this.skipDotIgnore||s.push(".rgignore",".ignore");for(let n of s){let r=this.fs.resolvePath(t,n);try{let l=await this.fs.readFile(r),i=new T(t);i.parse(l),this.parsers.push(i)}catch{}}}addPatternsFromContent(t,s){let n=new T(s);n.parse(t),this.parsers.push(n)}matches(t,s){for(let n of this.parsers){let r=n.getBasePath();if(!t.startsWith(r))continue;let l=t.slice(r.length).replace(/^\//,"");if(n.matches(l,s))return!0}return!1}isWhitelisted(t,s){for(let n of this.parsers){let r=n.getBasePath();if(!t.startsWith(r))continue;let l=t.slice(r.length).replace(/^\//,"");if(n.isWhitelisted(l,s))return!0}return!1}static isCommonIgnored(t){return new Set(["node_modules",".git",".svn",".hg","__pycache__",".pytest_cache",".mypy_cache","venv",".venv",".next",".nuxt",".cargo"]).has(t)}};async function R(e,t,s=!1,n=!1,r=[]){let l=new N(e,t,s,n);await l.load(t);for(let i of r)try{let o=e.resolvePath(t,i),c=await e.readFile(o);l.addPatternsFromContent(c,t)}catch{}return l}function ge(e){return e.length>=2&&e[0]===31&&e[1]===139}function pe(e){let t=!1;for(let s=0;s<e.length;s++){let n=e[s];n==="["&&!t?t=!0:n==="]"&&t&&(t=!1)}return t?`rg: glob '${e}' has an unclosed character class`:null}async function X(e){let{ctx:t,options:s,paths:n,explicitLineNumbers:r}=e;for(let g of s.globs){let f=g.startsWith("!")?g.slice(1):g,d=pe(f);if(d)return{stdout:"",stderr:`${d}
|
|
8
|
+
`,exitCode:1}}if(s.files){let g=[...s.patterns,...n];return xe(t,g,s)}let l=[...s.patterns];for(let g of s.patternFiles)try{let f;if(g==="-")f=D(t.stdin);else{let v=t.fs.resolvePath(t.cwd,g);f=await t.fs.readFile(v)}let d=f.split(`
|
|
9
|
+
`).filter(v=>v.length>0);l.push(...d)}catch{return{stdout:"",stderr:`rg: ${g}: No such file or directory
|
|
10
|
+
`,exitCode:2}}if(l.length===0)return s.patternFiles.length>0?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`rg: no pattern given
|
|
11
|
+
`,exitCode:2};let i=de(s,l),o,c;try{let g=me(l,s,i);o=g.regex,c=g.kResetGroup}catch{return{stdout:"",stderr:`rg: invalid regex: ${l.join(", ")}
|
|
12
|
+
`,exitCode:2}}let a=s.patternFiles.includes("-"),h=D(t.stdin);if(n.length===0&&h.length>0&&!a){let f=B(h,o,{invertMatch:s.invertMatch,showLineNumbers:s.lineNumber,countOnly:s.count,countMatches:s.countMatches,filename:"",onlyMatching:s.onlyMatching,beforeContext:s.beforeContext,afterContext:s.afterContext,maxCount:s.maxCount,contextSeparator:s.contextSeparator,showColumn:s.column,vimgrep:s.vimgrep,showByteOffset:s.byteOffset,replace:s.replace!==null?A(s.replace):null,passthru:s.passthru,multiline:s.multiline,kResetGroup:c});return s.quiet?{stdout:"",stderr:"",exitCode:f.matched?0:1}:s.filesWithMatches?{stdout:f.matched?`(standard input)
|
|
13
|
+
`:"",stderr:"",exitCode:f.matched?0:1}:s.filesWithoutMatch?{stdout:f.matched?"":`(standard input)
|
|
14
|
+
`,stderr:"",exitCode:f.matched?1:0}:{stdout:f.output,stderr:"",exitCode:f.matched?0:1}}let y=n.length===0?["."]:n,x=null;s.noIgnore||(x=await R(t.fs,t.cwd,s.noIgnoreDot,s.noIgnoreVcs,s.ignoreFiles));let p=new $;for(let g of s.typeClear)p.clearType(g);for(let g of s.typeAdd)p.addType(g);let{files:b,singleExplicitFile:m}=await Q(t,y,s,x,p);if(b.length===0)return{stdout:"",stderr:"",exitCode:1};let u=!s.noFilename&&(s.withFilename||!m||b.length>1),w=s.lineNumber;return r||(m&&b.length===1&&(w=!1),s.onlyMatching&&(w=!1)),we(t,b,o,s,u,w,c)}function de(e,t){return e.caseSensitive?!1:e.ignoreCase?!0:e.smartCase?!t.some(s=>/[A-Z]/.test(s)):!1}function me(e,t,s){let n;return e.length===1?n=e[0]:n=e.map(r=>t.fixedStrings?r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):`(?:${r})`).join("|"),U(n,{mode:t.fixedStrings&&e.length===1?"fixed":"perl",ignoreCase:s,wholeWord:t.wordRegexp,lineRegexp:t.lineRegexp,multiline:t.multiline,multilineDotall:t.multilineDotall})}async function Q(e,t,s,n,r){let l=[],i=0,o=0;for(let a of t){let h=e.fs.resolvePath(e.cwd,a);try{let y=await e.fs.stat(h);if(y.isFile){if(i++,s.maxFilesize>0&&y.size>s.maxFilesize)continue;te(a,s,n,h,r)&&l.push(a)}else y.isDirectory&&(o++,await ee(e,a,h,0,s,n,r,l))}catch{}}return{files:s.sort==="path"?l.sort():l,singleExplicitFile:i===1&&o===0}}async function ee(e,t,s,n,r,l,i,o){if(!(n>=r.maxDepth)){l&&await l.loadForDirectory(s);try{let c=e.fs.readdirWithFileTypes?await e.fs.readdirWithFileTypes(s):(await e.fs.readdir(s)).map(a=>({name:a,isFile:void 0}));for(let a of c){let h=a.name;if(!r.noIgnore&&N.isCommonIgnored(h))continue;let y=h.startsWith("."),x=t==="."?h:t==="./"?`./${h}`:t.endsWith("/")?`${t}${h}`:`${t}/${h}`,p=e.fs.resolvePath(s,h),b,m,u=!1;if(a.isFile!==void 0&&"isDirectory"in a){let f=a;if(u=f.isSymbolicLink===!0,u&&!r.followSymlinks)continue;if(u&&r.followSymlinks)try{let d=await e.fs.stat(p);b=d.isFile,m=d.isDirectory}catch{continue}else b=f.isFile,m=f.isDirectory}else try{let f=e.fs.lstat?await e.fs.lstat(p):await e.fs.stat(p);if(u=f.isSymbolicLink===!0,u&&!r.followSymlinks)continue;let d=u&&r.followSymlinks?await e.fs.stat(p):f;b=d.isFile,m=d.isDirectory}catch{continue}if(!l?.matches(p,m)&&!(y&&!r.hidden&&!l?.isWhitelisted(p,m))){if(m)await ee(e,x,p,n+1,r,l,i,o);else if(b){if(r.maxFilesize>0)try{if((await e.fs.stat(p)).size>r.maxFilesize)continue}catch{continue}te(x,r,l,p,i)&&o.push(x)}}}}catch{}}}function te(e,t,s,n,r){let l=e.split("/").pop()||e;if(s?.matches(n,!1)||t.types.length>0&&!r.matchesType(l,t.types)||t.typesNot.length>0&&r.matchesType(l,t.typesNot))return!1;if(t.globs.length>0){let i=t.globCaseInsensitive,o=t.globs.filter(a=>!a.startsWith("!")),c=t.globs.filter(a=>a.startsWith("!")).map(a=>a.slice(1));if(o.length>0){let a=!1;for(let h of o)if(C(l,h,i)||C(e,h,i)){a=!0;break}if(!a)return!1}for(let a of c)if(a.startsWith("/")){let h=a.slice(1);if(C(e,h,i))return!1}else if(C(l,a,i)||C(e,a,i))return!1}if(t.iglobs.length>0){let i=t.iglobs.filter(c=>!c.startsWith("!")),o=t.iglobs.filter(c=>c.startsWith("!")).map(c=>c.slice(1));if(i.length>0){let c=!1;for(let a of i)if(C(l,a,!0)||C(e,a,!0)){c=!0;break}if(!c)return!1}for(let c of o)if(c.startsWith("/")){let a=c.slice(1);if(C(e,a,!0))return!1}else if(C(l,c,!0)||C(e,c,!0))return!1}return!0}function C(e,t,s=!1){let n="^";for(let r=0;r<t.length;r++){let l=t[r];if(l==="*")t[r+1]==="*"?(n+=".*",r++):n+="[^/]*";else if(l==="?")n+="[^/]";else if(l==="["){let i=r+1;for(i<t.length&&t[i]==="!"&&i++,i<t.length&&t[i]==="]"&&i++;i<t.length&&t[i]!=="]";)i++;if(i<t.length){let o=t.slice(r,i+1);o.startsWith("[!")&&(o=`[^${o.slice(2)}`),n+=o,r=i}else n+="\\["}else n+=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return n+="$",M(n,s?"i":"").test(e)}async function xe(e,t,s){let n=null;s.noIgnore||(n=await R(e.fs,e.cwd,s.noIgnoreDot,s.noIgnoreVcs,s.ignoreFiles));let r=new $;for(let a of s.typeClear)r.clearType(a);for(let a of s.typeAdd)r.addType(a);let l=t.length===0?["."]:t,{files:i}=await Q(e,l,s,n,r);if(i.length===0)return{stdout:"",stderr:"",exitCode:1};if(s.quiet)return{stdout:"",stderr:"",exitCode:0};let o=s.nullSeparator?"\0":`
|
|
15
|
+
`;return{stdout:i.map(a=>a+o).join(""),stderr:"",exitCode:0}}function ye(e,t){if(t.length===0)return!0;for(let s of t)if(C(e,s,!1))return!0;return!1}async function be(e,t,s,n){try{if(n.preprocessor&&e.exec){let i=s.split("/").pop()||s;if(ye(i,n.preprocessorGlobs)){let o=await e.exec(q([n.preprocessor]),{cwd:e.cwd,signal:e.signal,args:[t]});if(o.exitCode===0&&o.stdout){let c=D(o.stdout),a=c.slice(0,8192);return{content:c,isBinary:a.includes("\0")}}}}if(n.searchZip&&s.endsWith(".gz")){let i=await e.fs.readFileBuffer(t);if(ge(i))try{let o=he(i),c=new TextDecoder().decode(o),a=c.slice(0,8192);return{content:c,isBinary:a.includes("\0")}}catch{return null}}let r=await e.fs.readFile(t),l=r.slice(0,8192);return{content:r,isBinary:l.includes("\0")}}catch{return null}}async function we(e,t,s,n,r,l,i){let o="",c=!1,a=[],h=0,y=0,x=0,p=50;e:for(let u=0;u<t.length;u+=p){let w=t.slice(u,u+p),g=await Promise.all(w.map(async f=>{let d=e.fs.resolvePath(e.cwd,f),v=await be(e,d,f,n);if(!v)return null;let{content:F,isBinary:W}=v;if(x+=F.length,W&&!n.searchBinary)return null;let k=r&&!n.heading?f:"",I=B(F,s,{invertMatch:n.invertMatch,showLineNumbers:l,countOnly:n.count,countMatches:n.countMatches,filename:k,onlyMatching:n.onlyMatching,beforeContext:n.beforeContext,afterContext:n.afterContext,maxCount:n.maxCount,contextSeparator:n.contextSeparator,showColumn:n.column,vimgrep:n.vimgrep,showByteOffset:n.byteOffset,replace:n.replace!==null?A(n.replace):null,passthru:n.passthru,multiline:n.multiline,kResetGroup:i});return n.json&&I.matched?{file:f,result:I,content:F,isBinary:!1}:{file:f,result:I}}));for(let f of g){if(!f)continue;let{file:d,result:v}=f;if(v.matched){if(c=!0,y++,h+=v.matchCount,n.quiet&&!n.json)break e;if(n.json&&!n.quiet){let F=f.content||"";a.push(JSON.stringify({type:"begin",data:{path:{text:d}}}));let W=F.split(`
|
|
16
|
+
`);s.lastIndex=0;let k=0;for(let I=0;I<W.length;I++){let j=W[I];s.lastIndex=0;let L=[];for(let S=s.exec(j);S!==null;S=s.exec(j)){let _={match:{text:S[0]},start:S.index,end:S.index+S[0].length};n.replace!==null&&(_.replacement={text:n.replace}),L.push(_),S[0].length===0&&s.lastIndex++}if(L.length>0){let S={type:"match",data:{path:{text:d},lines:{text:`${j}
|
|
17
|
+
`},line_number:I+1,absolute_offset:k,submatches:L}};a.push(JSON.stringify(S))}k+=j.length+1}a.push(JSON.stringify({type:"end",data:{path:{text:d},binary_offset:null,stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:1,searches_with_match:1,bytes_searched:F.length,bytes_printed:0,matched_lines:v.matchCount,matches:v.matchCount}}}))}else if(n.filesWithMatches){let F=n.nullSeparator?"\0":`
|
|
18
|
+
`;o+=`${d}${F}`}else n.filesWithoutMatch||(n.heading&&!n.noFilename&&(o+=`${d}
|
|
19
|
+
`),o+=v.output)}else if(n.filesWithoutMatch){let F=n.nullSeparator?"\0":`
|
|
20
|
+
`;o+=`${d}${F}`}else n.includeZero&&(n.count||n.countMatches)&&(o+=v.output)}}n.json&&(a.push(JSON.stringify({type:"summary",data:{elapsed_total:{secs:0,nanos:0,human:"0s"},stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:t.length,searches_with_match:y,bytes_searched:x,bytes_printed:0,matched_lines:h,matches:h}}})),o=`${a.join(`
|
|
21
|
+
`)}
|
|
22
|
+
`);let b=n.quiet&&!n.json?"":o;if(n.stats&&!n.json){let u=["",`${h} matches`,`${h} matched lines`,`${y} files contained matches`,`${t.length} files searched`,`${x} bytes searched`].join(`
|
|
23
|
+
`);b+=`${u}
|
|
24
|
+
`}let m;return n.filesWithoutMatch?m=o.length>0?0:1:m=c?0:1,{stdout:b,stderr:"",exitCode:m}}var ve={name:"rg",summary:"recursively search for a pattern",usage:"rg [OPTIONS] PATTERN [PATH ...]",description:`rg (ripgrep) recursively searches directories for a regex pattern.
|
|
25
|
+
Unlike grep, rg is recursive by default and respects .gitignore files.
|
|
26
|
+
|
|
27
|
+
EXAMPLES:
|
|
28
|
+
rg foo Search for 'foo' in current directory
|
|
29
|
+
rg foo src/ Search in src/ directory
|
|
30
|
+
rg -i foo Case-insensitive search
|
|
31
|
+
rg -w foo Match whole words only
|
|
32
|
+
rg -t js foo Search only JavaScript files
|
|
33
|
+
rg -g '*.ts' foo Search files matching glob
|
|
34
|
+
rg --hidden foo Include hidden files
|
|
35
|
+
rg -l foo List files with matches only`,options:["-e, --regexp PATTERN search for PATTERN (can be used multiple times)","-f, --file FILE read patterns from FILE, one per line","-i, --ignore-case case-insensitive search","-s, --case-sensitive case-sensitive search (overrides smart-case)","-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)","-F, --fixed-strings treat pattern as literal string","-w, --word-regexp match whole words only","-x, --line-regexp match whole lines only","-v, --invert-match select non-matching lines","-r, --replace TEXT replace matches with TEXT","-c, --count print count of matching lines per file"," --count-matches print count of individual matches per file","-l, --files-with-matches print only file names with matches"," --files-without-match print file names without matches"," --files list files that would be searched","-o, --only-matching print only matching parts","-m, --max-count NUM stop after NUM matches per file","-q, --quiet suppress output, exit 0 on match"," --stats print search statistics","-n, --line-number print line numbers (default: on)","-N, --no-line-number do not print line numbers","-I, --no-filename suppress the prefixing of file names","-0, --null use NUL as filename separator","-b, --byte-offset show byte offset of each match"," --column show column number of first match"," --vimgrep show results in vimgrep format"," --json show results in JSON Lines format","-A NUM print NUM lines after each match","-B NUM print NUM lines before each match","-C NUM print NUM lines before and after each match"," --context-separator SEP separator for context groups (default: --)","-U, --multiline match patterns across lines","-z, --search-zip search in compressed files (gzip only)","-g, --glob GLOB include files matching GLOB","-t, --type TYPE only search files of TYPE (e.g., js, py, ts)","-T, --type-not TYPE exclude files of TYPE","-L, --follow follow symbolic links","-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)","-a, --text search binary files as text"," --hidden search hidden files and directories"," --no-ignore don't respect .gitignore/.ignore files","-d, --max-depth NUM maximum search depth"," --sort TYPE sort files (path, none)"," --heading show file path above matches"," --passthru print all lines (non-matches use - separator)"," --include-zero include files with 0 matches in count output"," --type-list list all available file types"," --help display this help and exit"]},Ge={name:"rg",async execute(e,t){if(E(e))return z(ve);if(e.includes("--type-list"))return{stdout:V(),stderr:"",exitCode:0};let s=K(e);return s.success?X({ctx:t,options:s.options,paths:s.paths,explicitLineNumbers:s.explicitLineNumbers}):s.error}},qe={name:"rg",flags:[{flag:"-i",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-N",type:"boolean"},{flag:"--hidden",type:"boolean"},{flag:"--no-ignore",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-g",type:"value",valueHint:"pattern"},{flag:"-t",type:"value",valueHint:"string"},{flag:"-T",type:"value",valueHint:"string"}],needsArgs:!0};export{Ge as a,qe as b};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{a as $l}from"./chunk-4I3HOE5Z.js";import{a as Be,b as er}from"./chunk-
|
|
2
|
+
import{a as $l}from"./chunk-4I3HOE5Z.js";import{a as Be,b as er}from"./chunk-J3LJZWL2.js";import{d as D}from"./chunk-4WKZNNJK.js";import{a as Qi,b as Zi}from"./chunk-KAPG5ONA.js";import{a as Bs}from"./chunk-VACKIICN.js";import{c as Hi}from"./chunk-XEKXHOPO.js";import{k as Vs}from"./chunk-SAI2SPQQ.js";import{a as js}from"./chunk-FOCWZZDE.js";import{a as Xi,b as zi,c as he}from"./chunk-QAYAQNCG.js";import{a as Ot,c as w,e as Fs}from"./chunk-BZUGFHVS.js";var xr=w((xm,_r)=>{var{hasOwnProperty:nn}=Object.prototype,rn=(s,e={})=>{typeof e=="string"&&(e={section:e}),e.align=e.align===!0,e.newline=e.newline===!0,e.sort=e.sort===!0,e.whitespace=e.whitespace===!0||e.align===!0,e.platform=e.platform||typeof process<"u"&&process.platform,e.bracketedArray=e.bracketedArray!==!1;let t=e.platform==="win32"?`\r
|
|
3
3
|
`:`
|
|
4
4
|
`,n=e.whitespace?" = ":"=",i=[],r=e.sort?Object.keys(s).sort():Object.keys(s),o=0;e.align&&(o=z(r.filter(c=>s[c]===null||Array.isArray(s[c])||typeof s[c]!="object").map(c=>Array.isArray(s[c])?`${c}[]`:c).concat([""]).reduce((c,u)=>z(c).length>=z(u).length?c:u)).length);let a="",l=e.bracketedArray?"[]":"";for(let c of r){let u=s[c];if(u&&Array.isArray(u))for(let f of u)a+=z(`${c}${l}`).padEnd(o," ")+n+z(f)+t;else u&&typeof u=="object"?i.push(c):a+=z(c).padEnd(o," ")+n+z(u)+t}e.section&&a.length&&(a="["+z(e.section)+"]"+(e.newline?t+t:t)+a);for(let c of i){let u=qr(c,".").join("\\."),f=(e.section?e.section+".":"")+u,h=rn(s[c],{...e,section:f});a.length&&h.length&&(a+=t),a+=h}return a};function qr(s,e){var t=0,n=0,i=0,r=[];do if(i=s.indexOf(e,t),i!==-1){if(t=i+e.length,i>0&&s[i-1]==="\\")continue;r.push(s.slice(n,i)),n=i+e.length}while(i!==-1);return r.push(s.slice(n)),r}var Lr=(s,e={})=>{e.bracketedArray=e.bracketedArray!==!1;let t=Object.create(null),n=t,i=null,r=/^\[([^\]]*)\]\s*$|^([^=]+)(=(.*))?$/i,o=s.split(/[\r\n]+/g),a={};for(let c of o){if(!c||c.match(/^\s*[;#]/)||c.match(/^\s*$/))continue;let u=c.match(r);if(!u)continue;if(u[1]!==void 0){if(i=Mt(u[1]),i==="__proto__"){n=Object.create(null);continue}n=t[i]=t[i]||Object.create(null);continue}let f=Mt(u[2]),h;e.bracketedArray?h=f.length>2&&f.slice(-2)==="[]":(a[f]=(a?.[f]||0)+1,h=a[f]>1);let p=h&&f.endsWith("[]")?f.slice(0,-2):f;if(p==="__proto__")continue;let g=u[3]?Mt(u[4]):!0,d=g==="true"||g==="false"||g==="null"?JSON.parse(g):g;h&&(nn.call(n,p)?Array.isArray(n[p])||(n[p]=[n[p]]):n[p]=[]),Array.isArray(n[p])?n[p].push(d):n[p]=d}let l=[];for(let c of Object.keys(t)){if(!nn.call(t,c)||typeof t[c]!="object"||Array.isArray(t[c]))continue;let u=qr(c,".");n=t;let f=u.pop(),h=f.replace(/\\\./g,".");for(let p of u)p!=="__proto__"&&((!nn.call(n,p)||typeof n[p]!="object")&&(n[p]=Object.create(null)),n=n[p]);n===t&&h===f||(n[h]=t[c],l.push(c))}for(let c of l)delete t[c];return t},Pr=s=>s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"),z=s=>typeof s!="string"||s.match(/[=\r\n]/)||s.match(/^\[/)||s.length>1&&Pr(s)||s!==s.trim()?JSON.stringify(s):s.split(";").join("\\;").split("#").join("\\#"),Mt=s=>{if(s=(s||"").trim(),Pr(s)){s.charAt(0)==="'"&&(s=s.slice(1,-1));try{s=JSON.parse(s)}catch{}}else{let e=!1,t="";for(let n=0,i=s.length;n<i;n++){let r=s.charAt(n);if(e)"\\;#".indexOf(r)!==-1?t+=r:t+="\\"+r,e=!1;else{if(";#".indexOf(r)!==-1)break;r==="\\"?e=!0:t+=r}}return e&&(t+="\\"),t.trim()}return s};_r.exports={parse:Lr,decode:Lr,stringify:rn,encode:rn,safe:z,unsafe:Mt}});var C=w(x=>{"use strict";var un=Symbol.for("yaml.alias"),Ur=Symbol.for("yaml.document"),jt=Symbol.for("yaml.map"),Kr=Symbol.for("yaml.pair"),fn=Symbol.for("yaml.scalar"),Ut=Symbol.for("yaml.seq"),Q=Symbol.for("yaml.node.type"),zc=s=>!!s&&typeof s=="object"&&s[Q]===un,Qc=s=>!!s&&typeof s=="object"&&s[Q]===Ur,Zc=s=>!!s&&typeof s=="object"&&s[Q]===jt,eu=s=>!!s&&typeof s=="object"&&s[Q]===Kr,Yr=s=>!!s&&typeof s=="object"&&s[Q]===fn,tu=s=>!!s&&typeof s=="object"&&s[Q]===Ut;function Dr(s){if(s&&typeof s=="object")switch(s[Q]){case jt:case Ut:return!0}return!1}function su(s){if(s&&typeof s=="object")switch(s[Q]){case un:case jt:case fn:case Ut:return!0}return!1}var nu=s=>(Yr(s)||Dr(s))&&!!s.anchor;x.ALIAS=un;x.DOC=Ur;x.MAP=jt;x.NODE_TYPE=Q;x.PAIR=Kr;x.SCALAR=fn;x.SEQ=Ut;x.hasAnchor=nu;x.isAlias=zc;x.isCollection=Dr;x.isDocument=Qc;x.isMap=Zc;x.isNode=su;x.isPair=eu;x.isScalar=Yr;x.isSeq=tu});var He=w(hn=>{"use strict";var _=C(),V=Symbol("break visit"),Jr=Symbol("skip children"),H=Symbol("remove node");function Kt(s,e){let t=Gr(e);_.isDocument(s)?ke(null,s.contents,t,Object.freeze([s]))===H&&(s.contents=null):ke(null,s,t,Object.freeze([]))}Kt.BREAK=V;Kt.SKIP=Jr;Kt.REMOVE=H;function ke(s,e,t,n){let i=Wr(s,e,t,n);if(_.isNode(i)||_.isPair(i))return Hr(s,n,i),ke(s,i,t,n);if(typeof i!="symbol"){if(_.isCollection(e)){n=Object.freeze(n.concat(e));for(let r=0;r<e.items.length;++r){let o=ke(r,e.items[r],t,n);if(typeof o=="number")r=o-1;else{if(o===V)return V;o===H&&(e.items.splice(r,1),r-=1)}}}else if(_.isPair(e)){n=Object.freeze(n.concat(e));let r=ke("key",e.key,t,n);if(r===V)return V;r===H&&(e.key=null);let o=ke("value",e.value,t,n);if(o===V)return V;o===H&&(e.value=null)}}return i}async function Yt(s,e){let t=Gr(e);_.isDocument(s)?await Ie(null,s.contents,t,Object.freeze([s]))===H&&(s.contents=null):await Ie(null,s,t,Object.freeze([]))}Yt.BREAK=V;Yt.SKIP=Jr;Yt.REMOVE=H;async function Ie(s,e,t,n){let i=await Wr(s,e,t,n);if(_.isNode(i)||_.isPair(i))return Hr(s,n,i),Ie(s,i,t,n);if(typeof i!="symbol"){if(_.isCollection(e)){n=Object.freeze(n.concat(e));for(let r=0;r<e.items.length;++r){let o=await Ie(r,e.items[r],t,n);if(typeof o=="number")r=o-1;else{if(o===V)return V;o===H&&(e.items.splice(r,1),r-=1)}}}else if(_.isPair(e)){n=Object.freeze(n.concat(e));let r=await Ie("key",e.key,t,n);if(r===V)return V;r===H&&(e.key=null);let o=await Ie("value",e.value,t,n);if(o===V)return V;o===H&&(e.value=null)}}return i}function Gr(s){return typeof s=="object"&&(s.Collection||s.Node||s.Value)?Object.assign({Alias:s.Node,Map:s.Node,Scalar:s.Node,Seq:s.Node},s.Value&&{Map:s.Value,Scalar:s.Value,Seq:s.Value},s.Collection&&{Map:s.Collection,Seq:s.Collection},s):s}function Wr(s,e,t,n){if(typeof t=="function")return t(s,e,n);if(_.isMap(e))return t.Map?.(s,e,n);if(_.isSeq(e))return t.Seq?.(s,e,n);if(_.isPair(e))return t.Pair?.(s,e,n);if(_.isScalar(e))return t.Scalar?.(s,e,n);if(_.isAlias(e))return t.Alias?.(s,e,n)}function Hr(s,e,t){let n=e[e.length-1];if(_.isCollection(n))n.items[s]=t;else if(_.isPair(n))s==="key"?n.key=t:n.value=t;else if(_.isDocument(n))n.contents=t;else{let i=_.isAlias(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}hn.visit=Kt;hn.visitAsync=Yt});var dn=w(zr=>{"use strict";var Xr=C(),iu=He(),ru={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},ou=s=>s.replace(/[!,[\]{}]/g,e=>ru[e]),Xe=class s{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},s.defaultYaml,e),this.tags=Object.assign({},s.defaultTags,t)}clone(){let e=new s(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new s(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:s.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},s.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:s.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},s.defaultTags),this.atNextDocument=!1);let n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;let[r,o]=n;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=n;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{let o=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,o),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}let[,n,i]=e.match(/^(.*!)([^!]*)$/s);i||t(`The ${e} tag has no suffix`);let r=this.tags[n];if(r)try{return r+decodeURIComponent(i)}catch(o){return t(String(o)),null}return n==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+ou(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags),i;if(e&&n.length>0&&Xr.isNode(e.contents)){let r={};iu.visit(e.contents,(o,a)=>{Xr.isNode(a)&&a.tag&&(r[a.tag]=!0)}),i=Object.keys(r)}else i=[];for(let[r,o]of n)r==="!!"&&o==="tag:yaml.org,2002:"||(!e||i.some(a=>a.startsWith(o)))&&t.push(`%TAG ${r} ${o}`);return t.join(`
|
|
5
5
|
`)}};Xe.defaultYaml={explicit:!1,version:"1.2"};Xe.defaultTags={"!!":"tag:yaml.org,2002:"};zr.Directives=Xe});var Dt=w(ze=>{"use strict";var Qr=C(),au=He();function lu(s){if(/[\x00-\x19\s,[\]{}]/.test(s)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;throw new Error(t)}return!0}function Zr(s){let e=new Set;return au.visit(s,{Value(t,n){n.anchor&&e.add(n.anchor)}}),e}function eo(s,e){for(let t=1;;++t){let n=`${s}${t}`;if(!e.has(n))return n}}function cu(s,e){let t=[],n=new Map,i=null;return{onAnchor:r=>{t.push(r),i??(i=Zr(s));let o=eo(e,i);return i.add(o),o},setAnchors:()=>{for(let r of t){let o=n.get(r);if(typeof o=="object"&&o.anchor&&(Qr.isScalar(o.node)||Qr.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=r,a}}},sourceObjects:n}}ze.anchorIsValid=lu;ze.anchorNames=Zr;ze.createNodeAnchors=cu;ze.findNewAnchor=eo});var pn=w(to=>{"use strict";function Qe(s,e,t,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let i=0,r=n.length;i<r;++i){let o=n[i],a=Qe(s,n,String(i),o);a===void 0?delete n[i]:a!==o&&(n[i]=a)}else if(n instanceof Map)for(let i of Array.from(n.keys())){let r=n.get(i),o=Qe(s,n,i,r);o===void 0?n.delete(i):o!==r&&n.set(i,o)}else if(n instanceof Set)for(let i of Array.from(n)){let r=Qe(s,n,i,i);r===void 0?n.delete(i):r!==i&&(n.delete(i),n.add(r))}else for(let[i,r]of Object.entries(n)){let o=Qe(s,n,i,r);o===void 0?delete n[i]:o!==r&&(n[i]=o)}return s.call(e,t,n)}to.applyReviver=Qe});var se=w(no=>{"use strict";var uu=C();function so(s,e,t){if(Array.isArray(s))return s.map((n,i)=>so(n,String(i),t));if(s&&typeof s.toJSON=="function"){if(!t||!uu.hasAnchor(s))return s.toJSON(e,t);let n={aliasCount:0,count:1,res:void 0};t.anchors.set(s,n),t.onCreate=r=>{n.res=r,delete t.onCreate};let i=s.toJSON(e,t);return t.onCreate&&t.onCreate(i),i}return typeof s=="bigint"&&!t?.keep?Number(s):s}no.toJS=so});var Jt=w(ro=>{"use strict";var fu=pn(),io=C(),hu=se(),mn=class{constructor(e){Object.defineProperty(this,io.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:i,reviver:r}={}){if(!io.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},a=hu.toJS(this,"",o);if(typeof i=="function")for(let{count:l,res:c}of o.anchors.values())i(c,l);return typeof r=="function"?fu.applyReviver(r,{"":a},"",a):a}};ro.NodeBase=mn});var Ze=w(oo=>{"use strict";var du=Dt(),pu=He(),Le=C(),mu=Jt(),gu=se(),gn=class extends mu.NodeBase{constructor(e){super(Le.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],pu.visit(e,{Node:(r,o)=>{(Le.isAlias(o)||Le.hasAnchor(o))&&n.push(o)}}),t&&(t.aliasResolveCache=n));let i;for(let r of n){if(r===this)break;r.anchor===this.source&&(i=r)}return i}toJSON(e,t){if(!t)return{source:this.source};let{anchors:n,doc:i,maxAliasCount:r}=t,o=this.resolve(i,t);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=n.get(o);if(a||(gu.toJS(o,null,t),a=n.get(o)),a?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(r>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Gt(i,o,n)),a.count*a.aliasCount>r)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,t,n){let i=`*${this.source}`;if(e){if(du.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(r)}if(e.implicitKey)return`${i} `}return i}};function Gt(s,e,t){if(Le.isAlias(e)){let n=e.resolve(s),i=t&&n&&t.get(n);return i?i.count*i.aliasCount:0}else if(Le.isCollection(e)){let n=0;for(let i of e.items){let r=Gt(s,i,t);r>n&&(n=r)}return n}else if(Le.isPair(e)){let n=Gt(s,e.key,t),i=Gt(s,e.value,t);return Math.max(n,i)}return 1}oo.Alias=gn});var L=w(yn=>{"use strict";var yu=C(),bu=Jt(),wu=se(),Su=s=>!s||typeof s!="function"&&typeof s!="object",ne=class extends bu.NodeBase{constructor(e){super(yu.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:wu.toJS(this.value,e,t)}toString(){return String(this.value)}};ne.BLOCK_FOLDED="BLOCK_FOLDED";ne.BLOCK_LITERAL="BLOCK_LITERAL";ne.PLAIN="PLAIN";ne.QUOTE_DOUBLE="QUOTE_DOUBLE";ne.QUOTE_SINGLE="QUOTE_SINGLE";yn.Scalar=ne;yn.isScalarValue=Su});var et=w(lo=>{"use strict";var Nu=Ze(),me=C(),ao=L(),Au="tag:yaml.org,2002:";function Eu(s,e,t){if(e){let n=t.filter(r=>r.tag===e),i=n.find(r=>!r.format)??n[0];if(!i)throw new Error(`Tag ${e} not found`);return i}return t.find(n=>n.identify?.(s)&&!n.format)}function vu(s,e,t){if(me.isDocument(s)&&(s=s.contents),me.isNode(s))return s;if(me.isPair(s)){let f=t.schema[me.MAP].createNode?.(t.schema,null,t);return f.items.push(s),f}(s instanceof String||s instanceof Number||s instanceof Boolean||typeof BigInt<"u"&&s instanceof BigInt)&&(s=s.valueOf());let{aliasDuplicateObjects:n,onAnchor:i,onTagObj:r,schema:o,sourceObjects:a}=t,l;if(n&&s&&typeof s=="object"){if(l=a.get(s),l)return l.anchor??(l.anchor=i(s)),new Nu.Alias(l.anchor);l={anchor:null,node:null},a.set(s,l)}e?.startsWith("!!")&&(e=Au+e.slice(2));let c=Eu(s,e,o.tags);if(!c){if(s&&typeof s.toJSON=="function"&&(s=s.toJSON()),!s||typeof s!="object"){let f=new ao.Scalar(s);return l&&(l.node=f),f}c=s instanceof Map?o[me.MAP]:Symbol.iterator in Object(s)?o[me.SEQ]:o[me.MAP]}r&&(r(c),delete t.onTagObj);let u=c?.createNode?c.createNode(t.schema,s,t):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(t.schema,s,t):new ao.Scalar(s);return e?u.tag=e:c.default||(u.tag=c.tag),l&&(l.node=u),u}lo.createNode=vu});var Ht=w(Wt=>{"use strict";var Tu=et(),X=C(),Cu=Jt();function bn(s,e,t){let n=t;for(let i=e.length-1;i>=0;--i){let r=e[i];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){let o=[];o[r]=n,n=o}else n=new Map([[r,n]])}return Tu.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:s,sourceObjects:new Map})}var co=s=>s==null||typeof s=="object"&&!!s[Symbol.iterator]().next().done,wn=class extends Cu.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(n=>X.isNode(n)||X.isPair(n)?n.clone(e):n),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(co(e))this.add(t);else{let[n,...i]=e,r=this.get(n,!0);if(X.isCollection(r))r.addIn(i,t);else if(r===void 0&&this.schema)this.set(n,bn(this.schema,i,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let i=this.get(t,!0);if(X.isCollection(i))return i.deleteIn(n);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...i]=e,r=this.get(n,!0);return i.length===0?!t&&X.isScalar(r)?r.value:r:X.isCollection(r)?r.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!X.isPair(t))return!1;let n=t.value;return n==null||e&&X.isScalar(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let i=this.get(t,!0);return X.isCollection(i)?i.hasIn(n):!1}setIn(e,t){let[n,...i]=e;if(i.length===0)this.set(n,t);else{let r=this.get(n,!0);if(X.isCollection(r))r.setIn(i,t);else if(r===void 0&&this.schema)this.set(n,bn(this.schema,i,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}};Wt.Collection=wn;Wt.collectionFromPath=bn;Wt.isEmptyPath=co});var tt=w(Xt=>{"use strict";var Ou=s=>s.replace(/^(?!$)(?: $)?/gm,"#");function Sn(s,e){return/^\n+$/.test(s)?s.substring(1):e?s.replace(/^(?! *$)/gm,e):s}var ku=(s,e,t)=>s.endsWith(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{b as yr}from"./chunk-HAIOEUEV.js";import{b as Ar}from"./chunk-
|
|
2
|
+
import{b as yr}from"./chunk-HAIOEUEV.js";import{b as Ar}from"./chunk-QM4DZQWX.js";import{b as $r}from"./chunk-6Y4TGEZL.js";import"./chunk-WKPK7M56.js";import"./chunk-4I3HOE5Z.js";import{c as Sr}from"./chunk-55LZFN6S.js";import{b as wr}from"./chunk-H2TS57O5.js";import{b as xr}from"./chunk-MQKGGNPS.js";import{b as vr}from"./chunk-2SMD2AUA.js";import{b as kr}from"./chunk-LI6PTSPD.js";import{b as qr}from"./chunk-SBBYKIYU.js";import{b as Cr}from"./chunk-4MZPEZTU.js";import{b as br}from"./chunk-KTL5PAHY.js";import{d as Ir,e as Mr,f as jr}from"./chunk-KWGBQNTV.js";import{b as tr}from"./chunk-XPK7ZFVA.js";import{b as lr}from"./chunk-2VDTE5BV.js";import{b as ur}from"./chunk-Y4LIDHSD.js";import{b as pr}from"./chunk-FLMHFDSN.js";import{b as er}from"./chunk-CQV3EITV.js";import{b as dr}from"./chunk-DVJY2RAX.js";import{b as cr}from"./chunk-GHB6M7KA.js";import"./chunk-AXMYAPFA.js";import{b as hr}from"./chunk-WVRWIZF5.js";import{c as or,d as ar}from"./chunk-HDRAUQK2.js";import{b as sr}from"./chunk-7EUWTCWK.js";import{c as ir,d as gr}from"./chunk-VBLMIJON.js";import{b as mr}from"./chunk-JA7M2FXG.js";import"./chunk-J3LJZWL2.js";import{b as Fr}from"./chunk-CN5XGDNN.js";import{b as zr}from"./chunk-CJFAMHFC.js";import{b as fr}from"./chunk-BU36VZYL.js";import{b as nr}from"./chunk-XZUZRAAC.js";import"./chunk-SX2HC7SO.js";import{b as R}from"./chunk-ZDPFA4L3.js";import{b as U}from"./chunk-FX4RBUYU.js";import{b as V}from"./chunk-7AISL3XV.js";import{b as W}from"./chunk-2VJJEDV2.js";import{c as X,d as Y}from"./chunk-A4R2GWRF.js";import{c as Z,d as _}from"./chunk-FHC24QSK.js";import{b as N}from"./chunk-UIJUTQPH.js";import{b as rr}from"./chunk-NGPDJCUE.js";import{b as G}from"./chunk-PYDWFCTN.js";import{b as H}from"./chunk-AAGO7IQ5.js";import{b as J}from"./chunk-MFDPAVC6.js";import{b as K}from"./chunk-6L65G6A7.js";import{b as L}from"./chunk-MIZIUC5M.js";import{b as O}from"./chunk-TA74ENH7.js";import{b as P}from"./chunk-LSLPJOYM.js";import{b as Q}from"./chunk-OVH44QKR.js";import{b as y}from"./chunk-5MV7Q5QB.js";import{b as A}from"./chunk-K5JMLDHX.js";import{b as $}from"./chunk-H7WISVP3.js";import{b as S}from"./chunk-6NYPZ4NX.js";import{b as T}from"./chunk-YRNR2VHY.js";import{b as B}from"./chunk-S2BIZAWY.js";import{b as D}from"./chunk-RCXNPPJY.js";import{b as E}from"./chunk-R4QNMLOB.js";import{b as w}from"./chunk-YWOZZRSK.js";import{b as x}from"./chunk-MTHXXA6H.js";import{b as v}from"./chunk-SETW5JBN.js";import"./chunk-TDD4NFYE.js";import{d as k,e as q,f as C}from"./chunk-GE6OQDB2.js";import"./chunk-QAJKDPNS.js";import{b}from"./chunk-JNYYVLEL.js";import"./chunk-4WKZNNJK.js";import"./chunk-KSBHIW2H.js";import{b as I}from"./chunk-IZ6KBTV7.js";import{b as M}from"./chunk-GRQJA2J7.js";import{b as j}from"./chunk-JTMQLUCH.js";import{b as t}from"./chunk-LPJEKUCB.js";import{b as l}from"./chunk-4JLVZKHC.js";import{b as u}from"./chunk-ZDIT6ST5.js";import{b as p}from"./chunk-YS4NUBYX.js";import{b as e}from"./chunk-WM5IJFMP.js";import{b as d}from"./chunk-SHKOQWO4.js";import{b as c}from"./chunk-WPGQVBSY.js";import{b as h}from"./chunk-TC2WHAIS.js";import"./chunk-PDUL32DM.js";import"./chunk-HBVMHTO5.js";import"./chunk-SY4HAUHP.js";import"./chunk-L2UW7DWF.js";import"./chunk-DLL7UR66.js";import"./chunk-KAPG5ONA.js";import"./chunk-VACKIICN.js";import"./chunk-7CSMHFIJ.js";import{b as i}from"./chunk-6SHYIICL.js";import{b as g}from"./chunk-MFRETFZB.js";import"./chunk-KTPCYKBB.js";import"./chunk-XEKXHOPO.js";import{b as m}from"./chunk-MJLETYZI.js";import"./chunk-RBQG6ZUG.js";import"./chunk-27JIFWUR.js";import"./chunk-SAI2SPQQ.js";import{b as F}from"./chunk-R4IFXNY5.js";import"./chunk-STHBFACM.js";import{b as z}from"./chunk-MLIO3BK2.js";import"./chunk-FOCWZZDE.js";import{b as f}from"./chunk-SJYEXC2Z.js";import"./chunk-QIQMJJZ4.js";import{b as n}from"./chunk-FZRQOL3C.js";import"./chunk-W5DWRFSU.js";import"./chunk-QAYAQNCG.js";import"./chunk-BZUGFHVS.js";var Er=[i,g,m,F,z,f,n,t,l,u,p,e,d,c,h,w,x,v,k,q,C,b,I,M,j,y,A,$,S,T,B,D,E,G,H,J,K,L,O,P,Q,R,U,V,W,X,Y,Z,_,N,rr,or,ar,sr,ir,gr,mr,Fr,zr,fr,nr,tr,lr,ur,pr,er,dr,cr,hr,wr,xr,vr,kr,qr,Cr,br,Ir,Mr,jr,yr,Ar,$r,Sr];function Tr(){return Er}var Br=new Map;for(let r of Tr())Br.set(r.name,new Set(r.flags.map(o=>o.flag)));function Fa(r,o,Dr){let a=Br.get(o);if(!(!a||a.size===0))for(let s of Dr)a.has(s)&&r.hit(`cmd:flag:${o}:${s}`)}export{Fa as emitFlagCoverage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-JA7M2FXG.js";import"./chunk-J3LJZWL2.js";import"./chunk-4WKZNNJK.js";import"./chunk-DLL7UR66.js";import"./chunk-KAPG5ONA.js";import"./chunk-VACKIICN.js";import"./chunk-7CSMHFIJ.js";import"./chunk-KTPCYKBB.js";import"./chunk-XEKXHOPO.js";import"./chunk-SAI2SPQQ.js";import"./chunk-STHBFACM.js";import"./chunk-FOCWZZDE.js";import"./chunk-QAYAQNCG.js";import"./chunk-BZUGFHVS.js";export{b as flagsForFuzzing,a as jqCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-JNYYVLEL.js";import"./chunk-4WKZNNJK.js";import"./chunk-KSBHIW2H.js";import"./chunk-L2UW7DWF.js";import"./chunk-7CSMHFIJ.js";import"./chunk-XEKXHOPO.js";import"./chunk-QAYAQNCG.js";import"./chunk-BZUGFHVS.js";export{b as flagsForFuzzing,a as rgCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-6Y4TGEZL.js";import"./chunk-WKPK7M56.js";import"./chunk-4I3HOE5Z.js";import"./chunk-J3LJZWL2.js";import"./chunk-4WKZNNJK.js";import"./chunk-DLL7UR66.js";import"./chunk-KAPG5ONA.js";import"./chunk-VACKIICN.js";import"./chunk-7CSMHFIJ.js";import"./chunk-KTPCYKBB.js";import"./chunk-XEKXHOPO.js";import"./chunk-SAI2SPQQ.js";import"./chunk-STHBFACM.js";import"./chunk-QAYAQNCG.js";import"./chunk-BZUGFHVS.js";export{b as flagsForFuzzing,a as xanCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire} from"node:module";const require=createRequire(import.meta.url);
|
|
2
|
-
import{a,b}from"./chunk-
|
|
2
|
+
import{a,b}from"./chunk-QM4DZQWX.js";import"./chunk-4I3HOE5Z.js";import"./chunk-J3LJZWL2.js";import"./chunk-4WKZNNJK.js";import"./chunk-DLL7UR66.js";import"./chunk-KAPG5ONA.js";import"./chunk-VACKIICN.js";import"./chunk-7CSMHFIJ.js";import"./chunk-XEKXHOPO.js";import"./chunk-SAI2SPQQ.js";import"./chunk-FOCWZZDE.js";import"./chunk-QAYAQNCG.js";import"./chunk-BZUGFHVS.js";export{b as flagsForFuzzing,a as yqCommand};
|