@laot/bridge 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ltbridge.js CHANGED
@@ -1,29 +1,29 @@
1
1
  #!/usr/bin/env node
2
- var H=(d,s)=>()=>(s||d((s={exports:{}}).exports,s),s.exports);var Fe=H((jt,xn)=>{xn.exports={name:"@laot/bridge",version:"1.1.0",description:"LTBridge CLI for fetching and bundling FiveM modules.",license:"MIT",repository:{type:"git",url:"https://github.com/laot7490/ltbridge.git"},author:"laot",keywords:["fivem","lua","bridge","module-manager","bundler","cli","gta5","redm","laot","ltbridge"],main:"dist/ltbridge.js",scripts:{build:"node scripts/compiler.js && esbuild bin/ltbridge.js --bundle --minify --platform=node --target=node18 --packages=external --outfile=dist/ltbridge.js",zip:"node scripts/zip-dist.js",prepublishOnly:"npm run build && npm run zip"},bin:{ltbridge:"./dist/ltbridge.js"},files:["dist","LICENSE","README.md"],dependencies:{chokidar:"^5.0.0",commander:"^11.0.0","fs-extra":"^11.1.1",prompts:"^2.4.2"},devDependencies:{esbuild:"^0.25.0"}}});var Ke=H((Dt,Ue)=>{var Bn=/__LT_VERSION\s*=\s*'[^']*'/g,Gn=/__LT_DISABLE_DEBUG\s*=\s*(true|false)/g;function $n(d,{version:s,disableDebug:u}={}){if(!d)return d;let n=d;return s&&(n=n.replace(Bn,`__LT_VERSION = '${s}'`)),u!==void 0&&(n=n.replace(Gn,`__LT_DISABLE_DEBUG = ${u?"true":"false"}`)),n}Ue.exports={applyBuildConstants:$n}});var oe=H((qt,He)=>{var ze=require("fs"),Rn=require("path"),we=null;function Ae(){if(we)return we;let d=Rn.join(__dirname,"..","dist","modules.dat");return ze.existsSync(d)||(console.log("\x1B[31m\u2716 LTBridge is not compiled. Please run 'npm run build' first.\x1B[0m"),process.exit(1)),we=JSON.parse(ze.readFileSync(d,"utf8")),we}function An(){return Ae().registry}function In(d){return Ae().modules[d]}He.exports={getModuleRegistry:An,getDatabase:Ae,getModuleData:In}});var Ie=H((Wt,Ze)=>{var{getModuleData:Pn}=oe();function Je(d){let s=Pn(d);if(!s)return!1;for(let u of["shared","client","server"])if(s[u]&&s[u].stubs&&s[u].stubs.some(n=>n.metadata&&n.metadata.global))return!0;return!1}function Mn(d,s){if(!s||s.length===0)return null;if(s.length===1)return s[0];if(d.includes(".")){let n=d.split(".")[0].toLowerCase(),t=s.find(i=>i.toLowerCase().includes(n));if(t)return t}return s.find(n=>Je(n))||s[0]}Ze.exports={pickExportModule:Mn,moduleHasGlobalStub:Je}});var xe=H((Ut,Qe)=>{var{getModuleRegistry:Nn,getModuleData:Vn}=oe(),{pickExportModule:vn}=Ie();function On(d,s){let u=Nn(),n=Object.keys(u),t=new Set,i=new Set,e=[],o={};function c(l,m){let h=Vn(l);if(!h)return[];if(h.meta&&Array.isArray(h.meta.dependencies))return h.meta.dependencies;let f=new Set,p="";["shared","client","server"].forEach(x=>{h[x]&&h[x].code&&(p+=h[x].code+`
3
- `)});let g=/(?:^|[^a-zA-Z0-9_.:"'\]])(LT\.[a-zA-Z0-9_.]+)/g,_;for(;(_=g.exec(p))!==null;){let $=_[1].substring(3).split("."),I="";for(let q of $){I=I?I+"."+q:q;let v="@"+I.replace(/\./g,"/"),O=I.replace(/\./g,"/");if(n.includes(v)&&v!==l?f.add(v):n.includes(O)&&O!==l?f.add(O):n.includes(I)&&I!==l&&f.add(I),m&&m[I]){let K=vn(I,m[I]);K&&K!==l&&f.add(K)}}}let w=u[l];if(w){let $=w.replace(/\\/g,"/").split("/");for(;$.length>1;){$.pop();let I=$[$.length-1],q=I,v="@"+I;l!==q&&n.includes(q)&&f.add(q),l!==v&&n.includes(v)&&f.add(v)}}return Array.from(f)}function a(l){if(t.has(l))return;if(i.has(l)){console.log(`
4
- \x1B[33m! Circular dependency detected involving '${l}'.\x1B[0m`);return}if(i.add(l),!u[l]){console.log(`\x1B[31m\u2716 Trying to resolve '${l}' but it does not exist in LTBridge.\x1B[0m`),i.delete(l);return}let m=c(l,s);o[l]=m;for(let h of m)a(h);i.delete(l),t.add(l),e.push(l)}for(let l of d)a(l);return{sequence:e,graph:o}}Qe.exports={resolveDependencies:On}});var on=H((Kt,Be)=>{var ke=console.log,U=function(d,s){if(!d)throw s};function jn(d,s){if(!d)return 0;var u=d.toString().split(".");return u.length>1?parseInt(u[0],s)+parseInt(u[1],s)/Math.pow(s,u[1].length):parseInt(u[0],s)}var Dn=[" ",`
2
+ var Z=(d,s)=>()=>(s||d((s={exports:{}}).exports,s),s.exports);var Fe=Z((jt,xn)=>{xn.exports={name:"@laot/bridge",version:"1.1.1",description:"LTBridge CLI for fetching and bundling FiveM modules.",license:"MIT",repository:{type:"git",url:"https://github.com/laot7490/ltbridge.git"},author:"laot",keywords:["fivem","lua","bridge","module-manager","bundler","cli","gta5","redm","laot","ltbridge"],main:"dist/ltbridge.js",scripts:{build:"node scripts/compiler.js && esbuild bin/ltbridge.js --bundle --minify --platform=node --target=node18 --packages=external --outfile=dist/ltbridge.js",zip:"node scripts/zip-dist.js",prepublishOnly:"npm run build && npm run zip"},bin:{ltbridge:"./dist/ltbridge.js"},files:["dist","LICENSE","README.md"],dependencies:{chokidar:"^5.0.0",commander:"^11.0.0","fs-extra":"^11.1.1",prompts:"^2.4.2"},devDependencies:{esbuild:"^0.25.0"}}});var Ke=Z((Dt,Ue)=>{var Bn=/__LT_VERSION\s*=\s*'[^']*'/g,Gn=/__LT_DISABLE_DEBUG\s*=\s*(true|false)/g;function $n(d,{version:s,disableDebug:u}={}){if(!d)return d;let n=d;return s&&(n=n.replace(Bn,`__LT_VERSION = '${s}'`)),u!==void 0&&(n=n.replace(Gn,`__LT_DISABLE_DEBUG = ${u?"true":"false"}`)),n}Ue.exports={applyBuildConstants:$n}});var re=Z((qt,He)=>{var ze=require("fs"),Rn=require("path"),we=null;function Ae(){if(we)return we;let d=Rn.join(__dirname,"..","dist","modules.dat");return ze.existsSync(d)||(console.log("\x1B[31m\u2716 LTBridge is not compiled. Please run 'npm run build' first.\x1B[0m"),process.exit(1)),we=JSON.parse(ze.readFileSync(d,"utf8")),we}function An(){return Ae().registry}function In(d){return Ae().modules[d]}He.exports={getModuleRegistry:An,getDatabase:Ae,getModuleData:In}});var Ie=Z((Wt,Je)=>{var{getModuleData:Nn}=re();function Ze(d){let s=Nn(d);if(!s)return!1;for(let u of["shared","client","server"])if(s[u]&&s[u].stubs&&s[u].stubs.some(n=>n.metadata&&n.metadata.global))return!0;return!1}function Pn(d,s){if(!s||s.length===0)return null;if(s.length===1)return s[0];if(d.includes(".")){let n=d.split(".")[0].toLowerCase(),t=s.find(i=>i.toLowerCase().includes(n));if(t)return t}return s.find(n=>Ze(n))||s[0]}Je.exports={pickExportModule:Pn,moduleHasGlobalStub:Ze}});var xe=Z((Ut,Qe)=>{var{getModuleRegistry:Mn,getModuleData:Vn}=re(),{pickExportModule:vn}=Ie();function On(d,s){let u=Mn(),n=Object.keys(u),t=new Set,i=new Set,e=[],o={};function c(l,h){let m=Vn(l);if(!m)return[];if(m.meta&&Array.isArray(m.meta.dependencies))return m.meta.dependencies;let f=new Set,p="";["shared","client","server"].forEach(N=>{m[N]&&m[N].code&&(p+=m[N].code+`
3
+ `)});function g(N){let q=N.split("."),I="";for(let v of q){I=I?I+"."+v:v;let W="@"+I.replace(/\./g,"/"),ne=I.replace(/\./g,"/");if(n.includes(W)&&W!==l?f.add(W):n.includes(ne)&&ne!==l?f.add(ne):n.includes(I)&&I!==l&&f.add(I),h&&h[I]){let z=vn(I,h[I]);z&&z!==l&&f.add(z)}}}let _=/(?:^|[^a-zA-Z0-9_.:"'\]])(LT\.[a-zA-Z0-9_.]+)/g,w=/(?:^|[^a-zA-Z0-9_.:"'\]])([A-Z][a-zA-Z0-9_]*)/g,x;for(;(x=_.exec(p))!==null;)g(x[1].substring(3));for(;(x=w.exec(p))!==null;){let N=x[1];h&&h[N]&&g(N)}let A=u[l];if(A){let q=A.replace(/\\/g,"/").split("/");for(;q.length>1;){q.pop();let I=q[q.length-1],v=I,W="@"+I;l!==v&&n.includes(v)&&f.add(v),l!==W&&n.includes(W)&&f.add(W)}}return Array.from(f)}function a(l){if(t.has(l))return;if(i.has(l)){console.log(`
4
+ \x1B[33m! Circular dependency detected involving '${l}'.\x1B[0m`);return}if(i.add(l),!u[l]){console.log(`\x1B[31m\u2716 Trying to resolve '${l}' but it does not exist in LTBridge.\x1B[0m`),i.delete(l);return}let h=c(l,s);o[l]=h;for(let m of h)a(m);i.delete(l),t.add(l),e.push(l)}for(let l of d)a(l);return{sequence:e,graph:o}}Qe.exports={resolveDependencies:On}});var on=Z((Kt,Be)=>{var ge=console.log,K=function(d,s){if(!d)throw s};function jn(d,s){if(!d)return 0;var u=d.toString().split(".");return u.length>1?parseInt(u[0],s)+parseInt(u[1],s)/Math.pow(s,u[1].length):parseInt(u[0],s)}var Dn=[" ",`
5
5
  `," ","\r"],qn={r:"\r",n:`
6
- `,t:" ",'"':'"',"'":"'","\\":"\\"},Xe=new Proxy(qn,{get(d,s){return jn(s)}}),Wn=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","_","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],Me=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","_","a","b","c","d","e","f","g","t","u","v","w","h","i","j","k","l","m","n","o","p","q","r","s","x","y","z"],pe=["0","1","2","3","4","5","6","7","8","9"],Un=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","A","B","C","D","E","F"],Kn=["+","-","*",")",";","/","^","%","#",",","{","}",":","[","]","(",".","`"],zn=["~","=",">","<"],Hn=["+","-","*","/","^","..","%","//"],Jn=["+=","-=","*=","/=","^=","..=","%=","//="],en=["and","break","do","else","elseif","end","false","for","function","goto","if","in","local","nil","not","or","repeat","return","then","true","until","while","continue"],he=["continue","goto"],Zn=["else","elseif","until","end"],Qn=["-","not","#","~"],nn=["+","-","*","/","%","^","#","//","&","|","~","<<",">>","..",".",":",">","<","<=",">=","~=","==","+=","-=","*=","/=","%=","^=","..=","//=","and","or"],Xn=11,Pe={"^":[13,12],"%":[10,10],"//":[10,10],"/":[10,10],"*":[10,10],"+":[9,9],"-":[9,9],"..":[8,7],">>":[7,7],"<<":[7,7],"&":[6,6],"~":[5,5],"|":[4,4],"==":[3,3],"~=":[3,3],">=":[3,3],"<=":[3,3],">":[3,3],"<":[3,3],"+=":[3,3],"-=":[3,3],"*=":[3,3],"/=":[3,3],"^=":[3,3],"%=":[3,3],"..=":[3,3],"//=":[3,3],and:[2,2],or:[1,1]};function Yn(d){let s=0,u=d.length,n=[];function t(f){return f=f||0,s<=u?d.substr(s+f,1):""}function i(){if(s<=u){let f=d.substr(s,1);return s++,f}else return""}function e(f){let p=0,g=1,_=1;for(;p<=s;)d.substr(p,1)==`
7
- `?(g++,_=1):_++;let w;for(w=0;w<n.length;w++){let x=n[w];ke(`${x.Type}<${x.Source}>`)}throw`file<${g}:${_}>: ${f}`}function o(f){for(;;){let p=i();if(p=="")e("Unfinished long string.");else if(p=="]"){let g=!0,_;for(_=1;_<=f;_++)if(t()=="=")s++;else{g=!1;break}if(g&&i()=="]")return}}}function c(){let f=s;for(;t()=="=";)s++;if(t()=="[")return s++,s-f-1;s=f}let a=0,l=0,m=0;function h(f){m++;let p=d.substr(l,s-l),g=null;f=="Number"&&(p=p.replace(/[\_]+/g,""),p.substr(0,2).toLowerCase()=="0x"?(g="hex",parseInt(p,16)<999999999999&&(p=parseInt(p,16))):p.substr(0,2).toLowerCase()=="0b"&&(g="bin",parseInt(p.substr(2),2)<999999999999&&(p=parseInt(p.substr(2),2))));let _={Type:f,LeadingWhite:d.substr(a,l-a),Source:p};return g!==null&&(_.NType=g),n.push(_),a=s,l=s,_}for(;;){for(a=s;;){let p=t();if(p=="")break;if(p=="-")if(t(1)=="-")if(s+=2,t()=="["){s++;let g=c();if(g!=null)o(g),a=s;else for(;;){let _=i();if(_==""||_==`
6
+ `,t:" ",'"':'"',"'":"'","\\":"\\"},Xe=new Proxy(qn,{get(d,s){return jn(s)}}),Wn=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","_","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],Pe=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","_","a","b","c","d","e","f","g","t","u","v","w","h","i","j","k","l","m","n","o","p","q","r","s","x","y","z"],he=["0","1","2","3","4","5","6","7","8","9"],Un=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","A","B","C","D","E","F"],Kn=["+","-","*",")",";","/","^","%","#",",","{","}",":","[","]","(",".","`"],zn=["~","=",">","<"],Hn=["+","-","*","/","^","..","%","//"],Zn=["+=","-=","*=","/=","^=","..=","%=","//="],en=["and","break","do","else","elseif","end","false","for","function","goto","if","in","local","nil","not","or","repeat","return","then","true","until","while","continue"],me=["continue","goto"],Jn=["else","elseif","until","end"],Qn=["-","not","#","~"],nn=["+","-","*","/","%","^","#","//","&","|","~","<<",">>","..",".",":",">","<","<=",">=","~=","==","+=","-=","*=","/=","%=","^=","..=","//=","and","or"],Xn=11,Ne={"^":[13,12],"%":[10,10],"//":[10,10],"/":[10,10],"*":[10,10],"+":[9,9],"-":[9,9],"..":[8,7],">>":[7,7],"<<":[7,7],"&":[6,6],"~":[5,5],"|":[4,4],"==":[3,3],"~=":[3,3],">=":[3,3],"<=":[3,3],">":[3,3],"<":[3,3],"+=":[3,3],"-=":[3,3],"*=":[3,3],"/=":[3,3],"^=":[3,3],"%=":[3,3],"..=":[3,3],"//=":[3,3],and:[2,2],or:[1,1]};function Yn(d){let s=0,u=d.length,n=[];function t(f){return f=f||0,s<=u?d.substr(s+f,1):""}function i(){if(s<=u){let f=d.substr(s,1);return s++,f}else return""}function e(f){let p=0,g=1,_=1;for(;p<=s;)d.substr(p,1)==`
7
+ `?(g++,_=1):_++;let w;for(w=0;w<n.length;w++){let x=n[w];ge(`${x.Type}<${x.Source}>`)}throw`file<${g}:${_}>: ${f}`}function o(f){for(;;){let p=i();if(p=="")e("Unfinished long string.");else if(p=="]"){let g=!0,_;for(_=1;_<=f;_++)if(t()=="=")s++;else{g=!1;break}if(g&&i()=="]")return}}}function c(){let f=s;for(;t()=="=";)s++;if(t()=="[")return s++,s-f-1;s=f}let a=0,l=0,h=0;function m(f){h++;let p=d.substr(l,s-l),g=null;f=="Number"&&(p=p.replace(/[\_]+/g,""),p.substr(0,2).toLowerCase()=="0x"?(g="hex",parseInt(p,16)<999999999999&&(p=parseInt(p,16))):p.substr(0,2).toLowerCase()=="0b"&&(g="bin",parseInt(p.substr(2),2)<999999999999&&(p=parseInt(p.substr(2),2))));let _={Type:f,LeadingWhite:d.substr(a,l-a),Source:p};return g!==null&&(_.NType=g),n.push(_),a=s,l=s,_}for(;;){for(a=s;;){let p=t();if(p=="")break;if(p=="-")if(t(1)=="-")if(s+=2,t()=="["){s++;let g=c();if(g!=null)o(g),a=s;else for(;;){let _=i();if(_==""||_==`
8
8
  `)break}}else for(;;){let g=i();if(g==""||g==`
9
- `)break}else break;else if(Dn.includes(p))s++;else break}l=s;let f=i();if(f==""){h("Eof");break}else if(f=="'"||f=='"'){for(;;){let p=i();if(p=="\\"){let g=i();if(Xe[g]==null)throw`Invalid Escape Sequence \`${g}\`.`}else{if(p==f)break;if(p=="")throw"Unfinished string!"}}h("String")}else if(f=="`"){for(;;){let p=i();if(p=="\\"){let g=i();if(Xe[g]==null)throw`Invalid Escape Sequence \`${g}\`.`}else{if(p==f)break;if(p=="")throw"Unfinished string!"}}h("Hash")}else if(Wn.includes(f)){for(;Me.includes(t());)s++;en.includes(d.substr(l,s-l))?h("Keyword"):h("Ident")}else if(pe.includes(f)||f=="."&&pe.includes(t())){if(f=="0"&&t().toLowerCase()=="x")for(s++;Un.includes(t())||t()==="_";)s++;else if(f=="0"&&t().toLowerCase()=="b")for(s++;t()==="0"||t()==="1"||t()==="_";)s++;else{for(;pe.includes(t())||t()==="_";)s++;if(t()==".")for(s++;pe.includes(t());)s++;if(t()=="e"||t()=="E")for(s++,(t()=="-"||t()=="+")&&s++;pe.includes(t());)s++}h("Number")}else if(f=="["){let p=c();p!=null?(o(p),h("String")):h("Symbol")}else if(f==".")t()=="."&&(i(),(t()=="."||t()=="=")&&i()),h("Symbol");else if(f+t()=="//")i(),t()=="="&&i(),h("Symbol");else if(f+t()=="::")i(),h("Symbol");else if(nn.includes(f+t()))i(),h("Symbol");else if(zn.includes(f))t()=="="&&s++,h("Symbol");else if(Hn.includes(f)&&t()=="=")i(),h("Symbol");else if(Kn.includes(f))h("Symbol");else throw`Bad symbol \`${f}\` in source. ${s}`}return n}function et(d){let s=Yn(d),u=0;function n(){let k=s[u];return u<s.length&&u++,k}function t(k){return k=u+(k||0),s[k]||s[s.length-1]}function i(k){let L=1,r=0,T=0;for(;;){let S=s[T],b;S==k?b=S.LeadingWhite:b=S.LeadingWhite+S.Source;let y;for(y=0;y<=b.length;y++)b.substr(y,1)==`
10
- `?(L++,r=0):r++;if(S==k)break;T++}return`${L}:${r+1}`}function e(){let k=t();return`<${k.Type} \`${k.Source}\`> at: ${i(k)}`}function o(){let k=t();return k.Type=="Eof"||k.Type=="Keyword"&&Zn.includes(k.Source)}function c(){return Qn.includes(t().Source)||!1}function a(){return nn.includes(t().Source)||!1}function l(k,L){let r=t();if(r.Type==k&&(L==null||r.Source==L))return n();if(r.Type=="Keyword"&&k=="Ident"&&he.includes(r.Source)&&(L==null||r.Source==L))return n();{let T;for(T=-3;T<=3;T++)ke(`Tokens[${T}] = \`${t(T).Source}\``);throw L?`${i(r)}: \`${L}\` expected.`:`${i(r)}: ${k} expected.`}}function m(k){let L=k.GetFirstToken,r=k.GetLastToken,T=k;return k.GetFirstToken=function(){let S=L(T);return U(S),S},k.GetLastToken=function(){let S=r(T);return U(S),S},k}let h,f;function p(k,L){let r=[f(k,L)],T=[];for(;t().Source==",";)T.push(n()),r.push(f(k,L));return[r,T]}function g(k,L){let r=t();if(r.Source=="("){let T=n(),S=f(k,L),b=l("Symbol",")"),y;return y=m({Type:"ParenExpr",Expression:S,Token_OpenParen:T,Token_CloseParen:b,GetFirstToken:()=>y.Token_OpenParen,GetLastToken:()=>y.Token_CloseParen}),y}else if(r.Type=="Ident"||r.Type=="Keyword"&&he.includes(r.Source)){let T;return T=m({Type:"VariableExpr",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),k[T.Token.Source]!=null&&k[T.Token.Source]?.Tokens?.push!=null?(k[T.Token.Source].Tokens.push(T.Token),k[T.Token.Source].UseCountIncrease()):L[T.Token.Source]!=null&&L[T.Token.Source]?.Tokens?.push!=null&&(L[T.Token.Source].Tokens.push(T.Token),L[T.Token.Source].UseCountIncrease()),T}else throw ke(e()),`${i(r)}: Unexpected symbol. ${r.Type} ${r.Source}`}function _(k,L){let r=l("Symbol","{"),T=[],S=[];for(;t().Source!="}";){let E,C;if(t().Source=="["){let F=n(),R=f(k,L),G=l("Symbol","]"),B=l("Symbol","="),j=f(k,L);E=R.Token&&R.Token.Source,C=j,T.push({EntryType:"Index",Index:R,Value:j,Token_OpenBracket:F,Token_CloseBracket:G,Token_Equals:B})}else if((t().Type=="Ident"||t().Type=="Keyword"&&he.includes(t().Source))&&t(1).Source=="="){let F=n(),R=n(),G=f(k,L);E=F,C=G,T.push({EntryType:"Field",Field:F,Value:G,Token_Equals:R})}else{let F=f(k,L);T.push({EntryType:"Value",Value:F})}if(t().Source==","||t().Source==";")S.push(n());else break}let b=l("Symbol","}"),y;return y=m({Type:"TableLiteral",EntryList:T,Token_SeperatorList:S,Token_OpenBrace:r,Token_CloseBrace:b,GetFirstToken:()=>y.Token_OpenBrace,GetLastToken:()=>y.Token_CloseBrace}),y}function w(k,L){let r=[],T=[];if(t().Type=="Ident"||t().Type=="Keyword"&&he.includes(t().Source)){let S=n();if(L&&t().Source=="<"&&t(2).Source==">"){let b=t(1).Source;S.Attribute={LeadingWhite:t().LeadingWhite,Source:`<${b}>`},n(),n(),n()}r.push(S)}else if(t().Source=="..."&&k)return[r,T,n()];for(;t().Source==",";){if(T.push(n()),t().Source=="..."&&k)return[r,T,n()];{let S=l("Ident");if(L&&t().Source=="<"&&t(2).Source==">"){let b=t(1).Source;S.Attribute={LeadingWhite:t().LeadingWhite,Source:`<${b}>`},n(),n(),n()}r.push(S)}}return[r,T]}function x(k,L,r){let T=h(L,r),S=t();if(S.Type=="Keyword"&&S.Source==k)return n(),[T,S];throw ke(S.Type,S.Source),`${i(S)}: ${k} expected.`}function $(k,L,r,T){let S=n(),b,y;if(!k){b=[],y=[];let A=l("Ident");for(b.push(A);t().Source==".";)y.push(n()),b.push(l("Ident"));t().Source==":"&&(y.push(n()),b.push(l("Ident")))}let E=l("Symbol","("),[C,F,R]=w(!0),G=l("Symbol",")"),[B,j]=x("end",L,r),V;return V=m({Type:k==!0?"FunctionLiteral":"FunctionStat",NameChain:b,ArgList:C,Body:B,Token_Function:S,Token_NameChainSeperator:y,Token_OpenParen:E,Token_Varg:R,Token_ArgCommaList:F,Token_CloseParen:G,Token_End:j,GetFirstToken:()=>V.Token_Function,GetLastToken:()=>V.Token_End}),V}function I(k,L){let r=t();if(r.Source=="("){let T=n(),S=[],b=[];for(;t().Source!=")"&&(S.push(f(k,L)),t().Source==",");)b.push(n());let y=l("Symbol",")"),E;return E=m({CallType:"ArgCall",ArgList:S,Token_CommaList:b,Token_OpenParen:T,Token_CloseParen:y,GetFirstToken:()=>E.Token_OpenParen,GetLastToken:()=>E.Token_CloseParen}),E}else if(r.Source=="{"){let T;return T=m({CallType:"TableCall",TableExpr:f(k,L),GetFirstToken:()=>T.TableExpr.GetFirstToken(),GetLastToken:()=>T.TableExpr.GetLastToken()}),T}else if(r.Type=="String"){let T;return T=m({CallType:"StringCall",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else throw"Function arguments expected."}function q(k,L){let r=g(k,L);for(U(r,"nil prefixexpr");;){let T=t();if(T.Source=="."){let S=n(),b=l("Ident"),y;y=m({Type:"FieldExpr",Base:r,Field:b,Token_Dot:S,GetFirstToken:()=>y.Base.GetFirstToken(),GetLastToken:()=>y.Field}),r=y}else if(T.Source==":"){let S=n(),b=l("Ident"),y=I(k,L),E;E=m({Type:"MethodExpr",Base:r,Method:b,FunctionArguments:y,Token_Colon:S,GetFirstToken:()=>E.Base.GetFirstToken(),GetLastToken:()=>E.FunctionArguments.GetLastToken()}),r=E}else if(T.Source=="["){let S=n(),b=f(k,L),y=l("Symbol","]"),E;E=m({Type:"IndexExpr",Base:r,Index:b,Token_OpenBracket:S,Token_CloseBracket:y,GetFirstToken:()=>E.Base.GetFirstToken(),GetLastToken:()=>E.Token_CloseBracket}),r=E}else if(T.Source=="{"||T.Source=="("||T.Type=="String"){let S;S=m({Type:"CallExpr",Base:r,FunctionArguments:I(k,L),GetFirstToken:()=>S.Base.GetFirstToken(),GetLastToken:()=>S.FunctionArguments.GetLastToken()}),r=S}else if(Jn.includes(T.Source)){let S=n(),b=f(k,L),y;y=m({Type:"CompoundStat",Base:r,Token_Compound:S,Rhs:b,Lhs:r,GetFirstToken:()=>y.Base.GetFirstToken(),GetLastToken:()=>y.Rhs.GetLastToken()}),r=y}else return r}}function v(k,L){let r=t();if(r.Type=="Number"){let T;return T=m({Type:"NumberLiteral",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else if(r.Type=="String"){let T;return T=m({Type:"StringLiteral",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else if(r.Type=="Hash"){let T;return T=m({Type:"HashLiteral",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else if(r.Source=="nil"){let T;return T=m({Type:"NilLiteral",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else if(r.Source=="true"||r.Source=="false"){let T;return T=m({Type:"BooleanLiteral",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else if(r.Source=="..."){let T;return T=m({Type:"VargLiteral",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else return r.Source=="{"?_(k,L):r.Source=="function"?$(!0,k,L):r.Source=="if"?be(!0,k,L):q(k,L)}function O(k,L,r){let T;if(c()){let S=n(),b=O(Xn,L,r),y;y=m({Type:"UnopExpr",Token_Op:S,Rhs:b,GetFirstToken:()=>y.Token_Op,GetLastToken:()=>y.Rhs.GetLastToken()}),T=y}else T=v(L,r),U(T,"nil sipleexpr");for(;a()&&Pe[t().Source]!=null&&Pe[t().Source][0]>k;){let S=n(),b=O(Pe[S.Source][1],L,r);U(b,"RhsNeeded");let y;y=m({Type:"BinopExpr",Lhs:T,Rhs:b,Token_Op:S,GetFirstToken:()=>y.Lhs.GetFirstToken(),GetLastToken:()=>y.Rhs.GetLastToken()}),T=y}return T}f=(k,L)=>O(0,k,L);function K(k,L){let r=q(k,L);if(r.Type=="MethodExpr"||r.Type=="CallExpr"){let T;return T=m({Type:"CallExprStat",Expression:r,GetFirstToken:()=>T.Expression.GetFirstToken(),GetLastToken:()=>T.Expression.GetLastToken()}),T}else{if(r.Type=="CompoundStat")return r;{let T=[r],S=[];for(r.IsStat=!0;t().Source==",";){S.push(n());let F=q(k,L);if(F.Type=="MethodExpr"||F.Type=="CallExpr")throw"Bad left hand side of asignment";F.IsStat=!0,T.push(F)}let b=l("Symbol","="),y=[f(k,L)],E=[];for(;t().Source==",";)E.push(n()),y.push(f(k,L));let C;return C=m({Type:"AssignmentStat",Rhs:y,Lhs:T,Token_Equals:b,Token_LhsSeperatorList:S,Token_RhsSeperatorList:E,GetFirstToken:()=>C.Lhs[0].GetFirstToken(),GetLastToken:()=>C.Rhs[C.Rhs.length-1].GetLastToken()}),C}}}function be(k,L,r){let T=n(),S=f(L,r),b=l("Keyword","then"),y=k?f(L,r):h(L,r),E=[];for(;t().Source=="elseif"||t().Source=="else";){let R=n(),G,B;R.Source=="elseif"&&(G=f(L,r),B=l("Keyword","then"));let j=k?f(L,r):h(L,r);if(E.push({Condition:G,Body:j,ClauseType:R.Source,Token:R,Token_Then:B}),R.Source=="else")break}let C=k?null:l("Keyword","end"),F;return F=m({Type:k?"IfExpr":"IfStat",Condition:S,Body:y,ElseClauseList:E,Token_If:T,Token_Then:b,Token_End:C,GetFirstToken:()=>F.Token_If,GetLastToken:()=>F.Token_End}),F}function se(k,L){let r=n(),[T,S]=x("end",k,L),b;return b=m({Type:"DoStat",Body:T,Token_Do:r,Token_End:S,GetFirstToken:()=>b.Token_Do,GetLastToken:()=>b.Token_End}),b}function Q(k,L){let r=n(),T=f(k,L),S=l("Keyword","do"),[b,y]=x("end",k,L),E;return E=m({Type:"WhileStat",Condition:T,Body:b,Token_While:r,Token_Do:S,Token_End:y,GetFirstToken:()=>E.Token_While,GetLastToken:()=>E.Token_End}),E}function ae(k,L){let r=n(),[T,S]=w(),b=[];if(t().Source=="="){let y=n(),[E,C]=p(k,L);if(E.length<2||E.length>3)throw"Expected 2 or 3 values for range bounds";let F=l("Keyword","do"),[R,G]=x("end",k,L),B;return B=m({Type:"NumericForStat",VarList:T,RangeList:E,Body:R,Token_For:r,Token_VarCommaList:S,Token_Equals:y,Token_RangeCommaList:C,Token_Do:F,Token_End:G,GetFirstToken:()=>B.Token_For,GetLastToken:()=>B.Token_End}),B}else if(t().Source=="in"){let y=n(),[E,C]=p(k,L),F=l("Keyword","do"),[R,G]=x("end",k,L),B;return B=m({Type:"GenericForStat",VarList:T,GeneratorList:E,Body:R,Token_For:r,Token_VarCommaList:S,Token_In:y,Token_GeneratorCommaList:C,Token_Do:F,Token_End:G,GetFirstToken:()=>B.Token_For,GetLastToken:()=>B.Token_End}),B}}function fe(k,L){let r=n(),[T,S]=x("until",k),b=f(k,L),y;return y=m({Type:"RepeatStat",Body:T,Condition:b,Token_Repeat:r,Token_Until:S,GetFirstToken:()=>y.Token_Repeat,GetLastToken:()=>y.Condition.GetLastToken()}),y}function ie(k,L){let r=n();if(t().Source=="function"){let T=$(!1,k,L,!0);if(T.NameChain.length>1)throw i(T.Token_NameChainSeperator[0])+": `(` expected.";let S;return S=m({Type:"LocalFunctionStat",FunctionStat:T,Token_Local:r,GetFirstToken:()=>S.Token_Local,GetLastToken:()=>S.FunctionStat.GetLastToken()}),S}else if(t().Type=="Ident"||t().Type=="Keyword"&&he.includes(t().Source)){let[T,S]=w(!1,!0),b=[],y=[],E;if(t().Source=="="){E=n();let[F,R]=p(k,L);b=F,y=R}let C;return C=m({Type:"LocalVarStat",VarList:T,ExprList:b,Token_Local:r,Token_Equals:E,Token_VarCommaList:S,Token_ExprCommaList:y,GetFirstToken:()=>C.Token_Local,GetLastToken:function(){return C.ExprList.length>0?C.ExprList[C.ExprList.length-1].GetLastToken():C.VarList[C.VarList.length-1]}}),C}else throw"`function` or ident expected"}function de(k,L){let r=n(),T,S;o()||t().Source==";"?(T=[],S=[]):[T,S]=p(k,L);let b;return b={Type:"ReturnStat",ExprList:T,Token_Return:r,Token_CommaList:S,GetFirstToken:()=>b.Token_Return,GetLastToken:function(){return b.ExprList.length>0?b.ExprList[b.ExprList.length-1].GetLastToken():b.Token_Return}},b}function ee(){let k=n(),L;return L={Type:"BreakStat",Token_Break:k,GetFirstToken:()=>L.Token_Break,GetLastToken:()=>L.Token_Break},L}function ue(k,L){if(t(1).Source=="(")return[!1,K(k,L)];let r=n(),T;return T={Type:"ContinueStat",Token_Continue:r,GetFirstToken:()=>T.Token_Continue,GetLastToken:()=>T.Token_Continue},[!0,T]}function ye(){let k=n(),L;t().Type=="Keyword"?L=l("Keyword"):L=l("Ident");let r;return r={Type:"GotoStat",Token_Goto:k,Token_Label:L,GetFirstToken:()=>r.Token_Goto,GetLastToken:()=>r.Token_Label},r}function _e(){let k=n(),L;t().Type=="Keyword"?L=l("Keyword"):L=l("Ident");let r=l("Symbol","::"),T;return T={Type:"LabelStat",Token_ColonsLeft:k,Token_Label:L,Token_ColonsRight:r,GetFirstToken:()=>T.Token_ColonsLeft,GetLastToken:()=>T.Token_ColonsRight},T}function z(k,L){let r=t();return r.Source=="if"?[!1,be(!1,k,L)]:r.Source=="while"?[!1,Q(k,L)]:r.Source=="do"?[!1,se(k,L)]:r.Source=="for"?[!1,ae(k,L)]:r.Source=="repeat"?[!1,fe(k,L)]:r.Source=="function"?[!1,$(!1,k,L)]:r.Source=="local"?[!1,ie(k,L)]:r.Source=="return"?[!0,de(k,L)]:r.Source=="break"?[!0,ee(k,L)]:r.Source=="continue"?ue(k,L):r.Source=="goto"?[!1,ye()]:r.Source=="::"?[!1,_e()]:[!1,K(k,L)]}let We=1;return h=function(k,L){let r=[],T=[],S=!1,b={},y={};if(L!=null)for(let[G,B]of Object.entries(L))y[G]=B;if(k!=null)for(let[G,B]of Object.entries(k))y[G]=B;let E,C=0;for(;!S&&!o();){E&&E==t()&&ke(`INFINITE LOOP POSSIBLE ON STATEMENT ${E.Source} :`,E),E=t();let[G,B]=z(b,y);if(B)switch(r.push(B),B.Type){case"LocalVarStat":B.VarList.forEach(A=>{A.UseCount=0,A.Number=C++,b[A.Source]=A;let X=[];function ne(){A.UseCount++,X.forEach(D=>{D.UseCount=A.UseCount})}A.Tokens={},A.Tokens.push=D=>{D.UseCountIncrease=ne,D.UseCount=A.UseCount,D.Tokens=A.Tokens,X.push(D)},A.Tokens.get=()=>X,A.UseCountIncrease=ne});break;case"LocalFunctionStat":let V=B.FunctionStat.NameChain;if(V.length===1){let ne=function(){A.UseCount++,X.forEach(D=>{D.UseCount=A.UseCount})};var R=ne;let A=V[0];A.UseCount=0,A.Number=C++,b[A.Source]=A;let X=[];A.Tokens={},A.Tokens.push=D=>{D.UseCountIncrease=ne,D.UseCount=A.UseCount,D.Tokens=A.Tokens,X.push(D)},A.Tokens.get=()=>X,A.UseCountIncrease=ne}break;default:break}let j=t();j.Type=="Symbol"&&j.Source==";"&&(T[r.length-1]=n())}let F;return F={Type:"StatList",StatementList:r,SemicolonList:T,GetFirstToken:function(){if(F.StatementList.length!=0)return F.StatementList[0]?.GetFirstToken()},GetLastToken:function(){if(F.StatementList.length!=0)return F.SemicolonList[F.StatementList.length-1]?F.SemicolonList[F.StatementList.length-1]:F.StatementList[F.StatementList.length-1].GetLastToken()}},F},h([],[])}function me(d,s){let u={BinopExpr:!0,UnopExpr:!0,NumberLiteral:!0,StringLiteral:!0,NilLiteral:!0,BooleanLiteral:!0,VargLiteral:!0,HashLiteral:!0,FieldExpr:!0,IndexExpr:!0,MethodExpr:!0,CallExpr:!0,FunctionLiteral:!0,VariableExpr:!0,ParenExpr:!0,TableLiteral:!0},n={StatList:!0,BreakStat:!0,ContinueStat:!0,LabelStat:!0,GotoStat:!0,ReturnStat:!0,LocalVarStat:!0,LocalFunctionStat:!0,FunctionStat:!0,RepeatStat:!0,GenericForStat:!0,NumericForStat:!0,WhileStat:!0,DoStat:!0,IfStat:!0,CallExprStat:!0,AssignmentStat:!0,CompoundStat:!0};for(var[t,i]of Object.entries(s))if(!(t==="VisitStat"||t==="VisitExpr")&&!n[t]&&!u[t])throw`Invalid visitor target: \`${t}\``;function e(l){if(l!=null){let m=s[l.Type];if(typeof m=="function")return m(l);if(m&&m.Pre)return m.Pre(l)}}function o(l){let m=s[l.Type];if(m&&typeof m=="object"&&m.Post)return m.Post(l)}let c,a;c=function(l){if(!e(l)){if(l.Type=="BinopExpr")c(l.Lhs),c(l.Rhs);else if(l.Type=="UnopExpr")c(l.Rhs);else if(!(l.Type=="NumberLiteral"||l.Type=="StringLiteral"||l.Type=="NilLiteral"||l.Type=="BooleanLiteral"||l.Type=="VargLiteral"||l.Type=="HashLiteral")){if(l.Type=="FieldExpr")c(l.Base);else if(l.Type=="IndexExpr")c(l.Base),c(l.Index);else if(l.Type=="MethodExpr"||l.Type=="CallExpr")c(l.Base),l.FunctionArguments.CallType=="ArgCall"?l.FunctionArguments.ArgList.forEach((m,h)=>{c(m)}):l.FunctionArguments.CallType=="TableCall"&&c(l.FunctionArguments.TableExpr);else if(l.Type=="FunctionLiteral")a(l.Body);else if(l.Type!="VariableExpr")if(l.Type=="ParenExpr")c(l.Expression);else if(l.Type=="TableLiteral")l.EntryList.forEach((m,h)=>{if(m.EntryType=="Field")c(m.Value);else if(m.EntryType=="Index")c(m.Index),c(m.Value);else if(m.EntryType=="Value")c(m.Value);else throw"unreachable"});else if(l.Type=="CompoundStat")c(l.Lhs),c(l.Rhs);else if(l.Type=="IfExpr")c(l.Condition),c(l.Body),l.ElseClauseList.forEach(m=>{m.Condition!=null&&c(m.Condition),c(m.Body)});else throw`unreachable, type: ${l.Type}: ${l}`}o(l)}},a=function(l){if(!e(l)){if(l.Type=="StatList")l.StatementList.forEach((m,h)=>{if(m!=null){if(m===null||m.Type===null)return;m.Remove=()=>{l.StatementList[h]=null},a(m)}});else if(l.Type!="BreakStat"){if(l.Type!="ContinueStat"){if(l.Type!="GotoStat"){if(l.Type!="LabelStat")if(l.Type=="ReturnStat")l.ExprList.forEach((m,h)=>{c(m)});else if(l.Type=="LocalVarStat")l.Token_Equals&&l.ExprList.forEach((m,h)=>{c(m)});else if(l.Type=="LocalFunctionStat")a(l.FunctionStat.Body);else if(l.Type=="FunctionStat")a(l.Body);else if(l.Type=="RepeatStat")a(l.Body),c(l.Condition);else if(l.Type=="GenericForStat")l.GeneratorList.forEach((m,h)=>{c(m)}),a(l.Body);else if(l.Type=="NumericForStat")l.RangeList.forEach((m,h)=>{c(m)}),a(l.Body);else if(l.Type=="WhileStat")c(l.Condition),a(l.Body);else if(l.Type=="DoStat")a(l.Body);else if(l.Type=="IfStat")c(l.Condition),a(l.Body),l.ElseClauseList.forEach(m=>{m.Condition!=null&&c(m.Condition),a(m.Body)});else if(l.Type=="CallExprStat")c(l.Expression);else if(l.Type=="CompoundStat")c(l.Lhs),c(l.Rhs);else if(l.Type=="AssignmentStat")l.Lhs.forEach(m=>{c(m)}),l.Rhs.forEach(m=>{c(m)});else throw"Unreachable code. Got "+l.Type}}}o(l)}},s.VisitStat=a,s.VisitExpr=c,n[d.Type]?a(d):c(d)}function nt(d){let s=[],u,n=0;function t(){return n++,n}function i(){u={ParentScope:u,ChildScopeList:[],VariableList:[],BeginLocation:t(),Depth:null,GetVar:null},u.ParentScope?(u.Depth=u.ParentScope.Depth+1,u.ParentScope.ChildScopeList.push(u)):u.Depth=1;let f=u;u.GetVar=function(p){for(let g of f.VariableList)if(g.Name==p)return g;if(f.ParentScope)return f.ParentScope.GetVar(p);for(let g of s)if(g.Name==p)return g}}function e(){let f=u;return f.EndLocation=t(),f.VariableList.forEach(p=>{p.ScopeEndLocation=f.EndLocation}),u=f.ParentScope,f}i();function o(f,p,g){U(g,"Missing localInfo"),U(f,"Missing local var name");let _={Type:"Local",Name:f,RenameList:[p],AssignedTo:!1,Info:g,Scope:u,BeginLocation:t(),EndLocation:t(),ReferenceLocationList:[t()]};return _.Rename=function(w){_.Name=w,_.RenameList.forEach(x=>{x(w)})},u.VariableList.push(_),_}function c(f){for(let g of s)if(g.Name==f)return g;let p={Type:"Global",Name:f,RenameList:[],AssignedTo:!1,Scope:null,BeginLocation:t(),EndLocation:t(),ReferenceLocationList:[]};return p.Rename=function(g){p.Name=g,p.RenameList.forEach(_=>{_(g)})},s.push(p),p}function a(f,p){U(f,"Missing var name");let g=c(f);return g.RenameList.push(p),g}function l(f,p){let g;for(g=f.VariableList.length-1;g>=0;g--)if(f.VariableList[g].Name==p)return f.VariableList[g];if(f.ParentScope){let _=l(f.ParentScope,p);if(_)return _}}function m(f,p){U(f,"Missing var name");let g=l(u,f);g?g.RenameList.push(p):g=a(f,p);let _=t();return g.EndLocation=_,g.ReferenceLocationList.push(g.EndLocation),g}let h={};return h.FunctionLiteral={Pre:function(f){i(),f.ArgList.forEach((p,g)=>{let _=o(p.Source,function(w,x){x||(p.Source=w)},{Type:"Argument",Index:g});p.var=_})},Post:function(f){e()}},h.VariableExpr=function(f){f.Variable=m(f.Token.Source,function(p,g=!1){g&&f.IsStat||(f.Token.Source=p)})},h.StatList={Pre:function(f){i()},Post:function(f){f.SkipPop||e()}},h.LocalVarStat={Post:function(f){f.VarList.forEach((p,g)=>{o(p.Source,function(_){f.VarList[g].Source=_},{Type:"Local",Expr:f.ExprList})})}},h.LocalFunctionStat={Pre:function(f){o(f.FunctionStat.NameChain[0].Source,function(p){f.FunctionStat.NameChain[0].Source=p},{Type:"LocalFunction"}),i(),f.FunctionStat.ArgList.forEach((p,g)=>{o(p.Source,function(_){p.Source=_},{Type:"Argument",Index:g})})},Post:function(){e()}},h.FunctionStat={Pre:function(f){let p=f.NameChain,g;p.length==1?l(u,p[0].Source)?g=m(p[0].Source,function(_){p[0].Source=_}):g=a(p[0].Source,function(_){p[0].Source=_}):g=m(p[0].Source,function(_){p[0].Source=_}),g.AssignedTo=!0,i(),f.ArgList.forEach((_,w)=>{o(_.Source,function(x){_.Source=x},{Type:"Argument",Index:w})})},Post:function(){e()}},h.GenericForStat={Pre:function(f){return f.GeneratorList.forEach(p=>{me(p,h)}),i(),f.VarList.forEach((p,g)=>{o(p.Source,function(_){p.Source=_},{Type:"ForRange",Index:g})}),me(f.Body,h),e(),!0}},h.NumericForStat={Pre:function(f){return f.RangeList.forEach(p=>{me(p,h)}),i(),f.VarList.forEach((p,g)=>{o(p.Source,function(_){p.Source=_},{Type:"ForRange",Index:g})}),me(f.Body,h),e(),!0}},h.RepeatStat={Pre:function(f){f.Body.SkipPop=!0},Post:function(f){e()}},h.AssignmentStat={Post:function(f){f.Lhs.forEach(p=>{p.Variable!=null&&(p.Variable.AssignedTo=!0)})}},me(d,h),[s,e()]}function tt(d){let s,u,n="",t=e=>typeof e?.LeadingWhite!="string"?" ":e.LeadingWhite;function i(e){if(e.LeadingWhite==null||e.Source==null)throw`Bad token: tk=${e} | lwhite=${e.LeadingWhite} | source=${e.Source}`;n=`${n}${e.LeadingWhite}${e.Source}`}return u=function(e){if(e.Type=="BinopExpr")u(e.Lhs),i(e.Token_Op),u(e.Rhs);else if(e.Type=="UnopExpr")i(e.Token_Op),u(e.Rhs);else if(e.Type=="NumberLiteral"||e.Type=="StringLiteral"||e.Type=="NilLiteral"||e.Type=="BooleanLiteral"||e.Type=="VargLiteral"||e.Type=="HashLiteral")i(e.Token);else if(e.Type=="FieldExpr")u(e.Base),i(e.Token_Dot),i(e.Field);else if(e.Type=="IndexExpr")u(e.Base),i(e.Token_OpenBracket),u(e.Index),i(e.Token_CloseBracket);else if(e.Type=="MethodExpr"||e.Type=="CallExpr")u(e.Base),e.Type=="MethodExpr"&&(i(e.Token_Colon),i(e.Method)),e.FunctionArguments.CallType=="StringCall"?i(e.FunctionArguments.Token):e.FunctionArguments.CallType=="ArgCall"?(i(e.FunctionArguments.Token_OpenParen),e.FunctionArguments.ArgList.forEach((o,c)=>{u(o);let a=e.FunctionArguments.Token_CommaList[c];a!=null&&i(a)}),i(e.FunctionArguments.Token_CloseParen)):e.FunctionArguments.CallType=="TableCall"&&u(e.FunctionArguments.TableExpr);else if(e.Type=="FunctionLiteral")i(e.Token_Function),i(e.Token_OpenParen),e.ArgList.forEach((o,c)=>{i(o);let a=e.Token_ArgCommaList[c];a!=null&&i(a)}),e.Token_Varg!=null&&i(e.Token_Varg),i(e.Token_CloseParen),s(e.Body),i(e.Token_End);else if(e.Type=="VariableExpr")i(e.Token);else if(e.Type=="ParenExpr")i(e.Token_OpenParen),u(e.Expression),i(e.Token_CloseParen);else if(e.Type=="TableLiteral")i(e.Token_OpenBrace),e.EntryList.forEach((o,c)=>{if(o.EntryType=="Field")i(o.Field),i(o.Token_Equals),u(o.Value);else if(o.EntryType=="Index")i(o.Token_OpenBracket),u(o.Index),i(o.Token_CloseBracket),i(o.Token_Equals),u(o.Value);else if(o.EntryType=="Value")u(o.Value);else throw"unreachable";let a=e.Token_SeperatorList[c];a!=null&&i(a)}),i(e.Token_CloseBrace);else if(e.Type=="CompoundStat")s(e);else if(e.Type=="IfExpr")i(e.Token_If),u(e.Condition),i(e.Token_Then),u(e.Body),e.ElseClauseList.forEach(o=>{i(o.Token),o.Condition!=null&&(u(o.Condition),i(o.Token_Then)),u(o.Body)});else throw`unreachable, type: ${e.Type}: ${e}`},s=function(e){if(e==null)throw`STAT IS NIL! ${e}`;if(!(e.Type==="StatList"&&e.StatementList.length===0)){if(e.WrapInDo){let o=t(e.GetFirstToken());e.GetFirstToken().LeadingWhite="",n+=`${o}do `}e.Type=="StatList"?e.StatementList.forEach((o,c)=>{o===null||o.Type===null||(o.Remove=()=>{e.StatementList[c]=null},s(o),e.SemicolonList[c]&&i(e.SemicolonList[c]))}):e.Type=="BreakStat"?i(e.Token_Break):e.Type=="ContinueStat"?i(e.Token_Continue):e.Type=="GotoStat"?(i(e.Token_Goto),i(e.Token_Label)):e.Type=="LabelStat"?(i(e.Token_ColonsLeft),i(e.Token_Label),i(e.Token_ColonsRight)):e.Type=="ReturnStat"?(i(e.Token_Return),e.ExprList.forEach((o,c)=>{u(o),e.Token_CommaList[c]&&i(e.Token_CommaList[c])})):e.Type=="LocalVarStat"?(i(e.Token_Local),e.VarList.forEach((o,c)=>{i(o),o.Attribute!=null&&i(o.Attribute);let a=e.Token_VarCommaList[c];a!=null&&i(a)}),e.Token_Equals!=null&&(i(e.Token_Equals),e.ExprList.forEach((o,c)=>{u(o);let a=e.Token_ExprCommaList[c];a!=null&&i(a)}))):e.Type=="LocalFunctionStat"?(i(e.Token_Local),i(e.FunctionStat.Token_Function),i(e.FunctionStat.NameChain[0]),i(e.FunctionStat.Token_OpenParen),e.FunctionStat.ArgList.forEach((o,c)=>{i(o);let a=e.FunctionStat.Token_ArgCommaList[c];a!=null&&i(a)}),e.FunctionStat.Token_Varg&&i(e.FunctionStat.Token_Varg),i(e.FunctionStat.Token_CloseParen),s(e.FunctionStat.Body),i(e.FunctionStat.Token_End)):e.Type=="FunctionStat"?(i(e.Token_Function),e.NameChain.forEach((o,c)=>{i(o);let a=e.Token_NameChainSeperator[c];a!=null&&i(a)}),i(e.Token_OpenParen),e.ArgList.forEach((o,c)=>{i(o);let a=e.Token_ArgCommaList[c];a!=null&&i(a)}),e.Token_Varg&&i(e.Token_Varg),i(e.Token_CloseParen),s(e.Body),i(e.Token_End)):e.Type=="RepeatStat"?(i(e.Token_Repeat),s(e.Body),i(e.Token_Until),u(e.Condition)):e.Type=="GenericForStat"?(i(e.Token_For),e.VarList.forEach((o,c)=>{i(o);let a=e.Token_VarCommaList[c];a!=null&&i(a)}),i(e.Token_In),e.GeneratorList.forEach((o,c)=>{u(o);let a=e.Token_GeneratorCommaList[c];a!=null&&i(a)}),i(e.Token_Do),s(e.Body),i(e.Token_End)):e.Type=="NumericForStat"?(i(e.Token_For),e.VarList.forEach((o,c)=>{i(o);let a=e.Token_VarCommaList[c];a!=null&&i(a)}),i(e.Token_Equals),e.RangeList.forEach((o,c)=>{u(o);let a=e.Token_RangeCommaList[c];a!=null&&i(a)}),i(e.Token_Do),s(e.Body),i(e.Token_End)):e.Type=="WhileStat"?(i(e.Token_While),u(e.Condition),i(e.Token_Do),s(e.Body),i(e.Token_End)):e.Type=="DoStat"?(i(e.Token_Do),s(e.Body),i(e.Token_End)):e.Type=="IfStat"?(i(e.Token_If),u(e.Condition),i(e.Token_Then),s(e.Body),e.ElseClauseList.forEach(o=>{i(o.Token),o.Condition!=null&&(u(o.Condition),i(o.Token_Then)),s(o.Body)}),i(e.Token_End)):e.Type=="CallExprStat"?u(e.Expression):e.Type=="CompoundStat"?(u(e.Lhs),i(e.Token_Compound),u(e.Rhs),e.Type="CompoundStat"):e.Type=="AssignmentStat"?(e.Lhs.forEach((o,c)=>{u(o);let a=e.Token_LhsSeperatorList[c];a!=null&&i(a)}),i(e.Token_Equals),e.Rhs.forEach((o,c)=>{u(o);let a=e.Token_RhsSeperatorList[c];a!=null&&i(a)})):U(!1,"unreachable"),e.WrapInDo&&(n+=" end ")}},s(d),n}function ot(d){let s,u;function n(e){e&&(e.LeadingWhite="")}function t(e,o,c=!1){n(o);let a=(typeof e.Source=="string"?e.Source:e.Source.toString()).substr(e.Source.length-1,1),l=(typeof o.Source=="string"?o.Source:o.Source.toString()).substr(0,1);a=="-"&&l=="-"||Me.includes(a)&&Me.includes(l)||c&&a==")"&&l=="("?o.LeadingWhite=c?";":" ":o.LeadingWhite=""}function i(e,o,c){s(o),n(c);let a=o.GetFirstToken(),l=o.GetLastToken();a!=null?(t(e,a),t(l,c)):t(e,c)}u=function(e){if(e.Type==="BinopExpr")u(e.Lhs),u(e.Rhs),e.Lhs.Type=="NumberLiteral"&&e.Token_Op.Source==".."?e.Token_Op.LeadingWhite=" ":(n(e.Token_Op),t(e.Lhs.GetLastToken(),e.Token_Op)),t(e.Token_Op,e.Rhs.GetFirstToken());else if(e.Type==="UnopExpr")n(e.Token_Op),u(e.Rhs),t(e.Token_Op,e.Rhs.GetFirstToken());else if(e.Type==="NumberLiteral"||e.Type==="StringLiteral"||e.Type==="NilLiteral"||e.Type==="BooleanLiteral"||e.Type==="VargLiteral"||e.Type==="HashLiteral")n(e.Token);else if(e.Type=="FieldExpr")u(e.Base),n(e.Token_Dot),n(e.Field);else if(e.Type=="IndexExpr")u(e.Base),n(e.Token_OpenBracket),u(e.Index),n(e.Token_CloseBracket);else if(e.Type=="MethodExpr"||e.Type=="CallExpr")u(e.Base),e.Type=="MethodExpr"&&(n(e.Token_Colon),n(e.Method)),e.FunctionArguments.CallType=="StringCall"?n(e.FunctionArguments.Token):e.FunctionArguments.CallType=="ArgCall"?(n(e.FunctionArguments.Token_OpenParen),e.FunctionArguments.ArgList.forEach((o,c)=>{u(o);let a=e.FunctionArguments.Token_CommaList[c];a!=null&&n(a)}),n(e.FunctionArguments.Token_CloseParen)):e.FunctionArguments.CallType=="TableCall"&&u(e.FunctionArguments.TableExpr);else if(e.Type=="FunctionLiteral")n(e.Token_Function),n(e.Token_OpenParen),e.ArgList.forEach((o,c)=>{n(o);let a=e.Token_ArgCommaList[c];a!=null&&n(a)}),e.Token_Varg!=null&&n(e.Token_Varg),n(e.Token_CloseParen),i(e.Token_CloseParen,e.Body,e.Token_End);else if(e.Type=="VariableExpr")n(e.Token);else if(e.Type=="ParenExpr")n(e.Token_OpenParen),u(e.Expression),n(e.Token_CloseParen);else if(e.Type=="IfExpr"){n(e.Token_If),u(e.Condition),t(e.Token_If,e.Condition.GetFirstToken()),t(e.Condition.GetLastToken(),e.Token_Then);let o=e.Token_Then,c=e.Body;e.ElseClauseList.forEach((a,l)=>{t(o,c.GetFirstToken()),t(c.GetLastToken(),a.Token),o=a.Token,a.Condition!=null&&(u(a.Condition),t(a.Token,a.Condition.GetFirstToken()),t(a.Condition.GetLastToken(),a.Token_Then),o=a.Token_Then),u(a.Body),c=a.Body}),t(o,c.GetFirstToken())}else if(e.Type=="TableLiteral")n(e.Token_OpenBrace),e.EntryList.forEach((o,c)=>{o.EntryType=="Field"?(n(o.Field),n(o.Token_Equals),u(o.Value)):o.EntryType=="Index"?(n(o.Token_OpenBracket),u(o.Index),n(o.Token_CloseBracket),n(o.Token_Equals),u(o.Value)):o.EntryType=="Value"?u(o.Value):U(!1,"unreachable");let a=e.Token_SeperatorList[c];a!=null&&n(a)}),e.Token_SeperatorList[e.EntryList.length-1]=null,n(e.Token_CloseBrace);else throw`unreachable, type: ${e.Type}:${e} ${console.trace()}`},s=function(e){if(e.Type=="StatList"){let o;for(o=0;o<=e.StatementList.length;o++){let c=e.StatementList[o];if(c==null)continue;s(c),n(c.GetFirstToken());let a=e.StatementList[o-1];if(a!=null){let l={")":["(","["],"]":["(","["]};if(e.SemicolonList[o-1]){let m=a.GetLastToken().Source,h=c.GetFirstToken().Source;(l[m]===null||l[m]===void 0||!l[m].includes(h))&&(e.SemicolonList[o-1]=null)}e.SemicolonList[o-1]||t(a.GetLastToken(),c.GetFirstToken(),!0)}}e.SemicolonList[e.StatementList.length-1]=null,e.StatementList.length>0&&n(e.StatementList[0].GetFirstToken())}else if(e.Type=="BreakStat")n(e.Token_Break);else if(e.Type=="ContinueStat")n(e.Token_Continue);else if(e.Type=="GotoStat")n(e.Token_Goto),t(e.Token_Goto,e.Token_Label);else if(e.Type=="LabelStat")n(e.Token_ColonsLeft),n(e.Token_Label),n(e.Token_ColonsRight);else if(e.Type=="ReturnStat")n(e.Token_Return),e.ExprList.forEach((o,c)=>{u(o),e.Token_CommaList[c]!=null&&n(e.Token_CommaList[c])}),e.ExprList.length>0&&t(e.Token_Return,e.ExprList[0].GetFirstToken());else if(e.Type=="LocalVarStat"){n(e.Token_Local);let o=!1;e.VarList.forEach((c,a)=>{a==0?t(e.Token_Local,c):n(c),c.Attribute&&(n(c.Attribute),a+1==e.VarList.length&&(o=!0));let l=e.Token_VarCommaList[a];l!=null&&n(l)}),e.Token_Equals!=null&&(o||n(e.Token_Equals),e.ExprList.forEach((c,a)=>{u(c);let l=e.Token_ExprCommaList[a];l!=null&&n(l)}))}else if(e.Type=="LocalFunctionStat")n(e.Token_Local),t(e.Token_Local,e.FunctionStat.Token_Function),t(e.FunctionStat.Token_Function,e.FunctionStat.NameChain[0]),t(e.FunctionStat.NameChain[0],e.FunctionStat.Token_OpenParen),e.FunctionStat.ArgList.forEach((o,c)=>{n(o);let a=e.FunctionStat.Token_ArgCommaList[c];a!=null&&n(a)}),e.FunctionStat.Token_Varg&&n(e.FunctionStat.Token_Varg),n(e.FunctionStat.Token_CloseParen),i(e.FunctionStat.Token_CloseParen,e.FunctionStat.Body,e.FunctionStat.Token_End);else if(e.Type=="FunctionStat")n(e.Token_Function),e.NameChain.forEach((o,c)=>{c==0?t(e.Token_Function,o):n(o);let a=e.Token_NameChainSeperator[c];a!=null&&n(a)}),n(e.Token_OpenParen),e.ArgList.forEach((o,c)=>{n(o);let a=e.Token_ArgCommaList[c];a!=null&&n(a)}),e.Token_Varg&&n(e.Token_Varg),n(e.Token_CloseParen),i(e.Token_CloseParen,e.Body,e.Token_End);else if(e.Type=="RepeatStat")n(e.Token_Repeat),i(e.Token_Repeat,e.Body,e.Token_Until),u(e.Condition),t(e.Token_Until,e.Condition.GetFirstToken());else if(e.Type=="GenericForStat")n(e.Token_For),e.VarList.forEach((o,c)=>{c==0?t(e.Token_For,o):n(o);let a=e.Token_VarCommaList[c];a!=null&&n(a)}),t(e.VarList[e.VarList.length-1],e.Token_In),e.GeneratorList.forEach((o,c)=>{u(o),c==0&&t(e.Token_In,o.GetFirstToken());let a=e.Token_GeneratorCommaList[c];a!=null&&n(a)}),t(e.GeneratorList[e.GeneratorList.length-1].GetLastToken(),e.Token_Do),i(e.Token_Do,e.Body,e.Token_End);else if(e.Type=="NumericForStat")n(e.Token_For),e.VarList.forEach((o,c)=>{c==0?t(e.Token_For,o):n(o);let a=e.Token_VarCommaList[c];a!=null&&n(a)}),t(e.VarList[e.VarList.length-1],e.Token_Equals),e.RangeList.forEach((o,c)=>{u(o),c==0&&t(e.Token_Equals,o.GetFirstToken());let a=e.Token_RangeCommaList[c];a!=null&&n(a)}),t(e.RangeList[e.RangeList.length-1].GetLastToken(),e.Token_Do),i(e.Token_Do,e.Body,e.Token_End);else if(e.Type=="WhileStat")n(e.Token_While),u(e.Condition),n(e.Token_Do),t(e.Token_While,e.Condition.GetFirstToken()),t(e.Condition.GetLastToken(),e.Token_Do),i(e.Token_Do,e.Body,e.Token_End);else if(e.Type=="DoStat")n(e.Token_Do),n(e.Token_End),i(e.Token_Do,e.Body,e.Token_End);else if(e.Type=="IfStat"){n(e.Token_If),u(e.Condition),t(e.Token_If,e.Condition.GetFirstToken()),t(e.Condition.GetLastToken(),e.Token_Then);let o=e.Token_Then,c=e.Body;e.ElseClauseList.forEach((a,l)=>{i(o,c,a.Token),o=a.Token,a.Condition!=null&&(u(a.Condition),t(a.Token,a.Condition.GetFirstToken()),t(a.Condition.GetLastToken(),a.Token_Then),o=a.Token_Then),s(a.Body),c=a.Body}),i(o,c,e.Token_End)}else if(e.Type=="CallExprStat")u(e.Expression);else if(e.Type=="CompoundStat")u(e.Lhs),n(e.Token_Compound),u(e.Rhs),t(e.Lhs.GetLastToken(),e.Token_Compound),t(e.Token_Compound,e.Rhs.GetFirstToken());else if(e.Type=="AssignmentStat")e.Lhs.forEach((o,c)=>{u(o);let a=e.Token_LhsSeperatorList[c];a!=null&&n(a)}),n(e.Token_Equals),e.Rhs.forEach((o,c)=>{u(o);let a=e.Token_RhsSeperatorList[c];a!=null&&n(a)});else return u(e)},s(d)}var re=[],P;for(P=97;P<=122;P++)re.push(String.fromCharCode(P));for(P=65;P<=90;P++)re.push(String.fromCharCode(P));for(P=48;P<=57;P++)re.push(String.fromCharCode(P));re.push("_");var ge=[];for(P=97;P<=122;P++)ge.push(String.fromCharCode(P));for(P=65;P<=90;P++)ge.push(String.fromCharCode(P));function Ye(d){let s="",u=d%ge.length;for(d=(d-u)/ge.length,s=`${s}${ge[u]}`;d>0;){let n=d%re.length;d=(d-n)/re.length,s=`${s}${re[n]}`}return s}function it(d,s,u){let n=[];for(var[t,i]of Object.entries(en))n[t]=!0;let e=[],o=[];d.forEach(h=>{h.AssignedTo&&u?e.push(h):n[h.Name]=!0});function c(h){h.VariableList.forEach(f=>{e.push(f),o.push(f)}),h.ChildScopeList.forEach(f=>{c(f)})}c(s),e.forEach(h=>{h.UsedNameArray=[]}),e.sort((h,f)=>h-f);let a=0,l=[];function m(h){let f=l[h];if(f==null){for(f=Ye(a),a++;n[f];)f=Ye(a),a++;l[h]=f}return f}e.forEach((h,f)=>{h.Renamed=!0;let p=0;for(;h.UsedNameArray[p];)p++;h.Rename(m(p)),h.Scope?e.forEach(g=>{g.Renamed||(!g.Scope||g.Scope.Depth<h.Scope.Depth?g.ReferenceLocationList.some(_=>_>=h.BeginLocation&&_<=h.ScopeEndLocation?(g.UsedNameArray[p]=!0,!0):!1):g.Scope.Depth>h.Scope.Depth?h.ReferenceLocationList.some(_=>_>=g.BeginLocation&&_<=g.ScopeEndLocation?(g.UsedNameArray[p]=!0,!0):!1):h.BeginLocation<g.EndLocation&&h.EndLocation>g.BeginLocation&&(g.UsedNameArray[p]=!0))}):e.forEach(g=>{if(!g.Renamed)if(g.Type=="Global")g.UsedNameArray[p]=!0;else if(g.Type=="Local")h.ReferenceLocationList.some(_=>_>=g.BeginLocation&&_<=g.ScopeEndLocation?(g.UsedNameArray[p]=!0,!0):!1);else throw"Unreachable"})})}var tn={};tn.Minify=function(d,s){let u=et(d),[n,t]=nt(u);s.RenameVariables==!0&&it(n,t,s.RenameGlobals),s.SolveMath==!0&&SolveMath(u),ot(u);let i=tt(u);return i=`${i}`,i};try{Be!=null&&Be.exports!=null&&(Be.exports.Minify=tn.Minify)}catch{}});var an=H((zt,sn)=>{var Ne=require("fs-extra"),rt=require("path");function ln(d,s){let u=0,n=s,t=d.length,i=!1,e="";for(;n<t;){let o=d[n];if(i){if(o==="\\"){n+=2;continue}o===e&&(i=!1)}else{if(o==='"'||o==="'"){i=!0,e=o,n++;continue}if(o==="{")u++;else if(o==="}"&&(u--,u===0))return n}n++}return-1}function rn(d,s){let u=new RegExp(`^\\s*${s}\\s*\\{`,"m"),n=d.match(u);if(!n)return null;let t=n.index,i=d.indexOf("{",t);if(i===-1)return null;let e=ln(d,i);return e===-1?null:{header:n[0],blockStart:t,blockEnd:e,blockContent:d.substring(t,e+1)}}function lt(d,s,u,n,t=!1){let i=["fxmanifest.lua","__resource.lua"],e=null;for(let g of i){let _=rt.join(d,g);if(Ne.existsSync(_)){e=_;break}}if(!e){console.log("\x1B[33m! No fxmanifest.lua or __resource.lua found. Skipping manifest injection.\x1B[0m");return}let o=Ne.readFileSync(e,"utf8"),c=!1,a=(g,_)=>{let w=g.replace("_scripts","_script").replace("files","file"),x=g,$=`'ltbridge/modules/${_}'`,I=rn(o,x);if(I){if(I.blockContent.includes($))return;let O=o.indexOf("{",I.blockStart);o=o.substring(0,O+1)+`
11
- ${$},`+o.substring(O+1),c=!0;return}let q=new RegExp(`^\\s*${w}\\s+(['"].+?['"])`,"m"),v=o.match(q);if(v){if(v[0].includes($))return;let O=v[1],K=`${x} {
12
- ${$},
13
- ${O}
14
- }`;o=o.replace(v[0],K),c=!0;return}o+=`
9
+ `)break}else break;else if(Dn.includes(p))s++;else break}l=s;let f=i();if(f==""){m("Eof");break}else if(f=="'"||f=='"'){for(;;){let p=i();if(p=="\\"){let g=i();if(Xe[g]==null)throw`Invalid Escape Sequence \`${g}\`.`}else{if(p==f)break;if(p=="")throw"Unfinished string!"}}m("String")}else if(f=="`"){for(;;){let p=i();if(p=="\\"){let g=i();if(Xe[g]==null)throw`Invalid Escape Sequence \`${g}\`.`}else{if(p==f)break;if(p=="")throw"Unfinished string!"}}m("Hash")}else if(Wn.includes(f)){for(;Pe.includes(t());)s++;en.includes(d.substr(l,s-l))?m("Keyword"):m("Ident")}else if(he.includes(f)||f=="."&&he.includes(t())){if(f=="0"&&t().toLowerCase()=="x")for(s++;Un.includes(t())||t()==="_";)s++;else if(f=="0"&&t().toLowerCase()=="b")for(s++;t()==="0"||t()==="1"||t()==="_";)s++;else{for(;he.includes(t())||t()==="_";)s++;if(t()==".")for(s++;he.includes(t());)s++;if(t()=="e"||t()=="E")for(s++,(t()=="-"||t()=="+")&&s++;he.includes(t());)s++}m("Number")}else if(f=="["){let p=c();p!=null?(o(p),m("String")):m("Symbol")}else if(f==".")t()=="."&&(i(),(t()=="."||t()=="=")&&i()),m("Symbol");else if(f+t()=="//")i(),t()=="="&&i(),m("Symbol");else if(f+t()=="::")i(),m("Symbol");else if(nn.includes(f+t()))i(),m("Symbol");else if(zn.includes(f))t()=="="&&s++,m("Symbol");else if(Hn.includes(f)&&t()=="=")i(),m("Symbol");else if(Kn.includes(f))m("Symbol");else throw`Bad symbol \`${f}\` in source. ${s}`}return n}function et(d){let s=Yn(d),u=0;function n(){let k=s[u];return u<s.length&&u++,k}function t(k){return k=u+(k||0),s[k]||s[s.length-1]}function i(k){let L=1,r=0,T=0;for(;;){let S=s[T],b;S==k?b=S.LeadingWhite:b=S.LeadingWhite+S.Source;let y;for(y=0;y<=b.length;y++)b.substr(y,1)==`
10
+ `?(L++,r=0):r++;if(S==k)break;T++}return`${L}:${r+1}`}function e(){let k=t();return`<${k.Type} \`${k.Source}\`> at: ${i(k)}`}function o(){let k=t();return k.Type=="Eof"||k.Type=="Keyword"&&Jn.includes(k.Source)}function c(){return Qn.includes(t().Source)||!1}function a(){return nn.includes(t().Source)||!1}function l(k,L){let r=t();if(r.Type==k&&(L==null||r.Source==L))return n();if(r.Type=="Keyword"&&k=="Ident"&&me.includes(r.Source)&&(L==null||r.Source==L))return n();{let T;for(T=-3;T<=3;T++)ge(`Tokens[${T}] = \`${t(T).Source}\``);throw L?`${i(r)}: \`${L}\` expected.`:`${i(r)}: ${k} expected.`}}function h(k){let L=k.GetFirstToken,r=k.GetLastToken,T=k;return k.GetFirstToken=function(){let S=L(T);return K(S),S},k.GetLastToken=function(){let S=r(T);return K(S),S},k}let m,f;function p(k,L){let r=[f(k,L)],T=[];for(;t().Source==",";)T.push(n()),r.push(f(k,L));return[r,T]}function g(k,L){let r=t();if(r.Source=="("){let T=n(),S=f(k,L),b=l("Symbol",")"),y;return y=h({Type:"ParenExpr",Expression:S,Token_OpenParen:T,Token_CloseParen:b,GetFirstToken:()=>y.Token_OpenParen,GetLastToken:()=>y.Token_CloseParen}),y}else if(r.Type=="Ident"||r.Type=="Keyword"&&me.includes(r.Source)){let T;return T=h({Type:"VariableExpr",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),k[T.Token.Source]!=null&&k[T.Token.Source]?.Tokens?.push!=null?(k[T.Token.Source].Tokens.push(T.Token),k[T.Token.Source].UseCountIncrease()):L[T.Token.Source]!=null&&L[T.Token.Source]?.Tokens?.push!=null&&(L[T.Token.Source].Tokens.push(T.Token),L[T.Token.Source].UseCountIncrease()),T}else throw ge(e()),`${i(r)}: Unexpected symbol. ${r.Type} ${r.Source}`}function _(k,L){let r=l("Symbol","{"),T=[],S=[];for(;t().Source!="}";){let E,C;if(t().Source=="["){let F=n(),$=f(k,L),G=l("Symbol","]"),B=l("Symbol","="),j=f(k,L);E=$.Token&&$.Token.Source,C=j,T.push({EntryType:"Index",Index:$,Value:j,Token_OpenBracket:F,Token_CloseBracket:G,Token_Equals:B})}else if((t().Type=="Ident"||t().Type=="Keyword"&&me.includes(t().Source))&&t(1).Source=="="){let F=n(),$=n(),G=f(k,L);E=F,C=G,T.push({EntryType:"Field",Field:F,Value:G,Token_Equals:$})}else{let F=f(k,L);T.push({EntryType:"Value",Value:F})}if(t().Source==","||t().Source==";")S.push(n());else break}let b=l("Symbol","}"),y;return y=h({Type:"TableLiteral",EntryList:T,Token_SeperatorList:S,Token_OpenBrace:r,Token_CloseBrace:b,GetFirstToken:()=>y.Token_OpenBrace,GetLastToken:()=>y.Token_CloseBrace}),y}function w(k,L){let r=[],T=[];if(t().Type=="Ident"||t().Type=="Keyword"&&me.includes(t().Source)){let S=n();if(L&&t().Source=="<"&&t(2).Source==">"){let b=t(1).Source;S.Attribute={LeadingWhite:t().LeadingWhite,Source:`<${b}>`},n(),n(),n()}r.push(S)}else if(t().Source=="..."&&k)return[r,T,n()];for(;t().Source==",";){if(T.push(n()),t().Source=="..."&&k)return[r,T,n()];{let S=l("Ident");if(L&&t().Source=="<"&&t(2).Source==">"){let b=t(1).Source;S.Attribute={LeadingWhite:t().LeadingWhite,Source:`<${b}>`},n(),n(),n()}r.push(S)}}return[r,T]}function x(k,L,r){let T=m(L,r),S=t();if(S.Type=="Keyword"&&S.Source==k)return n(),[T,S];throw ge(S.Type,S.Source),`${i(S)}: ${k} expected.`}function A(k,L,r,T){let S=n(),b,y;if(!k){b=[],y=[];let R=l("Ident");for(b.push(R);t().Source==".";)y.push(n()),b.push(l("Ident"));t().Source==":"&&(y.push(n()),b.push(l("Ident")))}let E=l("Symbol","("),[C,F,$]=w(!0),G=l("Symbol",")"),[B,j]=x("end",L,r),O;return O=h({Type:k==!0?"FunctionLiteral":"FunctionStat",NameChain:b,ArgList:C,Body:B,Token_Function:S,Token_NameChainSeperator:y,Token_OpenParen:E,Token_Varg:$,Token_ArgCommaList:F,Token_CloseParen:G,Token_End:j,GetFirstToken:()=>O.Token_Function,GetLastToken:()=>O.Token_End}),O}function N(k,L){let r=t();if(r.Source=="("){let T=n(),S=[],b=[];for(;t().Source!=")"&&(S.push(f(k,L)),t().Source==",");)b.push(n());let y=l("Symbol",")"),E;return E=h({CallType:"ArgCall",ArgList:S,Token_CommaList:b,Token_OpenParen:T,Token_CloseParen:y,GetFirstToken:()=>E.Token_OpenParen,GetLastToken:()=>E.Token_CloseParen}),E}else if(r.Source=="{"){let T;return T=h({CallType:"TableCall",TableExpr:f(k,L),GetFirstToken:()=>T.TableExpr.GetFirstToken(),GetLastToken:()=>T.TableExpr.GetLastToken()}),T}else if(r.Type=="String"){let T;return T=h({CallType:"StringCall",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else throw"Function arguments expected."}function q(k,L){let r=g(k,L);for(K(r,"nil prefixexpr");;){let T=t();if(T.Source=="."){let S=n(),b=l("Ident"),y;y=h({Type:"FieldExpr",Base:r,Field:b,Token_Dot:S,GetFirstToken:()=>y.Base.GetFirstToken(),GetLastToken:()=>y.Field}),r=y}else if(T.Source==":"){let S=n(),b=l("Ident"),y=N(k,L),E;E=h({Type:"MethodExpr",Base:r,Method:b,FunctionArguments:y,Token_Colon:S,GetFirstToken:()=>E.Base.GetFirstToken(),GetLastToken:()=>E.FunctionArguments.GetLastToken()}),r=E}else if(T.Source=="["){let S=n(),b=f(k,L),y=l("Symbol","]"),E;E=h({Type:"IndexExpr",Base:r,Index:b,Token_OpenBracket:S,Token_CloseBracket:y,GetFirstToken:()=>E.Base.GetFirstToken(),GetLastToken:()=>E.Token_CloseBracket}),r=E}else if(T.Source=="{"||T.Source=="("||T.Type=="String"){let S;S=h({Type:"CallExpr",Base:r,FunctionArguments:N(k,L),GetFirstToken:()=>S.Base.GetFirstToken(),GetLastToken:()=>S.FunctionArguments.GetLastToken()}),r=S}else if(Zn.includes(T.Source)){let S=n(),b=f(k,L),y;y=h({Type:"CompoundStat",Base:r,Token_Compound:S,Rhs:b,Lhs:r,GetFirstToken:()=>y.Base.GetFirstToken(),GetLastToken:()=>y.Rhs.GetLastToken()}),r=y}else return r}}function I(k,L){let r=t();if(r.Type=="Number"){let T;return T=h({Type:"NumberLiteral",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else if(r.Type=="String"){let T;return T=h({Type:"StringLiteral",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else if(r.Type=="Hash"){let T;return T=h({Type:"HashLiteral",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else if(r.Source=="nil"){let T;return T=h({Type:"NilLiteral",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else if(r.Source=="true"||r.Source=="false"){let T;return T=h({Type:"BooleanLiteral",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else if(r.Source=="..."){let T;return T=h({Type:"VargLiteral",Token:n(),GetFirstToken:()=>T.Token,GetLastToken:()=>T.Token}),T}else return r.Source=="{"?_(k,L):r.Source=="function"?A(!0,k,L):r.Source=="if"?ne(!0,k,L):q(k,L)}function v(k,L,r){let T;if(c()){let S=n(),b=v(Xn,L,r),y;y=h({Type:"UnopExpr",Token_Op:S,Rhs:b,GetFirstToken:()=>y.Token_Op,GetLastToken:()=>y.Rhs.GetLastToken()}),T=y}else T=I(L,r),K(T,"nil sipleexpr");for(;a()&&Ne[t().Source]!=null&&Ne[t().Source][0]>k;){let S=n(),b=v(Ne[S.Source][1],L,r);K(b,"RhsNeeded");let y;y=h({Type:"BinopExpr",Lhs:T,Rhs:b,Token_Op:S,GetFirstToken:()=>y.Lhs.GetFirstToken(),GetLastToken:()=>y.Rhs.GetLastToken()}),T=y}return T}f=(k,L)=>v(0,k,L);function W(k,L){let r=q(k,L);if(r.Type=="MethodExpr"||r.Type=="CallExpr"){let T;return T=h({Type:"CallExprStat",Expression:r,GetFirstToken:()=>T.Expression.GetFirstToken(),GetLastToken:()=>T.Expression.GetLastToken()}),T}else{if(r.Type=="CompoundStat")return r;{let T=[r],S=[];for(r.IsStat=!0;t().Source==",";){S.push(n());let F=q(k,L);if(F.Type=="MethodExpr"||F.Type=="CallExpr")throw"Bad left hand side of asignment";F.IsStat=!0,T.push(F)}let b=l("Symbol","="),y=[f(k,L)],E=[];for(;t().Source==",";)E.push(n()),y.push(f(k,L));let C;return C=h({Type:"AssignmentStat",Rhs:y,Lhs:T,Token_Equals:b,Token_LhsSeperatorList:S,Token_RhsSeperatorList:E,GetFirstToken:()=>C.Lhs[0].GetFirstToken(),GetLastToken:()=>C.Rhs[C.Rhs.length-1].GetLastToken()}),C}}}function ne(k,L,r){let T=n(),S=f(L,r),b=l("Keyword","then"),y=k?f(L,r):m(L,r),E=[];for(;t().Source=="elseif"||t().Source=="else";){let $=n(),G,B;$.Source=="elseif"&&(G=f(L,r),B=l("Keyword","then"));let j=k?f(L,r):m(L,r);if(E.push({Condition:G,Body:j,ClauseType:$.Source,Token:$,Token_Then:B}),$.Source=="else")break}let C=k?null:l("Keyword","end"),F;return F=h({Type:k?"IfExpr":"IfStat",Condition:S,Body:y,ElseClauseList:E,Token_If:T,Token_Then:b,Token_End:C,GetFirstToken:()=>F.Token_If,GetLastToken:()=>F.Token_End}),F}function z(k,L){let r=n(),[T,S]=x("end",k,L),b;return b=h({Type:"DoStat",Body:T,Token_Do:r,Token_End:S,GetFirstToken:()=>b.Token_Do,GetLastToken:()=>b.Token_End}),b}function X(k,L){let r=n(),T=f(k,L),S=l("Keyword","do"),[b,y]=x("end",k,L),E;return E=h({Type:"WhileStat",Condition:T,Body:b,Token_While:r,Token_Do:S,Token_End:y,GetFirstToken:()=>E.Token_While,GetLastToken:()=>E.Token_End}),E}function ue(k,L){let r=n(),[T,S]=w(),b=[];if(t().Source=="="){let y=n(),[E,C]=p(k,L);if(E.length<2||E.length>3)throw"Expected 2 or 3 values for range bounds";let F=l("Keyword","do"),[$,G]=x("end",k,L),B;return B=h({Type:"NumericForStat",VarList:T,RangeList:E,Body:$,Token_For:r,Token_VarCommaList:S,Token_Equals:y,Token_RangeCommaList:C,Token_Do:F,Token_End:G,GetFirstToken:()=>B.Token_For,GetLastToken:()=>B.Token_End}),B}else if(t().Source=="in"){let y=n(),[E,C]=p(k,L),F=l("Keyword","do"),[$,G]=x("end",k,L),B;return B=h({Type:"GenericForStat",VarList:T,GeneratorList:E,Body:$,Token_For:r,Token_VarCommaList:S,Token_In:y,Token_GeneratorCommaList:C,Token_Do:F,Token_End:G,GetFirstToken:()=>B.Token_For,GetLastToken:()=>B.Token_End}),B}}function de(k,L){let r=n(),[T,S]=x("until",k),b=f(k,L),y;return y=h({Type:"RepeatStat",Body:T,Condition:b,Token_Repeat:r,Token_Until:S,GetFirstToken:()=>y.Token_Repeat,GetLastToken:()=>y.Condition.GetLastToken()}),y}function le(k,L){let r=n();if(t().Source=="function"){let T=A(!1,k,L,!0);if(T.NameChain.length>1)throw i(T.Token_NameChainSeperator[0])+": `(` expected.";let S;return S=h({Type:"LocalFunctionStat",FunctionStat:T,Token_Local:r,GetFirstToken:()=>S.Token_Local,GetLastToken:()=>S.FunctionStat.GetLastToken()}),S}else if(t().Type=="Ident"||t().Type=="Keyword"&&me.includes(t().Source)){let[T,S]=w(!1,!0),b=[],y=[],E;if(t().Source=="="){E=n();let[F,$]=p(k,L);b=F,y=$}let C;return C=h({Type:"LocalVarStat",VarList:T,ExprList:b,Token_Local:r,Token_Equals:E,Token_VarCommaList:S,Token_ExprCommaList:y,GetFirstToken:()=>C.Token_Local,GetLastToken:function(){return C.ExprList.length>0?C.ExprList[C.ExprList.length-1].GetLastToken():C.VarList[C.VarList.length-1]}}),C}else throw"`function` or ident expected"}function Te(k,L){let r=n(),T,S;o()||t().Source==";"?(T=[],S=[]):[T,S]=p(k,L);let b;return b={Type:"ReturnStat",ExprList:T,Token_Return:r,Token_CommaList:S,GetFirstToken:()=>b.Token_Return,GetLastToken:function(){return b.ExprList.length>0?b.ExprList[b.ExprList.length-1].GetLastToken():b.Token_Return}},b}function te(){let k=n(),L;return L={Type:"BreakStat",Token_Break:k,GetFirstToken:()=>L.Token_Break,GetLastToken:()=>L.Token_Break},L}function ce(k,L){if(t(1).Source=="(")return[!1,W(k,L)];let r=n(),T;return T={Type:"ContinueStat",Token_Continue:r,GetFirstToken:()=>T.Token_Continue,GetLastToken:()=>T.Token_Continue},[!0,T]}function ye(){let k=n(),L;t().Type=="Keyword"?L=l("Keyword"):L=l("Ident");let r;return r={Type:"GotoStat",Token_Goto:k,Token_Label:L,GetFirstToken:()=>r.Token_Goto,GetLastToken:()=>r.Token_Label},r}function _e(){let k=n(),L;t().Type=="Keyword"?L=l("Keyword"):L=l("Ident");let r=l("Symbol","::"),T;return T={Type:"LabelStat",Token_ColonsLeft:k,Token_Label:L,Token_ColonsRight:r,GetFirstToken:()=>T.Token_ColonsLeft,GetLastToken:()=>T.Token_ColonsRight},T}function H(k,L){let r=t();return r.Source=="if"?[!1,ne(!1,k,L)]:r.Source=="while"?[!1,X(k,L)]:r.Source=="do"?[!1,z(k,L)]:r.Source=="for"?[!1,ue(k,L)]:r.Source=="repeat"?[!1,de(k,L)]:r.Source=="function"?[!1,A(!1,k,L)]:r.Source=="local"?[!1,le(k,L)]:r.Source=="return"?[!0,Te(k,L)]:r.Source=="break"?[!0,te(k,L)]:r.Source=="continue"?ce(k,L):r.Source=="goto"?[!1,ye()]:r.Source=="::"?[!1,_e()]:[!1,W(k,L)]}let We=1;return m=function(k,L){let r=[],T=[],S=!1,b={},y={};if(L!=null)for(let[G,B]of Object.entries(L))y[G]=B;if(k!=null)for(let[G,B]of Object.entries(k))y[G]=B;let E,C=0;for(;!S&&!o();){E&&E==t()&&ge(`INFINITE LOOP POSSIBLE ON STATEMENT ${E.Source} :`,E),E=t();let[G,B]=H(b,y);if(B)switch(r.push(B),B.Type){case"LocalVarStat":B.VarList.forEach(R=>{R.UseCount=0,R.Number=C++,b[R.Source]=R;let Y=[];function oe(){R.UseCount++,Y.forEach(D=>{D.UseCount=R.UseCount})}R.Tokens={},R.Tokens.push=D=>{D.UseCountIncrease=oe,D.UseCount=R.UseCount,D.Tokens=R.Tokens,Y.push(D)},R.Tokens.get=()=>Y,R.UseCountIncrease=oe});break;case"LocalFunctionStat":let O=B.FunctionStat.NameChain;if(O.length===1){let oe=function(){R.UseCount++,Y.forEach(D=>{D.UseCount=R.UseCount})};var $=oe;let R=O[0];R.UseCount=0,R.Number=C++,b[R.Source]=R;let Y=[];R.Tokens={},R.Tokens.push=D=>{D.UseCountIncrease=oe,D.UseCount=R.UseCount,D.Tokens=R.Tokens,Y.push(D)},R.Tokens.get=()=>Y,R.UseCountIncrease=oe}break;default:break}let j=t();j.Type=="Symbol"&&j.Source==";"&&(T[r.length-1]=n())}let F;return F={Type:"StatList",StatementList:r,SemicolonList:T,GetFirstToken:function(){if(F.StatementList.length!=0)return F.StatementList[0]?.GetFirstToken()},GetLastToken:function(){if(F.StatementList.length!=0)return F.SemicolonList[F.StatementList.length-1]?F.SemicolonList[F.StatementList.length-1]:F.StatementList[F.StatementList.length-1].GetLastToken()}},F},m([],[])}function ke(d,s){let u={BinopExpr:!0,UnopExpr:!0,NumberLiteral:!0,StringLiteral:!0,NilLiteral:!0,BooleanLiteral:!0,VargLiteral:!0,HashLiteral:!0,FieldExpr:!0,IndexExpr:!0,MethodExpr:!0,CallExpr:!0,FunctionLiteral:!0,VariableExpr:!0,ParenExpr:!0,TableLiteral:!0},n={StatList:!0,BreakStat:!0,ContinueStat:!0,LabelStat:!0,GotoStat:!0,ReturnStat:!0,LocalVarStat:!0,LocalFunctionStat:!0,FunctionStat:!0,RepeatStat:!0,GenericForStat:!0,NumericForStat:!0,WhileStat:!0,DoStat:!0,IfStat:!0,CallExprStat:!0,AssignmentStat:!0,CompoundStat:!0};for(var[t,i]of Object.entries(s))if(!(t==="VisitStat"||t==="VisitExpr")&&!n[t]&&!u[t])throw`Invalid visitor target: \`${t}\``;function e(l){if(l!=null){let h=s[l.Type];if(typeof h=="function")return h(l);if(h&&h.Pre)return h.Pre(l)}}function o(l){let h=s[l.Type];if(h&&typeof h=="object"&&h.Post)return h.Post(l)}let c,a;c=function(l){if(!e(l)){if(l.Type=="BinopExpr")c(l.Lhs),c(l.Rhs);else if(l.Type=="UnopExpr")c(l.Rhs);else if(!(l.Type=="NumberLiteral"||l.Type=="StringLiteral"||l.Type=="NilLiteral"||l.Type=="BooleanLiteral"||l.Type=="VargLiteral"||l.Type=="HashLiteral")){if(l.Type=="FieldExpr")c(l.Base);else if(l.Type=="IndexExpr")c(l.Base),c(l.Index);else if(l.Type=="MethodExpr"||l.Type=="CallExpr")c(l.Base),l.FunctionArguments.CallType=="ArgCall"?l.FunctionArguments.ArgList.forEach((h,m)=>{c(h)}):l.FunctionArguments.CallType=="TableCall"&&c(l.FunctionArguments.TableExpr);else if(l.Type=="FunctionLiteral")a(l.Body);else if(l.Type!="VariableExpr")if(l.Type=="ParenExpr")c(l.Expression);else if(l.Type=="TableLiteral")l.EntryList.forEach((h,m)=>{if(h.EntryType=="Field")c(h.Value);else if(h.EntryType=="Index")c(h.Index),c(h.Value);else if(h.EntryType=="Value")c(h.Value);else throw"unreachable"});else if(l.Type=="CompoundStat")c(l.Lhs),c(l.Rhs);else if(l.Type=="IfExpr")c(l.Condition),c(l.Body),l.ElseClauseList.forEach(h=>{h.Condition!=null&&c(h.Condition),c(h.Body)});else throw`unreachable, type: ${l.Type}: ${l}`}o(l)}},a=function(l){if(!e(l)){if(l.Type=="StatList")l.StatementList.forEach((h,m)=>{if(h!=null){if(h===null||h.Type===null)return;h.Remove=()=>{l.StatementList[m]=null},a(h)}});else if(l.Type!="BreakStat"){if(l.Type!="ContinueStat"){if(l.Type!="GotoStat"){if(l.Type!="LabelStat")if(l.Type=="ReturnStat")l.ExprList.forEach((h,m)=>{c(h)});else if(l.Type=="LocalVarStat")l.Token_Equals&&l.ExprList.forEach((h,m)=>{c(h)});else if(l.Type=="LocalFunctionStat")a(l.FunctionStat.Body);else if(l.Type=="FunctionStat")a(l.Body);else if(l.Type=="RepeatStat")a(l.Body),c(l.Condition);else if(l.Type=="GenericForStat")l.GeneratorList.forEach((h,m)=>{c(h)}),a(l.Body);else if(l.Type=="NumericForStat")l.RangeList.forEach((h,m)=>{c(h)}),a(l.Body);else if(l.Type=="WhileStat")c(l.Condition),a(l.Body);else if(l.Type=="DoStat")a(l.Body);else if(l.Type=="IfStat")c(l.Condition),a(l.Body),l.ElseClauseList.forEach(h=>{h.Condition!=null&&c(h.Condition),a(h.Body)});else if(l.Type=="CallExprStat")c(l.Expression);else if(l.Type=="CompoundStat")c(l.Lhs),c(l.Rhs);else if(l.Type=="AssignmentStat")l.Lhs.forEach(h=>{c(h)}),l.Rhs.forEach(h=>{c(h)});else throw"Unreachable code. Got "+l.Type}}}o(l)}},s.VisitStat=a,s.VisitExpr=c,n[d.Type]?a(d):c(d)}function nt(d){let s=[],u,n=0;function t(){return n++,n}function i(){u={ParentScope:u,ChildScopeList:[],VariableList:[],BeginLocation:t(),Depth:null,GetVar:null},u.ParentScope?(u.Depth=u.ParentScope.Depth+1,u.ParentScope.ChildScopeList.push(u)):u.Depth=1;let f=u;u.GetVar=function(p){for(let g of f.VariableList)if(g.Name==p)return g;if(f.ParentScope)return f.ParentScope.GetVar(p);for(let g of s)if(g.Name==p)return g}}function e(){let f=u;return f.EndLocation=t(),f.VariableList.forEach(p=>{p.ScopeEndLocation=f.EndLocation}),u=f.ParentScope,f}i();function o(f,p,g){K(g,"Missing localInfo"),K(f,"Missing local var name");let _={Type:"Local",Name:f,RenameList:[p],AssignedTo:!1,Info:g,Scope:u,BeginLocation:t(),EndLocation:t(),ReferenceLocationList:[t()]};return _.Rename=function(w){_.Name=w,_.RenameList.forEach(x=>{x(w)})},u.VariableList.push(_),_}function c(f){for(let g of s)if(g.Name==f)return g;let p={Type:"Global",Name:f,RenameList:[],AssignedTo:!1,Scope:null,BeginLocation:t(),EndLocation:t(),ReferenceLocationList:[]};return p.Rename=function(g){p.Name=g,p.RenameList.forEach(_=>{_(g)})},s.push(p),p}function a(f,p){K(f,"Missing var name");let g=c(f);return g.RenameList.push(p),g}function l(f,p){let g;for(g=f.VariableList.length-1;g>=0;g--)if(f.VariableList[g].Name==p)return f.VariableList[g];if(f.ParentScope){let _=l(f.ParentScope,p);if(_)return _}}function h(f,p){K(f,"Missing var name");let g=l(u,f);g?g.RenameList.push(p):g=a(f,p);let _=t();return g.EndLocation=_,g.ReferenceLocationList.push(g.EndLocation),g}let m={};return m.FunctionLiteral={Pre:function(f){i(),f.ArgList.forEach((p,g)=>{let _=o(p.Source,function(w,x){x||(p.Source=w)},{Type:"Argument",Index:g});p.var=_})},Post:function(f){e()}},m.VariableExpr=function(f){f.Variable=h(f.Token.Source,function(p,g=!1){g&&f.IsStat||(f.Token.Source=p)})},m.StatList={Pre:function(f){i()},Post:function(f){f.SkipPop||e()}},m.LocalVarStat={Post:function(f){f.VarList.forEach((p,g)=>{o(p.Source,function(_){f.VarList[g].Source=_},{Type:"Local",Expr:f.ExprList})})}},m.LocalFunctionStat={Pre:function(f){o(f.FunctionStat.NameChain[0].Source,function(p){f.FunctionStat.NameChain[0].Source=p},{Type:"LocalFunction"}),i(),f.FunctionStat.ArgList.forEach((p,g)=>{o(p.Source,function(_){p.Source=_},{Type:"Argument",Index:g})})},Post:function(){e()}},m.FunctionStat={Pre:function(f){let p=f.NameChain,g;p.length==1?l(u,p[0].Source)?g=h(p[0].Source,function(_){p[0].Source=_}):g=a(p[0].Source,function(_){p[0].Source=_}):g=h(p[0].Source,function(_){p[0].Source=_}),g.AssignedTo=!0,i(),f.ArgList.forEach((_,w)=>{o(_.Source,function(x){_.Source=x},{Type:"Argument",Index:w})})},Post:function(){e()}},m.GenericForStat={Pre:function(f){return f.GeneratorList.forEach(p=>{ke(p,m)}),i(),f.VarList.forEach((p,g)=>{o(p.Source,function(_){p.Source=_},{Type:"ForRange",Index:g})}),ke(f.Body,m),e(),!0}},m.NumericForStat={Pre:function(f){return f.RangeList.forEach(p=>{ke(p,m)}),i(),f.VarList.forEach((p,g)=>{o(p.Source,function(_){p.Source=_},{Type:"ForRange",Index:g})}),ke(f.Body,m),e(),!0}},m.RepeatStat={Pre:function(f){f.Body.SkipPop=!0},Post:function(f){e()}},m.AssignmentStat={Post:function(f){f.Lhs.forEach(p=>{p.Variable!=null&&(p.Variable.AssignedTo=!0)})}},ke(d,m),[s,e()]}function tt(d){let s,u,n="",t=e=>typeof e?.LeadingWhite!="string"?" ":e.LeadingWhite;function i(e){if(e.LeadingWhite==null||e.Source==null)throw`Bad token: tk=${e} | lwhite=${e.LeadingWhite} | source=${e.Source}`;n=`${n}${e.LeadingWhite}${e.Source}`}return u=function(e){if(e.Type=="BinopExpr")u(e.Lhs),i(e.Token_Op),u(e.Rhs);else if(e.Type=="UnopExpr")i(e.Token_Op),u(e.Rhs);else if(e.Type=="NumberLiteral"||e.Type=="StringLiteral"||e.Type=="NilLiteral"||e.Type=="BooleanLiteral"||e.Type=="VargLiteral"||e.Type=="HashLiteral")i(e.Token);else if(e.Type=="FieldExpr")u(e.Base),i(e.Token_Dot),i(e.Field);else if(e.Type=="IndexExpr")u(e.Base),i(e.Token_OpenBracket),u(e.Index),i(e.Token_CloseBracket);else if(e.Type=="MethodExpr"||e.Type=="CallExpr")u(e.Base),e.Type=="MethodExpr"&&(i(e.Token_Colon),i(e.Method)),e.FunctionArguments.CallType=="StringCall"?i(e.FunctionArguments.Token):e.FunctionArguments.CallType=="ArgCall"?(i(e.FunctionArguments.Token_OpenParen),e.FunctionArguments.ArgList.forEach((o,c)=>{u(o);let a=e.FunctionArguments.Token_CommaList[c];a!=null&&i(a)}),i(e.FunctionArguments.Token_CloseParen)):e.FunctionArguments.CallType=="TableCall"&&u(e.FunctionArguments.TableExpr);else if(e.Type=="FunctionLiteral")i(e.Token_Function),i(e.Token_OpenParen),e.ArgList.forEach((o,c)=>{i(o);let a=e.Token_ArgCommaList[c];a!=null&&i(a)}),e.Token_Varg!=null&&i(e.Token_Varg),i(e.Token_CloseParen),s(e.Body),i(e.Token_End);else if(e.Type=="VariableExpr")i(e.Token);else if(e.Type=="ParenExpr")i(e.Token_OpenParen),u(e.Expression),i(e.Token_CloseParen);else if(e.Type=="TableLiteral")i(e.Token_OpenBrace),e.EntryList.forEach((o,c)=>{if(o.EntryType=="Field")i(o.Field),i(o.Token_Equals),u(o.Value);else if(o.EntryType=="Index")i(o.Token_OpenBracket),u(o.Index),i(o.Token_CloseBracket),i(o.Token_Equals),u(o.Value);else if(o.EntryType=="Value")u(o.Value);else throw"unreachable";let a=e.Token_SeperatorList[c];a!=null&&i(a)}),i(e.Token_CloseBrace);else if(e.Type=="CompoundStat")s(e);else if(e.Type=="IfExpr")i(e.Token_If),u(e.Condition),i(e.Token_Then),u(e.Body),e.ElseClauseList.forEach(o=>{i(o.Token),o.Condition!=null&&(u(o.Condition),i(o.Token_Then)),u(o.Body)});else throw`unreachable, type: ${e.Type}: ${e}`},s=function(e){if(e==null)throw`STAT IS NIL! ${e}`;if(!(e.Type==="StatList"&&e.StatementList.length===0)){if(e.WrapInDo){let o=t(e.GetFirstToken());e.GetFirstToken().LeadingWhite="",n+=`${o}do `}e.Type=="StatList"?e.StatementList.forEach((o,c)=>{o===null||o.Type===null||(o.Remove=()=>{e.StatementList[c]=null},s(o),e.SemicolonList[c]&&i(e.SemicolonList[c]))}):e.Type=="BreakStat"?i(e.Token_Break):e.Type=="ContinueStat"?i(e.Token_Continue):e.Type=="GotoStat"?(i(e.Token_Goto),i(e.Token_Label)):e.Type=="LabelStat"?(i(e.Token_ColonsLeft),i(e.Token_Label),i(e.Token_ColonsRight)):e.Type=="ReturnStat"?(i(e.Token_Return),e.ExprList.forEach((o,c)=>{u(o),e.Token_CommaList[c]&&i(e.Token_CommaList[c])})):e.Type=="LocalVarStat"?(i(e.Token_Local),e.VarList.forEach((o,c)=>{i(o),o.Attribute!=null&&i(o.Attribute);let a=e.Token_VarCommaList[c];a!=null&&i(a)}),e.Token_Equals!=null&&(i(e.Token_Equals),e.ExprList.forEach((o,c)=>{u(o);let a=e.Token_ExprCommaList[c];a!=null&&i(a)}))):e.Type=="LocalFunctionStat"?(i(e.Token_Local),i(e.FunctionStat.Token_Function),i(e.FunctionStat.NameChain[0]),i(e.FunctionStat.Token_OpenParen),e.FunctionStat.ArgList.forEach((o,c)=>{i(o);let a=e.FunctionStat.Token_ArgCommaList[c];a!=null&&i(a)}),e.FunctionStat.Token_Varg&&i(e.FunctionStat.Token_Varg),i(e.FunctionStat.Token_CloseParen),s(e.FunctionStat.Body),i(e.FunctionStat.Token_End)):e.Type=="FunctionStat"?(i(e.Token_Function),e.NameChain.forEach((o,c)=>{i(o);let a=e.Token_NameChainSeperator[c];a!=null&&i(a)}),i(e.Token_OpenParen),e.ArgList.forEach((o,c)=>{i(o);let a=e.Token_ArgCommaList[c];a!=null&&i(a)}),e.Token_Varg&&i(e.Token_Varg),i(e.Token_CloseParen),s(e.Body),i(e.Token_End)):e.Type=="RepeatStat"?(i(e.Token_Repeat),s(e.Body),i(e.Token_Until),u(e.Condition)):e.Type=="GenericForStat"?(i(e.Token_For),e.VarList.forEach((o,c)=>{i(o);let a=e.Token_VarCommaList[c];a!=null&&i(a)}),i(e.Token_In),e.GeneratorList.forEach((o,c)=>{u(o);let a=e.Token_GeneratorCommaList[c];a!=null&&i(a)}),i(e.Token_Do),s(e.Body),i(e.Token_End)):e.Type=="NumericForStat"?(i(e.Token_For),e.VarList.forEach((o,c)=>{i(o);let a=e.Token_VarCommaList[c];a!=null&&i(a)}),i(e.Token_Equals),e.RangeList.forEach((o,c)=>{u(o);let a=e.Token_RangeCommaList[c];a!=null&&i(a)}),i(e.Token_Do),s(e.Body),i(e.Token_End)):e.Type=="WhileStat"?(i(e.Token_While),u(e.Condition),i(e.Token_Do),s(e.Body),i(e.Token_End)):e.Type=="DoStat"?(i(e.Token_Do),s(e.Body),i(e.Token_End)):e.Type=="IfStat"?(i(e.Token_If),u(e.Condition),i(e.Token_Then),s(e.Body),e.ElseClauseList.forEach(o=>{i(o.Token),o.Condition!=null&&(u(o.Condition),i(o.Token_Then)),s(o.Body)}),i(e.Token_End)):e.Type=="CallExprStat"?u(e.Expression):e.Type=="CompoundStat"?(u(e.Lhs),i(e.Token_Compound),u(e.Rhs),e.Type="CompoundStat"):e.Type=="AssignmentStat"?(e.Lhs.forEach((o,c)=>{u(o);let a=e.Token_LhsSeperatorList[c];a!=null&&i(a)}),i(e.Token_Equals),e.Rhs.forEach((o,c)=>{u(o);let a=e.Token_RhsSeperatorList[c];a!=null&&i(a)})):K(!1,"unreachable"),e.WrapInDo&&(n+=" end ")}},s(d),n}function ot(d){let s,u;function n(e){e&&(e.LeadingWhite="")}function t(e,o,c=!1){n(o);let a=(typeof e.Source=="string"?e.Source:e.Source.toString()).substr(e.Source.length-1,1),l=(typeof o.Source=="string"?o.Source:o.Source.toString()).substr(0,1);a=="-"&&l=="-"||Pe.includes(a)&&Pe.includes(l)||c&&a==")"&&l=="("?o.LeadingWhite=c?";":" ":o.LeadingWhite=""}function i(e,o,c){s(o),n(c);let a=o.GetFirstToken(),l=o.GetLastToken();a!=null?(t(e,a),t(l,c)):t(e,c)}u=function(e){if(e.Type==="BinopExpr")u(e.Lhs),u(e.Rhs),e.Lhs.Type=="NumberLiteral"&&e.Token_Op.Source==".."?e.Token_Op.LeadingWhite=" ":(n(e.Token_Op),t(e.Lhs.GetLastToken(),e.Token_Op)),t(e.Token_Op,e.Rhs.GetFirstToken());else if(e.Type==="UnopExpr")n(e.Token_Op),u(e.Rhs),t(e.Token_Op,e.Rhs.GetFirstToken());else if(e.Type==="NumberLiteral"||e.Type==="StringLiteral"||e.Type==="NilLiteral"||e.Type==="BooleanLiteral"||e.Type==="VargLiteral"||e.Type==="HashLiteral")n(e.Token);else if(e.Type=="FieldExpr")u(e.Base),n(e.Token_Dot),n(e.Field);else if(e.Type=="IndexExpr")u(e.Base),n(e.Token_OpenBracket),u(e.Index),n(e.Token_CloseBracket);else if(e.Type=="MethodExpr"||e.Type=="CallExpr")u(e.Base),e.Type=="MethodExpr"&&(n(e.Token_Colon),n(e.Method)),e.FunctionArguments.CallType=="StringCall"?n(e.FunctionArguments.Token):e.FunctionArguments.CallType=="ArgCall"?(n(e.FunctionArguments.Token_OpenParen),e.FunctionArguments.ArgList.forEach((o,c)=>{u(o);let a=e.FunctionArguments.Token_CommaList[c];a!=null&&n(a)}),n(e.FunctionArguments.Token_CloseParen)):e.FunctionArguments.CallType=="TableCall"&&u(e.FunctionArguments.TableExpr);else if(e.Type=="FunctionLiteral")n(e.Token_Function),n(e.Token_OpenParen),e.ArgList.forEach((o,c)=>{n(o);let a=e.Token_ArgCommaList[c];a!=null&&n(a)}),e.Token_Varg!=null&&n(e.Token_Varg),n(e.Token_CloseParen),i(e.Token_CloseParen,e.Body,e.Token_End);else if(e.Type=="VariableExpr")n(e.Token);else if(e.Type=="ParenExpr")n(e.Token_OpenParen),u(e.Expression),n(e.Token_CloseParen);else if(e.Type=="IfExpr"){n(e.Token_If),u(e.Condition),t(e.Token_If,e.Condition.GetFirstToken()),t(e.Condition.GetLastToken(),e.Token_Then);let o=e.Token_Then,c=e.Body;e.ElseClauseList.forEach((a,l)=>{t(o,c.GetFirstToken()),t(c.GetLastToken(),a.Token),o=a.Token,a.Condition!=null&&(u(a.Condition),t(a.Token,a.Condition.GetFirstToken()),t(a.Condition.GetLastToken(),a.Token_Then),o=a.Token_Then),u(a.Body),c=a.Body}),t(o,c.GetFirstToken())}else if(e.Type=="TableLiteral")n(e.Token_OpenBrace),e.EntryList.forEach((o,c)=>{o.EntryType=="Field"?(n(o.Field),n(o.Token_Equals),u(o.Value)):o.EntryType=="Index"?(n(o.Token_OpenBracket),u(o.Index),n(o.Token_CloseBracket),n(o.Token_Equals),u(o.Value)):o.EntryType=="Value"?u(o.Value):K(!1,"unreachable");let a=e.Token_SeperatorList[c];a!=null&&n(a)}),e.Token_SeperatorList[e.EntryList.length-1]=null,n(e.Token_CloseBrace);else throw`unreachable, type: ${e.Type}:${e} ${console.trace()}`},s=function(e){if(e.Type=="StatList"){let o;for(o=0;o<=e.StatementList.length;o++){let c=e.StatementList[o];if(c==null)continue;s(c),n(c.GetFirstToken());let a=e.StatementList[o-1];if(a!=null){let l={")":["(","["],"]":["(","["]};if(e.SemicolonList[o-1]){let h=a.GetLastToken().Source,m=c.GetFirstToken().Source;(l[h]===null||l[h]===void 0||!l[h].includes(m))&&(e.SemicolonList[o-1]=null)}e.SemicolonList[o-1]||t(a.GetLastToken(),c.GetFirstToken(),!0)}}e.SemicolonList[e.StatementList.length-1]=null,e.StatementList.length>0&&n(e.StatementList[0].GetFirstToken())}else if(e.Type=="BreakStat")n(e.Token_Break);else if(e.Type=="ContinueStat")n(e.Token_Continue);else if(e.Type=="GotoStat")n(e.Token_Goto),t(e.Token_Goto,e.Token_Label);else if(e.Type=="LabelStat")n(e.Token_ColonsLeft),n(e.Token_Label),n(e.Token_ColonsRight);else if(e.Type=="ReturnStat")n(e.Token_Return),e.ExprList.forEach((o,c)=>{u(o),e.Token_CommaList[c]!=null&&n(e.Token_CommaList[c])}),e.ExprList.length>0&&t(e.Token_Return,e.ExprList[0].GetFirstToken());else if(e.Type=="LocalVarStat"){n(e.Token_Local);let o=!1;e.VarList.forEach((c,a)=>{a==0?t(e.Token_Local,c):n(c),c.Attribute&&(n(c.Attribute),a+1==e.VarList.length&&(o=!0));let l=e.Token_VarCommaList[a];l!=null&&n(l)}),e.Token_Equals!=null&&(o||n(e.Token_Equals),e.ExprList.forEach((c,a)=>{u(c);let l=e.Token_ExprCommaList[a];l!=null&&n(l)}))}else if(e.Type=="LocalFunctionStat")n(e.Token_Local),t(e.Token_Local,e.FunctionStat.Token_Function),t(e.FunctionStat.Token_Function,e.FunctionStat.NameChain[0]),t(e.FunctionStat.NameChain[0],e.FunctionStat.Token_OpenParen),e.FunctionStat.ArgList.forEach((o,c)=>{n(o);let a=e.FunctionStat.Token_ArgCommaList[c];a!=null&&n(a)}),e.FunctionStat.Token_Varg&&n(e.FunctionStat.Token_Varg),n(e.FunctionStat.Token_CloseParen),i(e.FunctionStat.Token_CloseParen,e.FunctionStat.Body,e.FunctionStat.Token_End);else if(e.Type=="FunctionStat")n(e.Token_Function),e.NameChain.forEach((o,c)=>{c==0?t(e.Token_Function,o):n(o);let a=e.Token_NameChainSeperator[c];a!=null&&n(a)}),n(e.Token_OpenParen),e.ArgList.forEach((o,c)=>{n(o);let a=e.Token_ArgCommaList[c];a!=null&&n(a)}),e.Token_Varg&&n(e.Token_Varg),n(e.Token_CloseParen),i(e.Token_CloseParen,e.Body,e.Token_End);else if(e.Type=="RepeatStat")n(e.Token_Repeat),i(e.Token_Repeat,e.Body,e.Token_Until),u(e.Condition),t(e.Token_Until,e.Condition.GetFirstToken());else if(e.Type=="GenericForStat")n(e.Token_For),e.VarList.forEach((o,c)=>{c==0?t(e.Token_For,o):n(o);let a=e.Token_VarCommaList[c];a!=null&&n(a)}),t(e.VarList[e.VarList.length-1],e.Token_In),e.GeneratorList.forEach((o,c)=>{u(o),c==0&&t(e.Token_In,o.GetFirstToken());let a=e.Token_GeneratorCommaList[c];a!=null&&n(a)}),t(e.GeneratorList[e.GeneratorList.length-1].GetLastToken(),e.Token_Do),i(e.Token_Do,e.Body,e.Token_End);else if(e.Type=="NumericForStat")n(e.Token_For),e.VarList.forEach((o,c)=>{c==0?t(e.Token_For,o):n(o);let a=e.Token_VarCommaList[c];a!=null&&n(a)}),t(e.VarList[e.VarList.length-1],e.Token_Equals),e.RangeList.forEach((o,c)=>{u(o),c==0&&t(e.Token_Equals,o.GetFirstToken());let a=e.Token_RangeCommaList[c];a!=null&&n(a)}),t(e.RangeList[e.RangeList.length-1].GetLastToken(),e.Token_Do),i(e.Token_Do,e.Body,e.Token_End);else if(e.Type=="WhileStat")n(e.Token_While),u(e.Condition),n(e.Token_Do),t(e.Token_While,e.Condition.GetFirstToken()),t(e.Condition.GetLastToken(),e.Token_Do),i(e.Token_Do,e.Body,e.Token_End);else if(e.Type=="DoStat")n(e.Token_Do),n(e.Token_End),i(e.Token_Do,e.Body,e.Token_End);else if(e.Type=="IfStat"){n(e.Token_If),u(e.Condition),t(e.Token_If,e.Condition.GetFirstToken()),t(e.Condition.GetLastToken(),e.Token_Then);let o=e.Token_Then,c=e.Body;e.ElseClauseList.forEach((a,l)=>{i(o,c,a.Token),o=a.Token,a.Condition!=null&&(u(a.Condition),t(a.Token,a.Condition.GetFirstToken()),t(a.Condition.GetLastToken(),a.Token_Then),o=a.Token_Then),s(a.Body),c=a.Body}),i(o,c,e.Token_End)}else if(e.Type=="CallExprStat")u(e.Expression);else if(e.Type=="CompoundStat")u(e.Lhs),n(e.Token_Compound),u(e.Rhs),t(e.Lhs.GetLastToken(),e.Token_Compound),t(e.Token_Compound,e.Rhs.GetFirstToken());else if(e.Type=="AssignmentStat")e.Lhs.forEach((o,c)=>{u(o);let a=e.Token_LhsSeperatorList[c];a!=null&&n(a)}),n(e.Token_Equals),e.Rhs.forEach((o,c)=>{u(o);let a=e.Token_RhsSeperatorList[c];a!=null&&n(a)});else return u(e)},s(d)}var se=[],P;for(P=97;P<=122;P++)se.push(String.fromCharCode(P));for(P=65;P<=90;P++)se.push(String.fromCharCode(P));for(P=48;P<=57;P++)se.push(String.fromCharCode(P));se.push("_");var Le=[];for(P=97;P<=122;P++)Le.push(String.fromCharCode(P));for(P=65;P<=90;P++)Le.push(String.fromCharCode(P));function Ye(d){let s="",u=d%Le.length;for(d=(d-u)/Le.length,s=`${s}${Le[u]}`;d>0;){let n=d%se.length;d=(d-n)/se.length,s=`${s}${se[n]}`}return s}function it(d,s,u){let n=[];for(var[t,i]of Object.entries(en))n[t]=!0;let e=[],o=[];d.forEach(m=>{m.AssignedTo&&u?e.push(m):n[m.Name]=!0});function c(m){m.VariableList.forEach(f=>{e.push(f),o.push(f)}),m.ChildScopeList.forEach(f=>{c(f)})}c(s),e.forEach(m=>{m.UsedNameArray=[]}),e.sort((m,f)=>m-f);let a=0,l=[];function h(m){let f=l[m];if(f==null){for(f=Ye(a),a++;n[f];)f=Ye(a),a++;l[m]=f}return f}e.forEach((m,f)=>{m.Renamed=!0;let p=0;for(;m.UsedNameArray[p];)p++;m.Rename(h(p)),m.Scope?e.forEach(g=>{g.Renamed||(!g.Scope||g.Scope.Depth<m.Scope.Depth?g.ReferenceLocationList.some(_=>_>=m.BeginLocation&&_<=m.ScopeEndLocation?(g.UsedNameArray[p]=!0,!0):!1):g.Scope.Depth>m.Scope.Depth?m.ReferenceLocationList.some(_=>_>=g.BeginLocation&&_<=g.ScopeEndLocation?(g.UsedNameArray[p]=!0,!0):!1):m.BeginLocation<g.EndLocation&&m.EndLocation>g.BeginLocation&&(g.UsedNameArray[p]=!0))}):e.forEach(g=>{if(!g.Renamed)if(g.Type=="Global")g.UsedNameArray[p]=!0;else if(g.Type=="Local")m.ReferenceLocationList.some(_=>_>=g.BeginLocation&&_<=g.ScopeEndLocation?(g.UsedNameArray[p]=!0,!0):!1);else throw"Unreachable"})})}var tn={};tn.Minify=function(d,s){let u=et(d),[n,t]=nt(u);s.RenameVariables==!0&&it(n,t,s.RenameGlobals),s.SolveMath==!0&&SolveMath(u),ot(u);let i=tt(u);return i=`${i}`,i};try{Be!=null&&Be.exports!=null&&(Be.exports.Minify=tn.Minify)}catch{}});var an=Z((zt,sn)=>{var Me=require("fs-extra"),rt=require("path");function ln(d,s){let u=0,n=s,t=d.length,i=!1,e="";for(;n<t;){let o=d[n];if(i){if(o==="\\"){n+=2;continue}o===e&&(i=!1)}else{if(o==='"'||o==="'"){i=!0,e=o,n++;continue}if(o==="{")u++;else if(o==="}"&&(u--,u===0))return n}n++}return-1}function rn(d,s){let u=new RegExp(`^\\s*${s}\\s*\\{`,"m"),n=d.match(u);if(!n)return null;let t=n.index,i=d.indexOf("{",t);if(i===-1)return null;let e=ln(d,i);return e===-1?null:{header:n[0],blockStart:t,blockEnd:e,blockContent:d.substring(t,e+1)}}function lt(d,s,u,n,t=!1){let i=["fxmanifest.lua","__resource.lua"],e=null;for(let g of i){let _=rt.join(d,g);if(Me.existsSync(_)){e=_;break}}if(!e){console.log("\x1B[33m! No fxmanifest.lua or __resource.lua found. Skipping manifest injection.\x1B[0m");return}let o=Me.readFileSync(e,"utf8"),c=!1,a=(g,_)=>{let w=g.replace("_scripts","_script").replace("files","file"),x=g,A=`'ltbridge/modules/${_}'`,N=rn(o,x);if(N){if(N.blockContent.includes(A))return;let v=o.indexOf("{",N.blockStart);o=o.substring(0,v+1)+`
11
+ ${A},`+o.substring(v+1),c=!0;return}let q=new RegExp(`^\\s*${w}\\s+(['"].+?['"])`,"m"),I=o.match(q);if(I){if(I[0].includes(A))return;let v=I[1],W=`${x} {
12
+ ${A},
13
+ ${v}
14
+ }`;o=o.replace(I[0],W),c=!0;return}o+=`
15
15
 
16
16
  ${x} {
17
- ${$}
18
- }`,c=!0},l=g=>{let _=g.replace(/[*.]/g,"\\$&"),w=new RegExp(`\\s*['"]ltbridge\\/modules\\/${_}['"],?`,"g");w.test(o)&&(o=o.replace(w,""),c=!0)},m="shared.lua",h="client.lua",f="server.lua";n?a("shared_scripts",m):l(m),s?a("client_scripts",h):l(h),u?a("server_scripts",f):l(f),(()=>{if(o.includes("'ltbridge/**/*.lua'")||o.includes('"ltbridge/**/*.lua"'))return;let g=rn(o,"escrow_ignore");if(g){let x=o.indexOf("{",g.blockStart);o=o.substring(0,x+1)+`
19
- 'ltbridge/**/*.lua',`+o.substring(x+1),c=!0;return}let _=/^(\s*)escrow_ignore\s+(['"].+?['"])/m,w=o.match(_);if(w){let $=`escrow_ignore {
17
+ ${A}
18
+ }`,c=!0},l=g=>{let _=g.replace(/[*.]/g,"\\$&"),w=new RegExp(`\\s*['"]ltbridge\\/modules\\/${_}['"],?`,"g");w.test(o)&&(o=o.replace(w,""),c=!0)},h="shared.lua",m="client.lua",f="server.lua";n?a("shared_scripts",h):l(h),s?a("client_scripts",m):l(m),u?a("server_scripts",f):l(f),(()=>{if(o.includes("'ltbridge/**/*.lua'")||o.includes('"ltbridge/**/*.lua"'))return;let g=rn(o,"escrow_ignore");if(g){let x=o.indexOf("{",g.blockStart);o=o.substring(0,x+1)+`
19
+ 'ltbridge/**/*.lua',`+o.substring(x+1),c=!0;return}let _=/^(\s*)escrow_ignore\s+(['"].+?['"])/m,w=o.match(_);if(w){let A=`escrow_ignore {
20
20
  'ltbridge/**/*.lua',
21
21
  ${w[2]}
22
- }`;o=o.replace(w[0],$),c=!0;return}o+=`
22
+ }`;o=o.replace(w[0],A),c=!0;return}o+=`
23
23
 
24
24
  escrow_ignore {
25
25
  'ltbridge/**/*.lua'
26
- }`,c=!0})(),t&&(n||s)?a("files","imports/**/*.lua"):(l("imports/**/*.lua"),l("modules/**/*.lua")),c&&(Ne.writeFileSync(e,o),console.log("\x1B[32m\u2713 Updated manifest.\x1B[0m"))}sn.exports={injectManifest:lt,findBlockEnd:ln}});var ve=H((Ht,dn)=>{var W=require("fs-extra"),J=require("path"),{applyBuildConstants:st}=Ke(),Ge=null;function un(){if(Ge)return Ge;let{getDatabase:d}=oe();return Ge=d().exportMap,Ge}function cn(d){let{getDatabase:s}=oe(),u=s(),n=[],t=new Set;for(let[a,l]of Object.entries(u.modules)){l.ns&&t.add(`LT.${l.ns} = LT.${l.ns} or {}`);let m=h=>{if(h&&h.stubs)for(let f of h.stubs)f.stubCode&&!f.metadata.internal&&n.push(f.stubCode)};m(l.shared),m(l.client),m(l.server)}let i=J.join(d,"ltbridge");W.ensureDirSync(i);let e=`--- @meta
26
+ }`,c=!0})(),t&&(n||s)?a("files","imports/**/*.lua"):(l("imports/**/*.lua"),l("modules/**/*.lua")),c&&(Me.writeFileSync(e,o),console.log("\x1B[32m\u2713 Updated manifest.\x1B[0m"))}sn.exports={injectManifest:lt,findBlockEnd:ln}});var ve=Z((Ht,dn)=>{var U=require("fs-extra"),J=require("path"),{applyBuildConstants:st}=Ke(),Ge=null;function un(){if(Ge)return Ge;let{getDatabase:d}=re();return Ge=d().exportMap,Ge}function cn(d){let{getDatabase:s}=re(),u=s(),n=[],t=new Set;for(let[a,l]of Object.entries(u.modules)){l.ns&&t.add(`LT.${l.ns} = LT.${l.ns} or {}`);let h=m=>{if(m&&m.stubs)for(let f of m.stubs)f.stubCode&&!f.metadata.internal&&n.push(f.stubCode)};h(l.shared),h(l.client),h(l.server)}let i=J.join(d,"ltbridge");U.ensureDirSync(i);let e=`--- @meta
27
27
  --- LT Bridge API Reference
28
28
  --- Auto-generated stub file for IDE intellisense.
29
29
  --- Do NOT include this file in your fxmanifest.
@@ -35,18 +35,18 @@ escrow_ignore {
35
35
  `,c=e+o+n.join(`
36
36
 
37
37
  `)+`
38
- `;W.writeFileSync(J.join(i,"api.lua"),c)}function at(d,s,u={}){let{version:n}=Fe(),t=u.skipApi===!0;if(s.version!==n){t?console.log(`\x1B[36m\u2139 LTBridge version updated (${s.version||"unknown"} -> ${n}). Run 'ltbridge api' to refresh API stubs.\x1B[0m`):(console.log(`\x1B[36m\u2139 LTBridge version updated (${s.version||"unknown"} -> ${n}). Regenerating API stubs...\x1B[0m`),cn(d)),s.version=n;let r=J.join(d,"ltbridge","ltbridge.config.json");W.writeFileSync(r,JSON.stringify(s,null,2))}let i=Date.now(),e=s.modules||[],o=s.minify!==!1,c=s.buildAsBundle!==!0,a=[],{resolveDependencies:l}=xe();e.length>0&&(a=l(e,un()).sequence),a=["__init__",...a.filter(r=>r!=="__init__")];let{getModuleData:m}=oe(),h=!1,f=!1,p=!1,g={},_={},w=[],x=r=>{let T=m(r);if(!T)return;let S=T.ns,b=F=>{let R=T[F];if(R){if(R.stubs)for(let V of R.stubs)g[V.funcName]=S,_[V.funcName]=V.metadata;let G=R.code,B=`
38
+ `;U.writeFileSync(J.join(i,"api.lua"),c)}function at(d,s,u={}){let{version:n}=Fe(),t=u.skipApi===!0;if(s.version!==n){t?console.log(`\x1B[36m\u2139 LTBridge version updated (${s.version||"unknown"} -> ${n}). Run 'ltbridge api' to refresh API stubs.\x1B[0m`):(console.log(`\x1B[36m\u2139 LTBridge version updated (${s.version||"unknown"} -> ${n}). Regenerating API stubs...\x1B[0m`),cn(d)),s.version=n;let r=J.join(d,"ltbridge","ltbridge.config.json");U.writeFileSync(r,JSON.stringify(s,null,2))}let i=Date.now(),e=s.modules||[],o=s.minify!==!1,c=s.buildAsBundle!==!0,a=[],{resolveDependencies:l}=xe();e.length>0&&(a=l(e,un()).sequence),a=["__init__",...a.filter(r=>r!=="__init__")];let{getModuleData:h}=re(),m=!1,f=!1,p=!1,g={},_={},w=[],x=r=>{let T=h(r);if(!T)return;let S=T.ns,b=F=>{let $=T[F];if($){if($.stubs)for(let O of $.stubs)g[O.funcName]=S,_[O.funcName]=O.metadata;let G=$.code,B=`
39
39
  -- Module: ${r} (${F}.lua)
40
40
  `,j=G;return o||(j=G.split(`
41
- `).map(V=>V.trim().length>0&&!c?" "+V:V).join(`
41
+ `).map(O=>O.trim().length>0&&!c?" "+O:O).join(`
42
42
  `)),c?`${j}
43
43
  `:B+`do
44
44
  ${j}
45
45
  end
46
- `}return null},y=b("shared"),E=b("client"),C=b("server");(y||E||C)&&(w.push({modName:r,ns:S,shared:y||"",client:E||"",server:C||""}),y&&(p=!0),E&&(h=!0),C&&(f=!0))};u.details&&(console.log(`
47
- \x1B[1m\x1B[35m\u{1F4E6} Bundling Sequence (${a.length} modules):\x1B[0m`),a.forEach((r,T)=>console.log(` \x1B[90m${(T+1).toString().padStart(2,"0")}.\x1B[0m ${r}`)),console.log(""));for(let r of a)x(r);let $=on(),I=(r,T)=>{if(!o)return r;try{return $.Minify(r,{RenameVariables:!0,RenameGlobals:!1,SolveMath:!1})}catch(S){return console.log(`\x1B[33m! Minification failed for ${T}. Emitting unminified code. Error: ${S.message}\x1B[0m`),r}},q=["LT","QBCore","ESX","QBX","exports"],v=new Set,O=r=>{let T=/^([a-zA-Z_][a-zA-Z0-9_]*)\s*=/gm,S;for(;(S=T.exec(r))!==null;){let b=S[1];q.includes(b)||v.add(b)}},K=s.debug===!1||s.debug===void 0;for(let r of w)r.shared&&(r.shared=st(r.shared,{version:n,disableDebug:K}));if(o)for(let r of w)r.shared&&O(r.shared),r.client&&O(r.client),r.server&&O(r.server);let be=require("crypto"),se=r=>be.createHash("md5").update(r).digest("hex").substring(0,5),Q={},ae=new Set;for(let r of v){let T=se(r),S=0;for(;ae.has(T);)S++,T=se(r+S);ae.add(T),Q[r]="__"+T}let fe=r=>{if(!r)return r;let T=Object.keys(Q);if(T.length===0)return r;let S=T.sort((y,E)=>E.length-y.length).map(y=>y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),b=new RegExp(`\\[\\[[\\s\\S]*?\\]\\]|'(?:[^'\\\\]|\\\\.)*'|"(?:[^"\\\\]|\\\\.)*"|\\b(${S.join("|")})\\b`,"g");return r.replace(b,(y,E)=>E&&Q[E]?Q[E]:y)};if(o)for(let r of w)r.shared=fe(r.shared),r.client=fe(r.client),r.server=fe(r.server);let ie={shared:new Set,client:new Set,server:new Set},de=(r,T)=>{if(!r)return r;let S=Object.keys(g).sort((C,F)=>F.length-C.length);if(S.length===0)return r;let b=r,y=new Set,E="";for(let C of S){let F=g[C],R=F?`LT.${F}.`:"LT.",G=_[C]||{};if(o&&G.internal){if(!Q[C]){let Te=se(C),Ce=0;for(;ae.has(Te);)Ce++,Te=se(C+Ce);ae.add(Te),Q[C]="__"+Te}let te=Q[C],Ee=new RegExp(`(^|[^a-zA-Z0-9_.:"'])(${C})(\\s*[=().,\\[\\]])`,"g");b=b.replace(Ee,`$1${te}$3`);continue}let B=`${R}${C}`,j=!!F;if(G.export){if(B=`${R}${G.export}`,G.global){let te=G.global===!0?G.export:G.global;E+=`LT.${te} = ${B}
48
- `}}else G.global&&(B=`LT.${G.global===!0?C:G.global}`,j=!1);let V=new RegExp(`\\b${C}\\b`).test(r);if(j&&V&&(T?T.add(`LT.${F} = LT.${F} or {}`):y.add(`LT.${F} = LT.${F} or {}`)),G.alias&&V&&G.alias.forEach(te=>{E+=`${R}${te} = ${B}
49
- `}),!V)continue;let A=new RegExp(`(^[ \\t]*function\\s+)${C}(\\s*\\()`,"gm");b=b.replace(A,`$1${B}$2`);let X=R.replace(/\./g,"\\."),ne=new RegExp(`\\b${X}(${C})(\\s*\\()`,"g");b=b.replace(ne,"$1$2");let D=new RegExp(`(^|[^a-zA-Z0-9_.:"'])(${C})(\\s*\\()`,"g");b=b.replace(D,(te,Ee,Te,Ce)=>Ee.trim().endsWith("function")?te:`${Ee}${B}${Ce}`)}return T?b+(E.length>0?`
46
+ `}return null},y=b("shared"),E=b("client"),C=b("server");(y||E||C)&&(w.push({modName:r,ns:S,shared:y||"",client:E||"",server:C||""}),y&&(p=!0),E&&(m=!0),C&&(f=!0))};u.details&&(console.log(`
47
+ \x1B[1m\x1B[35m\u{1F4E6} Bundling Sequence (${a.length} modules):\x1B[0m`),a.forEach((r,T)=>console.log(` \x1B[90m${(T+1).toString().padStart(2,"0")}.\x1B[0m ${r}`)),console.log(""));for(let r of a)x(r);let A=on(),N=(r,T)=>{if(!o)return r;try{return A.Minify(r,{RenameVariables:!0,RenameGlobals:!1,SolveMath:!1})}catch(S){return console.log(`\x1B[33m! Minification failed for ${T}. Emitting unminified code. Error: ${S.message}\x1B[0m`),r}},q=["LT","QBCore","ESX","QBX","exports"],I=new Set,v=r=>{let T=/^([a-zA-Z_][a-zA-Z0-9_]*)\s*=/gm,S;for(;(S=T.exec(r))!==null;){let b=S[1];q.includes(b)||I.add(b)}},W=s.debug===!1||s.debug===void 0;for(let r of w)r.shared&&(r.shared=st(r.shared,{version:n,disableDebug:W}));if(o)for(let r of w)r.shared&&v(r.shared),r.client&&v(r.client),r.server&&v(r.server);let ne=require("crypto"),z=r=>ne.createHash("md5").update(r).digest("hex").substring(0,5),X={},ue=new Set;for(let r of I){let T=z(r),S=0;for(;ue.has(T);)S++,T=z(r+S);ue.add(T),X[r]="__"+T}let de=r=>{if(!r)return r;let T=Object.keys(X);if(T.length===0)return r;let S=T.sort((y,E)=>E.length-y.length).map(y=>y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),b=new RegExp(`\\[\\[[\\s\\S]*?\\]\\]|'(?:[^'\\\\]|\\\\.)*'|"(?:[^"\\\\]|\\\\.)*"|\\b(${S.join("|")})\\b`,"g");return r.replace(b,(y,E)=>E&&X[E]?X[E]:y)};if(o)for(let r of w)r.shared=de(r.shared),r.client=de(r.client),r.server=de(r.server);let le={shared:new Set,client:new Set,server:new Set},Te=(r,T)=>{if(!r)return r;let S=Object.keys(g).sort((C,F)=>F.length-C.length);if(S.length===0)return r;let b=r,y=new Set,E="";for(let C of S){let F=g[C],$=F?`LT.${F}.`:"LT.",G=_[C]||{};if(o&&G.internal){if(!X[C]){let pe=z(C),Ce=0;for(;ue.has(pe);)Ce++,pe=z(C+Ce);ue.add(pe),X[C]="__"+pe}let ie=X[C],Ee=new RegExp(`(^|[^a-zA-Z0-9_.:"'])(${C})(\\s*[=().,\\[\\]])`,"g");b=b.replace(Ee,`$1${ie}$3`);continue}let B=`${$}${C}`,j=!!F;if(G.export){if(B=`${$}${G.export}`,G.global){let ie=G.global===!0?G.export:G.global;E+=`LT.${ie} = ${B}
48
+ `}}else G.global&&(B=`LT.${G.global===!0?C:G.global}`,j=!1);let O=new RegExp(`\\b${C}\\b`).test(r);if(j&&O&&(T?T.add(`LT.${F} = LT.${F} or {}`):y.add(`LT.${F} = LT.${F} or {}`)),G.alias&&O&&G.alias.forEach(ie=>{E+=`${$}${ie} = ${B}
49
+ `}),!O)continue;let R=new RegExp(`(^[ \\t]*function\\s+)${C}(\\s*\\()`,"gm");b=b.replace(R,`$1${B}$2`);let Y=$.replace(/\./g,"\\."),oe=new RegExp(`\\b${Y}(${C})(\\s*\\()`,"g");b=b.replace(oe,"$1$2");let D=new RegExp(`(^|[^a-zA-Z0-9_.:"'])(${C})(\\s*\\()`,"g");b=b.replace(D,(ie,Ee,pe,Ce)=>Ee.trim().endsWith("function")?ie:`${Ee}${B}${Ce}`)}return T?b+(E.length>0?`
50
50
  -- Exports
51
51
  ${E}`:""):`LT = LT or {}
52
52
  `+Array.from(y).join(`
@@ -55,15 +55,15 @@ ${E}`:""):`LT = LT or {}
55
55
  `:`
56
56
  `)+b+(E.length>0?`
57
57
  -- Exports
58
- ${E}`:"")},ee={shared:"",client:"",server:""},ue=[];for(let r of w)r.shared=de(r.shared,c?null:ie.shared),r.client=de(r.client,c?null:ie.client),r.server=de(r.server,c?null:ie.server),c?(r.shared&&ue.push({path:Ve(r.modName,"shared"),content:I(r.shared,`${r.modName} shared.lua`),type:"shared",ns:r.ns}),r.client&&ue.push({path:Ve(r.modName,"client"),content:I(r.client,`${r.modName} client.lua`),type:"client",ns:r.ns}),r.server&&ue.push({path:Ve(r.modName,"server"),content:I(r.server,`${r.modName} server.lua`),type:"server",ns:r.ns})):(r.shared&&(ee.shared+=I(r.shared,`${r.modName} shared.lua`)+`
59
- `),r.client&&(ee.client+=I(r.client,`${r.modName} client.lua`)+`
60
- `),r.server&&(ee.server+=I(r.server,`${r.modName} server.lua`)+`
61
- `));let ye=J.join(d,"ltbridge"),_e=new Set,z=(r,T)=>{let S=r.replace(/\\/g,"/"),b=J.join(ye,S);W.ensureDirSync(J.dirname(b)),W.writeFileSync(b,T),_e.add(S)},We=`=== LTBridge Auto-Generated Modules ===
58
+ ${E}`:"")},te={shared:"",client:"",server:""},ce=[];for(let r of w)r.shared=Te(r.shared,c?null:le.shared),r.client=Te(r.client,c?null:le.client),r.server=Te(r.server,c?null:le.server),c?(r.shared&&ce.push({path:Ve(r.modName,"shared"),content:N(r.shared,`${r.modName} shared.lua`),type:"shared",ns:r.ns}),r.client&&ce.push({path:Ve(r.modName,"client"),content:N(r.client,`${r.modName} client.lua`),type:"client",ns:r.ns}),r.server&&ce.push({path:Ve(r.modName,"server"),content:N(r.server,`${r.modName} server.lua`),type:"server",ns:r.ns})):(r.shared&&(te.shared+=N(r.shared,`${r.modName} shared.lua`)+`
59
+ `),r.client&&(te.client+=N(r.client,`${r.modName} client.lua`)+`
60
+ `),r.server&&(te.server+=N(r.server,`${r.modName} server.lua`)+`
61
+ `));let ye=J.join(d,"ltbridge"),_e=new Set,H=(r,T)=>{let S=r.replace(/\\/g,"/"),b=J.join(ye,S);U.ensureDirSync(J.dirname(b)),U.writeFileSync(b,T),_e.add(S)},We=`=== LTBridge Auto-Generated Modules ===
62
62
  These files were automatically generated and/or minified by LTBridge.
63
63
  Repository: https://github.com/laot7490/ltbridge
64
64
  Last Build Time: ${new Date().toLocaleString()}
65
65
  LTBridge Version: ${n}
66
- `;z("README.txt",We);let{injectManifest:k}=an(),L=r=>`--[[
66
+ `;H("README.txt",We);let{injectManifest:k}=an(),L=r=>`--[[
67
67
  * @license LT Bridge
68
68
  * ${r.toLowerCase()}.lua
69
69
  *
@@ -73,7 +73,7 @@ LTBridge Version: ${n}
73
73
  * LICENSE file in the root directory of this source tree.
74
74
  ]]
75
75
 
76
- `;if(c){let r={shared:[],client:[],server:[]};for(let S of ue){let b="modules/"+S.path.replace(/\\/g,"/");z(b,L(S.type)+`--- @diagnostic disable
76
+ `;if(c){let r={shared:[],client:[],server:[]};for(let S of ce){let b="modules/"+S.path.replace(/\\/g,"/");H(b,L(S.type)+`--- @diagnostic disable
77
77
  `+S.content);let y=S.path.replace(/\\/g,"/").replace(/^imports\//,"");r[S.type].push(` "${y}"`)}let T=(S,b)=>b.length===0?"":`-- LTBridge Auto-Generated ${S} Loader
78
78
  local loadSequence = {
79
79
  ${b.join(`,
@@ -93,29 +93,29 @@ for _, modPathSuffix in ipairs(loadSequence) do
93
93
  print("^6[LTBridge ${n}] ^1ERROR: Module file not found: " .. modPathSuffix .. "^7")
94
94
  end
95
95
  end
96
- `;p&&z("modules/shared.lua",T("Shared",r.shared)),h&&z("modules/client.lua",T("Client",r.client)),f&&z("modules/server.lua",T("Server",r.server)),k(d,h,f,p,!0)}else{let r=T=>`LT = LT or {}
97
- `+Array.from(ie[T]).join(`
98
- `)+(ie[T].size>0?`
96
+ `;p&&H("modules/shared.lua",T("Shared",r.shared)),m&&H("modules/client.lua",T("Client",r.client)),f&&H("modules/server.lua",T("Server",r.server)),k(d,m,f,p,!0)}else{let r=T=>`LT = LT or {}
97
+ `+Array.from(le[T]).join(`
98
+ `)+(le[T].size>0?`
99
99
 
100
100
  `:`
101
- `);p&&z("modules/shared.lua",L("Shared")+`--- @diagnostic disable
102
- `+r("shared")+ee.shared),h&&z("modules/client.lua",L("Client")+`--- @diagnostic disable
103
- `+r("client")+ee.client),f&&z("modules/server.lua",L("Server")+`--- @diagnostic disable
104
- `+r("server")+ee.server),k(d,h,f,p,!1)}ut(ye,_e),console.log(`\x1B[32m\u2713\x1B[0m ${a.length} modules bundled in ${Date.now()-i}ms`)}function ut(d,s){let u=J.join(d,"modules");W.existsSync(u)&&fn(u,d,s);let n=J.join(d,"README.txt");W.existsSync(n)&&!s.has("README.txt")&&W.removeSync(n)}function fn(d,s,u){for(let n of W.readdirSync(d)){let t=J.join(d,n),i=J.relative(s,t).replace(/\\/g,"/");W.statSync(t).isDirectory()?(fn(t,s,u),W.existsSync(t)&&W.readdirSync(t).length===0&&W.removeSync(t)):u.has(i)||W.removeSync(t)}}function Ve(d,s){let u=d.split("/"),n="uncategorized",t=d;return d==="__init__"?(n="Core",t="init"):u.length>1?(n=u.slice(0,-1).join("/").replace(/^@/,""),t=u[u.length-1]):d.startsWith("@")?(n=d.replace(/^@/,""),t="init"):t=d.replace(/^@/,""),t==="init"?`imports/${n}/${s}.lua`:`imports/${n}/${t}/${s}.lua`}dn.exports={rebuildBundle:at,generateFullApi:cn,getModuleExportMap:un}});var pn=H((Jt,Tn)=>{var{getModuleRegistry:ct,getModuleData:ft}=oe(),{resolveDependencies:dt}=xe(),{getModuleExportMap:Tt}=ve();function pt(){let d=ct();return Object.keys(d).filter(s=>{if(s==="__init__")return!1;let u=ft(s);return!(u&&u.meta&&u.meta.internal===!0)})}function ht(d,s){let u={};for(let n of d){let t=s[n],i=[];if(t){let c=t.split("/");for(let a=0;a<c.length-1;a++){let l=c[a];(l.startsWith("@")||l.startsWith("#"))&&(l=l.substring(1)),i.push(l)}}let e=i.length>0?i.join(" / "):"Uncategorized",o=n.split("/").pop();u[e]||(u[e]=[]),u[e].push({mod:n,name:o})}return u}function mt(d){let s=new Set;if(d&&d.length>0){let{graph:u}=dt(d,Tt());for(let n of Object.values(u))for(let t of n)s.add(t)}return s}function kt(d,s){let n="@"+s.split(" / ").pop();return(d.length>1?d.filter(i=>i.mod!==n):d).sort((i,e)=>i.name.localeCompare(e.name))}Tn.exports={getVisibleModules:pt,buildModuleGroups:ht,getDependencySets:mt,getFilteredSortedMods:kt}});var wn=H((Zt,Fn)=>{var N=require("fs-extra"),M=require("path"),{version:Re}=Fe(),{rebuildBundle:le,generateFullApi:mn,getModuleExportMap:qe}=ve(),{resolveDependencies:gt}=xe(),{getModuleRegistry:ce,getModuleData:kn}=oe(),{pickExportModule:Lt}=Ie(),{getVisibleModules:gn,buildModuleGroups:Ln,getDependencySets:Sn,getFilteredSortedMods:bn}=pn(),De=require("prompts"),Y=M.join("ltbridge","ltbridge.config.json");async function St(d,s={}){let u=M.join(d,Y);if(N.existsSync(u)&&!(await De({type:"confirm",name:"value",message:"LTBridge is already initialized. Do you want to overwrite the configuration?",initial:!1})).value){console.log("\x1B[33m! Initialization cancelled.\x1B[0m");return}console.log(`
101
+ `);p&&H("modules/shared.lua",L("Shared")+`--- @diagnostic disable
102
+ `+r("shared")+te.shared),m&&H("modules/client.lua",L("Client")+`--- @diagnostic disable
103
+ `+r("client")+te.client),f&&H("modules/server.lua",L("Server")+`--- @diagnostic disable
104
+ `+r("server")+te.server),k(d,m,f,p,!1)}ut(ye,_e),console.log(`\x1B[32m\u2713\x1B[0m ${a.length} modules bundled in ${Date.now()-i}ms`)}function ut(d,s){let u=J.join(d,"modules");U.existsSync(u)&&fn(u,d,s);let n=J.join(d,"README.txt");U.existsSync(n)&&!s.has("README.txt")&&U.removeSync(n)}function fn(d,s,u){for(let n of U.readdirSync(d)){let t=J.join(d,n),i=J.relative(s,t).replace(/\\/g,"/");U.statSync(t).isDirectory()?(fn(t,s,u),U.existsSync(t)&&U.readdirSync(t).length===0&&U.removeSync(t)):u.has(i)||U.removeSync(t)}}function Ve(d,s){let u=d.split("/"),n="uncategorized",t=d;return d==="__init__"?(n="Core",t="init"):u.length>1?(n=u.slice(0,-1).join("/").replace(/^@/,""),t=u[u.length-1]):d.startsWith("@")?(n=d.replace(/^@/,""),t="init"):t=d.replace(/^@/,""),t==="init"?`imports/${n}/${s}.lua`:`imports/${n}/${t}/${s}.lua`}dn.exports={rebuildBundle:at,generateFullApi:cn,getModuleExportMap:un}});var pn=Z((Zt,Tn)=>{var{getModuleRegistry:ct,getModuleData:ft}=re(),{resolveDependencies:dt}=xe(),{getModuleExportMap:Tt}=ve();function pt(){let d=ct();return Object.keys(d).filter(s=>{if(s==="__init__")return!1;let u=ft(s);return!(u&&u.meta&&u.meta.internal===!0)})}function ht(d,s){let u={};for(let n of d){let t=s[n],i=[];if(t){let c=t.split("/");for(let a=0;a<c.length-1;a++){let l=c[a];(l.startsWith("@")||l.startsWith("#"))&&(l=l.substring(1)),i.push(l)}}let e=i.length>0?i.join(" / "):"Uncategorized",o=n.split("/").pop();u[e]||(u[e]=[]),u[e].push({mod:n,name:o})}return u}function mt(d){let s=new Set;if(d&&d.length>0){let{graph:u}=dt(d,Tt());for(let n of Object.values(u))for(let t of n)s.add(t)}return s}function kt(d,s){let n="@"+s.split(" / ").pop();return(d.length>1?d.filter(i=>i.mod!==n):d).sort((i,e)=>i.name.localeCompare(e.name))}Tn.exports={getVisibleModules:pt,buildModuleGroups:ht,getDependencySets:mt,getFilteredSortedMods:kt}});var wn=Z((Jt,Fn)=>{var V=require("fs-extra"),M=require("path"),{version:Re}=Fe(),{rebuildBundle:ae,generateFullApi:mn,getModuleExportMap:qe}=ve(),{resolveDependencies:gt}=xe(),{getModuleRegistry:fe,getModuleData:kn}=re(),{pickExportModule:Lt}=Ie(),{getVisibleModules:gn,buildModuleGroups:Ln,getDependencySets:Sn,getFilteredSortedMods:bn}=pn(),De=require("prompts"),ee=M.join("ltbridge","ltbridge.config.json");async function St(d,s={}){let u=M.join(d,ee);if(V.existsSync(u)&&!(await De({type:"confirm",name:"value",message:"LTBridge is already initialized. Do you want to overwrite the configuration?",initial:!1})).value){console.log("\x1B[33m! Initialization cancelled.\x1B[0m");return}console.log(`
105
105
  \x1B[36m\u26A1 ltbridge v${Re}\x1B[0m \x1B[32mInitializing project...\x1B[0m
106
- `);let t=s.minify!==!1,i=s.debug===!0,e=!1;if(!process.argv.includes("--no-minify")&&!process.argv.includes("--debug")){let a=await De([{type:"select",name:"buildMode",message:"Build Output Mode:",choices:[{title:"Individual (Separate files per module)",value:!1},{title:"Bundle (Combine all into 3 files)",value:!0}],initial:0},{type:"select",name:"minify",message:"Bundled code minification:",choices:[{title:"Enabled (Compact production code)",value:!0},{title:"Disabled (Readable development code)",value:!1}],initial:0},{type:"select",name:"debug",message:"Runtime debug mode:",choices:[{title:"Disabled (Recommended for production)",value:!1},{title:"Enabled (Detailed logs and helper outputs)",value:!0}],initial:0}]);a.buildMode!==void 0&&(e=a.buildMode),a.minify!==void 0&&(t=a.minify),a.debug!==void 0&&(i=a.debug)}let c={version:Re,buildAsBundle:e,debug:i,minify:t,modules:[]};N.ensureDirSync(M.dirname(u)),N.writeFileSync(u,JSON.stringify(c,null,2)),console.log(`
107
- \x1B[32m\u2713 Created configuration: ${Y}\x1B[0m`),console.log(`\x1B[90m\u2139 Build Mode: ${e?"bundle":"individual"}\x1B[0m`),console.log(`\x1B[90m\u2139 Minify: ${t?"enabled":"disabled"}\x1B[0m`),console.log(`\x1B[90m\u2139 Debug: ${i?"enabled":"disabled"}\x1B[0m
108
- `),mn(d),s.noBuild!==!0&&le(d,c)}function Le(d){let s=M.join(d,Y);return N.existsSync(s)||(console.log("\x1B[31m\u2716 Not an LTBridge initialized directory. Run 'ltbridge init' first.\x1B[0m"),process.exit(1)),JSON.parse(N.readFileSync(s,"utf-8"))}function Se(d,s){let u=M.join(d,Y);N.writeFileSync(u,JSON.stringify(s,null,2))}function yn(d,s){if(!d.endsWith("*")){let t=_n(d,s);return t?[t]:[]}let u=d.replace(/\\/g,"/").replace(/^@/,"").replace(/\*$/,"").toLowerCase(),n=[];for(let t of Object.keys(s)){if(t==="__init__")continue;if(t.replace(/^@/,"").toLowerCase().startsWith(u)){let e=!1,o=kn(t);o&&o.meta&&(e=o.meta.internal===!0),e||n.push(t)}}return n}function _n(d,s){if(s[d])return d;let u=d.replace(/\\/g,"/").replace(/^@/,"").toLowerCase(),n=[];for(let e of Object.keys(s)){if(e.replace(/^@/,"").toLowerCase()===u)return e;let c=e.split("/"),a=c[c.length-1].toLowerCase();(a===u||a===u.replace(/^@/,""))&&n.push(e)}if(n.length===1)return n[0];n.length>1&&(console.log(`\x1B[31m\u2716 Ambiguous module name '${d}'.\x1B[0m`),console.log("\x1B[90m\u2139 Did you mean one of these?\x1B[0m"),n.forEach(e=>console.log(` - ${e.replace(/^@/,"")}`)),process.exit(1));let t=qe(),i=d.replace(/^LT\./,"");if(t[i]){let e=t[i];if(e.length===1)return e[0];console.log(`\x1B[31m\u2716 Ambiguous export name '${d}' provided by multiple modules.\x1B[0m`),console.log("\x1B[90m\u2139 Please use the full module path to add it:\x1B[0m"),e.forEach(o=>console.log(` - ltbridge add ${o.replace(/^@/,"")}`)),process.exit(1)}return null}function bt(d,s){let u=Le(d),n=ce(),t=yn(s,n);t.length===0&&(console.log(`\x1B[31m\u2716 No modules found matching '${s}'.\x1B[0m`),process.exit(1));let i=0,e=!1;for(let o of t){if(o==="__init__")continue;let c=!1,a=kn(o);if(a&&a.meta&&(c=a.meta.internal===!0),c){s.endsWith("*")||(console.log(`\x1B[31m\u2716 Cannot manually add internal ghost module '${o}'.\x1B[0m`),console.log("\x1B[90m\u2139 Ghost modules are active and managed purely as auto-dependencies behind the scenes.\x1B[0m"),e=!0);continue}if(u.modules.includes(o)){s.endsWith("*")||console.log(`\x1B[90m\u2139 Module '${o}' is already added.\x1B[0m`);continue}u.modules.push(o),console.log(`\x1B[32m\u2713 Added module '${o}'.\x1B[0m`),i++}i>0?(Se(d,u),le(d,u,{skipApi:!0})):s.endsWith("*")?(e&&(console.log(`\x1B[31m\u2716 No addable modules matched '${s}' (internal-only modules are auto-managed).\x1B[0m`),process.exit(1)),console.log("\x1B[90m\u2139 All matching modules are already added.\x1B[0m")):e&&process.exit(1)}function yt(d,s){let u=Le(d),n=ce(),t=yn(s,n);t.length===0&&(console.log(`\x1B[31m\u2716 No modules found matching '${s}'.\x1B[0m`),process.exit(1));let i=0;for(let e of t){if(!u.modules.includes(e)){s.endsWith("*")||console.log(`\x1B[90m\u2139 Module '${e}' is not currently added.\x1B[0m`);continue}u.modules=u.modules.filter(o=>o!==e),console.log(`\x1B[33m- Removed module '${e}'.\x1B[0m`),i++}i>0?(Se(d,u),le(d,u,{skipApi:!0})):s.endsWith("*")&&console.log("\x1B[90m\u2139 No matching modules were currently added.\x1B[0m")}function _t(d,s={}){let u=Le(d);console.log(`
109
- \x1B[36m\u26A1 ltbridge v${Re}\x1B[0m \x1B[32mbuilding for production...\x1B[0m`),le(d,u,s)}function En(d){let s=new Set;function u(n){if(!N.existsSync(n))return;let t=N.readdirSync(n);for(let i of t){if(i==="ltbridge"||i==="node_modules"||i===".git")continue;let e=M.join(n,i);if(N.statSync(e).isDirectory())u(e);else if(i.endsWith(".lua")){let c=N.readFileSync(e,"utf8"),a=/LT\.([a-zA-Z0-9_.]+)/g,l;for(;(l=a.exec(c))!==null;){let m=l[1];s.add(m);let h=m.split("."),f="";for(let p of h)f=f?f+"."+p:p,s.add(f)}}}}return u(d),s}function Cn(d){let s=ce(),u=Object.keys(s),n=qe(),t=new Set;for(let i of d){let e="@"+i.replace(/\./g,"/");if(u.includes(e)){t.add(e);continue}if(n[i]){let o=Lt(i,n[i]);o&&t.add(o)}}return t}function Et(d){let s=Le(d);console.log("\x1B[90m\u2139 Scanning project for unused LT modules...\x1B[0m");let u=En(d),n=Cn(u),t=[],i=[];for(let e of s.modules)n.has(e)?t.push(e):i.push(e);i.length>0?(console.log(`\x1B[32m\u2713 Pruned ${i.length} unused modules: ${i.join(", ")}\x1B[0m`),s.modules=t,Se(d,s)):console.log("\x1B[90m\u2139 No unused modules found. Everything is tightly integrated!\x1B[0m"),le(d,s,{skipApi:!0})}var Oe=null,$e=!1,je=!1;function hn(d,s){if(!s)return!0;let u=M.resolve(d),n=M.resolve(M.isAbsolute(s)?s:M.join(u,s)),t=M.relative(u,n).replace(/\\/g,"/");if(t===""||t===".")return!1;if(t.startsWith("..")||t.includes("node_modules")||t==="ltbridge/modules"||t.startsWith("ltbridge/modules/")||t==="ltbridge/api.lua"||t==="fxmanifest.lua"||t==="__resource.lua")return!0;if(t.endsWith("ltbridge.config.json"))return!1;let i;try{i=N.statSync(n)}catch{return!0}return i.isDirectory()?!1:!t.endsWith(".lua")}function Ct(d,s={}){let u="",n=M.join(d,Y);N.existsSync(n)&&(u=N.readFileSync(n,"utf-8"));function t(c=!1){if($e){je=!0;return}let a=Le(d),l=En(d),m=Cn(l),h=!1,f=new Set(a.modules);for(let p of m)f.has(p)||(f.add(p),h=!0);for(let p of a.modules)m.has(p)||(f.delete(p),h=!0);if(!(!h&&!c)){$e=!0;try{h&&(a.modules=Array.from(f)),u=JSON.stringify(a,null,2),h&&Se(d,a),le(d,a,{skipApi:!0,...s})}finally{$e=!1,je&&(je=!1,i())}}}function i(){Oe&&clearTimeout(Oe),Oe=setTimeout(()=>{try{t(!0)}catch(c){console.log(`\x1B[31m\u2716 Watcher error: ${c.message}\x1B[0m`)}},400)}console.log(`
106
+ `);let t=s.minify!==!1,i=s.debug===!0,e=!1;if(!process.argv.includes("--no-minify")&&!process.argv.includes("--debug")){let a=await De([{type:"select",name:"buildMode",message:"Build Output Mode:",choices:[{title:"Individual (Separate files per module)",value:!1},{title:"Bundle (Combine all into 3 files)",value:!0}],initial:0},{type:"select",name:"minify",message:"Bundled code minification:",choices:[{title:"Enabled (Compact production code)",value:!0},{title:"Disabled (Readable development code)",value:!1}],initial:0},{type:"select",name:"debug",message:"Runtime debug mode:",choices:[{title:"Disabled (Recommended for production)",value:!1},{title:"Enabled (Detailed logs and helper outputs)",value:!0}],initial:0}]);a.buildMode!==void 0&&(e=a.buildMode),a.minify!==void 0&&(t=a.minify),a.debug!==void 0&&(i=a.debug)}let c={version:Re,buildAsBundle:e,debug:i,minify:t,modules:[]};V.ensureDirSync(M.dirname(u)),V.writeFileSync(u,JSON.stringify(c,null,2)),console.log(`
107
+ \x1B[32m\u2713 Created configuration: ${ee}\x1B[0m`),console.log(`\x1B[90m\u2139 Build Mode: ${e?"bundle":"individual"}\x1B[0m`),console.log(`\x1B[90m\u2139 Minify: ${t?"enabled":"disabled"}\x1B[0m`),console.log(`\x1B[90m\u2139 Debug: ${i?"enabled":"disabled"}\x1B[0m
108
+ `),mn(d),s.noBuild!==!0&&ae(d,c)}function Se(d){let s=M.join(d,ee);return V.existsSync(s)||(console.log("\x1B[31m\u2716 Not an LTBridge initialized directory. Run 'ltbridge init' first.\x1B[0m"),process.exit(1)),JSON.parse(V.readFileSync(s,"utf-8"))}function be(d,s){let u=M.join(d,ee);V.writeFileSync(u,JSON.stringify(s,null,2))}function yn(d,s){if(!d.endsWith("*")){let t=_n(d,s);return t?[t]:[]}let u=d.replace(/\\/g,"/").replace(/^@/,"").replace(/\*$/,"").toLowerCase(),n=[];for(let t of Object.keys(s)){if(t==="__init__")continue;if(t.replace(/^@/,"").toLowerCase().startsWith(u)){let e=!1,o=kn(t);o&&o.meta&&(e=o.meta.internal===!0),e||n.push(t)}}return n}function _n(d,s){if(s[d])return d;let u=d.replace(/\\/g,"/").replace(/^@/,"").toLowerCase(),n=[];for(let e of Object.keys(s)){if(e.replace(/^@/,"").toLowerCase()===u)return e;let c=e.split("/"),a=c[c.length-1].toLowerCase();(a===u||a===u.replace(/^@/,""))&&n.push(e)}if(n.length===1)return n[0];n.length>1&&(console.log(`\x1B[31m\u2716 Ambiguous module name '${d}'.\x1B[0m`),console.log("\x1B[90m\u2139 Did you mean one of these?\x1B[0m"),n.forEach(e=>console.log(` - ${e.replace(/^@/,"")}`)),process.exit(1));let t=qe(),i=d.replace(/^LT\./,"");if(t[i]){let e=t[i];if(e.length===1)return e[0];console.log(`\x1B[31m\u2716 Ambiguous export name '${d}' provided by multiple modules.\x1B[0m`),console.log("\x1B[90m\u2139 Please use the full module path to add it:\x1B[0m"),e.forEach(o=>console.log(` - ltbridge add ${o.replace(/^@/,"")}`)),process.exit(1)}return null}function bt(d,s){let u=Se(d),n=fe(),t=yn(s,n);t.length===0&&(console.log(`\x1B[31m\u2716 No modules found matching '${s}'.\x1B[0m`),process.exit(1));let i=0,e=!1;for(let o of t){if(o==="__init__")continue;let c=!1,a=kn(o);if(a&&a.meta&&(c=a.meta.internal===!0),c){s.endsWith("*")||(console.log(`\x1B[31m\u2716 Cannot manually add internal ghost module '${o}'.\x1B[0m`),console.log("\x1B[90m\u2139 Ghost modules are active and managed purely as auto-dependencies behind the scenes.\x1B[0m"),e=!0);continue}if(u.modules.includes(o)){s.endsWith("*")||console.log(`\x1B[90m\u2139 Module '${o}' is already added.\x1B[0m`);continue}u.modules.push(o),console.log(`\x1B[32m\u2713 Added module '${o}'.\x1B[0m`),i++}i>0?(be(d,u),ae(d,u,{skipApi:!0})):s.endsWith("*")?(e&&(console.log(`\x1B[31m\u2716 No addable modules matched '${s}' (internal-only modules are auto-managed).\x1B[0m`),process.exit(1)),console.log("\x1B[90m\u2139 All matching modules are already added.\x1B[0m")):e&&process.exit(1)}function yt(d,s){let u=Se(d),n=fe(),t=yn(s,n);t.length===0&&(console.log(`\x1B[31m\u2716 No modules found matching '${s}'.\x1B[0m`),process.exit(1));let i=0;for(let e of t){if(!u.modules.includes(e)){s.endsWith("*")||console.log(`\x1B[90m\u2139 Module '${e}' is not currently added.\x1B[0m`);continue}u.modules=u.modules.filter(o=>o!==e),console.log(`\x1B[33m- Removed module '${e}'.\x1B[0m`),i++}i>0?(be(d,u),ae(d,u,{skipApi:!0})):s.endsWith("*")&&console.log("\x1B[90m\u2139 No matching modules were currently added.\x1B[0m")}function _t(d,s={}){let u=Se(d);console.log(`
109
+ \x1B[36m\u26A1 ltbridge v${Re}\x1B[0m \x1B[32mbuilding for production...\x1B[0m`),ae(d,u,s)}function En(d){let s=new Set;function u(n){if(!V.existsSync(n))return;let t=V.readdirSync(n);for(let i of t){if(i==="ltbridge"||i==="node_modules"||i===".git")continue;let e=M.join(n,i);if(V.statSync(e).isDirectory())u(e);else if(i.endsWith(".lua")){let c=V.readFileSync(e,"utf8"),a=/LT\.([a-zA-Z0-9_.]+)/g,l;for(;(l=a.exec(c))!==null;){let h=l[1];s.add(h);let m=h.split("."),f="";for(let p of m)f=f?f+"."+p:p,s.add(f)}}}}return u(d),s}function Cn(d){let s=fe(),u=Object.keys(s),n=qe(),t=new Set;for(let i of d){let e="@"+i.replace(/\./g,"/");if(u.includes(e)){t.add(e);continue}if(n[i]){let o=Lt(i,n[i]);o&&t.add(o)}}return t}function Et(d){let s=Se(d);console.log("\x1B[90m\u2139 Scanning project for unused LT modules...\x1B[0m");let u=En(d),n=Cn(u),t=[],i=[];for(let e of s.modules)n.has(e)?t.push(e):i.push(e);i.length>0?(console.log(`\x1B[32m\u2713 Pruned ${i.length} unused modules: ${i.join(", ")}\x1B[0m`),s.modules=t,be(d,s)):console.log("\x1B[90m\u2139 No unused modules found. Everything is tightly integrated!\x1B[0m"),ae(d,s,{skipApi:!0})}var Oe=null,$e=!1,je=!1;function hn(d,s){if(!s)return!0;let u=M.resolve(d),n=M.resolve(M.isAbsolute(s)?s:M.join(u,s)),t=M.relative(u,n).replace(/\\/g,"/");if(t===""||t===".")return!1;if(t.startsWith("..")||t.includes("node_modules")||t==="ltbridge/modules"||t.startsWith("ltbridge/modules/")||t==="ltbridge/api.lua"||t==="fxmanifest.lua"||t==="__resource.lua")return!0;if(t.endsWith("ltbridge.config.json"))return!1;let i;try{i=V.statSync(n)}catch{return!0}return i.isDirectory()?!1:!t.endsWith(".lua")}function Ct(d,s={}){let u="",n=M.join(d,ee);V.existsSync(n)&&(u=V.readFileSync(n,"utf-8"));function t(c=!1){if($e){je=!0;return}let a=Se(d),l=En(d),h=Cn(l),m=!1,f=new Set(a.modules);for(let p of h)f.has(p)||(f.add(p),m=!0);for(let p of a.modules)h.has(p)||(f.delete(p),m=!0);if(!(!m&&!c)){$e=!0;try{m&&(a.modules=Array.from(f)),u=JSON.stringify(a,null,2),m&&be(d,a),ae(d,a,{skipApi:!0,...s})}finally{$e=!1,je&&(je=!1,i())}}}function i(){Oe&&clearTimeout(Oe),Oe=setTimeout(()=>{try{t(!0)}catch(c){console.log(`\x1B[31m\u2716 Watcher error: ${c.message}\x1B[0m`)}},400)}console.log(`
110
110
  \x1B[36m\u26A1 ltbridge v${Re}\x1B[0m \x1B[32mwatching for changes...\x1B[0m`),t(!0);let o=require("chokidar").watch(d,{ignored:c=>hn(d,c),persistent:!0,ignoreInitial:!0,awaitWriteFinish:{stabilityThreshold:150,pollInterval:50}});o.on("ready",()=>{console.log(`\x1B[90m\u2139 Watching Lua files in ${M.resolve(d)} (Ctrl+C to stop)\x1B[0m
111
- `)}),o.on("error",c=>{console.log(`\x1B[31m\u2716 Watcher error: ${c.message}\x1B[0m`)}),o.on("all",(c,a)=>{if($e||!a||hn(d,a)||c!=="change"&&c!=="add")return;let l=M.isAbsolute(a)?a:M.join(d,a),m=M.relative(d,l).replace(/\\/g,"/");if(m.endsWith("ltbridge.config.json")||m===M.basename(Y).replace(/\\/g,"/"))try{if(N.readFileSync(n,"utf-8")===u)return}catch{return}i()})}function Ft(d){let s=ce(),u=gn(),n=null,t=M.join(d,Y);if(N.existsSync(t))try{n=JSON.parse(N.readFileSync(t,"utf-8"))}catch{}let i=n?new Set(n.modules):new Set,e=Sn(n?n.modules:[]),o=new Set(u),c=new Set([...i].filter(h=>o.has(h))),a=new Set([...e].filter(h=>o.has(h)&&!c.has(h))),l=c.size+a.size;if(console.log(`
111
+ `)}),o.on("error",c=>{console.log(`\x1B[31m\u2716 Watcher error: ${c.message}\x1B[0m`)}),o.on("all",(c,a)=>{if($e||!a||hn(d,a)||c!=="change"&&c!=="add")return;let l=M.isAbsolute(a)?a:M.join(d,a),h=M.relative(d,l).replace(/\\/g,"/");if(h.endsWith("ltbridge.config.json")||h===M.basename(ee).replace(/\\/g,"/"))try{if(V.readFileSync(n,"utf-8")===u)return}catch{return}i()})}function Ft(d){let s=fe(),u=gn(),n=null,t=M.join(d,ee);if(V.existsSync(t))try{n=JSON.parse(V.readFileSync(t,"utf-8"))}catch{}let i=n?new Set(n.modules):new Set,e=Sn(n?n.modules:[]),o=new Set(u),c=new Set([...i].filter(m=>o.has(m))),a=new Set([...e].filter(m=>o.has(m)&&!c.has(m))),l=c.size+a.size;if(console.log(`
112
112
  \x1B[1m\x1B[36m\u2139 LTBridge Modules List (${c.size} manual + ${a.size} auto = ${l} active / ${u.length} total)\x1B[0m
113
- `),u.length===0){console.log(" No modules found in the repository.");return}let m=Ln(u,s);for(let h of Object.keys(m).sort()){console.log(`
114
- \x1B[1m\x1B[35m\u{1F4C1} ${h}\x1B[0m`);let f=bn(m[h],h);for(let{mod:p,name:g}of f){let _=i.has(p),w=e.has(p),x=" ",$="\x1B[90m";_?(x="\u2714",$="\x1B[32m"):w&&(x="\u2699",$="\x1B[33m"),process.stdout.write(` ${$}${x} ${g.padEnd(30)}\x1B[0m`),w&&!_?process.stdout.write(" \x1B[90m\u2699 Auto-Dependency\x1B[0m"):w&&_&&process.stdout.write(" \x1B[90m(Also a Dependency)\x1B[0m"),process.stdout.write(`
113
+ `),u.length===0){console.log(" No modules found in the repository.");return}let h=Ln(u,s);for(let m of Object.keys(h).sort()){console.log(`
114
+ \x1B[1m\x1B[35m\u{1F4C1} ${m}\x1B[0m`);let f=bn(h[m],m);for(let{mod:p,name:g}of f){let _=i.has(p),w=e.has(p),x=" ",A="\x1B[90m";_?(x="\u2714",A="\x1B[32m"):w&&(x="\u2699",A="\x1B[33m"),process.stdout.write(` ${A}${x} ${g.padEnd(30)}\x1B[0m`),w&&!_?process.stdout.write(" \x1B[90m\u2699 Auto-Dependency\x1B[0m"):w&&_&&process.stdout.write(" \x1B[90m(Also a Dependency)\x1B[0m"),process.stdout.write(`
115
115
  `)}}console.log(`
116
116
  \x1B[90m(\u2714 = Installed | \u2699 = Auto Dependency)\x1B[0m
117
- `)}async function wt(d){let s=ce(),u=gn(),n=null,t=M.join(d,Y);if(N.existsSync(t))try{n=JSON.parse(N.readFileSync(t,"utf-8"))}catch{}if(!n){console.log("\x1B[31m\u2716 Not an LTBridge initialized directory. Run 'ltbridge init' first.\x1B[0m");return}let i=new Set(n.modules||[]),e=Sn(n.modules||[]),o=Ln(u,s),c=[];for(let f of Object.keys(o).sort()){c.push({title:`\x1B[1m\x1B[36m--- ${f.toUpperCase()} ---\x1B[0m`,value:`__group_${f}__`,disabled:!0});let p=bn(o[f],f);for(let{mod:g,name:_}of p){let w=i.has(g),x=e.has(g),$=_;x&&!w?$=`${$} \x1B[90m(\u2699 Auto-Dependency [INCLUDED])\x1B[0m`:x&&w&&($=`${$} \x1B[90m(Also a Dependency)\x1B[0m`),c.push({title:$,value:g,selected:w,disabled:x&&!w})}}let a=await De({type:"multiselect",name:"selectedModules",message:"Select LTBridge modules",choices:c,instructions:!1,hint:"- [Space] select. [Return] submit",min:0});if(!a.selectedModules){console.log("\x1B[90m\u2139 Module selection cancelled.\x1B[0m");return}let l=a.selectedModules.filter(f=>!f.startsWith("__group_")),m=l.filter(f=>!i.has(f)),h=Array.from(i).filter(f=>!l.includes(f));if(m.length===0&&h.length===0){console.log("\x1B[90m\u2139 No changes made to module selection.\x1B[0m");return}m.length>0&&console.log(`\x1B[32m\u2713 Adding: ${m.join(", ")}\x1B[0m`),h.length>0&&console.log(`\x1B[33m- Removing: ${h.join(", ")}\x1B[0m`),n.modules=l,Se(d,n),le(d,n,{skipApi:!0})}function xt(d,s){let u=ce(),n=_n(s,u);n||(console.log(`\x1B[31m\u2716 Module '${s}' does not exist in the repository.\x1B[0m`),process.exit(1));let t=M.join(d,Y);if(!N.existsSync(t)){console.log("\x1B[31m\u2716 Not an LTBridge initialized directory. Run 'ltbridge init' first.\x1B[0m");return}let i={modules:[]};try{i=JSON.parse(N.readFileSync(t,"utf-8"))}catch{}let e=new Set(i.modules||[]),{graph:o}=gt(i.modules||[],qe()),c={};for(let[h,f]of Object.entries(o))for(let p of f)c[p]||(c[p]=[]),c[p].includes(h)||c[p].push(h);let a=e.has(n),l=c[n]||[],m=l.length>0;if(console.log(`
118
- \x1B[1m\x1B[36m\u2139 Why is '${n}' included in your project?\x1B[0m`),!a&&!m){console.log(` \x1B[90m\u25CB This module is NOT currently included in your project build.\x1B[0m
119
- `);return}if(a&&console.log(" \x1B[32m\u2714 You explicitly added it to your ltbridge.config.json\x1B[0m"),m){console.log(" \x1B[33m\u2699 It is automatically included as a dependency for the following modules:\x1B[0m");for(let h of l)console.log(` - ${h}`)}console.log("")}Fn.exports={initProject:St,addModule:bt,removeModule:yt,refreshModules:_t,pruneModules:Et,watchProject:Ct,generateFullApi:mn,listModules:Ft,interactiveSelect:wt,explainModule:xt}});var{program:Z}=require("commander"),{version:Bt}=Fe(),{initProject:Gt,addModule:$t,removeModule:Rt,refreshModules:At,pruneModules:It,watchProject:Pt,generateFullApi:Mt,listModules:Nt,interactiveSelect:Vt,explainModule:vt}=wn();Z.name("ltbridge").description("LT Bridge CLI tool for managing Lua modules and intellisense stubs").version(Bt);Z.command("init").description("Initialize LTBridge in the current directory and generate Master API stubs").option("--no-minify","Disable minification").option("--debug","Enable debug mode").option("--no-build","Skip initial bundle after init (api stubs still generated)").action(async d=>{let s=process.cwd();await Gt(s,d)});Z.command("build").alias("refresh").alias("install").alias("sync").description("Resolve dependencies, rebuild bundles, and regenerate API stubs").option("-w, --watch","Watch project mode for continuous bundling").option("-d, --details","Show detailed bundling sequence").action(d=>{let s=process.cwd();d.watch?Pt(s,d):At(s,d)});Z.command("api").description("Regenerate the API stubs for IDE intellisense (Internal use for developers)").action(()=>{let d=process.cwd();console.log(`
120
- \x1B[36m\u26A1 ltbridge\x1B[0m \x1B[32mRegenerating API stubs...\x1B[0m`),Mt(d),console.log(`\x1B[32m\u2713 API reference successfully updated.\x1B[0m
121
- `)});Z.command("add <name>").description("Add a module to your project").action(d=>{$t(process.cwd(),d)});Z.command("remove <name>").description("Remove a module from your project").action(d=>{Rt(process.cwd(),d)});Z.command("why <name>").alias("explain").description("Explain why a module is included in your project (dependency graph)").action(d=>{vt(process.cwd(),d)});Z.command("list").description("List installed and available modules").action(()=>{Nt(process.cwd())});Z.command("prune").description("Prune unused modules from your project bundles").action(()=>{It(process.cwd())});process.argv.length<=2?Vt(process.cwd()):Z.parse(process.argv);
117
+ `)}async function wt(d){let s=fe(),u=gn(),n=null,t=M.join(d,ee);if(V.existsSync(t))try{n=JSON.parse(V.readFileSync(t,"utf-8"))}catch{}if(!n){console.log("\x1B[31m\u2716 Not an LTBridge initialized directory. Run 'ltbridge init' first.\x1B[0m");return}let i=new Set(n.modules||[]),e=Sn(n.modules||[]),o=Ln(u,s),c=[];for(let f of Object.keys(o).sort()){c.push({title:`\x1B[1m\x1B[36m--- ${f.toUpperCase()} ---\x1B[0m`,value:`__group_${f}__`,disabled:!0});let p=bn(o[f],f);for(let{mod:g,name:_}of p){let w=i.has(g),x=e.has(g),A=_;x&&!w?A=`${A} \x1B[90m(\u2699 Auto-Dependency [INCLUDED])\x1B[0m`:x&&w&&(A=`${A} \x1B[90m(Also a Dependency)\x1B[0m`),c.push({title:A,value:g,selected:w,disabled:x&&!w})}}let a=await De({type:"multiselect",name:"selectedModules",message:"Select LTBridge modules",choices:c,instructions:!1,hint:"- [Space] select. [Return] submit",min:0});if(!a.selectedModules){console.log("\x1B[90m\u2139 Module selection cancelled.\x1B[0m");return}let l=a.selectedModules.filter(f=>!f.startsWith("__group_")),h=l.filter(f=>!i.has(f)),m=Array.from(i).filter(f=>!l.includes(f));if(h.length===0&&m.length===0){console.log("\x1B[90m\u2139 No changes made to module selection.\x1B[0m");return}h.length>0&&console.log(`\x1B[32m\u2713 Adding: ${h.join(", ")}\x1B[0m`),m.length>0&&console.log(`\x1B[33m- Removing: ${m.join(", ")}\x1B[0m`),n.modules=l,be(d,n),ae(d,n,{skipApi:!0})}function xt(d,s){let u=fe(),n=_n(s,u);n||(console.log(`\x1B[31m\u2716 Module '${s}' does not exist in the repository.\x1B[0m`),process.exit(1));let t=M.join(d,ee);if(!V.existsSync(t)){console.log("\x1B[31m\u2716 Not an LTBridge initialized directory. Run 'ltbridge init' first.\x1B[0m");return}let i={modules:[]};try{i=JSON.parse(V.readFileSync(t,"utf-8"))}catch{}let e=new Set(i.modules||[]),{graph:o}=gt(i.modules||[],qe()),c={};for(let[m,f]of Object.entries(o))for(let p of f)c[p]||(c[p]=[]),c[p].includes(m)||c[p].push(m);let a=e.has(n),l=c[n]||[],h=l.length>0;if(console.log(`
118
+ \x1B[1m\x1B[36m\u2139 Why is '${n}' included in your project?\x1B[0m`),!a&&!h){console.log(` \x1B[90m\u25CB This module is NOT currently included in your project build.\x1B[0m
119
+ `);return}if(a&&console.log(" \x1B[32m\u2714 You explicitly added it to your ltbridge.config.json\x1B[0m"),h){console.log(" \x1B[33m\u2699 It is automatically included as a dependency for the following modules:\x1B[0m");for(let m of l)console.log(` - ${m}`)}console.log("")}Fn.exports={initProject:St,addModule:bt,removeModule:yt,refreshModules:_t,pruneModules:Et,watchProject:Ct,generateFullApi:mn,listModules:Ft,interactiveSelect:wt,explainModule:xt}});var{program:Q}=require("commander"),{version:Bt}=Fe(),{initProject:Gt,addModule:$t,removeModule:Rt,refreshModules:At,pruneModules:It,watchProject:Nt,generateFullApi:Pt,listModules:Mt,interactiveSelect:Vt,explainModule:vt}=wn();Q.name("ltbridge").description("LT Bridge CLI tool for managing Lua modules and intellisense stubs").version(Bt);Q.command("init").description("Initialize LTBridge in the current directory and generate Master API stubs").option("--no-minify","Disable minification").option("--debug","Enable debug mode").option("--no-build","Skip initial bundle after init (api stubs still generated)").action(async d=>{let s=process.cwd();await Gt(s,d)});Q.command("build").alias("refresh").alias("install").alias("sync").description("Resolve dependencies, rebuild bundles, and regenerate API stubs").option("-w, --watch","Watch project mode for continuous bundling").option("-d, --details","Show detailed bundling sequence").action(d=>{let s=process.cwd();d.watch?Nt(s,d):At(s,d)});Q.command("api").description("Regenerate the API stubs for IDE intellisense (Internal use for developers)").action(()=>{let d=process.cwd();console.log(`
120
+ \x1B[36m\u26A1 ltbridge\x1B[0m \x1B[32mRegenerating API stubs...\x1B[0m`),Pt(d),console.log(`\x1B[32m\u2713 API reference successfully updated.\x1B[0m
121
+ `)});Q.command("add <name>").description("Add a module to your project").action(d=>{$t(process.cwd(),d)});Q.command("remove <name>").description("Remove a module from your project").action(d=>{Rt(process.cwd(),d)});Q.command("why <name>").alias("explain").description("Explain why a module is included in your project (dependency graph)").action(d=>{vt(process.cwd(),d)});Q.command("list").description("List installed and available modules").action(()=>{Mt(process.cwd())});Q.command("prune").description("Prune unused modules from your project bundles").action(()=>{It(process.cwd())});process.argv.length<=2?Vt(process.cwd()):Q.parse(process.argv);