@aventusjs/cli 0.0.24 → 0.0.25

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 CHANGED
@@ -231,13 +231,29 @@ export default preview;`}var Zt=class e{static getFullname(e){let t=e.fullName.r
231
231
  <Title>Live</Title>
232
232
  <Canvas />
233
233
  <Controls />
234
- </div>`):this.replaceVariable(e,`live`,``),e=this.replaceVariable(e,`blocks`,`import { Canvas, Controls, Title } from '@storybook/addon-docs/blocks'`);let i=r.kind[0].toUpperCase()+r.kind.slice(1);e=this.replaceVariable(e,`render`,`import { Story${i}Render } from '@aventusjs/storybook-render/AventusStorybook'`),this.writeFile(a+`_.mdx`,e)},l=e=>{let t=`{`+x.EOL;for(let n in e){let r=e[n];typeof r==`string`&&(r=r.replace(/\\"/g,``)),r==``&&(r=`""`),t+=` "`+n+`":`+r+`,`+x.EOL}return t+=`}`,t};c(),(()=>{let o=!0;t.storieDecorator&&t.storieDecorator.noDefaultStory&&(o=!1);let c=s()?Yt():Jt(),u=t.name,d=e.getFullname(t);if(c=this.replaceVariable(c,`name`,u),c=this.replaceVariable(c,`fullname`,d),c=this.replaceVariable(c,`description`,t.documentation?.definitions.join(`
234
+ </div>`):this.replaceVariable(e,`live`,``),e=this.replaceVariable(e,`blocks`,`import { Canvas, Controls, Title } from '@storybook/addon-docs/blocks'`);let i=r.kind[0].toUpperCase()+r.kind.slice(1);e=this.replaceVariable(e,`render`,`import { Story${i}Render } from '@aventusjs/storybook-render/AventusStorybook'`),this.writeFile(a+`_.mdx`,e)},l=e=>{let t=`{
235
+ `;for(let n in e){let r=e[n];typeof r==`string`&&(r=r.replace(/\\"/g,``)),r==``&&(r=`""`),t+=` "`+n+`":`+r+`,
236
+ `}return t+=`}`,t};c(),(()=>{let o=!0;t.storieDecorator&&t.storieDecorator.noDefaultStory&&(o=!1);let c=s()?Yt():Jt(),u=t.name,d=e.getFullname(t);if(c=this.replaceVariable(c,`name`,u),c=this.replaceVariable(c,`fullname`,d),c=this.replaceVariable(c,`description`,t.documentation?.definitions.join(`
235
237
  `).replace(/`/g,"\\`")??``),c=this.replaceVariable(c,`aventus`,`aventus: `+JSON.stringify(r,null,2)+`,`),c=this.replaceVariable(c,`defaultStory`,o?`export const DefaultStory: Story = {}`:``),n instanceof F){c=this.replaceVariable(c,`argTypes`,`argTypes: `+JSON.stringify(n.storyBookInfo.argsTypes,null,2)+`,`),c=this.replaceVariable(c,`args`,`args: `+l(n.storyBookInfo.args)+`,`);let e=n.fileParsed?.classes[n.componentClassName].storieInject??{},t=We(D((0,f.join)(i,...r.namespace.split(`.`))),D(a));e[t]?e[t].includes(u)||e[t].push(u):e[t]=[u];let o=[];for(let t in e)o.push(`import { ${e[t].join(`, `)} } from '${t}';`);c=this.replaceVariable(c,`importPathes`,o.join(`
236
238
  `))}else c=this.replaceVariable(c,`argTypes`,``),c=this.replaceVariable(c,`args`,``);this.writeFile(a+`.stories.ts`,c)})()}readEnvStoryBook(){if(!this.buildConfig.stories)return;(0,u.existsSync)(this.buildConfig.stories.output)||(0,u.mkdirSync)(this.buildConfig.stories.output,{recursive:!0});let e=this.buildConfig.stories.output,t=`@`+this.buildConfig.module,n=this.buildConfig.module;this.buildConfig.name&&(t+=`/`+this.buildConfig.name,n+=` `+this.buildConfig.name);let r={name:(t+`_storybook`).toLowerCase(),displayName:n+`_storybook`,description:`Aventus storybook for `+t,version:this.buildConfig.version};if((0,u.readdirSync)(this.buildConfig.stories.output).length==0){let t=$.extensionPath+f.sep+`templates`+f.sep+`storybook`,n=(0,u.readdirSync)(t),i=``,a=t=>{let n=(0,u.readdirSync)(t);for(let o of n){let n=t+f.sep+o,s=n.replace(i,e);for(let e in r){let t=RegExp(`\\$\\{\\{`+e+`\\}\\}`,`gm`);s=s.replace(t,r[e])}if(s=(0,f.normalize)(s),(0,u.statSync)(n).isDirectory()){if(o==`.git`)continue;(0,u.mkdirSync)(s),a(n)}else if(/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(n.toLowerCase()))(0,u.copyFileSync)(n,s);else{let e=(0,u.readFileSync)(n,`utf-8`);for(let t in r){let n=RegExp(`\\$\\{\\{`+t+`\\}\\}`,`gm`);e=e.replace(n,r[t])}if(o==`package.json`){let t=JSON.parse(e);t.devDependencies||={};for(let e of this.build.externalPackageInformation.filesUri){let n=this.build.externalPackageInformation.getByUri(e);n&&n.npmUri&&n.name!=this.buildConfig.fullname&&(t.devDependencies[n.npmUri]=`^`+n.versionTxt)}t.devDependencies=Object.keys(t.devDependencies).sort().reduce((e,n)=>(e[n]=t.devDependencies[n],e),{}),e=JSON.stringify(t,null,4)}this.writeFile(s,e)}}};if(n.length==1)i=t+f.sep+n[0];else throw`TODO code multiple template`;a(i)}let i=(0,f.join)(this.buildConfig.stories.workspace?(0,f.resolve)(this.build.project.getConfigFile().folderPath,this.buildConfig.stories.workspace):e,`.storybook`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0});let a=(0,f.join)(i,`main.ts`);if(!(0,u.existsSync)(a)){let e=Kt(),t=We(D(this.buildConfig.stories.output),D(a));e=this.replaceVariable(e,`path`,t),this.writeFile(a,e)}let o=(0,f.join)(i,`preview.ts`);if(!(0,u.existsSync)(o)){let e=Xt();this.writeFile(o,e)}}replaceVariable(e,t,n){let r=RegExp(`\\$`+t+`\\$`,`g`);return e=e.replace(r,n),e}writeFile(e,t){qe(e,t,`storybook`)}},Qt=class e{static Parse(t,n,r){if(t.importClause){if(t.importClause.namedBindings){if(t.importClause.namedBindings.kind==p.SyntaxKind.NamespaceImport){let e=t.moduleSpecifier.getText().replace(/"/g,``).replace(/'/g,``);if(e=r.build.project.resolveAlias(e,n),e.startsWith(`.`))r.errors.push({range:m.Range.create(r.document.positionAt(t.getStart()),r.document.positionAt(t.getEnd())),severity:m.DiagnosticSeverity.Error,source:w.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`error can't use namespace import`,`
237
239
  `)});else{let n=t.importClause.namedBindings.name.getText();t.importClause.isTypeOnly||(r.build.npmBuilder.register(r.document.uri,{libName:`*`,uri:e,alias:n}),r.npmImports[n]={uri:e,nameInsideLib:`*`})}}else if(t.importClause.namedBindings.kind==p.SyntaxKind.NamedImports){let i=t.moduleSpecifier.getText().replace(/"/g,``).replace(/'/g,``);if(i=r.build.project.resolveAlias(i,n),i.startsWith(`.`))for(let n of t.importClause.namedBindings.elements){let a=n.isTypeOnly||t.importClause.isTypeOnly,o=new e({parserInfo:r,moduleName:i,identifier:n.propertyName?n.propertyName:n.name,alias:n.propertyName?n.name.getText():void 0,isTypeImport:a});r.importsLocal[o.alias??o.name]=o}else if(!i.startsWith(`.`)&&i.includes(T.Package))for(let e of t.importClause.namedBindings.elements)if(e.propertyName)r.errors.push({range:m.Range.create(r.document.positionAt(t.getStart()),r.document.positionAt(t.getEnd())),severity:m.DiagnosticSeverity.Error,source:w.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`error can't use renamed import`,`
238
240
  `)});else{let n=e.name.getText(),a=i.split(`:`);if(a.length>1){let e=a[1].replace(T.Package,``)+`.`+n;r.packages[n]={fullname:e}}else r.errors.push({range:m.Range.create(r.document.positionAt(t.getStart()),r.document.positionAt(t.getEnd())),severity:m.DiagnosticSeverity.Error,source:w.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`The package import is malformated`,`
239
241
  `)})}else for(let e of t.importClause.namedBindings.elements){let n=e.name.getText(),a=n;e.propertyName&&(a=e.propertyName.getText()),!t.importClause.isTypeOnly&&!e.isTypeOnly&&(r.build.npmBuilder.register(r.document.uri,{libName:a,uri:i,alias:n}),r.npmImports[n]={uri:i,nameInsideLib:a})}}}else if(t.importClause.name){let i=t.moduleSpecifier.getText().replace(/"/g,``).replace(/'/g,``);if(i=r.build.project.resolveAlias(i,n),i.startsWith(`.`)){let n=new e({parserInfo:r,moduleName:i,identifier:t.importClause.name,isTypeImport:t.importClause.isTypeOnly});r.importsLocal[n.alias??n.name]=n}else t.importClause.isTypeOnly||(r.build.npmBuilder.register(r.document.uri,{libName:`default`,uri:i,alias:this.name}),r.npmImports[this.name]={uri:i,nameInsideLib:`default`})}}}static manualLocalImport(t,n,r){let i=t.parserInfo,a=n.split(`.`).pop();if(!a)return;let o=new e({parserInfo:t.parserInfo,name:a,moduleUri:r});if(i.manualImportLocal[o.alias??o.name]){let e=0,t=a+e;for(;i.manualImportLocal[t];)e++,t=a+e;a=t,o.alias=a}return i.manualImportLocal[a]=o,o}nameStart=0;nameEnd=0;name=``;info;realName;isTypeImport;alias;_parserInfo;get parserInfo(){return this._parserInfo}isCst1(e){return!!e.identifier}constructor(e){this._parserInfo=e.parserInfo;let t;if(this.isCst1(e)?(this.name=e.identifier.getText(),this.nameStart=e.identifier.getStart(),this.nameEnd=e.identifier.getEnd(),this.isTypeImport=e.isTypeImport,this.alias=e.alias,t=D((0,f.normalize)(Le(O(this.parserInfo.document.uri))+`/`+e.moduleName))):(this.name=e.name,this.nameStart=0,this.nameEnd=0,this.isTypeImport=!1,t=e.moduleUri),!P.parsedDoc[t]){let e=R.getInstance().getByUri(t);if(e)P.parse(e,!1,this.parserInfo.build);else{let e=O(t),n=(0,u.existsSync)(e)?(0,u.readFileSync)(e,`utf8`):``,r=new j(d.TextDocument.create(t,w.TypeScript,1,n));P.parse(r,!1,this.parserInfo.build)}}if(P.parsedDoc[t]?.result.isReady){let e=P.parsedDoc[t].result.getBaseInfo(this.name);e?this.info=e:P.addError(this.nameStart,this.nameEnd,`Can't load `+t+` `+this.name+` from `+this.parserInfo.document.uri)}else{if(this.parserInfo.waitingImports[this.alias??this.name])return;this.parserInfo.waitingImports[this.alias??this.name]=[],P.parsedDoc[t].result.onReady(()=>{this.asyncImportLocal(t,this.alias??this.name)})}}asyncImportLocal(e,t){let n=P.parsedDoc[e].result.getBaseInfo(t);if(n){this.info=n;let e=[this.parserInfo.classes,this.parserInfo.enums,this.parserInfo.aliases,this.parserInfo.functions,this.parserInfo.variables];for(let r of e)for(let e in r){let i=r[e],a=Object.values(i.dependencies);for(let e of a)e.uri==`@external`&&e.fullName==t&&(e.uri=`@local`,e.fullName=`$namespace$`+n.fullName)}for(let e of this.parserInfo.waitingImports[t])e(n);delete this.parserInfo.waitingImports[t]}else P.addError(this.nameStart,this.nameEnd,`Can't load `+e+` `+t+` from `+this.parserInfo.document.uri)}},$t=class e{msg=`This code is deprecated`;static is(t){if(t.name==`Deprecated`){let n=new e;if(t.arguments.length>0)try{n.msg=t.arguments[0].value}catch{}return n}return null}},N=class e{static infoByShortName={};static infoByFullName={};static getInfoByShortName(e){return this.infoByShortName[e]}static getInfoByFullName(e,t){e=e.replace(/<.*>/,``);let n=this.infoByFullName[e];return n||=this.infoByFullName[t.fullName.split(`.`)[0]+`.`+e],n}static isExported(e){if(e.modifiers){for(let t of e.modifiers)if(t.kind==p.SyntaxKind.ExportKeyword)return!0}return!1}static isStoryExported(e,t){if(!t.buildConfig.stories)return!1;let n=Bt.buildDecorator(e).find(e=>e.name==`Storybook`);if(n){let e=Wt.is(n);if(e)return e.exportType?e.exportType==`all`||e.exportType==`public`||e.exportType==`protected`:!0}return t.buildConfig.stories.format==`all`||t.buildConfig.stories.format==`public`||t.buildConfig.stories.format==`protected`}name=``;nameStart=0;nameEnd=0;start=0;end=0;fullName=``;namespace=``;decorators=[];useNormalDecorator=!1;storieContent;storieInject={};storieDecorator;storyType=`none`;dependencies={};compiled=``;documentation;isExported=!1;isInternalExported=!1;_parserInfo;content=``;deprecated=!1;deprecatedMsg=``;compileTransformations={};get compiledContent(){return e.getContent(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get compiledContentHotReload(){return e.getContentHotReload(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get compiledContentNpm(){return e.getContentNpm(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get compiledContentDoc(){return e.getContentDoc(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get fileUri(){return this.document.uri}document;dependenciesPrevented=[];dependenciesLocations={};infoType=0;build;willBeCompiled;get parserInfo(){return this._parserInfo}constructor(t,n,r,i=!0){if(this._parserInfo=r,this.document=r.document,this.decorators=Bt.buildDecorator(t,this),this.dependenciesLocations={},this.build=r.build,this.willBeCompiled=t.kind!=p.SyntaxKind.InterfaceDeclaration&&t.kind!=p.SyntaxKind.TypeAliasDeclaration,t.name){this.start=t.getStart(),this.end=t.getEnd(),this.name=t.name.getText(),this.nameStart=t.name.getStart(),this.nameEnd=t.name.getEnd(),this.namespace=n.join(`.`),this.fullName=[...n,this.name].join(`.`),this.content=t.getText(),r.isExternal||(e.infoByShortName[this.name]=this);let a=new Gt(t);if(a.hasDoc&&(this.documentation=a),i&&this.loadDecorators(),t.kind!=p.SyntaxKind.VariableDeclaration){this.isExported=e.isExported(t),this.isInternalExported=this.isExported;for(let e of this.decorators)if(Ht.is(e)){this.isExported=!1;break}}e.infoByFullName[this.fullName]=this}}loadDecorators(){for(let e of this.decorators){let t=Vt.is(e);if(t)for(let e of t.dependencies)this.addDependencyName(e.type,e.strong,0,0);let n=$t.is(e);n&&(this.deprecated=!0,this.deprecatedMsg=n.msg)}}preventDependencyAdd(e){this.dependenciesPrevented.includes(e)||this.dependenciesPrevented.push(e)}loadExpression(e,t=0,n=!1){if($.debug(`***`+t+`. `+e.getText()),$.debug(p.SyntaxKind[e.kind]),e.kind==p.SyntaxKind.ExpressionWithTypeArguments)this.addDependency(e,n);else if(e.kind==p.SyntaxKind.NewExpression){let r=e;this.loadExpression(r.expression,t+1,n)}else if(e.kind==p.SyntaxKind.PropertyAccessExpression){let r=e,i=r.name.getText(),a=P.getBaseInfo(i);if(a&&r.expression.getText()+`.`+i==a.fullName)this.addDependencyName(a.fullName,n,r.getStart(),r.getEnd());else{let e=r.expression.getText();e!=`this`&&!e.includes(`.`)&&(P.hasLocal(e)||P.hasImport(e))&&this.addDependencyName(e,n,r.expression.getStart(),r.expression.getEnd())}this.loadExpression(r.expression,t+1,n)}else if(e.kind==p.SyntaxKind.Identifier){if(e.parent.kind==p.SyntaxKind.PropertyAccessExpression||e.parent.kind==p.SyntaxKind.GetAccessor||e.parent.kind==p.SyntaxKind.SetAccessor||!this.checkParentIdentifier(e))return;let t=e.getText();t!=`this`&&!t.includes(`.`)&&(P.getBaseInfo(t)||P.hasLocal(t)||P.hasImport(t))&&this.addDependencyName(t,n,e.getStart(),e.getEnd())}else if(e.kind==p.SyntaxKind.CallExpression){let r=e;this.loadExpression(r.expression,t+1,n)}}checkParentIdentifier(e){let t=[p.SyntaxKind.VariableDeclaration,p.SyntaxKind.FunctionDeclaration,p.SyntaxKind.ClassDeclaration,p.SyntaxKind.InterfaceDeclaration,p.SyntaxKind.TypeAliasDeclaration,p.SyntaxKind.EnumDeclaration,p.SyntaxKind.ModuleDeclaration,p.SyntaxKind.NamespaceExportDeclaration,p.SyntaxKind.ImportEqualsDeclaration,p.SyntaxKind.ExportAssignment,p.SyntaxKind.ExportDeclaration,p.SyntaxKind.NamespaceExport,p.SyntaxKind.ExportSpecifier,p.SyntaxKind.MissingDeclaration,p.SyntaxKind.MethodDeclaration,p.SyntaxKind.ClassStaticBlockDeclaration],n=[p.SyntaxKind.ImportDeclaration,p.SyntaxKind.ImportClause,p.SyntaxKind.NamespaceImport,p.SyntaxKind.NamedImports,p.SyntaxKind.ImportSpecifier];return t.includes(e.parent.kind)?e.parent.name!=e:n.includes(e.parent.kind)?!1:!(e.parent.kind>=p.SyntaxKind.JsxElement&&e.parent.kind<=p.SyntaxKind.JsxExpression)}loadDependencyContext=void 0;maybeDependencies={};loadOnlyDependenciesRecu(e,t=0,n=!1){this.parserInfo.isExternal||(e.kind==p.SyntaxKind.Decorator&&(this.loadDependencyContext=`Decorator`),(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.TypeReference){this.addDependency(e,n);return}else this.loadExpression(e,t,n);this.loadOnlyDependenciesRecu(e,t+1,n)}),e.kind==p.SyntaxKind.Decorator&&(this.loadDependencyContext=void 0))}addDependency(e,t){if(this.parserInfo.isExternal)return;let n=e=>{if(e.kind==`type`){this.addDependencyName(e.value,t,e.start,e.endNonGeneric);for(let t of e.nested)n(t);for(let t of e.genericValue)n(t)}else if(e.kind==`typeLiteral`||e.kind==`function`)for(let t of e.nested)n(t);else if(e.kind==`union`)for(let t of e.nested)n(t)};n(new M(e))}addDependencyWaitName(e,t,n){if(this.parserInfo.isExternal){n([e.getText()],[e.getText()]);return}let r=[],i=[],a=0,o=!1,s=()=>{!o&&a==0&&(o=!0,n(r,i))},c=(e,n)=>{if(e.kind==`type`){a++,this.addDependencyName(e.value,t,e.start,e.endNonGeneric,(e,t)=>{n==0&&(e&&r.push(e),t&&i.push(t)),a--,s()});for(let t of e.nested)c(t,n+1);for(let r of e.genericValue)t=!1,c(r,n+1)}else if(e.kind==`typeLiteral`||e.kind==`function`)for(let t of e.nested)c(t,n+1);else if(e.kind==`union`)for(let t of e.nested)c(t,n+1)};c(new M(e),0),s()}loadStoryBookInject(){let e=this.build.buildConfig.stories;if(!e)return;let t=this.storieContent;if(!t)return;let n=(e,t)=>{this.storieInject[e]?this.storieInject[e].includes(t)||this.storieInject[e].push(t):this.storieInject[e]=[t]},r=r=>{let i=(0,f.join)(e.output,`generated`),a=(0,f.join)(e.output,`auto`,...this.fullName.split(`.`)),o=We(D((0,f.join)(i,...t.namespace.split(`.`))),D(a)),s=this.fullName.split(`.`);s.pop();let c=r.split(`.`),l=c.pop()??``;for(let e=0;e<s.length;e++)if(c.length>e)if(c[e]==s[e])c.splice(e,1),s.splice(e,1),e--;else break;let u=``;for(let e=0;e<s.length;e++)u+=`../`;u==``&&(u+=`./`),u+=c.join(`/`),u=(0,f.normalize)((0,f.join)(o,u)).replace(/\\/g,`/`),n(u,l)};if(this.storieDecorator?.slots?.inject)for(let e of this.storieDecorator.slots.inject)if(e.includes(`.`)){let t=this.build.externalPackageInformation.getNpmUri(e);t&&n(t.uri,t.name)}else this.parserInfo.internalObjects[e]?r(this.parserInfo.internalObjects[e].fullname):this.parserInfo.importsLocal[e]?.info?r(this.parserInfo.importsLocal[e].info.fullName):this.parserInfo.packages[e]||this.parserInfo.npmImports[e]&&n(this.parserInfo.npmImports[e].uri,e)}getNpmReplacementName(e){let t=[this.build.module,this.fullName].join(`.`);return this.parserInfo.getNpmReplacementName(t,e)}addDependencyTag(e,t){let n=this.build.getWebComponentTagDependency(e);if(n){for(let e of t.dependencies)if(e.fullName==n.fullName)return;let e=n.uri;if(e==`@external`){let e=n.fullName,t=this.build.externalPackageInformation.getNpmUri(e),r=this.getNpmReplacementName(e);t&&this._parserInfo.registerGeneratedImport({uri:t.uri,name:t.name,compiled:t.compiled,alias:r,forced:!0})}else if(e==`@npm`){let e=n.fullName,t=Je(this.parserInfo.npmImports[e].uri),r=this.getNpmReplacementName(t+`.`+e);this._parserInfo.registerGeneratedImport({uri:this.parserInfo.npmImports[e].uri,name:e,compiled:!0,alias:r,forced:!0})}else{let e=Qt.manualLocalImport(this,n.fullName,n.uri),t=n.fullName,r=this.fullName.split(`.`);r.pop();let i=t.split(`.`),a=i.pop()??``;for(let e=0;e<r.length;e++)if(i.length>e)if(i[e]==r[e])i.splice(e,1),r.splice(e,1),e--;else break;let o=r.length==0&&i.length==0,s=``;for(let e=0;e<r.length;e++)s+=`../`;s==``&&(s+=`./`),s+=i.join(`/`);let c=this.getNpmReplacementName([this.build.module,t].join(`.`));this._parserInfo.registerGeneratedImport({uri:s,nameAlias:e?.alias,name:a,compiled:!0,alias:c,onlySrc:o,forced:!0})}t.dependencies.push(n)}}addDependencyName(e,t,n,r,i){if(this.parserInfo.isExternal)return;let a;if(a=i||(()=>{}),!e||e==`constructor`||e==`toString`){a();return}$.debug(`try add dendency `+e);let o=/<.*>/g.exec(e);if(o&&(r-=o[0].length,e=e.replace(o[0],``)),e==this.fullName){a();return}if(Ft.exists(e)&&!this.parserInfo.internalObjects[e]&&!this.parserInfo.importsLocal[e]&&!this.parserInfo.waitingImports[e]&&!this.parserInfo.npmImports[e]&&!this.parserInfo.packages[e]){a();return}if(n>0&&r>0){this.dependenciesLocations[e]||(this.dependenciesLocations[e]={locations:{},typeRemplacement:null,replacement:null,docReplacement:null,hotReloadReplacement:null,npmReplacement:null});let t=n+`_`+r;if(!this.dependenciesLocations[e].locations){$.showErrorMessage(`For the admin : you can add `+e+` as dependency to avoid`),a();return}if(!this.dependenciesLocations[e].locations[t]){let i=(0,p.getTokenAtPosition)(this.parserInfo.srcFile,(n+r)/2),a=(0,p.isTypeReferenceNode)(i)||(0,p.isTypeReferenceNode)(i.parent);this.dependenciesLocations[e].locations[t]={start:n,end:r,isType:a}}}if(!this.addDependencyNameCustomCheck(e)){a();return}if(this.dependenciesPrevented.includes(e)){a();return}if(this.dependencies[e]){if(a(),this.loadDependencyContext===void 0&&this.maybeDependencies[e]){let t=this.getNpmReplacementName(this.maybeDependencies[e].name);this._parserInfo.registerGeneratedImport({uri:this.maybeDependencies[e].uri,name:this.maybeDependencies[e].name,compiled:this.maybeDependencies[e].compiled,alias:t,forced:!1})}return}if(e.includes(`.`)){this.dependencies[e]={fullName:e,uri:`@external`,isStrong:t};let n=this.build.externalPackageInformation.getNpmUri(e),r=this.getNpmReplacementName(e);n&&(this.dependenciesLocations[e].npmReplacement=r,this.loadDependencyContext===void 0?this._parserInfo.registerGeneratedImport({uri:n.uri,name:n.name,compiled:n.compiled,alias:r,forced:!1}):this.maybeDependencies[e]=n),a(e,r);return}let s=(t,n,r)=>{let i=this.fullName.split(`.`);i.pop();let a=t.split(`.`),o=a.pop()??``;for(let e=0;e<i.length;e++)if(a.length>e)if(a[e]==i[e])a.splice(e,1),i.splice(e,1),e--;else break;let s=i.length==0&&a.length==0,c=``;for(let e=0;e<i.length;e++)c+=`../`;c==``&&(c+=`./`),c+=a.join(`/`),this.loadDependencyContext===void 0?this._parserInfo.registerGeneratedImport({uri:c,name:o,compiled:n,alias:r,onlySrc:s,forced:!1}):this.maybeDependencies[e]={uri:c,name:o,compiled:n}};if(this.parserInfo.internalObjects[e]){let n=this.parserInfo.internalObjects[e].fullname,r=[this.build.module,...this.build.namespaces,n].join(`.`);if(n==this.fullName&&(t=!1),this.dependencies[e]={fullName:`$namespace$`+n,uri:`@local`,isStrong:t},$.debug(`add dependence `+e+` : same file`),this.dependenciesLocations[e]){let t=this.build.module+`.`+n;this.isExported!=this.parserInfo.internalObjects[e].isExported&&(t=this.isExported?[`___`+this.build.module,n].join(`.`):[`globalThis`,this.build.module,n].join(`.`)),this.dependenciesLocations[e].typeRemplacement=t,this.dependenciesLocations[e].replacement=n,this.dependenciesLocations[e].docReplacement=this.build.module+`.`+n,this.dependenciesLocations[e].npmReplacement=e,this.dependenciesLocations[e].hotReloadReplacement=r,s(n,this.parserInfo.internalObjects[e].isCompiled,e)}a(n,e);return}let c=this.parserInfo.importsLocal[e]?.info;if(c){let n=c.fullName,r=[this.build.module,...this.build.namespaces,n].join(`.`);this.dependencies[e]={fullName:`$namespace$`+n,uri:c.fileUri,isStrong:t},$.debug(`add dependency `+e+` : imported file`);let i=this.getNpmReplacementName([this.build.module,n].join(`.`));if(this.dependenciesLocations[e]){let t=this.build.module+`.`+n;this.isExported!=c.isExported&&(t=this.isExported?[`___`+this.build.module,n].join(`.`):[`globalThis`,this.build.module,n].join(`.`));let a=n,o=this.fullName.split(`.`);o.slice(0,1);let l=n.split(`.`)[0];o.includes(l)&&(a=`_.`+a),this.dependenciesLocations[e].typeRemplacement=t,this.dependenciesLocations[e].replacement=a,this.dependenciesLocations[e].docReplacement=this.build.module+`.`+n,this.dependenciesLocations[e].npmReplacement=i,this.dependenciesLocations[e].hotReloadReplacement=r,s(n,c.willBeCompiled,i)}a(n,i);return}else if(this.parserInfo.waitingImports[e]){$.debug(`add dependency `+e+` : but waiting import file`),this.parserInfo.waitingImports[e].push(n=>{let r=n.fullName,i=[this.build.module,...this.build.namespaces,r].join(`.`),o=this.getNpmReplacementName([this.build.module,r].join(`.`));if(this.dependenciesLocations[e]){let t=this.build.module+`.`+r;this.isExported!=n.isExported&&(t=this.isExported?[`___`+this.build.module,r].join(`.`):[`globalThis`,this.build.module,r].join(`.`)),this.dependenciesLocations[e].typeRemplacement=t,this.dependenciesLocations[e].replacement=r,this.dependenciesLocations[e].docReplacement=this.build.module+`.`+r,this.dependenciesLocations[e].npmReplacement=o,this.dependenciesLocations[e].hotReloadReplacement=i,s(r,n.willBeCompiled,o)}this.dependencies[e]={fullName:`$namespace$`+r,uri:n.fileUri,isStrong:t},a(r,o)});return}else if(this.parserInfo.packages[e]){let n=this.parserInfo.packages[e].fullname,r=this.build.externalPackageInformation.getNpmUri(n);this.dependencies[e]={fullName:n,uri:`@external`,isStrong:t};let i=this.getNpmReplacementName(n);this.dependenciesLocations[e]&&(this.dependenciesLocations[e].typeRemplacement=n,this.dependenciesLocations[e].replacement=n,this.dependenciesLocations[e].docReplacement=n,this.dependenciesLocations[e].npmReplacement=i,this.dependenciesLocations[e].hotReloadReplacement=n),r&&this._parserInfo.registerGeneratedImport({uri:r.uri,name:r.name,compiled:r.compiled,alias:i,forced:!1}),a(n,i);return}if(this.parserInfo.npmImports[e]){this.dependencies[e]={fullName:e,uri:`@npm`,isStrong:t},$.debug(`add dependency `+e+` : npm`);let i=Je(this.parserInfo.npmImports[e].uri),o=this.getNpmReplacementName(i+`.`+e);this.dependenciesLocations[e]&&(this.dependenciesLocations[e].replacement=`npmCompilation['`+i+`'].`+e,this.dependenciesLocations[e].docReplacement=`npmCompilation['`+i+`'].`+e,o!=e&&(this.dependenciesLocations[e].npmReplacement=o),this.loadDependencyContext===void 0?this._parserInfo.registerGeneratedImport({uri:this.parserInfo.npmImports[e].uri,name:e,compiled:!0,alias:o,forced:!1}):this.maybeDependencies[e]={uri:this.parserInfo.npmImports[e].uri,name:e,compiled:!0}),n>0&&r>0&&(this.dependenciesLocations[e].locations[n+`_`+r].isNpm=!0),a(e,o);return}this.dependencies[e]={fullName:e,uri:`@external`,isStrong:t},$.debug(`add dependency `+e+` : external`),a(e,e)}addDependencyNameCustomCheck(e){return!0}static getContent(e,t,n,r,i){return this._getContent(e,t,n,r,i,1)}static getContentHotReload(e,t,n,r,i){return this._getContent(e,t,n,r,i,2)}static getContentNpm(e,t,n,r,i){return this._getContent(e,t,n,r,i,3)}static getContentDoc(e,t,n,r,i){return this._getContent(e,t,n,r,i,4)}static _getContent(e,t,n,r,i,a){let o=[];for(let e in r){let i=null;a==1?i=r[e].replacement:a==2?i=r[e].hotReloadReplacement:a==3?i=r[e].npmReplacement:a==4&&(i=r[e].docReplacement);let s=r[e].typeRemplacement;if(i)for(let c in r[e].locations){let l=r[e].locations[c];if(l.start>=t&&l.end<=n)if(l.isType&&s&&a!=3)o.push({newText:s,start:l.start-t,end:l.end-t});else if(l.isNpm&&l.isType)continue;else o.push({newText:i,start:l.start-t,end:l.end-t})}}for(let e in i){let r=i[e];r.start>=t&&r.end<=n&&o.push({newText:r.newText,start:r.start-t,end:r.end-t})}o.sort((e,t)=>t.end-e.end);let s=e.length;for(let t of o)t.end>s||(e=e.slice(0,t.start)+t.newText+e.slice(t.end,e.length),s=t.start);return e.replace(/^\s*export\s+(class|interface|enum|type|abstract|function|async)/m,`$1`)}loadStorieContent(){if(this.build.buildConfig.stories&&!this._parserInfo.isExternal){for(let e of this.decorators){let t=Wt.is(e);if(t){this.storieDecorator=t;break}}let e=this.build.buildConfig.stories.format;if(this.storieDecorator?this.storieDecorator.exportType?this.storyType=this.storieDecorator.exportType:e?this.storyType=e==`manual`?`all`:e:this.storyType=`none`:e?this.storyType=e==`manual`?`none`:e:this.storyType=`none`,this.storyType==`public`||this.storyType==`protected`?(this.storieDecorator||this.isExported)&&(this.storieContent=this.defineStoryContent(this.storieDecorator)):this.storyType==`all`&&(this.storieContent=this.defineStoryContent(this.storieDecorator)),this.storieContent&&this.build.buildConfig.stories.srcBaseUrl){let e=this.build.project.getConfigFile().uri.replace(T.Config,``),t=O(this.fileUri.replace(e,``)).replace(/\\/g,`/`);this.storieContent.srcUrl=this.build.buildConfig.stories.srcBaseUrl+`/`+t}}}transformTypeForStory(e,t){if(e){if(e.kind==`type`){let n={kind:`simple`,name:e.value};if(e.isArray&&(n.isArray=!0),e.genericValue.length>0){let r=[];for(let n of e.genericValue){let e=this.transformTypeForStory(n,t);e&&r.push(e)}r.length>0&&(n.generics=r)}let r=t.parserInfo.importsLocal[e.value]?.info;if(r)r.storyType!=`none`&&(n.ref=Zt.getFullname(r));else{let r=t.parserInfo.internalObjects[e.value];r?.isStoryExported&&(n.ref=r.fullname)}return n}if(e.kind==`any`||e.kind==`never`||e.kind==`unknown`||e.kind==`boolean`||e.kind==`null`||e.kind==`number`||e.kind==`string`||e.kind==`undefined`||e.kind==`void`||e.kind==`object`||e.kind==`symbol`||e.kind==`this`)return{kind:`simple`,name:e.kind};if(e.kind==`literal`)return{kind:`simple`,name:e.value.slice(1,-1)};if(e.kind==`function`||e.kind==`constructor`){if(!e.fctType)return;let t={kind:`function`};if(Object.keys(e.fctType.parameters).length>0){t.parameters=[];for(let n in e.fctType.parameters){let r={name:n},i=this.transformTypeForStory(e.fctType.parameters[n],this);i&&(r.type=i),t.parameters.push(r)}}let n=this.transformTypeForStory(e.fctType.return,this);n&&(t.return=n),e.kind==`constructor`&&(t.isConstructor=!0);let r=e.node;if(r.typeParameters){t.generics=[];for(let e of r.typeParameters){let n={name:e.name.getText()},r=this.transformTypeForStory(new M(e.default),this);r&&(n.default=r);let i=this.transformTypeForStory(new M(e.constraint),this);i&&(n.constraint=i),t.generics.push(n)}}return t}if(e.kind==`tuple`){let n={kind:`tupple`,tupples:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.tupples.push(e)}return n}if(e.kind==`typeLiteral`){let n={kind:`object`},r=e.node;return(0,p.forEachChild)(r,e=>{if(e.kind==p.SyntaxKind.PropertySignature){let r=e;if(r.type){let e=r.name.getText(),i=new M(r.type),a=this.transformTypeForStory(i,t);a&&(n.keys||={},n.keys[e]=a)}else $.error(`need implements property signature no type `+p.SyntaxKind[e.kind]+` `+t.fileUri)}else if(e.kind==p.SyntaxKind.IndexSignature){let r=e;if(r.parameters.length>0&&r.parameters[0].type){n.indexSignatures||=[];let e=this.transformTypeForStory(new M(r.type),t),i=this.transformTypeForStory(new M(r.parameters[0].type),t);e&&i&&n.indexSignatures.push({keyName:r.parameters[0].name.getText(),keyType:i,type:e})}}else if(e.kind==p.SyntaxKind.TypeLiteral){let r=e,i=this.transformTypeForStory(new M(r),t);i&&(n.array=i)}else $.error(`need implements for `+p.SyntaxKind[e.kind]+` `+t.fileUri)}),n}if(e.kind==`union`){let n={kind:`union`,types:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.types.push(e)}return n}if(e.kind==`intersection`){let n={kind:`intersection`,types:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.types.push(e)}return n}if(e.kind==`typeOperator`){if(e.nested.length>0){let n=this.transformTypeForStory(e.nested[0],t);if(n)return{kind:`typeOperator`,value:e.value,type:n}}return}if(e.kind==`indexedAccess`){if(e.nested.length==2){let n=this.transformTypeForStory(e.nested[0],t),r=this.transformTypeForStory(e.nested[1],t);if(r&&n)return{kind:`indexAccess`,obj:n,key:r}}return}if(e.kind==`mappedType`){if(e.mappedType){let n=this.transformTypeForStory(e.mappedType.parameterType,t),r=this.transformTypeForStory(e.mappedType.type,t);if(n&&r){let t={kind:`mappedType`,parameterName:e.mappedType.parameterName,parameterType:n,type:r};return e.mappedType.modifier&&(t.modifier=e.mappedType.modifier),t}}return}if(e.kind==`infer`)return{kind:`infer`,name:e.value};if(e.kind==`conditional`){if(e.conditionalType){let n=this.transformTypeForStory(e.conditionalType.check,t),r=this.transformTypeForStory(e.conditionalType.extends,t),i=this.transformTypeForStory(e.conditionalType.true,t),a=this.transformTypeForStory(e.conditionalType.false,t);if(r&&i&&a&&n)return{kind:`conditional`,check:n,extends:r,true:i,false:a}}return}e.kind==`mock`&&$.warning(`mock type`)}}loadGenericForStory(e,t){let n=e.name.getText(),r={name:n};if(t||=this.documentation,t?.documentationTemplates[n]&&(r.documentation=t.documentationTemplates[n]),e.constraint){let t=this.transformTypeForStory(new M(e.constraint),this);t&&(r.constraint=t)}if(e.default){let t=this.transformTypeForStory(new M(e.default),this);t&&(r.default=t)}return r}loadParameterForStory(e,t){let n=e.name.getText(),r={name:n},i=this.transformTypeForStory(new M(e.type),this);return i&&(r.type=i),t||=this.documentation,t?.documentationParameters[n]&&(r.documentation=t.documentationParameters[n]),r}setAccessibilityForStroy(e){this.isExported||(e.accessibility=`internal`)}setNamespaceForStroy(e){this.build.noNamespaceUri[this.fileUri]?this.namespace.length>0&&(e.namespace=this.namespace):(e.namespace=this.build.module,this.namespace.length>0&&(e.namespace+=`.`+this.namespace))}setDocumentationForStroy(e){this.documentation&&(e.documentation=this.documentation.definitions.join(`
240
- `))}},en=class extends N{node;type;constructor(e,t,n){super(e,t,n),this.node=e,this.type=new M(this.node.type),this.loadOnlyDependenciesRecu(e)}defineStoryContent(){let e={kind:`type`,name:this.name};this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e);let t=this.transformTypeForStory(new M(this.node.type),this);if(t&&(e.type=t),this.node.typeParameters){e.generics=[];for(let t of this.node.typeParameters)e.generics.push(this.loadGenericForStory(t))}return e}},tn=class e{static is(t){return t.name==`NoCompile`?new e:null}},nn=class e{static is(t){return t.name==`BindThis`?new e:null}},rn=class{fullStart=0;start=0;end=0;name=``;nameStart=0;nameEnd=0;content=``;documentation;decorators=[];_class;accessibilityModifierTransformation;mustBeCompiled=!0;isStatic=!1;isOverride=!1;isAbstract=!1;isAsync=!1;isPrivate=!1;isProtected=!1;isBindThis=!1;deprecated=!1;deprecatedMsg=``;node;returnType;get compiledContent(){return N.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return N.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return N.getContentNpm(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}constructor(e,t){this.node=e,this._class=t,this.fullStart=e.getFullStart(),this.start=e.getStart(),this.end=e.getEnd(),this.name=e.name.getText(),this.nameStart=e.name.getStart(),this.nameEnd=e.name.getEnd(),this.content=e.getText(),this.decorators=Bt.buildDecorator(e,t),this.returnType=new M(e.type);let n=new Gt(e);n.hasDoc&&(this.documentation=n),this.loadAccessibilityModifier(e);let r=null;for(let e of this.decorators)tn.is(e)?this.mustBeCompiled=!1:(r=$t.is(e))&&(this.deprecated=!0,this.deprecatedMsg=r.msg)}loadAccessibilityModifier(e){let t=!1,n=null;for(let e of this.decorators){let t=Ht.is(e);if(t){n=t;continue}let r=Ut.is(e);if(r){n=r;continue}if(nn.is(e)){this.isBindThis=!0;continue}}if(e.modifiers)for(let r of e.modifiers)if(r.kind==p.SyntaxKind.PublicKeyword){if(n){let e=n instanceof Ht?`private`:`protected`;this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:e},e==`private`?this.isPrivate=!0:e==`protected`&&(this.isProtected=!0)}t=!0}else r.kind==p.SyntaxKind.ProtectedKeyword?(n instanceof Ht?(this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:`private`},this.isPrivate=!0):this.isProtected=!0,t=!0):r.kind==p.SyntaxKind.PrivateKeyword?(t=!0,this.isPrivate=!0):r.kind==p.SyntaxKind.OverrideKeyword?this.isOverride=!0:r.kind==p.SyntaxKind.StaticKeyword?this.isStatic=!0:r.kind==p.SyntaxKind.AbstractKeyword?this.isAbstract=!0:r.kind==p.SyntaxKind.AsyncKeyword&&(this.isAsync=!0);!this.documentation&&!this.isOverride&&!this.isPrivate&&P.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name),t===!1&&!this._class.isInterface&&P.addError(this.nameStart,this.nameEnd,`A accessibility modifier (public / private / protected) is mandatory for `+this.name)}},an=class e{static is(t){if(t.name==`StoryValue`){if(t.arguments.length>0){let n=t.arguments[0].value;return new e(n)}return null}return null}value;constructor(e){this.value=e}},on=class{name=``;nameStart=0;nameEnd=0;documentation;decorators=[];defaultValueTxt=null;defaultValueStart=0;defaultValueEnd=0;content=``;type;prop;isAbstract=!1;isGet=!1;isSet=!1;isGetSet=!1;isInsideInterface=!1;isStatic=!1;isProtected=!1;isPrivate=!1;isOverride=!1;start=0;end=0;isNullable=!1;overrideNullable=!1;_class;accessibilityModifierTransformation;deprecated=!1;deprecatedMsg=``;get compiledContent(){return N.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return N.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return N.getContentNpm(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValue(){return this.defaultValueTxt===null?null:N.getContent(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueHotReload(){return this.defaultValueTxt===null?null:N.getContentHotReload(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueNpm(){return this.defaultValueTxt===null?null:N.getContentNpm(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}defaultValueStory=null;constructor(e,t,n){this.isInsideInterface=t,this._class=n,this.prop=e,this.name=e.name.getText(),this.nameStart=e.name.getStart(),this.nameEnd=e.name.getEnd(),this.start=e.getStart(),this.end=e.getEnd(),this.content=e.getText(),this.decorators=Bt.buildDecorator(e,n),e.kind==p.SyntaxKind.GetAccessor?this.isGet=!0:e.kind==p.SyntaxKind.SetAccessor?this.isSet=!0:this.isGetSet=!0;let r=new Gt(e);r.hasDoc&&(this.documentation=r),e.questionToken&&(this.isNullable=!0),e.exclamationToken&&(this.overrideNullable=!0),this.loadAccessibilityModifier(e),this.type=this.loadType(e),this.loadInitializer(e);for(let e of this.decorators){let t=an.is(e);t&&(this.defaultValueStory=t.value);let n=$t.is(e);n&&(this.deprecated=!0,this.deprecatedMsg=n.msg)}}loadAccessibilityModifier(e){if(this.isInsideInterface)return;let t=!1,n=null;for(let e of this.decorators){let t=Ht.is(e);if(t){n=t;break}let r=Ut.is(e);if(r){n=r;break}}if(e.modifiers)for(let r of e.modifiers)if(r.kind==p.SyntaxKind.PublicKeyword){if(n){let e=n instanceof Ht?`private`:`protected`;this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:e},e==`private`?this.isPrivate=!0:e==`protected`&&(this.isProtected=!0)}t=!0}else r.kind==p.SyntaxKind.ProtectedKeyword?(n instanceof Ht?(this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:`private`},this.isPrivate=!0):this.isProtected=!0,t=!0):r.kind==p.SyntaxKind.PrivateKeyword?(t=!0,this.isPrivate=!0):r.kind==p.SyntaxKind.AbstractKeyword?this.isAbstract=!0:r.kind==p.SyntaxKind.OverrideKeyword?this.isOverride=!0:r.kind==p.SyntaxKind.StaticKeyword&&(this.isStatic=!0);!this.documentation&&!this.isOverride&&!this.isPrivate&&P.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name),t===!1&&P.addError(e.getStart(),e.getEnd(),`A accessibility modifier (public / private / protected) is mandatory for `+this.name)}loadType(e){let t=e,n;return n=t.type?new M(t.type):t.initializer&&t.initializer.kind==p.SyntaxKind.ExpressionWithTypeArguments?new M(t.initializer):new M(null),n}loadInitializer(e){let t=e;t.initializer&&(this.defaultValueTxt=t.initializer.getText(),this.defaultValueStart=t.initializer.getStart(),this.defaultValueEnd=t.initializer.getEnd())}},sn=class e{name=`Fullname`;static is(t){if(t.name==`Convertible`){let n=new e;if(t.arguments.length>0)try{n.name=t.arguments[0].value}catch{}return n}return null}};const cn=[`Callback`,`Aventus.Callback`,`CallbackGroup`,`Aventus.CallbackGroup`];var ln=class extends on{propType=`Simple`;inParent=!1;arguments},un=class e extends N{extends=[];extendsNpm=[];implements=[];parentClass=null;methods={};methodsStatic={};properties={};propertiesStatic={};isInterface=!1;isAbstract=!1;constructorBody;constructorParams=[];parameters=[];methodParameters=[];convertibleName=``;extendsType;implementsType=[];extraConstructorCode=[];get isWebcomponent(){return this.implements.includes(`Aventus.DefaultComponent`)&&!this.isInterface}get constructorContent(){if(!this.constructorBody){if(this.extraConstructorCode.length>0){let e=this.parentClass?this.parentClass.constructorParams.map(e=>e.getText()).join():``,t=this.parentClass?this.parentClass.constructorParams.map(e=>e.name.getText()).join():``;return this.parentClass?`constructor(`+e+`) { super(`+t+`); `+x.EOL+this.extraConstructorCode.join(x.EOL)+` }`:`constructor(`+e+`) {`+this.extraConstructorCode.join(x.EOL)+` }`}return``}let e=this.constructorBody.getText();return e=N.getContent(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}get constructorContentHotReload(){if(!this.constructorBody){if(this.extraConstructorCode.length>0){let e=this.parentClass?this.parentClass.constructorParams.map(e=>e.getText()).join():``,t=this.parentClass?this.parentClass.constructorParams.map(e=>e.name.getText()).join():``;return this.parentClass?`constructor(`+e+`) { super(`+t+`); `+x.EOL+this.extraConstructorCode.join(x.EOL)+` }`:`constructor(`+e+`) {`+this.extraConstructorCode.join(x.EOL)+` }`}return``}let e=this.constructorBody.getText();return e=N.getContentHotReload(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}get constructorContentNpm(){if(!this.constructorBody){if(this.extraConstructorCode.length>0){let e=this.parentClass?this.parentClass.constructorParams.map(e=>e.getText()).join():``,t=this.parentClass?this.parentClass.constructorParams.map(e=>e.name.getText()).join():``;return this.parentClass?`constructor(`+e+`) { super(`+t+`); `+x.EOL+this.extraConstructorCode.join(x.EOL)+` }`:`constructor(`+e+`) {`+this.extraConstructorCode.join(x.EOL)+` }`}return``}let e=this.constructorBody.getText();return e=N.getContentNpm(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}node;constructor(e,t,n){if(super(e,t,n,!1),this.node=e,this.isInterface=e.kind==p.SyntaxKind.InterfaceDeclaration,this.infoType=this.isInterface?3:1,e.typeParameters)for(let t of e.typeParameters)this.parameters.push(t.name.getText());if(e.modifiers)for(let t of e.modifiers)t.kind==p.SyntaxKind.AbstractKeyword&&(this.isAbstract=!0);if(e.heritageClauses)for(let t of e.heritageClauses)this.getClassInheritance(t);(0,p.forEachChild)(e,e=>{let t=!1,n=null;if(e.kind==p.SyntaxKind.Constructor){let t=e;t.body&&(this.constructorBody=t.body),this.constructorParams=Array.from(t.parameters)}else if(e.kind==p.SyntaxKind.PropertyDeclaration){let r=new on(e,this.isInterface,this);r.isStatic?(this.propertiesStatic[r.name]=r,t=!0):this.properties[r.name]=r;let i=e;i.type||P.addError(i.getStart(),i.getEnd(),`You must define a type for the prop `+r.name),n=r}else if(e.kind==p.SyntaxKind.GetAccessor){let t=e,r=new on(t,this.isInterface,this);r.isStatic?this.propertiesStatic[r.name]=r:this.properties[r.name]=r,t.type||P.addError(t.getStart(),t.getEnd(),`You must define a type for the prop `+r.name),n=r}else if(e.kind==p.SyntaxKind.SetAccessor){let t=new on(e,this.isInterface,this);t.isStatic?this.propertiesStatic[`°set°`+t.name]=t:this.properties[`°set°`+t.name]=t,n=t}else if(e.kind==p.SyntaxKind.MethodDeclaration){let t=e;if(t.typeParameters)for(let e of t.typeParameters)this.methodParameters.push(e.name.getText());let r=new rn(e,this);r.isStatic?this.methodsStatic[r.name]=r:this.methods[r.name]=r,this.methodParameters=[],n=r}else if(e.kind==p.SyntaxKind.MethodSignature){let t=e;if(t.typeParameters)for(let e of t.typeParameters)this.methodParameters.push(e.name.getText());let r=new rn(e,this);r.isStatic?this.methodsStatic[r.name]=r:this.methods[r.name]=r,this.methodParameters=[],n=r}else if(e.kind==p.SyntaxKind.PropertySignature){let r=new on(e,this.isInterface,this);r.isStatic?(this.propertiesStatic[r.name]=r,t=!0):this.properties[r.name]=r;let i=e;i.type||P.addError(i.getStart(),i.getEnd(),`You must define a type for the prop `+r.name),n=r}if(n&&n.accessibilityModifierTransformation){let e=n.accessibilityModifierTransformation.start+`_`+n.accessibilityModifierTransformation.end;this.compileTransformations[e]=n.accessibilityModifierTransformation}this.loadOnlyDependenciesRecu(e,0,t)}),this.loadConvertible(),this.loadDecorators(),this.addConstructor()}getClassInheritance(t){t.token==p.SyntaxKind.ExtendsKeyword?(0,p.forEachChild)(t,t=>{t.kind==p.SyntaxKind.ExpressionWithTypeArguments&&(this.build.hasStories&&(this.extendsType=new M(t)),this.addDependencyWaitName(t,!0,(t,n)=>{if(t.length>0&&(this.extends.push(t[0]),this.extends.length==1)){let n=N.getInfoByFullName(t[0],this);if(n&&n instanceof e&&(this.parentClass=n,this.parentClass==this))throw this.parentClass=null,`The parent is the child => impossible. Please send it to an admin`}n.length>0&&this.extendsNpm.push(n[0])}),(0,p.forEachChild)(t,e=>{this.loadOnlyDependenciesRecu(e,0,!0)}))}):t.token==p.SyntaxKind.ImplementsKeyword&&(0,p.forEachChild)(t,e=>{e.kind==p.SyntaxKind.ExpressionWithTypeArguments&&(this.build.hasStories&&this.implementsType.push(new M(e)),this.addDependencyWaitName(e,!0,e=>{if(e.length>0)for(let t of e)this.implements.push(t)}))})}addConstructor(){this.extraConstructorCode=[];let e=this.build.isCoreBuild?`DefaultComponent`:`Aventus.DefaultComponent`;this.implements.includes(e)&&!this.isInterface&&this.isAbstract&&this.extraConstructorCode.push(`if (this.constructor == `+this.name+`) { throw "can't instanciate an abstract class"; }`);for(let e in this.methods)this.methods[e].isBindThis&&this.extraConstructorCode.push(`this.${e}=this.${e}.bind(this)`);if(this.extraConstructorCode.length>0)if(this.constructorBody){let e=this.constructorBody.getEnd()-1,t=e+`_`+e;this.compileTransformations[t]={start:e,end:e,newText:x.EOL+this.extraConstructorCode.join(x.EOL)}}else{let e=this.node.getChildren().find(e=>e.kind==p.SyntaxKind.OpenBraceToken)?.end??0,t=e+`_`+e;if(this.parentClass){let n=this.parentClass.constructorParams.map(e=>e.getText()).join(),r=this.parentClass.constructorParams.map(e=>e.name.getText()).join();this.compileTransformations[t]={start:e,end:e,newText:`constructor(`+n+`) { super(`+r+`); `+x.EOL+this.extraConstructorCode.join(x.EOL)+` }`}}else this.compileTransformations[t]={start:e,end:e,newText:`constructor() { `+this.extraConstructorCode.join(x.EOL)+` }`}}}loadConvertible(){let e=this;for(;e!=null;){for(let t of e.decorators){let e=sn.is(t);if(e){this.convertibleName=e.name;return}}e=e.parentClass}}addDependencyNameCustomCheck(e){return!(this.parameters.includes(e)||this.methodParameters.includes(e))}hasStaticField(e){let t=this;for(;t!=null;){if(t.propertiesStatic[e]!=null)return!0;t=t.parentClass}return!1}getStaticFieldParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.propertiesStatic[e]!=null)return t;t=t.parentClass}return null}hasField(e){return this.getField(e)!=null}getField(e){let t=this;for(;t!=null;){if(t.properties[e]!=null)return t.properties[e];t=t.parentClass}return null}getFieldParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.properties[e]!=null)return t;t=t.parentClass}return null}getMethodParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.methods[e]!=null)return t;t=t.parentClass}return null}getStaticMethodParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.methodsStatic[e]!=null)return t;t=t.parentClass}return null}getEvent(e){let t;e.startsWith(`@`)&&(e=e.slice(1)),t=e.startsWith(`on`)?[e]:[e,`on`+e,`on`+e.charAt(0).toUpperCase()+e.slice(1)];for(let e of t){let t=this;for(;t!=null;){if(t.properties[e]!=null){let n=t.properties[e].type.value;if(cn.includes(n))return t.properties[e]}t=t.parentClass}}return null}defineStoryContent(e){let t={kind:this.isInterface?`interface`:`class`,name:this.name};if(this.setNamespaceForStroy(t),this.setDocumentationForStroy(t),this.setAccessibilityForStroy(t),this.isAbstract&&t.kind==`class`&&(t.modifier=`abstract`),this.extendsType){let e=this.transformTypeForStory(this.extendsType,this);e&&(t.extends=e)}if(this.implementsType.length>0&&t.kind==`class`){t.implements=[];for(let e of this.implementsType){let n=this.transformTypeForStory(e,this);n&&t.implements.push(n)}}if(this.node.typeParameters){t.generics=[];for(let e of this.node.typeParameters)t.generics.push(this.loadGenericForStory(e))}for(let e in this.methods)this.addMethodStoryContent(t,this.methods[e]);for(let e in this.methodsStatic)this.addMethodStoryContent(t,this.methodsStatic[e]);for(let e in this.properties)this.addPropertyStoryContent(t,this.properties[e]);for(let e in this.propertiesStatic)this.addPropertyStoryContent(t,this.propertiesStatic[e]);return t}addMethodStoryContent(e,t){if(!this.canAddToStory(t))return;let n=[this.build.module,this.fullName].join(`.`);if(t.name.startsWith(`__`+Je(n)+`method`))return;e.methods||=[];let r={name:t.name,accessibility:t.isPrivate?`private`:t.isProtected?`protected`:`public`};e.methods.push(r);let i=e=>{r.modifiers||=[],r.modifiers.push(e)};if(t.documentation&&(r.documentation=t.documentation.definitions.join(`
242
+ `))}},en=class extends N{node;type;constructor(e,t,n){super(e,t,n),this.node=e,this.type=new M(this.node.type),this.loadOnlyDependenciesRecu(e)}defineStoryContent(){let e={kind:`type`,name:this.name};this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e);let t=this.transformTypeForStory(new M(this.node.type),this);if(t&&(e.type=t),this.node.typeParameters){e.generics=[];for(let t of this.node.typeParameters)e.generics.push(this.loadGenericForStory(t))}return e}},tn=class e{static is(t){return t.name==`NoCompile`?new e:null}},nn=class e{static is(t){return t.name==`BindThis`?new e:null}},rn=class{fullStart=0;start=0;end=0;name=``;nameStart=0;nameEnd=0;content=``;documentation;decorators=[];_class;accessibilityModifierTransformation;mustBeCompiled=!0;isStatic=!1;isOverride=!1;isAbstract=!1;isAsync=!1;isPrivate=!1;isProtected=!1;isBindThis=!1;deprecated=!1;deprecatedMsg=``;node;returnType;get compiledContent(){return N.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return N.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return N.getContentNpm(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}constructor(e,t){this.node=e,this._class=t,this.fullStart=e.getFullStart(),this.start=e.getStart(),this.end=e.getEnd(),this.name=e.name.getText(),this.nameStart=e.name.getStart(),this.nameEnd=e.name.getEnd(),this.content=e.getText(),this.decorators=Bt.buildDecorator(e,t),this.returnType=new M(e.type);let n=new Gt(e);n.hasDoc&&(this.documentation=n),this.loadAccessibilityModifier(e);let r=null;for(let e of this.decorators)tn.is(e)?this.mustBeCompiled=!1:(r=$t.is(e))&&(this.deprecated=!0,this.deprecatedMsg=r.msg)}loadAccessibilityModifier(e){let t=!1,n=null;for(let e of this.decorators){let t=Ht.is(e);if(t){n=t;continue}let r=Ut.is(e);if(r){n=r;continue}if(nn.is(e)){this.isBindThis=!0;continue}}if(e.modifiers)for(let r of e.modifiers)if(r.kind==p.SyntaxKind.PublicKeyword){if(n){let e=n instanceof Ht?`private`:`protected`;this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:e},e==`private`?this.isPrivate=!0:e==`protected`&&(this.isProtected=!0)}t=!0}else r.kind==p.SyntaxKind.ProtectedKeyword?(n instanceof Ht?(this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:`private`},this.isPrivate=!0):this.isProtected=!0,t=!0):r.kind==p.SyntaxKind.PrivateKeyword?(t=!0,this.isPrivate=!0):r.kind==p.SyntaxKind.OverrideKeyword?this.isOverride=!0:r.kind==p.SyntaxKind.StaticKeyword?this.isStatic=!0:r.kind==p.SyntaxKind.AbstractKeyword?this.isAbstract=!0:r.kind==p.SyntaxKind.AsyncKeyword&&(this.isAsync=!0);!this.documentation&&!this.isOverride&&!this.isPrivate&&P.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name),t===!1&&!this._class.isInterface&&P.addError(this.nameStart,this.nameEnd,`A accessibility modifier (public / private / protected) is mandatory for `+this.name)}},an=class e{static is(t){if(t.name==`StoryValue`){if(t.arguments.length>0){let n=t.arguments[0].value;return new e(n)}return null}return null}value;constructor(e){this.value=e}},on=class{name=``;nameStart=0;nameEnd=0;documentation;decorators=[];defaultValueTxt=null;defaultValueStart=0;defaultValueEnd=0;content=``;type;prop;isAbstract=!1;isGet=!1;isSet=!1;isGetSet=!1;isInsideInterface=!1;isStatic=!1;isProtected=!1;isPrivate=!1;isOverride=!1;start=0;end=0;isNullable=!1;overrideNullable=!1;_class;accessibilityModifierTransformation;deprecated=!1;deprecatedMsg=``;get compiledContent(){return N.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return N.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return N.getContentNpm(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValue(){return this.defaultValueTxt===null?null:N.getContent(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueHotReload(){return this.defaultValueTxt===null?null:N.getContentHotReload(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueNpm(){return this.defaultValueTxt===null?null:N.getContentNpm(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}defaultValueStory=null;constructor(e,t,n){this.isInsideInterface=t,this._class=n,this.prop=e,this.name=e.name.getText(),this.nameStart=e.name.getStart(),this.nameEnd=e.name.getEnd(),this.start=e.getStart(),this.end=e.getEnd(),this.content=e.getText(),this.decorators=Bt.buildDecorator(e,n),e.kind==p.SyntaxKind.GetAccessor?this.isGet=!0:e.kind==p.SyntaxKind.SetAccessor?this.isSet=!0:this.isGetSet=!0;let r=new Gt(e);r.hasDoc&&(this.documentation=r),e.questionToken&&(this.isNullable=!0),e.exclamationToken&&(this.overrideNullable=!0),this.loadAccessibilityModifier(e),this.type=this.loadType(e),this.loadInitializer(e);for(let e of this.decorators){let t=an.is(e);t&&(this.defaultValueStory=t.value);let n=$t.is(e);n&&(this.deprecated=!0,this.deprecatedMsg=n.msg)}}loadAccessibilityModifier(e){if(this.isInsideInterface)return;let t=!1,n=null;for(let e of this.decorators){let t=Ht.is(e);if(t){n=t;break}let r=Ut.is(e);if(r){n=r;break}}if(e.modifiers)for(let r of e.modifiers)if(r.kind==p.SyntaxKind.PublicKeyword){if(n){let e=n instanceof Ht?`private`:`protected`;this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:e},e==`private`?this.isPrivate=!0:e==`protected`&&(this.isProtected=!0)}t=!0}else r.kind==p.SyntaxKind.ProtectedKeyword?(n instanceof Ht?(this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:`private`},this.isPrivate=!0):this.isProtected=!0,t=!0):r.kind==p.SyntaxKind.PrivateKeyword?(t=!0,this.isPrivate=!0):r.kind==p.SyntaxKind.AbstractKeyword?this.isAbstract=!0:r.kind==p.SyntaxKind.OverrideKeyword?this.isOverride=!0:r.kind==p.SyntaxKind.StaticKeyword&&(this.isStatic=!0);!this.documentation&&!this.isOverride&&!this.isPrivate&&P.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name),t===!1&&P.addError(e.getStart(),e.getEnd(),`A accessibility modifier (public / private / protected) is mandatory for `+this.name)}loadType(e){let t=e,n;return n=t.type?new M(t.type):t.initializer&&t.initializer.kind==p.SyntaxKind.ExpressionWithTypeArguments?new M(t.initializer):new M(null),n}loadInitializer(e){let t=e;t.initializer&&(this.defaultValueTxt=t.initializer.getText(),this.defaultValueStart=t.initializer.getStart(),this.defaultValueEnd=t.initializer.getEnd())}},sn=class e{name=`Fullname`;static is(t){if(t.name==`Convertible`){let n=new e;if(t.arguments.length>0)try{n.name=t.arguments[0].value}catch{}return n}return null}};const cn=[`Callback`,`Aventus.Callback`,`CallbackGroup`,`Aventus.CallbackGroup`];var ln=class extends on{propType=`Simple`;inParent=!1;arguments},un=class e extends N{extends=[];extendsNpm=[];implements=[];parentClass=null;methods={};methodsStatic={};properties={};propertiesStatic={};isInterface=!1;isAbstract=!1;constructorBody;constructorParams=[];parameters=[];methodParameters=[];convertibleName=``;extendsType;implementsType=[];extraConstructorCode=[];get isWebcomponent(){return this.implements.includes(`Aventus.DefaultComponent`)&&!this.isInterface}get constructorContent(){if(!this.constructorBody){if(this.extraConstructorCode.length>0){let e=this.parentClass?this.parentClass.constructorParams.map(e=>e.getText()).join():``,t=this.parentClass?this.parentClass.constructorParams.map(e=>e.name.getText()).join():``;return this.parentClass?`constructor(`+e+`) { super(`+t+`);
243
+ `+this.extraConstructorCode.join(`
244
+ `)+` }`:`constructor(`+e+`) {`+this.extraConstructorCode.join(`
245
+ `)+` }`}return``}let e=this.constructorBody.getText();return e=N.getContent(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}get constructorContentHotReload(){if(!this.constructorBody){if(this.extraConstructorCode.length>0){let e=this.parentClass?this.parentClass.constructorParams.map(e=>e.getText()).join():``,t=this.parentClass?this.parentClass.constructorParams.map(e=>e.name.getText()).join():``;return this.parentClass?`constructor(`+e+`) { super(`+t+`);
246
+ `+this.extraConstructorCode.join(`
247
+ `)+` }`:`constructor(`+e+`) {`+this.extraConstructorCode.join(`
248
+ `)+` }`}return``}let e=this.constructorBody.getText();return e=N.getContentHotReload(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}get constructorContentNpm(){if(!this.constructorBody){if(this.extraConstructorCode.length>0){let e=this.parentClass?this.parentClass.constructorParams.map(e=>e.getText()).join():``,t=this.parentClass?this.parentClass.constructorParams.map(e=>e.name.getText()).join():``;return this.parentClass?`constructor(`+e+`) { super(`+t+`);
249
+ `+this.extraConstructorCode.join(`
250
+ `)+` }`:`constructor(`+e+`) {`+this.extraConstructorCode.join(`
251
+ `)+` }`}return``}let e=this.constructorBody.getText();return e=N.getContentNpm(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}node;constructor(e,t,n){if(super(e,t,n,!1),this.node=e,this.isInterface=e.kind==p.SyntaxKind.InterfaceDeclaration,this.infoType=this.isInterface?3:1,e.typeParameters)for(let t of e.typeParameters)this.parameters.push(t.name.getText());if(e.modifiers)for(let t of e.modifiers)t.kind==p.SyntaxKind.AbstractKeyword&&(this.isAbstract=!0);if(e.heritageClauses)for(let t of e.heritageClauses)this.getClassInheritance(t);(0,p.forEachChild)(e,e=>{let t=!1,n=null;if(e.kind==p.SyntaxKind.Constructor){let t=e;t.body&&(this.constructorBody=t.body),this.constructorParams=Array.from(t.parameters)}else if(e.kind==p.SyntaxKind.PropertyDeclaration){let r=new on(e,this.isInterface,this);r.isStatic?(this.propertiesStatic[r.name]=r,t=!0):this.properties[r.name]=r;let i=e;i.type||P.addError(i.getStart(),i.getEnd(),`You must define a type for the prop `+r.name),n=r}else if(e.kind==p.SyntaxKind.GetAccessor){let t=e,r=new on(t,this.isInterface,this);r.isStatic?this.propertiesStatic[r.name]=r:this.properties[r.name]=r,t.type||P.addError(t.getStart(),t.getEnd(),`You must define a type for the prop `+r.name),n=r}else if(e.kind==p.SyntaxKind.SetAccessor){let t=new on(e,this.isInterface,this);t.isStatic?this.propertiesStatic[`°set°`+t.name]=t:this.properties[`°set°`+t.name]=t,n=t}else if(e.kind==p.SyntaxKind.MethodDeclaration){let t=e;if(t.typeParameters)for(let e of t.typeParameters)this.methodParameters.push(e.name.getText());let r=new rn(e,this);r.isStatic?this.methodsStatic[r.name]=r:this.methods[r.name]=r,this.methodParameters=[],n=r}else if(e.kind==p.SyntaxKind.MethodSignature){let t=e;if(t.typeParameters)for(let e of t.typeParameters)this.methodParameters.push(e.name.getText());let r=new rn(e,this);r.isStatic?this.methodsStatic[r.name]=r:this.methods[r.name]=r,this.methodParameters=[],n=r}else if(e.kind==p.SyntaxKind.PropertySignature){let r=new on(e,this.isInterface,this);r.isStatic?(this.propertiesStatic[r.name]=r,t=!0):this.properties[r.name]=r;let i=e;i.type||P.addError(i.getStart(),i.getEnd(),`You must define a type for the prop `+r.name),n=r}if(n&&n.accessibilityModifierTransformation){let e=n.accessibilityModifierTransformation.start+`_`+n.accessibilityModifierTransformation.end;this.compileTransformations[e]=n.accessibilityModifierTransformation}this.loadOnlyDependenciesRecu(e,0,t)}),this.loadConvertible(),this.loadDecorators(),this.addConstructor()}getClassInheritance(t){t.token==p.SyntaxKind.ExtendsKeyword?(0,p.forEachChild)(t,t=>{t.kind==p.SyntaxKind.ExpressionWithTypeArguments&&(this.build.hasStories&&(this.extendsType=new M(t)),this.addDependencyWaitName(t,!0,(t,n)=>{if(t.length>0&&(this.extends.push(t[0]),this.extends.length==1)){let n=N.getInfoByFullName(t[0],this);if(n&&n instanceof e&&(this.parentClass=n,this.parentClass==this))throw this.parentClass=null,`The parent is the child => impossible. Please send it to an admin`}n.length>0&&this.extendsNpm.push(n[0])}),(0,p.forEachChild)(t,e=>{this.loadOnlyDependenciesRecu(e,0,!0)}))}):t.token==p.SyntaxKind.ImplementsKeyword&&(0,p.forEachChild)(t,e=>{e.kind==p.SyntaxKind.ExpressionWithTypeArguments&&(this.build.hasStories&&this.implementsType.push(new M(e)),this.addDependencyWaitName(e,!0,e=>{if(e.length>0)for(let t of e)this.implements.push(t)}))})}addConstructor(){this.extraConstructorCode=[];let e=this.build.isCoreBuild?`DefaultComponent`:`Aventus.DefaultComponent`;this.implements.includes(e)&&!this.isInterface&&this.isAbstract&&this.extraConstructorCode.push(`if (this.constructor == `+this.name+`) { throw "can't instanciate an abstract class"; }`);for(let e in this.methods)this.methods[e].isBindThis&&this.extraConstructorCode.push(`this.${e}=this.${e}.bind(this)`);if(this.extraConstructorCode.length>0)if(this.constructorBody){let e=this.constructorBody.getEnd()-1,t=e+`_`+e;this.compileTransformations[t]={start:e,end:e,newText:`
252
+ `+this.extraConstructorCode.join(`
253
+ `)}}else{let e=this.node.getChildren().find(e=>e.kind==p.SyntaxKind.OpenBraceToken)?.end??0,t=e+`_`+e;if(this.parentClass){let n=this.parentClass.constructorParams.map(e=>e.getText()).join(),r=this.parentClass.constructorParams.map(e=>e.name.getText()).join();this.compileTransformations[t]={start:e,end:e,newText:`constructor(`+n+`) { super(`+r+`);
254
+ `+this.extraConstructorCode.join(`
255
+ `)+` }`}}else this.compileTransformations[t]={start:e,end:e,newText:`constructor() { `+this.extraConstructorCode.join(`
256
+ `)+` }`}}}loadConvertible(){let e=this;for(;e!=null;){for(let t of e.decorators){let e=sn.is(t);if(e){this.convertibleName=e.name;return}}e=e.parentClass}}addDependencyNameCustomCheck(e){return!(this.parameters.includes(e)||this.methodParameters.includes(e))}hasStaticField(e){let t=this;for(;t!=null;){if(t.propertiesStatic[e]!=null)return!0;t=t.parentClass}return!1}getStaticFieldParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.propertiesStatic[e]!=null)return t;t=t.parentClass}return null}hasField(e){return this.getField(e)!=null}getField(e){let t=this;for(;t!=null;){if(t.properties[e]!=null)return t.properties[e];t=t.parentClass}return null}getFieldParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.properties[e]!=null)return t;t=t.parentClass}return null}getMethodParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.methods[e]!=null)return t;t=t.parentClass}return null}getStaticMethodParentClass(e){let t=this.parentClass;for(;t!=null;){if(t.methodsStatic[e]!=null)return t;t=t.parentClass}return null}getEvent(e){let t;e.startsWith(`@`)&&(e=e.slice(1)),t=e.startsWith(`on`)?[e]:[e,`on`+e,`on`+e.charAt(0).toUpperCase()+e.slice(1)];for(let e of t){let t=this;for(;t!=null;){if(t.properties[e]!=null){let n=t.properties[e].type.value;if(cn.includes(n))return t.properties[e]}t=t.parentClass}}return null}defineStoryContent(e){let t={kind:this.isInterface?`interface`:`class`,name:this.name};if(this.setNamespaceForStroy(t),this.setDocumentationForStroy(t),this.setAccessibilityForStroy(t),this.isAbstract&&t.kind==`class`&&(t.modifier=`abstract`),this.extendsType){let e=this.transformTypeForStory(this.extendsType,this);e&&(t.extends=e)}if(this.implementsType.length>0&&t.kind==`class`){t.implements=[];for(let e of this.implementsType){let n=this.transformTypeForStory(e,this);n&&t.implements.push(n)}}if(this.node.typeParameters){t.generics=[];for(let e of this.node.typeParameters)t.generics.push(this.loadGenericForStory(e))}for(let e in this.methods)this.addMethodStoryContent(t,this.methods[e]);for(let e in this.methodsStatic)this.addMethodStoryContent(t,this.methodsStatic[e]);for(let e in this.properties)this.addPropertyStoryContent(t,this.properties[e]);for(let e in this.propertiesStatic)this.addPropertyStoryContent(t,this.propertiesStatic[e]);return t}addMethodStoryContent(e,t){if(!this.canAddToStory(t))return;let n=[this.build.module,this.fullName].join(`.`);if(t.name.startsWith(`__`+Je(n)+`method`))return;e.methods||=[];let r={name:t.name,accessibility:t.isPrivate?`private`:t.isProtected?`protected`:`public`};e.methods.push(r);let i=e=>{r.modifiers||=[],r.modifiers.push(e)};if(t.documentation&&(r.documentation=t.documentation.definitions.join(`
241
257
  `)),t.isAbstract&&i(`abstract`),t.isOverride&&i(`override`),t.isStatic&&i(`static`),t.node.typeParameters){r.generics=[];for(let e of t.node.typeParameters)r.generics.push(this.loadGenericForStory(e,t.documentation))}if(t.node.parameters.length>0){r.parameters=[];for(let e of t.node.parameters)r.parameters.push(this.loadParameterForStory(e,t.documentation))}if(t.node.type){let e=new M(t.node.type),n=this.transformTypeForStory(e,this);if(n){let e={type:n};t.documentation?.documentationReturn&&(e.documentation=t.documentation?.documentationReturn),r.return=e}}}addPropertyStoryContent(e,t){if(!this.canAddToStory(t))return;e.properties||=[];let n={name:t.name,accessibility:t.isPrivate?`private`:t.isProtected?`protected`:`public`};e.properties.push(n),t.documentation&&(n.documentation=t.documentation.definitions.join(`
242
258
  `));let r=e=>{n.modifiers||=[],n.modifiers.push(e)};t.isOverride&&r(`override`),t.isAbstract&&r(`abstract`),t.isGet&&r(`readonly`),t.isSet&&r(`writeonly`),t.isStatic&&r(`static`);let i=this.transformTypeForStory(t.type,this);i&&(n.type=i)}canAddToStory(e){if(!this.build.buildConfig.stories)return!1;let t=this.storyType;return t==`public`?e.isPrivate||e.isProtected?e.decorators.find(e=>e.name==`AddToStory`)!==void 0:e.decorators.find(e=>e.name==`NoStory`)===void 0:t==`protected`?e.isPrivate?e.decorators.find(e=>e.name==`AddToStory`)!==void 0:e.decorators.find(e=>e.name==`NoStory`)===void 0:t==`all`?e.decorators.find(e=>e.name==`NoStory`)===void 0:!1}mergeClassInfo(e){for(let t of e.extends)this.extends.includes(t)||this.extends.push(t);for(let t of e.implements)this.implements.includes(t)||this.implements.push(t);this.methods={...e.methods,...this.methods},this.methodsStatic={...e.methodsStatic,...this.methodsStatic},this.properties={...e.properties,...this.properties},this.propertiesStatic={...e.propertiesStatic,...this.propertiesStatic},this.useNormalDecorator=e.useNormalDecorator}},dn=class extends N{node;constructor(e,t,n){super(e,t,n,!1),this.infoType=6,this.node=e}defineStoryContent(){let e={kind:`enum`,name:this.name,properties:[]};this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e);let t=0;for(let n of this.node.members){let r={name:n.name.getText()},i;n.initializer?(i=(0,eval)(n.initializer.getText()),t=i+1):i=t++,r.value=i+``;let a=new Gt(n);a.hasDoc&&(r.documentation=a.definitions.join(`
243
259
  `)),e.properties.push(r)}return e}},fn=class{start=0;end=0;name=``;bodyStart=0;bodyEnd=0;constructor(e){this.name=e.name.getText(),this.start=e.getStart(),this.end=e.getEnd(),e.body&&(this.bodyStart=e.body.getStart()+1,this.bodyEnd=e.body.getEnd()-1)}},pn=class extends N{node;constructor(e,t,n){if(super(e,t,n),this.node=e,this.infoType=4,e.typeParameters)for(let t of e.typeParameters)this.preventDependencyAdd(t.name.getText()),t.constraint&&this.addDependency(t.constraint,!0);for(let t of e.parameters)t.type&&this.addDependency(t.type,!1);(0,p.forEachChild)(e,e=>{e.kind==p.SyntaxKind.Block&&this.loadOnlyDependenciesRecu(e,0,!1)})}defineStoryContent(){let e={kind:`function`,name:this.name};if(this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e),this.node.typeParameters){e.generics=[];for(let t of this.node.typeParameters)e.generics.push(this.loadGenericForStory(t))}if(this.node.parameters.length>0){e.parameters=[];for(let t of this.node.parameters)e.parameters.push(this.loadParameterForStory(t))}if(this.node.type){let t=new M(this.node.type),n=this.transformTypeForStory(t,this);if(n){let t={type:n};this.documentation?.documentationReturn&&(t.documentation=this.documentation.documentationReturn),e.return=t}}return e}},mn=class extends N{type=`var`;node;constructor(e,t,n,r){super(e,t,n),this.decorators=Bt.buildDecorator(r,this),this.node=e,this.infoType=5,e.parent.flags==p.NodeFlags.Let?this.type=`let`:e.parent.flags==p.NodeFlags.Const&&(this.type=`const`),this.isExported=N.isExported(r),this.isInternalExported=this.isExported;for(let e of this.decorators)if(Ht.is(e)){this.isExported=!1;break}this.loadOnlyDependenciesRecu(e,0,!0)}defineStoryContent(){let e={kind:`variable`,name:this.name,modifier:this.type==`const`?`const`:this.type==`let`?`let`:`var`};if(this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e),this.node.type){let t=new M(this.node.type),n=this.transformTypeForStory(t,this);n&&(e.type=n)}return e}},P=class e{static waitingUri={};static parsedDoc={};static parse(t,n,r){return e.parsedDoc[t.uri]&&this.parsedDoc[t.uri].version==t.versionInternal?this.parsedDoc[t.uri].result:(new e(t,n,r),e.parsedDoc[t.uri].result)}static parsingDocs=[];static get currentParsingDoc(){return this.parsingDocs.length>0?this.parsingDocs[this.parsingDocs.length-1]:null}static addError(e,t,n){if(this.currentParsingDoc&&!this.currentParsingDoc.isExternal){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Error,source:w.TypeScript,message:(0,p.flattenDiagnosticMessageText)(n,`
@@ -291,21 +307,43 @@ $namespaceEnd$
291
307
  `}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
308
  `,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
309
  `,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){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,`
310
+ `,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};
311
+ `,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
312
  `)}`;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
313
  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(`&nbsp;`);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
314
  \`\`\`
298
315
  ***
299
316
  `),i+=t.join(`
300
317
 
301
- `),{range:Re(e.documentInternal,n.textSpan),contents:{kind:`markdown`,value:i}}}}catch(e){this.printCatchError(e)}return null}getType(e,t){try{let n=this.languageService.getProgram();if(!n)return;let r=n.getSourceFile(e.file.uri);if(!r)return;let i=n.getTypeChecker(),a=(0,p.getTokenAtPosition)(r,t),o=i.getTypeAtLocation(a),s=e=>{if(e.isUnion()){let t=[];for(let n of e.types)t.push(s(n));return t.join(` | `)}else if(e.isIntersection()){let t=[];for(let n of e.types)t.push(s(n));return t.join(` & `)}else if(e.isNumberLiteral())return e.value+``;else if(e.isStringLiteral())return`"`+e.value+`"`;else if(e.isLiteral())return e.value+``;return i.typeToString(e,a,p.TypeFormatFlags.UseFullyQualifiedType)},c=s(o);if(c.includes(`.`))return c;if(e.fileParsed)for(let t in e.fileParsed.importsLocal){if(t==c)return c;let n=e.fileParsed.importsLocal[t];if(n.realName===void 0){let e=(0,p.getTokenAtPosition)(r,(n.nameEnd+n.nameStart)/2),t=i.getTypeAtLocation(e);n.realName=i.typeToString(t)}if(c==n.realName)return t}return c}catch(e){this.printCatchError(e)}}async findDefinition(e,t){let n=[];try{let r=e.documentInternal.offsetAt(t),i=this.languageService.getDefinitionAtPosition(e.uri,r);if(i&&i.length>0){for(let e of i){e.fileName.endsWith(`.avt.ts`)&&(e.fileName=e.fileName.replace(`.avt.ts`,`.avt`));let t=this.filesLoaded[e.fileName];if(t instanceof Cn){let r=await t.goToDefinition(Re(t.file.documentInternal,e.textSpan));r&&!Array.isArray(r)&&(r=[r]),r&&(n=[...r])}else if(t)n.push({uri:t.file.uri,range:Re(t.file.documentInternal,e.textSpan)});else{let t=Pt(e.fileName);if(t){let r=d.TextDocument.create(e.fileName,`typescript`,1,t);n.push({uri:e.fileName,range:Re(r,e.textSpan)})}}}return n}else if(i&&i.length==0){let t=this.languageService.getProgram();if(t){let i=t.getSourceFile(e.uri);if(i){let a=t.getTypeChecker(),o=(0,p.getTokenAtPosition)(i,r),s=a.getTypeAtLocation(o);if(s.isStringLiteral()){let t=e=>{for(let t in this.i18nFiles){let r=this.i18nFiles[t];if(r.parsed&&r.parsed[e]){let i=r.file.documentUser.positionAt(r.parsed[e].keyStart),a=r.file.documentUser.positionAt(r.parsed[e].keyEnd);n.push({uri:t,range:m.Range.create(i,a)})}}},r=o.parent.getText();if(r.startsWith(`t(`)){let e=s.value;t(e)}else if(r.startsWith(`this.t(`)){let r=s.value,i=this.build.tsFiles[e.uri];if(i instanceof F&&i.I18nFile?.parsed&&i.I18nFile?.parsed[r]){let e=i.I18nFile,t=i.I18nFile.parsed[r],a=e.file.documentUser.positionAt(t.keyStart),o=e.file.documentUser.positionAt(t.keyEnd);n.push({uri:i.I18nFile.file.uri,range:m.Range.create(a,o)})}t(r)}}}}}}catch(e){this.printCatchError(e)}return n}async format(e,t,n,r=!0){try{let i=e.documentInternal,a=i.offsetAt(t.start),o=i.offsetAt(t.end),s=null;t.end.line>t.start.line&&(t.end.character===0||An(i.getText().substr(o-t.end.character,t.end.character)))&&(o-=t.end.character,s=m.Range.create(m.Position.create(t.end.line,0),t.end));let c={...On};r?c.semicolons=p.SemicolonPreference.Insert:c.semicolons=p.SemicolonPreference.Remove;let l=this.languageServiceNamespace.getFormattingEditsForRange(i.uri,a,o,c);if(l){let e=[];for(let t of l)t.span.start>=a&&t.span.start+t.span.length<=o&&e.push({range:Re(i,t.span),newText:t.newText});return s&&e.push({range:s,newText:jn(0,n)}),e}}catch(e){this.printCatchError(e)}return[]}async doCodeAction(e,t){let n=[];try{let r=P.parse(e,!1,this.build),i=e.documentInternal,a=this.languageService.getSyntacticDiagnostics(i.uri),o=this.languageService.getSemanticDiagnostics(i.uri),s=[];for(let e of a)s.push(e.code);for(let e of o)e.code!=6133&&s.push(e.code);let c=[];try{c=this.languageService.getCodeFixesAtPosition(i.uri,i.offsetAt(t.start),i.offsetAt(t.end),s,On,Dn)}catch{}for(let t of c){let a=[],o={changes:{[i.uri]:a}};for(let n of t.changes)for(let o of n.textChanges){if(t.description.startsWith(`Add import from`)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let n=this.simplifyPath(e[1],i.uri);t.description=`Add import from `+n,o.newText=o.newText.replace(e[1],n)}}else if(t.fixName===`fixClassDoesntImplementInheritedAbstractMember`){let t=!1;for(let e in r.classes){let n=r.classes[e];o.span.start>=n.start&&o.span.start<=n.end&&(t=!0)}if(t){let t=Nn(e,`methods`);t!=-1&&(o.span.start=t),o.newText.match(/ (public|protected) /g)||(o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),o.newText.match(/(public|protected)[ ]*?override/g)||(o.newText=o.newText.replace(/((public|protected)[ ]*?)([a-z])/g,`$1override $3`)),o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(o.newText.startsWith(`import `)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);o.newText=o.newText.replace(e[1],t)}}}else if(t.fixName==`fixClassIncorrectlyImplementsInterface`){let t=!1;for(let e in r.classes){let n=r.classes[e];o.span.start>=n.start&&o.span.start<=n.end&&(t=!0)}if(t){let t=Nn(e,`methods`);t!=-1&&(o.span.start=t),!o.newText.includes(` protected `)&&!o.newText.includes(` public `)&&(o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(o.newText.startsWith(`import `)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);o.newText=o.newText.replace(e[1],t)}}}a.push({newText:o.newText,range:Re(i,o.span)})}n.push({title:t.description,edit:o})}}catch(e){this.printCatchError(e)}return n}async onReferences(e,t){let n=[];try{let r=e.documentInternal.offsetAt(t),i=this.languageService.findReferences(e.uri,r);if(i){for(let e of i)for(let t of e.references)if(this.filesLoaded[t.fileName]){let e=this.filesLoaded[t.fileName].file.documentInternal.positionAt(t.textSpan.start),r=this.filesLoaded[t.fileName].file.documentInternal.positionAt(t.textSpan.start+t.textSpan.length);n.push(m.Location.create(t.fileName,{start:e,end:r}))}}}catch(e){this.printCatchError(e)}return n}async onCodeLens(e){let t=[];try{let n=this.filesLoaded[e.uri];if(n&&n.fileParsed){let r=async n=>{for(let r of n){let n=e.documentInternal.positionAt(r.start),i=await this.onReferences(e,n),a=i.length>1?i.length+` references`:i.length+` reference`;t.push({range:{start:n,end:n},command:{title:a,command:i.length?`editor.action.showReferences`:``,arguments:[e.uri,n,i]}})}};await r(Object.values(n.fileParsed.classes)),await r(Object.values(n.fileParsed.enums)),await r(Object.values(n.fileParsed.aliases))}let r=Nn(e,`props`);if(r!=-1){let n=e.documentInternal.positionAt(r);t.push({range:{start:n,end:n},command:{title:`Add property | attribute`,command:`editor.action.showReferences`,arguments:[e.uri]}})}}catch(e){this.printCatchError(e)}return t}async onRename(e,t,n){this.languageService.getFileReferences(e.uri);let r=e.documentInternal.offsetAt(t),i={};if(!this.languageService.getRenameInfo(e.uri,r,i).canRename)return null;let a=this.languageService.findRenameLocations(e.uri,r,!1,!1,i);if(!a)return null;let o={changes:{}};if(o.changes){for(let e of a)if(this.filesLoaded[e.fileName]){o.changes[e.fileName]||(o.changes[e.fileName]=[]);let t={newText:n,range:{start:this.filesLoaded[e.fileName].file.documentInternal.positionAt(e.textSpan.start),end:this.filesLoaded[e.fileName].file.documentInternal.positionAt(e.textSpan.start+e.textSpan.length)}};o.changes[e.fileName].push(t)}}return o}async onRenameFile(e,t){let n={},r=this.languageService.getFileReferences(e);for(let e of r){let r=R.getInstance().getByUri(e.fileName);if(r){let i=[],a=r.folderUri.split(`/`),o=t.split(`/`);for(;a.length>0&&o.length>0&&a[0]==o[0];)a.splice(0,1),o.splice(0,1);let s=[];if(a.length>0)for(let e=0;e<a.length;e++)s.push(`..`);else s.push(`.`);for(let e of o)s.push(e);i.push({newText:s.join(`/`),range:{start:r.documentInternal.positionAt(e.textSpan.start),end:r.documentInternal.positionAt(e.textSpan.start+e.textSpan.length)}}),n[r.uri]=i}}return n}static removeComments(e){return e=e.replace(/(\".*?\"|\'.*?\')|(\/\*.*?\*\/|\/\/[^(\r\n|\n)]*$)/gm,(e,t,n)=>n?``:t),e}static removeEmptyComments(e){return e=e.replace(/\/\*. \*\//gm,(e,t,n)=>n?``:t),e}static prepareDataSchema(e,t,n){let r={},i=r=>{let i=(()=>{if(r.kind==`boolean`)return`boolean`;if(r.kind==`number`)return`number`;if(r.kind==`string`)return`string`;if(r.kind==`type`){if(r.value.includes(`.`))return r.value;{let i=e.parserInfo.importsLocal[r.value]?.info;return i?n?i.name:t+`.`+i.fullName:r.value}}else if(r.kind==`literal`||r.kind==`typeLiteral`)return`literal`;return null})();return i&&r.isArray&&(i+=`[]`),i};for(let a in e.properties){let o=e.properties[a];if(o.isStatic)continue;let s=!1;for(let i of o.decorators){let o=bn.is(i);if(o){s=!0;let i=e.parserInfo.importsLocal[o.refType]?.info;o.refType.includes(`.`)?r[a]=`ref:`+o.refType:i?r[a]=`ref:`+(n?i.name:t+`.`+i.fullName):r[a]=`ref:`+o.refType}}if(!s){let e=i(o.type);e&&(r[a]=e)}}let a=JSON.stringify(r).replace(/\\"/g,`"`);return e.parentClass&&(a=`{...(${n?e.extendsNpm[0]:e.parentClass.fullName}?.$schema ?? {}), ${a.slice(1)}`),a}static compileTs(e,t){let n={compiled:``,hotReload:``,docVisible:``,docInvisible:``,dependencies:Object.values(e.dependencies),classScript:``,classDoc:``,debugTxt:``,uri:t.file.uri,required:!1,type:e.infoType,isExported:{external:e.isExported,internal:e.isInternalExported},convertibleName:``,npm:{defTs:``,namespace:``,exportPath:``,uri:t.file.uri,src:``},useDecorator:!1};try{let r=``,i=``,a=e.compiledContent,o=e.compiledContentDoc,s=e.compiledContentHotReload,c=t.build.module;if(e instanceof un&&!e.isInterface){let t=`Aventus.`;e.build.isCoreBuild&&(t=``);let a=``;e.namespace&&(a=`.`+e.namespace),r+=e.fullName+".Namespace=`"+c+a+"`;"+x.EOL,i+=e.name+".Namespace=`"+c+a+"`;"+x.EOL,e.implements.includes(t+`IData`)&&(n.type=2),e.convertibleName?(r+=e.fullName+`.$schema=`+this.prepareDataSchema(e,c)+`;`+x.EOL,i+=e.name+`.$schema=`+this.prepareDataSchema(e,c)+`;`+x.EOL,r+=t+`Converter.register(`+e.fullName+`.`+e.convertibleName+`, `+e.fullName+`);`+x.EOL,i+=t+`Converter.register(`+e.fullName+`.`+e.convertibleName+`, `+e.fullName+`);`+x.EOL):e.implements.includes(t+`IData`)&&(r+=e.fullName+`.$schema=`+this.prepareDataSchema(e,c)+`;`+x.EOL,i+=e.name+`.$schema=`+this.prepareDataSchema(e,c)+`;`+x.EOL,r+=t+`Converter.register(`+e.fullName+`.Fullname, `+e.fullName+`);`+x.EOL,i+=t+`Converter.register(`+e.fullName+`.Fullname, `+e.fullName+`);`+x.EOL),n.convertibleName=e.convertibleName}else e instanceof mn&&(a=e.type+` `+e.compiledContent,o=e.type+` `+e.compiledContentDoc,s=e.type+` `+e.compiledContentHotReload);if(e.name==`MainState`)debugger;a=this.removeComments(a);let l=(0,p.transpile)(a,En);if(e.useNormalDecorator){let t=RegExp(`^var(\\s|\\S)*?let `+e.name+` = `,`gm`);l=l.replace(t,``),n.useDecorator=!0}n.compiled=l+r,yt.isRunning&&(s=this.removeComments(s),n.hotReload=(0,p.transpile)(s,En)),o=this.removeEmptyComments(o);let u=this.compileDocTs(o,e),d=yn.correct(u,e),f=this.compileTsToNpm(e,t);if(f&&(n.npm=f),d.length>0){let t=e.namespace;t.length>0&&(u=`namespace `+t+` {\r
318
+ `),{range:Re(e.documentInternal,n.textSpan),contents:{kind:`markdown`,value:i}}}}catch(e){this.printCatchError(e)}return null}getType(e,t){try{let n=this.languageService.getProgram();if(!n)return;let r=n.getSourceFile(e.file.uri);if(!r)return;let i=n.getTypeChecker(),a=(0,p.getTokenAtPosition)(r,t),o=i.getTypeAtLocation(a),s=e=>{if(e.isUnion()){let t=[];for(let n of e.types)t.push(s(n));return t.join(` | `)}else if(e.isIntersection()){let t=[];for(let n of e.types)t.push(s(n));return t.join(` & `)}else if(e.isNumberLiteral())return e.value+``;else if(e.isStringLiteral())return`"`+e.value+`"`;else if(e.isLiteral())return e.value+``;return i.typeToString(e,a,p.TypeFormatFlags.UseFullyQualifiedType)},c=s(o);if(c.includes(`.`))return c;if(e.fileParsed)for(let t in e.fileParsed.importsLocal){if(t==c)return c;let n=e.fileParsed.importsLocal[t];if(n.realName===void 0){let e=(0,p.getTokenAtPosition)(r,(n.nameEnd+n.nameStart)/2),t=i.getTypeAtLocation(e);n.realName=i.typeToString(t)}if(c==n.realName)return t}return c}catch(e){this.printCatchError(e)}}async findDefinition(e,t){let n=[];try{let r=e.documentInternal.offsetAt(t),i=this.languageService.getDefinitionAtPosition(e.uri,r);if(i&&i.length>0){for(let e of i){e.fileName.endsWith(`.avt.ts`)&&(e.fileName=e.fileName.replace(`.avt.ts`,`.avt`));let t=this.filesLoaded[e.fileName];if(t instanceof Cn){let r=await t.goToDefinition(Re(t.file.documentInternal,e.textSpan));r&&!Array.isArray(r)&&(r=[r]),r&&(n=[...r])}else if(t)n.push({uri:t.file.uri,range:Re(t.file.documentInternal,e.textSpan)});else{let t=Pt(e.fileName);if(t){let r=d.TextDocument.create(e.fileName,`typescript`,1,t);n.push({uri:e.fileName,range:Re(r,e.textSpan)})}}}return n}else if(i&&i.length==0){let t=this.languageService.getProgram();if(t){let i=t.getSourceFile(e.uri);if(i){let a=t.getTypeChecker(),o=(0,p.getTokenAtPosition)(i,r),s=a.getTypeAtLocation(o);if(s.isStringLiteral()){let t=e=>{for(let t in this.i18nFiles){let r=this.i18nFiles[t];if(r.parsed&&r.parsed[e]){let i=r.file.documentUser.positionAt(r.parsed[e].keyStart),a=r.file.documentUser.positionAt(r.parsed[e].keyEnd);n.push({uri:t,range:m.Range.create(i,a)})}}},r=o.parent.getText();if(r.startsWith(`t(`)){let e=s.value;t(e)}else if(r.startsWith(`this.t(`)){let r=s.value,i=this.build.tsFiles[e.uri];if(i instanceof F&&i.I18nFile?.parsed&&i.I18nFile?.parsed[r]){let e=i.I18nFile,t=i.I18nFile.parsed[r],a=e.file.documentUser.positionAt(t.keyStart),o=e.file.documentUser.positionAt(t.keyEnd);n.push({uri:i.I18nFile.file.uri,range:m.Range.create(a,o)})}t(r)}}}}}}catch(e){this.printCatchError(e)}return n}async format(e,t,n,r=!0){try{let i=e.documentInternal,a=i.offsetAt(t.start),o=i.offsetAt(t.end),s=null;t.end.line>t.start.line&&(t.end.character===0||An(i.getText().substr(o-t.end.character,t.end.character)))&&(o-=t.end.character,s=m.Range.create(m.Position.create(t.end.line,0),t.end));let c={...On};r?c.semicolons=p.SemicolonPreference.Insert:c.semicolons=p.SemicolonPreference.Remove;let l=this.languageServiceNamespace.getFormattingEditsForRange(i.uri,a,o,c);if(l){let e=[];for(let t of l)t.span.start>=a&&t.span.start+t.span.length<=o&&e.push({range:Re(i,t.span),newText:t.newText});return s&&e.push({range:s,newText:jn(0,n)}),e}}catch(e){this.printCatchError(e)}return[]}async doCodeAction(e,t){let n=[];try{let r=P.parse(e,!1,this.build),i=e.documentInternal,a=this.languageService.getSyntacticDiagnostics(i.uri),o=this.languageService.getSemanticDiagnostics(i.uri),s=[];for(let e of a)s.push(e.code);for(let e of o)e.code!=6133&&s.push(e.code);let c=[];try{c=this.languageService.getCodeFixesAtPosition(i.uri,i.offsetAt(t.start),i.offsetAt(t.end),s,On,Dn)}catch{}for(let t of c){let a=[],o={changes:{[i.uri]:a}};for(let n of t.changes)for(let o of n.textChanges){if(t.description.startsWith(`Add import from`)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let n=this.simplifyPath(e[1],i.uri);t.description=`Add import from `+n,o.newText=o.newText.replace(e[1],n)}}else if(t.fixName===`fixClassDoesntImplementInheritedAbstractMember`){let t=!1;for(let e in r.classes){let n=r.classes[e];o.span.start>=n.start&&o.span.start<=n.end&&(t=!0)}if(t){let t=Nn(e,`methods`);t!=-1&&(o.span.start=t),o.newText.match(/ (public|protected) /g)||(o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),o.newText.match(/(public|protected)[ ]*?override/g)||(o.newText=o.newText.replace(/((public|protected)[ ]*?)([a-z])/g,`$1override $3`)),o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(o.newText.startsWith(`import `)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);o.newText=o.newText.replace(e[1],t)}}}else if(t.fixName==`fixClassIncorrectlyImplementsInterface`){let t=!1;for(let e in r.classes){let n=r.classes[e];o.span.start>=n.start&&o.span.start<=n.end&&(t=!0)}if(t){let t=Nn(e,`methods`);t!=-1&&(o.span.start=t),!o.newText.includes(` protected `)&&!o.newText.includes(` public `)&&(o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(o.newText.startsWith(`import `)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);o.newText=o.newText.replace(e[1],t)}}}a.push({newText:o.newText,range:Re(i,o.span)})}n.push({title:t.description,edit:o})}}catch(e){this.printCatchError(e)}return n}async onReferences(e,t){let n=[];try{let r=e.documentInternal.offsetAt(t),i=this.languageService.findReferences(e.uri,r);if(i){for(let e of i)for(let t of e.references)if(this.filesLoaded[t.fileName]){let e=this.filesLoaded[t.fileName].file.documentInternal.positionAt(t.textSpan.start),r=this.filesLoaded[t.fileName].file.documentInternal.positionAt(t.textSpan.start+t.textSpan.length);n.push(m.Location.create(t.fileName,{start:e,end:r}))}}}catch(e){this.printCatchError(e)}return n}async onCodeLens(e){let t=[];try{let n=this.filesLoaded[e.uri];if(n&&n.fileParsed){let r=async n=>{for(let r of n){let n=e.documentInternal.positionAt(r.start),i=await this.onReferences(e,n),a=i.length>1?i.length+` references`:i.length+` reference`;t.push({range:{start:n,end:n},command:{title:a,command:i.length?`editor.action.showReferences`:``,arguments:[e.uri,n,i]}})}};await r(Object.values(n.fileParsed.classes)),await r(Object.values(n.fileParsed.enums)),await r(Object.values(n.fileParsed.aliases))}let r=Nn(e,`props`);if(r!=-1){let n=e.documentInternal.positionAt(r);t.push({range:{start:n,end:n},command:{title:`Add property | attribute`,command:`editor.action.showReferences`,arguments:[e.uri]}})}}catch(e){this.printCatchError(e)}return t}async onRename(e,t,n){this.languageService.getFileReferences(e.uri);let r=e.documentInternal.offsetAt(t),i={};if(!this.languageService.getRenameInfo(e.uri,r,i).canRename)return null;let a=this.languageService.findRenameLocations(e.uri,r,!1,!1,i);if(!a)return null;let o={changes:{}};if(o.changes){for(let e of a)if(this.filesLoaded[e.fileName]){o.changes[e.fileName]||(o.changes[e.fileName]=[]);let t={newText:n,range:{start:this.filesLoaded[e.fileName].file.documentInternal.positionAt(e.textSpan.start),end:this.filesLoaded[e.fileName].file.documentInternal.positionAt(e.textSpan.start+e.textSpan.length)}};o.changes[e.fileName].push(t)}}return o}async onRenameFile(e,t){let n={},r=this.languageService.getFileReferences(e);for(let e of r){let r=R.getInstance().getByUri(e.fileName);if(r){let i=[],a=r.folderUri.split(`/`),o=t.split(`/`);for(;a.length>0&&o.length>0&&a[0]==o[0];)a.splice(0,1),o.splice(0,1);let s=[];if(a.length>0)for(let e=0;e<a.length;e++)s.push(`..`);else s.push(`.`);for(let e of o)s.push(e);i.push({newText:s.join(`/`),range:{start:r.documentInternal.positionAt(e.textSpan.start),end:r.documentInternal.positionAt(e.textSpan.start+e.textSpan.length)}}),n[r.uri]=i}}return n}static removeComments(e){return e=e.replace(/(\".*?\"|\'.*?\')|(\/\*.*?\*\/|\/\/[^(\r\n|\n)]*$)/gm,(e,t,n)=>n?``:t),e}static removeEmptyComments(e){return e=e.replace(/\/\*. \*\//gm,(e,t,n)=>n?``:t),e}static prepareDataSchema(e,t,n){let r={},i=r=>{let i=(()=>{if(r.kind==`boolean`)return`boolean`;if(r.kind==`number`)return`number`;if(r.kind==`string`)return`string`;if(r.kind==`type`){if(r.value.includes(`.`))return r.value;{let i=e.parserInfo.importsLocal[r.value]?.info;return i?n?i.name:t+`.`+i.fullName:r.value}}else if(r.kind==`literal`||r.kind==`typeLiteral`)return`literal`;return null})();return i&&r.isArray&&(i+=`[]`),i};for(let a in e.properties){let o=e.properties[a];if(o.isStatic)continue;let s=!1;for(let i of o.decorators){let o=bn.is(i);if(o){s=!0;let i=e.parserInfo.importsLocal[o.refType]?.info;o.refType.includes(`.`)?r[a]=`ref:`+o.refType:i?r[a]=`ref:`+(n?i.name:t+`.`+i.fullName):r[a]=`ref:`+o.refType}}if(!s){let e=i(o.type);e&&(r[a]=e)}}let a=JSON.stringify(r).replace(/\\"/g,`"`);return e.parentClass&&(a=`{...(${n?e.extendsNpm[0]:e.parentClass.fullName}?.$schema ?? {}), ${a.slice(1)}`),a}static compileTs(e,t){let n={compiled:``,hotReload:``,docVisible:``,docInvisible:``,dependencies:Object.values(e.dependencies),classScript:``,classDoc:``,debugTxt:``,uri:t.file.uri,required:!1,type:e.infoType,isExported:{external:e.isExported,internal:e.isInternalExported},convertibleName:``,npm:{defTs:``,namespace:``,exportPath:``,uri:t.file.uri,src:``},useDecorator:!1};try{let r=``,i=``,a=e.compiledContent,o=e.compiledContentDoc,s=e.compiledContentHotReload,c=t.build.module;if(e instanceof un&&!e.isInterface){let t=`Aventus.`;e.build.isCoreBuild&&(t=``);let a=``;e.namespace&&(a=`.`+e.namespace),r+=e.fullName+".Namespace=`"+c+a+`\`;
319
+ `,i+=e.name+".Namespace=`"+c+a+`\`;
320
+ `,e.implements.includes(t+`IData`)&&(n.type=2),e.convertibleName?(r+=e.fullName+`.$schema=`+this.prepareDataSchema(e,c)+`;
321
+ `,i+=e.name+`.$schema=`+this.prepareDataSchema(e,c)+`;
322
+ `,r+=t+`Converter.register(`+e.fullName+`.`+e.convertibleName+`, `+e.fullName+`);
323
+ `,i+=t+`Converter.register(`+e.fullName+`.`+e.convertibleName+`, `+e.fullName+`);
324
+ `):e.implements.includes(t+`IData`)&&(r+=e.fullName+`.$schema=`+this.prepareDataSchema(e,c)+`;
325
+ `,i+=e.name+`.$schema=`+this.prepareDataSchema(e,c)+`;
326
+ `,r+=t+`Converter.register(`+e.fullName+`.Fullname, `+e.fullName+`);
327
+ `,i+=t+`Converter.register(`+e.fullName+`.Fullname, `+e.fullName+`);
328
+ `),n.convertibleName=e.convertibleName}else e instanceof mn&&(a=e.type+` `+e.compiledContent,o=e.type+` `+e.compiledContentDoc,s=e.type+` `+e.compiledContentHotReload);if(e.name==`MainState`)debugger;a=this.removeComments(a);let l=(0,p.transpile)(a,En);if(e.useNormalDecorator){let t=RegExp(`^var(\\s|\\S)*?let `+e.name+` = `,`gm`);l=l.replace(t,``),n.useDecorator=!0}n.compiled=l+r,yt.isRunning&&(s=this.removeComments(s),n.hotReload=(0,p.transpile)(s,En)),o=this.removeEmptyComments(o);let u=this.compileDocTs(o,e),d=yn.correct(u,e),f=this.compileTsToNpm(e,t);if(f&&(n.npm=f),d.length>0){let t=e.namespace;t.length>0&&(u=`namespace `+t+` {\r
302
329
  `+u+`}\r
303
330
  `,d=`namespace `+t+` {\r
304
331
  `+d+`}\r
305
- `),e.isExported?n.docVisible=d:n.docInvisible=d}let m=()=>{let r=``,i=t.build.namespaces.includes(e.fullName);i&&(r+=`_n = `+e.fullName+`;`+x.EOL);let a=n.compiled;if(e instanceof mn)a=a.slice(a.indexOf(`=`)+1),a=e.fullName.includes(`.`)?e.fullName+`=`+a:`let `+e.fullName+`=`+a;else if(e instanceof dn){let t=`})(${e.name} || (${e.name} = {}))`,n=`})(${e.fullName} || (${e.fullName} = {}))`;if(a=a.replaceAll(t,n),e.fullName.includes(`.`)){let e=a.split(`
332
+ `),e.isExported?n.docVisible=d:n.docInvisible=d}let m=()=>{let r=``,i=t.build.namespaces.includes(e.fullName);i&&(r+=`_n = `+e.fullName+`;
333
+ `);let a=n.compiled;if(e instanceof mn)a=a.slice(a.indexOf(`=`)+1),a=e.fullName.includes(`.`)?e.fullName+`=`+a:`let `+e.fullName+`=`+a;else if(e instanceof dn){let t=`})(${e.name} || (${e.name} = {}))`,n=`})(${e.fullName} || (${e.fullName} = {}))`;if(a=a.replaceAll(t,n),e.fullName.includes(`.`)){let e=a.split(`
306
334
  `);e.splice(0,1),a=e.join(`
307
- `)}}else a=e.fullName+`=`+n.compiled,e.fullName.includes(`.`)||(a=`let ${a}`);return e.isExported&&(a+=`__as1(_${e.namespace==``?``:`.`+e.namespace}, '${e.name}', ${e.fullName});`,a+=x.EOL),r+=a,i&&(r+=x.EOL+`Object.assign(`+e.fullName+`, _n);`+x.EOL),r},h=n.compiled;n.compiled.length>0&&(n.classScript=e.fullName,n.compiled=m()),(n.docVisible.length>0||n.docInvisible.length>0)&&(n.classDoc=e.fullName);for(let t of e.decorators){let e=_n.is(t);e&&e.writeCompiled&&(n.debugTxt=h),vn.is(t)&&(n.required=!0)}}catch(e){this.printCatchError(e)}return n}static compileTsToNpm(e,t){try{if(!t.build.hasNpmOutput)return null;let n={defTs:``,namespace:``,exportPath:``,uri:t.file.uri,src:``},r=``,i=e.compiledContentNpm,a=t.build.module;if(e instanceof un&&!e.isInterface){let n=`Aventus.`;e.build.isCoreBuild&&(n=``);let i=``;if(e.namespace&&(i=`.`+e.namespace),r+=e.name+".Namespace=`"+a+i+"`;"+x.EOL,e.convertibleName){r+=e.name+`.$schema=`+this.prepareDataSchema(e,a,!0)+`;`+x.EOL;let i=t.build.getNpmReplacementName(``,n+`Converter`);r+=i+`.register(`+e.name+`.`+e.convertibleName+`, `+e.name+`);`+x.EOL,t.fileParsed&&t.fileParsed.registerGeneratedImport({uri:`@aventusjs/main/Aventus`,name:`Converter`,compiled:!0,alias:i,forced:!1})}else if(e.implements.includes(n+`IData`)){r+=e.name+`.$schema=`+this.prepareDataSchema(e,a,!0)+`;`+x.EOL;let i=t.build.getNpmReplacementName(``,n+`Converter`);r+=i+`.register(`+e.name+`.Fullname, `+e.name+`);`+x.EOL,t.fileParsed&&t.fileParsed.registerGeneratedImport({uri:`@aventusjs/main/Aventus`,name:`Converter`,compiled:!0,alias:i,forced:!1})}}else e instanceof mn&&(i=e.type+` `+e.compiledContentNpm);i=this.removeComments(i);let o=(0,p.transpile)(i,En),s=this.compileDocTs(i,e);n.namespace=t.build.module,e.namespace.length>0&&(n.namespace+=`.`+e.namespace),n.defTs=s,n.src=o+r;let c=t.file.path.replace(t.build.project.getConfigFile().path.replace(T.Config,``),``);return c=c.replace(T.Base,`.js`),n.exportPath=c,n}catch(e){this.printCatchError(e)}return null}static compileDocTs(e,t){try{let n=(0,p.createLanguageService)({getCompilationSettings:()=>({allowJs:!0,declaration:!0}),getScriptFileNames:()=>[`temp.js`],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>`1`,getScriptSnapshot:t=>{let n=e;return{getText:(e,t)=>n?.substring(e,t)||``,getLength:()=>n?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>``,readFile:(t,n)=>e,fileExists:e=>!0,directoryExists:e=>!e.startsWith(`node_modules`)}).getEmitOutput(`temp.js`,!0,!0).outputFiles[0].text.replace(/^declare /g,``);if(t instanceof un&&!t.constructorBody&&t.extraConstructorCode.length>0&&(n=n.replace(/^ *constructor\(.*\);$/gm,``)),t instanceof un&&t.isWebcomponent){let e=t.build.tsFiles[t.fileUri];if(e instanceof F){let t=RegExp(`^ *private `+e.viewMethodName+`[0-9]+?;
308
- `,`gm`);n=n.replace(t,``)}}return t?.documentation&&(n=t.documentation.fullDefinitions.join(x.EOL)+x.EOL+n),n}catch(e){this.printCatchError(e)}return``}static removeUnusedImport(e,t){try{let n=d.TextDocument.create(`temp.js`,`js`,1,e),r=(0,p.createLanguageService)({getCompilationSettings:()=>({noUnusedLocals:!0,allowNonTsExtensions:!0,allowJs:!0}),getScriptFileNames:()=>[`temp.js`],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>`1`,getScriptSnapshot:t=>{let n=e;return{getText:(e,t)=>n?.substring(e,t)||``,getLength:()=>n?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>``,readFile:(t,n)=>t==`temp.js`?e:``,fileExists:e=>!1,directoryExists:e=>!1}).getSemanticDiagnostics(`temp.js`),i=[];for(let a of r)if(a.reportsUnnecessary&&a.start!=null){let r=n.positionAt(a.start),o={line:r.line,character:0},s={line:r.line,character:6};if(e.slice(n.offsetAt(o),n.offsetAt(s))==`import`){let e=/'(\S*)'/.exec(a.messageText+``);if(e&&e[1]&&t.includes(e[1]))continue;i.push({start:a.start,length:a.length})}}i.sort((e,t)=>t.start-e.start);for(let t of i)e=e.slice(0,t.start)+e.slice(t.start+t.length);return e=e.replace(/import\s*\{[^}]*\}\s*from\s*['"][^'"]*['"];\s*/g,e=>{let t=e.replace(/(,|{)(?:\s*(\S+)\s+as\s+)(?=,|})/g,`$1`);return t=t.replace(/(,\s*)+/g,`, `).replace(/,\s*}/g,` }`).replace(/{\s*,/g,`{ `),t.match(/\{\s*\}/)?``:t}),e}catch(e){this.printCatchError(e)}return``}static getCompilerOptionsCompile(){return En}simplifyPath(e,t){if(e=decodeURIComponent(e),e.startsWith(`custom://`))return e;let n=[];n=f.sep===`/`?decodeURIComponent(t).replace(`file://`,``).split(`/`):decodeURIComponent(t).replace(`file:///`,``).split(`/`),n.pop();let r=(0,f.normalize)(n.join(`/`)).split(f.sep),i=(0,f.normalize)(n.join(`/`)+`/`+e).split(f.sep);for(let e=0;e<r.length;e++)if(i.length>e)if(r[e]==i[e])r.splice(e,1),i.splice(e,1),e--;else break;let a=``;for(let e=0;e<r.length;e++)a+=`../`;a==``&&(a+=`./`),a+=i.join(`/`);let o=(0,f.normalize)((0,f.join)(...n,a)),s=this.build.getAliases();for(let e in s){let t=s[e],n=(0,f.normalize)((0,f.join)(this.build.project.getConfigFile().folderPath,t));if(o.startsWith(n)){a=o.replace(n,e).replace(/\\/g,`/`);break}}return a}printCatchError(t){e.printCatchError(t)}static printCatchError(e){/^Debug Failure\. Expected \d+ <= \d+$/g.test(e.message)||console.error(e)}};const Tn={allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,target:p.ScriptTarget.ES2025,module:p.ModuleKind.NodeNext,moduleDetection:p.ModuleDetectionKind.Force,moduleResolution:p.ModuleResolutionKind.NodeNext,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,noUnusedLocals:!0,strictNullChecks:!0,verbatimModuleSyntax:!0,baseUrl:`./`,alwaysStrict:!1},En={allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,target:p.ScriptTarget.ES2025,module:p.ModuleKind.NodeNext,moduleDetection:p.ModuleDetectionKind.Auto,moduleResolution:p.ModuleResolutionKind.NodeNext,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,strictNullChecks:!0,verbatimModuleSyntax:!0,baseUrl:`./`,alwaysStrict:!1},Dn={includeExternalModuleExports:!0,includeInsertTextCompletions:!0,includeCompletionsWithClassMemberSnippets:!0,includeAutomaticOptionalChainCompletions:!0,includeCompletionsForImportStatements:!0,includeCompletionsForModuleExports:!0,includeCompletionsWithInsertText:!0,includeInlayEnumMemberValueHints:!0,includeInlayFunctionLikeReturnTypeHints:!0,includeInlayFunctionParameterTypeHints:!0,includeInlayParameterNameHints:`all`,includeInlayParameterNameHintsWhenArgumentMatchesName:!0,includeInlayPropertyDeclarationTypeHints:!0,useLabelDetailsInCompletionEntries:!0,importModuleSpecifierEnding:`index`,importModuleSpecifierPreference:`relative`},On={convertTabsToSpaces:!0,tabSize:4,indentSize:4,indentStyle:p.IndentStyle.Smart,newLineCharacter:`
335
+ `)}}else a=e.fullName+`=`+n.compiled,e.fullName.includes(`.`)||(a=`let ${a}`);return e.isExported&&(a+=`__as1(_${e.namespace==``?``:`.`+e.namespace}, '${e.name}', ${e.fullName});`,a+=`
336
+ `),r+=a,i&&(r+=`
337
+ Object.assign(`+e.fullName+`, _n);
338
+ `),r},h=n.compiled;n.compiled.length>0&&(n.classScript=e.fullName,n.compiled=m()),(n.docVisible.length>0||n.docInvisible.length>0)&&(n.classDoc=e.fullName);for(let t of e.decorators){let e=_n.is(t);e&&e.writeCompiled&&(n.debugTxt=h),vn.is(t)&&(n.required=!0)}}catch(e){this.printCatchError(e)}return n}static compileTsToNpm(e,t){try{if(!t.build.hasNpmOutput)return null;let n={defTs:``,namespace:``,exportPath:``,uri:t.file.uri,src:``},r=``,i=e.compiledContentNpm,a=t.build.module;if(e instanceof un&&!e.isInterface){let n=`Aventus.`;e.build.isCoreBuild&&(n=``);let i=``;if(e.namespace&&(i=`.`+e.namespace),r+=e.name+".Namespace=`"+a+i+`\`;
339
+ `,e.convertibleName){r+=e.name+`.$schema=`+this.prepareDataSchema(e,a,!0)+`;
340
+ `;let i=t.build.getNpmReplacementName(``,n+`Converter`);r+=i+`.register(`+e.name+`.`+e.convertibleName+`, `+e.name+`);
341
+ `,t.fileParsed&&t.fileParsed.registerGeneratedImport({uri:`@aventusjs/main/Aventus`,name:`Converter`,compiled:!0,alias:i,forced:!1})}else if(e.implements.includes(n+`IData`)){r+=e.name+`.$schema=`+this.prepareDataSchema(e,a,!0)+`;
342
+ `;let i=t.build.getNpmReplacementName(``,n+`Converter`);r+=i+`.register(`+e.name+`.Fullname, `+e.name+`);
343
+ `,t.fileParsed&&t.fileParsed.registerGeneratedImport({uri:`@aventusjs/main/Aventus`,name:`Converter`,compiled:!0,alias:i,forced:!1})}}else e instanceof mn&&(i=e.type+` `+e.compiledContentNpm);i=this.removeComments(i);let o=(0,p.transpile)(i,En),s=this.compileDocTs(i,e);n.namespace=t.build.module,e.namespace.length>0&&(n.namespace+=`.`+e.namespace),n.defTs=s,n.src=o+r;let c=t.file.path.replace(t.build.project.getConfigFile().path.replace(T.Config,``),``);return c=c.replace(T.Base,`.js`),n.exportPath=c,n}catch(e){this.printCatchError(e)}return null}static compileDocTs(e,t){try{let n=(0,p.createLanguageService)({getCompilationSettings:()=>({allowJs:!0,declaration:!0}),getScriptFileNames:()=>[`temp.js`],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>`1`,getScriptSnapshot:t=>{let n=e;return{getText:(e,t)=>n?.substring(e,t)||``,getLength:()=>n?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>``,readFile:(t,n)=>e,fileExists:e=>!0,directoryExists:e=>!e.startsWith(`node_modules`)}).getEmitOutput(`temp.js`,!0,!0).outputFiles[0].text.replace(/^declare /g,``);if(t instanceof un&&!t.constructorBody&&t.extraConstructorCode.length>0&&(n=n.replace(/^ *constructor\(.*\);$/gm,``)),t instanceof un&&t.isWebcomponent){let e=t.build.tsFiles[t.fileUri];if(e instanceof F){let t=RegExp(`^ *private `+e.viewMethodName+`[0-9]+?;
344
+ `,`gm`);n=n.replace(t,``)}}return t?.documentation&&(n=t.documentation.fullDefinitions.join(`
345
+ `)+`
346
+ `+n),n}catch(e){this.printCatchError(e)}return``}static removeUnusedImport(e,t){try{let n=d.TextDocument.create(`temp.js`,`js`,1,e),r=(0,p.createLanguageService)({getCompilationSettings:()=>({noUnusedLocals:!0,allowNonTsExtensions:!0,allowJs:!0}),getScriptFileNames:()=>[`temp.js`],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>`1`,getScriptSnapshot:t=>{let n=e;return{getText:(e,t)=>n?.substring(e,t)||``,getLength:()=>n?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>``,readFile:(t,n)=>t==`temp.js`?e:``,fileExists:e=>!1,directoryExists:e=>!1}).getSemanticDiagnostics(`temp.js`),i=[];for(let a of r)if(a.reportsUnnecessary&&a.start!=null){let r=n.positionAt(a.start),o={line:r.line,character:0},s={line:r.line,character:6};if(e.slice(n.offsetAt(o),n.offsetAt(s))==`import`){let e=/'(\S*)'/.exec(a.messageText+``);if(e&&e[1]&&t.includes(e[1]))continue;i.push({start:a.start,length:a.length})}}i.sort((e,t)=>t.start-e.start);for(let t of i)e=e.slice(0,t.start)+e.slice(t.start+t.length);return e=e.replace(/import\s*\{[^}]*\}\s*from\s*['"][^'"]*['"];\s*/g,e=>{let t=e.replace(/(,|{)(?:\s*(\S+)\s+as\s+)(?=,|})/g,`$1`);return t=t.replace(/(,\s*)+/g,`, `).replace(/,\s*}/g,` }`).replace(/{\s*,/g,`{ `),t.match(/\{\s*\}/)?``:t}),e}catch(e){this.printCatchError(e)}return``}static getCompilerOptionsCompile(){return En}simplifyPath(e,t){if(e=decodeURIComponent(e),e.startsWith(`custom://`))return e;let n=[];n=f.sep===`/`?decodeURIComponent(t).replace(`file://`,``).split(`/`):decodeURIComponent(t).replace(`file:///`,``).split(`/`),n.pop();let r=(0,f.normalize)(n.join(`/`)).split(f.sep),i=(0,f.normalize)(n.join(`/`)+`/`+e).split(f.sep);for(let e=0;e<r.length;e++)if(i.length>e)if(r[e]==i[e])r.splice(e,1),i.splice(e,1),e--;else break;let a=``;for(let e=0;e<r.length;e++)a+=`../`;a==``&&(a+=`./`),a+=i.join(`/`);let o=(0,f.normalize)((0,f.join)(...n,a)),s=this.build.getAliases();for(let e in s){let t=s[e],n=(0,f.normalize)((0,f.join)(this.build.project.getConfigFile().folderPath,t));if(o.startsWith(n)){a=o.replace(n,e).replace(/\\/g,`/`);break}}return a}printCatchError(t){e.printCatchError(t)}static printCatchError(e){/^Debug Failure\. Expected \d+ <= \d+$/g.test(e.message)||console.error(e)}};const Tn={allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,target:p.ScriptTarget.ES2025,module:p.ModuleKind.NodeNext,moduleDetection:p.ModuleDetectionKind.Force,moduleResolution:p.ModuleResolutionKind.NodeNext,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,noUnusedLocals:!0,strictNullChecks:!0,verbatimModuleSyntax:!0,baseUrl:`./`,alwaysStrict:!1},En={allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,target:p.ScriptTarget.ES2025,module:p.ModuleKind.NodeNext,moduleDetection:p.ModuleDetectionKind.Auto,moduleResolution:p.ModuleResolutionKind.NodeNext,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,strictNullChecks:!0,verbatimModuleSyntax:!0,baseUrl:`./`,alwaysStrict:!1},Dn={includeExternalModuleExports:!0,includeInsertTextCompletions:!0,includeCompletionsWithClassMemberSnippets:!0,includeAutomaticOptionalChainCompletions:!0,includeCompletionsForImportStatements:!0,includeCompletionsForModuleExports:!0,includeCompletionsWithInsertText:!0,includeInlayEnumMemberValueHints:!0,includeInlayFunctionLikeReturnTypeHints:!0,includeInlayFunctionParameterTypeHints:!0,includeInlayParameterNameHints:`all`,includeInlayParameterNameHintsWhenArgumentMatchesName:!0,includeInlayPropertyDeclarationTypeHints:!0,useLabelDetailsInCompletionEntries:!0,importModuleSpecifierEnding:`index`,importModuleSpecifierPreference:`relative`},On={convertTabsToSpaces:!0,tabSize:4,indentSize:4,indentStyle:p.IndentStyle.Smart,newLineCharacter:`
309
347
  `,baseIndentSize:0,insertSpaceAfterCommaDelimiter:!0,insertSpaceAfterConstructor:!1,insertSpaceAfterSemicolonInForStatements:!0,insertSpaceBeforeAndAfterBinaryOperators:!0,insertSpaceAfterKeywordsInControlFlowStatements:!1,insertSpaceAfterFunctionKeywordForAnonymousFunctions:!0,insertSpaceBeforeFunctionParenthesis:!1,insertSpaceAfterTypeAssertion:!0,placeOpenBraceOnNewLineForControlBlocks:!1,placeOpenBraceOnNewLineForFunctions:!1,semicolons:p.SemicolonPreference.Insert,insertSpaceBeforeTypeAnnotation:!1};function kn(e){switch(e){case`primitive type`:case`keyword`:return m.CompletionItemKind.Keyword;case`const`:case`let`:case`var`:case`local var`:case`alias`:case`parameter`:return m.CompletionItemKind.Variable;case`property`:case`getter`:case`setter`:return m.CompletionItemKind.Field;case`function`:case`local function`:return m.CompletionItemKind.Function;case`method`:case`construct`:case`call`:case`index`:return m.CompletionItemKind.Method;case`enum`:return m.CompletionItemKind.Enum;case`enum member`:return m.CompletionItemKind.EnumMember;case`module`:case`external module name`:return m.CompletionItemKind.Module;case`class`:case`type`:return m.CompletionItemKind.Class;case`interface`:return m.CompletionItemKind.Interface;case`warning`:return m.CompletionItemKind.Text;case`script`:return m.CompletionItemKind.File;case`directory`:return m.CompletionItemKind.Folder;case`string`:return m.CompletionItemKind.Constant;default:return m.CompletionItemKind.Property}}function An(e){return/^\s*$/.test(e)}function jn(e,t){return t.insertSpaces?Mn(` `,e*t.tabSize):Mn(` `,e)}function Mn(e,t){let n=``;for(;t>0;)(t&1)==1&&(n+=e),e+=e,t>>>=1;return n}function Nn(e,t){let n=RegExp(`//#region `+t+`(\\s|\\S)*?//#endregion`).exec(e.documentInternal.getText());return n?n.index+10+t.length:-1}var Pn=class e{removeViewVariables=[];static is(t){if(t.name==`OverrideView`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);e.removeViewVariables&&(n.removeViewVariables=e.removeViewVariables)}catch{}return n}return null}},Fn=class e{tagName=``;static is(t){if(t.name==`TagName`){let n=new e;return t.arguments.length>0&&(n.tagName=t.arguments[0].value),n}return null}},In=class e{fctTxt=null;static is(t){if(t.name==`Property`){let n=new e;if(t.arguments.length>0)try{t.arguments[0].type==`call`&&(n.fctTxt=t.arguments[0].value)}catch{}return n}return null}},Ln=class e{useLive=void 0;static is(t){if(t.name==`ViewElement`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);e.useLive===!0?n.useLive=!0:e.useLive===!1&&(n.useLive=!1)}catch{}return n}return null}},Rn=class e{stateName=``;managerName=``;functionName=`active`;static is(t){if(t.name==`StateActive`){let n=new e;if(t.arguments.length>0)try{let e=zn.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},zn=class{static parse(e){let t={stateName:``};try{let n=e.arguments[0].value;if(e.arguments[0].type==`identifier`){let t=e.arguments[0].value.split(`.`),r=e.baseInfo?.dependenciesLocations[t[0]]?.replacement;r&&(t[0]=r),n=t.join(`.`)}if(t.stateName=n,e.arguments.length>1){let n=e.arguments[1].value,r=e.baseInfo?.dependenciesLocations[n]?.replacement;r&&(n=r),t.managerName=n}}catch{}return t}},Bn=class e{stateName=``;managerName=``;functionName=`askChange`;static is(t){if(t.name==`StateChange`){let n=new e;if(t.arguments.length>0)try{let e=zn.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},Vn=class e{stateName=``;managerName=``;functionName=`inactive`;static is(t){if(t.name==`StateInactive`){let n=new e;if(t.arguments.length>0)try{let e=zn.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},Hn=class e{fctTxt=null;static is(t){if(t.name==`Watch`){let n=new e;if(t.arguments.length>0)try{t.arguments[0].type==`call`&&(n.fctTxt=t.arguments[0].value)}catch{}return n}return null}};const Un={"@press":`onPress`,"@press-start":`onPressStart`,"@press-stop":`onPressEnd`,"@longpress":`onLongPress`,"@longpress-delay":`delayLongPress`,"@dblpress":`onDblPress`,"@dblpress-delay":`delayDblPress`,"@drag":`onDrag`,"@drag-start":`onDragStart`,"@drag-end":`onDragEnd`};var Wn=class e{managerName=``;static is(t){if(t.name==`DefaultStateActive`){let n=new e;if(t.arguments.length>0)try{n.managerName=Gn.parse(t).managerName}catch{}return n}return null}},Gn=class{static parse(e){let t={managerName:``};try{let n=e.arguments[0].value,r=e.baseInfo?.dependenciesLocations[n]?.replacement;r&&(n=r),t.managerName=n}catch{}return t}},Kn=class e{managerName=``;static is(t){if(t.name==`DefaultStateInactive`){let n=new e;if(t.arguments.length>0)try{n.managerName=Gn.parse(t).managerName}catch{}return n}return null}},qn=class e{options={autoInit:!0};static is(t){if(t.name==`Effect`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);e.autoInit!==void 0&&(n.options.autoInit=e.autoInit)}catch{}return n}return null}},Jn=class e{fctTxt=null;static is(t){if(t.name==`Signal`){let n=new e;if(t.arguments.length>0)try{t.arguments[0].type==`call`&&(n.fctTxt=t.arguments[0].value)}catch{}return n}return null}},Yn=class e{static is(t){return t.name==`Injectable`?new e:null}},Xn=class{static getVersion(e,t){let n={ts:e.file.documentUser.version,scss:-1,html:-1,i18n:-1},r,i,a;return e.file.uri.endsWith(T.Component)?(r=t.wcFiles[e.file.uri].style,i=t.wcFiles[e.file.uri].view,a=t.wcFiles[e.file.uri].i18n):(r=t.scssFiles[e.file.uri.replace(T.ComponentLogic,T.ComponentStyle)],i=t.htmlFiles[e.file.uri.replace(T.ComponentLogic,T.ComponentView)],a=t.i18nComponentsFiles[e.file.uri.replace(T.ComponentLogic,T.I18n)]),r&&(n.scss=r.compiledVersion),i&&(n.html=i.compiledVersion),a&&(n.i18n=a.file.versionUser),n}file;logicalFile;scssTxt=``;template;templateHotReload;templateNpm;document;build;fileParsed;classInfo;className=``;fullName=``;tagName=``;htmlParsed;htmlParsedResult;htmlDoc;htmlFile;scssFile;allFields={};methodsName=[];listBoolProperties=[];defaultValueTxt=``;defaultValueHotReloadTxt=``;defaultValueNpmTxt=``;result={diagnostics:[],writeCompiled:!1,missingViewElements:{position:-1,elements:{}},missingMethods:{position:-1,elements:[]},componentName:``,result:[],htmlDoc:{},scssDoc:{},debug:``,needRebuild:!1};componentResult={hotReload:``,compiled:``,docVisible:``,npm:{defTs:``,namespace:``,exportPath:``,uri:``,src:``},docInvisible:``,dependencies:[],classScript:``,classDoc:``,debugTxt:``,uri:``,required:!1,type:1,isExported:{internal:!0,external:!0},convertibleName:``,tagName:``,useDecorator:!1};parentClassName=``;parentClassNameNpm=``;overrideViewDecorator=null;debuggerDecorator=null;AventusWebComponent=`Aventus.WebComponent`;AventusDefaultComponent=`Aventus.DefaultComponent`;hasStory;constructor(e,t){this.logicalFile=e,this.hasStory=t.hasStories,t.isCoreBuild&&(this.AventusDefaultComponent=`DefaultComponent`,this.AventusWebComponent=`WebComponent`);let n,r;e.file.uri.endsWith(T.Component)?(this.file=t.wcFiles[e.file.uri].logic.file,n=t.wcFiles[e.file.uri].style,r=t.wcFiles[e.file.uri].view):(this.file=e.file,n=t.scssFiles[e.file.uri.replace(T.ComponentLogic,T.ComponentStyle)],r=t.htmlFiles[e.file.uri.replace(T.ComponentLogic,T.ComponentView)]),this.scssFile=n,this.scssTxt=n?n.compileResult:``,this.htmlFile=r,this.htmlFile&&(this.htmlParsed=this.htmlFile.fileParsed,this.htmlFile.tsErrors=[]);let i=t.tsLanguageService.doValidation(this.file),a=this.logicalFile.viewMethodName;for(let e=0;e<i.length;e++)i[e].message.startsWith(`'`+a)&&(i.splice(e,1),e--);this.result.diagnostics=i,this.template=gn(),this.templateHotReload=gn(),t.hasNpmOutput&&(this.templateNpm=gn()),this.document=e.file.documentInternal,this.build=t,this.fileParsed=e.fileParsed}compile(){if(this.fileParsed){for(let e in this.fileParsed.aliases)this.result.result.push(wn.compileTs(this.fileParsed.aliases[e],this.logicalFile));for(let e in this.fileParsed.enums)this.result.result.push(wn.compileTs(this.fileParsed.enums[e],this.logicalFile));for(let e in this.fileParsed.classes){let t=this.fileParsed.classes[e];if(this.isComponentClassInfo(t))if(this.classInfo!=null){let e=`Only one class is allowed inside a file. Get `+t.name+` and `+this.classInfo.name;this.result.diagnostics.push(k(this.document,e,t.nameStart,t.nameEnd,1003)),this.result.diagnostics.push(k(this.document,e,this.classInfo.nameStart,this.classInfo.nameEnd,1003))}else this.classInfo=t;else this.result.result.push(wn.compileTs(t,this.logicalFile))}}if(this.classInfo){this.logicalFile.build.addNamespace(this.classInfo.namespace),this.compileComponentClassInfo(),this.result.htmlDoc=this.htmlDoc??{},this.result.scssDoc=this.prepareDocSCSS(),this.result.componentName=this.className,this.result.writeCompiled=this.debuggerDecorator!==null&&this.debuggerDecorator.writeCompiled;for(let e of this.result.result)e.debugTxt&&(this.result.debug+=e.debugTxt+x.EOL);if(this.htmlParsed&&this.hasStory&&this.classInfo.storieContent){let e=this.classInfo.storieContent;delete e.slots;let t=[];this.classInfo.storieDecorator?.slots?.inject&&this.classInfo.storieDecorator.slots.inject;for(let e in this.htmlParsed.slotsInfo){let n={name:e};this.storyArgTypes[`@`+e]={control:`text`,table:{category:`Slot`}},this.classInfo.documentation?.documentationSlots[e]&&(n.documentation=this.classInfo.documentation.documentationSlots[e],this.storyArgTypes[`@`+e].description=n.documentation),this.classInfo.storieDecorator?.slots?.values&&this.classInfo.storieDecorator.slots.values[e]?this.storyArgs[`@`+e]=this.classInfo.storieDecorator.slots.values[e]:this.storyArgs[`@`+e]=``,t.push(n)}this.classInfo.loadStoryBookInject(),t.length>0&&(e.slots=t)}}else this.result.diagnostics.push(ke(this.document,`Can't found a web component class to compile inside`,1002));return this.result}isComponentClassInfo(e){return e instanceof un&&e.isWebcomponent}compileComponentClassInfo(){if(this.classInfo){this.prepareComponentClassInfo(this.classInfo);let e=wn.compileTs(this.classInfo,this.logicalFile);this.componentResult.classScript=e.classScript,this.componentResult.classDoc=e.classDoc,this.componentResult.dependencies=e.dependencies,this.componentResult.docInvisible=e.docInvisible,this.componentResult.docVisible=e.docVisible,this.componentResult.npm=e.npm,this.componentResult.type=e.type,this.componentResult.isExported=e.isExported,this.componentResult.uri=e.uri,this.prepareHTMLDocObject(),this.loadParent(this.classInfo),this.addViewElementToDependency(),this.writeFile(),!this.classInfo.isAbstract&&!this.classInfo.isInterface&&(this.componentResult.tagName=this.tagName),this.componentResult.slots=this.htmlFile?.slotsInfo,this.componentResult.compiled=this.template.replace(`//todelete for hmr °`,``),this.componentResult.npm.src=this.templateNpm?.replace(`//todelete for hmr °`,``)??``,yt.isRunning&&(this.componentResult.hotReload=this.templateHotReload.split(`//todelete for hmr °`)[0],this.componentResult.hotReload=this.componentResult.hotReload.slice(this.componentResult.hotReload.indexOf(`=`)+1)),this.debuggerDecorator&&this.debuggerDecorator.writeCompiled&&(this.componentResult.debugTxt=this.componentResult.compiled),this.result.result.push(this.componentResult)}}prepareComponentClassInfo(e){for(let t of e.decorators){let e=Pn.is(t);if(e){this.overrideViewDecorator=e;continue}let n=_n.is(t);if(n){this.debuggerDecorator=n;continue}let r=Fn.is(t);if(r&&r.tagName){r.tagName.indexOf(`-`)==-1||r.tagName.toLowerCase()!=r.tagName?this.result.diagnostics.push(k(this.document,`tag name must be in lower case and have a - inside`,t.contentStart,t.contentEnd,1004)):this.tagName=r.tagName;continue}vn.is(t)&&(this.componentResult.required=!0)}if(e.extends.length>0&&e.extends[0]==this.AventusWebComponent&&(this.overrideViewDecorator=new Pn),this.getClassName(e),this.htmlParsed){let e=this.className.toLowerCase(),t=[],n=null,r=this.classInfo?.parentClass;for(;r;){let i=r.name.toLowerCase();if(t.push(i),n==null&&t.includes(e)&&(n=e+`1`),n&&t.includes(n)){let r=1;for(;t.includes(n);)r++,n=e+r}r=r.parentClass}n&&this.htmlParsed.replaceId(n),this.htmlParsedResult=this.htmlParsed.getParsedInfo(this.className)}}prepareHTMLDocObject(){this.classInfo&&!this.classInfo.isAbstract&&(this.htmlDoc={[this.tagName]:{class:this.classInfo.fullName,name:this.tagName,description:this.classInfo.documentation?.fullDefinitions.join(x.EOL)??``,attributes:{}}})}getClassName(e){let t=e.name.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g);if(t){let n=this.build.getComponentPrefix().split(`-`);for(let e=0;e<n.length;e++){let r=n[e];if(r.length>0&&t[e].toLowerCase()!=r.toLowerCase()){t.splice(0,0,n.join(`-`).toLowerCase());break}}this.tagName==``&&(this.tagName=t.join(`-`).toLowerCase()),this.className=e.name,this.fullName=e.fullName,this.parentClassName=`Aventus.WebComponent`,this.parentClassNameNpm=this.build.getNpmReplacementName([this.build.module,this.fullName].join(`.`),`Aventus.WebComponent`),e.extends.length>0&&e.extends[0]&&(this.parentClassName=e.extends[0],this.parentClassNameNpm=e.extendsNpm[0])}}loadParent(e,t=!0){let n=this.loadFields(e,t);this.allFields={...n,...this.allFields};for(let t in e.methods)this.methodsName.includes(t)||this.methodsName.push(t);if(e.extends.length>0&&e.extends[0]!=this.AventusWebComponent){let t=e.parentClass;t?this.loadParent(t,!1):this.classInfo&&this.result.diagnostics.push(k(this.document,`can't found the path for parent `+e.extends[0],this.classInfo.nameStart,this.classInfo.nameEnd,1007))}}loadFields(e,t){let n={};for(let r in e.properties){let i=e.properties[r];if(this.allFields[i.name])continue;let a=!1,o=new ln(i.prop,i.isInsideInterface,e);for(let e of i.decorators)if([`Attribute`,`Property`,`Watch`,`Signal`,`ViewElement`].includes(e.name)&&(o.propType=e.name,a=!0),a){n[i.name]=o,o.inParent=!t;break}a||(o.propType=`Simple`,o.inParent=!t,n[r]=o)}return n}addViewElementToDependency(){if(this.htmlParsed&&this.htmlFile&&this.classInfo){this.logicalFile.resetViewClassInfoDep();let e=[],t={};for(let n of this.htmlParsed.interestPoints)if(n.type==`tag`){if(e.includes(n.name)||(e.push(n.name),this.classInfo.addDependencyTag(n.name,this.componentResult)),!t.hasOwnProperty(n.name)){let e=this.build.getWebComponentDefinitionFile(n.name);e instanceof F?t[n.name]=e:(this.build.htmlLanguageService.getInternalTagUri(n.name)&&(this.result.needRebuild=!0),t[n.name]=null)}let r=t[n.name];r&&this.logicalFile.addViewClassInfoDep(r,n.start,n.end)}}}writeFile(){this.writeFileName(),this.writeFileTemplateHtml(),this.writeFileReplaceVar(`style`,this.scssTxt),this.writeFileHotReloadReplaceVar(`style`,this.scssTxt),this.writeFileNpmReplaceVar(`style`,this.scssTxt),this.writeFileFields(),this.writeFileMethods(),this.writeWatchableElements(),this.writeFileConstructor(),this.template=this.template.replace(/\|\!\*(.*?)\*\!\|/g,`{{$1}}`),this.template=this.removeWhiteSpaceLines(this.template),this.templateHotReload=this.templateHotReload.replace(/\|\!\*(.*?)\*\!\|/g,`{{$1}}`),this.templateHotReload=this.removeWhiteSpaceLines(this.templateHotReload),this.templateNpm&&=(this.templateNpm=this.templateNpm.replace(/\|\!\*(.*?)\*\!\|/g,`{{$1}}`),this.removeWhiteSpaceLines(this.templateNpm))}writeFileName(){this.writeFileReplaceVar(`classname`,this.className),this.writeFileHotReloadReplaceVar(`classname`,this.className),this.writeFileNpmReplaceVar(`classname`,this.className),this.writeFileReplaceVar(`parentClass`,this.parentClassName),this.writeFileHotReloadReplaceVar(`parentClass`,this.parentClassName),this.writeFileNpmReplaceVar(`parentClass`,this.parentClassNameNpm);let e=this.build.module;if(this.fullName.includes(`.`)){this.writeFileReplaceVar(`fullname`,this.fullName),this.writeFileHotReloadReplaceVar(`fullname`,this.fullName),this.writeFileNpmReplaceVar(`fullname`,`const `+this.className);let t=`.`+this.classInfo?.namespace;this.writeFileReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+t+"`;"),this.writeFileHotReloadReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+t+"`;"),this.writeFileNpmReplaceVar(`namespace`,this.className+".Namespace=`"+e+t+"`;")}else this.writeFileReplaceVar(`fullname`,`const `+this.fullName),this.writeFileHotReloadReplaceVar(`fullname`,`const `+this.fullName),this.writeFileNpmReplaceVar(`fullname`,`const `+this.fullName),this.writeFileReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+"`;"),this.writeFileHotReloadReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+"`;"),this.writeFileNpmReplaceVar(`namespace`,this.className+".Namespace=`"+e+"`;");if(this.classInfo?.isAbstract?(this.writeFileReplaceVar(`tag`,``),this.writeFileHotReloadReplaceVar(`tag`,``),this.writeFileNpmReplaceVar(`tag`,``)):(this.writeFileReplaceVar(`tag`,this.fullName+".Tag=`"+this.tagName+"`;"),this.writeFileHotReloadReplaceVar(`tag`,this.fullName+".Tag=`"+this.tagName+"`;"),this.writeFileNpmReplaceVar(`tag`,this.className+".Tag=`"+this.tagName+"`;")),this.build.namespaces.includes(this.fullName)?(this.writeFileReplaceVar(`namespaceStart`,`_n = `+this.fullName+`;`+x.EOL),this.writeFileHotReloadReplaceVar(`namespaceStart`,`_n = `+this.fullName+`;`+x.EOL),this.writeFileNpmReplaceVar(`namespaceStart`,`_n = `+this.fullName+`;`+x.EOL),this.writeFileReplaceVar(`namespaceEnd`,x.EOL+`Object.assign(`+this.fullName+`, _n);`+x.EOL),this.writeFileHotReloadReplaceVar(`namespaceEnd`,x.EOL+`Object.assign(`+this.fullName+`, _n);`+x.EOL),this.writeFileNpmReplaceVar(`namespaceEnd`,x.EOL+`Object.assign(`+this.fullName+`, _n);`+x.EOL)):(this.writeFileReplaceVar(`namespaceStart`,``),this.writeFileHotReloadReplaceVar(`namespaceStart`,``),this.writeFileNpmReplaceVar(`namespaceStart`,``),this.writeFileReplaceVar(`namespaceEnd`,``),this.writeFileHotReloadReplaceVar(`namespaceEnd`,``),this.writeFileNpmReplaceVar(`namespaceEnd`,``)),this.classInfo?.isExported){let e=`__as1(_${this.classInfo.namespace==``?``:`.`+this.classInfo.namespace}, '${this.classInfo.name}', ${this.fullName});`;this.writeFileReplaceVar(`exported`,e),this.writeFileHotReloadReplaceVar(`exported`,`_.`+this.fullName+`=`+this.fullName+`;`)}else this.writeFileReplaceVar(`exported`,``),this.writeFileHotReloadReplaceVar(`exported`,``);if(this.writeFileNpmReplaceVar(`exported`,``),this.classInfo?.isAbstract)this.writeFileReplaceVar(`definition`,``),this.writeFileHotReloadReplaceVar(`definition`,``),this.writeFileNpmReplaceVar(`definition`,``),this.writeFileReplaceVar(`customImport`,``),this.writeFileHotReloadReplaceVar(`customImport`,``),this.writeFileNpmReplaceVar(`customImport`,``);else{let e=this.build.isCoreBuild?``:`Aventus.`;if(this.writeFileReplaceVar(`definition`,`if(!window.customElements.get('`+this.tagName+`')){window.customElements.define('`+this.tagName+`', `+this.fullName+`);`+e+`WebComponentInstance.registerDefinition(`+this.fullName+`);}`),this.writeFileHotReloadReplaceVar(`definition`,`if(!window.customElements.get('`+this.tagName+`')){window.customElements.define('`+this.tagName+`', `+this.fullName+`);`+e+`WebComponentInstance.registerDefinition(`+this.fullName+`);}`),this.templateNpm&&this.fileParsed){let e=this.build.getNpmReplacementName(``,`Aventus.WebComponentInstance`);this.writeFileNpmReplaceVar(`definition`,`if(!window.customElements.get('`+this.tagName+`')){window.customElements.define('`+this.tagName+`', `+this.className+`);`+e+`.registerDefinition(`+this.className+`);}`),this.fileParsed.registerGeneratedImport({uri:`@aventusjs/main/Aventus`,name:`WebComponentInstance`,compiled:!0,alias:e,forced:!1})}}}writeFileTemplateHtml(){let e=``;if(this.htmlParsed){let t=this.htmlParsed.getSlotsInfoTxt(),n=this.htmlParsed.getBlocksInfoTxt();if(t.length+n.length>0){let r=x.EOL+`super.__getHtml();`,i=``,a=``;t.length>0&&(i=`slots: { ${t} },`),n.length>0&&(a=`blocks: { ${n} }`),this.overrideViewDecorator&&(r=``),e=`__getHtml() {${r}
310
348
  this.__getStatic().__template.setHTML({
311
349
  ${i}
@@ -388,7 +426,16 @@ this.clearWatchHistory = () => {
388
426
  `;let n=e.keys.map(e=>`"${e.replace(/"/g,`\\"`)}": string`).join(`,\r
389
427
  `);c+=`\ntype ${this.componentClassName}__Generated = {
390
428
  ${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,`&#123;&#123;$1&#125;&#125;`),t=t.replace(/\\if/g,`&#105;f`),t=t.replace(/\\else/g,`&#101;lse`),t=t.replace(/\\for/g,`&#102;or`),t=t.replace(/\\@Context/g,`&#64;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(`
429
+ }`})(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()
430
+ protected `+t+`!: `+this.compilationResult.missingViewElements.elements[t]+`;
431
+ `}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+=`/**
432
+ *
433
+ */
434
+ protected ${t}(){
435
+ throw new Error("Method not implemented.");
436
+ }
437
+ `}return e!=``&&(e=`
438
+ `+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,`&#123;&#123;$1&#125;&#125;`),t=t.replace(/\\if/g,`&#105;f`),t=t.replace(/\\else/g,`&#101;lse`),t=t.replace(/\\for/g,`&#102;or`),t=t.replace(/\\@Context/g,`&#64;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
439
  `)&&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
440
  `))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
441
  `))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(`
@@ -424,13 +471,32 @@ this.clearWatchHistory = () => {
424
471
  \${1}
425
472
  }`,"@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
473
  `)??``}};{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,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/\|/g,`&vert;`),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?`&lt;${e.tagName}&gt;&lt;/${e.tagName}&gt;`: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),(t+``).includes(`Error: invalid signature: 0x4f44213c`)&&console.log((0,u.readFileSync)(e,`utf8`)),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
- `),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
- ${this.npmDepBuildTxt.result+x.EOL}
474
+ `)[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,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/\|/g,`&vert;`),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(`
475
+ `)??``,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?`&lt;${e.tagName}&gt;&lt;/${e.tagName}&gt;`:void 0,type:t.isInterface?`Interface`:`Class`,description:t.documentation?.definitions.join(`
476
+ `)??``,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(`
477
+ `)??``,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(`
478
+ `)??``,isAbstract:e.isAbstract}}getContent(){return this.content.join(`
479
+ `)}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),(t+``).includes(`Error: invalid signature: 0x4f44213c`)&&console.log((0,u.readFileSync)(e,`utf8`)),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(`
480
+ `),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;
481
+ `,this.npmBuildTxt+=`(npmCompilation||(npmCompilation = {}));
482
+ `,this.npmBuildTxt+=`(function (npmCompilation) {
483
+ ${this.npmDepBuildTxt.result+`
484
+ `}
430
485
  ${t.toExport}
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(`
486
+ })(npmCompilation);
487
+ `}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}'] = {};
488
+ `,r.all){e+=`import * as ${r.all.internalAlias} from "${i}";
489
+ `,n.push(r.all.internalAlias);for(let e of r.all.externalAlias)t+=`npmCompilation['${r.md5}']['${e}'] = _.default['${r.all.internalAlias}'];
490
+ `;for(let e in r.part)for(let n of r.part[e].externalAlias)t+=`npmCompilation['${r.md5}']['${n}'] = _.default['${r.all.internalAlias}'];
491
+ `}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}'];
492
+ `}e+=`import {${Object.values(a).join(`, `)}} from "${i}";
493
+ `}}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=`
494
+ `+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
495
  `).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>([\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(`
496
+ `+a(1))),t.firstLast&&(n.newText=n.newText.trim(),n.range.start.character==0&&n.range.start.line==0&&(n.newText=t.tab?`
497
+ `+a(1)+n.newText:`
498
+ `+n.newText),e.file.file.documentInternal.offsetAt(n.range.end)==e.file.file.documentInternal.getText().length&&(n.newText+=`
499
+ `)),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
500
  `)),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
501
  `)),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
