@aventusjs/cli 0.0.19 → 0.0.21
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/out/RealServer.js +8 -8
- package/out/cli.js +1 -1
- package/package.json +1 -1
package/out/RealServer.js
CHANGED
|
@@ -291,7 +291,7 @@ $namespaceEnd$
|
|
|
291
291
|
`}var _n=class e{writeCompiled=!1;enableWatchHistory=!1;writeHTML=!1;writeComponentTs=!1;static is(t){if(t.name==`Debugger`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);n.writeCompiled=e.writeCompiled==1,n.enableWatchHistory=e.enableWatchHistory==1,n.writeHTML=e.writeHTML==1,n.writeComponentTs=e.writeComponentTs==1}catch{}return n}return null}},vn=class e{static is(t){return t.name==`Required`?new e:null}},yn=class{static allChanges=[];static currentElement;static correct(e,t){var n=(0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0);if(this.allChanges=[],t instanceof un&&!this.currentElement){this.currentElement=t,(0,p.forEachChild)(n,e=>{var n=e.kind===p.SyntaxKind.InterfaceDeclaration,r=e.kind===p.SyntaxKind.ClassDeclaration;if(!(!n&&!r)){var i=e;for(let e of t.decorators)e.name!=`Debugger`&&this.addChange(e.content+`\r
|
|
292
292
|
`,i.getStart(),i.getStart());if(i.typeParameters&&i.typeParameters.forEach(e=>{e.constraint&&this.correctType(e.constraint)}),i.heritageClauses)for(let e of i.heritageClauses)this.correctClassInheritance(e);(0,p.forEachChild)(i,e=>{e.kind==p.SyntaxKind.Constructor||e.kind==p.SyntaxKind.MethodDeclaration?this.correctMethod(e):(e.kind==p.SyntaxKind.PropertyDeclaration||e.kind==p.SyntaxKind.GetAccessor||e.kind==p.SyntaxKind.SetAccessor)&&this.correctProperty(e)})}}),this.allChanges.sort((e,t)=>t.end-e.end);for(let t of this.allChanges)e=e.slice(0,t.start)+t.value+e.slice(t.end,e.length);this.currentElement=null}return e}static correctClassInheritance(e){(e.token==p.SyntaxKind.ExtendsKeyword||e.token==p.SyntaxKind.ImplementsKeyword)&&(0,p.forEachChild)(e,e=>{e.kind==p.SyntaxKind.ExpressionWithTypeArguments&&this.correctType(e)})}static correctMethod(e){if(e.type&&this.correctType(e.type),e.typeParameters&&e.typeParameters.forEach(e=>{e.constraint&&this.correctType(e.constraint)}),e.parameters.forEach(e=>{this.correctType(e.type)}),e.name){if(!this.currentElement)return;let t=e.name.getText(),n=this.currentElement.methods[t]??this.currentElement.methodsStatic[t];if(n){let t=n.decorators;for(let n of t)this.addChange(n.content+`\r
|
|
293
293
|
`,e.getStart(),e.getStart())}}}static correctProperty(e){if(e.type&&this.correctType(e.type),!this.currentElement)return;let t=e.name.getText(),n=this.currentElement.properties[t]??this.currentElement.propertiesStatic[t];if(n){let t=n.decorators;for(let n of t)this.addChange(n.content+`\r
|
|
294
|
-
`,e.getStart(),e.getStart())}}static addChange(e,t,n){this.allChanges.push({start:t,end:n,value:e})}static addChangeType(e,t,n){if(this.currentElement){let r=this.currentElement.parserInfo.getBaseInfo(e);r&&e!=r.fullName&&this.addChange(r.fullName,t,n)}}static correctType(e){if(e){if(e.kind===p.SyntaxKind.TypeReference){var t=e;let n=this.parseQualified(t.typeName);n&&(this.addChangeType(n,t.getStart(),t.getEnd()),t.typeArguments&&t.typeArguments.forEach(e=>{this.correctType(e)}))}else if(e.kind===p.SyntaxKind.ArrayType){var n=e;this.correctType(n.elementType)}else if(e.kind===p.SyntaxKind.UnionType){var r=e;for(let e of r.types)this.correctType(e)}else if(e.kind===p.SyntaxKind.ExpressionWithTypeArguments){var i=e;let t=this.parseQualified2(i.expression);t&&(this.addChangeType(t,i.expression.getStart(),i.expression.getEnd()),i.typeArguments&&i.typeArguments.forEach(e=>{this.correctType(e)}))}}}static parseQualified2(e){let t=``;if(e.expression)if(e.expression.kind===p.SyntaxKind.PropertyAccessExpression){let n=this.parseQualified2(e.expression);n&&(t=n+`.`)}else e.expression.kind===p.SyntaxKind.Identifier&&(t=e.expression.text+`.`);return e.name?t+e.name.text:t+e.text}static parseQualified(e){if(e.kind===p.SyntaxKind.Identifier)return e.text;var t=e;return this.parseQualified(t.left)+`.`+this.parseQualified(t.right)}},bn=class e{refType=``;constructor(e){this.refType=e}static is(t){if(t.name==`ForeignKey`&&t.arguments.length>0)try{if(t.arguments[0].type==`identifier`)return new e(t.arguments[0].value)}catch{}return null}},xn=class extends st{static getQuickInfo(e){if(e.contentUser.match(/\/\/#region js def \/\/((\s|\S)*)\/\/#endregion js def \/\//g)){let t=/^\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)$/gm.exec(e.contentUser);if(t)return{name:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])}}}}tsFile=null;tsDef=null;srcInfo={namespace:``,available:[],existing:[]};externalCSS={};name=``;npmUri=``;description=``;version={major:1,minor:0,patch:0};get versionTxt(){return this.version.major+`.`+this.version.minor+`.`+this.version.patch}get classInfoByName(){return this.tsDef?.classInfoByName||{}}get fileParsed(){return this.tsDef?.fileParsed||null}get definition(){return this.tsFile.contentUser}dependencies={};constructor(e,t){super(e,t),this.prepareFile()}async refreshDeprecated(e){this.tsDef&&await this.tsDef.refreshDeprecated(e)}loadWebComponents(){this.tsDef?.loadWebComponents()}prepareFile(){let e=this.separeSection();if(e){let t=d.TextDocument.create(this.file.uri,w.TypeScript,this.file.versionUser,e.jsDef);this.tsFile?this.tsFile.triggerContentChange(t):(this.tsFile=new j(t),this.tsDef=new Sn(this.tsFile,this.build));try{this.srcInfo=JSON.parse(e.jsSrc)}catch{}try{let t=JSON.parse(e.scssDefTxt);this.build.scssLanguageService.addExternalDefinition(this.file.uri,t)}catch{}try{this.externalCSS=JSON.parse(e.scssTxt)}catch{}try{let t=JSON.parse(e.htmlTxt);this.build.htmlLanguageService.addExternalDefinition(this.file.uri,t)}catch{}try{this.dependencies=JSON.parse(e.depsTxt)}catch{}this.build.externalPackageInformation.rebuild()}}separeSection(){if(this.file.contentUser.match(/\/\/#region js def \/\/((\s|\S)*)\/\/#endregion js def \/\//g)){let e=/^\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)$/gm.exec(this.file.contentUser);e&&(this.name=e[1],this.version.major=Number(e[2]),this.version.minor=Number(e[3]),this.version.patch=Number(e[4]));let t=/((\s|\S)*)\/\/#endregion js def \/\//g.exec(this.file.contentUser),n=``;t&&(n=t[0]);let r=/\/\/#region js src \/\/((\s|\S)*)\/\/#endregion js src \/\//g.exec(this.file.contentUser),i=``;r&&(i=r[1]);let a=/\/\/#region css \/\/((\s|\S)*)\/\/#endregion css \/\//g.exec(this.file.contentUser),o=``;a&&(o=a[1]);let s=/\/\/#region css def \/\/((\s|\S)*)\/\/#endregion css def \/\//g.exec(this.file.contentUser),c=``;s&&(c=s[1]);let l=/\/\/#region html \/\/((\s|\S)*)\/\/#endregion html \/\//g.exec(this.file.contentUser),u=``;l&&(u=l[1]);let d=/\/\/#region dependencies \/\/((\s|\S)*)\/\/#endregion dependencies \/\//g.exec(this.file.contentUser),f=``;return d&&(f=d[1]),{jsDef:n,jsSrc:i,scssDefTxt:c,scssTxt:o,htmlTxt:u,depsTxt:f}}return null}async onContentChange(){this.prepareFile(),this.build.reloadPage=!0,this.build.build()}async onValidate(){return[]}async onSave(){}async onDelete(){this.build.scssLanguageService.removeExternalDefinition(this.file.uri),this.build.htmlLanguageService.removeExternalDefinition(this.file.uri),this.tsFile&&this.tsFile.triggerDelete()}async onCompletion(e,t){return{isIncomplete:!0,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.tsFile?this.tsFile.getHover(t):null}async onDefinition(e,t){return this.tsFile?await this.tsFile.getDefinition(t):null}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return this.tsFile?this.tsFile.getReferences(t):[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}onGetBuild(){return[this.build]}transformPosition(e,t,n,r){let i=e.file.documentUser.offsetAt(t);return n.file.documentUser.positionAt(i-r)}},Sn=class extends hn{_classInfoByName={};packagesFiles=[];get extension(){return T.Package}get classInfoByName(){return this._classInfoByName}constructor(e,t){super(e,t)}loadWebComponents(){try{this.refreshFileParsed(!0);let e=this.fileParsed;if(e){this.loadFilePackage();for(let t in e.classes){let n=e.classes[t],r=!1;for(let e of n.implements){if(e==`Aventus.DefaultComponent`){r=!0;break}if(e==`Aventus.IData`)break}r&&(this._classInfoByName[n.fullName]=n)}}}catch(e){let t=this.file.uri.split(`/`),n=t[t.length-1];$.showErrorMessage(`There is an error inside file :`+n),$.error(e)}}loadFilePackage(){try{this.deletePackageFile();let e=this.fileParsed;if(e){let t={},n=e=>{for(let n in e){let r=e[n],i=r.fullName.split(`.`);i.pop();let a=i.join(`.`);t[a]||(t[a]={text:``,parts:[]});let o=t[a].text.length;t[a].text+=`export import ${r.name} = ${r.fullName};`+x.EOL,t[a].parts.push({startDef:r.start,endDef:r.end,startVirtual:o,endVirtual:t[a].text.length})}};n(e.classes),n(e.aliases),n(e.enums),n(e.functions),n(e.variables);for(let e in t)if(e){let n=this.file.name.replace(T.Package,``)+`:`+e+T.Package;this.packagesFiles.push(new Cn(t[e],n,this.build,this))}}}catch(e){$.error(e)}}deletePackageFile(){let e=[...this.packagesFiles];this.packagesFiles=[];for(let t of e)t.internalFile.triggerDelete()}async onContentChange(){this.loadWebComponents()}async onValidate(){return[]}async onSave(){}async onCompletion(e,t){return{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return null}async onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}async onDelete(){await super.onDelete()}},Cn=class extends hn{get extension(){return T.Package}internalFile;info;packageFile;constructor(e,t,n,r){let i=new j(d.TextDocument.create(`file:///`+t,w.TypeScript,1,e.text));i.triggerDelete(),super(i,n),this.info=e,this.internalFile=i,this._contentForLanguageService=e.text,this.fileParsed=r.fileParsed,this.packageFile=r}async goToDefinition(e){let t=this.file.documentInternal.offsetAt(e.start),n=this.file.documentInternal.offsetAt(e.end),r=n-t;for(let e of this.info.parts)if(t>=e.startVirtual&&n<=e.endVirtual){let n=t-e.startVirtual,i=e.startDef+n-7,a=i+r,o=this.packageFile.file.documentInternal.positionAt(i),s=this.packageFile.file.documentInternal.positionAt(a);return[{uri:this.packageFile.file.uri,range:{start:o,end:s}}]}return null}async onContentChange(){}async onValidate(){return[]}async onSave(){}async onCompletion(e,t){return{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return null}async onDefinition(e,t){return null}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}},wn=class e{languageService;languageServiceNamespace;build;filesNeeded=[];filesNpm=[];filesNpmLoaded=!1;filesLoaded={};i18nFiles={};constructor(e){this.build=e,Mt(),this.onSettingsChanged(e),E.getInstance().onSettingsChange(()=>{this.onSettingsChanged(e)}),this.languageService=(0,p.createLanguageService)(this.createHost()),this.languageServiceNamespace=(0,p.createLanguageService)(this.createHostNamespace())}onSettingsChanged(e){let t=E.getInstance().settings.readNodeModules;t!=this.filesNpmLoaded&&(t?this.filesNpm=Nt((0,f.join)(e.project.getConfigFile().folderPath,`node_modules`)):this.filesNpm=[],this.filesNpmLoaded=t)}createHostNamespace(){let e=this;return{getCompilationSettings:()=>Tn,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].version+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionUser+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:Pt(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:Pt(e),fileExists:e=>(e.endsWith(T.Base+`.ts`)&&(e=e.replace(T.Base+`.ts`,T.Base)),this.filesLoaded[e]||this.i18nFiles[e]?!0:!!Pt(e)),directoryExists:e=>(0,u.existsSync)(O(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}createHost(){let e=this;return{getCompilationSettings:()=>Tn,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].versionInternal+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionInternal+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].contentForLanguageService:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:Pt(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>{let n;if(this.filesLoaded[e])n=this.filesLoaded[e].contentForLanguageService;else if(this.i18nFiles[e])return this.i18nFiles[e].file.contentInternal;else n=Pt(e);return n},fileExists:e=>{let t=!1;if(e.endsWith(T.Base+`.ts`)&&(e=e.replace(T.Base+`.ts`,T.Base)),this.filesLoaded[e])t=!0;else if(this.i18nFiles[e])return!0;else t=!!Pt(e);return t},directoryExists:e=>(0,u.existsSync)(O(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}resolveModuleNames(e,t,n,r,i,a,o){let s=[];for(let r of t){if(!r.startsWith(`.`)&&r.endsWith(T.Package)){let e={extension:p.Extension.Ts,resolvedFileName:`file:///`+r};s.push(e);continue}let t=R.getInstance().getByUri(n);t&&(r=this.build.project.resolveAlias(r,t));let i=(0,p.resolveModuleName)(r,n,Tn,e);if(i.resolvedModule)i.resolvedModule.resolvedFileName.endsWith(`.avt.ts`)&&(i.resolvedModule.resolvedFileName=i.resolvedModule.resolvedFileName.replace(`.avt.ts`,`.avt`)),s.push(i.resolvedModule);else{let e={extension:p.Extension.Ts,resolvedFileName:r};s.push(e)}}return s}addFile(e){this.filesNeeded.indexOf(e.file.uri)==-1&&(this.filesNeeded.push(e.file.uri),this.filesLoaded[e.file.uri]=e)}removeFile(e){let t=this.filesNeeded.indexOf(e.file.uri);t!=-1&&(this.filesNeeded.splice(t,1),delete this.filesLoaded[e.file.uri])}doValidation(e){try{let t=[1206,1249,2612],n=[],r=this.languageService.getSyntacticDiagnostics(e.uri),i=this.languageService.getSemanticDiagnostics(e.uri),a=r.concat(i);for(let r of a){if(t.includes(r.code))continue;let i=`${(0,p.flattenDiagnosticMessageText)(r.messageText,`
|
|
294
|
+
`,e.getStart(),e.getStart())}}static addChange(e,t,n){this.allChanges.push({start:t,end:n,value:e})}static addChangeType(e,t,n){if(this.currentElement){let r=this.currentElement.parserInfo.getBaseInfo(e);r&&e!=r.fullName&&this.addChange(r.fullName,t,n)}}static correctType(e){if(e){if(e.kind===p.SyntaxKind.TypeReference){var t=e;let n=this.parseQualified(t.typeName);n&&(this.addChangeType(n,t.getStart(),t.getEnd()),t.typeArguments&&t.typeArguments.forEach(e=>{this.correctType(e)}))}else if(e.kind===p.SyntaxKind.ArrayType){var n=e;this.correctType(n.elementType)}else if(e.kind===p.SyntaxKind.UnionType){var r=e;for(let e of r.types)this.correctType(e)}else if(e.kind===p.SyntaxKind.ExpressionWithTypeArguments){var i=e;let t=this.parseQualified2(i.expression);t&&(this.addChangeType(t,i.expression.getStart(),i.expression.getEnd()),i.typeArguments&&i.typeArguments.forEach(e=>{this.correctType(e)}))}}}static parseQualified2(e){let t=``;if(e.expression)if(e.expression.kind===p.SyntaxKind.PropertyAccessExpression){let n=this.parseQualified2(e.expression);n&&(t=n+`.`)}else e.expression.kind===p.SyntaxKind.Identifier&&(t=e.expression.text+`.`);return e.name?t+e.name.text:t+e.text}static parseQualified(e){if(e.kind===p.SyntaxKind.Identifier)return e.text;var t=e;return this.parseQualified(t.left)+`.`+this.parseQualified(t.right)}},bn=class e{refType=``;constructor(e){this.refType=e}static is(t){if(t.name==`ForeignKey`&&t.arguments.length>0)try{if(t.arguments[0].type==`identifier`)return new e(t.arguments[0].value)}catch{}return null}},xn=class extends st{static getQuickInfo(e){try{if(/\/\/#region js def \/\/([\s\S]*?)\/\/#endregion js def \/\//.test(e.contentUser)){let t=/^\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)$/gm.exec(e.contentUser);if(t)return{name:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])}}}}catch(e){console.error(e)}}tsFile=null;tsDef=null;srcInfo={namespace:``,available:[],existing:[]};externalCSS={};name=``;npmUri=``;description=``;version={major:1,minor:0,patch:0};get versionTxt(){return this.version.major+`.`+this.version.minor+`.`+this.version.patch}get classInfoByName(){return this.tsDef?.classInfoByName||{}}get fileParsed(){return this.tsDef?.fileParsed||null}get definition(){return this.tsFile.contentUser}dependencies={};constructor(e,t){super(e,t),this.prepareFile()}async refreshDeprecated(e){this.tsDef&&await this.tsDef.refreshDeprecated(e)}loadWebComponents(){this.tsDef?.loadWebComponents()}prepareFile(){let e=this.separeSection();if(e){let t=d.TextDocument.create(this.file.uri,w.TypeScript,this.file.versionUser,e.jsDef);this.tsFile?this.tsFile.triggerContentChange(t):(this.tsFile=new j(t),this.tsDef=new Sn(this.tsFile,this.build));try{this.srcInfo=JSON.parse(e.jsSrc)}catch{}try{let t=JSON.parse(e.scssDefTxt);this.build.scssLanguageService.addExternalDefinition(this.file.uri,t)}catch{}try{this.externalCSS=JSON.parse(e.scssTxt)}catch{}try{let t=JSON.parse(e.htmlTxt);this.build.htmlLanguageService.addExternalDefinition(this.file.uri,t)}catch{}try{this.dependencies=JSON.parse(e.depsTxt)}catch{}this.build.externalPackageInformation.rebuild()}}separeSection(){if(this.file.contentUser.match(/\/\/#region js def \/\/([\s\S]*?)\/\/#endregion js def \/\//g)){let e=/^\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)$/gm.exec(this.file.contentUser);e&&(this.name=e[1],this.version.major=Number(e[2]),this.version.minor=Number(e[3]),this.version.patch=Number(e[4]));let t=/([\s\S]*?)\/\/#endregion js def \/\//g.exec(this.file.contentUser),n=``;t&&(n=t[0]);let r=/\/\/#region js src \/\/([\s\S]*?)\/\/#endregion js src \/\//g.exec(this.file.contentUser),i=``;r&&(i=r[1]);let a=/\/\/#region css \/\/([\s\S]*?)\/\/#endregion css \/\//g.exec(this.file.contentUser),o=``;a&&(o=a[1]);let s=/\/\/#region css def \/\/([\s\S]*?)\/\/#endregion css def \/\//g.exec(this.file.contentUser),c=``;s&&(c=s[1]);let l=/\/\/#region html \/\/([\s\S]*?)\/\/#endregion html \/\//g.exec(this.file.contentUser),u=``;l&&(u=l[1]);let d=/\/\/#region dependencies \/\/([\s\S]*?)\/\/#endregion dependencies \/\//g.exec(this.file.contentUser),f=``;return d&&(f=d[1]),{jsDef:n,jsSrc:i,scssDefTxt:c,scssTxt:o,htmlTxt:u,depsTxt:f}}return null}async onContentChange(){this.prepareFile(),this.build.reloadPage=!0,this.build.build()}async onValidate(){return[]}async onSave(){}async onDelete(){this.build.scssLanguageService.removeExternalDefinition(this.file.uri),this.build.htmlLanguageService.removeExternalDefinition(this.file.uri),this.tsFile&&this.tsFile.triggerDelete()}async onCompletion(e,t){return{isIncomplete:!0,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.tsFile?this.tsFile.getHover(t):null}async onDefinition(e,t){return this.tsFile?await this.tsFile.getDefinition(t):null}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return this.tsFile?this.tsFile.getReferences(t):[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}onGetBuild(){return[this.build]}transformPosition(e,t,n,r){let i=e.file.documentUser.offsetAt(t);return n.file.documentUser.positionAt(i-r)}},Sn=class extends hn{_classInfoByName={};packagesFiles=[];get extension(){return T.Package}get classInfoByName(){return this._classInfoByName}constructor(e,t){super(e,t)}loadWebComponents(){try{this.refreshFileParsed(!0);let e=this.fileParsed;if(e){this.loadFilePackage();for(let t in e.classes){let n=e.classes[t],r=!1;for(let e of n.implements){if(e==`Aventus.DefaultComponent`){r=!0;break}if(e==`Aventus.IData`)break}r&&(this._classInfoByName[n.fullName]=n)}}}catch(e){let t=this.file.uri.split(`/`),n=t[t.length-1];$.showErrorMessage(`There is an error inside file :`+n),$.error(e)}}loadFilePackage(){try{this.deletePackageFile();let e=this.fileParsed;if(e){let t={},n=e=>{for(let n in e){let r=e[n],i=r.fullName.split(`.`);i.pop();let a=i.join(`.`);t[a]||(t[a]={text:``,parts:[]});let o=t[a].text.length;t[a].text+=`export import ${r.name} = ${r.fullName};`+x.EOL,t[a].parts.push({startDef:r.start,endDef:r.end,startVirtual:o,endVirtual:t[a].text.length})}};n(e.classes),n(e.aliases),n(e.enums),n(e.functions),n(e.variables);for(let e in t)if(e){let n=this.file.name.replace(T.Package,``)+`:`+e+T.Package;this.packagesFiles.push(new Cn(t[e],n,this.build,this))}}}catch(e){$.error(e)}}deletePackageFile(){let e=[...this.packagesFiles];this.packagesFiles=[];for(let t of e)t.internalFile.triggerDelete()}async onContentChange(){this.loadWebComponents()}async onValidate(){return[]}async onSave(){}async onCompletion(e,t){return{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return null}async onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}async onDelete(){await super.onDelete()}},Cn=class extends hn{get extension(){return T.Package}internalFile;info;packageFile;constructor(e,t,n,r){let i=new j(d.TextDocument.create(`file:///`+t,w.TypeScript,1,e.text));i.triggerDelete(),super(i,n),this.info=e,this.internalFile=i,this._contentForLanguageService=e.text,this.fileParsed=r.fileParsed,this.packageFile=r}async goToDefinition(e){let t=this.file.documentInternal.offsetAt(e.start),n=this.file.documentInternal.offsetAt(e.end),r=n-t;for(let e of this.info.parts)if(t>=e.startVirtual&&n<=e.endVirtual){let n=t-e.startVirtual,i=e.startDef+n-7,a=i+r,o=this.packageFile.file.documentInternal.positionAt(i),s=this.packageFile.file.documentInternal.positionAt(a);return[{uri:this.packageFile.file.uri,range:{start:o,end:s}}]}return null}async onContentChange(){}async onValidate(){return[]}async onSave(){}async onCompletion(e,t){return{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return null}async onDefinition(e,t){return null}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}},wn=class e{languageService;languageServiceNamespace;build;filesNeeded=[];filesNpm=[];filesNpmLoaded=!1;filesLoaded={};i18nFiles={};constructor(e){this.build=e,Mt(),this.onSettingsChanged(e),E.getInstance().onSettingsChange(()=>{this.onSettingsChanged(e)}),this.languageService=(0,p.createLanguageService)(this.createHost()),this.languageServiceNamespace=(0,p.createLanguageService)(this.createHostNamespace())}onSettingsChanged(e){let t=E.getInstance().settings.readNodeModules;t!=this.filesNpmLoaded&&(t?this.filesNpm=Nt((0,f.join)(e.project.getConfigFile().folderPath,`node_modules`)):this.filesNpm=[],this.filesNpmLoaded=t)}createHostNamespace(){let e=this;return{getCompilationSettings:()=>Tn,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].version+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionUser+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:Pt(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:Pt(e),fileExists:e=>(e.endsWith(T.Base+`.ts`)&&(e=e.replace(T.Base+`.ts`,T.Base)),this.filesLoaded[e]||this.i18nFiles[e]?!0:!!Pt(e)),directoryExists:e=>(0,u.existsSync)(O(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}createHost(){let e=this;return{getCompilationSettings:()=>Tn,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].versionInternal+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionInternal+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].contentForLanguageService:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:Pt(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>{let n;if(this.filesLoaded[e])n=this.filesLoaded[e].contentForLanguageService;else if(this.i18nFiles[e])return this.i18nFiles[e].file.contentInternal;else n=Pt(e);return n},fileExists:e=>{let t=!1;if(e.endsWith(T.Base+`.ts`)&&(e=e.replace(T.Base+`.ts`,T.Base)),this.filesLoaded[e])t=!0;else if(this.i18nFiles[e])return!0;else t=!!Pt(e);return t},directoryExists:e=>(0,u.existsSync)(O(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}resolveModuleNames(e,t,n,r,i,a,o){let s=[];for(let r of t){if(!r.startsWith(`.`)&&r.endsWith(T.Package)){let e={extension:p.Extension.Ts,resolvedFileName:`file:///`+r};s.push(e);continue}let t=R.getInstance().getByUri(n);t&&(r=this.build.project.resolveAlias(r,t));let i=(0,p.resolveModuleName)(r,n,Tn,e);if(i.resolvedModule)i.resolvedModule.resolvedFileName.endsWith(`.avt.ts`)&&(i.resolvedModule.resolvedFileName=i.resolvedModule.resolvedFileName.replace(`.avt.ts`,`.avt`)),s.push(i.resolvedModule);else{let e={extension:p.Extension.Ts,resolvedFileName:r};s.push(e)}}return s}addFile(e){this.filesNeeded.indexOf(e.file.uri)==-1&&(this.filesNeeded.push(e.file.uri),this.filesLoaded[e.file.uri]=e)}removeFile(e){let t=this.filesNeeded.indexOf(e.file.uri);t!=-1&&(this.filesNeeded.splice(t,1),delete this.filesLoaded[e.file.uri])}doValidation(e){try{let t=[1206,1249,2612],n=[],r=this.languageService.getSyntacticDiagnostics(e.uri),i=this.languageService.getSemanticDiagnostics(e.uri),a=r.concat(i);for(let r of a){if(t.includes(r.code))continue;let i=`${(0,p.flattenDiagnosticMessageText)(r.messageText,`
|
|
295
295
|
`)}`;r.reportsUnnecessary?n.push({range:Re(e.documentInternal,r),severity:m.DiagnosticSeverity.Hint,source:w.TypeScript,message:i,tags:[m.DiagnosticTag.Unnecessary]}):n.push({range:Re(e.documentInternal,r),severity:m.DiagnosticSeverity.Error,source:w.TypeScript,message:i})}return n}catch(e){this.printCatchError(e)}return[]}async doComplete(e,t){try{let n=e.documentInternal,r=n.offsetAt(t),i=Re(n,Ue(n.getText(),r)),a;try{a=this.languageService.getCompletionsAtPosition(n.uri,r,Dn)}catch(e){this.printCatchError(e)}if(!a)return{isIncomplete:!1,items:[]};let o=[];for(let e=0;e<a.entries.length;e++){let t=a.entries[e],s=t.insertText?t.insertText:t.name;s=s.replace(/\.\?\./g,`?.`);let c;if(s.startsWith(`?`)){let e=n.offsetAt(i.start)-1;n.getText()[e]==`.`&&(c=[{newText:``,range:{start:{line:i.start.line,character:i.start.character-1},end:{line:i.start.line,character:i.start.character}}}])}let l={languageId:w.TypeScript,offset:r,uri:n.uri},u={label:t.name,sortText:t.sortText,kind:kn(t.kind),textEdit:m.TextEdit.replace(i,s),additionalTextEdits:c,data:{...t.data,...l}};o.push(u)}return{isIncomplete:!1,items:o}}catch(e){this.printCatchError(e)}return{isIncomplete:!1,items:[]}}async doResolve(e){try{if(e.data){let t=this.build.tsFiles[e.data.uri];if(t!=null){let n={languageId:e.data.languageIdJs,offset:e.data.offset,uri:e.data.uri};delete e.data.languageId,delete e.data.offset,delete e.data.uri,Object.keys(e.data).length==0&&(e.data=void 0);let r=this.languageService.getCompletionEntryDetails(n.uri,n.offset,e.label,{},t.file.contentInternal,Dn,e.data);if(r){if(e.detail=(0,p.displayPartsToString)(r.displayParts),e.documentation=(0,p.displayPartsToString)(r.documentation),e.additionalTextEdits=[],r.codeActions)for(let n=0;n<r.codeActions.length;n++)for(let i of r.codeActions[n].changes)for(let n of i.textChanges){n.newText=Te(n.newText.replace(/'/g,`"`));let r=/"(.*)"/g.exec(n.newText);if(r&&r.length>1){if(r[0].includes(T.Package)){let e=r[1];e=this.filesNeeded.find(t=>t.toLowerCase()==e)??e,e=e.replace(`file:///`,``).replace(/\.\.\//g,``),n.newText=n.newText.replace(r[1],e)}else if(r[1].startsWith(`.`)){let i=this.simplifyPath(r[1],t.file.uri);e.detail+=`\r
|
|
296
296
|
import from `+i,n.newText=n.newText.replace(r[1],i)}}e.additionalTextEdits.push({newText:n.newText,range:Re(t.file.documentInternal,n.span)})}delete e.data}}}}catch(e){this.printCatchError(e)}return e}async doHover(e,t){try{let n=this.languageService.getQuickInfoAtPosition(e.uri,e.documentInternal.offsetAt(t));if(n){let t=[],r=[];if(n.documentation)for(let e of n.documentation)t.push(`${e.text.trim()}`),r.push(e.text.trim());if(n.tags){r.push(` `);for(let e of n.tags){if(e.name===`inheritdoc`)continue;let n=!0,i=[];if(e.text)for(let t of e.text){if(t.kind==`text`&&t.text==r.join(``)){n=!1;break}i.push(t.text)}if(!n)continue;let a=i.join(``).trim();e.name===`example`?t.push(`\`@${e.name}\`\n\`\`\`typescript\n${a}\n\`\`\``):t.push(`\`@${e.name}\` ${a}`)}}let i=``;return n.displayParts&&(i+="\n```typescript\n",i+=(0,p.displayPartsToString)(n.displayParts).trim(),i+=`
|
|
297
297
|
\`\`\`
|
|
@@ -311,7 +311,7 @@ import from `+i,n.newText=n.newText.replace(r[1],i)}}e.additionalTextEdits.push(
|
|
|
311
311
|
${i}
|
|
312
312
|
${a}
|
|
313
313
|
});
|
|
314
|
-
}`}}this.writeFileReplaceVar(`slotBlock`,e),this.writeFileHotReloadReplaceVar(`slotBlock`,e),this.writeFileNpmReplaceVar(`slotBlock`,e)}writeFileConstructor(){if(this.classInfo){let e=``,t=``,n=``,r=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContent}}`,wn.getCompilerOptionsCompile()),i=/\{(
|
|
314
|
+
}`}}this.writeFileReplaceVar(`slotBlock`,e),this.writeFileHotReloadReplaceVar(`slotBlock`,e),this.writeFileNpmReplaceVar(`slotBlock`,e)}writeFileConstructor(){if(this.classInfo){let e=``,t=``,n=``,r=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContent}}`,wn.getCompilerOptionsCompile()),i=/\{([\s\S]*?)\}/gm.exec(r);if(i&&(e=i[1].trim()),yt.isRunning){let e=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContentHotReload}}`,wn.getCompilerOptionsCompile()),n=/\{([\s\S]*?)\}/gm.exec(e);n&&(t=n[1].trim())}if(this.templateNpm){let e=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContentNpm}}`,wn.getCompilerOptionsCompile()),t=/\{([\s\S]*?)\}/gm.exec(e);t&&(n=t[1].trim())}this.writeFileReplaceVar(`constructor`,e),this.writeFileHotReloadReplaceVar(`constructor`,t),this.writeFileNpmReplaceVar(`constructor`,n)}}viewsElements={};upgradeAttributes=``;storyArgTypes={};storyArgs={};addStoryField(e){if(e.propType==`Simple`||!this.hasStory||!this.classInfo?.storieContent)return;let t=``;if(e.propType==`Attribute`?t=`Attributes`:e.propType==`Property`?t=`Properties`:e.propType==`Watch`?t=`Watches`:e.propType==`Signal`&&(t=`Signals`),this.classInfo.storieContent.kind==`class`){let t=this.classInfo.storieContent.properties?.find(t=>t.name==e.name);t&&(t.modifiers?t.modifiers.includes(e.propType)||t.modifiers.push(e.propType):t.modifiers=[e.propType])}if(e.propType==`ViewElement`)return;let n=e.type;if(!n)return;let r=`text`,i=[],a=e.defaultValue??void 0,o,s=e=>{if(e.kind==`string`)r=`text`,o=`string`;else if(e.kind==`literal`){r=`select`;let t=e.value;(t.startsWith(`'`)||t.startsWith(`"`))&&(t=t.substring(1)),(t.endsWith(`'`)||t.endsWith(`"`))&&(t=t.substring(0,t.length-1)),i.push(t),o=`string`}else if(e.kind==`union`){r=`select`;for(let t of e.nested){let e=t.value;(e.startsWith(`'`)||e.startsWith(`"`))&&(e=e.substring(1)),(e.endsWith(`'`)||e.endsWith(`"`))&&(e=e.substring(0,e.length-1)),i.push(e)}o=`string`}else if(e.kind==`number`)r=`number`,o=`number`;else if(e.kind==`boolean`)r=`boolean`,o=`boolean`;else if(e.kind==`type`)if(e.value==`Date`||e.value==`DateTime`)r=`date`;else{let t=P.getBaseInfo(e.value,this.document.uri);t&&t instanceof en?s(t.type):r=`object`}else r=`object`};s(n),this.storyArgTypes[e.name]={control:r,table:{category:t}},o&&(this.storyArgTypes[e.name].type=o),i.length>0&&(this.storyArgTypes[e.name].options=i),e.defaultValueStory!==null&&(a=e.defaultValueStory),this.storyArgs[e.name]=a}writeFileFields(){let e=[],t=[],n=[],r=[],i=[],a=[],o=[],s={};for(let c in this.allFields){let l=this.allFields[c];for(let e of l.decorators)Yn.is(e)&&a.push(l);if(cn.includes(l.type.value)&&o.push(l),l.inParent){(l.propType==`Attribute`||l.propType==`Property`)&&this.createHtmlDoc(l,l.type);continue}if(this.addStoryField(l),l.propType==`Attribute`){t.push(l);continue}else if(l.propType==`Property`){for(let e of l.decorators){let t=In.is(e);t&&n.push({field:l,fctTxt:t.fctTxt})}continue}else if(l.propType==`Signal`){for(let e of l.decorators){let t=Jn.is(e);t&&r.push({field:l,fctTxt:t.fctTxt})}continue}else if(l.propType==`Watch`)for(let e of l.decorators){let t=Hn.is(e);t&&i.push({field:l,fctTxt:t.fctTxt})}else l.propType==`ViewElement`?(s[l.name]=l,!l.overrideNullable&&l.defaultValue===null&&!l.isNullable&&this.result.diagnostics.push(k(this.document,`You must add ! after the name to avoid undefined value`,l.nameStart,l.nameEnd,1025))):l.propType==`Simple`&&e.push(l)}if(this.viewsElements=s,this.writeFileFieldsSimpleVariable(e),this.writeFileFieldsAttribute(t),this.writeFileFieldsProperty(n),this.writeFileFieldsSignal(r),this.writeFileFieldsWatch(i),this.createInjectableHtmlDoc(a),this.createEventsHtmlDoc(o),this.upgradeAttributes.length>0&&(this.upgradeAttributes=`__upgradeAttributes() { super.__upgradeAttributes(); ${this.upgradeAttributes} }`),this.writeFileReplaceVar(`upgradeAttributes`,this.upgradeAttributes),this.writeFileHotReloadReplaceVar(`upgradeAttributes`,this.upgradeAttributes),this.writeFileNpmReplaceVar(`upgradeAttributes`,this.upgradeAttributes),this.htmlParsedResult){this.writeViewInfo(this.htmlParsedResult,!0);for(let e in s)this.createUnusedViewElement(s[e])}else this.writeFileReplaceVar(`templateAction`,``),this.writeFileHotReloadReplaceVar(`templateAction`,``),this.writeFileNpmReplaceVar(`templateAction`,``),this.writeFileReplaceVar(`variablesInViewDynamic`,``),this.writeFileHotReloadReplaceVar(`variablesInViewDynamic`,``),this.writeFileNpmReplaceVar(`variablesInViewDynamic`,``);this.writeViewGlobalVariables()}writeFileFieldsSimpleVariable(e){if(!this.htmlParsedResult){this.writeFileReplaceVar(`variables`,``),this.writeFileHotReloadReplaceVar(`variables`,``),this.writeFileNpmReplaceVar(`variables`,``);return}let t=``,n=``,r=``,i=[],a=``,o=``,s=``;if(this.classInfo)for(let e in this.classInfo.propertiesStatic){let t=this.classInfo.propertiesStatic[e];a+=t.compiledContent+x.EOL,o+=t.compiledContentHotReload+x.EOL,this.templateNpm&&(s+=t.compiledContentNpm+x.EOL)}for(let t of e)a+=t.compiledContent+x.EOL,o+=t.compiledContentHotReload+x.EOL,this.templateNpm&&(s+=t.compiledContentNpm+x.EOL),(t.isGet||t.isSet)&&(i.includes(t.name)||(i.push(t.name),this.upgradeAttributes+=`this.__correctGetter('`+t.name+`');`+x.EOL));let c=`class MyCompilationClassAventus {${a}}`,l=``;try{l=(0,p.transpile)(c,wn.getCompilerOptionsCompile())}catch{}let u=/\{([\s\S]*?)\}/gm.exec(l);if(u&&(t=u[1].trim()),this.writeFileReplaceVar(`variables`,t),yt.isRunning){let e=`class MyCompilationClassAventus {${o}}`,t=``;try{t=(0,p.transpile)(e,wn.getCompilerOptionsCompile())}catch{}let r=/\{([\s\S]*?)\}/gm.exec(t);r&&(n=r[1].trim()),this.writeFileHotReloadReplaceVar(`variables`,n)}if(this.templateNpm){let e=`class MyCompilationClassAventus {${s}}`,t=``;try{t=(0,p.transpile)(e,wn.getCompilerOptionsCompile())}catch{}let n=/\{([\s\S]*?)\}/gm.exec(t);n&&(r=n[1].trim()),this.writeFileNpmReplaceVar(`variables`,r)}}getGetterAndSetter(e,t,n){let r=``,i=e.name,a=n?`Prop`:`Attr`;return t.kind==`string`||t.kind==`literal`||t.kind==`union`?r+=`get '${i}'() { return this.getString${a}('${i}') }
|
|
315
315
|
set '${i}'(val) { this.setStringAttr('${i}', val) }${x.EOL}`:t.kind==`number`?r+=`get '${i}'() { return this.getNumber${a}('${i}') }
|
|
316
316
|
set '${i}'(val) { this.setNumberAttr('${i}', val) }${x.EOL}`:t.kind==`boolean`?(this.listBoolProperties.push(`"`+i+`"`),r+=`get '${i}'() { return this.getBool${a}('${i}') }
|
|
317
317
|
set '${i}'(val) { this.setBoolAttr('${i}', val) }${x.EOL}`):t.kind===`type`&&t.value==`Date`?r+=`get '${i}'() { return this.getDate${a}('${i}') }
|
|
@@ -326,7 +326,7 @@ import from `+i,n.newText=n.newText.replace(r[1],i)}}e.additionalTextEdits.push(
|
|
|
326
326
|
}
|
|
327
327
|
set '${e.name}'(val) {
|
|
328
328
|
this.__watch["${e.name}"] = val;
|
|
329
|
-
}`+x.EOL,n+=`w["${e.name}"] = ${e.defaultValue?.replace(/\\"/g,``)};`+x.EOL,this.upgradeAttributes+=`this.__correctGetter('`+e.name+`');`+x.EOL,yt.isRunning&&(r+=`w["${e.name}"] = ${e.defaultValueHotReload?.replace(/\\"/g,``)};`+x.EOL),this.templateNpm&&(i+=`w["${e.name}"] = ${e.defaultValueNpm?.replace(/\\"/g,``)};`+x.EOL)}n.length>0&&(n=`__defaultValuesWatch(w) { super.__defaultValuesWatch(w); ${n} }`),this.writeFileReplaceVar(`defaultValueWatch`,n),r.length>0&&(r=`__defaultValuesWatch(w) { super.__defaultValuesWatch(w); ${r} }`),this.writeFileHotReloadReplaceVar(`defaultValueWatch`,r),i.length>0&&(i=`__defaultValuesWatch(w) { super.__defaultValuesWatch(w); ${i} }`),this.writeFileNpmReplaceVar(`defaultValueWatch`,i),this.writeFileReplaceVar(`getterSetterWatch`,t),this.writeFileHotReloadReplaceVar(`getterSetterWatch`,t),this.writeFileNpmReplaceVar(`getterSetterWatch`,t)}writeViewGlobalVariables(){let e=``;if(this.defaultValueTxt.length>0&&(e=`__defaultValues() { super.__defaultValues(); ${this.defaultValueTxt} }`),this.writeFileReplaceVar(`defaultValue`,e),yt.isRunning){let e=``;this.defaultValueHotReloadTxt.length>0&&(e=`__defaultValues() { super.__defaultValues(); ${this.defaultValueHotReloadTxt} }`),this.writeFileHotReloadReplaceVar(`defaultValue`,e)}if(this.templateNpm){let e=``;this.defaultValueNpmTxt.length>0&&(e=`__defaultValues() { super.__defaultValues(); ${this.defaultValueNpmTxt} }`),this.writeFileNpmReplaceVar(`defaultValue`,e)}let t=``;this.listBoolProperties.length>0&&(t=`__listBoolProps() { return [${this.listBoolProperties.join(`,`)}].concat(super.__listBoolProps()).filter((v, i, a) => a.indexOf(v) === i); }`),this.writeFileReplaceVar(`listBool`,t),this.writeFileHotReloadReplaceVar(`listBool`,t),this.writeFileNpmReplaceVar(`listBool`,t)}writeFileMethods(){try{let e={},t=``,n=``,r=``,i=``;if(this.classInfo){let a=``,o=``,s=``,c=[...Object.values(this.classInfo.methods),...Object.values(this.classInfo.methodsStatic)];for(let t of c){if(!t.mustBeCompiled)continue;let n=t.name;if(a+=t.compiledContent+x.EOL,yt.isRunning&&(o+=t.compiledContentHotReload+x.EOL),this.templateNpm&&(s+=t.compiledContentNpm+x.EOL),!t.isStatic)for(let r of t.decorators){let a=qn.is(r);if(a){this.watchFunctions[n]=a.options;continue}let o=null,s=Bn.is(r);if(s)o=s;else{let e=Rn.is(r);if(e)o=e;else{let e=Vn.is(r);e&&(o=e)}}let c,l;o===null?(c=Wn.is(r))?i+=`this.__addActiveDefState(${c.managerName}, this.${t.name});`+x.EOL:(l=Kn.is(r))&&(i+=`this.__addInactiveDefState(${l.managerName}, this.${t.name});`+x.EOL):r.arguments.length>0&&(e[o.stateName]||(e[o.stateName]={}),e[o.stateName][o.managerName]||(e[o.stateName][o.managerName]={active:[],inactive:[],askChange:[]}),e[o.stateName][o.managerName][o.functionName].push(t.name))}}let l=(0,p.transpile)(`class MyCompilationClassAventus {${a}}`,wn.getCompilerOptionsCompile()),u=/\{(
|
|
329
|
+
}`+x.EOL,n+=`w["${e.name}"] = ${e.defaultValue?.replace(/\\"/g,``)};`+x.EOL,this.upgradeAttributes+=`this.__correctGetter('`+e.name+`');`+x.EOL,yt.isRunning&&(r+=`w["${e.name}"] = ${e.defaultValueHotReload?.replace(/\\"/g,``)};`+x.EOL),this.templateNpm&&(i+=`w["${e.name}"] = ${e.defaultValueNpm?.replace(/\\"/g,``)};`+x.EOL)}n.length>0&&(n=`__defaultValuesWatch(w) { super.__defaultValuesWatch(w); ${n} }`),this.writeFileReplaceVar(`defaultValueWatch`,n),r.length>0&&(r=`__defaultValuesWatch(w) { super.__defaultValuesWatch(w); ${r} }`),this.writeFileHotReloadReplaceVar(`defaultValueWatch`,r),i.length>0&&(i=`__defaultValuesWatch(w) { super.__defaultValuesWatch(w); ${i} }`),this.writeFileNpmReplaceVar(`defaultValueWatch`,i),this.writeFileReplaceVar(`getterSetterWatch`,t),this.writeFileHotReloadReplaceVar(`getterSetterWatch`,t),this.writeFileNpmReplaceVar(`getterSetterWatch`,t)}writeViewGlobalVariables(){let e=``;if(this.defaultValueTxt.length>0&&(e=`__defaultValues() { super.__defaultValues(); ${this.defaultValueTxt} }`),this.writeFileReplaceVar(`defaultValue`,e),yt.isRunning){let e=``;this.defaultValueHotReloadTxt.length>0&&(e=`__defaultValues() { super.__defaultValues(); ${this.defaultValueHotReloadTxt} }`),this.writeFileHotReloadReplaceVar(`defaultValue`,e)}if(this.templateNpm){let e=``;this.defaultValueNpmTxt.length>0&&(e=`__defaultValues() { super.__defaultValues(); ${this.defaultValueNpmTxt} }`),this.writeFileNpmReplaceVar(`defaultValue`,e)}let t=``;this.listBoolProperties.length>0&&(t=`__listBoolProps() { return [${this.listBoolProperties.join(`,`)}].concat(super.__listBoolProps()).filter((v, i, a) => a.indexOf(v) === i); }`),this.writeFileReplaceVar(`listBool`,t),this.writeFileHotReloadReplaceVar(`listBool`,t),this.writeFileNpmReplaceVar(`listBool`,t)}writeFileMethods(){try{let e={},t=``,n=``,r=``,i=``;if(this.classInfo){let a=``,o=``,s=``,c=[...Object.values(this.classInfo.methods),...Object.values(this.classInfo.methodsStatic)];for(let t of c){if(!t.mustBeCompiled)continue;let n=t.name;if(a+=t.compiledContent+x.EOL,yt.isRunning&&(o+=t.compiledContentHotReload+x.EOL),this.templateNpm&&(s+=t.compiledContentNpm+x.EOL),!t.isStatic)for(let r of t.decorators){let a=qn.is(r);if(a){this.watchFunctions[n]=a.options;continue}let o=null,s=Bn.is(r);if(s)o=s;else{let e=Rn.is(r);if(e)o=e;else{let e=Vn.is(r);e&&(o=e)}}let c,l;o===null?(c=Wn.is(r))?i+=`this.__addActiveDefState(${c.managerName}, this.${t.name});`+x.EOL:(l=Kn.is(r))&&(i+=`this.__addInactiveDefState(${l.managerName}, this.${t.name});`+x.EOL):r.arguments.length>0&&(e[o.stateName]||(e[o.stateName]={}),e[o.stateName][o.managerName]||(e[o.stateName][o.managerName]={active:[],inactive:[],askChange:[]}),e[o.stateName][o.managerName][o.functionName].push(t.name))}}let l=(0,p.transpile)(`class MyCompilationClassAventus {${a}}`,wn.getCompilerOptionsCompile()),u=/\{([\s\S]*?)\}/gm.exec(l);if(u&&(t=u[1].trim()),yt.isRunning){let e=(0,p.transpile)(`class MyCompilationClassAventus {${o}}`,wn.getCompilerOptionsCompile()),t=/\{([\s\S]*?)\}/gm.exec(e);t&&(n=t[1].trim())}if(this.templateNpm){let e=(0,p.transpile)(`class MyCompilationClassAventus {${s}}`,wn.getCompilerOptionsCompile()),t=/\{([\s\S]*?)\}/gm.exec(e);t&&(r=t[1].trim())}}this.writeFileReplaceVar(`methods`,t),this.writeFileHotReloadReplaceVar(`methods`,n),this.writeFileNpmReplaceVar(`methods`,r);let a=``;for(let t in e)for(let n in e[t]){let r=e[t][n];if(a+=`this.__createStatesList(${t}, ${n});`,r.active.length>0){let e=``;for(let t of r.active)e+=`that.`+t+`(state, slugs);`;a+=`this.__addActiveState(${t}, ${n}, (state, slugs) => { that.__inactiveDefaultState(${n}); ${e}})`+x.EOL}if(r.inactive.length>0){let e=``;for(let t of r.inactive)e+=`that.`+t+`(state, nextState, slugs);`;a+=`this.__addInactiveState(${t}, ${n}, (state, nextState, slugs) => { ${e}that.__activeDefaultState(nextState, ${n});})`+x.EOL}if(r.askChange.length>0){let e=``;for(let t of r.askChange)e+=`if(!await that.`+t+`(state, nextState, slugs)){return false;}`+x.EOL;a+=`this.__addAskChangeState(${t}, ${n}, async (state, nextState, slugs) => { ${e} return true;})`+x.EOL}}(a.length>0||i.length>0)&&(a=`__createStates() { super.__createStates(); let that = this; ${i} ${a} }`),this.writeFileReplaceVar(`states`,a),this.writeFileHotReloadReplaceVar(`states`,a),this.writeFileNpmReplaceVar(`states`,a)}catch{}}variablesInViewDynamic=``;writeViewInfo(e,t,n,r){let i={},a=``,o=``,s=e.elements,c=[];for(let e of s){let n=e.name;if(this.allFields[n]){let r=this.allFields[n];if(r.propType==`ViewElement`){e.useLive=!t;for(let t of r.decorators){let n=Ln.is(t);if(n&&n.useLive!==void 0){e.useLive=n.useLive;break}}if(e.useLive){let t=e.ids.map(e=>`[_id="${e}"]`).join(`|`);r.type.isArray||e.isArray?this.variablesInViewDynamic+=`get ${n} () { var list = Array.from(this.shadowRoot.querySelectorAll('${t}')); return list; }`+x.EOL:this.variablesInViewDynamic+=`get ${n} () { return this.shadowRoot.querySelector('${t}'); }`+x.EOL}else e.isArray?c.push({name:e.name,ids:e.ids,isArray:!0}):c.push({name:e.name,ids:e.ids})}else this.result.diagnostics.push(k(this.document,`You must add the decorator @ViewElement for `+n,r.nameStart,r.nameEnd,1011));delete this.viewsElements[n]}else this.createMissingViewElement(e)}c.length>0&&(i.elements=c);let l=e.content,u={};for(let e in l)u[e]={fct:`@_@${l[e].fct}@_@`},l[e].once&&(u[e].once=!0);Object.keys(u).length>0&&(i.content=u),e.injection.length>0&&(i.injection=e.injection);let d=e.bindings,f=[];for(let e of d){let t={id:e.id,injectionName:e.injectionName,eventNames:e.eventNames,inject:e.inject,extract:e.extract};if(e.once&&(t.once=e.once),e.eventNames.length==1&&e.tagName){let n=this.build.getWebComponentDefinition(e.tagName);if(n){let r=this.isCallback(n.class,e.eventNames[0]);r!=null&&(t.isCallback=!0,t.eventNames[0]=r)}else this.build.htmlLanguageService.getInternalTagUri(e.tagName)&&(this.result.needRebuild=!0)}f.push(t)}f.length>0&&(i.bindings=f);let p=[];for(let t of e.events)if(this.methodsName.includes(t.fct)){let e={eventName:t.eventName,id:t.id,fct:`@_@(e, c) => c.comp.${t.fct}(e)@_@`};if(t.tagName){let n=this.build.getWebComponentDefinition(t.tagName);if(n){let r=this.isCallback(n.class,t.eventName);r!=null&&(e.isCallback=!0,e.eventName=r,e.fct=`@_@(c, ...args) => c.comp.${t.fct}.apply(c.comp, ...args)@_@`)}else this.build.htmlLanguageService.getInternalTagUri(t.tagName)&&(this.result.needRebuild=!0)}p.push(e)}else t.position&&this.createMissingMethod(t.fct,t.position.start,t.position.end);p.length>0&&(i.events=p);let m=[],h=[Un[`@dblpress`],Un[`@drag`],Un[`@drag-end`],Un[`@drag-start`],Un[`@longpress`],Un[`@press`],Un[`@press-start`],Un[`@press-stop`]],g=[Un[`@dblpress-delay`],Un[`@longpress-delay`]];for(let t of e.pressEvents){let e={id:t.id};for(let n in t){let r=t[n];r instanceof Object&&(h.includes(n)?this.methodsName.includes(r.value)?e[n]=`@_@(e, pressInstance, c) => { c.comp.${r.value}(e, pressInstance); }@_@`:this.createMissingMethod(r.value,r.start,r.end):g.includes(n)&&(e[n]=`@_@${r.value}@_@`))}m.push(e)}if(m.length>0&&(i.pressEvents=m),e.contextEdits.length>0&&(i.contextEdits=e.contextEdits),Object.keys(i).length>0||n||r){let e=JSON.stringify(i,null,2).replace(/"@_@(.*?)@_@"/g,`$1`).replace(/\\"/g,`"`);if(t)a=`this.__getStatic().__template.setActions(${e});`+x.EOL;else if(n){a=`const templ${n.templateId} = new Aventus.Template(this);`+x.EOL,a+=`templ${n.templateId}.setTemplate(\`${n.template}\`);`+x.EOL,Object.keys(i).length>0&&(a+=`templ${n.templateId}.setActions(${e});`+x.EOL);let t=n.parentId===void 0?`this.__getStatic().__template`:`templ${n.parentId}`;a+=`${t}.addLoop({
|
|
330
330
|
anchorId: '${n.anchorId}',
|
|
331
331
|
template: templ${n.templateId},
|
|
332
332
|
`,n.simple?(a+=`simple:{data: "${n.simple.data.replace(/[\!|\?]/g,``)}"`,n.simple.index&&(a+=`,index:"${n.simple.index.replace(/[\!|\?]/g,``)}"`),n.simple.item&&(a+=`,item:"${n.simple.item.replace(/[\!|\?]/g,``)}"`),a+=`}`+x.EOL):a+=`func: ${n.func}`+x.EOL,a+=`});`+x.EOL}else r&&(a=`const templ${r.templateId} = new Aventus.Template(this);`+x.EOL,a+=`templ${r.templateId}.setTemplate(\`${r.template}\`);`+x.EOL,Object.keys(i).length>0&&(a+=`templ${r.templateId}.setActions(${e});`+x.EOL))}for(let t of e.loops)a+=this.writeViewInfo(t.actions,!1,t);for(let t of e.ifs){let e=``;for(let n of t.parts){a+=this.writeViewInfo(n.templateAction,!1,void 0,n);let t=n.once?`once: true,`:``;e+=`{${t}
|
|
@@ -388,7 +388,7 @@ this.clearWatchHistory = () => {
|
|
|
388
388
|
`;let n=e.keys.map(e=>`"${e.replace(/"/g,`\\"`)}": string`).join(`,\r
|
|
389
389
|
`);c+=`\ntype ${this.componentClassName}__Generated = {
|
|
390
390
|
${n}
|
|
391
|
-
}`})(n),a+=t.slice(this.componentEnd-r),a+=c,this.file instanceof j&&this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,i,a))}this.refreshFileParsed();let s=(0,f.join)(this.file.folderPath,`compiled.html`),c=(0,f.join)(this.file.folderPath,`compiled.ts`);this.writeHtml?(0,u.writeFileSync)(s,this.HTMLFile?.fileParsed?.compiledTxt??``):(0,u.existsSync)(s)&&(0,u.unlinkSync)(s),this.writeTs?(0,u.writeFileSync)(c,a):(0,u.existsSync)(c)&&(0,u.unlinkSync)(c)}}else this.file instanceof j&&this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,i,this.file.contentUser)),this.refreshFileParsed()}async onValidate(){return await this.runWebCompiler(),this.diagnostics=this.compilationResult?.diagnostics||[],this.transformDiagnosticForView(),this.HTMLFile?.validate(),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}transformDiagnosticForView(){let e=this.HTMLFile;if(e){let t=[],n=[],r=[];for(let i of this.diagnostics){let a=this.file.documentInternal.offsetAt(i.range.start),o=this.file.documentInternal.offsetAt(i.range.end),s=!1,c=a>=this.file.contentUser.length;for(let t=0;t<this.viewMethodsInfo.length;t++){let c=this.viewMethodsInfo[t].fullStart,l=this.viewMethodsInfo[t].end;if(a>c&&o<l){i.source=w.HTML;let c=this.viewMethodsInfo[t].fct,l=this.viewMethodsInfo[t].offsetAfter,u=this.viewMethodsInfo[t].offsetBefore;if(r.indexOf(i.range)==-1){let s=this.viewMethodsInfo[t].transform(a,0);r.push(i.range);let d=a-this.viewMethodsInfo[t].start-s,f=o-this.viewMethodsInfo[t].start-s;for(let t=0;t<c.positions.length;t++){let r=c.positions[t].start,a=c.positions[t].end,o=i;t>0&&(o={...i});let s=r+u+d,p=r+u+f;s<r||p>a-l?o.range={start:e.file.documentInternal.positionAt(r),end:e.file.documentInternal.positionAt(a)}:o.range={start:e.file.documentInternal.positionAt(s),end:e.file.documentInternal.positionAt(p)},t>0&&n.push(o)}}s=!0;break}}s?n.push(i):c||t.push(i)}this.diagnostics=t,this.htmlDiagnostics=n}else this.htmlDiagnostics=[]}quickParse(){let e=Zn.parse(this.file.documentUser.getText(),this.build);this._componentEnd=e.end,this._fullname=e.fullname,this._componentClassName=e.className,this.writeHtml=e.writeHtml,this.writeTs=e.writeTs,e.tagName&&this.build.htmlLanguageService.addInternalTagUri(e.tagName,this.file.uri,this._fullname);let t=``;for(let n=0;n<e.whiteSpaceBefore+4;n++)t+=` `;this._space=t}async onContentChange(){this.quickParse(),await this.runWebCompiler()}async onSave(){await this.runWebCompiler(),this.compilationResult?this.setCompileResult(this.compilationResult.result):this.setCompileResult([]),this.compilationResult?.writeCompiled?(0,u.writeFileSync)(this.file.folderPath+`/compiled.js`,ze(this.compilationResult.debug,this.build.project.getConfig())):(0,u.existsSync)(this.file.folderPath+`/compiled.js`)&&(0,u.unlinkSync)(this.file.folderPath+`/compiled.js`),this.canUpdateComponent||=!0}emitToHtttpServer(e){if(!this.canUpdateComponent)return;let t={};for(let n of e)t[n.name]=n.src;let n=!1,r=``,i=``,a;if(this.compilationResult)for(let e of this.compileResult)e.classScript!=``&&t[e.classScript]&&t[e.classScript]!=e.compiled&&(e.classScript==this.compilationResult.componentName?(n=!0,r=e.hotReload,i=e.classScript,a=this.fileParsed?.classes[i]):this.build.reloadPage=!0);if(!this.build.reloadPage&&n&&a){let e=this.buildNamespace;a.namespace&&(e+=a.namespace),e.length>0&&!e.endsWith(`.`)&&(e+=`.`),yt.getInstance().updateComponent(r,e+i,[])}}async onDelete(){await super.onDelete(),this.build.scssLanguageService.removeInternalDefinition(this.file.uri),this.build.htmlLanguageService.removeInternalDefinition(this.file.uri),this.build.htmlLanguageService.removeInternalTagUri(this.file.uri)}async doViewCompletion(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let r of e.fct.positions)if(n>=r.start+e.offsetBefore&&n<=r.end){let i=n-r.start-e.offsetAfter,a=e.start+i;a=e.transform(a,a);let o=this.file.documentInternal.positionAt(a),s=await this.onCompletion(this.file,o),c=[],l=[];for(let n of s.items)if(!(this.viewMethodName&&n.label.startsWith(this.viewMethodName))){if(n.data&&n.data.uri&&(n.data.languageId=w.HTML,n.data.uri=t.file.uri),n.textEdit){let i=n.textEdit;if(i.range&&l.indexOf(i.range)==-1){l.push(i.range),e.fct;let n=this.file.documentInternal.offsetAt(i.range.start),a=this.file.documentInternal.offsetAt(i.range.end),o=e.transform(n,0),s=n-e.start-o,c=a-e.start-o;i.range.start=t.file.documentInternal.positionAt(r.start+e.offsetBefore+s),i.range.end=t.file.documentInternal.positionAt(r.start+e.offsetBefore+c)}}if(n.additionalTextEdits){for(let i of n.additionalTextEdits)if(i.range&&l.indexOf(i.range)==-1){l.push(i.range),e.fct;let n=this.file.documentInternal.offsetAt(i.range.start),a=this.file.documentInternal.offsetAt(i.range.end),o=e.transform(n,0),s=n-e.start-o,c=a-e.start-o;i.range.start=t.file.documentInternal.positionAt(r.start+e.offsetBefore+s),i.range.end=t.file.documentInternal.positionAt(r.start+e.offsetBefore+c)}}c.push(n)}return s.items=c,s}return null}async onCompletion(e,t){return await this.runWebCompiler(),this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}async doHover(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let r of e.fct.positions)if(n>=r.start+e.offsetBefore&&n<=r.end){let i=n-r.start-e.offsetAfter,a=e.start+i;a=e.transform(a,a);let o=this.file.documentInternal.positionAt(a),s=await this.onHover(this.file,o);if(s&&s.range){let n=this.file.documentInternal.offsetAt(s.range.start),i=this.file.documentInternal.offsetAt(s.range.end),a=e.transform(n,0),o=n-e.start-a,c=i-e.start-a;s.range.start=t.file.documentInternal.positionAt(r.start+e.offsetBefore+o),s.range.end=t.file.documentInternal.positionAt(r.start+e.offsetBefore+c)}return s}return null}onHover(e,t){return this.tsLanguageService.doHover(e,t)}async doDefinition(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let t of e.fct.positions)if(n>=t.start+e.offsetBefore&&n<=t.end){let r=n-t.start-e.offsetAfter,i=e.start+r;i=e.transform(r,i);let a=this.file.documentInternal.positionAt(i);return await this.onDefinition(this.file,a)}return null}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async doFormatting(e,t){return await this.runWebCompiler(),this.HTMLFile?(await this.getFormatting(t,!1)).html:null}async onFormatting(e,t,n){return(await this.getFormatting(n,!0)).js}async getFormatting(e,t){let n={js:[],html:[]},r={start:{character:0,line:0},end:this.file.documentInternal.positionAt(this.file.contentInternal.length)},i=await this.tsLanguageService.format(this.file,r,e,t),a=this.HTMLFile,o=[];for(let e of i){let t=this.file.documentInternal.offsetAt(e.range.start),r=this.file.documentInternal.offsetAt(e.range.end),i=!1,s=t>=this.file.contentUser.length;if(a)for(let a=0;a<this.viewMethodsInfo.length;a++){let s=this.viewMethodsInfo[a].start,c=this.viewMethodsInfo[a].end,l=this.viewMethodsInfo[a].transform(t,0);if(t>=s+l&&r<c){if(t==s&&!/\S/.test(e.newText)){i=!0;break}let c=this.viewMethodsInfo[a].fct,u=this.viewMethodsInfo[a].offsetBefore;if(o.indexOf(e.range)==-1){o.push(e.range);let i=t-this.viewMethodsInfo[a].start-l,s=r-this.viewMethodsInfo[a].start-l;for(let t=0;t<c.positions.length;t++){let r=c.positions[t].start+u+i,o=c.positions[t].start+u+s;n.html.push({edit:{newText:e.newText,range:{start:r,end:o}},start:c.positions[t].start,end:c.positions[t].end,kind:this.viewMethodsInfo[a].kind})}}i=!0;break}else if(t>=this.viewMethodsInfo[a].fullStart&&r<=c){i=!0;break}}!i&&!s&&n.js.push(e)}return n}async onCodeAction(e,t){let n=await this.tsLanguageService.doCodeAction(e,t);return this.addCustomCodeAction(n),n}async doReferences(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let t of e.fct.positions)if(n>=t.start+e.offsetBefore&&n<=t.end){let r=n-t.start-e.offsetAfter,i=e.start+r;i=e.transform(i,i);let a=this.file.documentInternal.positionAt(i);return await this.onReferences(this.file,a)}return null}async onReferences(e,t){let n=[],r=await this.tsLanguageService.onReferences(e,t)||[];if(this._compilationResult?.componentName&&this.fileParsed?.classes[this._compilationResult.componentName]){let e=this.file.documentInternal.offsetAt(t),r=this.fileParsed?.classes[this._compilationResult.componentName];if(e>=r.nameStart&&e<=r.nameEnd)for(let[e,t]of this.reverseViewClassInfoDependencies)for(let r of t)n.push({uri:e.file.uri,range:{start:e.file.documentInternal.positionAt(r.start),end:e.file.documentInternal.positionAt(r.end)}})}let i=[...r,...n];return i=this.transformRefrencesToView(i),i}transformRefrencesToView(t){let n=[];for(let r of t){if(r.uri.endsWith(T.ComponentLogic)){let t=this.build.tsFiles[r.uri];if(!t)continue;if(t instanceof e){let e=t.HTMLFile;if(e){let i=[],a=t._file.documentInternal.offsetAt(r.range.start),o=t._file.documentInternal.offsetAt(r.range.end);for(let t=0;t<this.viewMethodsInfo.length;t++){let s=this.viewMethodsInfo[t].fullStart,c=this.viewMethodsInfo[t].end;if(a>s&&o<c){r.uri=e.file.uri;let s=this.viewMethodsInfo[t].fct,c=this.viewMethodsInfo[t].offsetBefore;if(this.viewMethodsInfo[t].offsetAfter,i.indexOf(r.range)==-1){let l=this.viewMethodsInfo[t].transform(a,0);i.push(r.range);let u=a-this.viewMethodsInfo[t].start-l,d=o-this.viewMethodsInfo[t].start-l;for(let t=0;t<s.positions.length;t++){let i=s.positions[t].start+c+u,a=s.positions[t].start+c+d,o=r;t>0&&(o={...o}),o.range={start:e.file.documentInternal.positionAt(i),end:e.file.documentInternal.positionAt(a)},t>0&&n.push(o)}}break}}}}}n.push(r)}return n}async onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async doRename(e,t){let n=this.HTMLFile;if(!n)return null;let r=n.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let n of e.fct.positions)if(r>=n.start+e.offsetBefore&&r<=n.end){let i=r-n.start-e.offsetAfter,a=e.start+i;a=e.transform(a,a);let o=this.file.documentInternal.positionAt(a);return await this.onRename(this.file,o,t)}return null}async onRename(e,t,n){let r=await this.tsLanguageService.onRename(e,t,n);return r&&this.transformRenameToView(r),r}transformRenameToView(t){if(t.changes){let n={};for(let r in t.changes)if(r.endsWith(T.ComponentLogic)){let i=t.changes[r],a=this.build.tsFiles[r];if(!a)continue;if(a instanceof e){let e=a.HTMLFile;if(e)for(let t=0;t<i.length;t++){let r=i[t],o=a._file.documentInternal.offsetAt(r.range.start),s=a._file.documentInternal.offsetAt(r.range.end);for(let a=0;a<this.viewMethodsInfo.length;a++){let c=this.viewMethodsInfo[a].fullStart,l=this.viewMethodsInfo[a].end;if(o>c&&s<l){n[e.file.uri]||(n[e.file.uri]=[]);let c=this.viewMethodsInfo[a].fct,l=this.viewMethodsInfo[a].transform(o,0),u=o-this.viewMethodsInfo[a].start-l,d=s-this.viewMethodsInfo[a].start-l;for(let t of c.positions){let i=t.start+this.viewMethodsInfo[a].offsetBefore+u,o=t.start+this.viewMethodsInfo[a].offsetBefore+d;n[e.file.uri].push({newText:r.newText,range:{start:e.file.documentInternal.positionAt(i),end:e.file.documentInternal.positionAt(o)}})}i.splice(t,1),t--;break}}}}}for(let e in n)if(!t.changes[e])t.changes[e]=n[e];else for(let r of n[e])t.changes[e].push(r)}}addCustomCodeAction(e){let t=!1,n=!1;for(let r of this.diagnostics)if(r.code==1011&&!t)t=!0,e.push({title:`Import missing view elements`,command:{command:`aventus.wc.import.viewElement`,title:`Import missing view elements`}});else if(r.code==1014){let t=r.message.match(/#[a-zA-Z0-9_]+/g);if(t){let n=t[0].replace(`#`,``);e.push({title:`Import missing property `+n,command:{command:`aventus.wc.create.property`,title:`Create property`,arguments:[`prefill:`+n]}})}}else if(r.code==1019&&!n)n=!0,e.push({title:`Import missing methods`,command:{command:`aventus.wc.import.viewMethod`,title:`Import missing methods`}});else if(r.code==1012&&r.data){let t=r.data;e.push({title:`Remove element`,edit:{changes:{[this.file.uri]:[{newText:``,range:{start:this.file.documentInternal.positionAt(t.start),end:this.file.documentInternal.positionAt(t.end)}}]}}})}}getMissingVariablesInfo(){let e=``,t=-1;if(this.compilationResult){t=this.compilationResult?.missingViewElements.position;for(let t in this.compilationResult.missingViewElements.elements)e+=`@ViewElement()`+x.EOL+`protected `+t+`!: `+this.compilationResult.missingViewElements.elements[t]+`;`+x.EOL}return{start:t,text:e}}getMissingMethodsInfo(){let e=``,t=-1;if(this.compilationResult){t=this.compilationResult?.missingMethods.position;for(let t of this.compilationResult.missingMethods.elements)e+=`/**${x.EOL} * ${x.EOL} */${x.EOL}protected ${t}(){${x.EOL} throw new Error("Method not implemented.");${x.EOL} }${x.EOL} `}return e!=``&&(e=x.EOL+e),{start:t,text:e}}getComponentName(){return this.compilationResult?.componentName||``}viewClassInfoDependencies=[];reverseViewClassInfoDependencies=new Map;resetViewClassInfoDep(){let t=this.HTMLFile;if(t){for(let n of this.viewClassInfoDependencies)n instanceof e&&n.reverseViewClassInfoDependencies.delete(t);this.viewClassInfoDependencies=[]}}addViewClassInfoDep(t,n,r){let i=this.HTMLFile;i&&(this.viewClassInfoDependencies.includes(t)||this.viewClassInfoDependencies.push(t),t instanceof e&&(t.reverseViewClassInfoDependencies.has(i)||t.reverseViewClassInfoDependencies.set(i,[]),t.reverseViewClassInfoDependencies.get(i)?.push({start:n,end:r})))}},Qn=class e{tagName=``;children=[];attributes={};hasClose=!1;selfClosing=!1;id=``;start=0;end=0;parent=null;parentTemplateId;openTagStart=0;openTagEnd=0;alias=null;aliasMultiple=void 0;pressEvent=null;eventsPerso=[];injections=[];bindings=[];changes={};variableNames=[];parser;_idBase;get idBase(){return this._idBase||=this.componentClassName+`_`,this._idBase}get componentClassName(){return this.parser.htmlFile.tsFile?.componentClassName.toLowerCase()??``}get isLoop(){return this.tagName==rr.tagName}get isIf(){return this.tagName==ir.tagName}get isContextEditing(){return this.tagName==ar.tagName}loopInfo;ifInfo;contextEdit;constructor(e,t,n,r){if(this.parser=e,this.tagName=t,this.start=n,this.openTagStart=n,this.end=r,this.isLoop){this.createId();return}this.isIf||this.isContextEditing||(I.addInterestPoint({name:t,start:n,end:r,type:`tag`}),$n.includes(t)&&(this.selfClosing=!0))}createId(){return this.id||(this.id=this.idBase+I.idElement,I.idElement++),this.id}addAttribute(e){if(e.name==`@for`){I.addError(e.nameStart,e.nameEnd,`Deprecated : use for directly inside template`);return}this.attributes[e.name]?I.addError(e.nameStart,e.nameEnd,`Duplicate attribute `+e.name):this.attributes[e.name]=e}addChild(e){this.children.push(e),e.parent=this}addContent(e){this.children.push(e)}addChanges(e,t,n){let r=this.createId()+`°`+e;this.changes[r]={fct:t,once:n}}validateAllProps(e){if(this.openTagEnd=e,this.alias){let e=this.alias.endsWith(`[]`);e&&(this.alias=this.alias.replace(`[]`,``)),e&&(this.aliasMultiple=e)}if(this.isLoop){this.parentTemplateId=I.getParentId();let e=I.addLoopStack(Number(this.attributes.id.value));e&&(this.loopInfo=e)}else if(this.isIf){this.parentTemplateId=I.getParentId();let e=Number(this.attributes.id.value),t=I.addIfStack(e);t&&(this.ifInfo=t,e==t.idsTemplate[0]&&(t._id=this.createId()))}else if(this.isContextEditing){this.parentTemplateId=I.getParentId();let e=Number(this.attributes.id.value),t=I.getContextEditing(e);if(t&&(this.contextEdit=t,this.parent))for(let e of t.variableNames)this.parent.variableNames.includes(e)||this.parent.variableNames.push(e)}I.addTagInfoStack(this)}afterClose(e,t){this.hasClose=!0,this.selfClosing||I.addInterestPoint({name:this.tagName,start:e,end:t,type:`tag`}),this.checkStyle(I.getRules(),e=>I.addStyleLink(e)),I.removeStack(),(this.isLoop||this.isIf)&&I.removeStack()}checkStyle(e,t){for(let[n,r]of e)n(this)&&t([{start:this.openTagStart,end:this.openTagEnd},r])}_render(){let e=[];for(let t in this.attributes){let n=this.attributes[t];n.mustBeAdded&&(n.value==null?e.push(n.name):e.push(n.name+`="`+n.value+`"`))}this.id&&e.push(`_id="`+this.id+`"`);let t=``;return e.length>0&&(t=` `+e.join(` `)),this.selfClosing?`<${this.tagName}${t} />`:`<${this.tagName}${t}>${this.children.map(e=>e.render()).join(``)}</${this.tagName}>`}render(){return this.isContextEditing?``:this.isLoop?`<template _id="`+this.id+`"></template>`:this.isIf?this.id?`<template _id="`+this.id+`"></template>`:``:this._render()}replaceId(t){t.endsWith(`_`)||(t+=`_`),this.id=this.id.replace(this.idBase,t);let n={};for(let e in this.changes){let r=e.replace(this.idBase,t);n[r]=this.changes[e]}this.changes=n,this.ifInfo&&(this.ifInfo._id=this.ifInfo._id.replace(this.idBase,t)),this._idBase=t;for(let n of this.children)n instanceof e&&n.replaceId(t)}getTemplateInfo(t){let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},r=this.id,i=e=>{if(this.alias){let t=this.aliasMultiple?2:1;e.elements.push({name:this.alias,ids:[r],tags:{[this.tagName]:t},useLive:!1,isArray:t>1,positions:[{start:this.attributes[`@element`].valueStart,end:this.attributes[`@element`].valueEnd}]})}for(let t in this.changes)e.content[t]=this.changes[t];for(let t of this.injections){let n={id:r,injectionName:t.attr,inject:`@_@${t.injectTxt}@_@`};t.computedOnce&&(n.once=!0),e.injection.push(n)}for(let t of this.bindings){let n=[];n=t.event?[t.event]:[`input`,`textarea`].includes(this.tagName)?[`change`,`input`]:[`change`];let i={id:r,eventNames:n,injectionName:t.valueName,tagName:this.tagName,inject:`@_@${t.injectTxt}@_@`,extract:`@_@${t.extractTxt}@_@`};t.computedOnce&&(i.once=!0),e.bindings.push(i)}for(let t of this.eventsPerso)e.events.push({eventName:t.event,id:r,fct:t.fct,tagName:this.tagName,position:{start:t.start,end:t.end}});if(this.pressEvent&&e.pressEvents.push({...this.pressEvent,id:r}),this.contextEdit){let t={fct:this.contextEdit.fctJs};this.contextEdit.computedOnce&&(t.once=!0),e.contextEdits.push(t)}};if(this.loopInfo){let r={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},i=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);I.mergeTemplateResult(r,e)}i+=n.render()}let a={templateId:this.loopInfo.idTemplate||0,anchorId:this.id,template:i,actions:r,parentId:this.parentTemplateId};this.loopInfo.isSimple?a.simple=this.loopInfo.simple:a.func=this.loopInfo.complex.fct,n.loops.push(a)}else if(this.isIf&&this.ifInfo){let r=Number(this.attributes.id.value),i={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},a=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);I.mergeTemplateResult(i,e)}a+=n.render()}if(this.ifInfo.registerPart({template:a,templateId:r,templateAction:i,condition:``}),r==this.ifInfo.idsTemplate[this.ifInfo.idsTemplate.length-1]){let e={anchorId:this.ifInfo._id,parts:this.ifInfo.parts,parentId:this.parentTemplateId};n.ifs.push(e)}}else{i(n);for(let r of this.children)if(r instanceof e){let e=r.getTemplateInfo(t);I.mergeTemplateResult(n,e)}}return n}};const $n=[`area`,`base`,`br`,`col`,`embed`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`],er=[`_id`];var tr=class{name=``;value=null;nameStart=0;nameEnd=0;valueStart=0;valueEnd=0;tag;mustBeAdded=!0;constructor(e,t,n,r){this.name=e,this.nameStart=I.fromCompiledToRaw(t),this.nameEnd=I.fromCompiledToRaw(n),this.tag=r,this.manageSpecialAttribute()}manageSpecialAttribute(){this.name.startsWith(`@`)||this.name.startsWith(`:`)?(this.tag.createId(),this.mustBeAdded=!1):er.includes(this.name)&&(I.addError(this.nameStart,this.nameEnd,`The attribute `+this.name+` is used by Aventus internally`),this.mustBeAdded=!1)}setValue(e,t,n){if(e=e.replace(/"/g,``),this.value=e,this.valueStart=I.fromCompiledToRaw(t),this.valueEnd=I.fromCompiledToRaw(n),this.name!=`@for`)if(this.name===`@element`)this.tag.alias=e,I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`property`});else if(this.name.startsWith(`@bind`)||this.name.startsWith(`$`)){let r=new sr(this.name,e,t,n);this.tag.bindings.push(r),I.addBinding(r)}else if(this.name.startsWith(`:`)){let r=new or(this.name.slice(1),e,t,n);this.tag.injections.push(r),I.addInjection(r)}else if(Un.hasOwnProperty(this.name))this.tag.pressEvent||(this.tag.pressEvent={}),this.tag.pressEvent[Un[this.name]]={value:e,start:this.valueStart,end:this.valueEnd},I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else if(this.name.startsWith(`@`))this.tag.eventsPerso.push({event:this.name.slice(1),fct:e,start:this.valueStart,end:this.valueEnd}),I.addInterestPoint({name:this.name.slice(1),start:this.nameStart,end:this.nameEnd,type:`event`}),I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else{let t=cr(e,this.valueStart);t.changes.length>0&&(this.tag.addChanges(this.name,t.txt,t.once),this.mustBeAdded=!1)}}},nr=class{content=``;start=0;end=0;tag;mustBeAdded=!0;constructor(e,t,n,r,i=!0){this.content=e,this.start=I.fromCompiledToRaw(t),this.end=I.fromCompiledToRaw(n),this.tag=r,i&&this.manageVariables()}manageVariables(){let e=this.content,t=cr(e,this.start);t.changes.length>0&&(this.tag.addChanges(`@HTML`,t.txt,t.once),this.mustBeAdded=!1);for(let e of t.variables)this.tag.variableNames.includes(e)||this.tag.variableNames.push(e)}render(){return this.mustBeAdded?this.content:``}},rr=class e{static tagName=`l`;idTemplate=0;isSimple=!1;transformations=[];start=0;startBlock=0;end=0;loopTxt=``;loopName=``;isValid=!0;typeToLoad=[];simple={data:``};complex={init:[],condition:``,transform:[],apply:[],loopName:``,fct:``};get variableNames(){return this.typeToLoad.map(e=>e.txt)}variables=[];sliceText;constructor(e,t){this.sliceText=t,this.idTemplate=I.createIdTemplate(),this.variables=I.getVariables(),e.kind==p.SyntaxKind.ForOfStatement||e.kind==p.SyntaxKind.ForInStatement?(this.isSimple=!0,this.loadForInOf(e)):this.loadFor(e),this.loopName=I.getCustomFctName()??``}loadForInOf(t){let n=0;(0,p.forEachChild)(t,r=>{if(n==0){let e=r.getChildAt(1),n=e.getStart(),i=e.getEnd(),a=this.sliceText(n,i);t.kind==p.SyntaxKind.ForInStatement?this.simple.index=a:this.simple.item=a,this.typeToLoad.push({txt:a,start:n,end:i})}else if(n==1)this.simple.data=this.sliceText(r.getStart(),r.getEnd());else if(n==2){let n=t.getStart(),i=r.getStart()+1;this.loopTxt=this.sliceText(n,i)+` }`;let a=`<`+e.tagName+` id="`+this.idTemplate+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o}),this.start=n,this.startBlock=i,this.end=s}n++})}loadFor(t){let n=[],r=[],i=``,a=[],o=0,s=``;if((0,p.forEachChild)(t,c=>{if(o==0&&c.kind==p.SyntaxKind.VariableDeclarationList)(0,p.forEachChild)(c,e=>{let t=e.getChildAt(0),i=t.getStart(),a=t.getEnd(),o=this.sliceText(i,a);n.push(`let `+e.getText()),r.push(e.getChildAt(0).getText()),this.typeToLoad.push({txt:o,start:i,end:a})});else if(o==1&&c.kind==p.SyntaxKind.BinaryExpression)i=c.getText();else if(o==2){let e=t=>{t.kind==p.SyntaxKind.BinaryExpression&&t.getChildAt(1).getText()==`,`?(e(t.getChildAt(0)),e(t.getChildAt(2))):a.push(t.getText())};e(c)}else if(o==3&&c.kind==p.SyntaxKind.Block){let n=t.getStart(),r=c.getStart()+1;s=this.sliceText(n,r)+` }`,this.loopTxt=s;let i=`<`+e.tagName+` id="`+this.idTemplate+`">`,a=`</`+e.tagName+`>`;this.transformations.push({start:n,end:r,newText:i});let o=c.getEnd();this.transformations.push({start:o-1,end:o,newText:a}),this.start=n,this.startBlock=r,this.end=o}o++}),this.transformations.length==0&&(this.isValid=!1),!this.checkIsSimple(n,i,a)){let e=I.getCustomFctName(1)??``;this.complex={init:n,condition:i,transform:a,apply:r,loopName:e,fct:`(c) => c.comp.${e}`}}}recalculateVariables(){if(this.variables=lr(this.loopTxt,I.getVariables()),!this.isSimple){let e=this.variables.map(e=>`c.data.`+e).join(`,`);this.complex.fct+=`(${e})`}}checkIsSimple(e,t,n){if(e.length!=1)return!1;let r=e[0].split(`=`);if(r.length!=2)return!1;let i=r[0].replace(`let `,``).trim();if(r[1].trim()!=`0`)return!1;let a=RegExp(`\\s*`+i+`\\s*<\\s*([a-zA-Z0-9\\._\\[\\]-]+)\\.length`).exec(t);if(!a)return!1;let o=a[1];return n.length!=1||!RegExp(`\\s*`+i+`\\+\\+\\s*`).exec(n[0])?!1:(this.isSimple=!0,this.simple={data:o,index:i},!0)}},ir=class e{static tagName=`if`;statements=[];idsTemplate=[];defaultVariables=[];transformations=[];end=0;_id=``;parts=[];isValid=!0;conditions=[];sliceText;constructor(e,t){this.sliceText=t,this.defaultVariables=I.getVariables(),this.loadIf(e)}loadIf(t){let n=[],r=()=>{let e=I.createIdTemplate();return this.idsTemplate.push(e),e},i=(t,n,r)=>{let i=r.getStart()+1,a=`<`+e.tagName+` id="`+t+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o})},a=(e,t=0,o)=>{let s=0;o===void 0&&(o=e.getStart());let c=o,l;for(let t of e.getChildren())t.kind==p.SyntaxKind.ElseKeyword&&(l=t.getStart());let u=r();(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Block){if(s++,s==2){if(l==null)throw`impossible`;i(r(),l,e)}else i(u,c,e);n.push(e)}else if(e.kind==p.SyntaxKind.IfStatement){if(l==null)throw`impossible`;a(e,t+1,l)}else if(p.SyntaxKind[e.kind].includes(`Expression`)){let n=I.getCustomFctName(this.conditions.length)??``,r=this.sliceText(e.getStart(),e.getEnd());this.conditions.push({fctName:n,txt:r,fctTxt:`(c) => c.comp.${n}`,start:e.getStart(),end:e.getEnd(),offsetAfter:0,offsetBefore:0,idTemplate:u,type:t==0?`if`:`elif`,variables:[],computedOnce:ur(r)})}}),s==0&&(this.isValid=!1)};a(t)}registerPart(e){this.conditions.length>this.parts.length?(e.condition=this.conditions[this.parts.length].fctTxt,e.once=this.conditions[this.parts.length].computedOnce):(e.condition=`(c) => true`,e.once=!0),this.parts.push(e)}recalculateVariables(e){let t=I.getVariables();for(let n of this.conditions)if(n.idTemplate==e){let e=lr(n.txt,t),r=e.map(e=>`c.data.`+e).join(`,`);n.fctTxt+=`(${r})`,n.variables=e}}},ar=class e{static tagName=`c`;sliceText;variables=[];transformations=[];id;fctTs=``;fctJs=``;editName;start=0;end=0;mapping=[``,``];computedOnce=!1;typeToLoad=[];get variableNames(){return this.typeToLoad.map(e=>e.txt)}constructor(e,t){this.sliceText=t,this.editName=I.getCustomFctName()??``,this.id=I.createIdTemplate(),this.loadContextEditing(e)}loadContextEditing(t){this.start=t.getStart(),this.end=t.getEnd(),this.transformations.push({start:t.getStart(),end:t.getEnd(),newText:`<`+e.tagName+` id="`+this.id+`"></`+e.tagName+`>`}),(0,p.forEachChild)(t,e=>{if(e.kind==p.SyntaxKind.CallExpression){let t=e,n=`{ `,r=0;for(let e of t.arguments)n+=e.getText(),r==0&&(this.typeToLoad.push({txt:e.getText().replace(/['`"]/g,``),start:e.getStart(),end:e.getEnd()}),n+=`: `),this.mapping[r]=e.getText(),r++;n+=` }`,this.fctTs=`return `+n,this.computedOnce=ur(this.fctTs)}}),this.variables=lr(this.fctTs,I.getVariables());let n=this.variables.map(e=>`c.data.`+e).join(`,`);this.fctJs=`@_@(c) => c.comp.${this.editName}(${n})@_@`}},or=class{start=0;end=0;attr;injectFctName;injectTsTxt;injectTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){this.attr=e,this.start=I.fromCompiledToRaw(n),this.end=I.fromCompiledToRaw(r),this.injectFctName=I.getCustomFctName()??``,this.injectTsTxt=t,this.computedOnce=ur(t),this.variables=lr(t,I.getVariables());let i=this.variables.map(e=>`c.data.`+e).join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${i})`}},sr=class{start=0;end=0;event;valueName=`value`;injectFctName;extractFctName;injectTsTxt;extractTsCond;extractTsTxt;injectTxt;extractTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){let i=e.split(`:`),a=i[0];a.startsWith(`@bind_`)?this.event=a.replace(`@bind_`,``):a.startsWith(`$`)&&a.length>0&&(this.event=a.replace(`$`,``)),i.length>1&&(this.valueName=i[1]),this.start=I.fromCompiledToRaw(n),this.end=I.fromCompiledToRaw(r),this.injectFctName=I.getCustomFctName()??``,this.extractFctName=I.getCustomFctName(1)??``,this.injectTsTxt=t,this.computedOnce=ur(t);let o=t.split(`.`);o.pop(),this.extractTsCond=o.join(`.`).trim(),this.extractTsCond.endsWith(`?`)&&(this.extractTsCond=this.extractTsCond.slice(0,this.extractTsCond.length-1)),this.extractTsTxt=t.replace(/\?/g,``),this.variables=lr(t,I.getVariables());let s=this.variables.map(e=>`c.data.`+e),c=[`v`].concat(s).join(`,`),l=s.join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${l})`,this.extractTxt=`(c, v) => c.comp.${this.extractFctName}(${c})`}};function cr(e,t){let n=/\{\{([\s|\S]*?)\}\}/g,r,i={changes:[],txt:e,variables:[],once:!0};for(;r=n.exec(e);){let e=t+r.index,n=t+r.index+r[0].length,a=I.createChange({txt:r[1],start:e,end:n});if(i.once&&!ur(r[1])&&(i.once=!1),a){a.variables=lr(r[1],a.variables);let e=a.variables.map(e=>`c.data.`+e).join(`,`),t="${c.print(c.comp."+a.name+`(`+e+`))}`;i.txt=i.txt.replace(r[0],t),i.changes.push(a)}}return i.changes.length>0&&(i.txt="(c) => `"+i.txt+"`"),i}function lr(e,t){if(t.length==0)return t;let n=[],r=(0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0),i=e=>{(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Identifier){if(e.parent.kind!=p.SyntaxKind.PropertyAccessExpression){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}else if(e.parent.getChildAt(0)==e){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}}i(e)})};return i(r),n}function ur(e){return!/if|switch|\?|\[.+?\]/g.test(e)}var I=class e{static languageService=(0,C.getLanguageService)();static parsedDoc={};static getVersion(t){return e.parsedDoc[t.file.uri]?this.parsedDoc[t.file.uri].version:0}static parse(t,n){return e.parsedDoc[t.file.uri]&&this.parsedDoc[t.file.uri].version==t.file.versionUser?this.parsedDoc[t.file.uri].result:(new e(t,n),e.parsedDoc[t.file.uri].result)}static currentParsingDoc;static addError(e,t,n){if(this.currentParsingDoc){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Error,source:w.HTML,message:n};this.currentParsingDoc.errors.push(r)}}static addWarning(e,t,n){if(this.currentParsingDoc){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Warning,source:w.TypeScript,message:n};this.currentParsingDoc.errors.push(r)}}static mergeTemplateResult(e,t){e.events=[...e.events,...t.events],e.pressEvents=[...e.pressEvents,...t.pressEvents],e.loops=[...e.loops,...t.loops],e.ifs=[...e.ifs,...t.ifs],e.content={...e.content,...t.content},e.contextEdits=[...e.contextEdits,...t.contextEdits],e.injection=[...e.injection,...t.injection],e.bindings=[...e.bindings,...t.bindings];for(let n of t.elements){let t=!1;for(let r of e.elements)if(r.name==n.name){t=!0;for(let e of n.ids)r.ids.includes(e)||r.ids.push(e);for(let e in n.tags)r.tags[e]?r.tags[e]+=n.tags[e]:r.tags[e]=n.tags[e];r.isArray||(n.isArray?r.isArray=!0:r.isArray=Object.values(r.tags).reduce((e,t)=>e+t,0)>1),r.positions=[...r.positions,...n.positions]}t||e.elements.push(n)}}static addInterestPoint(e){this.currentParsingDoc&&this.currentParsingDoc.interestPoints.push(e)}static addStyleLink(e){this.currentParsingDoc&&this.currentParsingDoc.styleLinks.push(e)}static getRules(){return this.currentParsingDoc?this.currentParsingDoc.rules:new Map}static refreshStyle(t,n){if(e.parsedDoc[t.file.uri]&&this.parsedDoc[t.file.uri].version==t.file.versionUser){let e=this.parsedDoc[t.file.uri];e.result.styleLinks=[],e.result.rules=t.scssFile?.rules??new Map;for(let t of e.result.tags)t.checkStyle(e.result.rules,t=>{e.result.styleLinks.push(t)})}this.parse(t,n)}static idElement=0;static idTemplate=0;static createIdTemplate(){let e=this.idTemplate;return this.idTemplate++,e}static getCustomFctName(e=0){if(this.currentParsingDoc?.htmlFile.tsFile){let t=this.currentParsingDoc.ifs.reduce((e,t)=>e+t.conditions.length,0),n=this.currentParsingDoc.loops.length+this.currentParsingDoc.loops.reduce((e,t)=>t.isSimple?e:e+1,0),r=Object.keys(this.currentParsingDoc.fcts).length,i=this.currentParsingDoc.contextEdits.length,a=this.currentParsingDoc.injections.length,o=this.currentParsingDoc.bindings.length*2,s=e+r+n+t+i+a+o;return this.currentParsingDoc.htmlFile.tsFile?.viewMethodName+s}return null}static createChange(e){if(this.currentParsingDoc){let t=Je(e.txt);if(this.currentParsingDoc.fcts[t])return this.currentParsingDoc.fcts[t].positions.push({start:e.start,end:e.end}),this.currentParsingDoc.fcts[t];{let n=this.getCustomFctName(),r=this.getVariables();if(n){let i={name:n,positions:[{start:e.start,end:e.end}],txt:e.txt,variables:r};return this.currentParsingDoc.fcts[t]=i,i}}}return null}static fromRawToCompiled(e){return this.currentParsingDoc?this.currentParsingDoc.fromRawToCompiled(e):e}static fromCompiledToRaw(e){return this.currentParsingDoc?this.currentParsingDoc.fromCompiledToRaw(e):e}static addLoopStack(e){if(this.currentParsingDoc){let t=this.currentParsingDoc.loops.find(t=>t.idTemplate==e);if(t)return t.recalculateVariables(),this.currentParsingDoc?.stacks.push(t),t}return null}static addIfStack(e){if(this.currentParsingDoc){for(let t of this.currentParsingDoc.ifs)if(t.idsTemplate.includes(e))return t.recalculateVariables(e),this.currentParsingDoc?.stacks.push({idTemplate:e}),t}return null}static addInjection(e){this.currentParsingDoc?.injections.push(e)}static addBinding(e){this.currentParsingDoc?.bindings.push(e)}static addTagInfoStack(e){this.currentParsingDoc?.stacks.push(e)}static getContextEditing(e){return this.currentParsingDoc?.contextEdits.find(t=>t.id==e)}static removeStack(){this.currentParsingDoc?.stacks.pop()}static getParentId(){if(this.currentParsingDoc&&this.currentParsingDoc.stacks.length>0)for(let e=this.currentParsingDoc.stacks.length-1;e>=0;e--){let t=this.currentParsingDoc.stacks[e];if(t instanceof rr||!(t instanceof Qn))return t.idTemplate}}static getVariables(){let e=[];if(this.currentParsingDoc){for(let t of this.currentParsingDoc.stacks)if(t instanceof rr||t instanceof Qn)for(let n of t.variableNames)e.includes(n)||e.push(n)}return e}uri;errors=[];document;rootTags=[];tags=[];blocksInfo={};slotsInfo={};resultsByClassName={};interestPoints=[];rules;styleLinks=[];fcts={};htmlFile;loops=[];ifs=[];injections=[];bindings=[];contextEdits=[];diffRawToCompiled={};diffCompiledToRaw={};stacks=[];compiledTxt=``;fromRawToCompiled(e){let t=e;for(let n in this.diffRawToCompiled){if(Number(n)>e)break;t+=this.diffRawToCompiled[n]}return t}fromCompiledToRaw(e){let t=e;for(let n in this.diffCompiledToRaw){if(Number(n)>e)break;t+=this.diffCompiledToRaw[n]}return t}getBlocksInfoTxt(){let e=[];for(let t in this.blocksInfo)e.push(`'`+t+"':`"+this.blocksInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}getSlotsInfoTxt(){let e=[];for(let t in this.slotsInfo)e.push(`'`+t+"':`"+this.slotsInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}isReady=!1;build;constructor(t,n){this.build=n,this.htmlFile=t,e.parsedDoc[t.file.uri]={version:t.file.versionUser,result:this};let r=this.getFileContent(t.file.documentUser);this.rules=t.scssFile?.rules??new Map,this.document=d.TextDocument.create(t.file.uri,t.file.documentUser.languageId,t.file.versionUser,r),e.currentParsingDoc=this,this.uri=t.file.uri,e.idElement=0,e.idTemplate=0,e.idTemplate=0,this.parse(this.document),e.currentParsingDoc=null,this.isReady=!0;for(let e of this.readyCb)e()}getFileContent(e){let t=e.getText();return t=t.replace(/\\\{\{(.*?)\}\}/g,`{{$1}}`),t=t.replace(/\\if/g,`if`),t=t.replace(/\\else/g,`else`),t=t.replace(/\\for/g,`for`),t=t.replace(/\\@Context/g,`@Context`),t}readyCb=[];onReady(e){this.isReady||this.readyCb.push(e)}parseJs(e){let t=e.getText(),n={},r=/<!--(.|\s)*?-->/g,i;for(;i=r.exec(t);){let e=``;for(let t=0;t<i[0].length;t++)e+=` `;n[i.index]=i[0],t=t.slice(0,i.index)+e+t.slice(i.index+i[0].length)}let a=t,o=(e,t)=>a.slice(e,t),s=(0,p.createSourceFile)(`sample.ts`,t.replace(/\{\{|\}\}/g,` `).replace(/<(\/?.*?)>/g,`'$1'`),p.ScriptTarget.ESNext,!0),c=[],l=(e,t)=>{(0,p.forEachChild)(e,n=>{let r;if(n.kind==p.SyntaxKind.IfStatement){let e=n,t=!0;if(e.parent.kind==p.SyntaxKind.IfStatement&&e.parent.elseStatement==e&&(t=!1),t){let e=new ir(n,o);e.isValid&&(this.ifs.push(e),c=[...c,...e.transformations])}}else if([p.SyntaxKind.ForInStatement,p.SyntaxKind.ForOfStatement,p.SyntaxKind.ForStatement].includes(n.kind)){if(n.getText()!==`for`){let e=new rr(n,o);e.isValid&&(r=e,c=[...c,...r.transformations],this.loops.push(r),this.stacks.push(r))}}else if(n.kind==p.SyntaxKind.Decorator&&n.getText().startsWith(`@Context(`)){let e=new ar(n,o);c=[...c,...e.transformations],this.contextEdits.push(e)}n.kind==p.SyntaxKind.Block&&e.kind==p.SyntaxKind.Block||(l(n,t+1),r&&this.stacks.pop())})};l(s,0),c.sort((e,t)=>t.end-e.end);let u=t.length;this.diffRawToCompiled={};for(let e of c){if(e.end>u)continue;let n=Math.min(e.newText.length,e.end-e.start);this.diffRawToCompiled[e.start+n]=e.newText.length-(e.end-e.start),t=t.slice(0,e.start)+e.newText+t.slice(e.end,t.length),u=e.start}let d=0;for(let e in this.diffRawToCompiled){let t=Number(e)+d,n=this.diffRawToCompiled[e]*-1;d+=this.diffRawToCompiled[e],this.diffCompiledToRaw[t]=n}for(let e in n){let r=n[e],i=this.fromRawToCompiled(Number(e));t=t.slice(0,i)+r+t.slice(i+r.length)}return t}parse(t){let n=this.parseJs(t);this.compiledTxt=n;let r=[],i=!1,a=e.languageService.createScanner(n,0),o=[],s=null;try{for(;a.scan()!=C.TokenType.EOS;)if(r.length>0){if(a.getTokenType()==C.TokenType.EndTagClose&&i){i=!1;let e=o.pop(),n=r.pop();if(e&&n){let r=a.getTokenEnd(),i=t.getText().slice(n,r);e.addContent(new nr(i,n,r,e,!1))}}else if(a.getTokenType()==C.TokenType.EndTag){let e=a.getTokenText(),t=o[o.length-1];t&&t.tagName==e&&(i=!0,t.afterClose(a.getTokenOffset(),a.getTokenEnd()))}}else if(a.getTokenType()!=C.TokenType.StartTagOpen){if(a.getTokenType()==C.TokenType.StartTagClose){if(o.length>0){let e=o[o.length-1];e.validateAllProps(a.getTokenOffset()),e.selfClosing&&(o.pop(),e.afterClose(a.getTokenOffset(),a.getTokenEnd())),this.build.getAvoidParsingTags().includes(e.tagName)&&r.push(a.getTokenEnd())}}else if(a.getTokenType()==C.TokenType.StartTagSelfClose){let e=o.pop();e&&(e.validateAllProps(a.getTokenOffset()),e.afterClose(a.getTokenOffset(),a.getTokenEnd()))}else if(a.getTokenType()==C.TokenType.StartTag){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd(),r=new Qn(this,e,t,n);o.length>0?o[o.length-1].addChild(r):this.rootTags.push(r),this.tags.push(r),o.push(r)}else if(a.getTokenType()!=C.TokenType.EndTagOpen&&a.getTokenType()!=C.TokenType.EndTagClose){if(a.getTokenType()==C.TokenType.EndTag){let e=a.getTokenText(),n=o.pop();if(n&&n.tagName==e)n.afterClose(a.getTokenOffset(),a.getTokenEnd());else{n?this.errors.push(Ne(t,`The tag `+n?.tagName+` isn't correctly closed`,n?.start,n?.end)):this.errors.push(Ne(t,`No opening tag found for `+e,a.getTokenOffset(),a.getTokenEnd()));return}}else if(a.getTokenType()!=C.TokenType.DelimiterAssign)if(a.getTokenType()==C.TokenType.AttributeName){let e=a.getTokenText();if(o.length>0){let t=o[o.length-1];s=new tr(e,a.getTokenOffset(),a.getTokenEnd(),t),t.addAttribute(s)}}else if(a.getTokenType()==C.TokenType.AttributeValue){if(s){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd();s.setValue(e,t,n),s=null}}else if(a.getTokenType()==C.TokenType.Content){if(o.length>0){let e=o[o.length-1],t=a.getTokenText(),n=a.getTokenOffset(),r=a.getTokenEnd();e.addContent(new nr(t,n,r,e))}}else a.getTokenType()==C.TokenType.Whitespace||a.getTokenType()==C.TokenType.Unknown||a.getTokenType()==C.TokenType.Script||(a.getTokenType(),C.TokenType.Styles)}}}catch(e){$.error(e)}let c=``;for(let e of this.rootTags)c+=e.render();this.manageSlotAndBlock(c)}getParsedInfo(t){if(t=t.toLowerCase(),this.resultsByClassName[t])return this.resultsByClassName[t];let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]};for(let r of this.rootTags){let i=r.getTemplateInfo(t);e.mergeTemplateResult(n,i)}return this.resultsByClassName[t]=n,n}replaceId(e){let t=``;for(let n of this.rootTags)n.replaceId(e),t+=n.render();this.manageSlotAndBlock(t)}manageSlotAndBlock(e){let t=e,n=t,r=/<block.*?( name="(.*?)")?>((\s|\S)*?)<\/block>/g,i;for(;i=r.exec(t);)this.blocksInfo[i[2]]=i[3],n=n.replace(i[0],``);n=n.trim(),(n.length>0||e.trim().length==0)&&(this.blocksInfo.default=n);let a=/<slot.*?( name="(.*?)")?>(\s|\S)*?<\/slot>/g;for(;i=a.exec(t);)i[2]||=`default`,this.slotsInfo[i[2]]=i[0]}},dr=o(((e,t)=>{t.exports=function(e){return e&&typeof e.valueOf()==`string`}})),fr=o(((e,t)=>{let n=dr();t.exports=function(e){if(e==null)return!1;if(!u(e))return r(`Options should be an object.`);if(e.order!==void 0&&e.order!==null){let{isValid:t,message:n}=o(e.order);if(!t)return i(`order`,n)}if(e[`properties-order`]!==void 0&&e[`properties-order`]!==null){let{isValid:t,message:n}=s(e[`properties-order`]);if(!t)return i(`properties-order`,n)}if(e[`unspecified-properties-position`]!==void 0&&e[`unspecified-properties-position`]!==null){let{isValid:t,message:n}=c(e[`unspecified-properties-position`]);if(!t)return i(`unspecified-properties-position`,n)}return!0};function r(e){return`postcss-sorting: ${e}`}function i(e,t=`Invalid value`){return r(`${e}: ${t}`)}function a(e){return e.join(`, `)}function o(e){if(!Array.isArray(e))return{isValid:!1,message:`Should be an array`};let t=[`custom-properties`,`dollar-variables`,`at-variables`,`declarations`,`rules`,`at-rules`];if(!e.every(e=>n(e)?t.includes(e):u(e)&&e.type!==void 0))return{isValid:!1,message:`Every item in the array must be an object with a "type" property, or one of keywords: ${a(t)}.`};let r=e.filter(u),i;return r.every(e=>{let t=!0;if(e.type!==`at-rule`&&e.type!==`rule`)return i=`"type" could be 'at-rule' or 'rule' only`,!1;if(e.type===`at-rule`){if(e.parameter!==void 0&&e.name===void 0)return i=`"at-rule" with "parameter" should also has a "name"`,!1;e.hasBlock!==void 0&&(t=e.hasBlock===!0||e.hasBlock===!1),e.name!==void 0&&(t=n(e.name)&&e.name.length),e.parameter!==void 0&&(t=n(e.parameter)&&e.parameter.length||l(e.parameter))}return e.type===`rule`&&e.selector!==void 0&&(t=n(e.selector)&&e.selector.length||l(e.selector)),t||(i=`Following option is incorrect: ${JSON.stringify(e)}`),t})?{isValid:!0}:{isValid:!1,message:i}}function s(e){return e===`alphabetical`?{isValid:!0}:Array.isArray(e)?e.every(e=>n(e))?{isValid:!0}:{isValid:!1,message:`Array should contain strings only`}:{isValid:!1,message:`Should be an array`}}function c(e){let t=[`top`,`bottom`,`bottomAlphabetical`];return n(e)&&t.includes(e)?{isValid:!0}:{isValid:!1,message:`Option should be one of the following values: ${a(t)}.`}}function l(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function u(e){return typeof e==`object`&&!!e}})),pr=o(((e,t)=>{t.exports=function(e){return e.type===`rule`||e.type===`atrule`?e:e.parent?.type===`root`&&e.parent?.raws.isRuleLike||e.parent?.document?.nodes?.some(e=>e.type===`root`)?e.parent:e}})),mr=o(((e,t)=>{let n=dr();t.exports=function(e){let t={},r=0;return e.forEach(e=>{let i=e;if(r+=1,n(i)&&i!==`at-rules`&&i!==`rules`&&(t[i]={position:r}),i===`rules`||i.type===`rule`){i===`rules`&&(i={type:`rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.selector&&(e.selector=i.selector,n(i.selector)&&(e.selector=new RegExp(i.selector))),t[i.type].push(e)}if(i===`at-rules`||i.type===`at-rule`){i===`at-rules`&&(i={type:`at-rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.name&&(e.name=i.name),i.parameter&&(e.parameter=i.parameter,n(i.parameter)&&(e.parameter=new RegExp(i.parameter))),i.hasBlock!==void 0&&(e.hasBlock=i.hasBlock),t[i.type].push(e)}}),t}})),hr=o(((e,t)=>{let n=[`function`,`if`,`else`,`for`,`each`,`while`];t.exports=function(e,t){return!(e.type===`atrule`&&n.includes(e.name)||!e?.nodes?.length||!(t&&t.ignoreInterpolations)&&(e.raws.after?.includes("${")||e.nodes.some(e=>e.raws.before.includes("${"))))}})),gr=o(((e,t)=>{t.exports=function(e,t,n){return e.type===`comment`&&!e.hasOwnProperty(`position`)?(e.position=1/0,e.initialIndex=t,[...n,e]):n}})),_r=o(((e,t)=>{t.exports=function(e){return!(e[0]===`$`||e[0]===`@`||/#{.+?}|@{.+?}|\$\(.+?\)/.test(e))}})),vr=o(((e,t)=>{t.exports=function(e){return e.slice(0,2)===`--`}})),yr=o(((e,t)=>{t.exports=function(e){return e[0]===`$`}})),br=o(((e,t)=>{t.exports=function(e){return e.type===`atrule`&&e.variable}})),xr=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`hasBlock`)&&t.hasBlock===e.hasBlock&&(n+=10,n+=1e4),e.hasOwnProperty(`name`)&&t.name===e.name&&(n+=100,n+=1e4),e.hasOwnProperty(`parameter`)&&e.parameter.test(t.parameter)&&(n+=1100,n+=1e4),!e.hasOwnProperty(`hasBlock`)&&!e.hasOwnProperty(`name`)&&!e.hasOwnProperty(`paremeter`)&&(n=1),e.hasOwnProperty(`hasBlock`)&&e.hasOwnProperty(`name`)&&n<2e4&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&n<21100&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&e.hasOwnProperty(`hasBlock`)&&n<3e4&&(n=0),n}})),Sr=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`selector`)||(n=1),e.hasOwnProperty(`selector`)&&e.selector.test(t.selector)&&(n=2),n}})),Cr=o(((e,t)=>{let n=_r(),r=vr(),i=yr(),a=br(),o=xr(),s=Sr();t.exports=function(e,t){let c;if(a(t))c=`at-variables`;else if(t.type===`decl`)r(t.prop)?c=`custom-properties`:i(t.prop)?c=`dollar-variables`:n(t.prop)&&(c=`declarations`);else if(t.type===`rule`){c={type:`rule`,selector:t.selector};let n=e.rule;if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=s(n,c);r>t&&(t=r,e=n)}),t)return e}}else if(t.type===`atrule`){c={type:`at-rule`,name:t.name,hasBlock:!1},t.nodes&&t.nodes.length&&(c.hasBlock=!0),t.params&&t.params.length&&(c.parameter=t.params);let n=e[`at-rule`];if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=o(n,c);r>t&&(t=r,e=n)}),t)return e}}return e[c]?e[c]:null}})),wr=o(((e,t)=>{t.exports={beforeNode:n,afterNode:r,beforeDeclaration:i,afterDeclaration:a};function n(e,t,r,i){if(!t||t.type!==`comment`||!t.raws.before||!t.raws.before.includes(`
|
|
391
|
+
}`})(n),a+=t.slice(this.componentEnd-r),a+=c,this.file instanceof j&&this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,i,a))}this.refreshFileParsed();let s=(0,f.join)(this.file.folderPath,`compiled.html`),c=(0,f.join)(this.file.folderPath,`compiled.ts`);this.writeHtml?(0,u.writeFileSync)(s,this.HTMLFile?.fileParsed?.compiledTxt??``):(0,u.existsSync)(s)&&(0,u.unlinkSync)(s),this.writeTs?(0,u.writeFileSync)(c,a):(0,u.existsSync)(c)&&(0,u.unlinkSync)(c)}}else this.file instanceof j&&this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,i,this.file.contentUser)),this.refreshFileParsed()}async onValidate(){return await this.runWebCompiler(),this.diagnostics=this.compilationResult?.diagnostics||[],this.transformDiagnosticForView(),this.HTMLFile?.validate(),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}transformDiagnosticForView(){let e=this.HTMLFile;if(e){let t=[],n=[],r=[];for(let i of this.diagnostics){let a=this.file.documentInternal.offsetAt(i.range.start),o=this.file.documentInternal.offsetAt(i.range.end),s=!1,c=a>=this.file.contentUser.length;for(let t=0;t<this.viewMethodsInfo.length;t++){let c=this.viewMethodsInfo[t].fullStart,l=this.viewMethodsInfo[t].end;if(a>c&&o<l){i.source=w.HTML;let c=this.viewMethodsInfo[t].fct,l=this.viewMethodsInfo[t].offsetAfter,u=this.viewMethodsInfo[t].offsetBefore;if(r.indexOf(i.range)==-1){let s=this.viewMethodsInfo[t].transform(a,0);r.push(i.range);let d=a-this.viewMethodsInfo[t].start-s,f=o-this.viewMethodsInfo[t].start-s;for(let t=0;t<c.positions.length;t++){let r=c.positions[t].start,a=c.positions[t].end,o=i;t>0&&(o={...i});let s=r+u+d,p=r+u+f;s<r||p>a-l?o.range={start:e.file.documentInternal.positionAt(r),end:e.file.documentInternal.positionAt(a)}:o.range={start:e.file.documentInternal.positionAt(s),end:e.file.documentInternal.positionAt(p)},t>0&&n.push(o)}}s=!0;break}}s?n.push(i):c||t.push(i)}this.diagnostics=t,this.htmlDiagnostics=n}else this.htmlDiagnostics=[]}quickParse(){let e=Zn.parse(this.file.documentUser.getText(),this.build);this._componentEnd=e.end,this._fullname=e.fullname,this._componentClassName=e.className,this.writeHtml=e.writeHtml,this.writeTs=e.writeTs,e.tagName&&this.build.htmlLanguageService.addInternalTagUri(e.tagName,this.file.uri,this._fullname);let t=``;for(let n=0;n<e.whiteSpaceBefore+4;n++)t+=` `;this._space=t}async onContentChange(){this.quickParse(),await this.runWebCompiler()}async onSave(){await this.runWebCompiler(),this.compilationResult?this.setCompileResult(this.compilationResult.result):this.setCompileResult([]),this.compilationResult?.writeCompiled?(0,u.writeFileSync)(this.file.folderPath+`/compiled.js`,ze(this.compilationResult.debug,this.build.project.getConfig())):(0,u.existsSync)(this.file.folderPath+`/compiled.js`)&&(0,u.unlinkSync)(this.file.folderPath+`/compiled.js`),this.canUpdateComponent||=!0}emitToHtttpServer(e){if(!this.canUpdateComponent)return;let t={};for(let n of e)t[n.name]=n.src;let n=!1,r=``,i=``,a;if(this.compilationResult)for(let e of this.compileResult)e.classScript!=``&&t[e.classScript]&&t[e.classScript]!=e.compiled&&(e.classScript==this.compilationResult.componentName?(n=!0,r=e.hotReload,i=e.classScript,a=this.fileParsed?.classes[i]):this.build.reloadPage=!0);if(!this.build.reloadPage&&n&&a){let e=this.buildNamespace;a.namespace&&(e+=a.namespace),e.length>0&&!e.endsWith(`.`)&&(e+=`.`),yt.getInstance().updateComponent(r,e+i,[])}}async onDelete(){await super.onDelete(),this.build.scssLanguageService.removeInternalDefinition(this.file.uri),this.build.htmlLanguageService.removeInternalDefinition(this.file.uri),this.build.htmlLanguageService.removeInternalTagUri(this.file.uri)}async doViewCompletion(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let r of e.fct.positions)if(n>=r.start+e.offsetBefore&&n<=r.end){let i=n-r.start-e.offsetAfter,a=e.start+i;a=e.transform(a,a);let o=this.file.documentInternal.positionAt(a),s=await this.onCompletion(this.file,o),c=[],l=[];for(let n of s.items)if(!(this.viewMethodName&&n.label.startsWith(this.viewMethodName))){if(n.data&&n.data.uri&&(n.data.languageId=w.HTML,n.data.uri=t.file.uri),n.textEdit){let i=n.textEdit;if(i.range&&l.indexOf(i.range)==-1){l.push(i.range),e.fct;let n=this.file.documentInternal.offsetAt(i.range.start),a=this.file.documentInternal.offsetAt(i.range.end),o=e.transform(n,0),s=n-e.start-o,c=a-e.start-o;i.range.start=t.file.documentInternal.positionAt(r.start+e.offsetBefore+s),i.range.end=t.file.documentInternal.positionAt(r.start+e.offsetBefore+c)}}if(n.additionalTextEdits){for(let i of n.additionalTextEdits)if(i.range&&l.indexOf(i.range)==-1){l.push(i.range),e.fct;let n=this.file.documentInternal.offsetAt(i.range.start),a=this.file.documentInternal.offsetAt(i.range.end),o=e.transform(n,0),s=n-e.start-o,c=a-e.start-o;i.range.start=t.file.documentInternal.positionAt(r.start+e.offsetBefore+s),i.range.end=t.file.documentInternal.positionAt(r.start+e.offsetBefore+c)}}c.push(n)}return s.items=c,s}return null}async onCompletion(e,t){return await this.runWebCompiler(),this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}async doHover(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let r of e.fct.positions)if(n>=r.start+e.offsetBefore&&n<=r.end){let i=n-r.start-e.offsetAfter,a=e.start+i;a=e.transform(a,a);let o=this.file.documentInternal.positionAt(a),s=await this.onHover(this.file,o);if(s&&s.range){let n=this.file.documentInternal.offsetAt(s.range.start),i=this.file.documentInternal.offsetAt(s.range.end),a=e.transform(n,0),o=n-e.start-a,c=i-e.start-a;s.range.start=t.file.documentInternal.positionAt(r.start+e.offsetBefore+o),s.range.end=t.file.documentInternal.positionAt(r.start+e.offsetBefore+c)}return s}return null}onHover(e,t){return this.tsLanguageService.doHover(e,t)}async doDefinition(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let t of e.fct.positions)if(n>=t.start+e.offsetBefore&&n<=t.end){let r=n-t.start-e.offsetAfter,i=e.start+r;i=e.transform(r,i);let a=this.file.documentInternal.positionAt(i);return await this.onDefinition(this.file,a)}return null}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async doFormatting(e,t){return await this.runWebCompiler(),this.HTMLFile?(await this.getFormatting(t,!1)).html:null}async onFormatting(e,t,n){return(await this.getFormatting(n,!0)).js}async getFormatting(e,t){let n={js:[],html:[]},r={start:{character:0,line:0},end:this.file.documentInternal.positionAt(this.file.contentInternal.length)},i=await this.tsLanguageService.format(this.file,r,e,t),a=this.HTMLFile,o=[];for(let e of i){let t=this.file.documentInternal.offsetAt(e.range.start),r=this.file.documentInternal.offsetAt(e.range.end),i=!1,s=t>=this.file.contentUser.length;if(a)for(let a=0;a<this.viewMethodsInfo.length;a++){let s=this.viewMethodsInfo[a].start,c=this.viewMethodsInfo[a].end,l=this.viewMethodsInfo[a].transform(t,0);if(t>=s+l&&r<c){if(t==s&&!/\S/.test(e.newText)){i=!0;break}let c=this.viewMethodsInfo[a].fct,u=this.viewMethodsInfo[a].offsetBefore;if(o.indexOf(e.range)==-1){o.push(e.range);let i=t-this.viewMethodsInfo[a].start-l,s=r-this.viewMethodsInfo[a].start-l;for(let t=0;t<c.positions.length;t++){let r=c.positions[t].start+u+i,o=c.positions[t].start+u+s;n.html.push({edit:{newText:e.newText,range:{start:r,end:o}},start:c.positions[t].start,end:c.positions[t].end,kind:this.viewMethodsInfo[a].kind})}}i=!0;break}else if(t>=this.viewMethodsInfo[a].fullStart&&r<=c){i=!0;break}}!i&&!s&&n.js.push(e)}return n}async onCodeAction(e,t){let n=await this.tsLanguageService.doCodeAction(e,t);return this.addCustomCodeAction(n),n}async doReferences(e){let t=this.HTMLFile;if(!t)return null;let n=t.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let t of e.fct.positions)if(n>=t.start+e.offsetBefore&&n<=t.end){let r=n-t.start-e.offsetAfter,i=e.start+r;i=e.transform(i,i);let a=this.file.documentInternal.positionAt(i);return await this.onReferences(this.file,a)}return null}async onReferences(e,t){let n=[],r=await this.tsLanguageService.onReferences(e,t)||[];if(this._compilationResult?.componentName&&this.fileParsed?.classes[this._compilationResult.componentName]){let e=this.file.documentInternal.offsetAt(t),r=this.fileParsed?.classes[this._compilationResult.componentName];if(e>=r.nameStart&&e<=r.nameEnd)for(let[e,t]of this.reverseViewClassInfoDependencies)for(let r of t)n.push({uri:e.file.uri,range:{start:e.file.documentInternal.positionAt(r.start),end:e.file.documentInternal.positionAt(r.end)}})}let i=[...r,...n];return i=this.transformRefrencesToView(i),i}transformRefrencesToView(t){let n=[];for(let r of t){if(r.uri.endsWith(T.ComponentLogic)){let t=this.build.tsFiles[r.uri];if(!t)continue;if(t instanceof e){let e=t.HTMLFile;if(e){let i=[],a=t._file.documentInternal.offsetAt(r.range.start),o=t._file.documentInternal.offsetAt(r.range.end);for(let t=0;t<this.viewMethodsInfo.length;t++){let s=this.viewMethodsInfo[t].fullStart,c=this.viewMethodsInfo[t].end;if(a>s&&o<c){r.uri=e.file.uri;let s=this.viewMethodsInfo[t].fct,c=this.viewMethodsInfo[t].offsetBefore;if(this.viewMethodsInfo[t].offsetAfter,i.indexOf(r.range)==-1){let l=this.viewMethodsInfo[t].transform(a,0);i.push(r.range);let u=a-this.viewMethodsInfo[t].start-l,d=o-this.viewMethodsInfo[t].start-l;for(let t=0;t<s.positions.length;t++){let i=s.positions[t].start+c+u,a=s.positions[t].start+c+d,o=r;t>0&&(o={...o}),o.range={start:e.file.documentInternal.positionAt(i),end:e.file.documentInternal.positionAt(a)},t>0&&n.push(o)}}break}}}}}n.push(r)}return n}async onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async doRename(e,t){let n=this.HTMLFile;if(!n)return null;let r=n.file.documentInternal.offsetAt(e);for(let e of this.viewMethodsInfo)for(let n of e.fct.positions)if(r>=n.start+e.offsetBefore&&r<=n.end){let i=r-n.start-e.offsetAfter,a=e.start+i;a=e.transform(a,a);let o=this.file.documentInternal.positionAt(a);return await this.onRename(this.file,o,t)}return null}async onRename(e,t,n){let r=await this.tsLanguageService.onRename(e,t,n);return r&&this.transformRenameToView(r),r}transformRenameToView(t){if(t.changes){let n={};for(let r in t.changes)if(r.endsWith(T.ComponentLogic)){let i=t.changes[r],a=this.build.tsFiles[r];if(!a)continue;if(a instanceof e){let e=a.HTMLFile;if(e)for(let t=0;t<i.length;t++){let r=i[t],o=a._file.documentInternal.offsetAt(r.range.start),s=a._file.documentInternal.offsetAt(r.range.end);for(let a=0;a<this.viewMethodsInfo.length;a++){let c=this.viewMethodsInfo[a].fullStart,l=this.viewMethodsInfo[a].end;if(o>c&&s<l){n[e.file.uri]||(n[e.file.uri]=[]);let c=this.viewMethodsInfo[a].fct,l=this.viewMethodsInfo[a].transform(o,0),u=o-this.viewMethodsInfo[a].start-l,d=s-this.viewMethodsInfo[a].start-l;for(let t of c.positions){let i=t.start+this.viewMethodsInfo[a].offsetBefore+u,o=t.start+this.viewMethodsInfo[a].offsetBefore+d;n[e.file.uri].push({newText:r.newText,range:{start:e.file.documentInternal.positionAt(i),end:e.file.documentInternal.positionAt(o)}})}i.splice(t,1),t--;break}}}}}for(let e in n)if(!t.changes[e])t.changes[e]=n[e];else for(let r of n[e])t.changes[e].push(r)}}addCustomCodeAction(e){let t=!1,n=!1;for(let r of this.diagnostics)if(r.code==1011&&!t)t=!0,e.push({title:`Import missing view elements`,command:{command:`aventus.wc.import.viewElement`,title:`Import missing view elements`}});else if(r.code==1014){let t=r.message.match(/#[a-zA-Z0-9_]+/g);if(t){let n=t[0].replace(`#`,``);e.push({title:`Import missing property `+n,command:{command:`aventus.wc.create.property`,title:`Create property`,arguments:[`prefill:`+n]}})}}else if(r.code==1019&&!n)n=!0,e.push({title:`Import missing methods`,command:{command:`aventus.wc.import.viewMethod`,title:`Import missing methods`}});else if(r.code==1012&&r.data){let t=r.data;e.push({title:`Remove element`,edit:{changes:{[this.file.uri]:[{newText:``,range:{start:this.file.documentInternal.positionAt(t.start),end:this.file.documentInternal.positionAt(t.end)}}]}}})}}getMissingVariablesInfo(){let e=``,t=-1;if(this.compilationResult){t=this.compilationResult?.missingViewElements.position;for(let t in this.compilationResult.missingViewElements.elements)e+=`@ViewElement()`+x.EOL+`protected `+t+`!: `+this.compilationResult.missingViewElements.elements[t]+`;`+x.EOL}return{start:t,text:e}}getMissingMethodsInfo(){let e=``,t=-1;if(this.compilationResult){t=this.compilationResult?.missingMethods.position;for(let t of this.compilationResult.missingMethods.elements)e+=`/**${x.EOL} * ${x.EOL} */${x.EOL}protected ${t}(){${x.EOL} throw new Error("Method not implemented.");${x.EOL} }${x.EOL} `}return e!=``&&(e=x.EOL+e),{start:t,text:e}}getComponentName(){return this.compilationResult?.componentName||``}viewClassInfoDependencies=[];reverseViewClassInfoDependencies=new Map;resetViewClassInfoDep(){let t=this.HTMLFile;if(t){for(let n of this.viewClassInfoDependencies)n instanceof e&&n.reverseViewClassInfoDependencies.delete(t);this.viewClassInfoDependencies=[]}}addViewClassInfoDep(t,n,r){let i=this.HTMLFile;i&&(this.viewClassInfoDependencies.includes(t)||this.viewClassInfoDependencies.push(t),t instanceof e&&(t.reverseViewClassInfoDependencies.has(i)||t.reverseViewClassInfoDependencies.set(i,[]),t.reverseViewClassInfoDependencies.get(i)?.push({start:n,end:r})))}},Qn=class e{tagName=``;children=[];attributes={};hasClose=!1;selfClosing=!1;id=``;start=0;end=0;parent=null;parentTemplateId;openTagStart=0;openTagEnd=0;alias=null;aliasMultiple=void 0;pressEvent=null;eventsPerso=[];injections=[];bindings=[];changes={};variableNames=[];parser;_idBase;get idBase(){return this._idBase||=this.componentClassName+`_`,this._idBase}get componentClassName(){return this.parser.htmlFile.tsFile?.componentClassName.toLowerCase()??``}get isLoop(){return this.tagName==rr.tagName}get isIf(){return this.tagName==ir.tagName}get isContextEditing(){return this.tagName==ar.tagName}loopInfo;ifInfo;contextEdit;constructor(e,t,n,r){if(this.parser=e,this.tagName=t,this.start=n,this.openTagStart=n,this.end=r,this.isLoop){this.createId();return}this.isIf||this.isContextEditing||(I.addInterestPoint({name:t,start:n,end:r,type:`tag`}),$n.includes(t)&&(this.selfClosing=!0))}createId(){return this.id||(this.id=this.idBase+I.idElement,I.idElement++),this.id}addAttribute(e){if(e.name==`@for`){I.addError(e.nameStart,e.nameEnd,`Deprecated : use for directly inside template`);return}this.attributes[e.name]?I.addError(e.nameStart,e.nameEnd,`Duplicate attribute `+e.name):this.attributes[e.name]=e}addChild(e){this.children.push(e),e.parent=this}addContent(e){this.children.push(e)}addChanges(e,t,n){let r=this.createId()+`°`+e;this.changes[r]={fct:t,once:n}}validateAllProps(e){if(this.openTagEnd=e,this.alias){let e=this.alias.endsWith(`[]`);e&&(this.alias=this.alias.replace(`[]`,``)),e&&(this.aliasMultiple=e)}if(this.isLoop){this.parentTemplateId=I.getParentId();let e=I.addLoopStack(Number(this.attributes.id.value));e&&(this.loopInfo=e)}else if(this.isIf){this.parentTemplateId=I.getParentId();let e=Number(this.attributes.id.value),t=I.addIfStack(e);t&&(this.ifInfo=t,e==t.idsTemplate[0]&&(t._id=this.createId()))}else if(this.isContextEditing){this.parentTemplateId=I.getParentId();let e=Number(this.attributes.id.value),t=I.getContextEditing(e);if(t&&(this.contextEdit=t,this.parent))for(let e of t.variableNames)this.parent.variableNames.includes(e)||this.parent.variableNames.push(e)}I.addTagInfoStack(this)}afterClose(e,t){this.hasClose=!0,this.selfClosing||I.addInterestPoint({name:this.tagName,start:e,end:t,type:`tag`}),this.checkStyle(I.getRules(),e=>I.addStyleLink(e)),I.removeStack(),(this.isLoop||this.isIf)&&I.removeStack()}checkStyle(e,t){for(let[n,r]of e)n(this)&&t([{start:this.openTagStart,end:this.openTagEnd},r])}_render(){let e=[];for(let t in this.attributes){let n=this.attributes[t];n.mustBeAdded&&(n.value==null?e.push(n.name):e.push(n.name+`="`+n.value+`"`))}this.id&&e.push(`_id="`+this.id+`"`);let t=``;return e.length>0&&(t=` `+e.join(` `)),this.selfClosing?`<${this.tagName}${t} />`:`<${this.tagName}${t}>${this.children.map(e=>e.render()).join(``)}</${this.tagName}>`}render(){return this.isContextEditing?``:this.isLoop?`<template _id="`+this.id+`"></template>`:this.isIf?this.id?`<template _id="`+this.id+`"></template>`:``:this._render()}replaceId(t){t.endsWith(`_`)||(t+=`_`),this.id=this.id.replace(this.idBase,t);let n={};for(let e in this.changes){let r=e.replace(this.idBase,t);n[r]=this.changes[e]}this.changes=n,this.ifInfo&&(this.ifInfo._id=this.ifInfo._id.replace(this.idBase,t)),this._idBase=t;for(let n of this.children)n instanceof e&&n.replaceId(t)}getTemplateInfo(t){let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},r=this.id,i=e=>{if(this.alias){let t=this.aliasMultiple?2:1;e.elements.push({name:this.alias,ids:[r],tags:{[this.tagName]:t},useLive:!1,isArray:t>1,positions:[{start:this.attributes[`@element`].valueStart,end:this.attributes[`@element`].valueEnd}]})}for(let t in this.changes)e.content[t]=this.changes[t];for(let t of this.injections){let n={id:r,injectionName:t.attr,inject:`@_@${t.injectTxt}@_@`};t.computedOnce&&(n.once=!0),e.injection.push(n)}for(let t of this.bindings){let n=[];n=t.event?[t.event]:[`input`,`textarea`].includes(this.tagName)?[`change`,`input`]:[`change`];let i={id:r,eventNames:n,injectionName:t.valueName,tagName:this.tagName,inject:`@_@${t.injectTxt}@_@`,extract:`@_@${t.extractTxt}@_@`};t.computedOnce&&(i.once=!0),e.bindings.push(i)}for(let t of this.eventsPerso)e.events.push({eventName:t.event,id:r,fct:t.fct,tagName:this.tagName,position:{start:t.start,end:t.end}});if(this.pressEvent&&e.pressEvents.push({...this.pressEvent,id:r}),this.contextEdit){let t={fct:this.contextEdit.fctJs};this.contextEdit.computedOnce&&(t.once=!0),e.contextEdits.push(t)}};if(this.loopInfo){let r={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},i=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);I.mergeTemplateResult(r,e)}i+=n.render()}let a={templateId:this.loopInfo.idTemplate||0,anchorId:this.id,template:i,actions:r,parentId:this.parentTemplateId};this.loopInfo.isSimple?a.simple=this.loopInfo.simple:a.func=this.loopInfo.complex.fct,n.loops.push(a)}else if(this.isIf&&this.ifInfo){let r=Number(this.attributes.id.value),i={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},a=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);I.mergeTemplateResult(i,e)}a+=n.render()}if(this.ifInfo.registerPart({template:a,templateId:r,templateAction:i,condition:``}),r==this.ifInfo.idsTemplate[this.ifInfo.idsTemplate.length-1]){let e={anchorId:this.ifInfo._id,parts:this.ifInfo.parts,parentId:this.parentTemplateId};n.ifs.push(e)}}else{i(n);for(let r of this.children)if(r instanceof e){let e=r.getTemplateInfo(t);I.mergeTemplateResult(n,e)}}return n}};const $n=[`area`,`base`,`br`,`col`,`embed`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`],er=[`_id`];var tr=class{name=``;value=null;nameStart=0;nameEnd=0;valueStart=0;valueEnd=0;tag;mustBeAdded=!0;constructor(e,t,n,r){this.name=e,this.nameStart=I.fromCompiledToRaw(t),this.nameEnd=I.fromCompiledToRaw(n),this.tag=r,this.manageSpecialAttribute()}manageSpecialAttribute(){this.name.startsWith(`@`)||this.name.startsWith(`:`)?(this.tag.createId(),this.mustBeAdded=!1):er.includes(this.name)&&(I.addError(this.nameStart,this.nameEnd,`The attribute `+this.name+` is used by Aventus internally`),this.mustBeAdded=!1)}setValue(e,t,n){if(e=e.replace(/"/g,``),this.value=e,this.valueStart=I.fromCompiledToRaw(t),this.valueEnd=I.fromCompiledToRaw(n),this.name!=`@for`)if(this.name===`@element`)this.tag.alias=e,I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`property`});else if(this.name.startsWith(`@bind`)||this.name.startsWith(`$`)){let r=new sr(this.name,e,t,n);this.tag.bindings.push(r),I.addBinding(r)}else if(this.name.startsWith(`:`)){let r=new or(this.name.slice(1),e,t,n);this.tag.injections.push(r),I.addInjection(r)}else if(Un.hasOwnProperty(this.name))this.tag.pressEvent||(this.tag.pressEvent={}),this.tag.pressEvent[Un[this.name]]={value:e,start:this.valueStart,end:this.valueEnd},I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else if(this.name.startsWith(`@`))this.tag.eventsPerso.push({event:this.name.slice(1),fct:e,start:this.valueStart,end:this.valueEnd}),I.addInterestPoint({name:this.name.slice(1),start:this.nameStart,end:this.nameEnd,type:`event`}),I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else{let t=cr(e,this.valueStart);t.changes.length>0&&(this.tag.addChanges(this.name,t.txt,t.once),this.mustBeAdded=!1)}}},nr=class{content=``;start=0;end=0;tag;mustBeAdded=!0;constructor(e,t,n,r,i=!0){this.content=e,this.start=I.fromCompiledToRaw(t),this.end=I.fromCompiledToRaw(n),this.tag=r,i&&this.manageVariables()}manageVariables(){let e=this.content,t=cr(e,this.start);t.changes.length>0&&(this.tag.addChanges(`@HTML`,t.txt,t.once),this.mustBeAdded=!1);for(let e of t.variables)this.tag.variableNames.includes(e)||this.tag.variableNames.push(e)}render(){return this.mustBeAdded?this.content:``}},rr=class e{static tagName=`l`;idTemplate=0;isSimple=!1;transformations=[];start=0;startBlock=0;end=0;loopTxt=``;loopName=``;isValid=!0;typeToLoad=[];simple={data:``};complex={init:[],condition:``,transform:[],apply:[],loopName:``,fct:``};get variableNames(){return this.typeToLoad.map(e=>e.txt)}variables=[];sliceText;constructor(e,t){this.sliceText=t,this.idTemplate=I.createIdTemplate(),this.variables=I.getVariables(),e.kind==p.SyntaxKind.ForOfStatement||e.kind==p.SyntaxKind.ForInStatement?(this.isSimple=!0,this.loadForInOf(e)):this.loadFor(e),this.loopName=I.getCustomFctName()??``}loadForInOf(t){let n=0;(0,p.forEachChild)(t,r=>{if(n==0){let e=r.getChildAt(1),n=e.getStart(),i=e.getEnd(),a=this.sliceText(n,i);t.kind==p.SyntaxKind.ForInStatement?this.simple.index=a:this.simple.item=a,this.typeToLoad.push({txt:a,start:n,end:i})}else if(n==1)this.simple.data=this.sliceText(r.getStart(),r.getEnd());else if(n==2){let n=t.getStart(),i=r.getStart()+1;this.loopTxt=this.sliceText(n,i)+` }`;let a=`<`+e.tagName+` id="`+this.idTemplate+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o}),this.start=n,this.startBlock=i,this.end=s}n++})}loadFor(t){let n=[],r=[],i=``,a=[],o=0,s=``;if((0,p.forEachChild)(t,c=>{if(o==0&&c.kind==p.SyntaxKind.VariableDeclarationList)(0,p.forEachChild)(c,e=>{let t=e.getChildAt(0),i=t.getStart(),a=t.getEnd(),o=this.sliceText(i,a);n.push(`let `+e.getText()),r.push(e.getChildAt(0).getText()),this.typeToLoad.push({txt:o,start:i,end:a})});else if(o==1&&c.kind==p.SyntaxKind.BinaryExpression)i=c.getText();else if(o==2){let e=t=>{t.kind==p.SyntaxKind.BinaryExpression&&t.getChildAt(1).getText()==`,`?(e(t.getChildAt(0)),e(t.getChildAt(2))):a.push(t.getText())};e(c)}else if(o==3&&c.kind==p.SyntaxKind.Block){let n=t.getStart(),r=c.getStart()+1;s=this.sliceText(n,r)+` }`,this.loopTxt=s;let i=`<`+e.tagName+` id="`+this.idTemplate+`">`,a=`</`+e.tagName+`>`;this.transformations.push({start:n,end:r,newText:i});let o=c.getEnd();this.transformations.push({start:o-1,end:o,newText:a}),this.start=n,this.startBlock=r,this.end=o}o++}),this.transformations.length==0&&(this.isValid=!1),!this.checkIsSimple(n,i,a)){let e=I.getCustomFctName(1)??``;this.complex={init:n,condition:i,transform:a,apply:r,loopName:e,fct:`(c) => c.comp.${e}`}}}recalculateVariables(){if(this.variables=lr(this.loopTxt,I.getVariables()),!this.isSimple){let e=this.variables.map(e=>`c.data.`+e).join(`,`);this.complex.fct+=`(${e})`}}checkIsSimple(e,t,n){if(e.length!=1)return!1;let r=e[0].split(`=`);if(r.length!=2)return!1;let i=r[0].replace(`let `,``).trim();if(r[1].trim()!=`0`)return!1;let a=RegExp(`\\s*`+i+`\\s*<\\s*([a-zA-Z0-9\\._\\[\\]-]+)\\.length`).exec(t);if(!a)return!1;let o=a[1];return n.length!=1||!RegExp(`\\s*`+i+`\\+\\+\\s*`).exec(n[0])?!1:(this.isSimple=!0,this.simple={data:o,index:i},!0)}},ir=class e{static tagName=`if`;statements=[];idsTemplate=[];defaultVariables=[];transformations=[];end=0;_id=``;parts=[];isValid=!0;conditions=[];sliceText;constructor(e,t){this.sliceText=t,this.defaultVariables=I.getVariables(),this.loadIf(e)}loadIf(t){let n=[],r=()=>{let e=I.createIdTemplate();return this.idsTemplate.push(e),e},i=(t,n,r)=>{let i=r.getStart()+1,a=`<`+e.tagName+` id="`+t+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o})},a=(e,t=0,o)=>{let s=0;o===void 0&&(o=e.getStart());let c=o,l;for(let t of e.getChildren())t.kind==p.SyntaxKind.ElseKeyword&&(l=t.getStart());let u=r();(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Block){if(s++,s==2){if(l==null)throw`impossible`;i(r(),l,e)}else i(u,c,e);n.push(e)}else if(e.kind==p.SyntaxKind.IfStatement){if(l==null)throw`impossible`;a(e,t+1,l)}else if(p.SyntaxKind[e.kind].includes(`Expression`)){let n=I.getCustomFctName(this.conditions.length)??``,r=this.sliceText(e.getStart(),e.getEnd());this.conditions.push({fctName:n,txt:r,fctTxt:`(c) => c.comp.${n}`,start:e.getStart(),end:e.getEnd(),offsetAfter:0,offsetBefore:0,idTemplate:u,type:t==0?`if`:`elif`,variables:[],computedOnce:ur(r)})}}),s==0&&(this.isValid=!1)};a(t)}registerPart(e){this.conditions.length>this.parts.length?(e.condition=this.conditions[this.parts.length].fctTxt,e.once=this.conditions[this.parts.length].computedOnce):(e.condition=`(c) => true`,e.once=!0),this.parts.push(e)}recalculateVariables(e){let t=I.getVariables();for(let n of this.conditions)if(n.idTemplate==e){let e=lr(n.txt,t),r=e.map(e=>`c.data.`+e).join(`,`);n.fctTxt+=`(${r})`,n.variables=e}}},ar=class e{static tagName=`c`;sliceText;variables=[];transformations=[];id;fctTs=``;fctJs=``;editName;start=0;end=0;mapping=[``,``];computedOnce=!1;typeToLoad=[];get variableNames(){return this.typeToLoad.map(e=>e.txt)}constructor(e,t){this.sliceText=t,this.editName=I.getCustomFctName()??``,this.id=I.createIdTemplate(),this.loadContextEditing(e)}loadContextEditing(t){this.start=t.getStart(),this.end=t.getEnd(),this.transformations.push({start:t.getStart(),end:t.getEnd(),newText:`<`+e.tagName+` id="`+this.id+`"></`+e.tagName+`>`}),(0,p.forEachChild)(t,e=>{if(e.kind==p.SyntaxKind.CallExpression){let t=e,n=`{ `,r=0;for(let e of t.arguments)n+=e.getText(),r==0&&(this.typeToLoad.push({txt:e.getText().replace(/['`"]/g,``),start:e.getStart(),end:e.getEnd()}),n+=`: `),this.mapping[r]=e.getText(),r++;n+=` }`,this.fctTs=`return `+n,this.computedOnce=ur(this.fctTs)}}),this.variables=lr(this.fctTs,I.getVariables());let n=this.variables.map(e=>`c.data.`+e).join(`,`);this.fctJs=`@_@(c) => c.comp.${this.editName}(${n})@_@`}},or=class{start=0;end=0;attr;injectFctName;injectTsTxt;injectTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){this.attr=e,this.start=I.fromCompiledToRaw(n),this.end=I.fromCompiledToRaw(r),this.injectFctName=I.getCustomFctName()??``,this.injectTsTxt=t,this.computedOnce=ur(t),this.variables=lr(t,I.getVariables());let i=this.variables.map(e=>`c.data.`+e).join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${i})`}},sr=class{start=0;end=0;event;valueName=`value`;injectFctName;extractFctName;injectTsTxt;extractTsCond;extractTsTxt;injectTxt;extractTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){let i=e.split(`:`),a=i[0];a.startsWith(`@bind_`)?this.event=a.replace(`@bind_`,``):a.startsWith(`$`)&&a.length>0&&(this.event=a.replace(`$`,``)),i.length>1&&(this.valueName=i[1]),this.start=I.fromCompiledToRaw(n),this.end=I.fromCompiledToRaw(r),this.injectFctName=I.getCustomFctName()??``,this.extractFctName=I.getCustomFctName(1)??``,this.injectTsTxt=t,this.computedOnce=ur(t);let o=t.split(`.`);o.pop(),this.extractTsCond=o.join(`.`).trim(),this.extractTsCond.endsWith(`?`)&&(this.extractTsCond=this.extractTsCond.slice(0,this.extractTsCond.length-1)),this.extractTsTxt=t.replace(/\?/g,``),this.variables=lr(t,I.getVariables());let s=this.variables.map(e=>`c.data.`+e),c=[`v`].concat(s).join(`,`),l=s.join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${l})`,this.extractTxt=`(c, v) => c.comp.${this.extractFctName}(${c})`}};function cr(e,t){let n=/\{\{([\s|\S]*?)\}\}/g,r,i={changes:[],txt:e,variables:[],once:!0};for(;r=n.exec(e);){let e=t+r.index,n=t+r.index+r[0].length,a=I.createChange({txt:r[1],start:e,end:n});if(i.once&&!ur(r[1])&&(i.once=!1),a){a.variables=lr(r[1],a.variables);let e=a.variables.map(e=>`c.data.`+e).join(`,`),t="${c.print(c.comp."+a.name+`(`+e+`))}`;i.txt=i.txt.replace(r[0],t),i.changes.push(a)}}return i.changes.length>0&&(i.txt="(c) => `"+i.txt+"`"),i}function lr(e,t){if(t.length==0)return t;let n=[],r=(0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0),i=e=>{(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Identifier){if(e.parent.kind!=p.SyntaxKind.PropertyAccessExpression){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}else if(e.parent.getChildAt(0)==e){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}}i(e)})};return i(r),n}function ur(e){return!/if|switch|\?|\[.+?\]/g.test(e)}var I=class e{static languageService=(0,C.getLanguageService)();static parsedDoc={};static getVersion(t){return e.parsedDoc[t.file.uri]?this.parsedDoc[t.file.uri].version:0}static parse(t,n){return e.parsedDoc[t.file.uri]&&this.parsedDoc[t.file.uri].version==t.file.versionUser?this.parsedDoc[t.file.uri].result:(new e(t,n),e.parsedDoc[t.file.uri].result)}static currentParsingDoc;static addError(e,t,n){if(this.currentParsingDoc){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Error,source:w.HTML,message:n};this.currentParsingDoc.errors.push(r)}}static addWarning(e,t,n){if(this.currentParsingDoc){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Warning,source:w.TypeScript,message:n};this.currentParsingDoc.errors.push(r)}}static mergeTemplateResult(e,t){e.events=[...e.events,...t.events],e.pressEvents=[...e.pressEvents,...t.pressEvents],e.loops=[...e.loops,...t.loops],e.ifs=[...e.ifs,...t.ifs],e.content={...e.content,...t.content},e.contextEdits=[...e.contextEdits,...t.contextEdits],e.injection=[...e.injection,...t.injection],e.bindings=[...e.bindings,...t.bindings];for(let n of t.elements){let t=!1;for(let r of e.elements)if(r.name==n.name){t=!0;for(let e of n.ids)r.ids.includes(e)||r.ids.push(e);for(let e in n.tags)r.tags[e]?r.tags[e]+=n.tags[e]:r.tags[e]=n.tags[e];r.isArray||(n.isArray?r.isArray=!0:r.isArray=Object.values(r.tags).reduce((e,t)=>e+t,0)>1),r.positions=[...r.positions,...n.positions]}t||e.elements.push(n)}}static addInterestPoint(e){this.currentParsingDoc&&this.currentParsingDoc.interestPoints.push(e)}static addStyleLink(e){this.currentParsingDoc&&this.currentParsingDoc.styleLinks.push(e)}static getRules(){return this.currentParsingDoc?this.currentParsingDoc.rules:new Map}static refreshStyle(t,n){if(e.parsedDoc[t.file.uri]&&this.parsedDoc[t.file.uri].version==t.file.versionUser){let e=this.parsedDoc[t.file.uri];e.result.styleLinks=[],e.result.rules=t.scssFile?.rules??new Map;for(let t of e.result.tags)t.checkStyle(e.result.rules,t=>{e.result.styleLinks.push(t)})}this.parse(t,n)}static idElement=0;static idTemplate=0;static createIdTemplate(){let e=this.idTemplate;return this.idTemplate++,e}static getCustomFctName(e=0){if(this.currentParsingDoc?.htmlFile.tsFile){let t=this.currentParsingDoc.ifs.reduce((e,t)=>e+t.conditions.length,0),n=this.currentParsingDoc.loops.length+this.currentParsingDoc.loops.reduce((e,t)=>t.isSimple?e:e+1,0),r=Object.keys(this.currentParsingDoc.fcts).length,i=this.currentParsingDoc.contextEdits.length,a=this.currentParsingDoc.injections.length,o=this.currentParsingDoc.bindings.length*2,s=e+r+n+t+i+a+o;return this.currentParsingDoc.htmlFile.tsFile?.viewMethodName+s}return null}static createChange(e){if(this.currentParsingDoc){let t=Je(e.txt);if(this.currentParsingDoc.fcts[t])return this.currentParsingDoc.fcts[t].positions.push({start:e.start,end:e.end}),this.currentParsingDoc.fcts[t];{let n=this.getCustomFctName(),r=this.getVariables();if(n){let i={name:n,positions:[{start:e.start,end:e.end}],txt:e.txt,variables:r};return this.currentParsingDoc.fcts[t]=i,i}}}return null}static fromRawToCompiled(e){return this.currentParsingDoc?this.currentParsingDoc.fromRawToCompiled(e):e}static fromCompiledToRaw(e){return this.currentParsingDoc?this.currentParsingDoc.fromCompiledToRaw(e):e}static addLoopStack(e){if(this.currentParsingDoc){let t=this.currentParsingDoc.loops.find(t=>t.idTemplate==e);if(t)return t.recalculateVariables(),this.currentParsingDoc?.stacks.push(t),t}return null}static addIfStack(e){if(this.currentParsingDoc){for(let t of this.currentParsingDoc.ifs)if(t.idsTemplate.includes(e))return t.recalculateVariables(e),this.currentParsingDoc?.stacks.push({idTemplate:e}),t}return null}static addInjection(e){this.currentParsingDoc?.injections.push(e)}static addBinding(e){this.currentParsingDoc?.bindings.push(e)}static addTagInfoStack(e){this.currentParsingDoc?.stacks.push(e)}static getContextEditing(e){return this.currentParsingDoc?.contextEdits.find(t=>t.id==e)}static removeStack(){this.currentParsingDoc?.stacks.pop()}static getParentId(){if(this.currentParsingDoc&&this.currentParsingDoc.stacks.length>0)for(let e=this.currentParsingDoc.stacks.length-1;e>=0;e--){let t=this.currentParsingDoc.stacks[e];if(t instanceof rr||!(t instanceof Qn))return t.idTemplate}}static getVariables(){let e=[];if(this.currentParsingDoc){for(let t of this.currentParsingDoc.stacks)if(t instanceof rr||t instanceof Qn)for(let n of t.variableNames)e.includes(n)||e.push(n)}return e}uri;errors=[];document;rootTags=[];tags=[];blocksInfo={};slotsInfo={};resultsByClassName={};interestPoints=[];rules;styleLinks=[];fcts={};htmlFile;loops=[];ifs=[];injections=[];bindings=[];contextEdits=[];diffRawToCompiled={};diffCompiledToRaw={};stacks=[];compiledTxt=``;fromRawToCompiled(e){let t=e;for(let n in this.diffRawToCompiled){if(Number(n)>e)break;t+=this.diffRawToCompiled[n]}return t}fromCompiledToRaw(e){let t=e;for(let n in this.diffCompiledToRaw){if(Number(n)>e)break;t+=this.diffCompiledToRaw[n]}return t}getBlocksInfoTxt(){let e=[];for(let t in this.blocksInfo)e.push(`'`+t+"':`"+this.blocksInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}getSlotsInfoTxt(){let e=[];for(let t in this.slotsInfo)e.push(`'`+t+"':`"+this.slotsInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}isReady=!1;build;constructor(t,n){this.build=n,this.htmlFile=t,e.parsedDoc[t.file.uri]={version:t.file.versionUser,result:this};let r=this.getFileContent(t.file.documentUser);this.rules=t.scssFile?.rules??new Map,this.document=d.TextDocument.create(t.file.uri,t.file.documentUser.languageId,t.file.versionUser,r),e.currentParsingDoc=this,this.uri=t.file.uri,e.idElement=0,e.idTemplate=0,e.idTemplate=0,this.parse(this.document),e.currentParsingDoc=null,this.isReady=!0;for(let e of this.readyCb)e()}getFileContent(e){let t=e.getText();return t=t.replace(/\\\{\{(.*?)\}\}/g,`{{$1}}`),t=t.replace(/\\if/g,`if`),t=t.replace(/\\else/g,`else`),t=t.replace(/\\for/g,`for`),t=t.replace(/\\@Context/g,`@Context`),t}readyCb=[];onReady(e){this.isReady||this.readyCb.push(e)}parseJs(e){let t=e.getText(),n={},r=/<!--(.|\s)*?-->/g,i;for(;i=r.exec(t);){let e=``;for(let t=0;t<i[0].length;t++)e+=` `;n[i.index]=i[0],t=t.slice(0,i.index)+e+t.slice(i.index+i[0].length)}let a=t,o=(e,t)=>a.slice(e,t),s=(0,p.createSourceFile)(`sample.ts`,t.replace(/\{\{|\}\}/g,` `).replace(/<(\/?.*?)>/g,`'$1'`),p.ScriptTarget.ESNext,!0),c=[],l=(e,t)=>{(0,p.forEachChild)(e,n=>{let r;if(n.kind==p.SyntaxKind.IfStatement){let e=n,t=!0;if(e.parent.kind==p.SyntaxKind.IfStatement&&e.parent.elseStatement==e&&(t=!1),t){let e=new ir(n,o);e.isValid&&(this.ifs.push(e),c=[...c,...e.transformations])}}else if([p.SyntaxKind.ForInStatement,p.SyntaxKind.ForOfStatement,p.SyntaxKind.ForStatement].includes(n.kind)){if(n.getText()!==`for`){let e=new rr(n,o);e.isValid&&(r=e,c=[...c,...r.transformations],this.loops.push(r),this.stacks.push(r))}}else if(n.kind==p.SyntaxKind.Decorator&&n.getText().startsWith(`@Context(`)){let e=new ar(n,o);c=[...c,...e.transformations],this.contextEdits.push(e)}n.kind==p.SyntaxKind.Block&&e.kind==p.SyntaxKind.Block||(l(n,t+1),r&&this.stacks.pop())})};l(s,0),c.sort((e,t)=>t.end-e.end);let u=t.length;this.diffRawToCompiled={};for(let e of c){if(e.end>u)continue;let n=Math.min(e.newText.length,e.end-e.start);this.diffRawToCompiled[e.start+n]=e.newText.length-(e.end-e.start),t=t.slice(0,e.start)+e.newText+t.slice(e.end,t.length),u=e.start}let d=0;for(let e in this.diffRawToCompiled){let t=Number(e)+d,n=this.diffRawToCompiled[e]*-1;d+=this.diffRawToCompiled[e],this.diffCompiledToRaw[t]=n}for(let e in n){let r=n[e],i=this.fromRawToCompiled(Number(e));t=t.slice(0,i)+r+t.slice(i+r.length)}return t}parse(t){let n=this.parseJs(t);this.compiledTxt=n;let r=[],i=!1,a=e.languageService.createScanner(n,0),o=[],s=null;try{for(;a.scan()!=C.TokenType.EOS;)if(r.length>0){if(a.getTokenType()==C.TokenType.EndTagClose&&i){i=!1;let e=o.pop(),n=r.pop();if(e&&n){let r=a.getTokenEnd(),i=t.getText().slice(n,r);e.addContent(new nr(i,n,r,e,!1))}}else if(a.getTokenType()==C.TokenType.EndTag){let e=a.getTokenText(),t=o[o.length-1];t&&t.tagName==e&&(i=!0,t.afterClose(a.getTokenOffset(),a.getTokenEnd()))}}else if(a.getTokenType()!=C.TokenType.StartTagOpen){if(a.getTokenType()==C.TokenType.StartTagClose){if(o.length>0){let e=o[o.length-1];e.validateAllProps(a.getTokenOffset()),e.selfClosing&&(o.pop(),e.afterClose(a.getTokenOffset(),a.getTokenEnd())),this.build.getAvoidParsingTags().includes(e.tagName)&&r.push(a.getTokenEnd())}}else if(a.getTokenType()==C.TokenType.StartTagSelfClose){let e=o.pop();e&&(e.validateAllProps(a.getTokenOffset()),e.afterClose(a.getTokenOffset(),a.getTokenEnd()))}else if(a.getTokenType()==C.TokenType.StartTag){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd(),r=new Qn(this,e,t,n);o.length>0?o[o.length-1].addChild(r):this.rootTags.push(r),this.tags.push(r),o.push(r)}else if(a.getTokenType()!=C.TokenType.EndTagOpen&&a.getTokenType()!=C.TokenType.EndTagClose){if(a.getTokenType()==C.TokenType.EndTag){let e=a.getTokenText(),n=o.pop();if(n&&n.tagName==e)n.afterClose(a.getTokenOffset(),a.getTokenEnd());else{n?this.errors.push(Ne(t,`The tag `+n?.tagName+` isn't correctly closed`,n?.start,n?.end)):this.errors.push(Ne(t,`No opening tag found for `+e,a.getTokenOffset(),a.getTokenEnd()));return}}else if(a.getTokenType()!=C.TokenType.DelimiterAssign)if(a.getTokenType()==C.TokenType.AttributeName){let e=a.getTokenText();if(o.length>0){let t=o[o.length-1];s=new tr(e,a.getTokenOffset(),a.getTokenEnd(),t),t.addAttribute(s)}}else if(a.getTokenType()==C.TokenType.AttributeValue){if(s){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd();s.setValue(e,t,n),s=null}}else if(a.getTokenType()==C.TokenType.Content){if(o.length>0){let e=o[o.length-1],t=a.getTokenText(),n=a.getTokenOffset(),r=a.getTokenEnd();e.addContent(new nr(t,n,r,e))}}else a.getTokenType()==C.TokenType.Whitespace||a.getTokenType()==C.TokenType.Unknown||a.getTokenType()==C.TokenType.Script||(a.getTokenType(),C.TokenType.Styles)}}}catch(e){$.error(e)}let c=``;for(let e of this.rootTags)c+=e.render();this.manageSlotAndBlock(c)}getParsedInfo(t){if(t=t.toLowerCase(),this.resultsByClassName[t])return this.resultsByClassName[t];let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]};for(let r of this.rootTags){let i=r.getTemplateInfo(t);e.mergeTemplateResult(n,i)}return this.resultsByClassName[t]=n,n}replaceId(e){let t=``;for(let n of this.rootTags)n.replaceId(e),t+=n.render();this.manageSlotAndBlock(t)}manageSlotAndBlock(e){let t=e,n=t,r=/<block.*?( name="(.*?)")?>([\s\S]*?)<\/block>/g,i;for(;i=r.exec(t);)this.blocksInfo[i[2]]=i[3],n=n.replace(i[0],``);n=n.trim(),(n.length>0||e.trim().length==0)&&(this.blocksInfo.default=n);let a=/<slot.*?( name="(.*?)")?>[\s\S]*?<\/slot>/g;for(;i=a.exec(t);)i[2]||=`default`,this.slotsInfo[i[2]]=i[0]}},dr=o(((e,t)=>{t.exports=function(e){return e&&typeof e.valueOf()==`string`}})),fr=o(((e,t)=>{let n=dr();t.exports=function(e){if(e==null)return!1;if(!u(e))return r(`Options should be an object.`);if(e.order!==void 0&&e.order!==null){let{isValid:t,message:n}=o(e.order);if(!t)return i(`order`,n)}if(e[`properties-order`]!==void 0&&e[`properties-order`]!==null){let{isValid:t,message:n}=s(e[`properties-order`]);if(!t)return i(`properties-order`,n)}if(e[`unspecified-properties-position`]!==void 0&&e[`unspecified-properties-position`]!==null){let{isValid:t,message:n}=c(e[`unspecified-properties-position`]);if(!t)return i(`unspecified-properties-position`,n)}return!0};function r(e){return`postcss-sorting: ${e}`}function i(e,t=`Invalid value`){return r(`${e}: ${t}`)}function a(e){return e.join(`, `)}function o(e){if(!Array.isArray(e))return{isValid:!1,message:`Should be an array`};let t=[`custom-properties`,`dollar-variables`,`at-variables`,`declarations`,`rules`,`at-rules`];if(!e.every(e=>n(e)?t.includes(e):u(e)&&e.type!==void 0))return{isValid:!1,message:`Every item in the array must be an object with a "type" property, or one of keywords: ${a(t)}.`};let r=e.filter(u),i;return r.every(e=>{let t=!0;if(e.type!==`at-rule`&&e.type!==`rule`)return i=`"type" could be 'at-rule' or 'rule' only`,!1;if(e.type===`at-rule`){if(e.parameter!==void 0&&e.name===void 0)return i=`"at-rule" with "parameter" should also has a "name"`,!1;e.hasBlock!==void 0&&(t=e.hasBlock===!0||e.hasBlock===!1),e.name!==void 0&&(t=n(e.name)&&e.name.length),e.parameter!==void 0&&(t=n(e.parameter)&&e.parameter.length||l(e.parameter))}return e.type===`rule`&&e.selector!==void 0&&(t=n(e.selector)&&e.selector.length||l(e.selector)),t||(i=`Following option is incorrect: ${JSON.stringify(e)}`),t})?{isValid:!0}:{isValid:!1,message:i}}function s(e){return e===`alphabetical`?{isValid:!0}:Array.isArray(e)?e.every(e=>n(e))?{isValid:!0}:{isValid:!1,message:`Array should contain strings only`}:{isValid:!1,message:`Should be an array`}}function c(e){let t=[`top`,`bottom`,`bottomAlphabetical`];return n(e)&&t.includes(e)?{isValid:!0}:{isValid:!1,message:`Option should be one of the following values: ${a(t)}.`}}function l(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function u(e){return typeof e==`object`&&!!e}})),pr=o(((e,t)=>{t.exports=function(e){return e.type===`rule`||e.type===`atrule`?e:e.parent?.type===`root`&&e.parent?.raws.isRuleLike||e.parent?.document?.nodes?.some(e=>e.type===`root`)?e.parent:e}})),mr=o(((e,t)=>{let n=dr();t.exports=function(e){let t={},r=0;return e.forEach(e=>{let i=e;if(r+=1,n(i)&&i!==`at-rules`&&i!==`rules`&&(t[i]={position:r}),i===`rules`||i.type===`rule`){i===`rules`&&(i={type:`rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.selector&&(e.selector=i.selector,n(i.selector)&&(e.selector=new RegExp(i.selector))),t[i.type].push(e)}if(i===`at-rules`||i.type===`at-rule`){i===`at-rules`&&(i={type:`at-rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.name&&(e.name=i.name),i.parameter&&(e.parameter=i.parameter,n(i.parameter)&&(e.parameter=new RegExp(i.parameter))),i.hasBlock!==void 0&&(e.hasBlock=i.hasBlock),t[i.type].push(e)}}),t}})),hr=o(((e,t)=>{let n=[`function`,`if`,`else`,`for`,`each`,`while`];t.exports=function(e,t){return!(e.type===`atrule`&&n.includes(e.name)||!e?.nodes?.length||!(t&&t.ignoreInterpolations)&&(e.raws.after?.includes("${")||e.nodes.some(e=>e.raws.before.includes("${"))))}})),gr=o(((e,t)=>{t.exports=function(e,t,n){return e.type===`comment`&&!e.hasOwnProperty(`position`)?(e.position=1/0,e.initialIndex=t,[...n,e]):n}})),_r=o(((e,t)=>{t.exports=function(e){return!(e[0]===`$`||e[0]===`@`||/#{.+?}|@{.+?}|\$\(.+?\)/.test(e))}})),vr=o(((e,t)=>{t.exports=function(e){return e.slice(0,2)===`--`}})),yr=o(((e,t)=>{t.exports=function(e){return e[0]===`$`}})),br=o(((e,t)=>{t.exports=function(e){return e.type===`atrule`&&e.variable}})),xr=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`hasBlock`)&&t.hasBlock===e.hasBlock&&(n+=10,n+=1e4),e.hasOwnProperty(`name`)&&t.name===e.name&&(n+=100,n+=1e4),e.hasOwnProperty(`parameter`)&&e.parameter.test(t.parameter)&&(n+=1100,n+=1e4),!e.hasOwnProperty(`hasBlock`)&&!e.hasOwnProperty(`name`)&&!e.hasOwnProperty(`paremeter`)&&(n=1),e.hasOwnProperty(`hasBlock`)&&e.hasOwnProperty(`name`)&&n<2e4&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&n<21100&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&e.hasOwnProperty(`hasBlock`)&&n<3e4&&(n=0),n}})),Sr=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`selector`)||(n=1),e.hasOwnProperty(`selector`)&&e.selector.test(t.selector)&&(n=2),n}})),Cr=o(((e,t)=>{let n=_r(),r=vr(),i=yr(),a=br(),o=xr(),s=Sr();t.exports=function(e,t){let c;if(a(t))c=`at-variables`;else if(t.type===`decl`)r(t.prop)?c=`custom-properties`:i(t.prop)?c=`dollar-variables`:n(t.prop)&&(c=`declarations`);else if(t.type===`rule`){c={type:`rule`,selector:t.selector};let n=e.rule;if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=s(n,c);r>t&&(t=r,e=n)}),t)return e}}else if(t.type===`atrule`){c={type:`at-rule`,name:t.name,hasBlock:!1},t.nodes&&t.nodes.length&&(c.hasBlock=!0),t.params&&t.params.length&&(c.parameter=t.params);let n=e[`at-rule`];if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=o(n,c);r>t&&(t=r,e=n)}),t)return e}}return e[c]?e[c]:null}})),wr=o(((e,t)=>{t.exports={beforeNode:n,afterNode:r,beforeDeclaration:i,afterDeclaration:a};function n(e,t,r,i){if(!t||t.type!==`comment`||!t.raws.before||!t.raws.before.includes(`
|
|
392
392
|
`)&&t.prev())return e;let a=i||r.initialIndex;return t.position=r.position,t.initialIndex=a-1e-4,n([t,...e],t.prev(),r,t.initialIndex)}function r(e,t,n,i){if(!t||t.type!==`comment`||!t.raws.before||t.raws.before.includes(`
|
|
393
393
|
`))return e;let a=i||n.initialIndex;return t.position=n.position,t.initialIndex=a+1e-4,r([...e,t],t.next(),n,t.initialIndex)}function i(e,t,n,r){if(!t||t.type!==`comment`||!t.raws.before||!t.raws.before.includes(`
|
|
394
394
|
`))return e;let a=r||n.initialIndex,o={orderData:n.orderData,node:t,unprefixedName:n.unprefixedName,unspecifiedPropertiesPosition:n.unspecifiedPropertiesPosition};return o.initialIndex=a-1e-4,i([o,...e],t.prev(),n,o.initialIndex)}function a(e,t,n,r){if(!t||t.type!==`comment`||!t.raws.before||t.raws.before.includes(`
|
|
@@ -423,14 +423,14 @@ this.clearWatchHistory = () => {
|
|
|
423
423
|
}`,else:`else {
|
|
424
424
|
\${1}
|
|
425
425
|
}`,"@Context":"@Context('${1:element}', ${2:this.elements[i]})"};var bi=class{languageService;id=0;isAutoComplete=!1;customTagsData=[];documentationInfo={};extenalDocumentation={};internalDocumentation={};internalDocumentationReverse={};internalTagUri={};_allowRebuildDefinition=!0;build;constructor(e){this.build=e,this.languageService=this.getHTMLLanguageService(),E.getInstance().onSettingsChangeHtml(()=>{this.languageService.setDataProviders(!0,[this.defaultProvider(),...this.loadOthersProviders()])})}getInternalDocumentation(){let e={};for(let t in this.internalDocumentation)try{e={...e,...this.internalDocumentation[t]}}catch{}return e}getClassByTag(e){let t=this.documentationInfo[e];return t?t.class:null}getGenericHTML(e){return vi[e]?vi[e]:null}getHTMLLanguageService(){return(0,C.getLanguageService)({useDefaultDataProvider:!0,customDataProviders:[this.defaultProvider(),...this.loadOthersProviders()]})}defaultProvider(){return{getId:this.getId.bind(this),isApplicable(e){return e==w.HTML},provideTags:this.provideTags.bind(this),provideAttributes:this.provideAttributes.bind(this),provideValues:this.provideValues.bind(this)}}loadOthersProviders(){let e=E.getInstance().settingsHtml,t=[];for(let n of e.customData){let e=(0,f.normalize)(O($.getWorkspaceUri()+`/`+n));if((0,u.existsSync)(e)){let r;try{let i=(0,u.readFileSync)(e,`utf8`);r=JSON.parse(i);let a=(0,C.newHTMLDataProvider)(n,{version:r.version||1,tags:r.tags||[],globalAttributes:r.globalAttributes||[],valueSets:r.valueSets||[]});t.push(a)}catch{}}}return t}getId(){return this.id+``}provideTags(){return this.customTagsData}provideAttributes(e){let t=[];if(e==`block`){let e={name:`name`,values:[]},n=this.currentFile?.slotsInfo??{};for(let t in n)e.values?.push({name:t,description:n[t].doc});t.push(e)}else if(t=[..._i],this.documentationInfo[e]){let n=this.documentationInfo[e].attributes;for(let e in n){let r=n[e];this.isAutoComplete?t.push({name:`!!`+r.name,description:JSON.stringify({description:r.description,type:r.type})}):t.push({name:r.name,description:r.description})}}return t}provideValues(e,t){if(e==`block`&&t==`name`){let e=[],t=this.currentFile?.slotsInfo??{};for(let n in t)e.push({name:n,description:t[n].doc});return e}if(t==`slot`&&this.currentFile&&this.currentFileOffset){let e=this.getTag(this.currentFile,this.currentFileOffset);if(e?.parent){let t=this.currentFile.build.getWebComponentDefinition(e.parent.tagName);if(t?.class){let e=this.currentFile.build.getSlotsInfo(t?.class),n=[];for(let t in e)n.push({name:t,description:e[t].doc});return n}}}return this.documentationInfo[e]&&this.documentationInfo[e].attributes[t]?this.documentationInfo[e].attributes[t].values:[]}currentFile=void 0;currentFileOffset=void 0;async doValidation(e){return[]}async doComplete(e,t){this.currentFile=e,this.currentFileOffset=e.file.documentUser.offsetAt(t);let n=this.languageService.parseHTMLDocument(e.file.documentUser);if(n){this.isAutoComplete=!0;let r=this.languageService.doComplete(e.file.documentUser,t,n);this.isAutoComplete=!1;for(let e of r.items){if(e.label.startsWith(`!!`)&&(e.kind=m.CompletionItemKind.Snippet,e.textEdit)){let t=e.label.replace(`!!`,``);if(e.textEdit.newText=e.textEdit.newText.replace(e.label,t),e.documentation){let t=JSON.parse(e.documentation.value);t.description==``?delete e.documentation:e.documentation=t.description,t.type==`boolean`&&(e.textEdit.newText=e.textEdit.newText.split(`=`)[0])}e.label=t}e.kind==m.CompletionItemKind.Property&&e.textEdit&&(e.textEdit.newText.endsWith(`>`)||(e.textEdit.newText+=`></`+e.textEdit.newText+`>`))}return r.items=r.items.concat(this.doCustomComplete(e,t)),this.currentFile=void 0,this.currentFileOffset=void 0,r}return this.currentFile=void 0,this.currentFileOffset=void 0,{isIncomplete:!1,items:[]}}doCustomComplete(e,t){let n=[];if(!e.fileParsed)return n;let r=e.file.documentUser,i=r.offsetAt(t);for(let t of e.fileParsed.tags){if(i<t.start)break;if(i>=t.openTagStart&&i<=t.openTagEnd)return n}let a=Re(r,Ue(r.getText(),i)),o=r.getText().slice(r.offsetAt(a.start),r.offsetAt(a.end));for(let e in yi)e.startsWith(o)&&n.push({label:e,kind:m.CompletionItemKind.Snippet,insertText:yi[e],insertTextFormat:C.InsertTextFormat.Snippet,insertTextMode:C.InsertTextMode.adjustIndentation});return n}getTag(e,t){if(!e.fileParsed)return null;for(let n of e.fileParsed.tags){if(t<n.start)break;if(t>=n.openTagStart&&t<=n.openTagEnd)return n}return null}async doHover(e,t){this.currentFile=e;let n=this.getLinkToLogic(e,t);if(n)return this.currentFile=void 0,{contents:{kind:`markdown`,value:n.documentation?.definitions.join(`
|
|
426
|
-
`)??``}};{let n=this.languageService.parseHTMLDocument(e.file.documentUser);if(n)return this.currentFile=void 0,this.languageService.doHover(e.file.documentUser,t,n)}return this.currentFile=void 0,null}async format(e,t,n){return this.languageService.format(e,t,n)}async onDefinition(e,t){this.currentFile=e;let n=this.getLinkToLogic(e,t);if(n instanceof rn||n instanceof on){let t=e.build.tsFiles[n._class.fileUri];return this.currentFile=void 0,[{uri:t.file.uri,range:{start:t.file.documentUser.positionAt(n.nameStart),end:t.file.documentUser.positionAt(n.nameEnd)}}]}else if(n instanceof un)return this.currentFile=void 0,[{uri:n.document.uri,range:{start:n.document.positionAt(n.nameStart),end:n.document.positionAt(n.nameEnd)}}];else return this.currentFile=void 0,this.build.htmlLanguageService.getLinkToStyle(e,t)}getLinkToLogic(e,t){let n=e.file.documentUser.offsetAt(t),r=e.tsFile,i=r?.fileParsed?.classes[r.getComponentName()];if(r&&i&&e.fileParsed){for(let t of e.fileParsed.interestPoints)if(n>=t.start&&n<=t.end){let r=null;if(t.type==`event`){let r=this.getTag(e,n);if(r){let n=e.build.getWebComponentDefinition(r.tagName);if(n){let e=n.class.getEvent(t.name);if(e)return e}}}if(t.type==`method`)r=i.methods[t.name];else if(t.type==`property`)r=i.properties[t.name];else if(t.type==`tag`){let n=this.documentationInfo[t.name];if(n){let t=this.internalDocumentationReverse[n.class];if(t&&t.fileParsed){for(let e in t.fileParsed.classes)if(e==n.class)return t.fileParsed.classes[e]}let r=e.build.getWebComponentDefinition(n.name,!0);if(r)return r.class}}return r}else if(t.end>=n)return null}return null}getLinkToStyle(e,t){let n=[],r=e.file.documentUser.offsetAt(t),i=e.scssFile;if(i&&e.fileParsed)for(let t of e.fileParsed.styleLinks){let e=t[0];r>=e.start&&r<=e.end&&n.push({uri:i.file.uri,range:{start:i.file.documentUser.positionAt(t[1].start),end:i.file.documentUser.positionAt(t[1].end)}})}return n}allowRebuildDefinition(e){this._allowRebuildDefinition=e,this.rebuildDefinition()}rebuildDefinition(){if(!this._allowRebuildDefinition)return;this.documentationInfo={};for(let e in this.extenalDocumentation){let t=this.extenalDocumentation[e];this.documentationInfo={...this.documentationInfo,...t}}for(let e in this.internalDocumentation){let t=this.internalDocumentation[e];try{this.documentationInfo={...this.documentationInfo,...t}}catch{}}this.customTagsData=[{name:`block`,attributes:[{name:`name`}]}];let e=[];for(let t in this.documentationInfo){let n=this.documentationInfo[t];if(e.indexOf(n.name)==-1){e.push(n.name);let t=[],r={name:n.name,description:n.description,attributes:t};for(let e in n.attributes){let r=n.attributes[e];t.push({name:r.name,description:r.description,values:r.values})}this.customTagsData.push(r)}}}addExternalDefinition(e,t){this.extenalDocumentation[e]=t,this.rebuildDefinition()}removeExternalDefinition(e){delete this.extenalDocumentation[e],this.rebuildDefinition()}getInternalDefinition(e){let t=this.documentationInfo[e];if(t)return this.internalDocumentationReverse[t.class]}addInternalDefinition(e,t,n){this.internalDocumentation[e]=t;for(let e in t)this.internalDocumentationReverse[t[e].class]=n;this.rebuildDefinition()}removeInternalDefinition(e){let t=this.internalDocumentation[e];if(t)for(let e in t)delete this.internalDocumentationReverse[t[e].class];delete this.internalDocumentation[e],this.rebuildDefinition()}getInternalTagUri(e){return this.internalTagUri[e]}addInternalTagUri(e,t,n){this.internalTagUri[e]={uri:t,fullname:n}}removeInternalTagUri(e){for(let t in this.internalTagUri)if(this.internalTagUri[t].uri==e){delete this.internalTagUri[t];return}}};function xi(e){let t=``,n=[],r=r=>{for(let i of r){let r=wn.compileTs(i,e);e.build.addNamespace(i.namespace),n.push(r),t+=r.debugTxt}};e.fileParsed&&(r(Object.values(e.fileParsed.classes)),r(Object.values(e.fileParsed.enums)),r(Object.values(e.fileParsed.aliases)),r(Object.values(e.fileParsed.functions)),r(Object.values(e.fileParsed.variables)));let i=e.file.path.replace(`.avt`,`.js`);return t==``?(0,u.existsSync)(i)&&(0,u.unlinkSync)(i):(0,u.writeFileSync)(i,t),n}var Si=class extends hn{get extension(){return T.Data}constructor(e,t){super(e,t),this.refreshFileParsed()}async onValidate(){let e=this.file.documentUser;this.diagnostics=this.tsLanguageService.doValidation(this.file),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.build.isCoreBuild?this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`IData`]}):this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`Aventus.IData`],customClassRules:[e=>{!e.isInterface&&e.convertibleName&&(e.hasStaticField(e.convertibleName)||this.diagnostics.push(k(this.file.documentUser,`Missing static property ${e.convertibleName}`,e.nameStart,e.nameEnd,1022)))}]});let t=this.fileParsed;if(t)for(let n in t.classes){let r=t.classes[n];if(!r.isInterface){for(let t in r.properties){let n=r.properties[t];!n.isAbstract&&n.isGetSet&&!n.overrideNullable&&n.defaultValue===null&&this.diagnostics.push(k(e,`Property '${n.name}' has no initializer and is not definitely assigned.`,n.nameStart,n.nameEnd,1013))}let t=r,n=!1;for(;t!=null;){if(t.propertiesStatic.Fullname!=null){n=!0;break}t=t.parentClass}n||this.diagnostics.push(k(e,`Missing static property Fullname`,r.nameStart,r.nameEnd,1022))}}return this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return await this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Ci=class extends hn{get extension(){return T.Definition}constructor(e,t){super(e,t),this._contentForLanguageService=this.file.contentUser}async onContentChange(){this._contentForLanguageService=this.file.contentUser}async onValidate(){return[]}async onSave(){}async onCompletion(e,t){return this.build.tsLanguageService.doComplete(e,t)}async onCompletionResolve(e,t){return t}async onHover(e,t){return null}async onDefinition(e,t){return null}async onFormatting(e,t,n){return this.build.tsLanguageService.format(e,t,n)}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return this.build.tsLanguageService.onRename(e,t,n)}},wi=class extends hn{get extension(){return T.Lib}constructor(e,t){super(e,t),this.refreshFileParsed()}async onValidate(){return this.diagnostics=this.tsLanguageService.doValidation(this.file),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.validateRules({allow_variables:!0,allow_function:!0,customClassRules:[e=>{!e.isInterface&&e.convertibleName&&(e.hasStaticField(e.convertibleName)||this.diagnostics.push(k(this.file.documentUser,`Missing static property ${e.convertibleName}`,e.nameStart,e.nameEnd,1022)))}]}),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}onFormatting(e,t,n){return this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Ti=class extends hn{get extension(){return T.RAM}constructor(e,t){super(e,t),this.refreshFileParsed()}async onValidate(){return this.diagnostics=this.tsLanguageService.doValidation(this.file),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.build.isCoreBuild?this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`IRam`]}):this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`Aventus.IRam`]}),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}onFormatting(e,t,n){return this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Ei=class extends hn{get extension(){return T.State}constructor(e,t){super(e,t),this.refreshFileParsed()}async onValidate(){return this.file.documentUser,this.diagnostics=this.tsLanguageService.doValidation(this.file),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.build.isCoreBuild?this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`IStateManager`,`IState`]}):this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`Aventus.IStateManager`,`Aventus.IState`]}),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return await this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Di=class extends hn{get extension(){return T.Static}mustBeAddedToLanguageService(){return!1}async onValidate(){return[]}async onContentChange(){}async onSave(){let e=this.file.path,t=e.replace(this.extension,T.Definition),n=``,r=``;t.endsWith(T.Definition)&&(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`).replace(/declare global \{((\s|\S)*)\}/gm,`$1`));let i=e.replace(this.extension,T.DefinitionNpm);r=i.endsWith(T.DefinitionNpm)&&(0,u.existsSync)(i)?(0,u.readFileSync)(i,`utf8`):n;let a=Je(e+this.file.contentUser),o=this.file.path.replace(this.build.project.getConfigFile().path.replace(T.Config,``),``);o=o.replace(this.extension,`.js`),this.setCompileResult([{classDoc:``,classScript:`!staticClass_`+a,compiled:this.file.contentUser,hotReload:``,docVisible:n,npm:{namespace:``,defTs:r,src:this.file.contentUser,exportPath:o,uri:this.file.uri},docInvisible:``,debugTxt:``,dependencies:[],uri:this.file.uri,required:!0,type:0,isExported:{external:!1,internal:!1},convertibleName:``}])}async onCompletion(e,t){return{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return null}async onDefinition(e,t){return null}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}};function Oi(e,t){let n=null;return e.uri.endsWith(T.ComponentLogic)?n=new F(e,t):e.uri.endsWith(T.Data)?n=new Si(e,t):e.uri.endsWith(T.Lib)?n=new wi(e,t):e.uri.endsWith(T.RAM)?n=new Ti(e,t):e.uri.endsWith(T.State)?n=new Ei(e,t):e.uri.endsWith(T.Static)?n=new Di(e,t):e.uri.endsWith(T.Definition)&&(n=new Ci(e,t)),n}var ki=class{static send(e,t){$.sendNotification(`aventus/compiled`,e,t)}static part(e){$.sendNotification(`aventus/compiled/part`,e)}},Ai=class{static send(e,t){$.sendNotification(`aventus/registerBuild`,{pathConfig:e,buildName:t})}},ji=class{static send(e,t){$.sendNotification(`aventus/unregisterBuild`,{pathConfig:e,buildName:t})}},Mi=o(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r(require("child_process"),require("crypto")):typeof define==`function`&&define.amd?define([`child_process`,`crypto`],r):typeof e==`object`?e["electron-machine-id"]=r(require("child_process"),require("crypto")):n[`electron-machine-id`]=r(n.child_process,n.crypto)})(e,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=``,t(0)}([function(e,t,n){e.exports=n(34)},function(e,t,n){var r=n(29)(`wks`),i=n(33),a=n(2).Symbol,o=typeof a==`function`,s=e.exports=function(e){return r[e]||(r[e]=o&&a[e]||(o?a:i)(`Symbol.`+e))};s.store=r},function(e,t){var n=e.exports=typeof window<`u`&&window.Math==Math?window:typeof self<`u`&&self.Math==Math?self:Function(`return this`)();typeof __g==`number`&&(__g=n)},function(e,t,n){var r=n(9);e.exports=function(e){if(!r(e))throw TypeError(e+` is not an object!`);return e}},function(e,t,n){e.exports=!n(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(e,t,n){var r=n(12),i=n(17);e.exports=n(4)?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t){var n=e.exports={version:`2.4.0`};typeof __e==`number`&&(__e=n)},function(e,t,n){var r=n(14);e.exports=function(e,t,n){if(r(e),t===void 0)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t){e.exports=function(e){return typeof e==`object`?e!==null:typeof e==`function`}},function(e,t){e.exports={}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var r=n(3),i=n(26),a=n(32),o=Object.defineProperty;t.f=n(4)?Object.defineProperty:function(e,t,n){if(r(e),t=a(t,!0),r(n),i)try{return o(e,t,n)}catch{}if(`get`in n||`set`in n)throw TypeError(`Accessors not supported!`);return`value`in n&&(e[t]=n.value),e}},function(e,t,n){var r=n(42),i=n(15);e.exports=function(e){return r(i(e))}},function(e,t){e.exports=function(e){if(typeof e!=`function`)throw TypeError(e+` is not a function!`);return e}},function(e,t){e.exports=function(e){if(e==null)throw TypeError(`Can't call method on `+e);return e}},function(e,t,n){var r=n(9),i=n(2).document,a=r(i)&&r(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){var r=n(12).f,i=n(8),a=n(1)(`toStringTag`);e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,a)&&r(e,a,{configurable:!0,value:t})}},function(e,t,n){var r=n(29)(`keys`),i=n(33);e.exports=function(e){return r[e]||(r[e]=i(e))}},function(e,t){var n=Math.ceil,r=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?r:n)(e)}},function(e,t,n){var r=n(11),i=n(1)(`toStringTag`),a=r(function(){return arguments}())==`Arguments`,o=function(e,t){try{return e[t]}catch{}};e.exports=function(e){var t,n,s;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=o(t=Object(e),i))==`string`?n:a?r(t):(s=r(t))==`Object`&&typeof t.callee==`function`?`Arguments`:s}},function(e,t){e.exports=`constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf`.split(`,`)},function(e,t,n){var r=n(2),i=n(6),a=n(7),o=n(5),s=`prototype`,c=function(e,t,n){var l,u,d,f=e&c.F,p=e&c.G,m=e&c.S,h=e&c.P,g=e&c.B,_=e&c.W,v=p?i:i[t]||(i[t]={}),y=v[s],b=p?r:m?r[t]:(r[t]||{})[s];for(l in p&&(n=t),n)u=!f&&b&&b[l]!==void 0,u&&l in v||(d=u?b[l]:n[l],v[l]=p&&typeof b[l]!=`function`?n[l]:g&&u?a(d,r):_&&b[l]==d?function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t[s]=e[s],t}(d):h&&typeof d==`function`?a(Function.call,d):d,h&&((v.virtual||={})[l]=d,e&c.R&&y&&!y[l]&&o(y,l,d)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,e.exports=c},function(e,t){e.exports=function(e){try{return!!e()}catch{return!0}}},function(e,t,n){e.exports=n(2).document&&document.documentElement},function(e,t,n){e.exports=!n(4)&&!n(24)(function(){return Object.defineProperty(n(16)(`div`),"a",{get:function(){return 7}}).a!=7})},function(e,t,n){"use strict";var r=n(28),i=n(23),a=n(57),o=n(5),s=n(8),c=n(10),l=n(45),u=n(18),d=n(52),f=n(1)(`iterator`),p=!([].keys&&`next`in[].keys()),m=`@@iterator`,h=`keys`,g=`values`,_=function(){return this};e.exports=function(e,t,n,v,y,b,x){l(n,t,v);var ee,te,S,ne=function(e){if(!p&&e in oe)return oe[e];switch(e){case h:return function(){return new n(this,e)};case g:return function(){return new n(this,e)}}return function(){return new n(this,e)}},re=t+` Iterator`,ie=y==g,ae=!1,oe=e.prototype,C=oe[f]||oe[m]||y&&oe[y],se=C||ne(y),ce=y?ie?ne(`entries`):se:void 0,le=t==`Array`&&oe.entries||C;if(le&&(S=d(le.call(new e)),S!==Object.prototype&&(u(S,re,!0),r||s(S,f)||o(S,f,_))),ie&&C&&C.name!==g&&(ae=!0,se=function(){return C.call(this)}),r&&!x||!p&&!ae&&oe[f]||o(oe,f,se),c[t]=se,c[re]=_,y)if(ee={values:ie?se:ne(g),keys:b?se:ne(h),entries:ce},x)for(te in ee)te in oe||a(oe,te,ee[te]);else i(i.P+i.F*(p||ae),t,ee);return ee}},function(e,t){e.exports=!0},function(e,t,n){var r=n(2),i=`__core-js_shared__`,a=r[i]||(r[i]={});e.exports=function(e){return a[e]||(a[e]={})}},function(e,t,n){var r,i,a,o=n(7),s=n(41),c=n(25),l=n(16),u=n(2),d=u.process,f=u.setImmediate,p=u.clearImmediate,m=u.MessageChannel,h=0,g={},_=`onreadystatechange`,v=function(){var e=+this;if(g.hasOwnProperty(e)){var t=g[e];delete g[e],t()}},y=function(e){v.call(e.data)};f&&p||(f=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return g[++h]=function(){s(typeof e==`function`?e:Function(e),t)},r(h),h},p=function(e){delete g[e]},n(11)(d)==`process`?r=function(e){d.nextTick(o(v,e,1))}:m?(i=new m,a=i.port2,i.port1.onmessage=y,r=o(a.postMessage,a,1)):u.addEventListener&&typeof postMessage==`function`&&!u.importScripts?(r=function(e){u.postMessage(e+``,`*`)},u.addEventListener(`message`,y,!1)):r=_ in l(`script`)?function(e){c.appendChild(l(`script`))[_]=function(){c.removeChild(this),v.call(e)}}:function(e){setTimeout(o(v,e,1),0)}),e.exports={set:f,clear:p}},function(e,t,n){var r=n(20),i=Math.min;e.exports=function(e){return e>0?i(r(e),9007199254740991):0}},function(e,t,n){var r=n(9);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&typeof(n=e.toString)==`function`&&!r(i=n.call(e))||typeof(n=e.valueOf)==`function`&&!r(i=n.call(e))||!t&&typeof(n=e.toString)==`function`&&!r(i=n.call(e)))return i;throw TypeError(`Can't convert object to primitive value`)}},function(e,t){var n=0,r=Math.random();e.exports=function(e){return`Symbol(${e===void 0?``:e})_${(++n+r).toString(36)}`}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(){return process.platform===`win32`?process.arch===`ia32`&&process.env.hasOwnProperty(`PROCESSOR_ARCHITEW6432`)?`mixed`:`native`:``}function a(e){return(0,d.createHash)(`sha256`).update(e).digest(`hex`)}function o(e){switch(f){case`darwin`:return e.split(`IOPlatformUUID`)[1].split(`
|
|
427
|
-
`)[0].replace(/\=|\s+|\"/gi,``).toLowerCase();case`win32`:return e.toString().split(`REG_SZ`)[1].replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`linux`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`freebsd`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();default:throw Error(`Unsupported platform: `+process.platform)}}function s(e){var t=o((0,u.execSync)(p[f]).toString());return e?t:a(t)}function c(e){return new l.default(function(t,n){return(0,u.exec)(p[f],{},function(r,i,s){if(r)return n(Error(`Error while obtaining machine id: `+r.stack));var c=o(i.toString());return t(e?c:a(c))})})}Object.defineProperty(t,"__esModule",{value:!0});var l=r(n(35));t.machineIdSync=s,t.machineId=c;var u=n(70),d=n(71),f=process.platform,p={darwin:`ioreg -rd1 -c IOPlatformExpertDevice`,win32:{native:`%windir%\\System32`,mixed:`%windir%\\sysnative\\cmd.exe /c %windir%\\System32`}[i()]+`\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`,linux:`( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :`,freebsd:`kenv -q smbios.system.uuid || sysctl -n kern.hostuuid`}},function(e,t,n){e.exports={default:n(36),__esModule:!0}},function(e,t,n){n(66),n(68),n(69),n(67),e.exports=n(6).Promise},function(e,t){e.exports=function(){}},function(e,t){e.exports=function(e,t,n,r){if(!(e instanceof t)||r!==void 0&&r in e)throw TypeError(n+`: incorrect invocation!`);return e}},function(e,t,n){var r=n(13),i=n(31),a=n(62);e.exports=function(e){return function(t,n,o){var s,c=r(t),l=i(c.length),u=a(o,l);if(e&&n!=n){for(;l>u;)if(s=c[u++],s!=s)return!0}else for(;l>u;u++)if((e||u in c)&&c[u]===n)return e||u||0;return!e&&-1}}},function(e,t,n){var r=n(7),i=n(44),a=n(43),o=n(3),s=n(31),c=n(64),l={},u={},t=e.exports=function(e,t,n,d,f){var p,m,h,g,_=f?function(){return e}:c(e),v=r(n,d,t?2:1),y=0;if(typeof _!=`function`)throw TypeError(e+` is not iterable!`);if(a(_)){for(p=s(e.length);p>y;y++)if(g=t?v(o(m=e[y])[0],m[1]):v(e[y]),g===l||g===u)return g}else for(h=_.call(e);!(m=h.next()).done;)if(g=i(h,v,m.value,t),g===l||g===u)return g};t.BREAK=l,t.RETURN=u},function(e,t){e.exports=function(e,t,n){var r=n===void 0;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}return e.apply(n,t)}},function(e,t,n){var r=n(11);e.exports=Object(`z`).propertyIsEnumerable(0)?Object:function(e){return r(e)==`String`?e.split(``):Object(e)}},function(e,t,n){var r=n(10),i=n(1)(`iterator`),a=Array.prototype;e.exports=function(e){return e!==void 0&&(r.Array===e||a[i]===e)}},function(e,t,n){var r=n(3);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var a=e.return;throw a!==void 0&&r(a.call(e)),t}}},function(e,t,n){"use strict";var r=n(49),i=n(17),a=n(18),o={};n(5)(o,n(1)(`iterator`),function(){return this}),e.exports=function(e,t,n){e.prototype=r(o,{next:i(1,n)}),a(e,t+` Iterator`)}},function(e,t,n){var r=n(1)(`iterator`),i=!1;try{var a=[7][r]();a.return=function(){i=!0},Array.from(a,function(){throw 2})}catch{}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var a=[7],o=a[r]();o.next=function(){return{done:n=!0}},a[r]=function(){return o},e(a)}catch{}return n}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){var r=n(2),i=n(30).set,a=r.MutationObserver||r.WebKitMutationObserver,o=r.process,s=r.Promise,c=n(11)(o)==`process`;e.exports=function(){var e,t,n,l=function(){var r,i;for(c&&(r=o.domain)&&r.exit();e;){i=e.fn,e=e.next;try{i()}catch(r){throw e?n():t=void 0,r}}t=void 0,r&&r.enter()};if(c)n=function(){o.nextTick(l)};else if(a){var u=!0,d=document.createTextNode(``);new a(l).observe(d,{characterData:!0}),n=function(){d.data=u=!u}}else if(s&&s.resolve){var f=s.resolve();n=function(){f.then(l)}}else n=function(){i.call(r,l)};return function(r){var i={fn:r,next:void 0};t&&(t.next=i),e||(e=i,n()),t=i}}},function(e,t,n){var r=n(3),i=n(50),a=n(22),o=n(19)(`IE_PROTO`),s=function(){},c=`prototype`,l=function(){var e,t=n(16)(`iframe`),r=a.length,i=`>`;for(t.style.display=`none`,n(25).appendChild(t),t.src=`javascript:`,e=t.contentWindow.document,e.open(),e.write(`<script>document.F=Object<\/script`+i),e.close(),l=e.F;r--;)delete l[c][a[r]];return l()};e.exports=Object.create||function(e,t){var n;return e===null?n=l():(s[c]=r(e),n=new s,s[c]=null,n[o]=e),t===void 0?n:i(n,t)}},function(e,t,n){var r=n(12),i=n(3),a=n(54);e.exports=n(4)?Object.defineProperties:function(e,t){i(e);for(var n,o=a(t),s=o.length,c=0;s>c;)r.f(e,n=o[c++],t[n]);return e}},function(e,t,n){var r=n(55),i=n(17),a=n(13),o=n(32),s=n(8),c=n(26),l=Object.getOwnPropertyDescriptor;t.f=n(4)?l:function(e,t){if(e=a(e),t=o(t,!0),c)try{return l(e,t)}catch{}if(s(e,t))return i(!r.f.call(e,t),e[t])}},function(e,t,n){var r=n(8),i=n(63),a=n(19)(`IE_PROTO`),o=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=i(e),r(e,a)?e[a]:typeof e.constructor==`function`&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?o:null}},function(e,t,n){var r=n(8),i=n(13),a=n(39)(!1),o=n(19)(`IE_PROTO`);e.exports=function(e,t){var n,s=i(e),c=0,l=[];for(n in s)n!=o&&r(s,n)&&l.push(n);for(;t.length>c;)r(s,n=t[c++])&&(~a(l,n)||l.push(n));return l}},function(e,t,n){var r=n(53),i=n(22);e.exports=Object.keys||function(e){return r(e,i)}},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){var r=n(5);e.exports=function(e,t,n){for(var i in t)n&&e[i]?e[i]=t[i]:r(e,i,t[i]);return e}},function(e,t,n){e.exports=n(5)},function(e,t,n){var r=n(9),i=n(3),a=function(e,t){if(i(e),!r(t)&&t!==null)throw TypeError(t+`: can't set as prototype!`)};e.exports={set:Object.setPrototypeOf||(`__proto__`in{}?function(e,t,r){try{r=n(7)(Function.call,n(51).f(Object.prototype,`__proto__`).set,2),r(e,[]),t=!(e instanceof Array)}catch{t=!0}return function(e,n){return a(e,n),t?e.__proto__=n:r(e,n),e}}({},!1):void 0),check:a}},function(e,t,n){"use strict";var r=n(2),i=n(6),a=n(12),o=n(4),s=n(1)(`species`);e.exports=function(e){var t=typeof i[e]==`function`?i[e]:r[e];o&&t&&!t[s]&&a.f(t,s,{configurable:!0,get:function(){return this}})}},function(e,t,n){var r=n(3),i=n(14),a=n(1)(`species`);e.exports=function(e,t){var n,o=r(e).constructor;return o===void 0||(n=r(o)[a])==null?t:i(n)}},function(e,t,n){var r=n(20),i=n(15);e.exports=function(e){return function(t,n){var a,o,s=String(i(t)),c=r(n),l=s.length;return c<0||c>=l?e?``:void 0:(a=s.charCodeAt(c),a<55296||a>56319||c+1===l||(o=s.charCodeAt(c+1))<56320||o>57343?e?s.charAt(c):a:e?s.slice(c,c+2):(a-55296<<10)+(o-56320)+65536)}}},function(e,t,n){var r=n(20),i=Math.max,a=Math.min;e.exports=function(e,t){return e=r(e),e<0?i(e+t,0):a(e,t)}},function(e,t,n){var r=n(15);e.exports=function(e){return Object(r(e))}},function(e,t,n){var r=n(21),i=n(1)(`iterator`),a=n(10);e.exports=n(6).getIteratorMethod=function(e){if(e!=null)return e[i]||e[`@@iterator`]||a[r(e)]}},function(e,t,n){"use strict";var r=n(37),i=n(47),a=n(10),o=n(13);e.exports=n(27)(Array,`Array`,function(e,t){this._t=o(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,i(1)):t==`keys`?i(0,n):t==`values`?i(0,e[n]):i(0,[n,e[n]])},`values`),a.Arguments=a.Array,r(`keys`),r(`values`),r(`entries`)},function(e,t){},function(e,t,n){"use strict";var r,i,a,o=n(28),s=n(2),c=n(7),l=n(21),u=n(23),d=n(9),f=(n(3),n(14)),p=n(38),m=n(40),h=(n(58).set,n(60)),g=n(30).set,_=n(48)(),v=`Promise`,y=s.TypeError,b=s.process,x=s[v],b=s.process,ee=l(b)==`process`,te=function(){},S=!!function(){try{var e=x.resolve(1),t=(e.constructor={})[n(1)(`species`)]=function(e){e(te,te)};return(ee||typeof PromiseRejectionEvent==`function`)&&e.then(te)instanceof t}catch{}}(),ne=function(e,t){return e===t||e===x&&t===a},re=function(e){var t;return!(!d(e)||typeof(t=e.then)!=`function`)&&t},ie=function(e){return ne(x,e)?new ae(e):new i(e)},ae=i=function(e){var t,n;this.promise=new e(function(e,r){if(t!==void 0||n!==void 0)throw y(`Bad Promise constructor`);t=e,n=r}),this.resolve=f(t),this.reject=f(n)},oe=function(e){try{e()}catch(e){return{error:e}}},C=function(e,t){if(!e._n){e._n=!0;var n=e._c;_(function(){for(var r=e._v,i=e._s==1,a=0,o=function(t){var n,a,o=i?t.ok:t.fail,s=t.resolve,c=t.reject,l=t.domain;try{o?(i||(e._h==2&&le(e),e._h=1),o===!0?n=r:(l&&l.enter(),n=o(r),l&&l.exit()),n===t.promise?c(y(`Promise-chain cycle`)):(a=re(n))?a.call(n,s,c):s(n)):c(r)}catch(e){c(e)}};n.length>a;)o(n[a++]);e._c=[],e._n=!1,t&&!e._h&&se(e)})}},se=function(e){g.call(s,function(){var t,n,r,i=e._v;if(ce(e)&&(t=oe(function(){ee?b.emit(`unhandledRejection`,i,e):(n=s.onunhandledrejection)?n({promise:e,reason:i}):(r=s.console)&&r.error&&r.error(`Unhandled promise rejection`,i)}),e._h=ee||ce(e)?2:1),e._a=void 0,t)throw t.error})},ce=function(e){if(e._h==1)return!1;for(var t,n=e._a||e._c,r=0;n.length>r;)if(t=n[r++],t.fail||!ce(t.promise))return!1;return!0},le=function(e){g.call(s,function(){var t;ee?b.emit(`rejectionHandled`,e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},ue=function(e){var t=this;t._d||(t._d=!0,t=t._w||t,t._v=e,t._s=2,t._a||=t._c.slice(),C(t,!0))},de=function(e){var t,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===e)throw y(`Promise can't be resolved itself`);(t=re(e))?_(function(){var r={_w:n,_d:!1};try{t.call(e,c(de,r,1),c(ue,r,1))}catch(e){ue.call(r,e)}}):(n._v=e,n._s=1,C(n,!1))}catch(e){ue.call({_w:n,_d:!1},e)}}};S||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(de,this,1),c(ue,this,1))}catch(e){ue.call(this,e)}},r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},r.prototype=n(56)(x.prototype,{then:function(e,t){var n=ie(h(this,x));return n.ok=typeof e!=`function`||e,n.fail=typeof t==`function`&&t,n.domain=ee?b.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&C(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),ae=function(){var e=new r;this.promise=e,this.resolve=c(de,e,1),this.reject=c(ue,e,1)}),u(u.G+u.W+u.F*!S,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!S,v,{reject:function(e){var t=ie(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!S),v,{resolve:function(e){if(e instanceof x&&ne(e.constructor,this))return e;var t=ie(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(S&&n(46)(function(e){x.all(e).catch(te)})),v,{all:function(e){var t=this,n=ie(t),r=n.resolve,i=n.reject,a=oe(function(){var n=[],a=0,o=1;m(e,!1,function(e){var s=a++,c=!1;n.push(void 0),o++,t.resolve(e).then(function(e){c||(c=!0,n[s]=e,--o||r(n))},i)}),--o||r(n)});return a&&i(a.error),n.promise},race:function(e){var t=this,n=ie(t),r=n.reject,i=oe(function(){m(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i&&r(i.error),n.promise}})},function(e,t,n){"use strict";var r=n(61)(!0);n(27)(String,`String`,function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,n=this._i;return n>=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){n(65);for(var r=n(2),i=n(5),a=n(10),o=n(1)(`toStringTag`),s=[`NodeList`,`DOMTokenList`,`MediaList`,`StyleSheetList`,`CSSRuleList`],c=0;c<5;c++){var l=s[c],u=r[l],d=u&&u.prototype;d&&!d[o]&&i(d,o,l),a[l]=a.Array}},function(e,t){e.exports=require("child_process")},function(e,t){e.exports=require("crypto")}])})}))(),Ni=class e{static url=`https://store.aventusjs.com`;static _settings;static get settings(){return this._settings||=E.getInstance().hiddenSettings.store,this._settings}static get token(){return this.settings.token}static get isConnected(){return this.token!=``}static setSettings(e){let t={...this.settings,...e};E.getInstance().setHiddenSettings({store:t}),this._settings=t}static async connect(e,t){let n=await(0,Mi.machineId)(),r=(0,x.hostname)(),i=await this.post(`/login`,{username:e,password:t,machineId:n,machineName:r},{withoutBearer:!0});return i?(this.setSettings({token:i,username:e}),!0):!1}static async disconnect(){await this.post(`/logout`),this.setSettings({token:``,username:void 0})}static async publishPackage(e){let t=new FormData;t.append(`name`,e.buildConfig.fullname),t.append(`description`,e.buildConfig.description??``),t.append(`version`,e.buildConfig.version),e.buildConfig.organization&&t.append(`organization`,e.buildConfig.organization),e.buildConfig.documentation&&t.append(`documentation`,e.buildConfig.documentation),e.buildConfig.repository&&t.append(`repository`,e.buildConfig.repository);for(let n of e.buildConfig.tags)t.append(`tags[]`,n);let n=(0,f.join)(Ri.getInstance().getPath(),`@locals`,e.buildConfig.fullname+T.Package);if(!(0,u.existsSync)(n))return!1;let r=new Blob([(0,u.readFileSync)(n)],{type:`text/plain`});t.append(`packageFile`,r,e.buildConfig.fullname+T.Package);let i=e.project.getConfigFile().folderPath;if(e.buildConfig.readme){let n;if(e.buildConfig.readme.startsWith(`.`)){let t=(0,f.normalize)((0,f.join)(i,e.buildConfig.readme));if((0,u.existsSync)(t))n=t;else return new Pi([{code:-1,message:`Readme not found`}])}else if((0,u.existsSync)(e.buildConfig.readme))n=e.buildConfig.readme;else{let t=(0,f.normalize)((0,f.join)(i,e.buildConfig.readme));if((0,u.existsSync)(t))n=t;else return new Pi([{code:-1,message:`Readme not found`}])}let r=new Blob([(0,u.readFileSync)((0,f.join)(i,n))],{type:`text/plain`});t.append(`readMe`,r,`README.md`)}else{let e=(0,u.readdirSync)(i).find(e=>e.toLowerCase()===`readme.md`);if(e){let n=new Blob([(0,u.readFileSync)((0,f.join)(i,e))],{type:`text/plain`});t.append(`readMe`,n,`README.md`)}}return await this.postWithErrors(`/package/publish`,t)}static async publishTemplate(e){let t=new FormData;t.append(`name`,e.name),t.append(`description`,e.description),t.append(`version`,e.version),t.append(`is_project`,e.isProject?`1`:`0`),t.append(`is_global`,e.isGlobal?`1`:`0`),e.organization&&t.append(`organization`,e.organization),e.documentation&&t.append(`documentation`,e.documentation),e.repository&&t.append(`repository`,e.repository);for(let n of e.tags)t.append(`tags[]`,n);let n=e.folderPath,r=(0,u.readdirSync)(n).find(e=>e.toLowerCase()===`readme.md`);if(r){let e=new Blob([(0,u.readFileSync)((0,f.join)(n,r))],{type:`text/plain`});t.append(`readMe`,e,`README.md`)}let i=(0,f.dirname)(e.config),a=(0,f.join)($.savePath,`temp`,e.name+`.zip`);await this.zip(i,a);let o=new Blob([(0,u.readFileSync)(a)],{type:`application/zip`});t.append(`templateFile`,o,e.name+`.zip`);let s=await this.postWithErrors(`/template/publish`,t);return(0,u.unlinkSync)(a),s}static async post(e,t={},n){let r=await this.postWithErrors(e,t,n);if(r instanceof Pi){for(let e of r.errors)$.error(e.message);return null}return r}static async postWithErrors(t,n={},r){let i=null;try{let a={};if(n instanceof FormData||(a[`Content-Type`]=`application/json`),!r?.withoutBearer){let e=await(0,Mi.machineId)();a.Authorization=`Bearer `+(this.token+`|`+e)}if(i=await fetch(e.url+`/api/remote`+t,{method:`POST`,body:n instanceof FormData?n:JSON.stringify(n),headers:a}),i.status==401)return new Pi([{code:401,message:`No token provided`}]);if(i.status==403)return t!=`/logout`&&this.disconnect(),new Pi([{code:403,message:`You must connect to your account first`}]);let o=await i.text(),s;try{s=JSON.parse(o)}catch(e){throw $.error(o),e}return s.errors?s.errors.length>0?new Pi(s.errors):s.result:new Pi([{code:-500,message:`Wrong response format from the api`}])}catch(e){return new Pi([{code:-500,message:e+``}])}}static zip(e,t){return new Promise(async(n,r)=>{let i=(0,u.createWriteStream)(t),a=(0,fe.create)(`zip`,{zlib:{level:9}});i.on(`close`,()=>{n()}),a.on(`error`,e=>{r(e)}),a.pipe(i),a.directory(e,!1,e=>e.name.startsWith(`.git/`)||e.name===`.git`?!1:e),await a.finalize()})}},Pi=class{errors;constructor(e){this.errors=e}},Fi=class e{fctTxt=null;static is(t){return t.name==`Attribute`?new e:null}},Ii=class{static files={};static done=!1;static register(e){this.files[e.file.uri]||(this.files[e.file.uri]=e,this.done&&this.write())}static write(e=!1){let t={html:{snippets:{block:'<block name="${1}">${2}</block>'}}},n=!1;for(let e in this.files){let r=this.files[e].srcInfo.available;for(let e of r)if(e.tagName){let r=e.tagName;t.html.snippets[r]=`<${r}>\${1}</${r}>`,n=!0}}if(n){let n=(0,f.join)(O($.getWorkspaceUri()),`.aventus`,`emmet`),r=(0,f.join)(n,`snippets.json`);if(!e&&!(0,u.existsSync)(r)){this.done=!0;return}(0,u.existsSync)(n)||(0,u.mkdirSync)(n,{recursive:!0}),qe(r,JSON.stringify(t,null,2),`manifest`),this.done=!0}}static getMarkdown(e){return this.files[e]?new Li(this.files[e]).getContent():``}},Li=class{file;content=[];overviews=[];parts=[];scss;constructor(e){this.file=e,this.scss=e.build.scssLanguageService.getExternalDefinition(this.file.file.uri)??{};let t=this.file.srcInfo.available;if(this.file.fileParsed)for(let e of t)e.type==1||e.type==2||e.type==3?this.loadClass(e):e.type==4&&this.loadFunction(e);this.overviews.length>0&&(this.writeOverview(),this.writeContent())}isManifestClass(e){return e.isWebComponent!==void 0}isManifestFunction(e){return e.result!==void 0}getType(e){e instanceof M||(e=new M(e));let t=e.getFullTxt().trim();return t.startsWith(`___`)&&(t=t.substring(3)),t=t.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\|/g,`|`),t}loadFunction(e){let t=this.file.fileParsed.functions[e.fullName],n=t.fullName;if(t.node.typeParameters){let e=[];for(let n of t.node.typeParameters){let t=n.name.getText();n.constraint&&(t+=` extends `+this.getType(n.constraint)),n.default&&(t+=` = `+this.getType(n.default)),e.push(t)}e.length>0&&(n+=`<${e.join(`, `)}>`)}let r=[];for(let e of t.node.parameters){let t=e.name.getText();e.type?t+=`: `+this.getType(e.type):t+=`: any`,r.push(t)}n+=`(${r.join(`, `)})`;let i={name:n,result:t.node.type?this.getType(t.node.type):`any`,description:t.documentation?.definitions.join(x.EOL)??``,isAbstract:!1};this.parts.push(i)}loadClass(e){let t=this.file.fileParsed.classes[e.fullName],n=t.fullName;if(t.node.typeParameters){let e=[];for(let n of t.node.typeParameters){let t=n.name.getText();n.constraint&&(t+=` extends `+this.getType(n.constraint)),n.default&&(t+=` = `+this.getType(n.default)),e.push(t)}e.length>0&&(n+=`<${e.join(`, `)}>`)}let r={name:n,isWebComponent:t.isWebcomponent,tag:e.tagName?`<${e.tagName}></${e.tagName}>`:void 0,type:t.isInterface?`Interface`:`Class`,description:t.documentation?.definitions.join(x.EOL)??``,import:`import { ${t.name} } from "${this.file.name}:${t.namespace}.package.avt"`,parent:t.parentClass?.fullName,impl:t.implementsType.map(e=>this.getType(e)).join(`, `)};if(Object.keys(t.properties).length>0){r.jsProps=[];for(let e in t.properties){let n=this.loadProperty(t.properties[e]);n&&r.jsProps.push(n)}}if(Object.keys(t.propertiesStatic).length>0){r.jsPropsStatic=[];for(let e in t.propertiesStatic){let n=this.loadProperty(t.propertiesStatic[e]);n&&r.jsPropsStatic.push(n)}}if(Object.keys(t.methods).length>0){r.jsMethods=[];for(let e in t.methods){let n=this.loadMethod(t.methods[e]);n&&r.jsMethods.push(n)}}if(Object.keys(t.methodsStatic).length>0){r.jsMethodsStatic=[];for(let e in t.methodsStatic){let n=this.loadMethod(t.methodsStatic[e]);n&&r.jsMethodsStatic.push(n)}}if(t.isWebcomponent){if(e.tagName&&this.scss[e.tagName]&&this.scss[e.tagName].length>0){let t=this.scss[e.tagName];r.cssProps=[];for(let e of t)r.cssProps.push({name:e.name,type:e.type??``,description:e.documentation??``})}if(e.slots&&Object.keys(e.slots).length>0){r.htmlSlots=[];for(let t in e.slots)r.htmlSlots.push({name:t,description:e.slots[t].doc})}}this.overviews.push({name:t.fullName,type:r.isWebComponent?r.type+` (Webcomponent)`:r.type,description:r.tag?r.description+` (`+r.tag+`)`:r.description}),this.parts.push(r)}loadProperty(e){if(e.isPrivate||e.isProtected)return null;let t;return e.decorators.find(e=>In.is(e))&&(t=`@Property()`),e.decorators.find(e=>Fi.is(e))&&(t=`@Attribute()`),e.decorators.find(e=>Hn.is(e))&&(t=`@Watch()`),e.decorators.find(e=>Jn.is(e))&&(t=`@Signal()`),{name:e.name,type:this.getType(e.type),description:e.documentation?.definitions.join(x.EOL)??``,decorator:t}}loadMethod(e){if(e.isPrivate||e.isProtected)return null;let t=e.name;if(e.node.typeParameters){let n=[];for(let t of e.node.typeParameters){let e=t.name.getText();t.constraint&&(e+=` extends `+this.getType(t.constraint)),t.default&&(e+=` = `+this.getType(t.default)),n.push(e)}n.length>0&&(t+=`<${n.join(`, `)}>`)}let n=[];for(let t of e.node.parameters){let e=t.name.getText();t.type?e+=`: `+this.getType(t.type):e+=`: any`,n.push(e)}return t+=`(${n.join(`, `)})`,{name:t,result:e.node.type?this.getType(e.node.type):`any`,description:e.documentation?.definitions.join(x.EOL)??``,isAbstract:e.isAbstract}}getContent(){return this.content.join(x.EOL)}writeOverview(){this.add(`# `+this.file.name),this.line(),this.file.description&&(this.add(this.file.description),this.line()),this.add(`## Overview`),this.line(),this.addColumnsHeader([`Nom`,`Type`,`Description`]),this.overviews.sort((e,t)=>e.name.localeCompare(t.name));for(let e of this.overviews)this.addColumns([`[${e.name}](${e.name.toLowerCase()})`,e.type,e.description??``]);this.line()}writeContent(){this.parts.sort((e,t)=>e.name.localeCompare(t.name));for(let e of this.parts)this.add(`## `+e.name),this.line(),e.description&&(this.add(`${e.description}`),this.line()),this.isManifestClass(e)?this.writeClass(e):this.isManifestFunction(e)&&this.writeFunction(e),e.example&&(this.add(`### Example`),this.line(),this.add(e.example))}writeClass(e){e.isWebComponent?this.add(` - Type : ${e.type} (Webcomponent)`):this.add(` - Type : ${e.type}`),e.tag&&this.add(` - Tag : ${e.tag}`),this.add(` - Import : ${e.import}`),e.parent&&this.add(` - Parent : ${e.parent}`),e.impl&&this.add(` - Implements : ${e.impl}`);let t=e.isWebComponent;if(this.line(),e.jsProps&&e.jsProps.length>0&&(this.add(`### JS Props`),this.line(),this.writeProps(e.jsProps,t),this.line()),e.jsMethods&&e.jsMethods.length>0&&(this.add(`### Methods`),this.line(),this.writeMethods(e.jsMethods),this.line()),e.jsPropsStatic&&e.jsPropsStatic.length>0&&(this.add(`### JS Props Static`),this.line(),this.writeProps(e.jsPropsStatic,t),this.line()),e.jsMethodsStatic&&e.jsMethodsStatic.length>0&&(this.add(`### Methods Static`),this.line(),this.writeMethods(e.jsMethodsStatic),this.line()),e.htmlSlots&&e.htmlSlots.length>0){this.add(`### HTML Slots`),this.line(),this.addColumnsHeader([`Name`,`Description`]);for(let t of e.htmlSlots)this.addColumns([t.name,t.description??``]);this.line()}e.cssProps&&e.cssProps.length>0&&(this.add(`### CSS Props`),this.line(),this.writeProps(e.cssProps,!1),this.line())}writeFunction(e){this.add(` - Return : ${e.result}`)}writeProps(e,t){if(e.length!=0)if(t){this.addColumnsHeader([`Name`,`Type`,`Description`,`Decorator`]);for(let t of e)this.addColumns([t.name,t.type,t.description,t.decorator??``])}else{this.addColumnsHeader([`Name`,`Type`,`Description`]);for(let t of e)this.addColumns([t.name,t.type,t.description])}}writeMethods(e){if(e.length!=0){this.addColumnsHeader([`Name`,`Return`,`Description`]);for(let t of e){let e=t.description??``;t.isAbstract&&(e=`(abstract) `+e),this.addColumns([t.name,t.result,e])}}}line(){this.content.push(``)}add(e){this.content.push(e)}addColumns(e){let t=`| ${e.map(e=>e.replace(/\r\n|\n/g,``).replace(/ {2,}/g,` `).trim()).join(` | `)} |`;this.add(t)}addColumnsHeader(e){this.addColumns(e);let t=[];for(let n=0;n<e.length;n++)t.push(`---`);let n=`| ${t.join(` | `)} |`;this.add(n)}},Ri=class e{path;static instance;static getInstance(){return this.instance||=new e,this.instance}getPath(){return this.path}constructor(){this.path=(0,f.join)($.savePath,`packages`),(0,u.existsSync)(this.path)||(0,u.mkdirSync)(this.path,{recursive:!0})}predefinedPaths={"Aventus@Main":Tt(),"Aventus@UI":Et(),"Aventus@Sharp":Ot(),"Aventus@Php":kt(),"Aventus@I18n":Dt()};predefinedNpm={"Aventus@Main":`@aventusjs/main`,"Aventus@UI":`@aventusjs/ui`,"Aventus@I18n":`@aventusjs/i18n`,"Aventus@Sharp":`@aventussharp/main`,"Aventus@Php":`@aventusphp/main`};loadedPackages={};get packages(){let e=[];for(let t in this.loadedPackages)e.push(this.loadedPackages[t]);return e}async loadDependenciesFromBuild(e,t){let n={files:[],dependencyNeedUris:[],dependencyFullUris:[],dependencyUris:[]},r={},i={};for(let n in e.dependencies){let a=e.dependencies[n],o=await this.loadDependency(n,a,e,t,r);o&&(i[o.name]=a.include??`need`)}for(let e in r)i[e]||(i[e]=r[e].include);r[`Aventus@Main`]||await this.loadDependency(`Aventus@Main`,{uri:``,npm:``,version:`x.x.x`,include:`need`,subDependenciesInclude:{"*":`need`}},e,t,r),t?.buildConfig.i18n!==void 0&&!r[`Aventus@I18n`]&&await this.loadDependency(`Aventus@I18n`,{uri:``,npm:``,version:`x.x.x`,include:`need`,subDependenciesInclude:{"*":`need`}},e,t,r);let a=[];for(let e in r){let t=r[e];this.orderLoop(e,t,r,a)}for(let e of a){let t=r[e];t.file.loadWebComponents(),n.files.push(t.file);let a=i[e]??`need`;a==`full`?(n.dependencyFullUris.push(t.uri),n.dependencyUris.push(t.uri)):a==`need`&&(n.dependencyNeedUris.push(t.uri),n.dependencyUris.push(t.uri))}return n}orderLoop(e,t,n,r){let i=r.indexOf(e);if(i!=-1)return i+1;let a=0;for(let e of t.dependencies)if(n[e.name]){let t=this.orderLoop(e.name,n[e.name],n,r);t>=0&&t>a&&(a=t)}return r.splice(a,0,e),r.length}async loadDependency(e,t,n,r,i){let a,o;if(this.predefinedPaths[e]){t.uri=this.predefinedPaths[e];let n=D(t.uri);a=await this.loadByUri(r,n),o=n}else if(t.uri)if(t.uri.startsWith(`http`))$.showErrorMessage(`http package isn't supported right now. Plz use the store`);else{let e=D(t.uri);a=await this.loadByUri(r,e),o=e}else if(t.isLocal){let t=await this.loadLocal(e,r);a=t.file,o=t.uri}else if(t.version){let n=await this.loadStore(e,t.version,r);n?(a=n.file,o=n.uri):$.showErrorMessage(`Can't load `+e+` from the store`)}else $.showErrorMessage(`You need to define a version to load a package via the store (`+e+`)`);if(o&&a){let s=t.version?this.parseVersion(t.version):{major:-1,minor:-1,patch:-1};if(t.npm)a.npmUri=t.npm;else if(this.predefinedNpm[e])a.npmUri=this.predefinedNpm[e];else{let e=/\/\/ npm:(.*)$/m.exec(a.file.contentUser);e&&(a.npmUri=e[1])}let c=/\/\* description:(.*) \*\//gm.exec(a.file.contentUser);c&&(a.description=c[1]);let l=async(e,a)=>{i[e.name]={file:e,uri:a,include:t.include??`need`,version:s,dependencies:[]};for(let t in e.dependencies){let a=e.dependencies[t];typeof a==`string`&&(a={version:a});let o=await this.loadDependency(t,a,n,r,i);if(o){let t=i[e.name].dependencies.find(e=>e.name==o.name),n=`need`;a.subDependenciesInclude&&a.subDependenciesInclude[o.name]&&(n=a.subDependenciesInclude[o.name]),t?(t.include==`none`&&n!=`none`||t.include==`need`&&n==`full`)&&(t.include=n):i[e.name].dependencies.push({name:o.name,include:n})}}e.name!=`Aventus@Main`&&(i[e.name].dependencies.find(e=>e.name==`Aventus@Main`)||i[e.name].dependencies.push({name:`Aventus@Main`,include:`need`}))};if(!i[a.name])await l(a,o);else{let e=i[a.name].version;this.compareVersion(e,s,a.name)==s&&await l(a,o)}Ii.register(a)}return a}async loadByUri(e,t){let n=await R.getInstance().registerFilePackage(t);return this.loadPackage(n,e)}async loadLocal(e,t){let n=D((0,f.join)(this.path,`@locals`,e));n.endsWith(T.Package)||(n+=T.Package);let r=await R.getInstance().registerFilePackage(n),i=this.loadPackage(r,t);return{uri:n,file:i}}async loadStore(e,t,n){let r=(0,f.join)(this.path,`store`,e,t),i=(0,u.existsSync)(r),{major:a,minor:o,patch:s}=this.parseVersion(t),c=null;if(i&&(c=this.findPackage(r),c||(i=!1)),!i){(0,u.existsSync)(r)&&(0,u.rmSync)(r,{force:!0,recursive:!0}),(0,u.mkdirSync)(r,{recursive:!0});let n=(0,f.join)(r,`temp.zip`);if(!await this.downloadFile(n,Ni.url+`/package/download/${e}/${t}`)||!await this.extractZip(n,r))return null;if((0,u.rmSync)(n,{force:!0}),c=this.findPackage(r),!c)return;let i=await this.readFirstLine(c),a=/\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)/g.exec(i);if(!a)return console.error(`Invalid package header for "${e}@${t}". First line:`,JSON.stringify(i)),null;let o=a[1],s=Number(a[2]),l=Number(a[3]),d=Number(a[4]),p=s+`.`+l+`.`+d;if(o!==e)return console.error(`Package name mismatch: requested "${e}", downloaded "${o}"`),null;if(p!==t)return console.error(`Package version mismatch: requested "${t}", downloaded "${p}"`),null}if(!c)return console.error(`Package file not found after extracting "${e}@${t}" into "${r}"`),null;let l=D(c),d=await R.getInstance().registerFilePackage(l);return{uri:l,file:this.loadPackage(d,n)}}extractZip(e,t){return new Promise(n=>{let r=!1,i=e=>{r||(r=!0,n(e))},a=(0,u.createReadStream)(e),o=(0,de.Extract)({path:t});a.on(`error`,t=>{console.error(`Can't read ZIP "${e}":`,t),i(!1)}),o.on(`close`,()=>i(!0)),o.on(`error`,t=>{console.error(`Can't extract ZIP "${e}":`,t),i(!1)}),a.pipe(o)})}findPackage(e){let t=null,n=(0,u.readdirSync)(e);for(let r of n)if(r.endsWith(T.Package)){t=(0,f.join)(e,r);break}return t}loadPackage(e,t){let n=xn.getQuickInfo(e);if(n)return this.loadedPackages[n.name]=new xn(e,t),this.loadedPackages[n.name]}downloadFile(e,t){return new Promise(n=>{let r=()=>{try{(0,u.existsSync)(e)&&(0,u.unlinkSync)(e)}catch{}};(t.startsWith(`https:`)?ue.get:ne.get)(t,i=>{let a=i.statusCode??0;if(a>=300&&a<400&&i.headers.location){i.resume(),this.downloadFile(e,i.headers.location).then(n).catch(()=>n(!1));return}if(a<200||a>=300){console.error(`Download failed: HTTP ${a} for ${t}`),i.resume(),r(),n(!1);return}let o=(0,u.createWriteStream)(e);o.on(`error`,t=>{console.error(`File write error for ${e}:`,t),i.destroy(),r(),n(!1)}),i.on(`error`,e=>{console.error(`HTTP response error for ${t}:`,e),o.destroy(),r(),n(!1)}),o.on(`finish`,()=>{o.close(t=>{if(t){console.error(`File close error for ${e}:`,t),r(),n(!1);return}n(!0)})}),i.pipe(o)}).on(`error`,e=>{console.error(`HTTP request error for ${t}:`,e),r(),n(!1)});let i=(0,u.createWriteStream)(e);try{(t.startsWith(`https`)?ue.get:ne.get)(t,function(t){t.pipe(i),i.on(`finish`,()=>{i.close(),n(!0)}),i.on(`error`,()=>{i.close(),(0,u.unlinkSync)(e),n(!1)})})}catch{i.close(),(0,u.unlinkSync)(e),n(!1)}})}readFirstLine(e){return new Promise(function(t,n){var r=(0,u.createReadStream)(e,{encoding:`utf8`}),i=``,a=0,o;r.on(`data`,function(e){o=e.indexOf(`
|
|
426
|
+
`)??``}};{let n=this.languageService.parseHTMLDocument(e.file.documentUser);if(n)return this.currentFile=void 0,this.languageService.doHover(e.file.documentUser,t,n)}return this.currentFile=void 0,null}async format(e,t,n){return this.languageService.format(e,t,n)}async onDefinition(e,t){this.currentFile=e;let n=this.getLinkToLogic(e,t);if(n instanceof rn||n instanceof on){let t=e.build.tsFiles[n._class.fileUri];return this.currentFile=void 0,[{uri:t.file.uri,range:{start:t.file.documentUser.positionAt(n.nameStart),end:t.file.documentUser.positionAt(n.nameEnd)}}]}else if(n instanceof un)return this.currentFile=void 0,[{uri:n.document.uri,range:{start:n.document.positionAt(n.nameStart),end:n.document.positionAt(n.nameEnd)}}];else return this.currentFile=void 0,this.build.htmlLanguageService.getLinkToStyle(e,t)}getLinkToLogic(e,t){let n=e.file.documentUser.offsetAt(t),r=e.tsFile,i=r?.fileParsed?.classes[r.getComponentName()];if(r&&i&&e.fileParsed){for(let t of e.fileParsed.interestPoints)if(n>=t.start&&n<=t.end){let r=null;if(t.type==`event`){let r=this.getTag(e,n);if(r){let n=e.build.getWebComponentDefinition(r.tagName);if(n){let e=n.class.getEvent(t.name);if(e)return e}}}if(t.type==`method`)r=i.methods[t.name];else if(t.type==`property`)r=i.properties[t.name];else if(t.type==`tag`){let n=this.documentationInfo[t.name];if(n){let t=this.internalDocumentationReverse[n.class];if(t&&t.fileParsed){for(let e in t.fileParsed.classes)if(e==n.class)return t.fileParsed.classes[e]}let r=e.build.getWebComponentDefinition(n.name,!0);if(r)return r.class}}return r}else if(t.end>=n)return null}return null}getLinkToStyle(e,t){let n=[],r=e.file.documentUser.offsetAt(t),i=e.scssFile;if(i&&e.fileParsed)for(let t of e.fileParsed.styleLinks){let e=t[0];r>=e.start&&r<=e.end&&n.push({uri:i.file.uri,range:{start:i.file.documentUser.positionAt(t[1].start),end:i.file.documentUser.positionAt(t[1].end)}})}return n}allowRebuildDefinition(e){this._allowRebuildDefinition=e,this.rebuildDefinition()}rebuildDefinition(){if(!this._allowRebuildDefinition)return;this.documentationInfo={};for(let e in this.extenalDocumentation){let t=this.extenalDocumentation[e];this.documentationInfo={...this.documentationInfo,...t}}for(let e in this.internalDocumentation){let t=this.internalDocumentation[e];try{this.documentationInfo={...this.documentationInfo,...t}}catch{}}this.customTagsData=[{name:`block`,attributes:[{name:`name`}]}];let e=[];for(let t in this.documentationInfo){let n=this.documentationInfo[t];if(e.indexOf(n.name)==-1){e.push(n.name);let t=[],r={name:n.name,description:n.description,attributes:t};for(let e in n.attributes){let r=n.attributes[e];t.push({name:r.name,description:r.description,values:r.values})}this.customTagsData.push(r)}}}addExternalDefinition(e,t){this.extenalDocumentation[e]=t,this.rebuildDefinition()}removeExternalDefinition(e){delete this.extenalDocumentation[e],this.rebuildDefinition()}getInternalDefinition(e){let t=this.documentationInfo[e];if(t)return this.internalDocumentationReverse[t.class]}addInternalDefinition(e,t,n){this.internalDocumentation[e]=t;for(let e in t)this.internalDocumentationReverse[t[e].class]=n;this.rebuildDefinition()}removeInternalDefinition(e){let t=this.internalDocumentation[e];if(t)for(let e in t)delete this.internalDocumentationReverse[t[e].class];delete this.internalDocumentation[e],this.rebuildDefinition()}getInternalTagUri(e){return this.internalTagUri[e]}addInternalTagUri(e,t,n){this.internalTagUri[e]={uri:t,fullname:n}}removeInternalTagUri(e){for(let t in this.internalTagUri)if(this.internalTagUri[t].uri==e){delete this.internalTagUri[t];return}}};function xi(e){let t=``,n=[],r=r=>{for(let i of r){let r=wn.compileTs(i,e);e.build.addNamespace(i.namespace),n.push(r),t+=r.debugTxt}};e.fileParsed&&(r(Object.values(e.fileParsed.classes)),r(Object.values(e.fileParsed.enums)),r(Object.values(e.fileParsed.aliases)),r(Object.values(e.fileParsed.functions)),r(Object.values(e.fileParsed.variables)));let i=e.file.path.replace(`.avt`,`.js`);return t==``?(0,u.existsSync)(i)&&(0,u.unlinkSync)(i):(0,u.writeFileSync)(i,t),n}var Si=class extends hn{get extension(){return T.Data}constructor(e,t){super(e,t),this.refreshFileParsed()}async onValidate(){let e=this.file.documentUser;this.diagnostics=this.tsLanguageService.doValidation(this.file),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.build.isCoreBuild?this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`IData`]}):this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`Aventus.IData`],customClassRules:[e=>{!e.isInterface&&e.convertibleName&&(e.hasStaticField(e.convertibleName)||this.diagnostics.push(k(this.file.documentUser,`Missing static property ${e.convertibleName}`,e.nameStart,e.nameEnd,1022)))}]});let t=this.fileParsed;if(t)for(let n in t.classes){let r=t.classes[n];if(!r.isInterface){for(let t in r.properties){let n=r.properties[t];!n.isAbstract&&n.isGetSet&&!n.overrideNullable&&n.defaultValue===null&&this.diagnostics.push(k(e,`Property '${n.name}' has no initializer and is not definitely assigned.`,n.nameStart,n.nameEnd,1013))}let t=r,n=!1;for(;t!=null;){if(t.propertiesStatic.Fullname!=null){n=!0;break}t=t.parentClass}n||this.diagnostics.push(k(e,`Missing static property Fullname`,r.nameStart,r.nameEnd,1022))}}return this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return await this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Ci=class extends hn{get extension(){return T.Definition}constructor(e,t){super(e,t),this._contentForLanguageService=this.file.contentUser}async onContentChange(){this._contentForLanguageService=this.file.contentUser}async onValidate(){return[]}async onSave(){}async onCompletion(e,t){return this.build.tsLanguageService.doComplete(e,t)}async onCompletionResolve(e,t){return t}async onHover(e,t){return null}async onDefinition(e,t){return null}async onFormatting(e,t,n){return this.build.tsLanguageService.format(e,t,n)}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return this.build.tsLanguageService.onRename(e,t,n)}},wi=class extends hn{get extension(){return T.Lib}constructor(e,t){super(e,t),this.refreshFileParsed()}async onValidate(){return this.diagnostics=this.tsLanguageService.doValidation(this.file),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.validateRules({allow_variables:!0,allow_function:!0,customClassRules:[e=>{!e.isInterface&&e.convertibleName&&(e.hasStaticField(e.convertibleName)||this.diagnostics.push(k(this.file.documentUser,`Missing static property ${e.convertibleName}`,e.nameStart,e.nameEnd,1022)))}]}),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}onFormatting(e,t,n){return this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Ti=class extends hn{get extension(){return T.RAM}constructor(e,t){super(e,t),this.refreshFileParsed()}async onValidate(){return this.diagnostics=this.tsLanguageService.doValidation(this.file),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.build.isCoreBuild?this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`IRam`]}):this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`Aventus.IRam`]}),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}onFormatting(e,t,n){return this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Ei=class extends hn{get extension(){return T.State}constructor(e,t){super(e,t),this.refreshFileParsed()}async onValidate(){return this.file.documentUser,this.diagnostics=this.tsLanguageService.doValidation(this.file),this.fileParsed&&(this.diagnostics=this.diagnostics.concat(this.fileParsed.errors)),this.build.isCoreBuild?this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`IStateManager`,`IState`]}):this.validateRules({allow_variables:!1,allow_function:!1,class_implement:[`Aventus.IStateManager`,`Aventus.IState`]}),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return await this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Di=class extends hn{get extension(){return T.Static}mustBeAddedToLanguageService(){return!1}async onValidate(){return[]}async onContentChange(){}async onSave(){let e=this.file.path,t=e.replace(this.extension,T.Definition),n=``,r=``;t.endsWith(T.Definition)&&(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`).replace(/declare global \{([\s\S]*?)\}/gm,`$1`));let i=e.replace(this.extension,T.DefinitionNpm);r=i.endsWith(T.DefinitionNpm)&&(0,u.existsSync)(i)?(0,u.readFileSync)(i,`utf8`):n;let a=Je(e+this.file.contentUser),o=this.file.path.replace(this.build.project.getConfigFile().path.replace(T.Config,``),``);o=o.replace(this.extension,`.js`),this.setCompileResult([{classDoc:``,classScript:`!staticClass_`+a,compiled:this.file.contentUser,hotReload:``,docVisible:n,npm:{namespace:``,defTs:r,src:this.file.contentUser,exportPath:o,uri:this.file.uri},docInvisible:``,debugTxt:``,dependencies:[],uri:this.file.uri,required:!0,type:0,isExported:{external:!1,internal:!1},convertibleName:``,useDecorator:!1}])}async onCompletion(e,t){return{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return null}async onDefinition(e,t){return null}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}};function Oi(e,t){let n=null;return e.uri.endsWith(T.ComponentLogic)?n=new F(e,t):e.uri.endsWith(T.Data)?n=new Si(e,t):e.uri.endsWith(T.Lib)?n=new wi(e,t):e.uri.endsWith(T.RAM)?n=new Ti(e,t):e.uri.endsWith(T.State)?n=new Ei(e,t):e.uri.endsWith(T.Static)?n=new Di(e,t):e.uri.endsWith(T.Definition)&&(n=new Ci(e,t)),n}var ki=class{static send(e,t){$.sendNotification(`aventus/compiled`,e,t)}static part(e){$.sendNotification(`aventus/compiled/part`,e)}},Ai=class{static send(e,t){$.sendNotification(`aventus/registerBuild`,{pathConfig:e,buildName:t})}},ji=class{static send(e,t){$.sendNotification(`aventus/unregisterBuild`,{pathConfig:e,buildName:t})}},Mi=o(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r(require("child_process"),require("crypto")):typeof define==`function`&&define.amd?define([`child_process`,`crypto`],r):typeof e==`object`?e["electron-machine-id"]=r(require("child_process"),require("crypto")):n[`electron-machine-id`]=r(n.child_process,n.crypto)})(e,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=``,t(0)}([function(e,t,n){e.exports=n(34)},function(e,t,n){var r=n(29)(`wks`),i=n(33),a=n(2).Symbol,o=typeof a==`function`,s=e.exports=function(e){return r[e]||(r[e]=o&&a[e]||(o?a:i)(`Symbol.`+e))};s.store=r},function(e,t){var n=e.exports=typeof window<`u`&&window.Math==Math?window:typeof self<`u`&&self.Math==Math?self:Function(`return this`)();typeof __g==`number`&&(__g=n)},function(e,t,n){var r=n(9);e.exports=function(e){if(!r(e))throw TypeError(e+` is not an object!`);return e}},function(e,t,n){e.exports=!n(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(e,t,n){var r=n(12),i=n(17);e.exports=n(4)?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t){var n=e.exports={version:`2.4.0`};typeof __e==`number`&&(__e=n)},function(e,t,n){var r=n(14);e.exports=function(e,t,n){if(r(e),t===void 0)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t){e.exports=function(e){return typeof e==`object`?e!==null:typeof e==`function`}},function(e,t){e.exports={}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var r=n(3),i=n(26),a=n(32),o=Object.defineProperty;t.f=n(4)?Object.defineProperty:function(e,t,n){if(r(e),t=a(t,!0),r(n),i)try{return o(e,t,n)}catch{}if(`get`in n||`set`in n)throw TypeError(`Accessors not supported!`);return`value`in n&&(e[t]=n.value),e}},function(e,t,n){var r=n(42),i=n(15);e.exports=function(e){return r(i(e))}},function(e,t){e.exports=function(e){if(typeof e!=`function`)throw TypeError(e+` is not a function!`);return e}},function(e,t){e.exports=function(e){if(e==null)throw TypeError(`Can't call method on `+e);return e}},function(e,t,n){var r=n(9),i=n(2).document,a=r(i)&&r(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){var r=n(12).f,i=n(8),a=n(1)(`toStringTag`);e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,a)&&r(e,a,{configurable:!0,value:t})}},function(e,t,n){var r=n(29)(`keys`),i=n(33);e.exports=function(e){return r[e]||(r[e]=i(e))}},function(e,t){var n=Math.ceil,r=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?r:n)(e)}},function(e,t,n){var r=n(11),i=n(1)(`toStringTag`),a=r(function(){return arguments}())==`Arguments`,o=function(e,t){try{return e[t]}catch{}};e.exports=function(e){var t,n,s;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=o(t=Object(e),i))==`string`?n:a?r(t):(s=r(t))==`Object`&&typeof t.callee==`function`?`Arguments`:s}},function(e,t){e.exports=`constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf`.split(`,`)},function(e,t,n){var r=n(2),i=n(6),a=n(7),o=n(5),s=`prototype`,c=function(e,t,n){var l,u,d,f=e&c.F,p=e&c.G,m=e&c.S,h=e&c.P,g=e&c.B,_=e&c.W,v=p?i:i[t]||(i[t]={}),y=v[s],b=p?r:m?r[t]:(r[t]||{})[s];for(l in p&&(n=t),n)u=!f&&b&&b[l]!==void 0,u&&l in v||(d=u?b[l]:n[l],v[l]=p&&typeof b[l]!=`function`?n[l]:g&&u?a(d,r):_&&b[l]==d?function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t[s]=e[s],t}(d):h&&typeof d==`function`?a(Function.call,d):d,h&&((v.virtual||={})[l]=d,e&c.R&&y&&!y[l]&&o(y,l,d)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,e.exports=c},function(e,t){e.exports=function(e){try{return!!e()}catch{return!0}}},function(e,t,n){e.exports=n(2).document&&document.documentElement},function(e,t,n){e.exports=!n(4)&&!n(24)(function(){return Object.defineProperty(n(16)(`div`),"a",{get:function(){return 7}}).a!=7})},function(e,t,n){"use strict";var r=n(28),i=n(23),a=n(57),o=n(5),s=n(8),c=n(10),l=n(45),u=n(18),d=n(52),f=n(1)(`iterator`),p=!([].keys&&`next`in[].keys()),m=`@@iterator`,h=`keys`,g=`values`,_=function(){return this};e.exports=function(e,t,n,v,y,b,x){l(n,t,v);var ee,te,S,ne=function(e){if(!p&&e in oe)return oe[e];switch(e){case h:return function(){return new n(this,e)};case g:return function(){return new n(this,e)}}return function(){return new n(this,e)}},re=t+` Iterator`,ie=y==g,ae=!1,oe=e.prototype,C=oe[f]||oe[m]||y&&oe[y],se=C||ne(y),ce=y?ie?ne(`entries`):se:void 0,le=t==`Array`&&oe.entries||C;if(le&&(S=d(le.call(new e)),S!==Object.prototype&&(u(S,re,!0),r||s(S,f)||o(S,f,_))),ie&&C&&C.name!==g&&(ae=!0,se=function(){return C.call(this)}),r&&!x||!p&&!ae&&oe[f]||o(oe,f,se),c[t]=se,c[re]=_,y)if(ee={values:ie?se:ne(g),keys:b?se:ne(h),entries:ce},x)for(te in ee)te in oe||a(oe,te,ee[te]);else i(i.P+i.F*(p||ae),t,ee);return ee}},function(e,t){e.exports=!0},function(e,t,n){var r=n(2),i=`__core-js_shared__`,a=r[i]||(r[i]={});e.exports=function(e){return a[e]||(a[e]={})}},function(e,t,n){var r,i,a,o=n(7),s=n(41),c=n(25),l=n(16),u=n(2),d=u.process,f=u.setImmediate,p=u.clearImmediate,m=u.MessageChannel,h=0,g={},_=`onreadystatechange`,v=function(){var e=+this;if(g.hasOwnProperty(e)){var t=g[e];delete g[e],t()}},y=function(e){v.call(e.data)};f&&p||(f=function(e){for(var t=[],n=1;arguments.length>n;)t.push(arguments[n++]);return g[++h]=function(){s(typeof e==`function`?e:Function(e),t)},r(h),h},p=function(e){delete g[e]},n(11)(d)==`process`?r=function(e){d.nextTick(o(v,e,1))}:m?(i=new m,a=i.port2,i.port1.onmessage=y,r=o(a.postMessage,a,1)):u.addEventListener&&typeof postMessage==`function`&&!u.importScripts?(r=function(e){u.postMessage(e+``,`*`)},u.addEventListener(`message`,y,!1)):r=_ in l(`script`)?function(e){c.appendChild(l(`script`))[_]=function(){c.removeChild(this),v.call(e)}}:function(e){setTimeout(o(v,e,1),0)}),e.exports={set:f,clear:p}},function(e,t,n){var r=n(20),i=Math.min;e.exports=function(e){return e>0?i(r(e),9007199254740991):0}},function(e,t,n){var r=n(9);e.exports=function(e,t){if(!r(e))return e;var n,i;if(t&&typeof(n=e.toString)==`function`&&!r(i=n.call(e))||typeof(n=e.valueOf)==`function`&&!r(i=n.call(e))||!t&&typeof(n=e.toString)==`function`&&!r(i=n.call(e)))return i;throw TypeError(`Can't convert object to primitive value`)}},function(e,t){var n=0,r=Math.random();e.exports=function(e){return`Symbol(${e===void 0?``:e})_${(++n+r).toString(36)}`}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function i(){return process.platform===`win32`?process.arch===`ia32`&&process.env.hasOwnProperty(`PROCESSOR_ARCHITEW6432`)?`mixed`:`native`:``}function a(e){return(0,d.createHash)(`sha256`).update(e).digest(`hex`)}function o(e){switch(f){case`darwin`:return e.split(`IOPlatformUUID`)[1].split(`
|
|
427
|
+
`)[0].replace(/\=|\s+|\"/gi,``).toLowerCase();case`win32`:return e.toString().split(`REG_SZ`)[1].replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`linux`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();case`freebsd`:return e.toString().replace(/\r+|\n+|\s+/gi,``).toLowerCase();default:throw Error(`Unsupported platform: `+process.platform)}}function s(e){var t=o((0,u.execSync)(p[f]).toString());return e?t:a(t)}function c(e){return new l.default(function(t,n){return(0,u.exec)(p[f],{},function(r,i,s){if(r)return n(Error(`Error while obtaining machine id: `+r.stack));var c=o(i.toString());return t(e?c:a(c))})})}Object.defineProperty(t,"__esModule",{value:!0});var l=r(n(35));t.machineIdSync=s,t.machineId=c;var u=n(70),d=n(71),f=process.platform,p={darwin:`ioreg -rd1 -c IOPlatformExpertDevice`,win32:{native:`%windir%\\System32`,mixed:`%windir%\\sysnative\\cmd.exe /c %windir%\\System32`}[i()]+`\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid`,linux:`( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :`,freebsd:`kenv -q smbios.system.uuid || sysctl -n kern.hostuuid`}},function(e,t,n){e.exports={default:n(36),__esModule:!0}},function(e,t,n){n(66),n(68),n(69),n(67),e.exports=n(6).Promise},function(e,t){e.exports=function(){}},function(e,t){e.exports=function(e,t,n,r){if(!(e instanceof t)||r!==void 0&&r in e)throw TypeError(n+`: incorrect invocation!`);return e}},function(e,t,n){var r=n(13),i=n(31),a=n(62);e.exports=function(e){return function(t,n,o){var s,c=r(t),l=i(c.length),u=a(o,l);if(e&&n!=n){for(;l>u;)if(s=c[u++],s!=s)return!0}else for(;l>u;u++)if((e||u in c)&&c[u]===n)return e||u||0;return!e&&-1}}},function(e,t,n){var r=n(7),i=n(44),a=n(43),o=n(3),s=n(31),c=n(64),l={},u={},t=e.exports=function(e,t,n,d,f){var p,m,h,g,_=f?function(){return e}:c(e),v=r(n,d,t?2:1),y=0;if(typeof _!=`function`)throw TypeError(e+` is not iterable!`);if(a(_)){for(p=s(e.length);p>y;y++)if(g=t?v(o(m=e[y])[0],m[1]):v(e[y]),g===l||g===u)return g}else for(h=_.call(e);!(m=h.next()).done;)if(g=i(h,v,m.value,t),g===l||g===u)return g};t.BREAK=l,t.RETURN=u},function(e,t){e.exports=function(e,t,n){var r=n===void 0;switch(t.length){case 0:return r?e():e.call(n);case 1:return r?e(t[0]):e.call(n,t[0]);case 2:return r?e(t[0],t[1]):e.call(n,t[0],t[1]);case 3:return r?e(t[0],t[1],t[2]):e.call(n,t[0],t[1],t[2]);case 4:return r?e(t[0],t[1],t[2],t[3]):e.call(n,t[0],t[1],t[2],t[3])}return e.apply(n,t)}},function(e,t,n){var r=n(11);e.exports=Object(`z`).propertyIsEnumerable(0)?Object:function(e){return r(e)==`String`?e.split(``):Object(e)}},function(e,t,n){var r=n(10),i=n(1)(`iterator`),a=Array.prototype;e.exports=function(e){return e!==void 0&&(r.Array===e||a[i]===e)}},function(e,t,n){var r=n(3);e.exports=function(e,t,n,i){try{return i?t(r(n)[0],n[1]):t(n)}catch(t){var a=e.return;throw a!==void 0&&r(a.call(e)),t}}},function(e,t,n){"use strict";var r=n(49),i=n(17),a=n(18),o={};n(5)(o,n(1)(`iterator`),function(){return this}),e.exports=function(e,t,n){e.prototype=r(o,{next:i(1,n)}),a(e,t+` Iterator`)}},function(e,t,n){var r=n(1)(`iterator`),i=!1;try{var a=[7][r]();a.return=function(){i=!0},Array.from(a,function(){throw 2})}catch{}e.exports=function(e,t){if(!t&&!i)return!1;var n=!1;try{var a=[7],o=a[r]();o.next=function(){return{done:n=!0}},a[r]=function(){return o},e(a)}catch{}return n}},function(e,t){e.exports=function(e,t){return{value:t,done:!!e}}},function(e,t,n){var r=n(2),i=n(30).set,a=r.MutationObserver||r.WebKitMutationObserver,o=r.process,s=r.Promise,c=n(11)(o)==`process`;e.exports=function(){var e,t,n,l=function(){var r,i;for(c&&(r=o.domain)&&r.exit();e;){i=e.fn,e=e.next;try{i()}catch(r){throw e?n():t=void 0,r}}t=void 0,r&&r.enter()};if(c)n=function(){o.nextTick(l)};else if(a){var u=!0,d=document.createTextNode(``);new a(l).observe(d,{characterData:!0}),n=function(){d.data=u=!u}}else if(s&&s.resolve){var f=s.resolve();n=function(){f.then(l)}}else n=function(){i.call(r,l)};return function(r){var i={fn:r,next:void 0};t&&(t.next=i),e||(e=i,n()),t=i}}},function(e,t,n){var r=n(3),i=n(50),a=n(22),o=n(19)(`IE_PROTO`),s=function(){},c=`prototype`,l=function(){var e,t=n(16)(`iframe`),r=a.length,i=`>`;for(t.style.display=`none`,n(25).appendChild(t),t.src=`javascript:`,e=t.contentWindow.document,e.open(),e.write(`<script>document.F=Object<\/script`+i),e.close(),l=e.F;r--;)delete l[c][a[r]];return l()};e.exports=Object.create||function(e,t){var n;return e===null?n=l():(s[c]=r(e),n=new s,s[c]=null,n[o]=e),t===void 0?n:i(n,t)}},function(e,t,n){var r=n(12),i=n(3),a=n(54);e.exports=n(4)?Object.defineProperties:function(e,t){i(e);for(var n,o=a(t),s=o.length,c=0;s>c;)r.f(e,n=o[c++],t[n]);return e}},function(e,t,n){var r=n(55),i=n(17),a=n(13),o=n(32),s=n(8),c=n(26),l=Object.getOwnPropertyDescriptor;t.f=n(4)?l:function(e,t){if(e=a(e),t=o(t,!0),c)try{return l(e,t)}catch{}if(s(e,t))return i(!r.f.call(e,t),e[t])}},function(e,t,n){var r=n(8),i=n(63),a=n(19)(`IE_PROTO`),o=Object.prototype;e.exports=Object.getPrototypeOf||function(e){return e=i(e),r(e,a)?e[a]:typeof e.constructor==`function`&&e instanceof e.constructor?e.constructor.prototype:e instanceof Object?o:null}},function(e,t,n){var r=n(8),i=n(13),a=n(39)(!1),o=n(19)(`IE_PROTO`);e.exports=function(e,t){var n,s=i(e),c=0,l=[];for(n in s)n!=o&&r(s,n)&&l.push(n);for(;t.length>c;)r(s,n=t[c++])&&(~a(l,n)||l.push(n));return l}},function(e,t,n){var r=n(53),i=n(22);e.exports=Object.keys||function(e){return r(e,i)}},function(e,t){t.f={}.propertyIsEnumerable},function(e,t,n){var r=n(5);e.exports=function(e,t,n){for(var i in t)n&&e[i]?e[i]=t[i]:r(e,i,t[i]);return e}},function(e,t,n){e.exports=n(5)},function(e,t,n){var r=n(9),i=n(3),a=function(e,t){if(i(e),!r(t)&&t!==null)throw TypeError(t+`: can't set as prototype!`)};e.exports={set:Object.setPrototypeOf||(`__proto__`in{}?function(e,t,r){try{r=n(7)(Function.call,n(51).f(Object.prototype,`__proto__`).set,2),r(e,[]),t=!(e instanceof Array)}catch{t=!0}return function(e,n){return a(e,n),t?e.__proto__=n:r(e,n),e}}({},!1):void 0),check:a}},function(e,t,n){"use strict";var r=n(2),i=n(6),a=n(12),o=n(4),s=n(1)(`species`);e.exports=function(e){var t=typeof i[e]==`function`?i[e]:r[e];o&&t&&!t[s]&&a.f(t,s,{configurable:!0,get:function(){return this}})}},function(e,t,n){var r=n(3),i=n(14),a=n(1)(`species`);e.exports=function(e,t){var n,o=r(e).constructor;return o===void 0||(n=r(o)[a])==null?t:i(n)}},function(e,t,n){var r=n(20),i=n(15);e.exports=function(e){return function(t,n){var a,o,s=String(i(t)),c=r(n),l=s.length;return c<0||c>=l?e?``:void 0:(a=s.charCodeAt(c),a<55296||a>56319||c+1===l||(o=s.charCodeAt(c+1))<56320||o>57343?e?s.charAt(c):a:e?s.slice(c,c+2):(a-55296<<10)+(o-56320)+65536)}}},function(e,t,n){var r=n(20),i=Math.max,a=Math.min;e.exports=function(e,t){return e=r(e),e<0?i(e+t,0):a(e,t)}},function(e,t,n){var r=n(15);e.exports=function(e){return Object(r(e))}},function(e,t,n){var r=n(21),i=n(1)(`iterator`),a=n(10);e.exports=n(6).getIteratorMethod=function(e){if(e!=null)return e[i]||e[`@@iterator`]||a[r(e)]}},function(e,t,n){"use strict";var r=n(37),i=n(47),a=n(10),o=n(13);e.exports=n(27)(Array,`Array`,function(e,t){this._t=o(e),this._i=0,this._k=t},function(){var e=this._t,t=this._k,n=this._i++;return!e||n>=e.length?(this._t=void 0,i(1)):t==`keys`?i(0,n):t==`values`?i(0,e[n]):i(0,[n,e[n]])},`values`),a.Arguments=a.Array,r(`keys`),r(`values`),r(`entries`)},function(e,t){},function(e,t,n){"use strict";var r,i,a,o=n(28),s=n(2),c=n(7),l=n(21),u=n(23),d=n(9),f=(n(3),n(14)),p=n(38),m=n(40),h=(n(58).set,n(60)),g=n(30).set,_=n(48)(),v=`Promise`,y=s.TypeError,b=s.process,x=s[v],b=s.process,ee=l(b)==`process`,te=function(){},S=!!function(){try{var e=x.resolve(1),t=(e.constructor={})[n(1)(`species`)]=function(e){e(te,te)};return(ee||typeof PromiseRejectionEvent==`function`)&&e.then(te)instanceof t}catch{}}(),ne=function(e,t){return e===t||e===x&&t===a},re=function(e){var t;return!(!d(e)||typeof(t=e.then)!=`function`)&&t},ie=function(e){return ne(x,e)?new ae(e):new i(e)},ae=i=function(e){var t,n;this.promise=new e(function(e,r){if(t!==void 0||n!==void 0)throw y(`Bad Promise constructor`);t=e,n=r}),this.resolve=f(t),this.reject=f(n)},oe=function(e){try{e()}catch(e){return{error:e}}},C=function(e,t){if(!e._n){e._n=!0;var n=e._c;_(function(){for(var r=e._v,i=e._s==1,a=0,o=function(t){var n,a,o=i?t.ok:t.fail,s=t.resolve,c=t.reject,l=t.domain;try{o?(i||(e._h==2&&le(e),e._h=1),o===!0?n=r:(l&&l.enter(),n=o(r),l&&l.exit()),n===t.promise?c(y(`Promise-chain cycle`)):(a=re(n))?a.call(n,s,c):s(n)):c(r)}catch(e){c(e)}};n.length>a;)o(n[a++]);e._c=[],e._n=!1,t&&!e._h&&se(e)})}},se=function(e){g.call(s,function(){var t,n,r,i=e._v;if(ce(e)&&(t=oe(function(){ee?b.emit(`unhandledRejection`,i,e):(n=s.onunhandledrejection)?n({promise:e,reason:i}):(r=s.console)&&r.error&&r.error(`Unhandled promise rejection`,i)}),e._h=ee||ce(e)?2:1),e._a=void 0,t)throw t.error})},ce=function(e){if(e._h==1)return!1;for(var t,n=e._a||e._c,r=0;n.length>r;)if(t=n[r++],t.fail||!ce(t.promise))return!1;return!0},le=function(e){g.call(s,function(){var t;ee?b.emit(`rejectionHandled`,e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},ue=function(e){var t=this;t._d||(t._d=!0,t=t._w||t,t._v=e,t._s=2,t._a||=t._c.slice(),C(t,!0))},de=function(e){var t,n=this;if(!n._d){n._d=!0,n=n._w||n;try{if(n===e)throw y(`Promise can't be resolved itself`);(t=re(e))?_(function(){var r={_w:n,_d:!1};try{t.call(e,c(de,r,1),c(ue,r,1))}catch(e){ue.call(r,e)}}):(n._v=e,n._s=1,C(n,!1))}catch(e){ue.call({_w:n,_d:!1},e)}}};S||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(de,this,1),c(ue,this,1))}catch(e){ue.call(this,e)}},r=function(e){this._c=[],this._a=void 0,this._s=0,this._d=!1,this._v=void 0,this._h=0,this._n=!1},r.prototype=n(56)(x.prototype,{then:function(e,t){var n=ie(h(this,x));return n.ok=typeof e!=`function`||e,n.fail=typeof t==`function`&&t,n.domain=ee?b.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&C(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),ae=function(){var e=new r;this.promise=e,this.resolve=c(de,e,1),this.reject=c(ue,e,1)}),u(u.G+u.W+u.F*!S,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!S,v,{reject:function(e){var t=ie(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!S),v,{resolve:function(e){if(e instanceof x&&ne(e.constructor,this))return e;var t=ie(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(S&&n(46)(function(e){x.all(e).catch(te)})),v,{all:function(e){var t=this,n=ie(t),r=n.resolve,i=n.reject,a=oe(function(){var n=[],a=0,o=1;m(e,!1,function(e){var s=a++,c=!1;n.push(void 0),o++,t.resolve(e).then(function(e){c||(c=!0,n[s]=e,--o||r(n))},i)}),--o||r(n)});return a&&i(a.error),n.promise},race:function(e){var t=this,n=ie(t),r=n.reject,i=oe(function(){m(e,!1,function(e){t.resolve(e).then(n.resolve,r)})});return i&&r(i.error),n.promise}})},function(e,t,n){"use strict";var r=n(61)(!0);n(27)(String,`String`,function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,n=this._i;return n>=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t,n){n(65);for(var r=n(2),i=n(5),a=n(10),o=n(1)(`toStringTag`),s=[`NodeList`,`DOMTokenList`,`MediaList`,`StyleSheetList`,`CSSRuleList`],c=0;c<5;c++){var l=s[c],u=r[l],d=u&&u.prototype;d&&!d[o]&&i(d,o,l),a[l]=a.Array}},function(e,t){e.exports=require("child_process")},function(e,t){e.exports=require("crypto")}])})}))(),Ni=class e{static url=`https://store.aventusjs.com`;static _settings;static get settings(){return this._settings||=E.getInstance().hiddenSettings.store,this._settings}static get token(){return this.settings.token}static get isConnected(){return this.token!=``}static setSettings(e){let t={...this.settings,...e};E.getInstance().setHiddenSettings({store:t}),this._settings=t}static async connect(e,t){let n=await(0,Mi.machineId)(),r=(0,x.hostname)(),i=await this.post(`/login`,{username:e,password:t,machineId:n,machineName:r},{withoutBearer:!0});return i?(this.setSettings({token:i,username:e}),!0):!1}static async disconnect(){await this.post(`/logout`),this.setSettings({token:``,username:void 0})}static async publishPackage(e){let t=new FormData;t.append(`name`,e.buildConfig.fullname),t.append(`description`,e.buildConfig.description??``),t.append(`version`,e.buildConfig.version),e.buildConfig.organization&&t.append(`organization`,e.buildConfig.organization),e.buildConfig.documentation&&t.append(`documentation`,e.buildConfig.documentation),e.buildConfig.repository&&t.append(`repository`,e.buildConfig.repository);for(let n of e.buildConfig.tags)t.append(`tags[]`,n);let n=(0,f.join)(Ri.getInstance().getPath(),`@locals`,e.buildConfig.fullname+T.Package);if(!(0,u.existsSync)(n))return!1;let r=new Blob([(0,u.readFileSync)(n)],{type:`text/plain`});t.append(`packageFile`,r,e.buildConfig.fullname+T.Package);let i=e.project.getConfigFile().folderPath;if(e.buildConfig.readme){let n;if(e.buildConfig.readme.startsWith(`.`)){let t=(0,f.normalize)((0,f.join)(i,e.buildConfig.readme));if((0,u.existsSync)(t))n=t;else return new Pi([{code:-1,message:`Readme not found`}])}else if((0,u.existsSync)(e.buildConfig.readme))n=e.buildConfig.readme;else{let t=(0,f.normalize)((0,f.join)(i,e.buildConfig.readme));if((0,u.existsSync)(t))n=t;else return new Pi([{code:-1,message:`Readme not found`}])}let r=new Blob([(0,u.readFileSync)((0,f.join)(i,n))],{type:`text/plain`});t.append(`readMe`,r,`README.md`)}else{let e=(0,u.readdirSync)(i).find(e=>e.toLowerCase()===`readme.md`);if(e){let n=new Blob([(0,u.readFileSync)((0,f.join)(i,e))],{type:`text/plain`});t.append(`readMe`,n,`README.md`)}}return await this.postWithErrors(`/package/publish`,t)}static async publishTemplate(e){let t=new FormData;t.append(`name`,e.name),t.append(`description`,e.description),t.append(`version`,e.version),t.append(`is_project`,e.isProject?`1`:`0`),t.append(`is_global`,e.isGlobal?`1`:`0`),e.organization&&t.append(`organization`,e.organization),e.documentation&&t.append(`documentation`,e.documentation),e.repository&&t.append(`repository`,e.repository);for(let n of e.tags)t.append(`tags[]`,n);let n=e.folderPath,r=(0,u.readdirSync)(n).find(e=>e.toLowerCase()===`readme.md`);if(r){let e=new Blob([(0,u.readFileSync)((0,f.join)(n,r))],{type:`text/plain`});t.append(`readMe`,e,`README.md`)}let i=(0,f.dirname)(e.config),a=(0,f.join)($.savePath,`temp`,e.name+`.zip`);await this.zip(i,a);let o=new Blob([(0,u.readFileSync)(a)],{type:`application/zip`});t.append(`templateFile`,o,e.name+`.zip`);let s=await this.postWithErrors(`/template/publish`,t);return(0,u.unlinkSync)(a),s}static async post(e,t={},n){let r=await this.postWithErrors(e,t,n);if(r instanceof Pi){for(let e of r.errors)$.error(e.message);return null}return r}static async postWithErrors(t,n={},r){let i=null;try{let a={};if(n instanceof FormData||(a[`Content-Type`]=`application/json`),!r?.withoutBearer){let e=await(0,Mi.machineId)();a.Authorization=`Bearer `+(this.token+`|`+e)}if(i=await fetch(e.url+`/api/remote`+t,{method:`POST`,body:n instanceof FormData?n:JSON.stringify(n),headers:a}),i.status==401)return new Pi([{code:401,message:`No token provided`}]);if(i.status==403)return t!=`/logout`&&this.disconnect(),new Pi([{code:403,message:`You must connect to your account first`}]);let o=await i.text(),s;try{s=JSON.parse(o)}catch(e){throw $.error(o),e}return s.errors?s.errors.length>0?new Pi(s.errors):s.result:new Pi([{code:-500,message:`Wrong response format from the api`}])}catch(e){return new Pi([{code:-500,message:e+``}])}}static zip(e,t){return new Promise(async(n,r)=>{let i=(0,u.createWriteStream)(t),a=(0,fe.create)(`zip`,{zlib:{level:9}});i.on(`close`,()=>{n()}),a.on(`error`,e=>{r(e)}),a.pipe(i),a.directory(e,!1,e=>e.name.startsWith(`.git/`)||e.name===`.git`?!1:e),await a.finalize()})}},Pi=class{errors;constructor(e){this.errors=e}},Fi=class e{fctTxt=null;static is(t){return t.name==`Attribute`?new e:null}},Ii=class{static files={};static done=!1;static register(e){this.files[e.file.uri]||(this.files[e.file.uri]=e,this.done&&this.write())}static write(e=!1){let t={html:{snippets:{block:'<block name="${1}">${2}</block>'}}},n=!1;for(let e in this.files){let r=this.files[e].srcInfo.available;for(let e of r)if(e.tagName){let r=e.tagName;t.html.snippets[r]=`<${r}>\${1}</${r}>`,n=!0}}if(n){let n=(0,f.join)(O($.getWorkspaceUri()),`.aventus`,`emmet`),r=(0,f.join)(n,`snippets.json`);if(!e&&!(0,u.existsSync)(r)){this.done=!0;return}(0,u.existsSync)(n)||(0,u.mkdirSync)(n,{recursive:!0}),qe(r,JSON.stringify(t,null,2),`manifest`),this.done=!0}}static getMarkdown(e){return this.files[e]?new Li(this.files[e]).getContent():``}},Li=class{file;content=[];overviews=[];parts=[];scss;constructor(e){this.file=e,this.scss=e.build.scssLanguageService.getExternalDefinition(this.file.file.uri)??{};let t=this.file.srcInfo.available;if(this.file.fileParsed)for(let e of t)e.type==1||e.type==2||e.type==3?this.loadClass(e):e.type==4&&this.loadFunction(e);this.overviews.length>0&&(this.writeOverview(),this.writeContent())}isManifestClass(e){return e.isWebComponent!==void 0}isManifestFunction(e){return e.result!==void 0}getType(e){e instanceof M||(e=new M(e));let t=e.getFullTxt().trim();return t.startsWith(`___`)&&(t=t.substring(3)),t=t.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\|/g,`|`),t}loadFunction(e){let t=this.file.fileParsed.functions[e.fullName],n=t.fullName;if(t.node.typeParameters){let e=[];for(let n of t.node.typeParameters){let t=n.name.getText();n.constraint&&(t+=` extends `+this.getType(n.constraint)),n.default&&(t+=` = `+this.getType(n.default)),e.push(t)}e.length>0&&(n+=`<${e.join(`, `)}>`)}let r=[];for(let e of t.node.parameters){let t=e.name.getText();e.type?t+=`: `+this.getType(e.type):t+=`: any`,r.push(t)}n+=`(${r.join(`, `)})`;let i={name:n,result:t.node.type?this.getType(t.node.type):`any`,description:t.documentation?.definitions.join(x.EOL)??``,isAbstract:!1};this.parts.push(i)}loadClass(e){let t=this.file.fileParsed.classes[e.fullName],n=t.fullName;if(t.node.typeParameters){let e=[];for(let n of t.node.typeParameters){let t=n.name.getText();n.constraint&&(t+=` extends `+this.getType(n.constraint)),n.default&&(t+=` = `+this.getType(n.default)),e.push(t)}e.length>0&&(n+=`<${e.join(`, `)}>`)}let r={name:n,isWebComponent:t.isWebcomponent,tag:e.tagName?`<${e.tagName}></${e.tagName}>`:void 0,type:t.isInterface?`Interface`:`Class`,description:t.documentation?.definitions.join(x.EOL)??``,import:`import { ${t.name} } from "${this.file.name}:${t.namespace}.package.avt"`,parent:t.parentClass?.fullName,impl:t.implementsType.map(e=>this.getType(e)).join(`, `)};if(Object.keys(t.properties).length>0){r.jsProps=[];for(let e in t.properties){let n=this.loadProperty(t.properties[e]);n&&r.jsProps.push(n)}}if(Object.keys(t.propertiesStatic).length>0){r.jsPropsStatic=[];for(let e in t.propertiesStatic){let n=this.loadProperty(t.propertiesStatic[e]);n&&r.jsPropsStatic.push(n)}}if(Object.keys(t.methods).length>0){r.jsMethods=[];for(let e in t.methods){let n=this.loadMethod(t.methods[e]);n&&r.jsMethods.push(n)}}if(Object.keys(t.methodsStatic).length>0){r.jsMethodsStatic=[];for(let e in t.methodsStatic){let n=this.loadMethod(t.methodsStatic[e]);n&&r.jsMethodsStatic.push(n)}}if(t.isWebcomponent){if(e.tagName&&this.scss[e.tagName]&&this.scss[e.tagName].length>0){let t=this.scss[e.tagName];r.cssProps=[];for(let e of t)r.cssProps.push({name:e.name,type:e.type??``,description:e.documentation??``})}if(e.slots&&Object.keys(e.slots).length>0){r.htmlSlots=[];for(let t in e.slots)r.htmlSlots.push({name:t,description:e.slots[t].doc})}}this.overviews.push({name:t.fullName,type:r.isWebComponent?r.type+` (Webcomponent)`:r.type,description:r.tag?r.description+` (`+r.tag+`)`:r.description}),this.parts.push(r)}loadProperty(e){if(e.isPrivate||e.isProtected)return null;let t;return e.decorators.find(e=>In.is(e))&&(t=`@Property()`),e.decorators.find(e=>Fi.is(e))&&(t=`@Attribute()`),e.decorators.find(e=>Hn.is(e))&&(t=`@Watch()`),e.decorators.find(e=>Jn.is(e))&&(t=`@Signal()`),{name:e.name,type:this.getType(e.type),description:e.documentation?.definitions.join(x.EOL)??``,decorator:t}}loadMethod(e){if(e.isPrivate||e.isProtected)return null;let t=e.name;if(e.node.typeParameters){let n=[];for(let t of e.node.typeParameters){let e=t.name.getText();t.constraint&&(e+=` extends `+this.getType(t.constraint)),t.default&&(e+=` = `+this.getType(t.default)),n.push(e)}n.length>0&&(t+=`<${n.join(`, `)}>`)}let n=[];for(let t of e.node.parameters){let e=t.name.getText();t.type?e+=`: `+this.getType(t.type):e+=`: any`,n.push(e)}return t+=`(${n.join(`, `)})`,{name:t,result:e.node.type?this.getType(e.node.type):`any`,description:e.documentation?.definitions.join(x.EOL)??``,isAbstract:e.isAbstract}}getContent(){return this.content.join(x.EOL)}writeOverview(){this.add(`# `+this.file.name),this.line(),this.file.description&&(this.add(this.file.description),this.line()),this.add(`## Overview`),this.line(),this.addColumnsHeader([`Nom`,`Type`,`Description`]),this.overviews.sort((e,t)=>e.name.localeCompare(t.name));for(let e of this.overviews)this.addColumns([`[${e.name}](${e.name.toLowerCase()})`,e.type,e.description??``]);this.line()}writeContent(){this.parts.sort((e,t)=>e.name.localeCompare(t.name));for(let e of this.parts)this.add(`## `+e.name),this.line(),e.description&&(this.add(`${e.description}`),this.line()),this.isManifestClass(e)?this.writeClass(e):this.isManifestFunction(e)&&this.writeFunction(e),e.example&&(this.add(`### Example`),this.line(),this.add(e.example))}writeClass(e){e.isWebComponent?this.add(` - Type : ${e.type} (Webcomponent)`):this.add(` - Type : ${e.type}`),e.tag&&this.add(` - Tag : ${e.tag}`),this.add(` - Import : ${e.import}`),e.parent&&this.add(` - Parent : ${e.parent}`),e.impl&&this.add(` - Implements : ${e.impl}`);let t=e.isWebComponent;if(this.line(),e.jsProps&&e.jsProps.length>0&&(this.add(`### JS Props`),this.line(),this.writeProps(e.jsProps,t),this.line()),e.jsMethods&&e.jsMethods.length>0&&(this.add(`### Methods`),this.line(),this.writeMethods(e.jsMethods),this.line()),e.jsPropsStatic&&e.jsPropsStatic.length>0&&(this.add(`### JS Props Static`),this.line(),this.writeProps(e.jsPropsStatic,t),this.line()),e.jsMethodsStatic&&e.jsMethodsStatic.length>0&&(this.add(`### Methods Static`),this.line(),this.writeMethods(e.jsMethodsStatic),this.line()),e.htmlSlots&&e.htmlSlots.length>0){this.add(`### HTML Slots`),this.line(),this.addColumnsHeader([`Name`,`Description`]);for(let t of e.htmlSlots)this.addColumns([t.name,t.description??``]);this.line()}e.cssProps&&e.cssProps.length>0&&(this.add(`### CSS Props`),this.line(),this.writeProps(e.cssProps,!1),this.line())}writeFunction(e){this.add(` - Return : ${e.result}`)}writeProps(e,t){if(e.length!=0)if(t){this.addColumnsHeader([`Name`,`Type`,`Description`,`Decorator`]);for(let t of e)this.addColumns([t.name,t.type,t.description,t.decorator??``])}else{this.addColumnsHeader([`Name`,`Type`,`Description`]);for(let t of e)this.addColumns([t.name,t.type,t.description])}}writeMethods(e){if(e.length!=0){this.addColumnsHeader([`Name`,`Return`,`Description`]);for(let t of e){let e=t.description??``;t.isAbstract&&(e=`(abstract) `+e),this.addColumns([t.name,t.result,e])}}}line(){this.content.push(``)}add(e){this.content.push(e)}addColumns(e){let t=`| ${e.map(e=>e.replace(/\r\n|\n/g,``).replace(/ {2,}/g,` `).trim()).join(` | `)} |`;this.add(t)}addColumnsHeader(e){this.addColumns(e);let t=[];for(let n=0;n<e.length;n++)t.push(`---`);let n=`| ${t.join(` | `)} |`;this.add(n)}},Ri=class e{path;static instance;static getInstance(){return this.instance||=new e,this.instance}getPath(){return this.path}constructor(){this.path=(0,f.join)($.savePath,`packages`),(0,u.existsSync)(this.path)||(0,u.mkdirSync)(this.path,{recursive:!0})}predefinedPaths={"Aventus@Main":Tt(),"Aventus@UI":Et(),"Aventus@Sharp":Ot(),"Aventus@Php":kt(),"Aventus@I18n":Dt()};predefinedNpm={"Aventus@Main":`@aventusjs/main`,"Aventus@UI":`@aventusjs/ui`,"Aventus@I18n":`@aventusjs/i18n`,"Aventus@Sharp":`@aventussharp/main`,"Aventus@Php":`@aventusphp/main`};loadedPackages={};get packages(){let e=[];for(let t in this.loadedPackages)e.push(this.loadedPackages[t]);return e}async loadDependenciesFromBuild(e,t){let n={files:[],dependencyNeedUris:[],dependencyFullUris:[],dependencyUris:[]},r={},i={};for(let n in e.dependencies){let a=e.dependencies[n],o=await this.loadDependency(n,a,e,t,r);o&&(i[o.name]=a.include??`need`)}for(let e in r)i[e]||(i[e]=r[e].include);r[`Aventus@Main`]||await this.loadDependency(`Aventus@Main`,{uri:``,npm:``,version:`x.x.x`,include:`need`,subDependenciesInclude:{"*":`need`}},e,t,r),t?.buildConfig.i18n!==void 0&&!r[`Aventus@I18n`]&&await this.loadDependency(`Aventus@I18n`,{uri:``,npm:``,version:`x.x.x`,include:`need`,subDependenciesInclude:{"*":`need`}},e,t,r);let a=[];for(let e in r){let t=r[e];this.orderLoop(e,t,r,a)}for(let e of a){let t=r[e];t.file.loadWebComponents(),n.files.push(t.file);let a=i[e]??`need`;a==`full`?(n.dependencyFullUris.push(t.uri),n.dependencyUris.push(t.uri)):a==`need`&&(n.dependencyNeedUris.push(t.uri),n.dependencyUris.push(t.uri))}return n}orderLoop(e,t,n,r){let i=r.indexOf(e);if(i!=-1)return i+1;let a=0;for(let e of t.dependencies)if(n[e.name]){let t=this.orderLoop(e.name,n[e.name],n,r);t>=0&&t>a&&(a=t)}return r.splice(a,0,e),r.length}async loadDependency(e,t,n,r,i){let a,o;if(this.predefinedPaths[e]){t.uri=this.predefinedPaths[e];let n=D(t.uri);a=await this.loadByUri(r,n),o=n}else if(t.uri)if(t.uri.startsWith(`http`))$.showErrorMessage(`http package isn't supported right now. Plz use the store`);else{let e=D(t.uri);a=await this.loadByUri(r,e),o=e}else if(t.isLocal){let t=await this.loadLocal(e,r);a=t.file,o=t.uri}else if(t.version){let n=await this.loadStore(e,t.version,r);n?(a=n.file,o=n.uri):$.showErrorMessage(`Can't load `+e+` from the store`)}else $.showErrorMessage(`You need to define a version to load a package via the store (`+e+`)`);if(o&&a){let s=t.version?this.parseVersion(t.version):{major:-1,minor:-1,patch:-1};if(t.npm)a.npmUri=t.npm;else if(this.predefinedNpm[e])a.npmUri=this.predefinedNpm[e];else{let e=/\/\/ npm:(.*)$/m.exec(a.file.contentUser);e&&(a.npmUri=e[1])}let c=/\/\* description:(.*) \*\//gm.exec(a.file.contentUser);c&&(a.description=c[1]);let l=async(e,a)=>{i[e.name]={file:e,uri:a,include:t.include??`need`,version:s,dependencies:[]};for(let t in e.dependencies){let a=e.dependencies[t];typeof a==`string`&&(a={version:a});let o=await this.loadDependency(t,a,n,r,i);if(o){let t=i[e.name].dependencies.find(e=>e.name==o.name),n=`need`;a.subDependenciesInclude&&a.subDependenciesInclude[o.name]&&(n=a.subDependenciesInclude[o.name]),t?(t.include==`none`&&n!=`none`||t.include==`need`&&n==`full`)&&(t.include=n):i[e.name].dependencies.push({name:o.name,include:n})}}e.name!=`Aventus@Main`&&(i[e.name].dependencies.find(e=>e.name==`Aventus@Main`)||i[e.name].dependencies.push({name:`Aventus@Main`,include:`need`}))};if(!i[a.name])await l(a,o);else{let e=i[a.name].version;this.compareVersion(e,s,a.name)==s&&await l(a,o)}Ii.register(a)}return a}async loadByUri(e,t){let n=await R.getInstance().registerFilePackage(t);return this.loadPackage(n,e)}async loadLocal(e,t){let n=D((0,f.join)(this.path,`@locals`,e));n.endsWith(T.Package)||(n+=T.Package);let r=await R.getInstance().registerFilePackage(n),i=this.loadPackage(r,t);return{uri:n,file:i}}async loadStore(e,t,n){let r=(0,f.join)(this.path,`store`,e,t),i=(0,u.existsSync)(r),{major:a,minor:o,patch:s}=this.parseVersion(t),c=null;if(i&&(c=this.findPackage(r),c||(i=!1)),!i){(0,u.existsSync)(r)&&(0,u.rmSync)(r,{force:!0,recursive:!0}),(0,u.mkdirSync)(r,{recursive:!0});let n=(0,f.join)(r,`temp.zip`);if(!await this.downloadFile(n,Ni.url+`/package/download/${e}/${t}`)||!await this.extractZip(n,r))return null;if((0,u.rmSync)(n,{force:!0}),c=this.findPackage(r),!c)return;let i=await this.readFirstLine(c),a=/\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)/g.exec(i);if(!a)return console.error(`Invalid package header for "${e}@${t}". First line:`,JSON.stringify(i)),null;let o=a[1],s=Number(a[2]),l=Number(a[3]),d=Number(a[4]),p=s+`.`+l+`.`+d;if(o!==e)return console.error(`Package name mismatch: requested "${e}", downloaded "${o}"`),null;if(p!==t)return console.error(`Package version mismatch: requested "${t}", downloaded "${p}"`),null}if(!c)return console.error(`Package file not found after extracting "${e}@${t}" into "${r}"`),null;let l=D(c),d=await R.getInstance().registerFilePackage(l);return{uri:l,file:this.loadPackage(d,n)}}extractZip(e,t){return new Promise(n=>{let r=!1,i=e=>{r||(r=!0,n(e))},a=(0,u.createReadStream)(e),o=(0,de.Extract)({path:t});a.on(`error`,t=>{console.error(`Can't read ZIP "${e}":`,t),i(!1)}),o.on(`close`,()=>i(!0)),o.on(`error`,t=>{console.error(`Can't extract ZIP "${e}":`,t),i(!1)}),a.pipe(o)})}findPackage(e){let t=null,n=(0,u.readdirSync)(e);for(let r of n)if(r.endsWith(T.Package)){t=(0,f.join)(e,r);break}return t}loadPackage(e,t){let n=xn.getQuickInfo(e);if(n)return this.loadedPackages[n.name]=new xn(e,t),this.loadedPackages[n.name]}downloadFile(e,t){return new Promise(n=>{let r=()=>{try{(0,u.existsSync)(e)&&(0,u.unlinkSync)(e)}catch{}};(t.startsWith(`https:`)?ue.get:ne.get)(t,i=>{let a=i.statusCode??0;if(a>=300&&a<400&&i.headers.location){i.resume(),this.downloadFile(e,i.headers.location).then(n).catch(()=>n(!1));return}if(a<200||a>=300){console.error(`Download failed: HTTP ${a} for ${t}`),i.resume(),r(),n(!1);return}let o=(0,u.createWriteStream)(e);o.on(`error`,t=>{console.error(`File write error for ${e}:`,t),i.destroy(),r(),n(!1)}),i.on(`error`,e=>{console.error(`HTTP response error for ${t}:`,e),o.destroy(),r(),n(!1)}),o.on(`finish`,()=>{o.close(t=>{if(t){console.error(`File close error for ${e}:`,t),r(),n(!1);return}n(!0)})}),i.pipe(o)}).on(`error`,e=>{console.error(`HTTP request error for ${t}:`,e),r(),n(!1)})})}readFirstLine(e){return new Promise(function(t,n){var r=(0,u.createReadStream)(e,{encoding:`utf8`}),i=``,a=0,o;r.on(`data`,function(e){o=e.indexOf(`
|
|
428
428
|
`),i+=e,o===-1?a+=e.length:r.close()}).on(`close`,function(){t(i.slice(0,a+o))}).on(`error`,function(e){n(e)})})}parseVersion(e){let t=/([0-9xX]+)\.([0-9xX]+)\.([0-9xX]+)/g.exec(e)??[0,-1,-1,-1];return{major:isNaN(Number(t[1]))?-1:Number(t[1]),minor:isNaN(Number(t[2]))?-1:Number(t[2]),patch:isNaN(Number(t[3]))?-1:Number(t[3])}}compareVersion(e,t,n){let r=r=>{if(e[r]==-1)return t[r]==-1?null:t;if(t[r]==-1)return e;if(e[r]==t[r])return null;{let r=Object.values(e).join(`.`),i=Object.values(t).join(`.`);return $.showErrorMessage(`Can't resolve version for dependency ${n} between ${r} and ${i}`),-1}};for(let e of[`major`,`minor`,`patch`]){let t=r(e);if(typeof t==`number`)return null;if(t)return t}return e}},zi=class{static send(e,t){$.sendNotification(`aventus/addDebugFile`,e,t)}},Bi=class{infos={};lastInfo=``;lastInfoToCompile=``;internalNames=[];build;storedInfo={};constructor(e){this.build=e}getInternalName(e){if(e=="default"&&(e=`_default`),!this.internalNames.includes(e))return this.internalNames.push(e),e;let t=0,n=e+`_`+t;for(;this.internalNames.includes(n);)t++,n=e+`_`+t;return this.internalNames.push(n),n}register(e,t){this.storedInfo[e]||(this.storedInfo[e]=[]),this.storedInfo[e].push(t),this.rebuildInfo()}unregister(e){this.storedInfo[e]&&(delete this.storedInfo[e],this.rebuildInfo())}rebuildInfo(){if(this.build.isBuildAllowed){this.infos={},this.internalNames=[];for(let e in this.storedInfo)for(let t of this.storedInfo[e]){let n=t.uri;if(this.infos[n]||(this.infos[n]={md5:Je(n),part:{}}),t.libName==`*`){if(!t.alias)throw`The lib ${n} inside the file ${e} has no alias => impossible`;let r=this.infos[n].all;r||(r={externalAlias:[],internalAlias:this.getInternalName(`_default`)},this.infos[n].all=r),r.externalAlias.includes(t.alias)||r.externalAlias.push(t.alias)}else{let e=this.infos[n].part;e[t.libName]||(e[t.libName]={externalAlias:[],internalAlias:this.getInternalName(t.libName)});let r=t.alias?t.alias:t.libName;e[t.libName].externalAlias.includes(r)||e[t.libName].externalAlias.push(r)}}}}npmBuildTxt=``;npmDepBuildTxt={result:``,errors:[]};async compile(){if(Object.keys(this.infos).length==0)return{result:``,errors:[]};let e=JSON.stringify(this.infos);if(this.lastInfo!=e){this.lastInfo=e;let t=this.writeFileToCompile();this.lastInfoToCompile!=t.buildTxt&&(ki.part(`Compiling node modules`),this.lastInfoToCompile=t.buildTxt,this.npmDepBuildTxt=await this.esbuildBuild(this.lastInfoToCompile),ki.part(`Compiling node modules done`)),this.npmBuildTxt=`var npmCompilation;`+x.EOL,this.npmBuildTxt+=`(npmCompilation||(npmCompilation = {}));`+x.EOL,this.npmBuildTxt+=`(function (npmCompilation) {
|
|
429
429
|
${this.npmDepBuildTxt.result+x.EOL}
|
|
430
430
|
${t.toExport}
|
|
431
431
|
})(npmCompilation);`+x.EOL}return{result:this.npmBuildTxt,errors:this.npmDepBuildTxt.errors}}writeFileToCompile(){let e=``,t=``,n=[],r=Object.keys(this.infos);r.sort();for(let i of r){let r=this.infos[i];if(t+=`npmCompilation['${r.md5}'] = {};`+x.EOL,r.all){e+=`import * as ${r.all.internalAlias} from "${i}";`+x.EOL,n.push(r.all.internalAlias);for(let e of r.all.externalAlias)t+=`npmCompilation['${r.md5}']['${e}'] = _.default['${r.all.internalAlias}'];`+x.EOL;for(let e in r.part)for(let n of r.part[e].externalAlias)t+=`npmCompilation['${r.md5}']['${n}'] = _.default['${r.all.internalAlias}'];`+x.EOL}else{let a=[],o=Object.keys(r.part);o.sort();for(let e of o){a.push(`${e} as ${r.part[e].internalAlias}`),n.push(r.part[e].internalAlias);for(let n of r.part[e].externalAlias)t+=`npmCompilation['${r.md5}']['${n}'] = _.default['${r.part[e].internalAlias}'];`+x.EOL}e+=`import {${Object.values(a).join(`, `)}} from "${i}";`+x.EOL}}return e+=`export default { ${n.join(`, `)} }`,{buildTxt:e,toExport:t}}async esbuildBuild(e){let t={result:``,errors:[]};try{let n=(0,f.dirname)(this.build.nodeModulesDir),r=this.getPotentialNodeModulesPaths(n);t.result=(await(0,me.build)({stdin:{contents:e,resolveDir:n,sourcefile:`index.js`},bundle:!0,format:`iife`,globalName:`_`,nodePaths:r,minify:!0,define:{"process.env.NODE_ENV":`"production"`},legalComments:`none`,write:!1})).outputFiles?.[0].text||``}catch(e){let n=this.build.fullname+`_npmErrors`,r=(e+``).replace(/\0/g,``);zi.send(n,r),t.errors.push({title:`Npm compilation errors`,file:n})}return t}getPotentialNodeModulesPaths(e){let t=[],n=(0,f.resolve)(e);for(;;){let e=(0,f.join)(n,`node_modules`);(0,u.existsSync)(e)&&t.push(e);let r=(0,f.dirname)(n);if(r===n)break;n=r}return t}},Vi=class extends st{regionLogic={start:0,end:0};regionStyle={start:0,end:0};regionView={start:0,end:0};regionI18n={start:0,end:0};get logic(){if(this.regionLogic.file)return this.regionLogic.file;throw`should not append`}get style(){return this.regionStyle.file}get view(){return this.regionView.file}get i18n(){return this.regionI18n.file}get extension(){return T.Component}constructor(e,t){super(e,t);let n=this.getDocuments();this.regionLogic.file=n.ts,this.regionStyle.file=n.scss,this.regionView.file=n.html}async init(){await this.regionView.file?.init(),await this.regionStyle.file?.init(),(!this.regionView.file||!this.regionStyle.file)&&await this.file.validate()}async onValidate(){await this.transformDocument();let e=[],t=[],n=async n=>{if(n.file){let r=await n.file.file.validate(),i=n.file.file.documentInternal;for(let a of r)a.source=w.WebComponent,t.indexOf(a.range)==-1&&(t.push(a.range),a.range.start=this.file.documentInternal.positionAt(i.offsetAt(a.range.start)+n.start),a.range.end=this.file.documentInternal.positionAt(i.offsetAt(a.range.end)+n.start)),e.push(a)}};return await n(this.regionStyle),await n(this.regionView),await n(this.regionLogic),e}waitingFct={};currentVersion=``;isCompiling=!1;transformDocument(){return new Promise(async e=>{let t=this.file.versionInternal+``,n=this.build.insideRebuildAll;if(t==this.currentVersion&&!n)e();else if(this.isCompiling)this.waitingFct[t]||(this.waitingFct[t]=[]),this.waitingFct[t].push(()=>{e()});else{this.isCompiling=!0;let n=this.splitDocument(),r=async(e,t,n)=>{let r=d.TextDocument.create(this.file.uri,t,this.file.versionUser,n);if(e.file)await e.file.triggerContentChange(r);else if(t==w.HTML){let t=new gi(new j(d.TextDocument.create(this.file.uri,w.HTML,this.file.versionUser,n)),this.build);e.file=t,await t.init()}else if(t==w.SCSS){let t=new hi(new j(d.TextDocument.create(this.file.uri,w.SCSS,this.file.versionUser,n)),this.build);e.file=t,await t.init()}};if(n.cssText===null?this.regionStyle.file&&(this.regionStyle.file.triggerDelete(),this.regionStyle.file=void 0):await r(this.regionStyle,w.SCSS,n.cssText),n.htmlText===null?this.regionView.file&&(this.regionView.file.triggerDelete(),this.regionView.file=void 0):await r(this.regionView,w.HTML,n.htmlText),n.scriptText!==null&&await r(this.regionLogic,w.TypeScript,n.scriptText),this.isCompiling=!1,this.currentVersion=t,this.waitingFct[t])for(let e of this.waitingFct[t])e();e()}})}async onContentChange(){await this.transformDocument()}async onSave(){this.build.disableBuild(),this.style&&await this.style.file.triggerSave(),this.view&&await this.view.file.triggerSave(),this.build.enableBuild(),await this.logic.file.triggerSave()}async onCompletion(e,t){await this.transformDocument();let n=e.documentInternal.offsetAt(t),r=[],i=async e=>{if(n>=e.start&&n<=e.end&&e.file){let t=await(e.file?.file).getCompletion(e.file.file.documentInternal.positionAt(n-e.start));for(let n of t.items)if(n.data&&n.data.uri&&(n.data.previousLanguageId=n.data.languageId,n.data.languageId=w.WebComponent),n.textEdit){let t=n.textEdit;t.range&&r.indexOf(t.range)==-1&&(r.push(t.range),t.range.start=this.transformPosition(e.file,t.range.start,this,e.start*-1),t.range.end=this.transformPosition(e.file,t.range.end,this,e.start*-1))}return t}};return await i(this.regionStyle)||await i(this.regionView)||await i(this.regionLogic)||{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){let n=[];if(t.data&&t.data.previousLanguageId){let e=t.data.previousLanguageId;delete t.data.previousLanguageId;let r=async(r,i)=>{if(e==i){let e=r.file;if(e){let i=await e.file.getCompletionResolve(t);if(i.additionalTextEdits)for(let t of i.additionalTextEdits)e.file.documentInternal.offsetAt(t.range.start)==0&&(t.newText=x.EOL+t.newText),n.indexOf(t.range)==-1&&!t.range.wc_transformed&&(n.push(t.range),t.range.wc_transformed=!0,t.range.start=this.transformPosition(e,t.range.start,this,r.start*-1),t.range.end=this.transformPosition(e,t.range.end,this,r.start*-1));return i}}},i=await r(this.regionStyle,w.SCSS);if(i)return i;let a=await r(this.regionView,w.HTML);if(a)return a;let o=await r(this.regionLogic,w.TypeScript);if(o)return o}return t}async onHover(e,t){let n=e.documentInternal.offsetAt(t),r=[],i=async e=>{if(n>=e.start&&n<=e.end&&e.file){let t=await e.file.file.getHover(e.file.file.documentInternal.positionAt(n-e.start));return t?.range&&r.indexOf(t.range)==-1&&(r.push(t.range),t.range.start=this.transformPosition(e.file,t.range.start,this,e.start*-1),t.range.end=this.transformPosition(e.file,t.range.end,this,e.start*-1)),t}return null};return await i(this.regionStyle)||await i(this.regionView)||await i(this.regionLogic)||null}async onDefinition(e,t){let n=e.documentInternal.offsetAt(t),r=null;return this.style&&n>=this.regionStyle.start&&n<=this.regionStyle.end?r=await this.style.file.getDefinition(this.style.file.documentInternal.positionAt(n-this.regionStyle.start)):this.view&&n>=this.regionView.start&&n<=this.regionView.end?r=await this.view.file.getDefinition(this.view.file.documentInternal.positionAt(n-this.regionView.start)):n>=this.regionLogic.start&&n<=this.regionLogic.end&&(r=await this.logic.file.getDefinition(this.logic.file.documentInternal.positionAt(n-this.regionLogic.start))),r}async onFormatting(e,t,n){let r=[],i=[],a=e=>{let t=``;for(let n=0;n<e*4;n++)t+=` `;return t},o=async(e,t)=>{if(e.file){let o=await e.file.file.getFormatting(n);for(let n of o)t.tab&&(n.newText=n.newText.split(`
|
|
432
432
|
`).join(`
|
|
433
|
-
`+a(1))),t.firstLast&&(n.newText=n.newText.trim(),n.range.start.character==0&&n.range.start.line==0&&(n.newText=t.tab?x.EOL+a(1)+n.newText:x.EOL+n.newText),e.file.file.documentInternal.offsetAt(n.range.end)==e.file.file.documentInternal.getText().length&&(n.newText+=x.EOL)),i.indexOf(n.range)==-1&&(i.push(n.range),n.range.start=this.transformPosition(e.file,n.range.start,this,e.start*-1),n.range.end=this.transformPosition(e.file,n.range.end,this,e.start*-1)),r.push(n)}};return await o(this.regionStyle,{firstLast:!0,tab:!0}),await o(this.regionView,{firstLast:!0,tab:!0}),await o(this.regionLogic,{firstLast:!1,tab:!1}),r}async onCodeAction(e,t){let n={start:e.documentInternal.offsetAt(t.start),end:e.documentInternal.offsetAt(t.end)},r=[],i=async i=>{if(this.isOverlapping(n,i)&&i.file){let n=await i.file.file.getCodeAction({start:this.transformPosition(this,t.start,i.file,i.start),end:this.transformPosition(this,t.end,i.file,i.start)});for(let t of n)if(t.edit&&t.edit.changes){let n=[];for(let e in t.edit.changes){let a=t.edit.changes[e];for(let e of a)r.indexOf(e.range)==-1&&(r.push(e.range),e.range.start=this.transformPosition(i.file,e.range.start,this,i.start*-1),e.range.end=this.transformPosition(i.file,e.range.end,this,i.start*-1)),n.push(e)}n.length>0&&(delete t.edit.changes[i.file.file.uri],t.edit.changes[e.uri]=n)}return n}},a;return a=await i(this.regionStyle),a||(a=await i(this.regionView),a)||(a=await i(this.regionLogic),a)?a:[]}async onDelete(){delete this.build.tsFiles[this.file.uri]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}getDocuments(){let e=this.splitDocument();e.htmlText!==null&&new gi(new j(d.TextDocument.create(this.file.uri,w.HTML,this.file.versionUser,e.htmlText)),this.build);let t;e.cssText!==null&&(t=new hi(new j(d.TextDocument.create(this.file.uri,w.SCSS,this.file.versionUser,e.cssText)),this.build));let n=new F(new j(d.TextDocument.create(this.file.uri,w.TypeScript,this.file.versionUser,e.scriptText??``)),this.build),r={html:void 0,scss:t,ts:n};return this.build.tsFiles[r.ts.file.uri]=r.ts,r}splitDocument(){let e=/<script>(
|
|
433
|
+
`+a(1))),t.firstLast&&(n.newText=n.newText.trim(),n.range.start.character==0&&n.range.start.line==0&&(n.newText=t.tab?x.EOL+a(1)+n.newText:x.EOL+n.newText),e.file.file.documentInternal.offsetAt(n.range.end)==e.file.file.documentInternal.getText().length&&(n.newText+=x.EOL)),i.indexOf(n.range)==-1&&(i.push(n.range),n.range.start=this.transformPosition(e.file,n.range.start,this,e.start*-1),n.range.end=this.transformPosition(e.file,n.range.end,this,e.start*-1)),r.push(n)}};return await o(this.regionStyle,{firstLast:!0,tab:!0}),await o(this.regionView,{firstLast:!0,tab:!0}),await o(this.regionLogic,{firstLast:!1,tab:!1}),r}async onCodeAction(e,t){let n={start:e.documentInternal.offsetAt(t.start),end:e.documentInternal.offsetAt(t.end)},r=[],i=async i=>{if(this.isOverlapping(n,i)&&i.file){let n=await i.file.file.getCodeAction({start:this.transformPosition(this,t.start,i.file,i.start),end:this.transformPosition(this,t.end,i.file,i.start)});for(let t of n)if(t.edit&&t.edit.changes){let n=[];for(let e in t.edit.changes){let a=t.edit.changes[e];for(let e of a)r.indexOf(e.range)==-1&&(r.push(e.range),e.range.start=this.transformPosition(i.file,e.range.start,this,i.start*-1),e.range.end=this.transformPosition(i.file,e.range.end,this,i.start*-1)),n.push(e)}n.length>0&&(delete t.edit.changes[i.file.file.uri],t.edit.changes[e.uri]=n)}return n}},a;return a=await i(this.regionStyle),a||(a=await i(this.regionView),a)||(a=await i(this.regionLogic),a)?a:[]}async onDelete(){delete this.build.tsFiles[this.file.uri]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}getDocuments(){let e=this.splitDocument();e.htmlText!==null&&new gi(new j(d.TextDocument.create(this.file.uri,w.HTML,this.file.versionUser,e.htmlText)),this.build);let t;e.cssText!==null&&(t=new hi(new j(d.TextDocument.create(this.file.uri,w.SCSS,this.file.versionUser,e.cssText)),this.build));let n=new F(new j(d.TextDocument.create(this.file.uri,w.TypeScript,this.file.versionUser,e.scriptText??``)),this.build),r={html:void 0,scss:t,ts:n};return this.build.tsFiles[r.ts.file.uri]=r.ts,r}splitDocument(){let e=/<script>([\s\S]*?)<\/script>/g,t=/<template>([\s\S]*?)<\/template>/g,n=/<style>([\s\S]*?)<\/style>/g,r={cssText:null,htmlText:null,scriptText:null},i=e.exec(this.file.contentInternal);if(i){let e=i.index+8;this.regionLogic.start=e;let t=i.index+i[0].length-9;this.regionLogic.end=t,r.scriptText=this.file.contentInternal.substring(e,t)}let a=n.exec(this.file.contentInternal);if(a){let e=a.index+7;this.regionStyle.start=e;let t=a.index+a[0].length-8;this.regionStyle.end=t,r.cssText=this.file.contentInternal.substring(e,t)}let o=t.exec(this.file.contentInternal);if(o){let e=o.index+10;this.regionView.start=e;let t=o.index+o[0].length-11;this.regionView.end=t,r.htmlText=this.file.contentInternal.substring(e,t)}return r}transformPosition(e,t,n,r){let i=e.file.documentInternal.offsetAt(t);return n.file.documentInternal.positionAt(i-r)}isOverlapping(e,t){return t.start<e.start&&t.end>e.start||t.start<e.end&&t.end>e.end||t.start>e.start&&t.end<e.end}static getRegion(e){let t=/<script>([\s\S]*?)<\/script>/g,n=/<template>([\s\S]*?)<\/template>/g,r=/<style>([\s\S]*?)<\/style>/g,i={cssText:null,htmlText:null,scriptText:null},a=t.exec(e.contentInternal);if(a){let t=a.index+8,n=a.index+a[0].length-9;i.scriptText=e.contentInternal.substring(t,n)}let o=r.exec(e.contentInternal);if(o){let t=o.index+7,n=o.index+o[0].length-8;i.cssText=e.contentInternal.substring(t,n)}let s=n.exec(e.contentInternal);if(s){let t=s.index+10,n=s.index+s[0].length-11;i.htmlText=e.contentInternal.substring(t,n)}return i}onGetBuild(){return[this.build]}},Hi=class{manifest;_package;constructor(e){this.manifest=e,this._package={modules:[],schemaVersion:`1.0.0`,readme:``}}write(e){qe((0,f.join)(e,`custom-elements.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!e.fileParsed||!(e instanceof F))return;let n=t.class,r=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!r)return;let i={kind:`javascript-module`,path:this.getLocalUri(e.file.uri),declarations:[],exports:[]},a={kind:`class`,description:``,name:n.name,customElement:!0};if(n.documentation&&(a.summary=n.documentation?.definitions.join(`
|
|
434
434
|
`)),r.tagName&&(a.tagName=r.tagName),this.manifest.manifestConfig.srcBaseUrl&&(a.source={href:this.getSourceUri(e.file.uri)}),n.extends&&n.extends.length>0){let e=N.getInfoByFullName(n.extends[0],n);if(e&&e instanceof un)if(a.superclass={name:e.name},e.fileUri.endsWith(T.Package)){let t=this.manifest.build.externalPackageInformation.getByUri(e.fileUri);t&&t.npmUri&&(a.superclass.package=t.npmUri)}else a.superclass.module=this.getLocalUri(e.fileUri)}let o=[];for(let e of t.cssProperties){if(!e.local)continue;let t={name:e.name};e.defaultValue&&(t.default=e.defaultValue),e.documentation&&(t.description=e.documentation),e.type&&(t.syntax=e.type),o.push(t)}o.length>0&&(a.cssProperties=o);let s=[];for(let e of t.attributes){if(!e.local)continue;let t={name:e.name,fieldName:e.name,type:{text:this.getTypeTxt(e.type)}};if(e.defaultValue&&(t.default=e.defaultValue),e.documentation&&(t.description=e.documentation.definitions.join(`
|
|
435
435
|
`)),e.isOverride){let r=n.getFieldParentClass(e.name);if(r)if(t.inheritedFrom={name:r.name},r.fileUri.endsWith(T.Package)){let e=this.manifest.build.externalPackageInformation.getByUri(r.fileUri);e&&e.npmUri&&(t.inheritedFrom.package=e.npmUri)}else t.inheritedFrom.module=this.getLocalUri(r.fileUri)}s.push(t)}s.length>0&&(a.attributes=s);let c=[],l=(e,t)=>{if(!e.local)return;let r=e.name,i={kind:`field`,name:e.name,static:t};if(e.defaultValue&&(i.default=e.defaultValue),e.documentation&&(i.description=e.documentation.definitions.join(`
|
|
436
436
|
`)),e.isPrivate?i.privacy=`private`:e.isProtected?i.privacy=`protected`:i.privacy=`public`,e.isOverride){let e=t?n.getStaticFieldParentClass(r):n.getFieldParentClass(r);if(e)if(i.inheritedFrom={name:e.name},e.fileUri.endsWith(T.Package)){let t=this.manifest.build.externalPackageInformation.getByUri(e.fileUri);t&&t.npmUri&&(i.inheritedFrom.package=t.npmUri)}else i.inheritedFrom.module=this.getLocalUri(e.fileUri)}i.type={text:this.getTypeTxt(e.type)},c.push(i)};for(let e of t.props)l(e,!1);for(let e of t.propsStatic)l(e,!0);let u=(e,t)=>{if(!e.local)return;let r=e.name,i={kind:`method`,name:e.name,static:t};if(e.documentation&&(i.description=e.documentation.definitions.join(`
|
|
@@ -489,7 +489,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
489
489
|
return useValue ? value : void 0;
|
|
490
490
|
};
|
|
491
491
|
`);let s=this._buildStringModule(this.buildConfig.module,e.codeNoNamespaceBefore,e.code,e.classesName,e.codeNoNamespaceAfter,a),c=await this.npmBuilder.compile();i=[...i,...c.errors];for(let e of n){let n={};for(let t in e){let i=e[t].path;n[i]||(n[i]={code:o,compressed:(`compressed`in e[t]?e[t].compressed:r)??!1})}e[`@npm`]?n[e[`@npm`].path].code+=c.result:n[e[`@default`].path].code+=c.result;for(let r of t)e[r.lib]?n[e[r.lib].path].code+=r.code+x.EOL:n[e[`@default`].path].code+=r.code+x.EOL;n[e[`@default`].path].code+=s;for(let e in n){let t=Le(e.replace(/\\/g,`/`));(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let r=n[e];if(r.compressed)try{r.code=(await(0,pe.minify)({"file1.js":r.code},{compress:!0,format:{comments:!1}})).code??``}catch(e){$.error(e)}this.writeFile(e,r.code)}}}return i}writeBuildDocumentation(e,t,n,r){let i=``;i=`declare global {`+x.EOL,i+=`
|
|
492
|
-
namespace `+this.buildConfig.module+`{`+x.EOL,i+=t.doc.join(x.EOL)+x.EOL,i+=` }`,t.docNoNamespace.length>0?i+=x.EOL+t.docNoNamespace.join(x.EOL)+x.EOL:i+=x.EOL,i+=`}`+x.EOL,t.docInvisible.length>0&&(i+=`declare module ___`+this.buildConfig.module+` {`+x.EOL,i+=t.docInvisible.join(x.EOL),i+=`}`);let a=`// `+this.buildConfig.fullname+`:`+this.buildConfig.version+x.EOL;if(r.path.length>0){let e=r.npmName==``?(`@`+this.buildConfig.module+`/`+this.buildConfig.name).toLowerCase():r.npmName;a+=`// npm:`+e+x.EOL}this.buildConfig.description&&(a+=`/* description:`+this.buildConfig.description+` */`+x.EOL),a+=`//#region js def //`+x.EOL+i,a+=`//#endregion js def //`+x.EOL,a+=`//#region js src //`+x.EOL+JSON.stringify(n)+x.EOL,a+=`//#endregion js src //`+x.EOL,a+=`//#region css def //`+x.EOL,a+=JSON.stringify(this.scssLanguageService.getInternalDocumentation())+x.EOL,a+=`//#endregion css def //`+x.EOL,a+=`//#region css //`+x.EOL,a+=JSON.stringify(t.stylesheets)+x.EOL,a+=`//#endregion css //`+x.EOL,a+=`//#region html //`+x.EOL,a+=JSON.stringify(t.htmlDoc)+x.EOL,a+=`//#endregion html //`+x.EOL,a+=`//#region dependencies //`+x.EOL,a+=JSON.stringify(this.buildConfig.rawDependencies)+x.EOL,a+=`//#endregion dependencies //`+x.EOL;for(let t of e)t?this.writeFile(t,a):(0,u.existsSync)(t)&&(0,u.unlinkSync)(t);let o=(0,f.join)(Ri.getInstance().getPath(),`@locals`);(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0}),this.writeFile((0,f.join)(o,this.buildConfig.fullname+T.Package),a)}writeBuildNpm(e,t){let n=Object.keys(t.npm);n.includes(``)||n.push(``);for(let e of n){let t=e.split(`.`),r=``;for(let e of t)r=r?`${r}.${e}`:e,n.includes(r)||n.push(r)}n.sort((e,t)=>(e.match(/\./g)||[]).length-(t.match(/\./g)||[]).length);let r={},i=e.manifest?new Ki(e.manifest,this):null;for(let n in t.npmsrc){let a=``;for(let e in t.npmsrc[n].imports){let r=t.npmsrc[n].imports[e];r.length>0&&(a+=`import { ${r.join(`, `)} } from "${e}";`+x.EOL)}if(a!=``&&(a+=x.EOL),a+=t.npmsrc[n].content.join(x.EOL),a=wn.removeUnusedImport(a,t.npmsrc[n].forcedDependencies),i)for(let e of t.npmsrc[n].sourceUri){let t=this.tsFiles[e];t&&i.register(t)}for(let t of e.path){let e=(0,f.join)(t,`__src`,...Le(n).split(f.sep)),r=(0,f.join)(t,`__src`,...n.split(f.sep));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0}),this.writeFile(r,a)}for(let e of t.npmsrc[n].names){let t=e.split(`.`),i=t.pop()??``,a=[];for(let e=0;e<t.length;e++)a.push(`..`);a=[...a,`__src`,...n.split(f.sep)];let o=t.join(`.`);r[o]||(r[o]={});let s=a.join(`/`);r[o][s]||(r[o][s]=[]),r[o][s].push(i)}}let a=(t,r)=>{r||={content:[],imports:{}};let i=``,a=``,o=t==``?0:t.split(`.`).length,s=[];for(let e of n)if(e.startsWith(t)&&e!=t){let t=e.split(`.`);if(t.length==o+1){let e=t[t.length-1];i+=`import * as ${e} from "./${e}";`+x.EOL,a+=`export { ${e} };`+x.EOL,s.push(`./${e}`)}}for(let e in r.imports){let t=r.imports[e];t.length>0&&(i+=`import { ${t.join(`, `)} } from "${e}";`+x.EOL)}i+=x.EOL+r.content.join(x.EOL)+x.EOL,i+=a,i=i.replaceAll(`globalThis.Aventus.`,``),i=i.replaceAll(`___Aventus.`,``),i=wn.removeUnusedImport(i,[]);for(let n of e.path){let e=(0,f.join)(n,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0});let r=(0,f.join)(e,`index.d.ts`);this.writeFile(r,i)}},o=t=>{let i=``,a=``,o=t==``?0:t.split(`.`).length;for(let e of n)if(e.startsWith(t)&&e!=t){let t=e.split(`.`);if(t.length==o+1){let e=t[t.length-1];i+=`import * as ${e} from "./${e}/index.js";`+x.EOL,a+=`export { ${e} };`+x.EOL}}let s=r[t];if(s)for(let e in s){let t=s[e].join(`, `);i+=`export { ${t} } from "${e}"`+x.EOL}i+=a,i=wn.removeUnusedImport(i,[]);for(let n of e.path){let e=(0,f.join)(n,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0});let r=(0,f.join)(e,`index.js`);this.writeFile(r,i)}};for(let e of n)a(e,t.npm[e]),o(e);if(e.packageJson){let t=(0,f.join)(this.project.getConfigFile().folderPath,`package.json`),n={};(0,u.existsSync)(t)&&(n=JSON.parse((0,u.readFileSync)(t,`utf-8`)));let r={};for(let e of this.externalPackageInformation.filesUri){let t=this.externalPackageInformation.getByUri(e);t&&t.npmUri&&t.name!=this.buildConfig.fullname&&(n.dependencies&&n.dependencies[t.npmUri]?r[t.npmUri]=n.dependencies[t.npmUri]:r[t.npmUri]=`^`+t.versionTxt)}let i=`Aventus build for @`+this.buildConfig.module,a=this.buildConfig.module;this.buildConfig.name&&(i+=`/`+this.buildConfig.name,a+=` `+this.buildConfig.name);let o={name:e.npmName==``?(`@`+this.buildConfig.module+`/`+this.buildConfig.name).toLowerCase():e.npmName,displayName:a,description:i,version:this.buildConfig.version,type:`module`,main:`index.js`,types:`index.d.ts`,dependencies:r};this.buildConfig.organization?o.author={name:this.buildConfig.organization}:Ni.isConnected&&(o.author={name:Ni.settings.username});for(let t of e.path){(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let e=(0,f.join)(t,`package.json`),n={};if((0,u.existsSync)(e))try{n=JSON.parse((0,u.readFileSync)(e,`utf8`))}catch{}let r={...o,...n};r.name=o.name,r.displayName=o.displayName,r.version=o.version,this.writeFile(e,JSON.stringify(r,null,2))}}if(i)for(let t of e.path)(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0}),i.write(t)}writeBuildI18n(e){let t=this.buildConfig.i18n?.locales??[];for(let n of e)for(let e of n.output){t.length>0&&!(0,u.existsSync)(e)&&(0,u.mkdirSync)(e,{recursive:!0});for(let r of t)if(n.mode==`singleFile`){let t={};for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e];t={...t,...n.exported[r]}}for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[r]}}let n=(0,f.join)(e,r+`.json`).toLowerCase();this.writeFile(n,JSON.stringify(t,null,4))}else if(n.mode==`oneToOne`){for(let t in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[t],i=(0,f.join)(e,n.file.name.replace(`@`,``).replace(T.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(i,JSON.stringify(n.exported[r],null,4))}for(let t in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[t],i=this.tsFiles[t.replace(T.I18n,T.ComponentLogic)];if(i instanceof F&&i.fileParsed){let t=(0,f.join)(e,i.fileParsed.classes[i.componentClassName].namespace.replace(/\./g,f.sep));(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let a=(0,f.join)(e,n.file.name.replace(T.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(a,JSON.stringify(n.exported[r],null,4))}}}else if(n.mode==`groupComponent`){for(let t in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[t],i=(0,f.join)(e,n.file.name.replace(`@`,``).replace(T.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(i,JSON.stringify(n.exported[r],null,4))}let t={};for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[r]}}let n=(0,f.join)(e,`_components_`+r+`.json`).toLowerCase();this.writeFile(n,JSON.stringify(t,null,4))}else n.mode==`basedOnAttribute`||n.mode}}async buildLocalCode(e,t){let n={codeNoNamespaceBefore:[],code:[],codeNoNamespaceAfter:[],doc:[],docNoNamespace:[],docInvisible:[],classesName:{},stylesheets:{},codeRenderInJs:[],codeNotRenderInJs:[],npm:{},npmsrc:{},htmlDoc:{},useDecorator:!1},r={},i={},a=!1,o=``;t!=``&&(o=t+`.`);let s=(e,t)=>{let n=[];for(let r of e){let e=``;e=r.uri==`@local`?this.noNamespaceUri[t]?r.fullName.replace(`$namespace$`,``):r.fullName.replace(`$namespace$`,o):r.uri==`@external`||r.uri==`@npm`?r.fullName:this.noNamespaceUri[r.uri]?r.fullName.replace(`$namespace$`,``):r.fullName.replace(`$namespace$`,o),n.push({fullName:e,isStrong:r.isStrong})}return n},c=(e,t)=>{let r=this.tsFiles[e.uri];if(r instanceof F&&r.compilationResult)if(t){let e=JSON.parse(JSON.stringify(r.compilationResult.htmlDoc));for(let t in e)e[t].class=this.buildConfig.module+`.`+e[t].class,n.htmlDoc[t]=e[t]}else n.htmlDoc={...n.htmlDoc,...r.compilationResult.htmlDoc}};for(let t of e)if(t.useDecorator&&(n.useDecorator=!0),this.noNamespaceUri[t.uri]){if(t.compiled!=``){let e;t.compiled.startsWith(`@After()`)?(n.codeNoNamespaceAfter.push(t.compiled.slice(8)),e=`after`):t.compiled.startsWith(`@Before()`)?(n.codeNoNamespaceBefore.push(t.compiled.slice(9)),e=`before`):a?(n.codeNoNamespaceAfter.push(t.compiled),e=`after`):(n.codeNoNamespaceBefore.push(t.compiled),e=`before`),r[t.classScript]||(r[t.classScript]={code:ze(t.compiled,this.project.getConfig()),dependencies:s(t.dependencies,t.uri),fullName:t.classScript,required:t.required,noNamespace:e,type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName,tagName:t.tagName},t.slots&&(r[t.classScript].slots=t.slots))}else t.classScript!=``&&!i[t.classScript]&&!t.classScript.startsWith(`!staticClass_`)&&(i[t.classScript]={fullName:t.classScript,dependencies:s(t.dependencies,t.uri)}),t.classDoc!=``&&!i[t.classDoc]&&!t.classDoc.startsWith(`!staticClass_`)&&(i[t.classDoc]={fullName:t.classScript,dependencies:s(t.dependencies,t.uri)});if(t.docVisible!=``&&n.docNoNamespace.push(t.docVisible),t.docInvisible!=``&&n.docInvisible.push(t.docInvisible),t.npm.defTs&&(n.npm[``]||(n.npm[``]={content:[],imports:{}}),n.npm[``].content.push(t.npm.defTs)),t.npm.src){n.npmsrc[t.npm.exportPath]||(n.npmsrc[t.npm.exportPath]={content:[],imports:{},names:[],forcedDependencies:[],sourceUri:[]});let e=t.isExported.internal?`export `+t.npm.src:t.npm.src;n.npmsrc[t.npm.exportPath].content.push(e),n.npmsrc[t.npm.exportPath].sourceUri.includes(t.uri)||n.npmsrc[t.npm.exportPath].sourceUri.push(t.uri)}c(t,!1)}else{if(a=!0,t.classScript!=``&&!t.classScript.startsWith(`!staticClass_`)&&(n.classesName[t.classScript]={type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName}),t.compiled!=``){n.code.push(ze(t.compiled,this.project.getConfig()));let e=o+t.classScript;r[e]||(r[e]={code:ze(t.compiled,this.project.getConfig()),dependencies:s(t.dependencies,t.uri),fullName:e,required:t.required,type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName,tagName:t.tagName},t.slots&&(r[e].slots=t.slots))}else{if(t.classScript!=``&&!i[t.classScript]&&!t.classScript.startsWith(`!staticClass_`)){let e=o+t.classScript;i[t.classScript]={fullName:e,dependencies:s(t.dependencies,t.uri)}}if(t.classDoc!=``&&!i[t.classDoc]&&!t.classDoc.startsWith(`!staticClass_`)){let e=o+t.classDoc;i[t.classDoc]={fullName:e,dependencies:s(t.dependencies,t.uri)}}}if(t.docVisible!=``&&n.doc.push(t.docVisible),t.docInvisible!=``&&n.docInvisible.push(t.docInvisible),t.npm.defTs){n.npm[t.npm.namespace]||(n.npm[t.npm.namespace]={content:[],imports:{}});let e=t.npm.defTs;if(t.isExported.external)if(e.startsWith(`/**`)){let t=/\/\*\*(\s|\S)*?\*\/((\r)?(\n)?)*/.exec(e);t&&(e=e.replace(t[0],t[0]+`export `))}else e=`export `+e;n.npm[t.npm.namespace].content.push(e);let r=this.tsFiles[t.npm.uri].fileParsed?.npmGeneratedImport;if(r)for(let e in r){let i=n.npm[t.npm.namespace].imports;i[e]||(i[e]=[]);for(let t of r[e]){if(t.onlySrc)continue;let n=t.alias?t.name+` as `+t.alias:t.name;i[e].includes(n)||i[e].push(n)}}}if(t.npm.src){if(!n.npmsrc[t.npm.exportPath]){n.npmsrc[t.npm.exportPath]={content:[],imports:{},names:[],forcedDependencies:[],sourceUri:[]};let e=this.tsFiles[t.npm.uri].fileParsed,r=e?.npmGeneratedImport;if(r)for(let i in r)if(i.startsWith(`.`)){let a=e?.importsLocal??{},o=e?.manualImportLocal??{};for(let e of r[i]){let r=a[e.name]??o[e.nameAlias??e.name];if(!r||r.isTypeImport)continue;let i=r.info?.fileUri??``,s=t.npm.uri,c=We(i,s);c=c.replace(T.Base,`.js`),n.npmsrc[t.npm.exportPath].imports[c]||(n.npmsrc[t.npm.exportPath].imports[c]=[]);let l=e.alias?e.name+` as `+e.alias:e.name;n.npmsrc[t.npm.exportPath].imports[c].push(l),e.forced&&n.npmsrc[t.npm.exportPath].forcedDependencies.push(e.alias??e.name)}}else{n.npmsrc[t.npm.exportPath].imports[i+`/index.js`]||(n.npmsrc[t.npm.exportPath].imports[i+`/index.js`]=[]);for(let e of r[i])if(e.compiled){let r=e.alias?e.name+` as `+e.alias:e.name;n.npmsrc[t.npm.exportPath].imports[i+`/index.js`].push(r),e.forced&&n.npmsrc[t.npm.exportPath].forcedDependencies.push(e.alias??e.name)}}}let e=t.isExported.internal?`export `+t.npm.src:t.npm.src;n.npmsrc[t.npm.exportPath].content.push(e),n.npmsrc[t.npm.exportPath].sourceUri.includes(t.uri)||n.npmsrc[t.npm.exportPath].sourceUri.push(t.uri),t.isExported.internal&&t.classScript&&n.npmsrc[t.npm.exportPath].names.push(this.module+`.`+t.classScript)}c(t,!0)}n.codeRenderInJs=Object.values(r),n.codeNotRenderInJs=Object.values(i);for(let e in this.globalComponentSCSSFiles){let t=this.globalComponentSCSSFiles[e];n.stylesheets[t.globalName]=t.compileResult}return n}async buildOrderCompilationInfo(e){let t={toCompile:[],libSrc:[],errors:[]},n={},r=[],i={},a={};for(let e in this.tsFiles){let t=this.tsFiles[e];for(let e of t.compileResult){if(e.classScript!==``)if(a[e.classScript]){let n=!1,r=`The name `+e.classScript+` is registered more than once.`,i=t.fileParsed?.getBaseInfoFullName(e.classScript);i&&(this.addDiagnostic(t,k(t.file.documentUser,r,i.nameStart,i.nameEnd,1023)),n=!0);let o=this.tsFiles[a[e.classScript].uri];i=o.fileParsed?.getBaseInfoFullName(e.classScript),i&&(this.addDiagnostic(o,k(o.file.documentUser,r,i.nameStart,i.nameEnd,1023)),n=!0),n||$.showErrorMessage(r)}else i[e.classScript]=e,a[e.classScript]=e;e.classDoc!==``&&!i[e.classDoc]&&(i[e.classDoc]=e)}}let o=[],s=[],c={},l=(e,a,u,d,f)=>{let p=e.fullName.replace(`$namespace$`,``),m=``,h=null;if(a)m=`@local`;else{if(h=this.externalPackageInformation.getByFullName(p),!h)return u;m=h.uri}if(d[p]!==void 0){if(e.isStrong){if(f[p]!==void 0)return r.push(`You have an infinite loop with your strong dependency [`+p+`]`),u;let e=new Promise(e=>{d[p].push(()=>{e({[m]:p})})});return o.push(e),e}return u}else d[p]=[];e.isStrong&&(f[p]=!0);let g=[],_=(()=>{if(a){if(!i[p]){u[m]===void 0&&(u[m]=-1);return}let e=s.indexOf(p);if(e!=-1){u[m]===void 0&&(u[m]=e+1);return}let a=i[p],o=0,c=[...a.dependencies];if(p.includes(`.`)){let e=p.split(`.`);e.pop();let t=i[e.join(`.`)];t&&t!=a&&c.push({fullName:t.classScript,isStrong:!0,uri:t.uri})}for(let e of c){if(e.uri==`@npm`)continue;let n={...u};if(e.uri==`@external`){let t=l(e,!1,u,d,{});t instanceof Promise?e.isStrong&&g.push(t):u=t}else if(e.isStrong){if(e.fullName.replace(`$namespace$`,``)!=p){let t=l(e,!0,u,d,f);t instanceof Promise?g.push(t):(u=t,u[m]&&u[m]>=0&&u[m]>o&&(o=u[m]))}}else{let n=t.toCompile.length,r=l(e,!0,u,d,{});r instanceof Promise||(u=r,u[m]&&u[m]>=0&&u[m]>o&&(o=u[m]));let i=t.toCompile.length;u[m]&&u[m]>=0&&u[m]>o&&o>0&&(o+=i-n)}u=n}if(s.indexOf(p)!=-1){t[m]=s.indexOf(p);return}if(g.length==0){a.tagName&&(n[a.tagName]?r.push(`The tag <`+a.tagName+`> is declared by `+n[a.tagName]+` and `+a.classScript):n[a.tagName]=a.classScript),t.toCompile.splice(o,0,a),s.splice(o,0,p);for(let e of d[p])e();d[p]=[],u[m]=t.toCompile.length}else return u[m]=t.toCompile.length,o==s.length?`@end_`+s[s.length-1]:s[o];return}else{if(!h||!this.dependencyUris.includes(m))return;c[m]||(c[m]=[]);let e=c[m].indexOf(p);if(e!=-1){u[m]=e+1;return}let t=0;if(h.content!=`noCode`)for(let e of h.content.dependencies){let n={...u},r=e.isStrong?f:{},i=l(e,!1,u,d,r);i instanceof Promise?e.isStrong&&g.push(i):(u=i,u[m]&&u[m]>=0&&u[m]>t&&(t=u[m])),u=n}if(c[m].includes(p)){u[m]=c[m].indexOf(p);return}if(g.length==0){if(h.content!=`noCode`&&h.content.tagName){let e=h.content.tagName;n[e]?r.push(`The tag <`+h.content.tagName+`> is declared by `+n[e]+` and `+h.content.fullName):n[e]=h.content.fullName}c[m].splice(t,0,p),u[m]=c[m].length;for(let e of d[p])e();d[p]=[]}else return t==c[m].length?`@end_`+c[m][c[m].length-1]:c[m][t];return}})();if(e.isStrong&&delete f[p],g.length==0)return d[p]&&d[p].length==0&&delete d[p],u;{let e=new Promise(async e=>{let n=await Promise.all(g),r=u[m]??0;if(_){let e=-1,t=_.replace(`@end_`,``);e=a?s.indexOf(t):c[m].indexOf(t),e!=-1&&(_.startsWith(`@end_`)&&e++,r=e)}for(let e of n)if(e[m]){let t=e[m];if(a){let e=s.indexOf(t)+1;e>r&&(r=e)}else{let e=c[m].indexOf(t)+1;e>r&&(r=e)}}if(a){let e=i[p];s.includes(p)||(t.toCompile.splice(r,0,e),s.splice(r,0,p))}else c[m].includes(p)||c[m].splice(r,0,p);for(let e of d[p])e();delete d[p],e({[m]:p})});return o.push(e),e}};for(let t in this.tsFiles){let n=this.tsFiles[t],r=n.file.path.match(e.inputPathRegex);for(let e of n.compileResult)!e.required&&!r||(e.classScript!==``&&l({fullName:e.classScript,isStrong:!0},!0,{},{},{}),e.classDoc!==``&&l({fullName:e.classDoc,isStrong:!0},!0,{},{},{}))}await Promise.all(o),o=[];for(let e of this.dependencyNeedUris){let t=this.externalPackageInformation.getInformationsRequired(e);c[e]||(c[e]=[]);for(let n of t)c[e].includes(n.fullName)||l({fullName:n.fullName,isStrong:!0},!1,{},{},{})}await Promise.all(o),o=[];for(let e of this.dependencyFullUris){c[e]||(c[e]=[]);let t=this.externalPackageInformation.getFullInformations(e);for(let n of t)c[e].includes(n.fullName)||l({fullName:n.fullName,isStrong:!0},!1,{},{},{})}await Promise.all(o),o=[];let u=[],d=this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1;for(let t of this.dependencyUris){let n={namespace:this.externalPackageInformation.getNamespaceByUri(t),before:[],code:[],after:[],classesName:{}};if(!c[t])continue;for(let e of c[t]){let t=this.externalPackageInformation.getByFullName(e);if(t.content!=`noCode`){let e=ze(t.content.code,this.project.getConfig());if(t.content.noNamespace)t.content.noNamespace==`before`?n.before.push(e):t.content.noNamespace==`after`&&n.after.push(e);else{n.code.push(e);let r=RegExp(`^`+this.externalPackageInformation.getNamespaceByUri(t.uri)+`.`),i=t.content.fullName.replace(r,``);n.classesName[i]={type:t.content.type,isExported:t.content.isExported,convertibleName:t.content.convertibleName}}}}let r=this.externalPackageInformation.getStyleByUri(t),i=[];for(let e in r)i.push(`Aventus.Style.store("${e}", \`${r[e]}\`)`);let a=this._buildStringModule(n.namespace,n.before,n.code,n.classesName,n.after,i);if(n.namespace==`Aventus`&&n.classesName.I18n&&this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1){d=!1;let t=e.i18n[0];if(a+=`Aventus.I18n.registerLocales(${JSON.stringify(this.buildConfig.i18n.locales)})`+x.EOL,a+=`Aventus.I18n.registerFallback("${this.buildConfig.i18n.fallback}")`+x.EOL,t.mode==`singleFile`){let e=(t.mount+`/$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}else if(t.mode==`oneToOne`){for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),r=(t.mount+`/`+n+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${r}", { load: false })`+x.EOL}for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e],r=this.tsFiles[e.replace(T.I18n,T.ComponentLogic)];if(r instanceof F&&r.fileParsed){let e=r.fileParsed.classes[r.componentClassName].namespace.replace(/\./g,`/`);e&&e+``;let i=n.file.name.replace(T.I18n,``),o=(t.mount+`/`+e+i+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${o}", { load: false })`+x.EOL}}}else if(t.mode==`groupComponent`){for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),r=(t.mount+`/`+n+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${r}", { load: false })`+x.EOL}if(Object.keys(this.i18nComponentsFiles).length>0){let e=(t.mount+`/_components_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}}else t.mode==`basedOnAttribute`||t.mode;a+=`Aventus.I18n.init()`+x.EOL}let o=this.externalPackageInformation.getNameByUri(t);u.push({lib:o,code:a})}if(d){let t=``;if(this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1){d=!1;let n=e.i18n[0];if(t+=`Aventus.I18n.registerLocales(${JSON.stringify(this.buildConfig.i18n.locales)})`+x.EOL,t+=`Aventus.I18n.registerFallback("${this.buildConfig.i18n.fallback}")`+x.EOL,n.mode==`singleFile`){let e=(n.mount+`/$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}else if(n.mode==`oneToOne`){for(let e in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),i=(n.mount+`/`+r+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${i}", { load: false })`+x.EOL}for(let e in this.i18nComponentsFiles){let r=this.i18nComponentsFiles[e],i=this.tsFiles[e.replace(T.I18n,T.ComponentLogic)];if(i instanceof F&&i.fileParsed){let e=i.fileParsed.classes[i.componentClassName].namespace.replace(/\./g,`/`);e&&e+``;let a=r.file.name.replace(T.I18n,``),o=(n.mount+`/`+e+a+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${o}", { load: false })`+x.EOL}}}else if(n.mode==`groupComponent`){for(let e in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),i=(n.mount+`/`+r+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${i}", { load: false })`+x.EOL}if(Object.keys(this.i18nComponentsFiles).length>0){let e=(n.mount+`/_components_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}}else n.mode==`basedOnAttribute`||n.mode;t+=`Aventus.I18n.init()`+x.EOL}u.push({lib:`Aventus@I18n`,code:t})}if(t.libSrc=u,r.length>0){let e=this.buildConfig.fullname+`_dependencyErrors`;zi.send(e,r.join(`\r
|
|
492
|
+
namespace `+this.buildConfig.module+`{`+x.EOL,i+=t.doc.join(x.EOL)+x.EOL,i+=` }`,t.docNoNamespace.length>0?i+=x.EOL+t.docNoNamespace.join(x.EOL)+x.EOL:i+=x.EOL,i+=`}`+x.EOL,t.docInvisible.length>0&&(i+=`declare module ___`+this.buildConfig.module+` {`+x.EOL,i+=t.docInvisible.join(x.EOL),i+=`}`);let a=`// `+this.buildConfig.fullname+`:`+this.buildConfig.version+x.EOL;if(r.path.length>0){let e=r.npmName==``?(`@`+this.buildConfig.module+`/`+this.buildConfig.name).toLowerCase():r.npmName;a+=`// npm:`+e+x.EOL}this.buildConfig.description&&(a+=`/* description:`+this.buildConfig.description+` */`+x.EOL),a+=`//#region js def //`+x.EOL+i,a+=`//#endregion js def //`+x.EOL,a+=`//#region js src //`+x.EOL+JSON.stringify(n)+x.EOL,a+=`//#endregion js src //`+x.EOL,a+=`//#region css def //`+x.EOL,a+=JSON.stringify(this.scssLanguageService.getInternalDocumentation())+x.EOL,a+=`//#endregion css def //`+x.EOL,a+=`//#region css //`+x.EOL,a+=JSON.stringify(t.stylesheets)+x.EOL,a+=`//#endregion css //`+x.EOL,a+=`//#region html //`+x.EOL,a+=JSON.stringify(t.htmlDoc)+x.EOL,a+=`//#endregion html //`+x.EOL,a+=`//#region dependencies //`+x.EOL,a+=JSON.stringify(this.buildConfig.rawDependencies)+x.EOL,a+=`//#endregion dependencies //`+x.EOL;for(let t of e)t?this.writeFile(t,a):(0,u.existsSync)(t)&&(0,u.unlinkSync)(t);let o=(0,f.join)(Ri.getInstance().getPath(),`@locals`);(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0}),this.writeFile((0,f.join)(o,this.buildConfig.fullname+T.Package),a)}writeBuildNpm(e,t){let n=Object.keys(t.npm);n.includes(``)||n.push(``);for(let e of n){let t=e.split(`.`),r=``;for(let e of t)r=r?`${r}.${e}`:e,n.includes(r)||n.push(r)}n.sort((e,t)=>(e.match(/\./g)||[]).length-(t.match(/\./g)||[]).length);let r={},i=e.manifest?new Ki(e.manifest,this):null;for(let n in t.npmsrc){let a=``;for(let e in t.npmsrc[n].imports){let r=t.npmsrc[n].imports[e];r.length>0&&(a+=`import { ${r.join(`, `)} } from "${e}";`+x.EOL)}if(a!=``&&(a+=x.EOL),a+=t.npmsrc[n].content.join(x.EOL),a=wn.removeUnusedImport(a,t.npmsrc[n].forcedDependencies),i)for(let e of t.npmsrc[n].sourceUri){let t=this.tsFiles[e];t&&i.register(t)}for(let t of e.path){let e=(0,f.join)(t,`__src`,...Le(n).split(f.sep)),r=(0,f.join)(t,`__src`,...n.split(f.sep));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0}),this.writeFile(r,a)}for(let e of t.npmsrc[n].names){let t=e.split(`.`),i=t.pop()??``,a=[];for(let e=0;e<t.length;e++)a.push(`..`);a=[...a,`__src`,...n.split(f.sep)];let o=t.join(`.`);r[o]||(r[o]={});let s=a.join(`/`);r[o][s]||(r[o][s]=[]),r[o][s].push(i)}}let a=(t,r)=>{r||={content:[],imports:{}};let i=``,a=``,o=t==``?0:t.split(`.`).length,s=[];for(let e of n)if(e.startsWith(t)&&e!=t){let t=e.split(`.`);if(t.length==o+1){let e=t[t.length-1];i+=`import * as ${e} from "./${e}";`+x.EOL,a+=`export { ${e} };`+x.EOL,s.push(`./${e}`)}}for(let e in r.imports){let t=r.imports[e];t.length>0&&(i+=`import { ${t.join(`, `)} } from "${e}";`+x.EOL)}i+=x.EOL+r.content.join(x.EOL)+x.EOL,i+=a,i=i.replaceAll(`globalThis.Aventus.`,``),i=i.replaceAll(`___Aventus.`,``),i=wn.removeUnusedImport(i,[]);for(let n of e.path){let e=(0,f.join)(n,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0});let r=(0,f.join)(e,`index.d.ts`);this.writeFile(r,i)}},o=t=>{let i=``,a=``,o=t==``?0:t.split(`.`).length;for(let e of n)if(e.startsWith(t)&&e!=t){let t=e.split(`.`);if(t.length==o+1){let e=t[t.length-1];i+=`import * as ${e} from "./${e}/index.js";`+x.EOL,a+=`export { ${e} };`+x.EOL}}let s=r[t];if(s)for(let e in s){let t=s[e].join(`, `);i+=`export { ${t} } from "${e}"`+x.EOL}i+=a,i=wn.removeUnusedImport(i,[]);for(let n of e.path){let e=(0,f.join)(n,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0});let r=(0,f.join)(e,`index.js`);this.writeFile(r,i)}};for(let e of n)a(e,t.npm[e]),o(e);if(e.packageJson){let t=(0,f.join)(this.project.getConfigFile().folderPath,`package.json`),n={};(0,u.existsSync)(t)&&(n=JSON.parse((0,u.readFileSync)(t,`utf-8`)));let r={};for(let e of this.externalPackageInformation.filesUri){let t=this.externalPackageInformation.getByUri(e);t&&t.npmUri&&t.name!=this.buildConfig.fullname&&(n.dependencies&&n.dependencies[t.npmUri]?r[t.npmUri]=n.dependencies[t.npmUri]:r[t.npmUri]=`^`+t.versionTxt)}let i=`Aventus build for @`+this.buildConfig.module,a=this.buildConfig.module;this.buildConfig.name&&(i+=`/`+this.buildConfig.name,a+=` `+this.buildConfig.name);let o={name:e.npmName==``?(`@`+this.buildConfig.module+`/`+this.buildConfig.name).toLowerCase():e.npmName,displayName:a,description:i,version:this.buildConfig.version,type:`module`,main:`index.js`,types:`index.d.ts`,dependencies:r};this.buildConfig.organization?o.author={name:this.buildConfig.organization}:Ni.isConnected&&(o.author={name:Ni.settings.username});for(let t of e.path){(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let e=(0,f.join)(t,`package.json`),n={};if((0,u.existsSync)(e))try{n=JSON.parse((0,u.readFileSync)(e,`utf8`))}catch{}let r={...o,...n};r.name=o.name,r.displayName=o.displayName,r.version=o.version,this.writeFile(e,JSON.stringify(r,null,2))}}if(i)for(let t of e.path)(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0}),i.write(t)}writeBuildI18n(e){let t=this.buildConfig.i18n?.locales??[];for(let n of e)for(let e of n.output){t.length>0&&!(0,u.existsSync)(e)&&(0,u.mkdirSync)(e,{recursive:!0});for(let r of t)if(n.mode==`singleFile`){let t={};for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e];t={...t,...n.exported[r]}}for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[r]}}let n=(0,f.join)(e,r+`.json`).toLowerCase();this.writeFile(n,JSON.stringify(t,null,4))}else if(n.mode==`oneToOne`){for(let t in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[t],i=(0,f.join)(e,n.file.name.replace(`@`,``).replace(T.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(i,JSON.stringify(n.exported[r],null,4))}for(let t in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[t],i=this.tsFiles[t.replace(T.I18n,T.ComponentLogic)];if(i instanceof F&&i.fileParsed){let t=(0,f.join)(e,i.fileParsed.classes[i.componentClassName].namespace.replace(/\./g,f.sep));(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let a=(0,f.join)(e,n.file.name.replace(T.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(a,JSON.stringify(n.exported[r],null,4))}}}else if(n.mode==`groupComponent`){for(let t in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[t],i=(0,f.join)(e,n.file.name.replace(`@`,``).replace(T.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(i,JSON.stringify(n.exported[r],null,4))}let t={};for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[r]}}let n=(0,f.join)(e,`_components_`+r+`.json`).toLowerCase();this.writeFile(n,JSON.stringify(t,null,4))}else n.mode==`basedOnAttribute`||n.mode}}async buildLocalCode(e,t){let n={codeNoNamespaceBefore:[],code:[],codeNoNamespaceAfter:[],doc:[],docNoNamespace:[],docInvisible:[],classesName:{},stylesheets:{},codeRenderInJs:[],codeNotRenderInJs:[],npm:{},npmsrc:{},htmlDoc:{},useDecorator:!1},r={},i={},a=!1,o=``;t!=``&&(o=t+`.`);let s=(e,t)=>{let n=[];for(let r of e){let e=``;e=r.uri==`@local`?this.noNamespaceUri[t]?r.fullName.replace(`$namespace$`,``):r.fullName.replace(`$namespace$`,o):r.uri==`@external`||r.uri==`@npm`?r.fullName:this.noNamespaceUri[r.uri]?r.fullName.replace(`$namespace$`,``):r.fullName.replace(`$namespace$`,o),n.push({fullName:e,isStrong:r.isStrong})}return n},c=(e,t)=>{let r=this.tsFiles[e.uri];if(r instanceof F&&r.compilationResult)if(t){let e=JSON.parse(JSON.stringify(r.compilationResult.htmlDoc));for(let t in e)e[t].class=this.buildConfig.module+`.`+e[t].class,n.htmlDoc[t]=e[t]}else n.htmlDoc={...n.htmlDoc,...r.compilationResult.htmlDoc}};for(let t of e)if(t.useDecorator&&(n.useDecorator=!0),this.noNamespaceUri[t.uri]){if(t.compiled!=``){let e;t.compiled.startsWith(`@After()`)?(n.codeNoNamespaceAfter.push(t.compiled.slice(8)),e=`after`):t.compiled.startsWith(`@Before()`)?(n.codeNoNamespaceBefore.push(t.compiled.slice(9)),e=`before`):a?(n.codeNoNamespaceAfter.push(t.compiled),e=`after`):(n.codeNoNamespaceBefore.push(t.compiled),e=`before`),r[t.classScript]||(r[t.classScript]={code:ze(t.compiled,this.project.getConfig()),dependencies:s(t.dependencies,t.uri),fullName:t.classScript,required:t.required,noNamespace:e,type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName,tagName:t.tagName},t.slots&&(r[t.classScript].slots=t.slots))}else t.classScript!=``&&!i[t.classScript]&&!t.classScript.startsWith(`!staticClass_`)&&(i[t.classScript]={fullName:t.classScript,dependencies:s(t.dependencies,t.uri)}),t.classDoc!=``&&!i[t.classDoc]&&!t.classDoc.startsWith(`!staticClass_`)&&(i[t.classDoc]={fullName:t.classScript,dependencies:s(t.dependencies,t.uri)});if(t.docVisible!=``&&n.docNoNamespace.push(t.docVisible),t.docInvisible!=``&&n.docInvisible.push(t.docInvisible),t.npm.defTs&&(n.npm[``]||(n.npm[``]={content:[],imports:{}}),n.npm[``].content.push(t.npm.defTs)),t.npm.src){n.npmsrc[t.npm.exportPath]||(n.npmsrc[t.npm.exportPath]={content:[],imports:{},names:[],forcedDependencies:[],sourceUri:[]});let e=t.isExported.internal?`export `+t.npm.src:t.npm.src;n.npmsrc[t.npm.exportPath].content.push(e),n.npmsrc[t.npm.exportPath].sourceUri.includes(t.uri)||n.npmsrc[t.npm.exportPath].sourceUri.push(t.uri)}c(t,!1)}else{if(a=!0,t.classScript!=``&&!t.classScript.startsWith(`!staticClass_`)&&(n.classesName[t.classScript]={type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName}),t.compiled!=``){n.code.push(ze(t.compiled,this.project.getConfig()));let e=o+t.classScript;r[e]||(r[e]={code:ze(t.compiled,this.project.getConfig()),dependencies:s(t.dependencies,t.uri),fullName:e,required:t.required,type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName,tagName:t.tagName},t.slots&&(r[e].slots=t.slots))}else{if(t.classScript!=``&&!i[t.classScript]&&!t.classScript.startsWith(`!staticClass_`)){let e=o+t.classScript;i[t.classScript]={fullName:e,dependencies:s(t.dependencies,t.uri)}}if(t.classDoc!=``&&!i[t.classDoc]&&!t.classDoc.startsWith(`!staticClass_`)){let e=o+t.classDoc;i[t.classDoc]={fullName:e,dependencies:s(t.dependencies,t.uri)}}}if(t.docVisible!=``&&n.doc.push(t.docVisible),t.docInvisible!=``&&n.docInvisible.push(t.docInvisible),t.npm.defTs){n.npm[t.npm.namespace]||(n.npm[t.npm.namespace]={content:[],imports:{}});let e=t.npm.defTs;if(t.isExported.external)if(e.startsWith(`/**`)){let t=/\/\*\*[\s\S]*?\*\/((\r)?(\n)?)*/.exec(e);t&&(e=e.replace(t[0],t[0]+`export `))}else e=`export `+e;n.npm[t.npm.namespace].content.push(e);let r=this.tsFiles[t.npm.uri].fileParsed?.npmGeneratedImport;if(r)for(let e in r){let i=n.npm[t.npm.namespace].imports;i[e]||(i[e]=[]);for(let t of r[e]){if(t.onlySrc)continue;let n=t.alias?t.name+` as `+t.alias:t.name;i[e].includes(n)||i[e].push(n)}}}if(t.npm.src){if(!n.npmsrc[t.npm.exportPath]){n.npmsrc[t.npm.exportPath]={content:[],imports:{},names:[],forcedDependencies:[],sourceUri:[]};let e=this.tsFiles[t.npm.uri].fileParsed,r=e?.npmGeneratedImport;if(r)for(let i in r)if(i.startsWith(`.`)){let a=e?.importsLocal??{},o=e?.manualImportLocal??{};for(let e of r[i]){let r=a[e.name]??o[e.nameAlias??e.name];if(!r||r.isTypeImport)continue;let i=r.info?.fileUri??``,s=t.npm.uri,c=We(i,s);c=c.replace(T.Base,`.js`),n.npmsrc[t.npm.exportPath].imports[c]||(n.npmsrc[t.npm.exportPath].imports[c]=[]);let l=e.alias?e.name+` as `+e.alias:e.name;n.npmsrc[t.npm.exportPath].imports[c].push(l),e.forced&&n.npmsrc[t.npm.exportPath].forcedDependencies.push(e.alias??e.name)}}else{n.npmsrc[t.npm.exportPath].imports[i+`/index.js`]||(n.npmsrc[t.npm.exportPath].imports[i+`/index.js`]=[]);for(let e of r[i])if(e.compiled){let r=e.alias?e.name+` as `+e.alias:e.name;n.npmsrc[t.npm.exportPath].imports[i+`/index.js`].push(r),e.forced&&n.npmsrc[t.npm.exportPath].forcedDependencies.push(e.alias??e.name)}}}let e=t.isExported.internal?`export `+t.npm.src:t.npm.src;n.npmsrc[t.npm.exportPath].content.push(e),n.npmsrc[t.npm.exportPath].sourceUri.includes(t.uri)||n.npmsrc[t.npm.exportPath].sourceUri.push(t.uri),t.isExported.internal&&t.classScript&&n.npmsrc[t.npm.exportPath].names.push(this.module+`.`+t.classScript)}c(t,!0)}n.codeRenderInJs=Object.values(r),n.codeNotRenderInJs=Object.values(i);for(let e in this.globalComponentSCSSFiles){let t=this.globalComponentSCSSFiles[e];n.stylesheets[t.globalName]=t.compileResult}return n}async buildOrderCompilationInfo(e){let t={toCompile:[],libSrc:[],errors:[]},n={},r=[],i={},a={};for(let e in this.tsFiles){let t=this.tsFiles[e];for(let e of t.compileResult){if(e.classScript!==``)if(a[e.classScript]){let n=!1,r=`The name `+e.classScript+` is registered more than once.`,i=t.fileParsed?.getBaseInfoFullName(e.classScript);i&&(this.addDiagnostic(t,k(t.file.documentUser,r,i.nameStart,i.nameEnd,1023)),n=!0);let o=this.tsFiles[a[e.classScript].uri];i=o.fileParsed?.getBaseInfoFullName(e.classScript),i&&(this.addDiagnostic(o,k(o.file.documentUser,r,i.nameStart,i.nameEnd,1023)),n=!0),n||$.showErrorMessage(r)}else i[e.classScript]=e,a[e.classScript]=e;e.classDoc!==``&&!i[e.classDoc]&&(i[e.classDoc]=e)}}let o=[],s=[],c={},l=(e,a,u,d,f)=>{let p=e.fullName.replace(`$namespace$`,``),m=``,h=null;if(a)m=`@local`;else{if(h=this.externalPackageInformation.getByFullName(p),!h)return u;m=h.uri}if(d[p]!==void 0){if(e.isStrong){if(f[p]!==void 0)return r.push(`You have an infinite loop with your strong dependency [`+p+`]`),u;let e=new Promise(e=>{d[p].push(()=>{e({[m]:p})})});return o.push(e),e}return u}else d[p]=[];e.isStrong&&(f[p]=!0);let g=[],_=(()=>{if(a){if(!i[p]){u[m]===void 0&&(u[m]=-1);return}let e=s.indexOf(p);if(e!=-1){u[m]===void 0&&(u[m]=e+1);return}let a=i[p],o=0,c=[...a.dependencies];if(p.includes(`.`)){let e=p.split(`.`);e.pop();let t=i[e.join(`.`)];t&&t!=a&&c.push({fullName:t.classScript,isStrong:!0,uri:t.uri})}for(let e of c){if(e.uri==`@npm`)continue;let n={...u};if(e.uri==`@external`){let t=l(e,!1,u,d,{});t instanceof Promise?e.isStrong&&g.push(t):u=t}else if(e.isStrong){if(e.fullName.replace(`$namespace$`,``)!=p){let t=l(e,!0,u,d,f);t instanceof Promise?g.push(t):(u=t,u[m]&&u[m]>=0&&u[m]>o&&(o=u[m]))}}else{let n=t.toCompile.length,r=l(e,!0,u,d,{});r instanceof Promise||(u=r,u[m]&&u[m]>=0&&u[m]>o&&(o=u[m]));let i=t.toCompile.length;u[m]&&u[m]>=0&&u[m]>o&&o>0&&(o+=i-n)}u=n}if(s.indexOf(p)!=-1){t[m]=s.indexOf(p);return}if(g.length==0){a.tagName&&(n[a.tagName]?r.push(`The tag <`+a.tagName+`> is declared by `+n[a.tagName]+` and `+a.classScript):n[a.tagName]=a.classScript),t.toCompile.splice(o,0,a),s.splice(o,0,p);for(let e of d[p])e();d[p]=[],u[m]=t.toCompile.length}else return u[m]=t.toCompile.length,o==s.length?`@end_`+s[s.length-1]:s[o];return}else{if(!h||!this.dependencyUris.includes(m))return;c[m]||(c[m]=[]);let e=c[m].indexOf(p);if(e!=-1){u[m]=e+1;return}let t=0;if(h.content!=`noCode`)for(let e of h.content.dependencies){let n={...u},r=e.isStrong?f:{},i=l(e,!1,u,d,r);i instanceof Promise?e.isStrong&&g.push(i):(u=i,u[m]&&u[m]>=0&&u[m]>t&&(t=u[m])),u=n}if(c[m].includes(p)){u[m]=c[m].indexOf(p);return}if(g.length==0){if(h.content!=`noCode`&&h.content.tagName){let e=h.content.tagName;n[e]?r.push(`The tag <`+h.content.tagName+`> is declared by `+n[e]+` and `+h.content.fullName):n[e]=h.content.fullName}c[m].splice(t,0,p),u[m]=c[m].length;for(let e of d[p])e();d[p]=[]}else return t==c[m].length?`@end_`+c[m][c[m].length-1]:c[m][t];return}})();if(e.isStrong&&delete f[p],g.length==0)return d[p]&&d[p].length==0&&delete d[p],u;{let e=new Promise(async e=>{let n=await Promise.all(g),r=u[m]??0;if(_){let e=-1,t=_.replace(`@end_`,``);e=a?s.indexOf(t):c[m].indexOf(t),e!=-1&&(_.startsWith(`@end_`)&&e++,r=e)}for(let e of n)if(e[m]){let t=e[m];if(a){let e=s.indexOf(t)+1;e>r&&(r=e)}else{let e=c[m].indexOf(t)+1;e>r&&(r=e)}}if(a){let e=i[p];s.includes(p)||(t.toCompile.splice(r,0,e),s.splice(r,0,p))}else c[m].includes(p)||c[m].splice(r,0,p);for(let e of d[p])e();delete d[p],e({[m]:p})});return o.push(e),e}};for(let t in this.tsFiles){let n=this.tsFiles[t],r=n.file.path.match(e.inputPathRegex);for(let e of n.compileResult)!e.required&&!r||(e.classScript!==``&&l({fullName:e.classScript,isStrong:!0},!0,{},{},{}),e.classDoc!==``&&l({fullName:e.classDoc,isStrong:!0},!0,{},{},{}))}await Promise.all(o),o=[];for(let e of this.dependencyNeedUris){let t=this.externalPackageInformation.getInformationsRequired(e);c[e]||(c[e]=[]);for(let n of t)c[e].includes(n.fullName)||l({fullName:n.fullName,isStrong:!0},!1,{},{},{})}await Promise.all(o),o=[];for(let e of this.dependencyFullUris){c[e]||(c[e]=[]);let t=this.externalPackageInformation.getFullInformations(e);for(let n of t)c[e].includes(n.fullName)||l({fullName:n.fullName,isStrong:!0},!1,{},{},{})}await Promise.all(o),o=[];let u=[],d=this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1;for(let t of this.dependencyUris){let n={namespace:this.externalPackageInformation.getNamespaceByUri(t),before:[],code:[],after:[],classesName:{}};if(!c[t])continue;for(let e of c[t]){let t=this.externalPackageInformation.getByFullName(e);if(t.content!=`noCode`){let e=ze(t.content.code,this.project.getConfig());if(t.content.noNamespace)t.content.noNamespace==`before`?n.before.push(e):t.content.noNamespace==`after`&&n.after.push(e);else{n.code.push(e);let r=RegExp(`^`+this.externalPackageInformation.getNamespaceByUri(t.uri)+`.`),i=t.content.fullName.replace(r,``);n.classesName[i]={type:t.content.type,isExported:t.content.isExported,convertibleName:t.content.convertibleName}}}}let r=this.externalPackageInformation.getStyleByUri(t),i=[];for(let e in r)i.push(`Aventus.Style.store("${e}", \`${r[e]}\`)`);let a=this._buildStringModule(n.namespace,n.before,n.code,n.classesName,n.after,i);if(n.namespace==`Aventus`&&n.classesName.I18n&&this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1){d=!1;let t=e.i18n[0];if(a+=`Aventus.I18n.registerLocales(${JSON.stringify(this.buildConfig.i18n.locales)})`+x.EOL,a+=`Aventus.I18n.registerFallback("${this.buildConfig.i18n.fallback}")`+x.EOL,t.mode==`singleFile`){let e=(t.mount+`/$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}else if(t.mode==`oneToOne`){for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),r=(t.mount+`/`+n+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${r}", { load: false })`+x.EOL}for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e],r=this.tsFiles[e.replace(T.I18n,T.ComponentLogic)];if(r instanceof F&&r.fileParsed){let e=r.fileParsed.classes[r.componentClassName].namespace.replace(/\./g,`/`);e&&e+``;let i=n.file.name.replace(T.I18n,``),o=(t.mount+`/`+e+i+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${o}", { load: false })`+x.EOL}}}else if(t.mode==`groupComponent`){for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),r=(t.mount+`/`+n+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${r}", { load: false })`+x.EOL}if(Object.keys(this.i18nComponentsFiles).length>0){let e=(t.mount+`/_components_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}}else t.mode==`basedOnAttribute`||t.mode;a+=`Aventus.I18n.init()`+x.EOL}let o=this.externalPackageInformation.getNameByUri(t);u.push({lib:o,code:a})}if(d){let t=``;if(this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1){d=!1;let n=e.i18n[0];if(t+=`Aventus.I18n.registerLocales(${JSON.stringify(this.buildConfig.i18n.locales)})`+x.EOL,t+=`Aventus.I18n.registerFallback("${this.buildConfig.i18n.fallback}")`+x.EOL,n.mode==`singleFile`){let e=(n.mount+`/$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}else if(n.mode==`oneToOne`){for(let e in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),i=(n.mount+`/`+r+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${i}", { load: false })`+x.EOL}for(let e in this.i18nComponentsFiles){let r=this.i18nComponentsFiles[e],i=this.tsFiles[e.replace(T.I18n,T.ComponentLogic)];if(i instanceof F&&i.fileParsed){let e=i.fileParsed.classes[i.componentClassName].namespace.replace(/\./g,`/`);e&&e+``;let a=r.file.name.replace(T.I18n,``),o=(n.mount+`/`+e+a+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${o}", { load: false })`+x.EOL}}}else if(n.mode==`groupComponent`){for(let e in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(T.I18n,``),i=(n.mount+`/`+r+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${i}", { load: false })`+x.EOL}if(Object.keys(this.i18nComponentsFiles).length>0){let e=(n.mount+`/_components_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${e}", { load: false })`+x.EOL}}else n.mode==`basedOnAttribute`||n.mode;t+=`Aventus.I18n.init()`+x.EOL}u.push({lib:`Aventus@I18n`,code:t})}if(t.libSrc=u,r.length>0){let e=this.buildConfig.fullname+`_dependencyErrors`;zi.send(e,r.join(`\r
|
|
493
493
|
`)),t.errors.push({title:`Dependencies errors`,file:e})}return t}getAllFullnames(){let e={},t=t=>{if(t.startsWith(`!staticClass_`))return;let n=t.split(`.`)[0];e[n]||(e[n]=[]),e[n].push(t)};for(let e in this.tsFiles){let n=this.tsFiles[e];for(let e of n.compileResult)e.classScript!==``&&t(e.classScript)}for(let e of this.dependencyNeedUris){let n=this.externalPackageInformation.getInformationsRequired(e);for(let e of n)e.code&&t(e.fullName)}for(let e of this.dependencyFullUris){let n=this.externalPackageInformation.getFullInformations(e);for(let e of n)e.code&&t(e.fullName)}return e}async onNewFile(e){this.buildConfig.srcPathRegex&&e.path.match(this.buildConfig.srcPathRegex)&&this.registerFile(e,!1),this.buildConfig.outsideModulePathRegex&&e.path.match(this.buildConfig.outsideModulePathRegex)&&(this.registerFile(e,!1),this.noNamespaceUri[e.uri]=!0)}async loadFiles(){Se.startSendBuildTime(this.buildConfig.fullname),this.allowBuild=!1;let e=await Ri.getInstance().loadDependenciesFromBuild(this.buildConfig,this);this.dependencyFullUris=e.dependencyFullUris,this.dependencyNeedUris=e.dependencyNeedUris,this.dependencyUris=e.dependencyUris,this.externalPackageInformation.init(e.files);let t=R.getInstance();if(this.buildConfig.srcPathRegex){let e=t.getFilesMatching(this.buildConfig.srcPathRegex);for(let t of e)this.registerFile(t,!0)}if(this.buildConfig.outsideModulePathRegex){let e=t.getFilesMatching(this.buildConfig.outsideModulePathRegex);for(let t of e)this.registerFile(t,!0),this.noNamespaceUri[t.uri]=!0}$.debug(`loaded all files needed`),this.allowBuild=!0,this._filesLoaded=!0,await this.rebuildAll(!0),Se.sendBuildTime(this.buildConfig.fullname)}async registerFile(e,t){if(e.uri.endsWith(T.ComponentStyle))this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new hi(e,this),t||await this.scssFiles[e.uri].init(),this.registerOnFileDelete(e),this.scssFiles[e.uri].isGlobal&&(this.globalComponentSCSSFiles[e.uri]=this.scssFiles[e.uri]));else if(e.uri.endsWith(T.ComponentView))this.htmlFiles[e.uri]||(this.htmlFiles[e.uri]=new gi(e,this),t||await this.htmlFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(T.Component))this.wcFiles[e.uri]||(this.wcFiles[e.uri]=new Vi(e,this),t||await this.wcFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(T.I18n))e.name.startsWith(`@`)?this.tsLanguageService.i18nFiles[e.uri]||(this.tsLanguageService.i18nFiles[e.uri]=new Xi(e,!0,this),t||await this.tsLanguageService.i18nFiles[e.uri].validate(),this.registerOnFileDelete(e)):this.i18nComponentsFiles[e.uri]||(this.i18nComponentsFiles[e.uri]=new Xi(e,!1,this),t||await this.i18nComponentsFiles[e.uri].validate(),this.registerOnFileDelete(e));else if(!this.tsFiles[e.uri]){let t=Oi(e,this);t&&(this.tsFiles[e.uri]=t,this.registerOnFileDelete(e))}}registerOnFileDelete(e){this.onFileDeleteUUIDs[e.uri]=e.onDelete(this.onFileDelete.bind(this))}async onFileDelete(e){e.removeOnDelete(this.onFileDeleteUUIDs[e.uri]),delete this.onFileDeleteUUIDs[e.uri],e.uri.endsWith(T.ComponentStyle)?delete this.scssFiles[e.uri]:e.uri.endsWith(T.ComponentView)?delete this.htmlFiles[e.uri]:e.uri.endsWith(T.Component)?delete this.wcFiles[e.uri]:delete this.tsFiles[e.uri],await this.rebuildAll()}getLocalWebComponentDefinition(e,t=!1){let n=this.htmlLanguageService.getInternalDefinition(e);if(n&&n.fileParsed){let e=n.getComponentName();if(e){let t=n.fileParsed.classes[e];if(t)return t}}}getWebComponentTagDependency(e){let t=this.htmlLanguageService.getInternalTagUri(e);if(t){let e=RegExp(`^`+this.module+`\\.`);return{fullName:t.fullname.replace(e,`$namespace$`),uri:t.uri,isStrong:!1}}let n=this.getWebComponentDefinition(e);if(n){let e=n.class.fileUri;return n.isLocal||(e=`@external`),{fullName:n.class.fullName,uri:e,isStrong:!1}}return null}getWebComponentDefinition(e,t=!1){let n=this.htmlLanguageService.getInternalDefinition(e);if(n&&n.fileParsed){let e=n.getComponentName();if(e){let t=n.fileParsed.classes[e];if(t)return{class:t,isLocal:!0}}}let r=this.htmlLanguageService.getClassByTag(e);if(r){let n=this.externalPackageInformation.getExternalWebComponentDefinition(r);if(n){if(t){let t=this.project.getInternalWebComponentDefinition(O(n.fileUri),e);if(t)return{class:t,isLocal:!1}}return{class:n,isLocal:!1}}}}getWebComponentDefinitionFile(e){let t=this.htmlLanguageService.getInternalDefinition(e);if(t)return t;let n=this.htmlLanguageService.getClassByTag(e);if(n)return this.externalPackageInformation.getExternalWebComponentDefinitionFile(n)}getSlotsInfo(e){let t={},n=[],r=!1,i=e;for(;i&&i.fullName!=`Aventus.WebComponent`;){let a=this.tsFiles[i.fileUri];if(!a){let a=this.externalPackageInformation.getByFullName(i.fullName);if(a&&a.content!=`noCode`&&a.content.slots&&!r)for(let r in a.content.slots)n.includes(r)||(t[r]||(t[r]={local:i==e}),!t[r].doc&&i.documentation?.documentationSlots[r]&&(t[r].doc=i.documentation?.documentationSlots[r]))}else if(a instanceof F&&a.HTMLFile?.fileParsed?.slotsInfo&&!r){for(let r in a.HTMLFile.fileParsed.slotsInfo)n.includes(r)||(t[r]||(t[r]={local:i==e}),!t[r].doc&&i.documentation?.documentationSlots[r]&&(t[r].doc=i.documentation?.documentationSlots[r]));for(let e in a.HTMLFile.fileParsed.blocksInfo)t[e]||n.push(e)}i.decorators.find(e=>Pn.is(e))&&(r=!0),i=i.parentClass}return t}getNamespaceForUri(e){if(this.buildConfig.namespaceStrategy==`manual`)return``;if(this.buildConfig.namespaceStrategy==`rules`){let t=O(e);for(let e in this.buildConfig.namespaceRulesRegex){let n=this.buildConfig.namespaceRulesRegex[e];if(t.match(n))return e}}else if(this.buildConfig.namespaceStrategy==`followFolders`||this.buildConfig.namespaceStrategy==`followFoldersCamelCase`){let t=e.endsWith(T.ComponentLogic),n=O(e),r=n.split(`/`);r.pop(),t&&r.pop(),n=r.join(`/`)+`/`;let i=n.replace(this.buildConfig.namespaceRoot,``).replace(/\//g,`.`);return i.endsWith(`.`)&&(i=i.slice(0,-1)),i.startsWith(`.`)&&(i=i.slice(1)),i.includes(`:`)?``:this.buildConfig.namespaceStrategy==`followFoldersCamelCase`?(i=i.slice(0,1).toUpperCase()+i.slice(1),i.replace(/(([-_\.]|^)[a-z])/g,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))):i}return``}addNamespace(e){if(!this.namespaces.includes(e)){let t=e.split(`.`),n=``;for(let e of t)n+=e,n&&!this.namespaces.includes(n)&&this.namespaces.push(n),n+=`.`}}async onRename(e){for(let t of e)if(t.oldUri.endsWith(T.Component)||t.oldUri.endsWith(T.ComponentLogic)||t.oldUri.endsWith(T.Data)||t.oldUri.endsWith(T.Lib)||t.oldUri.endsWith(T.RAM))return await this.tsLanguageService.onRenameFile(t.oldUri,t.newUri);return{}}npmAliases={};npmNameCount={};getNpmReplacementName(e,t){if(!this.hasNpmOutput)return``;let n=t.split(`.`),r=n.pop(),i=e.split(`.`);return i.pop(),n.join(`.`)==i.join(`.`)?r:this.npmAliases[t]?this.npmAliases[t]:(this.npmNameCount[r]||(this.npmNameCount[r]=0),this.npmNameCount[r]++,this.npmAliases[t]=r+this.npmNameCount[r],this.npmAliases[t])}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID);for(let e in this.scssFiles)this.scssFiles[e].removeEvents(),this.scssFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.htmlFiles)this.htmlFiles[e].removeEvents(),this.htmlFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.tsFiles)this.tsFiles[e].removeEvents(),this.tsFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.tsLanguageService.i18nFiles)this.tsLanguageService.i18nFiles[e].removeEvents(),this.tsLanguageService.i18nFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.i18nComponentsFiles)this.i18nComponentsFiles[e].removeEvents(),this.i18nComponentsFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);ji.send(this.project.getConfigFile().path,this.buildConfig.fullname)}writeFile(e,t){qe(e,t,`build`,this.buildConfig.fullname)}},Qi=class{files={};informations={};informationsRequired={};webComponentByName={};build;constructor(e){this.build=e}get filesUri(){return Object.keys(this.files)}init(e){for(let t of e)this.files[t.file.uri]=t;this.rebuild()}getByFullName(e){return this.informations[e]}getByUri(e){return this.files[e]}getNpmUri(e){if(!this.build.hasNpmOutput)return null;if(this.informations[e]){let t=this.files[this.informations[e].uri];!t.npmUri&&this.build.initDone&&$.showErrorMessage(`Can't find a npm package for `+t.name+`. You must define the npm field inside the dependencies section of your aventus.conf.avt. Otherwise, you can disable storybook or remove npm export.`);let n=e.split(`.`),r=n.pop();n.splice(0,0,t.npmUri);let i=t.fileParsed?.getBaseInfo(r)?.willBeCompiled??!1;return{name:r,uri:n.join(`/`),compiled:i}}return null}getNamespaceByUri(e){return this.files[e].srcInfo.namespace}getNameByUri(e){return this.files[e].name}getInformationsRequired(e){return this.informationsRequired[e]}getFullInformations(e){return this.files[e]?.srcInfo.available||[]}getStyleByUri(e){return this.files[e]?this.files[e].externalCSS:{}}rebuild(){this.informations={},this.webComponentByName={};let e=[];for(let t in this.files){let n=this.files[t];this.informationsRequired[t]=[];for(let r of n.srcInfo.available)(r.required||this.build.buildConfig.i18n&&r.fullName==`Aventus.I18n`)&&this.informationsRequired[t].push(r),r.fullName&&(this.informations[r.fullName]?this.informations[r.fullName].uri!=t&&e.push({range:{start:{line:0,character:0},end:{line:0,character:0}},severity:m.DiagnosticSeverity.Error,source:w.TypeScript,message:`The name `+r.fullName+` exist inside `+t+` and `+this.informations[r.fullName].uri}):this.informations[r.fullName]={content:r,uri:t});for(let r of n.srcInfo.existing)r.fullName&&(this.informations[r.fullName]?this.informations[r.fullName].uri!=t&&e.push({range:{start:{line:0,character:0},end:{line:0,character:0}},severity:m.DiagnosticSeverity.Error,source:w.TypeScript,message:`The name `+r.fullName+` exist inside `+t+` and `+this.informations[r.fullName].uri}):this.informations[r.fullName]={content:`noCode`,uri:t});this.webComponentByName={...this.webComponentByName,...n.classInfoByName}}$.sendDiagnostics({uri:`@Import lib`,diagnostics:e},this.build)}getExternalWebComponentDefinition(e){return this.webComponentByName[e]}getExternalWebComponentDefinitionFile(e){let t=this.webComponentByName[e];if(t){let e=t.fileUri,n=this.files[e];if(n)return n}}},$i=class{staticConfig;watcher;isReady=!1;project;get name(){return this.staticConfig.name}constructor(e,t){this.project=e,this.staticConfig=t,this.registerWatcher(),this.isReady=!0}async export(){if(this.isReady){Se.startSendStaticTime(this.name);let e=e=>{var t=[],n=e=>((0,u.existsSync)(e)&&(0,u.readdirSync)(e).forEach(r=>{let i=e+`/`+r;if((0,u.lstatSync)(i).isDirectory()){let e=n(i);e.length>0&&t.concat(e)}else t.push(i)}),t);return t=n(e),t},t=(e,t)=>{try{t=(0,f.normalize)(t);let n=t.split(f.sep),r=n.pop(),i=n.join(f.sep);if((0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0}),r.endsWith(`.scss`)){if(!r.startsWith(`_`)){let n=(0,le.compile)(e,{style:`compressed`}).css.toString().trim();qe(t.replace(`.scss`,`.css`),n,`static`,this.name)}}else (0,u.copyFileSync)(e,t),Se.sendFileSize(t,void 0,`static`,this.name)}catch(e){$.error(e)}},n=e(this.staticConfig.inputPathFolder);for(let e of n){e=e.replace(/\\/g,`/`);for(let n of this.staticConfig.outputPathFolder){let r=e.replace(this.staticConfig.inputPathFolder,n);if(e.endsWith(T.Base)){if(e.endsWith(T.GlobalStyle)){r=r.replace(T.GlobalStyle,`.css`);let t=this.project.scssFiles[D(e)];if(!t){let n=d.TextDocument.create(D(e),T.GlobalStyle,1,(0,u.readFileSync)(e,`utf8`));await R.getInstance().registerFile(n),t=this.project.scssFiles[D(e)]}await t.addOutPath(r,this.name)}}else t(e,r)}}yt.getInstance().reload(),Se.sendStaticTime(this.name)}}registerWatcher(){E.getInstance().settings.watchFiles&&(this.watcher=(0,v.watch)(this.staticConfig.inputPathFolder,{ignored:/^\./,persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:100},ignoreInitial:!0}),this.watcher.on(`add`,e=>{this.export()}),this.watcher.on(`change`,e=>{this.export()}),this.watcher.on(`unlink`,e=>{this.export()}),this.watcher.on(`error`,function(e){}))}destroy(){this.watcher&&this.watcher.close()}},ea=class{languageService;variablesByUri={};variablesByName={};constructor(){this.languageService=(0,ce.getSCSSLanguageService)()}async doValidation(e){return this.languageService.doValidation(e.documentUser,this.languageService.parseStylesheet(e.documentUser))}async doComplete(e,t){return this.languageService.doComplete(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async doHover(e,t){return this.languageService.doHover(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async findDefinition(e,t){let n=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));return n&&[n]}async format(e,t,n){let r={...n,preserveNewLines:!0,spaceAroundSelectorSeparator:!0,insertFinalNewline:!0,insertSpaces:!1,tabSize:4},i=e.documentUser,a=await this.languageService.format(i,t,r);if(a.length==1){let e=i.offsetAt(a[0].range.start),t=i.offsetAt(a[0].range.end),n=i.getText().length;if(e==0&&t==n){let e=await(0,se.default)([(0,oi.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:si,from:`./temp.scss`,to:`./temp.scss`});a[0].newText=e.css}}return a}async doCodeAction(e,t){let n=this.languageService.parseStylesheet(e.documentUser),r=m.CodeActionContext.create(this.languageService.doValidation(e.documentUser,n));return this.languageService.doCodeActions2(e.documentUser,t,r,n)}async onReferences(e,t){let n=this.languageService.parseStylesheet(e.documentUser);return this.languageService.findReferences(e.documentUser,t,n)}loadVariables(e,t){let n=e.file.documentUser,r={},i=e=>{if(e.type==69){let i=e;for(;i&&i.selectors==null;)i=i.parent;if(i&&i.selectors.getText()==`:root`){let i=e.getChild(0),a=e.getChild(1);if(i&&a){let e=i.getText();e.startsWith(`--`)&&(i.offset,r[e]||(r[e]={name:e,uri:t,range:{start:n.positionAt(i.offset),end:n.positionAt(i.end)},value:a.getText()}))}}}else if(e.hasChildren())for(let t of e.getChildren())i(t)},a=pi((0,ce.getSCSSLanguageService)().parseStylesheet(n),0);for(let e of a)i(e);this.variablesByUri[t]=Object.values(r),this.reloadVariables()}reloadVariables(){this.variablesByName={};for(let e in this.variablesByUri)for(let t of this.variablesByUri[e])this.variablesByName[t.name]||(this.variablesByName[t.name]=t)}removeVariables(e){delete this.variablesByUri[e],this.reloadVariables()}getDefinition(e){return this.variablesByName[e]}},ta=class{_file;_project;get file(){return this._file}get project(){return this._project}constructor(e,t){this._file=e,this._project=t,this.addEvents()}uuidEvents={onContentChange:``,onValidate:``,onSave:``,onDelete:``,onCompletion:``,onCompletionResolve:``,onHover:``,onDefinition:``,onFormatting:``,onCodeAction:``,onReferences:``,onCodeLens:``,onRename:``};addEvents(){this.uuidEvents.onContentChange=this.file.onContentChange(this.onContentChange.bind(this)),this.uuidEvents.onValidate=this.file.onValidate(this._onValidate.bind(this)),this.uuidEvents.onSave=this.file.onSave(this.onSave.bind(this)),this.uuidEvents.onDelete=this.file.onDelete(this._onDelete.bind(this)),this.uuidEvents.onCompletion=this.file.onCompletion(this.onCompletion.bind(this)),this.uuidEvents.onCompletionResolve=this.file.onCompletionResolve(this.onCompletionResolve.bind(this)),this.uuidEvents.onHover=this.file.onHover(this.onHover.bind(this)),this.uuidEvents.onDefinition=this.file.onDefinition(this.onDefinition.bind(this)),this.uuidEvents.onFormatting=this.file.onFormatting(this.onFormatting.bind(this)),this.uuidEvents.onCodeAction=this.file.onCodeAction(this.onCodeAction.bind(this)),this.uuidEvents.onReferences=this.file.onReferences(this.onReferences.bind(this)),this.uuidEvents.onCodeLens=this.file.onCodeLens(this.onCodeLens.bind(this)),this.uuidEvents.onRename=this.file.onRename(this.onRename.bind(this))}removeEvents(){this.file.removeOnContentChange(this.uuidEvents.onContentChange),this.file.removeOnValidate(this.uuidEvents.onValidate),this.file.removeOnSave(this.uuidEvents.onSave),this.file.removeOnDelete(this.uuidEvents.onDelete),this.file.removeOnCompletion(this.uuidEvents.onCompletion),this.file.removeOnCompletionResolve(this.uuidEvents.onCompletionResolve),this.file.removeOnHover(this.uuidEvents.onHover),this.file.removeOnDefinition(this.uuidEvents.onDefinition),this.file.removeOnFormatting(this.uuidEvents.onFormatting),this.file.removeOnCodeAction(this.uuidEvents.onCodeAction),this.file.removeOnReferences(this.uuidEvents.onReferences),this.file.removeOnCodeLens(this.uuidEvents.onCodeLens),this.file.removeOnRename(this.uuidEvents.onRename)}async validate(){this.file instanceof j&&await this.file.validate()}triggerSave(){this.file instanceof j&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof j&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async _onDelete(){await this.onDelete(),this.removeEvents()}},na=class e extends ta{compiledVersion=-1;usedBy={};dependencies={};diagnostics=[];diagnosticCompile;compiledTxt=``;savedOnce=!1;staticNamebyOutPath={};get resultCompiled(){return this.compiledTxt}constructor(e,t){super(e,t),this.loadDependencies(),this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}async onContentChange(){}async onValidate(){return this.diagnostics=await this.project.globalSCSSLanguageService.doValidation(this.file),this.loadDependencies(),this.diagnosticCompile?[...this.diagnostics,this.diagnosticCompile]:this.diagnostics}async onSave(){this.savedOnce=!0,this.compileRoot(),this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}compileRoot(){if(Object.values(this.usedBy).length==0)this.compile();else for(let e in this.usedBy)this.usedBy[e].onSave()}compile(){try{let e=this.compiledTxt,t=`|error|`,n=e=>{let r=e.contentUser;r=r.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let i=/@import *?('|")(\S*?)('|");?/g,a=null;for(;a=i.exec(r);){let i=a[2],o=this.resolvePath(i,e.folderPath);if(o){let e=n(o);if(e==t)return e;r=r.replace(a[0],e)}else return t}return r},r=n(this.file);if(r!=`|error|`){let t=e=>{if(E.getInstance().settings.errorByBuild){let t=this.project.getBuilds();for(let n of t)$.sendDiagnostics({uri:this.file.uri,diagnostics:e},n)}else $.sendDiagnostics({uri:this.file.uri,diagnostics:e})};try{let n=(0,le.compileString)(r,{style:`compressed`}).css.toString().trim();n=n.replace(/\\/g,`\\\\`),e=n,this.diagnosticCompile&&(this.diagnosticCompile=void 0,t(this.diagnostics))}catch(e){e instanceof le.Exception&&(this.diagnosticCompile=je(this.file.documentUser,e.message),t([...this.diagnostics,this.diagnosticCompile]))}}e!=this.compiledTxt&&(this.compiledVersion++,this.compiledTxt=e,this.export())}catch(e){console.error(e)}}async onDelete(){for(let e in this.dependencies)this.removeDependency(e);for(let e in this.usedBy)delete this.usedBy[e].dependencies[this.file.uri],delete this.usedBy[e],await this.usedBy[e].onContentChange();this.project.globalSCSSLanguageService.removeVariables(this.file.uri)}async onCompletion(e,t){let n={isIncomplete:!1,items:[]};return n=await this.project.globalSCSSLanguageService.doComplete(e,t),n}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.project.globalSCSSLanguageService.doHover(e,t)}async onDefinition(e,t){return this.project.globalSCSSLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return this.project.globalSCSSLanguageService.format(e,t,n)}async onCodeAction(e,t){return this.project.globalSCSSLanguageService.doCodeAction(e,t)}async onReferences(e,t){return await this.project.globalSCSSLanguageService.onReferences(e,t)}async onCodeLens(e){return[]}async onRename(e,t,n){return null}async addOutPath(e,t){this.file.shortname.startsWith(`_`)||this.staticNamebyOutPath[e]||(this.staticNamebyOutPath[e]=t,this.savedOnce||await this.onSave(),this.export())}export(){for(let e in this.staticNamebyOutPath){let t=(0,f.normalize)(e),n=t.split(f.sep);n.pop();let r=n.join(f.sep);(0,u.existsSync)(r)||(0,u.mkdirSync)(r,{recursive:!0}),qe(t,this.compiledTxt,`static`,this.staticNamebyOutPath[e])}}loadDependencies(){let e=this.file.contentUser,t=e.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`),n=/@import *?('|")(\S*?)('|");?/g,r=null;for(let e in this.dependencies)this.removeDependency(e);for(;r=n.exec(t);){let t=r[2],n=this.resolvePath(t,this.file.folderPath);if(n)this.addDependency(n);else{let t=e.indexOf(r[0]),n=t+r[0].length;this.diagnostics.push(Me(this.file.documentUser,`Can't load this file`,t,n))}}}removeDependency(e){this.dependencies[e]&&(delete this.dependencies[e].usedBy[this.file.uri],delete this.dependencies[e])}addDependency(t){this.project.scssFiles[t.uri]?(this.dependencies[t.uri]=this.project.scssFiles[t.uri],this.project.scssFiles[t.uri].usedBy[this.file.uri]=this):t.uri.endsWith(T.GlobalStyle)&&(this.project.scssFiles[t.uri]=new e(t,this.project),this.dependencies[t.uri]=this.project.scssFiles[t.uri],this.project.scssFiles[t.uri].usedBy[this.file.uri]=this)}resolvePath(e,t){e=this.project.resolveAlias(e,t),e=(0,f.normalize)(t+`/`+e);let n=R.getInstance().getByPath(e);if(n)return n;let r=e+T.GlobalStyle;if(n=R.getInstance().getByPath(r),n)return n;let i=e.split(f.sep);i[i.length-1]=`_`+i[i.length-1];let a=i.join(f.sep);if(n=R.getInstance().getByPath(a),n)return n;let o=a+T.GlobalStyle;if(n=R.getInstance().getByPath(o),n)return n}},ra=class{waitingList=[];isLocked=!1;waitOne(){return new Promise(e=>{this.isLocked?this.waitingList.push(()=>{e()}):(this.isLocked=!0,e())})}release(){let e=this.waitingList.shift();e?e():this.isLocked=!1}dispose(){this.waitingList=[],this.isLocked=!1}},ia=class{configFile;config=null;builds=[];statics=[];_isCoreBuild=!1;scssFiles={};onValidateUUID;onSaveUUID;onFormattingUUID;onCompletionUUID;onCompletionResolveUUID;onHoverUUID;onNewFileUUID;onFileDeleteUUIDs={};buildsAllowed;staticsAllowed;globalSCSSLanguageService;get isCoreBuild(){return this._isCoreBuild}getConfigFile(){return this.configFile}getConfig(){return this.config}resolveAlias(e,t){if(e.startsWith(`@`)){let n=e.split(`/`),r=n[0],i=this.config?.aliases[r];if(i){let e=(0,f.normalize)(this.configFile.folderPath+`/`+i);typeof t!=`string`&&(t=t.folderPath);let r=(0,f.normalize)(t);e.endsWith(f.sep)&&(e=e.substring(0,e.length-1)),r.endsWith(f.sep)&&(r=r.substring(0,r.length-1));let a=e.split(f.sep),o=r.split(f.sep);for(let e=0;e<a.length;e++)if(o.length>e)if(a[e]==o[e])a.splice(e,1),o.splice(e,1),e--;else break;let s=``;for(let e=0;e<o.length;e++)s+=`../`;return s==``&&(s+=`./`),s+=a.join(`/`),n.splice(0,1,s),n.join(`/`).replace(/\/\//g,`/`)}}return e}getInternalWebComponentDefinition(e,t){for(let n of this.builds)if(n.outputPathes.includes(e))return n.getLocalWebComponentDefinition(t)}constructor(e,t){this.configFile=e,this.onValidateUUID=this.configFile.onValidate(this.onValidate.bind(this)),this.onSaveUUID=this.configFile.onSave(this.onConfigSave.bind(this)),this.onFormattingUUID=this.configFile.onFormatting(this.onFormatting.bind(this)),this.onCompletionUUID=this.configFile.onCompletion(this.onCompletion.bind(this)),this.onCompletionResolveUUID=this.configFile.onCompletionResolve(this.onCompletionResolve.bind(this)),this.onHoverUUID=this.configFile.onHover(this.onHover.bind(this)),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile.bind(this)),e.folderUri.toLowerCase().endsWith(`/aventus/base/src`)&&(this._isCoreBuild=!0),this.globalSCSSLanguageService=new ea,t&&this.loadFiles(),e.validate()}async init(){await this.onConfigSave()}async onValidate(){return await ot.getInstance().validate(this.configFile)}async loadConfig(){let e=await ot.getInstance().getConfig(this.configFile);if(this.config){let t=JSON.stringify(this.config),n=``;if(e&&(n=JSON.stringify(e)),t==n)return;for(let e of this.builds)e.destroy()}this.builds=[],this.config=e}onConfigSaveMutex=new ra;async onConfigSave(){if(await this.onConfigSaveMutex.waitOne(),await this.loadConfig(),this.config){for(let e of this.builds)e.destroy();for(let e of this.statics)e.destroy();for(let e of this.config.build){if(this.buildsAllowed){if(!this.buildsAllowed.includes(e.name??``)){let t=this.builds.find(t=>t.buildConfig.name==e.name);t&&t.build();continue}}else if(e.disabled)continue;let t=new Zi(this,e);this.builds.push(t),await t.init()}if(this.config.static)for(let e of this.config.static){if(this.staticsAllowed&&!this.staticsAllowed.includes(e.name))continue;let t=new $i(this,e);await t.export(),this.statics.push(t)}}this.onConfigSaveMutex.release()}async onFormatting(e,t,n){return await ot.getInstance().format(e,t,n)}async onCompletion(e,t){return await ot.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return await ot.getInstance().doResolve(t)}async onHover(e,t){return await ot.getInstance().doHover(e,t)}getBuildsName(){let e=[];for(let t of this.builds)e.push(t.fullname);return e}getBuildsNameWithStory(){let e=[];for(let t of this.builds)t.hasStories&&e.push(t.fullname);return e}getBuildsNameWithNpm(){let e=[];for(let t of this.builds)t.hasNpmOutput&&e.push(t.fullname);return e}getBuild(e){for(let t of this.builds)if(t.fullname==e)return t}getBuilds(){return this.builds}getMatchingBuildsByUri(e){let t=[];for(let n of this.builds)n.isFileInside(e)&&t.push(n);return t}getStaticsName(){let e=[];for(let t of this.statics)e.push(t.name);return e}getStatic(e){for(let t of this.statics)if(t.name==e)return t}loadFiles(){let e=R.getInstance().getFilesWithExtension(T.GlobalStyle);for(let t of e)this.onNewFile(t)}async onNewFile(e){e.path.endsWith(T.GlobalStyle)&&(this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new na(e,this),this.registerOnFileDelete(e)))}registerOnFileDelete(e){this.onFileDeleteUUIDs[e.uri]=e.onDelete(this.onFileDelete.bind(this))}async onFileDelete(e){e.removeOnDelete(this.onFileDeleteUUIDs[e.uri]),delete this.onFileDeleteUUIDs[e.uri],e.uri.endsWith(T.GlobalStyle)&&delete this.scssFiles[e.uri]}async onRename(e){let t={};for(let n of this.builds){let r=await n.onRename(e);for(let e in r)t[e]||(t[e]=[]),t[e]=t[e].concat(r[e])}return t}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),this.configFile.removeOnSave(this.onSaveUUID),this.configFile.removeOnValidate(this.onValidateUUID),this.configFile.removeOnFormatting(this.onFormattingUUID),this.configFile.removeOnCompletion(this.onCompletionUUID),this.configFile.removeOnCompletionResolve(this.onCompletionResolveUUID),this.configFile.removeOnHover(this.onHoverUUID);for(let e of this.builds)e.destroy();for(let e of this.statics)e.destroy()}},L=class e{static autoLoad=!0;static instance;static getInstance(){return this.instance||=new e,this.instance}projects={};constructor(){R.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(t){if(t.documentUser.uri.endsWith(`/`+T.Config)){let n=t.documentUser.uri.replace(T.Config,T.Template);if(R.getInstance().getByUri(n))return;this.projects[t.documentUser.uri]?console.error(`a config file with the uri :`+t.documentUser.uri+` is already inside project manager`):(this.projects[t.documentUser.uri]=new ia(t,e.autoLoad),e.autoLoad&&await this.projects[t.documentUser.uri].init(),t.onDelete(this.onDeleteFile.bind(this)))}}async onDeleteFile(e){this.projects[e.documentUser.uri]&&(this.projects[e.documentUser.uri].destroy(),delete this.projects[e.documentUser.uri])}getProjectByUri(e){return this.projects[e]}getMatchingBuildsByUri(e){let t=[];for(let n in this.projects){let r=this.projects[n].getMatchingBuildsByUri(e);for(let e of r)t.push(e)}return t}destroyAll(){for(let e in this.projects)this.projects[e].destroy()}async onRename(e){let t={};for(let n in this.projects){let r=await this.projects[n].onRename(e);for(let e in r)t[e]||(t[e]=[]),t[e]=t[e].concat(r[e])}return t}getAllConfigFiles(){let e=[];for(let t in this.projects)e.push(this.projects[t].getConfigFile().uri);return e}getAllBuilds(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsName();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllBuildsWithStory(){let e=[],t=[];for(let n in this.projects){let r=this.projects[n],i=r.getBuildsNameWithStory();for(let n of i){let i=n+`_`+r.getConfigFile().uri;t.includes(i)||(t.push(i),e.push({name:n,uri:r.getConfigFile().uri}))}}return e}getAllBuildsWithNpm(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsNameWithNpm();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllStatics(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsName();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}},R=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}constructor(){}files={};lockedUpdatedUri={};loadingInProgress=!0;preventUpdateUri(e){this.lockedUpdatedUri[e]&&clearTimeout(this.lockedUpdatedUri[e]),this.lockedUpdatedUri[e]=setTimeout(()=>{delete this.lockedUpdatedUri[e]},2e3)}async onCreatedUri(e){if(!this.files[e]){let t=De(e);if(t){let n=O(e),r=d.TextDocument.create(e,t,0,(0,u.readFileSync)(n,`utf8`));await this.registerFile(r),this.onSave(r)}}}async onUpdatedUri(e){if(this.lockedUpdatedUri[e])return;let t=De(e),n=O(e),r=``;if((0,u.existsSync)(n))r=(0,u.readFileSync)(n,`utf8`);else{this.onDeletedUri(e);return}if(this.files[e]){let n=this.files[e].versionUser+1,i=d.TextDocument.create(e,t,n,r);await this.onContentChange(i),this.onSave(i)}else{let n=d.TextDocument.create(e,t,0,r);await this.registerFile(n),this.onSave(n)}}async onDeletedUri(e){if(this.files[e]){if(E.getInstance().settings.errorByBuild){let t=this.files[e].getBuild();if(t===null)$.sendDiagnostics({uri:e,diagnostics:[]});else for(let n of t)$.sendDiagnostics({uri:e,diagnostics:[]},n)}else $.sendDiagnostics({uri:e,diagnostics:[]});await this.files[e].triggerDelete(),delete this.files[e],nt.getInstance().unwatch(e)}}async loadConfigFileNotSet(e,t,n){for(let r=0;r<e.length;r++){let i=O(e[r]),a=async e=>{let r=(0,u.readdirSync)(e);for(let i=0;i<r.length;i++){let o=e+`/`+r[i];if((0,u.lstatSync)(o).isDirectory()){if(r[i]!=`node_modules`&&await a(o))return!0}else{let e=D(o);if(r[i]==T.Config)return await this.loadConfigFile(e,t,n),!0}}return!1};if(await a(i))return}tt.sendDone()}async loadConfigFile(e,t,n){L.autoLoad=!1;let r=O(e);e=D(r);let i=d.TextDocument.create(D(r),T.Config,0,(0,u.readFileSync)(r,`utf8`));this.loadingInProgress=!1,await this.registerFile(i),this.loadingInProgress=!0;let a=L.getInstance().getProjectByUri(e);if(a){await a.loadConfig(),a.buildsAllowed=t,a.staticsAllowed=n;let e=a.getConfig();if(e){let r=async e=>{if(!(0,u.existsSync)(e))return;let t=(0,u.readdirSync)(e);for(let n=0;n<t.length;n++){let i=e+`/`+t[n];if((0,u.lstatSync)(i).isDirectory())t[n]!=`node_modules`&&await r(i);else{let e=D(i),r=De(e);if(t[n]!=T.Config&&t[n].endsWith(T.Base)){let t=d.TextDocument.create(e,r,0,(0,u.readFileSync)(i,`utf8`));await this.registerFile(t)}}}};for(let n of e.build)if(!t||t.includes(n.name??``))for(let e of n.srcPath)await r(e);for(let t of e.static)(!n||n.includes(t.name??``))&&await r(t.inputPathFolder);Se.startSendLoadFile(),a.loadFiles(),Se.sendLoadFile(),this.loadingInProgress=!1,await a.init(),tt.sendDone()}}}async parseWorkspace(e,t){let n=O(e),r=E.getInstance().settings.readDirs,i=e=>!0;if(r.length>0){let t=[],n=[];for(let i of r){let r=``,a=i.replace(/\\/g,`/`);a.startsWith(`/`)||(r=`/`);let o=a.split(`/`);o[o.length-1]==``||o[o.length-1]==`*`?o[o.length-1]=`*`:o[o.length-1].indexOf(`.`)==-1&&o.push(`*`),a=o.join(`/`);let s=(0,f.normalize)(O(e)+r+a).replace(/\\/g,`/`);s=Be(s,!0).replace(`*`,`.*`);let c=s.split(`/`),l=``;for(let e of c)e!=`.*`&&(l==``?l=e:l+=`/`+e,n.includes(l)||n.push(l));t.push(`(^`+s+`$)`)}let a=t.join(`|`);a==``&&(a=`(?!)`);let o=new RegExp(a);i=e=>{let t=(e+`/`).match(o)!=null,r=n.includes(e);return t||r}}let a=async e=>{if(!i(e))return;let n=(0,u.readdirSync)(e);for(let r=0;r<n.length;r++){let i=e+`/`+n[r];(0,u.lstatSync)(i).isDirectory()?n[r]!=`node_modules`&&n[r]!=`.git`&&await a(i):await t(n[r],i)}};await a(n)}async loadAllAventusConfigFiles(e){let t=[];for(let n=0;n<e.length;n++)await this.parseWorkspace(e[n],async(e,n)=>{let r=D(n),i=De(r);e==T.Config&&t.push(new j(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`))))});return t}async loadAllAventusFiles(e){this.loadingInProgress=!0;let t=[];tt.send(`$(loading~spin) Aventus : Loading files`);for(let n=0;n<e.length;n++)await this.parseWorkspace(e[n],async(e,n)=>{let r=D(n),i=De(r);if(e==T.Config)t.push(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`)));else if(e.endsWith(T.Base)){let e=d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`));await this.registerFile(e)}});tt.send(`$(loading~spin) Aventus : Register config`),this.loadingInProgress=!1;for(let e of t)await this.registerFile(e);tt.sendDone()}async onShutdown(){for(let e in this.files)await this.files[e].triggerDelete(),delete this.files[e],nt.getInstance().unwatch(e)}async fileExists(e){return this.files[e.uri]?!0:e.uri.endsWith(T.Template)?(await this.registerFile(e),this.onSave(e),!0):!1}async registerFilePackage(e){let t=O(e),n=``;(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`));let r=d.TextDocument.create(e,w.Package,0,n);return nt.getInstance().watch(e),await this.registerFile(r)}async registerFile(e){return $.debug(`registering `+e.uri),this.files[e.uri]?await this.files[e.uri].triggerContentChange(e):await this.triggerOnNewFile(e),$.isIDE||nt.getInstance().watch(e.uri),this.files[e.uri]}async onContentChange(e){this.files[e.uri]?await this.files[e.uri].triggerContentChange(e):await this.triggerOnNewFile(e)}async onSave(e){this.files[e.uri]?await this.files[e.uri].triggerSave():await this.triggerOnNewFile(e)}async onClose(e){(0,u.existsSync)(O(e.uri))||this.onDeletedUri(e.uri)}async onCompletion(e,t){return await this.fileExists(e)?this.files[e.uri].getCompletion(t):{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){return await this.fileExists(e)?this.files[e.uri].getCompletionResolve(t):t}async onHover(e,t){return await this.fileExists(e)?this.files[e.uri].getHover(t):null}async onDefinition(e,t){return await this.fileExists(e)?this.files[e.uri].getDefinition(t):null}async onFormatting(e,t){return await this.fileExists(e)?this.files[e.uri].getFormatting(t):[]}async onCodeAction(e,t){return await this.fileExists(e)?this.files[e.uri].getCodeAction(t):[]}async onReferences(e,t){return await this.fileExists(e)?this.files[e.uri].getReferences(t):[]}async onCodeLens(e){return await this.fileExists(e)?this.files[e.uri].getCodeLens():[]}async onRename(e,t,n){return await this.fileExists(e)?this.files[e.uri].getRename(t,n):null}getBuild(e){return this.files[e.uri]?this.files[e.uri].getBuild():[]}onNewFileCb={};async triggerOnNewFile(e){if($.debug(`triggerOnNewFile `+e.uri),this.loadingInProgress&&e.uri.endsWith(T.Config))return;this.files[e.uri]=new j(e);let t=[];for(let n in this.onNewFileCb)t.push(this.onNewFileCb[n](this.files[e.uri]));await Promise.all(t)}onNewFile(e){let t=A();for(;this.onNewFileCb[t]!=null;)t=A();return this.onNewFileCb[t]=e,t}removeOnNewFile(e){delete this.onNewFileCb[e]}onFileRemoveCb={};async triggerOnFileRemove(e){$.debug(`triggerOnFileRemove `+e);let t=[];for(let n in this.onFileRemoveCb)t.push(this.onFileRemoveCb[n](e));await Promise.all(t)}onFileRemove(e){let t=A();for(;this.onNewFileCb[t]!=null;)t=A();return this.onFileRemoveCb[t]=e,t}removeOnFileRemove(e){delete this.onFileRemoveCb[e]}getFilesMatching(e){let t=[];for(let n in this.files)this.files[n].path.match(e)&&t.push(this.files[n]);return t}getFilesWithExtension(e){Array.isArray(e)||(e=[e]);let t=[];for(let n in this.files)for(let r of e)this.files[n].path.endsWith(r)&&t.push(this.files[n]);return t}getByPath(e){return this.files[D(e)]}getByUri(e){return this.files[e]}getUris(){return Object.keys(this.files)}},aa=class e{static tc(e,t){if(typeof e!=t)throw TypeError(`required type ${t} got ${typeof e}`);return e}static ic(e,t){if(!(e instanceof t))throw TypeError(`required type ${t} got ${typeof e}`);return e}static nc(e){return isNaN(e)?0:e}static oc(e){return{angle:e&&e.angle?e.angle:15,results:e&&e.results?e.results:3}}static clmp(e,t,n){return n!==void 0&&e<n?n:e>t?t:e}static shift(e,t){for(e+=t;e>=360;)e-=360;for(;e<0;)e+=360;return e}#e;#t;#n;alpha;static Colors=class{static get BLACK(){return e.fromHex(`#000000`)}static get SILVER(){return e.fromHex(`#c0c0c0`)}static get GRAY(){return e.fromHex(`#808080`)}static get WHITE(){return e.fromHex(`#ffffff`)}static get MAROON(){return e.fromHex(`#800000`)}static get RED(){return e.fromHex(`#ff0000`)}static get PURPLE(){return e.fromHex(`#800080`)}static get GREEN(){return e.fromHex(`#008000`)}static get LIME(){return e.fromHex(`#00ff00`)}static get OLIVE(){return e.fromHex(`#808000`)}static get YELLOW(){return e.fromHex(`#ffff00`)}static get NAVY(){return e.fromHex(`#000080`)}static get BLUE(){return e.fromHex(`#0000ff`)}static get TEAL(){return e.fromHex(`#008080`)}static get AQUA(){return e.fromHex(`#00ffff`)}static get ORANGE(){return e.fromHex(`#ffa500`)}static get ALICEBLUE(){return e.fromHex(`#f0f8ff`)}static get ANTIQUEWHITE(){return e.fromHex(`#faebd7`)}static get AQUAMARINE(){return e.fromHex(`#7fffd4`)}static get AZURE(){return e.fromHex(`#f0ffff`)}static get BEIGE(){return e.fromHex(`#f5f5dc`)}static get BISQUE(){return e.fromHex(`#ffe4c4`)}static get BLANCHEDALMOND(){return e.fromHex(`#ffebcd`)}static get BLUEVIOLET(){return e.fromHex(`#8a2be2`)}static get BROWN(){return e.fromHex(`#a52a2a`)}static get BURLYWOOD(){return e.fromHex(`#deb887`)}static get CADETBLUE(){return e.fromHex(`#5f9ea0`)}static get CHARTREUSE(){return e.fromHex(`#7fff00`)}static get CHOCOLATE(){return e.fromHex(`#d2691e`)}static get CORAL(){return e.fromHex(`#ff7f50`)}static get CORNFLOWERBLUE(){return e.fromHex(`#6495ed`)}static get CORNSILK(){return e.fromHex(`#fff8dc`)}static get CRIMSON(){return e.fromHex(`#dc143c`)}static get CYAN(){return e.fromHex(`#00ffff`)}static get DARKBLUE(){return e.fromHex(`#00008b`)}static get DARKCYAN(){return e.fromHex(`#008b8b`)}static get DARKGOLDENROD(){return e.fromHex(`#b8860b`)}static get DARKGRAY(){return e.fromHex(`#a9a9a9`)}static get DARKGREEN(){return e.fromHex(`#006400`)}static get DARKGREY(){return e.fromHex(`#a9a9a9`)}static get DARKKHAKI(){return e.fromHex(`#bdb76b`)}static get DARKMAGENTA(){return e.fromHex(`#8b008b`)}static get DARKOLIVEGREEN(){return e.fromHex(`#556b2f`)}static get DARKORANGE(){return e.fromHex(`#ff8c00`)}static get DARKORCHID(){return e.fromHex(`#9932cc`)}static get DARKRED(){return e.fromHex(`#8b0000`)}static get DARKSALMON(){return e.fromHex(`#e9967a`)}static get DARKSEAGREEN(){return e.fromHex(`#8fbc8f`)}static get DARKSLATEBLUE(){return e.fromHex(`#483d8b`)}static get DARKSLATEGRAY(){return e.fromHex(`#2f4f4f`)}static get DARKSLATEGREY(){return e.fromHex(`#2f4f4f`)}static get DARKTURQUOISE(){return e.fromHex(`#00ced1`)}static get DARKVIOLET(){return e.fromHex(`#9400d3`)}static get DEEPPINK(){return e.fromHex(`#ff1493`)}static get DEEPSKYBLUE(){return e.fromHex(`#00bfff`)}static get DIMGRAY(){return e.fromHex(`#696969`)}static get DIMGREY(){return e.fromHex(`#696969`)}static get DODGERBLUE(){return e.fromHex(`#1e90ff`)}static get FIREBRICK(){return e.fromHex(`#b22222`)}static get FLORALWHITE(){return e.fromHex(`#fffaf0`)}static get FORESTGREEN(){return e.fromHex(`#228b22`)}static get GAINSBORO(){return e.fromHex(`#dcdcdc`)}static get GHOSTWHITE(){return e.fromHex(`#f8f8ff`)}static get GOLD(){return e.fromHex(`#ffd700`)}static get GOLDENROD(){return e.fromHex(`#daa520`)}static get GREENYELLOW(){return e.fromHex(`#adff2f`)}static get GREY(){return e.fromHex(`#808080`)}static get HONEYDEW(){return e.fromHex(`#f0fff0`)}static get HOTPINK(){return e.fromHex(`#ff69b4`)}static get INDIANRED(){return e.fromHex(`#cd5c5c`)}static get INDIGO(){return e.fromHex(`#4b0082`)}static get IVORY(){return e.fromHex(`#fffff0`)}static get KHAKI(){return e.fromHex(`#f0e68c`)}static get LAVENDER(){return e.fromHex(`#e6e6fa`)}static get LAVENDERBLUSH(){return e.fromHex(`#fff0f5`)}static get LAWNGREEN(){return e.fromHex(`#7cfc00`)}static get LEMONCHIFFON(){return e.fromHex(`#fffacd`)}static get LIGHTBLUE(){return e.fromHex(`#add8e6`)}static get LIGHTCORAL(){return e.fromHex(`#f08080`)}static get LIGHTCYAN(){return e.fromHex(`#e0ffff`)}static get LIGHTGOLDENRODYELLOW(){return e.fromHex(`#fafad2`)}static get LIGHTGRAY(){return e.fromHex(`#d3d3d3`)}static get LIGHTGREEN(){return e.fromHex(`#90ee90`)}static get LIGHTGREY(){return e.fromHex(`#d3d3d3`)}static get LIGHTPINK(){return e.fromHex(`#ffb6c1`)}static get LIGHTSALMON(){return e.fromHex(`#ffa07a`)}static get LIGHTSEAGREEN(){return e.fromHex(`#20b2aa`)}static get LIGHTSKYBLUE(){return e.fromHex(`#87cefa`)}static get LIGHTSLATEGRAY(){return e.fromHex(`#778899`)}static get LIGHTSLATEGREY(){return e.fromHex(`#778899`)}static get LIGHTSTEELBLUE(){return e.fromHex(`#b0c4de`)}static get LIGHTYELLOW(){return e.fromHex(`#ffffe0`)}static get LIMEGREEN(){return e.fromHex(`#32cd32`)}static get LINEN(){return e.fromHex(`#faf0e6`)}static get MAGENTA(){return e.fromHex(`#ff00ff`)}static get FUCHSIA(){return e.fromHex(`#ff00ff`)}static get MEDIUMAQUAMARINE(){return e.fromHex(`#66cdaa`)}static get MEDIUMBLUE(){return e.fromHex(`#0000cd`)}static get MEDIUMORCHID(){return e.fromHex(`#ba55d3`)}static get MEDIUMPURPLE(){return e.fromHex(`#9370db`)}static get MEDIUMSEAGREEN(){return e.fromHex(`#3cb371`)}static get MEDIUMSLATEBLUE(){return e.fromHex(`#7b68ee`)}static get MEDIUMSPRINGGREEN(){return e.fromHex(`#00fa9a`)}static get MEDIUMTURQUOISE(){return e.fromHex(`#48d1cc`)}static get MEDIUMVIOLETRED(){return e.fromHex(`#c71585`)}static get MIDNIGHTBLUE(){return e.fromHex(`#191970`)}static get MINTCREAM(){return e.fromHex(`#f5fffa`)}static get MISTYROSE(){return e.fromHex(`#ffe4e1`)}static get MOCCASIN(){return e.fromHex(`#ffe4b5`)}static get NAVAJOWHITE(){return e.fromHex(`#ffdead`)}static get OLDLACE(){return e.fromHex(`#fdf5e6`)}static get OLIVEDRAB(){return e.fromHex(`#6b8e23`)}static get ORANGERED(){return e.fromHex(`#ff4500`)}static get ORCHID(){return e.fromHex(`#da70d6`)}static get PALEGOLDENROD(){return e.fromHex(`#eee8aa`)}static get PALEGREEN(){return e.fromHex(`#98fb98`)}static get PALETURQUOISE(){return e.fromHex(`#afeeee`)}static get PALEVIOLETRED(){return e.fromHex(`#db7093`)}static get PAPAYAWHIP(){return e.fromHex(`#ffefd5`)}static get PEACHPUFF(){return e.fromHex(`#ffdab9`)}static get PERU(){return e.fromHex(`#cd853f`)}static get PINK(){return e.fromHex(`#ffc0cb`)}static get PLUM(){return e.fromHex(`#dda0dd`)}static get POWDERBLUE(){return e.fromHex(`#b0e0e6`)}static get ROSYBROWN(){return e.fromHex(`#bc8f8f`)}static get ROYALBLUE(){return e.fromHex(`#4169e1`)}static get SADDLEBROWN(){return e.fromHex(`#8b4513`)}static get SALMON(){return e.fromHex(`#fa8072`)}static get SANDYBROWN(){return e.fromHex(`#f4a460`)}static get SEAGREEN(){return e.fromHex(`#2e8b57`)}static get SEASHELL(){return e.fromHex(`#fff5ee`)}static get SIENNA(){return e.fromHex(`#a0522d`)}static get SKYBLUE(){return e.fromHex(`#87ceeb`)}static get SLATEBLUE(){return e.fromHex(`#6a5acd`)}static get SLATEGRAY(){return e.fromHex(`#708090`)}static get SLATEGREY(){return e.fromHex(`#708090`)}static get SNOW(){return e.fromHex(`#fffafa`)}static get SPRINGGREEN(){return e.fromHex(`#00ff7f`)}static get STEELBLUE(){return e.fromHex(`#4682b4`)}static get TAN(){return e.fromHex(`#d2b48c`)}static get THISTLE(){return e.fromHex(`#d8bfd8`)}static get TOMATO(){return e.fromHex(`#ff6347`)}static get TURQUOISE(){return e.fromHex(`#40e0d0`)}static get VIOLET(){return e.fromHex(`#ee82ee`)}static get WHEAT(){return e.fromHex(`#f5deb3`)}static get WHITESMOKE(){return e.fromHex(`#f5f5f5`)}static get YELLOWGREEN(){return e.fromHex(`#9acd32`)}static get REBECCAPURPLE(){return e.fromHex(`#663399`)}};getScheme(t,n){return e.createScheme(this,t,n)}static getScheme(t,n,r){return e.createScheme(t,n,r)}static monochromatic(t,n){this.ic(t,e);let r=this.oc(n).results||3,i=e.toHsv(t),a=i.h,o=i.s,s=i.v/100,c=[],l=1/r;for(;r--;)c.push(e.fromHsv(a,o,this.clmp(s*100,100,0))),s=(s-l)%1;return c}monochromatic(t){return e.monochromatic(this,t)}static complementary(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l;return e.fromHsl(this.shift(r,180),i,a)}complementary(){return e.complementary(this)}static splitComplementary(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle||15,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180+i),o,s),e.fromHsl(this.shift(a,180-i),o,s)]}splitComplementary(t){return e.splitComplementary(this,t)}static doubleComplementary(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle||15,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180),o,s),e.fromHsl(this.shift(a,i),o,s),e.fromHsl(this.shift(a,180+i),o,s)]}doubleComplementary(t){return e.doubleComplementary(this,t)}static square(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l,o=[t];for(let t=1;t<4;t++)r=this.shift(r,90),o.push(e.fromHsl(r,i,a));return o}square(){return e.square(this)}static tetradic(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180),o,s),e.fromHsl(this.shift(a,180-i),o,s),e.fromHsl(this.shift(a,-i),o,s)]}tetradic(t){return e.tetradic(this,t)}static triadic(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l;return[t,e.fromHsl(this.shift(r,120),i,a),e.fromHsl(this.shift(r,240),i,a)]}triadic(){return e.triadic(this)}static analogous(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,-i),o,s),e.fromHsl(this.shift(a,+i),o,s)]}analogous(t){return e.analogous(this,t)}static createScheme(t,n,r){switch(n.toLowerCase()){case`analogous`:case`analog`:return e.analogous(t,r);case`triadic`:case`triad`:return e.triadic(t);case`tetradic`:case`tetra`:return e.tetradic(t,r);case`monochromatic`:case`monochrome`:case`mono`:return e.monochromatic(t,r);case`complementary`:case`complement`:case`comp`:return e.complementary(t);case`double-complementary`:case`double-complement`:case`double`:return e.doubleComplementary(t,r);case`split-complementary`:case`split-complement`:case`split`:return e.splitComplementary(t,r);case`square`:return e.square(t)}return null}constructor(t,n,r){if(!(0<=t&&t<=255&&0<=n&&n<=255&&0<=r&&r<=255))throw Error(`Color values out of bounds (0 - 255)`);this.#e=e.nc(e.tc(t,`number`)),this.#t=e.nc(e.tc(n,`number`)),this.#n=e.nc(e.tc(r,`number`)),this.alpha=1}static saturate(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=this.clmp(r.s+n,100,0),o=r.l;return e.fromHsl(i,a,o)}saturate(t){return e.saturate(this,t)}static desaturate(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=this.clmp(r.s-n,100,0),o=r.l;return e.fromHsl(i,a,o)}desaturate(t){return e.desaturate(this,t)}static grayscale(t){return e.desaturate(t,100)}grayscale(){return e.greyscale(this)}static greyscale(t){return e.desaturate(t,100)}greyscale(){return e.greyscale(this)}static lighten(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=r.s,o=this.clmp(r.l+n,100,0);return e.fromHsl(i,a,o)}lighten(t){return e.lighten(this,t)}static darken(t,n){return e.lighten(t,-n)}darken(t){return e.darken(this,t)}static brighten(t,n){let r=t.toRgb();return r.r=Math.max(0,Math.min(255,r.r-Math.round(255*-(n/100)))),r.g=Math.max(0,Math.min(255,r.g-Math.round(255*-(n/100)))),r.b=Math.max(0,Math.min(255,r.b-Math.round(255*-(n/100)))),new e(r.r,r.g,r.b)}brighten(t){return e.brighten(this,t)}static shiftHue(t,n){this.ic(t,e),this.tc(n,Number);let{h:r,s:i,l:a}=t.toHsl();return r=this.shift(r,n),e.fromHsl(r,i,a)}shiftHue(t){return e.shiftHue(this,t)}static multiply(t,n){this.ic(t,e),this.ic(n,e);let{r1:r,g1:i,b1:a}=t.toRgb(),{r2:o,g2:s,b2:c}=n.toRgb();return e.fromRgb(r*o/255,i*s/255,a*c/255)}multiply(t){return e.multiply(this,t)}static mix(t,n,r=50){this.ic(t,e),this.ic(t,e),this.tc(r,`number`);let i=t.toRgb(),a=n.toRgb(),o=this.clmp(r,100,0)/100,s=Math.round((a.r-i.r)*o+i.r),c=Math.round((a.g-i.g)*o+i.g),l=Math.round((a.b-i.b)*o+i.b);return e.fromRgb(s,c,l)}mix(t,n){return e.mix(this,t,n)}static lerp(t,n,r=.5){this.tc(r,`number`),this.ic(t,e),this.ic(n,e),r=this.clmp(r,1,0);let i=t.toRgb(),a=n.toRgb(),o=i.r/255,s=i.g/255,c=i.b/255,l=a.r/255,u=a.g/255,d=a.b/255;return e.fromRgb((o+(l-o)*r)*255,(s+(u-s)*r)*255,(c+(d-c)*r)*255)}lerp(t,n){return e.lerp(this,t,n)}static add(t,n){this.ic(t,e),this.ic(n,e);let r=t.toRgb(),i=n.toRgb(),a=r.r,o=r.g,s=r.b,c=i.r,l=i.g,u=i.b;return e.fromRgb(Math.round((a+c)/2),Math.round((o+l)/2),Math.round((s+u)/2))}add(t){return e.add(this,t)}static fromHex(t){if(!t.match(/^#?(?:[0-9a-fA-F]{3}){1,2}$/i))throw Error(`Invalid Hex code: "`+t+`"`);let n=`0x00`,r=`0x00`,i=`0x00`;return t.length==4?(n=`0x`+t[1]+t[1],r=`0x`+t[2]+t[2],i=`0x`+t[3]+t[3]):t.length==3?(n=`0x`+t[0]+t[0],r=`0x`+t[1]+t[1],i=`0x`+t[2]+t[2]):t.length==7?(n=`0x`+t[1]+t[2],r=`0x`+t[3]+t[4],i=`0x`+t[5]+t[6]):t.length==6&&(n=`0x`+t[0]+t[1],r=`0x`+t[2]+t[3],i=`0x`+t[4]+t[5]),new e(parseInt(n,16),parseInt(r,16),parseInt(i,16))}static fromRgb(t,n,r){return new e(t,n,r)}static fromHsl(t,n,r){if(t=this.tc(t,`number`),n=this.tc(n,`number`),r=this.tc(r,`number`),!(0<=t&&t<=360))throw Error(`HSL color values out of range, hue (0 - 360)`);if(!(0<=n&&n<=100))throw Error(`HSL color values out of range, sat (0 - 100)`);if(!(0<=r&&r<=100))throw Error(`HSL color values out of range, lum (0 - 100)`);n/=100,r/=100;let i=(1-Math.abs(2*r-1))*n,a=i*(1-Math.abs(t/60%2-1)),o=r-i/2,s=0,c=0,l=0;return 0<=t&&t<60?(s=i,c=a,l=0):60<=t&&t<120?(s=a,c=i,l=0):120<=t&&t<180?(s=0,c=i,l=a):180<=t&&t<240?(s=0,c=a,l=i):240<=t&&t<300?(s=a,c=0,l=i):300<=t&&t<=360&&(s=i,c=0,l=a),new e(Math.round((s+o)*255),Math.round((c+o)*255),Math.round((l+o)*255))}static fromHsv(t,n,r){if(t=this.tc(t,`number`),n=this.tc(n,`number`),r=this.tc(r,`number`),!(0<=t&&t<=360))throw Error(`HSL color values out of range, hue (0 - 360)`);if(!(0<=n&&n<=100))throw Error(`HSL color values out of range, sat (0 - 100)`);if(!(0<=r&&r<=100))throw Error(`HSL color values out of range, lum (0 - 100)`);n/=100,r/=100;let i=r*n,a=i*(1-Math.abs(t/60%2-1)),o=r-i,s=0,c=0,l=0;return 0<=t&&t<60?(s=i,c=a,l=0):60<=t&&t<120?(s=a,c=i,l=0):120<=t&&t<180?(s=0,c=i,l=a):180<=t&&t<240?(s=0,c=a,l=i):240<=t&&t<300?(s=a,c=0,l=i):300<=t&&t<=360&&(s=i,c=0,l=a),new e((s+o)*255,(c+o)*255,(l+o)*255)}static fromCssString(t){this.tc(t,`string`);var n=document.createElement(`canvas`).getContext(`2d`);let r;if(n&&(n.fillStyle=t,r=n.fillStyle),!r)throw Error(`Invalid Color string`);return e.fromHex(r)}static fromName(e){e=this.tc(e,`string`);let t=this.Colors[e.toUpperCase()];if(!t)throw Error(`Invalid Color name`);return t}static toHex(t){t=this.ic(t,e);let n=Math.round(t.#e).toString(16),r=Math.round(t.#t).toString(16),i=Math.round(t.#n).toString(16);return n.length==1&&(n=`0`+n),r.length==1&&(r=`0`+r),i.length==1&&(i=`0`+i),`#`+n+r+i}static toHsl(t){t=this.ic(t,e);let n=0,r=0,i=0,a=t.#e/255,o=t.#t/255,s=t.#n/255,c=Math.min(Math.min(a,o),s),l=Math.max(Math.max(a,o),s),u=l-c;return n=u===0?0:l===a?(o-s)/u%6:l===o?(s-a)/u+2:(a-o)/u+4,n=Math.round(n*60),n<0&&(n+=360),i=(l+c)/2,r=u===0?0:u/(1-Math.abs(2*i-1)),r=parseFloat(Math.abs(r*100)+``),i=parseFloat(Math.abs(i*100)+``),{h:this.nc(n),s:this.nc(r),l:this.nc(i)}}static toHsv(e){let t=0,n=0,r=0,i=e.#e/255,a=e.#t/255,o=e.#n/255,s=Math.min(Math.min(i,a),o),c=Math.max(Math.max(i,a),o),l=c-s;return t=l===0?0:c===i?(a-o)/l%6:c===a?(o-i)/l+2:(i-a)/l+4,t=Math.round(t*60),t<0&&(t+=360),c!==0&&(n=l/c*100),r=c*100,{h:this.nc(t),s:this.nc(n),v:this.nc(r)}}static toRgb(t){return this.ic(t,e),{r:t.#e,g:t.#t,b:t.#n}}static toCmyk(t){this.ic(t,e);let{r:n,g:r,b:i}=t.toRgb(),a=1-n/255,o=1-r/255,s=1-i/255,c=Math.min(a,Math.min(o,s));return a=(a-c)/(1-c),o=(o-c)/(1-c),s=(s-c)/(1-c),a=this.nc(Math.round(a*1e4)/100),o=this.nc(Math.round(o*1e4)/100),s=this.nc(Math.round(s*1e4)/100),c=this.nc(Math.round(c*1e4)/100),{c:a,m:o,y:s,k:c}}toHsl(){return e.toHsl(this)}toHsv(){return e.toHsv(this)}toHex(){return e.toHex(this)}toRgb(){return e.toRgb(this)}toCmyk(){return e.toCmyk(this)}static random(){return new e(Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255))}toString(t=`hex`){e.tc(t,`string`);let n=this.toRgb(),r=this.toHsl();switch(t.toLowerCase()){case`hex`:return this.toHex();case`hexa`:let e=Math.round(this.alpha*255).toString(16);return e.length===1&&(e=`0`+e),this.toHex()+e;case`rgb`:return`rgb(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)})`;case`rgba`:return`rgba(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)}, ${this.alpha})`;case`hsl`:return`hsl(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(r.l)}%)`;case`hsla`:return`hsla(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(r.l)}%, ${this.alpha})`;case`hsv`:let t=this.toHsv();return`hsv(${Math.round(t.h)}, ${Math.round(t.s)}%, ${Math.round(t.v)}%)`;case`cmyk`:let i=this.toCmyk();return`cmyk(${Math.round(i.c)}%, ${Math.round(i.m)}%, ${Math.round(i.y)}%, ${Math.round(i.k)}%)`;default:}return``}valueOf(){return parseInt(`0x`+this.toHex().slice(1))}},oa=class extends Error{sourceStart;sourceEnd;parserState;constructor(e,t,n,r){super(e),this.name=`ParseError`,this.sourceStart=t,this.sourceEnd=n,this.parserState=r}},sa=class extends oa{token;constructor(e,t,n,r,i){super(e,t,n,r),this.token=i}};const ca={UnexpectedNewLineInString:`Unexpected newline while consuming a string token.`,UnexpectedEOFInString:`Unexpected EOF while consuming a string token.`,UnexpectedEOFInComment:`Unexpected EOF while consuming a comment.`,UnexpectedEOFInURL:`Unexpected EOF while consuming a url token.`,UnexpectedEOFInEscapedCodePoint:`Unexpected EOF while consuming an escaped code point.`,UnexpectedCharacterInURL:`Unexpected character while consuming a url token.`,InvalidEscapeSequenceInURL:`Invalid escape sequence while consuming a url token.`,InvalidEscapeSequenceAfterBackslash:`Invalid escape sequence after "\\"`};typeof globalThis<`u`&&`structuredClone`in globalThis;function la(...e){let t=``;for(let n=0;n<e.length;n++)t+=e[n][1];return t}const ua=65533;function da(e){return e.source.codePointAt(e.cursor)===60&&e.source.codePointAt(e.cursor+1)===33&&e.source.codePointAt(e.cursor+2)===45&&e.source.codePointAt(e.cursor+3)===45}function fa(e){return e>=48&&e<=57}function pa(e){return e>=65&&e<=90}function ma(e){return e>=97&&e<=122}function ha(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function ga(e){return ma(e)||pa(e)}function _a(e){return ga(e)||ya(e)||e===95}function va(e){return _a(e)||fa(e)||e===45}function ya(e){return e===183||e===8204||e===8205||e===8255||e===8256||e===8204||192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=893||895<=e&&e<=8191||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||63744<=e&&e<=64975||65008<=e&&e<=65533||e===0||!!Ca(e)||e>=65536}function ba(e){return e===11||e===127||0<=e&&e<=8||14<=e&&e<=31}function xa(e){return e===10||e===13||e===12}function Sa(e){return e===32||e===10||e===9||e===13||e===12}function Ca(e){return e>=55296&&e<=57343}function wa(e){return e.source.codePointAt(e.cursor)===92&&!xa(e.source.codePointAt(e.cursor+1)??-1)}function Ta(e,t){return t.source.codePointAt(t.cursor)===45?t.source.codePointAt(t.cursor+1)===45||!!_a(t.source.codePointAt(t.cursor+1)??-1)||t.source.codePointAt(t.cursor+1)===92&&!xa(t.source.codePointAt(t.cursor+2)??-1):!!_a(t.source.codePointAt(t.cursor)??-1)||wa(t)}function Ea(e){return e.source.codePointAt(e.cursor)===43||e.source.codePointAt(e.cursor)===45?!!fa(e.source.codePointAt(e.cursor+1)??-1)||e.source.codePointAt(e.cursor+1)===46&&fa(e.source.codePointAt(e.cursor+2)??-1):e.source.codePointAt(e.cursor)===46?fa(e.source.codePointAt(e.cursor+1)??-1):fa(e.source.codePointAt(e.cursor)??-1)}function Da(e){return e.source.codePointAt(e.cursor)===47&&e.source.codePointAt(e.cursor+1)===42}function Oa(e){return e.source.codePointAt(e.cursor)===45&&e.source.codePointAt(e.cursor+1)===45&&e.source.codePointAt(e.cursor+2)===62}var z,B,ka;function Aa(e){switch(e){case z.OpenParen:return z.CloseParen;case z.CloseParen:return z.OpenParen;case z.OpenCurly:return z.CloseCurly;case z.CloseCurly:return z.OpenCurly;case z.OpenSquare:return z.CloseSquare;case z.CloseSquare:return z.OpenSquare;default:return null}}function ja(e){switch(e[0]){case z.OpenParen:return[z.CloseParen,`)`,-1,-1,void 0];case z.CloseParen:return[z.OpenParen,`(`,-1,-1,void 0];case z.OpenCurly:return[z.CloseCurly,`}`,-1,-1,void 0];case z.CloseCurly:return[z.OpenCurly,`{`,-1,-1,void 0];case z.OpenSquare:return[z.CloseSquare,`]`,-1,-1,void 0];case z.CloseSquare:return[z.OpenSquare,`[`,-1,-1,void 0];default:return null}}function Ma(e,t){for(t.advanceCodePoint(2);;){let n=t.readCodePoint();if(n===void 0){let n=[z.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new sa(ca.UnexpectedEOFInComment,t.representationStart,t.representationEnd,[`4.3.2. Consume comments`,`Unexpected EOF`],n)),n}if(n===42&&t.source.codePointAt(t.cursor)!==void 0&&t.source.codePointAt(t.cursor)===47){t.advanceCodePoint();break}}return[z.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0]}function Na(e,t){let n=t.readCodePoint();if(n===void 0)return e.onParseError(new oa(ca.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,[`4.3.7. Consume an escaped code point`,`Unexpected EOF`])),ua;if(ha(n)){let e=[n],r;for(;(r=t.source.codePointAt(t.cursor))!==void 0&&ha(r)&&e.length<6;)e.push(r),t.advanceCodePoint();Sa(t.source.codePointAt(t.cursor)??-1)&&(t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10&&t.advanceCodePoint(),t.advanceCodePoint());let i=parseInt(String.fromCodePoint(...e),16);return i===0||Ca(i)||i>1114111?ua:i}return n===0||Ca(n)?ua:n}function Pa(e,t){let n=[];for(;;){let r=t.source.codePointAt(t.cursor)??-1;if(r===0||Ca(r))n.push(ua),t.advanceCodePoint(+(r>65535)+1);else if(va(r))n.push(r),t.advanceCodePoint(+(r>65535)+1);else{if(!wa(t))return n;t.advanceCodePoint(),n.push(Na(e,t))}}}function Fa(e,t){t.advanceCodePoint();let n=t.source.codePointAt(t.cursor);if(n!==void 0&&(va(n)||wa(t))){let n=ka.Unrestricted;Ta(0,t)&&(n=ka.ID);let r=Pa(e,t);return[z.Hash,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...r),type:n}]}return[z.Delim,`#`,t.representationStart,t.representationEnd,{value:`#`}]}function Ia(e,t){let n=B.Integer;for(t.source.codePointAt(t.cursor)!==43&&t.source.codePointAt(t.cursor)!==45||t.advanceCodePoint();fa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===46&&fa(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint(2),n=B.Number;fa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===101||t.source.codePointAt(t.cursor)===69){if(fa(t.source.codePointAt(t.cursor+1)??-1))t.advanceCodePoint(2);else{if(t.source.codePointAt(t.cursor+1)!==45&&t.source.codePointAt(t.cursor+1)!==43||!fa(t.source.codePointAt(t.cursor+2)??-1))return n;t.advanceCodePoint(3)}for(n=B.Number;fa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint()}return n}function La(e,t){let n;{let e=t.source.codePointAt(t.cursor);e===45?n=`-`:e===43&&(n=`+`)}let r=Ia(0,t),i=parseFloat(t.source.slice(t.representationStart,t.representationEnd+1));if(Ta(0,t)){let a=Pa(e,t);return[z.Dimension,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n,type:r,unit:String.fromCodePoint(...a)}]}return t.source.codePointAt(t.cursor)===37?(t.advanceCodePoint(),[z.Percentage,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n}]):[z.Number,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n,type:r}]}function Ra(e){for(;Sa(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return[z.Whitespace,e.source.slice(e.representationStart,e.representationEnd+1),e.representationStart,e.representationEnd,void 0]}(function(e){e.Comment=`comment`,e.AtKeyword=`at-keyword-token`,e.BadString=`bad-string-token`,e.BadURL=`bad-url-token`,e.CDC=`CDC-token`,e.CDO=`CDO-token`,e.Colon=`colon-token`,e.Comma=`comma-token`,e.Delim=`delim-token`,e.Dimension=`dimension-token`,e.EOF=`EOF-token`,e.Function=`function-token`,e.Hash=`hash-token`,e.Ident=`ident-token`,e.Number=`number-token`,e.Percentage=`percentage-token`,e.Semicolon=`semicolon-token`,e.String=`string-token`,e.URL=`url-token`,e.Whitespace=`whitespace-token`,e.OpenParen=`(-token`,e.CloseParen=`)-token`,e.OpenSquare=`[-token`,e.CloseSquare=`]-token`,e.OpenCurly=`{-token`,e.CloseCurly=`}-token`,e.UnicodeRange=`unicode-range-token`})(z||={}),function(e){e.Integer=`integer`,e.Number=`number`}(B||={}),function(e){e.Unrestricted=`unrestricted`,e.ID=`id`}(ka||={});var za=class{cursor=0;source=``;representationStart=0;representationEnd=-1;constructor(e){this.source=e}advanceCodePoint(e=1){this.cursor+=e,this.representationEnd=this.cursor-1}readCodePoint(){let e=this.source.codePointAt(this.cursor);if(e!==void 0)return this.cursor+=1,this.representationEnd=this.cursor-1,e}unreadCodePoint(e=1){this.cursor-=e,this.representationEnd=this.cursor-1}resetRepresentation(){this.representationStart=this.cursor,this.representationEnd=-1}};function Ba(e,t){let n=``,r=t.readCodePoint();for(;;){let i=t.readCodePoint();if(i===void 0){let r=[z.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new sa(ca.UnexpectedEOFInString,t.representationStart,t.representationEnd,[`4.3.5. Consume a string token`,`Unexpected EOF`],r)),r}if(xa(i)){t.unreadCodePoint();let n=[z.BadString,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new sa(ca.UnexpectedNewLineInString,t.representationStart,t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10?t.representationEnd+2:t.representationEnd+1,[`4.3.5. Consume a string token`,`Unexpected newline`],n)),n}if(i===r)return[z.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(i!==92)i===0||Ca(i)?n+=String.fromCodePoint(ua):n+=String.fromCodePoint(i);else{if(t.source.codePointAt(t.cursor)===void 0)continue;if(xa(t.source.codePointAt(t.cursor)??-1)){t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10&&t.advanceCodePoint(),t.advanceCodePoint();continue}n+=String.fromCodePoint(Na(e,t))}}}function Va(e){return!(e.length!==3||e[0]!==117&&e[0]!==85||e[1]!==114&&e[1]!==82||e[2]!==108&&e[2]!==76)}function Ha(e,t){for(;;){let n=t.source.codePointAt(t.cursor);if(n===void 0)return;if(n===41)return void t.advanceCodePoint();wa(t)?(t.advanceCodePoint(),Na(e,t)):t.advanceCodePoint()}}function Ua(e,t){for(;Sa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();let n=``;for(;;){if(t.source.codePointAt(t.cursor)===void 0){let r=[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new sa(ca.UnexpectedEOFInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Unexpected EOF`],r)),r}if(t.source.codePointAt(t.cursor)===41)return t.advanceCodePoint(),[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(Sa(t.source.codePointAt(t.cursor)??-1)){for(t.advanceCodePoint();Sa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===void 0){let r=[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new sa(ca.UnexpectedEOFInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Consume as much whitespace as possible`,`Unexpected EOF`],r)),r}return t.source.codePointAt(t.cursor)===41?(t.advanceCodePoint(),[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}]):(Ha(e,t),[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0])}let r=t.source.codePointAt(t.cursor);if(r===34||r===39||r===40||ba(r??-1)){Ha(e,t);let n=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new sa(ca.UnexpectedCharacterInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Unexpected U+0022 QUOTATION MARK ("), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point`],n)),n}if(r===92){if(wa(t)){t.advanceCodePoint(),n+=String.fromCodePoint(Na(e,t));continue}Ha(e,t);let r=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new sa(ca.InvalidEscapeSequenceInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`U+005C REVERSE SOLIDUS (\\)`,`The input stream does not start with a valid escape sequence`],r)),r}t.source.codePointAt(t.cursor)===0||Ca(t.source.codePointAt(t.cursor)??-1)?(n+=String.fromCodePoint(ua),t.advanceCodePoint()):(n+=t.source[t.cursor],t.advanceCodePoint())}}function Wa(e,t){let n=Pa(e,t);if(t.source.codePointAt(t.cursor)!==40)return[z.Ident,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];if(Va(n)){t.advanceCodePoint();let r=0;for(;;){let e=Sa(t.source.codePointAt(t.cursor)??-1),i=Sa(t.source.codePointAt(t.cursor+1)??-1);if(e&&i){r+=1,t.advanceCodePoint(1);continue}let a=e?t.source.codePointAt(t.cursor+1):t.source.codePointAt(t.cursor);if(a===34||a===39)return r>0&&t.unreadCodePoint(r),[z.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];break}return Ua(e,t)}return t.advanceCodePoint(),[z.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}]}function Ga(e){return!(e.source.codePointAt(e.cursor)!==117&&e.source.codePointAt(e.cursor)!==85||e.source.codePointAt(e.cursor+1)!==43||e.source.codePointAt(e.cursor+2)!==63&&!ha(e.source.codePointAt(e.cursor+2)??-1))}function Ka(e,t){t.advanceCodePoint(2);let n=[],r=[],i;for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&ha(i);)n.push(i),t.advanceCodePoint();for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&i===63;)r.length===0&&r.push(...n),n.push(48),r.push(70),t.advanceCodePoint();if(!r.length&&t.source.codePointAt(t.cursor)===45&&ha(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint();(i=t.source.codePointAt(t.cursor))!==void 0&&r.length<6&&ha(i);)r.push(i),t.advanceCodePoint();if(!r.length){let e=parseInt(String.fromCodePoint(...n),16);return[z.UnicodeRange,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{startOfRange:e,endOfRange:e}]}let a=parseInt(String.fromCodePoint(...n),16),o=parseInt(String.fromCodePoint(...r),16);return[z.UnicodeRange,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{startOfRange:a,endOfRange:o}]}function qa(e,t){let n=Ja(e,t),r=[];for(;!n.endOfFile();)r.push(n.nextToken());return r.push(n.nextToken()),r}function Ja(e,t){let n=e.css.valueOf(),r=e.unicodeRangesAllowed??!1,i=new za(n),a={onParseError:t?.onParseError??Ya};return{nextToken:function(){i.resetRepresentation();let e=i.source.codePointAt(i.cursor);if(e===void 0)return[z.EOF,``,-1,-1,void 0];if(e===47&&Da(i))return Ma(a,i);if(r&&(e===117||e===85)&&Ga(i))return Ka(0,i);if(_a(e))return Wa(a,i);if(fa(e))return La(a,i);switch(e){case 44:return i.advanceCodePoint(),[z.Comma,`,`,i.representationStart,i.representationEnd,void 0];case 58:return i.advanceCodePoint(),[z.Colon,`:`,i.representationStart,i.representationEnd,void 0];case 59:return i.advanceCodePoint(),[z.Semicolon,`;`,i.representationStart,i.representationEnd,void 0];case 40:return i.advanceCodePoint(),[z.OpenParen,`(`,i.representationStart,i.representationEnd,void 0];case 41:return i.advanceCodePoint(),[z.CloseParen,`)`,i.representationStart,i.representationEnd,void 0];case 91:return i.advanceCodePoint(),[z.OpenSquare,`[`,i.representationStart,i.representationEnd,void 0];case 93:return i.advanceCodePoint(),[z.CloseSquare,`]`,i.representationStart,i.representationEnd,void 0];case 123:return i.advanceCodePoint(),[z.OpenCurly,`{`,i.representationStart,i.representationEnd,void 0];case 125:return i.advanceCodePoint(),[z.CloseCurly,`}`,i.representationStart,i.representationEnd,void 0];case 39:case 34:return Ba(a,i);case 35:return Fa(a,i);case 43:case 46:return Ea(i)?La(a,i):(i.advanceCodePoint(),[z.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]);case 10:case 13:case 12:case 9:case 32:return Ra(i);case 45:return Ea(i)?La(a,i):Oa(i)?(i.advanceCodePoint(3),[z.CDC,`-->`,i.representationStart,i.representationEnd,void 0]):Ta(0,i)?Wa(a,i):(i.advanceCodePoint(),[z.Delim,`-`,i.representationStart,i.representationEnd,{value:`-`}]);case 60:return da(i)?(i.advanceCodePoint(4),[z.CDO,`<!--`,i.representationStart,i.representationEnd,void 0]):(i.advanceCodePoint(),[z.Delim,`<`,i.representationStart,i.representationEnd,{value:`<`}]);case 64:if(i.advanceCodePoint(),Ta(0,i)){let e=Pa(a,i);return[z.AtKeyword,i.source.slice(i.representationStart,i.representationEnd+1),i.representationStart,i.representationEnd,{value:String.fromCodePoint(...e)}]}return[z.Delim,`@`,i.representationStart,i.representationEnd,{value:`@`}];case 92:{if(wa(i))return Wa(a,i);i.advanceCodePoint();let e=[z.Delim,`\\`,i.representationStart,i.representationEnd,{value:`\\`}];return a.onParseError(new sa(ca.InvalidEscapeSequenceAfterBackslash,i.representationStart,i.representationEnd,[`4.3.1. Consume a token`,`U+005C REVERSE SOLIDUS (\\)`,`The input stream does not start with a valid escape sequence`],e)),e}}return i.advanceCodePoint(),[z.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]},endOfFile:function(){return i.source.codePointAt(i.cursor)===void 0}}}function Ya(){}function Xa(e,t){let n=[];for(let e of t)n.push(e.codePointAt(0));let r=Za(n);r[0]===101&&$a(r,0,r[0]);let i=String.fromCodePoint(...r);e[1]=`${e[4].signCharacter===`+`?e[4].signCharacter:``}${e[4].value.toString()}${i}`,e[4].unit=t}function Za(e){let t=0;if(e[0]===0)e.splice(0,1,ua),t=1;else if(e[0]===45&&e[1]===45)t=2;else if(e[0]===45&&e[1])t=2,_a(e[1])||(t+=$a(e,1,e[1]));else{if(e[0]===45&&!e[1])return[92,e[0]];_a(e[0])?t=1:(t=1,t+=$a(e,0,e[0]))}for(let n=t;n<e.length;n++)e[n]===0?(e.splice(n,1,ua),n++):va(e[n])||(n+=Qa(e,n,e[n]));return e}function Qa(e,t,n){return e.splice(t,1,92,n),1}function $a(e,t,n){let r=n.toString(16),i=[];for(let e of r)i.push(e.codePointAt(0));return e.splice(t,1,92,...i,32),1+i.length}const eo=Object.values(z);function to(e){return!!Array.isArray(e)&&!(e.length<4)&&!!eo.includes(e[0])&&typeof e[1]==`string`&&typeof e[2]==`number`&&typeof e[3]==`number`}function V(e){if(!e)return!1;switch(e[0]){case z.Dimension:case z.Number:case z.Percentage:return!0;default:return!1}}function no(e){if(!e)return!1;switch(e[0]){case z.Whitespace:case z.Comment:return!0;default:return!1}}function ro(e){return!!e&&e[0]===z.Colon}function io(e){return!!e&&e[0]===z.Comma}function ao(e){return!!e&&e[0]===z.Comment}function oo(e){return!!e&&e[0]===z.Delim}function H(e){return!!e&&e[0]===z.Dimension}function so(e){return!!e&&e[0]===z.EOF}function co(e){return!!e&&e[0]===z.Function}function lo(e){return!!e&&e[0]===z.Hash}function U(e){return!!e&&e[0]===z.Ident}function W(e){return!!e&&e[0]===z.Number}function G(e){return!!e&&e[0]===z.Percentage}function uo(e){return!!e&&e[0]===z.Semicolon}function fo(e){return!!e&&e[0]===z.Whitespace}function po(e){return!!e&&e[0]===z.OpenParen}function mo(e){return!!e&&e[0]===z.CloseParen}function ho(e){return!!e&&e[0]===z.OpenSquare}function go(e){return!!e&&e[0]===z.OpenCurly}function _o(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}const vo=[.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124];
|
|
494
494
|
/**
|
|
495
495
|
* Bradford chromatic adaptation from D50 to D65
|
package/out/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
let e=require("commander"),t=require("path"),n=require("vscode-languageserver");var r=class{static realInteraction;static async load(e){let t=eval;this.realInteraction=(await t(`import("./RealInteraction.js")`)).default.RealInteraction,this.realInteraction._server=i,e&&(this.realInteraction.config=e)}static async init(){this.clear(),console.log(`Welcome inside Aventus CLI`)}static clear(){this.realInteraction.clear()}static async select(e,t){return this.realInteraction?.select(e,t)||null}static async selectMultiple(e,t){return this.realInteraction?.selectMultiple(e,t)||null}static async input(e,t,n){return this.realInteraction?.input(e,t,n)||null}static async password(e,t){return this.realInteraction?.password(e,t)||null}static async tree(e,t,n){return this.realInteraction?.tree(e,t,n)||null}static async log(){return this.realInteraction?.log()||null}},i=class{static realServer;static get notifications(){return this.realServer?.notifications}static async load(){let e=eval;this.realServer=(await e(`import("./RealServer.js")`)).default.RealServer,this.realServer._interaction=r}static subscribeErrors(e){return this.realServer?.subscribeErrors(e)}static unsubscribeErrors(e){return this.realServer?.unsubscribeErrors(e)}static executeCommand(e,...t){return this.realServer?.executeCommand(e,...t)}static getErrors(){return this.realServer?.getErrors()}static start(e){return this.realServer?.start(e)}static create(){return this.realServer?.create()}static getStatistics(){return this.realServer?.getStatistics()}static async Input(e){return this.realServer?.Input(e)}},a=class e{static actions={};argsNb=0;register(t){let n=this.name.trim().split(` `),r=``,i=t;for(let t of n)r+=t,e.actions[r]||(e.actions[r]=i.command(t)),i=e.actions[r],r+=` `;i=i.description(this.description),i=this._registerArgs(i),i=this._registerOptions(i),i.action(async(...e)=>{let t=[];for(let n=0;n<this.argsNb;n++)t.push(e[n]);let n=e[this.argsNb];await this.run(t,n),process.exit(0)})}_registerArgs(e){return this.registerArgs(t=>{let n=``;if(t.type){let e=`<`,r=`>`;t.typeIsRequired!==void 0&&!t.typeIsRequired&&(e=`[`,r=`]`),t.typeIsArray&&(r=`...`+r),n+=`${e}${t.type}${r}`}this.argsNb++,e=e.argument(n,t.description,t.defaultValue)}),e}_registerOptions(e){return this.registerOptions(t=>{let n=[];if(t.shortName){Array.isArray(t.shortName)||(t.shortName=[t.shortName]);for(let e of t.shortName)n.push(`-`+e)}n.push(`--`+t.name);let r=n.join(`, `);if(t.type){let e=`<`,n=`>`;t.typeIsRequired!==void 0&&!t.typeIsRequired&&(e=`[`,n=`]`),t.typeIsArray&&(n=`...`+n),r+=` ${e}${t.type}${n}`}e=t.required?e.requiredOption(r,t.description,t.defaultValue):e.option(r,t.description,t.defaultValue)}),e}},o=class{register(e){let t=this.name.trim().split(` `),n=``,r=e;for(let e of t)n+=e,a.actions[n]||(a.actions[n]=r.command(e)),r=a.actions[n],n+=` `;r=r.description(this.description)}};function s(e){return t.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function c(e){if(e.startsWith(`file://`))return e;let n=e[0].toLowerCase()+e.substring(1);return n=l(encodeURI(n.replace(/\\/g,`/`))),t.sep===`/`?`file://`+n:`file:///`+n}function l(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function u(e){let t=1024,n=[`Bytes`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],r=e==0?0:Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`}const d={Error:n.DiagnosticSeverity.Error,Warning:n.DiagnosticSeverity.Warning,Information:n.DiagnosticSeverity.Information,Hint:n.DiagnosticSeverity.Hint};var f=class extends a{get name(){return`build`}get description(){return`Build an aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`no-builds`,description:`No builds`,type:`boolean`,typeIsRequired:!1}),e({name:`statics`,description:`Define the static files to export`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`no-statics`,description:`No statics`,type:`boolean`,typeIsRequired:!1}),e({name:`verbose`,shortName:`v`,description:`Debug your compilation`}),e({name:`silent`,shortName:`s`,description:`No output`}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),await i.load(),n.builds===!1&&(n.builds=[]),n.statics===!1&&(n.statics=[]),await i.start({configPath:r,loadFiles:!0,buildOnly:n[`no-statics`],noBuild:n[`no-builds`],builds:n.builds,statics:n.statics,logLevel:n.verbose?0:3,errorByBuild:!0,useStats:!n.silent}),n.json?this.handleResultJson(n):this.handleResult(n)}handleResult(e){let t=i.getStatistics(),n=e.silent?e=>{}:console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=i.getErrors(),a=!1,o={},c={};for(let e in t.files){let n=t.files[e];if(n.type==`build`&&n.typeName){o[n.typeName]||(o[n.typeName]=[]);let e=` ${n.path} - ${u(n.size)}`;o[n.typeName].push(e)}else if(n.type==`static`&&n.typeName){c[n.typeName]||(c[n.typeName]=[]);let e=` ${n.path} - ${u(n.size)}`;c[n.typeName].push(e)}}let l=Object.keys(t.builds).length,f=Object.keys(t.statics).length,p=0;for(let i in t.builds){n(`Building `+i),n();let c=!1,u=r[i],m=t.builds[i],h=o[i];if(h){for(let e of h)n(e);n()}if(u){let t=!1;for(let n in u)for(let r of u[n]){let i=``,a;if(r.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,c=!0,a=console.error;else if(r.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}e.silent||(a(` ${i} ${s(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),t=!0)}t&&n()}c?(n(` Build failed in `+m.buildTime+`ms`),a=!0):n(` Build success in `+m.buildTime+`ms`),p++,p==l&&f==0?n():(n(),n(`----`),n())}p=0;for(let e in t.statics){n(`Export static `+e),n();let r=t.statics[e],i=c[e];if(i){for(let e of i)n(e);n()}n(` Exported in `+r.buildTime+`ms`),p++,p==f?n():(n(),n(`----`),n())}a&&process.exit(1)}handleResultJson(e){let t=i.getStatistics(),n={success:!0,builds:{},statics:{}},r=i.getErrors(),a=!1,o=e=>{n.builds[e]||(n.builds[e]={diagnostics:{},outputSize:{},success:!0})},c=e=>{n.statics[e]||(n.statics[e]={outputSize:{}})},l=e=>{let t=1024,n=[`Bytes`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],r=e==0?0:Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`};for(let e in t.files){let r=t.files[e];if(r.type==`build`&&r.typeName){let e=r.typeName,t=s(r.path).replace(/\\/g,`/`);o(e),n.builds[e].outputSize[t]=l(r.size)}else if(r.type==`static`&&r.typeName){let e=s(r.path).replace(/\\/g,`/`);c(r.typeName),n.statics[r.typeName].outputSize[e]=l(r.size)}}for(let e in t.builds){o(e);let t=r[e];if(t)for(let r in t){let i=s(r).replace(/\\/g,`/`),o=[];n.builds[e].diagnostics[i]=o;for(let i of t[r]){let t;i.severity==d.Error?(n.builds[e].success=!1,n.success=!1,a=!0,t=`error`):i.severity==d.Warning?t=`warning`:i.severity==d.Information?t=`info`:i.severity==d.Hint&&(t=`hint`),o.push({content:i.message,start:i.range.start.line+1+`:`+i.range.start.character,end:i.range.end.line+1+`:`+i.range.end.character,type:t})}}}console.log(JSON.stringify(n,void 0,4)),a&&process.exit(1)}},p=class extends a{get name(){return`dev`}get description(){return`Start an interactive cli to dev with your aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){}async run(e,t){await r.load({clear:!0,printLogo:!0}),await i.load(),console.clear(),await r.init(),await i.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!0});let n=[{value:`create`,name:`Create...`},{value:`log`,name:`Show logs`},{value:`quit`,name:`Quit`}];for(r.clear();;){let e=await r.select(`Which action shoud I perform?`,n);e==`create`?await i.create():e==`log`?await r.log():e==`quit`?process.exit(0):console.log(`WIP`),r.clear()}}},m=class extends a{get name(){return`check`}get description(){return`Check an aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),n.builds===!1&&(n.builds=[]),await i.load(),await i.start({noBuild:!0,loadFiles:!0,buildOnly:!0,configPath:r,builds:n.builds,statics:void 0,logLevel:3,errorByBuild:!0,useStats:!1}),n.json?this.handleResultJson(n):this.handleResult(n)}handleResult(e){let t=i.getStatistics(),n=console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=i.getErrors();for(let e in r){let t=!1,i=r[e];if(i){let e=!1;for(let n in i)for(let r of i[n]){let i=``,a;if(r.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,t=!0,a=console.error;else if(r.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${s(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),e=!0}e&&n()}t||n(` Build has no error`)}}handleResultJson(e){let t={success:!0,builds:{}},n=i.getErrors(),r=!1,a=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let e in n){a(e);let i=n[e];if(i)for(let n in i){let a=s(n).replace(/\\/g,`/`),o=[];t.builds[e].diagnostics[a]=o;for(let a of i[n]){let n;a.severity==d.Error?(t.builds[e].success=!1,t.success=!1,r=!0,n=`error`):a.severity==d.Warning?n=`warning`:a.severity==d.Information?n=`info`:a.severity==d.Hint&&(n=`hint`),o.push({content:a.message,start:a.range.start.line+1+`:`+a.range.start.character,end:a.range.end.line+1+`:`+a.range.end.character,type:n})}}}console.log(JSON.stringify(t,void 0,4)),r&&process.exit(1)}},h=class extends a{get name(){return`format`}get description(){return`Format your project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),await i.load(),await i.start({noBuild:!0,configPath:r}),await i.executeCommand(`aventus.format`)}},g=class extends a{get name(){return`store login`}get description(){return`Login to the store`}registerArgs(e){}registerOptions(e){e({name:`username`,shortName:`u`,description:`Username for connection`,type:`string`,typeIsRequired:!0}),e({name:`password`,shortName:`p`,description:`Password for connection`,type:`string`,typeIsRequired:!0})}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.connect`,t.username,t.password)}catch(e){console.log(e)}}},_=class extends a{get name(){return`store logout`}get description(){return`Logout from the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.disconnect`)}catch(e){console.log(e)}}},v=class extends a{get name(){return`store publish`}get description(){return`Publish to the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.publish_package`)}catch(e){console.log(e)}}},y=class extends a{get name(){return`create`}get description(){return`Create new project / files from a template`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0,loadFiles:!0}),await i.executeCommand(`aventus.create`,c(process.cwd()))}catch(e){console.log(e)}}},b=class extends a{get name(){return`template install`}get description(){return`Import template to create aventus element`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.import`)}catch(e){console.log(e)}}},x=class extends a{get name(){return`project install`}get description(){return`Import project to init aventus`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.import_project`)}catch(e){console.log(e)}}},S=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}};const C=[y,p,class extends a{get name(){return`watch`}get description(){return`Start the compiler in watch mode`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),n.builds===!1&&(n.builds=[]),await i.load(),console.clear(),await i.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!1,configPath:r,builds:n.builds,useStats:!1}),await this.sleep(2e3);let a=i.getErrors(),o=n.json?this.renderLogJson:this.renderLog;o(a),i.subscribeErrors((e,t)=>{a[t]=e,o(a)}),await new Promise(()=>{process.on(`SIGINT`,()=>{process.exit(0)})})}sleep(e){return new Promise(t=>setTimeout(t,e))}renderLog(e){console.clear();let t=console.log;for(let n in e){let r=!1;t(`Build : `+(n??`default`));let i=e[n];if(i){let e=!1;for(let t in i)for(let n of i[t]){let i=``,a;if(n.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,r=!0,a=console.error;else if(n.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(n.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(n.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${s(t).replace(/\\/g,`/`)}:${n.range.start.line+1} : ${n.message}`),e=!0}e&&t()}r||t(` No error detected`)}}renderLogJson(e){console.clear();let t={success:!0,builds:{}},n=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let r in e){let i=e[r];if(r=r==``?`default`:r,n(r),i)for(let e in i){let n=s(e).replace(/\\/g,`/`),a=[];t.builds[r].diagnostics[n]=a;for(let n of i[e]){let e;if(n.severity==d.Error)t.builds[r].success=!1,t.success=!1,e=`error`;else if(n.severity==d.Warning)e=`warning`;else if(n.severity==d.Information)e=`info`;else if(n.severity==d.Hint){e=`hint`;continue}a.push({content:n.message,start:n.range.start.line+1+`:`+n.range.start.character,end:n.range.end.line+1+`:`+n.range.end.character,type:e})}t.builds[r].diagnostics[n].length==0&&delete t.builds[r].diagnostics[n]}}console.log(JSON.stringify(t,void 0,4))}},class extends a{get name(){return`serve`}get description(){return`Start live server`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({loadFiles:!0,watchFiles:!0}),await i.executeCommand(`aventus.liveserver.start`),await this.waitStart(),await i.Input({title:`Press enter to stop server`})}catch(e){console.log(e)}}getAction(){return i.notifications.allNotifications[S.cmd]}waitStart(){return new Promise(e=>{let t=n=>{console.log(`Server started : `+n);let r=this.getAction().callbacks.indexOf(t);r!=-1&&this.getAction().callbacks.splice(r,1),e()};this.getAction().callbacks.push(t)})}},f,m,h,class extends o{get name(){return`dependencies`}get description(){return`Manage project's dependencies`}},class extends a{get name(){return`dependencies help-llm`}get description(){return`Write dependencies to help llm`}registerArgs(e){}registerOptions(e){}async run(e,n){try{let n=e[0];n&&=(0,t.resolve)(n),await i.load(),await i.start({noBuild:!0,loadFiles:!1,configPath:n}),await i.executeCommand(`aventus.ai.dependencies`)}catch(e){console.log(e)}}},class extends o{get name(){return`ai`}get description(){return`Manage ai helpers`}},class extends a{get name(){return`ai prepare`}get description(){return`Prepare file to help AI`}registerArgs(e){}registerOptions(e){}async run(e,n){try{let n=e[0];n&&=(0,t.resolve)(n),await i.load(),await i.start({noBuild:!0,loadFiles:!1,configPath:n}),await i.executeCommand(`aventus.ai.dependencies`),await i.executeCommand(`aventus.ai.rules`)}catch(e){console.log(e)}}},class extends o{get name(){return`project`}get description(){return`Manage project's templates`}},x,class extends a{get name(){return`project uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.uninstall_project`)}catch(e){console.log(e)}}},class extends o{get name(){return`template`}get description(){return`Manage templates`}},b,class extends a{get name(){return`template uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.uninstall`)}catch(e){console.log(e)}}},class extends o{get name(){return`store`}get description(){return`Manage store`}},g,_,v];function w(e){for(let t of C)new t().register(e)}e.program.version(`0.0.19`).name(`aventus`).description(`Aventus CLI`),w(e.program),e.program.parse(process.argv);
|
|
2
|
+
let e=require("commander"),t=require("path"),n=require("vscode-languageserver");var r=class{static realInteraction;static async load(e){let t=eval;this.realInteraction=(await t(`import("./RealInteraction.js")`)).default.RealInteraction,this.realInteraction._server=i,e&&(this.realInteraction.config=e)}static async init(){this.clear(),console.log(`Welcome inside Aventus CLI`)}static clear(){this.realInteraction.clear()}static async select(e,t){return this.realInteraction?.select(e,t)||null}static async selectMultiple(e,t){return this.realInteraction?.selectMultiple(e,t)||null}static async input(e,t,n){return this.realInteraction?.input(e,t,n)||null}static async password(e,t){return this.realInteraction?.password(e,t)||null}static async tree(e,t,n){return this.realInteraction?.tree(e,t,n)||null}static async log(){return this.realInteraction?.log()||null}},i=class{static realServer;static get notifications(){return this.realServer?.notifications}static async load(){let e=eval;this.realServer=(await e(`import("./RealServer.js")`)).default.RealServer,this.realServer._interaction=r}static subscribeErrors(e){return this.realServer?.subscribeErrors(e)}static unsubscribeErrors(e){return this.realServer?.unsubscribeErrors(e)}static executeCommand(e,...t){return this.realServer?.executeCommand(e,...t)}static getErrors(){return this.realServer?.getErrors()}static start(e){return this.realServer?.start(e)}static create(){return this.realServer?.create()}static getStatistics(){return this.realServer?.getStatistics()}static async Input(e){return this.realServer?.Input(e)}},a=class e{static actions={};argsNb=0;register(t){let n=this.name.trim().split(` `),r=``,i=t;for(let t of n)r+=t,e.actions[r]||(e.actions[r]=i.command(t)),i=e.actions[r],r+=` `;i=i.description(this.description),i=this._registerArgs(i),i=this._registerOptions(i),i.action(async(...e)=>{let t=[];for(let n=0;n<this.argsNb;n++)t.push(e[n]);let n=e[this.argsNb];await this.run(t,n),process.exit(0)})}_registerArgs(e){return this.registerArgs(t=>{let n=``;if(t.type){let e=`<`,r=`>`;t.typeIsRequired!==void 0&&!t.typeIsRequired&&(e=`[`,r=`]`),t.typeIsArray&&(r=`...`+r),n+=`${e}${t.type}${r}`}this.argsNb++,e=e.argument(n,t.description,t.defaultValue)}),e}_registerOptions(e){return this.registerOptions(t=>{let n=[];if(t.shortName){Array.isArray(t.shortName)||(t.shortName=[t.shortName]);for(let e of t.shortName)n.push(`-`+e)}n.push(`--`+t.name);let r=n.join(`, `);if(t.type){let e=`<`,n=`>`;t.typeIsRequired!==void 0&&!t.typeIsRequired&&(e=`[`,n=`]`),t.typeIsArray&&(n=`...`+n),r+=` ${e}${t.type}${n}`}e=t.required?e.requiredOption(r,t.description,t.defaultValue):e.option(r,t.description,t.defaultValue)}),e}},o=class{register(e){let t=this.name.trim().split(` `),n=``,r=e;for(let e of t)n+=e,a.actions[n]||(a.actions[n]=r.command(e)),r=a.actions[n],n+=` `;r=r.description(this.description)}};function s(e){return t.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function c(e){if(e.startsWith(`file://`))return e;let n=e[0].toLowerCase()+e.substring(1);return n=l(encodeURI(n.replace(/\\/g,`/`))),t.sep===`/`?`file://`+n:`file:///`+n}function l(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function u(e){let t=1024,n=[`Bytes`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],r=e==0?0:Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`}const d={Error:n.DiagnosticSeverity.Error,Warning:n.DiagnosticSeverity.Warning,Information:n.DiagnosticSeverity.Information,Hint:n.DiagnosticSeverity.Hint};var f=class extends a{get name(){return`build`}get description(){return`Build an aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`no-builds`,description:`No builds`,type:`boolean`,typeIsRequired:!1}),e({name:`statics`,description:`Define the static files to export`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`no-statics`,description:`No statics`,type:`boolean`,typeIsRequired:!1}),e({name:`verbose`,shortName:`v`,description:`Debug your compilation`}),e({name:`silent`,shortName:`s`,description:`No output`}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),await i.load(),n.builds===!1&&(n.builds=[]),n.statics===!1&&(n.statics=[]),await i.start({configPath:r,loadFiles:!0,buildOnly:n[`no-statics`],noBuild:n[`no-builds`],builds:n.builds,statics:n.statics,logLevel:n.verbose?0:3,errorByBuild:!0,useStats:!n.silent}),n.json?this.handleResultJson(n):this.handleResult(n)}handleResult(e){let t=i.getStatistics(),n=e.silent?e=>{}:console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=i.getErrors(),a=!1,o={},c={};for(let e in t.files){let n=t.files[e];if(n.type==`build`&&n.typeName){o[n.typeName]||(o[n.typeName]=[]);let e=` ${n.path} - ${u(n.size)}`;o[n.typeName].push(e)}else if(n.type==`static`&&n.typeName){c[n.typeName]||(c[n.typeName]=[]);let e=` ${n.path} - ${u(n.size)}`;c[n.typeName].push(e)}}let l=Object.keys(t.builds).length,f=Object.keys(t.statics).length,p=0;for(let i in t.builds){n(`Building `+i),n();let c=!1,u=r[i],m=t.builds[i],h=o[i];if(h){for(let e of h)n(e);n()}if(u){let t=!1;for(let n in u)for(let r of u[n]){let i=``,a;if(r.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,c=!0,a=console.error;else if(r.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}e.silent||(a(` ${i} ${s(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),t=!0)}t&&n()}c?(n(` Build failed in `+m.buildTime+`ms`),a=!0):n(` Build success in `+m.buildTime+`ms`),p++,p==l&&f==0?n():(n(),n(`----`),n())}p=0;for(let e in t.statics){n(`Export static `+e),n();let r=t.statics[e],i=c[e];if(i){for(let e of i)n(e);n()}n(` Exported in `+r.buildTime+`ms`),p++,p==f?n():(n(),n(`----`),n())}a&&process.exit(1)}handleResultJson(e){let t=i.getStatistics(),n={success:!0,builds:{},statics:{}},r=i.getErrors(),a=!1,o=e=>{n.builds[e]||(n.builds[e]={diagnostics:{},outputSize:{},success:!0})},c=e=>{n.statics[e]||(n.statics[e]={outputSize:{}})},l=e=>{let t=1024,n=[`Bytes`,`KiB`,`MiB`,`GiB`,`TiB`,`PiB`,`EiB`,`ZiB`,`YiB`],r=e==0?0:Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`};for(let e in t.files){let r=t.files[e];if(r.type==`build`&&r.typeName){let e=r.typeName,t=s(r.path).replace(/\\/g,`/`);o(e),n.builds[e].outputSize[t]=l(r.size)}else if(r.type==`static`&&r.typeName){let e=s(r.path).replace(/\\/g,`/`);c(r.typeName),n.statics[r.typeName].outputSize[e]=l(r.size)}}for(let e in t.builds){o(e);let t=r[e];if(t)for(let r in t){let i=s(r).replace(/\\/g,`/`),o=[];n.builds[e].diagnostics[i]=o;for(let i of t[r]){let t;i.severity==d.Error?(n.builds[e].success=!1,n.success=!1,a=!0,t=`error`):i.severity==d.Warning?t=`warning`:i.severity==d.Information?t=`info`:i.severity==d.Hint&&(t=`hint`),o.push({content:i.message,start:i.range.start.line+1+`:`+i.range.start.character,end:i.range.end.line+1+`:`+i.range.end.character,type:t})}}}console.log(JSON.stringify(n,void 0,4)),a&&process.exit(1)}},p=class extends a{get name(){return`dev`}get description(){return`Start an interactive cli to dev with your aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){}async run(e,t){await r.load({clear:!0,printLogo:!0}),await i.load(),console.clear(),await r.init(),await i.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!0});let n=[{value:`create`,name:`Create...`},{value:`log`,name:`Show logs`},{value:`quit`,name:`Quit`}];for(r.clear();;){let e=await r.select(`Which action shoud I perform?`,n);e==`create`?await i.create():e==`log`?await r.log():e==`quit`?process.exit(0):console.log(`WIP`),r.clear()}}},m=class extends a{get name(){return`check`}get description(){return`Check an aventus project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),n.builds===!1&&(n.builds=[]),await i.load(),await i.start({noBuild:!0,loadFiles:!0,buildOnly:!0,configPath:r,builds:n.builds,statics:void 0,logLevel:3,errorByBuild:!0,useStats:!1}),n.json?this.handleResultJson(n):this.handleResult(n)}handleResult(e){let t=i.getStatistics(),n=console.log;n(),n(`Loading all files : Done in `+t.loadFileTime+`ms`),n(),n(`----`),n();let r=i.getErrors();for(let e in r){let t=!1,i=r[e];if(i){let e=!1;for(let n in i)for(let r of i[n]){let i=``,a;if(r.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,t=!0,a=console.error;else if(r.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(r.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(r.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${s(n).replace(/\\/g,`/`)}:${r.range.start.line+1} : ${r.message}`),e=!0}e&&n()}t||n(` Build has no error`)}}handleResultJson(e){let t={success:!0,builds:{}},n=i.getErrors(),r=!1,a=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let e in n){a(e);let i=n[e];if(i)for(let n in i){let a=s(n).replace(/\\/g,`/`),o=[];t.builds[e].diagnostics[a]=o;for(let a of i[n]){let n;a.severity==d.Error?(t.builds[e].success=!1,t.success=!1,r=!0,n=`error`):a.severity==d.Warning?n=`warning`:a.severity==d.Information?n=`info`:a.severity==d.Hint&&(n=`hint`),o.push({content:a.message,start:a.range.start.line+1+`:`+a.range.start.character,end:a.range.end.line+1+`:`+a.range.end.character,type:n})}}}console.log(JSON.stringify(t,void 0,4)),r&&process.exit(1)}},h=class extends a{get name(){return`format`}get description(){return`Format your project`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),await i.load(),await i.start({noBuild:!0,configPath:r}),await i.executeCommand(`aventus.format`)}},g=class extends a{get name(){return`store login`}get description(){return`Login to the store`}registerArgs(e){}registerOptions(e){e({name:`username`,shortName:`u`,description:`Username for connection`,type:`string`,typeIsRequired:!0}),e({name:`password`,shortName:`p`,description:`Password for connection`,type:`string`,typeIsRequired:!0})}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.connect`,t.username,t.password)}catch(e){console.log(e)}}},_=class extends a{get name(){return`store logout`}get description(){return`Logout from the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.disconnect`)}catch(e){console.log(e)}}},v=class extends a{get name(){return`store publish`}get description(){return`Publish to the store`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noStart:!0}),await i.executeCommand(`aventus.store.publish_package`)}catch(e){console.log(e)}}},y=class extends a{get name(){return`create`}get description(){return`Create new project / files from a template`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0,loadFiles:!0}),await i.executeCommand(`aventus.create`,c(process.cwd()))}catch(e){console.log(e)}}},b=class extends a{get name(){return`template install`}get description(){return`Import template to create aventus element`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.import`)}catch(e){console.log(e)}}},x=class extends a{get name(){return`project install`}get description(){return`Import project to init aventus`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.import_project`)}catch(e){console.log(e)}}},S=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}};const C=[y,p,class extends a{get name(){return`watch`}get description(){return`Start the compiler in watch mode`}registerArgs(e){e({description:`aventus.conf.avt path`,type:`string`,typeIsRequired:!1})}registerOptions(e){e({name:`builds`,description:`Define the build name`,type:`string`,typeIsRequired:!0,typeIsArray:!0}),e({name:`json`,type:`boolean`,typeIsRequired:!1,description:`Result as json`})}async run(e,n){let r=e[0];r&&=(0,t.resolve)(r),n.builds===!1&&(n.builds=[]),await i.load(),console.clear(),await i.start({loadFiles:!0,watchFiles:!0,useCompilators:!0,useTemplates:!1,configPath:r,builds:n.builds,useStats:!1}),await this.sleep(2e3);let a=i.getErrors(),o=n.json?this.renderLogJson:this.renderLog;o(a),i.subscribeErrors((e,t)=>{a[t]=e,o(a)}),await new Promise(()=>{process.on(`SIGINT`,()=>{process.exit(0)})})}sleep(e){return new Promise(t=>setTimeout(t,e))}renderLog(e){console.clear();let t=console.log;for(let n in e){let r=!1;t(`Build : `+(n??`default`));let i=e[n];if(i){let e=!1;for(let t in i)for(let n of i[t]){let i=``,a;if(n.severity==d.Error)i=`\x1B[31m[error]\x1B[0m`,r=!0,a=console.error;else if(n.severity==d.Warning)i=`\x1B[33m[warning]\x1B[0m`,a=console.warn;else if(n.severity==d.Information)i=`\x1B[34m[info]\x1B[0m`,a=console.info;else if(n.severity==d.Hint){i=`\x1B[90m[hint]\x1B[0m`;continue}a(` ${i} ${s(t).replace(/\\/g,`/`)}:${n.range.start.line+1} : ${n.message}`),e=!0}e&&t()}r||t(` No error detected`)}}renderLogJson(e){console.clear();let t={success:!0,builds:{}},n=e=>{t.builds[e]||(t.builds[e]={diagnostics:{},success:!0})};for(let r in e){let i=e[r];if(r=r==``?`default`:r,n(r),i)for(let e in i){let n=s(e).replace(/\\/g,`/`),a=[];t.builds[r].diagnostics[n]=a;for(let n of i[e]){let e;if(n.severity==d.Error)t.builds[r].success=!1,t.success=!1,e=`error`;else if(n.severity==d.Warning)e=`warning`;else if(n.severity==d.Information)e=`info`;else if(n.severity==d.Hint){e=`hint`;continue}a.push({content:n.message,start:n.range.start.line+1+`:`+n.range.start.character,end:n.range.end.line+1+`:`+n.range.end.character,type:e})}t.builds[r].diagnostics[n].length==0&&delete t.builds[r].diagnostics[n]}}console.log(JSON.stringify(t,void 0,4))}},class extends a{get name(){return`serve`}get description(){return`Start live server`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({loadFiles:!0,watchFiles:!0}),await i.executeCommand(`aventus.liveserver.start`),await this.waitStart(),await i.Input({title:`Press enter to stop server`})}catch(e){console.log(e)}}getAction(){return i.notifications.allNotifications[S.cmd]}waitStart(){return new Promise(e=>{let t=n=>{console.log(`Server started : `+n);let r=this.getAction().callbacks.indexOf(t);r!=-1&&this.getAction().callbacks.splice(r,1),e()};this.getAction().callbacks.push(t)})}},f,m,h,class extends o{get name(){return`dependencies`}get description(){return`Manage project's dependencies`}},class extends a{get name(){return`dependencies help-llm`}get description(){return`Write dependencies to help llm`}registerArgs(e){}registerOptions(e){}async run(e,n){try{let n=e[0];n&&=(0,t.resolve)(n),await i.load(),await i.start({noBuild:!0,loadFiles:!1,configPath:n}),await i.executeCommand(`aventus.ai.dependencies`)}catch(e){console.log(e)}}},class extends o{get name(){return`ai`}get description(){return`Manage ai helpers`}},class extends a{get name(){return`ai prepare`}get description(){return`Prepare file to help AI`}registerArgs(e){}registerOptions(e){}async run(e,n){try{let n=e[0];n&&=(0,t.resolve)(n),await i.load(),await i.start({noBuild:!0,loadFiles:!1,configPath:n}),await i.executeCommand(`aventus.ai.dependencies`),await i.executeCommand(`aventus.ai.rules`)}catch(e){console.log(e)}}},class extends o{get name(){return`project`}get description(){return`Manage project's templates`}},x,class extends a{get name(){return`project uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.uninstall_project`)}catch(e){console.log(e)}}},class extends o{get name(){return`template`}get description(){return`Manage templates`}},b,class extends a{get name(){return`template uninstall`}get description(){return`Uninstall project`}registerArgs(e){}registerOptions(e){}async run(e,t){try{await r.load(),await i.load(),await i.start({noBuild:!0,useTemplates:!0}),await i.executeCommand(`aventus.template.uninstall`)}catch(e){console.log(e)}}},class extends o{get name(){return`store`}get description(){return`Manage store`}},g,_,v];function w(e){for(let t of C)new t().register(e)}e.program.version(`0.0.20`).name(`aventus`).description(`Aventus CLI`),w(e.program),e.program.parse(process.argv);
|
package/package.json
CHANGED