@tslite/core 0.1.0 → 0.2.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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var v=Object.defineProperty;var N=(e,r)=>{for(var o in r)v(e,o,{get:r[o],enumerable:true});};var y=class extends Error{constructor(r,o,a){super(o),this.name="TSLiteError",this.code=r,this.details=a;}};var x="#ast",M=/^[a-zA-Z_][a-zA-Z_0-9]*$/,E=["Identifier","MemberExpression","CallExpression","ArrowFunctionExpression","FunctionExpression","BinaryExpression","LogicalExpression","UnaryExpression","UpdateExpression","ConditionalExpression","AssignmentExpression","NewExpression","ArrayExpression","ObjectExpression","AwaitExpression","TemplateLiteral","TaggedTemplateExpression","SequenceExpression","ChainExpression","Program"];function A(e){return E.includes(e)}function g(e){return new y("invalid-ast-entry",`Invalid #ast entry type: "${e}". The #ast marker is used to embed executable logic inside JSON. Only expression types that can be used as VALUES are allowed: ${E.join(", ")}. "${e}" is not a valid entry point because it cannot be used as a value in JSON.`,{type:e,validTypes:E})}var b={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ChainExpression:["expression"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportExpression:["source"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],JsonExpression:[],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],PrivateIdentifier:[],Program:["body"],Property:["key","value"],PropertyDefinition:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"]},p={Sequence:0,Yield:1,Assignment:1,Conditional:2,ArrowFunction:2,Coalesce:3,LogicalOR:4,LogicalAND:5,BitwiseOR:6,BitwiseXOR:7,BitwiseAND:8,Equality:9,Relational:10,BitwiseSHIFT:11,Additive:12,Multiplicative:13,Exponentiation:14,Await:15,Unary:15,Postfix:16,OptionalChaining:17,Call:18,New:19,TaggedTemplate:20,Member:21,Primary:22},U={"??":p.Coalesce,"||":p.LogicalOR,"&&":p.LogicalAND,"|":p.BitwiseOR,"^":p.BitwiseXOR,"&":p.BitwiseAND,"==":p.Equality,"!=":p.Equality,"===":p.Equality,"!==":p.Equality,is:p.Equality,isnt:p.Equality,"<":p.Relational,">":p.Relational,"<=":p.Relational,">=":p.Relational,in:p.Relational,instanceof:p.Relational,"<<":p.BitwiseSHIFT,">>":p.BitwiseSHIFT,">>>":p.BitwiseSHIFT,"+":p.Additive,"-":p.Additive,"*":p.Multiplicative,"%":p.Multiplicative,"/":p.Multiplicative,"**":p.Exponentiation};var u={};N(u,{arrayExpression:()=>J,arrayPattern:()=>ke,arrowFunctionExpression:()=>ae,assignmentExpression:()=>re,assignmentProperty:()=>Be,ast:()=>C,awaitExpression:()=>oe,binaryExpression:()=>G,blockStatement:()=>ce,breakStatement:()=>Ae,callExpression:()=>z,catchClause:()=>fe,chainExpression:()=>Z,conditionalExpression:()=>ne,continueStatement:()=>ge,doWhileStatement:()=>Ce,emptyStatement:()=>be,expressionStatement:()=>ye,forInStatement:()=>he,forOfStatement:()=>we,forStatement:()=>Te,fromAstMarker:()=>D,functionDeclaration:()=>le,functionExpression:()=>pe,identifier:()=>W,ifStatement:()=>xe,importDeclaration:()=>_e,importDefaultSpecifier:()=>Re,importNamespaceSpecifier:()=>je,importSpecifier:()=>Le,json:()=>I,jsonExpression:()=>T,literal:()=>q,logicalExpression:()=>Q,memberExpression:()=>X,newExpression:()=>H,objectExpression:()=>$,objectPattern:()=>Pe,program:()=>Oe,property:()=>K,restElement:()=>Fe,returnStatement:()=>me,spreadElement:()=>Y,switchCase:()=>Ee,switchStatement:()=>de,templateElement:()=>se,templateLiteral:()=>ie,throwStatement:()=>ue,tryStatement:()=>Se,unaryExpression:()=>ee,updateExpression:()=>te,variableDeclaration:()=>De,variableDeclarator:()=>Ie,whileStatement:()=>Ne});var C=e=>{let{type:r,...o}=e;if(!r||typeof r!="string")throw new y("missing-node-type","ast() requires a node with a valid type property");if(!A(r))throw g(r);return {[x]:r,...o}},D=e=>{if(!e||typeof e!="object"||!(x in e))return e;let{[x]:r,...o}=e;return {type:r,...o}},W=e=>({type:"Identifier",name:e}),q=e=>e instanceof RegExp?{type:"Literal",value:e,regex:{pattern:e.source,flags:e.flags}}:typeof e=="bigint"?{type:"Literal",value:e,bigint:String(e)}:{type:"Literal",value:e},J=e=>({type:"ArrayExpression",elements:e}),$=e=>({type:"ObjectExpression",properties:e}),K=(e,r,o=false,a=false)=>({type:"Property",shorthand:o,computed:a,key:e,value:r,kind:"init"}),Y=e=>({type:"SpreadElement",argument:e}),z=(e,r,o=false)=>({type:"CallExpression",callee:e,arguments:r,optional:o}),H=(e,r)=>({type:"NewExpression",callee:e,arguments:r}),X=(e,r,o=false,a=false)=>({type:"MemberExpression",object:e,property:r,computed:o,optional:a}),Z=e=>({type:"ChainExpression",expression:e}),G=(e,r,o)=>({type:"BinaryExpression",left:r,right:o,operator:e}),Q=(e,r,o)=>({type:"LogicalExpression",operator:e,left:r,right:o}),ee=(e,r)=>({type:"UnaryExpression",operator:e,argument:r,prefix:true}),te=(e,r,o=false)=>({type:"UpdateExpression",operator:e,argument:r,prefix:o}),re=(e,r,o)=>({type:"AssignmentExpression",operator:e,left:r,right:o}),ne=(e,r,o)=>({type:"ConditionalExpression",test:e,consequent:r,alternate:o}),oe=e=>({type:"AwaitExpression",argument:e}),se=(e,r=false)=>({type:"TemplateElement",value:e,tail:r}),ie=(e,r)=>({type:"TemplateLiteral",quasis:e,expressions:r}),ae=(e,r,o=false,a=false)=>({type:"ArrowFunctionExpression",expression:r.type!="BlockStatement",generator:a,async:o,params:e,body:r}),pe=(e=null,r,o,a=false,l=false)=>({type:"FunctionExpression",id:e,params:r,body:o,async:a,generator:l}),le=(e,r,o,a=false,l=false)=>({type:"FunctionDeclaration",id:e,params:r,body:o,generator:a,async:l}),ce=e=>({type:"BlockStatement",body:e}),ye=e=>({type:"ExpressionStatement",expression:e}),me=e=>({type:"ReturnStatement",argument:e}),xe=(e,r,o=null)=>({type:"IfStatement",test:e,consequent:r,alternate:o}),de=(e,r)=>({type:"SwitchStatement",cases:r,discriminant:e}),Ee=(e,r)=>({type:"SwitchCase",consequent:r,test:e}),ue=e=>({type:"ThrowStatement",argument:e}),Se=(e,r,o=null)=>({type:"TryStatement",block:e,handler:r,finalizer:o}),fe=(e,r)=>({type:"CatchClause",param:e,body:r}),Ae=(e=null)=>({type:"BreakStatement",label:e}),ge=(e=null)=>({type:"ContinueStatement",label:e}),be=()=>({type:"EmptyStatement"}),Te=(e,r,o,a)=>({type:"ForStatement",init:e,test:r,update:o,body:a}),he=(e,r,o)=>({type:"ForInStatement",body:o,left:e,right:r}),we=(e,r,o,a=false)=>({type:"ForOfStatement",body:o,left:e,right:r,await:a}),Ne=(e,r)=>({type:"WhileStatement",test:e,body:r}),Ce=(e,r)=>({type:"DoWhileStatement",body:e,test:r}),De=(e,r)=>({type:"VariableDeclaration",declarations:r,kind:e}),Ie=(e,r=null)=>({type:"VariableDeclarator",id:e,init:r}),Pe=e=>({type:"ObjectPattern",properties:e}),ke=e=>({type:"ArrayPattern",elements:e}),Be=(e,r=e,o=false,a=false)=>({type:"Property",key:e,kind:"init",value:r,shorthand:o,computed:a,method:false}),Fe=e=>({type:"RestElement",argument:e}),Oe=(e,r="script")=>({type:"Program",body:e,sourceType:r}),T=e=>({type:"JsonExpression",body:e}),_e=(e,r)=>({type:"ImportDeclaration",specifiers:e,source:r}),Le=(e,r)=>({type:"ImportSpecifier",imported:e,local:r}),Re=e=>({type:"ImportDefaultSpecifier",local:e}),je=e=>({type:"ImportNamespaceSpecifier",local:e}),I=T;var Ve=(e="b")=>{class r{constructor(s){this.text=s;}}let o=(t,s)=>{if(typeof t!="object")return typeof t=="string"?`"${t}"`:typeof t=="bigint"?`${t}n`:String(t);if(!t)return "null";if(t instanceof RegExp)return t;if(Array.isArray(t))return `[${t.map(m=>o(m,s)).join(", ")}]`;if(!t.type)return t instanceof r?t.text:`${e}.jsonExpression(${JSON.stringify(t)})`;if(t.type in c)return c[t.type](t,s);throw new y("unknown-node-type","Unknown type: "+t.type,{type:t.type})},a=t=>`(${e}) => ${o(t)}`,l=t=>new Function("b",`return ${t}`)(u),n=(t,s,...m)=>{let f=[],h=false;return m.reverse().forEach(w=>{w===void 0?h&&f.push("false"):(f.push(o(w,t)),h=true);}),`${e}.${s}(${f.reverse().join(", ")})`},c={ArrayExpression:(t,s)=>n(t,"arrayExpression",t.elements),ArrayPattern:(t,s)=>n(t,"arrayPattern",t.elements),ArrowFunctionExpression:(t,s)=>n(t,"arrowFunctionExpression",t.params,t.body,t.async||void 0),AssignmentExpression:(t,s)=>n(t,"assignmentExpression",t.operator,t.left,t.right),AssignmentProperty:(t,s)=>n(t,"assignmentProperty",t.key,t.value||void 0,t.shorthand||void 0),AwaitExpression:(t,s)=>n(t,"awaitExpression",t.argument),BinaryExpression:(t,s)=>n(t,"binaryExpression",t.operator,t.left,t.right),BlockStatement:(t,s)=>n(t,"blockStatement",t.body),BreakStatement:(t,s)=>t.label?n(t,"breakStatement",t.label):n(t,"breakStatement"),CallExpression:(t,s)=>n(t,"callExpression",t.callee,t.arguments,t.optional||void 0),CatchClause:(t,s)=>n(t,"catchClause",t.param,t.body),ChainExpression:(t,s)=>n(t,"chainExpression",t.expression),ConditionalExpression:(t,s)=>n(t,"conditionalExpression",t.test,t.consequent,t.alternate),ContinueStatement:(t,s)=>n(t,"continueStatement",t.label),DoWhileStatement:(t,s)=>n(t,"doWhileStatement",t.body,t.test),EmptyStatement:(t,s)=>n(t,"emptyStatement"),ExpressionStatement:(t,s)=>n(t,"expressionStatement",t.expression),ForInStatement:(t,s)=>n(t,"forInStatement",t.left,t.right,t.body),ForOfStatement:(t,s)=>n(t,"forOfStatement",t.left,t.right,t.body),ForStatement:(t,s)=>n(t,"forStatement",t.init,t.test,t.update,t.body),FunctionDeclaration:(t,s)=>n(t,"functionDeclaration",t.id,t.params,t.body,t.generator||void 0,t.async||void 0),FunctionExpression:(t,s)=>n(t,"functionExpression",t.id||null,t.params,t.body,t.generator||void 0,t.async||void 0),Identifier:(t,s)=>n(t,"identifier",t.name),IfStatement:(t,s)=>n(t,"ifStatement",t.test,t.consequent,t.alternate),ImportDeclaration:(t,s)=>n(t,"importDeclaration",t.specifiers,t.source),ImportDefaultSpecifier:(t,s)=>n(t,"importDefaultSpecifier",t.local),ImportNamespaceSpecifier:(t,s)=>n(t,"importNamespaceSpecifier",t.local),ImportSpecifier:(t,s)=>n(t,"importSpecifier",t.imported,t.local),JsonExpression:(t,s)=>n(t,"jsonExpression",JSON.stringify(t.body)),Literal:(t,s)=>n(t,"literal",t.value),LogicalExpression:(t,s)=>n(t,"logicalExpression",t.operator,t.left,t.right),MemberExpression:(t,s)=>n(t,"memberExpression",t.object,t.property,t.computed||void 0,t.optional||void 0),NewExpression:(t,s)=>n(t,"newExpression",t.callee,t.arguments),ObjectExpression:(t,s)=>n(t,"objectExpression",t.properties),ObjectPattern:(t,s)=>n(t,"objectPattern",t.properties),Program:(t,s)=>n(t,"program",t.body),Property:(t,s)=>{if(s.type==="ObjectPattern")return n(t,"assignmentProperty",t.key,t.value,t.shorthand||void 0);if(s.type==="ObjectExpression")return n(t,"property",t.key,t.value,t.shorthand||void 0,t.computed||void 0)},ReturnStatement:(t,s)=>n(t,"returnStatement",t.argument),SwitchCase:(t,s)=>n(t,"switchCase",t.test,t.consequent),SwitchStatement:(t,s)=>n(t,"switchStatement",t.discriminant,t.cases),TemplateElement:(t,s)=>t.tail?n(t,"templateElement",new r(JSON.stringify(t.value)),true):n(t,"templateElement",new r(JSON.stringify(t.value))),TemplateLiteral:(t,s)=>n(t,"templateLiteral",t.quasis,t.expressions),ThrowStatement:(t,s)=>n(t,"throwStatement",t.argument),TryStatement:(t,s)=>n(t,"tryStatement",t.block,t.handler,t.finalizer),UnaryExpression:(t,s)=>n(t,"unaryExpression",t.operator,t.argument),UpdateExpression:(t,s)=>t.prefix==true?n(t,"updateExpression",t.operator,t.argument,true):n(t,"updateExpression",t.operator,t.argument),VariableDeclaration:(t,s)=>n(t,"variableDeclaration",t.kind,t.declarations),VariableDeclarator:(t,s)=>n(t,"variableDeclarator",t.id,t.init||void 0),WhileStatement:(t,s)=>n(t,"whileStatement",t.test,t.body),SpreadElement:(t,s)=>n(t,"spreadElement",t.argument),RestElement:(t,s)=>n(t,"restElement",t.argument)};return {build:o,buildFunction:a,safeEval:l,builders:c}};var _={};N(_,{isArrayExpression:()=>He,isArrayPattern:()=>Et,isArrowFunctionExpression:()=>$e,isAssignmentExpression:()=>tt,isAssignmentProperty:()=>Rt,isAwaitExpression:()=>rt,isBinaryExpression:()=>Je,isBlockStatement:()=>it,isBreakStatement:()=>lt,isCallExpression:()=>Ye,isCatchClause:()=>Ct,isConditionalExpression:()=>Xe,isContinueStatement:()=>ct,isDirective:()=>Lt,isDoWhileStatement:()=>wt,isEmptyStatement:()=>yt,isExpressionStatement:()=>st,isForInStatement:()=>Tt,isForOfStatement:()=>ht,isForStatement:()=>bt,isFunctionDeclaration:()=>ut,isFunctionExpression:()=>Ke,isIdentifier:()=>qe,isIfStatement:()=>pt,isImportDeclaration:()=>kt,isImportDefaultSpecifier:()=>Ft,isImportNamespaceSpecifier:()=>Ot,isImportSpecifier:()=>Bt,isJsonExpression:()=>ot,isLiteral:()=>We,isLogicalExpression:()=>Ze,isMemberExpression:()=>et,isModuleDeclaration:()=>_t,isNewExpression:()=>nt,isNode:()=>jt,isObjectExpression:()=>ze,isObjectPattern:()=>dt,isProgram:()=>St,isProperty:()=>O,isReturnStatement:()=>at,isSwitchCase:()=>At,isSwitchStatement:()=>ft,isTemplateElement:()=>It,isTemplateLiteral:()=>Pt,isThrowStatement:()=>Dt,isTryStatement:()=>Nt,isUnaryExpression:()=>Ge,isUpdateExpression:()=>Qe,isVariableDeclaration:()=>xt,isVariableDeclarator:()=>mt,isWhileStatement:()=>gt});var P=e=>typeof e=="object"&&e!==null&&typeof e.type=="string",ve=b;function d(e,r){let o=ve[e.type],a=e,l=(n,c)=>{if(n!=null)if(Array.isArray(n))for(let t=0;t<n.length;t++)P(n[t])&&r(n[t],c,t);else P(n)&&r(n,c,null);};if(o){for(let n of o)l(a[n],n);return}for(let n in a)Object.prototype.hasOwnProperty.call(a,n)&&l(a[n],n);}function k(e){let r=[];return d(e,o=>r.push(o)),r}function S(e,r){let o=false;function a(l,n){if(!l||o)return;let c=r[l.type]??r["*"],t=false;if(c){let s=c(l,n);if(s===false&&(t=true),s==="break"){o=true;return}}t||d(l,s=>{o||a(s,l);});}a(e,null);}var Me=new Proxy({fn:{}},{get(e,r){return {type:"Identifier",name:r}}}),i=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function B(e,r){let o;return S(e,{"*":a=>{if(r(a))return o=a,"break"}}),o}function F(e,r,o){let a=l=>{if(r(l))return o(l);if(Array.isArray(l)){let n=false,c=l.map(t=>{let s=a(t);return s!==t&&(n=true),s});return n?c:l}if(i(l)){let n=false,c={};for(let t in l){let s=l[t],m=a(s);c[t]=m,m!==s&&(n=true);}return n?c:l}return l};return a(e)}function Ue(e,r){let o={};return r.forEach(a=>{a in e&&(o[a]=e[a]);}),o}var We=e=>e?.type==="Literal"&&"value"in e,qe=e=>e?.type==="Identifier"&&typeof e.name=="string",Je=e=>e?.type==="BinaryExpression"&&i(e.left)&&i(e.right)&&typeof e.operator=="string",$e=e=>e?.type==="ArrowFunctionExpression"&&i(e.body),Ke=e=>e?.type==="FunctionExpression"&&i(e.body),Ye=e=>e?.type==="CallExpression"&&i(e.callee)&&Array.isArray(e.arguments),ze=e=>e?.type==="ObjectExpression"&&Array.isArray(e.properties),He=e=>e?.type==="ArrayExpression"&&Array.isArray(e.elements),Xe=e=>e?.type==="ConditionalExpression"&&i(e.test)&&i(e.consequent)&&i(e.alternate),Ze=e=>e?.type==="LogicalExpression"&&i(e.left)&&i(e.right)&&typeof e.operator=="string",Ge=e=>e?.type==="UnaryExpression"&&typeof e.operator=="string"&&i(e.argument),Qe=e=>e?.type==="UpdateExpression"&&typeof e.operator=="string"&&i(e.argument),et=e=>e?.type==="MemberExpression"&&i(e.object)&&i(e.property),tt=e=>e?.type==="AssignmentExpression"&&i(e.left)&&i(e.right)&&typeof e.operator=="string",rt=e=>e?.type==="AwaitExpression"&&"argument"in e,nt=e=>e?.type==="NewExpression"&&i(e.callee)&&Array.isArray(e.arguments),ot=e=>e?.type==="JsonExpression"&&i(e.body),st=e=>e?.type==="ExpressionStatement"&&i(e.expression),it=e=>e?.type==="BlockStatement"&&Array.isArray(e.body),at=e=>e?.type==="ReturnStatement",pt=e=>e?.type==="IfStatement"&&i(e.test)&&i(e.consequent),lt=e=>e?.type==="BreakStatement",ct=e=>e?.type==="ContinueStatement",yt=e=>e?.type==="EmptyStatement",mt=e=>e?.type==="VariableDeclarator"&&i(e.id),xt=e=>e?.type==="VariableDeclaration"&&Array.isArray(e.declarations),dt=e=>e?.type==="ObjectPattern"&&Array.isArray(e.properties),Et=e=>e?.type==="ArrayPattern"&&Array.isArray(e.elements),ut=e=>e?.type==="FunctionDeclaration"&&i(e.id)&&i(e.body),St=e=>e?.type==="Program"&&Array.isArray(e.body),ft=e=>e?.type==="SwitchStatement"&&i(e.discriminant)&&Array.isArray(e.cases),At=e=>e?.type==="SwitchCase"&&Array.isArray(e.consequent),gt=e=>e?.type==="WhileStatement"&&i(e.test)&&i(e.body),bt=e=>e?.type==="ForStatement"&&"body"in e,Tt=e=>e?.type==="ForInStatement"&&i(e.left)&&i(e.right)&&i(e.body),ht=e=>e?.type==="ForOfStatement"&&i(e.left)&&i(e.right)&&i(e.body),wt=e=>e?.type==="DoWhileStatement"&&i(e.body)&&i(e.test),Nt=e=>e?.type==="TryStatement"&&i(e.block),Ct=e=>e?.type==="CatchClause"&&i(e.body),Dt=e=>e?.type==="ThrowStatement"&&i(e.argument),It=e=>e?.type==="TemplateElement"&&i(e.value),Pt=e=>e?.type==="TemplateLiteral"&&Array.isArray(e.quasis)&&Array.isArray(e.expressions),kt=e=>e?.type==="ImportDeclaration"&&Array.isArray(e.specifiers)&&i(e.source),Bt=e=>e?.type==="ImportSpecifier"&&i(e.imported)&&i(e.local),Ft=e=>e?.type==="ImportDefaultSpecifier"&&i(e.local),Ot=e=>e?.type==="ImportNamespaceSpecifier"&&i(e.local),_t=e=>e?.type==="ModuleDeclaration",Lt=e=>e?.type==="Directive",O=e=>e?.type==="Property"&&i(e.key)&&i(e.value),Rt=e=>O(e),jt=e=>typeof e?.type=="string";var L=(e={})=>({vars:e,parent:null}),R=(e,r)=>({vars:r,parent:e});function j(e,r){for(let o=e;o;o=o.parent)if(Object.prototype.hasOwnProperty.call(o.vars,r))return o.vars[r]}function V(e){let r=new Map;for(let o=e;o;o=o.parent)for(let a of Object.keys(o.vars))r.has(a)||r.set(a,o.vars[a]);return r}exports.AST_MARKER=x;exports.BinaryPrecedence=U;exports.Mock=Me;exports.Precedence=p;exports.TSLiteError=y;exports.VALID_AST_ENTRY_TYPES=E;exports.VALID_OBJECT_KEY=M;exports.VisitorKeys=b;exports.ast=C;exports.builders=u;exports.childScope=R;exports.childrenOf=k;exports.find=B;exports.forEachChild=d;exports.fromAstMarker=D;exports.generateBuilders=Ve;exports.guards=_;exports.invalidAstEntryError=g;exports.isObject=i;exports.isValidAstEntryType=A;exports.json=I;exports.jsonExpression=T;exports.lookup=j;exports.mutate=F;exports.pick=Ue;exports.rootScope=L;exports.visibleNames=V;exports.walk=S;
1
+ 'use strict';var G=Object.defineProperty;var O=(e,r)=>{for(var n in r)G(e,n,{get:r[n],enumerable:true});};var y=class extends Error{constructor(r,n,i){super(n),this.name="TSLiteError",this.code=r,this.details=i;}};var u="#ast",Q=/^[a-zA-Z_][a-zA-Z_0-9]*$/,f=["Identifier","MemberExpression","CallExpression","ArrowFunctionExpression","FunctionExpression","BinaryExpression","LogicalExpression","UnaryExpression","UpdateExpression","ConditionalExpression","AssignmentExpression","NewExpression","ArrayExpression","ObjectExpression","AwaitExpression","TemplateLiteral","TaggedTemplateExpression","SequenceExpression","ChainExpression","JSXElement","JSXFragment","Program"];function h(e){return f.includes(e)}function N(e){return new y("invalid-ast-entry",`Invalid #ast entry type: "${e}". The #ast marker is used to embed executable logic inside JSON. Only expression types that can be used as VALUES are allowed: ${f.join(", ")}. "${e}" is not a valid entry point because it cannot be used as a value in JSON.`,{type:e,validTypes:f})}var w={AssignmentExpression:["left","right"],AssignmentPattern:["left","right"],ArrayExpression:["elements"],ArrayPattern:["elements"],ArrowFunctionExpression:["params","body"],AwaitExpression:["argument"],BlockStatement:["body"],BinaryExpression:["left","right"],BreakStatement:["label"],CallExpression:["callee","arguments"],CatchClause:["param","body"],ChainExpression:["expression"],ClassBody:["body"],ClassDeclaration:["id","superClass","body"],ClassExpression:["id","superClass","body"],ConditionalExpression:["test","consequent","alternate"],ContinueStatement:["label"],DebuggerStatement:[],DirectiveStatement:[],DoWhileStatement:["body","test"],EmptyStatement:[],ExpressionStatement:["expression"],ForStatement:["init","test","update","body"],ForInStatement:["left","right","body"],ForOfStatement:["left","right","body"],FunctionDeclaration:["id","params","body"],FunctionExpression:["id","params","body"],Identifier:[],IfStatement:["test","consequent","alternate"],ImportDeclaration:["specifiers","source"],ImportDefaultSpecifier:["local"],ImportExpression:["source"],ImportNamespaceSpecifier:["local"],ImportSpecifier:["imported","local"],JsonExpression:[],Literal:[],LabeledStatement:["label","body"],LogicalExpression:["left","right"],MemberExpression:["object","property"],MetaProperty:["meta","property"],MethodDefinition:["key","value"],ModuleSpecifier:[],NewExpression:["callee","arguments"],ObjectExpression:["properties"],ObjectPattern:["properties"],PrivateIdentifier:[],Program:["body"],Property:["key","value"],PropertyDefinition:["key","value"],RestElement:["argument"],ReturnStatement:["argument"],SequenceExpression:["expressions"],SpreadElement:["argument"],SwitchStatement:["discriminant","cases"],SwitchCase:["test","consequent"],TaggedTemplateExpression:["tag","quasi"],TemplateElement:[],TemplateLiteral:["quasis","expressions"],ThisExpression:[],ThrowStatement:["argument"],TryStatement:["block","handler","finalizer"],UnaryExpression:["argument"],UpdateExpression:["argument"],VariableDeclaration:["declarations"],VariableDeclarator:["id","init"],WhileStatement:["test","body"],WithStatement:["object","body"],JSXElement:["openingElement","children","closingElement"],JSXFragment:["openingFragment","children","closingFragment"],JSXOpeningElement:["name","attributes"],JSXClosingElement:["name"],JSXOpeningFragment:[],JSXClosingFragment:[],JSXAttribute:["name","value"],JSXSpreadAttribute:["argument"],JSXExpressionContainer:["expression"],JSXEmptyExpression:[],JSXText:[],JSXIdentifier:[],JSXMemberExpression:["object","property"],JSXNamespacedName:["namespace","name"]},l={Sequence:0,Yield:1,Assignment:1,Conditional:2,ArrowFunction:2,Coalesce:3,LogicalOR:4,LogicalAND:5,BitwiseOR:6,BitwiseXOR:7,BitwiseAND:8,Equality:9,Relational:10,BitwiseSHIFT:11,Additive:12,Multiplicative:13,Exponentiation:14,Await:15,Unary:15,Postfix:16,OptionalChaining:17,Call:18,New:19,TaggedTemplate:20,Member:21,Primary:22},ee={"??":l.Coalesce,"||":l.LogicalOR,"&&":l.LogicalAND,"|":l.BitwiseOR,"^":l.BitwiseXOR,"&":l.BitwiseAND,"==":l.Equality,"!=":l.Equality,"===":l.Equality,"!==":l.Equality,is:l.Equality,isnt:l.Equality,"<":l.Relational,">":l.Relational,"<=":l.Relational,">=":l.Relational,in:l.Relational,instanceof:l.Relational,"<<":l.BitwiseSHIFT,">>":l.BitwiseSHIFT,">>>":l.BitwiseSHIFT,"+":l.Additive,"-":l.Additive,"*":l.Multiplicative,"%":l.Multiplicative,"/":l.Multiplicative,"**":l.Exponentiation};var b={};O(b,{arrayExpression:()=>te,arrayPattern:()=>Le,arrowFunctionExpression:()=>xe,assignmentExpression:()=>pe,assignmentPattern:()=>Re,assignmentProperty:()=>je,ast:()=>k,awaitExpression:()=>ce,binaryExpression:()=>se,blockStatement:()=>ue,breakStatement:()=>we,callExpression:()=>D,catchClause:()=>Ne,chainExpression:()=>ne,conditionalExpression:()=>le,continueStatement:()=>Ce,doWhileStatement:()=>Fe,emptyStatement:()=>Je,exportDefaultDeclaration:()=>$e,exportNamedDeclaration:()=>qe,exportSpecifier:()=>Ke,expressionStatement:()=>de,forInStatement:()=>Ie,forOfStatement:()=>Pe,forStatement:()=>De,fromAstMarker:()=>B,functionDeclaration:()=>Se,functionExpression:()=>Ee,identifier:()=>E,ifStatement:()=>ge,importDeclaration:()=>Me,importDefaultSpecifier:()=>Ue,importNamespaceSpecifier:()=>We,importSpecifier:()=>ve,json:()=>_,jsonExpression:()=>P,jsxAttribute:()=>et,jsxClosingElement:()=>rt,jsxClosingFragment:()=>j,jsxElement:()=>st,jsxEmptyExpression:()=>Ze,jsxExpressionContainer:()=>Ge,jsxFragment:()=>ot,jsxIdentifier:()=>Ye,jsxMemberExpression:()=>ze,jsxNamespacedName:()=>He,jsxOpeningElement:()=>tt,jsxOpeningFragment:()=>L,jsxSpreadAttribute:()=>Qe,jsxText:()=>nt,literal:()=>x,logicalExpression:()=>oe,memberExpression:()=>I,newExpression:()=>re,objectExpression:()=>g,objectPattern:()=>Be,program:()=>Ve,property:()=>C,restElement:()=>_e,returnStatement:()=>fe,spreadElement:()=>J,switchCase:()=>Ae,switchStatement:()=>be,templateElement:()=>me,templateLiteral:()=>ye,throwStatement:()=>Te,tryStatement:()=>he,unaryExpression:()=>ie,updateExpression:()=>ae,variableDeclaration:()=>Oe,variableDeclarator:()=>ke,whileStatement:()=>Xe});var k=e=>{let{type:r,...n}=e;if(!r||typeof r!="string")throw new y("missing-node-type","ast() requires a node with a valid type property");if(!h(r))throw N(r);return {[u]:r,...n}},B=e=>{if(!e||typeof e!="object"||!(u in e))return e;let{[u]:r,...n}=e;return {type:r,...n}},E=e=>({type:"Identifier",name:e}),x=e=>e instanceof RegExp?{type:"Literal",value:e,regex:{pattern:e.source,flags:e.flags}}:typeof e=="bigint"?{type:"Literal",value:e,bigint:String(e)}:{type:"Literal",value:e},te=e=>({type:"ArrayExpression",elements:e}),g=e=>({type:"ObjectExpression",properties:e}),C=(e,r,n=false,i=false)=>({type:"Property",shorthand:n,computed:i,key:e,value:r,kind:"init"}),J=e=>({type:"SpreadElement",argument:e}),D=(e,r,n=false)=>({type:"CallExpression",callee:e,arguments:r,optional:n}),re=(e,r)=>({type:"NewExpression",callee:e,arguments:r}),I=(e,r,n=false,i=false)=>({type:"MemberExpression",object:e,property:r,computed:n,optional:i}),ne=e=>({type:"ChainExpression",expression:e}),se=(e,r,n)=>({type:"BinaryExpression",left:r,right:n,operator:e}),oe=(e,r,n)=>({type:"LogicalExpression",operator:e,left:r,right:n}),ie=(e,r)=>({type:"UnaryExpression",operator:e,argument:r,prefix:true}),ae=(e,r,n=false)=>({type:"UpdateExpression",operator:e,argument:r,prefix:n}),pe=(e,r,n)=>({type:"AssignmentExpression",operator:e,left:r,right:n}),le=(e,r,n)=>({type:"ConditionalExpression",test:e,consequent:r,alternate:n}),ce=e=>({type:"AwaitExpression",argument:e}),me=(e,r=false)=>({type:"TemplateElement",value:e,tail:r}),ye=(e,r)=>({type:"TemplateLiteral",quasis:e,expressions:r}),xe=(e,r,n=false,i=false)=>({type:"ArrowFunctionExpression",expression:r.type!="BlockStatement",generator:i,async:n,params:e,body:r}),Ee=(e=null,r,n,i=false,p=false)=>({type:"FunctionExpression",id:e,params:r,body:n,async:i,generator:p}),Se=(e,r,n,i=false,p=false)=>({type:"FunctionDeclaration",id:e,params:r,body:n,generator:i,async:p}),ue=e=>({type:"BlockStatement",body:e}),de=e=>({type:"ExpressionStatement",expression:e}),fe=e=>({type:"ReturnStatement",argument:e}),ge=(e,r,n=null)=>({type:"IfStatement",test:e,consequent:r,alternate:n}),be=(e,r)=>({type:"SwitchStatement",cases:r,discriminant:e}),Ae=(e,r)=>({type:"SwitchCase",consequent:r,test:e}),Te=e=>({type:"ThrowStatement",argument:e}),he=(e,r,n=null)=>({type:"TryStatement",block:e,handler:r,finalizer:n}),Ne=(e,r)=>({type:"CatchClause",param:e,body:r}),we=(e=null)=>({type:"BreakStatement",label:e}),Ce=(e=null)=>({type:"ContinueStatement",label:e}),Je=()=>({type:"EmptyStatement"}),De=(e,r,n,i)=>({type:"ForStatement",init:e,test:r,update:n,body:i}),Ie=(e,r,n)=>({type:"ForInStatement",body:n,left:e,right:r}),Pe=(e,r,n,i=false)=>({type:"ForOfStatement",body:n,left:e,right:r,await:i}),Xe=(e,r)=>({type:"WhileStatement",test:e,body:r}),Fe=(e,r)=>({type:"DoWhileStatement",body:e,test:r}),Oe=(e,r)=>({type:"VariableDeclaration",declarations:r,kind:e}),ke=(e,r=null)=>({type:"VariableDeclarator",id:e,init:r}),Be=e=>({type:"ObjectPattern",properties:e}),Le=e=>({type:"ArrayPattern",elements:e}),je=(e,r=e,n=false,i=false)=>({type:"Property",key:e,kind:"init",value:r,shorthand:n,computed:i,method:false}),_e=e=>({type:"RestElement",argument:e}),Re=(e,r)=>({type:"AssignmentPattern",left:e,right:r}),Ve=(e,r="script")=>({type:"Program",body:e,sourceType:r}),P=e=>({type:"JsonExpression",body:e}),Me=(e,r)=>({type:"ImportDeclaration",specifiers:e,source:r}),ve=(e,r)=>({type:"ImportSpecifier",imported:e,local:r}),Ue=e=>({type:"ImportDefaultSpecifier",local:e}),We=e=>({type:"ImportNamespaceSpecifier",local:e}),qe=(e=null,r=[],n=null)=>({type:"ExportNamedDeclaration",declaration:e,specifiers:r,source:n}),$e=e=>({type:"ExportDefaultDeclaration",declaration:e}),Ke=(e,r=e)=>({type:"ExportSpecifier",local:e,exported:r}),Ye=e=>({type:"JSXIdentifier",name:e}),ze=(e,r)=>({type:"JSXMemberExpression",object:e,property:r}),He=(e,r)=>({type:"JSXNamespacedName",namespace:e,name:r}),Ze=()=>({type:"JSXEmptyExpression"}),Ge=e=>({type:"JSXExpressionContainer",expression:e}),Qe=e=>({type:"JSXSpreadAttribute",argument:e}),et=(e,r=null)=>({type:"JSXAttribute",name:e,value:r}),tt=(e,r=[],n=false)=>({type:"JSXOpeningElement",name:e,attributes:r,selfClosing:n}),rt=e=>({type:"JSXClosingElement",name:e}),L=()=>({type:"JSXOpeningFragment"}),j=()=>({type:"JSXClosingFragment"}),nt=(e,r=e)=>({type:"JSXText",value:e,raw:r}),st=(e,r=[],n=null)=>({type:"JSXElement",openingElement:e,children:r,closingElement:n}),ot=(e=[],r=L(),n=j())=>({type:"JSXFragment",openingFragment:r,children:e,closingFragment:n}),_=P;var it=(e="b")=>{class r{constructor(o){this.text=o;}}let n=(t,o)=>{if(typeof t!="object")return typeof t=="string"?`"${t}"`:typeof t=="bigint"?`${t}n`:String(t);if(!t)return "null";if(t instanceof RegExp)return t;if(Array.isArray(t))return `[${t.map(S=>n(S,o)).join(", ")}]`;if(!t.type)return t instanceof r?t.text:`${e}.jsonExpression(${JSON.stringify(t)})`;if(t.type in m)return m[t.type](t,o);throw new y("unknown-node-type","Unknown type: "+t.type,{type:t.type})},i=t=>`(${e}) => ${n(t)}`,p=t=>new Function("b",`return ${t}`)(b),s=(t,o,...S)=>{let T=[],X=false;return S.reverse().forEach(F=>{F===void 0?X&&T.push("false"):(T.push(n(F,t)),X=true);}),`${e}.${o}(${T.reverse().join(", ")})`},m={ArrayExpression:(t,o)=>s(t,"arrayExpression",t.elements),ArrayPattern:(t,o)=>s(t,"arrayPattern",t.elements),ArrowFunctionExpression:(t,o)=>s(t,"arrowFunctionExpression",t.params,t.body,t.async||void 0),AssignmentExpression:(t,o)=>s(t,"assignmentExpression",t.operator,t.left,t.right),AssignmentProperty:(t,o)=>s(t,"assignmentProperty",t.key,t.value||void 0,t.shorthand||void 0),AwaitExpression:(t,o)=>s(t,"awaitExpression",t.argument),BinaryExpression:(t,o)=>s(t,"binaryExpression",t.operator,t.left,t.right),BlockStatement:(t,o)=>s(t,"blockStatement",t.body),BreakStatement:(t,o)=>t.label?s(t,"breakStatement",t.label):s(t,"breakStatement"),CallExpression:(t,o)=>s(t,"callExpression",t.callee,t.arguments,t.optional||void 0),CatchClause:(t,o)=>s(t,"catchClause",t.param,t.body),ChainExpression:(t,o)=>s(t,"chainExpression",t.expression),ConditionalExpression:(t,o)=>s(t,"conditionalExpression",t.test,t.consequent,t.alternate),ContinueStatement:(t,o)=>s(t,"continueStatement",t.label),DoWhileStatement:(t,o)=>s(t,"doWhileStatement",t.body,t.test),EmptyStatement:(t,o)=>s(t,"emptyStatement"),ExpressionStatement:(t,o)=>s(t,"expressionStatement",t.expression),ForInStatement:(t,o)=>s(t,"forInStatement",t.left,t.right,t.body),ForOfStatement:(t,o)=>s(t,"forOfStatement",t.left,t.right,t.body),ForStatement:(t,o)=>s(t,"forStatement",t.init,t.test,t.update,t.body),FunctionDeclaration:(t,o)=>s(t,"functionDeclaration",t.id,t.params,t.body,t.generator||void 0,t.async||void 0),FunctionExpression:(t,o)=>s(t,"functionExpression",t.id||null,t.params,t.body,t.generator||void 0,t.async||void 0),Identifier:(t,o)=>s(t,"identifier",t.name),IfStatement:(t,o)=>s(t,"ifStatement",t.test,t.consequent,t.alternate),ImportDeclaration:(t,o)=>s(t,"importDeclaration",t.specifiers,t.source),ImportDefaultSpecifier:(t,o)=>s(t,"importDefaultSpecifier",t.local),ImportNamespaceSpecifier:(t,o)=>s(t,"importNamespaceSpecifier",t.local),ImportSpecifier:(t,o)=>s(t,"importSpecifier",t.imported,t.local),JsonExpression:(t,o)=>s(t,"jsonExpression",JSON.stringify(t.body)),Literal:(t,o)=>s(t,"literal",t.value),LogicalExpression:(t,o)=>s(t,"logicalExpression",t.operator,t.left,t.right),MemberExpression:(t,o)=>s(t,"memberExpression",t.object,t.property,t.computed||void 0,t.optional||void 0),NewExpression:(t,o)=>s(t,"newExpression",t.callee,t.arguments),ObjectExpression:(t,o)=>s(t,"objectExpression",t.properties),ObjectPattern:(t,o)=>s(t,"objectPattern",t.properties),Program:(t,o)=>s(t,"program",t.body),Property:(t,o)=>{if(o.type==="ObjectPattern")return s(t,"assignmentProperty",t.key,t.value,t.shorthand||void 0);if(o.type==="ObjectExpression")return s(t,"property",t.key,t.value,t.shorthand||void 0,t.computed||void 0)},ReturnStatement:(t,o)=>s(t,"returnStatement",t.argument),SwitchCase:(t,o)=>s(t,"switchCase",t.test,t.consequent),SwitchStatement:(t,o)=>s(t,"switchStatement",t.discriminant,t.cases),TemplateElement:(t,o)=>t.tail?s(t,"templateElement",new r(JSON.stringify(t.value)),true):s(t,"templateElement",new r(JSON.stringify(t.value))),TemplateLiteral:(t,o)=>s(t,"templateLiteral",t.quasis,t.expressions),ThrowStatement:(t,o)=>s(t,"throwStatement",t.argument),TryStatement:(t,o)=>s(t,"tryStatement",t.block,t.handler,t.finalizer),UnaryExpression:(t,o)=>s(t,"unaryExpression",t.operator,t.argument),UpdateExpression:(t,o)=>t.prefix==true?s(t,"updateExpression",t.operator,t.argument,true):s(t,"updateExpression",t.operator,t.argument),VariableDeclaration:(t,o)=>s(t,"variableDeclaration",t.kind,t.declarations),VariableDeclarator:(t,o)=>s(t,"variableDeclarator",t.id,t.init||void 0),WhileStatement:(t,o)=>s(t,"whileStatement",t.test,t.body),SpreadElement:(t,o)=>s(t,"spreadElement",t.argument),RestElement:(t,o)=>s(t,"restElement",t.argument)};return {build:n,buildFunction:i,safeEval:p,builders:m}};var W={};O(W,{isArrayExpression:()=>dt,isArrayPattern:()=>jt,isArrowFunctionExpression:()=>xt,isAssignmentExpression:()=>ht,isAssignmentProperty:()=>sr,isAwaitExpression:()=>Nt,isBinaryExpression:()=>yt,isBlockStatement:()=>Dt,isBreakStatement:()=>Xt,isCallExpression:()=>St,isCatchClause:()=>Yt,isConditionalExpression:()=>ft,isContinueStatement:()=>Ft,isDirective:()=>nr,isDoWhileStatement:()=>$t,isEmptyStatement:()=>Ot,isExpressionStatement:()=>Jt,isForInStatement:()=>Wt,isForOfStatement:()=>qt,isForStatement:()=>Ut,isFunctionDeclaration:()=>_t,isFunctionExpression:()=>Et,isIdentifier:()=>mt,isIfStatement:()=>Pt,isImportDeclaration:()=>Gt,isImportDefaultSpecifier:()=>er,isImportNamespaceSpecifier:()=>tr,isImportSpecifier:()=>Qt,isJsonExpression:()=>Ct,isLiteral:()=>ct,isLogicalExpression:()=>gt,isMemberExpression:()=>Tt,isModuleDeclaration:()=>rr,isNewExpression:()=>wt,isNode:()=>or,isObjectExpression:()=>ut,isObjectPattern:()=>Lt,isProgram:()=>Rt,isProperty:()=>U,isReturnStatement:()=>It,isSwitchCase:()=>Mt,isSwitchStatement:()=>Vt,isTemplateElement:()=>Ht,isTemplateLiteral:()=>Zt,isThrowStatement:()=>zt,isTryStatement:()=>Kt,isUnaryExpression:()=>bt,isUpdateExpression:()=>At,isVariableDeclaration:()=>Bt,isVariableDeclarator:()=>kt,isWhileStatement:()=>vt});var R=e=>typeof e=="object"&&e!==null&&typeof e.type=="string",at=w;function d(e,r){let n=at[e.type],i=e,p=(s,m)=>{if(s!=null)if(Array.isArray(s))for(let t=0;t<s.length;t++)R(s[t])&&r(s[t],m,t);else R(s)&&r(s,m,null);};if(n){for(let s of n)p(i[s],s);return}for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&p(i[s],s);}function V(e){let r=[];return d(e,n=>r.push(n)),r}function A(e,r){let n=false;function i(p,s){if(!p||n)return;let m=r[p.type]??r["*"],t=false;if(m){let o=m(p,s);if(o===false&&(t=true),o==="break"){n=true;return}}t||d(p,o=>{n||i(o,p);});}i(e,null);}var pt=new Proxy({fn:{}},{get(e,r){return {type:"Identifier",name:r}}}),a=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function M(e,r){let n;return A(e,{"*":i=>{if(r(i))return n=i,"break"}}),n}function v(e,r,n){let i=p=>{if(r(p))return n(p);if(Array.isArray(p)){let s=false,m=p.map(t=>{let o=i(t);return o!==t&&(s=true),o});return s?m:p}if(a(p)){let s=false,m={};for(let t in p){let o=p[t],S=i(o);m[t]=S,S!==o&&(s=true);}return s?m:p}return p};return i(e)}function lt(e,r){let n={};return r.forEach(i=>{i in e&&(n[i]=e[i]);}),n}var ct=e=>e?.type==="Literal"&&"value"in e,mt=e=>e?.type==="Identifier"&&typeof e.name=="string",yt=e=>e?.type==="BinaryExpression"&&a(e.left)&&a(e.right)&&typeof e.operator=="string",xt=e=>e?.type==="ArrowFunctionExpression"&&a(e.body),Et=e=>e?.type==="FunctionExpression"&&a(e.body),St=e=>e?.type==="CallExpression"&&a(e.callee)&&Array.isArray(e.arguments),ut=e=>e?.type==="ObjectExpression"&&Array.isArray(e.properties),dt=e=>e?.type==="ArrayExpression"&&Array.isArray(e.elements),ft=e=>e?.type==="ConditionalExpression"&&a(e.test)&&a(e.consequent)&&a(e.alternate),gt=e=>e?.type==="LogicalExpression"&&a(e.left)&&a(e.right)&&typeof e.operator=="string",bt=e=>e?.type==="UnaryExpression"&&typeof e.operator=="string"&&a(e.argument),At=e=>e?.type==="UpdateExpression"&&typeof e.operator=="string"&&a(e.argument),Tt=e=>e?.type==="MemberExpression"&&a(e.object)&&a(e.property),ht=e=>e?.type==="AssignmentExpression"&&a(e.left)&&a(e.right)&&typeof e.operator=="string",Nt=e=>e?.type==="AwaitExpression"&&"argument"in e,wt=e=>e?.type==="NewExpression"&&a(e.callee)&&Array.isArray(e.arguments),Ct=e=>e?.type==="JsonExpression"&&a(e.body),Jt=e=>e?.type==="ExpressionStatement"&&a(e.expression),Dt=e=>e?.type==="BlockStatement"&&Array.isArray(e.body),It=e=>e?.type==="ReturnStatement",Pt=e=>e?.type==="IfStatement"&&a(e.test)&&a(e.consequent),Xt=e=>e?.type==="BreakStatement",Ft=e=>e?.type==="ContinueStatement",Ot=e=>e?.type==="EmptyStatement",kt=e=>e?.type==="VariableDeclarator"&&a(e.id),Bt=e=>e?.type==="VariableDeclaration"&&Array.isArray(e.declarations),Lt=e=>e?.type==="ObjectPattern"&&Array.isArray(e.properties),jt=e=>e?.type==="ArrayPattern"&&Array.isArray(e.elements),_t=e=>e?.type==="FunctionDeclaration"&&a(e.id)&&a(e.body),Rt=e=>e?.type==="Program"&&Array.isArray(e.body),Vt=e=>e?.type==="SwitchStatement"&&a(e.discriminant)&&Array.isArray(e.cases),Mt=e=>e?.type==="SwitchCase"&&Array.isArray(e.consequent),vt=e=>e?.type==="WhileStatement"&&a(e.test)&&a(e.body),Ut=e=>e?.type==="ForStatement"&&"body"in e,Wt=e=>e?.type==="ForInStatement"&&a(e.left)&&a(e.right)&&a(e.body),qt=e=>e?.type==="ForOfStatement"&&a(e.left)&&a(e.right)&&a(e.body),$t=e=>e?.type==="DoWhileStatement"&&a(e.body)&&a(e.test),Kt=e=>e?.type==="TryStatement"&&a(e.block),Yt=e=>e?.type==="CatchClause"&&a(e.body),zt=e=>e?.type==="ThrowStatement"&&a(e.argument),Ht=e=>e?.type==="TemplateElement"&&a(e.value),Zt=e=>e?.type==="TemplateLiteral"&&Array.isArray(e.quasis)&&Array.isArray(e.expressions),Gt=e=>e?.type==="ImportDeclaration"&&Array.isArray(e.specifiers)&&a(e.source),Qt=e=>e?.type==="ImportSpecifier"&&a(e.imported)&&a(e.local),er=e=>e?.type==="ImportDefaultSpecifier"&&a(e.local),tr=e=>e?.type==="ImportNamespaceSpecifier"&&a(e.local),rr=e=>e?.type==="ModuleDeclaration",nr=e=>e?.type==="Directive",U=e=>e?.type==="Property"&&a(e.key)&&a(e.value),sr=e=>U(e),or=e=>typeof e?.type=="string";var ir="createElement",ar="Fragment";function c(e,r){return r.start!==void 0&&(e.start=r.start),r.end!==void 0&&(e.end=r.end),r.loc!==void 0&&(e.loc=r.loc),r.range!==void 0&&(e.range=r.range),e}var pr=e=>/^[a-zA-Z_$][\w$]*$/.test(e);function q(e){return e.type==="JSXIdentifier"?c(/^[a-z]/.test(e.name)||e.name.includes("-")?x(e.name):E(e.name),e):e.type==="JSXNamespacedName"?c(x(`${e.namespace.name}:${e.name.name}`),e):c(I(q(e.object),c(E(e.property.name),e.property)),e)}function lr(e){return e.type==="JSXNamespacedName"?c(x(`${e.namespace.name}:${e.name.name}`),e):c(pr(e.name)?E(e.name):x(e.name),e)}function cr(e,r){return e===null?c(x(true),r):e.type==="JSXExpressionContainer"?e.expression:e}var $=(e,r)=>c(r.emptyPropsAsObject?g([]):x(null),e);function mr(e,r,n){if(e.length===0)return $(r,n);let i=e.map(p=>p.type==="JSXSpreadAttribute"?c(J(p.argument),p):c(C(lr(p.name),cr(p.value,p)),p));return c(g(i),r)}function yr(e){let r=e.split(/\r\n|\n|\r/),n=-1;for(let p=0;p<r.length;p++)/[^ \t]/.test(r[p])&&(n=p);let i="";for(let p=0;p<r.length;p++){let s=r[p].replace(/\t/g," ");p!==0&&(s=s.replace(/^ +/,"")),p!==r.length-1&&(s=s.replace(/ +$/,"")),s&&(p!==n&&(s+=" "),i+=s);}return i===""?null:i}function xr(e){if(e.type==="JSXText"){let r=yr(e.value);return r===null?null:c(x(r),e)}return e.type==="JSXExpressionContainer"?e.expression.type==="JSXEmptyExpression"?null:e.expression:e}function K(e,r={}){let n=e.type==="JSXFragment"?c(E(ar),e.openingFragment):q(e.openingElement.name),i=e.type==="JSXFragment"?$(e.openingFragment,r):mr(e.openingElement.attributes,e.openingElement,r),p=e.children.map(xr).filter(s=>s!==null);return c(D(c(E(ir),e),[n,i,...p]),e)}var Y=(e={})=>({vars:e,parent:null}),z=(e,r)=>({vars:r,parent:e});function H(e,r){for(let n=e;n;n=n.parent)if(Object.prototype.hasOwnProperty.call(n.vars,r))return n.vars[r]}function Z(e){let r=new Map;for(let n=e;n;n=n.parent)for(let i of Object.keys(n.vars))r.has(i)||r.set(i,n.vars[i]);return r}exports.AST_MARKER=u;exports.BinaryPrecedence=ee;exports.Mock=pt;exports.Precedence=l;exports.TSLiteError=y;exports.VALID_AST_ENTRY_TYPES=f;exports.VALID_OBJECT_KEY=Q;exports.VisitorKeys=w;exports.ast=k;exports.childScope=z;exports.childrenOf=V;exports.desugarJSX=K;exports.find=M;exports.forEachChild=d;exports.fromAstMarker=B;exports.generateBuilders=it;exports.guards=W;exports.invalidAstEntryError=N;exports.isObject=a;exports.isValidAstEntryType=h;exports.json=_;exports.jsonExpression=P;exports.lookup=H;exports.mutate=v;exports.pick=lt;exports.rootScope=Y;exports.visibleNames=Z;exports.walk=A;