502
  `)),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(`
@@ -771,7 +837,17 @@ var n;return t=[ss((n=t)[0]),ss(n[1]),ss(n[2])],t=_o(cs,t),t=xo(t),t}function As
771
837
  </style>
772
838
  `,_=d.TextDocument.create(o+T.Component,w.WebComponent,s+1,g);(0,u.writeFileSync)(O(_.uri),g),f&&((0,u.unlinkSync)(f.path),R.getInstance().onClose(f.documentUser),gd.send(f.uri)),c&&((0,u.unlinkSync)(c.path),R.getInstance().onClose(c.documentUser),gd.send(c.uri)),m&&((0,u.unlinkSync)(m.path),R.getInstance().onClose(m.documentUser),gd.send(m.uri)),(0,u.rmdirSync)(O(r.join(`/`)+`/`+a)),R.getInstance().registerFile(_),ld.send(_.uri)}};function vd(e){return e.split(`
773
839
  `).join(`
774
- `)}var yd=class{static cmd=`aventus.component.split`;static async run(e){if(!e)return;let t=e.split(`/`).pop()?.replace(T.Component,``),n=R.getInstance().getByUri(e);if(n){let r=O(e.replace(T.Component,``));(0,u.existsSync)(r)||(0,u.mkdirSync)(r);let i=e.replace(T.Component,``)+`/`+t,a=Vi.getRegion(n),o=i+T.ComponentStyle,s=d.TextDocument.create(o,w.SCSS,n.versionUser+1,a.cssText??``);(0,u.writeFileSync)(O(o),s.getText());let c=i+T.ComponentView,l=d.TextDocument.create(c,w.HTML,n.versionUser+1,a.htmlText??``);(0,u.writeFileSync)(O(c),l.getText());let f=i+T.ComponentLogic,p=d.TextDocument.create(f,w.TypeScript,n.versionUser+1,a.scriptText??``);(0,u.writeFileSync)(O(f),p.getText()),(0,u.unlinkSync)(n.path),R.getInstance().onClose(n.documentUser),gd.send(n.uri),R.getInstance().registerFile(s),R.getInstance().registerFile(l),R.getInstance().registerFile(p),ld.send(p.uri)}}},bd=class{static cmd=`aventus.liveserver.start`;static run(){yt.getInstance().start()}},xd=class{static cmd=`aventus.liveserver.toggle`;static run(){yt.getInstance().toggle()}},Sd=class{static cmd=`aventus.static`;static async run(){let e=[],t=L.getInstance().getAllStatics();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{placeHolder:`Static to export`});if(n){let e=n.detail??``,t=n.label;await L.getInstance().getProjectByUri(e)?.getStatic(t)?.export()}}},Cd=class{static cmd=`aventus.liveserver.stop`;static run(){yt.getInstance().stop()}},wd=class{static send(e,t){$.sendNotification(`aventus/editFile`,{uri:e,transformations:t})}},Td=class e{static cmd=`aventus.wc.create.attribute`;static attrType=[{label:`Number`,detail:`number`},{label:`String`,detail:`string`},{label:`Boolean`,detail:`boolean`},{label:`Date`,detail:`Date`},{label:`Datetime`,detail:`Datetime`},{label:`Custom`,detail:``}];static async run(t,n){if(!t||typeof n!=`number`)return;let r=await $.Input({title:`Provide a name for your Attribute`,validations:[{message:`A property must be with lowercase, number or _`,regex:`^[_a-z0-9]+$`}]});if(!r)return;let i=await $.Select(e.attrType,{placeHolder:`Choose a type?`});if(!i)return;Ee(e.attrType,i);let a=i.detail,o=R.getInstance().getByUri(t);if(o){let e=`?`;(a==`boolean`||a==`number`)&&(e=`!`);let i=o.documentUser.positionAt(o.contentUser.length),s=`@Attribute()`+x.EOL+`public `+r+e+`:`+a+`;`+x.EOL,c=o.contentUser.slice(0,n),l=o.contentUser.slice(n+1,o.contentUser.length),u=c+s+l,f=d.TextDocument.create(o.uri,w.TypeScript,o.versionUser+1,u);await o.triggerContentChange(f);let p=await o.getFormatting({insertSpaces:!0,tabSize:4});await o.applyTextEdits(p);let m=[{newText:o.contentUser,range:{start:{character:0,line:0},end:i}}];wd.send(t,[m])}}},Ed=class e{static cmd=`aventus.wc.create.property`;static attrType=[{label:`Number`,detail:`number`},{label:`String`,detail:`string`},{label:`Boolean`,detail:`boolean`},{label:`Date`,detail:`Date`},{label:`Datetime`,detail:`Datetime`},{label:`Custom`,detail:``}];static async run(t,n,r){if(!t||typeof n!=`number`)return;let i=await $.Input({title:`Provide a name for your Property`,validations:[{message:`A property must be with lowercase, number or _`,regex:`^[_a-z0-9]+$`}],value:r});if(!i)return;let a=await $.Select(e.attrType,{placeHolder:`Choose a type?`});if(!a)return;Ee(e.attrType,a);let o=a.detail,s=await $.Select([{label:`Yes`},{label:`No`}],{placeHolder:`Do you need a callback function?`});if(!s)return;let c=s.label==`Yes`,l=R.getInstance().getByUri(t);if(l){let e=l.documentUser.positionAt(l.contentUser.length),r=R.getInstance().getBuild(l.documentUser),a=``;if(r&&r.length>0){let e=r[0].tsFiles[t];e instanceof F&&(a=e.getComponentName())}if(a==``)return;let s=``;c&&(s=`(target: `+a+`) => {`+x.EOL+x.EOL+`}`);let u=`?`;(o==`boolean`||o==`number`)&&(u=`!`);let f=`@Property(`+s+`)`+x.EOL+`public `+i+u+`:`+o+`;`+x.EOL,p=l.contentUser.slice(0,n),m=l.contentUser.slice(n+1,l.contentUser.length),h=p+f+m,g=d.TextDocument.create(l.uri,w.TypeScript,l.versionUser+1,h);await l.triggerContentChange(g);let _=await l.getFormatting({insertSpaces:!0,tabSize:4});await l.applyTextEdits(_);let v=[{newText:l.contentUser,range:{start:l.documentUser.positionAt(0),end:e}}];wd.send(t,[v])}}},Dd=class{static cmd=`aventus.wc.create.watch`;static async run(e,t,n){if(!e||typeof t!=`number`)return;let r=await $.Input({title:`Provide a name for your Watch variable`,value:n});if(!r)return;let i=await $.Input({title:`Provide a type for your Watch`});if(!i)return;let a=await $.Select([{label:`Yes`},{label:`No`}],{placeHolder:`Do you need a callback function?`});if(!a)return;let o=a.label==`Yes`,s=R.getInstance().getByUri(e);if(s){let n=s.documentUser.positionAt(s.contentUser.length),a=R.getInstance().getBuild(s.documentUser),c=``;if(a&&a.length>0){let t=a[0].tsFiles[e];t instanceof F&&(c=t.getComponentName())}if(c==``)return;let l=``;if(o){let e=`Aventus.`;a&&a.length>0&&a[0].isCoreBuild&&(e=``),l=`(target: `+c+`, action: `+e+`WatchAction, path: string, value: any) => {`+x.EOL+x.EOL+`}`}let u=`@Watch(`+l+`)`+x.EOL+`public `+r+`?:`+i+`;`+x.EOL,f=s.contentUser.slice(0,t),p=s.contentUser.slice(t+1,s.contentUser.length),m=f+u+p,h=d.TextDocument.create(s.uri,w.TypeScript,s.versionUser+1,m);await s.triggerContentChange(h);let g=await s.getFormatting({insertSpaces:!0,tabSize:4});await s.applyTextEdits(g);let _=[{newText:s.contentUser,range:{start:s.documentUser.positionAt(0),end:n}}];wd.send(e,[_])}}},Od=class{static cmd=`aventus.wc.import.viewElement`;static async run(e,t){let n=R.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=R.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof F){let i=a.getMissingVariablesInfo();if(t==-1&&(t=i.start),t==-1)return;if(i.text!=``){let a=n.contentUser.slice(0,t),o=n.contentUser.slice(t+1,n.contentUser.length),s=a+i.text+o,c=d.TextDocument.create(n.uri,w.TypeScript,n.versionUser+1,s);await n.triggerContentChange(c);let l=await n.getFormatting({insertSpaces:!0,tabSize:4});await n.applyTextEdits(l);let u=[{newText:n.contentUser,range:{start:n.documentUser.positionAt(0),end:r}}];wd.send(e,[u])}}}}}},kd=class{static cmd=`aventus.wc.import.viewMethod`;static async run(e,t){let n=R.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=R.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof F){let i=a.getMissingMethodsInfo();if(t==-1&&(t=i.start),t==-1)return;if(i.text!=``){let a=n.contentUser.slice(0,t),o=n.contentUser.slice(t+1,n.contentUser.length),s=a+i.text+o,c=d.TextDocument.create(n.uri,w.TypeScript,n.versionUser+1,s);await n.triggerContentChange(c);let l=await n.getFormatting({insertSpaces:!0,tabSize:4});await n.applyTextEdits(l);let u=[{newText:n.contentUser,range:{start:n.documentUser.positionAt(0),end:r}}];wd.send(e,[u])}}}}}},Ad=class{static cmd=`aventus.rename`;static async run(e){if(!E.getInstance().settings.updateImportOnRename||!e)return;let t=[];for(let n of e){let e=n.newUri,r=n.oldUri,i=O(e),a=O(r),o,s=!0;if((0,u.existsSync)(i)?o=i:(s=!1,o=a),(0,u.statSync)(o).isDirectory()){let n=i=>{let a=(0,u.readdirSync)(i);for(let o of a){let a=(0,f.join)(i,o);if((0,u.statSync)(a).isDirectory())n(a);else{let n=D(a);s?t.push({newUri:n,oldUri:n.replace(e,r)}):t.push({newUri:n.replace(r,e),oldUri:n})}}};n(o)}else t.push({oldUri:r,newUri:e})}let n=await L.getInstance().onRename(t),r={},i=R.getInstance();for(let e in n){let t=i.getByUri(e);t&&(await t.applyTextEdits(n[e]),r[O(t.uri)]=t.contentUser)}setTimeout(()=>{for(let e in r)(0,u.writeFileSync)(e,r[e])},500)}},jd=class{static cmd=`aventus.component.rename`;static async run(e){if(!e)return;e=e.toString().replace(/\.wcv\.avt$/,`.wcl.avt`).replace(/\.wcs\.avt$/,`.wcl.avt`);let t=e.split(`/`),n=t[t.length-1].replace(`.wcl.avt`,``),r=await $.Input({title:`New name`,value:n,validations:[{message:`Your name isn't valid`,regex:`^[_A-Za-z0-9-]+$`}]});if(!r)return;let i=R.getInstance().getByUri(e);if(i&&i instanceof j){let e=R.getInstance(),t=i.documentUser.uri.split(`/`),n=t[t.length-1].replace(T.ComponentLogic,``),a=Be(n),o=i.folderUri,s=o.replace(RegExp(a+`$`),r),c=RegExp(`(class +)`+a+` `).exec(i.contentUser),l={};if(c){let t=c.index+c[1].length,n=i.documentUser.positionAt(t),a=await i.getRename(n,r);if(a&&a.changes)for(let t in a.changes){if(!l[t]){let n=e.getByUri(t);if(!n)continue;l[t]=n}let n=a.changes[t];await l[t].applyTextEdits(n)}}let f=[],p=e=>{let t=o+`/`+n+e;if((0,u.existsSync)(O(t))){let n=s+`/`+r+e;f.push({oldUri:t,newUri:n})}};p(T.ComponentLogic),p(T.ComponentStyle),p(T.ComponentView);let m=await L.getInstance().onRename(f);for(let t in m){if(!l[t]){let n=e.getByUri(t);if(!n)continue;l[t]=n}await l[t].applyTextEdits(m[t])}setTimeout(()=>{for(let e in l)(0,u.writeFileSync)(O(e),l[e].contentUser);(0,u.mkdirSync)(O(s));for(let t of f){let n=t.oldUri,r=t.newUri;(0,u.renameSync)(O(n),O(r)),gd.send(n);let i=e.getByUri(n);i&&(e.registerFile(d.TextDocument.create(r,De(r),1,i.contentUser)),e.onClose(i?.documentUser))}let t=O(o),n=(0,u.readdirSync)(t);n.length==0?(0,u.rmdirSync)(t):n.length==1&&n[0].endsWith(`.js`)&&(0,u.rmSync)(t,{recursive:!0,force:!0})},500)}}},Md=class{static cmd=`aventus.filesystem.openAventus`;static async run(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e);let t;switch((0,x.platform)()){case`win32`:t=`explorer`;break;case`linux`:t=`xdg-open`;break;case`darwin`:t=`open`;break}(0,g.spawn)(t,[e],{detached:!0}).unref()}},Nd=class{static waitingResponse={};static send(e,...t){return new Promise(n=>{let r=A();for(;this.waitingResponse[r]!=null;)r=A();this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/popup`,r,e,t)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Pd=class{static cmd=`aventus.popupresponse`;static run(e,t){Nd.resolve(e,t)}},Fd=class{static waitingResponse={};static send(e){return new Promise(t=>{let n=A();for(;this.waitingResponse[n]!=null;)n=A();this.waitingResponse[n]=e=>{t(e)},$.sendNotification(`aventus/askinput`,n,e)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Id=class{static cmd=`aventus.receiveinput`;static run(e,t){Fd.resolve(e,t)}},Ld=class{static waitingResponse={};static waitingOptions={};static send(e,t){return new Promise(n=>{let r=A();for(;this.waitingResponse[r]!=null;)r=A();this.waitingOptions[r]=e,this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/askselect`,r,e,t)})}static resolve(e,t){if(this.waitingResponse[e]){if(t)for(let n of this.waitingOptions[e])n.label==t.label&&(t=n);this.waitingResponse[e](t),delete this.waitingResponse[e],delete this.waitingOptions[e]}}},Rd=class{static cmd=`aventus.receiveselect`;static run(e,t){Ld.resolve(e,t)}},zd=class{static waitingResponse={};static send(e,t){return new Promise(n=>{let r=A();for(;this.waitingResponse[r]!=null;)r=A();this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/askselectmultiple`,r,e,t)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Bd=class{static cmd=`aventus.receiveselectmultiple`;static run(e,t){zd.resolve(e,t)}},Vd=class{static cmd=`aventus.template.import`;static async run(){await $.templateManager?.selectTemplateToImport()}},Hd=o(((e,t)=>{var n=require("child_process").exec,r=require("child_process").execSync,i=require("fs"),a=require("path"),o=i.access,s=i.accessSync,c=i.constants||i,l=process.platform==`win32`,u=function(e,t){o(e,c.F_OK,function(e){t(!e)})},d=function(e){try{return s(e,c.F_OK),!1}catch{return!0}},f=function(e,t){o(e,c.F_OK|c.X_OK,function(e){t(null,!e)})},p=function(e){try{return s(e,c.F_OK|c.X_OK),!0}catch{return!1}},m=function(e,t,r){u(e,function(i){if(!i){n(`command -v `+t+` 2>/dev/null && { echo >&1 `+t+`; exit 0; }`,function(e,t,n){r(null,!!t)});return}f(e,r)})},h=function(e,t,r){if(!/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(e)){r(null,!1);return}n(`where `+t,function(e){e===null?r(null,!0):r(null,!1)})},g=function(e,t){if(d(e))try{return!!r(`command -v `+t+` 2>/dev/null && { echo >&1 `+t+`; exit 0; }`)}catch{return!1}return p(e)},_=function(e,t,n){if(!/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(e))return!1;try{return!!r(`where `+t,{stdio:[]})}catch{return!1}},v=function(e){return/[^A-Za-z0-9_\/:=-]/.test(e)&&(e=`'`+e.replace(/'/g,`'\\''`)+`'`,e=e.replace(/^(?:'')+/g,``).replace(/\\'''/g,`\\'`)),e};l&&(v=function(e){if(/[\\]/.test(e)){var t=`"`+a.dirname(e)+`"`,n=`"`+a.basename(e)+`"`;return t+`:`+n}return`"`+e+`"`}),t.exports=function e(t,n){var r=v(t);if(!n&&typeof Promise<`u`)return new Promise(function(n,r){e(t,function(e,i){i?n(t):r(e)})});l?h(t,r,n):m(t,r,n)},t.exports.sync=function(e){var t=v(e);return l?_(e,t):g(e,t)}})),Ud=o(((e,t)=>{t.exports=Hd()}))(),Wd=class{static send(e,t,n){$.sendNotification(`aventus/sharp/compiling`,e,t,n)}},Gd=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}files={};onNewFileUUID;onFileRemoveUUID;constructor(){this.onNewFile=this.onNewFile.bind(this),this.onFileRemove=this.onFileRemove.bind(this),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=R.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(T.CsharpConfig)&&(this.files[e.uri]=new Kd(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},Kd=class{_file;get file(){return this._file}constructor(e){this._file=e,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 onContentChange(){}async onValidate(){return ot.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return ot.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return ot.getInstance().doResolve(t)}async onHover(e,t){return ot.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return ot.getInstance().format(e,t,n)}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}},qd=class{static cmd=`aventus.sharp.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Ud.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}if(!(0,Ud.sync)(`csharp-converter`))try{if(await $.ask(`csharp-converter is missing. Can I install it?`)&&await Ce(`dotnet tool install --global AventusSharp.Converter`),!(0,Ud.sync)(`csharp-converter`)){$.showErrorMessage(`Can't find the converter. Run the command : dotnet tool install --global AventusSharp.Converter`);return}}catch(e){$.showErrorMessage(e+``);return}if(!e||!e.endsWith(T.CsharpConfig)){let t=Object.keys(Gd.getInstance().files);if(t.length==1)e=t[0];else if(t.length>1){let n=[];for(let e of t)n.push({label:e});let r=await $.Select(n,{placeHolder:`Project to compile`});if(r)e=r.label;else return}else{$.showErrorMessage(`No aventus.sharp.avt found`);return}}let t=``;try{let n=(0,u.readFileSync)(O(e),`utf-8`);t=JSON.parse(n).csProj}catch(e){$.error(e)}this.isCompiling=!0,Wd.send(t,`compiling`);try{let{stdout:n}=await Ce(`csharp-converter `+O(e)),r=n.toString();if(r.indexOf(`Error : `)==-1)Wd.send(t,`success`);else{console.clear(),$.error(r);let e=`csharp_errors`;zi.send(e,r),Wd.send(t,`error`,[{title:`C# error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},Jd=class{static cmd=`aventus.reloadSettings`;static async run(){$.refreshSettings()}},Yd=class{static cmd=`aventus.wc.create.cssvar`;static async run(e,t){if(!e||typeof t!=`number`)return;let n=await $.Input({title:`Provide a name for your variable`});if(!n)return;let r=await $.Input({title:`Provide a default value for your variable`}),i=R.getInstance().getByUri(e);if(i){let a=i.name.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g)?.join(`-`).toLowerCase()??i.name,o=n.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g)?.join(`-`).toLowerCase()??n,s=r?`, `+r:``,c=i.documentUser.positionAt(i.contentUser.length),l=`--_${a}-${o}: var(--${a}-${o}${s});`,u=i.contentUser.slice(0,t),f=i.contentUser.slice(t+1,i.contentUser.length),p=u+l+f,m=d.TextDocument.create(i.uri,w.SCSS,i.versionUser+1,p);await i.triggerContentChange(m);let h=await i.getFormatting({insertSpaces:!0,tabSize:4});await i.applyTextEdits(h);let g=[{newText:i.contentUser,range:{start:{character:0,line:0},end:c}}];wd.send(e,[g])}}},Xd=class{static cmd=`aventus.storybook.build`;static async run(){let e=[],t=L.getInstance().getAllBuildsWithStory();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{placeHolder:`Story to build`});if(n){let e=n.detail??``,t=n.label;L.getInstance().getProjectByUri(e)?.getBuild(t)?.buildStorybook()}}},Zd=class{static cmd=`aventus.template.import_project`;static async run(){await $.templateManager?.selectProjectToImport(!1)}},Qd=class{static cmd=`aventus.npm.build`;static async run(){let e=[],t=L.getInstance().getAllBuildsWithNpm();for(let n of t)e.push({label:n.name,detail:n.uri});let n=e.length==1?e[0]:await $.Select(e,{placeHolder:`Package to build`});if(n){let e=n.detail??``,t=n.label;L.getInstance().getProjectByUri(e)?.getBuild(t)?.buildNpm()}}},$d=class{static cmd=`aventus.i18n.add`;static async run(e,t,n=!0){try{let r=L.getInstance().getMatchingBuildsByUri(e);if(r.length>0){let i=r[0],a=e.replace(T.ComponentView,T.I18n),o=[];if(n&&i.i18nComponentsFiles[a]){let e=O(a);o.push({label:(0,f.basename)(e),detail:e})}for(let e in i.tsLanguageService.i18nFiles){let t=O(e);o.push({label:(0,f.basename)(t),detail:t})}let s=await $.Select(o,{title:`Where should I insert the transalation?`});if(s){let n=D(s.detail),r=i.i18nComponentsFiles[n]??i.tsLanguageService.i18nFiles[n],a=JSON.parse(JSON.stringify(r.parsedSrc));a[t]={};let o=r.build.buildConfig.i18n?.locales??[],c=r.build.buildConfig.i18n?.fallback??`en-GB`;for(let e of o)a[t][e]=e==c?t:Ji.empty;let l=[{newText:JSON.stringify(Ji.sortObj(a),null,4),range:{start:r.file.documentUser.positionAt(0),end:r.file.documentUser.positionAt(r.file.documentUser.getText().length)}}];wd.send(n,[l]),setTimeout(async()=>{let t=e.replace(T.ComponentView,T.ComponentLogic),n=i.tsFiles[t],r=i.htmlFiles[e];await n?.validate(),await r?.validate()},2e3)}}}catch(e){console.error(e)}}},ef=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}files={};onNewFileUUID;onFileRemoveUUID;constructor(){this.onNewFile=this.onNewFile.bind(this),this.onFileRemove=this.onFileRemove.bind(this),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=R.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(T.PhpConfig)&&!e.uri.includes(`/vendor/`)&&(this.files[e.uri]=new tf(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},tf=class{_file;get file(){return this._file}constructor(e){this._file=e,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 onContentChange(){}async onValidate(){return ot.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return ot.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return ot.getInstance().doResolve(t)}async onHover(e,t){return ot.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return ot.getInstance().format(e,t,n)}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}},nf=class{static cmd=`aventus.php.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Ud.sync)(`php`)){$.showErrorMessage(`Php isn't installed on your system`);return}if(!(0,Ud.sync)(`php-converter`))try{if(!(0,Ud.sync)(`composer`)){$.showErrorMessage(`composer isn't installed on your system`);return}if(await $.ask(`php-converter is missing. Can I install it?`)&&await Ce(`composer global require aventus/transpiler`),!(0,Ud.sync)(`php-converter`)){$.showErrorMessage(`Can't find the converter. Run the command : composer global require aventus/transpiler`);return}}catch(e){$.showErrorMessage(e+``);return}if(!e||!e.endsWith(T.PhpConfig)){let t=Object.keys(ef.getInstance().files);if(t.length==1)e=t[0];else if(t.length>1){let n=[];for(let e of t)n.push({label:e});let r=await $.Select(n,{placeHolder:`Project to compile`});if(r)e=r.label;else return}else{$.showErrorMessage(`No aventus.php.avt found`);return}}let t=``;try{let n=O(e.replace(T.PhpConfig,`composer.json`));if((0,u.existsSync)(n)){let e=(0,u.readFileSync)(n,`utf-8`);t=JSON.parse(e).name}}catch(e){$.error(e)}this.isCompiling=!0,Wd.send(t,`compiling`);try{let n=(0,f.join)($.extensionPath,`lib`,`bin`,`PhpToTypescript`,`PhpToTypescript.phar`),r=O(e),{stdout:i}=await Ce(`php `+n+` `+r+` 2>&1`,{encoding:`utf8`}),a=i.toString();if(a.indexOf(`Error : `)==-1)Wd.send(t,`success`);else{console.clear(),$.error(a);let e=`php_errors`;zi.send(e,a),Wd.send(t,`error`,[{title:`PHP error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},rf=class{static cmd=`aventus.store.connect`;static async run(e,t){if(Ni.isConnected){await $.showInformationMessage(`You are already connected with account `+Ni.settings.username);return}!e&&(e=await $.Input({title:`Username`}),!e)||!t&&(t=await $.Input({title:`Password`,password:!0}),!t)||(console.log(e),console.log(t),await Ni.connect(e,t)?await $.showInformationMessage(`Connection successful`):await $.showErrorMessage(`Connection failed`))}},af=class{static cmd=`aventus.store.disconnect`;static async run(){Ni.isConnected&&(await Ni.disconnect(),$.showInformationMessage(`You are disconnected`))}},of=class{static cmd=`aventus.store.publish_package`;static async run(){if(!Ni.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let e=L.getInstance().getAllBuilds(),t=[],n=null;if(e.length==1)n={label:e[0].name,detail:e[0].uri};else for(let r of e)t.push({label:r.name,detail:r.uri}),n=await $.Select(t,{placeHolder:`Project to compile`});if(n){let e=n.detail??``,t=n.label,r=L.getInstance().getProjectByUri(e)?.getBuild(t);if(r){let e=await Ni.publishPackage(r);if(e instanceof Pi)for(let t of e.errors)$.showErrorMessage(t.message);else $.showInformationMessage(`Package published`)}}}},sf=class{static send(e){let t=A();return $.sendNotification(`aventus/progress_start`,t,e),t}},cf=class{static send(e){$.sendNotification(`aventus/progress_stop`,e)}},lf=class e{config;folderPath;name=``;version=`1.0.0`;description=``;organization;tags=[];lastModified;allowQuick=!1;isProject=!1;isGlobal=!1;hasIsAllow=!1;containsError=!1;installationFolder;documentation;repository;static memory={};static async create(t){let n=(0,f.dirname)(t);if(this.memory[t]){if((0,u.statSync)(t).mtime.getTime()>this.memory[t].lastModified.getTime()){let r=new e(t,n);await r.postConstructor(),r.containsError||(this.memory[t]=r)}}else{let r=new e(t,n);await r.postConstructor(),r.containsError||(this.memory[t]=r)}return this.memory[t]}constructor(e,t){this.config=e,this.folderPath=t,this.lastModified=(0,u.statSync)(this.config).mtime}async postConstructor(){let e=await this.prepareScript();for(let t in e)e[t]&&(this[t]=e[t]);this.lastModified=(0,u.statSync)(this.config).mtime}init(e,t){return new Promise(n=>{try{let r=`
840
+ `)}var yd=class{static cmd=`aventus.component.split`;static async run(e){if(!e)return;let t=e.split(`/`).pop()?.replace(T.Component,``),n=R.getInstance().getByUri(e);if(n){let r=O(e.replace(T.Component,``));(0,u.existsSync)(r)||(0,u.mkdirSync)(r);let i=e.replace(T.Component,``)+`/`+t,a=Vi.getRegion(n),o=i+T.ComponentStyle,s=d.TextDocument.create(o,w.SCSS,n.versionUser+1,a.cssText??``);(0,u.writeFileSync)(O(o),s.getText());let c=i+T.ComponentView,l=d.TextDocument.create(c,w.HTML,n.versionUser+1,a.htmlText??``);(0,u.writeFileSync)(O(c),l.getText());let f=i+T.ComponentLogic,p=d.TextDocument.create(f,w.TypeScript,n.versionUser+1,a.scriptText??``);(0,u.writeFileSync)(O(f),p.getText()),(0,u.unlinkSync)(n.path),R.getInstance().onClose(n.documentUser),gd.send(n.uri),R.getInstance().registerFile(s),R.getInstance().registerFile(l),R.getInstance().registerFile(p),ld.send(p.uri)}}},bd=class{static cmd=`aventus.liveserver.start`;static run(){yt.getInstance().start()}},xd=class{static cmd=`aventus.liveserver.toggle`;static run(){yt.getInstance().toggle()}},Sd=class{static cmd=`aventus.static`;static async run(){let e=[],t=L.getInstance().getAllStatics();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{placeHolder:`Static to export`});if(n){let e=n.detail??``,t=n.label;await L.getInstance().getProjectByUri(e)?.getStatic(t)?.export()}}},Cd=class{static cmd=`aventus.liveserver.stop`;static run(){yt.getInstance().stop()}},wd=class{static send(e,t){$.sendNotification(`aventus/editFile`,{uri:e,transformations:t})}},Td=class e{static cmd=`aventus.wc.create.attribute`;static attrType=[{label:`Number`,detail:`number`},{label:`String`,detail:`string`},{label:`Boolean`,detail:`boolean`},{label:`Date`,detail:`Date`},{label:`Datetime`,detail:`Datetime`},{label:`Custom`,detail:``}];static async run(t,n){if(!t||typeof n!=`number`)return;let r=await $.Input({title:`Provide a name for your Attribute`,validations:[{message:`A property must be with lowercase, number or _`,regex:`^[_a-z0-9]+$`}]});if(!r)return;let i=await $.Select(e.attrType,{placeHolder:`Choose a type?`});if(!i)return;Ee(e.attrType,i);let a=i.detail,o=R.getInstance().getByUri(t);if(o){let e=`?`;(a==`boolean`||a==`number`)&&(e=`!`);let i=o.documentUser.positionAt(o.contentUser.length),s=`@Attribute()
841
+ public `+r+e+`:`+a+`;
842
+ `,c=o.contentUser.slice(0,n),l=o.contentUser.slice(n+1,o.contentUser.length),u=c+s+l,f=d.TextDocument.create(o.uri,w.TypeScript,o.versionUser+1,u);await o.triggerContentChange(f);let p=await o.getFormatting({insertSpaces:!0,tabSize:4});await o.applyTextEdits(p);let m=[{newText:o.contentUser,range:{start:{character:0,line:0},end:i}}];wd.send(t,[m])}}},Ed=class e{static cmd=`aventus.wc.create.property`;static attrType=[{label:`Number`,detail:`number`},{label:`String`,detail:`string`},{label:`Boolean`,detail:`boolean`},{label:`Date`,detail:`Date`},{label:`Datetime`,detail:`Datetime`},{label:`Custom`,detail:``}];static async run(t,n,r){if(!t||typeof n!=`number`)return;let i=await $.Input({title:`Provide a name for your Property`,validations:[{message:`A property must be with lowercase, number or _`,regex:`^[_a-z0-9]+$`}],value:r});if(!i)return;let a=await $.Select(e.attrType,{placeHolder:`Choose a type?`});if(!a)return;Ee(e.attrType,a);let o=a.detail,s=await $.Select([{label:`Yes`},{label:`No`}],{placeHolder:`Do you need a callback function?`});if(!s)return;let c=s.label==`Yes`,l=R.getInstance().getByUri(t);if(l){let e=l.documentUser.positionAt(l.contentUser.length),r=R.getInstance().getBuild(l.documentUser),a=``;if(r&&r.length>0){let e=r[0].tsFiles[t];e instanceof F&&(a=e.getComponentName())}if(a==``)return;let s=``;c&&(s=`(target: `+a+`) => {
843
+
844
+ }`);let u=`?`;(o==`boolean`||o==`number`)&&(u=`!`);let f=`@Property(`+s+`)
845
+ public `+i+u+`:`+o+`;
846
+ `,p=l.contentUser.slice(0,n),m=l.contentUser.slice(n+1,l.contentUser.length),h=p+f+m,g=d.TextDocument.create(l.uri,w.TypeScript,l.versionUser+1,h);await l.triggerContentChange(g);let _=await l.getFormatting({insertSpaces:!0,tabSize:4});await l.applyTextEdits(_);let v=[{newText:l.contentUser,range:{start:l.documentUser.positionAt(0),end:e}}];wd.send(t,[v])}}},Dd=class{static cmd=`aventus.wc.create.watch`;static async run(e,t,n){if(!e||typeof t!=`number`)return;let r=await $.Input({title:`Provide a name for your Watch variable`,value:n});if(!r)return;let i=await $.Input({title:`Provide a type for your Watch`});if(!i)return;let a=await $.Select([{label:`Yes`},{label:`No`}],{placeHolder:`Do you need a callback function?`});if(!a)return;let o=a.label==`Yes`,s=R.getInstance().getByUri(e);if(s){let n=s.documentUser.positionAt(s.contentUser.length),a=R.getInstance().getBuild(s.documentUser),c=``;if(a&&a.length>0){let t=a[0].tsFiles[e];t instanceof F&&(c=t.getComponentName())}if(c==``)return;let l=``;if(o){let e=`Aventus.`;a&&a.length>0&&a[0].isCoreBuild&&(e=``),l=`(target: `+c+`, action: `+e+`WatchAction, path: string, value: any) => {
847
+
848
+ }`}let u=`@Watch(`+l+`)
849
+ public `+r+`?:`+i+`;
850
+ `,f=s.contentUser.slice(0,t),p=s.contentUser.slice(t+1,s.contentUser.length),m=f+u+p,h=d.TextDocument.create(s.uri,w.TypeScript,s.versionUser+1,m);await s.triggerContentChange(h);let g=await s.getFormatting({insertSpaces:!0,tabSize:4});await s.applyTextEdits(g);let _=[{newText:s.contentUser,range:{start:s.documentUser.positionAt(0),end:n}}];wd.send(e,[_])}}},Od=class{static cmd=`aventus.wc.import.viewElement`;static async run(e,t){let n=R.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=R.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof F){let i=a.getMissingVariablesInfo();if(t==-1&&(t=i.start),t==-1)return;if(i.text!=``){let a=n.contentUser.slice(0,t),o=n.contentUser.slice(t+1,n.contentUser.length),s=a+i.text+o,c=d.TextDocument.create(n.uri,w.TypeScript,n.versionUser+1,s);await n.triggerContentChange(c);let l=await n.getFormatting({insertSpaces:!0,tabSize:4});await n.applyTextEdits(l);let u=[{newText:n.contentUser,range:{start:n.documentUser.positionAt(0),end:r}}];wd.send(e,[u])}}}}}},kd=class{static cmd=`aventus.wc.import.viewMethod`;static async run(e,t){let n=R.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=R.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof F){let i=a.getMissingMethodsInfo();if(t==-1&&(t=i.start),t==-1)return;if(i.text!=``){let a=n.contentUser.slice(0,t),o=n.contentUser.slice(t+1,n.contentUser.length),s=a+i.text+o,c=d.TextDocument.create(n.uri,w.TypeScript,n.versionUser+1,s);await n.triggerContentChange(c);let l=await n.getFormatting({insertSpaces:!0,tabSize:4});await n.applyTextEdits(l);let u=[{newText:n.contentUser,range:{start:n.documentUser.positionAt(0),end:r}}];wd.send(e,[u])}}}}}},Ad=class{static cmd=`aventus.rename`;static async run(e){if(!E.getInstance().settings.updateImportOnRename||!e)return;let t=[];for(let n of e){let e=n.newUri,r=n.oldUri,i=O(e),a=O(r),o,s=!0;if((0,u.existsSync)(i)?o=i:(s=!1,o=a),(0,u.statSync)(o).isDirectory()){let n=i=>{let a=(0,u.readdirSync)(i);for(let o of a){let a=(0,f.join)(i,o);if((0,u.statSync)(a).isDirectory())n(a);else{let n=D(a);s?t.push({newUri:n,oldUri:n.replace(e,r)}):t.push({newUri:n.replace(r,e),oldUri:n})}}};n(o)}else t.push({oldUri:r,newUri:e})}let n=await L.getInstance().onRename(t),r={},i=R.getInstance();for(let e in n){let t=i.getByUri(e);t&&(await t.applyTextEdits(n[e]),r[O(t.uri)]=t.contentUser)}setTimeout(()=>{for(let e in r)(0,u.writeFileSync)(e,r[e])},500)}},jd=class{static cmd=`aventus.component.rename`;static async run(e){if(!e)return;e=e.toString().replace(/\.wcv\.avt$/,`.wcl.avt`).replace(/\.wcs\.avt$/,`.wcl.avt`);let t=e.split(`/`),n=t[t.length-1].replace(`.wcl.avt`,``),r=await $.Input({title:`New name`,value:n,validations:[{message:`Your name isn't valid`,regex:`^[_A-Za-z0-9-]+$`}]});if(!r)return;let i=R.getInstance().getByUri(e);if(i&&i instanceof j){let e=R.getInstance(),t=i.documentUser.uri.split(`/`),n=t[t.length-1].replace(T.ComponentLogic,``),a=Be(n),o=i.folderUri,s=o.replace(RegExp(a+`$`),r),c=RegExp(`(class +)`+a+` `).exec(i.contentUser),l={};if(c){let t=c.index+c[1].length,n=i.documentUser.positionAt(t),a=await i.getRename(n,r);if(a&&a.changes)for(let t in a.changes){if(!l[t]){let n=e.getByUri(t);if(!n)continue;l[t]=n}let n=a.changes[t];await l[t].applyTextEdits(n)}}let f=[],p=e=>{let t=o+`/`+n+e;if((0,u.existsSync)(O(t))){let n=s+`/`+r+e;f.push({oldUri:t,newUri:n})}};p(T.ComponentLogic),p(T.ComponentStyle),p(T.ComponentView);let m=await L.getInstance().onRename(f);for(let t in m){if(!l[t]){let n=e.getByUri(t);if(!n)continue;l[t]=n}await l[t].applyTextEdits(m[t])}setTimeout(()=>{for(let e in l)(0,u.writeFileSync)(O(e),l[e].contentUser);(0,u.mkdirSync)(O(s));for(let t of f){let n=t.oldUri,r=t.newUri;(0,u.renameSync)(O(n),O(r)),gd.send(n);let i=e.getByUri(n);i&&(e.registerFile(d.TextDocument.create(r,De(r),1,i.contentUser)),e.onClose(i?.documentUser))}let t=O(o),n=(0,u.readdirSync)(t);n.length==0?(0,u.rmdirSync)(t):n.length==1&&n[0].endsWith(`.js`)&&(0,u.rmSync)(t,{recursive:!0,force:!0})},500)}}},Md=class{static cmd=`aventus.filesystem.openAventus`;static async run(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e);let t;switch((0,x.platform)()){case`win32`:t=`explorer`;break;case`linux`:t=`xdg-open`;break;case`darwin`:t=`open`;break}(0,g.spawn)(t,[e],{detached:!0}).unref()}},Nd=class{static waitingResponse={};static send(e,...t){return new Promise(n=>{let r=A();for(;this.waitingResponse[r]!=null;)r=A();this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/popup`,r,e,t)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Pd=class{static cmd=`aventus.popupresponse`;static run(e,t){Nd.resolve(e,t)}},Fd=class{static waitingResponse={};static send(e){return new Promise(t=>{let n=A();for(;this.waitingResponse[n]!=null;)n=A();this.waitingResponse[n]=e=>{t(e)},$.sendNotification(`aventus/askinput`,n,e)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Id=class{static cmd=`aventus.receiveinput`;static run(e,t){Fd.resolve(e,t)}},Ld=class{static waitingResponse={};static waitingOptions={};static send(e,t){return new Promise(n=>{let r=A();for(;this.waitingResponse[r]!=null;)r=A();this.waitingOptions[r]=e,this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/askselect`,r,e,t)})}static resolve(e,t){if(this.waitingResponse[e]){if(t)for(let n of this.waitingOptions[e])n.label==t.label&&(t=n);this.waitingResponse[e](t),delete this.waitingResponse[e],delete this.waitingOptions[e]}}},Rd=class{static cmd=`aventus.receiveselect`;static run(e,t){Ld.resolve(e,t)}},zd=class{static waitingResponse={};static send(e,t){return new Promise(n=>{let r=A();for(;this.waitingResponse[r]!=null;)r=A();this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/askselectmultiple`,r,e,t)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Bd=class{static cmd=`aventus.receiveselectmultiple`;static run(e,t){zd.resolve(e,t)}},Vd=class{static cmd=`aventus.template.import`;static async run(){await $.templateManager?.selectTemplateToImport()}},Hd=o(((e,t)=>{var n=require("child_process").exec,r=require("child_process").execSync,i=require("fs"),a=require("path"),o=i.access,s=i.accessSync,c=i.constants||i,l=process.platform==`win32`,u=function(e,t){o(e,c.F_OK,function(e){t(!e)})},d=function(e){try{return s(e,c.F_OK),!1}catch{return!0}},f=function(e,t){o(e,c.F_OK|c.X_OK,function(e){t(null,!e)})},p=function(e){try{return s(e,c.F_OK|c.X_OK),!0}catch{return!1}},m=function(e,t,r){u(e,function(i){if(!i){n(`command -v `+t+` 2>/dev/null && { echo >&1 `+t+`; exit 0; }`,function(e,t,n){r(null,!!t)});return}f(e,r)})},h=function(e,t,r){if(!/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(e)){r(null,!1);return}n(`where `+t,function(e){e===null?r(null,!0):r(null,!1)})},g=function(e,t){if(d(e))try{return!!r(`command -v `+t+` 2>/dev/null && { echo >&1 `+t+`; exit 0; }`)}catch{return!1}return p(e)},_=function(e,t,n){if(!/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(e))return!1;try{return!!r(`where `+t,{stdio:[]})}catch{return!1}},v=function(e){return/[^A-Za-z0-9_\/:=-]/.test(e)&&(e=`'`+e.replace(/'/g,`'\\''`)+`'`,e=e.replace(/^(?:'')+/g,``).replace(/\\'''/g,`\\'`)),e};l&&(v=function(e){if(/[\\]/.test(e)){var t=`"`+a.dirname(e)+`"`,n=`"`+a.basename(e)+`"`;return t+`:`+n}return`"`+e+`"`}),t.exports=function e(t,n){var r=v(t);if(!n&&typeof Promise<`u`)return new Promise(function(n,r){e(t,function(e,i){i?n(t):r(e)})});l?h(t,r,n):m(t,r,n)},t.exports.sync=function(e){var t=v(e);return l?_(e,t):g(e,t)}})),Ud=o(((e,t)=>{t.exports=Hd()}))(),Wd=class{static send(e,t,n){$.sendNotification(`aventus/sharp/compiling`,e,t,n)}},Gd=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}files={};onNewFileUUID;onFileRemoveUUID;constructor(){this.onNewFile=this.onNewFile.bind(this),this.onFileRemove=this.onFileRemove.bind(this),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=R.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(T.CsharpConfig)&&(this.files[e.uri]=new Kd(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},Kd=class{_file;get file(){return this._file}constructor(e){this._file=e,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 onContentChange(){}async onValidate(){return ot.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return ot.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return ot.getInstance().doResolve(t)}async onHover(e,t){return ot.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return ot.getInstance().format(e,t,n)}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}},qd=class{static cmd=`aventus.sharp.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Ud.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}if(!(0,Ud.sync)(`csharp-converter`))try{if(await $.ask(`csharp-converter is missing. Can I install it?`)&&await Ce(`dotnet tool install --global AventusSharp.Converter`),!(0,Ud.sync)(`csharp-converter`)){$.showErrorMessage(`Can't find the converter. Run the command : dotnet tool install --global AventusSharp.Converter`);return}}catch(e){$.showErrorMessage(e+``);return}if(!e||!e.endsWith(T.CsharpConfig)){let t=Object.keys(Gd.getInstance().files);if(t.length==1)e=t[0];else if(t.length>1){let n=[];for(let e of t)n.push({label:e});let r=await $.Select(n,{placeHolder:`Project to compile`});if(r)e=r.label;else return}else{$.showErrorMessage(`No aventus.sharp.avt found`);return}}let t=``;try{let n=(0,u.readFileSync)(O(e),`utf-8`);t=JSON.parse(n).csProj}catch(e){$.error(e)}this.isCompiling=!0,Wd.send(t,`compiling`);try{let{stdout:n}=await Ce(`csharp-converter `+O(e)),r=n.toString();if(r.indexOf(`Error : `)==-1)Wd.send(t,`success`);else{console.clear(),$.error(r);let e=`csharp_errors`;zi.send(e,r),Wd.send(t,`error`,[{title:`C# error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},Jd=class{static cmd=`aventus.reloadSettings`;static async run(){$.refreshSettings()}},Yd=class{static cmd=`aventus.wc.create.cssvar`;static async run(e,t){if(!e||typeof t!=`number`)return;let n=await $.Input({title:`Provide a name for your variable`});if(!n)return;let r=await $.Input({title:`Provide a default value for your variable`}),i=R.getInstance().getByUri(e);if(i){let a=i.name.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g)?.join(`-`).toLowerCase()??i.name,o=n.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g)?.join(`-`).toLowerCase()??n,s=r?`, `+r:``,c=i.documentUser.positionAt(i.contentUser.length),l=`--_${a}-${o}: var(--${a}-${o}${s});`,u=i.contentUser.slice(0,t),f=i.contentUser.slice(t+1,i.contentUser.length),p=u+l+f,m=d.TextDocument.create(i.uri,w.SCSS,i.versionUser+1,p);await i.triggerContentChange(m);let h=await i.getFormatting({insertSpaces:!0,tabSize:4});await i.applyTextEdits(h);let g=[{newText:i.contentUser,range:{start:{character:0,line:0},end:c}}];wd.send(e,[g])}}},Xd=class{static cmd=`aventus.storybook.build`;static async run(){let e=[],t=L.getInstance().getAllBuildsWithStory();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{placeHolder:`Story to build`});if(n){let e=n.detail??``,t=n.label;L.getInstance().getProjectByUri(e)?.getBuild(t)?.buildStorybook()}}},Zd=class{static cmd=`aventus.template.import_project`;static async run(){await $.templateManager?.selectProjectToImport(!1)}},Qd=class{static cmd=`aventus.npm.build`;static async run(){let e=[],t=L.getInstance().getAllBuildsWithNpm();for(let n of t)e.push({label:n.name,detail:n.uri});let n=e.length==1?e[0]:await $.Select(e,{placeHolder:`Package to build`});if(n){let e=n.detail??``,t=n.label;L.getInstance().getProjectByUri(e)?.getBuild(t)?.buildNpm()}}},$d=class{static cmd=`aventus.i18n.add`;static async run(e,t,n=!0){try{let r=L.getInstance().getMatchingBuildsByUri(e);if(r.length>0){let i=r[0],a=e.replace(T.ComponentView,T.I18n),o=[];if(n&&i.i18nComponentsFiles[a]){let e=O(a);o.push({label:(0,f.basename)(e),detail:e})}for(let e in i.tsLanguageService.i18nFiles){let t=O(e);o.push({label:(0,f.basename)(t),detail:t})}let s=await $.Select(o,{title:`Where should I insert the transalation?`});if(s){let n=D(s.detail),r=i.i18nComponentsFiles[n]??i.tsLanguageService.i18nFiles[n],a=JSON.parse(JSON.stringify(r.parsedSrc));a[t]={};let o=r.build.buildConfig.i18n?.locales??[],c=r.build.buildConfig.i18n?.fallback??`en-GB`;for(let e of o)a[t][e]=e==c?t:Ji.empty;let l=[{newText:JSON.stringify(Ji.sortObj(a),null,4),range:{start:r.file.documentUser.positionAt(0),end:r.file.documentUser.positionAt(r.file.documentUser.getText().length)}}];wd.send(n,[l]),setTimeout(async()=>{let t=e.replace(T.ComponentView,T.ComponentLogic),n=i.tsFiles[t],r=i.htmlFiles[e];await n?.validate(),await r?.validate()},2e3)}}}catch(e){console.error(e)}}},ef=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}files={};onNewFileUUID;onFileRemoveUUID;constructor(){this.onNewFile=this.onNewFile.bind(this),this.onFileRemove=this.onFileRemove.bind(this),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=R.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(T.PhpConfig)&&!e.uri.includes(`/vendor/`)&&(this.files[e.uri]=new tf(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},tf=class{_file;get file(){return this._file}constructor(e){this._file=e,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 onContentChange(){}async onValidate(){return ot.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return ot.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return ot.getInstance().doResolve(t)}async onHover(e,t){return ot.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return ot.getInstance().format(e,t,n)}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}},nf=class{static cmd=`aventus.php.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Ud.sync)(`php`)){$.showErrorMessage(`Php isn't installed on your system`);return}if(!(0,Ud.sync)(`php-converter`))try{if(!(0,Ud.sync)(`composer`)){$.showErrorMessage(`composer isn't installed on your system`);return}if(await $.ask(`php-converter is missing. Can I install it?`)&&await Ce(`composer global require aventus/transpiler`),!(0,Ud.sync)(`php-converter`)){$.showErrorMessage(`Can't find the converter. Run the command : composer global require aventus/transpiler`);return}}catch(e){$.showErrorMessage(e+``);return}if(!e||!e.endsWith(T.PhpConfig)){let t=Object.keys(ef.getInstance().files);if(t.length==1)e=t[0];else if(t.length>1){let n=[];for(let e of t)n.push({label:e});let r=await $.Select(n,{placeHolder:`Project to compile`});if(r)e=r.label;else return}else{$.showErrorMessage(`No aventus.php.avt found`);return}}let t=``;try{let n=O(e.replace(T.PhpConfig,`composer.json`));if((0,u.existsSync)(n)){let e=(0,u.readFileSync)(n,`utf-8`);t=JSON.parse(e).name}}catch(e){$.error(e)}this.isCompiling=!0,Wd.send(t,`compiling`);try{let n=(0,f.join)($.extensionPath,`lib`,`bin`,`PhpToTypescript`,`PhpToTypescript.phar`),r=O(e),{stdout:i}=await Ce(`php `+n+` `+r+` 2>&1`,{encoding:`utf8`}),a=i.toString();if(a.indexOf(`Error : `)==-1)Wd.send(t,`success`);else{console.clear(),$.error(a);let e=`php_errors`;zi.send(e,a),Wd.send(t,`error`,[{title:`PHP error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},rf=class{static cmd=`aventus.store.connect`;static async run(e,t){if(Ni.isConnected){await $.showInformationMessage(`You are already connected with account `+Ni.settings.username);return}!e&&(e=await $.Input({title:`Username`}),!e)||!t&&(t=await $.Input({title:`Password`,password:!0}),!t)||(console.log(e),console.log(t),await Ni.connect(e,t)?await $.showInformationMessage(`Connection successful`):await $.showErrorMessage(`Connection failed`))}},af=class{static cmd=`aventus.store.disconnect`;static async run(){Ni.isConnected&&(await Ni.disconnect(),$.showInformationMessage(`You are disconnected`))}},of=class{static cmd=`aventus.store.publish_package`;static async run(){if(!Ni.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let e=L.getInstance().getAllBuilds(),t=[],n=null;if(e.length==1)n={label:e[0].name,detail:e[0].uri};else for(let r of e)t.push({label:r.name,detail:r.uri}),n=await $.Select(t,{placeHolder:`Project to compile`});if(n){let e=n.detail??``,t=n.label,r=L.getInstance().getProjectByUri(e)?.getBuild(t);if(r){let e=await Ni.publishPackage(r);if(e instanceof Pi)for(let t of e.errors)$.showErrorMessage(t.message);else $.showInformationMessage(`Package published`)}}}},sf=class{static send(e){let t=A();return $.sendNotification(`aventus/progress_start`,t,e),t}},cf=class{static send(e){$.sendNotification(`aventus/progress_stop`,e)}},lf=class e{config;folderPath;name=``;version=`1.0.0`;description=``;organization;tags=[];lastModified;allowQuick=!1;isProject=!1;isGlobal=!1;hasIsAllow=!1;containsError=!1;installationFolder;documentation;repository;static memory={};static async create(t){let n=(0,f.dirname)(t);if(this.memory[t]){if((0,u.statSync)(t).mtime.getTime()>this.memory[t].lastModified.getTime()){let r=new e(t,n);await r.postConstructor(),r.containsError||(this.memory[t]=r)}}else{let r=new e(t,n);await r.postConstructor(),r.containsError||(this.memory[t]=r)}return this.memory[t]}constructor(e,t){this.config=e,this.folderPath=t,this.lastModified=(0,u.statSync)(this.config).mtime}async postConstructor(){let e=await this.prepareScript();for(let t in e)e[t]&&(this[t]=e[t]);this.lastModified=(0,u.statSync)(this.config).mtime}init(e,t){return new Promise(n=>{try{let r=`
775
851
  import { AventusTemplate } from 'file://${(0,f.join)(xt(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
776
852
  import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
777
853