@aventusjs/cli 0.0.38 → 0.0.39

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
@@ -220,19 +220,19 @@ const preview: Preview = {
220
220
  },
221
221
  };
222
222
 
223
- export default preview;`}var gt=class e{static getFullname(e){let t=e.fullName.replace(/\./g,`/`),n=!1,r=e.build.buildConfig,i=e=>{e===``||(t=e.endsWith(`/`)?e+t:e+`/`+t)};return e.storieDecorator&&(e.storieDecorator.group!==void 0&&(t=e.storieDecorator.group?e.storieDecorator.group+`/`+e.name:e.name),e.storieDecorator.prefix!==void 0&&(n=!0,i(e.storieDecorator.prefix))),!n&&r.stories?.prefix!==void 0&&i(r.stories.prefix),t}build;buildConfig;constructor(e,t){this.build=e,this.buildConfig=t}async check(){this.readEnvStoryBook()}write(e,t=!1){t&&this.clear();for(let t in e){let n=e[t];if(n.fileParsed){for(let e in n.fileParsed.classes){let t=n.fileParsed.classes[e];this.writeStory(t,n)}for(let e in n.fileParsed.aliases){let t=n.fileParsed.aliases[e];this.writeStory(t)}for(let e in n.fileParsed.enums){let t=n.fileParsed.enums[e];this.writeStory(t)}for(let e in n.fileParsed.functions){let t=n.fileParsed.functions[e];this.writeStory(t)}for(let e in n.fileParsed.variables){let t=n.fileParsed.variables[e];this.writeStory(t)}}}}clear(){this.buildConfig.stories&&(0,f.join)(this.buildConfig.stories.output,`auto`)}writeStory(t,n){if(!t.storieContent||!this.buildConfig.stories)return;let r=t.storieContent,i=(0,f.join)(this.buildConfig.stories.output,`generated`),a=(0,f.join)(this.buildConfig.stories.output,`auto`,...t.fullName.split(`.`)),o=I(Yi(F(a)));(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0});let s=()=>{let e=!1;return t.storieDecorator&&(t.storieDecorator.noLive||t.storieDecorator.noDefaultStory)&&(e=!0),n instanceof j&&n.componentClassName==t.name&&n.fileParsed?.classes[n.componentClassName]&&!n.fileParsed.classes[n.componentClassName].isAbstract&&!e},c=()=>{let e=ft();e=this.replaceVariable(e,`name`,t.name);let n=`<av-story-${r.kind}-render json={JSON.stringify(Meta.aventus)}></av-story-${r.kind}-render>`;e=this.replaceVariable(e,`tag`,n),e=s()?this.replaceVariable(e,`live`,`
223
+ export default preview;`}var gt=class e{static getFullname(e){let t=e.fullName.replace(/\./g,`/`),n=!1,r=e.build.buildConfig,i=e=>{e===``||(t=e.endsWith(`/`)?e+t:e+`/`+t)};return e.storieDecorator&&(e.storieDecorator.group!==void 0&&(t=e.storieDecorator.group?e.storieDecorator.group+`/`+e.name:e.name),e.storieDecorator.prefix!==void 0&&(n=!0,i(e.storieDecorator.prefix))),!n&&r.stories?.prefix!==void 0&&i(r.stories.prefix),t}build;buildConfig;constructor(e,t){this.build=e,this.buildConfig=t}async check(){await this.readEnvStoryBook()}async write(e,t=!1){t&&this.clear();for(let t in e){let n=e[t];if(n.fileParsed){for(let e in n.fileParsed.classes){let t=n.fileParsed.classes[e];await this.writeStory(t,n)}for(let e in n.fileParsed.aliases){let t=n.fileParsed.aliases[e];await this.writeStory(t)}for(let e in n.fileParsed.enums){let t=n.fileParsed.enums[e];await this.writeStory(t)}for(let e in n.fileParsed.functions){let t=n.fileParsed.functions[e];await this.writeStory(t)}for(let e in n.fileParsed.variables){let t=n.fileParsed.variables[e];await this.writeStory(t)}}}}clear(){this.buildConfig.stories&&(0,f.join)(this.buildConfig.stories.output,`auto`)}async writeStory(t,n){if(!t.storieContent||!this.buildConfig.stories)return;let r=t.storieContent,i=(0,f.join)(this.buildConfig.stories.output,`generated`),a=(0,f.join)(this.buildConfig.stories.output,`auto`,...t.fullName.split(`.`)),o=I(Yi(F(a)));(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0});let s=()=>{let e=!1;return t.storieDecorator&&(t.storieDecorator.noLive||t.storieDecorator.noDefaultStory)&&(e=!0),n instanceof j&&n.componentClassName==t.name&&n.fileParsed?.classes[n.componentClassName]&&!n.fileParsed.classes[n.componentClassName].isAbstract&&!e},c=async()=>{let e=ft();e=this.replaceVariable(e,`name`,t.name);let n=`<av-story-${r.kind}-render json={JSON.stringify(Meta.aventus)}></av-story-${r.kind}-render>`;e=this.replaceVariable(e,`tag`,n),e=s()?this.replaceVariable(e,`live`,`
224
224
  <div>
225
225
  <Title>Live</Title>
226
226
  <Canvas />
227
227
  <Controls />
228
- </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=`{
228
+ </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'`),await this.writeFile(a+`_.mdx`,e)},l=e=>{let t=`{
229
229
  `;for(let n in e){let r=e[n];typeof r==`string`&&(r=r.replace(/\\"/g,``)),r==``&&(r=`""`),t+=` "`+n+`":`+r+`,
230
- `}return t+=`}`,t};c(),(()=>{let o=!0;t.storieDecorator&&t.storieDecorator.noDefaultStory&&(o=!1);let c=s()?mt():pt(),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(`
230
+ `}return t+=`}`,t};await c(),await(async()=>{let o=!0;t.storieDecorator&&t.storieDecorator.noDefaultStory&&(o=!1);let c=s()?mt():pt(),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(`
231
231
  `).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 j){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=na(F((0,f.join)(i,...r.namespace.split(`.`))),F(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(`
232
- `))}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=dt(),t=na(F(this.buildConfig.stories.output),F(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=ht();this.writeFile(o,e)}}replaceVariable(e,t,n){let r=RegExp(`\\$`+t+`\\$`,`g`);return e=e.replace(r,n),e}writeFile(e,t){aa(e,t,`storybook`)}},_t=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:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`error can't use namespace import`,`
232
+ `))}else c=this.replaceVariable(c,`argTypes`,``),c=this.replaceVariable(c,`args`,``);await this.writeFile(a+`.stories.ts`,c)})()}async 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=async 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),await 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)}await this.writeFile(s,e)}}};if(n.length==1)i=t+f.sep+n[0];else throw`TODO code multiple template`;await 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=dt(),t=na(F(this.buildConfig.stories.output),F(a));e=this.replaceVariable(e,`path`,t),await this.writeFile(a,e)}let o=(0,f.join)(i,`preview.ts`);if(!(0,u.existsSync)(o)){let e=ht();await this.writeFile(o,e)}}replaceVariable(e,t,n){let r=RegExp(`\\$`+t+`\\$`,`g`);return e=e.replace(r,n),e}async writeFile(e,t){await ca(e,t,`storybook`)}},_t=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:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`error can't use namespace import`,`
233
233
  `)});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(w.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:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`error can't use renamed import`,`
234
234
  `)});else{let n=e.name.getText(),a=i.split(`:`);if(a.length>1){let e=a[1].replace(w.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:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`The package import is malformated`,`
235
- `)})}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=F((0,f.normalize)(Yi(I(this.parserInfo.document.uri))+`/`+e.moduleName))):(this.name=e.name,this.nameStart=0,this.nameEnd=0,this.isTypeImport=!1,t=e.moduleUri),!A.parsedDoc[t]){let e=R.getInstance().getByUri(t);if(e)A.parse(e,!1,this.parserInfo.build);else{let e=I(t),n=(0,u.existsSync)(e)?(0,u.readFileSync)(e,`utf8`):``,r=new E(d.TextDocument.create(t,C.TypeScript,1,n));A.parse(r,!1,this.parserInfo.build)}}if(A.parsedDoc[t]?.result.isReady){let e=A.parsedDoc[t].result.getBaseInfo(this.name);e?this.info=e:A.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]=[],A.parsedDoc[t].result.onReady(()=>{this.asyncImportLocal(t,this.alias??this.name)})}}asyncImportLocal(e,t){let n=A.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 A.addError(this.nameStart,this.nameEnd,`Can't load `+e+` `+t+` from `+this.parserInfo.document.uri)}},vt=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}},k=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=at.buildDecorator(e).find(e=>e.name==`Storybook`);if(n){let e=lt.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=at.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 ut(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(st.is(e)){this.isExported=!1;break}}e.infoByFullName[this.fullName]=this}}loadDecorators(){for(let e of this.decorators){let t=ot.is(e);if(t)for(let e of t.dependencies)this.addDependencyName(e.type,e.strong,0,0);let n=vt.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=A.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(`.`)&&(A.hasLocal(e)||A.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(`.`)&&(A.getBaseInfo(t)||A.hasLocal(t)||A.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 O(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 O(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=na(F((0,f.join)(i,...t.namespace.split(`.`))),F(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=oa(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=_t.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(et.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=oa(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=lt.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(w.Config,``),t=I(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=gt.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 O(e.default),this);r&&(n.default=r);let i=this.transformTypeForStory(new O(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 O(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 O(r.type),t),i=this.transformTypeForStory(new O(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 O(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 O(e.constraint),this);t&&(r.constraint=t)}if(e.default){let t=this.transformTypeForStory(new O(e.default),this);t&&(r.default=t)}return r}loadParameterForStory(e,t){let n=e.name.getText(),r={name:n},i=this.transformTypeForStory(new O(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(`
235
+ `)})}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=F((0,f.normalize)(Yi(I(this.parserInfo.document.uri))+`/`+e.moduleName))):(this.name=e.name,this.nameStart=0,this.nameEnd=0,this.isTypeImport=!1,t=e.moduleUri),!A.parsedDoc[t]){let e=R.getInstance().getByUri(t);if(e)A.parse(e,!1,this.parserInfo.build);else{let e=I(t),n=(0,u.existsSync)(e)?(0,u.readFileSync)(e,`utf8`):``,r=new E(d.TextDocument.create(t,C.TypeScript,1,n));A.parse(r,!1,this.parserInfo.build)}}if(A.parsedDoc[t]?.result.isReady){let e=A.parsedDoc[t].result.getBaseInfo(this.name);e?this.info=e:A.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]=[],A.parsedDoc[t].result.onReady(()=>{this.asyncImportLocal(t,this.alias??this.name)})}}asyncImportLocal(e,t){let n=A.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 A.addError(this.nameStart,this.nameEnd,`Can't load `+e+` `+t+` from `+this.parserInfo.document.uri)}},vt=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}},k=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=at.buildDecorator(e).find(e=>e.name==`Storybook`);if(n){let e=lt.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=at.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 ut(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(st.is(e)){this.isExported=!1;break}}e.infoByFullName[this.fullName]=this}}loadDecorators(){for(let e of this.decorators){let t=ot.is(e);if(t)for(let e of t.dependencies)this.addDependencyName(e.type,e.strong,0,0);let n=vt.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=A.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(`.`)&&(A.hasLocal(e)||A.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(`.`)&&(A.getBaseInfo(t)||A.hasLocal(t)||A.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 O(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 O(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=na(F((0,f.join)(i,...t.namespace.split(`.`))),F(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=la(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=_t.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(et.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=la(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=lt.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(w.Config,``),t=I(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=gt.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 O(e.default),this);r&&(n.default=r);let i=this.transformTypeForStory(new O(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 O(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 O(r.type),t),i=this.transformTypeForStory(new O(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 O(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 O(e.constraint),this);t&&(r.constraint=t)}if(e.default){let t=this.transformTypeForStory(new O(e.default),this);t&&(r.default=t)}return r}loadParameterForStory(e,t){let n=e.name.getText(),r={name:n},i=this.transformTypeForStory(new O(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(`
236
236
  `))}},yt=class extends k{node;type;constructor(e,t,n){super(e,t,n),this.node=e,this.type=new O(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 O(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}},bt=class e{static is(t){return t.name==`NoCompile`?new e:null}},xt=class e{static is(t){return t.name==`BindThis`?new e:null}},St=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 k.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return k.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return k.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=at.buildDecorator(e,t),this.returnType=new O(e.type);let n=new ut(e);n.hasDoc&&(this.documentation=n),this.loadAccessibilityModifier(e);let r=null;for(let e of this.decorators)bt.is(e)?this.mustBeCompiled=!1:(r=vt.is(e))&&(this.deprecated=!0,this.deprecatedMsg=r.msg)}loadAccessibilityModifier(e){let t=!1,n=null;for(let e of this.decorators){let t=st.is(e);if(t){n=t;continue}let r=ct.is(e);if(r){n=r;continue}if(xt.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 st?`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 st?(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&&A.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name),t===!1&&!this._class.isInterface&&A.addError(this.nameStart,this.nameEnd,`A accessibility modifier (public / private / protected) is mandatory for `+this.name)}},Ct=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}},wt=class e{static is(t){return t.name==`NoType`?new e:null}},Tt=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;noType=!1;deprecatedMsg=``;get compiledContent(){return k.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return k.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return k.getContentNpm(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValue(){return this.defaultValueTxt===null?null:k.getContent(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueHotReload(){return this.defaultValueTxt===null?null:k.getContentHotReload(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueNpm(){return this.defaultValueTxt===null?null:k.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=at.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 ut(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=Ct.is(e);if(t){this.defaultValueStory=t.value;continue}let n=vt.is(e);if(n){this.deprecated=!0,this.deprecatedMsg=n.msg;continue}if(wt.is(e)){this.noType=!0;continue}}}loadAccessibilityModifier(e){if(this.isInsideInterface)return;let t=!1,n=null;for(let e of this.decorators){let t=st.is(e);if(t){n=t;break}let r=ct.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 st?`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 st?(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&&A.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name),t===!1&&A.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 O(t.type):t.initializer&&t.initializer.kind==p.SyntaxKind.ExpressionWithTypeArguments?new O(t.initializer):new O(null),n}loadInitializer(e){let t=e;t.initializer&&(this.defaultValueTxt=t.initializer.getText(),this.defaultValueStart=t.initializer.getStart(),this.defaultValueEnd=t.initializer.getEnd())}},Et=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 Dt=[`Callback`,`Aventus.Callback`,`CallbackGroup`,`Aventus.CallbackGroup`];var Ot=class extends Tt{propType=`Simple`;inParent=!1;arguments},kt=class e extends k{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+`);
237
237
  `+this.extraConstructorCode.join(`
238
238
  `)+` }`:`constructor(`+e+`) {`+this.extraConstructorCode.join(`
@@ -247,7 +247,7 @@ export default preview;`}var gt=class e{static getFullname(e){let t=e.fullName.r
247
247
  `)}}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+`);
248
248
  `+this.extraConstructorCode.join(`
249
249
  `)+` }`}}else this.compileTransformations[t]={start:e,end:e,newText:`constructor() { `+this.extraConstructorCode.join(`
250
- `)+` }`}}}loadConvertible(){let e=this;for(;e!=null;){for(let t of e.decorators){let e=Et.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(Dt.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(`__`+oa(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(`
250
+ `)+` }`}}}loadConvertible(){let e=this;for(;e!=null;){for(let t of e.decorators){let e=Et.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(Dt.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(`__`+la(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(`
251
251
  `)),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 O(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(`
252
252
  `));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}},At=class extends k{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 ut(n);a.hasDoc&&(r.documentation=a.definitions.join(`
253
253
  `)),e.properties.push(r)}return e}},jt=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)}},Mt=class extends k{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 O(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}},Nt=class extends k{type=`var`;node;constructor(e,t,n,r){super(e,t,n),this.decorators=at.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=k.isExported(r),this.isInternalExported=this.isExported;for(let e of this.decorators)if(st.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 O(this.node.type),n=this.transformTypeForStory(t,this);n&&(e.type=n)}return e}},A=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:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(n,`
@@ -462,11 +462,11 @@ this.clearWatchHistory = () => {
462
462
  }`),this.writeFileReplaceVar(`watchesChangeCb`,e),this.writeFileHotReloadReplaceVar(`watchesChangeCb`,e),this.writeFileNpmReplaceVar(`watchesChangeCb`,e)}createHtmlDoc(e,t){if(this.htmlDoc){let n=[];if(e.isProtected||e.isPrivate)return;let r=`string`;if(t.kind==`literal`){let e=t.value;(e.startsWith(`'`)||e.startsWith(`"`))&&(e=e.substring(1)),(e.endsWith(`'`)||e.endsWith(`"`))&&(e=e.substring(0,e.length-1)),n.push({name:e,description:``})}else if(t.kind==`union`)for(let e of t.nested){let t=e.value;(t.startsWith(`'`)||t.startsWith(`"`))&&(t=t.substring(1)),(t.endsWith(`'`)||t.endsWith(`"`))&&(t=t.substring(0,t.length-1)),n.push({name:t,description:``})}else t.kind==`boolean`?r=`boolean`:t.kind==`number`?r=`number`:t.kind==`type`&&t.value==`Date`?r=`Date`:t.kind==`type`&&t.value==`DateTime`?r=`DateTime`:t.kind==`type`&&t.value==`Time`&&(r=`Time`);this.htmlDoc[this.tagName].attributes[e.name]={name:e.name,description:e.documentation?.definitions.join(`
463
463
  `)??``,type:r,values:n}}}createInjectableHtmlDoc(e){if(this.htmlDoc)for(let t of e)this.htmlDoc[this.tagName].attributes[t.name]={name:`:`+t.name,description:t.documentation?.fullDefinitions.join(`
464
464
  `)??``,values:[]}}createEventsHtmlDoc(e){if(this.htmlDoc)for(let t of e){let e=t.name;e.startsWith(`on`)&&(e=e.slice(2),e=e.charAt(0).toLowerCase()+e.slice(1)),this.htmlDoc[this.tagName].attributes[t.name]={name:`@`+e,description:t.documentation?.fullDefinitions.join(`
465
- `)??``,values:[]}}}writeFileReplaceVar(e,t){let n=RegExp(`\\$`+e+`\\$`,`g`);this.template=this.template.replace(n,t+``)}writeFileHotReloadReplaceVar(e,t){if(D.isRunning){let n=RegExp(`\\$`+e+`\\$`,`g`);this.templateHotReload=this.templateHotReload.replace(n,t+``)}}writeFileNpmReplaceVar(e,t){if(this.templateNpm){let n=RegExp(`\\$`+e+`\\$`,`g`);this.templateNpm=this.templateNpm.replace(n,t+``)}}createMissingMethod(e,t,n){if(!this.htmlParsed)return;if(this.result.missingMethods.position==-1){let e=tn(this.file,`methods`);this.result.missingMethods.position=e}let r=`missing method `+e;this.result.missingMethods.elements.includes(e)||(this.result.missingMethods.elements.push(e),this.result.diagnostics.push(Hi(this.document,r,`methods`,1019))),this.htmlFile&&this.htmlFile.tsErrors.push(Gi(this.htmlFile.file.documentUser,r,t,n))}createMissingViewElement(e){let t=[];for(let n in e.tags){let r=this.build.htmlLanguageService.getClassByTag(n),i=``;i=r||this.build.htmlLanguageService.getGenericHTML(n)||`HTMLElement`,e.tags[n]>1&&(i+=`[]`),t.push(i)}let n=``;if(t.length==1)n=t[0];else if(t.length>1){for(let e=0;e<t.length;e++)t[e]=t[e].replace(`[]`,``);n=`(`+t.join(` | `)+`)[]`}let r=`Missing variable view element`+e.name;if(this.result.missingViewElements.elements[e.name]=n,this.result.diagnostics.push(Hi(this.document,r,`variables`,1011)),this.htmlFile)for(let t of e.positions)this.htmlFile.tsErrors.push(Gi(this.htmlFile.file.documentUser,r,t.start,t.end))}createUnusedViewElement(e){let t=e.name;this.overrideViewDecorator?this.overrideViewDecorator.removeViewVariables.indexOf(t)==-1&&this.result.diagnostics.push(L(this.document,`Can't find the variable `+t+` inside the view`,e.nameStart,e.nameEnd,1012,{start:e.start,end:e.end})):this.result.diagnostics.push(L(this.document,`Can't find the variable `+t+` inside the view`,e.nameStart,e.nameEnd,1012,{start:e.start,end:e.end}))}isCallback(e,t){let n;n=t.startsWith(`on`)?[t]:[t,`on`+t,`on`+t.charAt(0).toUpperCase()+t.slice(1)];for(let t of n){let n=e.getField(t);if(n){let e=n.type.value;if(Dt.includes(e))return t}}return null}prepareDocSCSS(){let e=this.scssFile?.customProperties??[],t={[this.tagName]:e};if(this.hasStory&&this.classInfo?.storieContent){let t=this.classInfo.storieContent;delete t.style;let n=[];for(let t of e){this.storyArgTypes[t.name]={table:{category:`Style`}};let e={name:t.name};t.documentation&&(this.storyArgTypes[t.name].description=t.documentation,e.documentation=t.documentation),t.type&&(e.type=t.type),t.type==`color`?(this.storyArgTypes[t.name].control=`color`,this.storyArgTypes[t.name].type=`color`):(this.storyArgTypes[t.name].type=`string`,this.storyArgTypes[t.name].control=`text`),t.defaultValue&&(this.storyArgs[t.name]=`"${t.defaultValue}"`),t.chainValues&&(e.value=t.chainValues.join(` | `)),n.push(e)}n.length>0&&(t.style=n)}return t}prepareMethodToTranspile(e){if(e=e.trim(),e.startsWith(`function`)&&(e=e.replace(`function`,``),e=e.trim()),!e.match(/^\(.*?\)( *?)=>/g)&&!e.match(/^\S*?( *?)=>/g)){e=e.replace(/^.*?\(/g,`(`);let t=e.match(/^\(.*?\)/g);t&&(e=e.replace(t[0],t[0]+` => `))}return e}transpileMethodNoRun(e){try{e=this.prepareMethodToTranspile(e);let t=(0,p.transpile)(e,Kt.getCompilerOptionsCompile()).trim();return t=t.substring(0,t.length-1),t=`(`+t+`)`,t}catch{}return``}_validateTypeForProp(e,t,n){if(n.kind==`boolean`||n.kind==`number`||n.kind==`string`)return n;if(n.kind==`type`){if(n.value==`Date`||n.value==`DateTime`||n.value==`Time`)return n;{let r=A.getBaseInfo(n.value,e.uri);if(r&&r instanceof yt)return this._validateTypeForProp(e,t,r.type)}}else if(n.kind==`literal`)return n;else if(n.kind==`union`){let r;for(let e of n.nested)if(e.kind==`undefined`&&(t.isNullable=!0),!r)e.kind!=`undefined`&&(r=e);else if(e.kind!=r.kind&&e.kind!=`undefined`){r=void 0;break}if(r)return r.kind==`literal`?n:this._validateTypeForProp(e,t,r)}else if(n.kind==`typeOperator`&&n.value==`keyof`)return n;return this.result.diagnostics.push(L(e,`Can't use the the type `+n.kind+` (`+n.value+`) as attribute / property`,t.nameStart,t.nameEnd,1016)),null}validateTypeForProp(e,t){t.name.toLowerCase()!=t.name&&this.result.diagnostics.push(L(this.document,`An attribute must be in lower case`,t.nameStart,t.nameEnd,1005));let n=this._validateTypeForProp(e,t,t.type);return n&&(n.kind==`boolean`||n.kind==`number`?!t.overrideNullable&&t.defaultValue===null&&this.result.diagnostics.push(L(this.document,`You must add ! after the name to avoid undefined value`,t.nameStart,t.nameEnd,1025)):!t.isNullable&&t.defaultValue===null&&this.result.diagnostics.push(L(this.document,`You must add ? after the name to allow undefined value`,t.nameStart,t.nameEnd,1026))),n}removeWhiteSpaceLines(e){return e.replace(/^(?:[\t ]*(?:\r?\n|\r))+/gm,``)}},bn=class e{static parse(t,n){return new e(t,n)}AventusDefaultComponent=`Aventus.DefaultComponent`;end=-1;currentNamespace=[];fullname=``;className=``;tagName=null;whiteSpaceBefore=0;writeHtml=!1;writeTs=!1;prefixes;isAbstract=!1;constructor(e,t){this.currentNamespace.push(t.module),t.isCoreBuild&&(this.AventusDefaultComponent=`DefaultComponent`),this.prefixes=t.getComponentPrefix().split(`-`),this.loadRoot((0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0))}loadRoot(e){if(e.kind==p.SyntaxKind.ModuleDeclaration)return this.loadNamespace(e);if((0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.ModuleDeclaration)return this.loadNamespace(e);if(e.kind==p.SyntaxKind.ClassDeclaration)return this.loadClass(e)}),this.end)return!0}loadNamespace(e){if(tt(e.flags,p.NodeFlags.Namespace)&&e.body){this.currentNamespace.push(e.name.getText());let t=this.loadRoot(e.body);return this.currentNamespace.splice(this.currentNamespace.length-1,1),t}else if(tt(e.flags,p.NodeFlags.GlobalAugmentation)&&e.body)return this.loadRoot(e.body)}loadClass(e){let t=/^(\s)*/.exec(e.getText());if(t&&(this.whiteSpaceBefore=t[0].length),e.modifiers)for(let t of e.modifiers)t.kind==p.SyntaxKind.AbstractKeyword&&(this.isAbstract=!0);if(e.name&&e.heritageClauses){let t=e.name;for(let n of e.heritageClauses)if(n.token==p.SyntaxKind.ImplementsKeyword&&((0,p.forEachChild)(n,n=>{if(n.kind==p.SyntaxKind.ExpressionWithTypeArguments&&n.getText()==this.AventusDefaultComponent){this.end=e.getEnd(),this.fullname=[...this.currentNamespace,t.getText()].join(`.`),this.className=t.getText();let n=at.buildDecorator(e);for(let e of n){let t=zt.is(e);if(t){t.writeHTML&&(this.writeHtml=!0),t.writeComponentTs&&(this.writeTs=!0);continue}if(!this.isAbstract){let t=rn.is(e);t&&(this.tagName=t.tagName)}}if(!this.isAbstract&&this.tagName==null){let e=this.className.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g);if(e){for(let t=0;t<this.prefixes.length;t++){let n=this.prefixes[t];if(n.length>0&&e[t].toLowerCase()!=n.toLowerCase()){e.splice(0,0,this.prefixes.join(`-`).toLowerCase());break}}this.tagName=e.join(`-`).toLowerCase()}}return!0}}),this.end))return!0}}},j=class e extends Pt{_compilationResult;canUpdateComponent=!0;viewMethodsInfo=[];storyBookInfo={argsTypes:{},args:{}};get compilationResult(){return this._compilationResult}get extension(){return w.ComponentLogic}get version(){let e=yn.getVersion(this,this.build);return e.html=e.html==-1?0:e.html,e.i18n=e.i18n==-1?0:e.i18n,e.scss=e.scss==-1?0:e.scss,e.ts=e.ts==-1?0:e.ts,e.html+e.i18n+e.scss+e.ts}get HTMLFile(){return this.file.uri.endsWith(w.Component)?this.build.wcFiles[this.file.uri].view:this.build.htmlFiles[this.file.uri.replace(w.ComponentLogic,w.ComponentView)]}get SCSSFile(){return this.file.uri.endsWith(w.Component)?this.build.wcFiles[this.file.uri].style:this.build.scssFiles[this.file.uri.replace(w.ComponentLogic,w.ComponentStyle)]}get I18nFile(){return this.build.i18nComponentsFiles[this.file.uri.replace(w.ComponentLogic,w.I18n)]}_fullname=``;get fullName(){return this._fullname}get viewMethodName(){return`__`+oa(this.fullName)+`method`}_componentEnd=0;get componentEnd(){return this._componentEnd}_componentClassName=``;get componentClassName(){return this._componentClassName}_space=``;writeHtml=!1;writeTs=!1;needRebuild=!1;htmlDiagnostics=[];constructor(e,t){super(e,t),e.linkInternalAndUser=!1,this.quickParse(),this.refreshFileParsed()}waitingFct={};mergedVersion=`-1_-1_-1_-1`;isCompiling=!1;runWebCompiler(){return new Promise(e=>{let t=yn.getVersion(this,this.build),n=t.ts+`_`+t.scss+`_`+t.html+`_`+t.i18n,r=this.build.insideRebuildAll||this.needRebuild;if(n==this.mergedVersion&&!r)e();else if(this.isCompiling)this.waitingFct[n]||(this.waitingFct[n]=[]),this.waitingFct[n].push(()=>{e()});else{this.isCompiling=!0,this.needRebuild=!1,this.recreateFileContent();let t=new yn(this,this.build);if(this._compilationResult=t.compile(),this.build.scssLanguageService.addInternalDefinition(this.file.uri,this._compilationResult.scssDoc),this.build.htmlLanguageService.addInternalDefinition(this.file.uri,this._compilationResult.htmlDoc,this),this.needRebuild=this._compilationResult.needRebuild,this.isCompiling=!1,this.mergedVersion=n,this.storyBookInfo.argsTypes=t.storyArgTypes,this.storyBookInfo.args=t.storyArgs,this.I18nFile&&this.I18nFile.transformForExport(),this.waitingFct[n])for(let e of this.waitingFct[n])e();e()}})}lastFileVersionCreated={html:-1,js:-1,i18n:-1};typeInfered={};recreateFileContent(){let e=this.HTMLFile,t=e?.file.versionUser??0,n=this.I18nFile,r=n?.file.versionUser??0,i=this.file.documentUser.version+t+r+1;if(e){let a=!1,o=!1;if(this.lastFileVersionCreated.js==this.file.documentUser.version?this.lastFileVersionCreated.html==t?this.lastFileVersionCreated.i18n!=r&&(a=!0):a=!0:(a=!0,o=!0),a){this.lastFileVersionCreated={html:t,js:this.file.documentUser.version,i18n:r};let a=``;if(this.componentEnd>=0){let t=this.file.documentUser.getText(),r=1;for(;[`}`,` `,` `].includes(t[this.componentEnd-r]);)r++;a=t.slice(0,this.componentEnd-r),this.viewMethodsInfo=[];let s=0,c=``,l=e=>{let t=[];for(let n of e){let e=this.typeInfered[n]??`any`;t.push(n+`:`+e)}return t};o&&(()=>{if(!e)return;let t=e.fileParsed?.loops??[],n=0;for(let e of t){let t=l(e.variables),r=a;r+=`/** */\n@NoCompile()\nprivate ${e.loopName}(${t.join(`,`)}): void {\n`;let o=r.length;r+=e.loopTxt+`
465
+ `)??``,values:[]}}}writeFileReplaceVar(e,t){let n=RegExp(`\\$`+e+`\\$`,`g`);this.template=this.template.replace(n,t+``)}writeFileHotReloadReplaceVar(e,t){if(D.isRunning){let n=RegExp(`\\$`+e+`\\$`,`g`);this.templateHotReload=this.templateHotReload.replace(n,t+``)}}writeFileNpmReplaceVar(e,t){if(this.templateNpm){let n=RegExp(`\\$`+e+`\\$`,`g`);this.templateNpm=this.templateNpm.replace(n,t+``)}}createMissingMethod(e,t,n){if(!this.htmlParsed)return;if(this.result.missingMethods.position==-1){let e=tn(this.file,`methods`);this.result.missingMethods.position=e}let r=`missing method `+e;this.result.missingMethods.elements.includes(e)||(this.result.missingMethods.elements.push(e),this.result.diagnostics.push(Hi(this.document,r,`methods`,1019))),this.htmlFile&&this.htmlFile.tsErrors.push(Gi(this.htmlFile.file.documentUser,r,t,n))}createMissingViewElement(e){let t=[];for(let n in e.tags){let r=this.build.htmlLanguageService.getClassByTag(n),i=``;i=r||this.build.htmlLanguageService.getGenericHTML(n)||`HTMLElement`,e.tags[n]>1&&(i+=`[]`),t.push(i)}let n=``;if(t.length==1)n=t[0];else if(t.length>1){for(let e=0;e<t.length;e++)t[e]=t[e].replace(`[]`,``);n=`(`+t.join(` | `)+`)[]`}let r=`Missing variable view element`+e.name;if(this.result.missingViewElements.elements[e.name]=n,this.result.diagnostics.push(Hi(this.document,r,`variables`,1011)),this.htmlFile)for(let t of e.positions)this.htmlFile.tsErrors.push(Gi(this.htmlFile.file.documentUser,r,t.start,t.end))}createUnusedViewElement(e){let t=e.name;this.overrideViewDecorator?this.overrideViewDecorator.removeViewVariables.indexOf(t)==-1&&this.result.diagnostics.push(L(this.document,`Can't find the variable `+t+` inside the view`,e.nameStart,e.nameEnd,1012,{start:e.start,end:e.end})):this.result.diagnostics.push(L(this.document,`Can't find the variable `+t+` inside the view`,e.nameStart,e.nameEnd,1012,{start:e.start,end:e.end}))}isCallback(e,t){let n;n=t.startsWith(`on`)?[t]:[t,`on`+t,`on`+t.charAt(0).toUpperCase()+t.slice(1)];for(let t of n){let n=e.getField(t);if(n){let e=n.type.value;if(Dt.includes(e))return t}}return null}prepareDocSCSS(){let e=this.scssFile?.customProperties??[],t={[this.tagName]:e};if(this.hasStory&&this.classInfo?.storieContent){let t=this.classInfo.storieContent;delete t.style;let n=[];for(let t of e){this.storyArgTypes[t.name]={table:{category:`Style`}};let e={name:t.name};t.documentation&&(this.storyArgTypes[t.name].description=t.documentation,e.documentation=t.documentation),t.type&&(e.type=t.type),t.type==`color`?(this.storyArgTypes[t.name].control=`color`,this.storyArgTypes[t.name].type=`color`):(this.storyArgTypes[t.name].type=`string`,this.storyArgTypes[t.name].control=`text`),t.defaultValue&&(this.storyArgs[t.name]=`"${t.defaultValue}"`),t.chainValues&&(e.value=t.chainValues.join(` | `)),n.push(e)}n.length>0&&(t.style=n)}return t}prepareMethodToTranspile(e){if(e=e.trim(),e.startsWith(`function`)&&(e=e.replace(`function`,``),e=e.trim()),!e.match(/^\(.*?\)( *?)=>/g)&&!e.match(/^\S*?( *?)=>/g)){e=e.replace(/^.*?\(/g,`(`);let t=e.match(/^\(.*?\)/g);t&&(e=e.replace(t[0],t[0]+` => `))}return e}transpileMethodNoRun(e){try{e=this.prepareMethodToTranspile(e);let t=(0,p.transpile)(e,Kt.getCompilerOptionsCompile()).trim();return t=t.substring(0,t.length-1),t=`(`+t+`)`,t}catch{}return``}_validateTypeForProp(e,t,n){if(n.kind==`boolean`||n.kind==`number`||n.kind==`string`)return n;if(n.kind==`type`){if(n.value==`Date`||n.value==`DateTime`||n.value==`Time`)return n;{let r=A.getBaseInfo(n.value,e.uri);if(r&&r instanceof yt)return this._validateTypeForProp(e,t,r.type)}}else if(n.kind==`literal`)return n;else if(n.kind==`union`){let r;for(let e of n.nested)if(e.kind==`undefined`&&(t.isNullable=!0),!r)e.kind!=`undefined`&&(r=e);else if(e.kind!=r.kind&&e.kind!=`undefined`){r=void 0;break}if(r)return r.kind==`literal`?n:this._validateTypeForProp(e,t,r)}else if(n.kind==`typeOperator`&&n.value==`keyof`)return n;return this.result.diagnostics.push(L(e,`Can't use the the type `+n.kind+` (`+n.value+`) as attribute / property`,t.nameStart,t.nameEnd,1016)),null}validateTypeForProp(e,t){t.name.toLowerCase()!=t.name&&this.result.diagnostics.push(L(this.document,`An attribute must be in lower case`,t.nameStart,t.nameEnd,1005));let n=this._validateTypeForProp(e,t,t.type);return n&&(n.kind==`boolean`||n.kind==`number`?!t.overrideNullable&&t.defaultValue===null&&this.result.diagnostics.push(L(this.document,`You must add ! after the name to avoid undefined value`,t.nameStart,t.nameEnd,1025)):!t.isNullable&&t.defaultValue===null&&this.result.diagnostics.push(L(this.document,`You must add ? after the name to allow undefined value`,t.nameStart,t.nameEnd,1026))),n}removeWhiteSpaceLines(e){return e.replace(/^(?:[\t ]*(?:\r?\n|\r))+/gm,``)}},bn=class e{static parse(t,n){return new e(t,n)}AventusDefaultComponent=`Aventus.DefaultComponent`;end=-1;currentNamespace=[];fullname=``;className=``;tagName=null;whiteSpaceBefore=0;writeHtml=!1;writeTs=!1;prefixes;isAbstract=!1;constructor(e,t){this.currentNamespace.push(t.module),t.isCoreBuild&&(this.AventusDefaultComponent=`DefaultComponent`),this.prefixes=t.getComponentPrefix().split(`-`),this.loadRoot((0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0))}loadRoot(e){if(e.kind==p.SyntaxKind.ModuleDeclaration)return this.loadNamespace(e);if((0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.ModuleDeclaration)return this.loadNamespace(e);if(e.kind==p.SyntaxKind.ClassDeclaration)return this.loadClass(e)}),this.end)return!0}loadNamespace(e){if(tt(e.flags,p.NodeFlags.Namespace)&&e.body){this.currentNamespace.push(e.name.getText());let t=this.loadRoot(e.body);return this.currentNamespace.splice(this.currentNamespace.length-1,1),t}else if(tt(e.flags,p.NodeFlags.GlobalAugmentation)&&e.body)return this.loadRoot(e.body)}loadClass(e){let t=/^(\s)*/.exec(e.getText());if(t&&(this.whiteSpaceBefore=t[0].length),e.modifiers)for(let t of e.modifiers)t.kind==p.SyntaxKind.AbstractKeyword&&(this.isAbstract=!0);if(e.name&&e.heritageClauses){let t=e.name;for(let n of e.heritageClauses)if(n.token==p.SyntaxKind.ImplementsKeyword&&((0,p.forEachChild)(n,n=>{if(n.kind==p.SyntaxKind.ExpressionWithTypeArguments&&n.getText()==this.AventusDefaultComponent){this.end=e.getEnd(),this.fullname=[...this.currentNamespace,t.getText()].join(`.`),this.className=t.getText();let n=at.buildDecorator(e);for(let e of n){let t=zt.is(e);if(t){t.writeHTML&&(this.writeHtml=!0),t.writeComponentTs&&(this.writeTs=!0);continue}if(!this.isAbstract){let t=rn.is(e);t&&(this.tagName=t.tagName)}}if(!this.isAbstract&&this.tagName==null){let e=this.className.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g);if(e){for(let t=0;t<this.prefixes.length;t++){let n=this.prefixes[t];if(n.length>0&&e[t].toLowerCase()!=n.toLowerCase()){e.splice(0,0,this.prefixes.join(`-`).toLowerCase());break}}this.tagName=e.join(`-`).toLowerCase()}}return!0}}),this.end))return!0}}},j=class e extends Pt{_compilationResult;canUpdateComponent=!0;viewMethodsInfo=[];storyBookInfo={argsTypes:{},args:{}};get compilationResult(){return this._compilationResult}get extension(){return w.ComponentLogic}get version(){let e=yn.getVersion(this,this.build);return e.html=e.html==-1?0:e.html,e.i18n=e.i18n==-1?0:e.i18n,e.scss=e.scss==-1?0:e.scss,e.ts=e.ts==-1?0:e.ts,e.html+e.i18n+e.scss+e.ts}get HTMLFile(){return this.file.uri.endsWith(w.Component)?this.build.wcFiles[this.file.uri].view:this.build.htmlFiles[this.file.uri.replace(w.ComponentLogic,w.ComponentView)]}get SCSSFile(){return this.file.uri.endsWith(w.Component)?this.build.wcFiles[this.file.uri].style:this.build.scssFiles[this.file.uri.replace(w.ComponentLogic,w.ComponentStyle)]}get I18nFile(){return this.build.i18nComponentsFiles[this.file.uri.replace(w.ComponentLogic,w.I18n)]}_fullname=``;get fullName(){return this._fullname}get viewMethodName(){return`__`+la(this.fullName)+`method`}_componentEnd=0;get componentEnd(){return this._componentEnd}_componentClassName=``;get componentClassName(){return this._componentClassName}_space=``;writeHtml=!1;writeTs=!1;needRebuild=!1;htmlDiagnostics=[];constructor(e,t){super(e,t),e.linkInternalAndUser=!1,this.quickParse(),this.refreshFileParsed()}waitingFct={};mergedVersion=`-1_-1_-1_-1`;isCompiling=!1;runWebCompiler(){return new Promise(e=>{let t=yn.getVersion(this,this.build),n=t.ts+`_`+t.scss+`_`+t.html+`_`+t.i18n,r=this.build.insideRebuildAll||this.needRebuild;if(n==this.mergedVersion&&!r)e();else if(this.isCompiling)this.waitingFct[n]||(this.waitingFct[n]=[]),this.waitingFct[n].push(()=>{e()});else{this.isCompiling=!0,this.needRebuild=!1,this.recreateFileContent();let t=new yn(this,this.build);if(this._compilationResult=t.compile(),this.build.scssLanguageService.addInternalDefinition(this.file.uri,this._compilationResult.scssDoc),this.build.htmlLanguageService.addInternalDefinition(this.file.uri,this._compilationResult.htmlDoc,this),this.needRebuild=this._compilationResult.needRebuild,this.isCompiling=!1,this.mergedVersion=n,this.storyBookInfo.argsTypes=t.storyArgTypes,this.storyBookInfo.args=t.storyArgs,this.I18nFile&&this.I18nFile.transformForExport(),this.waitingFct[n])for(let e of this.waitingFct[n])e();e()}})}lastFileVersionCreated={html:-1,js:-1,i18n:-1};typeInfered={};recreateFileContent(){let e=this.HTMLFile,t=e?.file.versionUser??0,n=this.I18nFile,r=n?.file.versionUser??0,i=this.file.documentUser.version+t+r+1;if(e){let a=!1,o=!1;if(this.lastFileVersionCreated.js==this.file.documentUser.version?this.lastFileVersionCreated.html==t?this.lastFileVersionCreated.i18n!=r&&(a=!0):a=!0:(a=!0,o=!0),a){this.lastFileVersionCreated={html:t,js:this.file.documentUser.version,i18n:r};let a=``;if(this.componentEnd>=0){let t=this.file.documentUser.getText(),r=1;for(;[`}`,` `,` `].includes(t[this.componentEnd-r]);)r++;a=t.slice(0,this.componentEnd-r),this.viewMethodsInfo=[];let s=0,c=``,l=e=>{let t=[];for(let n of e){let e=this.typeInfered[n]??`any`;t.push(n+`:`+e)}return t},u=(e,t)=>{if(!e||!t)return`Aventus.NotVoid`;let n=this.build.getWebComponentDefinition(e),r=n?.class.getField(t);if(!n||!r||r.isPrivate||r.isProtected||r.isStatic)return`Aventus.NotVoid`;let i=n.class.fullName;if(n.isLocal&&n.class.fileUri!=this.file.uri){let e=(0,f.relative)((0,f.dirname)(I(this.file.uri)),I(n.class.fileUri)).replace(/\\/g,`/`);e.startsWith(`.`)||(e=`./`+e),i=`import(${JSON.stringify(e)}).${n.class.name}`}return`InstanceType<typeof ${i}>[${JSON.stringify(t)}]`};o&&(()=>{if(!e)return;let t=e.fileParsed?.loops??[],n=0;for(let e of t){let t=l(e.variables),r=a;r+=`/** */\n@NoCompile()\nprivate ${e.loopName}(${t.join(`,`)}): void {\n`;let o=r.length;r+=e.loopTxt+`
466
466
  `,r+=`}
467
467
  `,r+=`}`,this.file instanceof E&&(this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,(i+n)*-1,r)),this._contentForLanguageService=r);for(let t of e.typeToLoad){let n=o+(Math.floor((t.start+t.end)/2)-e.start),r=e.loopTxt.slice(t.start-e.start,t.end-e.start),i=this.tsLanguageService.getType(this,n)??`any`;this.typeInfered[r]=i}n++}let r=e.fileParsed?.contextEdits??[];for(let e of r){let t=l(e.variables),r=a;r+=`/** */\n@NoCompile()\nprivate ${e.editName}(${t.join(`,`)}): void {\n`;let o=r.length;r+=e.fctTs+`
468
468
  `,r+=`}
469
- `,r+=`}`,this.file instanceof E&&(this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,(i+n)*-1,r)),this._contentForLanguageService=r);for(let t of e.typeToLoad){let n=o+(Math.floor((t.start+t.end)/2)-e.start),r=this.tsLanguageService.getType(this,n)??`any`;this.typeInfered[t.txt]=r}}})();let u=e.fileParsed?.loops??[];for(let e of u){let t=a.length,n=l(e.variables),r=this._space;a+=`\n${r}/** */\n${r}@NoCompile()\n${r}private ${e.loopName}(${n.join(`,`)}): void {\n`;let i=a.length;a+=e.loopTxt+`
469
+ `,r+=`}`,this.file instanceof E&&(this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,(i+n)*-1,r)),this._contentForLanguageService=r);for(let t of e.typeToLoad){let n=o+(Math.floor((t.start+t.end)/2)-e.start),r=this.tsLanguageService.getType(this,n)??`any`;this.typeInfered[t.txt]=r}}})();let p=e.fileParsed?.loops??[];for(let e of p){let t=a.length,n=l(e.variables),r=this._space;a+=`\n${r}/** */\n${r}@NoCompile()\n${r}private ${e.loopName}(${n.join(`,`)}): void {\n`;let i=a.length;a+=e.loopTxt+`
470
470
  `;let o=a.length;a+=r+`}`,this.viewMethodsInfo.push(function(){return{name:e.loopName,fullStart:t,start:i,end:o,offsetBefore:0,offsetAfter:0,kind:`loop`,fct:{txt:e.loopTxt,positions:[{start:e.start,end:e.startBlock}]},transform(e,t){return t}}}()),e.isSimple||(a+=`\n${r}/** */\n${r}private ${e.complex.loopName}(${n.join(`,`)}) {\n
471
471
  ${e.complex.init.join(`;
472
472
  `)}
@@ -482,24 +482,24 @@ this.clearWatchHistory = () => {
482
482
  return ({${e.complex.apply}})
483
483
  }
484
484
  }
485
- }`)}let f=e.fileParsed?.fcts??{};for(let e of Object.values(f)){let t=e.txt.replace(/\n/g,`;`),n=-1,r=t.split(`;`);if(!t.includes(`return `)&&r.length>0){let e=r.pop();n=r.join(`
485
+ }`)}let m=e.fileParsed?.fcts??{};for(let e of Object.values(m)){let t=e.txt.replace(/\n/g,`;`),n=-1,r=t.split(`;`);if(!t.includes(`return `)&&r.length>0){let e=r.pop();n=r.join(`
486
486
  `).length,e?.startsWith(` `)?(r.push(`return`+e),s=6):(r.push(`return `+e),s=7)}t=r.join(`
487
- `);let i=a.length,o=l(e.variables),c=this._space;a+=`\n${c}/** */\n${c}private ${e.name}(${o.join(`,`)}): Aventus.NotVoid {\n`;let u=a.length;a+=t+`
488
- `;let d=a.length;a+=c+`}`,this.viewMethodsInfo.push(function(t,n){return{name:e.name,fullStart:i,start:u,end:d,fct:e,offsetBefore:2,offsetAfter:2,kind:`fct`,transform(e,r){return e>=t&&(r+=n),r}}}(n,s))}let p=e.fileParsed?.ifs??[];for(let e of p)for(let t of e.conditions){let e=t.txt.replace(/\n/g,`;`),n=-1,r=e.split(`;`);if(!e.includes(`return `)&&r.length>0){let e=r.pop();n=r.join(`
487
+ `);let i=a.length,o=l(e.variables),c=u(e.tagName,e.attributeName),d=this._space;a+=`\n${d}/** */\n${d}private ${e.name}(${o.join(`,`)}): ${c} {\n`;let f=a.length;a+=t+`
488
+ `;let p=a.length;a+=d+`}`,this.viewMethodsInfo.push(function(t,n){return{name:e.name,fullStart:i,start:f,end:p,fct:e,offsetBefore:2,offsetAfter:2,kind:`fct`,transform(e,r){return e>=t&&(r+=n),r}}}(n,s))}let h=e.fileParsed?.ifs??[];for(let e of h)for(let t of e.conditions){let e=t.txt.replace(/\n/g,`;`),n=-1,r=e.split(`;`);if(!e.includes(`return `)&&r.length>0){let e=r.pop();n=r.join(`
489
489
  `).length,e?.startsWith(` `)?(r.push(`return`+e),s=6):(r.push(`return `+e),s=7)}e=r.join(`
490
490
  `);let i=a.length,o=l(t.variables),c=this._space;a+=`\n${c}/** */\n${c}private ${t.fctName}(${o.join(`,`)}): Aventus.NotVoid {\n`;let u=a.length;a+=e+`
491
- `;let d=a.length;a+=c+`}`,this.viewMethodsInfo.push(function(n,r){return{name:t.fctName,fullStart:i,start:u,end:d,kind:`if`,fct:{positions:[{start:t.start,end:t.end}],txt:e},offsetBefore:t.offsetBefore,offsetAfter:t.offsetAfter,transform(e,t){return e>=n&&(t+=r),t}}}(n,s))}let m=e.fileParsed?.contextEdits??[];for(let e of m){let t=a.length,n=l(e.variables),r=this._space;a+=`\n${r}/** */\n${r}private ${e.editName}(${n.join(`,`)}): { [key: string]: any } {\n`;let i=a.length;a+=e.fctTs+`
492
- `;let o=a.length;a+=r+`}`,this.viewMethodsInfo.push(function(){return{name:e.editName,fullStart:t,start:i,end:o,offsetBefore:0,offsetAfter:0,kind:`context`,fct:{txt:e.fctTs,positions:[{start:e.start,end:e.end}]},transform(e,t){return t}}}())}let h=e=>{let t=e.injectTsTxt.replace(/\n/g,`;`),n=-1,r=t.split(`;`);if(!t.includes(`return `)&&r.length>0){let e=r.pop();n=r.join(`
491
+ `;let d=a.length;a+=c+`}`,this.viewMethodsInfo.push(function(n,r){return{name:t.fctName,fullStart:i,start:u,end:d,kind:`if`,fct:{positions:[{start:t.start,end:t.end}],txt:e},offsetBefore:t.offsetBefore,offsetAfter:t.offsetAfter,transform(e,t){return e>=n&&(t+=r),t}}}(n,s))}let g=e.fileParsed?.contextEdits??[];for(let e of g){let t=a.length,n=l(e.variables),r=this._space;a+=`\n${r}/** */\n${r}private ${e.editName}(${n.join(`,`)}): { [key: string]: any } {\n`;let i=a.length;a+=e.fctTs+`
492
+ `;let o=a.length;a+=r+`}`,this.viewMethodsInfo.push(function(){return{name:e.editName,fullStart:t,start:i,end:o,offsetBefore:0,offsetAfter:0,kind:`context`,fct:{txt:e.fctTs,positions:[{start:e.start,end:e.end}]},transform(e,t){return t}}}())}let _=e=>{let t=e.injectTsTxt.replace(/\n/g,`;`),n=-1,r=t.split(`;`);if(!t.includes(`return `)&&r.length>0){let e=r.pop();n=r.join(`
493
493
  `).length,e?.startsWith(` `)?(r.push(`return`+e),s=6):(r.push(`return `+e),s=7)}t=r.join(`
494
- `);let i=a.length,o=l(e.variables),c=this._space;a+=`\n${c}/** */\n${c}private ${e.injectFctName}(${o.join(`,`)}): Aventus.NotVoid {\n`;let u=a.length;a+=t+`
495
- `;let d=a.length;a+=c+`}`,this.viewMethodsInfo.push(function(t,n){return{name:e.injectFctName,fullStart:i,start:u,end:d,fct:{txt:e.injectTsTxt,positions:[{start:e.start,end:e.end}]},offsetBefore:1,offsetAfter:1,kind:`fct`,transform(e,r){return e>=t&&(r+=n),r}}}(n,s))},g=e.fileParsed?.injections??[];for(let e of g)h(e);let _=e.fileParsed?.bindings??[];for(let e of _){h(e);let t,n=l(e.variables),r=0,i=`v`;for(;e.variables.includes(i);)r++,i=`v`+r;n=[i+`: any`].concat(n),t=e.extractTsCond.length==0?e.extractTsTxt.replace(/\n/g,`;`)+` = `+i:`if( `+e.extractTsCond+` ) { `+e.extractTsTxt.replace(/\n/g,`;`)+` = `+i+` }`;let o=this._space;a+=`\n${o}/** */\n${o}private ${e.extractFctName}(${n.join(`,`)}): void {\n`,a.length,a+=t+`
494
+ `);let i=a.length,o=l(e.variables),c=this._space,d=u(e.tagName,e.attributeName);a+=`\n${c}/** */\n${c}private ${e.injectFctName}(${o.join(`,`)}): ${d} {\n`;let f=a.length;a+=t+`
495
+ `;let p=a.length;a+=c+`}`,this.viewMethodsInfo.push(function(t,n){return{name:e.injectFctName,fullStart:i,start:f,end:p,fct:{txt:e.injectTsTxt,positions:[{start:e.start,end:e.end}]},offsetBefore:1,offsetAfter:1,kind:`fct`,transform(e,r){return e>=t&&(r+=n),r}}}(n,s))},v=e.fileParsed?.injections??[];for(let e of v)_(e);let y=e.fileParsed?.bindings??[];for(let e of y){_(e);let t,n=l(e.variables),r=0,i=`v`;for(;e.variables.includes(i);)r++,i=`v`+r;n=[i+`: any`].concat(n),t=e.extractTsCond.length==0?e.extractTsTxt.replace(/\n/g,`;`)+` = `+i:`if( `+e.extractTsCond+` ) { `+e.extractTsTxt.replace(/\n/g,`;`)+` = `+i+` }`;let o=this._space;a+=`\n${o}/** */\n${o}private ${e.extractFctName}(${n.join(`,`)}): void {\n`,a.length,a+=t+`
496
496
  `,a.length,a+=o+`}`}this.build.buildConfig.i18n&&n&&(e=>{let t=`\n@NoCompile()\npublic override t(key: keyof ${this.componentClassName}__Generated | keyof Aventus.AventusI18n, params: { [key: string]: string; } = {}): string {
497
497
  return super.t(key as keyof Aventus.AventusI18n, params);
498
498
  }`;a+=t+`
499
499
  `;let n=e.keys.map(e=>`"${e.replace(/"/g,`\\"`)}": string`).join(`,
500
500
  `);c+=`\ntype ${this.componentClassName}__Generated = {
501
501
  ${n}
502
- }`})(n),a+=t.slice(this.componentEnd-r),a+=c,this.file instanceof E&&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)&&sa(s),this.writeTs?(0,u.writeFileSync)(c,a):(0,u.existsSync)(c)&&sa(c)}}else this.file instanceof E&&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=C.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=bn.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`,Zi(this.compilationResult.debug,this.build.project.getConfig())):(0,u.existsSync)(this.file.folderPath+`/compiled.js`)&&sa(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+=`.`),D.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=C.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(w.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(w.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()
502
+ }`})(n),a+=t.slice(this.componentEnd-r),a+=c,this.file instanceof E&&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)&&ua(s),this.writeTs?(0,u.writeFileSync)(c,a):(0,u.existsSync)(c)&&ua(c)}}else this.file instanceof E&&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=C.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=bn.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`,Zi(this.compilationResult.debug,this.build.project.getConfig())):(0,u.existsSync)(this.file.folderPath+`/compiled.js`)&&ua(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+=`.`),D.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=C.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(w.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(w.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()
503
503
  protected `+t+`!: `+this.compilationResult.missingViewElements.elements[t]+`;
504
504
  `}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+=`/**
505
505
  *
@@ -508,8 +508,8 @@ protected ${t}(){
508
508
  throw new Error("Method not implemented.");
509
509
  }
510
510
  `}return e!=``&&(e=`
511
- `+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})))}},xn=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==En.tagName}get isIf(){return this.tagName==Dn.tagName}get isContextEditing(){return this.tagName==On.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||(M.addInterestPoint({name:t,start:M.fromCompiledToRaw(n),end:M.fromCompiledToRaw(r),type:`tag`}),Sn.includes(t)&&(this.selfClosing=!0))}createId(){return this.id||(this.id=this.idBase+M.idElement,M.idElement++),this.id}addAttribute(e){if(e.name==`@for`){M.addError(e.nameStart,e.nameEnd,`Deprecated : use for directly inside template`);return}this.attributes[e.name]?M.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=M.getParentId();let e=M.addLoopStack(Number(this.attributes.id.value));e&&(this.loopInfo=e)}else if(this.isIf){this.parentTemplateId=M.getParentId();let e=Number(this.attributes.id.value),t=M.addIfStack(e);t&&(this.ifInfo=t,e==t.idsTemplate[0]&&(t._id=this.createId()))}else if(this.isContextEditing){this.parentTemplateId=M.getParentId();let e=Number(this.attributes.id.value),t=M.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)}M.addTagInfoStack(this)}afterClose(e,t){this.hasClose=!0,this.selfClosing||M.addInterestPoint({name:this.tagName,start:M.fromCompiledToRaw(e),end:M.fromCompiledToRaw(t),type:`tag`}),this.checkStyle(M.getRules(),e=>M.addStyleLink(e)),M.removeStack(),(this.isLoop||this.isIf)&&M.removeStack()}checkStyle(e,t){for(let[n,r]of e)n(this)&&t([{start:M.fromCompiledToRaw(this.openTagStart),end:M.fromCompiledToRaw(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);M.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);M.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);M.mergeTemplateResult(n,e)}}return n}};const Sn=[`area`,`base`,`br`,`col`,`embed`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`],Cn=[`_id`];var wn=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=M.fromCompiledToRaw(t),this.nameEnd=M.fromCompiledToRaw(n),this.tag=r,this.manageSpecialAttribute()}manageSpecialAttribute(){this.name.startsWith(`@`)||this.name.startsWith(`:`)?(this.tag.createId(),this.mustBeAdded=!1):Cn.includes(this.name)&&(M.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=M.fromCompiledToRaw(t),this.valueEnd=M.fromCompiledToRaw(n),this.name!=`@for`)if(this.name===`@element`)this.tag.alias=e,M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`property`});else if(this.name.startsWith(`@bind`)||this.name.startsWith(`$`)){let r=new An(this.name,e,t,n);this.tag.bindings.push(r),M.addBinding(r)}else if(this.name.startsWith(`:`)){let r=new kn(this.name.slice(1),e,t,n);this.tag.injections.push(r),M.addInjection(r)}else if(fn.hasOwnProperty(this.name))this.tag.pressEvent||(this.tag.pressEvent={}),this.tag.pressEvent[fn[this.name]]={value:e,start:this.valueStart,end:this.valueEnd},M.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}),M.addInterestPoint({name:this.name.slice(1),start:this.nameStart,end:this.nameEnd,type:`event`}),M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else{let t=jn(e,this.valueStart);t.changes.length>0&&(this.tag.addChanges(this.name,t.txt,t.once),this.mustBeAdded=!1)}}},Tn=class{content=``;start=0;end=0;tag;mustBeAdded=!0;constructor(e,t,n,r,i=!0){this.content=e,this.start=M.fromCompiledToRaw(t),this.end=M.fromCompiledToRaw(n),this.tag=r,i&&this.manageVariables()}manageVariables(){let e=this.content,t=jn(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:``}},En=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=M.createIdTemplate(),this.variables=M.getVariables(),e.kind==p.SyntaxKind.ForOfStatement||e.kind==p.SyntaxKind.ForInStatement?(this.isSimple=!0,this.loadForInOf(e)):this.loadFor(e),this.loopName=M.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=M.getCustomFctName(1)??``;this.complex={init:n,condition:i,transform:a,apply:r,loopName:e,fct:`(c) => c.comp.${e}`}}}recalculateVariables(){if(this.variables=Mn(this.loopTxt,M.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)}},Dn=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=M.getVariables(),this.loadIf(e)}loadIf(t){let n=[],r=()=>{let e=M.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=M.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:Nn(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=M.getVariables();for(let n of this.conditions)if(n.idTemplate==e){let e=Mn(n.txt,t),r=e.map(e=>`c.data.`+e).join(`,`);n.fctTxt+=`(${r})`,n.variables=e}}},On=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=M.getCustomFctName()??``,this.id=M.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=Nn(this.fctTs)}}),this.variables=Mn(this.fctTs,M.getVariables());let n=this.variables.map(e=>`c.data.`+e).join(`,`);this.fctJs=`@_@(c) => c.comp.${this.editName}(${n})@_@`}},kn=class{start=0;end=0;attr;injectFctName;injectTsTxt;injectTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){this.attr=e,this.start=M.fromCompiledToRaw(n),this.end=M.fromCompiledToRaw(r),this.injectFctName=M.getCustomFctName()??``,this.injectTsTxt=t,this.computedOnce=Nn(t),this.variables=Mn(t,M.getVariables());let i=this.variables.map(e=>`c.data.`+e).join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${i})`}},An=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=M.fromCompiledToRaw(n),this.end=M.fromCompiledToRaw(r),this.injectFctName=M.getCustomFctName()??``,this.extractFctName=M.getCustomFctName(1)??``,this.injectTsTxt=t,this.computedOnce=Nn(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=Mn(t,M.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 jn(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=M.createChange({txt:r[1],start:e,end:n});if(i.once&&!Nn(r[1])&&(i.once=!1),a){a.variables=Mn(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).replace(/\r\n?/g,`
512
- `),i.changes.push(a)}}return i.changes.length>0&&(i.txt="(c) => `"+i.txt+"`"),i}function Mn(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 Nn(e){return!/if|switch|\?|\[.+?\]|\|\||&&/g.test(e)}var M=class e{static languageService=(0,S.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:C.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:C.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=oa(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 En||!(t instanceof xn))return t.idTemplate}}static getVariables(){let e=[];if(this.currentParsingDoc){for(let t of this.currentParsingDoc.stacks)if(t instanceof En||t instanceof xn)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(/<\/?[A-Za-z][A-Za-z0-9:_-]*(?:\s+(?:[^"'<>]|"[^"]*"|'[^']*')*)?\s*\/?>/g,e=>`'`+e.slice(1,-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 Dn(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 En(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 On(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()!=S.TokenType.EOS;)if(r.length>0){if(a.getTokenType()==S.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 Tn(i,n,r,e,!1))}}else if(a.getTokenType()==S.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()!=S.TokenType.StartTagOpen){if(a.getTokenType()==S.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()==S.TokenType.StartTagSelfClose){let e=o.pop();e&&(e.validateAllProps(a.getTokenOffset()),e.afterClose(a.getTokenOffset(),a.getTokenEnd()))}else if(a.getTokenType()==S.TokenType.StartTag){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd(),r=new xn(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()!=S.TokenType.EndTagOpen&&a.getTokenType()!=S.TokenType.EndTagClose){if(a.getTokenType()==S.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(Gi(t,`The tag `+n?.tagName+` isn't correctly closed`,n?.start,n?.end)):this.errors.push(Gi(t,`No opening tag found for `+e,a.getTokenOffset(),a.getTokenEnd()));return}}else if(a.getTokenType()!=S.TokenType.DelimiterAssign)if(a.getTokenType()==S.TokenType.AttributeName){let e=a.getTokenText();if(o.length>0){let t=o[o.length-1];s=new wn(e,a.getTokenOffset(),a.getTokenEnd(),t),t.addAttribute(s)}}else if(a.getTokenType()==S.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()==S.TokenType.Content){if(o.length>0){let e=o[o.length-1],t=a.getTokenText(),n=a.getTokenOffset(),r=a.getTokenEnd();e.addContent(new Tn(t,n,r,e))}}else a.getTokenType()==S.TokenType.Whitespace||a.getTokenType()==S.TokenType.Unknown||a.getTokenType()==S.TokenType.Script||(a.getTokenType(),S.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]}},Pn=o(((e,t)=>{t.exports=function(e){return e&&typeof e.valueOf()==`string`}})),Fn=o(((e,t)=>{let n=Pn();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}})),In=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}})),Ln=o(((e,t)=>{let n=Pn();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}})),Rn=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("${"))))}})),zn=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}})),Bn=o(((e,t)=>{t.exports=function(e){return!(e[0]===`$`||e[0]===`@`||/#{.+?}|@{.+?}|\$\(.+?\)/.test(e))}})),Vn=o(((e,t)=>{t.exports=function(e){return e.slice(0,2)===`--`}})),Hn=o(((e,t)=>{t.exports=function(e){return e[0]===`$`}})),Un=o(((e,t)=>{t.exports=function(e){return e.type===`atrule`&&e.variable}})),Wn=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}})),Gn=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}})),Kn=o(((e,t)=>{let n=Bn(),r=Vn(),i=Hn(),a=Un(),o=Wn(),s=Gn();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}})),qn=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(`
511
+ `+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})))}},xn=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==En.tagName}get isIf(){return this.tagName==Dn.tagName}get isContextEditing(){return this.tagName==On.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||(M.addInterestPoint({name:t,start:M.fromCompiledToRaw(n),end:M.fromCompiledToRaw(r),type:`tag`}),Sn.includes(t)&&(this.selfClosing=!0))}createId(){return this.id||(this.id=this.idBase+M.idElement,M.idElement++),this.id}addAttribute(e){if(e.name==`@for`){M.addError(e.nameStart,e.nameEnd,`Deprecated : use for directly inside template`);return}this.attributes[e.name]?M.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=M.getParentId();let e=M.addLoopStack(Number(this.attributes.id.value));e&&(this.loopInfo=e)}else if(this.isIf){this.parentTemplateId=M.getParentId();let e=Number(this.attributes.id.value),t=M.addIfStack(e);t&&(this.ifInfo=t,e==t.idsTemplate[0]&&(t._id=this.createId()))}else if(this.isContextEditing){this.parentTemplateId=M.getParentId();let e=Number(this.attributes.id.value),t=M.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)}M.addTagInfoStack(this)}afterClose(e,t){this.hasClose=!0,this.selfClosing||M.addInterestPoint({name:this.tagName,start:M.fromCompiledToRaw(e),end:M.fromCompiledToRaw(t),type:`tag`}),this.checkStyle(M.getRules(),e=>M.addStyleLink(e)),M.removeStack(),(this.isLoop||this.isIf)&&M.removeStack()}checkStyle(e,t){for(let[n,r]of e)n(this)&&t([{start:M.fromCompiledToRaw(this.openTagStart),end:M.fromCompiledToRaw(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);M.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);M.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);M.mergeTemplateResult(n,e)}}return n}};const Sn=[`area`,`base`,`br`,`col`,`embed`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`],Cn=[`_id`];var wn=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=M.fromCompiledToRaw(t),this.nameEnd=M.fromCompiledToRaw(n),this.tag=r,this.manageSpecialAttribute()}manageSpecialAttribute(){this.name.startsWith(`@`)||this.name.startsWith(`:`)?(this.tag.createId(),this.mustBeAdded=!1):Cn.includes(this.name)&&(M.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=M.fromCompiledToRaw(t),this.valueEnd=M.fromCompiledToRaw(n),this.name!=`@for`)if(this.name===`@element`)this.tag.alias=e,M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`property`});else if(this.name.startsWith(`@bind`)||this.name.startsWith(`$`)){let r=new An(this.tag.tagName,this.name,e,t,n);this.tag.bindings.push(r),M.addBinding(r)}else if(this.name.startsWith(`:`)){let r=new kn(this.tag.tagName,this.name.slice(1),e,t,n);this.tag.injections.push(r),M.addInjection(r)}else if(fn.hasOwnProperty(this.name))this.tag.pressEvent||(this.tag.pressEvent={}),this.tag.pressEvent[fn[this.name]]={value:e,start:this.valueStart,end:this.valueEnd},M.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}),M.addInterestPoint({name:this.name.slice(1),start:this.nameStart,end:this.nameEnd,type:`event`}),M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else{let t=jn(e,this.valueStart,this.tag.tagName,this.name);t.changes.length>0&&(this.tag.addChanges(this.name,t.txt,t.once),this.mustBeAdded=!1)}}},Tn=class{content=``;start=0;end=0;tag;mustBeAdded=!0;constructor(e,t,n,r,i=!0){this.content=e,this.start=M.fromCompiledToRaw(t),this.end=M.fromCompiledToRaw(n),this.tag=r,i&&this.manageVariables()}manageVariables(){let e=this.content,t=jn(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:``}},En=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=M.createIdTemplate(),this.variables=M.getVariables(),e.kind==p.SyntaxKind.ForOfStatement||e.kind==p.SyntaxKind.ForInStatement?(this.isSimple=!0,this.loadForInOf(e)):this.loadFor(e),this.loopName=M.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=M.getCustomFctName(1)??``;this.complex={init:n,condition:i,transform:a,apply:r,loopName:e,fct:`(c) => c.comp.${e}`}}}recalculateVariables(){if(this.variables=Mn(this.loopTxt,M.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)}},Dn=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=M.getVariables(),this.loadIf(e)}loadIf(t){let n=[],r=()=>{let e=M.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=M.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:Nn(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=M.getVariables();for(let n of this.conditions)if(n.idTemplate==e){let e=Mn(n.txt,t),r=e.map(e=>`c.data.`+e).join(`,`);n.fctTxt+=`(${r})`,n.variables=e}}},On=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=M.getCustomFctName()??``,this.id=M.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=Nn(this.fctTs)}}),this.variables=Mn(this.fctTs,M.getVariables());let n=this.variables.map(e=>`c.data.`+e).join(`,`);this.fctJs=`@_@(c) => c.comp.${this.editName}(${n})@_@`}},kn=class{start=0;end=0;attr;injectFctName;injectTsTxt;injectTxt;variables=[];computedOnce=!1;tagName;attributeName;constructor(e,t,n,r,i){this.tagName=e,this.attributeName=t,this.attr=t,this.start=M.fromCompiledToRaw(r),this.end=M.fromCompiledToRaw(i),this.injectFctName=M.getCustomFctName()??``,this.injectTsTxt=n,this.computedOnce=Nn(n),this.variables=Mn(n,M.getVariables());let a=this.variables.map(e=>`c.data.`+e).join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${a})`}},An=class{start=0;end=0;event;valueName=`value`;injectFctName;extractFctName;injectTsTxt;extractTsCond;extractTsTxt;injectTxt;extractTxt;variables=[];computedOnce=!1;tagName;attributeName;constructor(e,t,n,r,i){this.tagName=e;let a=t.split(`:`),o=a[0];o.startsWith(`@bind_`)?this.event=o.replace(`@bind_`,``):o.startsWith(`$`)&&o.length>0&&(this.event=o.replace(`$`,``)),a.length>1&&(this.valueName=a[1]),this.attributeName=this.valueName,this.start=M.fromCompiledToRaw(r),this.end=M.fromCompiledToRaw(i),this.injectFctName=M.getCustomFctName()??``,this.extractFctName=M.getCustomFctName(1)??``,this.injectTsTxt=n,this.computedOnce=Nn(n);let s=n.split(`.`);s.pop(),this.extractTsCond=s.join(`.`).trim(),this.extractTsCond.endsWith(`?`)&&(this.extractTsCond=this.extractTsCond.slice(0,this.extractTsCond.length-1)),this.extractTsTxt=n.replace(/\?/g,``),this.variables=Mn(n,M.getVariables());let c=this.variables.map(e=>`c.data.`+e),l=[`v`].concat(c).join(`,`),u=c.join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${u})`,this.extractTxt=`(c, v) => c.comp.${this.extractFctName}(${l})`}};function jn(e,t,n,r){let i=/\{\{([\s|\S]*?)\}\}/g,a,o={changes:[],txt:e,variables:[],once:!0};for(;a=i.exec(e);){let e=t+a.index,i=t+a.index+a[0].length,s=M.createChange({txt:a[1],start:e,end:i,tagName:n,attributeName:r});if(o.once&&!Nn(a[1])&&(o.once=!1),s){s.variables=Mn(a[1],s.variables);let e=s.variables.map(e=>`c.data.`+e).join(`,`),t="${c.print(c.comp."+s.name+`(`+e+`))}`;o.txt=o.txt.replace(a[0],t).replace(/\r\n?/g,`
512
+ `),o.changes.push(s)}}return o.changes.length>0&&(o.txt="(c) => `"+o.txt+"`"),o}function Mn(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 Nn(e){return!/if|switch|\?|\[.+?\]|\|\||&&/g.test(e)}var M=class e{static languageService=(0,S.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:C.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:C.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=la(e.txt+`\0`+(e.tagName??``)+`\0`+(e.attributeName??``));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,tagName:e.tagName,attributeName:e.attributeName};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 En||!(t instanceof xn))return t.idTemplate}}static getVariables(){let e=[];if(this.currentParsingDoc){for(let t of this.currentParsingDoc.stacks)if(t instanceof En||t instanceof xn)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(/<\/?[A-Za-z][A-Za-z0-9:_-]*(?:\s+(?:[^"'<>]|"[^"]*"|'[^']*')*)?\s*\/?>/g,e=>`'`+e.slice(1,-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 Dn(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 En(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 On(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()!=S.TokenType.EOS;)if(r.length>0){if(a.getTokenType()==S.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 Tn(i,n,r,e,!1))}}else if(a.getTokenType()==S.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()!=S.TokenType.StartTagOpen){if(a.getTokenType()==S.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()==S.TokenType.StartTagSelfClose){let e=o.pop();e&&(e.validateAllProps(a.getTokenOffset()),e.afterClose(a.getTokenOffset(),a.getTokenEnd()))}else if(a.getTokenType()==S.TokenType.StartTag){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd(),r=new xn(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()!=S.TokenType.EndTagOpen&&a.getTokenType()!=S.TokenType.EndTagClose){if(a.getTokenType()==S.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(Gi(t,`The tag `+n?.tagName+` isn't correctly closed`,n?.start,n?.end)):this.errors.push(Gi(t,`No opening tag found for `+e,a.getTokenOffset(),a.getTokenEnd()));return}}else if(a.getTokenType()!=S.TokenType.DelimiterAssign)if(a.getTokenType()==S.TokenType.AttributeName){let e=a.getTokenText();if(o.length>0){let t=o[o.length-1];s=new wn(e,a.getTokenOffset(),a.getTokenEnd(),t),t.addAttribute(s)}}else if(a.getTokenType()==S.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()==S.TokenType.Content){if(o.length>0){let e=o[o.length-1],t=a.getTokenText(),n=a.getTokenOffset(),r=a.getTokenEnd();e.addContent(new Tn(t,n,r,e))}}else a.getTokenType()==S.TokenType.Whitespace||a.getTokenType()==S.TokenType.Unknown||a.getTokenType()==S.TokenType.Script||(a.getTokenType(),S.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]}},Pn=o(((e,t)=>{t.exports=function(e){return e&&typeof e.valueOf()==`string`}})),Fn=o(((e,t)=>{let n=Pn();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}})),In=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}})),Ln=o(((e,t)=>{let n=Pn();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}})),Rn=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("${"))))}})),zn=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}})),Bn=o(((e,t)=>{t.exports=function(e){return!(e[0]===`$`||e[0]===`@`||/#{.+?}|@{.+?}|\$\(.+?\)/.test(e))}})),Vn=o(((e,t)=>{t.exports=function(e){return e.slice(0,2)===`--`}})),Hn=o(((e,t)=>{t.exports=function(e){return e[0]===`$`}})),Un=o(((e,t)=>{t.exports=function(e){return e.type===`atrule`&&e.variable}})),Wn=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}})),Gn=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}})),Kn=o(((e,t)=>{let n=Bn(),r=Vn(),i=Hn(),a=Un(),o=Wn(),s=Gn();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}})),qn=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(`
513
513
  `)&&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(`
514
514
  `))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(`
515
515
  `))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(`
@@ -545,14 +545,14 @@ protected ${t}(){
545
545
  }`,else:`else {
546
546
  \${1}
547
547
  }`,"@Context":"@Context('${1:element}', ${2:this.elements[i]})"};var Ur=class{languageService;id=0;isAutoComplete=!1;customTagsData=[];documentationInfo={};extenalDocumentation={};internalDocumentation={};internalDocumentationReverse={};internalTagUri={};_allowRebuildDefinition=!0;build;constructor(e){this.build=e,this.languageService=this.getHTMLLanguageService(),P.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 Vr[e]?Vr[e]:null}getHTMLLanguageService(){return(0,S.getLanguageService)({useDefaultDataProvider:!0,customDataProviders:[this.defaultProvider(),...this.loadOthersProviders()]})}defaultProvider(){return{getId:this.getId.bind(this),isApplicable(e){return e==C.HTML},provideTags:this.provideTags.bind(this),provideAttributes:this.provideAttributes.bind(this),provideValues:this.provideValues.bind(this)}}loadOthersProviders(){let e=P.getInstance().settingsHtml,t=[];for(let n of e.customData){let e=(0,f.normalize)(I($.getWorkspaceUri()+`/`+n));if((0,u.existsSync)(e)){let r;try{let i=(0,u.readFileSync)(e,`utf8`);r=JSON.parse(i);let a=(0,S.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=[...Br],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=Xi(r,ta(r.getText(),i)),o=r.getText().slice(r.offsetAt(a.start),r.offsetAt(a.end));for(let e in Hr)e.startsWith(o)&&n.push({label:e,kind:m.CompletionItemKind.Snippet,insertText:Hr[e],insertTextFormat:S.InsertTextFormat.Snippet,insertTextMode:S.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(`
548
- `)??``}};{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){let r=n;return r.wrapAttributes=`preserve`,this.languageService.format(e,t,n)}async onDefinition(e,t){this.currentFile=e;let n=this.getLinkToLogic(e,t);if(n instanceof St||n instanceof Tt){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 kt)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 Wr(e){let t=``,n=[],r=r=>{for(let i of r){let r=Kt.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)&&sa(i):(0,u.writeFileSync)(i,t),n}var Gr=class extends Pt{get extension(){return w.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(L(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(L(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(L(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(Wr(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)}},Kr=class extends Pt{get extension(){return w.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)}},qr=class extends Pt{get extension(){return w.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(L(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(Wr(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)}},Jr=class extends Pt{get extension(){return w.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(Wr(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)}},Yr=class extends Pt{get extension(){return w.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(Wr(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)}},Xr=class extends Pt{get extension(){return w.Static}mustBeAddedToLanguageService(){return!1}async onValidate(){return[]}async onContentChange(){}async onSave(){let e=this.file.path,t=e.replace(this.extension,w.Definition),n=``,r=``;t.endsWith(w.Definition)&&(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`).replace(/declare global \{([\s\S]*)\}/gm,`$1`));let i=e.replace(this.extension,w.DefinitionNpm);r=i.endsWith(w.DefinitionNpm)&&(0,u.existsSync)(i)?(0,u.readFileSync)(i,`utf8`):n;let a=oa(e+this.file.contentUser),o=this.file.path.replace(this.build.project.getConfigFile().path.replace(w.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 Zr(e,t){let n=null;return e.uri.endsWith(w.ComponentLogic)?n=new j(e,t):e.uri.endsWith(w.Data)?n=new Gr(e,t):e.uri.endsWith(w.Lib)?n=new qr(e,t):e.uri.endsWith(w.RAM)?n=new Jr(e,t):e.uri.endsWith(w.State)?n=new Yr(e,t):e.uri.endsWith(w.Static)?n=new Xr(e,t):e.uri.endsWith(w.Definition)&&(n=new Kr(e,t)),n}var Qr=class{static send(e,t){$.sendNotification(`aventus/compiled`,e,t)}static part(e){$.sendNotification(`aventus/compiled/part`,e)}},$r=class{static send(e,t){$.sendNotification(`aventus/registerBuild`,{pathConfig:e,buildName:t})}},ei=class{static send(e,t){$.sendNotification(`aventus/unregisterBuild`,{pathConfig:e,buildName:t})}},ti=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,ne,S=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,se=oe[f]||oe[m]||y&&oe[y],ce=se||S(y),le=y?ie?S(`entries`):ce:void 0,ue=t==`Array`&&oe.entries||se;if(ue&&(ne=d(ue.call(new e)),ne!==Object.prototype&&(u(ne,re,!0),r||s(ne,f)||o(ne,f,_))),ie&&se&&se.name!==g&&(ae=!0,ce=function(){return se.call(this)}),r&&!x||!p&&!ae&&oe[f]||o(oe,f,ce),c[t]=ce,c[re]=_,y)if(ee={values:ie?ce:S(g),keys:b?ce:S(h),entries:le},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(`
549
- `)[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(){},ne=!!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{}}(),S=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 S(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}}},se=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&&ue(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&&ce(e)})}},ce=function(e){g.call(s,function(){var t,n,r,i=e._v;if(le(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||le(e)?2:1),e._a=void 0,t)throw t.error})},le=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||!le(t.promise))return!1;return!0},ue=function(e){g.call(s,function(){var t;ee?b.emit(`rejectionHandled`,e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},de=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(),se(t,!0))},fe=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(fe,r,1),c(de,r,1))}catch(e){de.call(r,e)}}):(n._v=e,n._s=1,se(n,!1))}catch(e){de.call({_w:n,_d:!1},e)}}};ne||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(fe,this,1),c(de,this,1))}catch(e){de.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&&se(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(fe,e,1),this.reject=c(de,e,1)}),u(u.G+u.W+u.F*!ne,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!ne,v,{reject:function(e){var t=ie(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!ne),v,{resolve:function(e){if(e instanceof x&&S(e.constructor,this))return e;var t=ie(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(ne&&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||=P.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};P.getInstance().setHiddenSettings({store:t}),this._settings=t}static async connect(e,t){let n=await(0,ti.machineId)(),r=(0,ue.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)(si.getInstance().getPath(),`@locals`,e.buildConfig.fullname+w.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+w.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 ri([{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 ri([{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 sa(a),s}static async post(e,t={},n){let r=await this.postWithErrors(e,t,n);if(r instanceof ri){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,ti.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 ri([{code:401,message:`No token provided`}]);if(i.status==403)return t!=`/logout`&&this.disconnect(),new ri([{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 ri(s.errors):s.result:new ri([{code:-500,message:`Wrong response format from the api`}])}catch(e){return new ri([{code:-500,message:e+``}])}}static zip(e,t){return new Promise(async(n,r)=>{let i=(0,u.createWriteStream)(t),a=(0,de.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()})}},ri=class{errors;constructor(e){this.errors=e}},ii=class e{fctTxt=null;static is(t){return t.name==`Attribute`?new e:null}},ai=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)(I($.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}),aa(r,JSON.stringify(t,null,2),`manifest`),this.done=!0}}static getMarkdown(e){return this.files[e]?new oi(this.files[e]).getContent():``}},oi=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 O||(e=new O(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(`
548
+ `)??``}};{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){let r=n;return r.wrapAttributes=`preserve`,this.languageService.format(e,t,n)}async onDefinition(e,t){this.currentFile=e;let n=this.getLinkToLogic(e,t);if(n instanceof St||n instanceof Tt){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 kt)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 Wr(e){let t=``,n=[],r=r=>{for(let i of r){let r=Kt.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)&&ua(i):(0,u.writeFileSync)(i,t),n}var Gr=class extends Pt{get extension(){return w.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(L(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(L(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(L(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(Wr(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)}},Kr=class extends Pt{get extension(){return w.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)}},qr=class extends Pt{get extension(){return w.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(L(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(Wr(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)}},Jr=class extends Pt{get extension(){return w.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(Wr(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)}},Yr=class extends Pt{get extension(){return w.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(Wr(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)}},Xr=class extends Pt{get extension(){return w.Static}mustBeAddedToLanguageService(){return!1}async onValidate(){return[]}async onContentChange(){}async onSave(){let e=this.file.path,t=e.replace(this.extension,w.Definition),n=``,r=``;t.endsWith(w.Definition)&&(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`).replace(/declare global \{([\s\S]*)\}/gm,`$1`));let i=e.replace(this.extension,w.DefinitionNpm);r=i.endsWith(w.DefinitionNpm)&&(0,u.existsSync)(i)?(0,u.readFileSync)(i,`utf8`):n;let a=la(e+this.file.contentUser),o=this.file.path.replace(this.build.project.getConfigFile().path.replace(w.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 Zr(e,t){let n=null;return e.uri.endsWith(w.ComponentLogic)?n=new j(e,t):e.uri.endsWith(w.Data)?n=new Gr(e,t):e.uri.endsWith(w.Lib)?n=new qr(e,t):e.uri.endsWith(w.RAM)?n=new Jr(e,t):e.uri.endsWith(w.State)?n=new Yr(e,t):e.uri.endsWith(w.Static)?n=new Xr(e,t):e.uri.endsWith(w.Definition)&&(n=new Kr(e,t)),n}var Qr=class{static send(e,t){$.sendNotification(`aventus/compiled`,e,t)}static part(e){$.sendNotification(`aventus/compiled/part`,e)}},$r=class{static send(e,t){$.sendNotification(`aventus/registerBuild`,{pathConfig:e,buildName:t})}},ei=class{static send(e,t){$.sendNotification(`aventus/unregisterBuild`,{pathConfig:e,buildName:t})}},ti=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,ne,S=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,se=oe[f]||oe[m]||y&&oe[y],ce=se||S(y),le=y?ie?S(`entries`):ce:void 0,ue=t==`Array`&&oe.entries||se;if(ue&&(ne=d(ue.call(new e)),ne!==Object.prototype&&(u(ne,re,!0),r||s(ne,f)||o(ne,f,_))),ie&&se&&se.name!==g&&(ae=!0,ce=function(){return se.call(this)}),r&&!x||!p&&!ae&&oe[f]||o(oe,f,ce),c[t]=ce,c[re]=_,y)if(ee={values:ie?ce:S(g),keys:b?ce:S(h),entries:le},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(`
549
+ `)[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(){},ne=!!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{}}(),S=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 S(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}}},se=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&&ue(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&&ce(e)})}},ce=function(e){g.call(s,function(){var t,n,r,i=e._v;if(le(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||le(e)?2:1),e._a=void 0,t)throw t.error})},le=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||!le(t.promise))return!1;return!0},ue=function(e){g.call(s,function(){var t;ee?b.emit(`rejectionHandled`,e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},de=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(),se(t,!0))},fe=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(fe,r,1),c(de,r,1))}catch(e){de.call(r,e)}}):(n._v=e,n._s=1,se(n,!1))}catch(e){de.call({_w:n,_d:!1},e)}}};ne||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(fe,this,1),c(de,this,1))}catch(e){de.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&&se(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(fe,e,1),this.reject=c(de,e,1)}),u(u.G+u.W+u.F*!ne,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!ne,v,{reject:function(e){var t=ie(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!ne),v,{resolve:function(e){if(e instanceof x&&S(e.constructor,this))return e;var t=ie(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(ne&&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||=P.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};P.getInstance().setHiddenSettings({store:t}),this._settings=t}static async connect(e,t){let n=await(0,ti.machineId)(),r=(0,ue.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)(si.getInstance().getPath(),`@locals`,e.buildConfig.fullname+w.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+w.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 ri([{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 ri([{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 ua(a),s}static async post(e,t={},n){let r=await this.postWithErrors(e,t,n);if(r instanceof ri){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,ti.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 ri([{code:401,message:`No token provided`}]);if(i.status==403)return t!=`/logout`&&this.disconnect(),new ri([{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 ri(s.errors):s.result:new ri([{code:-500,message:`Wrong response format from the api`}])}catch(e){return new ri([{code:-500,message:e+``}])}}static zip(e,t){return new Promise(async(n,r)=>{let i=(0,u.createWriteStream)(t),a=(0,de.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()})}},ri=class{errors;constructor(e){this.errors=e}},ii=class e{fctTxt=null;static is(t){return t.name==`Attribute`?new e:null}},ai=class{static files={};static done=!1;static async register(e){this.files[e.file.uri]||(this.files[e.file.uri]=e,this.done&&await this.write())}static async 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)(I($.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}),await ca(r,JSON.stringify(t,null,2),`manifest`),this.done=!0}}static getMarkdown(e){return this.files[e]?new oi(this.files[e]).getContent():``}},oi=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 O||(e=new O(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(`
550
550
  `)??``,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(`
551
551
  `)??``,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=>an.is(e))&&(t=`@Property()`),e.decorators.find(e=>ii.is(e))&&(t=`@Attribute()`),e.decorators.find(e=>dn.is(e))&&(t=`@Watch()`),e.decorators.find(e=>_n.is(e))&&(t=`@Signal()`),{name:e.name,type:this.getType(e.type),description:e.documentation?.definitions.join(`
552
552
  `)??``,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(`
553
553
  `)??``,isAbstract:e.isAbstract}}getContent(){return this.content.join(`
554
- `)}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)}},si=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":We(),"Aventus@UI":Ge(),"Aventus@Sharp":qe(),"Aventus@Php":Je(),"Aventus@I18n":Ke()};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=F(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=F(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)}ai.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=F((0,f.join)(this.path,`@locals`,e));n.endsWith(w.Package)||(n+=w.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=F(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,se.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(w.Package)){t=(0,f.join)(e,r);break}return t}loadPackage(e,t){let n=Ut.getQuickInfo(e);if(n)return this.loadedPackages[n.name]=new Ut(e,t),this.loadedPackages[n.name]}downloadFile(e,t){return new Promise(n=>{let r=()=>{try{(0,u.existsSync)(e)&&sa(e)}catch{}};(t.startsWith(`https:`)?oe.get:b.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(`
555
- `),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}},ci=class{static send(e,t){$.sendNotification(`aventus/addDebugFile`,e,t)}},li=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:oa(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&&(Qr.part(`Compiling node modules`),this.lastInfoToCompile=t.buildTxt,this.npmDepBuildTxt=await this.esbuildBuild(this.lastInfoToCompile),Qr.part(`Compiling node modules done`)),this.npmBuildTxt=`var npmCompilation;
554
+ `)}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)}},si=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":We(),"Aventus@UI":Ge(),"Aventus@Sharp":qe(),"Aventus@Php":Je(),"Aventus@I18n":Ke()};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=F(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=F(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)}await ai.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=F((0,f.join)(this.path,`@locals`,e));n.endsWith(w.Package)||(n+=w.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=F(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,se.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(w.Package)){t=(0,f.join)(e,r);break}return t}loadPackage(e,t){let n=Ut.getQuickInfo(e);if(n)return this.loadedPackages[n.name]=new Ut(e,t),this.loadedPackages[n.name]}downloadFile(e,t){return new Promise(n=>{let r=()=>{try{(0,u.existsSync)(e)&&ua(e)}catch{}};(t.startsWith(`https:`)?oe.get:b.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(`
555
+ `),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}},ci=class{static send(e,t){$.sendNotification(`aventus/addDebugFile`,e,t)}},li=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:la(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&&(Qr.part(`Compiling node modules`),this.lastInfoToCompile=t.buildTxt,this.npmDepBuildTxt=await this.esbuildBuild(this.lastInfoToCompile),Qr.part(`Compiling node modules done`)),this.npmBuildTxt=`var npmCompilation;
556
556
  `,this.npmBuildTxt+=`(npmCompilation||(npmCompilation = {}));
557
557
  `,this.npmBuildTxt+=`(function (npmCompilation) {
558
558
  ${this.npmDepBuildTxt.result+`
@@ -571,18 +571,18 @@ protected ${t}(){
571
571
  `+a(1))),t.firstLast&&(n.newText=n.newText.trim(),n.range.start.character==0&&n.range.start.line==0&&(n.newText=t.tab?`
572
572
  `+a(1)+n.newText:`
573
573
  `+n.newText),e.file.file.documentInternal.offsetAt(n.range.end)==e.file.file.documentInternal.getText().length&&(n.newText+=`
574
- `)),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 zr(new E(d.TextDocument.create(this.file.uri,C.HTML,this.file.versionUser,e.htmlText)),this.build);let t;e.cssText!==null&&(t=new Rr(new E(d.TextDocument.create(this.file.uri,C.SCSS,this.file.versionUser,e.cssText)),this.build));let n=new j(new E(d.TextDocument.create(this.file.uri,C.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]}},di=class{manifest;_package;constructor(e){this.manifest=e,this._package={modules:[],schemaVersion:`1.0.0`,readme:``}}write(e){aa((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 j))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(`
574
+ `)),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 zr(new E(d.TextDocument.create(this.file.uri,C.HTML,this.file.versionUser,e.htmlText)),this.build);let t;e.cssText!==null&&(t=new Rr(new E(d.TextDocument.create(this.file.uri,C.SCSS,this.file.versionUser,e.cssText)),this.build));let n=new j(new E(d.TextDocument.create(this.file.uri,C.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]}},di=class{manifest;_package;constructor(e){this.manifest=e,this._package={modules:[],schemaVersion:`1.0.0`,readme:``}}async write(e){await ca((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 j))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(`
575
575
  `)),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=k.getInfoByFullName(n.extends[0],n);if(e&&e instanceof kt)if(a.superclass={name:e.name},e.fileUri.endsWith(w.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(`
576
576
  `)),e.isOverride){let r=n.getFieldParentClass(e.name);if(r)if(t.inheritedFrom={name:r.name},r.fileUri.endsWith(w.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(`
577
577
  `)),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(w.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(`
578
- `)),e.isPrivate?i.privacy=`private`:e.isProtected?i.privacy=`protected`:i.privacy=`public`,e.node.type){let t=new O(e.node.type);i.return={type:{text:this.getTypeTxt(t)}},e.documentation?.documentationReturn&&(i.return.description=e.documentation.documentationReturn)}if(e.node.parameters.length>0){i.parameters=[];for(let t of e.node.parameters){let n=t.name.getText(),r={name:n};t.type&&(r.type={text:this.getTypeTxt(new O(t.type))}),e.documentation?.documentationParameters[n]&&(r.description=e.documentation?.documentationParameters[n]),t.questionToken&&(r.optional=!0),t.initializer&&(r.default=t.initializer.getText()),i.parameters.push(r)}}if(e.isOverride){let e=t?n.getStaticMethodParentClass(r):n.getMethodParentClass(r);if(e)if(i.inheritedFrom={name:e.name},e.fileUri.endsWith(w.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)}};for(let e of t.methods)u(e,!1);for(let e of t.methodsStatic)u(e,!0);c.length>0&&(a.members=c);let d=[];for(let e in t.slots){if(!t.slots[e].local)continue;let n={name:e};d.push(n)}d.length>0&&(a.slots=d),i.declarations.push(a);let f={kind:`custom-element-definition`,name:n.name,declaration:{name:n.name,module:this.getLocalUri(e.file.uri)}};i.exports.push(f),i.declarations?.length==0&&delete i.declarations,i.exports?.length==0&&delete i.exports,this._package.modules.push(i)}getSourceUri(e){return this.manifest.manifestConfig.srcBaseUrl+`/`+this.getLocalUri(e)}getLocalUri(e){let t=this.manifest.configFile.uri.replace(w.Config,``),n=I(e.replace(t,``)).replace(/\\/g,`/`);return n=n.replace(w.Base,`.js`),`__src/`+n}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},fi=class{manifest;_package;constructor(e){this.manifest=e,this._package={html:{snippets:{}}}}write(e){aa((0,f.join)(e,`emmet`,`snippets.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!e.fileParsed||!(e instanceof j))return;let n=t.class,r=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!n||!r||!r.tagName)return;let i=r.tagName;this._package.html.snippets[i]=`<${i}>\${1}</${i}>`}},pi=class{manifest;_package;constructor(e){this.manifest=e,this._package={version:1.1,tags:[]}}write(e){aa((0,f.join)(e,`vscode.html-custom-data.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!e.fileParsed||!(e instanceof j))return;let n=t.class,r=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!n||!r||!r.tagName)return;let i={name:r.tagName},{attributes:a}=t,o=[];for(let e of a){let t={name:e.name},n=this.getTypeTxt(e.type),r=e.documentation?.definitions.join(`
578
+ `)),e.isPrivate?i.privacy=`private`:e.isProtected?i.privacy=`protected`:i.privacy=`public`,e.node.type){let t=new O(e.node.type);i.return={type:{text:this.getTypeTxt(t)}},e.documentation?.documentationReturn&&(i.return.description=e.documentation.documentationReturn)}if(e.node.parameters.length>0){i.parameters=[];for(let t of e.node.parameters){let n=t.name.getText(),r={name:n};t.type&&(r.type={text:this.getTypeTxt(new O(t.type))}),e.documentation?.documentationParameters[n]&&(r.description=e.documentation?.documentationParameters[n]),t.questionToken&&(r.optional=!0),t.initializer&&(r.default=t.initializer.getText()),i.parameters.push(r)}}if(e.isOverride){let e=t?n.getStaticMethodParentClass(r):n.getMethodParentClass(r);if(e)if(i.inheritedFrom={name:e.name},e.fileUri.endsWith(w.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)}};for(let e of t.methods)u(e,!1);for(let e of t.methodsStatic)u(e,!0);c.length>0&&(a.members=c);let d=[];for(let e in t.slots){if(!t.slots[e].local)continue;let n={name:e};d.push(n)}d.length>0&&(a.slots=d),i.declarations.push(a);let f={kind:`custom-element-definition`,name:n.name,declaration:{name:n.name,module:this.getLocalUri(e.file.uri)}};i.exports.push(f),i.declarations?.length==0&&delete i.declarations,i.exports?.length==0&&delete i.exports,this._package.modules.push(i)}getSourceUri(e){return this.manifest.manifestConfig.srcBaseUrl+`/`+this.getLocalUri(e)}getLocalUri(e){let t=this.manifest.configFile.uri.replace(w.Config,``),n=I(e.replace(t,``)).replace(/\\/g,`/`);return n=n.replace(w.Base,`.js`),`__src/`+n}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},fi=class{manifest;_package;constructor(e){this.manifest=e,this._package={html:{snippets:{}}}}async write(e){await ca((0,f.join)(e,`emmet`,`snippets.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!e.fileParsed||!(e instanceof j))return;let n=t.class,r=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!n||!r||!r.tagName)return;let i=r.tagName;this._package.html.snippets[i]=`<${i}>\${1}</${i}>`}},pi=class{manifest;_package;constructor(e){this.manifest=e,this._package={version:1.1,tags:[]}}async write(e){await ca((0,f.join)(e,`vscode.html-custom-data.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!e.fileParsed||!(e instanceof j))return;let n=t.class,r=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!n||!r||!r.tagName)return;let i={name:r.tagName},{attributes:a}=t,o=[];for(let e of a){let t={name:e.name},n=this.getTypeTxt(e.type),r=e.documentation?.definitions.join(`
579
579
  `),i=``;n&&(i=n),r&&(i&&(i+=`
580
580
 
581
- `),i+=r),i&&(t.description=i);let a=[];if(e.type.kind==`literal`){let t=e.type.value;(t.startsWith(`'`)||t.startsWith(`"`))&&(t=t.substring(1)),(t.endsWith(`'`)||t.endsWith(`"`))&&(t=t.substring(0,t.length-1)),a.push({name:t})}else if(e.type.kind==`union`)for(let t of e.type.nested){let e=t.value;(e.startsWith(`'`)||e.startsWith(`"`))&&(e=e.substring(1)),(e.endsWith(`'`)||e.endsWith(`"`))&&(e=e.substring(0,e.length-1)),a.push({name:e})}a.length>0&&(t.values=a),o.push(t)}o.length>0&&(i.attributes=o);let s=this.manifest.generateDescription(t);s&&(i.description=s),this._package.tags.push(i)}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},mi=class{manifest;_package;constructor(e){this.manifest=e,this._package={$schema:`https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json`,name:``,version:`2.20.0`,"description-markup":`markdown`,contributions:{html:{elements:[]}}}}write(e){aa((0,f.join)(e,`web-types.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!this._package.contributions?.html?.elements)return;let n=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!n)return;let r={name:n.tagName,description:this.manifest.generateDescription(t),"doc-url":``};t.class.isAbstract&&(r.abstract=!0);let i=[];for(let e of t.attributes){let t={name:e.name},n=this.getTypeTxt(e.type),r=e.documentation?.definitions.join(`
581
+ `),i+=r),i&&(t.description=i);let a=[];if(e.type.kind==`literal`){let t=e.type.value;(t.startsWith(`'`)||t.startsWith(`"`))&&(t=t.substring(1)),(t.endsWith(`'`)||t.endsWith(`"`))&&(t=t.substring(0,t.length-1)),a.push({name:t})}else if(e.type.kind==`union`)for(let t of e.type.nested){let e=t.value;(e.startsWith(`'`)||e.startsWith(`"`))&&(e=e.substring(1)),(e.endsWith(`'`)||e.endsWith(`"`))&&(e=e.substring(0,e.length-1)),a.push({name:e})}a.length>0&&(t.values=a),o.push(t)}o.length>0&&(i.attributes=o);let s=this.manifest.generateDescription(t);s&&(i.description=s),this._package.tags.push(i)}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},mi=class{manifest;_package;constructor(e){this.manifest=e,this._package={$schema:`https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json`,name:``,version:`2.20.0`,"description-markup":`markdown`,contributions:{html:{elements:[]}}}}async write(e){await ca((0,f.join)(e,`web-types.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!this._package.contributions?.html?.elements)return;let n=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!n)return;let r={name:n.tagName,description:this.manifest.generateDescription(t),"doc-url":``};t.class.isAbstract&&(r.abstract=!0);let i=[];for(let e of t.attributes){let t={name:e.name},n=this.getTypeTxt(e.type),r=e.documentation?.definitions.join(`
582
582
  `),i=``;n&&(i=n),r&&(i&&(i+=`
583
583
 
584
584
  `),i+=r),i&&(t.description=i);let a=[];if(e.type.kind==`literal`){let t=e.type.value;(t.startsWith(`'`)||t.startsWith(`"`))&&(t=t.substring(1)),(t.endsWith(`'`)||t.endsWith(`"`))&&(t=t.substring(0,t.length-1)),a.push({type:t})}else if(e.type.kind==`union`)for(let t of e.type.nested){let e=t.value;(e.startsWith(`'`)||e.startsWith(`"`))&&(e=e.substring(1)),(e.endsWith(`'`)||e.endsWith(`"`))&&(e=e.substring(0,e.length-1)),a.push({type:e})}a.length>0&&(t.values=a)}i.length>0&&(r.attributes=i);let a=[];for(let e in t.slots){if(!t.slots[e].local)continue;let n={name:e};t.slots[e].doc&&(n.description=t.slots[e].doc),a.push(n)}a.length>0&&(r.slots=a);let o=[];for(let e of t.props){let t={};t.name=e.name,e.isAbstract&&(t.abstract=e.isAbstract),e.documentation&&(t.description=e.documentation.definitions.join(`
585
- `)),t.type=this.getTypeTxt(e.type),o.push(t)}o.length>0&&(r.js||={},r.js.properties=o),this._package.contributions.html.elements.push(r)}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},hi=class{customElements;htmlCustomData;emmetCustomData;webTypes;configFile;manifestConfig;build;constructor(e,t){this.build=t,this.customElements=new di(this),this.htmlCustomData=new pi(this),this.emmetCustomData=new fi(this),this.webTypes=new mi(this),this.manifestConfig=e,this.configFile=this.build.project.getConfigFile()}register(e){if(e instanceof j&&e.fileParsed){let t=e.fileParsed.classes[e.componentClassName];if(!t)return;let n=[],r=[],i=[],a=[],o=[],s=[],c={},l=[],u=!1,d=t;for(;d&&d.fullName!=`Aventus.WebComponent`;){for(let e in d.properties){let i={...d.properties[e]};i.local=d==t,!(i.isPrivate||i.isProtected)&&(i.decorators.find(e=>an.is(e)||ii.is(e))?n.push(i):r.push(i))}for(let e in d.propertiesStatic){let n={...d.propertiesStatic[e]};n.local=d==t,!(n.isPrivate||n.isProtected)&&i.push(n)}for(let e in d.methods){let n={...d.methods[e]};n.local=d==t,!(n.isPrivate||n.isProtected)&&a.push(n)}for(let e in d.methodsStatic){let n={...d.methodsStatic[e]};n.local=d==t,!(n.isPrivate||n.isProtected)&&o.push(n)}let e=this.build.tsFiles[d.fileUri];if(e instanceof j){if(e.SCSSFile)for(let n of e.SCSSFile.customProperties){let e={...n};e.local=d==t,s.push(e)}if(e.HTMLFile?.fileParsed?.slotsInfo&&!u){for(let n in e.HTMLFile.fileParsed.slotsInfo)l.includes(n)||(c[n]||(c[n]={local:d==t}),!c[n].doc&&d.documentation?.documentationSlots[n]&&(c[n].doc=d.documentation?.documentationSlots[n]));for(let t in e.HTMLFile.fileParsed.blocksInfo)c[t]||l.push(t)}}d.decorators.find(e=>nn.is(e))&&(u=!0),d=d.parentClass}let f=this.build.noNamespaceUri[e.file.uri]?t.fullName:this.build.buildConfig.module+`.`+t.fullName;n.sort((e,t)=>e.name.localeCompare(t.name)),r.sort((e,t)=>e.name.localeCompare(t.name)),i.sort((e,t)=>e.name.localeCompare(t.name)),a.sort((e,t)=>e.name.localeCompare(t.name)),o.sort((e,t)=>e.name.localeCompare(t.name)),s.sort((e,t)=>e.name.localeCompare(t.name)),c=Object.keys(c).sort().reduce((e,t)=>(e[t]=c[t],e),{});let p={fullName:f,class:t,attributes:n,props:r,propsStatic:i,methods:a,methodsStatic:o,slots:c,cssProperties:s};this.customElements.register(e,p),this.htmlCustomData.register(e,p),this.emmetCustomData.register(e,p),this.webTypes.register(e,p)}}write(e){this.customElements.write(e),this.htmlCustomData.write(e),this.emmetCustomData.write(e)}getTypeTxt(e){let t=``;if(e.kind==`union`){let n=[];for(let t of e.nested)n.push(this.getTypeTxt(t));t=n.join(` | `)}else if(e.kind==`intersection`){let n=[];for(let t of e.nested)n.push(this.getTypeTxt(t));t=n.join(` & `)}else if(e.kind==`literal`)t=e.value;else if(e.kind==`type`){t=e.value;let n=[];for(let t of e.genericValue)n.push(this.getTypeTxt(t));n.length>0&&(t+=`<${n.join(`, `)}>`)}else if(e.kind==`typeOperator`)t=e.value,e.nested.length>0&&(t+=`typeof ${this.getTypeTxt(e.nested[0])}`);else if(e.kind==`tuple`){let n=[];for(let t of e.nested)n.push(this.getTypeTxt(t));t=`[${n.join(`, `)}]`}else if(e.kind==`conditional`){let n=e.conditionalType;t=`${this.getTypeTxt(n.check)} extends ${this.getTypeTxt(n.extends)} ? ${this.getTypeTxt(n.true)} : ${this.getTypeTxt(n.false)}`}else if(e.kind==`mappedType`){let n=e.mappedType;t=`{ [${n.parameterName} in ${this.getTypeTxt(n.parameterType)}]${n.modifier??``}: ${this.getTypeTxt(n.type)} }`}else t=e.kind==`indexedAccess`?`${this.getTypeTxt(e.nested[0])}[${this.getTypeTxt(e.nested[1])}]`:e.kind==`infer`?`infer ${e.value}]`:e.kind==`typeLiteral`||e.kind==`constructor`||e.kind==`function`?e.value:e.kind;return e.isArray&&(t+=`[]`),t}generateDescription(e){let t=`## `+e.fullName;e.class.documentation&&(t+=`
585
+ `)),t.type=this.getTypeTxt(e.type),o.push(t)}o.length>0&&(r.js||={},r.js.properties=o),this._package.contributions.html.elements.push(r)}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},hi=class{customElements;htmlCustomData;emmetCustomData;webTypes;configFile;manifestConfig;build;constructor(e,t){this.build=t,this.customElements=new di(this),this.htmlCustomData=new pi(this),this.emmetCustomData=new fi(this),this.webTypes=new mi(this),this.manifestConfig=e,this.configFile=this.build.project.getConfigFile()}register(e){if(e instanceof j&&e.fileParsed){let t=e.fileParsed.classes[e.componentClassName];if(!t)return;let n=[],r=[],i=[],a=[],o=[],s=[],c={},l=[],u=!1,d=t;for(;d&&d.fullName!=`Aventus.WebComponent`;){for(let e in d.properties){let i={...d.properties[e]};i.local=d==t,!(i.isPrivate||i.isProtected)&&(i.decorators.find(e=>an.is(e)||ii.is(e))?n.push(i):r.push(i))}for(let e in d.propertiesStatic){let n={...d.propertiesStatic[e]};n.local=d==t,!(n.isPrivate||n.isProtected)&&i.push(n)}for(let e in d.methods){let n={...d.methods[e]};n.local=d==t,!(n.isPrivate||n.isProtected)&&a.push(n)}for(let e in d.methodsStatic){let n={...d.methodsStatic[e]};n.local=d==t,!(n.isPrivate||n.isProtected)&&o.push(n)}let e=this.build.tsFiles[d.fileUri];if(e instanceof j){if(e.SCSSFile)for(let n of e.SCSSFile.customProperties){let e={...n};e.local=d==t,s.push(e)}if(e.HTMLFile?.fileParsed?.slotsInfo&&!u){for(let n in e.HTMLFile.fileParsed.slotsInfo)l.includes(n)||(c[n]||(c[n]={local:d==t}),!c[n].doc&&d.documentation?.documentationSlots[n]&&(c[n].doc=d.documentation?.documentationSlots[n]));for(let t in e.HTMLFile.fileParsed.blocksInfo)c[t]||l.push(t)}}d.decorators.find(e=>nn.is(e))&&(u=!0),d=d.parentClass}let f=this.build.noNamespaceUri[e.file.uri]?t.fullName:this.build.buildConfig.module+`.`+t.fullName;n.sort((e,t)=>e.name.localeCompare(t.name)),r.sort((e,t)=>e.name.localeCompare(t.name)),i.sort((e,t)=>e.name.localeCompare(t.name)),a.sort((e,t)=>e.name.localeCompare(t.name)),o.sort((e,t)=>e.name.localeCompare(t.name)),s.sort((e,t)=>e.name.localeCompare(t.name)),c=Object.keys(c).sort().reduce((e,t)=>(e[t]=c[t],e),{});let p={fullName:f,class:t,attributes:n,props:r,propsStatic:i,methods:a,methodsStatic:o,slots:c,cssProperties:s};this.customElements.register(e,p),this.htmlCustomData.register(e,p),this.emmetCustomData.register(e,p),this.webTypes.register(e,p)}}async write(e){await this.customElements.write(e),await this.htmlCustomData.write(e),await this.emmetCustomData.write(e)}getTypeTxt(e){let t=``;if(e.kind==`union`){let n=[];for(let t of e.nested)n.push(this.getTypeTxt(t));t=n.join(` | `)}else if(e.kind==`intersection`){let n=[];for(let t of e.nested)n.push(this.getTypeTxt(t));t=n.join(` & `)}else if(e.kind==`literal`)t=e.value;else if(e.kind==`type`){t=e.value;let n=[];for(let t of e.genericValue)n.push(this.getTypeTxt(t));n.length>0&&(t+=`<${n.join(`, `)}>`)}else if(e.kind==`typeOperator`)t=e.value,e.nested.length>0&&(t+=`typeof ${this.getTypeTxt(e.nested[0])}`);else if(e.kind==`tuple`){let n=[];for(let t of e.nested)n.push(this.getTypeTxt(t));t=`[${n.join(`, `)}]`}else if(e.kind==`conditional`){let n=e.conditionalType;t=`${this.getTypeTxt(n.check)} extends ${this.getTypeTxt(n.extends)} ? ${this.getTypeTxt(n.true)} : ${this.getTypeTxt(n.false)}`}else if(e.kind==`mappedType`){let n=e.mappedType;t=`{ [${n.parameterName} in ${this.getTypeTxt(n.parameterType)}]${n.modifier??``}: ${this.getTypeTxt(n.type)} }`}else t=e.kind==`indexedAccess`?`${this.getTypeTxt(e.nested[0])}[${this.getTypeTxt(e.nested[1])}]`:e.kind==`infer`?`infer ${e.value}]`:e.kind==`typeLiteral`||e.kind==`constructor`||e.kind==`function`?e.value:e.kind;return e.isArray&&(t+=`[]`),t}generateDescription(e){let t=`## `+e.fullName;e.class.documentation&&(t+=`
586
586
  `+e.class.documentation?.definitions.join(`
587
587
  `)),t+=`
588
588
  `;let n=e=>{t+=`\n### **${e}:**\n`},r=(e,n)=>{n?t+=` - **${e}** - ${n}\n`:t+=` - **${e}**\n`},{attributes:i,methods:a,methodsStatic:o,props:s,propsStatic:c,slots:l,cssProperties:u}=e,d=(e,t)=>{if(e.length>0){n(t);for(let t of e){let e=this.getTypeTxt(t.type),n=t.documentation?.definitions.join(`
@@ -595,7 +595,7 @@ protected ${t}(){
595
595
  `)}
596
596
  }
597
597
  }
598
- }`;this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,this.file.documentUser.version,e))}}catch{}}transformForExport(){let e={},t=this.build.buildConfig.i18n?.locales??[];for(let n of t)e[n]={};if(this.isGlobal)for(let n in this.parsedSrc)for(let r in this.parsedSrc[n])t.includes(r)&&(e[r][n]=this.parsedSrc[n][r]);else{let n=this.build.module+`°`+(this.classInfo?.fullName.replace(/\./g,`°`)??``);n&&(n+=`°`),this.build.module;for(let r in this.parsedSrc)for(let i in this.parsedSrc[r])t.includes(i)&&(e[i][n+r]=this.parsedSrc[r][i])}this.exported=e}async onValidate(){return await _i.getInstance().validate(this)}async onSave(){this.build.build()}async onDelete(){this.build.build()}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 await _i.getInstance().format(e,t,n)}async onCodeAction(e,t){return await _i.getInstance().codeAction(this,t)}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}onGetBuild(){return[this.build]}getKeyFromLocation(e){if(!this.parsed)return null;let t=this.file.documentUser.offsetAt(e[0]),n=this.file.documentUser.offsetAt(e[1]);for(let e in this.parsed){let r=this.parsed[e];if(r.keyStart<=t&&r.keyEnd>=n)return e}return null}},bi=class{project;buildConfig;stories;onNewFileUUID;onFileDeleteUUIDs={};globalComponentSCSSFiles={};scssFiles={};tsFiles={};noNamespaceUri={};htmlFiles={};wcFiles={};i18nComponentsFiles={};namespaces=[];externalPackageInformation=new xi(this);dependencyNeedUris=[];dependencyFullUris=[];dependencyUris=[];diagnostics=new Map;tsLanguageService;get globalSCSSLanguageService(){return this.project.globalSCSSLanguageService}scssLanguageService;htmlLanguageService;_allowBuild=!0;get allowBuild(){if($.isIDE){let e=P.getInstance().settings;return this._allowBuild&&e.ideBuild}return this._allowBuild}set allowBuild(e){this._allowBuild=e}initDone=!1;_filesLoaded=!1;reloadPage=!1;_outputPathes=[];npmBuilder;get fullname(){return this.buildConfig.fullname}get module(){return this.buildConfig.module}get isCoreBuild(){return this.project.isCoreBuild}get hideWarnings(){return this.buildConfig.hideWarnings}get nodeModulesDir(){return this.buildConfig.nodeModulesDir}get outputPathes(){return this._outputPathes}_hasNpmOutput;get hasNpmOutput(){if(this._hasNpmOutput===void 0){let e=this.buildConfig.compile.findIndex(e=>e.outputNpm.path.length>0)!=-1;e?this._hasNpmOutput=e:this._hasNpmOutput=this.hasStories}return this._hasNpmOutput}get hasStories(){return this.buildConfig.stories!==void 0}get filesLoaded(){return this._filesLoaded}constructor(e,t){this.project=e,this.buildConfig=t,this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile.bind(this)),this.tsLanguageService=new Kt(this),this.scssLanguageService=new Lr(this),this.htmlLanguageService=new Ur(this),this.stories=new gt(this,t),this._outputPathes=[(0,f.join)(si.getInstance().getPath(),`@locals`,t.fullname+w.Package).replace(/\\/g,`/`)];for(let e of t.compile)for(let t of e.package)this._outputPathes.push(t.replace(/\\/g,`/`));this.npmBuilder=new li(this),$r.send(e.getConfigFile().path,t.fullname)}async init(){await this.loadFiles(),this.initDone=!0}getComponentPrefix(){return this.buildConfig.componentPrefix}getAvoidParsingTags(){return this.buildConfig.avoidParsingInsideTags}getAliases(){return this.project.getConfig()?.aliases??{}}isFileInside(e){return I(e).match(this.buildConfig.srcPathRegex)!=null}getNamespace(e){return this.noNamespaceUri[e]||this.buildConfig.module==``?``:this.buildConfig.module+`.`}enableBuild(){this.allowBuild=!0}disableBuild(){this.allowBuild=!1}get isBuildAllowed(){return this.allowBuild}timerBuild=void 0;insideRebuildAll=!1;async rebuildAll(e=!1){if(this.allowBuild=!1,this.insideRebuildAll=!0,this.scssLanguageService.allowRebuildDefinition(!1),this.htmlLanguageService.allowRebuildDefinition(!1),e){for(let e in this.tsLanguageService.i18nFiles)await this.tsLanguageService.i18nFiles[e].validate();for(let e in this.i18nComponentsFiles)await this.i18nComponentsFiles[e].validate();for(let e in this.wcFiles)await this.wcFiles[e].init();for(let e in this.scssFiles)await this.scssFiles[e].init(),await this.scssFiles[e].validate();for(let e in this.htmlFiles)await this.htmlFiles[e].init(),await this.htmlFiles[e].validate();for(let e in this.tsFiles)await this.tsFiles[e].validate()}else{for(let e in this.tsLanguageService.i18nFiles)await this.tsLanguageService.i18nFiles[e].validate();for(let e in this.i18nComponentsFiles)await this.i18nComponentsFiles[e].validate();for(let e in this.scssFiles)await this.scssFiles[e].validate();for(let e in this.htmlFiles)await this.htmlFiles[e].validate();for(let e in this.tsFiles)await this.tsFiles[e].validate()}this.scssLanguageService.allowRebuildDefinition(!0),this.htmlLanguageService.allowRebuildDefinition(!0),this.insideRebuildAll=!1;for(let e in this.scssFiles)await this.scssFiles[e].triggerSave();for(let e in this.wcFiles)await this.wcFiles[e].triggerSave();for(let e in this.tsFiles)await this.tsFiles[e].triggerSave();this.allowBuild=!0,this.npmBuilder.rebuildInfo(),this.initDone?await this.build():await this._build()}async build(){if(!this.initDone||$.noBuild)return;let e=$.delayBetweenBuild();e==0?await this._build():(this.timerBuild&&clearTimeout(this.timerBuild),this.timerBuild=setTimeout(async()=>{await this._build()},e))}addDiagnostic(e,t){this.diagnostics.has(e)||this.diagnostics.set(e,[]),this.diagnostics.get(e)?.push(t)}clearDiagnostics(){for(let[e,t]of this.diagnostics.entries())e instanceof Pt&&$.sendDiagnostics({uri:e.file.uri,diagnostics:e.getDiagnostics()},this);this.diagnostics.clear()}emitDiagnostics(){for(let[e,t]of this.diagnostics.entries())if(e instanceof Pt){let n=[...t,...e.getDiagnostics()];this.hideWarnings&&(n=n.filter(e=>e.severity!=m.DiagnosticSeverity.Warning)),$.sendDiagnostics({uri:e.file.uri,diagnostics:n},this)}}async _build(){if(!this.allowBuild)return;$.debug(`building `+this.buildConfig.fullname),this.clearDiagnostics();let e=[];for(let t of this.buildConfig.compile){t.i18n&&this.writeBuildI18n(t.i18n);let n=await this.buildOrderCompilationInfo(t),r=await this.buildLocalCode(n.toCompile,this.buildConfig.module);e=await this.writeBuildCode(r,n.libSrc,t.output,t.compressed),e=[...e,...n.errors];let i={namespace:this.buildConfig.module,available:r.codeRenderInJs,existing:r.codeNotRenderInJs};this.writeBuildDocumentation(t.package,r,i,t.outputNpm),t.outputNpm.live&&this.writeBuildNpm(t.outputNpm,r),this.buildConfig.stories&&this.buildConfig.stories.live&&(await this.stories.check(),this.writeBuildNpm({path:[(0,f.join)(this.buildConfig.stories.output,`generated`)],packageJson:!1,npmName:``,live:!1},r),this.stories.write(this.tsFiles))}Qr.send(this.buildConfig.fullname,e),this.reloadPage&&(this.reloadPage=!1,D.getInstance().reload()),this.emitDiagnostics()}_buildStringModule(e,t,n,r,i,a){let o=``,s=e.split(`.`);if(o+=t.join(`
598
+ }`;this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,this.file.documentUser.version,e))}}catch{}}transformForExport(){let e={},t=this.build.buildConfig.i18n?.locales??[];for(let n of t)e[n]={};if(this.isGlobal)for(let n in this.parsedSrc)for(let r in this.parsedSrc[n])t.includes(r)&&(e[r][n]=this.parsedSrc[n][r]);else{let n=this.build.module+`°`+(this.classInfo?.fullName.replace(/\./g,`°`)??``);n&&(n+=`°`),this.build.module;for(let r in this.parsedSrc)for(let i in this.parsedSrc[r])t.includes(i)&&(e[i][n+r]=this.parsedSrc[r][i])}this.exported=e}async onValidate(){return await _i.getInstance().validate(this)}async onSave(){this.build.build()}async onDelete(){this.build.build()}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 await _i.getInstance().format(e,t,n)}async onCodeAction(e,t){return await _i.getInstance().codeAction(this,t)}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}onGetBuild(){return[this.build]}getKeyFromLocation(e){if(!this.parsed)return null;let t=this.file.documentUser.offsetAt(e[0]),n=this.file.documentUser.offsetAt(e[1]);for(let e in this.parsed){let r=this.parsed[e];if(r.keyStart<=t&&r.keyEnd>=n)return e}return null}},bi=class{project;buildConfig;stories;onNewFileUUID;onFileDeleteUUIDs={};globalComponentSCSSFiles={};scssFiles={};tsFiles={};noNamespaceUri={};htmlFiles={};wcFiles={};i18nComponentsFiles={};namespaces=[];externalPackageInformation=new xi(this);dependencyNeedUris=[];dependencyFullUris=[];dependencyUris=[];diagnostics=new Map;tsLanguageService;get globalSCSSLanguageService(){return this.project.globalSCSSLanguageService}scssLanguageService;htmlLanguageService;_allowBuild=!0;get allowBuild(){if($.isIDE){let e=P.getInstance().settings;return this._allowBuild&&e.ideBuild}return this._allowBuild}set allowBuild(e){this._allowBuild=e}initDone=!1;_filesLoaded=!1;reloadPage=!1;_outputPathes=[];npmBuilder;get fullname(){return this.buildConfig.fullname}get module(){return this.buildConfig.module}get isCoreBuild(){return this.project.isCoreBuild}get hideWarnings(){return this.buildConfig.hideWarnings}get nodeModulesDir(){return this.buildConfig.nodeModulesDir}get outputPathes(){return this._outputPathes}_hasNpmOutput;get hasNpmOutput(){if(this._hasNpmOutput===void 0){let e=this.buildConfig.compile.findIndex(e=>e.outputNpm.path.length>0)!=-1;e?this._hasNpmOutput=e:this._hasNpmOutput=this.hasStories}return this._hasNpmOutput}get hasStories(){return this.buildConfig.stories!==void 0}get filesLoaded(){return this._filesLoaded}constructor(e,t){this.project=e,this.buildConfig=t,this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile.bind(this)),this.tsLanguageService=new Kt(this),this.scssLanguageService=new Lr(this),this.htmlLanguageService=new Ur(this),this.stories=new gt(this,t),this._outputPathes=[(0,f.join)(si.getInstance().getPath(),`@locals`,t.fullname+w.Package).replace(/\\/g,`/`)];for(let e of t.compile)for(let t of e.package)this._outputPathes.push(t.replace(/\\/g,`/`));this.npmBuilder=new li(this),$r.send(e.getConfigFile().path,t.fullname)}async init(){await this.loadFiles(),this.initDone=!0}getComponentPrefix(){return this.buildConfig.componentPrefix}getAvoidParsingTags(){return this.buildConfig.avoidParsingInsideTags}getAliases(){return this.project.getConfig()?.aliases??{}}isFileInside(e){return I(e).match(this.buildConfig.srcPathRegex)!=null}getNamespace(e){return this.noNamespaceUri[e]||this.buildConfig.module==``?``:this.buildConfig.module+`.`}enableBuild(){this.allowBuild=!0}disableBuild(){this.allowBuild=!1}get isBuildAllowed(){return this.allowBuild}timerBuild=void 0;insideRebuildAll=!1;async rebuildAll(e=!1){if(this.allowBuild=!1,this.insideRebuildAll=!0,this.scssLanguageService.allowRebuildDefinition(!1),this.htmlLanguageService.allowRebuildDefinition(!1),e){for(let e in this.tsLanguageService.i18nFiles)await this.tsLanguageService.i18nFiles[e].validate();for(let e in this.i18nComponentsFiles)await this.i18nComponentsFiles[e].validate();for(let e in this.wcFiles)await this.wcFiles[e].init();for(let e in this.scssFiles)await this.scssFiles[e].init(),await this.scssFiles[e].validate();for(let e in this.htmlFiles)await this.htmlFiles[e].init(),await this.htmlFiles[e].validate();for(let e in this.tsFiles)await this.tsFiles[e].validate()}else{for(let e in this.tsLanguageService.i18nFiles)await this.tsLanguageService.i18nFiles[e].validate();for(let e in this.i18nComponentsFiles)await this.i18nComponentsFiles[e].validate();for(let e in this.scssFiles)await this.scssFiles[e].validate();for(let e in this.htmlFiles)await this.htmlFiles[e].validate();for(let e in this.tsFiles)await this.tsFiles[e].validate()}this.scssLanguageService.allowRebuildDefinition(!0),this.htmlLanguageService.allowRebuildDefinition(!0),this.insideRebuildAll=!1;for(let e in this.scssFiles)await this.scssFiles[e].triggerSave();for(let e in this.wcFiles)await this.wcFiles[e].triggerSave();for(let e in this.tsFiles)await this.tsFiles[e].triggerSave();this.allowBuild=!0,this.npmBuilder.rebuildInfo(),this.initDone?await this.build():await this._build()}async build(){if(!this.initDone||$.noBuild)return;let e=$.delayBetweenBuild();e==0?await this._build():(this.timerBuild&&clearTimeout(this.timerBuild),this.timerBuild=setTimeout(async()=>{await this._build()},e))}addDiagnostic(e,t){this.diagnostics.has(e)||this.diagnostics.set(e,[]),this.diagnostics.get(e)?.push(t)}clearDiagnostics(){for(let[e,t]of this.diagnostics.entries())e instanceof Pt&&$.sendDiagnostics({uri:e.file.uri,diagnostics:e.getDiagnostics()},this);this.diagnostics.clear()}emitDiagnostics(){for(let[e,t]of this.diagnostics.entries())if(e instanceof Pt){let n=[...t,...e.getDiagnostics()];this.hideWarnings&&(n=n.filter(e=>e.severity!=m.DiagnosticSeverity.Warning)),$.sendDiagnostics({uri:e.file.uri,diagnostics:n},this)}}async _build(){if(!this.allowBuild)return;$.debug(`building `+this.buildConfig.fullname),this.clearDiagnostics();let e=[];for(let t of this.buildConfig.compile){t.i18n&&await this.writeBuildI18n(t.i18n);let n=await this.buildOrderCompilationInfo(t),r=await this.buildLocalCode(n.toCompile,this.buildConfig.module);e=await this.writeBuildCode(r,n.libSrc,t.output,t.compressed),e=[...e,...n.errors];let i={namespace:this.buildConfig.module,available:r.codeRenderInJs,existing:r.codeNotRenderInJs};await this.writeBuildDocumentation(t.package,r,i,t.outputNpm),t.outputNpm.live&&await this.writeBuildNpm(t.outputNpm,r),this.buildConfig.stories&&this.buildConfig.stories.live&&(await this.stories.check(),await this.writeBuildNpm({path:[(0,f.join)(this.buildConfig.stories.output,`generated`)],packageJson:!1,npmName:``,live:!1},r),await this.stories.write(this.tsFiles))}Qr.send(this.buildConfig.fullname,e),this.reloadPage&&(this.reloadPage=!1,D.getInstance().reload()),this.emitDiagnostics()}_buildStringModule(e,t,n,r,i,a){let o=``,s=e.split(`.`);if(o+=t.join(`
599
599
  `)+`
600
600
  `,n.length>0){let t=``;o+=`var `+s[0]+`;
601
601
  `;for(let e=0;e<s.length;e++)t==``?t=s[e]:t+=`.`+s[e],o+=`(`+t+`||(`+t+` = {}));
@@ -617,7 +617,7 @@ protected ${t}(){
617
617
  `}return o+=i.join(`
618
618
  `)+`
619
619
  `,o=o.trim()+`
620
- `,o}async buildStorybook(){if(this.buildConfig.stories){await this.stories.check();for(let e of this.buildConfig.compile){let t=await this.buildOrderCompilationInfo(e),n=await this.buildLocalCode(t.toCompile,this.buildConfig.module);this.writeBuildNpm({path:[(0,f.join)(this.buildConfig.stories.output,`generated`)],packageJson:!1,npmName:``,live:!1},n)}this.stories.write(this.tsFiles,!0)}}async buildNpm(){for(let e of this.buildConfig.compile){let t=await this.buildOrderCompilationInfo(e),n=await this.buildLocalCode(t.toCompile,this.buildConfig.module);this.writeBuildNpm(e.outputNpm,n)}}async writeBuildCode(e,t,n,r){let i=[];if(n&&n.length>0){let a=[];for(let t in e.stylesheets)a.push(`Aventus.Style.store("${t}", \`${e.stylesheets[t]}\`)`);let o=``;e.useDecorator&&(o+=`var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
620
+ `,o}async buildStorybook(){if(this.buildConfig.stories){await this.stories.check();for(let e of this.buildConfig.compile){let t=await this.buildOrderCompilationInfo(e),n=await this.buildLocalCode(t.toCompile,this.buildConfig.module);await this.writeBuildNpm({path:[(0,f.join)(this.buildConfig.stories.output,`generated`)],packageJson:!1,npmName:``,live:!1},n)}await this.stories.write(this.tsFiles,!0)}}async buildNpm(){for(let e of this.buildConfig.compile){let t=await this.buildOrderCompilationInfo(e),n=await this.buildLocalCode(t.toCompile,this.buildConfig.module);await this.writeBuildNpm(e.outputNpm,n)}}async writeBuildCode(e,t,n,r){let i=[];if(n&&n.length>0){let a=[];for(let t in e.stylesheets)a.push(`Aventus.Style.store("${t}", \`${e.stylesheets[t]}\`)`);let o=``;e.useDecorator&&(o+=`var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
621
621
  function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
622
622
  var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
623
623
  var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
@@ -653,7 +653,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
653
653
  };
654
654
  `);let s=this._buildStringModule(this.buildConfig.module,e.codeNoNamespaceBefore,e.code,e.classesName,e.codeNoNamespaceAfter,a),c=await this.npmBuilder.compile();i=[...i,...c.errors];for(let e of n){let n={};for(let t in e){let i=e[t].path;n[i]||(n[i]={code:o,compressed:(`compressed`in e[t]?e[t].compressed:r)??!1})}e[`@npm`]?n[e[`@npm`].path].code+=c.result:n[e[`@default`].path].code+=c.result;for(let r of t)e[r.lib]?n[e[r.lib].path].code+=r.code+`
655
655
  `:n[e[`@default`].path].code+=r.code+`
656
- `;n[e[`@default`].path].code+=s;for(let e in n){let t=Yi(e.replace(/\\/g,`/`));(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let r=n[e];if(r.compressed)try{r.code=(await(0,fe.minify)({"file1.js":r.code},{compress:!0,format:{comments:!1}})).code??``}catch(e){$.error(e)}this.writeFile(e,r.code)}}}return i}writeBuildDocumentation(e,t,n,r){let i=``;i=`declare global {
656
+ `;n[e[`@default`].path].code+=s;for(let e in n){let t=Yi(e.replace(/\\/g,`/`));(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let r=n[e];if(r.compressed)try{r.code=(await(0,fe.minify)({"file1.js":r.code},{compress:!0,format:{comments:!1}})).code??``}catch(e){$.error(e)}await this.writeFile(e,r.code)}}}return i}async writeBuildDocumentation(e,t,n,r){let i=``;i=`declare global {
657
657
  `,i+=`
658
658
  namespace `+this.buildConfig.module+`{
659
659
  `,i+=t.doc.join(`
@@ -685,19 +685,19 @@ namespace `+this.buildConfig.module+`{
685
685
  `,a+=`//#region dependencies //
686
686
  `,a+=JSON.stringify(this.buildConfig.rawDependencies)+`
687
687
  `,a+=`//#endregion dependencies //
688
- `;for(let t of e)t?this.writeFile(t,a):(0,u.existsSync)(t)&&sa(t);let o=(0,f.join)(si.getInstance().getPath(),`@locals`);(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0}),this.writeFile((0,f.join)(o,this.buildConfig.fullname+w.Package),a)}writeBuildNpm(e,t){let n=Object.keys(t.npm);n.includes(``)||n.push(``);for(let e of n){let t=e.split(`.`),r=``;for(let e of t)r=r?`${r}.${e}`:e,n.includes(r)||n.push(r)}n.sort((e,t)=>(e.match(/\./g)||[]).length-(t.match(/\./g)||[]).length);let r={},i=e.manifest?new hi(e.manifest,this):null;for(let n in t.npmsrc){let a=``;for(let e in t.npmsrc[n].imports){let r=t.npmsrc[n].imports[e];r.length>0&&(a+=`import { ${r.join(`, `)} } from "${e}";
688
+ `;for(let t of e)t?await this.writeFile(t,a):(0,u.existsSync)(t)&&ua(t);let o=(0,f.join)(si.getInstance().getPath(),`@locals`);(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0}),await this.writeFile((0,f.join)(o,this.buildConfig.fullname+w.Package),a)}async writeBuildNpm(e,t){let n=Object.keys(t.npm);n.includes(``)||n.push(``);for(let e of n){let t=e.split(`.`),r=``;for(let e of t)r=r?`${r}.${e}`:e,n.includes(r)||n.push(r)}n.sort((e,t)=>(e.match(/\./g)||[]).length-(t.match(/\./g)||[]).length);let r={},i=e.manifest?new hi(e.manifest,this):null;for(let n in t.npmsrc){let a=``;for(let e in t.npmsrc[n].imports){let r=t.npmsrc[n].imports[e];r.length>0&&(a+=`import { ${r.join(`, `)} } from "${e}";
689
689
  `)}if(a!=``&&(a+=`
690
690
  `),a+=t.npmsrc[n].content.join(`
691
- `),a=Kt.removeUnusedImport(a,t.npmsrc[n].forcedDependencies),i)for(let e of t.npmsrc[n].sourceUri){let t=this.tsFiles[e];t&&i.register(t)}for(let t of e.path){let e=(0,f.join)(t,`__src`,...Yi(n).split(f.sep)),r=(0,f.join)(t,`__src`,...n.split(f.sep));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0}),this.writeFile(r,a)}for(let e of t.npmsrc[n].names){let t=e.split(`.`),i=t.pop()??``,a=[];for(let e=0;e<t.length;e++)a.push(`..`);a=[...a,`__src`,...n.split(f.sep)];let o=t.join(`.`);r[o]||(r[o]={});let s=a.join(`/`);r[o][s]||(r[o][s]=[]),r[o][s].push(i)}}let a=(t,r)=>{r||={content:[],imports:{}};let i=``,a=``,o=t==``?0:t.split(`.`).length,s=[];for(let e of n)if(e.startsWith(t)&&e!=t){let t=e.split(`.`);if(t.length==o+1){let e=t[t.length-1];i+=`import * as ${e} from "./${e}";
691
+ `),a=Kt.removeUnusedImport(a,t.npmsrc[n].forcedDependencies),i)for(let e of t.npmsrc[n].sourceUri){let t=this.tsFiles[e];t&&i.register(t)}for(let t of e.path){let e=(0,f.join)(t,`__src`,...Yi(n).split(f.sep)),r=(0,f.join)(t,`__src`,...n.split(f.sep));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0}),await this.writeFile(r,a)}for(let e of t.npmsrc[n].names){let t=e.split(`.`),i=t.pop()??``,a=[];for(let e=0;e<t.length;e++)a.push(`..`);a=[...a,`__src`,...n.split(f.sep)];let o=t.join(`.`);r[o]||(r[o]={});let s=a.join(`/`);r[o][s]||(r[o][s]=[]),r[o][s].push(i)}}let a=async(t,r)=>{r||={content:[],imports:{}};let i=``,a=``,o=t==``?0:t.split(`.`).length,s=[];for(let e of n)if(e.startsWith(t)&&e!=t){let t=e.split(`.`);if(t.length==o+1){let e=t[t.length-1];i+=`import * as ${e} from "./${e}";
692
692
  `,a+=`export { ${e} };
693
693
  `,s.push(`./${e}`)}}for(let e in r.imports){let t=r.imports[e];t.length>0&&(i+=`import { ${t.join(`, `)} } from "${e}";
694
694
  `)}i+=`
695
695
  `+r.content.join(`
696
696
  `)+`
697
- `,i+=a,i=i.replaceAll(`globalThis.Aventus.`,``),i=i.replaceAll(`___Aventus.`,``),i=Kt.removeUnusedImport(i,[]);for(let n of e.path){let e=(0,f.join)(n,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0});let r=(0,f.join)(e,`index.d.ts`);this.writeFile(r,i)}},o=t=>{let i=``,a=``,o=t==``?0:t.split(`.`).length;for(let e of n)if(e.startsWith(t)&&e!=t){let t=e.split(`.`);if(t.length==o+1){let e=t[t.length-1];i+=`import * as ${e} from "./${e}/index.js";
697
+ `,i+=a,i=i.replaceAll(`globalThis.Aventus.`,``),i=i.replaceAll(`___Aventus.`,``),i=Kt.removeUnusedImport(i,[]);for(let n of e.path){let e=(0,f.join)(n,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0});let r=(0,f.join)(e,`index.d.ts`);await this.writeFile(r,i)}},o=async t=>{let i=``,a=``,o=t==``?0:t.split(`.`).length;for(let e of n)if(e.startsWith(t)&&e!=t){let t=e.split(`.`);if(t.length==o+1){let e=t[t.length-1];i+=`import * as ${e} from "./${e}/index.js";
698
698
  `,a+=`export { ${e} };
699
699
  `}}let s=r[t];if(s)for(let e in s){let t=s[e].join(`, `);i+=`export { ${t} } from "${e}"
700
- `}i+=a,i=Kt.removeUnusedImport(i,[]);for(let n of e.path){let e=(0,f.join)(n,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0});let r=(0,f.join)(e,`index.js`);this.writeFile(r,i)}};for(let e of n)a(e,t.npm[e]),o(e);if(e.packageJson){let t=(0,f.join)(this.project.getConfigFile().folderPath,`package.json`),n={};(0,u.existsSync)(t)&&(n=JSON.parse((0,u.readFileSync)(t,`utf-8`)));let r={};for(let e of this.externalPackageInformation.filesUri){let t=this.externalPackageInformation.getByUri(e);t&&t.npmUri&&t.name!=this.buildConfig.fullname&&(n.dependencies&&n.dependencies[t.npmUri]?r[t.npmUri]=n.dependencies[t.npmUri]:r[t.npmUri]=`^`+t.versionTxt)}let i=`Aventus build for @`+this.buildConfig.module,a=this.buildConfig.module;this.buildConfig.name&&(i+=`/`+this.buildConfig.name,a+=` `+this.buildConfig.name);let o={name:e.npmName==``?(`@`+this.buildConfig.module+`/`+this.buildConfig.name).toLowerCase():e.npmName,displayName:a,description:i,version:this.buildConfig.version,type:`module`,main:`index.js`,types:`index.d.ts`,dependencies:r};this.buildConfig.organization?o.author={name:this.buildConfig.organization}:ni.isConnected&&(o.author={name:ni.settings.username});for(let t of e.path){(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let e=(0,f.join)(t,`package.json`),n={};if((0,u.existsSync)(e))try{n=JSON.parse((0,u.readFileSync)(e,`utf8`))}catch{}let r={...o,...n};r.name=o.name,r.displayName=o.displayName,r.version=o.version,this.writeFile(e,JSON.stringify(r,null,2))}}if(i)for(let t of e.path)(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0}),i.write(t)}writeBuildI18n(e){let t=this.buildConfig.i18n?.locales??[];for(let n of e)for(let e of n.output){t.length>0&&!(0,u.existsSync)(e)&&(0,u.mkdirSync)(e,{recursive:!0});for(let r of t)if(n.mode==`singleFile`){let t={};for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e];t={...t,...n.exported[r]}}for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[r]}}let n=(0,f.join)(e,r+`.json`).toLowerCase();this.writeFile(n,JSON.stringify(t,null,4))}else if(n.mode==`oneToOne`){for(let t in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[t],i=(0,f.join)(e,n.file.name.replace(`@`,``).replace(w.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(i,JSON.stringify(n.exported[r],null,4))}for(let t in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[t],i=this.tsFiles[t.replace(w.I18n,w.ComponentLogic)];if(i instanceof j&&i.fileParsed){let t=(0,f.join)(e,i.fileParsed.classes[i.componentClassName].namespace.replace(/\./g,f.sep));(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let a=(0,f.join)(e,n.file.name.replace(w.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(a,JSON.stringify(n.exported[r],null,4))}}}else if(n.mode==`groupComponent`){for(let t in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[t],i=(0,f.join)(e,n.file.name.replace(`@`,``).replace(w.I18n,``)+`_`+r+`.json`).toLowerCase();this.writeFile(i,JSON.stringify(n.exported[r],null,4))}let t={};for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[r]}}let n=(0,f.join)(e,`_components_`+r+`.json`).toLowerCase();this.writeFile(n,JSON.stringify(t,null,4))}else n.mode==`basedOnAttribute`||n.mode}}async buildLocalCode(e,t){let n={codeNoNamespaceBefore:[],code:[],codeNoNamespaceAfter:[],doc:[],docNoNamespace:[],docInvisible:[],classesName:{},stylesheets:{},codeRenderInJs:[],codeNotRenderInJs:[],npm:{},npmsrc:{},htmlDoc:{},useDecorator:!1},r={},i={},a=!1,o=``;t!=``&&(o=t+`.`);let s=(e,t)=>{let n=[];for(let r of e){let e=``;e=r.uri==`@local`?this.noNamespaceUri[t]?r.fullName.replace(`$namespace$`,``):r.fullName.replace(`$namespace$`,o):r.uri==`@external`||r.uri==`@npm`?r.fullName:this.noNamespaceUri[r.uri]?r.fullName.replace(`$namespace$`,``):r.fullName.replace(`$namespace$`,o),n.push({fullName:e,isStrong:r.isStrong})}return n},c=(e,t)=>{let r=this.tsFiles[e.uri];if(r instanceof j&&r.compilationResult)if(t){let e=JSON.parse(JSON.stringify(r.compilationResult.htmlDoc));for(let t in e)e[t].class=this.buildConfig.module+`.`+e[t].class,n.htmlDoc[t]=e[t]}else n.htmlDoc={...n.htmlDoc,...r.compilationResult.htmlDoc}};for(let t of e)if(t.useDecorator&&(n.useDecorator=!0),this.noNamespaceUri[t.uri]){if(t.compiled!=``){let e;t.compiled.startsWith(`@After()`)?(n.codeNoNamespaceAfter.push(t.compiled.slice(8)),e=`after`):t.compiled.startsWith(`@Before()`)?(n.codeNoNamespaceBefore.push(t.compiled.slice(9)),e=`before`):a?(n.codeNoNamespaceAfter.push(t.compiled),e=`after`):(n.codeNoNamespaceBefore.push(t.compiled),e=`before`),r[t.classScript]||(r[t.classScript]={code:Zi(t.compiled,this.project.getConfig()),dependencies:s(t.dependencies,t.uri),fullName:t.classScript,required:t.required,noNamespace:e,type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName,tagName:t.tagName},t.slots&&(r[t.classScript].slots=t.slots))}else t.classScript!=``&&!i[t.classScript]&&!t.classScript.startsWith(`!staticClass_`)&&(i[t.classScript]={fullName:t.classScript,dependencies:s(t.dependencies,t.uri)}),t.classDoc!=``&&!i[t.classDoc]&&!t.classDoc.startsWith(`!staticClass_`)&&(i[t.classDoc]={fullName:t.classScript,dependencies:s(t.dependencies,t.uri)});if(t.docVisible!=``&&n.docNoNamespace.push(t.docVisible),t.docInvisible!=``&&n.docInvisible.push(t.docInvisible),t.npm.defTs&&(n.npm[``]||(n.npm[``]={content:[],imports:{}}),n.npm[``].content.push(t.npm.defTs)),t.npm.src){n.npmsrc[t.npm.exportPath]||(n.npmsrc[t.npm.exportPath]={content:[],imports:{},names:[],forcedDependencies:[],sourceUri:[]});let e=t.isExported.internal?`export `+t.npm.src:t.npm.src;n.npmsrc[t.npm.exportPath].content.push(e),n.npmsrc[t.npm.exportPath].sourceUri.includes(t.uri)||n.npmsrc[t.npm.exportPath].sourceUri.push(t.uri)}c(t,!1)}else{if(a=!0,t.classScript!=``&&!t.classScript.startsWith(`!staticClass_`)&&(n.classesName[t.classScript]={type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName}),t.compiled!=``){n.code.push(Zi(t.compiled,this.project.getConfig()));let e=o+t.classScript;r[e]||(r[e]={code:Zi(t.compiled,this.project.getConfig()),dependencies:s(t.dependencies,t.uri),fullName:e,required:t.required,type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName,tagName:t.tagName},t.slots&&(r[e].slots=t.slots))}else{if(t.classScript!=``&&!i[t.classScript]&&!t.classScript.startsWith(`!staticClass_`)){let e=o+t.classScript;i[t.classScript]={fullName:e,dependencies:s(t.dependencies,t.uri)}}if(t.classDoc!=``&&!i[t.classDoc]&&!t.classDoc.startsWith(`!staticClass_`)){let e=o+t.classDoc;i[t.classDoc]={fullName:e,dependencies:s(t.dependencies,t.uri)}}}if(t.docVisible!=``&&n.doc.push(t.docVisible),t.docInvisible!=``&&n.docInvisible.push(t.docInvisible),t.npm.defTs){n.npm[t.npm.namespace]||(n.npm[t.npm.namespace]={content:[],imports:{}});let e=t.npm.defTs;if(t.isExported.external)if(e.startsWith(`/**`)){let t=/\/\*\*[\s\S]*?\*\/((\r)?(\n)?)*/.exec(e);t&&(e=e.replace(t[0],t[0]+`export `))}else e=`export `+e;n.npm[t.npm.namespace].content.push(e);let r=this.tsFiles[t.npm.uri].fileParsed?.npmGeneratedImport;if(r)for(let e in r){let i=n.npm[t.npm.namespace].imports;i[e]||(i[e]=[]);for(let t of r[e]){if(t.onlySrc)continue;let n=t.alias?t.name+` as `+t.alias:t.name;i[e].includes(n)||i[e].push(n)}}}if(t.npm.src){if(!n.npmsrc[t.npm.exportPath]){n.npmsrc[t.npm.exportPath]={content:[],imports:{},names:[],forcedDependencies:[],sourceUri:[]};let e=this.tsFiles[t.npm.uri].fileParsed,r=e?.npmGeneratedImport;if(r)for(let i in r)if(i.startsWith(`.`)){let a=e?.importsLocal??{},o=e?.manualImportLocal??{};for(let e of r[i]){let r=a[e.name]??o[e.nameAlias??e.name];if(!r||r.isTypeImport)continue;let i=r.info?.fileUri??``,s=t.npm.uri,c=na(i,s);c=c.replace(w.Base,`.js`),n.npmsrc[t.npm.exportPath].imports[c]||(n.npmsrc[t.npm.exportPath].imports[c]=[]);let l=e.alias?e.name+` as `+e.alias:e.name;n.npmsrc[t.npm.exportPath].imports[c].push(l),e.forced&&n.npmsrc[t.npm.exportPath].forcedDependencies.push(e.alias??e.name)}}else{n.npmsrc[t.npm.exportPath].imports[i+`/index.js`]||(n.npmsrc[t.npm.exportPath].imports[i+`/index.js`]=[]);for(let e of r[i])if(e.compiled){let r=e.alias?e.name+` as `+e.alias:e.name;n.npmsrc[t.npm.exportPath].imports[i+`/index.js`].push(r),e.forced&&n.npmsrc[t.npm.exportPath].forcedDependencies.push(e.alias??e.name)}}}let e=t.isExported.internal?`export `+t.npm.src:t.npm.src;n.npmsrc[t.npm.exportPath].content.push(e),n.npmsrc[t.npm.exportPath].sourceUri.includes(t.uri)||n.npmsrc[t.npm.exportPath].sourceUri.push(t.uri),t.isExported.internal&&t.classScript&&n.npmsrc[t.npm.exportPath].names.push(this.module+`.`+t.classScript)}c(t,!0)}n.codeRenderInJs=Object.values(r),n.codeNotRenderInJs=Object.values(i);for(let e in this.globalComponentSCSSFiles){let t=this.globalComponentSCSSFiles[e];n.stylesheets[t.globalName]=t.compileResult}return n}async buildOrderCompilationInfo(e){let t={toCompile:[],libSrc:[],errors:[]},n={},r=[],i={},a={};for(let e in this.tsFiles){let t=this.tsFiles[e];for(let e of t.compileResult){if(e.classScript!==``)if(a[e.classScript]){let n=!1,r=`The name `+e.classScript+` is registered more than once.`,i=t.fileParsed?.getBaseInfoFullName(e.classScript);i&&(this.addDiagnostic(t,L(t.file.documentUser,r,i.nameStart,i.nameEnd,1023)),n=!0);let o=this.tsFiles[a[e.classScript].uri];i=o.fileParsed?.getBaseInfoFullName(e.classScript),i&&(this.addDiagnostic(o,L(o.file.documentUser,r,i.nameStart,i.nameEnd,1023)),n=!0),n||$.showErrorMessage(r)}else i[e.classScript]=e,a[e.classScript]=e;e.classDoc!==``&&!i[e.classDoc]&&(i[e.classDoc]=e)}}let o=[],s=[],c={},l=(e,a,u,d,f)=>{let p=e.fullName.replace(`$namespace$`,``),m=``,h=null;if(a)m=`@local`;else{if(h=this.externalPackageInformation.getByFullName(p),!h)return u;m=h.uri}if(d[p]!==void 0){if(e.isStrong){if(f[p]!==void 0)return r.push(`You have an infinite loop with your strong dependency [`+p+`]`),u;let e=new Promise(e=>{d[p].push(()=>{e({[m]:p})})});return o.push(e),e}return u}else d[p]=[];e.isStrong&&(f[p]=!0);let g=[],_=(()=>{if(a){if(!i[p]){u[m]===void 0&&(u[m]=-1);return}let e=s.indexOf(p);if(e!=-1){u[m]===void 0&&(u[m]=e+1);return}let a=i[p],o=0,c=[...a.dependencies];if(p.includes(`.`)){let e=p.split(`.`);e.pop();let t=i[e.join(`.`)];t&&t!=a&&c.push({fullName:t.classScript,isStrong:!0,uri:t.uri})}for(let e of c){if(e.uri==`@npm`)continue;let n={...u};if(e.uri==`@external`){let t=l(e,!1,u,d,{});t instanceof Promise?e.isStrong&&g.push(t):u=t}else if(e.isStrong){if(e.fullName.replace(`$namespace$`,``)!=p){let t=l(e,!0,u,d,f);t instanceof Promise?g.push(t):(u=t,u[m]&&u[m]>=0&&u[m]>o&&(o=u[m]))}}else{let n=t.toCompile.length,r=l(e,!0,u,d,{});r instanceof Promise||(u=r,u[m]&&u[m]>=0&&u[m]>o&&(o=u[m]));let i=t.toCompile.length;u[m]&&u[m]>=0&&u[m]>o&&o>0&&(o+=i-n)}u=n}if(s.indexOf(p)!=-1){t[m]=s.indexOf(p);return}if(g.length==0){a.tagName&&(n[a.tagName]?r.push(`The tag <`+a.tagName+`> is declared by `+n[a.tagName]+` and `+a.classScript):n[a.tagName]=a.classScript),t.toCompile.splice(o,0,a),s.splice(o,0,p);for(let e of d[p])e();d[p]=[],u[m]=t.toCompile.length}else return u[m]=t.toCompile.length,o==s.length?`@end_`+s[s.length-1]:s[o];return}else{if(!h||!this.dependencyUris.includes(m))return;c[m]||(c[m]=[]);let e=c[m].indexOf(p);if(e!=-1){u[m]=e+1;return}let t=0;if(h.content!=`noCode`){Array.isArray(h.content.dependencies)||(console.log(`Problem with `+h.content.fullName),console.log(h.content));for(let e of h.content.dependencies){let n={...u},r=e.isStrong?f:{},i=l(e,!1,u,d,r);i instanceof Promise?e.isStrong&&g.push(i):(u=i,u[m]&&u[m]>=0&&u[m]>t&&(t=u[m])),u=n}}if(c[m].includes(p)){u[m]=c[m].indexOf(p);return}if(g.length==0){if(h.content!=`noCode`&&h.content.tagName){let e=h.content.tagName;n[e]?r.push(`The tag <`+h.content.tagName+`> is declared by `+n[e]+` and `+h.content.fullName):n[e]=h.content.fullName}c[m].splice(t,0,p),u[m]=c[m].length;for(let e of d[p])e();d[p]=[]}else return t==c[m].length?`@end_`+c[m][c[m].length-1]:c[m][t];return}})();if(e.isStrong&&delete f[p],g.length==0)return d[p]&&d[p].length==0&&delete d[p],u;{let e=new Promise(async e=>{let n=await Promise.all(g),r=u[m]??0;if(_){let e=-1,t=_.replace(`@end_`,``);e=a?s.indexOf(t):c[m].indexOf(t),e!=-1&&(_.startsWith(`@end_`)&&e++,r=e)}for(let e of n)if(e[m]){let t=e[m];if(a){let e=s.indexOf(t)+1;e>r&&(r=e)}else{let e=c[m].indexOf(t)+1;e>r&&(r=e)}}if(a){let e=i[p];s.includes(p)||(t.toCompile.splice(r,0,e),s.splice(r,0,p))}else c[m].includes(p)||c[m].splice(r,0,p);for(let e of d[p])e();delete d[p],e({[m]:p})});return o.push(e),e}};for(let t in this.tsFiles){let n=this.tsFiles[t],r=n.file.path.match(e.inputPathRegex);for(let e of n.compileResult)!e.required&&!r||(e.classScript!==``&&l({fullName:e.classScript,isStrong:!0},!0,{},{},{}),e.classDoc!==``&&l({fullName:e.classDoc,isStrong:!0},!0,{},{},{}))}await Promise.all(o),o=[];for(let e of this.dependencyNeedUris){let t=this.externalPackageInformation.getInformationsRequired(e);c[e]||(c[e]=[]);for(let n of t)c[e].includes(n.fullName)||l({fullName:n.fullName,isStrong:!0},!1,{},{},{})}await Promise.all(o),o=[];for(let e of this.dependencyFullUris){c[e]||(c[e]=[]);let t=this.externalPackageInformation.getFullInformations(e);for(let n of t)c[e].includes(n.fullName)||l({fullName:n.fullName,isStrong:!0},!1,{},{},{})}await Promise.all(o),o=[];let u=[],d=this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1;for(let t of this.dependencyUris){let n={namespace:this.externalPackageInformation.getNamespaceByUri(t),before:[],code:[],after:[],classesName:{}};if(!c[t])continue;for(let e of c[t]){let t=this.externalPackageInformation.getByFullName(e);if(t.content!=`noCode`){let e=Zi(t.content.code,this.project.getConfig());if(t.content.noNamespace)t.content.noNamespace==`before`?n.before.push(e):t.content.noNamespace==`after`&&n.after.push(e);else{n.code.push(e);let r=RegExp(`^`+this.externalPackageInformation.getNamespaceByUri(t.uri)+`.`),i=t.content.fullName.replace(r,``);n.classesName[i]={type:t.content.type,isExported:t.content.isExported,convertibleName:t.content.convertibleName}}}}let r=this.externalPackageInformation.getStyleByUri(t),i=[];for(let e in r)i.push(`Aventus.Style.store("${e}", \`${r[e]}\`)`);let a=this._buildStringModule(n.namespace,n.before,n.code,n.classesName,n.after,i);if(n.namespace==`Aventus`&&n.classesName.I18n&&this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1){d=!1;let t=e.i18n[0];if(a+=`Aventus.I18n.registerLocales(${JSON.stringify(this.buildConfig.i18n.locales)})
700
+ `}i+=a,i=Kt.removeUnusedImport(i,[]);for(let n of e.path){let e=(0,f.join)(n,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0});let r=(0,f.join)(e,`index.js`);await this.writeFile(r,i)}};for(let e of n)await a(e,t.npm[e]),await o(e);if(e.packageJson){let t=(0,f.join)(this.project.getConfigFile().folderPath,`package.json`),n={};(0,u.existsSync)(t)&&(n=JSON.parse((0,u.readFileSync)(t,`utf-8`)));let r={};for(let e of this.externalPackageInformation.filesUri){let t=this.externalPackageInformation.getByUri(e);t&&t.npmUri&&t.name!=this.buildConfig.fullname&&(n.dependencies&&n.dependencies[t.npmUri]?r[t.npmUri]=n.dependencies[t.npmUri]:r[t.npmUri]=`^`+t.versionTxt)}let i=`Aventus build for @`+this.buildConfig.module,a=this.buildConfig.module;this.buildConfig.name&&(i+=`/`+this.buildConfig.name,a+=` `+this.buildConfig.name);let o={name:e.npmName==``?(`@`+this.buildConfig.module+`/`+this.buildConfig.name).toLowerCase():e.npmName,displayName:a,description:i,version:this.buildConfig.version,type:`module`,main:`index.js`,types:`index.d.ts`,dependencies:r};this.buildConfig.organization?o.author={name:this.buildConfig.organization}:ni.isConnected&&(o.author={name:ni.settings.username});for(let t of e.path){(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let e=(0,f.join)(t,`package.json`),n={};if((0,u.existsSync)(e))try{n=JSON.parse((0,u.readFileSync)(e,`utf8`))}catch{}let r={...o,...n};r.name=o.name,r.displayName=o.displayName,r.version=o.version,await this.writeFile(e,JSON.stringify(r,null,2))}}if(i)for(let t of e.path)(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0}),await i.write(t)}async writeBuildI18n(e){let t=this.buildConfig.i18n?.locales??[];for(let n of e)for(let e of n.output){t.length>0&&!(0,u.existsSync)(e)&&(0,u.mkdirSync)(e,{recursive:!0});for(let r of t)if(n.mode==`singleFile`){let t={};for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e];t={...t,...n.exported[r]}}for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[r]}}let n=(0,f.join)(e,r+`.json`).toLowerCase();await this.writeFile(n,JSON.stringify(t,null,4))}else if(n.mode==`oneToOne`){for(let t in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[t],i=(0,f.join)(e,n.file.name.replace(`@`,``).replace(w.I18n,``)+`_`+r+`.json`).toLowerCase();await this.writeFile(i,JSON.stringify(n.exported[r],null,4))}for(let t in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[t],i=this.tsFiles[t.replace(w.I18n,w.ComponentLogic)];if(i instanceof j&&i.fileParsed){let t=(0,f.join)(e,i.fileParsed.classes[i.componentClassName].namespace.replace(/\./g,f.sep));(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let a=(0,f.join)(e,n.file.name.replace(w.I18n,``)+`_`+r+`.json`).toLowerCase();await this.writeFile(a,JSON.stringify(n.exported[r],null,4))}}}else if(n.mode==`groupComponent`){for(let t in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[t],i=(0,f.join)(e,n.file.name.replace(`@`,``).replace(w.I18n,``)+`_`+r+`.json`).toLowerCase();await this.writeFile(i,JSON.stringify(n.exported[r],null,4))}let t={};for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[r]}}let n=(0,f.join)(e,`_components_`+r+`.json`).toLowerCase();await this.writeFile(n,JSON.stringify(t,null,4))}else n.mode==`basedOnAttribute`||n.mode}}async buildLocalCode(e,t){let n={codeNoNamespaceBefore:[],code:[],codeNoNamespaceAfter:[],doc:[],docNoNamespace:[],docInvisible:[],classesName:{},stylesheets:{},codeRenderInJs:[],codeNotRenderInJs:[],npm:{},npmsrc:{},htmlDoc:{},useDecorator:!1},r={},i={},a=!1,o=``;t!=``&&(o=t+`.`);let s=(e,t)=>{let n=[];for(let r of e){let e=``;e=r.uri==`@local`?this.noNamespaceUri[t]?r.fullName.replace(`$namespace$`,``):r.fullName.replace(`$namespace$`,o):r.uri==`@external`||r.uri==`@npm`?r.fullName:this.noNamespaceUri[r.uri]?r.fullName.replace(`$namespace$`,``):r.fullName.replace(`$namespace$`,o),n.push({fullName:e,isStrong:r.isStrong})}return n},c=(e,t)=>{let r=this.tsFiles[e.uri];if(r instanceof j&&r.compilationResult)if(t){let e=JSON.parse(JSON.stringify(r.compilationResult.htmlDoc));for(let t in e)e[t].class=this.buildConfig.module+`.`+e[t].class,n.htmlDoc[t]=e[t]}else n.htmlDoc={...n.htmlDoc,...r.compilationResult.htmlDoc}};for(let t of e)if(t.useDecorator&&(n.useDecorator=!0),this.noNamespaceUri[t.uri]){if(t.compiled!=``){let e;t.compiled.startsWith(`@After()`)?(n.codeNoNamespaceAfter.push(t.compiled.slice(8)),e=`after`):t.compiled.startsWith(`@Before()`)?(n.codeNoNamespaceBefore.push(t.compiled.slice(9)),e=`before`):a?(n.codeNoNamespaceAfter.push(t.compiled),e=`after`):(n.codeNoNamespaceBefore.push(t.compiled),e=`before`),r[t.classScript]||(r[t.classScript]={code:Zi(t.compiled,this.project.getConfig()),dependencies:s(t.dependencies,t.uri),fullName:t.classScript,required:t.required,noNamespace:e,type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName,tagName:t.tagName},t.slots&&(r[t.classScript].slots=t.slots))}else t.classScript!=``&&!i[t.classScript]&&!t.classScript.startsWith(`!staticClass_`)&&(i[t.classScript]={fullName:t.classScript,dependencies:s(t.dependencies,t.uri)}),t.classDoc!=``&&!i[t.classDoc]&&!t.classDoc.startsWith(`!staticClass_`)&&(i[t.classDoc]={fullName:t.classScript,dependencies:s(t.dependencies,t.uri)});if(t.docVisible!=``&&n.docNoNamespace.push(t.docVisible),t.docInvisible!=``&&n.docInvisible.push(t.docInvisible),t.npm.defTs&&(n.npm[``]||(n.npm[``]={content:[],imports:{}}),n.npm[``].content.push(t.npm.defTs)),t.npm.src){n.npmsrc[t.npm.exportPath]||(n.npmsrc[t.npm.exportPath]={content:[],imports:{},names:[],forcedDependencies:[],sourceUri:[]});let e=t.isExported.internal?`export `+t.npm.src:t.npm.src;n.npmsrc[t.npm.exportPath].content.push(e),n.npmsrc[t.npm.exportPath].sourceUri.includes(t.uri)||n.npmsrc[t.npm.exportPath].sourceUri.push(t.uri)}c(t,!1)}else{if(a=!0,t.classScript!=``&&!t.classScript.startsWith(`!staticClass_`)&&(n.classesName[t.classScript]={type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName}),t.compiled!=``){n.code.push(Zi(t.compiled,this.project.getConfig()));let e=o+t.classScript;r[e]||(r[e]={code:Zi(t.compiled,this.project.getConfig()),dependencies:s(t.dependencies,t.uri),fullName:e,required:t.required,type:t.type,isExported:t.isExported.external,convertibleName:t.convertibleName,tagName:t.tagName},t.slots&&(r[e].slots=t.slots))}else{if(t.classScript!=``&&!i[t.classScript]&&!t.classScript.startsWith(`!staticClass_`)){let e=o+t.classScript;i[t.classScript]={fullName:e,dependencies:s(t.dependencies,t.uri)}}if(t.classDoc!=``&&!i[t.classDoc]&&!t.classDoc.startsWith(`!staticClass_`)){let e=o+t.classDoc;i[t.classDoc]={fullName:e,dependencies:s(t.dependencies,t.uri)}}}if(t.docVisible!=``&&n.doc.push(t.docVisible),t.docInvisible!=``&&n.docInvisible.push(t.docInvisible),t.npm.defTs){n.npm[t.npm.namespace]||(n.npm[t.npm.namespace]={content:[],imports:{}});let e=t.npm.defTs;if(t.isExported.external)if(e.startsWith(`/**`)){let t=/\/\*\*[\s\S]*?\*\/((\r)?(\n)?)*/.exec(e);t&&(e=e.replace(t[0],t[0]+`export `))}else e=`export `+e;n.npm[t.npm.namespace].content.push(e);let r=this.tsFiles[t.npm.uri].fileParsed?.npmGeneratedImport;if(r)for(let e in r){let i=n.npm[t.npm.namespace].imports;i[e]||(i[e]=[]);for(let t of r[e]){if(t.onlySrc)continue;let n=t.alias?t.name+` as `+t.alias:t.name;i[e].includes(n)||i[e].push(n)}}}if(t.npm.src){if(!n.npmsrc[t.npm.exportPath]){n.npmsrc[t.npm.exportPath]={content:[],imports:{},names:[],forcedDependencies:[],sourceUri:[]};let e=this.tsFiles[t.npm.uri].fileParsed,r=e?.npmGeneratedImport;if(r)for(let i in r)if(i.startsWith(`.`)){let a=e?.importsLocal??{},o=e?.manualImportLocal??{};for(let e of r[i]){let r=a[e.name]??o[e.nameAlias??e.name];if(!r||r.isTypeImport)continue;let i=r.info?.fileUri??``,s=t.npm.uri,c=na(i,s);c=c.replace(w.Base,`.js`),n.npmsrc[t.npm.exportPath].imports[c]||(n.npmsrc[t.npm.exportPath].imports[c]=[]);let l=e.alias?e.name+` as `+e.alias:e.name;n.npmsrc[t.npm.exportPath].imports[c].push(l),e.forced&&n.npmsrc[t.npm.exportPath].forcedDependencies.push(e.alias??e.name)}}else{n.npmsrc[t.npm.exportPath].imports[i+`/index.js`]||(n.npmsrc[t.npm.exportPath].imports[i+`/index.js`]=[]);for(let e of r[i])if(e.compiled){let r=e.alias?e.name+` as `+e.alias:e.name;n.npmsrc[t.npm.exportPath].imports[i+`/index.js`].push(r),e.forced&&n.npmsrc[t.npm.exportPath].forcedDependencies.push(e.alias??e.name)}}}let e=t.isExported.internal?`export `+t.npm.src:t.npm.src;n.npmsrc[t.npm.exportPath].content.push(e),n.npmsrc[t.npm.exportPath].sourceUri.includes(t.uri)||n.npmsrc[t.npm.exportPath].sourceUri.push(t.uri),t.isExported.internal&&t.classScript&&n.npmsrc[t.npm.exportPath].names.push(this.module+`.`+t.classScript)}c(t,!0)}n.codeRenderInJs=Object.values(r),n.codeNotRenderInJs=Object.values(i);for(let e in this.globalComponentSCSSFiles){let t=this.globalComponentSCSSFiles[e];n.stylesheets[t.globalName]=t.compileResult}return n}async buildOrderCompilationInfo(e){let t={toCompile:[],libSrc:[],errors:[]},n={},r=[],i={},a={};for(let e in this.tsFiles){let t=this.tsFiles[e];for(let e of t.compileResult){if(e.classScript!==``)if(a[e.classScript]){let n=!1,r=`The name `+e.classScript+` is registered more than once.`,i=t.fileParsed?.getBaseInfoFullName(e.classScript);i&&(this.addDiagnostic(t,L(t.file.documentUser,r,i.nameStart,i.nameEnd,1023)),n=!0);let o=this.tsFiles[a[e.classScript].uri];i=o.fileParsed?.getBaseInfoFullName(e.classScript),i&&(this.addDiagnostic(o,L(o.file.documentUser,r,i.nameStart,i.nameEnd,1023)),n=!0),n||$.showErrorMessage(r)}else i[e.classScript]=e,a[e.classScript]=e;e.classDoc!==``&&!i[e.classDoc]&&(i[e.classDoc]=e)}}let o=[],s=[],c={},l=(e,a,u,d,f)=>{let p=e.fullName.replace(`$namespace$`,``),m=``,h=null;if(a)m=`@local`;else{if(h=this.externalPackageInformation.getByFullName(p),!h)return u;m=h.uri}if(d[p]!==void 0){if(e.isStrong){if(f[p]!==void 0)return r.push(`You have an infinite loop with your strong dependency [`+p+`]`),u;let e=new Promise(e=>{d[p].push(()=>{e({[m]:p})})});return o.push(e),e}return u}else d[p]=[];e.isStrong&&(f[p]=!0);let g=[],_=(()=>{if(a){if(!i[p]){u[m]===void 0&&(u[m]=-1);return}let e=s.indexOf(p);if(e!=-1){u[m]===void 0&&(u[m]=e+1);return}let a=i[p],o=0,c=[...a.dependencies];if(p.includes(`.`)){let e=p.split(`.`);e.pop();let t=i[e.join(`.`)];t&&t!=a&&c.push({fullName:t.classScript,isStrong:!0,uri:t.uri})}for(let e of c){if(e.uri==`@npm`)continue;let n={...u};if(e.uri==`@external`){let t=l(e,!1,u,d,{});t instanceof Promise?e.isStrong&&g.push(t):u=t}else if(e.isStrong){if(e.fullName.replace(`$namespace$`,``)!=p){let t=l(e,!0,u,d,f);t instanceof Promise?g.push(t):(u=t,u[m]&&u[m]>=0&&u[m]>o&&(o=u[m]))}}else{let n=t.toCompile.length,r=l(e,!0,u,d,{});r instanceof Promise||(u=r,u[m]&&u[m]>=0&&u[m]>o&&(o=u[m]));let i=t.toCompile.length;u[m]&&u[m]>=0&&u[m]>o&&o>0&&(o+=i-n)}u=n}if(s.indexOf(p)!=-1){t[m]=s.indexOf(p);return}if(g.length==0){a.tagName&&(n[a.tagName]?r.push(`The tag <`+a.tagName+`> is declared by `+n[a.tagName]+` and `+a.classScript):n[a.tagName]=a.classScript),t.toCompile.splice(o,0,a),s.splice(o,0,p);for(let e of d[p])e();d[p]=[],u[m]=t.toCompile.length}else return u[m]=t.toCompile.length,o==s.length?`@end_`+s[s.length-1]:s[o];return}else{if(!h||!this.dependencyUris.includes(m))return;c[m]||(c[m]=[]);let e=c[m].indexOf(p);if(e!=-1){u[m]=e+1;return}let t=0;if(h.content!=`noCode`){Array.isArray(h.content.dependencies)||(console.log(`Problem with `+h.content.fullName),console.log(h.content));for(let e of h.content.dependencies){let n={...u},r=e.isStrong?f:{},i=l(e,!1,u,d,r);i instanceof Promise?e.isStrong&&g.push(i):(u=i,u[m]&&u[m]>=0&&u[m]>t&&(t=u[m])),u=n}}if(c[m].includes(p)){u[m]=c[m].indexOf(p);return}if(g.length==0){if(h.content!=`noCode`&&h.content.tagName){let e=h.content.tagName;n[e]?r.push(`The tag <`+h.content.tagName+`> is declared by `+n[e]+` and `+h.content.fullName):n[e]=h.content.fullName}c[m].splice(t,0,p),u[m]=c[m].length;for(let e of d[p])e();d[p]=[]}else return t==c[m].length?`@end_`+c[m][c[m].length-1]:c[m][t];return}})();if(e.isStrong&&delete f[p],g.length==0)return d[p]&&d[p].length==0&&delete d[p],u;{let e=new Promise(async e=>{let n=await Promise.all(g),r=u[m]??0;if(_){let e=-1,t=_.replace(`@end_`,``);e=a?s.indexOf(t):c[m].indexOf(t),e!=-1&&(_.startsWith(`@end_`)&&e++,r=e)}for(let e of n)if(e[m]){let t=e[m];if(a){let e=s.indexOf(t)+1;e>r&&(r=e)}else{let e=c[m].indexOf(t)+1;e>r&&(r=e)}}if(a){let e=i[p];s.includes(p)||(t.toCompile.splice(r,0,e),s.splice(r,0,p))}else c[m].includes(p)||c[m].splice(r,0,p);for(let e of d[p])e();delete d[p],e({[m]:p})});return o.push(e),e}};for(let t in this.tsFiles){let n=this.tsFiles[t],r=n.file.path.match(e.inputPathRegex);for(let e of n.compileResult)!e.required&&!r||(e.classScript!==``&&l({fullName:e.classScript,isStrong:!0},!0,{},{},{}),e.classDoc!==``&&l({fullName:e.classDoc,isStrong:!0},!0,{},{},{}))}await Promise.all(o),o=[];for(let e of this.dependencyNeedUris){let t=this.externalPackageInformation.getInformationsRequired(e);c[e]||(c[e]=[]);for(let n of t)c[e].includes(n.fullName)||l({fullName:n.fullName,isStrong:!0},!1,{},{},{})}await Promise.all(o),o=[];for(let e of this.dependencyFullUris){c[e]||(c[e]=[]);let t=this.externalPackageInformation.getFullInformations(e);for(let n of t)c[e].includes(n.fullName)||l({fullName:n.fullName,isStrong:!0},!1,{},{},{})}await Promise.all(o),o=[];let u=[],d=this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1;for(let t of this.dependencyUris){let n={namespace:this.externalPackageInformation.getNamespaceByUri(t),before:[],code:[],after:[],classesName:{}};if(!c[t])continue;for(let e of c[t]){let t=this.externalPackageInformation.getByFullName(e);if(t.content!=`noCode`){let e=Zi(t.content.code,this.project.getConfig());if(t.content.noNamespace)t.content.noNamespace==`before`?n.before.push(e):t.content.noNamespace==`after`&&n.after.push(e);else{n.code.push(e);let r=RegExp(`^`+this.externalPackageInformation.getNamespaceByUri(t.uri)+`.`),i=t.content.fullName.replace(r,``);n.classesName[i]={type:t.content.type,isExported:t.content.isExported,convertibleName:t.content.convertibleName}}}}let r=this.externalPackageInformation.getStyleByUri(t),i=[];for(let e in r)i.push(`Aventus.Style.store("${e}", \`${r[e]}\`)`);let a=this._buildStringModule(n.namespace,n.before,n.code,n.classesName,n.after,i);if(n.namespace==`Aventus`&&n.classesName.I18n&&this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1){d=!1;let t=e.i18n[0];if(a+=`Aventus.I18n.registerLocales(${JSON.stringify(this.buildConfig.i18n.locales)})
701
701
  `,a+=`Aventus.I18n.registerFallback("${this.buildConfig.i18n.fallback}")
702
702
  `,t.mode==`singleFile`){let e=(t.mount+`/$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${e}", { load: false })
703
703
  `}else if(t.mode==`oneToOne`){for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(w.I18n,``),r=(t.mount+`/`+n+`_$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${r}", { load: false })
@@ -714,26 +714,26 @@ namespace `+this.buildConfig.module+`{
714
714
  `}if(Object.keys(this.i18nComponentsFiles).length>0){let e=(n.mount+`/_components_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${e}", { load: false })
715
715
  `}}else n.mode==`basedOnAttribute`||n.mode;t+=`Aventus.I18n.init()
716
716
  `}u.push({lib:`Aventus@I18n`,code:t})}if(t.libSrc=u,r.length>0){let e=this.buildConfig.fullname+`_dependencyErrors`;ci.send(e,r.join(`
717
- `)),t.errors.push({title:`Dependencies errors`,file:e})}return t}getAllFullnames(){let e={},t=t=>{if(t.startsWith(`!staticClass_`))return;let n=t.split(`.`)[0];e[n]||(e[n]=[]),e[n].push(t)};for(let e in this.tsFiles){let n=this.tsFiles[e];for(let e of n.compileResult)e.classScript!==``&&t(e.classScript)}for(let e of this.dependencyNeedUris){let n=this.externalPackageInformation.getInformationsRequired(e);for(let e of n)e.code&&t(e.fullName)}for(let e of this.dependencyFullUris){let n=this.externalPackageInformation.getFullInformations(e);for(let e of n)e.code&&t(e.fullName)}return e}async onNewFile(e){this.buildConfig.srcPathRegex&&e.path.match(this.buildConfig.srcPathRegex)&&this.registerFile(e,!1),this.buildConfig.outsideModulePathRegex&&e.path.match(this.buildConfig.outsideModulePathRegex)&&(this.registerFile(e,!1),this.noNamespaceUri[e.uri]=!0)}async loadFiles(){Pi.startSendBuildTime(this.buildConfig.fullname),this.allowBuild=!1;let e=await si.getInstance().loadDependenciesFromBuild(this.buildConfig,this);this.dependencyFullUris=e.dependencyFullUris,this.dependencyNeedUris=e.dependencyNeedUris,this.dependencyUris=e.dependencyUris,this.externalPackageInformation.init(e.files);let t=R.getInstance();if(this.buildConfig.srcPathRegex){let e=t.getFilesMatching(this.buildConfig.srcPathRegex);for(let t of e)this.registerFile(t,!0)}if(this.buildConfig.outsideModulePathRegex){let e=t.getFilesMatching(this.buildConfig.outsideModulePathRegex);for(let t of e)this.registerFile(t,!0),this.noNamespaceUri[t.uri]=!0}$.debug(`loaded all files needed`),this.allowBuild=!0,this._filesLoaded=!0,await this.rebuildAll(!0),Pi.sendBuildTime(this.buildConfig.fullname)}async registerFile(e,t){if(e.uri.endsWith(w.ComponentStyle))this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new Rr(e,this),t||await this.scssFiles[e.uri].init(),this.registerOnFileDelete(e),this.scssFiles[e.uri].isGlobal&&(this.globalComponentSCSSFiles[e.uri]=this.scssFiles[e.uri]));else if(e.uri.endsWith(w.ComponentView))this.htmlFiles[e.uri]||(this.htmlFiles[e.uri]=new zr(e,this),t||await this.htmlFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(w.Component))this.wcFiles[e.uri]||(this.wcFiles[e.uri]=new ui(e,this),t||await this.wcFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(w.I18n))e.name.startsWith(`@`)?this.tsLanguageService.i18nFiles[e.uri]||(this.tsLanguageService.i18nFiles[e.uri]=new yi(e,!0,this),t||await this.tsLanguageService.i18nFiles[e.uri].validate(),this.registerOnFileDelete(e)):this.i18nComponentsFiles[e.uri]||(this.i18nComponentsFiles[e.uri]=new yi(e,!1,this),t||await this.i18nComponentsFiles[e.uri].validate(),this.registerOnFileDelete(e));else if(!this.tsFiles[e.uri]){let t=Zr(e,this);t&&(this.tsFiles[e.uri]=t,this.registerOnFileDelete(e))}}registerOnFileDelete(e){this.onFileDeleteUUIDs[e.uri]=e.onDelete(this.onFileDelete.bind(this))}async onFileDelete(e){e.removeOnDelete(this.onFileDeleteUUIDs[e.uri]),delete this.onFileDeleteUUIDs[e.uri],e.uri.endsWith(w.ComponentStyle)?delete this.scssFiles[e.uri]:e.uri.endsWith(w.ComponentView)?delete this.htmlFiles[e.uri]:e.uri.endsWith(w.Component)?delete this.wcFiles[e.uri]:delete this.tsFiles[e.uri],await this.rebuildAll()}getLocalWebComponentDefinition(e,t=!1){let n=this.htmlLanguageService.getInternalDefinition(e);if(n&&n.fileParsed){let e=n.getComponentName();if(e){let t=n.fileParsed.classes[e];if(t)return t}}}getWebComponentTagDependency(e){let t=this.htmlLanguageService.getInternalTagUri(e);if(t){let e=RegExp(`^`+this.module+`\\.`);return{fullName:t.fullname.replace(e,`$namespace$`),uri:t.uri,isStrong:!1}}let n=this.getWebComponentDefinition(e);if(n){let e=n.class.fileUri;return n.isLocal||(e=`@external`),{fullName:n.class.fullName,uri:e,isStrong:!1}}return null}getWebComponentDefinition(e,t=!1){let n=this.htmlLanguageService.getInternalDefinition(e);if(n&&n.fileParsed){let e=n.getComponentName();if(e){let t=n.fileParsed.classes[e];if(t)return{class:t,isLocal:!0}}}let r=this.htmlLanguageService.getClassByTag(e);if(r){let n=this.externalPackageInformation.getExternalWebComponentDefinition(r);if(n){if(t){let t=this.project.getInternalWebComponentDefinition(I(n.fileUri),e);if(t)return{class:t,isLocal:!1}}return{class:n,isLocal:!1}}}}getWebComponentDefinitionFile(e){let t=this.htmlLanguageService.getInternalDefinition(e);if(t)return t;let n=this.htmlLanguageService.getClassByTag(e);if(n)return this.externalPackageInformation.getExternalWebComponentDefinitionFile(n)}getSlotsInfo(e){let t={},n=[],r=!1,i=e;for(;i&&i.fullName!=`Aventus.WebComponent`;){let a=this.tsFiles[i.fileUri];if(!a){let a=this.externalPackageInformation.getByFullName(i.fullName);if(a&&a.content!=`noCode`&&a.content.slots&&!r)for(let r in a.content.slots)n.includes(r)||(t[r]||(t[r]={local:i==e}),!t[r].doc&&i.documentation?.documentationSlots[r]&&(t[r].doc=i.documentation?.documentationSlots[r]))}else if(a instanceof j&&a.HTMLFile?.fileParsed?.slotsInfo&&!r){for(let r in a.HTMLFile.fileParsed.slotsInfo)n.includes(r)||(t[r]||(t[r]={local:i==e}),!t[r].doc&&i.documentation?.documentationSlots[r]&&(t[r].doc=i.documentation?.documentationSlots[r]));for(let e in a.HTMLFile.fileParsed.blocksInfo)t[e]||n.push(e)}i.decorators.find(e=>nn.is(e))&&(r=!0),i=i.parentClass}return t}getNamespaceForUri(e){if(this.buildConfig.namespaceStrategy==`manual`)return``;if(this.buildConfig.namespaceStrategy==`rules`){let t=I(e);for(let e in this.buildConfig.namespaceRulesRegex){let n=this.buildConfig.namespaceRulesRegex[e];if(t.match(n))return e}}else if(this.buildConfig.namespaceStrategy==`followFolders`||this.buildConfig.namespaceStrategy==`followFoldersCamelCase`){let t=e.endsWith(w.ComponentLogic),n=I(e),r=n.split(`/`);r.pop(),t&&r.pop(),n=r.join(`/`)+`/`;let i=n.replace(this.buildConfig.namespaceRoot,``).replace(/\//g,`.`);return i.endsWith(`.`)&&(i=i.slice(0,-1)),i.startsWith(`.`)&&(i=i.slice(1)),i.includes(`:`)?``:this.buildConfig.namespaceStrategy==`followFoldersCamelCase`?(i=i.slice(0,1).toUpperCase()+i.slice(1),i.replace(/(([-_\.]|^)[a-z])/g,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))):i}return``}addNamespace(e){if(!this.namespaces.includes(e)){let t=e.split(`.`),n=``;for(let e of t)n+=e,n&&!this.namespaces.includes(n)&&this.namespaces.push(n),n+=`.`}}async onRename(e){for(let t of e)if(t.oldUri.endsWith(w.Component)||t.oldUri.endsWith(w.ComponentLogic)||t.oldUri.endsWith(w.Data)||t.oldUri.endsWith(w.Lib)||t.oldUri.endsWith(w.RAM))return await this.tsLanguageService.onRenameFile(t.oldUri,t.newUri);return{}}npmAliases={};npmNameCount={};getNpmReplacementName(e,t){if(!this.hasNpmOutput)return``;let n=t.split(`.`),r=n.pop(),i=e.split(`.`);return i.pop(),n.join(`.`)==i.join(`.`)?r:this.npmAliases[t]?this.npmAliases[t]:(this.npmNameCount[r]||(this.npmNameCount[r]=0),this.npmNameCount[r]++,this.npmAliases[t]=r+this.npmNameCount[r],this.npmAliases[t])}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID);for(let e in this.scssFiles)this.scssFiles[e].removeEvents(),this.scssFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.htmlFiles)this.htmlFiles[e].removeEvents(),this.htmlFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.tsFiles)this.tsFiles[e].removeEvents(),this.tsFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.tsLanguageService.i18nFiles)this.tsLanguageService.i18nFiles[e].removeEvents(),this.tsLanguageService.i18nFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.i18nComponentsFiles)this.i18nComponentsFiles[e].removeEvents(),this.i18nComponentsFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);ei.send(this.project.getConfigFile().path,this.buildConfig.fullname)}writeFile(e,t){aa(e,t,`build`,this.buildConfig.fullname)}},xi=class{files={};informations={};informationsRequired={};webComponentByName={};build;constructor(e){this.build=e}get filesUri(){return Object.keys(this.files)}init(e){for(let t of e)this.files[t.file.uri]=t;this.rebuild()}getByFullName(e){return this.informations[e]}getByUri(e){return this.files[e]}getNpmUri(e){if(!this.build.hasNpmOutput)return null;if(this.informations[e]){let t=this.files[this.informations[e].uri];!t.npmUri&&this.build.initDone&&$.showErrorMessage(`Can't find a npm package for `+t.name+`. You must define the npm field inside the dependencies section of your aventus.conf.avt. Otherwise, you can disable storybook or remove npm export.`);let n=e.split(`.`),r=n.pop();n.splice(0,0,t.npmUri);let i=t.fileParsed?.getBaseInfo(r)?.willBeCompiled??!1;return{name:r,uri:n.join(`/`),compiled:i}}return null}getNamespaceByUri(e){return this.files[e].srcInfo.namespace}getNameByUri(e){return this.files[e].name}getInformationsRequired(e){return this.informationsRequired[e]}getFullInformations(e){return this.files[e]?.srcInfo.available||[]}getStyleByUri(e){return this.files[e]?this.files[e].externalCSS:{}}rebuild(){this.informations={},this.webComponentByName={};let e=[];for(let t in this.files){let n=this.files[t];this.informationsRequired[t]=[];for(let r of n.srcInfo.available)(r.required||this.build.buildConfig.i18n&&r.fullName==`Aventus.I18n`)&&this.informationsRequired[t].push(r),r.fullName&&(this.informations[r.fullName]?this.informations[r.fullName].uri!=t&&e.push({range:{start:{line:0,character:0},end:{line:0,character:0}},severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:`The name `+r.fullName+` exist inside `+t+` and `+this.informations[r.fullName].uri}):this.informations[r.fullName]={content:r,uri:t});for(let r of n.srcInfo.existing)r.fullName&&(this.informations[r.fullName]?this.informations[r.fullName].uri!=t&&e.push({range:{start:{line:0,character:0},end:{line:0,character:0}},severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:`The name `+r.fullName+` exist inside `+t+` and `+this.informations[r.fullName].uri}):this.informations[r.fullName]={content:`noCode`,uri:t});this.webComponentByName={...this.webComponentByName,...n.classInfoByName}}$.sendDiagnostics({uri:`@Import lib`,diagnostics:e},this.build)}getExternalWebComponentDefinition(e){return this.webComponentByName[e]}getExternalWebComponentDefinitionFile(e){let t=this.webComponentByName[e];if(t){let e=t.fileUri,n=this.files[e];if(n)return n}}},Si=class{staticConfig;watcher;isReady=!1;project;get name(){return this.staticConfig.name}constructor(e,t){this.project=e,this.staticConfig=t,this.registerWatcher(),this.isReady=!0}async export(){if(this.isReady){Pi.startSendStaticTime(this.name);let e=e=>{var t=[],n=e=>((0,u.existsSync)(e)&&(0,u.readdirSync)(e).forEach(r=>{let i=e+`/`+r;if((0,u.lstatSync)(i).isDirectory()){let e=n(i);e.length>0&&t.concat(e)}else t.push(i)}),t);return t=n(e),t},t=(e,t)=>{try{t=(0,f.normalize)(t);let n=t.split(f.sep),r=n.pop(),i=n.join(f.sep);if((0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0}),r.endsWith(`.scss`)){if(!r.startsWith(`_`)){let n=(0,ae.compile)(e,{style:`compressed`}).css.toString().trim();aa(t.replace(`.scss`,`.css`),n,`static`,this.name)}}else (0,u.copyFileSync)(e,t),Pi.sendFileSize(t,void 0,`static`,this.name)}catch(e){$.error(e)}},n=e(this.staticConfig.inputPathFolder);for(let e of n){e=e.replace(/\\/g,`/`);for(let n of this.staticConfig.outputPathFolder){let r=e.replace(this.staticConfig.inputPathFolder,n);if(e.endsWith(w.Base)){if(e.endsWith(w.GlobalStyle)){r=r.replace(w.GlobalStyle,`.css`);let t=this.project.scssFiles[F(e)];if(!t){let n=d.TextDocument.create(F(e),w.GlobalStyle,1,(0,u.readFileSync)(e,`utf8`));await R.getInstance().registerFile(n),t=this.project.scssFiles[F(e)]}await t.addOutPath(r,this.name)}}else t(e,r)}}D.getInstance().reload(),Pi.sendStaticTime(this.name)}}registerWatcher(){P.getInstance().settings.watchFiles&&(this.watcher=(0,me.watch)(this.staticConfig.inputPathFolder,{ignored:/^\./,persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:100},ignoreInitial:!0}),this.watcher.on(`add`,e=>{this.export()}),this.watcher.on(`change`,e=>{this.export()}),this.watcher.on(`unlink`,e=>{this.export()}),this.watcher.on(`error`,function(e){}))}destroy(){this.watcher&&this.watcher.close()}},Ci=class{languageService;variablesByUri={};variablesByName={};constructor(){this.languageService=(0,ie.getSCSSLanguageService)()}async doValidation(e){return this.languageService.doValidation(e.documentUser,this.languageService.parseStylesheet(e.documentUser))}async doComplete(e,t){return this.languageService.doComplete(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async doHover(e,t){return this.languageService.doHover(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async findDefinition(e,t){let n=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));return n&&[n]}async format(e,t,n){let r={...n,preserveNewLines:!0,spaceAroundSelectorSeparator:!0,insertFinalNewline:!0,insertSpaces:!1,tabSize:4},i=e.documentUser,a=await this.languageService.format(i,t,r);if(a.length==1){let e=i.offsetAt(a[0].range.start),t=i.offsetAt(a[0].range.end),n=i.getText().length;if(e==0&&t==n){let e=await(0,re.default)([(0,kr.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:Ar,from:`./temp.scss`,to:`./temp.scss`});a[0].newText=e.css}}return a}async doCodeAction(e,t){let n=this.languageService.parseStylesheet(e.documentUser),r=m.CodeActionContext.create(this.languageService.doValidation(e.documentUser,n));return this.languageService.doCodeActions2(e.documentUser,t,r,n)}async onReferences(e,t){let n=this.languageService.parseStylesheet(e.documentUser);return this.languageService.findReferences(e.documentUser,t,n)}loadVariables(e,t){let n=e.file.documentUser,r={},i=e=>{if(e.type==69){let i=e;for(;i&&i.selectors==null;)i=i.parent;if(i&&i.selectors.getText()==`:root`){let i=e.getChild(0),a=e.getChild(1);if(i&&a){let e=i.getText();e.startsWith(`--`)&&(i.offset,r[e]||(r[e]={name:e,uri:t,range:{start:n.positionAt(i.offset),end:n.positionAt(i.end)},value:a.getText()}))}}}else if(e.hasChildren())for(let t of e.getChildren())i(t)},a=Ir((0,ie.getSCSSLanguageService)().parseStylesheet(n),0);for(let e of a)i(e);this.variablesByUri[t]=Object.values(r),this.reloadVariables()}reloadVariables(){this.variablesByName={};for(let e in this.variablesByUri)for(let t of this.variablesByUri[e])this.variablesByName[t.name]||(this.variablesByName[t.name]=t)}removeVariables(e){delete this.variablesByUri[e],this.reloadVariables()}getDefinition(e){return this.variablesByName[e]}},wi=class{_file;_project;get file(){return this._file}get project(){return this._project}constructor(e,t){this._file=e,this._project=t,this.addEvents()}uuidEvents={onContentChange:``,onValidate:``,onSave:``,onDelete:``,onCompletion:``,onCompletionResolve:``,onHover:``,onDefinition:``,onFormatting:``,onCodeAction:``,onReferences:``,onCodeLens:``,onRename:``};addEvents(){this.uuidEvents.onContentChange=this.file.onContentChange(this.onContentChange.bind(this)),this.uuidEvents.onValidate=this.file.onValidate(this._onValidate.bind(this)),this.uuidEvents.onSave=this.file.onSave(this.onSave.bind(this)),this.uuidEvents.onDelete=this.file.onDelete(this._onDelete.bind(this)),this.uuidEvents.onCompletion=this.file.onCompletion(this.onCompletion.bind(this)),this.uuidEvents.onCompletionResolve=this.file.onCompletionResolve(this.onCompletionResolve.bind(this)),this.uuidEvents.onHover=this.file.onHover(this.onHover.bind(this)),this.uuidEvents.onDefinition=this.file.onDefinition(this.onDefinition.bind(this)),this.uuidEvents.onFormatting=this.file.onFormatting(this.onFormatting.bind(this)),this.uuidEvents.onCodeAction=this.file.onCodeAction(this.onCodeAction.bind(this)),this.uuidEvents.onReferences=this.file.onReferences(this.onReferences.bind(this)),this.uuidEvents.onCodeLens=this.file.onCodeLens(this.onCodeLens.bind(this)),this.uuidEvents.onRename=this.file.onRename(this.onRename.bind(this))}removeEvents(){this.file.removeOnContentChange(this.uuidEvents.onContentChange),this.file.removeOnValidate(this.uuidEvents.onValidate),this.file.removeOnSave(this.uuidEvents.onSave),this.file.removeOnDelete(this.uuidEvents.onDelete),this.file.removeOnCompletion(this.uuidEvents.onCompletion),this.file.removeOnCompletionResolve(this.uuidEvents.onCompletionResolve),this.file.removeOnHover(this.uuidEvents.onHover),this.file.removeOnDefinition(this.uuidEvents.onDefinition),this.file.removeOnFormatting(this.uuidEvents.onFormatting),this.file.removeOnCodeAction(this.uuidEvents.onCodeAction),this.file.removeOnReferences(this.uuidEvents.onReferences),this.file.removeOnCodeLens(this.uuidEvents.onCodeLens),this.file.removeOnRename(this.uuidEvents.onRename)}async validate(){this.file instanceof E&&await this.file.validate()}triggerSave(){this.file instanceof E&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof E&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async _onDelete(){await this.onDelete(),this.removeEvents()}},Ti=class e extends wi{compiledVersion=-1;usedBy={};dependencies={};diagnostics=[];diagnosticCompile;compiledTxt=``;savedOnce=!1;staticNamebyOutPath={};get resultCompiled(){return this.compiledTxt}constructor(e,t){super(e,t),this.loadDependencies(),this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}async onContentChange(){}async onValidate(){return this.diagnostics=await this.project.globalSCSSLanguageService.doValidation(this.file),this.loadDependencies(),this.diagnosticCompile?[...this.diagnostics,this.diagnosticCompile]:this.diagnostics}async onSave(){this.savedOnce=!0,this.compileRoot(),this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}compileRoot(){if(Object.values(this.usedBy).length==0)this.compile();else for(let e in this.usedBy)this.usedBy[e].onSave()}compile(){try{let e=this.compiledTxt,t=`|error|`,n=e=>{let r=e.contentUser;r=r.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let i=/@import *?('|")(\S*?)('|");?/g,a=null;for(;a=i.exec(r);){let i=a[2],o=this.resolvePath(i,e.folderPath);if(o){let e=n(o);if(e==t)return e;r=r.replace(a[0],e)}else return t}return r},r=n(this.file);if(r!=`|error|`){let t=e=>{if(P.getInstance().settings.errorByBuild){let t=this.project.getBuilds();for(let n of t)$.sendDiagnostics({uri:this.file.uri,diagnostics:e},n)}else $.sendDiagnostics({uri:this.file.uri,diagnostics:e})};try{let n=(0,ae.compileString)(r,{style:`compressed`}).css.toString().trim();n=n.replace(/\\/g,`\\\\`),e=n,this.diagnosticCompile&&(this.diagnosticCompile=void 0,t(this.diagnostics))}catch(e){e instanceof ae.Exception&&(this.diagnosticCompile=Ui(this.file.documentUser,e.message),t([...this.diagnostics,this.diagnosticCompile]))}}e!=this.compiledTxt&&(this.compiledVersion++,this.compiledTxt=e,this.export())}catch(e){console.error(e)}}async onDelete(){for(let e in this.dependencies)this.removeDependency(e);for(let e in this.usedBy)delete this.usedBy[e].dependencies[this.file.uri],delete this.usedBy[e],await this.usedBy[e].onContentChange();this.project.globalSCSSLanguageService.removeVariables(this.file.uri)}async onCompletion(e,t){let n={isIncomplete:!1,items:[]};return n=await this.project.globalSCSSLanguageService.doComplete(e,t),n}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.project.globalSCSSLanguageService.doHover(e,t)}async onDefinition(e,t){return this.project.globalSCSSLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return this.project.globalSCSSLanguageService.format(e,t,n)}async onCodeAction(e,t){return this.project.globalSCSSLanguageService.doCodeAction(e,t)}async onReferences(e,t){return await this.project.globalSCSSLanguageService.onReferences(e,t)}async onCodeLens(e){return[]}async onRename(e,t,n){return null}async addOutPath(e,t){this.file.shortname.startsWith(`_`)||this.staticNamebyOutPath[e]||(this.staticNamebyOutPath[e]=t,this.savedOnce||await this.onSave(),this.export())}export(){for(let e in this.staticNamebyOutPath){let t=(0,f.normalize)(e),n=t.split(f.sep);n.pop();let r=n.join(f.sep);(0,u.existsSync)(r)||(0,u.mkdirSync)(r,{recursive:!0}),aa(t,this.compiledTxt,`static`,this.staticNamebyOutPath[e])}}loadDependencies(){let e=this.file.contentUser,t=e.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`),n=/@import *?('|")(\S*?)('|");?/g,r=null;for(let e in this.dependencies)this.removeDependency(e);for(;r=n.exec(t);){let t=r[2],n=this.resolvePath(t,this.file.folderPath);if(n)this.addDependency(n);else{let t=e.indexOf(r[0]),n=t+r[0].length;this.diagnostics.push(Wi(this.file.documentUser,`Can't load this file`,t,n))}}}removeDependency(e){this.dependencies[e]&&(delete this.dependencies[e].usedBy[this.file.uri],delete this.dependencies[e])}addDependency(t){this.project.scssFiles[t.uri]?(this.dependencies[t.uri]=this.project.scssFiles[t.uri],this.project.scssFiles[t.uri].usedBy[this.file.uri]=this):t.uri.endsWith(w.GlobalStyle)&&(this.project.scssFiles[t.uri]=new e(t,this.project),this.dependencies[t.uri]=this.project.scssFiles[t.uri],this.project.scssFiles[t.uri].usedBy[this.file.uri]=this)}resolvePath(e,t){e=this.project.resolveAlias(e,t),e=(0,f.normalize)(t+`/`+e);let n=R.getInstance().getByPath(e);if(n)return n;let r=e+w.GlobalStyle;if(n=R.getInstance().getByPath(r),n)return n;let i=e.split(f.sep);i[i.length-1]=`_`+i[i.length-1];let a=i.join(f.sep);if(n=R.getInstance().getByPath(a),n)return n;let o=a+w.GlobalStyle;if(n=R.getInstance().getByPath(o),n)return n}},Ei=class{waitingList=[];isLocked=!1;waitOne(){return new Promise(e=>{this.isLocked?this.waitingList.push(()=>{e()}):(this.isLocked=!0,e())})}release(){let e=this.waitingList.shift();e?e():this.isLocked=!1}dispose(){this.waitingList=[],this.isLocked=!1}},Di=class{configFile;config=null;builds=[];statics=[];_isCoreBuild=!1;scssFiles={};onValidateUUID;onSaveUUID;onFormattingUUID;onCompletionUUID;onCompletionResolveUUID;onHoverUUID;onNewFileUUID;onFileDeleteUUIDs={};buildsAllowed;staticsAllowed;globalSCSSLanguageService;get isCoreBuild(){return this._isCoreBuild}getConfigFile(){return this.configFile}getConfig(){return this.config}resolveAlias(e,t){if(e.startsWith(`@`)){let n=e.split(`/`),r=n[0],i=this.config?.aliases[r];if(i){let e=(0,f.normalize)(this.configFile.folderPath+`/`+i);typeof t!=`string`&&(t=t.folderPath);let r=(0,f.normalize)(t);e.endsWith(f.sep)&&(e=e.substring(0,e.length-1)),r.endsWith(f.sep)&&(r=r.substring(0,r.length-1));let a=e.split(f.sep),o=r.split(f.sep);for(let e=0;e<a.length;e++)if(o.length>e)if(a[e]==o[e])a.splice(e,1),o.splice(e,1),e--;else break;let s=``;for(let e=0;e<o.length;e++)s+=`../`;return s==``&&(s+=`./`),s+=a.join(`/`),n.splice(0,1,s),n.join(`/`).replace(/\/\//g,`/`)}}return e}getInternalWebComponentDefinition(e,t){for(let n of this.builds)if(n.outputPathes.includes(e))return n.getLocalWebComponentDefinition(t)}constructor(e,t){this.configFile=e,this.onValidateUUID=this.configFile.onValidate(this.onValidate.bind(this)),this.onSaveUUID=this.configFile.onSave(this.onConfigSave.bind(this)),this.onFormattingUUID=this.configFile.onFormatting(this.onFormatting.bind(this)),this.onCompletionUUID=this.configFile.onCompletion(this.onCompletion.bind(this)),this.onCompletionResolveUUID=this.configFile.onCompletionResolve(this.onCompletionResolve.bind(this)),this.onHoverUUID=this.configFile.onHover(this.onHover.bind(this)),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile.bind(this)),e.folderUri.toLowerCase().endsWith(`/aventus/base/src`)&&(this._isCoreBuild=!0),this.globalSCSSLanguageService=new Ci,t&&this.loadFiles(),e.validate()}async init(){await this.onConfigSave()}async onValidate(){return await xe.getInstance().validate(this.configFile)}async loadConfig(){let e=await xe.getInstance().getConfig(this.configFile);if(this.config){let t=JSON.stringify(this.config),n=``;if(e&&(n=JSON.stringify(e)),t==n)return;for(let e of this.builds)e.destroy()}this.builds=[],this.config=e}onConfigSaveMutex=new Ei;async onConfigSave(){if(await this.onConfigSaveMutex.waitOne(),await this.loadConfig(),this.config){for(let e of this.builds)e.destroy();for(let e of this.statics)e.destroy();for(let e of this.config.build){if(this.buildsAllowed){if(!this.buildsAllowed.includes(e.name??``)){let t=this.builds.find(t=>t.buildConfig.name==e.name);t&&t.build();continue}}else if(e.disabled)continue;let t=new bi(this,e);this.builds.push(t),await t.init()}if(this.config.static)for(let e of this.config.static){if(this.staticsAllowed&&!this.staticsAllowed.includes(e.name))continue;let t=new Si(this,e);await t.export(),this.statics.push(t)}}this.onConfigSaveMutex.release()}async onFormatting(e,t,n){return await xe.getInstance().format(e,t,n)}async onCompletion(e,t){return await xe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return await xe.getInstance().doResolve(t)}async onHover(e,t){return await xe.getInstance().doHover(e,t)}getBuildsName(){let e=[];for(let t of this.builds)e.push(t.fullname);return e}getBuildsNameWithStory(){let e=[];for(let t of this.builds)t.hasStories&&e.push(t.fullname);return e}getBuildsNameWithNpm(){let e=[];for(let t of this.builds)t.hasNpmOutput&&e.push(t.fullname);return e}getBuild(e){for(let t of this.builds)if(t.fullname==e)return t}getBuilds(){return this.builds}getMatchingBuildsByUri(e){let t=[];for(let n of this.builds)n.isFileInside(e)&&t.push(n);return t}getStaticsName(){let e=[];for(let t of this.statics)e.push(t.name);return e}getStatic(e){for(let t of this.statics)if(t.name==e)return t}loadFiles(){let e=R.getInstance().getFilesWithExtension(w.GlobalStyle);for(let t of e)this.onNewFile(t)}async onNewFile(e){e.path.endsWith(w.GlobalStyle)&&(this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new Ti(e,this),this.registerOnFileDelete(e)))}registerOnFileDelete(e){this.onFileDeleteUUIDs[e.uri]=e.onDelete(this.onFileDelete.bind(this))}async onFileDelete(e){e.removeOnDelete(this.onFileDeleteUUIDs[e.uri]),delete this.onFileDeleteUUIDs[e.uri],e.uri.endsWith(w.GlobalStyle)&&delete this.scssFiles[e.uri]}async onRename(e){let t={};for(let n of this.builds){let r=await n.onRename(e);for(let e in r)t[e]||(t[e]=[]),t[e]=t[e].concat(r[e])}return t}async buildAll(){let e=[];for(let t of this.builds)e.push(t.build());for(let t of this.statics)e.push(t.export());await Promise.all(e)}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),this.configFile.removeOnSave(this.onSaveUUID),this.configFile.removeOnValidate(this.onValidateUUID),this.configFile.removeOnFormatting(this.onFormattingUUID),this.configFile.removeOnCompletion(this.onCompletionUUID),this.configFile.removeOnCompletionResolve(this.onCompletionResolveUUID),this.configFile.removeOnHover(this.onHoverUUID);for(let e of this.builds)e.destroy();for(let e of this.statics)e.destroy()}},N=class e{static autoLoad=!0;static instance;static getInstance(){return this.instance||=new e,this.instance}projects={};constructor(){R.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(t){if(t.documentUser.uri.endsWith(`/`+w.Config)){let n=t.documentUser.uri.replace(w.Config,w.Template);if(R.getInstance().getByUri(n))return;this.projects[t.documentUser.uri]?console.error(`a config file with the uri :`+t.documentUser.uri+` is already inside project manager`):(this.projects[t.documentUser.uri]=new Di(t,e.autoLoad),e.autoLoad&&await this.projects[t.documentUser.uri].init(),t.onDelete(this.onDeleteFile.bind(this)))}}async onDeleteFile(e){this.projects[e.documentUser.uri]&&(this.projects[e.documentUser.uri].destroy(),delete this.projects[e.documentUser.uri])}getProjectByUri(e){return this.projects[e]}getMatchingBuildsByUri(e){let t=[];for(let n in this.projects){let r=this.projects[n].getMatchingBuildsByUri(e);for(let e of r)t.push(e)}return t}destroyAll(){for(let e in this.projects)this.projects[e].destroy()}async buildAll(){let e=[];for(let t in this.projects)e.push(this.projects[t].buildAll());await Promise.all(e)}async onRename(e){let t={};for(let n in this.projects){let r=await this.projects[n].onRename(e);for(let e in r)t[e]||(t[e]=[]),t[e]=t[e].concat(r[e])}return t}getAllConfigFiles(){let e=[];for(let t in this.projects)e.push(this.projects[t].getConfigFile().uri);return e}getAllBuilds(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsName();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllBuildsWithStory(){let e=[],t=[];for(let n in this.projects){let r=this.projects[n],i=r.getBuildsNameWithStory();for(let n of i){let i=n+`_`+r.getConfigFile().uri;t.includes(i)||(t.push(i),e.push({name:n,uri:r.getConfigFile().uri}))}}return e}getAllBuildsWithNpm(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsNameWithNpm();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllStatics(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsName();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}};const Oi={liveserver:{host:`0.0.0.0`,autoIncrementPort:!0,port:8080,rootFolder:`./dist`,indexFile:`index.html`,delay:200,launch_browser:!0,browser:``,auto_close:!0},updateImportOnRename:!0,readNodeModules:!1,templatePath:[],projectPath:[],globalPath:[],readDirs:[],watchFiles:!0,buildOnly:!1,loadFiles:!0,logLevel:3,useStats:!1,useTemplates:!0,useCompilators:!0,useDefaultTemplate:!0,defaultHideWarnings:!1,deeplApiKey:``,quickCreations:[],ideBuild:!0};function ki(){return JSON.parse(JSON.stringify(Oi))}const Ai={version:`1.3.7`,store:{token:``,username:``}};function ji(){return JSON.parse(JSON.stringify(Ai))}const Mi={customData:[]};function Ni(){return JSON.parse(JSON.stringify(Mi))}var P=class e{static instance;_settings=ki();_settingsHtml=Ni();_hiddenSettings=ji();firstInit=!0;get settings(){return this._settings}get settingsHtml(){return this._settingsHtml}get hiddenSettings(){return this._hiddenSettings}static getInstance(){return this.instance||=new e,this.instance}constructor(){let e=(0,f.join)($.savePath,`config.json`);if((0,u.existsSync)(e)){let t={};try{t=JSON.parse((0,u.readFileSync)(e,`utf8`))}catch{}this._hiddenSettings={...this._hiddenSettings,...t}}}initSettings(e){let t=!1;this.firstInit||`ideBuild`in e&&this._settings.ideBuild!=e.ideBuild&&e.ideBuild&&(t=!0),this._settings=this.mergeDeep(ki(),e);let n=[...this.cbOnSettingsChange];for(let e of n)e();this.firstInit&&=!1,t&&N.getInstance().buildAll()}setSettings(e,t){$.setSettings(e,t)}setHiddenSettings(e){this._hiddenSettings={...this._hiddenSettings,...e},(0,u.writeFileSync)((0,f.join)($.savePath,`config.json`),JSON.stringify(this._hiddenSettings,null,4))}cbOnSettingsChange=[];onSettingsChange(e){this.cbOnSettingsChange.push(e)}setSettingsHtml(e){this._settingsHtml=this.mergeDeep(Ni(),e);let t=[...this.cbOnSettingsChangeHtml];for(let e of t)e()}cbOnSettingsChangeHtml=[];onSettingsChangeHtml(e){this.cbOnSettingsChangeHtml.push(e)}isObject(e){return e&&typeof e==`object`&&!Array.isArray(e)}mergeDeep(e,...t){if(!t.length)return e;let n=t.shift();if(this.isObject(e)&&this.isObject(n))for(let t in n)this.isObject(n[t])?(e[t]||Object.assign(e,{[t]:{}}),this.mergeDeep(e[t],n[t])):Object.assign(e,{[t]:n[t]});return this.mergeDeep(e,...t)}},Pi=class{static get isEnable(){return P.getInstance().settings.useStats}static startSendLoadFile(){this.isEnable&&ca.start(`load_files`)}static sendLoadFile(){this.isEnable&&$.sendNotification(`aventus/statistics/loadFileTime`,ca.stop(`load_files`))}static startSendBuildTime(e){this.isEnable&&ca.start(`full_build_`+e)}static sendBuildTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/buildTime`,e,ca.stop(`full_build_`+e))}static startSendStaticTime(e){this.isEnable&&ca.start(`full_static_`+e)}static sendStaticTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/staticTime`,e,ca.stop(`full_static_`+e))}static sendFileSize(e,t,n,r){if(this.isEnable){let i=0;i=typeof t==`string`?Buffer.from(t).length:(0,u.statSync)(e).size,$.sendNotification(`aventus/statistics/fileSize`,e,i,n,r)}}};const Fi=(0,he.promisify)(ce.exec);(0,he.promisify)(u.stat);function F(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=Ii(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function Ii(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function Li(e){return e.replace(/%3A/g,`:`).replace(/%40/g,`@`)}function I(e){return f.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function Ri(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1),e.splice(0,0,t)}function zi(e){let t=Object.keys(w).reverse();for(let n of t)if(e.endsWith(w[n]))return Bi(w[n]);return``}function Bi(e){return e==`.wcv.avt`?C.HTML:e==`.wcs.avt`?C.SCSS:C.TypeScript}function Vi(e,t,n,r){return L(e,t,0,e.getText().length,n,r)}function Hi(e,t,n,r,i){let a=RegExp(`//#region `+n+`(\\s|\\S)*?//#endregion`).exec(e.getText());if(a){let o=a.index+10+n.length,s=a.index+a[0].length,c={range:m.Range.create(e.positionAt(o),e.positionAt(s)),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(t,`
717
+ `)),t.errors.push({title:`Dependencies errors`,file:e})}return t}getAllFullnames(){let e={},t=t=>{if(t.startsWith(`!staticClass_`))return;let n=t.split(`.`)[0];e[n]||(e[n]=[]),e[n].push(t)};for(let e in this.tsFiles){let n=this.tsFiles[e];for(let e of n.compileResult)e.classScript!==``&&t(e.classScript)}for(let e of this.dependencyNeedUris){let n=this.externalPackageInformation.getInformationsRequired(e);for(let e of n)e.code&&t(e.fullName)}for(let e of this.dependencyFullUris){let n=this.externalPackageInformation.getFullInformations(e);for(let e of n)e.code&&t(e.fullName)}return e}async onNewFile(e){this.buildConfig.srcPathRegex&&e.path.match(this.buildConfig.srcPathRegex)&&this.registerFile(e,!1),this.buildConfig.outsideModulePathRegex&&e.path.match(this.buildConfig.outsideModulePathRegex)&&(this.registerFile(e,!1),this.noNamespaceUri[e.uri]=!0)}async loadFiles(){Pi.startSendBuildTime(this.buildConfig.fullname),this.allowBuild=!1;let e=await si.getInstance().loadDependenciesFromBuild(this.buildConfig,this);this.dependencyFullUris=e.dependencyFullUris,this.dependencyNeedUris=e.dependencyNeedUris,this.dependencyUris=e.dependencyUris,this.externalPackageInformation.init(e.files);let t=R.getInstance();if(this.buildConfig.srcPathRegex){let e=t.getFilesMatching(this.buildConfig.srcPathRegex);for(let t of e)this.registerFile(t,!0)}if(this.buildConfig.outsideModulePathRegex){let e=t.getFilesMatching(this.buildConfig.outsideModulePathRegex);for(let t of e)this.registerFile(t,!0),this.noNamespaceUri[t.uri]=!0}$.debug(`loaded all files needed`),this.allowBuild=!0,this._filesLoaded=!0,await this.rebuildAll(!0),Pi.sendBuildTime(this.buildConfig.fullname)}async registerFile(e,t){if(e.uri.endsWith(w.ComponentStyle))this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new Rr(e,this),t||await this.scssFiles[e.uri].init(),this.registerOnFileDelete(e),this.scssFiles[e.uri].isGlobal&&(this.globalComponentSCSSFiles[e.uri]=this.scssFiles[e.uri]));else if(e.uri.endsWith(w.ComponentView))this.htmlFiles[e.uri]||(this.htmlFiles[e.uri]=new zr(e,this),t||await this.htmlFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(w.Component))this.wcFiles[e.uri]||(this.wcFiles[e.uri]=new ui(e,this),t||await this.wcFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(w.I18n))e.name.startsWith(`@`)?this.tsLanguageService.i18nFiles[e.uri]||(this.tsLanguageService.i18nFiles[e.uri]=new yi(e,!0,this),t||await this.tsLanguageService.i18nFiles[e.uri].validate(),this.registerOnFileDelete(e)):this.i18nComponentsFiles[e.uri]||(this.i18nComponentsFiles[e.uri]=new yi(e,!1,this),t||await this.i18nComponentsFiles[e.uri].validate(),this.registerOnFileDelete(e));else if(!this.tsFiles[e.uri]){let t=Zr(e,this);t&&(this.tsFiles[e.uri]=t,this.registerOnFileDelete(e))}}registerOnFileDelete(e){this.onFileDeleteUUIDs[e.uri]=e.onDelete(this.onFileDelete.bind(this))}async onFileDelete(e){e.removeOnDelete(this.onFileDeleteUUIDs[e.uri]),delete this.onFileDeleteUUIDs[e.uri],e.uri.endsWith(w.ComponentStyle)?delete this.scssFiles[e.uri]:e.uri.endsWith(w.ComponentView)?delete this.htmlFiles[e.uri]:e.uri.endsWith(w.Component)?delete this.wcFiles[e.uri]:delete this.tsFiles[e.uri],await this.rebuildAll()}getLocalWebComponentDefinition(e,t=!1){let n=this.htmlLanguageService.getInternalDefinition(e);if(n&&n.fileParsed){let e=n.getComponentName();if(e){let t=n.fileParsed.classes[e];if(t)return t}}}getWebComponentTagDependency(e){let t=this.htmlLanguageService.getInternalTagUri(e);if(t){let e=RegExp(`^`+this.module+`\\.`);return{fullName:t.fullname.replace(e,`$namespace$`),uri:t.uri,isStrong:!1}}let n=this.getWebComponentDefinition(e);if(n){let e=n.class.fileUri;return n.isLocal||(e=`@external`),{fullName:n.class.fullName,uri:e,isStrong:!1}}return null}getWebComponentDefinition(e,t=!1){let n=this.htmlLanguageService.getInternalDefinition(e);if(n&&n.fileParsed){let e=n.getComponentName();if(e){let t=n.fileParsed.classes[e];if(t)return{class:t,isLocal:!0}}}let r=this.htmlLanguageService.getClassByTag(e);if(r){let n=this.externalPackageInformation.getExternalWebComponentDefinition(r);if(n){if(t){let t=this.project.getInternalWebComponentDefinition(I(n.fileUri),e);if(t)return{class:t,isLocal:!1}}return{class:n,isLocal:!1}}}}getWebComponentDefinitionFile(e){let t=this.htmlLanguageService.getInternalDefinition(e);if(t)return t;let n=this.htmlLanguageService.getClassByTag(e);if(n)return this.externalPackageInformation.getExternalWebComponentDefinitionFile(n)}getSlotsInfo(e){let t={},n=[],r=!1,i=e;for(;i&&i.fullName!=`Aventus.WebComponent`;){let a=this.tsFiles[i.fileUri];if(!a){let a=this.externalPackageInformation.getByFullName(i.fullName);if(a&&a.content!=`noCode`&&a.content.slots&&!r)for(let r in a.content.slots)n.includes(r)||(t[r]||(t[r]={local:i==e}),!t[r].doc&&i.documentation?.documentationSlots[r]&&(t[r].doc=i.documentation?.documentationSlots[r]))}else if(a instanceof j&&a.HTMLFile?.fileParsed?.slotsInfo&&!r){for(let r in a.HTMLFile.fileParsed.slotsInfo)n.includes(r)||(t[r]||(t[r]={local:i==e}),!t[r].doc&&i.documentation?.documentationSlots[r]&&(t[r].doc=i.documentation?.documentationSlots[r]));for(let e in a.HTMLFile.fileParsed.blocksInfo)t[e]||n.push(e)}i.decorators.find(e=>nn.is(e))&&(r=!0),i=i.parentClass}return t}getNamespaceForUri(e){if(this.buildConfig.namespaceStrategy==`manual`)return``;if(this.buildConfig.namespaceStrategy==`rules`){let t=I(e);for(let e in this.buildConfig.namespaceRulesRegex){let n=this.buildConfig.namespaceRulesRegex[e];if(t.match(n))return e}}else if(this.buildConfig.namespaceStrategy==`followFolders`||this.buildConfig.namespaceStrategy==`followFoldersCamelCase`){let t=e.endsWith(w.ComponentLogic),n=I(e),r=n.split(`/`);r.pop(),t&&r.pop(),n=r.join(`/`)+`/`;let i=n.replace(this.buildConfig.namespaceRoot,``).replace(/\//g,`.`);return i.endsWith(`.`)&&(i=i.slice(0,-1)),i.startsWith(`.`)&&(i=i.slice(1)),i.includes(`:`)?``:this.buildConfig.namespaceStrategy==`followFoldersCamelCase`?(i=i.slice(0,1).toUpperCase()+i.slice(1),i.replace(/(([-_\.]|^)[a-z])/g,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))):i}return``}addNamespace(e){if(!this.namespaces.includes(e)){let t=e.split(`.`),n=``;for(let e of t)n+=e,n&&!this.namespaces.includes(n)&&this.namespaces.push(n),n+=`.`}}async onRename(e){for(let t of e)if(t.oldUri.endsWith(w.Component)||t.oldUri.endsWith(w.ComponentLogic)||t.oldUri.endsWith(w.Data)||t.oldUri.endsWith(w.Lib)||t.oldUri.endsWith(w.RAM))return await this.tsLanguageService.onRenameFile(t.oldUri,t.newUri);return{}}npmAliases={};npmNameCount={};getNpmReplacementName(e,t){if(!this.hasNpmOutput)return``;let n=t.split(`.`),r=n.pop(),i=e.split(`.`);return i.pop(),n.join(`.`)==i.join(`.`)?r:this.npmAliases[t]?this.npmAliases[t]:(this.npmNameCount[r]||(this.npmNameCount[r]=0),this.npmNameCount[r]++,this.npmAliases[t]=r+this.npmNameCount[r],this.npmAliases[t])}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID);for(let e in this.scssFiles)this.scssFiles[e].removeEvents(),this.scssFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.htmlFiles)this.htmlFiles[e].removeEvents(),this.htmlFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.tsFiles)this.tsFiles[e].removeEvents(),this.tsFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.tsLanguageService.i18nFiles)this.tsLanguageService.i18nFiles[e].removeEvents(),this.tsLanguageService.i18nFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);for(let e in this.i18nComponentsFiles)this.i18nComponentsFiles[e].removeEvents(),this.i18nComponentsFiles[e].file.removeOnDelete(this.onFileDeleteUUIDs[e]);ei.send(this.project.getConfigFile().path,this.buildConfig.fullname)}async writeFile(e,t){await ca(e,t,`build`,this.buildConfig.fullname)}},xi=class{files={};informations={};informationsRequired={};webComponentByName={};build;constructor(e){this.build=e}get filesUri(){return Object.keys(this.files)}init(e){for(let t of e)this.files[t.file.uri]=t;this.rebuild()}getByFullName(e){return this.informations[e]}getByUri(e){return this.files[e]}getNpmUri(e){if(!this.build.hasNpmOutput)return null;if(this.informations[e]){let t=this.files[this.informations[e].uri];!t.npmUri&&this.build.initDone&&$.showErrorMessage(`Can't find a npm package for `+t.name+`. You must define the npm field inside the dependencies section of your aventus.conf.avt. Otherwise, you can disable storybook or remove npm export.`);let n=e.split(`.`),r=n.pop();n.splice(0,0,t.npmUri);let i=t.fileParsed?.getBaseInfo(r)?.willBeCompiled??!1;return{name:r,uri:n.join(`/`),compiled:i}}return null}getNamespaceByUri(e){return this.files[e].srcInfo.namespace}getNameByUri(e){return this.files[e].name}getInformationsRequired(e){return this.informationsRequired[e]}getFullInformations(e){return this.files[e]?.srcInfo.available||[]}getStyleByUri(e){return this.files[e]?this.files[e].externalCSS:{}}rebuild(){this.informations={},this.webComponentByName={};let e=[];for(let t in this.files){let n=this.files[t];this.informationsRequired[t]=[];for(let r of n.srcInfo.available)(r.required||this.build.buildConfig.i18n&&r.fullName==`Aventus.I18n`)&&this.informationsRequired[t].push(r),r.fullName&&(this.informations[r.fullName]?this.informations[r.fullName].uri!=t&&e.push({range:{start:{line:0,character:0},end:{line:0,character:0}},severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:`The name `+r.fullName+` exist inside `+t+` and `+this.informations[r.fullName].uri}):this.informations[r.fullName]={content:r,uri:t});for(let r of n.srcInfo.existing)r.fullName&&(this.informations[r.fullName]?this.informations[r.fullName].uri!=t&&e.push({range:{start:{line:0,character:0},end:{line:0,character:0}},severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:`The name `+r.fullName+` exist inside `+t+` and `+this.informations[r.fullName].uri}):this.informations[r.fullName]={content:`noCode`,uri:t});this.webComponentByName={...this.webComponentByName,...n.classInfoByName}}$.sendDiagnostics({uri:`@Import lib`,diagnostics:e},this.build)}getExternalWebComponentDefinition(e){return this.webComponentByName[e]}getExternalWebComponentDefinitionFile(e){let t=this.webComponentByName[e];if(t){let e=t.fileUri,n=this.files[e];if(n)return n}}},Si=class{staticConfig;watcher;isReady=!1;project;get name(){return this.staticConfig.name}constructor(e,t){this.project=e,this.staticConfig=t,this.registerWatcher(),this.isReady=!0}async export(){if(this.isReady){Pi.startSendStaticTime(this.name);let e=e=>{var t=[],n=e=>((0,u.existsSync)(e)&&(0,u.readdirSync)(e).forEach(r=>{let i=e+`/`+r;if((0,u.lstatSync)(i).isDirectory()){let e=n(i);e.length>0&&t.concat(e)}else t.push(i)}),t);return t=n(e),t},t=async(e,t)=>{try{t=(0,f.normalize)(t);let n=t.split(f.sep),r=n.pop(),i=n.join(f.sep);if((0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0}),r.endsWith(`.scss`)){if(!r.startsWith(`_`)){let n=(0,ae.compile)(e,{style:`compressed`}).css.toString().trim();await ca(t.replace(`.scss`,`.css`),n,`static`,this.name)}}else (0,u.copyFileSync)(e,t),Pi.sendFileSize(t,void 0,`static`,this.name)}catch(e){$.error(e)}},n=e(this.staticConfig.inputPathFolder);for(let e of n){e=e.replace(/\\/g,`/`);for(let n of this.staticConfig.outputPathFolder){let r=e.replace(this.staticConfig.inputPathFolder,n);if(e.endsWith(w.Base)){if(e.endsWith(w.GlobalStyle)){r=r.replace(w.GlobalStyle,`.css`);let t=this.project.scssFiles[F(e)];if(!t){let n=d.TextDocument.create(F(e),w.GlobalStyle,1,(0,u.readFileSync)(e,`utf8`));await R.getInstance().registerFile(n),t=this.project.scssFiles[F(e)]}await t.addOutPath(r,this.name)}}else await t(e,r)}}D.getInstance().reload(),Pi.sendStaticTime(this.name)}}registerWatcher(){P.getInstance().settings.watchFiles&&(this.watcher=(0,me.watch)(this.staticConfig.inputPathFolder,{ignored:/^\./,persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:100},ignoreInitial:!0}),this.watcher.on(`add`,e=>{this.export()}),this.watcher.on(`change`,e=>{this.export()}),this.watcher.on(`unlink`,e=>{this.export()}),this.watcher.on(`error`,function(e){}))}destroy(){this.watcher&&this.watcher.close()}},Ci=class{languageService;variablesByUri={};variablesByName={};constructor(){this.languageService=(0,ie.getSCSSLanguageService)()}async doValidation(e){return this.languageService.doValidation(e.documentUser,this.languageService.parseStylesheet(e.documentUser))}async doComplete(e,t){return this.languageService.doComplete(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async doHover(e,t){return this.languageService.doHover(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async findDefinition(e,t){let n=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));return n&&[n]}async format(e,t,n){let r={...n,preserveNewLines:!0,spaceAroundSelectorSeparator:!0,insertFinalNewline:!0,insertSpaces:!1,tabSize:4},i=e.documentUser,a=await this.languageService.format(i,t,r);if(a.length==1){let e=i.offsetAt(a[0].range.start),t=i.offsetAt(a[0].range.end),n=i.getText().length;if(e==0&&t==n){let e=await(0,re.default)([(0,kr.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:Ar,from:`./temp.scss`,to:`./temp.scss`});a[0].newText=e.css}}return a}async doCodeAction(e,t){let n=this.languageService.parseStylesheet(e.documentUser),r=m.CodeActionContext.create(this.languageService.doValidation(e.documentUser,n));return this.languageService.doCodeActions2(e.documentUser,t,r,n)}async onReferences(e,t){let n=this.languageService.parseStylesheet(e.documentUser);return this.languageService.findReferences(e.documentUser,t,n)}loadVariables(e,t){let n=e.file.documentUser,r={},i=e=>{if(e.type==69){let i=e;for(;i&&i.selectors==null;)i=i.parent;if(i&&i.selectors.getText()==`:root`){let i=e.getChild(0),a=e.getChild(1);if(i&&a){let e=i.getText();e.startsWith(`--`)&&(i.offset,r[e]||(r[e]={name:e,uri:t,range:{start:n.positionAt(i.offset),end:n.positionAt(i.end)},value:a.getText()}))}}}else if(e.hasChildren())for(let t of e.getChildren())i(t)},a=Ir((0,ie.getSCSSLanguageService)().parseStylesheet(n),0);for(let e of a)i(e);this.variablesByUri[t]=Object.values(r),this.reloadVariables()}reloadVariables(){this.variablesByName={};for(let e in this.variablesByUri)for(let t of this.variablesByUri[e])this.variablesByName[t.name]||(this.variablesByName[t.name]=t)}removeVariables(e){delete this.variablesByUri[e],this.reloadVariables()}getDefinition(e){return this.variablesByName[e]}},wi=class{_file;_project;get file(){return this._file}get project(){return this._project}constructor(e,t){this._file=e,this._project=t,this.addEvents()}uuidEvents={onContentChange:``,onValidate:``,onSave:``,onDelete:``,onCompletion:``,onCompletionResolve:``,onHover:``,onDefinition:``,onFormatting:``,onCodeAction:``,onReferences:``,onCodeLens:``,onRename:``};addEvents(){this.uuidEvents.onContentChange=this.file.onContentChange(this.onContentChange.bind(this)),this.uuidEvents.onValidate=this.file.onValidate(this._onValidate.bind(this)),this.uuidEvents.onSave=this.file.onSave(this.onSave.bind(this)),this.uuidEvents.onDelete=this.file.onDelete(this._onDelete.bind(this)),this.uuidEvents.onCompletion=this.file.onCompletion(this.onCompletion.bind(this)),this.uuidEvents.onCompletionResolve=this.file.onCompletionResolve(this.onCompletionResolve.bind(this)),this.uuidEvents.onHover=this.file.onHover(this.onHover.bind(this)),this.uuidEvents.onDefinition=this.file.onDefinition(this.onDefinition.bind(this)),this.uuidEvents.onFormatting=this.file.onFormatting(this.onFormatting.bind(this)),this.uuidEvents.onCodeAction=this.file.onCodeAction(this.onCodeAction.bind(this)),this.uuidEvents.onReferences=this.file.onReferences(this.onReferences.bind(this)),this.uuidEvents.onCodeLens=this.file.onCodeLens(this.onCodeLens.bind(this)),this.uuidEvents.onRename=this.file.onRename(this.onRename.bind(this))}removeEvents(){this.file.removeOnContentChange(this.uuidEvents.onContentChange),this.file.removeOnValidate(this.uuidEvents.onValidate),this.file.removeOnSave(this.uuidEvents.onSave),this.file.removeOnDelete(this.uuidEvents.onDelete),this.file.removeOnCompletion(this.uuidEvents.onCompletion),this.file.removeOnCompletionResolve(this.uuidEvents.onCompletionResolve),this.file.removeOnHover(this.uuidEvents.onHover),this.file.removeOnDefinition(this.uuidEvents.onDefinition),this.file.removeOnFormatting(this.uuidEvents.onFormatting),this.file.removeOnCodeAction(this.uuidEvents.onCodeAction),this.file.removeOnReferences(this.uuidEvents.onReferences),this.file.removeOnCodeLens(this.uuidEvents.onCodeLens),this.file.removeOnRename(this.uuidEvents.onRename)}async validate(){this.file instanceof E&&await this.file.validate()}triggerSave(){this.file instanceof E&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof E&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async _onDelete(){await this.onDelete(),this.removeEvents()}},Ti=class e extends wi{compiledVersion=-1;usedBy={};dependencies={};diagnostics=[];diagnosticCompile;compiledTxt=``;savedOnce=!1;staticNamebyOutPath={};get resultCompiled(){return this.compiledTxt}constructor(e,t){super(e,t),this.loadDependencies(),this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}async onContentChange(){}async onValidate(){return this.diagnostics=await this.project.globalSCSSLanguageService.doValidation(this.file),this.loadDependencies(),this.diagnosticCompile?[...this.diagnostics,this.diagnosticCompile]:this.diagnostics}async onSave(){this.savedOnce=!0,await this.compileRoot(),this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}async compileRoot(){if(Object.values(this.usedBy).length==0)await this.compile();else for(let e in this.usedBy)this.usedBy[e].onSave()}async compile(){try{let e=this.compiledTxt,t=`|error|`,n=e=>{let r=e.contentUser;r=r.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let i=/@import *?('|")(\S*?)('|");?/g,a=null;for(;a=i.exec(r);){let i=a[2],o=this.resolvePath(i,e.folderPath);if(o){let e=n(o);if(e==t)return e;r=r.replace(a[0],e)}else return t}return r},r=n(this.file);if(r!=`|error|`){let t=e=>{if(P.getInstance().settings.errorByBuild){let t=this.project.getBuilds();for(let n of t)$.sendDiagnostics({uri:this.file.uri,diagnostics:e},n)}else $.sendDiagnostics({uri:this.file.uri,diagnostics:e})};try{let n=(0,ae.compileString)(r,{style:`compressed`}).css.toString().trim();n=n.replace(/\\/g,`\\\\`),e=n,this.diagnosticCompile&&(this.diagnosticCompile=void 0,t(this.diagnostics))}catch(e){e instanceof ae.Exception&&(this.diagnosticCompile=Ui(this.file.documentUser,e.message),t([...this.diagnostics,this.diagnosticCompile]))}}e!=this.compiledTxt&&(this.compiledVersion++,this.compiledTxt=e,await this.export())}catch(e){console.error(e)}}async onDelete(){for(let e in this.dependencies)this.removeDependency(e);for(let e in this.usedBy)delete this.usedBy[e].dependencies[this.file.uri],delete this.usedBy[e],await this.usedBy[e].onContentChange();this.project.globalSCSSLanguageService.removeVariables(this.file.uri)}async onCompletion(e,t){let n={isIncomplete:!1,items:[]};return n=await this.project.globalSCSSLanguageService.doComplete(e,t),n}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.project.globalSCSSLanguageService.doHover(e,t)}async onDefinition(e,t){return this.project.globalSCSSLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return this.project.globalSCSSLanguageService.format(e,t,n)}async onCodeAction(e,t){return this.project.globalSCSSLanguageService.doCodeAction(e,t)}async onReferences(e,t){return await this.project.globalSCSSLanguageService.onReferences(e,t)}async onCodeLens(e){return[]}async onRename(e,t,n){return null}async addOutPath(e,t){this.file.shortname.startsWith(`_`)||this.staticNamebyOutPath[e]||(this.staticNamebyOutPath[e]=t,this.savedOnce||await this.onSave(),await this.export())}async export(){for(let e in this.staticNamebyOutPath){let t=(0,f.normalize)(e),n=t.split(f.sep);n.pop();let r=n.join(f.sep);(0,u.existsSync)(r)||(0,u.mkdirSync)(r,{recursive:!0}),await ca(t,this.compiledTxt,`static`,this.staticNamebyOutPath[e])}}loadDependencies(){let e=this.file.contentUser,t=e.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`),n=/@import *?('|")(\S*?)('|");?/g,r=null;for(let e in this.dependencies)this.removeDependency(e);for(;r=n.exec(t);){let t=r[2],n=this.resolvePath(t,this.file.folderPath);if(n)this.addDependency(n);else{let t=e.indexOf(r[0]),n=t+r[0].length;this.diagnostics.push(Wi(this.file.documentUser,`Can't load this file`,t,n))}}}removeDependency(e){this.dependencies[e]&&(delete this.dependencies[e].usedBy[this.file.uri],delete this.dependencies[e])}addDependency(t){this.project.scssFiles[t.uri]?(this.dependencies[t.uri]=this.project.scssFiles[t.uri],this.project.scssFiles[t.uri].usedBy[this.file.uri]=this):t.uri.endsWith(w.GlobalStyle)&&(this.project.scssFiles[t.uri]=new e(t,this.project),this.dependencies[t.uri]=this.project.scssFiles[t.uri],this.project.scssFiles[t.uri].usedBy[this.file.uri]=this)}resolvePath(e,t){e=this.project.resolveAlias(e,t),e=(0,f.normalize)(t+`/`+e);let n=R.getInstance().getByPath(e);if(n)return n;let r=e+w.GlobalStyle;if(n=R.getInstance().getByPath(r),n)return n;let i=e.split(f.sep);i[i.length-1]=`_`+i[i.length-1];let a=i.join(f.sep);if(n=R.getInstance().getByPath(a),n)return n;let o=a+w.GlobalStyle;if(n=R.getInstance().getByPath(o),n)return n}},Ei=class{waitingList=[];isLocked=!1;waitOne(){return new Promise(e=>{this.isLocked?this.waitingList.push(()=>{e()}):(this.isLocked=!0,e())})}release(){let e=this.waitingList.shift();e?e():this.isLocked=!1}dispose(){this.waitingList=[],this.isLocked=!1}},Di=class{configFile;config=null;builds=[];statics=[];_isCoreBuild=!1;scssFiles={};onValidateUUID;onSaveUUID;onFormattingUUID;onCompletionUUID;onCompletionResolveUUID;onHoverUUID;onNewFileUUID;onFileDeleteUUIDs={};buildsAllowed;staticsAllowed;globalSCSSLanguageService;get isCoreBuild(){return this._isCoreBuild}getConfigFile(){return this.configFile}getConfig(){return this.config}resolveAlias(e,t){if(e.startsWith(`@`)){let n=e.split(`/`),r=n[0],i=this.config?.aliases[r];if(i){let e=(0,f.normalize)(this.configFile.folderPath+`/`+i);typeof t!=`string`&&(t=t.folderPath);let r=(0,f.normalize)(t);e.endsWith(f.sep)&&(e=e.substring(0,e.length-1)),r.endsWith(f.sep)&&(r=r.substring(0,r.length-1));let a=e.split(f.sep),o=r.split(f.sep);for(let e=0;e<a.length;e++)if(o.length>e)if(a[e]==o[e])a.splice(e,1),o.splice(e,1),e--;else break;let s=``;for(let e=0;e<o.length;e++)s+=`../`;return s==``&&(s+=`./`),s+=a.join(`/`),n.splice(0,1,s),n.join(`/`).replace(/\/\//g,`/`)}}return e}getInternalWebComponentDefinition(e,t){for(let n of this.builds)if(n.outputPathes.includes(e))return n.getLocalWebComponentDefinition(t)}constructor(e,t){this.configFile=e,this.onValidateUUID=this.configFile.onValidate(this.onValidate.bind(this)),this.onSaveUUID=this.configFile.onSave(this.onConfigSave.bind(this)),this.onFormattingUUID=this.configFile.onFormatting(this.onFormatting.bind(this)),this.onCompletionUUID=this.configFile.onCompletion(this.onCompletion.bind(this)),this.onCompletionResolveUUID=this.configFile.onCompletionResolve(this.onCompletionResolve.bind(this)),this.onHoverUUID=this.configFile.onHover(this.onHover.bind(this)),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile.bind(this)),e.folderUri.toLowerCase().endsWith(`/aventus/base/src`)&&(this._isCoreBuild=!0),this.globalSCSSLanguageService=new Ci,t&&this.loadFiles(),e.validate()}async init(){await this.onConfigSave()}async onValidate(){return await xe.getInstance().validate(this.configFile)}async loadConfig(){let e=await xe.getInstance().getConfig(this.configFile);if(this.config){let t=JSON.stringify(this.config),n=``;if(e&&(n=JSON.stringify(e)),t==n)return;for(let e of this.builds)e.destroy()}this.builds=[],this.config=e}onConfigSaveMutex=new Ei;async onConfigSave(){if(await this.onConfigSaveMutex.waitOne(),await this.loadConfig(),this.config){for(let e of this.builds)e.destroy();for(let e of this.statics)e.destroy();for(let e of this.config.build){if(this.buildsAllowed){if(!this.buildsAllowed.includes(e.name??``)){let t=this.builds.find(t=>t.buildConfig.name==e.name);t&&t.build();continue}}else if(e.disabled)continue;let t=new bi(this,e);this.builds.push(t),await t.init()}if(this.config.static)for(let e of this.config.static){if(this.staticsAllowed&&!this.staticsAllowed.includes(e.name))continue;let t=new Si(this,e);await t.export(),this.statics.push(t)}}this.onConfigSaveMutex.release()}async onFormatting(e,t,n){return await xe.getInstance().format(e,t,n)}async onCompletion(e,t){return await xe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return await xe.getInstance().doResolve(t)}async onHover(e,t){return await xe.getInstance().doHover(e,t)}getBuildsName(){let e=[];for(let t of this.builds)e.push(t.fullname);return e}getBuildsNameWithStory(){let e=[];for(let t of this.builds)t.hasStories&&e.push(t.fullname);return e}getBuildsNameWithNpm(){let e=[];for(let t of this.builds)t.hasNpmOutput&&e.push(t.fullname);return e}getBuild(e){for(let t of this.builds)if(t.fullname==e)return t}getBuilds(){return this.builds}getMatchingBuildsByUri(e){let t=[];for(let n of this.builds)n.isFileInside(e)&&t.push(n);return t}getStaticsName(){let e=[];for(let t of this.statics)e.push(t.name);return e}getStatic(e){for(let t of this.statics)if(t.name==e)return t}loadFiles(){let e=R.getInstance().getFilesWithExtension(w.GlobalStyle);for(let t of e)this.onNewFile(t)}async onNewFile(e){e.path.endsWith(w.GlobalStyle)&&(this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new Ti(e,this),this.registerOnFileDelete(e)))}registerOnFileDelete(e){this.onFileDeleteUUIDs[e.uri]=e.onDelete(this.onFileDelete.bind(this))}async onFileDelete(e){e.removeOnDelete(this.onFileDeleteUUIDs[e.uri]),delete this.onFileDeleteUUIDs[e.uri],e.uri.endsWith(w.GlobalStyle)&&delete this.scssFiles[e.uri]}async onRename(e){let t={};for(let n of this.builds){let r=await n.onRename(e);for(let e in r)t[e]||(t[e]=[]),t[e]=t[e].concat(r[e])}return t}async buildAll(){let e=[];for(let t of this.builds)e.push(t.build());for(let t of this.statics)e.push(t.export());await Promise.all(e)}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),this.configFile.removeOnSave(this.onSaveUUID),this.configFile.removeOnValidate(this.onValidateUUID),this.configFile.removeOnFormatting(this.onFormattingUUID),this.configFile.removeOnCompletion(this.onCompletionUUID),this.configFile.removeOnCompletionResolve(this.onCompletionResolveUUID),this.configFile.removeOnHover(this.onHoverUUID);for(let e of this.builds)e.destroy();for(let e of this.statics)e.destroy()}},N=class e{static autoLoad=!0;static instance;static getInstance(){return this.instance||=new e,this.instance}projects={};constructor(){R.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(t){if(t.documentUser.uri.endsWith(`/`+w.Config)){let n=t.documentUser.uri.replace(w.Config,w.Template);if(R.getInstance().getByUri(n))return;this.projects[t.documentUser.uri]?console.error(`a config file with the uri :`+t.documentUser.uri+` is already inside project manager`):(this.projects[t.documentUser.uri]=new Di(t,e.autoLoad),e.autoLoad&&await this.projects[t.documentUser.uri].init(),t.onDelete(this.onDeleteFile.bind(this)))}}async onDeleteFile(e){this.projects[e.documentUser.uri]&&(this.projects[e.documentUser.uri].destroy(),delete this.projects[e.documentUser.uri])}getProjectByUri(e){return this.projects[e]}getMatchingBuildsByUri(e){let t=[];for(let n in this.projects){let r=this.projects[n].getMatchingBuildsByUri(e);for(let e of r)t.push(e)}return t}destroyAll(){for(let e in this.projects)this.projects[e].destroy()}async buildAll(){let e=[];for(let t in this.projects)e.push(this.projects[t].buildAll());await Promise.all(e)}async onRename(e){let t={};for(let n in this.projects){let r=await this.projects[n].onRename(e);for(let e in r)t[e]||(t[e]=[]),t[e]=t[e].concat(r[e])}return t}getAllConfigFiles(){let e=[];for(let t in this.projects)e.push(this.projects[t].getConfigFile().uri);return e}getAllBuilds(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsName();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllBuildsWithStory(){let e=[],t=[];for(let n in this.projects){let r=this.projects[n],i=r.getBuildsNameWithStory();for(let n of i){let i=n+`_`+r.getConfigFile().uri;t.includes(i)||(t.push(i),e.push({name:n,uri:r.getConfigFile().uri}))}}return e}getAllBuildsWithNpm(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsNameWithNpm();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllStatics(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsName();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}};const Oi={liveserver:{host:`0.0.0.0`,autoIncrementPort:!0,port:8080,rootFolder:`./dist`,indexFile:`index.html`,delay:200,launch_browser:!0,browser:``,auto_close:!0},updateImportOnRename:!0,readNodeModules:!1,templatePath:[],projectPath:[],globalPath:[],readDirs:[],watchFiles:!0,buildOnly:!1,loadFiles:!0,logLevel:3,useStats:!1,useTemplates:!0,useCompilators:!0,useDefaultTemplate:!0,defaultHideWarnings:!1,deeplApiKey:``,quickCreations:[],ideBuild:!0};function ki(){return JSON.parse(JSON.stringify(Oi))}const Ai={version:`1.3.7`,store:{token:``,username:``}};function ji(){return JSON.parse(JSON.stringify(Ai))}const Mi={customData:[]};function Ni(){return JSON.parse(JSON.stringify(Mi))}var P=class e{static instance;_settings=ki();_settingsHtml=Ni();_hiddenSettings=ji();firstInit=!0;get settings(){return this._settings}get settingsHtml(){return this._settingsHtml}get hiddenSettings(){return this._hiddenSettings}static getInstance(){return this.instance||=new e,this.instance}constructor(){let e=(0,f.join)($.savePath,`config.json`);if((0,u.existsSync)(e)){let t={};try{t=JSON.parse((0,u.readFileSync)(e,`utf8`))}catch{}this._hiddenSettings={...this._hiddenSettings,...t}}}initSettings(e){let t=!1;this.firstInit||`ideBuild`in e&&this._settings.ideBuild!=e.ideBuild&&e.ideBuild&&(t=!0),this._settings=this.mergeDeep(ki(),e);let n=[...this.cbOnSettingsChange];for(let e of n)e();this.firstInit&&=!1,t&&N.getInstance().buildAll()}setSettings(e,t){$.setSettings(e,t)}setHiddenSettings(e){this._hiddenSettings={...this._hiddenSettings,...e},(0,u.writeFileSync)((0,f.join)($.savePath,`config.json`),JSON.stringify(this._hiddenSettings,null,4))}cbOnSettingsChange=[];onSettingsChange(e){this.cbOnSettingsChange.push(e)}setSettingsHtml(e){this._settingsHtml=this.mergeDeep(Ni(),e);let t=[...this.cbOnSettingsChangeHtml];for(let e of t)e()}cbOnSettingsChangeHtml=[];onSettingsChangeHtml(e){this.cbOnSettingsChangeHtml.push(e)}isObject(e){return e&&typeof e==`object`&&!Array.isArray(e)}mergeDeep(e,...t){if(!t.length)return e;let n=t.shift();if(this.isObject(e)&&this.isObject(n))for(let t in n)this.isObject(n[t])?(e[t]||Object.assign(e,{[t]:{}}),this.mergeDeep(e[t],n[t])):Object.assign(e,{[t]:n[t]});return this.mergeDeep(e,...t)}},Pi=class{static get isEnable(){return P.getInstance().settings.useStats}static startSendLoadFile(){this.isEnable&&da.start(`load_files`)}static sendLoadFile(){this.isEnable&&$.sendNotification(`aventus/statistics/loadFileTime`,da.stop(`load_files`))}static startSendBuildTime(e){this.isEnable&&da.start(`full_build_`+e)}static sendBuildTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/buildTime`,e,da.stop(`full_build_`+e))}static startSendStaticTime(e){this.isEnable&&da.start(`full_static_`+e)}static sendStaticTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/staticTime`,e,da.stop(`full_static_`+e))}static sendFileSize(e,t,n,r){if(this.isEnable){let i=0;i=typeof t==`string`?Buffer.from(t).length:(0,u.statSync)(e).size,$.sendNotification(`aventus/statistics/fileSize`,e,i,n,r)}}};const Fi=(0,he.promisify)(ce.exec);(0,he.promisify)(u.stat);function F(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=Ii(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function Ii(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function Li(e){return e.replace(/%3A/g,`:`).replace(/%40/g,`@`)}function I(e){return f.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function Ri(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1),e.splice(0,0,t)}function zi(e){let t=Object.keys(w).reverse();for(let n of t)if(e.endsWith(w[n]))return Bi(w[n]);return``}function Bi(e){return e==`.wcv.avt`?C.HTML:e==`.wcs.avt`?C.SCSS:C.TypeScript}function Vi(e,t,n,r){return L(e,t,0,e.getText().length,n,r)}function Hi(e,t,n,r,i){let a=RegExp(`//#region `+n+`(\\s|\\S)*?//#endregion`).exec(e.getText());if(a){let o=a.index+10+n.length,s=a.index+a[0].length,c={range:m.Range.create(e.positionAt(o),e.positionAt(s)),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(t,`
718
718
  `),code:r};return i&&(c.data=i),c}return Vi(e,t,r)}function L(e,t,n,r,i,a){let o={range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(t,`
719
719
  `),code:i};return a&&(o.data=a),o}function Ui(e,t){return Wi(e,t,0,e.getText().length)}function Wi(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.SCSS,message:(0,p.flattenDiagnosticMessageText)(t,`
720
720
  `)}}function Gi(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.HTML,message:(0,p.flattenDiagnosticMessageText)(t,`
721
721
  `)}}function Ki(e,t){return qi(e,t,0,e.getText().length)}function qi(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:C.I18n,message:(0,p.flattenDiagnosticMessageText)(t,`
722
722
  `)}}function Ji(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Warning,source:C.I18n,message:(0,p.flattenDiagnosticMessageText)(t,`
723
- `)}}function Yi(e){let t=e.split(`/`);return t.pop(),t.join(`/`)}function Xi(e,t){if(t.start===void 0){let t=e.positionAt(0);return m.Range.create(t,t)}let n=e.positionAt(t.start),r=e.positionAt(t.start+(t.length||0));return m.Range.create(n,r)}function Zi(e,t){if(!t)return e;let n=t.aliases;for(let t in n)if(!t.startsWith(`@`)){let r=Qi(t),i=RegExp(`(?<!\\\\)`+r,`g`);e=e.replace(i,n[t])}return e}function Qi(e,t=!1){return t?e.replace(/[\\^$+?.()|[\]{}]/g,`\\$&`):e.replace(/[\\^$*+?.()|[\]{}]/g,`\\$&`)}function $i(e){return e===13||e===10}const ea=/(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;function ta(e,t){let n=ea,r=t;for(;r>0&&!$i(e.charCodeAt(r-1));)r--;let i=t-r,a=e.substr(r),o=n.ignoreCase?`gi`:`g`;n=new RegExp(n.source,o);let s=n.exec(a);for(;s&&s.index+s[0].length<i;)s=n.exec(a);return s&&s.index<=i?{start:s.index+r,length:s[0].length}:{start:t,length:0}}function na(e,t){e=decodeURIComponent(e),t=decodeURIComponent(t);let n=t.split(`/`);n.pop();let r=e.split(`/`);for(let e=0;e<n.length;e++)if(r.length>e)if(n[e]==r[e])n.splice(e,1),r.splice(e,1),e--;else break;let i=``;for(let e=0;e<n.length;e++)i+=`../`;return i==``&&(i+=`./`),i+=r.join(`/`),i}function ra(e,t,n){e=e.replace(/\[(.*?)\]/g,`.$1`);let r=e=>t instanceof Map?t.get(e):t[e],i=e.split(`.`);for(let e=0;e<i.length-1;e++){let n=i[e],a=r(n);a||=(t[n]={},t[n]),t=a}t instanceof Map?t.set(i[i.length-1],n):t[i[i.length-1]]=n}const ia={};function aa(e,t,n,r){t=t.replace(/\r\n?/g,`
724
- `);let i=oa(t),a=(0,f.dirname)(e);(0,u.existsSync)(a)||(0,u.mkdirSync)(a,{recursive:!0});let o=(0,u.existsSync)(e);(!ia[e]||ia[e]!=i||!o)&&(ia[e]=i,Pi.sendFileSize(e,t,n,r),(0,u.writeFileSync)(e,t))}function oa(e){return(0,le.createHash)(`md5`).update(e).digest(`hex`)}function sa(e){try{(0,u.existsSync)(e)&&(0,u.unlinkSync)(e)}catch{}}var ca=class{static timers={};static start(e){this.timers[e]=process.hrtime()}static stop(e){let t=process.hrtime(this.timers[e]),n=t[1]/1e6;return delete this.timers[e],t[0]*1e3+Math.round(n)}static stopNano(e){let t=process.hrtime(this.timers[e]);return delete this.timers[e],t[0]*1e9+t[1]}},la=class e{static isInit=!1;static send(e){$.sendNotification(`aventus/initStep`,e)}static sendDone(){$.sendNotification(`aventus/initStep`,`Aventus : Done`),e.isInit=!0}},ua=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}watcher;constructor(){P.getInstance().settings.watchFiles&&(this.watcher=(0,me.watch)(` `,{ignored:/(^|[\/\\])\../,persistent:!0}),this.watcher.on(`add`,this.onContentChange.bind(this)).on(`change`,this.onContentChange.bind(this)).on(`unlink`,this.onRemove.bind(this)))}watcheUris=[];watch(e){if(this.watcheUris.includes(e)||!this.watcher)return;this.watcheUris.push(e);let t=I(e);this.watcher.add(t)}unwatch(e){let t=this.watcheUris.indexOf(e);t!=-1&&this.watcheUris.splice(t,1)}async onContentChange(e){$.debug(`onContentChange : `+e);let t=F(e);this.watcheUris.includes(t)&&R.getInstance().onUpdatedUri(t)}async onRemove(e){let t=F(e);this.watcheUris.includes(t)&&R.getInstance().onDeletedUri(t)}async destroy(){await this.watcher?.close(),e.instance=void 0}},R=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}constructor(){}files={};lockedUpdatedUri={};loadingInProgress=!0;preventUpdateUri(e){this.lockedUpdatedUri[e]&&clearTimeout(this.lockedUpdatedUri[e]),this.lockedUpdatedUri[e]=setTimeout(()=>{delete this.lockedUpdatedUri[e]},2e3)}async onCreatedUri(e){if(!this.files[e]){let t=zi(e);if(t){let n=I(e),r=d.TextDocument.create(e,t,0,(0,u.readFileSync)(n,`utf8`));await this.registerFile(r),this.onSave(r)}}}async onUpdatedUri(e){if(this.lockedUpdatedUri[e])return;let t=zi(e),n=I(e),r=``;if((0,u.existsSync)(n))r=(0,u.readFileSync)(n,`utf8`);else{this.onDeletedUri(e);return}if(this.files[e]){let n=this.files[e].versionUser+1,i=d.TextDocument.create(e,t,n,r);await this.onContentChange(i),this.onSave(i)}else{let n=d.TextDocument.create(e,t,0,r);await this.registerFile(n),this.onSave(n)}}async onDeletedUri(e){if(this.files[e]){if(P.getInstance().settings.errorByBuild){let t=this.files[e].getBuild();if(t===null)$.sendDiagnostics({uri:e,diagnostics:[]});else for(let n of t)$.sendDiagnostics({uri:e,diagnostics:[]},n)}else $.sendDiagnostics({uri:e,diagnostics:[]});await this.files[e].triggerDelete(),delete this.files[e],ua.getInstance().unwatch(e)}}async loadConfigFileNotSet(e,t,n){for(let r=0;r<e.length;r++){let i=I(e[r]),a=async e=>{let r=(0,u.readdirSync)(e);for(let i=0;i<r.length;i++){let o=e+`/`+r[i];if((0,u.lstatSync)(o).isDirectory()){if(r[i]!=`node_modules`&&await a(o))return!0}else{let e=F(o);if(r[i]==w.Config)return await this.loadConfigFile(e,t,n),!0}}return!1};if(await a(i))return}la.sendDone()}async loadConfigFile(e,t,n){N.autoLoad=!1;let r=I(e);e=F(r);let i=d.TextDocument.create(F(r),w.Config,0,(0,u.readFileSync)(r,`utf8`));this.loadingInProgress=!1,await this.registerFile(i),this.loadingInProgress=!0;let a=N.getInstance().getProjectByUri(e);if(a){await a.loadConfig(),a.buildsAllowed=t,a.staticsAllowed=n;let e=a.getConfig();if(e){let r=async e=>{if(!(0,u.existsSync)(e))return;let t=(0,u.readdirSync)(e);for(let n=0;n<t.length;n++){let i=e+`/`+t[n];if((0,u.lstatSync)(i).isDirectory())t[n]!=`node_modules`&&await r(i);else{let e=F(i),r=zi(e);if(t[n]!=w.Config&&t[n].endsWith(w.Base)){let t=d.TextDocument.create(e,r,0,(0,u.readFileSync)(i,`utf8`));await this.registerFile(t)}}}};for(let n of e.build)if(!t||t.includes(n.name??``))for(let e of n.srcPath)await r(e);for(let t of e.static)(!n||n.includes(t.name??``))&&await r(t.inputPathFolder);Pi.startSendLoadFile(),a.loadFiles(),Pi.sendLoadFile(),this.loadingInProgress=!1,await a.init(),la.sendDone()}}}async parseWorkspace(e,t){let n=I(e),r=P.getInstance().settings.readDirs,i=e=>!0;if(r.length>0){let t=[],n=[];for(let i of r){let r=``,a=i.replace(/\\/g,`/`);a.startsWith(`/`)||(r=`/`);let o=a.split(`/`);o[o.length-1]==``||o[o.length-1]==`*`?o[o.length-1]=`*`:o[o.length-1].indexOf(`.`)==-1&&o.push(`*`),a=o.join(`/`);let s=(0,f.normalize)(I(e)+r+a).replace(/\\/g,`/`);s=Qi(s,!0).replace(`*`,`.*`);let c=s.split(`/`),l=``;for(let e of c)e!=`.*`&&(l==``?l=e:l+=`/`+e,n.includes(l)||n.push(l));t.push(`(^`+s+`$)`)}let a=t.join(`|`);a==``&&(a=`(?!)`);let o=new RegExp(a);i=e=>{let t=(e+`/`).match(o)!=null,r=n.includes(e);return t||r}}let a=async e=>{if(!i(e))return;let n=(0,u.readdirSync)(e);for(let r=0;r<n.length;r++){let i=e+`/`+n[r];(0,u.lstatSync)(i).isDirectory()?n[r]!=`node_modules`&&n[r]!=`.git`&&await a(i):await t(n[r],i)}};await a(n)}async loadAllAventusConfigFiles(e){let t=[];for(let n=0;n<e.length;n++)await this.parseWorkspace(e[n],async(e,n)=>{let r=F(n),i=zi(r);e==w.Config&&t.push(new E(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`))))});return t}async loadAllAventusFiles(e){this.loadingInProgress=!0;let t=[];la.send(`$(loading~spin) Aventus : Loading files`);for(let n=0;n<e.length;n++)await this.parseWorkspace(e[n],async(e,n)=>{let r=F(n),i=zi(r);if(e==w.Config)t.push(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`)));else if(e.endsWith(w.Base)){let e=d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`));await this.registerFile(e)}});la.send(`$(loading~spin) Aventus : Register config`),this.loadingInProgress=!1;for(let e of t)await this.registerFile(e);la.sendDone()}async onShutdown(){for(let e in this.files)await this.files[e].triggerDelete(),delete this.files[e],ua.getInstance().unwatch(e)}async fileExists(e){return this.files[e.uri]?!0:e.uri.endsWith(w.Template)?(await this.registerFile(e),this.onSave(e),!0):!1}async registerFilePackage(e){let t=I(e),n=``;(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`));let r=d.TextDocument.create(e,C.Package,0,n);return ua.getInstance().watch(e),await this.registerFile(r)}async registerFile(e){return $.debug(`registering `+e.uri),this.files[e.uri]?await this.files[e.uri].triggerContentChange(e):await this.triggerOnNewFile(e),$.isIDE||ua.getInstance().watch(e.uri),this.files[e.uri]}async onContentChange(e){this.files[e.uri]?await this.files[e.uri].triggerContentChange(e):await this.triggerOnNewFile(e)}async onSave(e){this.files[e.uri]?await this.files[e.uri].triggerSave():await this.triggerOnNewFile(e)}async onClose(e){(0,u.existsSync)(I(e.uri))||this.onDeletedUri(e.uri)}async onCompletion(e,t){return await this.fileExists(e)?this.files[e.uri].getCompletion(t):{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){return await this.fileExists(e)?this.files[e.uri].getCompletionResolve(t):t}async onHover(e,t){return await this.fileExists(e)?this.files[e.uri].getHover(t):null}async onDefinition(e,t){return await this.fileExists(e)?this.files[e.uri].getDefinition(t):null}async onFormatting(e,t){return await this.fileExists(e)?this.files[e.uri].getFormatting(t):[]}async onCodeAction(e,t){return await this.fileExists(e)?this.files[e.uri].getCodeAction(t):[]}async onReferences(e,t){return await this.fileExists(e)?this.files[e.uri].getReferences(t):[]}async onCodeLens(e){return await this.fileExists(e)?this.files[e.uri].getCodeLens():[]}async onRename(e,t,n){return await this.fileExists(e)?this.files[e.uri].getRename(t,n):null}getBuild(e){return this.files[e.uri]?this.files[e.uri].getBuild():[]}onNewFileCb={};async triggerOnNewFile(e){if($.debug(`triggerOnNewFile `+e.uri),this.loadingInProgress&&e.uri.endsWith(w.Config))return;this.files[e.uri]=new E(e);let t=[];for(let n in this.onNewFileCb)t.push(this.onNewFileCb[n](this.files[e.uri]));await Promise.all(t)}onNewFile(e){let t=T();for(;this.onNewFileCb[t]!=null;)t=T();return this.onNewFileCb[t]=e,t}removeOnNewFile(e){delete this.onNewFileCb[e]}onFileRemoveCb={};async triggerOnFileRemove(e){$.debug(`triggerOnFileRemove `+e);let t=[];for(let n in this.onFileRemoveCb)t.push(this.onFileRemoveCb[n](e));await Promise.all(t)}onFileRemove(e){let t=T();for(;this.onNewFileCb[t]!=null;)t=T();return this.onFileRemoveCb[t]=e,t}removeOnFileRemove(e){delete this.onFileRemoveCb[e]}getFilesMatching(e){let t=[];for(let n in this.files)this.files[n].path.match(e)&&t.push(this.files[n]);return t}getFilesWithExtension(e){Array.isArray(e)||(e=[e]);let t=[];for(let n in this.files)for(let r of e)this.files[n].path.endsWith(r)&&t.push(this.files[n]);return t}getByPath(e){return this.files[F(e)]}getByUri(e){return this.files[e]}getUris(){return Object.keys(this.files)}},da=class e{static tc(e,t){if(typeof e!=t)throw TypeError(`required type ${t} got ${typeof e}`);return e}static ic(e,t){if(!(e instanceof t))throw TypeError(`required type ${t} got ${typeof e}`);return e}static nc(e){return isNaN(e)?0:e}static oc(e){return{angle:e&&e.angle?e.angle:15,results:e&&e.results?e.results:3}}static clmp(e,t,n){return n!==void 0&&e<n?n:e>t?t:e}static shift(e,t){for(e+=t;e>=360;)e-=360;for(;e<0;)e+=360;return e}#e;#t;#n;alpha;static Colors=class{static get BLACK(){return e.fromHex(`#000000`)}static get SILVER(){return e.fromHex(`#c0c0c0`)}static get GRAY(){return e.fromHex(`#808080`)}static get WHITE(){return e.fromHex(`#ffffff`)}static get MAROON(){return e.fromHex(`#800000`)}static get RED(){return e.fromHex(`#ff0000`)}static get PURPLE(){return e.fromHex(`#800080`)}static get GREEN(){return e.fromHex(`#008000`)}static get LIME(){return e.fromHex(`#00ff00`)}static get OLIVE(){return e.fromHex(`#808000`)}static get YELLOW(){return e.fromHex(`#ffff00`)}static get NAVY(){return e.fromHex(`#000080`)}static get BLUE(){return e.fromHex(`#0000ff`)}static get TEAL(){return e.fromHex(`#008080`)}static get AQUA(){return e.fromHex(`#00ffff`)}static get ORANGE(){return e.fromHex(`#ffa500`)}static get ALICEBLUE(){return e.fromHex(`#f0f8ff`)}static get ANTIQUEWHITE(){return e.fromHex(`#faebd7`)}static get AQUAMARINE(){return e.fromHex(`#7fffd4`)}static get AZURE(){return e.fromHex(`#f0ffff`)}static get BEIGE(){return e.fromHex(`#f5f5dc`)}static get BISQUE(){return e.fromHex(`#ffe4c4`)}static get BLANCHEDALMOND(){return e.fromHex(`#ffebcd`)}static get BLUEVIOLET(){return e.fromHex(`#8a2be2`)}static get BROWN(){return e.fromHex(`#a52a2a`)}static get BURLYWOOD(){return e.fromHex(`#deb887`)}static get CADETBLUE(){return e.fromHex(`#5f9ea0`)}static get CHARTREUSE(){return e.fromHex(`#7fff00`)}static get CHOCOLATE(){return e.fromHex(`#d2691e`)}static get CORAL(){return e.fromHex(`#ff7f50`)}static get CORNFLOWERBLUE(){return e.fromHex(`#6495ed`)}static get CORNSILK(){return e.fromHex(`#fff8dc`)}static get CRIMSON(){return e.fromHex(`#dc143c`)}static get CYAN(){return e.fromHex(`#00ffff`)}static get DARKBLUE(){return e.fromHex(`#00008b`)}static get DARKCYAN(){return e.fromHex(`#008b8b`)}static get DARKGOLDENROD(){return e.fromHex(`#b8860b`)}static get DARKGRAY(){return e.fromHex(`#a9a9a9`)}static get DARKGREEN(){return e.fromHex(`#006400`)}static get DARKGREY(){return e.fromHex(`#a9a9a9`)}static get DARKKHAKI(){return e.fromHex(`#bdb76b`)}static get DARKMAGENTA(){return e.fromHex(`#8b008b`)}static get DARKOLIVEGREEN(){return e.fromHex(`#556b2f`)}static get DARKORANGE(){return e.fromHex(`#ff8c00`)}static get DARKORCHID(){return e.fromHex(`#9932cc`)}static get DARKRED(){return e.fromHex(`#8b0000`)}static get DARKSALMON(){return e.fromHex(`#e9967a`)}static get DARKSEAGREEN(){return e.fromHex(`#8fbc8f`)}static get DARKSLATEBLUE(){return e.fromHex(`#483d8b`)}static get DARKSLATEGRAY(){return e.fromHex(`#2f4f4f`)}static get DARKSLATEGREY(){return e.fromHex(`#2f4f4f`)}static get DARKTURQUOISE(){return e.fromHex(`#00ced1`)}static get DARKVIOLET(){return e.fromHex(`#9400d3`)}static get DEEPPINK(){return e.fromHex(`#ff1493`)}static get DEEPSKYBLUE(){return e.fromHex(`#00bfff`)}static get DIMGRAY(){return e.fromHex(`#696969`)}static get DIMGREY(){return e.fromHex(`#696969`)}static get DODGERBLUE(){return e.fromHex(`#1e90ff`)}static get FIREBRICK(){return e.fromHex(`#b22222`)}static get FLORALWHITE(){return e.fromHex(`#fffaf0`)}static get FORESTGREEN(){return e.fromHex(`#228b22`)}static get GAINSBORO(){return e.fromHex(`#dcdcdc`)}static get GHOSTWHITE(){return e.fromHex(`#f8f8ff`)}static get GOLD(){return e.fromHex(`#ffd700`)}static get GOLDENROD(){return e.fromHex(`#daa520`)}static get GREENYELLOW(){return e.fromHex(`#adff2f`)}static get GREY(){return e.fromHex(`#808080`)}static get HONEYDEW(){return e.fromHex(`#f0fff0`)}static get HOTPINK(){return e.fromHex(`#ff69b4`)}static get INDIANRED(){return e.fromHex(`#cd5c5c`)}static get INDIGO(){return e.fromHex(`#4b0082`)}static get IVORY(){return e.fromHex(`#fffff0`)}static get KHAKI(){return e.fromHex(`#f0e68c`)}static get LAVENDER(){return e.fromHex(`#e6e6fa`)}static get LAVENDERBLUSH(){return e.fromHex(`#fff0f5`)}static get LAWNGREEN(){return e.fromHex(`#7cfc00`)}static get LEMONCHIFFON(){return e.fromHex(`#fffacd`)}static get LIGHTBLUE(){return e.fromHex(`#add8e6`)}static get LIGHTCORAL(){return e.fromHex(`#f08080`)}static get LIGHTCYAN(){return e.fromHex(`#e0ffff`)}static get LIGHTGOLDENRODYELLOW(){return e.fromHex(`#fafad2`)}static get LIGHTGRAY(){return e.fromHex(`#d3d3d3`)}static get LIGHTGREEN(){return e.fromHex(`#90ee90`)}static get LIGHTGREY(){return e.fromHex(`#d3d3d3`)}static get LIGHTPINK(){return e.fromHex(`#ffb6c1`)}static get LIGHTSALMON(){return e.fromHex(`#ffa07a`)}static get LIGHTSEAGREEN(){return e.fromHex(`#20b2aa`)}static get LIGHTSKYBLUE(){return e.fromHex(`#87cefa`)}static get LIGHTSLATEGRAY(){return e.fromHex(`#778899`)}static get LIGHTSLATEGREY(){return e.fromHex(`#778899`)}static get LIGHTSTEELBLUE(){return e.fromHex(`#b0c4de`)}static get LIGHTYELLOW(){return e.fromHex(`#ffffe0`)}static get LIMEGREEN(){return e.fromHex(`#32cd32`)}static get LINEN(){return e.fromHex(`#faf0e6`)}static get MAGENTA(){return e.fromHex(`#ff00ff`)}static get FUCHSIA(){return e.fromHex(`#ff00ff`)}static get MEDIUMAQUAMARINE(){return e.fromHex(`#66cdaa`)}static get MEDIUMBLUE(){return e.fromHex(`#0000cd`)}static get MEDIUMORCHID(){return e.fromHex(`#ba55d3`)}static get MEDIUMPURPLE(){return e.fromHex(`#9370db`)}static get MEDIUMSEAGREEN(){return e.fromHex(`#3cb371`)}static get MEDIUMSLATEBLUE(){return e.fromHex(`#7b68ee`)}static get MEDIUMSPRINGGREEN(){return e.fromHex(`#00fa9a`)}static get MEDIUMTURQUOISE(){return e.fromHex(`#48d1cc`)}static get MEDIUMVIOLETRED(){return e.fromHex(`#c71585`)}static get MIDNIGHTBLUE(){return e.fromHex(`#191970`)}static get MINTCREAM(){return e.fromHex(`#f5fffa`)}static get MISTYROSE(){return e.fromHex(`#ffe4e1`)}static get MOCCASIN(){return e.fromHex(`#ffe4b5`)}static get NAVAJOWHITE(){return e.fromHex(`#ffdead`)}static get OLDLACE(){return e.fromHex(`#fdf5e6`)}static get OLIVEDRAB(){return e.fromHex(`#6b8e23`)}static get ORANGERED(){return e.fromHex(`#ff4500`)}static get ORCHID(){return e.fromHex(`#da70d6`)}static get PALEGOLDENROD(){return e.fromHex(`#eee8aa`)}static get PALEGREEN(){return e.fromHex(`#98fb98`)}static get PALETURQUOISE(){return e.fromHex(`#afeeee`)}static get PALEVIOLETRED(){return e.fromHex(`#db7093`)}static get PAPAYAWHIP(){return e.fromHex(`#ffefd5`)}static get PEACHPUFF(){return e.fromHex(`#ffdab9`)}static get PERU(){return e.fromHex(`#cd853f`)}static get PINK(){return e.fromHex(`#ffc0cb`)}static get PLUM(){return e.fromHex(`#dda0dd`)}static get POWDERBLUE(){return e.fromHex(`#b0e0e6`)}static get ROSYBROWN(){return e.fromHex(`#bc8f8f`)}static get ROYALBLUE(){return e.fromHex(`#4169e1`)}static get SADDLEBROWN(){return e.fromHex(`#8b4513`)}static get SALMON(){return e.fromHex(`#fa8072`)}static get SANDYBROWN(){return e.fromHex(`#f4a460`)}static get SEAGREEN(){return e.fromHex(`#2e8b57`)}static get SEASHELL(){return e.fromHex(`#fff5ee`)}static get SIENNA(){return e.fromHex(`#a0522d`)}static get SKYBLUE(){return e.fromHex(`#87ceeb`)}static get SLATEBLUE(){return e.fromHex(`#6a5acd`)}static get SLATEGRAY(){return e.fromHex(`#708090`)}static get SLATEGREY(){return e.fromHex(`#708090`)}static get SNOW(){return e.fromHex(`#fffafa`)}static get SPRINGGREEN(){return e.fromHex(`#00ff7f`)}static get STEELBLUE(){return e.fromHex(`#4682b4`)}static get TAN(){return e.fromHex(`#d2b48c`)}static get THISTLE(){return e.fromHex(`#d8bfd8`)}static get TOMATO(){return e.fromHex(`#ff6347`)}static get TURQUOISE(){return e.fromHex(`#40e0d0`)}static get VIOLET(){return e.fromHex(`#ee82ee`)}static get WHEAT(){return e.fromHex(`#f5deb3`)}static get WHITESMOKE(){return e.fromHex(`#f5f5f5`)}static get YELLOWGREEN(){return e.fromHex(`#9acd32`)}static get REBECCAPURPLE(){return e.fromHex(`#663399`)}};getScheme(t,n){return e.createScheme(this,t,n)}static getScheme(t,n,r){return e.createScheme(t,n,r)}static monochromatic(t,n){this.ic(t,e);let r=this.oc(n).results||3,i=e.toHsv(t),a=i.h,o=i.s,s=i.v/100,c=[],l=1/r;for(;r--;)c.push(e.fromHsv(a,o,this.clmp(s*100,100,0))),s=(s-l)%1;return c}monochromatic(t){return e.monochromatic(this,t)}static complementary(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l;return e.fromHsl(this.shift(r,180),i,a)}complementary(){return e.complementary(this)}static splitComplementary(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle||15,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180+i),o,s),e.fromHsl(this.shift(a,180-i),o,s)]}splitComplementary(t){return e.splitComplementary(this,t)}static doubleComplementary(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle||15,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180),o,s),e.fromHsl(this.shift(a,i),o,s),e.fromHsl(this.shift(a,180+i),o,s)]}doubleComplementary(t){return e.doubleComplementary(this,t)}static square(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l,o=[t];for(let t=1;t<4;t++)r=this.shift(r,90),o.push(e.fromHsl(r,i,a));return o}square(){return e.square(this)}static tetradic(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180),o,s),e.fromHsl(this.shift(a,180-i),o,s),e.fromHsl(this.shift(a,-i),o,s)]}tetradic(t){return e.tetradic(this,t)}static triadic(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l;return[t,e.fromHsl(this.shift(r,120),i,a),e.fromHsl(this.shift(r,240),i,a)]}triadic(){return e.triadic(this)}static analogous(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,-i),o,s),e.fromHsl(this.shift(a,+i),o,s)]}analogous(t){return e.analogous(this,t)}static createScheme(t,n,r){switch(n.toLowerCase()){case`analogous`:case`analog`:return e.analogous(t,r);case`triadic`:case`triad`:return e.triadic(t);case`tetradic`:case`tetra`:return e.tetradic(t,r);case`monochromatic`:case`monochrome`:case`mono`:return e.monochromatic(t,r);case`complementary`:case`complement`:case`comp`:return e.complementary(t);case`double-complementary`:case`double-complement`:case`double`:return e.doubleComplementary(t,r);case`split-complementary`:case`split-complement`:case`split`:return e.splitComplementary(t,r);case`square`:return e.square(t)}return null}constructor(t,n,r){if(!(0<=t&&t<=255&&0<=n&&n<=255&&0<=r&&r<=255))throw Error(`Color values out of bounds (0 - 255)`);this.#e=e.nc(e.tc(t,`number`)),this.#t=e.nc(e.tc(n,`number`)),this.#n=e.nc(e.tc(r,`number`)),this.alpha=1}static saturate(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=this.clmp(r.s+n,100,0),o=r.l;return e.fromHsl(i,a,o)}saturate(t){return e.saturate(this,t)}static desaturate(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=this.clmp(r.s-n,100,0),o=r.l;return e.fromHsl(i,a,o)}desaturate(t){return e.desaturate(this,t)}static grayscale(t){return e.desaturate(t,100)}grayscale(){return e.greyscale(this)}static greyscale(t){return e.desaturate(t,100)}greyscale(){return e.greyscale(this)}static lighten(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=r.s,o=this.clmp(r.l+n,100,0);return e.fromHsl(i,a,o)}lighten(t){return e.lighten(this,t)}static darken(t,n){return e.lighten(t,-n)}darken(t){return e.darken(this,t)}static brighten(t,n){let r=t.toRgb();return r.r=Math.max(0,Math.min(255,r.r-Math.round(255*-(n/100)))),r.g=Math.max(0,Math.min(255,r.g-Math.round(255*-(n/100)))),r.b=Math.max(0,Math.min(255,r.b-Math.round(255*-(n/100)))),new e(r.r,r.g,r.b)}brighten(t){return e.brighten(this,t)}static shiftHue(t,n){this.ic(t,e),this.tc(n,Number);let{h:r,s:i,l:a}=t.toHsl();return r=this.shift(r,n),e.fromHsl(r,i,a)}shiftHue(t){return e.shiftHue(this,t)}static multiply(t,n){this.ic(t,e),this.ic(n,e);let{r1:r,g1:i,b1:a}=t.toRgb(),{r2:o,g2:s,b2:c}=n.toRgb();return e.fromRgb(r*o/255,i*s/255,a*c/255)}multiply(t){return e.multiply(this,t)}static mix(t,n,r=50){this.ic(t,e),this.ic(t,e),this.tc(r,`number`);let i=t.toRgb(),a=n.toRgb(),o=this.clmp(r,100,0)/100,s=Math.round((a.r-i.r)*o+i.r),c=Math.round((a.g-i.g)*o+i.g),l=Math.round((a.b-i.b)*o+i.b);return e.fromRgb(s,c,l)}mix(t,n){return e.mix(this,t,n)}static lerp(t,n,r=.5){this.tc(r,`number`),this.ic(t,e),this.ic(n,e),r=this.clmp(r,1,0);let i=t.toRgb(),a=n.toRgb(),o=i.r/255,s=i.g/255,c=i.b/255,l=a.r/255,u=a.g/255,d=a.b/255;return e.fromRgb((o+(l-o)*r)*255,(s+(u-s)*r)*255,(c+(d-c)*r)*255)}lerp(t,n){return e.lerp(this,t,n)}static add(t,n){this.ic(t,e),this.ic(n,e);let r=t.toRgb(),i=n.toRgb(),a=r.r,o=r.g,s=r.b,c=i.r,l=i.g,u=i.b;return e.fromRgb(Math.round((a+c)/2),Math.round((o+l)/2),Math.round((s+u)/2))}add(t){return e.add(this,t)}static fromHex(t){if(!t.match(/^#?(?:[0-9a-fA-F]{3}){1,2}$/i))throw Error(`Invalid Hex code: "`+t+`"`);let n=`0x00`,r=`0x00`,i=`0x00`;return t.length==4?(n=`0x`+t[1]+t[1],r=`0x`+t[2]+t[2],i=`0x`+t[3]+t[3]):t.length==3?(n=`0x`+t[0]+t[0],r=`0x`+t[1]+t[1],i=`0x`+t[2]+t[2]):t.length==7?(n=`0x`+t[1]+t[2],r=`0x`+t[3]+t[4],i=`0x`+t[5]+t[6]):t.length==6&&(n=`0x`+t[0]+t[1],r=`0x`+t[2]+t[3],i=`0x`+t[4]+t[5]),new e(parseInt(n,16),parseInt(r,16),parseInt(i,16))}static fromRgb(t,n,r){return new e(t,n,r)}static fromHsl(t,n,r){if(t=this.tc(t,`number`),n=this.tc(n,`number`),r=this.tc(r,`number`),!(0<=t&&t<=360))throw Error(`HSL color values out of range, hue (0 - 360)`);if(!(0<=n&&n<=100))throw Error(`HSL color values out of range, sat (0 - 100)`);if(!(0<=r&&r<=100))throw Error(`HSL color values out of range, lum (0 - 100)`);n/=100,r/=100;let i=(1-Math.abs(2*r-1))*n,a=i*(1-Math.abs(t/60%2-1)),o=r-i/2,s=0,c=0,l=0;return 0<=t&&t<60?(s=i,c=a,l=0):60<=t&&t<120?(s=a,c=i,l=0):120<=t&&t<180?(s=0,c=i,l=a):180<=t&&t<240?(s=0,c=a,l=i):240<=t&&t<300?(s=a,c=0,l=i):300<=t&&t<=360&&(s=i,c=0,l=a),new e(Math.round((s+o)*255),Math.round((c+o)*255),Math.round((l+o)*255))}static fromHsv(t,n,r){if(t=this.tc(t,`number`),n=this.tc(n,`number`),r=this.tc(r,`number`),!(0<=t&&t<=360))throw Error(`HSL color values out of range, hue (0 - 360)`);if(!(0<=n&&n<=100))throw Error(`HSL color values out of range, sat (0 - 100)`);if(!(0<=r&&r<=100))throw Error(`HSL color values out of range, lum (0 - 100)`);n/=100,r/=100;let i=r*n,a=i*(1-Math.abs(t/60%2-1)),o=r-i,s=0,c=0,l=0;return 0<=t&&t<60?(s=i,c=a,l=0):60<=t&&t<120?(s=a,c=i,l=0):120<=t&&t<180?(s=0,c=i,l=a):180<=t&&t<240?(s=0,c=a,l=i):240<=t&&t<300?(s=a,c=0,l=i):300<=t&&t<=360&&(s=i,c=0,l=a),new e((s+o)*255,(c+o)*255,(l+o)*255)}static fromCssString(t){this.tc(t,`string`);var n=document.createElement(`canvas`).getContext(`2d`);let r;if(n&&(n.fillStyle=t,r=n.fillStyle),!r)throw Error(`Invalid Color string`);return e.fromHex(r)}static fromName(e){e=this.tc(e,`string`);let t=this.Colors[e.toUpperCase()];if(!t)throw Error(`Invalid Color name`);return t}static toHex(t){t=this.ic(t,e);let n=Math.round(t.#e).toString(16),r=Math.round(t.#t).toString(16),i=Math.round(t.#n).toString(16);return n.length==1&&(n=`0`+n),r.length==1&&(r=`0`+r),i.length==1&&(i=`0`+i),`#`+n+r+i}static toHsl(t){t=this.ic(t,e);let n=0,r=0,i=0,a=t.#e/255,o=t.#t/255,s=t.#n/255,c=Math.min(Math.min(a,o),s),l=Math.max(Math.max(a,o),s),u=l-c;return n=u===0?0:l===a?(o-s)/u%6:l===o?(s-a)/u+2:(a-o)/u+4,n=Math.round(n*60),n<0&&(n+=360),i=(l+c)/2,r=u===0?0:u/(1-Math.abs(2*i-1)),r=parseFloat(Math.abs(r*100)+``),i=parseFloat(Math.abs(i*100)+``),{h:this.nc(n),s:this.nc(r),l:this.nc(i)}}static toHsv(e){let t=0,n=0,r=0,i=e.#e/255,a=e.#t/255,o=e.#n/255,s=Math.min(Math.min(i,a),o),c=Math.max(Math.max(i,a),o),l=c-s;return t=l===0?0:c===i?(a-o)/l%6:c===a?(o-i)/l+2:(i-a)/l+4,t=Math.round(t*60),t<0&&(t+=360),c!==0&&(n=l/c*100),r=c*100,{h:this.nc(t),s:this.nc(n),v:this.nc(r)}}static toRgb(t){return this.ic(t,e),{r:t.#e,g:t.#t,b:t.#n}}static toCmyk(t){this.ic(t,e);let{r:n,g:r,b:i}=t.toRgb(),a=1-n/255,o=1-r/255,s=1-i/255,c=Math.min(a,Math.min(o,s));return a=(a-c)/(1-c),o=(o-c)/(1-c),s=(s-c)/(1-c),a=this.nc(Math.round(a*1e4)/100),o=this.nc(Math.round(o*1e4)/100),s=this.nc(Math.round(s*1e4)/100),c=this.nc(Math.round(c*1e4)/100),{c:a,m:o,y:s,k:c}}toHsl(){return e.toHsl(this)}toHsv(){return e.toHsv(this)}toHex(){return e.toHex(this)}toRgb(){return e.toRgb(this)}toCmyk(){return e.toCmyk(this)}static random(){return new e(Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255))}toString(t=`hex`){e.tc(t,`string`);let n=this.toRgb(),r=this.toHsl();switch(t.toLowerCase()){case`hex`:return this.toHex();case`hexa`:let e=Math.round(this.alpha*255).toString(16);return e.length===1&&(e=`0`+e),this.toHex()+e;case`rgb`:return`rgb(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)})`;case`rgba`:return`rgba(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)}, ${this.alpha})`;case`hsl`:return`hsl(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(r.l)}%)`;case`hsla`:return`hsla(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(r.l)}%, ${this.alpha})`;case`hsv`:let t=this.toHsv();return`hsv(${Math.round(t.h)}, ${Math.round(t.s)}%, ${Math.round(t.v)}%)`;case`cmyk`:let i=this.toCmyk();return`cmyk(${Math.round(i.c)}%, ${Math.round(i.m)}%, ${Math.round(i.y)}%, ${Math.round(i.k)}%)`;default:}return``}valueOf(){return parseInt(`0x`+this.toHex().slice(1))}},fa=class extends Error{sourceStart;sourceEnd;parserState;constructor(e,t,n,r){super(e),this.name=`ParseError`,this.sourceStart=t,this.sourceEnd=n,this.parserState=r}},pa=class extends fa{token;constructor(e,t,n,r,i){super(e,t,n,r),this.token=i}};const ma={UnexpectedNewLineInString:`Unexpected newline while consuming a string token.`,UnexpectedEOFInString:`Unexpected EOF while consuming a string token.`,UnexpectedEOFInComment:`Unexpected EOF while consuming a comment.`,UnexpectedEOFInURL:`Unexpected EOF while consuming a url token.`,UnexpectedEOFInEscapedCodePoint:`Unexpected EOF while consuming an escaped code point.`,UnexpectedCharacterInURL:`Unexpected character while consuming a url token.`,InvalidEscapeSequenceInURL:`Invalid escape sequence while consuming a url token.`,InvalidEscapeSequenceAfterBackslash:`Invalid escape sequence after "\\"`};typeof globalThis<`u`&&`structuredClone`in globalThis;function ha(...e){let t=``;for(let n=0;n<e.length;n++)t+=e[n][1];return t}const ga=65533;function _a(e){return e.source.codePointAt(e.cursor)===60&&e.source.codePointAt(e.cursor+1)===33&&e.source.codePointAt(e.cursor+2)===45&&e.source.codePointAt(e.cursor+3)===45}function va(e){return e>=48&&e<=57}function ya(e){return e>=65&&e<=90}function ba(e){return e>=97&&e<=122}function xa(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function Sa(e){return ba(e)||ya(e)}function Ca(e){return Sa(e)||Ta(e)||e===95}function wa(e){return Ca(e)||va(e)||e===45}function Ta(e){return e===183||e===8204||e===8205||e===8255||e===8256||e===8204||192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=893||895<=e&&e<=8191||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||63744<=e&&e<=64975||65008<=e&&e<=65533||e===0||!!ka(e)||e>=65536}function Ea(e){return e===11||e===127||0<=e&&e<=8||14<=e&&e<=31}function Da(e){return e===10||e===13||e===12}function Oa(e){return e===32||e===10||e===9||e===13||e===12}function ka(e){return e>=55296&&e<=57343}function Aa(e){return e.source.codePointAt(e.cursor)===92&&!Da(e.source.codePointAt(e.cursor+1)??-1)}function ja(e,t){return t.source.codePointAt(t.cursor)===45?t.source.codePointAt(t.cursor+1)===45||!!Ca(t.source.codePointAt(t.cursor+1)??-1)||t.source.codePointAt(t.cursor+1)===92&&!Da(t.source.codePointAt(t.cursor+2)??-1):!!Ca(t.source.codePointAt(t.cursor)??-1)||Aa(t)}function Ma(e){return e.source.codePointAt(e.cursor)===43||e.source.codePointAt(e.cursor)===45?!!va(e.source.codePointAt(e.cursor+1)??-1)||e.source.codePointAt(e.cursor+1)===46&&va(e.source.codePointAt(e.cursor+2)??-1):e.source.codePointAt(e.cursor)===46?va(e.source.codePointAt(e.cursor+1)??-1):va(e.source.codePointAt(e.cursor)??-1)}function Na(e){return e.source.codePointAt(e.cursor)===47&&e.source.codePointAt(e.cursor+1)===42}function Pa(e){return e.source.codePointAt(e.cursor)===45&&e.source.codePointAt(e.cursor+1)===45&&e.source.codePointAt(e.cursor+2)===62}var z,B,Fa;function Ia(e){switch(e){case z.OpenParen:return z.CloseParen;case z.CloseParen:return z.OpenParen;case z.OpenCurly:return z.CloseCurly;case z.CloseCurly:return z.OpenCurly;case z.OpenSquare:return z.CloseSquare;case z.CloseSquare:return z.OpenSquare;default:return null}}function La(e){switch(e[0]){case z.OpenParen:return[z.CloseParen,`)`,-1,-1,void 0];case z.CloseParen:return[z.OpenParen,`(`,-1,-1,void 0];case z.OpenCurly:return[z.CloseCurly,`}`,-1,-1,void 0];case z.CloseCurly:return[z.OpenCurly,`{`,-1,-1,void 0];case z.OpenSquare:return[z.CloseSquare,`]`,-1,-1,void 0];case z.CloseSquare:return[z.OpenSquare,`[`,-1,-1,void 0];default:return null}}function Ra(e,t){for(t.advanceCodePoint(2);;){let n=t.readCodePoint();if(n===void 0){let n=[z.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new pa(ma.UnexpectedEOFInComment,t.representationStart,t.representationEnd,[`4.3.2. Consume comments`,`Unexpected EOF`],n)),n}if(n===42&&t.source.codePointAt(t.cursor)!==void 0&&t.source.codePointAt(t.cursor)===47){t.advanceCodePoint();break}}return[z.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0]}function za(e,t){let n=t.readCodePoint();if(n===void 0)return e.onParseError(new fa(ma.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,[`4.3.7. Consume an escaped code point`,`Unexpected EOF`])),ga;if(xa(n)){let e=[n],r;for(;(r=t.source.codePointAt(t.cursor))!==void 0&&xa(r)&&e.length<6;)e.push(r),t.advanceCodePoint();Oa(t.source.codePointAt(t.cursor)??-1)&&(t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10&&t.advanceCodePoint(),t.advanceCodePoint());let i=parseInt(String.fromCodePoint(...e),16);return i===0||ka(i)||i>1114111?ga:i}return n===0||ka(n)?ga:n}function Ba(e,t){let n=[];for(;;){let r=t.source.codePointAt(t.cursor)??-1;if(r===0||ka(r))n.push(ga),t.advanceCodePoint(+(r>65535)+1);else if(wa(r))n.push(r),t.advanceCodePoint(+(r>65535)+1);else{if(!Aa(t))return n;t.advanceCodePoint(),n.push(za(e,t))}}}function Va(e,t){t.advanceCodePoint();let n=t.source.codePointAt(t.cursor);if(n!==void 0&&(wa(n)||Aa(t))){let n=Fa.Unrestricted;ja(0,t)&&(n=Fa.ID);let r=Ba(e,t);return[z.Hash,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...r),type:n}]}return[z.Delim,`#`,t.representationStart,t.representationEnd,{value:`#`}]}function Ha(e,t){let n=B.Integer;for(t.source.codePointAt(t.cursor)!==43&&t.source.codePointAt(t.cursor)!==45||t.advanceCodePoint();va(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===46&&va(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint(2),n=B.Number;va(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===101||t.source.codePointAt(t.cursor)===69){if(va(t.source.codePointAt(t.cursor+1)??-1))t.advanceCodePoint(2);else{if(t.source.codePointAt(t.cursor+1)!==45&&t.source.codePointAt(t.cursor+1)!==43||!va(t.source.codePointAt(t.cursor+2)??-1))return n;t.advanceCodePoint(3)}for(n=B.Number;va(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint()}return n}function Ua(e,t){let n;{let e=t.source.codePointAt(t.cursor);e===45?n=`-`:e===43&&(n=`+`)}let r=Ha(0,t),i=parseFloat(t.source.slice(t.representationStart,t.representationEnd+1));if(ja(0,t)){let a=Ba(e,t);return[z.Dimension,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n,type:r,unit:String.fromCodePoint(...a)}]}return t.source.codePointAt(t.cursor)===37?(t.advanceCodePoint(),[z.Percentage,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n}]):[z.Number,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n,type:r}]}function Wa(e){for(;Oa(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return[z.Whitespace,e.source.slice(e.representationStart,e.representationEnd+1),e.representationStart,e.representationEnd,void 0]}(function(e){e.Comment=`comment`,e.AtKeyword=`at-keyword-token`,e.BadString=`bad-string-token`,e.BadURL=`bad-url-token`,e.CDC=`CDC-token`,e.CDO=`CDO-token`,e.Colon=`colon-token`,e.Comma=`comma-token`,e.Delim=`delim-token`,e.Dimension=`dimension-token`,e.EOF=`EOF-token`,e.Function=`function-token`,e.Hash=`hash-token`,e.Ident=`ident-token`,e.Number=`number-token`,e.Percentage=`percentage-token`,e.Semicolon=`semicolon-token`,e.String=`string-token`,e.URL=`url-token`,e.Whitespace=`whitespace-token`,e.OpenParen=`(-token`,e.CloseParen=`)-token`,e.OpenSquare=`[-token`,e.CloseSquare=`]-token`,e.OpenCurly=`{-token`,e.CloseCurly=`}-token`,e.UnicodeRange=`unicode-range-token`})(z||={}),function(e){e.Integer=`integer`,e.Number=`number`}(B||={}),function(e){e.Unrestricted=`unrestricted`,e.ID=`id`}(Fa||={});var Ga=class{cursor=0;source=``;representationStart=0;representationEnd=-1;constructor(e){this.source=e}advanceCodePoint(e=1){this.cursor+=e,this.representationEnd=this.cursor-1}readCodePoint(){let e=this.source.codePointAt(this.cursor);if(e!==void 0)return this.cursor+=1,this.representationEnd=this.cursor-1,e}unreadCodePoint(e=1){this.cursor-=e,this.representationEnd=this.cursor-1}resetRepresentation(){this.representationStart=this.cursor,this.representationEnd=-1}};function Ka(e,t){let n=``,r=t.readCodePoint();for(;;){let i=t.readCodePoint();if(i===void 0){let r=[z.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new pa(ma.UnexpectedEOFInString,t.representationStart,t.representationEnd,[`4.3.5. Consume a string token`,`Unexpected EOF`],r)),r}if(Da(i)){t.unreadCodePoint();let n=[z.BadString,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new pa(ma.UnexpectedNewLineInString,t.representationStart,t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10?t.representationEnd+2:t.representationEnd+1,[`4.3.5. Consume a string token`,`Unexpected newline`],n)),n}if(i===r)return[z.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(i!==92)i===0||ka(i)?n+=String.fromCodePoint(ga):n+=String.fromCodePoint(i);else{if(t.source.codePointAt(t.cursor)===void 0)continue;if(Da(t.source.codePointAt(t.cursor)??-1)){t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10&&t.advanceCodePoint(),t.advanceCodePoint();continue}n+=String.fromCodePoint(za(e,t))}}}function qa(e){return!(e.length!==3||e[0]!==117&&e[0]!==85||e[1]!==114&&e[1]!==82||e[2]!==108&&e[2]!==76)}function Ja(e,t){for(;;){let n=t.source.codePointAt(t.cursor);if(n===void 0)return;if(n===41)return void t.advanceCodePoint();Aa(t)?(t.advanceCodePoint(),za(e,t)):t.advanceCodePoint()}}function Ya(e,t){for(;Oa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();let n=``;for(;;){if(t.source.codePointAt(t.cursor)===void 0){let r=[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new pa(ma.UnexpectedEOFInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Unexpected EOF`],r)),r}if(t.source.codePointAt(t.cursor)===41)return t.advanceCodePoint(),[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(Oa(t.source.codePointAt(t.cursor)??-1)){for(t.advanceCodePoint();Oa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===void 0){let r=[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new pa(ma.UnexpectedEOFInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Consume as much whitespace as possible`,`Unexpected EOF`],r)),r}return t.source.codePointAt(t.cursor)===41?(t.advanceCodePoint(),[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}]):(Ja(e,t),[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0])}let r=t.source.codePointAt(t.cursor);if(r===34||r===39||r===40||Ea(r??-1)){Ja(e,t);let n=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new pa(ma.UnexpectedCharacterInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Unexpected U+0022 QUOTATION MARK ("), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point`],n)),n}if(r===92){if(Aa(t)){t.advanceCodePoint(),n+=String.fromCodePoint(za(e,t));continue}Ja(e,t);let r=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new pa(ma.InvalidEscapeSequenceInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`U+005C REVERSE SOLIDUS (\\)`,`The input stream does not start with a valid escape sequence`],r)),r}t.source.codePointAt(t.cursor)===0||ka(t.source.codePointAt(t.cursor)??-1)?(n+=String.fromCodePoint(ga),t.advanceCodePoint()):(n+=t.source[t.cursor],t.advanceCodePoint())}}function Xa(e,t){let n=Ba(e,t);if(t.source.codePointAt(t.cursor)!==40)return[z.Ident,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];if(qa(n)){t.advanceCodePoint();let r=0;for(;;){let e=Oa(t.source.codePointAt(t.cursor)??-1),i=Oa(t.source.codePointAt(t.cursor+1)??-1);if(e&&i){r+=1,t.advanceCodePoint(1);continue}let a=e?t.source.codePointAt(t.cursor+1):t.source.codePointAt(t.cursor);if(a===34||a===39)return r>0&&t.unreadCodePoint(r),[z.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];break}return Ya(e,t)}return t.advanceCodePoint(),[z.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}]}function Za(e){return!(e.source.codePointAt(e.cursor)!==117&&e.source.codePointAt(e.cursor)!==85||e.source.codePointAt(e.cursor+1)!==43||e.source.codePointAt(e.cursor+2)!==63&&!xa(e.source.codePointAt(e.cursor+2)??-1))}function Qa(e,t){t.advanceCodePoint(2);let n=[],r=[],i;for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&xa(i);)n.push(i),t.advanceCodePoint();for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&i===63;)r.length===0&&r.push(...n),n.push(48),r.push(70),t.advanceCodePoint();if(!r.length&&t.source.codePointAt(t.cursor)===45&&xa(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint();(i=t.source.codePointAt(t.cursor))!==void 0&&r.length<6&&xa(i);)r.push(i),t.advanceCodePoint();if(!r.length){let e=parseInt(String.fromCodePoint(...n),16);return[z.UnicodeRange,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{startOfRange:e,endOfRange:e}]}let a=parseInt(String.fromCodePoint(...n),16),o=parseInt(String.fromCodePoint(...r),16);return[z.UnicodeRange,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{startOfRange:a,endOfRange:o}]}function $a(e,t){let n=eo(e,t),r=[];for(;!n.endOfFile();)r.push(n.nextToken());return r.push(n.nextToken()),r}function eo(e,t){let n=e.css.valueOf(),r=e.unicodeRangesAllowed??!1,i=new Ga(n),a={onParseError:t?.onParseError??to};return{nextToken:function(){i.resetRepresentation();let e=i.source.codePointAt(i.cursor);if(e===void 0)return[z.EOF,``,-1,-1,void 0];if(e===47&&Na(i))return Ra(a,i);if(r&&(e===117||e===85)&&Za(i))return Qa(0,i);if(Ca(e))return Xa(a,i);if(va(e))return Ua(a,i);switch(e){case 44:return i.advanceCodePoint(),[z.Comma,`,`,i.representationStart,i.representationEnd,void 0];case 58:return i.advanceCodePoint(),[z.Colon,`:`,i.representationStart,i.representationEnd,void 0];case 59:return i.advanceCodePoint(),[z.Semicolon,`;`,i.representationStart,i.representationEnd,void 0];case 40:return i.advanceCodePoint(),[z.OpenParen,`(`,i.representationStart,i.representationEnd,void 0];case 41:return i.advanceCodePoint(),[z.CloseParen,`)`,i.representationStart,i.representationEnd,void 0];case 91:return i.advanceCodePoint(),[z.OpenSquare,`[`,i.representationStart,i.representationEnd,void 0];case 93:return i.advanceCodePoint(),[z.CloseSquare,`]`,i.representationStart,i.representationEnd,void 0];case 123:return i.advanceCodePoint(),[z.OpenCurly,`{`,i.representationStart,i.representationEnd,void 0];case 125:return i.advanceCodePoint(),[z.CloseCurly,`}`,i.representationStart,i.representationEnd,void 0];case 39:case 34:return Ka(a,i);case 35:return Va(a,i);case 43:case 46:return Ma(i)?Ua(a,i):(i.advanceCodePoint(),[z.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]);case 10:case 13:case 12:case 9:case 32:return Wa(i);case 45:return Ma(i)?Ua(a,i):Pa(i)?(i.advanceCodePoint(3),[z.CDC,`-->`,i.representationStart,i.representationEnd,void 0]):ja(0,i)?Xa(a,i):(i.advanceCodePoint(),[z.Delim,`-`,i.representationStart,i.representationEnd,{value:`-`}]);case 60:return _a(i)?(i.advanceCodePoint(4),[z.CDO,`<!--`,i.representationStart,i.representationEnd,void 0]):(i.advanceCodePoint(),[z.Delim,`<`,i.representationStart,i.representationEnd,{value:`<`}]);case 64:if(i.advanceCodePoint(),ja(0,i)){let e=Ba(a,i);return[z.AtKeyword,i.source.slice(i.representationStart,i.representationEnd+1),i.representationStart,i.representationEnd,{value:String.fromCodePoint(...e)}]}return[z.Delim,`@`,i.representationStart,i.representationEnd,{value:`@`}];case 92:{if(Aa(i))return Xa(a,i);i.advanceCodePoint();let e=[z.Delim,`\\`,i.representationStart,i.representationEnd,{value:`\\`}];return a.onParseError(new pa(ma.InvalidEscapeSequenceAfterBackslash,i.representationStart,i.representationEnd,[`4.3.1. Consume a token`,`U+005C REVERSE SOLIDUS (\\)`,`The input stream does not start with a valid escape sequence`],e)),e}}return i.advanceCodePoint(),[z.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]},endOfFile:function(){return i.source.codePointAt(i.cursor)===void 0}}}function to(){}function no(e,t){let n=[];for(let e of t)n.push(e.codePointAt(0));let r=ro(n);r[0]===101&&ao(r,0,r[0]);let i=String.fromCodePoint(...r);e[1]=`${e[4].signCharacter===`+`?e[4].signCharacter:``}${e[4].value.toString()}${i}`,e[4].unit=t}function ro(e){let t=0;if(e[0]===0)e.splice(0,1,ga),t=1;else if(e[0]===45&&e[1]===45)t=2;else if(e[0]===45&&e[1])t=2,Ca(e[1])||(t+=ao(e,1,e[1]));else{if(e[0]===45&&!e[1])return[92,e[0]];Ca(e[0])?t=1:(t=1,t+=ao(e,0,e[0]))}for(let n=t;n<e.length;n++)e[n]===0?(e.splice(n,1,ga),n++):wa(e[n])||(n+=io(e,n,e[n]));return e}function io(e,t,n){return e.splice(t,1,92,n),1}function ao(e,t,n){let r=n.toString(16),i=[];for(let e of r)i.push(e.codePointAt(0));return e.splice(t,1,92,...i,32),1+i.length}const oo=Object.values(z);function so(e){return!!Array.isArray(e)&&!(e.length<4)&&!!oo.includes(e[0])&&typeof e[1]==`string`&&typeof e[2]==`number`&&typeof e[3]==`number`}function V(e){if(!e)return!1;switch(e[0]){case z.Dimension:case z.Number:case z.Percentage:return!0;default:return!1}}function co(e){if(!e)return!1;switch(e[0]){case z.Whitespace:case z.Comment:return!0;default:return!1}}function lo(e){return!!e&&e[0]===z.Colon}function uo(e){return!!e&&e[0]===z.Comma}function fo(e){return!!e&&e[0]===z.Comment}function po(e){return!!e&&e[0]===z.Delim}function H(e){return!!e&&e[0]===z.Dimension}function mo(e){return!!e&&e[0]===z.EOF}function ho(e){return!!e&&e[0]===z.Function}function go(e){return!!e&&e[0]===z.Hash}function U(e){return!!e&&e[0]===z.Ident}function W(e){return!!e&&e[0]===z.Number}function G(e){return!!e&&e[0]===z.Percentage}function _o(e){return!!e&&e[0]===z.Semicolon}function vo(e){return!!e&&e[0]===z.Whitespace}function yo(e){return!!e&&e[0]===z.OpenParen}function bo(e){return!!e&&e[0]===z.CloseParen}function xo(e){return!!e&&e[0]===z.OpenSquare}function So(e){return!!e&&e[0]===z.OpenCurly}function Co(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}const wo=[.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124];
723
+ `)}}function Yi(e){let t=e.split(`/`);return t.pop(),t.join(`/`)}function Xi(e,t){if(t.start===void 0){let t=e.positionAt(0);return m.Range.create(t,t)}let n=e.positionAt(t.start),r=e.positionAt(t.start+(t.length||0));return m.Range.create(n,r)}function Zi(e,t){if(!t)return e;let n=t.aliases;for(let t in n)if(!t.startsWith(`@`)){let r=Qi(t),i=RegExp(`(?<!\\\\)`+r,`g`);e=e.replace(i,n[t])}return e}function Qi(e,t=!1){return t?e.replace(/[\\^$+?.()|[\]{}]/g,`\\$&`):e.replace(/[\\^$*+?.()|[\]{}]/g,`\\$&`)}function $i(e){return e===13||e===10}const ea=/(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;function ta(e,t){let n=ea,r=t;for(;r>0&&!$i(e.charCodeAt(r-1));)r--;let i=t-r,a=e.substr(r),o=n.ignoreCase?`gi`:`g`;n=new RegExp(n.source,o);let s=n.exec(a);for(;s&&s.index+s[0].length<i;)s=n.exec(a);return s&&s.index<=i?{start:s.index+r,length:s[0].length}:{start:t,length:0}}function na(e,t){e=decodeURIComponent(e),t=decodeURIComponent(t);let n=t.split(`/`);n.pop();let r=e.split(`/`);for(let e=0;e<n.length;e++)if(r.length>e)if(n[e]==r[e])n.splice(e,1),r.splice(e,1),e--;else break;let i=``;for(let e=0;e<n.length;e++)i+=`../`;return i==``&&(i+=`./`),i+=r.join(`/`),i}function ra(e,t,n){e=e.replace(/\[(.*?)\]/g,`.$1`);let r=e=>t instanceof Map?t.get(e):t[e],i=e.split(`.`);for(let e=0;e<i.length-1;e++){let n=i[e],a=r(n);a||=(t[n]={},t[n]),t=a}t instanceof Map?t.set(i[i.length-1],n):t[i[i.length-1]]=n}function ia(e){return new Promise(t=>setTimeout(t,e))}const aa={},oa=new Map;function sa(e){let t=oa.get(e);return t||(t=new Ei,oa.set(e,t)),t}async function ca(e,t,n,r,i=5){let a=sa(e);await a.waitOne();for(let o=0;;o++)try{t=t.replace(/\r\n?/g,`
724
+ `);let i=la(t),o=(0,f.dirname)(e);(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0});let s=(0,u.existsSync)(e);(!aa[e]||aa[e]!=i||!s)&&((0,u.writeFileSync)(e,t),aa[e]=i,Pi.sendFileSize(e,t,n,r)),a.release();return}catch(e){if(!(e.code===`EBUSY`||e.code===`EPERM`||e.code===`EACCES`||e.code===`UNKNOWN`)||o>=i)throw a.release(),e;await ia(20*(o+1))}}function la(e){return(0,le.createHash)(`md5`).update(e).digest(`hex`)}function ua(e){try{(0,u.existsSync)(e)&&(0,u.unlinkSync)(e)}catch{}}var da=class{static timers={};static start(e){this.timers[e]=process.hrtime()}static stop(e){let t=process.hrtime(this.timers[e]),n=t[1]/1e6;return delete this.timers[e],t[0]*1e3+Math.round(n)}static stopNano(e){let t=process.hrtime(this.timers[e]);return delete this.timers[e],t[0]*1e9+t[1]}},fa=class e{static isInit=!1;static send(e){$.sendNotification(`aventus/initStep`,e)}static sendDone(){$.sendNotification(`aventus/initStep`,`Aventus : Done`),e.isInit=!0}},pa=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}watcher;constructor(){P.getInstance().settings.watchFiles&&(this.watcher=(0,me.watch)(` `,{ignored:/(^|[\/\\])\../,persistent:!0}),this.watcher.on(`add`,this.onContentChange.bind(this)).on(`change`,this.onContentChange.bind(this)).on(`unlink`,this.onRemove.bind(this)))}watcheUris=[];watch(e){if(this.watcheUris.includes(e)||!this.watcher)return;this.watcheUris.push(e);let t=I(e);this.watcher.add(t)}unwatch(e){let t=this.watcheUris.indexOf(e);t!=-1&&this.watcheUris.splice(t,1)}async onContentChange(e){$.debug(`onContentChange : `+e);let t=F(e);this.watcheUris.includes(t)&&R.getInstance().onUpdatedUri(t)}async onRemove(e){let t=F(e);this.watcheUris.includes(t)&&R.getInstance().onDeletedUri(t)}async destroy(){await this.watcher?.close(),e.instance=void 0}},R=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}constructor(){}files={};lockedUpdatedUri={};loadingInProgress=!0;preventUpdateUri(e){this.lockedUpdatedUri[e]&&clearTimeout(this.lockedUpdatedUri[e]),this.lockedUpdatedUri[e]=setTimeout(()=>{delete this.lockedUpdatedUri[e]},2e3)}async onCreatedUri(e){if(!this.files[e]){let t=zi(e);if(t){let n=I(e),r=d.TextDocument.create(e,t,0,(0,u.readFileSync)(n,`utf8`));await this.registerFile(r),this.onSave(r)}}}async onUpdatedUri(e){if(this.lockedUpdatedUri[e])return;let t=zi(e),n=I(e),r=``;if((0,u.existsSync)(n))r=(0,u.readFileSync)(n,`utf8`);else{this.onDeletedUri(e);return}if(this.files[e]){let n=this.files[e].versionUser+1,i=d.TextDocument.create(e,t,n,r);await this.onContentChange(i),this.onSave(i)}else{let n=d.TextDocument.create(e,t,0,r);await this.registerFile(n),this.onSave(n)}}async onDeletedUri(e){if(this.files[e]){if(P.getInstance().settings.errorByBuild){let t=this.files[e].getBuild();if(t===null)$.sendDiagnostics({uri:e,diagnostics:[]});else for(let n of t)$.sendDiagnostics({uri:e,diagnostics:[]},n)}else $.sendDiagnostics({uri:e,diagnostics:[]});await this.files[e].triggerDelete(),delete this.files[e],pa.getInstance().unwatch(e)}}async loadConfigFileNotSet(e,t,n){for(let r=0;r<e.length;r++){let i=I(e[r]),a=async e=>{let r=(0,u.readdirSync)(e);for(let i=0;i<r.length;i++){let o=e+`/`+r[i];if((0,u.lstatSync)(o).isDirectory()){if(r[i]!=`node_modules`&&await a(o))return!0}else{let e=F(o);if(r[i]==w.Config)return await this.loadConfigFile(e,t,n),!0}}return!1};if(await a(i))return}fa.sendDone()}async loadConfigFile(e,t,n){N.autoLoad=!1;let r=I(e);e=F(r);let i=d.TextDocument.create(F(r),w.Config,0,(0,u.readFileSync)(r,`utf8`));this.loadingInProgress=!1,await this.registerFile(i),this.loadingInProgress=!0;let a=N.getInstance().getProjectByUri(e);if(a){await a.loadConfig(),a.buildsAllowed=t,a.staticsAllowed=n;let e=a.getConfig();if(e){let r=async e=>{if(!(0,u.existsSync)(e))return;let t=(0,u.readdirSync)(e);for(let n=0;n<t.length;n++){let i=e+`/`+t[n];if((0,u.lstatSync)(i).isDirectory())t[n]!=`node_modules`&&await r(i);else{let e=F(i),r=zi(e);if(t[n]!=w.Config&&t[n].endsWith(w.Base)){let t=d.TextDocument.create(e,r,0,(0,u.readFileSync)(i,`utf8`));await this.registerFile(t)}}}};for(let n of e.build)if(!t||t.includes(n.name??``))for(let e of n.srcPath)await r(e);for(let t of e.static)(!n||n.includes(t.name??``))&&await r(t.inputPathFolder);Pi.startSendLoadFile(),a.loadFiles(),Pi.sendLoadFile(),this.loadingInProgress=!1,await a.init(),fa.sendDone()}}}async parseWorkspace(e,t){let n=I(e),r=P.getInstance().settings.readDirs,i=e=>!0;if(r.length>0){let t=[],n=[];for(let i of r){let r=``,a=i.replace(/\\/g,`/`);a.startsWith(`/`)||(r=`/`);let o=a.split(`/`);o[o.length-1]==``||o[o.length-1]==`*`?o[o.length-1]=`*`:o[o.length-1].indexOf(`.`)==-1&&o.push(`*`),a=o.join(`/`);let s=(0,f.normalize)(I(e)+r+a).replace(/\\/g,`/`);s=Qi(s,!0).replace(`*`,`.*`);let c=s.split(`/`),l=``;for(let e of c)e!=`.*`&&(l==``?l=e:l+=`/`+e,n.includes(l)||n.push(l));t.push(`(^`+s+`$)`)}let a=t.join(`|`);a==``&&(a=`(?!)`);let o=new RegExp(a);i=e=>{let t=(e+`/`).match(o)!=null,r=n.includes(e);return t||r}}let a=async e=>{if(!i(e))return;let n=(0,u.readdirSync)(e);for(let r=0;r<n.length;r++){let i=e+`/`+n[r];(0,u.lstatSync)(i).isDirectory()?n[r]!=`node_modules`&&n[r]!=`.git`&&await a(i):await t(n[r],i)}};await a(n)}async loadAllAventusConfigFiles(e){let t=[];for(let n=0;n<e.length;n++)await this.parseWorkspace(e[n],async(e,n)=>{let r=F(n),i=zi(r);e==w.Config&&t.push(new E(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`))))});return t}async loadAllAventusFiles(e){this.loadingInProgress=!0;let t=[];fa.send(`$(loading~spin) Aventus : Loading files`);for(let n=0;n<e.length;n++)await this.parseWorkspace(e[n],async(e,n)=>{let r=F(n),i=zi(r);if(e==w.Config)t.push(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`)));else if(e.endsWith(w.Base)){let e=d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`));await this.registerFile(e)}});fa.send(`$(loading~spin) Aventus : Register config`),this.loadingInProgress=!1;for(let e of t)await this.registerFile(e);fa.sendDone()}async onShutdown(){for(let e in this.files)await this.files[e].triggerDelete(),delete this.files[e],pa.getInstance().unwatch(e)}async fileExists(e){return this.files[e.uri]?!0:e.uri.endsWith(w.Template)?(await this.registerFile(e),this.onSave(e),!0):!1}async registerFilePackage(e){let t=I(e),n=``;(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`));let r=d.TextDocument.create(e,C.Package,0,n);return pa.getInstance().watch(e),await this.registerFile(r)}async registerFile(e){return $.debug(`registering `+e.uri),this.files[e.uri]?await this.files[e.uri].triggerContentChange(e):await this.triggerOnNewFile(e),$.isIDE||pa.getInstance().watch(e.uri),this.files[e.uri]}async onContentChange(e){this.files[e.uri]?await this.files[e.uri].triggerContentChange(e):await this.triggerOnNewFile(e)}async onSave(e){this.files[e.uri]?await this.files[e.uri].triggerSave():await this.triggerOnNewFile(e)}async onClose(e){(0,u.existsSync)(I(e.uri))||this.onDeletedUri(e.uri)}async onCompletion(e,t){return await this.fileExists(e)?this.files[e.uri].getCompletion(t):{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){return await this.fileExists(e)?this.files[e.uri].getCompletionResolve(t):t}async onHover(e,t){return await this.fileExists(e)?this.files[e.uri].getHover(t):null}async onDefinition(e,t){return await this.fileExists(e)?this.files[e.uri].getDefinition(t):null}async onFormatting(e,t){return await this.fileExists(e)?this.files[e.uri].getFormatting(t):[]}async onCodeAction(e,t){return await this.fileExists(e)?this.files[e.uri].getCodeAction(t):[]}async onReferences(e,t){return await this.fileExists(e)?this.files[e.uri].getReferences(t):[]}async onCodeLens(e){return await this.fileExists(e)?this.files[e.uri].getCodeLens():[]}async onRename(e,t,n){return await this.fileExists(e)?this.files[e.uri].getRename(t,n):null}getBuild(e){return this.files[e.uri]?this.files[e.uri].getBuild():[]}onNewFileCb={};async triggerOnNewFile(e){if($.debug(`triggerOnNewFile `+e.uri),this.loadingInProgress&&e.uri.endsWith(w.Config))return;this.files[e.uri]=new E(e);let t=[];for(let n in this.onNewFileCb)t.push(this.onNewFileCb[n](this.files[e.uri]));await Promise.all(t)}onNewFile(e){let t=T();for(;this.onNewFileCb[t]!=null;)t=T();return this.onNewFileCb[t]=e,t}removeOnNewFile(e){delete this.onNewFileCb[e]}onFileRemoveCb={};async triggerOnFileRemove(e){$.debug(`triggerOnFileRemove `+e);let t=[];for(let n in this.onFileRemoveCb)t.push(this.onFileRemoveCb[n](e));await Promise.all(t)}onFileRemove(e){let t=T();for(;this.onNewFileCb[t]!=null;)t=T();return this.onFileRemoveCb[t]=e,t}removeOnFileRemove(e){delete this.onFileRemoveCb[e]}getFilesMatching(e){let t=[];for(let n in this.files)this.files[n].path.match(e)&&t.push(this.files[n]);return t}getFilesWithExtension(e){Array.isArray(e)||(e=[e]);let t=[];for(let n in this.files)for(let r of e)this.files[n].path.endsWith(r)&&t.push(this.files[n]);return t}getByPath(e){return this.files[F(e)]}getByUri(e){return this.files[e]}getUris(){return Object.keys(this.files)}},ma=class e{static tc(e,t){if(typeof e!=t)throw TypeError(`required type ${t} got ${typeof e}`);return e}static ic(e,t){if(!(e instanceof t))throw TypeError(`required type ${t} got ${typeof e}`);return e}static nc(e){return isNaN(e)?0:e}static oc(e){return{angle:e&&e.angle?e.angle:15,results:e&&e.results?e.results:3}}static clmp(e,t,n){return n!==void 0&&e<n?n:e>t?t:e}static shift(e,t){for(e+=t;e>=360;)e-=360;for(;e<0;)e+=360;return e}#e;#t;#n;alpha;static Colors=class{static get BLACK(){return e.fromHex(`#000000`)}static get SILVER(){return e.fromHex(`#c0c0c0`)}static get GRAY(){return e.fromHex(`#808080`)}static get WHITE(){return e.fromHex(`#ffffff`)}static get MAROON(){return e.fromHex(`#800000`)}static get RED(){return e.fromHex(`#ff0000`)}static get PURPLE(){return e.fromHex(`#800080`)}static get GREEN(){return e.fromHex(`#008000`)}static get LIME(){return e.fromHex(`#00ff00`)}static get OLIVE(){return e.fromHex(`#808000`)}static get YELLOW(){return e.fromHex(`#ffff00`)}static get NAVY(){return e.fromHex(`#000080`)}static get BLUE(){return e.fromHex(`#0000ff`)}static get TEAL(){return e.fromHex(`#008080`)}static get AQUA(){return e.fromHex(`#00ffff`)}static get ORANGE(){return e.fromHex(`#ffa500`)}static get ALICEBLUE(){return e.fromHex(`#f0f8ff`)}static get ANTIQUEWHITE(){return e.fromHex(`#faebd7`)}static get AQUAMARINE(){return e.fromHex(`#7fffd4`)}static get AZURE(){return e.fromHex(`#f0ffff`)}static get BEIGE(){return e.fromHex(`#f5f5dc`)}static get BISQUE(){return e.fromHex(`#ffe4c4`)}static get BLANCHEDALMOND(){return e.fromHex(`#ffebcd`)}static get BLUEVIOLET(){return e.fromHex(`#8a2be2`)}static get BROWN(){return e.fromHex(`#a52a2a`)}static get BURLYWOOD(){return e.fromHex(`#deb887`)}static get CADETBLUE(){return e.fromHex(`#5f9ea0`)}static get CHARTREUSE(){return e.fromHex(`#7fff00`)}static get CHOCOLATE(){return e.fromHex(`#d2691e`)}static get CORAL(){return e.fromHex(`#ff7f50`)}static get CORNFLOWERBLUE(){return e.fromHex(`#6495ed`)}static get CORNSILK(){return e.fromHex(`#fff8dc`)}static get CRIMSON(){return e.fromHex(`#dc143c`)}static get CYAN(){return e.fromHex(`#00ffff`)}static get DARKBLUE(){return e.fromHex(`#00008b`)}static get DARKCYAN(){return e.fromHex(`#008b8b`)}static get DARKGOLDENROD(){return e.fromHex(`#b8860b`)}static get DARKGRAY(){return e.fromHex(`#a9a9a9`)}static get DARKGREEN(){return e.fromHex(`#006400`)}static get DARKGREY(){return e.fromHex(`#a9a9a9`)}static get DARKKHAKI(){return e.fromHex(`#bdb76b`)}static get DARKMAGENTA(){return e.fromHex(`#8b008b`)}static get DARKOLIVEGREEN(){return e.fromHex(`#556b2f`)}static get DARKORANGE(){return e.fromHex(`#ff8c00`)}static get DARKORCHID(){return e.fromHex(`#9932cc`)}static get DARKRED(){return e.fromHex(`#8b0000`)}static get DARKSALMON(){return e.fromHex(`#e9967a`)}static get DARKSEAGREEN(){return e.fromHex(`#8fbc8f`)}static get DARKSLATEBLUE(){return e.fromHex(`#483d8b`)}static get DARKSLATEGRAY(){return e.fromHex(`#2f4f4f`)}static get DARKSLATEGREY(){return e.fromHex(`#2f4f4f`)}static get DARKTURQUOISE(){return e.fromHex(`#00ced1`)}static get DARKVIOLET(){return e.fromHex(`#9400d3`)}static get DEEPPINK(){return e.fromHex(`#ff1493`)}static get DEEPSKYBLUE(){return e.fromHex(`#00bfff`)}static get DIMGRAY(){return e.fromHex(`#696969`)}static get DIMGREY(){return e.fromHex(`#696969`)}static get DODGERBLUE(){return e.fromHex(`#1e90ff`)}static get FIREBRICK(){return e.fromHex(`#b22222`)}static get FLORALWHITE(){return e.fromHex(`#fffaf0`)}static get FORESTGREEN(){return e.fromHex(`#228b22`)}static get GAINSBORO(){return e.fromHex(`#dcdcdc`)}static get GHOSTWHITE(){return e.fromHex(`#f8f8ff`)}static get GOLD(){return e.fromHex(`#ffd700`)}static get GOLDENROD(){return e.fromHex(`#daa520`)}static get GREENYELLOW(){return e.fromHex(`#adff2f`)}static get GREY(){return e.fromHex(`#808080`)}static get HONEYDEW(){return e.fromHex(`#f0fff0`)}static get HOTPINK(){return e.fromHex(`#ff69b4`)}static get INDIANRED(){return e.fromHex(`#cd5c5c`)}static get INDIGO(){return e.fromHex(`#4b0082`)}static get IVORY(){return e.fromHex(`#fffff0`)}static get KHAKI(){return e.fromHex(`#f0e68c`)}static get LAVENDER(){return e.fromHex(`#e6e6fa`)}static get LAVENDERBLUSH(){return e.fromHex(`#fff0f5`)}static get LAWNGREEN(){return e.fromHex(`#7cfc00`)}static get LEMONCHIFFON(){return e.fromHex(`#fffacd`)}static get LIGHTBLUE(){return e.fromHex(`#add8e6`)}static get LIGHTCORAL(){return e.fromHex(`#f08080`)}static get LIGHTCYAN(){return e.fromHex(`#e0ffff`)}static get LIGHTGOLDENRODYELLOW(){return e.fromHex(`#fafad2`)}static get LIGHTGRAY(){return e.fromHex(`#d3d3d3`)}static get LIGHTGREEN(){return e.fromHex(`#90ee90`)}static get LIGHTGREY(){return e.fromHex(`#d3d3d3`)}static get LIGHTPINK(){return e.fromHex(`#ffb6c1`)}static get LIGHTSALMON(){return e.fromHex(`#ffa07a`)}static get LIGHTSEAGREEN(){return e.fromHex(`#20b2aa`)}static get LIGHTSKYBLUE(){return e.fromHex(`#87cefa`)}static get LIGHTSLATEGRAY(){return e.fromHex(`#778899`)}static get LIGHTSLATEGREY(){return e.fromHex(`#778899`)}static get LIGHTSTEELBLUE(){return e.fromHex(`#b0c4de`)}static get LIGHTYELLOW(){return e.fromHex(`#ffffe0`)}static get LIMEGREEN(){return e.fromHex(`#32cd32`)}static get LINEN(){return e.fromHex(`#faf0e6`)}static get MAGENTA(){return e.fromHex(`#ff00ff`)}static get FUCHSIA(){return e.fromHex(`#ff00ff`)}static get MEDIUMAQUAMARINE(){return e.fromHex(`#66cdaa`)}static get MEDIUMBLUE(){return e.fromHex(`#0000cd`)}static get MEDIUMORCHID(){return e.fromHex(`#ba55d3`)}static get MEDIUMPURPLE(){return e.fromHex(`#9370db`)}static get MEDIUMSEAGREEN(){return e.fromHex(`#3cb371`)}static get MEDIUMSLATEBLUE(){return e.fromHex(`#7b68ee`)}static get MEDIUMSPRINGGREEN(){return e.fromHex(`#00fa9a`)}static get MEDIUMTURQUOISE(){return e.fromHex(`#48d1cc`)}static get MEDIUMVIOLETRED(){return e.fromHex(`#c71585`)}static get MIDNIGHTBLUE(){return e.fromHex(`#191970`)}static get MINTCREAM(){return e.fromHex(`#f5fffa`)}static get MISTYROSE(){return e.fromHex(`#ffe4e1`)}static get MOCCASIN(){return e.fromHex(`#ffe4b5`)}static get NAVAJOWHITE(){return e.fromHex(`#ffdead`)}static get OLDLACE(){return e.fromHex(`#fdf5e6`)}static get OLIVEDRAB(){return e.fromHex(`#6b8e23`)}static get ORANGERED(){return e.fromHex(`#ff4500`)}static get ORCHID(){return e.fromHex(`#da70d6`)}static get PALEGOLDENROD(){return e.fromHex(`#eee8aa`)}static get PALEGREEN(){return e.fromHex(`#98fb98`)}static get PALETURQUOISE(){return e.fromHex(`#afeeee`)}static get PALEVIOLETRED(){return e.fromHex(`#db7093`)}static get PAPAYAWHIP(){return e.fromHex(`#ffefd5`)}static get PEACHPUFF(){return e.fromHex(`#ffdab9`)}static get PERU(){return e.fromHex(`#cd853f`)}static get PINK(){return e.fromHex(`#ffc0cb`)}static get PLUM(){return e.fromHex(`#dda0dd`)}static get POWDERBLUE(){return e.fromHex(`#b0e0e6`)}static get ROSYBROWN(){return e.fromHex(`#bc8f8f`)}static get ROYALBLUE(){return e.fromHex(`#4169e1`)}static get SADDLEBROWN(){return e.fromHex(`#8b4513`)}static get SALMON(){return e.fromHex(`#fa8072`)}static get SANDYBROWN(){return e.fromHex(`#f4a460`)}static get SEAGREEN(){return e.fromHex(`#2e8b57`)}static get SEASHELL(){return e.fromHex(`#fff5ee`)}static get SIENNA(){return e.fromHex(`#a0522d`)}static get SKYBLUE(){return e.fromHex(`#87ceeb`)}static get SLATEBLUE(){return e.fromHex(`#6a5acd`)}static get SLATEGRAY(){return e.fromHex(`#708090`)}static get SLATEGREY(){return e.fromHex(`#708090`)}static get SNOW(){return e.fromHex(`#fffafa`)}static get SPRINGGREEN(){return e.fromHex(`#00ff7f`)}static get STEELBLUE(){return e.fromHex(`#4682b4`)}static get TAN(){return e.fromHex(`#d2b48c`)}static get THISTLE(){return e.fromHex(`#d8bfd8`)}static get TOMATO(){return e.fromHex(`#ff6347`)}static get TURQUOISE(){return e.fromHex(`#40e0d0`)}static get VIOLET(){return e.fromHex(`#ee82ee`)}static get WHEAT(){return e.fromHex(`#f5deb3`)}static get WHITESMOKE(){return e.fromHex(`#f5f5f5`)}static get YELLOWGREEN(){return e.fromHex(`#9acd32`)}static get REBECCAPURPLE(){return e.fromHex(`#663399`)}};getScheme(t,n){return e.createScheme(this,t,n)}static getScheme(t,n,r){return e.createScheme(t,n,r)}static monochromatic(t,n){this.ic(t,e);let r=this.oc(n).results||3,i=e.toHsv(t),a=i.h,o=i.s,s=i.v/100,c=[],l=1/r;for(;r--;)c.push(e.fromHsv(a,o,this.clmp(s*100,100,0))),s=(s-l)%1;return c}monochromatic(t){return e.monochromatic(this,t)}static complementary(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l;return e.fromHsl(this.shift(r,180),i,a)}complementary(){return e.complementary(this)}static splitComplementary(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle||15,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180+i),o,s),e.fromHsl(this.shift(a,180-i),o,s)]}splitComplementary(t){return e.splitComplementary(this,t)}static doubleComplementary(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle||15,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180),o,s),e.fromHsl(this.shift(a,i),o,s),e.fromHsl(this.shift(a,180+i),o,s)]}doubleComplementary(t){return e.doubleComplementary(this,t)}static square(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l,o=[t];for(let t=1;t<4;t++)r=this.shift(r,90),o.push(e.fromHsl(r,i,a));return o}square(){return e.square(this)}static tetradic(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180),o,s),e.fromHsl(this.shift(a,180-i),o,s),e.fromHsl(this.shift(a,-i),o,s)]}tetradic(t){return e.tetradic(this,t)}static triadic(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l;return[t,e.fromHsl(this.shift(r,120),i,a),e.fromHsl(this.shift(r,240),i,a)]}triadic(){return e.triadic(this)}static analogous(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,-i),o,s),e.fromHsl(this.shift(a,+i),o,s)]}analogous(t){return e.analogous(this,t)}static createScheme(t,n,r){switch(n.toLowerCase()){case`analogous`:case`analog`:return e.analogous(t,r);case`triadic`:case`triad`:return e.triadic(t);case`tetradic`:case`tetra`:return e.tetradic(t,r);case`monochromatic`:case`monochrome`:case`mono`:return e.monochromatic(t,r);case`complementary`:case`complement`:case`comp`:return e.complementary(t);case`double-complementary`:case`double-complement`:case`double`:return e.doubleComplementary(t,r);case`split-complementary`:case`split-complement`:case`split`:return e.splitComplementary(t,r);case`square`:return e.square(t)}return null}constructor(t,n,r){if(!(0<=t&&t<=255&&0<=n&&n<=255&&0<=r&&r<=255))throw Error(`Color values out of bounds (0 - 255)`);this.#e=e.nc(e.tc(t,`number`)),this.#t=e.nc(e.tc(n,`number`)),this.#n=e.nc(e.tc(r,`number`)),this.alpha=1}static saturate(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=this.clmp(r.s+n,100,0),o=r.l;return e.fromHsl(i,a,o)}saturate(t){return e.saturate(this,t)}static desaturate(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=this.clmp(r.s-n,100,0),o=r.l;return e.fromHsl(i,a,o)}desaturate(t){return e.desaturate(this,t)}static grayscale(t){return e.desaturate(t,100)}grayscale(){return e.greyscale(this)}static greyscale(t){return e.desaturate(t,100)}greyscale(){return e.greyscale(this)}static lighten(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=r.s,o=this.clmp(r.l+n,100,0);return e.fromHsl(i,a,o)}lighten(t){return e.lighten(this,t)}static darken(t,n){return e.lighten(t,-n)}darken(t){return e.darken(this,t)}static brighten(t,n){let r=t.toRgb();return r.r=Math.max(0,Math.min(255,r.r-Math.round(255*-(n/100)))),r.g=Math.max(0,Math.min(255,r.g-Math.round(255*-(n/100)))),r.b=Math.max(0,Math.min(255,r.b-Math.round(255*-(n/100)))),new e(r.r,r.g,r.b)}brighten(t){return e.brighten(this,t)}static shiftHue(t,n){this.ic(t,e),this.tc(n,Number);let{h:r,s:i,l:a}=t.toHsl();return r=this.shift(r,n),e.fromHsl(r,i,a)}shiftHue(t){return e.shiftHue(this,t)}static multiply(t,n){this.ic(t,e),this.ic(n,e);let{r1:r,g1:i,b1:a}=t.toRgb(),{r2:o,g2:s,b2:c}=n.toRgb();return e.fromRgb(r*o/255,i*s/255,a*c/255)}multiply(t){return e.multiply(this,t)}static mix(t,n,r=50){this.ic(t,e),this.ic(t,e),this.tc(r,`number`);let i=t.toRgb(),a=n.toRgb(),o=this.clmp(r,100,0)/100,s=Math.round((a.r-i.r)*o+i.r),c=Math.round((a.g-i.g)*o+i.g),l=Math.round((a.b-i.b)*o+i.b);return e.fromRgb(s,c,l)}mix(t,n){return e.mix(this,t,n)}static lerp(t,n,r=.5){this.tc(r,`number`),this.ic(t,e),this.ic(n,e),r=this.clmp(r,1,0);let i=t.toRgb(),a=n.toRgb(),o=i.r/255,s=i.g/255,c=i.b/255,l=a.r/255,u=a.g/255,d=a.b/255;return e.fromRgb((o+(l-o)*r)*255,(s+(u-s)*r)*255,(c+(d-c)*r)*255)}lerp(t,n){return e.lerp(this,t,n)}static add(t,n){this.ic(t,e),this.ic(n,e);let r=t.toRgb(),i=n.toRgb(),a=r.r,o=r.g,s=r.b,c=i.r,l=i.g,u=i.b;return e.fromRgb(Math.round((a+c)/2),Math.round((o+l)/2),Math.round((s+u)/2))}add(t){return e.add(this,t)}static fromHex(t){if(!t.match(/^#?(?:[0-9a-fA-F]{3}){1,2}$/i))throw Error(`Invalid Hex code: "`+t+`"`);let n=`0x00`,r=`0x00`,i=`0x00`;return t.length==4?(n=`0x`+t[1]+t[1],r=`0x`+t[2]+t[2],i=`0x`+t[3]+t[3]):t.length==3?(n=`0x`+t[0]+t[0],r=`0x`+t[1]+t[1],i=`0x`+t[2]+t[2]):t.length==7?(n=`0x`+t[1]+t[2],r=`0x`+t[3]+t[4],i=`0x`+t[5]+t[6]):t.length==6&&(n=`0x`+t[0]+t[1],r=`0x`+t[2]+t[3],i=`0x`+t[4]+t[5]),new e(parseInt(n,16),parseInt(r,16),parseInt(i,16))}static fromRgb(t,n,r){return new e(t,n,r)}static fromHsl(t,n,r){if(t=this.tc(t,`number`),n=this.tc(n,`number`),r=this.tc(r,`number`),!(0<=t&&t<=360))throw Error(`HSL color values out of range, hue (0 - 360)`);if(!(0<=n&&n<=100))throw Error(`HSL color values out of range, sat (0 - 100)`);if(!(0<=r&&r<=100))throw Error(`HSL color values out of range, lum (0 - 100)`);n/=100,r/=100;let i=(1-Math.abs(2*r-1))*n,a=i*(1-Math.abs(t/60%2-1)),o=r-i/2,s=0,c=0,l=0;return 0<=t&&t<60?(s=i,c=a,l=0):60<=t&&t<120?(s=a,c=i,l=0):120<=t&&t<180?(s=0,c=i,l=a):180<=t&&t<240?(s=0,c=a,l=i):240<=t&&t<300?(s=a,c=0,l=i):300<=t&&t<=360&&(s=i,c=0,l=a),new e(Math.round((s+o)*255),Math.round((c+o)*255),Math.round((l+o)*255))}static fromHsv(t,n,r){if(t=this.tc(t,`number`),n=this.tc(n,`number`),r=this.tc(r,`number`),!(0<=t&&t<=360))throw Error(`HSL color values out of range, hue (0 - 360)`);if(!(0<=n&&n<=100))throw Error(`HSL color values out of range, sat (0 - 100)`);if(!(0<=r&&r<=100))throw Error(`HSL color values out of range, lum (0 - 100)`);n/=100,r/=100;let i=r*n,a=i*(1-Math.abs(t/60%2-1)),o=r-i,s=0,c=0,l=0;return 0<=t&&t<60?(s=i,c=a,l=0):60<=t&&t<120?(s=a,c=i,l=0):120<=t&&t<180?(s=0,c=i,l=a):180<=t&&t<240?(s=0,c=a,l=i):240<=t&&t<300?(s=a,c=0,l=i):300<=t&&t<=360&&(s=i,c=0,l=a),new e((s+o)*255,(c+o)*255,(l+o)*255)}static fromCssString(t){this.tc(t,`string`);var n=document.createElement(`canvas`).getContext(`2d`);let r;if(n&&(n.fillStyle=t,r=n.fillStyle),!r)throw Error(`Invalid Color string`);return e.fromHex(r)}static fromName(e){e=this.tc(e,`string`);let t=this.Colors[e.toUpperCase()];if(!t)throw Error(`Invalid Color name`);return t}static toHex(t){t=this.ic(t,e);let n=Math.round(t.#e).toString(16),r=Math.round(t.#t).toString(16),i=Math.round(t.#n).toString(16);return n.length==1&&(n=`0`+n),r.length==1&&(r=`0`+r),i.length==1&&(i=`0`+i),`#`+n+r+i}static toHsl(t){t=this.ic(t,e);let n=0,r=0,i=0,a=t.#e/255,o=t.#t/255,s=t.#n/255,c=Math.min(Math.min(a,o),s),l=Math.max(Math.max(a,o),s),u=l-c;return n=u===0?0:l===a?(o-s)/u%6:l===o?(s-a)/u+2:(a-o)/u+4,n=Math.round(n*60),n<0&&(n+=360),i=(l+c)/2,r=u===0?0:u/(1-Math.abs(2*i-1)),r=parseFloat(Math.abs(r*100)+``),i=parseFloat(Math.abs(i*100)+``),{h:this.nc(n),s:this.nc(r),l:this.nc(i)}}static toHsv(e){let t=0,n=0,r=0,i=e.#e/255,a=e.#t/255,o=e.#n/255,s=Math.min(Math.min(i,a),o),c=Math.max(Math.max(i,a),o),l=c-s;return t=l===0?0:c===i?(a-o)/l%6:c===a?(o-i)/l+2:(i-a)/l+4,t=Math.round(t*60),t<0&&(t+=360),c!==0&&(n=l/c*100),r=c*100,{h:this.nc(t),s:this.nc(n),v:this.nc(r)}}static toRgb(t){return this.ic(t,e),{r:t.#e,g:t.#t,b:t.#n}}static toCmyk(t){this.ic(t,e);let{r:n,g:r,b:i}=t.toRgb(),a=1-n/255,o=1-r/255,s=1-i/255,c=Math.min(a,Math.min(o,s));return a=(a-c)/(1-c),o=(o-c)/(1-c),s=(s-c)/(1-c),a=this.nc(Math.round(a*1e4)/100),o=this.nc(Math.round(o*1e4)/100),s=this.nc(Math.round(s*1e4)/100),c=this.nc(Math.round(c*1e4)/100),{c:a,m:o,y:s,k:c}}toHsl(){return e.toHsl(this)}toHsv(){return e.toHsv(this)}toHex(){return e.toHex(this)}toRgb(){return e.toRgb(this)}toCmyk(){return e.toCmyk(this)}static random(){return new e(Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255))}toString(t=`hex`){e.tc(t,`string`);let n=this.toRgb(),r=this.toHsl();switch(t.toLowerCase()){case`hex`:return this.toHex();case`hexa`:let e=Math.round(this.alpha*255).toString(16);return e.length===1&&(e=`0`+e),this.toHex()+e;case`rgb`:return`rgb(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)})`;case`rgba`:return`rgba(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)}, ${this.alpha})`;case`hsl`:return`hsl(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(r.l)}%)`;case`hsla`:return`hsla(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(r.l)}%, ${this.alpha})`;case`hsv`:let t=this.toHsv();return`hsv(${Math.round(t.h)}, ${Math.round(t.s)}%, ${Math.round(t.v)}%)`;case`cmyk`:let i=this.toCmyk();return`cmyk(${Math.round(i.c)}%, ${Math.round(i.m)}%, ${Math.round(i.y)}%, ${Math.round(i.k)}%)`;default:}return``}valueOf(){return parseInt(`0x`+this.toHex().slice(1))}},ha=class extends Error{sourceStart;sourceEnd;parserState;constructor(e,t,n,r){super(e),this.name=`ParseError`,this.sourceStart=t,this.sourceEnd=n,this.parserState=r}},ga=class extends ha{token;constructor(e,t,n,r,i){super(e,t,n,r),this.token=i}};const _a={UnexpectedNewLineInString:`Unexpected newline while consuming a string token.`,UnexpectedEOFInString:`Unexpected EOF while consuming a string token.`,UnexpectedEOFInComment:`Unexpected EOF while consuming a comment.`,UnexpectedEOFInURL:`Unexpected EOF while consuming a url token.`,UnexpectedEOFInEscapedCodePoint:`Unexpected EOF while consuming an escaped code point.`,UnexpectedCharacterInURL:`Unexpected character while consuming a url token.`,InvalidEscapeSequenceInURL:`Invalid escape sequence while consuming a url token.`,InvalidEscapeSequenceAfterBackslash:`Invalid escape sequence after "\\"`};typeof globalThis<`u`&&`structuredClone`in globalThis;function va(...e){let t=``;for(let n=0;n<e.length;n++)t+=e[n][1];return t}const ya=65533;function ba(e){return e.source.codePointAt(e.cursor)===60&&e.source.codePointAt(e.cursor+1)===33&&e.source.codePointAt(e.cursor+2)===45&&e.source.codePointAt(e.cursor+3)===45}function xa(e){return e>=48&&e<=57}function Sa(e){return e>=65&&e<=90}function Ca(e){return e>=97&&e<=122}function wa(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function Ta(e){return Ca(e)||Sa(e)}function Ea(e){return Ta(e)||Oa(e)||e===95}function Da(e){return Ea(e)||xa(e)||e===45}function Oa(e){return e===183||e===8204||e===8205||e===8255||e===8256||e===8204||192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=893||895<=e&&e<=8191||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||63744<=e&&e<=64975||65008<=e&&e<=65533||e===0||!!Ma(e)||e>=65536}function ka(e){return e===11||e===127||0<=e&&e<=8||14<=e&&e<=31}function Aa(e){return e===10||e===13||e===12}function ja(e){return e===32||e===10||e===9||e===13||e===12}function Ma(e){return e>=55296&&e<=57343}function Na(e){return e.source.codePointAt(e.cursor)===92&&!Aa(e.source.codePointAt(e.cursor+1)??-1)}function Pa(e,t){return t.source.codePointAt(t.cursor)===45?t.source.codePointAt(t.cursor+1)===45||!!Ea(t.source.codePointAt(t.cursor+1)??-1)||t.source.codePointAt(t.cursor+1)===92&&!Aa(t.source.codePointAt(t.cursor+2)??-1):!!Ea(t.source.codePointAt(t.cursor)??-1)||Na(t)}function Fa(e){return e.source.codePointAt(e.cursor)===43||e.source.codePointAt(e.cursor)===45?!!xa(e.source.codePointAt(e.cursor+1)??-1)||e.source.codePointAt(e.cursor+1)===46&&xa(e.source.codePointAt(e.cursor+2)??-1):e.source.codePointAt(e.cursor)===46?xa(e.source.codePointAt(e.cursor+1)??-1):xa(e.source.codePointAt(e.cursor)??-1)}function Ia(e){return e.source.codePointAt(e.cursor)===47&&e.source.codePointAt(e.cursor+1)===42}function La(e){return e.source.codePointAt(e.cursor)===45&&e.source.codePointAt(e.cursor+1)===45&&e.source.codePointAt(e.cursor+2)===62}var z,B,Ra;function za(e){switch(e){case z.OpenParen:return z.CloseParen;case z.CloseParen:return z.OpenParen;case z.OpenCurly:return z.CloseCurly;case z.CloseCurly:return z.OpenCurly;case z.OpenSquare:return z.CloseSquare;case z.CloseSquare:return z.OpenSquare;default:return null}}function Ba(e){switch(e[0]){case z.OpenParen:return[z.CloseParen,`)`,-1,-1,void 0];case z.CloseParen:return[z.OpenParen,`(`,-1,-1,void 0];case z.OpenCurly:return[z.CloseCurly,`}`,-1,-1,void 0];case z.CloseCurly:return[z.OpenCurly,`{`,-1,-1,void 0];case z.OpenSquare:return[z.CloseSquare,`]`,-1,-1,void 0];case z.CloseSquare:return[z.OpenSquare,`[`,-1,-1,void 0];default:return null}}function Va(e,t){for(t.advanceCodePoint(2);;){let n=t.readCodePoint();if(n===void 0){let n=[z.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new ga(_a.UnexpectedEOFInComment,t.representationStart,t.representationEnd,[`4.3.2. Consume comments`,`Unexpected EOF`],n)),n}if(n===42&&t.source.codePointAt(t.cursor)!==void 0&&t.source.codePointAt(t.cursor)===47){t.advanceCodePoint();break}}return[z.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0]}function Ha(e,t){let n=t.readCodePoint();if(n===void 0)return e.onParseError(new ha(_a.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,[`4.3.7. Consume an escaped code point`,`Unexpected EOF`])),ya;if(wa(n)){let e=[n],r;for(;(r=t.source.codePointAt(t.cursor))!==void 0&&wa(r)&&e.length<6;)e.push(r),t.advanceCodePoint();ja(t.source.codePointAt(t.cursor)??-1)&&(t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10&&t.advanceCodePoint(),t.advanceCodePoint());let i=parseInt(String.fromCodePoint(...e),16);return i===0||Ma(i)||i>1114111?ya:i}return n===0||Ma(n)?ya:n}function Ua(e,t){let n=[];for(;;){let r=t.source.codePointAt(t.cursor)??-1;if(r===0||Ma(r))n.push(ya),t.advanceCodePoint(+(r>65535)+1);else if(Da(r))n.push(r),t.advanceCodePoint(+(r>65535)+1);else{if(!Na(t))return n;t.advanceCodePoint(),n.push(Ha(e,t))}}}function Wa(e,t){t.advanceCodePoint();let n=t.source.codePointAt(t.cursor);if(n!==void 0&&(Da(n)||Na(t))){let n=Ra.Unrestricted;Pa(0,t)&&(n=Ra.ID);let r=Ua(e,t);return[z.Hash,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...r),type:n}]}return[z.Delim,`#`,t.representationStart,t.representationEnd,{value:`#`}]}function Ga(e,t){let n=B.Integer;for(t.source.codePointAt(t.cursor)!==43&&t.source.codePointAt(t.cursor)!==45||t.advanceCodePoint();xa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===46&&xa(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint(2),n=B.Number;xa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===101||t.source.codePointAt(t.cursor)===69){if(xa(t.source.codePointAt(t.cursor+1)??-1))t.advanceCodePoint(2);else{if(t.source.codePointAt(t.cursor+1)!==45&&t.source.codePointAt(t.cursor+1)!==43||!xa(t.source.codePointAt(t.cursor+2)??-1))return n;t.advanceCodePoint(3)}for(n=B.Number;xa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint()}return n}function Ka(e,t){let n;{let e=t.source.codePointAt(t.cursor);e===45?n=`-`:e===43&&(n=`+`)}let r=Ga(0,t),i=parseFloat(t.source.slice(t.representationStart,t.representationEnd+1));if(Pa(0,t)){let a=Ua(e,t);return[z.Dimension,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n,type:r,unit:String.fromCodePoint(...a)}]}return t.source.codePointAt(t.cursor)===37?(t.advanceCodePoint(),[z.Percentage,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n}]):[z.Number,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n,type:r}]}function qa(e){for(;ja(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return[z.Whitespace,e.source.slice(e.representationStart,e.representationEnd+1),e.representationStart,e.representationEnd,void 0]}(function(e){e.Comment=`comment`,e.AtKeyword=`at-keyword-token`,e.BadString=`bad-string-token`,e.BadURL=`bad-url-token`,e.CDC=`CDC-token`,e.CDO=`CDO-token`,e.Colon=`colon-token`,e.Comma=`comma-token`,e.Delim=`delim-token`,e.Dimension=`dimension-token`,e.EOF=`EOF-token`,e.Function=`function-token`,e.Hash=`hash-token`,e.Ident=`ident-token`,e.Number=`number-token`,e.Percentage=`percentage-token`,e.Semicolon=`semicolon-token`,e.String=`string-token`,e.URL=`url-token`,e.Whitespace=`whitespace-token`,e.OpenParen=`(-token`,e.CloseParen=`)-token`,e.OpenSquare=`[-token`,e.CloseSquare=`]-token`,e.OpenCurly=`{-token`,e.CloseCurly=`}-token`,e.UnicodeRange=`unicode-range-token`})(z||={}),function(e){e.Integer=`integer`,e.Number=`number`}(B||={}),function(e){e.Unrestricted=`unrestricted`,e.ID=`id`}(Ra||={});var Ja=class{cursor=0;source=``;representationStart=0;representationEnd=-1;constructor(e){this.source=e}advanceCodePoint(e=1){this.cursor+=e,this.representationEnd=this.cursor-1}readCodePoint(){let e=this.source.codePointAt(this.cursor);if(e!==void 0)return this.cursor+=1,this.representationEnd=this.cursor-1,e}unreadCodePoint(e=1){this.cursor-=e,this.representationEnd=this.cursor-1}resetRepresentation(){this.representationStart=this.cursor,this.representationEnd=-1}};function Ya(e,t){let n=``,r=t.readCodePoint();for(;;){let i=t.readCodePoint();if(i===void 0){let r=[z.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new ga(_a.UnexpectedEOFInString,t.representationStart,t.representationEnd,[`4.3.5. Consume a string token`,`Unexpected EOF`],r)),r}if(Aa(i)){t.unreadCodePoint();let n=[z.BadString,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new ga(_a.UnexpectedNewLineInString,t.representationStart,t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10?t.representationEnd+2:t.representationEnd+1,[`4.3.5. Consume a string token`,`Unexpected newline`],n)),n}if(i===r)return[z.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(i!==92)i===0||Ma(i)?n+=String.fromCodePoint(ya):n+=String.fromCodePoint(i);else{if(t.source.codePointAt(t.cursor)===void 0)continue;if(Aa(t.source.codePointAt(t.cursor)??-1)){t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10&&t.advanceCodePoint(),t.advanceCodePoint();continue}n+=String.fromCodePoint(Ha(e,t))}}}function Xa(e){return!(e.length!==3||e[0]!==117&&e[0]!==85||e[1]!==114&&e[1]!==82||e[2]!==108&&e[2]!==76)}function Za(e,t){for(;;){let n=t.source.codePointAt(t.cursor);if(n===void 0)return;if(n===41)return void t.advanceCodePoint();Na(t)?(t.advanceCodePoint(),Ha(e,t)):t.advanceCodePoint()}}function Qa(e,t){for(;ja(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();let n=``;for(;;){if(t.source.codePointAt(t.cursor)===void 0){let r=[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new ga(_a.UnexpectedEOFInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Unexpected EOF`],r)),r}if(t.source.codePointAt(t.cursor)===41)return t.advanceCodePoint(),[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(ja(t.source.codePointAt(t.cursor)??-1)){for(t.advanceCodePoint();ja(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===void 0){let r=[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new ga(_a.UnexpectedEOFInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Consume as much whitespace as possible`,`Unexpected EOF`],r)),r}return t.source.codePointAt(t.cursor)===41?(t.advanceCodePoint(),[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}]):(Za(e,t),[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0])}let r=t.source.codePointAt(t.cursor);if(r===34||r===39||r===40||ka(r??-1)){Za(e,t);let n=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new ga(_a.UnexpectedCharacterInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Unexpected U+0022 QUOTATION MARK ("), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point`],n)),n}if(r===92){if(Na(t)){t.advanceCodePoint(),n+=String.fromCodePoint(Ha(e,t));continue}Za(e,t);let r=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new ga(_a.InvalidEscapeSequenceInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`U+005C REVERSE SOLIDUS (\\)`,`The input stream does not start with a valid escape sequence`],r)),r}t.source.codePointAt(t.cursor)===0||Ma(t.source.codePointAt(t.cursor)??-1)?(n+=String.fromCodePoint(ya),t.advanceCodePoint()):(n+=t.source[t.cursor],t.advanceCodePoint())}}function $a(e,t){let n=Ua(e,t);if(t.source.codePointAt(t.cursor)!==40)return[z.Ident,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];if(Xa(n)){t.advanceCodePoint();let r=0;for(;;){let e=ja(t.source.codePointAt(t.cursor)??-1),i=ja(t.source.codePointAt(t.cursor+1)??-1);if(e&&i){r+=1,t.advanceCodePoint(1);continue}let a=e?t.source.codePointAt(t.cursor+1):t.source.codePointAt(t.cursor);if(a===34||a===39)return r>0&&t.unreadCodePoint(r),[z.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];break}return Qa(e,t)}return t.advanceCodePoint(),[z.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}]}function eo(e){return!(e.source.codePointAt(e.cursor)!==117&&e.source.codePointAt(e.cursor)!==85||e.source.codePointAt(e.cursor+1)!==43||e.source.codePointAt(e.cursor+2)!==63&&!wa(e.source.codePointAt(e.cursor+2)??-1))}function to(e,t){t.advanceCodePoint(2);let n=[],r=[],i;for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&wa(i);)n.push(i),t.advanceCodePoint();for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&i===63;)r.length===0&&r.push(...n),n.push(48),r.push(70),t.advanceCodePoint();if(!r.length&&t.source.codePointAt(t.cursor)===45&&wa(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint();(i=t.source.codePointAt(t.cursor))!==void 0&&r.length<6&&wa(i);)r.push(i),t.advanceCodePoint();if(!r.length){let e=parseInt(String.fromCodePoint(...n),16);return[z.UnicodeRange,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{startOfRange:e,endOfRange:e}]}let a=parseInt(String.fromCodePoint(...n),16),o=parseInt(String.fromCodePoint(...r),16);return[z.UnicodeRange,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{startOfRange:a,endOfRange:o}]}function no(e,t){let n=ro(e,t),r=[];for(;!n.endOfFile();)r.push(n.nextToken());return r.push(n.nextToken()),r}function ro(e,t){let n=e.css.valueOf(),r=e.unicodeRangesAllowed??!1,i=new Ja(n),a={onParseError:t?.onParseError??io};return{nextToken:function(){i.resetRepresentation();let e=i.source.codePointAt(i.cursor);if(e===void 0)return[z.EOF,``,-1,-1,void 0];if(e===47&&Ia(i))return Va(a,i);if(r&&(e===117||e===85)&&eo(i))return to(0,i);if(Ea(e))return $a(a,i);if(xa(e))return Ka(a,i);switch(e){case 44:return i.advanceCodePoint(),[z.Comma,`,`,i.representationStart,i.representationEnd,void 0];case 58:return i.advanceCodePoint(),[z.Colon,`:`,i.representationStart,i.representationEnd,void 0];case 59:return i.advanceCodePoint(),[z.Semicolon,`;`,i.representationStart,i.representationEnd,void 0];case 40:return i.advanceCodePoint(),[z.OpenParen,`(`,i.representationStart,i.representationEnd,void 0];case 41:return i.advanceCodePoint(),[z.CloseParen,`)`,i.representationStart,i.representationEnd,void 0];case 91:return i.advanceCodePoint(),[z.OpenSquare,`[`,i.representationStart,i.representationEnd,void 0];case 93:return i.advanceCodePoint(),[z.CloseSquare,`]`,i.representationStart,i.representationEnd,void 0];case 123:return i.advanceCodePoint(),[z.OpenCurly,`{`,i.representationStart,i.representationEnd,void 0];case 125:return i.advanceCodePoint(),[z.CloseCurly,`}`,i.representationStart,i.representationEnd,void 0];case 39:case 34:return Ya(a,i);case 35:return Wa(a,i);case 43:case 46:return Fa(i)?Ka(a,i):(i.advanceCodePoint(),[z.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]);case 10:case 13:case 12:case 9:case 32:return qa(i);case 45:return Fa(i)?Ka(a,i):La(i)?(i.advanceCodePoint(3),[z.CDC,`-->`,i.representationStart,i.representationEnd,void 0]):Pa(0,i)?$a(a,i):(i.advanceCodePoint(),[z.Delim,`-`,i.representationStart,i.representationEnd,{value:`-`}]);case 60:return ba(i)?(i.advanceCodePoint(4),[z.CDO,`<!--`,i.representationStart,i.representationEnd,void 0]):(i.advanceCodePoint(),[z.Delim,`<`,i.representationStart,i.representationEnd,{value:`<`}]);case 64:if(i.advanceCodePoint(),Pa(0,i)){let e=Ua(a,i);return[z.AtKeyword,i.source.slice(i.representationStart,i.representationEnd+1),i.representationStart,i.representationEnd,{value:String.fromCodePoint(...e)}]}return[z.Delim,`@`,i.representationStart,i.representationEnd,{value:`@`}];case 92:{if(Na(i))return $a(a,i);i.advanceCodePoint();let e=[z.Delim,`\\`,i.representationStart,i.representationEnd,{value:`\\`}];return a.onParseError(new ga(_a.InvalidEscapeSequenceAfterBackslash,i.representationStart,i.representationEnd,[`4.3.1. Consume a token`,`U+005C REVERSE SOLIDUS (\\)`,`The input stream does not start with a valid escape sequence`],e)),e}}return i.advanceCodePoint(),[z.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]},endOfFile:function(){return i.source.codePointAt(i.cursor)===void 0}}}function io(){}function ao(e,t){let n=[];for(let e of t)n.push(e.codePointAt(0));let r=oo(n);r[0]===101&&co(r,0,r[0]);let i=String.fromCodePoint(...r);e[1]=`${e[4].signCharacter===`+`?e[4].signCharacter:``}${e[4].value.toString()}${i}`,e[4].unit=t}function oo(e){let t=0;if(e[0]===0)e.splice(0,1,ya),t=1;else if(e[0]===45&&e[1]===45)t=2;else if(e[0]===45&&e[1])t=2,Ea(e[1])||(t+=co(e,1,e[1]));else{if(e[0]===45&&!e[1])return[92,e[0]];Ea(e[0])?t=1:(t=1,t+=co(e,0,e[0]))}for(let n=t;n<e.length;n++)e[n]===0?(e.splice(n,1,ya),n++):Da(e[n])||(n+=so(e,n,e[n]));return e}function so(e,t,n){return e.splice(t,1,92,n),1}function co(e,t,n){let r=n.toString(16),i=[];for(let e of r)i.push(e.codePointAt(0));return e.splice(t,1,92,...i,32),1+i.length}const lo=Object.values(z);function uo(e){return!!Array.isArray(e)&&!(e.length<4)&&!!lo.includes(e[0])&&typeof e[1]==`string`&&typeof e[2]==`number`&&typeof e[3]==`number`}function V(e){if(!e)return!1;switch(e[0]){case z.Dimension:case z.Number:case z.Percentage:return!0;default:return!1}}function fo(e){if(!e)return!1;switch(e[0]){case z.Whitespace:case z.Comment:return!0;default:return!1}}function po(e){return!!e&&e[0]===z.Colon}function mo(e){return!!e&&e[0]===z.Comma}function ho(e){return!!e&&e[0]===z.Comment}function go(e){return!!e&&e[0]===z.Delim}function H(e){return!!e&&e[0]===z.Dimension}function _o(e){return!!e&&e[0]===z.EOF}function vo(e){return!!e&&e[0]===z.Function}function yo(e){return!!e&&e[0]===z.Hash}function U(e){return!!e&&e[0]===z.Ident}function W(e){return!!e&&e[0]===z.Number}function G(e){return!!e&&e[0]===z.Percentage}function bo(e){return!!e&&e[0]===z.Semicolon}function xo(e){return!!e&&e[0]===z.Whitespace}function So(e){return!!e&&e[0]===z.OpenParen}function Co(e){return!!e&&e[0]===z.CloseParen}function wo(e){return!!e&&e[0]===z.OpenSquare}function To(e){return!!e&&e[0]===z.OpenCurly}function Eo(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}const Do=[.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124];
725
725
  /**
726
726
  * Bradford chromatic adaptation from D50 to D65
727
727
  *
728
728
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
729
729
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
730
- */function To(e){return Co(wo,e)}const Eo=[1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371];
730
+ */function Oo(e){return Eo(Do,e)}const ko=[1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371];
731
731
  /**
732
732
  * Bradford chromatic adaptation from D65 to D50
733
733
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
734
734
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
735
735
  * @see http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html
736
- */function Do(e){return Co(Eo,e)}
736
+ */function Ao(e){return Eo(ko,e)}
737
737
  /**
738
738
  * @param {number} hue - Hue as degrees 0..360
739
739
  * @param {number} sat - Saturation as percentage 0..100
@@ -743,7 +743,7 @@ namespace `+this.buildConfig.module+`{
743
743
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
744
744
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
745
745
  * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js
746
- */function Oo(e){let t=e[0]%360,n=e[1]/100,r=e[2]/100;return t<0&&(t+=360),[ko(0,t,n,r),ko(8,t,n,r),ko(4,t,n,r)]}function ko(e,t,n,r){let i=(e+t/30)%12;return r-n*Math.min(r,1-r)*Math.max(-1,Math.min(i-3,9-i,1))}
746
+ */function jo(e){let t=e[0]%360,n=e[1]/100,r=e[2]/100;return t<0&&(t+=360),[Mo(0,t,n,r),Mo(8,t,n,r),Mo(4,t,n,r)]}function Mo(e,t,n,r){let i=(e+t/30)%12;return r-n*Math.min(r,1-r)*Math.max(-1,Math.min(i-3,9-i,1))}
747
747
  /**
748
748
  * @param {number} hue - Hue as degrees 0..360
749
749
  * @param {number} white - Whiteness as percentage 0..100
@@ -753,31 +753,31 @@ namespace `+this.buildConfig.module+`{
753
753
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
754
754
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
755
755
  * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js
756
- */function Ao(e){let t=e[0],n=e[1]/100,r=e[2]/100;if(n+r>=1){let e=n/(n+r);return[e,e,e]}let i=Oo([t,100,50]),a=1-n-r;return[i[0]*a+n,i[1]*a+n,i[2]*a+n]}
756
+ */function No(e){let t=e[0],n=e[1]/100,r=e[2]/100;if(n+r>=1){let e=n/(n+r);return[e,e,e]}let i=jo([t,100,50]),a=1-n-r;return[i[0]*a+n,i[1]*a+n,i[2]*a+n]}
757
757
  /**
758
758
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
759
759
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
760
- */function jo(e){let t=e[2]*Math.PI/180;return[e[0],e[1]*Math.cos(t),e[1]*Math.sin(t)]}
760
+ */function Po(e){let t=e[2]*Math.PI/180;return[e[0],e[1]*Math.cos(t),e[1]*Math.sin(t)]}
761
761
  /**
762
762
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
763
763
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
764
- */function Mo(e){let t=Math.sqrt(e[1]**2+e[2]**2),n=180*Math.atan2(e[2],e[1])/Math.PI;return n<0&&(n+=360),t<=.0015&&(n=NaN),[e[0],t,n]}const No=[.3457/.3585,1,.2958/.3585];
764
+ */function Fo(e){let t=Math.sqrt(e[1]**2+e[2]**2),n=180*Math.atan2(e[2],e[1])/Math.PI;return n<0&&(n+=360),t<=.0015&&(n=NaN),[e[0],t,n]}const Io=[.3457/.3585,1,.2958/.3585];
765
765
  /**
766
766
  * Convert Lab to D50-adapted XYZ
767
767
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
768
768
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
769
769
  * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
770
- */function Po(e){let t=24389/27,n=216/24389,r=(e[0]+16)/116,i=e[1]/500+r,a=r-e[2]/200;return[(i**3>n?i**3:(116*i-16)/t)*No[0],(e[0]>8?((e[0]+16)/116)**3:e[0]/t)*No[1],(a**3>n?a**3:(116*a-16)/t)*No[2]]}
770
+ */function Lo(e){let t=24389/27,n=216/24389,r=(e[0]+16)/116,i=e[1]/500+r,a=r-e[2]/200;return[(i**3>n?i**3:(116*i-16)/t)*Io[0],(e[0]>8?((e[0]+16)/116)**3:e[0]/t)*Io[1],(a**3>n?a**3:(116*a-16)/t)*Io[2]]}
771
771
  /**
772
772
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
773
773
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
774
774
  * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
775
- */function Fo(e){let t=e[2]*Math.PI/180;return[e[0],e[1]*Math.cos(t),e[1]*Math.sin(t)]}
775
+ */function Ro(e){let t=e[2]*Math.PI/180;return[e[0],e[1]*Math.cos(t),e[1]*Math.sin(t)]}
776
776
  /**
777
777
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
778
778
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
779
779
  * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
780
- */function Io(e){let t=Math.sqrt(e[1]**2+e[2]**2),n=180*Math.atan2(e[2],e[1])/Math.PI;return n<0&&(n+=360),t<=4e-6&&(n=NaN),[e[0],t,n]}const Lo=[1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],Ro=[1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092];
780
+ */function zo(e){let t=Math.sqrt(e[1]**2+e[2]**2),n=180*Math.atan2(e[2],e[1])/Math.PI;return n<0&&(n+=360),t<=4e-6&&(n=NaN),[e[0],t,n]}const Bo=[1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],Vo=[1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092];
781
781
  /**
782
782
  * Given OKLab, convert to XYZ relative to D65
783
783
  *
@@ -785,14 +785,14 @@ namespace `+this.buildConfig.module+`{
785
785
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
786
786
  * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
787
787
  */
788
- function zo(e){let t=Co(Ro,e);return Co(Lo,[t[0]**3,t[1]**3,t[2]**3])}
788
+ function Ho(e){let t=Eo(Vo,e);return Eo(Bo,[t[0]**3,t[1]**3,t[2]**3])}
789
789
  /**
790
790
  * Assuming XYZ is relative to D50, convert to CIE Lab
791
791
  * from CIE standard, which now defines these as a rational fraction
792
792
  *
793
793
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
794
794
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
795
- */function Bo(e){let t=Vo(e[0]/No[0]),n=Vo(e[1]/No[1]);return[116*n-16,500*(t-n),200*(n-Vo(e[2]/No[2]))]}function Vo(e){return e>.008856451679035631?Math.cbrt(e):(903.2962962962963*e+16)/116}const Ho=[.819022437996703,.3619062600528904,-.1288737815209879,.0329836539323885,.9292868615863434,.0361446663506424,.0481771893596242,.2642395317527308,.6335478284694309],Uo=[.210454268309314,.7936177747023054,-.0040720430116193,1.9779985324311684,-2.42859224204858,.450593709617411,.0259040424655478,.7827717124575296,-.8086757549230774];
795
+ */function Uo(e){let t=Wo(e[0]/Io[0]),n=Wo(e[1]/Io[1]);return[116*n-16,500*(t-n),200*(n-Wo(e[2]/Io[2]))]}function Wo(e){return e>.008856451679035631?Math.cbrt(e):(903.2962962962963*e+16)/116}const Go=[.819022437996703,.3619062600528904,-.1288737815209879,.0329836539323885,.9292868615863434,.0361446663506424,.0481771893596242,.2642395317527308,.6335478284694309],Ko=[.210454268309314,.7936177747023054,-.0040720430116193,1.9779985324311684,-2.42859224204858,.450593709617411,.0259040424655478,.7827717124575296,-.8086757549230774];
796
796
  /**
797
797
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
798
798
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
@@ -800,7 +800,7 @@ function zo(e){let t=Co(Ro,e);return Co(Lo,[t[0]**3,t[1]**3,t[2]**3])}
800
800
  * XYZ <-> LMS matrices recalculated for consistent reference white
801
801
  * @see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484
802
802
  */
803
- function Wo(e){let t=Co(Ho,e);return Co(Uo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math.cbrt(t[2])])}const Go=[30757411/17917100,-6372589/17917100,-4539589/17917100,-.666684351832489,1.616481236634939,467509/29648200,792561/44930125,-1921689/44930125,.942103121235474],Ko=[446124/178915,-333277/357830,-72051/178915,-14852/17905,63121/35810,423/17905,11844/330415,-50337/660830,316169/330415]
803
+ function qo(e){let t=Eo(Go,e);return Eo(Ko,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math.cbrt(t[2])])}const Jo=[30757411/17917100,-6372589/17917100,-4539589/17917100,-.666684351832489,1.616481236634939,467509/29648200,792561/44930125,-1921689/44930125,.942103121235474],Yo=[446124/178915,-333277/357830,-72051/178915,-14852/17905,63121/35810,423/17905,11844/330415,-50337/660830,316169/330415]
804
804
  /**
805
805
  * Convert XYZ to linear-light rec2020
806
806
  *
@@ -813,7 +813,7 @@ function Wo(e){let t=Co(Ho,e);return Co(Uo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
813
813
  *
814
814
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
815
815
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
816
- */function qo(e){return Co(Ko,e)}const Jo=[1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],Yo=[1829569/896150,-506331/896150,-308931/896150,-851781/878810,1648619/878810,36519/878810,16779/1248040,-147721/1248040,1266979/1248040],Xo=[12831/3959,-329/214,-1974/3959,-851781/878810,1648619/878810,36519/878810,705/12673,-2585/12673,705/667]
816
+ */function Xo(e){return Eo(Yo,e)}const Zo=[1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],Qo=[1829569/896150,-506331/896150,-308931/896150,-851781/878810,1648619/878810,36519/878810,16779/1248040,-147721/1248040,1266979/1248040],$o=[12831/3959,-329/214,-1974/3959,-851781/878810,1648619/878810,36519/878810,705/12673,-2585/12673,705/667]
817
817
  /**
818
818
  * Convert D50 XYZ to linear-light prophoto-rgb
819
819
  *
@@ -831,14 +831,14 @@ function Wo(e){let t=Co(Ho,e);return Co(Uo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
831
831
  /**
832
832
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
833
833
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
834
- */function Zo(e){return Co(Xo,e)}
834
+ */function es(e){return Eo($o,e)}
835
835
  /**
836
836
  * Convert an array of linear-light rec2020 RGB in the range 0.0-1.0
837
837
  * to gamma corrected form ITU-R BT.2020-2 p.4
838
838
  *
839
839
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
840
840
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
841
- */function Qo(e){return(e<0?-1:1)*Math.abs(e)**(1/2.4)}
841
+ */function ts(e){return(e<0?-1:1)*Math.abs(e)**(1/2.4)}
842
842
  /**
843
843
  * Convert an array of linear-light sRGB values in the range 0.0-1.0 to gamma corrected form
844
844
  * Extended transfer function:
@@ -848,14 +848,14 @@ function Wo(e){let t=Co(Ho,e);return Co(Uo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
848
848
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
849
849
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
850
850
  * @see https://en.wikipedia.org/wiki/SRGB
851
- */function $o(e){return[es(e[0]),es(e[1]),es(e[2])]}function es(e){let t=e<0?-1:1,n=Math.abs(e);return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e}
851
+ */function ns(e){return[rs(e[0]),rs(e[1]),rs(e[2])]}function rs(e){let t=e<0?-1:1,n=Math.abs(e);return n>.0031308?t*(1.055*n**(1/2.4)-.055):12.92*e}
852
852
  /**
853
853
  * Convert an array of linear-light display-p3 RGB in the range 0.0-1.0
854
854
  * to gamma corrected form
855
855
  *
856
856
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
857
857
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
858
- */function ts(e){return $o(e)}
858
+ */function is(e){return ns(e)}
859
859
  /**
860
860
  * Convert an array of linear-light prophoto-rgb in the range 0.0-1.0
861
861
  * to gamma corrected form.
@@ -864,14 +864,14 @@ function Wo(e){let t=Co(Ho,e);return Co(Uo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
864
864
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
865
865
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
866
866
  */
867
- function ns(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16*e}
867
+ function as(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16*e}
868
868
  /**
869
869
  * Convert an array of linear-light a98-rgb in the range 0.0-1.0
870
870
  * to gamma corrected form. Negative values are also now accepted
871
871
  *
872
872
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
873
873
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
874
- */function rs(e){return(e<0?-1:1)*Math.abs(e)**(256/563)}
874
+ */function os(e){return(e<0?-1:1)*Math.abs(e)**(256/563)}
875
875
  /**
876
876
  * Convert an array of rec2020 RGB values in the range 0.0 - 1.0
877
877
  * to linear light (un-companded) form.
@@ -879,7 +879,7 @@ function ns(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16
879
879
  *
880
880
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
881
881
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
882
- */function is(e){return(e<0?-1:1)*Math.abs(e)**2.4}const as=[63426534/99577255,20160776/139408157,47086771/278816314,26158966/99577255,.677998071518871,8267143/139408157,0,19567812/697040785,1.0609850577107909];
882
+ */function ss(e){return(e<0?-1:1)*Math.abs(e)**2.4}const cs=[63426534/99577255,20160776/139408157,47086771/278816314,26158966/99577255,.677998071518871,8267143/139408157,0,19567812/697040785,1.0609850577107909];
883
883
  /**
884
884
  * Convert an array of linear-light rec2020 values to CIE XYZ
885
885
  * using D65 (no chromatic adaptation)
@@ -899,14 +899,14 @@ function ns(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16
899
899
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
900
900
  * @see https://en.wikipedia.org/wiki/SRGB
901
901
  */
902
- function os(e){return[ss(e[0]),ss(e[1]),ss(e[2])]}function ss(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}
902
+ function ls(e){return[us(e[0]),us(e[1]),us(e[2])]}function us(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}
903
903
  /**
904
904
  * Convert an array of display-p3 RGB values in the range 0.0 - 1.0
905
905
  * to linear light (un-companded) form.
906
906
  *
907
907
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
908
908
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
909
- */function cs(e){return os(e)}const ls=[608311/1250200,189793/714400,198249/1000160,35783/156275,247089/357200,198249/2500400,0,32229/714400,5220557/5000800];
909
+ */function ds(e){return ls(e)}const fs=[608311/1250200,189793/714400,198249/1000160,35783/156275,247089/357200,198249/2500400,0,32229/714400,5220557/5000800];
910
910
  /**
911
911
  * Convert an array of linear-light display-p3 values to CIE XYZ
912
912
  * using D65 (no chromatic adaptation)
@@ -914,7 +914,7 @@ function os(e){return[ss(e[0]),ss(e[1]),ss(e[2])]}function ss(e){let t=e<0?-1:1,
914
914
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
915
915
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
916
916
  * @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
917
- */function us(e){return Co(ls,e)}
917
+ */function ps(e){return Eo(fs,e)}
918
918
  /**
919
919
  * Convert an array of prophoto-rgb values where in-gamut Colors are in the
920
920
  * range [0.0 - 1.0] to linear light (un-companded) form. Transfer curve is
@@ -923,7 +923,7 @@ function os(e){return[ss(e[0]),ss(e[1]),ss(e[2])]}function ss(e){let t=e<0?-1:1,
923
923
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
924
924
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
925
925
  */
926
- function ds(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const fs=[.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602];
926
+ function ms(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const hs=[.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602];
927
927
  /**
928
928
  * Convert an array of linear-light prophoto-rgb values to CIE D50 XYZ.
929
929
  * Matrix cannot be expressed in rational form, but is calculated to 64 bit accuracy.
@@ -931,7 +931,7 @@ function ds(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
931
931
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
932
932
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
933
933
  * @see see https://github.com/w3c/csswg-drafts/issues/7675
934
- */function ps(e){return(e<0?-1:1)*Math.abs(e)**(563/256)}const ms=[573536/994567,263643/1420810,187206/994567,591459/1989134,6239551/9945670,374412/4972835,53769/1989134,351524/4972835,4929758/4972835],hs=[506752/1228815,87881/245763,12673/70218,87098/409605,175762/245763,12673/175545,7918/409605,87881/737289,1001167/1053270]
934
+ */function gs(e){return(e<0?-1:1)*Math.abs(e)**(563/256)}const _s=[573536/994567,263643/1420810,187206/994567,591459/1989134,6239551/9945670,374412/4972835,53769/1989134,351524/4972835,4929758/4972835],vs=[506752/1228815,87881/245763,12673/70218,87098/409605,175762/245763,12673/175545,7918/409605,87881/737289,1001167/1053270]
935
935
  /**
936
936
  * Convert an array of linear-light a98-rgb values to CIE XYZ
937
937
  * http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
@@ -953,7 +953,7 @@ function ds(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
953
953
  *
954
954
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
955
955
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
956
- */function gs(e){return Co(hs,e)}
956
+ */function ys(e){return Eo(vs,e)}
957
957
  /**
958
958
  * Convert an array of gamma-corrected sRGB values in the 0.0 to 1.0 range to HSL.
959
959
  *
@@ -967,7 +967,7 @@ function ds(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
967
967
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/utilities.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
968
968
  *
969
969
  * @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/better-rgbToHsl.js
970
- */function _s(e){let t=e[0],n=e[1],r=e[2],i=Math.max(t,n,r),a=Math.min(t,n,r),o=(a+i)/2,s=i-a,c=NaN,l=0;if(Math.round(1e5*s)!==0){let e=Math.round(1e5*o);switch(l=e===0||e===1e5?0:(i-o)/Math.min(o,1-o),i){case t:c=(n-r)/s+(n<r?6:0);break;case n:c=(r-t)/s+2;break;case r:c=(t-n)/s+4}c*=60}return l<0&&(c+=180,l=Math.abs(l)),c>=360&&(c-=360),l<=1e-5&&(c=NaN),[c,100*l,100*o]}function vs(e){let t=e[0],n=e[1],r=e[2],i=Math.max(t,n,r),a=Math.min(t,n,r),o=NaN,s=i-a;if(s!==0){switch(i){case t:o=(n-r)/s+(n<r?6:0);break;case n:o=(r-t)/s+2;break;case r:o=(t-n)/s+4}o*=60}return o>=360&&(o-=360),o}function ys(e){let t=e;return t=os(t),t=gs(t),t=Do(t),t}function bs(e){let t=e;return t=To(t),t=Zo(t),t=$o(t),t}function xs(e){let t=e;return t=Oo(t),t=os(t),t=gs(t),t=Do(t),t}function Ss(e){let t=e;return t=To(t),t=Zo(t),t=$o(t),t=_s(t),t}function Cs(e){let t=e;return t=Ao(t),t=os(t),t=gs(t),t=Do(t),t}function ws(e){let t=e;t=To(t),t=Zo(t);let n=$o(t),r=Math.min(n[0],n[1],n[2]),i=1-Math.max(n[0],n[1],n[2]),a=vs(n);return r+i>=.99999&&(a=NaN),[a,100*r,100*i]}function Ts(e){let t=e;return t=Po(t),t}function Es(e){let t=e;return t=Bo(t),t}function Ds(e){let t=e;return t=jo(t),t=Po(t),t}function Os(e){let t=e;return t=Bo(t),t=Mo(t),t}function ks(e){let t=e;return t=zo(t),t=Do(t),t}function As(e){let t=e;return t=To(t),t=Wo(t),t}function js(e){let t=e;return t=Fo(t),t=zo(t),t=Do(t),t}function Ms(e){let t=e;return t=To(t),t=Wo(t),t=Io(t),t}function Ns(e){let t=e;return t=gs(t),t=Do(t),t}function Ps(e){let t=e;return t=To(t),t=Zo(t),t}function Fs(e){let t=e;
970
+ */function bs(e){let t=e[0],n=e[1],r=e[2],i=Math.max(t,n,r),a=Math.min(t,n,r),o=(a+i)/2,s=i-a,c=NaN,l=0;if(Math.round(1e5*s)!==0){let e=Math.round(1e5*o);switch(l=e===0||e===1e5?0:(i-o)/Math.min(o,1-o),i){case t:c=(n-r)/s+(n<r?6:0);break;case n:c=(r-t)/s+2;break;case r:c=(t-n)/s+4}c*=60}return l<0&&(c+=180,l=Math.abs(l)),c>=360&&(c-=360),l<=1e-5&&(c=NaN),[c,100*l,100*o]}function xs(e){let t=e[0],n=e[1],r=e[2],i=Math.max(t,n,r),a=Math.min(t,n,r),o=NaN,s=i-a;if(s!==0){switch(i){case t:o=(n-r)/s+(n<r?6:0);break;case n:o=(r-t)/s+2;break;case r:o=(t-n)/s+4}o*=60}return o>=360&&(o-=360),o}function Ss(e){let t=e;return t=ls(t),t=ys(t),t=Ao(t),t}function Cs(e){let t=e;return t=Oo(t),t=es(t),t=ns(t),t}function ws(e){let t=e;return t=jo(t),t=ls(t),t=ys(t),t=Ao(t),t}function Ts(e){let t=e;return t=Oo(t),t=es(t),t=ns(t),t=bs(t),t}function Es(e){let t=e;return t=No(t),t=ls(t),t=ys(t),t=Ao(t),t}function Ds(e){let t=e;t=Oo(t),t=es(t);let n=ns(t),r=Math.min(n[0],n[1],n[2]),i=1-Math.max(n[0],n[1],n[2]),a=xs(n);return r+i>=.99999&&(a=NaN),[a,100*r,100*i]}function Os(e){let t=e;return t=Lo(t),t}function ks(e){let t=e;return t=Uo(t),t}function As(e){let t=e;return t=Po(t),t=Lo(t),t}function js(e){let t=e;return t=Uo(t),t=Fo(t),t}function Ms(e){let t=e;return t=Ho(t),t=Ao(t),t}function Ns(e){let t=e;return t=Oo(t),t=qo(t),t}function Ps(e){let t=e;return t=Ro(t),t=Ho(t),t=Ao(t),t}function Fs(e){let t=e;return t=Oo(t),t=qo(t),t=zo(t),t}function Is(e){let t=e;return t=ys(t),t=Ao(t),t}function Ls(e){let t=e;return t=Oo(t),t=es(t),t}function Rs(e){let t=e;
971
971
  /**
972
972
  * Convert an array of a98-rgb values in the range 0.0 - 1.0
973
973
  * to linear light (un-companded) form. Negative values are also now accepted
@@ -975,7 +975,7 @@ function ds(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
975
975
  * @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
976
976
  * @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
977
977
  */
978
- var n;return t=[ps((n=t)[0]),ps(n[1]),ps(n[2])],t=Co(ms,t),t=Do(t),t}function Is(e){let t=e;var n;return t=To(t),t=Co(Yo,t),t=[rs((n=t)[0]),rs(n[1]),rs(n[2])],t}function Ls(e){let t=e;return t=cs(t),t=us(t),t=Do(t),t}function Rs(e){let t=e;return t=To(t),t=qo(t),t=ts(t),t}function zs(e){let t=e;return t=us(t),t=Do(t),t}function Bs(e){let t=e;return t=To(t),t=qo(t),t}function Vs(e){let t=e;var n;return t=[is((n=t)[0]),is(n[1]),is(n[2])],t=Co(as,t),t=Do(t),t}function Hs(e){let t=e;var n;return t=To(t),t=Co(Go,t),t=[Qo((n=t)[0]),Qo(n[1]),Qo(n[2])],t}function Us(e){let t=e;var n;return t=[ds((n=t)[0]),ds(n[1]),ds(n[2])],t=Co(fs,t),t}function Ws(e){let t=e;var n;return t=Co(Jo,t),t=[ns((n=t)[0]),ns(n[1]),ns(n[2])],t}function Gs(e){let t=e;return t=Do(t),t}function Ks(e){let t=e;return t=To(t),t}function qs(e){return e}function Js(e){return e[0]>=-1e-4&&e[0]<=1.0001&&e[1]>=-1e-4&&e[1]<=1.0001&&e[2]>=-1e-4&&e[2]<=1.0001}function Ys(e){return[e[0]<0?0:e[0]>1?1:e[0],e[1]<0?0:e[1]>1?1:e[1],e[2]<0?0:e[2]>1?1:e[2]]}
978
+ var n;return t=[gs((n=t)[0]),gs(n[1]),gs(n[2])],t=Eo(_s,t),t=Ao(t),t}function zs(e){let t=e;var n;return t=Oo(t),t=Eo(Qo,t),t=[os((n=t)[0]),os(n[1]),os(n[2])],t}function Bs(e){let t=e;return t=ds(t),t=ps(t),t=Ao(t),t}function Vs(e){let t=e;return t=Oo(t),t=Xo(t),t=is(t),t}function Hs(e){let t=e;return t=ps(t),t=Ao(t),t}function Us(e){let t=e;return t=Oo(t),t=Xo(t),t}function Ws(e){let t=e;var n;return t=[ss((n=t)[0]),ss(n[1]),ss(n[2])],t=Eo(cs,t),t=Ao(t),t}function Gs(e){let t=e;var n;return t=Oo(t),t=Eo(Jo,t),t=[ts((n=t)[0]),ts(n[1]),ts(n[2])],t}function Ks(e){let t=e;var n;return t=[ms((n=t)[0]),ms(n[1]),ms(n[2])],t=Eo(hs,t),t}function qs(e){let t=e;var n;return t=Eo(Zo,t),t=[as((n=t)[0]),as(n[1]),as(n[2])],t}function Js(e){let t=e;return t=Ao(t),t}function Ys(e){let t=e;return t=Oo(t),t}function Xs(e){return e}function Zs(e){return e[0]>=-1e-4&&e[0]<=1.0001&&e[1]>=-1e-4&&e[1]<=1.0001&&e[2]>=-1e-4&&e[2]<=1.0001}function Qs(e){return[e[0]<0?0:e[0]>1?1:e[0],e[1]<0?0:e[1]>1?1:e[1],e[2]<0?0:e[2]>1?1:e[2]]}
979
979
  /**
980
980
  * @description Calculate deltaE OK which is the simple root sum of squares
981
981
  * @param {number[]} reference - Array of OKLab values: L as 0..1, a and b as -1..1
@@ -988,32 +988,32 @@ var n;return t=[ps((n=t)[0]),ps(n[1]),ps(n[2])],t=Co(ms,t),t=Do(t),t}function Is
988
988
  */
989
989
  /**
990
990
  * @license MIT https://github.com/facelessuser/coloraide/blob/main/LICENSE.md
991
- */function Xs(e,t,n){let r=e[0],i=e[2],a=t(e),o=t([r,0,i]);for(let e=0;e<4;e++){if(e>0){let e=n(a);e[0]=r,e[2]=i,a=t(e)}let s=Zs(o,a);if(!s)break;a=s}return Ys(a)}function Zs(e,t){let n=1/0,r=-1/0,i=[0,0,0];for(let a=0;a<3;a++){let o=e[a],s=t[a]-o;if(i[a]=s,Math.abs(s)>1e-15){let e=1/s,t=(0-o)*e,i=(1-o)*e;r=Math.max(Math.min(t,i),r),n=Math.min(Math.max(t,i),n)}else if(o<0||o>1)return!1}return!(r>n||n<0)&&(r<0&&(r=n),!!isFinite(r)&&[e[0]+i[0]*r,e[1]+i[1]*r,e[2]+i[2]*r])}const Qs={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function $s(e){let[t,n,r]=e.map(e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4);return .2126*t+.7152*n+.0722*r}function ec(e,t){let n=$s(e),r=$s(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}var tc;function nc(e){let t=e.slice();return(e,n,r)=>{let i=-1;for(let a=t.indexOf(n);a<t.length&&(i=e.indexOf(t[a]),i===-1||i<r);a++);return i===-1||i===r&&n===e[r]&&(i++,i>=e.length)?-1:(t=e.slice(),i)}}function rc(e,t){let n=t[0];if(yo(n)||So(n)||xo(n)){let n=cc(e,t);return{advance:n.advance,node:n.node}}if(ho(n)){let n=oc(e,t);return{advance:n.advance,node:n.node}}if(vo(n)){let n=uc(e,t);return{advance:n.advance,node:n.node}}if(fo(n)){let n=fc(e,t);return{advance:n.advance,node:n.node}}return{advance:1,node:new K(n)}}(function(e){e.Function=`function`,e.SimpleBlock=`simple-block`,e.Whitespace=`whitespace`,e.Comment=`comment`,e.Token=`token`})(tc||={});var ic=class{value=[];indexOf(e){return this.value.indexOf(e)}at(e){if(typeof e==`number`)return e<0&&(e=this.value.length+e),this.value[e]}forEach(e,t){if(this.value.length===0)return;let n=nc(this.value),r=0;for(;r<this.value.length;){let i=this.value[r],a;if(t&&(a={...t}),!1===e({node:i,parent:this,state:a},r))return!1;if(r=n(this.value,i,r),r===-1)break}}walk(e,t){this.value.length!==0&&this.forEach((t,n)=>!1!==e(t,n)&&(!(`walk`in t.node)||!this.value.includes(t.node)||!1!==t.node.walk(e,t.state))&&void 0,t)}},ac=class e extends ic{type=tc.Function;name;endToken;constructor(e,t,n){super(),this.name=e,this.endToken=t,this.value=n}getName(){return this.name[4].value}normalize(){mo(this.endToken)&&(this.endToken=[z.CloseParen,`)`,-1,-1,void 0])}tokens(){return mo(this.endToken)?[this.name,...this.value.flatMap(e=>e.tokens())]:[this.name,...this.value.flatMap(e=>e.tokens()),this.endToken]}toString(){let e=this.value.map(e=>so(e)?ha(e):e.toString()).join(``);return ha(this.name)+e+ha(this.endToken)}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens(),value:this.value.map(e=>e.toJSON())}}isFunctionNode(){return e.isFunctionNode(this)}static isFunctionNode(t){return!!t&&t instanceof e&&t.type===tc.Function}};function oc(e,t){let n=[],r=1;for(;;){let i=t[r];if(!i||mo(i))return e.onParseError(new fa(`Unexpected EOF while consuming a function.`,t[0][2],t[t.length-1][3],[`5.4.9. Consume a function`,`Unexpected EOF`])),{advance:t.length,node:new ac(t[0],i,n)};if(bo(i))return{advance:r+1,node:new ac(t[0],i,n)};if(co(i)){let i=pc(e,t.slice(r));r+=i.advance,n.push(...i.nodes);continue}let a=rc(e,t.slice(r));r+=a.advance,n.push(a.node)}}var sc=class e extends ic{type=tc.SimpleBlock;startToken;endToken;constructor(e,t,n){super(),this.startToken=e,this.endToken=t,this.value=n}normalize(){if(mo(this.endToken)){let e=La(this.startToken);e&&(this.endToken=e)}}tokens(){return mo(this.endToken)?[this.startToken,...this.value.flatMap(e=>e.tokens())]:[this.startToken,...this.value.flatMap(e=>e.tokens()),this.endToken]}toString(){let e=this.value.map(e=>so(e)?ha(e):e.toString()).join(``);return ha(this.startToken)+e+ha(this.endToken)}toJSON(){return{type:this.type,startToken:this.startToken,tokens:this.tokens(),value:this.value.map(e=>e.toJSON())}}isSimpleBlockNode(){return e.isSimpleBlockNode(this)}static isSimpleBlockNode(t){return!!t&&t instanceof e&&t.type===tc.SimpleBlock}};function cc(e,t){let n=Ia(t[0][0]);if(!n)throw Error(`Failed to parse, a mirror variant must exist for all block open tokens.`);let r=[],i=1;for(;;){let a=t[i];if(!a||mo(a))return e.onParseError(new fa(`Unexpected EOF while consuming a simple block.`,t[0][2],t[t.length-1][3],[`5.4.8. Consume a simple block`,`Unexpected EOF`])),{advance:t.length,node:new sc(t[0],a,r)};if(a[0]===n)return{advance:i+1,node:new sc(t[0],a,r)};if(co(a)){let n=pc(e,t.slice(i));i+=n.advance,r.push(...n.nodes);continue}let o=rc(e,t.slice(i));i+=o.advance,r.push(o.node)}}var lc=class e{type=tc.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return ha(...this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isWhitespaceNode(){return e.isWhitespaceNode(this)}static isWhitespaceNode(t){return!!t&&t instanceof e&&t.type===tc.Whitespace}};function uc(e,t){let n=0;for(;;){let e=t[n];if(!vo(e))return{advance:n,node:new lc(t.slice(0,n))};n++}}var dc=class e{type=tc.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return ha(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isCommentNode(){return e.isCommentNode(this)}static isCommentNode(t){return!!t&&t instanceof e&&t.type===tc.Comment}};function fc(e,t){return{advance:1,node:new dc(t[0])}}function pc(e,t){let n=[],r=0;for(;;){if(vo(t[r])){let e=uc(0,t.slice(r));r+=e.advance,n.push(e.node);continue}if(!fo(t[r]))return{advance:r,nodes:n};n.push(new dc(t[r])),r++}}var K=class e{type=tc.Token;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return this.value[1]}toJSON(){return{type:this.type,tokens:this.tokens()}}isTokenNode(){return e.isTokenNode(this)}static isTokenNode(t){return!!t&&t instanceof e&&t.type===tc.Token}};function mc(e,t){let n={onParseError:t?.onParseError??(()=>{})},r=[...e];mo(r[r.length-1])||r.push([z.EOF,``,r[r.length-1][2],r[r.length-1][3],void 0]);let i=rc(n,r);if(mo(r[Math.min(i.advance,r.length-1)]))return i.node;n.onParseError(new fa(`Expected EOF after parsing a component value.`,e[0][2],e[e.length-1][3],[`5.3.9. Parse a component value`,`Expected EOF`]))}function hc(e,t,n){if(e.length===0)return;let r=nc(e),i=0;for(;i<e.length;){let a=e[i],o;if(n&&(o={...n}),!1===t({node:a,parent:{value:e},state:o},i))return!1;if(i=r(e,a,i),i===-1)break}}function gc(e,t,n){e.length!==0&&hc(e,(n,r)=>!1!==t(n,r)&&(!(`walk`in n.node)||!e.includes(n.node)||!1!==n.node.walk(t,n.state))&&void 0,n)}function _c(e,t){for(let n=0;n<e.length;n++)gc(e[n],(e,n)=>{if(typeof n!=`number`)return;let r=t(e.node);r&&(Array.isArray(r)?e.parent.value.splice(n,1,...r):e.parent.value.splice(n,1,r))});return e}function vc(e){return sc.isSimpleBlockNode(e)}function yc(e){return ac.isFunctionNode(e)}function bc(e){return lc.isWhitespaceNode(e)}function xc(e){return dc.isCommentNode(e)}function Sc(e){return bc(e)||xc(e)}function q(e){return K.isTokenNode(e)}function Cc(e){if(Array.isArray(e)){let t=e[0];if(!t)return[0,0];let n=e[e.length-1]||t;return[Cc(t)[0],Cc(n)[1]]}let t=e.tokens(),n=t[0],r=t[t.length-1];return n&&r?[n[2],r[3]]:[0,0]}var wc=class extends Error{sourceStart;sourceEnd;constructor(e,t,n){super(e),this.name=`ParseError`,this.sourceStart=t,this.sourceEnd=n}},Tc=class extends wc{componentValues;constructor(e,t){super(e,...Cc(t)),this.componentValues=t}};const Ec={UnexpectedAdditionOfDimensionOrPercentageWithNumber:`Unexpected addition of a dimension or percentage with a number.`,UnexpectedSubtractionOfDimensionOrPercentageWithNumber:`Unexpected subtraction of a dimension or percentage with a number.`},Dc=/[A-Z]/g;function Oc(e){return e.replace(Dc,e=>String.fromCharCode(e.charCodeAt(0)+32))}const kc={cm:`px`,in:`px`,mm:`px`,pc:`px`,pt:`px`,px:`px`,q:`px`,deg:`deg`,grad:`deg`,rad:`deg`,turn:`deg`,ms:`s`,s:`s`,hz:`hz`,khz:`hz`},Ac=new Map([[`cm`,e=>e],[`mm`,e=>10*e],[`q`,e=>40*e],[`in`,e=>e/2.54],[`pc`,e=>e/2.54*6],[`pt`,e=>e/2.54*72],[`px`,e=>e/2.54*96]]),jc=new Map([[`deg`,e=>e],[`grad`,e=>e/.9],[`rad`,e=>e/180*Math.PI],[`turn`,e=>e/360]]),Mc=new Map([[`deg`,e=>.9*e],[`grad`,e=>e],[`rad`,e=>.9*e/180*Math.PI],[`turn`,e=>.9*e/360]]),Nc=new Map([[`hz`,e=>e],[`khz`,e=>e/1e3]]),Pc=new Map([[`cm`,e=>2.54*e],[`mm`,e=>25.4*e],[`q`,e=>25.4*e*4],[`in`,e=>e],[`pc`,e=>6*e],[`pt`,e=>72*e],[`px`,e=>96*e]]),Fc=new Map([[`hz`,e=>1e3*e],[`khz`,e=>e]]),Ic=new Map([[`cm`,e=>e/10],[`mm`,e=>e],[`q`,e=>4*e],[`in`,e=>e/25.4],[`pc`,e=>e/25.4*6],[`pt`,e=>e/25.4*72],[`px`,e=>e/25.4*96]]),Lc=new Map([[`ms`,e=>e],[`s`,e=>e/1e3]]),Rc=new Map([[`cm`,e=>e/6*2.54],[`mm`,e=>e/6*25.4],[`q`,e=>e/6*25.4*4],[`in`,e=>e/6],[`pc`,e=>e],[`pt`,e=>e/6*72],[`px`,e=>e/6*96]]),zc=new Map([[`cm`,e=>e/72*2.54],[`mm`,e=>e/72*25.4],[`q`,e=>e/72*25.4*4],[`in`,e=>e/72],[`pc`,e=>e/72*6],[`pt`,e=>e],[`px`,e=>e/72*96]]),Bc=new Map([[`cm`,e=>e/96*2.54],[`mm`,e=>e/96*25.4],[`q`,e=>e/96*25.4*4],[`in`,e=>e/96],[`pc`,e=>e/96*6],[`pt`,e=>e/96*72],[`px`,e=>e]]),Vc=new Map([[`cm`,e=>e/4/10],[`mm`,e=>e/4],[`q`,e=>e],[`in`,e=>e/4/25.4],[`pc`,e=>e/4/25.4*6],[`pt`,e=>e/4/25.4*72],[`px`,e=>e/4/25.4*96]]),Hc=new Map([[`deg`,e=>180*e/Math.PI],[`grad`,e=>180*e/Math.PI/.9],[`rad`,e=>e],[`turn`,e=>180*e/Math.PI/360]]),Uc=new Map([[`ms`,e=>1e3*e],[`s`,e=>e]]),Wc=new Map([[`deg`,e=>360*e],[`grad`,e=>360*e/.9],[`rad`,e=>360*e/180*Math.PI],[`turn`,e=>e]]),Gc=new Map([[`cm`,Ac],[`mm`,Ic],[`q`,Vc],[`in`,Pc],[`pc`,Rc],[`pt`,zc],[`px`,Bc],[`ms`,Lc],[`s`,Uc],[`deg`,jc],[`grad`,Mc],[`rad`,Hc],[`turn`,Wc],[`hz`,Nc],[`khz`,Fc]]);function Kc(e,t){if(!H(e)||!H(t))return t;let n=Oc(e[4].unit),r=Oc(t[4].unit);if(n===r)return t;let i=Gc.get(r);if(!i)return t;let a=i.get(n);if(!a)return t;let o=a(t[4].value),s=[z.Dimension,``,t[2],t[3],{...t[4],signCharacter:o<0?`-`:void 0,type:Number.isInteger(o)?B.Integer:B.Number,value:o}];return no(s,e[4].unit),s}function qc(e){if(!H(e))return e;let t=Oc(e[4].unit),n=kc[t];if(t===n)return e;let r=Gc.get(t);if(!r)return e;let i=r.get(n);if(!i)return e;let a=i(e[4].value),o=[z.Dimension,``,e[2],e[3],{...e[4],signCharacter:a<0?`-`:void 0,type:Number.isInteger(a)?B.Integer:B.Number,value:a}];return no(o,n),o}function Jc(e,t){if(e.length!==2)return-1;let n=e[0].value,r=e[1].value;if(W(n)&&W(r)){let e=n[4].value+r[4].value;return new K([z.Number,e.toString(),n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number}])}if(G(n)&&G(r)){let e=n[4].value+r[4].value;return new K([z.Percentage,e.toString()+`%`,n[2],r[3],{value:e}])}if(H(n)&&H(r)&&(r=Kc(n,r),Oc(n[4].unit)===Oc(r[4].unit))){let e=n[4].value+r[4].value;return new K([z.Dimension,e.toString()+n[4].unit,n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number,unit:n[4].unit}])}return(W(n)&&(H(r)||G(r))||W(r)&&(H(n)||G(n)))&&t.onParseError?.(new Tc(Ec.UnexpectedAdditionOfDimensionOrPercentageWithNumber,e)),-1}function Yc(e){if(e.length!==2)return-1;let t=e[0].value,n=e[1].value;if(W(t)&&W(n)){let e=t[4].value/n[4].value;return new K([z.Number,e.toString(),t[2],n[3],{value:e,type:Number.isInteger(e)?B.Integer:B.Number}])}if(G(t)&&W(n)){let e=t[4].value/n[4].value;return new K([z.Percentage,e.toString()+`%`,t[2],n[3],{value:e}])}if(H(t)&&W(n)){let e=t[4].value/n[4].value;return new K([z.Dimension,e.toString()+t[4].unit,t[2],n[3],{value:e,type:Number.isInteger(e)?B.Integer:B.Number,unit:t[4].unit}])}return-1}function Xc(e){return!!e&&typeof e==`object`&&`inputs`in e&&Array.isArray(e.inputs)&&`operation`in e}function Zc(e,t){if(e===-1)return-1;let n=[];for(let r=0;r<e.inputs.length;r++){let i=e.inputs[r];if(q(i)){n.push(i);continue}let a=Zc(i,t);if(a===-1)return-1;n.push(a)}return e.operation(n,t)}function Qc(e){if(e.length!==2)return-1;let t=e[0].value,n=e[1].value;if(W(t)&&W(n)){let e=t[4].value*n[4].value;return new K([z.Number,e.toString(),t[2],n[3],{value:e,type:t[4].type===B.Integer&&n[4].type===B.Integer?B.Integer:B.Number}])}if(G(t)&&W(n)){let e=t[4].value*n[4].value;return new K([z.Percentage,e.toString()+`%`,t[2],n[3],{value:e}])}if(W(t)&&G(n)){let e=t[4].value*n[4].value;return new K([z.Percentage,e.toString()+`%`,t[2],n[3],{value:e}])}if(H(t)&&W(n)){let e=t[4].value*n[4].value;return new K([z.Dimension,e.toString()+t[4].unit,t[2],n[3],{value:e,type:t[4].type===B.Integer&&n[4].type===B.Integer?B.Integer:B.Number,unit:t[4].unit}])}if(W(t)&&H(n)){let e=t[4].value*n[4].value;return new K([z.Dimension,e.toString()+n[4].unit,t[2],n[3],{value:e,type:t[4].type===B.Integer&&n[4].type===B.Integer?B.Integer:B.Number,unit:n[4].unit}])}return-1}function $c(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(!q(r))continue;let i=r.value;if(!U(i))continue;let a=Oc(i[4].value);switch(a){case`e`:e.splice(n,1,new K([z.Number,Math.E.toString(),i[2],i[3],{value:Math.E,type:B.Number}]));break;case`pi`:e.splice(n,1,new K([z.Number,Math.PI.toString(),i[2],i[3],{value:Math.PI,type:B.Number}]));break;case`infinity`:e.splice(n,1,new K([z.Number,`infinity`,i[2],i[3],{value:1/0,type:B.Number}]));break;case`-infinity`:e.splice(n,1,new K([z.Number,`-infinity`,i[2],i[3],{value:-1/0,type:B.Number}]));break;case`nan`:e.splice(n,1,new K([z.Number,`NaN`,i[2],i[3],{value:NaN,type:B.Number}]));break;default:if(t.has(a)){let r=t.get(a);e.splice(n,1,new K(r))}}}return e}function el(e){if(e.length!==1)return-1;let t=e[0].value;return V(t)?e[0]:-1}function tl(e,t,n){return H(t)?nl(e,t[4].unit,n):G(t)?rl(e,n):W(t)?il(e,n):-1}function nl(e,t,n){let r=e.tokens();return{inputs:[new K([z.Dimension,n.toString()+t,r[0][2],r[r.length-1][3],{value:n,type:Number.isInteger(n)?B.Integer:B.Number,unit:t}])],operation:el}}function rl(e,t){let n=e.tokens();return{inputs:[new K([z.Percentage,t.toString()+`%`,n[0][2],n[n.length-1][3],{value:t}])],operation:el}}function il(e,t){let n=e.tokens();return{inputs:[new K([z.Number,t.toString(),n[0][2],n[n.length-1][3],{value:t,type:Number.isInteger(t)?B.Integer:B.Number}])],operation:el}}function al(e,t){let n=t.value;return W(n)?nl(e,`rad`,Math.acos(n[4].value)):-1}function ol(e,t){let n=t.value;return W(n)?nl(e,`rad`,Math.asin(n[4].value)):-1}function sl(e,t){let n=t.value;return W(n)?nl(e,`rad`,Math.atan(n[4].value)):-1}function cl(e){return H(e)||W(e)}function ll(e){if(e.length===0)return!0;let t=e[0];if(!V(t))return!1;if(e.length===1)return!0;if(H(t)){let n=Oc(t[4].unit);for(let r=1;r<e.length;r++){let i=e[r];if(t[0]!==i[0]||n!==Oc(i[4].unit))return!1}return!0}for(let n=1;n<e.length;n++){let r=e[n];if(t[0]!==r[0])return!1}return!0}function ul(e,t){return!!V(e)&&(H(e)?e[0]===t[0]&&Oc(e[4].unit)===Oc(t[4].unit):e[0]===t[0])}function dl(e,t,n){let r=t.value;if(!cl(r))return-1;let i=Kc(r,n.value);return ul(r,i)?nl(e,`rad`,Math.atan2(r[4].value,i[4].value)):-1}function fl(e,t,n){let r=t.value;return!V(r)||!n.rawPercentages&&G(r)?-1:tl(e,r,Math.abs(r[4].value))}function pl(e,t,n,r,i){if(!q(t)||!q(n)||!q(r))return-1;let a=t.value;if(!V(a)||!i.rawPercentages&&G(a))return-1;let o=Kc(a,n.value);if(!ul(a,o))return-1;let s=Kc(a,r.value);return ul(a,s)?tl(e,a,Math.max(a[4].value,Math.min(o[4].value,s[4].value))):-1}function ml(e,t){let n=t.value;if(!cl(n))return-1;let r=n[4].value;if(H(n))switch(n[4].unit.toLowerCase()){case`rad`:break;case`deg`:r=jc.get(`rad`)(n[4].value);break;case`grad`:r=Mc.get(`rad`)(n[4].value);break;case`turn`:r=Wc.get(`rad`)(n[4].value);break;default:return-1}return r=Math.cos(r),il(e,r)}function hl(e,t){let n=t.value;return W(n)?il(e,Math.exp(n[4].value)):-1}function gl(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!V(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>Kc(r,e.value));if(!ll(i))return-1;let a=i.map(e=>e[4].value);return tl(e,r,Math.hypot(...a))}function _l(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!V(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>Kc(r,e.value));if(!ll(i))return-1;let a=i.map(e=>e[4].value);return tl(e,r,Math.max(...a))}function vl(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!V(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>Kc(r,e.value));if(!ll(i))return-1;let a=i.map(e=>e[4].value);return tl(e,r,Math.min(...a))}function yl(e,t,n){let r=t.value;if(!V(r))return-1;let i=Kc(r,n.value);if(!ul(r,i))return-1;let a;return a=i[4].value===0?NaN:Number.isFinite(r[4].value)&&(Number.isFinite(i[4].value)||(i[4].value!==1/0||r[4].value!==-1/0&&!Object.is(0*r[4].value,-0))&&(i[4].value!==-1/0||r[4].value!==1/0&&!Object.is(0*r[4].value,0)))?Number.isFinite(i[4].value)?(r[4].value%i[4].value+i[4].value)%i[4].value:r[4].value:NaN,tl(e,r,a)}function bl(e,t,n){let r=t.value,i=n.value;return!W(r)||!ul(r,i)?-1:il(e,r[4].value**+i[4].value)}function xl(e,t,n){let r=t.value;if(!V(r))return-1;let i=Kc(r,n.value);if(!ul(r,i))return-1;let a;return a=i[4].value===0?NaN:Number.isFinite(r[4].value)?Number.isFinite(i[4].value)?r[4].value%i[4].value:r[4].value:NaN,tl(e,r,a)}function Sl(e,t,n){if(!H(t))return-1;let r=n.devicePixelLength??1,i=[z.Dimension,`${r}px`,t[2],t[3],{value:r,type:B.Integer,unit:`px`}],a=Kc(i,t);if(!ul(a,i))return-1;if(Number.isInteger(a[4].value/r))return tl(e,t,t[4].value);if(a[4].value>0){if(a[4].value<r)return tl(e,t,Kc(t,i)[4].value);let n=Math.floor(a[4].value/i[4].value)*i[4].value;return a[4].value=n,tl(e,t,Kc(t,a)[4].value)}if(Math.abs(a[4].value)<r)return tl(e,t,-1*Kc(t,i)[4].value);let o=Math.ceil(a[4].value/i[4].value)*i[4].value;return a[4].value=o,tl(e,t,Kc(t,a)[4].value)}function Cl(e,t,n,r,i){let a=n.value;if(!V(a)||t===`line-width`&&!H(a)||!i.rawPercentages&&G(a))return-1;let o=Kc(a,r.value);if(!ul(a,o))return-1;let s;if(o[4].value===0)s=NaN;else if(Number.isFinite(a[4].value)||Number.isFinite(o[4].value))if(!Number.isFinite(a[4].value)&&Number.isFinite(o[4].value))s=a[4].value;else if(Number.isFinite(a[4].value)&&!Number.isFinite(o[4].value))switch(t){case`down`:s=a[4].value<0?-1/0:Object.is(-0,0*a[4].value)?-0:0;break;case`up`:s=a[4].value>0?1/0:Object.is(0,0*a[4].value)?0:-0;break;default:s=Object.is(0,0*a[4].value)?0:-0}else switch(t){case`down`:s=Math.floor(a[4].value/o[4].value)*o[4].value;break;case`up`:s=Math.ceil(a[4].value/o[4].value)*o[4].value;break;case`to-zero`:s=Math.trunc(a[4].value/o[4].value)*o[4].value;break;default:{let n=Math.floor(a[4].value/o[4].value)*o[4].value,r=Math.ceil(a[4].value/o[4].value)*o[4].value;if(n>r){let e=n;n=r,r=e}let c=Math.abs(a[4].value-n),l=Math.abs(a[4].value-r);if(s=t===`line-width`&&a[4].value>=0&&(r===0||n===0)?r===0?n:r:c===l?r:c<l?n:r,t===`line-width`){let t=Zc(tl(e,a,s),i);return t===-1?-1:Sl(e,t.value,i)}break}}else s=NaN;return tl(e,a,s)}function wl(e,t,n){let r=t.value;return!V(r)||!n.rawPercentages&&G(r)?-1:il(e,Math.sign(r[4].value))}function Tl(e,t){let n=t.value;if(!cl(n))return-1;let r=n[4].value;if(H(n))switch(Oc(n[4].unit)){case`rad`:break;case`deg`:r=jc.get(`rad`)(n[4].value);break;case`grad`:r=Mc.get(`rad`)(n[4].value);break;case`turn`:r=Wc.get(`rad`)(n[4].value);break;default:return-1}return r=Math.sin(r),il(e,r)}function El(e,t){let n=t.value;return W(n)?il(e,Math.sqrt(n[4].value)):-1}function Dl(e,t){let n=t.value;if(!cl(n))return-1;let r=n[4].value,i=0,a=n[4].value;if(H(n))switch(Oc(n[4].unit)){case`rad`:i=Hc.get(`deg`)(r);break;case`deg`:i=r,a=jc.get(`rad`)(r);break;case`grad`:i=Mc.get(`deg`)(r),a=Mc.get(`rad`)(r);break;case`turn`:i=Wc.get(`deg`)(r),a=Wc.get(`rad`)(r);break;default:return-1}let o=i/90;return a=i%90==0&&o%2!=0?o>0?1/0:-1/0:Math.tan(a),il(e,a)}function Ol(e,t){if(e.length!==2)return-1;let n=e[0].value,r=e[1].value;if(W(n)&&W(r)){let e=n[4].value-r[4].value;return new K([z.Number,e.toString(),n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number}])}if(G(n)&&G(r)){let e=n[4].value-r[4].value;return new K([z.Percentage,e.toString()+`%`,n[2],r[3],{value:e}])}if(H(n)&&H(r)&&(r=Kc(n,r),Oc(n[4].unit)===Oc(r[4].unit))){let e=n[4].value-r[4].value;return new K([z.Dimension,e.toString()+n[4].unit,n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number,unit:n[4].unit}])}return(W(n)&&(H(r)||G(r))||W(r)&&(H(n)||G(n)))&&t.onParseError?.(new Tc(Ec.UnexpectedSubtractionOfDimensionOrPercentageWithNumber,e)),-1}function kl(e,t){if(t.length===1){let n=t[0];if(!n||!q(n))return-1;let r=n.value;return W(r)?il(e,Math.log(r[4].value)):-1}if(t.length===2){let n=t[0];if(!n||!q(n))return-1;let r=n.value;if(!W(r))return-1;let i=t[1];if(!i||!q(i))return-1;let a=i.value;return W(a)?il(e,Math.log(r[4].value)/Math.log(a[4].value)):-1}return-1}const Al=/^none$/i;function jl(e){if(Array.isArray(e)){let t=e.filter(e=>!(bc(e)&&xc(e)));return t.length===1&&jl(t[0])}if(!q(e))return!1;let t=e.value;return!!U(t)&&Al.test(t[4].value)}const Ml=String.fromCodePoint(0);function Nl(e,t,n,r,i,a){if(t.fixed===-1&&!a.randomCaching)return-1;a.randomCaching||={propertyName:``,propertyN:0,elementID:``,documentID:``},a.randomCaching&&!a.randomCaching.propertyN&&(a.randomCaching.propertyN=0);let o=n.value;if(!V(o))return-1;let s=Kc(o,r.value);if(!ul(o,s))return-1;let c=null;if(i&&(c=Kc(o,i.value),!ul(o,c)))return-1;if(!Number.isFinite(o[4].value)||!Number.isFinite(s[4].value)||!Number.isFinite(s[4].value-o[4].value))return tl(e,o,NaN);if(c&&!Number.isFinite(c[4].value))return tl(e,o,o[4].value);let l=t.fixed===-1?Pl(Fl([t.dashedIdent?t.dashedIdent:`${a.randomCaching?.propertyName} ${a.randomCaching.propertyN++}`,t.elementShared?``:a.randomCaching.elementID,a.randomCaching.documentID].join(Ml))):()=>t.fixed,u=o[4].value,d=s[4].value;if(u>d&&([u,d]=[d,u]),c&&(c[4].value<=0||Math.abs(u-d)/c[4].value>1e10)&&(c=null),c){let t=Math.max(c[4].value/1e3,1e-9),n=[u],r=0;for(;;){r+=c[4].value;let e=u+r;if(!(e+t<d)){n.push(d);break}if(n.push(e),e+c[4].value-t>d)break}let i=l();return tl(e,o,Number(n[Math.floor(n.length*i)].toFixed(5)))}let f=l();return tl(e,o,Number((f*(d-u)+u).toFixed(5)))}function Pl(e=.34944106645296036,t=.19228640875738723,n=.8784393832007205,r=.04850964319275053){return()=>{let i=((e|=0)+(t|=0)|0)+(r|=0)|0;return r=r+1|0,e=t^t>>>9,t=(n|=0)+(n<<3)|0,n=(n=n<<21|n>>>11)+i|0,(i>>>0)/4294967296}}function Fl(e){let t,n,r=0;r^=-1;for(let i=0,a=e.length;i<a;i++)n=255&(r^e.charCodeAt(i)),t=Number(`0x`+`00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D`.substring(9*n,9*n+8)),r=r>>>8^t;return(-1^r)>>>0}const Il=new Map([[`abs`,function(e,t,n){return Rl(e,t,n,fl)}],[`acos`,function(e,t,n){return Rl(e,t,n,al)}],[`asin`,function(e,t,n){return Rl(e,t,n,ol)}],[`atan`,function(e,t,n){return Rl(e,t,n,sl)}],[`atan2`,function(e,t,n){return Bl(e,t,n,dl)}],[`calc`,Ll],[`clamp`,function(e,t,n){let r=$c([...e.value.filter(e=>!Sc(e))],t),i=[],a=[],o=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&uo(n.value)){if(e===o)return-1;if(e===a){e=o;continue}if(e===i){e=a;continue}return-1}e.push(n)}}let s=jl(i),c=jl(o);if(s&&c)return Ll(Kl(e,a),t,n);let l=Zc(Ll(Kl(e,a),t,n),n);if(l===-1)return-1;if(s){let r=Zc(Ll(Kl(e,o),t,n),n);return r===-1?-1:vl((u=e,d=l,f=r,new ac([z.Function,`min(`,u.name[2],u.name[3],{value:`min`}],[z.CloseParen,`)`,u.endToken[2],u.endToken[3],void 0],[d,new K([z.Comma,`,`,...Cc(d),void 0]),f])),[l,r],n)}if(c){let r=Zc(Ll(Kl(e,i),t,n),n);return r===-1?-1:_l(ql(e,r,l),[r,l],n)}var u,d,f;let p=Zc(Ll(Kl(e,i),t,n),n);if(p===-1)return-1;let m=Zc(Ll(Kl(e,o),t,n),n);return m===-1?-1:pl(e,p,l,m,n)}],[`cos`,function(e,t,n){return Rl(e,t,n,ml)}],[`exp`,function(e,t,n){return Rl(e,t,n,hl)}],[`hypot`,function(e,t,n){return Hl(e,t,n,gl)}],[`log`,function(e,t,n){return Hl(e,t,n,kl)}],[`max`,function(e,t,n){return Hl(e,t,n,_l)}],[`min`,function(e,t,n){return Hl(e,t,n,vl)}],[`mod`,function(e,t,n){return Bl(e,t,n,yl)}],[`pow`,function(e,t,n){return Bl(e,t,n,bl)}],[`random`,function(e,t,n){let r=Gl(e,e.value.filter(e=>!Sc(e)),t,n);if(r===-1)return-1;let[i,a]=r,o=Ul(e,a,t,n);if(o===-1)return-1;let[s,c,l]=o;return!s||!c?-1:Nl(e,i,s,c,l,n)}],[`rem`,function(e,t,n){return Bl(e,t,n,xl)}],[`round`,function(e,t,n){let r=$c([...e.value.filter(e=>!Sc(e))],t),i=``,a=!1,o=[],s=[];{let e=o;for(let t=0;t<r.length;t++){let n=r[t];if(!i&&o.length===0&&s.length===0&&q(n)&&U(n.value)){let e=n.value[4].value.toLowerCase();if(Wl.has(e)){i=e;continue}}if(q(n)&&uo(n.value)){if(e===s)return-1;if(e===o&&i&&o.length===0)continue;if(e===o){a=!0,e=s;continue}return-1}e.push(n)}}let c=Zc(Ll(Kl(e,o),t,n),n);if(c===-1)return-1;if(i===`line-width`){let e=Kc([z.Dimension,`1px`,c.value[2],c.value[3],{value:1,type:B.Integer,unit:`px`}],c.value);if(!H(e)||e[4].unit!==`px`)return-1}if(!a&&s.length===0){if(i===`line-width`)return Sl(e,c.value,n);s.push(new K([z.Number,`1`,c.value[2],c.value[3],{value:1,type:B.Integer}]))}let l=Zc(Ll(Kl(e,s),t,n),n);return l===-1?-1:(i||=`nearest`,Cl(e,i,c,l,n))}],[`sign`,function(e,t,n){return Rl(e,t,n,wl)}],[`sin`,function(e,t,n){return Rl(e,t,n,Tl)}],[`sqrt`,function(e,t,n){return Rl(e,t,n,El)}],[`tan`,function(e,t,n){return Rl(e,t,n,Dl)}]]);function Ll(e,t,n){let r=$c([...e.value.filter(e=>!Sc(e))],t);if(r.length===1&&q(r[0]))return{inputs:[r[0]],operation:el};let i=0;for(;i<r.length;){let e=r[i];if(vc(e)&&yo(e.startToken)){let a=Ll(e,t,n);if(a===-1)return-1;r.splice(i,1,a);continue}if(yc(e)){let a=Il.get(e.getName().toLowerCase());if(!a)return-1;let o=a(e,t,n);if(o===-1)return-1;r.splice(i,1,o);continue}i++}if(i=0,r.length===1&&Xc(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!Xc(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!po(n)||n[4].value!==`*`&&n[4].value!==`/`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!Xc(a))return-1;n[4].value===`*`?r.splice(i,3,{inputs:[e,a],operation:Qc}):n[4].value===`/`?r.splice(i,3,{inputs:[e,a],operation:Yc}):i++}if(i=0,r.length===1&&Xc(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!Xc(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!po(n)||n[4].value!==`+`&&n[4].value!==`-`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!Xc(a))return-1;n[4].value===`+`?r.splice(i,3,{inputs:[e,a],operation:Jc}):n[4].value===`-`?r.splice(i,3,{inputs:[e,a],operation:Ol}):i++}return r.length===1&&Xc(r[0])?r[0]:-1}function Rl(e,t,n,r){let i=zl(e,t,n);return i===-1?-1:r(e,i,n)}function zl(e,t,n){let r=Zc(Ll(Kl(e,$c([...e.value.filter(e=>!Sc(e))],t)),t,n),n);return r===-1?-1:r}function Bl(e,t,n,r){let i=Vl(e,t,n);if(i===-1)return-1;let[a,o]=i;return r(e,a,o,n)}function Vl(e,t,n){let r=$c([...e.value.filter(e=>!Sc(e))],t),i=[],a=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&uo(n.value)){if(e===a)return-1;if(e===i){e=a;continue}return-1}e.push(n)}}let o=Zc(Ll(Kl(e,i),t,n),n);if(o===-1)return-1;let s=Zc(Ll(Kl(e,a),t,n),n);return s===-1?-1:[o,s]}function Hl(e,t,n,r){let i=Ul(e,e.value,t,n);return i===-1?-1:r(e,i,n)}function Ul(e,t,n,r){let i=$c([...t.filter(e=>!Sc(e))],n),a=[];{let t=[],o=[];for(let e=0;e<i.length;e++){let n=i[e];q(n)&&uo(n.value)?(t.push(o),o=[]):o.push(n)}t.push(o);for(let i=0;i<t.length;i++){if(t[i].length===0)return-1;let o=Zc(Ll(Kl(e,t[i]),n,r),r);if(o===-1)return-1;a.push(o)}}return a}const Wl=new Set([`nearest`,`line-width`,`up`,`down`,`to-zero`]);function Gl(e,t,n,r){let i={isAuto:!1,dashedIdent:``,fixed:-1,elementShared:!1},a=t[0];if(!q(a)||!U(a.value))return[i,t];for(let a=0;a<t.length;a++){let o=t[a];if(!q(o))return-1;if(uo(o.value))return[i,t.slice(a+1)];if(!U(o.value))return-1;let s=o.value[4].value.toLowerCase();if(s!==`element-shared`){if(s===`fixed`){if(i.elementShared||i.dashedIdent||i.isAuto)return-1;a++;let o=t[a];if(!o)return-1;let s=Zc(Ll(Kl(e,[o]),n,r),r);if(s===-1||!W(s.value)||s.value[4].value<0||s.value[4].value>1)return-1;i.fixed=Math.max(0,Math.min(s.value[4].value,.999999999));continue}if(s!==`auto`){if(s.startsWith(`--`)){if(i.fixed!==-1||i.isAuto)return-1;i.dashedIdent=s}}else{if(i.fixed!==-1||i.dashedIdent)return-1;i.isAuto=!0}}else{if(i.fixed!==-1)return-1;i.elementShared=!0}}return-1}function Kl(e,t){return new ac([z.Function,`calc(`,e.name[2],e.name[3],{value:`calc`}],[z.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],t)}function ql(e,t,n){return new ac([z.Function,`max(`,e.name[2],e.name[3],{value:`max`}],[z.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],[t,new K([z.Comma,`,`,...Cc(t),void 0]),n])}function Jl(e){if(e===-1)return-1;if(yc(e))return e;let t=e.value;return V(t)&&Number.isNaN(t[4].value)?W(t)?new ac([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,`NaN`,t[2],t[3],{value:`NaN`}])]):H(t)?new ac([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,`NaN`,t[2],t[3],{value:`NaN`}]),new lc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new lc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Dimension,`1`+t[4].unit,t[2],t[3],{value:1,type:B.Integer,unit:t[4].unit}])]):G(t)?new ac([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,`NaN`,t[2],t[3],{value:`NaN`}]),new lc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new lc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Percentage,`1%`,t[2],t[3],{value:1}])]):-1:e}function Yl(e){if(e===-1)return-1;if(yc(e))return e;let t=e.value;if(!V(t)||Number.isFinite(t[4].value)||Number.isNaN(t[4].value))return e;let n=``;return t[4].value===-1/0&&(n=`-`),W(t)?new ac([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}])]):H(t)?new ac([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}]),new lc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new lc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Dimension,`1`+t[4].unit,t[2],t[3],{value:1,type:B.Integer,unit:t[4].unit}])]):new ac([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}]),new lc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new lc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Percentage,`1%`,t[2],t[3],{value:1}])])}function Xl(e){if(e===-1)return-1;if(yc(e))return e;let t=e.value;return V(t)&&Object.is(-0,t[4].value)&&(t[1]===`-0`||(G(t)?t[1]=`-0%`:H(t)?t[1]=`-0`+t[4].unit:t[1]=`-0`)),e}function Zl(e,t=13){if(e===-1)return-1;if(t<=0||yc(e))return e;let n=e.value;if(!V(n)||Number.isInteger(n[4].value))return e;let r=Number(n[4].value.toFixed(t)).toString();return W(n)?n[1]=r:G(n)?n[1]=r+`%`:H(n)&&(n[1]=r+n[4].unit),e}function Ql(e){return e===-1?-1:(yc(e)||H(e.value)&&(e.value=qc(e.value)),e)}function $l(e,t){let n=e;return t?.toCanonicalUnits&&(n=Ql(n)),n=Zl(n,t?.precision),n=Xl(n),t?.censorIntoStandardRepresentableValues||(n=Jl(n),n=Yl(n)),n}function eu(e){let t=new Map;if(!e)return t;for(let[n,r]of e)if(so(r))t.set(n,r);else if(typeof r==`string`){let e=eo({css:r}),i=e.nextToken();if(e.nextToken(),!e.endOfFile()||!V(i))continue;t.set(n,i);continue}return t}function tu(e,t){let n=eu(t?.globals);return nu(e,e=>{if(!yc(e))return;let r=Il.get(e.getName().toLowerCase());if(!r)return;let i=$l(Zc(r(e,n,t??{}),t??{}),t);return i===-1?void 0:i})}function nu(e,t){for(let n=0;n<e.length;n++){let r=e[n];gc(r,(e,n)=>{if(typeof n!=`number`)return;let r=t(e.node);if(!r)return;let i=[r],a=e.parent.value[n-1];q(a)&&po(a.value)&&(a.value[4].value===`-`||a.value[4].value===`+`)&&i.splice(0,0,new lc([[z.Whitespace,` `,...Cc(e.node),void 0]]));let o=e.parent.value[n+1];!o||Sc(o)||q(o)&&(uo(o.value)||lo(o.value)||_o(o.value)||po(o.value)&&o.value[4].value!==`-`&&o.value[4].value!==`+`)||i.push(new lc([[z.Whitespace,` `,...Cc(e.node),void 0]])),e.parent.value.splice(n,1,...i)})}return e}const ru=new Set(Il.keys());var J,Y;function iu(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function au(e){switch(e.colorNotation){case J.HEX:case J.RGB:case J.sRGB:return{...e,colorNotation:J.XYZ_D50,channels:ys(iu(e.channels))};case J.Linear_sRGB:return{...e,colorNotation:J.XYZ_D50,channels:Ns(iu(e.channels))};case J.Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:Ls(iu(e.channels))};case J.Linear_Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:zs(iu(e.channels))};case J.Rec2020:return{...e,colorNotation:J.XYZ_D50,channels:Vs(iu(e.channels))};case J.A98_RGB:return{...e,colorNotation:J.XYZ_D50,channels:Fs(iu(e.channels))};case J.ProPhoto_RGB:return{...e,colorNotation:J.XYZ_D50,channels:Us(iu(e.channels))};case J.HSL:return{...e,colorNotation:J.XYZ_D50,channels:xs(iu(e.channels))};case J.HWB:return{...e,colorNotation:J.XYZ_D50,channels:Cs(iu(e.channels))};case J.Lab:return{...e,colorNotation:J.XYZ_D50,channels:Ts(iu(e.channels))};case J.OKLab:return{...e,colorNotation:J.XYZ_D50,channels:ks(iu(e.channels))};case J.LCH:return{...e,colorNotation:J.XYZ_D50,channels:Ds(iu(e.channels))};case J.OKLCH:return{...e,colorNotation:J.XYZ_D50,channels:js(iu(e.channels))};case J.XYZ_D50:return{...e,colorNotation:J.XYZ_D50,channels:qs(iu(e.channels))};case J.XYZ_D65:return{...e,colorNotation:J.XYZ_D50,channels:Gs(iu(e.channels))};default:throw Error(`Unsupported color notation`)}}(function(e){e.A98_RGB=`a98-rgb`,e.Display_P3=`display-p3`,e.Linear_Display_P3=`display-p3-linear`,e.HEX=`hex`,e.HSL=`hsl`,e.HWB=`hwb`,e.LCH=`lch`,e.Lab=`lab`,e.Linear_sRGB=`srgb-linear`,e.OKLCH=`oklch`,e.OKLab=`oklab`,e.ProPhoto_RGB=`prophoto-rgb`,e.RGB=`rgb`,e.sRGB=`srgb`,e.Rec2020=`rec2020`,e.XYZ_D50=`xyz-d50`,e.XYZ_D65=`xyz-d65`})(J||={}),function(e){e.ColorKeyword=`color-keyword`,e.HasAlpha=`has-alpha`,e.HasDimensionValues=`has-dimension-values`,e.HasNoneKeywords=`has-none-keywords`,e.HasNumberValues=`has-number-values`,e.HasPercentageAlpha=`has-percentage-alpha`,e.HasPercentageValues=`has-percentage-values`,e.HasVariableAlpha=`has-variable-alpha`,e.Hex=`hex`,e.LegacyHSL=`legacy-hsl`,e.LegacyRGB=`legacy-rgb`,e.NamedColor=`named-color`,e.RelativeColorSyntax=`relative-color-syntax`,e.ColorMix=`color-mix`,e.ColorMixVariadic=`color-mix-variadic`,e.ContrastColor=`contrast-color`,e.RelativeAlphaSyntax=`relative-alpha-syntax`,e.Experimental=`experimental`}(Y||={});const ou=new Set([J.A98_RGB,J.Display_P3,J.Linear_Display_P3,J.HEX,J.Linear_sRGB,J.ProPhoto_RGB,J.RGB,J.sRGB,J.Rec2020,J.XYZ_D50,J.XYZ_D65]);function su(e,t){let n={...e};if(e.colorNotation!==t){let e=au(n);switch(t){case J.HEX:case J.RGB:n.colorNotation=J.RGB,n.channels=bs(e.channels);break;case J.sRGB:n.colorNotation=J.sRGB,n.channels=bs(e.channels);break;case J.Linear_sRGB:n.colorNotation=J.Linear_sRGB,n.channels=Ps(e.channels);break;case J.Display_P3:n.colorNotation=J.Display_P3,n.channels=Rs(e.channels);break;case J.Linear_Display_P3:n.colorNotation=J.Linear_Display_P3,n.channels=Bs(e.channels);break;case J.Rec2020:n.colorNotation=J.Rec2020,n.channels=Hs(e.channels);break;case J.ProPhoto_RGB:n.colorNotation=J.ProPhoto_RGB,n.channels=Ws(e.channels);break;case J.A98_RGB:n.colorNotation=J.A98_RGB,n.channels=Is(e.channels);break;case J.HSL:n.colorNotation=J.HSL,n.channels=Ss(e.channels);break;case J.HWB:n.colorNotation=J.HWB,n.channels=ws(e.channels);break;case J.Lab:n.colorNotation=J.Lab,n.channels=Es(e.channels);break;case J.LCH:n.colorNotation=J.LCH,n.channels=Os(e.channels);break;case J.OKLCH:n.colorNotation=J.OKLCH,n.channels=Ms(e.channels);break;case J.OKLab:n.colorNotation=J.OKLab,n.channels=As(e.channels);break;case J.XYZ_D50:n.colorNotation=J.XYZ_D50,n.channels=qs(e.channels);break;case J.XYZ_D65:n.colorNotation=J.XYZ_D65,n.channels=Ks(e.channels);break;default:throw Error(`Unsupported color notation`)}}else n.channels=iu(e.channels);if(t===e.colorNotation)n.channels=lu(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else if(ou.has(t)&&ou.has(e.colorNotation))n.channels=lu(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else switch(t){case J.HSL:switch(e.colorNotation){case J.HWB:n.channels=lu(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=lu(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.LCH:case J.OKLCH:n.channels=lu(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;default:n.channels=lu(e.channels,[],[],n.channels,[],[])}break;case J.HWB:switch(e.colorNotation){case J.HSL:n.channels=lu(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=lu(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;default:n.channels=lu(e.channels,[],[],n.channels,[],[])}break;case J.Lab:case J.OKLab:switch(e.colorNotation){case J.HSL:n.channels=lu(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=lu(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;case J.LCH:case J.OKLCH:n.channels=lu(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;default:n.channels=lu(e.channels,[],[],n.channels,[],[])}break;case J.LCH:case J.OKLCH:switch(e.colorNotation){case J.HSL:n.channels=lu(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;case J.HWB:n.channels=lu(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.Lab:case J.OKLab:n.channels=lu(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=lu(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;default:n.channels=lu(e.channels,[],[],n.channels,[],[])}break;default:n.channels=lu(e.channels,[],[],n.channels,[],[])}return n.channels=cu(n.channels,t),n}function cu(e,t){let n=[...e];switch(t){case J.HSL:!Number.isNaN(n[1])&&n[1]<=.001&&(n[0]=NaN);break;case J.HWB:!Number.isNaN(n[1])&&!Number.isNaN(n[2])&&Math.max(0,n[1])+Math.max(0,n[2])>=99.999&&(n[0]=NaN);break;case J.LCH:!Number.isNaN(n[1])&&n[1]<=.0015&&(n[2]=NaN);break;case J.OKLCH:!Number.isNaN(n[1])&&n[1]<=4e-6&&(n[2]=NaN)}return n}function lu(e,t,n,r,i,a){if(t.length<3&&e.every(Number.isNaN))return[NaN,NaN,NaN];let o=[...r];for(let n=0;n<t.length;n++)Number.isNaN(e[t[n]])&&(o[i[n]]=NaN);if(n.length&&n.every(t=>Number.isNaN(e[t])))for(let e=0;e<a.length;e++)o[a[e]]=NaN;return o}function uu(e){let t=new Map;switch(e.colorNotation){case J.RGB:case J.HEX:t.set(`r`,X(255*e.channels[0])),t.set(`g`,X(255*e.channels[1])),t.set(`b`,X(255*e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.HSL:t.set(`h`,X(e.channels[0])),t.set(`s`,X(e.channels[1])),t.set(`l`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.HWB:t.set(`h`,X(e.channels[0])),t.set(`w`,X(e.channels[1])),t.set(`b`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.Lab:case J.OKLab:t.set(`l`,X(e.channels[0])),t.set(`a`,X(e.channels[1])),t.set(`b`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.LCH:case J.OKLCH:t.set(`l`,X(e.channels[0])),t.set(`c`,X(e.channels[1])),t.set(`h`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.sRGB:case J.A98_RGB:case J.Display_P3:case J.Linear_Display_P3:case J.Rec2020:case J.Linear_sRGB:case J.ProPhoto_RGB:t.set(`r`,X(e.channels[0])),t.set(`g`,X(e.channels[1])),t.set(`b`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.XYZ_D50:case J.XYZ_D65:t.set(`x`,X(e.channels[0])),t.set(`y`,X(e.channels[1])),t.set(`z`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha))}return t}function du(e){let t=new Map(e);for(let[n,r]of e)Number.isNaN(r[4].value)&&t.set(n,X(0));return t}function X(e){return Number.isNaN(e)?[z.Number,`none`,-1,-1,{value:NaN,type:B.Number}]:[z.Number,e.toString(),-1,-1,{value:e,type:B.Number}]}function Z(e,t,n,r){return Math.min(Math.max(e/t,n),r)}const fu=/[A-Z]/g;function Q(e){return e.replace(fu,e=>String.fromCharCode(e.charCodeAt(0)+32))}function pu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}const mu=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`xyz`,`xyz-d50`,`xyz-d65`]);function hu(e,t){let n=[],r=[],i=[],a=[],o,s,c=!1,l=!1,u={colorNotation:J.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])},d=n;for(let f=0;f<e.value.length;f++){let p=e.value[f];if(bc(p)||xc(p))for(;bc(e.value[f+1])||xc(e.value[f+1]);)f++;else if(d===n&&n.length&&(d=r),d===r&&r.length&&(d=i),q(p)&&po(p.value)&&p.value[4].value===`/`){if(d===a)return!1;d=a}else{if(yc(p)){if(d===a&&Q(p.getName())===`var`){u.syntaxFlags.add(Y.HasVariableAlpha),d.push(p);continue}if(!ru.has(Q(p.getName())))return!1;let[[e]]=tu([[p]],{censorIntoStandardRepresentableValues:!0,globals:s,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),p=e}if(d===n&&n.length===0&&q(p)&&U(p.value)&&mu.has(Q(p.value[4].value))){if(c)return!1;c=Q(p.value[4].value),u.colorNotation=gu(c),l&&(l.colorNotation!==u.colorNotation&&(l=su(l,u.colorNotation)),o=uu(l),s=du(o))}else if(d===n&&n.length===0&&q(p)&&U(p.value)&&Q(p.value[4].value)===`from`){if(l||c)return!1;for(;bc(e.value[f+1])||xc(e.value[f+1]);)f++;if(f++,p=e.value[f],l=t(p),!1===l)return!1;l.syntaxFlags.has(Y.Experimental)&&u.syntaxFlags.add(Y.Experimental),u.syntaxFlags.add(Y.RelativeColorSyntax)}else{if(!q(p))return!1;if(U(p.value)&&o&&o.has(Q(p.value[4].value))){d.push(new K(o.get(Q(p.value[4].value))));continue}d.push(p)}}}if(!c||d.length!==1||n.length!==1||r.length!==1||i.length!==1||!q(n[0])||!q(r[0])||!q(i[0])||o&&!o.has(`alpha`))return!1;let f=pu(n[0].value,0,u);if(!f||!W(f))return!1;let p=pu(r[0].value,1,u);if(!p||!W(p))return!1;let m=pu(i[0].value,2,u);if(!m||!W(m))return!1;let h=[f,p,m];if(a.length===1)if(u.syntaxFlags.add(Y.HasAlpha),q(a[0])){let e=pu(a[0].value,3,u);if(!e||!W(e))return!1;h.push(e)}else u.alpha=a[0];else if(o&&o.has(`alpha`)){let e=pu(o.get(`alpha`),3,u);if(!e||!W(e))return!1;h.push(e)}return u.channels=[h[0][4].value,h[1][4].value,h[2][4].value],h.length===4&&(u.alpha=h[3][4].value),u}function gu(e){switch(e){case`srgb`:return J.sRGB;case`srgb-linear`:return J.Linear_sRGB;case`display-p3`:return J.Display_P3;case`display-p3-linear`:return J.Linear_Display_P3;case`a98-rgb`:return J.A98_RGB;case`prophoto-rgb`:return J.ProPhoto_RGB;case`rec2020`:return J.Rec2020;case`xyz`:case`xyz-d65`:return J.XYZ_D65;case`xyz-d50`:return J.XYZ_D50;default:throw Error(`Unknown color space name: `+e)}}const _u=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`lab`,`oklab`,`xyz`,`xyz-d50`,`xyz-d65`]),vu=new Set([`hsl`,`hwb`,`lch`,`oklch`]),yu=new Set([`shorter`,`longer`,`increasing`,`decreasing`]);function bu(e,t){let n=null,r=null,i=null,a=!1;for(let o=0;o<e.value.length;o++){let s=e.value[o];if(!Sc(s)){if(!(n||q(s)&&U(s.value)&&Q(s.value[4].value)===`in`))return Su(`oklab`,xu(e.value,t));if(q(s)&&U(s.value)){if(!n&&Q(s.value[4].value)===`in`){n=s;continue}if(n&&!r){r=Q(s.value[4].value);continue}if(n&&r&&!i&&vu.has(r)){i=Q(s.value[4].value);continue}if(n&&r&&i&&!a&&Q(s.value[4].value)===`hue`){a=!0;continue}return!1}return!(!q(s)||!uo(s.value))&&!!r&&(i||a?!!(i&&a&&vu.has(r)&&yu.has(i))&&wu(r,i,xu(e.value.slice(o+1),t)):_u.has(r)?Su(r,xu(e.value.slice(o+1),t)):!!vu.has(r)&&wu(r,`shorter`,xu(e.value.slice(o+1),t)))}}return!1}function xu(e,t){let n=[],r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(!Sc(o)){if(!q(o)||!uo(o.value)){if(!r){let e=t(o);if(e){r=e;continue}}if(!i){if(yc(o)&&ru.has(Q(o.getName()))){if([[o]]=tu([[o]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0}),!o||!q(o)||!V(o.value))return!1;Number.isNaN(o.value[4].value)&&(o.value[4].value=0)}if(q(o)&&G(o.value)&&o.value[4].value>=0){i=o.value[4].value;continue}}return!1}if(!r)return!1;n.push({color:r,percentage:i}),r=!1,i=!1}}return!!r&&(n.push({color:r,percentage:i}),n)}function Su(e,t){if(!t||!t.length)return!1;for(let e of t)if(e.percentage&&(e.percentage<0||e.percentage>100))return!1;let{items:n,leftover:r}=Au(t,!0),i=1-r/100,a;switch(e){case`srgb`:a=J.RGB;break;case`srgb-linear`:a=J.Linear_sRGB;break;case`display-p3`:a=J.Display_P3;break;case`display-p3-linear`:a=J.Linear_Display_P3;break;case`a98-rgb`:a=J.A98_RGB;break;case`prophoto-rgb`:a=J.ProPhoto_RGB;break;case`rec2020`:a=J.Rec2020;break;case`lab`:a=J.Lab;break;case`oklab`:a=J.OKLab;break;case`xyz-d50`:a=J.XYZ_D50;break;case`xyz`:case`xyz-d65`:a=J.XYZ_D65;break;default:return!1}if(n.length===1){let e=su(n[0].color,a);return e.colorNotation=a,e.syntaxFlags.add(Y.ColorMixVariadic),typeof e.alpha==`number`?(e.alpha*=i,e):!1}for(n.reverse();n.length>=2;){let e=n.pop(),t=n.pop();if(!e||!t)return!1;let r=e.percentage+t.percentage,i=r>0?t.percentage/r:.5,o=Cu(a,e.color,t.color,i);if(!o)return!1;n.push({color:o,percentage:r})}let o=n[0]?.color;return!!o&&typeof o.alpha==`number`&&(o.alpha*=i,t.some(e=>e.color.syntaxFlags.has(Y.Experimental))&&o.syntaxFlags.add(Y.Experimental),t.length!==2&&o.syntaxFlags.add(Y.ColorMixVariadic),o)}function Cu(e,t,n,r){let i=t.alpha;if(typeof i!=`number`)return!1;let a=n.alpha;if(typeof a!=`number`)return!1;i=Number.isNaN(i)?a:i,a=Number.isNaN(a)?i:a;let o=su(t,e).channels,s=su(n,e).channels;o[0]=Eu(o[0],s[0]),s[0]=Eu(s[0],o[0]),o[1]=Eu(o[1],s[1]),s[1]=Eu(s[1],o[1]),o[2]=Eu(o[2],s[2]),s[2]=Eu(s[2],o[2]),o[0]=Ou(o[0],i),o[1]=Ou(o[1],i),o[2]=Ou(o[2],i),s[0]=Ou(s[0],a),s[1]=Ou(s[1],a),s[2]=Ou(s[2],a);let c=Du(i,a,r);return{colorNotation:e,channels:[ku(Du(o[0],s[0],r),c),ku(Du(o[1],s[1],r),c),ku(Du(o[2],s[2],r),c)],alpha:c,syntaxFlags:new Set([Y.ColorMix])}}function wu(e,t,n){if(!n||!n.length)return!1;for(let e of n)if(e.percentage&&(e.percentage<0||e.percentage>100))return!1;let{items:r,leftover:i}=Au(n,!0),a=1-i/100,o;switch(e){case`hsl`:o=J.HSL;break;case`hwb`:o=J.HWB;break;case`lch`:o=J.LCH;break;case`oklch`:o=J.OKLCH;break;default:return!1}if(r.length===1){let e=su(r[0].color,o);return e.colorNotation=o,e.syntaxFlags.add(Y.ColorMixVariadic),typeof e.alpha==`number`?(e.alpha*=a,e):!1}for(r.reverse();r.length>=2;){let e=r.pop(),n=r.pop();if(!e||!n)return!1;let i=e.percentage+n.percentage,a=i>0?n.percentage/i:.5,s=Tu(o,t,e.color,n.color,a);if(!s)return!1;r.push({color:s,percentage:i})}let s=r[0]?.color;return!!s&&typeof s.alpha==`number`&&(s.alpha*=a,n.some(e=>e.color.syntaxFlags.has(Y.Experimental))&&s.syntaxFlags.add(Y.Experimental),n.length!==2&&s.syntaxFlags.add(Y.ColorMixVariadic),s)}function Tu(e,t,n,r,i){let a=0,o=0,s=0,c=0,l=0,u=0,d=n.alpha;if(typeof d!=`number`)return!1;let f=r.alpha;if(typeof f!=`number`)return!1;d=Number.isNaN(d)?f:d,f=Number.isNaN(f)?d:f;let p=su(n,e).channels,m=su(r,e).channels;switch(e){case J.HSL:case J.HWB:a=p[0],o=m[0],s=p[1],c=m[1],l=p[2],u=m[2];break;case J.LCH:case J.OKLCH:s=p[0],c=m[0],l=p[1],u=m[1],a=p[2],o=m[2]}a=Eu(a,o),Number.isNaN(a)&&(a=0),o=Eu(o,a),Number.isNaN(o)&&(o=0),s=Eu(s,c),c=Eu(c,s),l=Eu(l,u),u=Eu(u,l);let h=o-a;switch(t){case`shorter`:h>180?a+=360:h<-180&&(o+=360);break;case`longer`:-180<h&&h<180&&(h>0?a+=360:o+=360);break;case`increasing`:h<0&&(o+=360);break;case`decreasing`:h>0&&(a+=360);break;default:throw Error(`Unknown hue interpolation method`)}s=Ou(s,d),l=Ou(l,d),c=Ou(c,f),u=Ou(u,f);let g=[0,0,0],_=Du(d,f,i);switch(e){case J.HSL:case J.HWB:g=[Du(a,o,i),ku(Du(s,c,i),_),ku(Du(l,u,i),_)];break;case J.LCH:case J.OKLCH:g=[ku(Du(s,c,i),_),ku(Du(l,u,i),_),Du(a,o,i)]}return{colorNotation:e,channels:g,alpha:_,syntaxFlags:new Set([Y.ColorMix])}}function Eu(e,t){return Number.isNaN(e)?t:e}function Du(e,t,n){return e*(1-n)+t*n}function Ou(e,t){return Number.isNaN(t)?e:Number.isNaN(e)?NaN:e*t}function ku(e,t){return t===0||Number.isNaN(t)?e:Number.isNaN(e)?NaN:e/t}function Au(e,t=!1){let n=0,r=0;for(let t of e)t.percentage&&(n+=t.percentage),!1===t.percentage&&r++;n=Math.min(100,n);for(let t of e)!1===t.percentage&&(t.percentage=(100-n)/r);let i=e.slice(),a=0;for(let e of i)a+=e.percentage;if(a>100||a>0&&t)for(let e of i)e.percentage*=100/a;let o=0;return a<100&&(o=100-a),{items:i,leftover:o}}function ju(e){let t=Q(e[4].value);if(t.match(/[^a-f0-9]/))return!1;let n={colorNotation:J.HEX,channels:[0,0,0],alpha:1,syntaxFlags:new Set([Y.Hex])},r=t.length;if(r===3){let e=t[0],r=t[1],i=t[2];return n.channels=[parseInt(e+e,16)/255,parseInt(r+r,16)/255,parseInt(i+i,16)/255],n}if(r===6){let e=t[0]+t[1],r=t[2]+t[3],i=t[4]+t[5];return n.channels=[parseInt(e,16)/255,parseInt(r,16)/255,parseInt(i,16)/255],n}if(r===4){let e=t[0],r=t[1],i=t[2],a=t[3];return n.channels=[parseInt(e+e,16)/255,parseInt(r+r,16)/255,parseInt(i+i,16)/255],n.alpha=parseInt(a+a,16)/255,n.syntaxFlags.add(Y.HasAlpha),n}if(r===8){let e=t[0]+t[1],r=t[2]+t[3],i=t[4]+t[5],a=t[6]+t[7];return n.channels=[parseInt(e,16)/255,parseInt(r,16)/255,parseInt(i,16)/255],n.alpha=parseInt(a,16)/255,n.syntaxFlags.add(Y.HasAlpha),n}return!1}function Mu(e){if(W(e))return e[4].value=e[4].value%360,e[1]=e[4].value.toString(),e;if(H(e)){let t=e[4].value;switch(Q(e[4].unit)){case`deg`:break;case`rad`:t=180*e[4].value/Math.PI;break;case`grad`:t=.9*e[4].value;break;case`turn`:t=360*e[4].value;break;default:return!1}return t%=360,[z.Number,t.toString(),e[2],e[3],{value:t,type:B.Number}]}return!1}function Nu(e,t,n){if(t===0){let t=Mu(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,1,0,100);return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){if(t!==3)return!1;let n=Z(e[4].value,1,0,100);return t===3&&(n=Z(e[4].value,1,0,1)),[z.Number,n.toString(),e[2],e[3],{value:n,type:B.Number}]}return!1}function Pu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===0){let t=Mu(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=e[4].value;return t===3?r=Z(e[4].value,100,0,1):t===1&&(r=Z(e[4].value,1,0,2147483647)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=e[4].value;return t===3?r=Z(e[4].value,1,0,1):t===1&&(r=Z(e[4].value,1,0,2147483647)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Fu(e,t,n,r){let i=[],a=[],o=[],s=[],c={colorNotation:n,channels:[0,0,0],alpha:1,syntaxFlags:new Set(r)},l=i;for(let t=0;t<e.value.length;t++){let n=e.value[t];if(!bc(n)&&!xc(n)){if(q(n)&&uo(n.value)){if(l===i){l=a;continue}if(l===a){l=o;continue}if(l===o){l=s;continue}if(l===s)return!1}if(yc(n)){if(l===s&&n.getName().toLowerCase()===`var`){c.syntaxFlags.add(Y.HasVariableAlpha),l.push(n);continue}if(!ru.has(n.getName().toLowerCase()))return!1;let[[e]]=tu([[n]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),n=e}if(!q(n))return!1;l.push(n)}}if(l.length!==1||i.length!==1||a.length!==1||o.length!==1||!q(i[0])||!q(a[0])||!q(o[0]))return!1;let u=t(i[0].value,0,c);if(!u||!W(u))return!1;let d=t(a[0].value,1,c);if(!d||!W(d))return!1;let f=t(o[0].value,2,c);if(!f||!W(f))return!1;let p=[u,d,f];if(s.length===1)if(c.syntaxFlags.add(Y.HasAlpha),q(s[0])){let e=t(s[0].value,3,c);if(!e||!W(e))return!1;p.push(e)}else c.alpha=s[0];return c.channels=[p[0][4].value,p[1][4].value,p[2][4].value],p.length===4&&(c.alpha=p[3][4].value),c}function Iu(e,t,n,r,i){let a=[],o=[],s=[],c=[],l,u,d=!1,f={colorNotation:n,channels:[0,0,0],alpha:1,syntaxFlags:new Set(r)},p=a;for(let t=0;t<e.value.length;t++){let r=e.value[t];if(bc(r)||xc(r))for(;bc(e.value[t+1])||xc(e.value[t+1]);)t++;else if(p===a&&a.length&&(p=o),p===o&&o.length&&(p=s),q(r)&&po(r.value)&&r.value[4].value===`/`){if(p===c)return!1;p=c}else{if(yc(r)){if(p===c&&r.getName().toLowerCase()===`var`){f.syntaxFlags.add(Y.HasVariableAlpha),p.push(r);continue}if(!ru.has(r.getName().toLowerCase()))return!1;let[[e]]=tu([[r]],{censorIntoStandardRepresentableValues:!0,globals:u,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),r=e}if(p===a&&a.length===0&&q(r)&&U(r.value)&&r.value[4].value.toLowerCase()===`from`){if(d)return!1;for(;bc(e.value[t+1])||xc(e.value[t+1]);)t++;if(t++,r=e.value[t],d=i(r),!1===d)return!1;d.syntaxFlags.has(Y.Experimental)&&f.syntaxFlags.add(Y.Experimental),f.syntaxFlags.add(Y.RelativeColorSyntax),d.colorNotation!==n&&(d=su(d,n)),l=uu(d),u=du(l)}else{if(!q(r))return!1;if(U(r.value)&&l){let e=r.value[4].value.toLowerCase();if(l.has(e)){p.push(new K(l.get(e)));continue}}p.push(r)}}}if(p.length!==1||a.length!==1||o.length!==1||s.length!==1||!q(a[0])||!q(o[0])||!q(s[0])||l&&!l.has(`alpha`))return!1;let m=t(a[0].value,0,f);if(!m||!W(m))return!1;let h=t(o[0].value,1,f);if(!h||!W(h))return!1;let g=t(s[0].value,2,f);if(!g||!W(g))return!1;let _=[m,h,g];if(c.length===1)if(f.syntaxFlags.add(Y.HasAlpha),q(c[0])){let e=t(c[0].value,3,f);if(!e||!W(e))return!1;_.push(e)}else f.alpha=c[0];else if(l&&l.has(`alpha`)){let e=t(l.get(`alpha`),3,f);if(!e||!W(e))return!1;_.push(e)}return f.channels=[_[0][4].value,_[1][4].value,_[2][4].value],_.length===4&&(f.alpha=_[3][4].value),f}function Lu(e,t){if(e.value.some(e=>q(e)&&uo(e.value))){let t=Ru(e);if(!1!==t)return t}{let n=zu(e,t);if(!1!==n)return n}return!1}function Ru(e){return Fu(e,Nu,J.HSL,[Y.LegacyHSL])}function zu(e,t){return Iu(e,Pu,J.HSL,[],t)}function Bu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===0){let t=Mu(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=e[4].value;return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=e[4].value;return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Vu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,1,0,100);return t===1||t===2?r=Z(e[4].value,.8,-2147483647,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,100);return t===1||t===2?r=Z(e[4].value,1,-2147483647,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Hu(e,t){return Iu(e,Vu,J.Lab,[],t)}function Uu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===2){let t=Mu(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,1,0,100);return t===1?r=Z(e[4].value,100/150,0,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,100);return t===1?r=Z(e[4].value,1,0,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Wu(e,t){return Iu(e,Uu,J.LCH,[],t)}const Gu=new Map;for(let[e,t]of Object.entries(Qs))Gu.set(e,t);function Ku(e){let t=Gu.get(Q(e));return!!t&&{colorNotation:J.RGB,channels:[t[0]/255,t[1]/255,t[2]/255],alpha:1,syntaxFlags:new Set([Y.ColorKeyword,Y.NamedColor])}}function qu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,0,1);return t===1||t===2?r=Z(e[4].value,250,-2147483647,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,1);return t===1||t===2?r=Z(e[4].value,1,-2147483647,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Ju(e,t){return Iu(e,qu,J.OKLab,[],t)}function Yu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===2){let t=Mu(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,0,1);return t===1?r=Z(e[4].value,250,0,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,1);return t===1?r=Z(e[4].value,1,0,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Xu(e,t){return Iu(e,Yu,J.OKLCH,[],t)}function Zu(e,t,n){if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,0,1);return[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,255,0,1);return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Qu(e,t,n){if(U(e)&&e[4].value.toLowerCase()===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,255,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function $u(e,t){if(e.value.some(e=>q(e)&&uo(e.value))){let t=ed(e);if(!1!==t)return(!t.syntaxFlags.has(Y.HasNumberValues)||!t.syntaxFlags.has(Y.HasPercentageValues))&&t}else{let n=td(e,t);if(!1!==n)return n}return!1}function ed(e){return Fu(e,Zu,J.RGB,[Y.LegacyRGB])}function td(e,t){return Iu(e,Qu,J.RGB,[],t)}function nd(e){let t=bs(e);if(Js(t))return Ys(t);let n=e;return n=Ms(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),$o(Xs(n,rd,id))}function rd(e){return e=Fo(e),e=zo(e),Zo(e)}function id(e){return e=gs(e),e=Wo(e),Io(e)}function ad(e,t){let n=!1;for(let r=0;r<e.value.length;r++){let i=e.value[r];if(!bc(i)&&!xc(i)&&(n||(n=t(i),!n)))return!1}if(!n)return!1;n.channels=iu(n.channels),n.channels=nd(au(n).channels),n.colorNotation=J.sRGB;let r={colorNotation:J.RGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([Y.ContrastColor,Y.Experimental])};return r.channels=ec(n.channels,[1,1,1])>ec(n.channels,[0,0,0])?[1,1,1]:[0,0,0],r}function od(e,t){let n,r,i=!1,a=!1,o=!1,s={colorNotation:J.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])};for(let c=0;c<e.value.length;c++){let l=e.value[c];if(bc(l)||xc(l))for(;bc(e.value[c+1])||xc(e.value[c+1]);)c++;else if(o&&!i&&!a&&q(l)&&po(l.value)&&l.value[4].value===`/`)i=!0;else{if(yc(l)&&ru.has(Q(l.getName()))){let[[e]]=tu([[l]],{censorIntoStandardRepresentableValues:!0,globals:r,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),l=e}if(i||a||!q(l)||!U(l.value)||Q(l.value[4].value)!==`from`){if(!i||a)return!1;if(q(l)){if(U(l.value)&&Q(l.value[4].value)===`alpha`&&n&&n.has(`alpha`)){s.alpha=n.get(`alpha`)[4].value,a=!0;continue}let e=pu(l.value,3,s);if(!e||!W(e))return!1;s.alpha=new K(e),a=!0;continue}if(yc(l)){s.alpha=_c([[l]],e=>{if(q(e)&&U(e.value)&&Q(e.value[4].value)===`alpha`&&n&&n.has(`alpha`))return new K(n.get(`alpha`))})[0][0],a=!0;continue}return!1}if(o)return!1;for(;bc(e.value[c+1])||xc(e.value[c+1]);)c++;if(c++,l=e.value[c],o=t(l),!1===o)return!1;n=uu(o),r=du(n),s.syntaxFlags=new Set(o.syntaxFlags),s.syntaxFlags.add(Y.RelativeAlphaSyntax),s.channels=[...o.channels],s.colorNotation=o.colorNotation,s.alpha=o.alpha}}return!!n&&s}function sd(e){if(yc(e))switch(Q(e.getName())){case`rgb`:case`rgba`:return $u(e,sd);case`hsl`:case`hsla`:return Lu(e,sd);case`hwb`:return t=sd,Iu(e,Bu,J.HWB,[],t);case`lab`:return Hu(e,sd);case`lch`:return Wu(e,sd);case`oklab`:return Ju(e,sd);case`oklch`:return Xu(e,sd);case`color`:return hu(e,sd);case`color-mix`:return bu(e,sd);case`contrast-color`:return ad(e,sd);case`alpha`:return od(e,sd)}var t;if(q(e)){if(go(e.value))return ju(e.value);if(U(e.value)){let t=Ku(e.value[4].value);return!1===t?Q(e.value[4].value)===`transparent`&&{colorNotation:J.RGB,channels:[0,0,0],alpha:0,syntaxFlags:new Set([Y.ColorKeyword])}:t}}return!1}function cd(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function ld(e){switch(e.colorNotation){case`hex`:case`rgb`:case`srgb`:return{...e,colorNotation:`xyz-d50`,channels:ys(cd(e.channels))};case`srgb-linear`:return{...e,colorNotation:`xyz-d50`,channels:Ns(cd(e.channels))};case`display-p3`:return{...e,colorNotation:`xyz-d50`,channels:Ls(cd(e.channels))};case`display-p3-linear`:return{...e,colorNotation:`xyz-d50`,channels:zs(cd(e.channels))};case`rec2020`:return{...e,colorNotation:`xyz-d50`,channels:Vs(cd(e.channels))};case`a98-rgb`:return{...e,colorNotation:`xyz-d50`,channels:Fs(cd(e.channels))};case`prophoto-rgb`:return{...e,colorNotation:`xyz-d50`,channels:Us(cd(e.channels))};case`hsl`:return{...e,colorNotation:`xyz-d50`,channels:xs(cd(e.channels))};case`hwb`:return{...e,colorNotation:`xyz-d50`,channels:Cs(cd(e.channels))};case`lab`:return{...e,colorNotation:`xyz-d50`,channels:Ts(cd(e.channels))};case`oklab`:return{...e,colorNotation:`xyz-d50`,channels:ks(cd(e.channels))};case`lch`:return{...e,colorNotation:`xyz-d50`,channels:Ds(cd(e.channels))};case`oklch`:return{...e,colorNotation:`xyz-d50`,channels:js(cd(e.channels))};case`xyz-d50`:return{...e,colorNotation:`xyz-d50`,channels:qs(cd(e.channels))};case`xyz-d65`:return{...e,colorNotation:`xyz-d50`,channels:Gs(cd(e.channels))};default:throw Error(`Unsupported color notation`)}}function ud(e,t=7){e=+e,t=+t;let n=(Math.floor(Math.abs(e))+``).length;if(t>n)return+e.toFixed(t-n);{let r=10**(n-t);return Math.round(e/r)*r}}function dd(e){let t=bs(e);if(Js(t))return Ys(t);let n=e;return n=Ms(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),$o(Xs(n,fd,pd))}function fd(e){return e=Fo(e),e=zo(e),Zo(e)}function pd(e){return e=gs(e),e=Wo(e),Io(e)}var md=class e{static colorTxtList=[];static parseColorString(e){try{let t=mc($a({css:e}));if(!t)return null;let n=sd(t);if(n===!1)return null;let r=dd(ld(n).channels),i=Math.min(255,Math.max(0,Math.round(ud(r[0])*255))),a=Math.min(255,Math.max(0,Math.round(ud(r[1])*255))),o=Math.min(255,Math.max(0,Math.round(ud(r[2])*255))),s=1;return typeof n.alpha==`number`&&(s=Math.min(1,Math.max(0,ud(Number.isNaN(n.alpha)?0:n.alpha)))),m.Color.create(i/255,a/255,o/255,s)}catch(e){return $.error(e),null}}static getPos(e,t){let n=Array.from(e.slice(0,t).matchAll(/\n/g)),r=n.length,i=n[r-1],a=0;i.index&&(a=i.index);let o=t-a;return m.Position.create(r,o-1)}static getMatches(e){let t=[],n=e.matchAll(/(#(?:[\da-f]{3,4}){2}|#(?:[\da-f]{3})|rgb\((?:\d{1,3},\s*){2}\d{1,3}\)|rgba\((?:\d{1,3},\s*){3}\d*\.?\d+\)|hsl\(\d{1,3}(?:,\s*\d{1,3}%){2}\)|hsla\(\d{1,3}(?:,\s*\d{1,3}%){2},\s*\d*\.?\d+\|oklab\(\s*\d*\.?\d+\s*,\s*-?\d*\.?\d+\s*,\s*-?\d*\.?\d+\s*\)|oklch\(\s*\d*\.?\d+%?\s*(,| )\s*\d*\.?\d+\s*(,| )\s*\d*\.?\d+\s*\))/gi);if(n)for(let r of n){let n=r[0];if(!r.index)continue;let i=n.length,a=``;n.startsWith(`hsl(`)?a=`hsl`:n.startsWith(`hsla(`)?a=`hsla`:n.startsWith(`rgb(`)?a=`rgb`:n.startsWith(`rgba(`)?a=`rgba`:n.startsWith(`#`)?a=`hex`:n.startsWith(`oklch(`)?a=`oklch`:n.startsWith(`oklab(`)&&(a=`oklab`);let o=m.Range.create(this.getPos(e,r.index),this.getPos(e,r.index+n.length)),s=this.parseColorString(n);s&&t.push({color:s,type:a,length:i,range:o})}if(this.colorTxtList.length==0){let e=Object.getOwnPropertyNames(da.Colors),t=[];for(let n of e)n!=`name`&&n!=`length`&&n!=`prototype`&&t.push(n);this.colorTxtList=t}let r=RegExp(`(?<![\\w\\d."'&$-])(`+this.colorTxtList.join(`|`)+`)(?![-\\w\\d])`,`gi`),i=e.matchAll(r);if(i)for(let n of i){let r=n[0];if(!n.index)continue;let i=r.length,a=m.Range.create(this.getPos(e,n.index),this.getPos(e,n.index+r.length)),o=this.parseColorString(da.fromName(r).toHex());o&&t.push({color:o,type:`hex`,length:i,range:a})}return t}static onDocumentColor(t){return e.getMatches(t.getText()).map(e=>m.ColorInformation.create(e.range,e.color))}static onColorPresentations(e,t,n){let r=da.fromRgb(n.red*255,n.green*255,n.blue*255);r.alpha=n.alpha;let i=e.getText(t),a=m.ColorPresentation.create(r.toString(`hex`)),o=m.ColorPresentation.create(r.toString(`hexa`)),s=m.ColorPresentation.create(r.toString(`hsl`)),c=m.ColorPresentation.create(r.toString(`hsla`)),l=m.ColorPresentation.create(r.toString(`rgb`)),u=m.ColorPresentation.create(r.toString(`rgba`)),d=!1;return i.startsWith(`#`)&&i.length===9&&(d=!0),i.startsWith(`hsla`)&&(d=!0),i.startsWith(`rgba`)&&(d=!0),n.alpha!==1&&(d=!0),d?[o,c,u]:[a,s,l]}},hd=class{static send(e){$.sendNotification(`aventus/openfile`,e)}},gd=class{static cmd=`aventus.addConfigSection`;static async run(e){try{if(!e){let t=[],n=N.getInstance().getAllConfigFiles();for(let e of n)t.push({label:e});if(t.length>1){let n=await $.Select(t,{title:`Select a project to add section`});if(!n)return;e=n.label}else e=t[0].label}let t=await $.Select([{label:`Build`},{label:`Static`}],{title:`Section type`});if(!t)return;let n=(0,u.readFileSync)(I(e),`utf8`),r=JSON.parse(n);if(t.label==`Build`){let e=await $.Input({title:`Provide a name for your build section`});if(!e)return;let t={name:e,src:[],compile:{output:`./dist/`+e.replace(/ /g,`-`)+`.js`}};r.build.push(t)}else if(t.label==`Static`){let e=await $.Input({title:`Provide a name for your static section`});if(!e)return;let t={name:e,input:``,output:``};r.static.push(t)}(0,u.writeFileSync)(I(e),JSON.stringify(r,null,4)),hd.send(e)}catch(e){console.error(e)}}},_d=class{static cmd=`aventus.compile`;static async run(){let e=[],t=N.getInstance().getAllBuilds();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Project to compile`});if(n){let e=n.detail??``,t=n.label;N.getInstance().getProjectByUri(e)?.getBuild(t)?.build()}}},vd=class e{static cmd=`aventus.create`;static async run(t){if(!t)return;let n=(0,f.normalize)(I(t));if(e.checkIfProject(t)){if(!$.isIDE){let e=await $.SelectFolder(`Select where to create`,n);if(!e)return;t=e,n=I(t)}await $.localTemplateManager?.createTemplate(n)}else await $.localProjectManager?.createGlobal(n)}static checkIfProject(e){let t=N.getInstance().getAllConfigFiles(),n=e.replace(/\\/g,`/`);for(let e of t)if(n.startsWith(e.replace(`/`+w.Config,``)))return!0;return!1}},yd=class{static cmd=`aventus.filesystem.created`;static run(e){e&&R.getInstance().onCreatedUri(e)}},bd=class{static cmd=`aventus.filesystem.deleted`;static async run(e){e&&R.getInstance().onDeletedUri(e)}},xd=class{static cmd=`aventus.filesystem.updated`;static async run(e){e&&R.getInstance().onUpdatedUri(e)}},Sd=class{static send(e){$.sendNotification(`aventus/closefile`,e)}},Cd=class{static cmd=`aventus.component.merge`;static async run(e){if(!e)return;let t=RegExp(`(`+w.ComponentLogic+`)|(`+w.ComponentView+`)|(`+w.ComponentView+`)$`),n=e.replace(t,``),r=n.split(`/`),i=r.pop(),a=r.pop(),o=r.join(`/`)+`/`+i,s=0,c=R.getInstance().getByUri(n+w.ComponentLogic);c&&c.versionUser>s&&(s=c.versionUser);let l=c?c.contentUser:``,f=R.getInstance().getByUri(n+w.ComponentStyle);f&&f.versionUser>s&&(s=f.versionUser);let p=f?f.contentUser:``,m=R.getInstance().getByUri(n+w.ComponentView);m&&m.versionUser>s&&(s=m.versionUser);let h=m?m.contentUser:``,g=`
991
+ */function $s(e,t,n){let r=e[0],i=e[2],a=t(e),o=t([r,0,i]);for(let e=0;e<4;e++){if(e>0){let e=n(a);e[0]=r,e[2]=i,a=t(e)}let s=ec(o,a);if(!s)break;a=s}return Qs(a)}function ec(e,t){let n=1/0,r=-1/0,i=[0,0,0];for(let a=0;a<3;a++){let o=e[a],s=t[a]-o;if(i[a]=s,Math.abs(s)>1e-15){let e=1/s,t=(0-o)*e,i=(1-o)*e;r=Math.max(Math.min(t,i),r),n=Math.min(Math.max(t,i),n)}else if(o<0||o>1)return!1}return!(r>n||n<0)&&(r<0&&(r=n),!!isFinite(r)&&[e[0]+i[0]*r,e[1]+i[1]*r,e[2]+i[2]*r])}const tc={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function nc(e){let[t,n,r]=e.map(e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4);return .2126*t+.7152*n+.0722*r}function rc(e,t){let n=nc(e),r=nc(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}var ic;function ac(e){let t=e.slice();return(e,n,r)=>{let i=-1;for(let a=t.indexOf(n);a<t.length&&(i=e.indexOf(t[a]),i===-1||i<r);a++);return i===-1||i===r&&n===e[r]&&(i++,i>=e.length)?-1:(t=e.slice(),i)}}function oc(e,t){let n=t[0];if(So(n)||To(n)||wo(n)){let n=dc(e,t);return{advance:n.advance,node:n.node}}if(vo(n)){let n=lc(e,t);return{advance:n.advance,node:n.node}}if(xo(n)){let n=pc(e,t);return{advance:n.advance,node:n.node}}if(ho(n)){let n=hc(e,t);return{advance:n.advance,node:n.node}}return{advance:1,node:new K(n)}}(function(e){e.Function=`function`,e.SimpleBlock=`simple-block`,e.Whitespace=`whitespace`,e.Comment=`comment`,e.Token=`token`})(ic||={});var sc=class{value=[];indexOf(e){return this.value.indexOf(e)}at(e){if(typeof e==`number`)return e<0&&(e=this.value.length+e),this.value[e]}forEach(e,t){if(this.value.length===0)return;let n=ac(this.value),r=0;for(;r<this.value.length;){let i=this.value[r],a;if(t&&(a={...t}),!1===e({node:i,parent:this,state:a},r))return!1;if(r=n(this.value,i,r),r===-1)break}}walk(e,t){this.value.length!==0&&this.forEach((t,n)=>!1!==e(t,n)&&(!(`walk`in t.node)||!this.value.includes(t.node)||!1!==t.node.walk(e,t.state))&&void 0,t)}},cc=class e extends sc{type=ic.Function;name;endToken;constructor(e,t,n){super(),this.name=e,this.endToken=t,this.value=n}getName(){return this.name[4].value}normalize(){_o(this.endToken)&&(this.endToken=[z.CloseParen,`)`,-1,-1,void 0])}tokens(){return _o(this.endToken)?[this.name,...this.value.flatMap(e=>e.tokens())]:[this.name,...this.value.flatMap(e=>e.tokens()),this.endToken]}toString(){let e=this.value.map(e=>uo(e)?va(e):e.toString()).join(``);return va(this.name)+e+va(this.endToken)}toJSON(){return{type:this.type,name:this.getName(),tokens:this.tokens(),value:this.value.map(e=>e.toJSON())}}isFunctionNode(){return e.isFunctionNode(this)}static isFunctionNode(t){return!!t&&t instanceof e&&t.type===ic.Function}};function lc(e,t){let n=[],r=1;for(;;){let i=t[r];if(!i||_o(i))return e.onParseError(new ha(`Unexpected EOF while consuming a function.`,t[0][2],t[t.length-1][3],[`5.4.9. Consume a function`,`Unexpected EOF`])),{advance:t.length,node:new cc(t[0],i,n)};if(Co(i))return{advance:r+1,node:new cc(t[0],i,n)};if(fo(i)){let i=gc(e,t.slice(r));r+=i.advance,n.push(...i.nodes);continue}let a=oc(e,t.slice(r));r+=a.advance,n.push(a.node)}}var uc=class e extends sc{type=ic.SimpleBlock;startToken;endToken;constructor(e,t,n){super(),this.startToken=e,this.endToken=t,this.value=n}normalize(){if(_o(this.endToken)){let e=Ba(this.startToken);e&&(this.endToken=e)}}tokens(){return _o(this.endToken)?[this.startToken,...this.value.flatMap(e=>e.tokens())]:[this.startToken,...this.value.flatMap(e=>e.tokens()),this.endToken]}toString(){let e=this.value.map(e=>uo(e)?va(e):e.toString()).join(``);return va(this.startToken)+e+va(this.endToken)}toJSON(){return{type:this.type,startToken:this.startToken,tokens:this.tokens(),value:this.value.map(e=>e.toJSON())}}isSimpleBlockNode(){return e.isSimpleBlockNode(this)}static isSimpleBlockNode(t){return!!t&&t instanceof e&&t.type===ic.SimpleBlock}};function dc(e,t){let n=za(t[0][0]);if(!n)throw Error(`Failed to parse, a mirror variant must exist for all block open tokens.`);let r=[],i=1;for(;;){let a=t[i];if(!a||_o(a))return e.onParseError(new ha(`Unexpected EOF while consuming a simple block.`,t[0][2],t[t.length-1][3],[`5.4.8. Consume a simple block`,`Unexpected EOF`])),{advance:t.length,node:new uc(t[0],a,r)};if(a[0]===n)return{advance:i+1,node:new uc(t[0],a,r)};if(fo(a)){let n=gc(e,t.slice(i));i+=n.advance,r.push(...n.nodes);continue}let o=oc(e,t.slice(i));i+=o.advance,r.push(o.node)}}var fc=class e{type=ic.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return va(...this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isWhitespaceNode(){return e.isWhitespaceNode(this)}static isWhitespaceNode(t){return!!t&&t instanceof e&&t.type===ic.Whitespace}};function pc(e,t){let n=0;for(;;){let e=t[n];if(!xo(e))return{advance:n,node:new fc(t.slice(0,n))};n++}}var mc=class e{type=ic.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return va(this.value)}toJSON(){return{type:this.type,tokens:this.tokens()}}isCommentNode(){return e.isCommentNode(this)}static isCommentNode(t){return!!t&&t instanceof e&&t.type===ic.Comment}};function hc(e,t){return{advance:1,node:new mc(t[0])}}function gc(e,t){let n=[],r=0;for(;;){if(xo(t[r])){let e=pc(0,t.slice(r));r+=e.advance,n.push(e.node);continue}if(!ho(t[r]))return{advance:r,nodes:n};n.push(new mc(t[r])),r++}}var K=class e{type=ic.Token;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return this.value[1]}toJSON(){return{type:this.type,tokens:this.tokens()}}isTokenNode(){return e.isTokenNode(this)}static isTokenNode(t){return!!t&&t instanceof e&&t.type===ic.Token}};function _c(e,t){let n={onParseError:t?.onParseError??(()=>{})},r=[...e];_o(r[r.length-1])||r.push([z.EOF,``,r[r.length-1][2],r[r.length-1][3],void 0]);let i=oc(n,r);if(_o(r[Math.min(i.advance,r.length-1)]))return i.node;n.onParseError(new ha(`Expected EOF after parsing a component value.`,e[0][2],e[e.length-1][3],[`5.3.9. Parse a component value`,`Expected EOF`]))}function vc(e,t,n){if(e.length===0)return;let r=ac(e),i=0;for(;i<e.length;){let a=e[i],o;if(n&&(o={...n}),!1===t({node:a,parent:{value:e},state:o},i))return!1;if(i=r(e,a,i),i===-1)break}}function yc(e,t,n){e.length!==0&&vc(e,(n,r)=>!1!==t(n,r)&&(!(`walk`in n.node)||!e.includes(n.node)||!1!==n.node.walk(t,n.state))&&void 0,n)}function bc(e,t){for(let n=0;n<e.length;n++)yc(e[n],(e,n)=>{if(typeof n!=`number`)return;let r=t(e.node);r&&(Array.isArray(r)?e.parent.value.splice(n,1,...r):e.parent.value.splice(n,1,r))});return e}function xc(e){return uc.isSimpleBlockNode(e)}function Sc(e){return cc.isFunctionNode(e)}function Cc(e){return fc.isWhitespaceNode(e)}function wc(e){return mc.isCommentNode(e)}function Tc(e){return Cc(e)||wc(e)}function q(e){return K.isTokenNode(e)}function Ec(e){if(Array.isArray(e)){let t=e[0];if(!t)return[0,0];let n=e[e.length-1]||t;return[Ec(t)[0],Ec(n)[1]]}let t=e.tokens(),n=t[0],r=t[t.length-1];return n&&r?[n[2],r[3]]:[0,0]}var Dc=class extends Error{sourceStart;sourceEnd;constructor(e,t,n){super(e),this.name=`ParseError`,this.sourceStart=t,this.sourceEnd=n}},Oc=class extends Dc{componentValues;constructor(e,t){super(e,...Ec(t)),this.componentValues=t}};const kc={UnexpectedAdditionOfDimensionOrPercentageWithNumber:`Unexpected addition of a dimension or percentage with a number.`,UnexpectedSubtractionOfDimensionOrPercentageWithNumber:`Unexpected subtraction of a dimension or percentage with a number.`},Ac=/[A-Z]/g;function jc(e){return e.replace(Ac,e=>String.fromCharCode(e.charCodeAt(0)+32))}const Mc={cm:`px`,in:`px`,mm:`px`,pc:`px`,pt:`px`,px:`px`,q:`px`,deg:`deg`,grad:`deg`,rad:`deg`,turn:`deg`,ms:`s`,s:`s`,hz:`hz`,khz:`hz`},Nc=new Map([[`cm`,e=>e],[`mm`,e=>10*e],[`q`,e=>40*e],[`in`,e=>e/2.54],[`pc`,e=>e/2.54*6],[`pt`,e=>e/2.54*72],[`px`,e=>e/2.54*96]]),Pc=new Map([[`deg`,e=>e],[`grad`,e=>e/.9],[`rad`,e=>e/180*Math.PI],[`turn`,e=>e/360]]),Fc=new Map([[`deg`,e=>.9*e],[`grad`,e=>e],[`rad`,e=>.9*e/180*Math.PI],[`turn`,e=>.9*e/360]]),Ic=new Map([[`hz`,e=>e],[`khz`,e=>e/1e3]]),Lc=new Map([[`cm`,e=>2.54*e],[`mm`,e=>25.4*e],[`q`,e=>25.4*e*4],[`in`,e=>e],[`pc`,e=>6*e],[`pt`,e=>72*e],[`px`,e=>96*e]]),Rc=new Map([[`hz`,e=>1e3*e],[`khz`,e=>e]]),zc=new Map([[`cm`,e=>e/10],[`mm`,e=>e],[`q`,e=>4*e],[`in`,e=>e/25.4],[`pc`,e=>e/25.4*6],[`pt`,e=>e/25.4*72],[`px`,e=>e/25.4*96]]),Bc=new Map([[`ms`,e=>e],[`s`,e=>e/1e3]]),Vc=new Map([[`cm`,e=>e/6*2.54],[`mm`,e=>e/6*25.4],[`q`,e=>e/6*25.4*4],[`in`,e=>e/6],[`pc`,e=>e],[`pt`,e=>e/6*72],[`px`,e=>e/6*96]]),Hc=new Map([[`cm`,e=>e/72*2.54],[`mm`,e=>e/72*25.4],[`q`,e=>e/72*25.4*4],[`in`,e=>e/72],[`pc`,e=>e/72*6],[`pt`,e=>e],[`px`,e=>e/72*96]]),Uc=new Map([[`cm`,e=>e/96*2.54],[`mm`,e=>e/96*25.4],[`q`,e=>e/96*25.4*4],[`in`,e=>e/96],[`pc`,e=>e/96*6],[`pt`,e=>e/96*72],[`px`,e=>e]]),Wc=new Map([[`cm`,e=>e/4/10],[`mm`,e=>e/4],[`q`,e=>e],[`in`,e=>e/4/25.4],[`pc`,e=>e/4/25.4*6],[`pt`,e=>e/4/25.4*72],[`px`,e=>e/4/25.4*96]]),Gc=new Map([[`deg`,e=>180*e/Math.PI],[`grad`,e=>180*e/Math.PI/.9],[`rad`,e=>e],[`turn`,e=>180*e/Math.PI/360]]),Kc=new Map([[`ms`,e=>1e3*e],[`s`,e=>e]]),qc=new Map([[`deg`,e=>360*e],[`grad`,e=>360*e/.9],[`rad`,e=>360*e/180*Math.PI],[`turn`,e=>e]]),Jc=new Map([[`cm`,Nc],[`mm`,zc],[`q`,Wc],[`in`,Lc],[`pc`,Vc],[`pt`,Hc],[`px`,Uc],[`ms`,Bc],[`s`,Kc],[`deg`,Pc],[`grad`,Fc],[`rad`,Gc],[`turn`,qc],[`hz`,Ic],[`khz`,Rc]]);function Yc(e,t){if(!H(e)||!H(t))return t;let n=jc(e[4].unit),r=jc(t[4].unit);if(n===r)return t;let i=Jc.get(r);if(!i)return t;let a=i.get(n);if(!a)return t;let o=a(t[4].value),s=[z.Dimension,``,t[2],t[3],{...t[4],signCharacter:o<0?`-`:void 0,type:Number.isInteger(o)?B.Integer:B.Number,value:o}];return ao(s,e[4].unit),s}function Xc(e){if(!H(e))return e;let t=jc(e[4].unit),n=Mc[t];if(t===n)return e;let r=Jc.get(t);if(!r)return e;let i=r.get(n);if(!i)return e;let a=i(e[4].value),o=[z.Dimension,``,e[2],e[3],{...e[4],signCharacter:a<0?`-`:void 0,type:Number.isInteger(a)?B.Integer:B.Number,value:a}];return ao(o,n),o}function Zc(e,t){if(e.length!==2)return-1;let n=e[0].value,r=e[1].value;if(W(n)&&W(r)){let e=n[4].value+r[4].value;return new K([z.Number,e.toString(),n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number}])}if(G(n)&&G(r)){let e=n[4].value+r[4].value;return new K([z.Percentage,e.toString()+`%`,n[2],r[3],{value:e}])}if(H(n)&&H(r)&&(r=Yc(n,r),jc(n[4].unit)===jc(r[4].unit))){let e=n[4].value+r[4].value;return new K([z.Dimension,e.toString()+n[4].unit,n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number,unit:n[4].unit}])}return(W(n)&&(H(r)||G(r))||W(r)&&(H(n)||G(n)))&&t.onParseError?.(new Oc(kc.UnexpectedAdditionOfDimensionOrPercentageWithNumber,e)),-1}function Qc(e){if(e.length!==2)return-1;let t=e[0].value,n=e[1].value;if(W(t)&&W(n)){let e=t[4].value/n[4].value;return new K([z.Number,e.toString(),t[2],n[3],{value:e,type:Number.isInteger(e)?B.Integer:B.Number}])}if(G(t)&&W(n)){let e=t[4].value/n[4].value;return new K([z.Percentage,e.toString()+`%`,t[2],n[3],{value:e}])}if(H(t)&&W(n)){let e=t[4].value/n[4].value;return new K([z.Dimension,e.toString()+t[4].unit,t[2],n[3],{value:e,type:Number.isInteger(e)?B.Integer:B.Number,unit:t[4].unit}])}return-1}function $c(e){return!!e&&typeof e==`object`&&`inputs`in e&&Array.isArray(e.inputs)&&`operation`in e}function el(e,t){if(e===-1)return-1;let n=[];for(let r=0;r<e.inputs.length;r++){let i=e.inputs[r];if(q(i)){n.push(i);continue}let a=el(i,t);if(a===-1)return-1;n.push(a)}return e.operation(n,t)}function tl(e){if(e.length!==2)return-1;let t=e[0].value,n=e[1].value;if(W(t)&&W(n)){let e=t[4].value*n[4].value;return new K([z.Number,e.toString(),t[2],n[3],{value:e,type:t[4].type===B.Integer&&n[4].type===B.Integer?B.Integer:B.Number}])}if(G(t)&&W(n)){let e=t[4].value*n[4].value;return new K([z.Percentage,e.toString()+`%`,t[2],n[3],{value:e}])}if(W(t)&&G(n)){let e=t[4].value*n[4].value;return new K([z.Percentage,e.toString()+`%`,t[2],n[3],{value:e}])}if(H(t)&&W(n)){let e=t[4].value*n[4].value;return new K([z.Dimension,e.toString()+t[4].unit,t[2],n[3],{value:e,type:t[4].type===B.Integer&&n[4].type===B.Integer?B.Integer:B.Number,unit:t[4].unit}])}if(W(t)&&H(n)){let e=t[4].value*n[4].value;return new K([z.Dimension,e.toString()+n[4].unit,t[2],n[3],{value:e,type:t[4].type===B.Integer&&n[4].type===B.Integer?B.Integer:B.Number,unit:n[4].unit}])}return-1}function nl(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(!q(r))continue;let i=r.value;if(!U(i))continue;let a=jc(i[4].value);switch(a){case`e`:e.splice(n,1,new K([z.Number,Math.E.toString(),i[2],i[3],{value:Math.E,type:B.Number}]));break;case`pi`:e.splice(n,1,new K([z.Number,Math.PI.toString(),i[2],i[3],{value:Math.PI,type:B.Number}]));break;case`infinity`:e.splice(n,1,new K([z.Number,`infinity`,i[2],i[3],{value:1/0,type:B.Number}]));break;case`-infinity`:e.splice(n,1,new K([z.Number,`-infinity`,i[2],i[3],{value:-1/0,type:B.Number}]));break;case`nan`:e.splice(n,1,new K([z.Number,`NaN`,i[2],i[3],{value:NaN,type:B.Number}]));break;default:if(t.has(a)){let r=t.get(a);e.splice(n,1,new K(r))}}}return e}function rl(e){if(e.length!==1)return-1;let t=e[0].value;return V(t)?e[0]:-1}function il(e,t,n){return H(t)?al(e,t[4].unit,n):G(t)?ol(e,n):W(t)?sl(e,n):-1}function al(e,t,n){let r=e.tokens();return{inputs:[new K([z.Dimension,n.toString()+t,r[0][2],r[r.length-1][3],{value:n,type:Number.isInteger(n)?B.Integer:B.Number,unit:t}])],operation:rl}}function ol(e,t){let n=e.tokens();return{inputs:[new K([z.Percentage,t.toString()+`%`,n[0][2],n[n.length-1][3],{value:t}])],operation:rl}}function sl(e,t){let n=e.tokens();return{inputs:[new K([z.Number,t.toString(),n[0][2],n[n.length-1][3],{value:t,type:Number.isInteger(t)?B.Integer:B.Number}])],operation:rl}}function cl(e,t){let n=t.value;return W(n)?al(e,`rad`,Math.acos(n[4].value)):-1}function ll(e,t){let n=t.value;return W(n)?al(e,`rad`,Math.asin(n[4].value)):-1}function ul(e,t){let n=t.value;return W(n)?al(e,`rad`,Math.atan(n[4].value)):-1}function dl(e){return H(e)||W(e)}function fl(e){if(e.length===0)return!0;let t=e[0];if(!V(t))return!1;if(e.length===1)return!0;if(H(t)){let n=jc(t[4].unit);for(let r=1;r<e.length;r++){let i=e[r];if(t[0]!==i[0]||n!==jc(i[4].unit))return!1}return!0}for(let n=1;n<e.length;n++){let r=e[n];if(t[0]!==r[0])return!1}return!0}function pl(e,t){return!!V(e)&&(H(e)?e[0]===t[0]&&jc(e[4].unit)===jc(t[4].unit):e[0]===t[0])}function ml(e,t,n){let r=t.value;if(!dl(r))return-1;let i=Yc(r,n.value);return pl(r,i)?al(e,`rad`,Math.atan2(r[4].value,i[4].value)):-1}function hl(e,t,n){let r=t.value;return!V(r)||!n.rawPercentages&&G(r)?-1:il(e,r,Math.abs(r[4].value))}function gl(e,t,n,r,i){if(!q(t)||!q(n)||!q(r))return-1;let a=t.value;if(!V(a)||!i.rawPercentages&&G(a))return-1;let o=Yc(a,n.value);if(!pl(a,o))return-1;let s=Yc(a,r.value);return pl(a,s)?il(e,a,Math.max(a[4].value,Math.min(o[4].value,s[4].value))):-1}function _l(e,t){let n=t.value;if(!dl(n))return-1;let r=n[4].value;if(H(n))switch(n[4].unit.toLowerCase()){case`rad`:break;case`deg`:r=Pc.get(`rad`)(n[4].value);break;case`grad`:r=Fc.get(`rad`)(n[4].value);break;case`turn`:r=qc.get(`rad`)(n[4].value);break;default:return-1}return r=Math.cos(r),sl(e,r)}function vl(e,t){let n=t.value;return W(n)?sl(e,Math.exp(n[4].value)):-1}function yl(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!V(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>Yc(r,e.value));if(!fl(i))return-1;let a=i.map(e=>e[4].value);return il(e,r,Math.hypot(...a))}function bl(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!V(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>Yc(r,e.value));if(!fl(i))return-1;let a=i.map(e=>e[4].value);return il(e,r,Math.max(...a))}function xl(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!V(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>Yc(r,e.value));if(!fl(i))return-1;let a=i.map(e=>e[4].value);return il(e,r,Math.min(...a))}function Sl(e,t,n){let r=t.value;if(!V(r))return-1;let i=Yc(r,n.value);if(!pl(r,i))return-1;let a;return a=i[4].value===0?NaN:Number.isFinite(r[4].value)&&(Number.isFinite(i[4].value)||(i[4].value!==1/0||r[4].value!==-1/0&&!Object.is(0*r[4].value,-0))&&(i[4].value!==-1/0||r[4].value!==1/0&&!Object.is(0*r[4].value,0)))?Number.isFinite(i[4].value)?(r[4].value%i[4].value+i[4].value)%i[4].value:r[4].value:NaN,il(e,r,a)}function Cl(e,t,n){let r=t.value,i=n.value;return!W(r)||!pl(r,i)?-1:sl(e,r[4].value**+i[4].value)}function wl(e,t,n){let r=t.value;if(!V(r))return-1;let i=Yc(r,n.value);if(!pl(r,i))return-1;let a;return a=i[4].value===0?NaN:Number.isFinite(r[4].value)?Number.isFinite(i[4].value)?r[4].value%i[4].value:r[4].value:NaN,il(e,r,a)}function Tl(e,t,n){if(!H(t))return-1;let r=n.devicePixelLength??1,i=[z.Dimension,`${r}px`,t[2],t[3],{value:r,type:B.Integer,unit:`px`}],a=Yc(i,t);if(!pl(a,i))return-1;if(Number.isInteger(a[4].value/r))return il(e,t,t[4].value);if(a[4].value>0){if(a[4].value<r)return il(e,t,Yc(t,i)[4].value);let n=Math.floor(a[4].value/i[4].value)*i[4].value;return a[4].value=n,il(e,t,Yc(t,a)[4].value)}if(Math.abs(a[4].value)<r)return il(e,t,-1*Yc(t,i)[4].value);let o=Math.ceil(a[4].value/i[4].value)*i[4].value;return a[4].value=o,il(e,t,Yc(t,a)[4].value)}function El(e,t,n,r,i){let a=n.value;if(!V(a)||t===`line-width`&&!H(a)||!i.rawPercentages&&G(a))return-1;let o=Yc(a,r.value);if(!pl(a,o))return-1;let s;if(o[4].value===0)s=NaN;else if(Number.isFinite(a[4].value)||Number.isFinite(o[4].value))if(!Number.isFinite(a[4].value)&&Number.isFinite(o[4].value))s=a[4].value;else if(Number.isFinite(a[4].value)&&!Number.isFinite(o[4].value))switch(t){case`down`:s=a[4].value<0?-1/0:Object.is(-0,0*a[4].value)?-0:0;break;case`up`:s=a[4].value>0?1/0:Object.is(0,0*a[4].value)?0:-0;break;default:s=Object.is(0,0*a[4].value)?0:-0}else switch(t){case`down`:s=Math.floor(a[4].value/o[4].value)*o[4].value;break;case`up`:s=Math.ceil(a[4].value/o[4].value)*o[4].value;break;case`to-zero`:s=Math.trunc(a[4].value/o[4].value)*o[4].value;break;default:{let n=Math.floor(a[4].value/o[4].value)*o[4].value,r=Math.ceil(a[4].value/o[4].value)*o[4].value;if(n>r){let e=n;n=r,r=e}let c=Math.abs(a[4].value-n),l=Math.abs(a[4].value-r);if(s=t===`line-width`&&a[4].value>=0&&(r===0||n===0)?r===0?n:r:c===l?r:c<l?n:r,t===`line-width`){let t=el(il(e,a,s),i);return t===-1?-1:Tl(e,t.value,i)}break}}else s=NaN;return il(e,a,s)}function Dl(e,t,n){let r=t.value;return!V(r)||!n.rawPercentages&&G(r)?-1:sl(e,Math.sign(r[4].value))}function Ol(e,t){let n=t.value;if(!dl(n))return-1;let r=n[4].value;if(H(n))switch(jc(n[4].unit)){case`rad`:break;case`deg`:r=Pc.get(`rad`)(n[4].value);break;case`grad`:r=Fc.get(`rad`)(n[4].value);break;case`turn`:r=qc.get(`rad`)(n[4].value);break;default:return-1}return r=Math.sin(r),sl(e,r)}function kl(e,t){let n=t.value;return W(n)?sl(e,Math.sqrt(n[4].value)):-1}function Al(e,t){let n=t.value;if(!dl(n))return-1;let r=n[4].value,i=0,a=n[4].value;if(H(n))switch(jc(n[4].unit)){case`rad`:i=Gc.get(`deg`)(r);break;case`deg`:i=r,a=Pc.get(`rad`)(r);break;case`grad`:i=Fc.get(`deg`)(r),a=Fc.get(`rad`)(r);break;case`turn`:i=qc.get(`deg`)(r),a=qc.get(`rad`)(r);break;default:return-1}let o=i/90;return a=i%90==0&&o%2!=0?o>0?1/0:-1/0:Math.tan(a),sl(e,a)}function jl(e,t){if(e.length!==2)return-1;let n=e[0].value,r=e[1].value;if(W(n)&&W(r)){let e=n[4].value-r[4].value;return new K([z.Number,e.toString(),n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number}])}if(G(n)&&G(r)){let e=n[4].value-r[4].value;return new K([z.Percentage,e.toString()+`%`,n[2],r[3],{value:e}])}if(H(n)&&H(r)&&(r=Yc(n,r),jc(n[4].unit)===jc(r[4].unit))){let e=n[4].value-r[4].value;return new K([z.Dimension,e.toString()+n[4].unit,n[2],r[3],{value:e,type:n[4].type===B.Integer&&r[4].type===B.Integer?B.Integer:B.Number,unit:n[4].unit}])}return(W(n)&&(H(r)||G(r))||W(r)&&(H(n)||G(n)))&&t.onParseError?.(new Oc(kc.UnexpectedSubtractionOfDimensionOrPercentageWithNumber,e)),-1}function Ml(e,t){if(t.length===1){let n=t[0];if(!n||!q(n))return-1;let r=n.value;return W(r)?sl(e,Math.log(r[4].value)):-1}if(t.length===2){let n=t[0];if(!n||!q(n))return-1;let r=n.value;if(!W(r))return-1;let i=t[1];if(!i||!q(i))return-1;let a=i.value;return W(a)?sl(e,Math.log(r[4].value)/Math.log(a[4].value)):-1}return-1}const Nl=/^none$/i;function Pl(e){if(Array.isArray(e)){let t=e.filter(e=>!(Cc(e)&&wc(e)));return t.length===1&&Pl(t[0])}if(!q(e))return!1;let t=e.value;return!!U(t)&&Nl.test(t[4].value)}const Fl=String.fromCodePoint(0);function Il(e,t,n,r,i,a){if(t.fixed===-1&&!a.randomCaching)return-1;a.randomCaching||={propertyName:``,propertyN:0,elementID:``,documentID:``},a.randomCaching&&!a.randomCaching.propertyN&&(a.randomCaching.propertyN=0);let o=n.value;if(!V(o))return-1;let s=Yc(o,r.value);if(!pl(o,s))return-1;let c=null;if(i&&(c=Yc(o,i.value),!pl(o,c)))return-1;if(!Number.isFinite(o[4].value)||!Number.isFinite(s[4].value)||!Number.isFinite(s[4].value-o[4].value))return il(e,o,NaN);if(c&&!Number.isFinite(c[4].value))return il(e,o,o[4].value);let l=t.fixed===-1?Ll(Rl([t.dashedIdent?t.dashedIdent:`${a.randomCaching?.propertyName} ${a.randomCaching.propertyN++}`,t.elementShared?``:a.randomCaching.elementID,a.randomCaching.documentID].join(Fl))):()=>t.fixed,u=o[4].value,d=s[4].value;if(u>d&&([u,d]=[d,u]),c&&(c[4].value<=0||Math.abs(u-d)/c[4].value>1e10)&&(c=null),c){let t=Math.max(c[4].value/1e3,1e-9),n=[u],r=0;for(;;){r+=c[4].value;let e=u+r;if(!(e+t<d)){n.push(d);break}if(n.push(e),e+c[4].value-t>d)break}let i=l();return il(e,o,Number(n[Math.floor(n.length*i)].toFixed(5)))}let f=l();return il(e,o,Number((f*(d-u)+u).toFixed(5)))}function Ll(e=.34944106645296036,t=.19228640875738723,n=.8784393832007205,r=.04850964319275053){return()=>{let i=((e|=0)+(t|=0)|0)+(r|=0)|0;return r=r+1|0,e=t^t>>>9,t=(n|=0)+(n<<3)|0,n=(n=n<<21|n>>>11)+i|0,(i>>>0)/4294967296}}function Rl(e){let t,n,r=0;r^=-1;for(let i=0,a=e.length;i<a;i++)n=255&(r^e.charCodeAt(i)),t=Number(`0x`+`00000000 77073096 EE0E612C 990951BA 076DC419 706AF48F E963A535 9E6495A3 0EDB8832 79DCB8A4 E0D5E91E 97D2D988 09B64C2B 7EB17CBD E7B82D07 90BF1D91 1DB71064 6AB020F2 F3B97148 84BE41DE 1ADAD47D 6DDDE4EB F4D4B551 83D385C7 136C9856 646BA8C0 FD62F97A 8A65C9EC 14015C4F 63066CD9 FA0F3D63 8D080DF5 3B6E20C8 4C69105E D56041E4 A2677172 3C03E4D1 4B04D447 D20D85FD A50AB56B 35B5A8FA 42B2986C DBBBC9D6 ACBCF940 32D86CE3 45DF5C75 DCD60DCF ABD13D59 26D930AC 51DE003A C8D75180 BFD06116 21B4F4B5 56B3C423 CFBA9599 B8BDA50F 2802B89E 5F058808 C60CD9B2 B10BE924 2F6F7C87 58684C11 C1611DAB B6662D3D 76DC4190 01DB7106 98D220BC EFD5102A 71B18589 06B6B51F 9FBFE4A5 E8B8D433 7807C9A2 0F00F934 9609A88E E10E9818 7F6A0DBB 086D3D2D 91646C97 E6635C01 6B6B51F4 1C6C6162 856530D8 F262004E 6C0695ED 1B01A57B 8208F4C1 F50FC457 65B0D9C6 12B7E950 8BBEB8EA FCB9887C 62DD1DDF 15DA2D49 8CD37CF3 FBD44C65 4DB26158 3AB551CE A3BC0074 D4BB30E2 4ADFA541 3DD895D7 A4D1C46D D3D6F4FB 4369E96A 346ED9FC AD678846 DA60B8D0 44042D73 33031DE5 AA0A4C5F DD0D7CC9 5005713C 270241AA BE0B1010 C90C2086 5768B525 206F85B3 B966D409 CE61E49F 5EDEF90E 29D9C998 B0D09822 C7D7A8B4 59B33D17 2EB40D81 B7BD5C3B C0BA6CAD EDB88320 9ABFB3B6 03B6E20C 74B1D29A EAD54739 9DD277AF 04DB2615 73DC1683 E3630B12 94643B84 0D6D6A3E 7A6A5AA8 E40ECF0B 9309FF9D 0A00AE27 7D079EB1 F00F9344 8708A3D2 1E01F268 6906C2FE F762575D 806567CB 196C3671 6E6B06E7 FED41B76 89D32BE0 10DA7A5A 67DD4ACC F9B9DF6F 8EBEEFF9 17B7BE43 60B08ED5 D6D6A3E8 A1D1937E 38D8C2C4 4FDFF252 D1BB67F1 A6BC5767 3FB506DD 48B2364B D80D2BDA AF0A1B4C 36034AF6 41047A60 DF60EFC3 A867DF55 316E8EEF 4669BE79 CB61B38C BC66831A 256FD2A0 5268E236 CC0C7795 BB0B4703 220216B9 5505262F C5BA3BBE B2BD0B28 2BB45A92 5CB36A04 C2D7FFA7 B5D0CF31 2CD99E8B 5BDEAE1D 9B64C2B0 EC63F226 756AA39C 026D930A 9C0906A9 EB0E363F 72076785 05005713 95BF4A82 E2B87A14 7BB12BAE 0CB61B38 92D28E9B E5D5BE0D 7CDCEFB7 0BDBDF21 86D3D2D4 F1D4E242 68DDB3F8 1FDA836E 81BE16CD F6B9265B 6FB077E1 18B74777 88085AE6 FF0F6A70 66063BCA 11010B5C 8F659EFF F862AE69 616BFFD3 166CCF45 A00AE278 D70DD2EE 4E048354 3903B3C2 A7672661 D06016F7 4969474D 3E6E77DB AED16A4A D9D65ADC 40DF0B66 37D83BF0 A9BCAE53 DEBB9EC5 47B2CF7F 30B5FFE9 BDBDF21C CABAC28A 53B39330 24B4A3A6 BAD03605 CDD70693 54DE5729 23D967BF B3667A2E C4614AB8 5D681B02 2A6F2B94 B40BBE37 C30C8EA1 5A05DF1B 2D02EF8D`.substring(9*n,9*n+8)),r=r>>>8^t;return(-1^r)>>>0}const zl=new Map([[`abs`,function(e,t,n){return Vl(e,t,n,hl)}],[`acos`,function(e,t,n){return Vl(e,t,n,cl)}],[`asin`,function(e,t,n){return Vl(e,t,n,ll)}],[`atan`,function(e,t,n){return Vl(e,t,n,ul)}],[`atan2`,function(e,t,n){return Ul(e,t,n,ml)}],[`calc`,Bl],[`clamp`,function(e,t,n){let r=nl([...e.value.filter(e=>!Tc(e))],t),i=[],a=[],o=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&mo(n.value)){if(e===o)return-1;if(e===a){e=o;continue}if(e===i){e=a;continue}return-1}e.push(n)}}let s=Pl(i),c=Pl(o);if(s&&c)return Bl(Yl(e,a),t,n);let l=el(Bl(Yl(e,a),t,n),n);if(l===-1)return-1;if(s){let r=el(Bl(Yl(e,o),t,n),n);return r===-1?-1:xl((u=e,d=l,f=r,new cc([z.Function,`min(`,u.name[2],u.name[3],{value:`min`}],[z.CloseParen,`)`,u.endToken[2],u.endToken[3],void 0],[d,new K([z.Comma,`,`,...Ec(d),void 0]),f])),[l,r],n)}if(c){let r=el(Bl(Yl(e,i),t,n),n);return r===-1?-1:bl(Xl(e,r,l),[r,l],n)}var u,d,f;let p=el(Bl(Yl(e,i),t,n),n);if(p===-1)return-1;let m=el(Bl(Yl(e,o),t,n),n);return m===-1?-1:gl(e,p,l,m,n)}],[`cos`,function(e,t,n){return Vl(e,t,n,_l)}],[`exp`,function(e,t,n){return Vl(e,t,n,vl)}],[`hypot`,function(e,t,n){return Gl(e,t,n,yl)}],[`log`,function(e,t,n){return Gl(e,t,n,Ml)}],[`max`,function(e,t,n){return Gl(e,t,n,bl)}],[`min`,function(e,t,n){return Gl(e,t,n,xl)}],[`mod`,function(e,t,n){return Ul(e,t,n,Sl)}],[`pow`,function(e,t,n){return Ul(e,t,n,Cl)}],[`random`,function(e,t,n){let r=Jl(e,e.value.filter(e=>!Tc(e)),t,n);if(r===-1)return-1;let[i,a]=r,o=Kl(e,a,t,n);if(o===-1)return-1;let[s,c,l]=o;return!s||!c?-1:Il(e,i,s,c,l,n)}],[`rem`,function(e,t,n){return Ul(e,t,n,wl)}],[`round`,function(e,t,n){let r=nl([...e.value.filter(e=>!Tc(e))],t),i=``,a=!1,o=[],s=[];{let e=o;for(let t=0;t<r.length;t++){let n=r[t];if(!i&&o.length===0&&s.length===0&&q(n)&&U(n.value)){let e=n.value[4].value.toLowerCase();if(ql.has(e)){i=e;continue}}if(q(n)&&mo(n.value)){if(e===s)return-1;if(e===o&&i&&o.length===0)continue;if(e===o){a=!0,e=s;continue}return-1}e.push(n)}}let c=el(Bl(Yl(e,o),t,n),n);if(c===-1)return-1;if(i===`line-width`){let e=Yc([z.Dimension,`1px`,c.value[2],c.value[3],{value:1,type:B.Integer,unit:`px`}],c.value);if(!H(e)||e[4].unit!==`px`)return-1}if(!a&&s.length===0){if(i===`line-width`)return Tl(e,c.value,n);s.push(new K([z.Number,`1`,c.value[2],c.value[3],{value:1,type:B.Integer}]))}let l=el(Bl(Yl(e,s),t,n),n);return l===-1?-1:(i||=`nearest`,El(e,i,c,l,n))}],[`sign`,function(e,t,n){return Vl(e,t,n,Dl)}],[`sin`,function(e,t,n){return Vl(e,t,n,Ol)}],[`sqrt`,function(e,t,n){return Vl(e,t,n,kl)}],[`tan`,function(e,t,n){return Vl(e,t,n,Al)}]]);function Bl(e,t,n){let r=nl([...e.value.filter(e=>!Tc(e))],t);if(r.length===1&&q(r[0]))return{inputs:[r[0]],operation:rl};let i=0;for(;i<r.length;){let e=r[i];if(xc(e)&&So(e.startToken)){let a=Bl(e,t,n);if(a===-1)return-1;r.splice(i,1,a);continue}if(Sc(e)){let a=zl.get(e.getName().toLowerCase());if(!a)return-1;let o=a(e,t,n);if(o===-1)return-1;r.splice(i,1,o);continue}i++}if(i=0,r.length===1&&$c(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!$c(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!go(n)||n[4].value!==`*`&&n[4].value!==`/`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!$c(a))return-1;n[4].value===`*`?r.splice(i,3,{inputs:[e,a],operation:tl}):n[4].value===`/`?r.splice(i,3,{inputs:[e,a],operation:Qc}):i++}if(i=0,r.length===1&&$c(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!$c(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!go(n)||n[4].value!==`+`&&n[4].value!==`-`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!$c(a))return-1;n[4].value===`+`?r.splice(i,3,{inputs:[e,a],operation:Zc}):n[4].value===`-`?r.splice(i,3,{inputs:[e,a],operation:jl}):i++}return r.length===1&&$c(r[0])?r[0]:-1}function Vl(e,t,n,r){let i=Hl(e,t,n);return i===-1?-1:r(e,i,n)}function Hl(e,t,n){let r=el(Bl(Yl(e,nl([...e.value.filter(e=>!Tc(e))],t)),t,n),n);return r===-1?-1:r}function Ul(e,t,n,r){let i=Wl(e,t,n);if(i===-1)return-1;let[a,o]=i;return r(e,a,o,n)}function Wl(e,t,n){let r=nl([...e.value.filter(e=>!Tc(e))],t),i=[],a=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&mo(n.value)){if(e===a)return-1;if(e===i){e=a;continue}return-1}e.push(n)}}let o=el(Bl(Yl(e,i),t,n),n);if(o===-1)return-1;let s=el(Bl(Yl(e,a),t,n),n);return s===-1?-1:[o,s]}function Gl(e,t,n,r){let i=Kl(e,e.value,t,n);return i===-1?-1:r(e,i,n)}function Kl(e,t,n,r){let i=nl([...t.filter(e=>!Tc(e))],n),a=[];{let t=[],o=[];for(let e=0;e<i.length;e++){let n=i[e];q(n)&&mo(n.value)?(t.push(o),o=[]):o.push(n)}t.push(o);for(let i=0;i<t.length;i++){if(t[i].length===0)return-1;let o=el(Bl(Yl(e,t[i]),n,r),r);if(o===-1)return-1;a.push(o)}}return a}const ql=new Set([`nearest`,`line-width`,`up`,`down`,`to-zero`]);function Jl(e,t,n,r){let i={isAuto:!1,dashedIdent:``,fixed:-1,elementShared:!1},a=t[0];if(!q(a)||!U(a.value))return[i,t];for(let a=0;a<t.length;a++){let o=t[a];if(!q(o))return-1;if(mo(o.value))return[i,t.slice(a+1)];if(!U(o.value))return-1;let s=o.value[4].value.toLowerCase();if(s!==`element-shared`){if(s===`fixed`){if(i.elementShared||i.dashedIdent||i.isAuto)return-1;a++;let o=t[a];if(!o)return-1;let s=el(Bl(Yl(e,[o]),n,r),r);if(s===-1||!W(s.value)||s.value[4].value<0||s.value[4].value>1)return-1;i.fixed=Math.max(0,Math.min(s.value[4].value,.999999999));continue}if(s!==`auto`){if(s.startsWith(`--`)){if(i.fixed!==-1||i.isAuto)return-1;i.dashedIdent=s}}else{if(i.fixed!==-1||i.dashedIdent)return-1;i.isAuto=!0}}else{if(i.fixed!==-1)return-1;i.elementShared=!0}}return-1}function Yl(e,t){return new cc([z.Function,`calc(`,e.name[2],e.name[3],{value:`calc`}],[z.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],t)}function Xl(e,t,n){return new cc([z.Function,`max(`,e.name[2],e.name[3],{value:`max`}],[z.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],[t,new K([z.Comma,`,`,...Ec(t),void 0]),n])}function Zl(e){if(e===-1)return-1;if(Sc(e))return e;let t=e.value;return V(t)&&Number.isNaN(t[4].value)?W(t)?new cc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,`NaN`,t[2],t[3],{value:`NaN`}])]):H(t)?new cc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,`NaN`,t[2],t[3],{value:`NaN`}]),new fc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new fc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Dimension,`1`+t[4].unit,t[2],t[3],{value:1,type:B.Integer,unit:t[4].unit}])]):G(t)?new cc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,`NaN`,t[2],t[3],{value:`NaN`}]),new fc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new fc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Percentage,`1%`,t[2],t[3],{value:1}])]):-1:e}function Ql(e){if(e===-1)return-1;if(Sc(e))return e;let t=e.value;if(!V(t)||Number.isFinite(t[4].value)||Number.isNaN(t[4].value))return e;let n=``;return t[4].value===-1/0&&(n=`-`),W(t)?new cc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}])]):H(t)?new cc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}]),new fc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new fc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Dimension,`1`+t[4].unit,t[2],t[3],{value:1,type:B.Integer,unit:t[4].unit}])]):new cc([z.Function,`calc(`,t[2],t[3],{value:`calc`}],[z.CloseParen,`)`,t[2],t[3],void 0],[new K([z.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}]),new fc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new fc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Percentage,`1%`,t[2],t[3],{value:1}])])}function $l(e){if(e===-1)return-1;if(Sc(e))return e;let t=e.value;return V(t)&&Object.is(-0,t[4].value)&&(t[1]===`-0`||(G(t)?t[1]=`-0%`:H(t)?t[1]=`-0`+t[4].unit:t[1]=`-0`)),e}function eu(e,t=13){if(e===-1)return-1;if(t<=0||Sc(e))return e;let n=e.value;if(!V(n)||Number.isInteger(n[4].value))return e;let r=Number(n[4].value.toFixed(t)).toString();return W(n)?n[1]=r:G(n)?n[1]=r+`%`:H(n)&&(n[1]=r+n[4].unit),e}function tu(e){return e===-1?-1:(Sc(e)||H(e.value)&&(e.value=Xc(e.value)),e)}function nu(e,t){let n=e;return t?.toCanonicalUnits&&(n=tu(n)),n=eu(n,t?.precision),n=$l(n),t?.censorIntoStandardRepresentableValues||(n=Zl(n),n=Ql(n)),n}function ru(e){let t=new Map;if(!e)return t;for(let[n,r]of e)if(uo(r))t.set(n,r);else if(typeof r==`string`){let e=ro({css:r}),i=e.nextToken();if(e.nextToken(),!e.endOfFile()||!V(i))continue;t.set(n,i);continue}return t}function iu(e,t){let n=ru(t?.globals);return au(e,e=>{if(!Sc(e))return;let r=zl.get(e.getName().toLowerCase());if(!r)return;let i=nu(el(r(e,n,t??{}),t??{}),t);return i===-1?void 0:i})}function au(e,t){for(let n=0;n<e.length;n++){let r=e[n];yc(r,(e,n)=>{if(typeof n!=`number`)return;let r=t(e.node);if(!r)return;let i=[r],a=e.parent.value[n-1];q(a)&&go(a.value)&&(a.value[4].value===`-`||a.value[4].value===`+`)&&i.splice(0,0,new fc([[z.Whitespace,` `,...Ec(e.node),void 0]]));let o=e.parent.value[n+1];!o||Tc(o)||q(o)&&(mo(o.value)||po(o.value)||bo(o.value)||go(o.value)&&o.value[4].value!==`-`&&o.value[4].value!==`+`)||i.push(new fc([[z.Whitespace,` `,...Ec(e.node),void 0]])),e.parent.value.splice(n,1,...i)})}return e}const ou=new Set(zl.keys());var J,Y;function su(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function cu(e){switch(e.colorNotation){case J.HEX:case J.RGB:case J.sRGB:return{...e,colorNotation:J.XYZ_D50,channels:Ss(su(e.channels))};case J.Linear_sRGB:return{...e,colorNotation:J.XYZ_D50,channels:Is(su(e.channels))};case J.Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:Bs(su(e.channels))};case J.Linear_Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:Hs(su(e.channels))};case J.Rec2020:return{...e,colorNotation:J.XYZ_D50,channels:Ws(su(e.channels))};case J.A98_RGB:return{...e,colorNotation:J.XYZ_D50,channels:Rs(su(e.channels))};case J.ProPhoto_RGB:return{...e,colorNotation:J.XYZ_D50,channels:Ks(su(e.channels))};case J.HSL:return{...e,colorNotation:J.XYZ_D50,channels:ws(su(e.channels))};case J.HWB:return{...e,colorNotation:J.XYZ_D50,channels:Es(su(e.channels))};case J.Lab:return{...e,colorNotation:J.XYZ_D50,channels:Os(su(e.channels))};case J.OKLab:return{...e,colorNotation:J.XYZ_D50,channels:Ms(su(e.channels))};case J.LCH:return{...e,colorNotation:J.XYZ_D50,channels:As(su(e.channels))};case J.OKLCH:return{...e,colorNotation:J.XYZ_D50,channels:Ps(su(e.channels))};case J.XYZ_D50:return{...e,colorNotation:J.XYZ_D50,channels:Xs(su(e.channels))};case J.XYZ_D65:return{...e,colorNotation:J.XYZ_D50,channels:Js(su(e.channels))};default:throw Error(`Unsupported color notation`)}}(function(e){e.A98_RGB=`a98-rgb`,e.Display_P3=`display-p3`,e.Linear_Display_P3=`display-p3-linear`,e.HEX=`hex`,e.HSL=`hsl`,e.HWB=`hwb`,e.LCH=`lch`,e.Lab=`lab`,e.Linear_sRGB=`srgb-linear`,e.OKLCH=`oklch`,e.OKLab=`oklab`,e.ProPhoto_RGB=`prophoto-rgb`,e.RGB=`rgb`,e.sRGB=`srgb`,e.Rec2020=`rec2020`,e.XYZ_D50=`xyz-d50`,e.XYZ_D65=`xyz-d65`})(J||={}),function(e){e.ColorKeyword=`color-keyword`,e.HasAlpha=`has-alpha`,e.HasDimensionValues=`has-dimension-values`,e.HasNoneKeywords=`has-none-keywords`,e.HasNumberValues=`has-number-values`,e.HasPercentageAlpha=`has-percentage-alpha`,e.HasPercentageValues=`has-percentage-values`,e.HasVariableAlpha=`has-variable-alpha`,e.Hex=`hex`,e.LegacyHSL=`legacy-hsl`,e.LegacyRGB=`legacy-rgb`,e.NamedColor=`named-color`,e.RelativeColorSyntax=`relative-color-syntax`,e.ColorMix=`color-mix`,e.ColorMixVariadic=`color-mix-variadic`,e.ContrastColor=`contrast-color`,e.RelativeAlphaSyntax=`relative-alpha-syntax`,e.Experimental=`experimental`}(Y||={});const lu=new Set([J.A98_RGB,J.Display_P3,J.Linear_Display_P3,J.HEX,J.Linear_sRGB,J.ProPhoto_RGB,J.RGB,J.sRGB,J.Rec2020,J.XYZ_D50,J.XYZ_D65]);function uu(e,t){let n={...e};if(e.colorNotation!==t){let e=cu(n);switch(t){case J.HEX:case J.RGB:n.colorNotation=J.RGB,n.channels=Cs(e.channels);break;case J.sRGB:n.colorNotation=J.sRGB,n.channels=Cs(e.channels);break;case J.Linear_sRGB:n.colorNotation=J.Linear_sRGB,n.channels=Ls(e.channels);break;case J.Display_P3:n.colorNotation=J.Display_P3,n.channels=Vs(e.channels);break;case J.Linear_Display_P3:n.colorNotation=J.Linear_Display_P3,n.channels=Us(e.channels);break;case J.Rec2020:n.colorNotation=J.Rec2020,n.channels=Gs(e.channels);break;case J.ProPhoto_RGB:n.colorNotation=J.ProPhoto_RGB,n.channels=qs(e.channels);break;case J.A98_RGB:n.colorNotation=J.A98_RGB,n.channels=zs(e.channels);break;case J.HSL:n.colorNotation=J.HSL,n.channels=Ts(e.channels);break;case J.HWB:n.colorNotation=J.HWB,n.channels=Ds(e.channels);break;case J.Lab:n.colorNotation=J.Lab,n.channels=ks(e.channels);break;case J.LCH:n.colorNotation=J.LCH,n.channels=js(e.channels);break;case J.OKLCH:n.colorNotation=J.OKLCH,n.channels=Fs(e.channels);break;case J.OKLab:n.colorNotation=J.OKLab,n.channels=Ns(e.channels);break;case J.XYZ_D50:n.colorNotation=J.XYZ_D50,n.channels=Xs(e.channels);break;case J.XYZ_D65:n.colorNotation=J.XYZ_D65,n.channels=Ys(e.channels);break;default:throw Error(`Unsupported color notation`)}}else n.channels=su(e.channels);if(t===e.colorNotation)n.channels=fu(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else if(lu.has(t)&&lu.has(e.colorNotation))n.channels=fu(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else switch(t){case J.HSL:switch(e.colorNotation){case J.HWB:n.channels=fu(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=fu(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.LCH:case J.OKLCH:n.channels=fu(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;default:n.channels=fu(e.channels,[],[],n.channels,[],[])}break;case J.HWB:switch(e.colorNotation){case J.HSL:n.channels=fu(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=fu(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;default:n.channels=fu(e.channels,[],[],n.channels,[],[])}break;case J.Lab:case J.OKLab:switch(e.colorNotation){case J.HSL:n.channels=fu(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=fu(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;case J.LCH:case J.OKLCH:n.channels=fu(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;default:n.channels=fu(e.channels,[],[],n.channels,[],[])}break;case J.LCH:case J.OKLCH:switch(e.colorNotation){case J.HSL:n.channels=fu(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;case J.HWB:n.channels=fu(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.Lab:case J.OKLab:n.channels=fu(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=fu(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;default:n.channels=fu(e.channels,[],[],n.channels,[],[])}break;default:n.channels=fu(e.channels,[],[],n.channels,[],[])}return n.channels=du(n.channels,t),n}function du(e,t){let n=[...e];switch(t){case J.HSL:!Number.isNaN(n[1])&&n[1]<=.001&&(n[0]=NaN);break;case J.HWB:!Number.isNaN(n[1])&&!Number.isNaN(n[2])&&Math.max(0,n[1])+Math.max(0,n[2])>=99.999&&(n[0]=NaN);break;case J.LCH:!Number.isNaN(n[1])&&n[1]<=.0015&&(n[2]=NaN);break;case J.OKLCH:!Number.isNaN(n[1])&&n[1]<=4e-6&&(n[2]=NaN)}return n}function fu(e,t,n,r,i,a){if(t.length<3&&e.every(Number.isNaN))return[NaN,NaN,NaN];let o=[...r];for(let n=0;n<t.length;n++)Number.isNaN(e[t[n]])&&(o[i[n]]=NaN);if(n.length&&n.every(t=>Number.isNaN(e[t])))for(let e=0;e<a.length;e++)o[a[e]]=NaN;return o}function pu(e){let t=new Map;switch(e.colorNotation){case J.RGB:case J.HEX:t.set(`r`,X(255*e.channels[0])),t.set(`g`,X(255*e.channels[1])),t.set(`b`,X(255*e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.HSL:t.set(`h`,X(e.channels[0])),t.set(`s`,X(e.channels[1])),t.set(`l`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.HWB:t.set(`h`,X(e.channels[0])),t.set(`w`,X(e.channels[1])),t.set(`b`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.Lab:case J.OKLab:t.set(`l`,X(e.channels[0])),t.set(`a`,X(e.channels[1])),t.set(`b`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.LCH:case J.OKLCH:t.set(`l`,X(e.channels[0])),t.set(`c`,X(e.channels[1])),t.set(`h`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.sRGB:case J.A98_RGB:case J.Display_P3:case J.Linear_Display_P3:case J.Rec2020:case J.Linear_sRGB:case J.ProPhoto_RGB:t.set(`r`,X(e.channels[0])),t.set(`g`,X(e.channels[1])),t.set(`b`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha));break;case J.XYZ_D50:case J.XYZ_D65:t.set(`x`,X(e.channels[0])),t.set(`y`,X(e.channels[1])),t.set(`z`,X(e.channels[2])),typeof e.alpha==`number`&&t.set(`alpha`,X(e.alpha))}return t}function mu(e){let t=new Map(e);for(let[n,r]of e)Number.isNaN(r[4].value)&&t.set(n,X(0));return t}function X(e){return Number.isNaN(e)?[z.Number,`none`,-1,-1,{value:NaN,type:B.Number}]:[z.Number,e.toString(),-1,-1,{value:e,type:B.Number}]}function Z(e,t,n,r){return Math.min(Math.max(e/t,n),r)}const hu=/[A-Z]/g;function Q(e){return e.replace(hu,e=>String.fromCharCode(e.charCodeAt(0)+32))}function gu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}const _u=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`xyz`,`xyz-d50`,`xyz-d65`]);function vu(e,t){let n=[],r=[],i=[],a=[],o,s,c=!1,l=!1,u={colorNotation:J.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])},d=n;for(let f=0;f<e.value.length;f++){let p=e.value[f];if(Cc(p)||wc(p))for(;Cc(e.value[f+1])||wc(e.value[f+1]);)f++;else if(d===n&&n.length&&(d=r),d===r&&r.length&&(d=i),q(p)&&go(p.value)&&p.value[4].value===`/`){if(d===a)return!1;d=a}else{if(Sc(p)){if(d===a&&Q(p.getName())===`var`){u.syntaxFlags.add(Y.HasVariableAlpha),d.push(p);continue}if(!ou.has(Q(p.getName())))return!1;let[[e]]=iu([[p]],{censorIntoStandardRepresentableValues:!0,globals:s,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),p=e}if(d===n&&n.length===0&&q(p)&&U(p.value)&&_u.has(Q(p.value[4].value))){if(c)return!1;c=Q(p.value[4].value),u.colorNotation=yu(c),l&&(l.colorNotation!==u.colorNotation&&(l=uu(l,u.colorNotation)),o=pu(l),s=mu(o))}else if(d===n&&n.length===0&&q(p)&&U(p.value)&&Q(p.value[4].value)===`from`){if(l||c)return!1;for(;Cc(e.value[f+1])||wc(e.value[f+1]);)f++;if(f++,p=e.value[f],l=t(p),!1===l)return!1;l.syntaxFlags.has(Y.Experimental)&&u.syntaxFlags.add(Y.Experimental),u.syntaxFlags.add(Y.RelativeColorSyntax)}else{if(!q(p))return!1;if(U(p.value)&&o&&o.has(Q(p.value[4].value))){d.push(new K(o.get(Q(p.value[4].value))));continue}d.push(p)}}}if(!c||d.length!==1||n.length!==1||r.length!==1||i.length!==1||!q(n[0])||!q(r[0])||!q(i[0])||o&&!o.has(`alpha`))return!1;let f=gu(n[0].value,0,u);if(!f||!W(f))return!1;let p=gu(r[0].value,1,u);if(!p||!W(p))return!1;let m=gu(i[0].value,2,u);if(!m||!W(m))return!1;let h=[f,p,m];if(a.length===1)if(u.syntaxFlags.add(Y.HasAlpha),q(a[0])){let e=gu(a[0].value,3,u);if(!e||!W(e))return!1;h.push(e)}else u.alpha=a[0];else if(o&&o.has(`alpha`)){let e=gu(o.get(`alpha`),3,u);if(!e||!W(e))return!1;h.push(e)}return u.channels=[h[0][4].value,h[1][4].value,h[2][4].value],h.length===4&&(u.alpha=h[3][4].value),u}function yu(e){switch(e){case`srgb`:return J.sRGB;case`srgb-linear`:return J.Linear_sRGB;case`display-p3`:return J.Display_P3;case`display-p3-linear`:return J.Linear_Display_P3;case`a98-rgb`:return J.A98_RGB;case`prophoto-rgb`:return J.ProPhoto_RGB;case`rec2020`:return J.Rec2020;case`xyz`:case`xyz-d65`:return J.XYZ_D65;case`xyz-d50`:return J.XYZ_D50;default:throw Error(`Unknown color space name: `+e)}}const bu=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`lab`,`oklab`,`xyz`,`xyz-d50`,`xyz-d65`]),xu=new Set([`hsl`,`hwb`,`lch`,`oklch`]),Su=new Set([`shorter`,`longer`,`increasing`,`decreasing`]);function Cu(e,t){let n=null,r=null,i=null,a=!1;for(let o=0;o<e.value.length;o++){let s=e.value[o];if(!Tc(s)){if(!(n||q(s)&&U(s.value)&&Q(s.value[4].value)===`in`))return Tu(`oklab`,wu(e.value,t));if(q(s)&&U(s.value)){if(!n&&Q(s.value[4].value)===`in`){n=s;continue}if(n&&!r){r=Q(s.value[4].value);continue}if(n&&r&&!i&&xu.has(r)){i=Q(s.value[4].value);continue}if(n&&r&&i&&!a&&Q(s.value[4].value)===`hue`){a=!0;continue}return!1}return!(!q(s)||!mo(s.value))&&!!r&&(i||a?!!(i&&a&&xu.has(r)&&Su.has(i))&&Du(r,i,wu(e.value.slice(o+1),t)):bu.has(r)?Tu(r,wu(e.value.slice(o+1),t)):!!xu.has(r)&&Du(r,`shorter`,wu(e.value.slice(o+1),t)))}}return!1}function wu(e,t){let n=[],r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(!Tc(o)){if(!q(o)||!mo(o.value)){if(!r){let e=t(o);if(e){r=e;continue}}if(!i){if(Sc(o)&&ou.has(Q(o.getName()))){if([[o]]=iu([[o]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0}),!o||!q(o)||!V(o.value))return!1;Number.isNaN(o.value[4].value)&&(o.value[4].value=0)}if(q(o)&&G(o.value)&&o.value[4].value>=0){i=o.value[4].value;continue}}return!1}if(!r)return!1;n.push({color:r,percentage:i}),r=!1,i=!1}}return!!r&&(n.push({color:r,percentage:i}),n)}function Tu(e,t){if(!t||!t.length)return!1;for(let e of t)if(e.percentage&&(e.percentage<0||e.percentage>100))return!1;let{items:n,leftover:r}=Nu(t,!0),i=1-r/100,a;switch(e){case`srgb`:a=J.RGB;break;case`srgb-linear`:a=J.Linear_sRGB;break;case`display-p3`:a=J.Display_P3;break;case`display-p3-linear`:a=J.Linear_Display_P3;break;case`a98-rgb`:a=J.A98_RGB;break;case`prophoto-rgb`:a=J.ProPhoto_RGB;break;case`rec2020`:a=J.Rec2020;break;case`lab`:a=J.Lab;break;case`oklab`:a=J.OKLab;break;case`xyz-d50`:a=J.XYZ_D50;break;case`xyz`:case`xyz-d65`:a=J.XYZ_D65;break;default:return!1}if(n.length===1){let e=uu(n[0].color,a);return e.colorNotation=a,e.syntaxFlags.add(Y.ColorMixVariadic),typeof e.alpha==`number`?(e.alpha*=i,e):!1}for(n.reverse();n.length>=2;){let e=n.pop(),t=n.pop();if(!e||!t)return!1;let r=e.percentage+t.percentage,i=r>0?t.percentage/r:.5,o=Eu(a,e.color,t.color,i);if(!o)return!1;n.push({color:o,percentage:r})}let o=n[0]?.color;return!!o&&typeof o.alpha==`number`&&(o.alpha*=i,t.some(e=>e.color.syntaxFlags.has(Y.Experimental))&&o.syntaxFlags.add(Y.Experimental),t.length!==2&&o.syntaxFlags.add(Y.ColorMixVariadic),o)}function Eu(e,t,n,r){let i=t.alpha;if(typeof i!=`number`)return!1;let a=n.alpha;if(typeof a!=`number`)return!1;i=Number.isNaN(i)?a:i,a=Number.isNaN(a)?i:a;let o=uu(t,e).channels,s=uu(n,e).channels;o[0]=ku(o[0],s[0]),s[0]=ku(s[0],o[0]),o[1]=ku(o[1],s[1]),s[1]=ku(s[1],o[1]),o[2]=ku(o[2],s[2]),s[2]=ku(s[2],o[2]),o[0]=ju(o[0],i),o[1]=ju(o[1],i),o[2]=ju(o[2],i),s[0]=ju(s[0],a),s[1]=ju(s[1],a),s[2]=ju(s[2],a);let c=Au(i,a,r);return{colorNotation:e,channels:[Mu(Au(o[0],s[0],r),c),Mu(Au(o[1],s[1],r),c),Mu(Au(o[2],s[2],r),c)],alpha:c,syntaxFlags:new Set([Y.ColorMix])}}function Du(e,t,n){if(!n||!n.length)return!1;for(let e of n)if(e.percentage&&(e.percentage<0||e.percentage>100))return!1;let{items:r,leftover:i}=Nu(n,!0),a=1-i/100,o;switch(e){case`hsl`:o=J.HSL;break;case`hwb`:o=J.HWB;break;case`lch`:o=J.LCH;break;case`oklch`:o=J.OKLCH;break;default:return!1}if(r.length===1){let e=uu(r[0].color,o);return e.colorNotation=o,e.syntaxFlags.add(Y.ColorMixVariadic),typeof e.alpha==`number`?(e.alpha*=a,e):!1}for(r.reverse();r.length>=2;){let e=r.pop(),n=r.pop();if(!e||!n)return!1;let i=e.percentage+n.percentage,a=i>0?n.percentage/i:.5,s=Ou(o,t,e.color,n.color,a);if(!s)return!1;r.push({color:s,percentage:i})}let s=r[0]?.color;return!!s&&typeof s.alpha==`number`&&(s.alpha*=a,n.some(e=>e.color.syntaxFlags.has(Y.Experimental))&&s.syntaxFlags.add(Y.Experimental),n.length!==2&&s.syntaxFlags.add(Y.ColorMixVariadic),s)}function Ou(e,t,n,r,i){let a=0,o=0,s=0,c=0,l=0,u=0,d=n.alpha;if(typeof d!=`number`)return!1;let f=r.alpha;if(typeof f!=`number`)return!1;d=Number.isNaN(d)?f:d,f=Number.isNaN(f)?d:f;let p=uu(n,e).channels,m=uu(r,e).channels;switch(e){case J.HSL:case J.HWB:a=p[0],o=m[0],s=p[1],c=m[1],l=p[2],u=m[2];break;case J.LCH:case J.OKLCH:s=p[0],c=m[0],l=p[1],u=m[1],a=p[2],o=m[2]}a=ku(a,o),Number.isNaN(a)&&(a=0),o=ku(o,a),Number.isNaN(o)&&(o=0),s=ku(s,c),c=ku(c,s),l=ku(l,u),u=ku(u,l);let h=o-a;switch(t){case`shorter`:h>180?a+=360:h<-180&&(o+=360);break;case`longer`:-180<h&&h<180&&(h>0?a+=360:o+=360);break;case`increasing`:h<0&&(o+=360);break;case`decreasing`:h>0&&(a+=360);break;default:throw Error(`Unknown hue interpolation method`)}s=ju(s,d),l=ju(l,d),c=ju(c,f),u=ju(u,f);let g=[0,0,0],_=Au(d,f,i);switch(e){case J.HSL:case J.HWB:g=[Au(a,o,i),Mu(Au(s,c,i),_),Mu(Au(l,u,i),_)];break;case J.LCH:case J.OKLCH:g=[Mu(Au(s,c,i),_),Mu(Au(l,u,i),_),Au(a,o,i)]}return{colorNotation:e,channels:g,alpha:_,syntaxFlags:new Set([Y.ColorMix])}}function ku(e,t){return Number.isNaN(e)?t:e}function Au(e,t,n){return e*(1-n)+t*n}function ju(e,t){return Number.isNaN(t)?e:Number.isNaN(e)?NaN:e*t}function Mu(e,t){return t===0||Number.isNaN(t)?e:Number.isNaN(e)?NaN:e/t}function Nu(e,t=!1){let n=0,r=0;for(let t of e)t.percentage&&(n+=t.percentage),!1===t.percentage&&r++;n=Math.min(100,n);for(let t of e)!1===t.percentage&&(t.percentage=(100-n)/r);let i=e.slice(),a=0;for(let e of i)a+=e.percentage;if(a>100||a>0&&t)for(let e of i)e.percentage*=100/a;let o=0;return a<100&&(o=100-a),{items:i,leftover:o}}function Pu(e){let t=Q(e[4].value);if(t.match(/[^a-f0-9]/))return!1;let n={colorNotation:J.HEX,channels:[0,0,0],alpha:1,syntaxFlags:new Set([Y.Hex])},r=t.length;if(r===3){let e=t[0],r=t[1],i=t[2];return n.channels=[parseInt(e+e,16)/255,parseInt(r+r,16)/255,parseInt(i+i,16)/255],n}if(r===6){let e=t[0]+t[1],r=t[2]+t[3],i=t[4]+t[5];return n.channels=[parseInt(e,16)/255,parseInt(r,16)/255,parseInt(i,16)/255],n}if(r===4){let e=t[0],r=t[1],i=t[2],a=t[3];return n.channels=[parseInt(e+e,16)/255,parseInt(r+r,16)/255,parseInt(i+i,16)/255],n.alpha=parseInt(a+a,16)/255,n.syntaxFlags.add(Y.HasAlpha),n}if(r===8){let e=t[0]+t[1],r=t[2]+t[3],i=t[4]+t[5],a=t[6]+t[7];return n.channels=[parseInt(e,16)/255,parseInt(r,16)/255,parseInt(i,16)/255],n.alpha=parseInt(a,16)/255,n.syntaxFlags.add(Y.HasAlpha),n}return!1}function Fu(e){if(W(e))return e[4].value=e[4].value%360,e[1]=e[4].value.toString(),e;if(H(e)){let t=e[4].value;switch(Q(e[4].unit)){case`deg`:break;case`rad`:t=180*e[4].value/Math.PI;break;case`grad`:t=.9*e[4].value;break;case`turn`:t=360*e[4].value;break;default:return!1}return t%=360,[z.Number,t.toString(),e[2],e[3],{value:t,type:B.Number}]}return!1}function Iu(e,t,n){if(t===0){let t=Fu(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,1,0,100);return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){if(t!==3)return!1;let n=Z(e[4].value,1,0,100);return t===3&&(n=Z(e[4].value,1,0,1)),[z.Number,n.toString(),e[2],e[3],{value:n,type:B.Number}]}return!1}function Lu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===0){let t=Fu(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=e[4].value;return t===3?r=Z(e[4].value,100,0,1):t===1&&(r=Z(e[4].value,1,0,2147483647)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=e[4].value;return t===3?r=Z(e[4].value,1,0,1):t===1&&(r=Z(e[4].value,1,0,2147483647)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Ru(e,t,n,r){let i=[],a=[],o=[],s=[],c={colorNotation:n,channels:[0,0,0],alpha:1,syntaxFlags:new Set(r)},l=i;for(let t=0;t<e.value.length;t++){let n=e.value[t];if(!Cc(n)&&!wc(n)){if(q(n)&&mo(n.value)){if(l===i){l=a;continue}if(l===a){l=o;continue}if(l===o){l=s;continue}if(l===s)return!1}if(Sc(n)){if(l===s&&n.getName().toLowerCase()===`var`){c.syntaxFlags.add(Y.HasVariableAlpha),l.push(n);continue}if(!ou.has(n.getName().toLowerCase()))return!1;let[[e]]=iu([[n]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),n=e}if(!q(n))return!1;l.push(n)}}if(l.length!==1||i.length!==1||a.length!==1||o.length!==1||!q(i[0])||!q(a[0])||!q(o[0]))return!1;let u=t(i[0].value,0,c);if(!u||!W(u))return!1;let d=t(a[0].value,1,c);if(!d||!W(d))return!1;let f=t(o[0].value,2,c);if(!f||!W(f))return!1;let p=[u,d,f];if(s.length===1)if(c.syntaxFlags.add(Y.HasAlpha),q(s[0])){let e=t(s[0].value,3,c);if(!e||!W(e))return!1;p.push(e)}else c.alpha=s[0];return c.channels=[p[0][4].value,p[1][4].value,p[2][4].value],p.length===4&&(c.alpha=p[3][4].value),c}function zu(e,t,n,r,i){let a=[],o=[],s=[],c=[],l,u,d=!1,f={colorNotation:n,channels:[0,0,0],alpha:1,syntaxFlags:new Set(r)},p=a;for(let t=0;t<e.value.length;t++){let r=e.value[t];if(Cc(r)||wc(r))for(;Cc(e.value[t+1])||wc(e.value[t+1]);)t++;else if(p===a&&a.length&&(p=o),p===o&&o.length&&(p=s),q(r)&&go(r.value)&&r.value[4].value===`/`){if(p===c)return!1;p=c}else{if(Sc(r)){if(p===c&&r.getName().toLowerCase()===`var`){f.syntaxFlags.add(Y.HasVariableAlpha),p.push(r);continue}if(!ou.has(r.getName().toLowerCase()))return!1;let[[e]]=iu([[r]],{censorIntoStandardRepresentableValues:!0,globals:u,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),r=e}if(p===a&&a.length===0&&q(r)&&U(r.value)&&r.value[4].value.toLowerCase()===`from`){if(d)return!1;for(;Cc(e.value[t+1])||wc(e.value[t+1]);)t++;if(t++,r=e.value[t],d=i(r),!1===d)return!1;d.syntaxFlags.has(Y.Experimental)&&f.syntaxFlags.add(Y.Experimental),f.syntaxFlags.add(Y.RelativeColorSyntax),d.colorNotation!==n&&(d=uu(d,n)),l=pu(d),u=mu(l)}else{if(!q(r))return!1;if(U(r.value)&&l){let e=r.value[4].value.toLowerCase();if(l.has(e)){p.push(new K(l.get(e)));continue}}p.push(r)}}}if(p.length!==1||a.length!==1||o.length!==1||s.length!==1||!q(a[0])||!q(o[0])||!q(s[0])||l&&!l.has(`alpha`))return!1;let m=t(a[0].value,0,f);if(!m||!W(m))return!1;let h=t(o[0].value,1,f);if(!h||!W(h))return!1;let g=t(s[0].value,2,f);if(!g||!W(g))return!1;let _=[m,h,g];if(c.length===1)if(f.syntaxFlags.add(Y.HasAlpha),q(c[0])){let e=t(c[0].value,3,f);if(!e||!W(e))return!1;_.push(e)}else f.alpha=c[0];else if(l&&l.has(`alpha`)){let e=t(l.get(`alpha`),3,f);if(!e||!W(e))return!1;_.push(e)}return f.channels=[_[0][4].value,_[1][4].value,_[2][4].value],_.length===4&&(f.alpha=_[3][4].value),f}function Bu(e,t){if(e.value.some(e=>q(e)&&mo(e.value))){let t=Vu(e);if(!1!==t)return t}{let n=Hu(e,t);if(!1!==n)return n}return!1}function Vu(e){return Ru(e,Iu,J.HSL,[Y.LegacyHSL])}function Hu(e,t){return zu(e,Lu,J.HSL,[],t)}function Uu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===0){let t=Fu(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=e[4].value;return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=e[4].value;return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Wu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,1,0,100);return t===1||t===2?r=Z(e[4].value,.8,-2147483647,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,100);return t===1||t===2?r=Z(e[4].value,1,-2147483647,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Gu(e,t){return zu(e,Wu,J.Lab,[],t)}function Ku(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===2){let t=Fu(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,1,0,100);return t===1?r=Z(e[4].value,100/150,0,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,100);return t===1?r=Z(e[4].value,1,0,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function qu(e,t){return zu(e,Ku,J.LCH,[],t)}const Ju=new Map;for(let[e,t]of Object.entries(tc))Ju.set(e,t);function Yu(e){let t=Ju.get(Q(e));return!!t&&{colorNotation:J.RGB,channels:[t[0]/255,t[1]/255,t[2]/255],alpha:1,syntaxFlags:new Set([Y.ColorKeyword,Y.NamedColor])}}function Xu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,0,1);return t===1||t===2?r=Z(e[4].value,250,-2147483647,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,1);return t===1||t===2?r=Z(e[4].value,1,-2147483647,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function Zu(e,t){return zu(e,Xu,J.OKLab,[],t)}function Qu(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(t===2){let t=Fu(e);return!1!==t&&(H(e)&&n.syntaxFlags.add(Y.HasDimensionValues),t)}if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,0,1);return t===1?r=Z(e[4].value,250,0,2147483647):t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,1,0,1);return t===1?r=Z(e[4].value,1,0,2147483647):t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function $u(e,t){return zu(e,Qu,J.OKLCH,[],t)}function ed(e,t,n){if(G(e)){t===3?n.syntaxFlags.add(Y.HasPercentageAlpha):n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,0,1);return[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,255,0,1);return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function td(e,t,n){if(U(e)&&e[4].value.toLowerCase()===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[z.Number,`none`,e[2],e[3],{value:NaN,type:B.Number}];if(G(e)){t!==3&&n.syntaxFlags.add(Y.HasPercentageValues);let r=Z(e[4].value,100,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,100,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}if(W(e)){t!==3&&n.syntaxFlags.add(Y.HasNumberValues);let r=Z(e[4].value,255,-2147483647,2147483647);return t===3&&(r=Z(e[4].value,1,0,1)),[z.Number,r.toString(),e[2],e[3],{value:r,type:B.Number}]}return!1}function nd(e,t){if(e.value.some(e=>q(e)&&mo(e.value))){let t=rd(e);if(!1!==t)return(!t.syntaxFlags.has(Y.HasNumberValues)||!t.syntaxFlags.has(Y.HasPercentageValues))&&t}else{let n=id(e,t);if(!1!==n)return n}return!1}function rd(e){return Ru(e,ed,J.RGB,[Y.LegacyRGB])}function id(e,t){return zu(e,td,J.RGB,[],t)}function ad(e){let t=Cs(e);if(Zs(t))return Qs(t);let n=e;return n=Fs(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),ns($s(n,od,sd))}function od(e){return e=Ro(e),e=Ho(e),es(e)}function sd(e){return e=ys(e),e=qo(e),zo(e)}function cd(e,t){let n=!1;for(let r=0;r<e.value.length;r++){let i=e.value[r];if(!Cc(i)&&!wc(i)&&(n||(n=t(i),!n)))return!1}if(!n)return!1;n.channels=su(n.channels),n.channels=ad(cu(n).channels),n.colorNotation=J.sRGB;let r={colorNotation:J.RGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([Y.ContrastColor,Y.Experimental])};return r.channels=rc(n.channels,[1,1,1])>rc(n.channels,[0,0,0])?[1,1,1]:[0,0,0],r}function ld(e,t){let n,r,i=!1,a=!1,o=!1,s={colorNotation:J.sRGB,channels:[0,0,0],alpha:1,syntaxFlags:new Set([])};for(let c=0;c<e.value.length;c++){let l=e.value[c];if(Cc(l)||wc(l))for(;Cc(e.value[c+1])||wc(e.value[c+1]);)c++;else if(o&&!i&&!a&&q(l)&&go(l.value)&&l.value[4].value===`/`)i=!0;else{if(Sc(l)&&ou.has(Q(l.getName()))){let[[e]]=iu([[l]],{censorIntoStandardRepresentableValues:!0,globals:r,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!V(e.value))return!1;Number.isNaN(e.value[4].value)&&(e.value[4].value=0),l=e}if(i||a||!q(l)||!U(l.value)||Q(l.value[4].value)!==`from`){if(!i||a)return!1;if(q(l)){if(U(l.value)&&Q(l.value[4].value)===`alpha`&&n&&n.has(`alpha`)){s.alpha=n.get(`alpha`)[4].value,a=!0;continue}let e=gu(l.value,3,s);if(!e||!W(e))return!1;s.alpha=new K(e),a=!0;continue}if(Sc(l)){s.alpha=bc([[l]],e=>{if(q(e)&&U(e.value)&&Q(e.value[4].value)===`alpha`&&n&&n.has(`alpha`))return new K(n.get(`alpha`))})[0][0],a=!0;continue}return!1}if(o)return!1;for(;Cc(e.value[c+1])||wc(e.value[c+1]);)c++;if(c++,l=e.value[c],o=t(l),!1===o)return!1;n=pu(o),r=mu(n),s.syntaxFlags=new Set(o.syntaxFlags),s.syntaxFlags.add(Y.RelativeAlphaSyntax),s.channels=[...o.channels],s.colorNotation=o.colorNotation,s.alpha=o.alpha}}return!!n&&s}function ud(e){if(Sc(e))switch(Q(e.getName())){case`rgb`:case`rgba`:return nd(e,ud);case`hsl`:case`hsla`:return Bu(e,ud);case`hwb`:return t=ud,zu(e,Uu,J.HWB,[],t);case`lab`:return Gu(e,ud);case`lch`:return qu(e,ud);case`oklab`:return Zu(e,ud);case`oklch`:return $u(e,ud);case`color`:return vu(e,ud);case`color-mix`:return Cu(e,ud);case`contrast-color`:return cd(e,ud);case`alpha`:return ld(e,ud)}var t;if(q(e)){if(yo(e.value))return Pu(e.value);if(U(e.value)){let t=Yu(e.value[4].value);return!1===t?Q(e.value[4].value)===`transparent`&&{colorNotation:J.RGB,channels:[0,0,0],alpha:0,syntaxFlags:new Set([Y.ColorKeyword])}:t}}return!1}function dd(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function fd(e){switch(e.colorNotation){case`hex`:case`rgb`:case`srgb`:return{...e,colorNotation:`xyz-d50`,channels:Ss(dd(e.channels))};case`srgb-linear`:return{...e,colorNotation:`xyz-d50`,channels:Is(dd(e.channels))};case`display-p3`:return{...e,colorNotation:`xyz-d50`,channels:Bs(dd(e.channels))};case`display-p3-linear`:return{...e,colorNotation:`xyz-d50`,channels:Hs(dd(e.channels))};case`rec2020`:return{...e,colorNotation:`xyz-d50`,channels:Ws(dd(e.channels))};case`a98-rgb`:return{...e,colorNotation:`xyz-d50`,channels:Rs(dd(e.channels))};case`prophoto-rgb`:return{...e,colorNotation:`xyz-d50`,channels:Ks(dd(e.channels))};case`hsl`:return{...e,colorNotation:`xyz-d50`,channels:ws(dd(e.channels))};case`hwb`:return{...e,colorNotation:`xyz-d50`,channels:Es(dd(e.channels))};case`lab`:return{...e,colorNotation:`xyz-d50`,channels:Os(dd(e.channels))};case`oklab`:return{...e,colorNotation:`xyz-d50`,channels:Ms(dd(e.channels))};case`lch`:return{...e,colorNotation:`xyz-d50`,channels:As(dd(e.channels))};case`oklch`:return{...e,colorNotation:`xyz-d50`,channels:Ps(dd(e.channels))};case`xyz-d50`:return{...e,colorNotation:`xyz-d50`,channels:Xs(dd(e.channels))};case`xyz-d65`:return{...e,colorNotation:`xyz-d50`,channels:Js(dd(e.channels))};default:throw Error(`Unsupported color notation`)}}function pd(e,t=7){e=+e,t=+t;let n=(Math.floor(Math.abs(e))+``).length;if(t>n)return+e.toFixed(t-n);{let r=10**(n-t);return Math.round(e/r)*r}}function md(e){let t=Cs(e);if(Zs(t))return Qs(t);let n=e;return n=Fs(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),ns($s(n,hd,gd))}function hd(e){return e=Ro(e),e=Ho(e),es(e)}function gd(e){return e=ys(e),e=qo(e),zo(e)}var _d=class e{static colorTxtList=[];static parseColorString(e){try{let t=_c(no({css:e}));if(!t)return null;let n=ud(t);if(n===!1)return null;let r=md(fd(n).channels),i=Math.min(255,Math.max(0,Math.round(pd(r[0])*255))),a=Math.min(255,Math.max(0,Math.round(pd(r[1])*255))),o=Math.min(255,Math.max(0,Math.round(pd(r[2])*255))),s=1;return typeof n.alpha==`number`&&(s=Math.min(1,Math.max(0,pd(Number.isNaN(n.alpha)?0:n.alpha)))),m.Color.create(i/255,a/255,o/255,s)}catch(e){return $.error(e),null}}static getPos(e,t){let n=Array.from(e.slice(0,t).matchAll(/\n/g)),r=n.length,i=n[r-1],a=0;i.index&&(a=i.index);let o=t-a;return m.Position.create(r,o-1)}static getMatches(e){let t=[],n=e.matchAll(/(#(?:[\da-f]{3,4}){2}|#(?:[\da-f]{3})|rgb\((?:\d{1,3},\s*){2}\d{1,3}\)|rgba\((?:\d{1,3},\s*){3}\d*\.?\d+\)|hsl\(\d{1,3}(?:,\s*\d{1,3}%){2}\)|hsla\(\d{1,3}(?:,\s*\d{1,3}%){2},\s*\d*\.?\d+\|oklab\(\s*\d*\.?\d+\s*,\s*-?\d*\.?\d+\s*,\s*-?\d*\.?\d+\s*\)|oklch\(\s*\d*\.?\d+%?\s*(,| )\s*\d*\.?\d+\s*(,| )\s*\d*\.?\d+\s*\))/gi);if(n)for(let r of n){let n=r[0];if(!r.index)continue;let i=n.length,a=``;n.startsWith(`hsl(`)?a=`hsl`:n.startsWith(`hsla(`)?a=`hsla`:n.startsWith(`rgb(`)?a=`rgb`:n.startsWith(`rgba(`)?a=`rgba`:n.startsWith(`#`)?a=`hex`:n.startsWith(`oklch(`)?a=`oklch`:n.startsWith(`oklab(`)&&(a=`oklab`);let o=m.Range.create(this.getPos(e,r.index),this.getPos(e,r.index+n.length)),s=this.parseColorString(n);s&&t.push({color:s,type:a,length:i,range:o})}if(this.colorTxtList.length==0){let e=Object.getOwnPropertyNames(ma.Colors),t=[];for(let n of e)n!=`name`&&n!=`length`&&n!=`prototype`&&t.push(n);this.colorTxtList=t}let r=RegExp(`(?<![\\w\\d."'&$-])(`+this.colorTxtList.join(`|`)+`)(?![-\\w\\d])`,`gi`),i=e.matchAll(r);if(i)for(let n of i){let r=n[0];if(!n.index)continue;let i=r.length,a=m.Range.create(this.getPos(e,n.index),this.getPos(e,n.index+r.length)),o=this.parseColorString(ma.fromName(r).toHex());o&&t.push({color:o,type:`hex`,length:i,range:a})}return t}static onDocumentColor(t){return e.getMatches(t.getText()).map(e=>m.ColorInformation.create(e.range,e.color))}static onColorPresentations(e,t,n){let r=ma.fromRgb(n.red*255,n.green*255,n.blue*255);r.alpha=n.alpha;let i=e.getText(t),a=m.ColorPresentation.create(r.toString(`hex`)),o=m.ColorPresentation.create(r.toString(`hexa`)),s=m.ColorPresentation.create(r.toString(`hsl`)),c=m.ColorPresentation.create(r.toString(`hsla`)),l=m.ColorPresentation.create(r.toString(`rgb`)),u=m.ColorPresentation.create(r.toString(`rgba`)),d=!1;return i.startsWith(`#`)&&i.length===9&&(d=!0),i.startsWith(`hsla`)&&(d=!0),i.startsWith(`rgba`)&&(d=!0),n.alpha!==1&&(d=!0),d?[o,c,u]:[a,s,l]}},vd=class{static send(e){$.sendNotification(`aventus/openfile`,e)}},yd=class{static cmd=`aventus.addConfigSection`;static async run(e){try{if(!e){let t=[],n=N.getInstance().getAllConfigFiles();for(let e of n)t.push({label:e});if(t.length>1){let n=await $.Select(t,{title:`Select a project to add section`});if(!n)return;e=n.label}else e=t[0].label}let t=await $.Select([{label:`Build`},{label:`Static`}],{title:`Section type`});if(!t)return;let n=(0,u.readFileSync)(I(e),`utf8`),r=JSON.parse(n);if(t.label==`Build`){let e=await $.Input({title:`Provide a name for your build section`});if(!e)return;let t={name:e,src:[],compile:{output:`./dist/`+e.replace(/ /g,`-`)+`.js`}};r.build.push(t)}else if(t.label==`Static`){let e=await $.Input({title:`Provide a name for your static section`});if(!e)return;let t={name:e,input:``,output:``};r.static.push(t)}(0,u.writeFileSync)(I(e),JSON.stringify(r,null,4)),vd.send(e)}catch(e){console.error(e)}}},bd=class{static cmd=`aventus.compile`;static async run(){let e=[],t=N.getInstance().getAllBuilds();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Project to compile`});if(n){let e=n.detail??``,t=n.label;N.getInstance().getProjectByUri(e)?.getBuild(t)?.build()}}},xd=class e{static cmd=`aventus.create`;static async run(t){if(!t)return;let n=(0,f.normalize)(I(t));if(e.checkIfProject(t)){if(!$.isIDE){let e=await $.SelectFolder(`Select where to create`,n);if(!e)return;t=e,n=I(t)}await $.localTemplateManager?.createTemplate(n)}else await $.localProjectManager?.createGlobal(n)}static checkIfProject(e){let t=N.getInstance().getAllConfigFiles(),n=e.replace(/\\/g,`/`);for(let e of t)if(n.startsWith(e.replace(`/`+w.Config,``)))return!0;return!1}},Sd=class{static cmd=`aventus.filesystem.created`;static run(e){e&&R.getInstance().onCreatedUri(e)}},Cd=class{static cmd=`aventus.filesystem.deleted`;static async run(e){e&&R.getInstance().onDeletedUri(e)}},wd=class{static cmd=`aventus.filesystem.updated`;static async run(e){e&&R.getInstance().onUpdatedUri(e)}},Td=class{static send(e){$.sendNotification(`aventus/closefile`,e)}},Ed=class{static cmd=`aventus.component.merge`;static async run(e){if(!e)return;let t=RegExp(`(`+w.ComponentLogic+`)|(`+w.ComponentView+`)|(`+w.ComponentView+`)$`),n=e.replace(t,``),r=n.split(`/`),i=r.pop(),a=r.pop(),o=r.join(`/`)+`/`+i,s=0,c=R.getInstance().getByUri(n+w.ComponentLogic);c&&c.versionUser>s&&(s=c.versionUser);let l=c?c.contentUser:``,f=R.getInstance().getByUri(n+w.ComponentStyle);f&&f.versionUser>s&&(s=f.versionUser);let p=f?f.contentUser:``,m=R.getInstance().getByUri(n+w.ComponentView);m&&m.versionUser>s&&(s=m.versionUser);let h=m?m.contentUser:``,g=`
992
992
  <script>
993
- ${wd(l)}
993
+ ${Dd(l)}
994
994
  <\/script>
995
995
 
996
996
  <template>
997
- ${wd(h)}
997
+ ${Dd(h)}
998
998
  </template>
999
999
 
1000
1000
  <style>
1001
- ${wd(p)}
1001
+ ${Dd(p)}
1002
1002
  </style>
1003
- `,_=d.TextDocument.create(o+w.Component,C.WebComponent,s+1,g);(0,u.writeFileSync)(I(_.uri),g),f&&(sa(f.path),R.getInstance().onClose(f.documentUser),Sd.send(f.uri)),c&&(sa(c.path),R.getInstance().onClose(c.documentUser),Sd.send(c.uri)),m&&(sa(m.path),R.getInstance().onClose(m.documentUser),Sd.send(m.uri)),(0,u.rmdirSync)(I(r.join(`/`)+`/`+a)),R.getInstance().registerFile(_),hd.send(_.uri)}};function wd(e){return e.replace(/\r\n?/g,`
1003
+ `,_=d.TextDocument.create(o+w.Component,C.WebComponent,s+1,g);(0,u.writeFileSync)(I(_.uri),g),f&&(ua(f.path),R.getInstance().onClose(f.documentUser),Td.send(f.uri)),c&&(ua(c.path),R.getInstance().onClose(c.documentUser),Td.send(c.uri)),m&&(ua(m.path),R.getInstance().onClose(m.documentUser),Td.send(m.uri)),(0,u.rmdirSync)(I(r.join(`/`)+`/`+a)),R.getInstance().registerFile(_),vd.send(_.uri)}};function Dd(e){return e.replace(/\r\n?/g,`
1004
1004
  `).split(`
1005
1005
  `).join(`
1006
- `)}var Td=class{static cmd=`aventus.component.split`;static async run(e){if(!e)return;let t=e.split(`/`).pop()?.replace(w.Component,``),n=R.getInstance().getByUri(e);if(n){let r=I(e.replace(w.Component,``));(0,u.existsSync)(r)||(0,u.mkdirSync)(r);let i=e.replace(w.Component,``)+`/`+t,a=ui.getRegion(n),o=i+w.ComponentStyle,s=d.TextDocument.create(o,C.SCSS,n.versionUser+1,a.cssText??``);(0,u.writeFileSync)(I(o),s.getText());let c=i+w.ComponentView,l=d.TextDocument.create(c,C.HTML,n.versionUser+1,a.htmlText??``);(0,u.writeFileSync)(I(c),l.getText());let f=i+w.ComponentLogic,p=d.TextDocument.create(f,C.TypeScript,n.versionUser+1,a.scriptText??``);(0,u.writeFileSync)(I(f),p.getText()),sa(n.path),R.getInstance().onClose(n.documentUser),Sd.send(n.uri),R.getInstance().registerFile(s),R.getInstance().registerFile(l),R.getInstance().registerFile(p),hd.send(p.uri)}}},Ed=class{static cmd=`aventus.liveserver.start`;static run(){D.getInstance().start()}},Dd=class{static cmd=`aventus.liveserver.toggle`;static run(){D.getInstance().toggle()}},Od=class{static cmd=`aventus.static`;static async run(){let e=[],t=N.getInstance().getAllStatics();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Static to export`});if(n){let e=n.detail??``,t=n.label;await N.getInstance().getProjectByUri(e)?.getStatic(t)?.export()}}},kd=class{static cmd=`aventus.liveserver.stop`;static run(){D.getInstance().stop()}},Ad=class{static send(e,t){$.sendNotification(`aventus/editFile`,{uri:e,transformations:t})}},jd=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,{title:`Choose a type?`});if(!i)return;Ri(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()
1006
+ `)}var Od=class{static cmd=`aventus.component.split`;static async run(e){if(!e)return;let t=e.split(`/`).pop()?.replace(w.Component,``),n=R.getInstance().getByUri(e);if(n){let r=I(e.replace(w.Component,``));(0,u.existsSync)(r)||(0,u.mkdirSync)(r);let i=e.replace(w.Component,``)+`/`+t,a=ui.getRegion(n),o=i+w.ComponentStyle,s=d.TextDocument.create(o,C.SCSS,n.versionUser+1,a.cssText??``);(0,u.writeFileSync)(I(o),s.getText());let c=i+w.ComponentView,l=d.TextDocument.create(c,C.HTML,n.versionUser+1,a.htmlText??``);(0,u.writeFileSync)(I(c),l.getText());let f=i+w.ComponentLogic,p=d.TextDocument.create(f,C.TypeScript,n.versionUser+1,a.scriptText??``);(0,u.writeFileSync)(I(f),p.getText()),ua(n.path),R.getInstance().onClose(n.documentUser),Td.send(n.uri),R.getInstance().registerFile(s),R.getInstance().registerFile(l),R.getInstance().registerFile(p),vd.send(p.uri)}}},kd=class{static cmd=`aventus.liveserver.start`;static run(){D.getInstance().start()}},Ad=class{static cmd=`aventus.liveserver.toggle`;static run(){D.getInstance().toggle()}},jd=class{static cmd=`aventus.static`;static async run(){let e=[],t=N.getInstance().getAllStatics();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Static to export`});if(n){let e=n.detail??``,t=n.label;await N.getInstance().getProjectByUri(e)?.getStatic(t)?.export()}}},Md=class{static cmd=`aventus.liveserver.stop`;static run(){D.getInstance().stop()}},Nd=class{static send(e,t){$.sendNotification(`aventus/editFile`,{uri:e,transformations:t})}},Pd=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,{title:`Choose a type?`});if(!i)return;Ri(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()
1007
1007
  public `+r+e+`:`+a+`;
1008
- `,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,C.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}}];Ad.send(t,[m])}}},Md=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,{title:`Choose a type?`});if(!a)return;Ri(e.attrType,a);let o=a.detail,s=await $.Select([{label:`Yes`},{label:`No`}],{title:`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 j&&(a=e.getComponentName())}if(a==``)return;let s=``;c&&(s=`(target: `+a+`) => {
1008
+ `,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,C.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}}];Nd.send(t,[m])}}},Fd=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,{title:`Choose a type?`});if(!a)return;Ri(e.attrType,a);let o=a.detail,s=await $.Select([{label:`Yes`},{label:`No`}],{title:`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 j&&(a=e.getComponentName())}if(a==``)return;let s=``;c&&(s=`(target: `+a+`) => {
1009
1009
 
1010
1010
  }`);let u=`?`;(o==`boolean`||o==`number`)&&(u=`!`);let f=`@Property(`+s+`)
1011
1011
  public `+i+u+`:`+o+`;
1012
- `,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,C.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}}];Ad.send(t,[v])}}},Nd=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`}],{title:`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 j&&(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) => {
1012
+ `,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,C.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}}];Nd.send(t,[v])}}},Id=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`}],{title:`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 j&&(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) => {
1013
1013
 
1014
1014
  }`}let u=`@Watch(`+l+`)
1015
1015
  public `+r+`?:`+i+`;
1016
- `,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,C.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}}];Ad.send(e,[_])}}},Pd=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 j){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,C.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}}];Ad.send(e,[u])}}}}}},Fd=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 j){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,C.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}}];Ad.send(e,[u])}}}}}},Id=class{static cmd=`aventus.rename`;static async run(e){if(!P.getInstance().settings.updateImportOnRename||!e)return;let t=[];for(let n of e){let e=n.newUri,r=n.oldUri,i=I(e),a=I(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=F(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 N.getInstance().onRename(t),r={},i=R.getInstance();for(let e in n){let t=i.getByUri(e);t&&(await t.applyTextEdits(n[e]),r[I(t.uri)]=t.contentUser)}setTimeout(()=>{for(let e in r)(0,u.writeFileSync)(e,r[e])},500)}},Ld=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 E){let e=R.getInstance(),t=i.documentUser.uri.split(`/`),n=t[t.length-1].replace(w.ComponentLogic,``),a=Qi(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)(I(t))){let n=s+`/`+r+e;f.push({oldUri:t,newUri:n})}};p(w.ComponentLogic),p(w.ComponentStyle),p(w.ComponentView);let m=await N.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)(I(e),l[e].contentUser);(0,u.mkdirSync)(I(s));for(let t of f){let n=t.oldUri,r=t.newUri;(0,u.renameSync)(I(n),I(r)),Sd.send(n);let i=e.getByUri(n);i&&(e.registerFile(d.TextDocument.create(r,zi(r),1,i.contentUser)),e.onClose(i?.documentUser))}let t=I(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)}}},Rd=class{static cmd=`aventus.filesystem.openAventus`;static async run(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e);let t;switch((0,ue.platform)()){case`win32`:t=`explorer`;break;case`linux`:t=`xdg-open`;break;case`darwin`:t=`open`;break}(0,ce.spawn)(t,[e],{detached:!0}).unref()}},zd=class{static waitingResponse={};static send(e,...t){return new Promise(n=>{let r=T();for(;this.waitingResponse[r]!=null;)r=T();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])}},Bd=class{static cmd=`aventus.popupresponse`;static run(e,t){zd.resolve(e,t)}},Vd=class{static waitingResponse={};static send(e){return new Promise(t=>{let n=T();for(;this.waitingResponse[n]!=null;)n=T();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])}},Hd=class{static cmd=`aventus.receiveinput`;static run(e,t){Vd.resolve(e,t)}},Ud=class{static waitingResponse={};static waitingOptions={};static send(e,t){return new Promise(n=>{let r=T();for(;this.waitingResponse[r]!=null;)r=T();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]}}},Wd=class{static cmd=`aventus.receiveselect`;static run(e,t){Ud.resolve(e,t)}},Gd=class{static waitingResponse={};static send(e,t){return new Promise(n=>{let r=T();for(;this.waitingResponse[r]!=null;)r=T();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])}},Kd=class{static cmd=`aventus.receiveselectmultiple`;static run(e,t){Gd.resolve(e,t)}},qd=class{static cmd=`aventus.template.import`;static async run(){await $.templateManager?.selectTemplateToImport()}},Jd=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)}})),Yd=o(((e,t)=>{t.exports=Jd()}))(),Xd=class{static send(e,t,n){$.sendNotification(`aventus/sharp/compiling`,e,t,n)}},Zd=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(w.CsharpConfig)&&(this.files[e.uri]=new Qd(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},Qd=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 E&&await this.file.validate()}triggerSave(){this.file instanceof E&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof E&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return xe.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return xe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return xe.getInstance().doResolve(t)}async onHover(e,t){return xe.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return xe.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}},$d=class{static cmd=`aventus.sharp.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Yd.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}if(!(0,Yd.sync)(`csharp-converter`))try{if(await $.ask(`csharp-converter is missing. Can I install it?`)&&await $.showLoadingMessage(`Installing csharp-converter`,async()=>{await Fi(`dotnet tool install --global AventusSharp.Converter`)}),!(0,Yd.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(w.CsharpConfig)){let t=Object.keys(Zd.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,{title:`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)(I(e),`utf-8`);t=JSON.parse(n).csProj}catch(e){$.error(e)}this.isCompiling=!0,Xd.send(t,`compiling`);try{let{stdout:n}=await Fi(`csharp-converter `+I(e)),r=n.toString();if(r.indexOf(`Error : `)==-1)Xd.send(t,`success`);else{console.clear(),$.error(r);let e=`csharp_errors`;ci.send(e,r),Xd.send(t,`error`,[{title:`C# error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},ef=class{static cmd=`aventus.reloadSettings`;static async run(){$.refreshSettings()}},tf=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,C.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}}];Ad.send(e,[g])}}},nf=class{static cmd=`aventus.storybook.build`;static async run(){let e=[],t=N.getInstance().getAllBuildsWithStory();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Story to build`});if(n){let e=n.detail??``,t=n.label;N.getInstance().getProjectByUri(e)?.getBuild(t)?.buildStorybook()}}},rf=class{static cmd=`aventus.template.import_project`;static async run(){await $.templateManager?.selectProjectToImport(!1)}},af=class{static cmd=`aventus.npm.build`;static async run(){let e=[],t=N.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,{title:`Package to build`});if(n){let e=n.detail??``,t=n.label;N.getInstance().getProjectByUri(e)?.getBuild(t)?.buildNpm()}}},of=class{static cmd=`aventus.i18n.add`;static async run(e,t,n=!0){try{let r=N.getInstance().getMatchingBuildsByUri(e);if(r.length>0){let i=r[0],a=e.replace(w.ComponentView,w.I18n),o=[];if(n&&i.i18nComponentsFiles[a]){let e=I(a);o.push({label:(0,f.basename)(e),detail:e})}for(let e in i.tsLanguageService.i18nFiles){let t=I(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=F(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:_i.empty;let l=[{newText:JSON.stringify(_i.sortObj(a),null,4),range:{start:r.file.documentUser.positionAt(0),end:r.file.documentUser.positionAt(r.file.documentUser.getText().length)}}];Ad.send(n,[l]),setTimeout(async()=>{let t=e.replace(w.ComponentView,w.ComponentLogic),n=i.tsFiles[t],r=i.htmlFiles[e];await n?.validate(),await r?.validate()},2e3)}}}catch(e){console.error(e)}}},sf=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(w.PhpConfig)&&!e.uri.includes(`/vendor/`)&&(this.files[e.uri]=new cf(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},cf=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 E&&await this.file.validate()}triggerSave(){this.file instanceof E&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof E&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return xe.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return xe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return xe.getInstance().doResolve(t)}async onHover(e,t){return xe.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return xe.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}},lf=class{static cmd=`aventus.php.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Yd.sync)(`php`)){$.showErrorMessage(`Php isn't installed on your system`);return}if(!(0,Yd.sync)(`php-converter`))try{if(!(0,Yd.sync)(`composer`)){$.showErrorMessage(`composer isn't installed on your system`);return}if(await $.ask(`php-converter is missing. Can I install it?`)&&await Fi(`composer global require aventus/transpiler`),!(0,Yd.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(w.PhpConfig)){let t=Object.keys(sf.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,{title:`Project to compile`});if(r)e=r.label;else return}else{$.showErrorMessage(`No aventus.php.avt found`);return}}let t=``;try{let n=I(e.replace(w.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,Xd.send(t,`compiling`);try{let n=(0,f.join)($.extensionPath,`lib`,`bin`,`PhpToTypescript`,`PhpToTypescript.phar`),r=I(e),{stdout:i}=await Fi(`php `+n+` `+r+` 2>&1`,{encoding:`utf8`}),a=i.toString();if(a.indexOf(`Error : `)==-1)Xd.send(t,`success`);else{console.clear(),$.error(a);let e=`php_errors`;ci.send(e,a),Xd.send(t,`error`,[{title:`PHP error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},uf=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`))}},df=class{static cmd=`aventus.store.disconnect`;static async run(){ni.isConnected&&(await ni.disconnect(),$.showInformationMessage(`You are disconnected`))}},ff=class{static cmd=`aventus.store.publish_package`;static async run(){if(!ni.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let e=N.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,{title:`Project to compile`});if(n){let e=n.detail??``,t=n.label,r=N.getInstance().getProjectByUri(e)?.getBuild(t);if(r){let e=await ni.publishPackage(r);if(e instanceof ri)for(let t of e.errors)$.showErrorMessage(t.message);else $.showInformationMessage(`Package published`)}}}},pf=class{static send(e){let t=T();return $.sendNotification(`aventus/progress_start`,t,e),t}},mf=class{static send(e){$.sendNotification(`aventus/progress_stop`,e)}},hf=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=`
1016
+ `,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,C.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}}];Nd.send(e,[_])}}},Ld=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 j){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,C.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}}];Nd.send(e,[u])}}}}}},Rd=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 j){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,C.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}}];Nd.send(e,[u])}}}}}},zd=class{static cmd=`aventus.rename`;static async run(e){if(!P.getInstance().settings.updateImportOnRename||!e)return;let t=[];for(let n of e){let e=n.newUri,r=n.oldUri,i=I(e),a=I(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=F(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 N.getInstance().onRename(t),r={},i=R.getInstance();for(let e in n){let t=i.getByUri(e);t&&(await t.applyTextEdits(n[e]),r[I(t.uri)]=t.contentUser)}setTimeout(()=>{for(let e in r)(0,u.writeFileSync)(e,r[e])},500)}},Bd=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 E){let e=R.getInstance(),t=i.documentUser.uri.split(`/`),n=t[t.length-1].replace(w.ComponentLogic,``),a=Qi(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)(I(t))){let n=s+`/`+r+e;f.push({oldUri:t,newUri:n})}};p(w.ComponentLogic),p(w.ComponentStyle),p(w.ComponentView);let m=await N.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)(I(e),l[e].contentUser);(0,u.mkdirSync)(I(s));for(let t of f){let n=t.oldUri,r=t.newUri;(0,u.renameSync)(I(n),I(r)),Td.send(n);let i=e.getByUri(n);i&&(e.registerFile(d.TextDocument.create(r,zi(r),1,i.contentUser)),e.onClose(i?.documentUser))}let t=I(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)}}},Vd=class{static cmd=`aventus.filesystem.openAventus`;static async run(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e);let t;switch((0,ue.platform)()){case`win32`:t=`explorer`;break;case`linux`:t=`xdg-open`;break;case`darwin`:t=`open`;break}(0,ce.spawn)(t,[e],{detached:!0}).unref()}},Hd=class{static waitingResponse={};static send(e,...t){return new Promise(n=>{let r=T();for(;this.waitingResponse[r]!=null;)r=T();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])}},Ud=class{static cmd=`aventus.popupresponse`;static run(e,t){Hd.resolve(e,t)}},Wd=class{static waitingResponse={};static send(e){return new Promise(t=>{let n=T();for(;this.waitingResponse[n]!=null;)n=T();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])}},Gd=class{static cmd=`aventus.receiveinput`;static run(e,t){Wd.resolve(e,t)}},Kd=class{static waitingResponse={};static waitingOptions={};static send(e,t){return new Promise(n=>{let r=T();for(;this.waitingResponse[r]!=null;)r=T();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]}}},qd=class{static cmd=`aventus.receiveselect`;static run(e,t){Kd.resolve(e,t)}},Jd=class{static waitingResponse={};static send(e,t){return new Promise(n=>{let r=T();for(;this.waitingResponse[r]!=null;)r=T();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])}},Yd=class{static cmd=`aventus.receiveselectmultiple`;static run(e,t){Jd.resolve(e,t)}},Xd=class{static cmd=`aventus.template.import`;static async run(){await $.templateManager?.selectTemplateToImport()}},Zd=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)}})),Qd=o(((e,t)=>{t.exports=Zd()}))(),$d=class{static send(e,t,n){$.sendNotification(`aventus/sharp/compiling`,e,t,n)}},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(w.CsharpConfig)&&(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 E&&await this.file.validate()}triggerSave(){this.file instanceof E&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof E&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return xe.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return xe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return xe.getInstance().doResolve(t)}async onHover(e,t){return xe.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return xe.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.sharp.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Qd.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}if(!(0,Qd.sync)(`csharp-converter`))try{if(await $.ask(`csharp-converter is missing. Can I install it?`)&&await $.showLoadingMessage(`Installing csharp-converter`,async()=>{await Fi(`dotnet tool install --global AventusSharp.Converter`)}),!(0,Qd.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(w.CsharpConfig)){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,{title:`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)(I(e),`utf-8`);t=JSON.parse(n).csProj}catch(e){$.error(e)}this.isCompiling=!0,$d.send(t,`compiling`);try{let{stdout:n}=await Fi(`csharp-converter `+I(e)),r=n.toString();if(r.indexOf(`Error : `)==-1)$d.send(t,`success`);else{console.clear(),$.error(r);let e=`csharp_errors`;ci.send(e,r),$d.send(t,`error`,[{title:`C# error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},rf=class{static cmd=`aventus.reloadSettings`;static async run(){$.refreshSettings()}},af=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,C.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}}];Nd.send(e,[g])}}},of=class{static cmd=`aventus.storybook.build`;static async run(){let e=[],t=N.getInstance().getAllBuildsWithStory();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Story to build`});if(n){let e=n.detail??``,t=n.label;N.getInstance().getProjectByUri(e)?.getBuild(t)?.buildStorybook()}}},sf=class{static cmd=`aventus.template.import_project`;static async run(){await $.templateManager?.selectProjectToImport(!1)}},cf=class{static cmd=`aventus.npm.build`;static async run(){let e=[],t=N.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,{title:`Package to build`});if(n){let e=n.detail??``,t=n.label;N.getInstance().getProjectByUri(e)?.getBuild(t)?.buildNpm()}}},lf=class{static cmd=`aventus.i18n.add`;static async run(e,t,n=!0){try{let r=N.getInstance().getMatchingBuildsByUri(e);if(r.length>0){let i=r[0],a=e.replace(w.ComponentView,w.I18n),o=[];if(n&&i.i18nComponentsFiles[a]){let e=I(a);o.push({label:(0,f.basename)(e),detail:e})}for(let e in i.tsLanguageService.i18nFiles){let t=I(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=F(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:_i.empty;let l=[{newText:JSON.stringify(_i.sortObj(a),null,4),range:{start:r.file.documentUser.positionAt(0),end:r.file.documentUser.positionAt(r.file.documentUser.getText().length)}}];Nd.send(n,[l]),setTimeout(async()=>{let t=e.replace(w.ComponentView,w.ComponentLogic),n=i.tsFiles[t],r=i.htmlFiles[e];await n?.validate(),await r?.validate()},2e3)}}}catch(e){console.error(e)}}},uf=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(w.PhpConfig)&&!e.uri.includes(`/vendor/`)&&(this.files[e.uri]=new df(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},df=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 E&&await this.file.validate()}triggerSave(){this.file instanceof E&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof E&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return xe.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return xe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return xe.getInstance().doResolve(t)}async onHover(e,t){return xe.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return xe.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}},ff=class{static cmd=`aventus.php.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Qd.sync)(`php`)){$.showErrorMessage(`Php isn't installed on your system`);return}if(!(0,Qd.sync)(`php-converter`))try{if(!(0,Qd.sync)(`composer`)){$.showErrorMessage(`composer isn't installed on your system`);return}if(await $.ask(`php-converter is missing. Can I install it?`)&&await Fi(`composer global require aventus/transpiler`),!(0,Qd.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(w.PhpConfig)){let t=Object.keys(uf.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,{title:`Project to compile`});if(r)e=r.label;else return}else{$.showErrorMessage(`No aventus.php.avt found`);return}}let t=``;try{let n=I(e.replace(w.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,$d.send(t,`compiling`);try{let n=(0,f.join)($.extensionPath,`lib`,`bin`,`PhpToTypescript`,`PhpToTypescript.phar`),r=I(e),{stdout:i}=await Fi(`php `+n+` `+r+` 2>&1`,{encoding:`utf8`}),a=i.toString();if(a.indexOf(`Error : `)==-1)$d.send(t,`success`);else{console.clear(),$.error(a);let e=`php_errors`;ci.send(e,a),$d.send(t,`error`,[{title:`PHP error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},pf=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`))}},mf=class{static cmd=`aventus.store.disconnect`;static async run(){ni.isConnected&&(await ni.disconnect(),$.showInformationMessage(`You are disconnected`))}},hf=class{static cmd=`aventus.store.publish_package`;static async run(){if(!ni.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let e=N.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,{title:`Project to compile`});if(n){let e=n.detail??``,t=n.label,r=N.getInstance().getProjectByUri(e)?.getBuild(t);if(r){let e=await ni.publishPackage(r);if(e instanceof ri)for(let t of e.errors)$.showErrorMessage(t.message);else $.showInformationMessage(`Package published`)}}}},gf=class{static send(e){let t=T();return $.sendNotification(`aventus/progress_start`,t,e),t}},_f=class{static send(e){$.sendNotification(`aventus/progress_stop`,e)}},vf=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=`
1017
1017
  import { AventusTemplate } from 'file://${(0,f.join)(Be(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
1018
1018
  import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
1019
1019
 
@@ -1022,10 +1022,10 @@ public `+r+`?:`+i+`;
1022
1022
  });
1023
1023
 
1024
1024
  const t = new Template();
1025
- await t._run(\`${this.folderPath.replace(/\\/g,`\\\\`)}\`, \`${e.replace(/\\/g,`\\\\`)}\`, \`${t.replace(/\\/g,`\\\\`)}\`)`,i=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i);let a=(0,f.join)(i,oa(this.config)+`_1.ts`);(0,u.writeFileSync)(a,r);let o=(0,ce.spawn)(`node`,[`--no-warnings`,a],{cwd:this.folderPath,detached:!0}),s=(e,t)=>{let n=JSON.stringify({cmd:e,result:t??`NULL`})+`
1025
+ await t._run(\`${this.folderPath.replace(/\\/g,`\\\\`)}\`, \`${e.replace(/\\/g,`\\\\`)}\`, \`${t.replace(/\\/g,`\\\\`)}\`)`,i=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i);let a=(0,f.join)(i,la(this.config)+`_1.ts`);(0,u.writeFileSync)(a,r);let o=(0,ce.spawn)(`node`,[`--no-warnings`,a],{cwd:this.folderPath,detached:!0}),s=(e,t)=>{let n=JSON.stringify({cmd:e,result:t??`NULL`})+`
1026
1026
  `;o.stdin.write(n)};o.stdin.on(`error`,function(e){console.log(e)}),o.stdout.on(`data`,async e=>{let t=e.toString().trim(),n=[t];if(t.indexOf(`}
1027
1027
  {`)!=-1){n=t.split(`}
1028
- {`);for(let e=1;e<n.length;e++)n[e-1]+=`}`,n[e]=`{`+n[e]}try{for(let e of n){let t=JSON.parse(e);if(t.cmd==`input`){let e=t.config,n=await $.Input(e);s(t.cmd,n)}else if(t.cmd==`select`){let e=t.config,n=await $.Select(e.items,e.options);n==null?s(t.cmd,`NULL`):s(t.cmd,JSON.stringify(n))}else if(t.cmd==`selectMultiple`){let e=t.config,n=await $.SelectMultiple(e.items,e.options);n==null?s(t.cmd,`NULL`):s(t.cmd,JSON.stringify(n))}else if(t.cmd==`registerFile`){let e=t.config;for(let t of e)R.getInstance().onCreatedUri(F(t))}else if(t.cmd==`openFile`){let e=t.config;for(let t of e)$.sendNotification(`aventus/openfile`,(0,y.pathToFileURL)(t).toString())}else if(t.cmd==`getNamespace`){let e=t.config,n=N.getInstance().getMatchingBuildsByUri(F(e));if(n.length>0){let r=n[0].getNamespaceForUri(F(e));s(t.cmd,r)}else s(t.cmd,null)}else if(t.cmd==`exec`){let e={};e.cwd=I($.getWorkspaceUri());let n=t.config;try{await Fi(n,e)}catch(e){$.error(e),$.showErrorMessage(`The command `+n+` failed`)}s(t.cmd,`done`)}else if(t.cmd==`execAdmin`){let e=t.config,n=I($.getWorkspaceUri());try{`${n}`,process.platform==`darwin`&&`${n}`,(0,ge.exec)(`cd `+n+` && `+e,(e,t,n)=>{e&&($.error(`error: `+e),$.error(`stdout: `+t),$.error(`stderr: `+n))})}catch(t){$.error(t),$.showErrorMessage(`The command `+e+` failed`)}s(t.cmd,`done`)}else if(t.cmd==`showErrorMessage`)$.showErrorMessage(t.config);else if(t.cmd==`showWarningMessage`)$.showWarningMessage(t.config);else if(t.cmd==`showInformationMessage`)$.showInformationMessage(t.config);else if(t.cmd==`progressStart`){let e=t.config,n=pf.send(e);s(t.cmd,n)}else if(t.cmd==`progressStop`){let e=t.config;mf.send(e)}else t.cmd==`log`?$.debug(t.config):t.cmd==`error`&&console.error(t.config)}}catch(e){$.error(e),$.error(`message `+t),$.error(n)}}),o.stderr.on(`data`,e=>{console.error(`Erreur with template : ${e.toString().trim()}`)}),o.on(`close`,e=>{sa(a),n()})}catch{n()}})}async isAllowed(e,t){if(!this.hasIsAllow)return!0;let n=`
1028
+ {`);for(let e=1;e<n.length;e++)n[e-1]+=`}`,n[e]=`{`+n[e]}try{for(let e of n){let t=JSON.parse(e);if(t.cmd==`input`){let e=t.config,n=await $.Input(e);s(t.cmd,n)}else if(t.cmd==`select`){let e=t.config,n=await $.Select(e.items,e.options);n==null?s(t.cmd,`NULL`):s(t.cmd,JSON.stringify(n))}else if(t.cmd==`selectMultiple`){let e=t.config,n=await $.SelectMultiple(e.items,e.options);n==null?s(t.cmd,`NULL`):s(t.cmd,JSON.stringify(n))}else if(t.cmd==`registerFile`){let e=t.config;for(let t of e)R.getInstance().onCreatedUri(F(t))}else if(t.cmd==`openFile`){let e=t.config;for(let t of e)$.sendNotification(`aventus/openfile`,(0,y.pathToFileURL)(t).toString())}else if(t.cmd==`getNamespace`){let e=t.config,n=N.getInstance().getMatchingBuildsByUri(F(e));if(n.length>0){let r=n[0].getNamespaceForUri(F(e));s(t.cmd,r)}else s(t.cmd,null)}else if(t.cmd==`exec`){let e={};e.cwd=I($.getWorkspaceUri());let n=t.config;try{await Fi(n,e)}catch(e){$.error(e),$.showErrorMessage(`The command `+n+` failed`)}s(t.cmd,`done`)}else if(t.cmd==`execAdmin`){let e=t.config,n=I($.getWorkspaceUri());try{`${n}`,process.platform==`darwin`&&`${n}`,(0,ge.exec)(`cd `+n+` && `+e,(e,t,n)=>{e&&($.error(`error: `+e),$.error(`stdout: `+t),$.error(`stderr: `+n))})}catch(t){$.error(t),$.showErrorMessage(`The command `+e+` failed`)}s(t.cmd,`done`)}else if(t.cmd==`showErrorMessage`)$.showErrorMessage(t.config);else if(t.cmd==`showWarningMessage`)$.showWarningMessage(t.config);else if(t.cmd==`showInformationMessage`)$.showInformationMessage(t.config);else if(t.cmd==`progressStart`){let e=t.config,n=gf.send(e);s(t.cmd,n)}else if(t.cmd==`progressStop`){let e=t.config;_f.send(e)}else t.cmd==`log`?$.debug(t.config):t.cmd==`error`&&console.error(t.config)}}catch(e){$.error(e),$.error(`message `+t),$.error(n)}}),o.stderr.on(`data`,e=>{console.error(`Erreur with template : ${e.toString().trim()}`)}),o.on(`close`,e=>{ua(a),n()})}catch{n()}})}async isAllowed(e,t){if(!this.hasIsAllow)return!0;let n=`
1029
1029
  import { AventusTemplate, log } from 'file://${(0,f.join)(Be(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
1030
1030
  import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
1031
1031
 
@@ -1034,16 +1034,16 @@ public `+r+`?:`+i+`;
1034
1034
  });
1035
1035
 
1036
1036
  const t = new Template();
1037
- log(t._isAllowed(\`${this.folderPath.replace(/\\/g,`\\\\`)}\`, \`${e.replace(/\\/g,`\\\\`)}\`, \`${t.replace(/\\/g,`\\\\`)}\`))`,r=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(r)||(0,u.mkdirSync)(r);let i=(0,f.join)(r,oa(this.config)+`.ts`);(0,u.writeFileSync)(i,n);var a=``,o=``;let s=!1;try{let e=await Fi(`node --no-warnings ${i}`,{cwd:this.folderPath});if(o=e.stderr.toString(),a=e.stdout.toString().trim(),a!==`true`&&a!==`false`)throw`Result isn't a boolean`;s=a.trim()==`true`}catch(e){$.error(e),$.error(o),$.error(a),this.containsError=!0}return sa(i),s}static preparing={};prepareScript(){return new Promise(async t=>{let n=oa(this.config);if(e.preparing[n]!==void 0){e.preparing[n].push(e=>{t(e)});return}e.preparing[n]=[];let r=`
1037
+ log(t._isAllowed(\`${this.folderPath.replace(/\\/g,`\\\\`)}\`, \`${e.replace(/\\/g,`\\\\`)}\`, \`${t.replace(/\\/g,`\\\\`)}\`))`,r=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(r)||(0,u.mkdirSync)(r);let i=(0,f.join)(r,la(this.config)+`.ts`);(0,u.writeFileSync)(i,n);var a=``,o=``;let s=!1;try{let e=await Fi(`node --no-warnings ${i}`,{cwd:this.folderPath});if(o=e.stderr.toString(),a=e.stdout.toString().trim(),a!==`true`&&a!==`false`)throw`Result isn't a boolean`;s=a.trim()==`true`}catch(e){$.error(e),$.error(o),$.error(a),this.containsError=!0}return ua(i),s}static preparing={};prepareScript(){return new Promise(async t=>{let n=la(this.config);if(e.preparing[n]!==void 0){e.preparing[n].push(e=>{t(e)});return}e.preparing[n]=[];let r=`
1038
1038
  import { AventusTemplate, log } from 'file://${(0,f.join)(Be(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
1039
1039
  import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
1040
1040
  const t = new Template();
1041
- log(t.basicInfo())`,i=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i);let a=(0,f.join)(i,n+`.ts`);(0,u.writeFileSync)(a,r);let o={name:``,version:`1.0.0`,description:``,isAllow:!0};var s=``,c=``;try{let e=await Fi(`node --no-warnings ${a}`,{cwd:this.folderPath});c=e.stderr.toString(),s=e.stdout.toString();let t=JSON.parse(s.trim());o={...o,...t}}catch(e){$.error(e),$.error(c),$.error(s),this.containsError=!0}sa(a);let l=[...e.preparing[n]];e.preparing[n]=[];for(let e of l)e(o);t(o)})}},gf=class{static cmd=`aventus.template.quick_edit`;static async run(){let e=P.getInstance().settings.quickCreations,t=[],n=r=>{if(r instanceof hf)r.allowQuick&&t.push({label:r.name,detail:r.description,picked:e.includes(r.folderPath),folderPath:r.folderPath});else for(let e in r)n(r[e])};if(n((await $.templateManager?.readGlobal()??{nb:0,templates:{}}).templates),n((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),n((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates),t.length==0){P.getInstance().setSettings({quickCreations:[]},!0),$.showErrorMessage(`No template/project allow quick creation`);return}let r=await $.SelectMultiple(t,{title:`Select quick templates`});if(r){e=[];for(let n of r){let r=t.find(e=>e.label==n.label)?.folderPath;r&&e.push(r)}P.getInstance().setSettings({quickCreations:e},!0)}}},_f=class{static cmd=`aventus.template.quick`;static async run(){let e=P.getInstance().settings.quickCreations;if(e.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let t=$.templateManager?.workspaces??[],n=``;if(t.length==0)return;if(t.length==1)n=t[0];else{let e=[];for(let n of t)e.push({label:n});let r=await $.Select(e,{title:`Select workspace`});if(!r)return;n=r.label}let r=``;if(e.length==1)r=e[0];else{let t=[],n={},i={},a=e=>{if(e instanceof hf)e.allowQuick&&(i[e.folderPath]=e);else for(let t in e)a(e[t])};a((await $.templateManager?.getGeneralGlobal()??{nb:0,templates:{}}).templates),a((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),a((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates);for(let r of e)if(i[r]){let e=i[r];t.push({label:e.name,detail:e.description}),n[e.name]=r}else if(r.endsWith(w.Template)||(r=(0,f.join)(r,w.Template)),(0,u.existsSync)(r)){let e=await hf.create(r);e&&(t.push({label:e.name,detail:e.description}),n[e.name]=r)}if(t.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let o=await $.Select(t,{title:`Select quick template`});if(!o)return;r=n[o.label]}if(r.endsWith(w.Template)||(0,u.existsSync)((0,f.join)(r,w.Template))&&(r=(0,f.join)(r,w.Template)),!(0,u.existsSync)(r)){$.showErrorMessage(`The file doesn't exist : `+r);return}let i=await hf.create(r);i&&await i.init(n,n)}},vf=class{static cmd=`aventus.store.publish_template`;static async run(e){if(!e)return;if(!ni.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let t=I(e);if((0,u.existsSync)(t)&&t.endsWith(w.Template)){let e=await hf.create(t);if(e){let t=await ni.publishTemplate(e);if(t instanceof ri)for(let e of t.errors)$.showErrorMessage(e.message);else $.showInformationMessage(`Template published`)}else $.showErrorMessage(`Your script for the template contains errors`)}}},yf=class{static cmd=`aventus.store.download_template`;static async run(e){e&&await $.templateManager?.downloadTemplateFromStore(e)}},bf=class{static cmd=`aventus.template.uninstall_project`;static async run(){await $.templateManager?.selectProjectToUninstall()}},xf=class{static cmd=`aventus.template.uninstall`;static async run(){await $.templateManager?.selectTemplateToUninstall()}},Sf=class{static cmd=`aventus.format`;static async run(e){let t=[];t=e?[e]:R.getInstance().getUris(),$.showLoadingMessage(`Formatting `+t.length+` files`,async()=>{for(let e of t){let t=R.getInstance().getByUri(e);if(t instanceof E)try{let n=t.contentUser,r=await t.getFormatting();await t.applyTextEdits(r),n!=t.contentUser&&(0,u.writeFileSync)(I(e),t.contentUser)}catch(e){console.error(e)}}})}},Cf=class{static cmd=`aventus.ai.dependencies`;static async run(){if(!$.isIDE){let e=await R.getInstance().loadAllAventusConfigFiles([$.getWorkspaceUri()]);for(let t of e){let e=new Di(t,!1);await e.init();for(let t of e.getBuilds())await si.getInstance().loadDependenciesFromBuild(t.buildConfig,t)}}let e=si.getInstance().packages,t=(0,f.join)(I($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t);let n=(0,f.join)(t,`dependencies`);(0,u.existsSync)(n)&&(0,u.rmSync)(n,{force:!0,recursive:!0}),(0,u.mkdirSync)(n);for(let t of e){console.log(`writting : `+(0,f.join)(n,t.name)+`.md`);let e=ai.getMarkdown(t.file.uri);e&&(0,u.writeFileSync)((0,f.join)(n,t.name+`.md`),e)}}},wf=class{static cmd=`aventus.ai.rules`;static async run(){let e=(0,f.join)($.extensionPath,`lib`,`aventusjs-rules.md`),t=(0,f.join)(I($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t),(0,u.copyFileSync)(e,(0,f.join)(t,`aventusjs-rules.md`))}},Tf=class{static cmd=`aventus.emmet`;static async run(){ai.write(!0)}},Ef=class{static cmd=`aventus.sharp.update_tools`;static async run(){if(!(0,Yd.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}let e={"csharp-converter":`dotnet tool update --global AventusSharp.Converter`,"db-query":`dotnet tool update --global AventusSharp.DatabaseQuery`},t=[];for(let n in e)(0,Yd.sync)(n)&&await $.showLoadingMessage(`Updating `+n,async()=>{let r=await Fi(e[n]);r.stderr?$.showErrorMessage(r.stderr):t.push(n)});t.length>0&&$.showInformationMessage(`Update done for : `+t.join(`, `))}};const Df={allCommandes:{[_d.cmd]:_d,[Ed.cmd]:Ed,[kd.cmd]:kd,[Dd.cmd]:Dd,[vd.cmd]:vd,[Id.cmd]:Id,[Ld.cmd]:Ld,[Cd.cmd]:Cd,[Td.cmd]:Td,[Od.cmd]:Od,[gd.cmd]:gd,[tf.cmd]:tf,[jd.cmd]:jd,[Md.cmd]:Md,[Nd.cmd]:Nd,[Pd.cmd]:Pd,[Fd.cmd]:Fd,[yd.cmd]:yd,[xd.cmd]:xd,[bd.cmd]:bd,[Rd.cmd]:Rd,[Bd.cmd]:Bd,[Hd.cmd]:Hd,[Wd.cmd]:Wd,[Kd.cmd]:Kd,[qd.cmd]:qd,[rf.cmd]:rf,[$d.cmd]:$d,[Ef.cmd]:Ef,[lf.cmd]:lf,[ef.cmd]:ef,[nf.cmd]:nf,[af.cmd]:af,[of.cmd]:of,[uf.cmd]:uf,[df.cmd]:df,[ff.cmd]:ff,[vf.cmd]:vf,[yf.cmd]:yf,[_f.cmd]:_f,[gf.cmd]:gf,[bf.cmd]:bf,[xf.cmd]:xf,[Sf.cmd]:Sf,[Cf.cmd]:Cf,[wf.cmd]:wf,[Tf.cmd]:Tf},execute:async function(e){let t=this.allCommandes[e.command];if(t){let n=e.arguments??[];await t.run.call(t,...n)}}};var Of=class{templateManager;constructor(e){this.templateManager=e}async createTemplate(e){let t=await this.readTemplates(),n=await this.templateManager.readGlobal(),r=await this.templateManager.query(e,{...n.templates,...t.templates});r&&await r.init(e,this.templateManager.findWorkspace(e))}readTemplates(){let e=this.templateManager.getGeneralTemplates(),t=this.templateManager.getGeneralTemplatesLength(),n=$.getWorkspaceUri();if(n){let r=I(n)+`/.aventus/templates`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}},kf=class{templatePath=[];projectPath=[];globalPath=[];loadedTemplates={};loadedProjects={};loadedGlobal={};loadedProjectsLength=0;loadedTemplatesLength=0;loadedGlobalLength=0;workspaces=[];getGeneralTemplates(){return this.loadedTemplates}getGeneralTemplatesLength(){return this.loadedTemplatesLength}getGeneralProjects(){return this.loadedProjects}getGeneralProjectsLength(){return this.loadedProjectsLength}getGeneralGlobal(){return this.loadedGlobal}getGeneralGlobalLength(){return this.loadedGlobalLength}constructor(e){this.workspaces=e.map(e=>I(e).replace(/\//g,f.sep))}async init(){$.isIDE?this.loadTemplates():await this.loadTemplates(),P.getInstance().onSettingsChange(()=>{this.loadTemplates()})}async loadTemplates(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e),this.templatePath=P.getInstance().settings.templatePath;let t=(0,f.normalize)(e+f.sep+`templates`);this.prepareFolders(this.templatePath,t),this.globalPath=P.getInstance().settings.globalPath;let n=(0,f.normalize)(e+f.sep+`global`);this.prepareFolders(this.globalPath,n),this.projectPath=P.getInstance().settings.projectPath;let r=(0,f.normalize)(e+f.sep+`projects`),i=!(0,u.existsSync)(r)||(0,u.readdirSync)(r).length==0;this.prepareFolders(this.projectPath,r),i&&await this.askTemplate();let a=[];a.push(this.reloadTemplates()),a.push(this.reloadProjects()),a.push(this.reloadGlobal()),await Promise.all(a)}async reloadTemplates(){let e=await this.readTemplates(this.templatePath);this.loadedTemplates=e.templates,this.loadedTemplatesLength=e.nb}async reloadProjects(){let e=await this.readTemplates(this.projectPath);this.loadedProjects=e.templates,this.loadedProjectsLength=e.nb}async reloadGlobal(){let e=await this.readTemplates(this.globalPath);this.loadedGlobal=e.templates,this.loadedGlobalLength=e.nb}prepareFolders(e,t){e.includes(t)||e.splice(0,0,t);for(let t=0;t<e.length;t++)e[t]=(0,f.normalize)(e[t]),(0,u.existsSync)(e[t])||(0,u.mkdirSync)(e[t])}findWorkspace(e){for(let t of this.workspaces)if(e.startsWith(t))return t;return $.showErrorMessage(`Can't load the workspace`),``}async readTemplates(e,t={},n=0){let r=[],i=e=>{let a=(0,f.join)(e,w.Template);if((0,u.existsSync)(a)){try{r.push(new Promise(async e=>{let r=await hf.create(a);r&&(ra(r.name,t,r),n++),e()}))}catch(e){console.error(e),$.showErrorMessage(`Error when parsing file `+a)}return}let o=(0,u.readdirSync)(e);for(let t of o)try{let n=(0,f.join)(e,t);(0,u.statSync)(n).isDirectory()&&i(n)}catch(e){$.error(e)}};for(let t of e)(0,u.existsSync)(t)&&i(t);return await Promise.all(r),{templates:t,nb:n}}async getGitURL(){return await $.Input({title:`Git url`,validations:[{message:`Provide an http(s):// url ending with .git`,regex:`^https?:\\//\\S*\\.git$`}]})}async askTemplate(){await $.ask(`Do you want to install project templates (recommended)?`)&&await this.selectProjectToImport(!0)}async selectProjectToImport(e){if(this.projectPath.length==0){$.showErrorMessage(`No project path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import projects`});if(t){if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`projects`,n=(0,u.readdirSync)(t),r=new Map,i={};for(let a of n){let n=t+f.sep+a;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+w.Template;if((0,u.existsSync)(t))try{let a=await hf.create(t);if(a){i[n]=a;let t={label:a.name,detail:a.description??``,picked:e};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select projects to import`});if(a){for(let e of a){let t=this.getSelectItem(r,e);if(t){let e=i[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.projectPath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Projects installed`)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await Fi(`git clone `+e,{cwd:this.projectPath[0]})}else t.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadProjects()}}async selectTemplateToImport(){if(this.templatePath.length==0){$.showErrorMessage(`No template path registered`);return}let e=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import templates`});if(e)if(e.label==`Local`){let e=$.extensionPath+f.sep+`templates`+f.sep+`templates`,t=(0,u.readdirSync)(e),n=new Map,r={};if(($.templateManager?.workspaces??[]).length==0)return;for(let i of t){let t=e+f.sep+i;if((0,u.statSync)(t).isDirectory()){let e=t+f.sep+w.Template;if((0,u.existsSync)(e))try{let i=await hf.create(e);if(i){r[t]=i;let e={label:i.name,detail:i.description??``,picked:!1};n.set(e,t)}}catch{}}}let i=await $.SelectMultiple(Array.from(n.keys()),{title:`Select templates to import`});if(i){for(let e of i){let t=this.getSelectItem(n,e);if(t){let e=r[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.templatePath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Templates installed`),await this.reloadTemplates()}}else if(e.label==`Git`){let e=await this.getGitURL();e&&await Fi(`git clone `+e,{cwd:this.templatePath[0]}),await this.reloadTemplates()}else e.label==`Store`&&await this.downloadTemplateFromStore()}async selectGlobalToImport(e){if(this.globalPath.length==0){$.showErrorMessage(`No global template path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import global templates`});if(t){if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`global`,n=(0,u.readdirSync)(t),r=new Map,i={};for(let a of n){let n=t+f.sep+a;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+w.Template;if((0,u.existsSync)(t))try{let a=await hf.create(t);if(a){i[n]=a;let t={label:a.name,detail:a.description??``,picked:e};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select global templates to import`});if(a){for(let e of a){let t=this.getSelectItem(r,e);if(t){let e=i[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.globalPath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Global templates installed`)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await Fi(`git clone `+e,{cwd:this.globalPath[0]})}else t.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadGlobal()}}async selectProjectToUninstall(){let e=this.getGeneralProjects(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof hf?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select projects to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadProjects(),$.showInformationMessage(`Projects deleted`))}}async selectTemplateToUninstall(){let e=this.getGeneralTemplates(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof hf?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select templates to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadTemplates(),$.showInformationMessage(`Templates deleted`))}}async selectGlobalToUninstall(){let e=this.getGeneralGlobal(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof hf?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select global templates to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadGlobal(),$.showInformationMessage(`Global templates deleted`))}}getSelectItem(e,t){for(let n of e.keys())if(n.label==t.label)return e.get(n);return null}async query(e,t,n){let r=!0;n||=(r=!1,[]);let i=new Map,a=new Map;for(let r in t){let o=t[r],s;if(o instanceof hf){if(!await o.isAllowed(e,this.findWorkspace(e)))continue;s={label:r,detail:o.description??``},a.set(s,o)}else s={label:r},i.set(s,o);n.push(s)}n.sort((e,t)=>e.label.localeCompare(t.label));let o=await $.Select(n,{title:`What do you want to create?`});if(o){let t=this.getSelectItem(a,o);if(t)return t;let n=this.getSelectItem(i,o);if(n)return this.query(e,n);if(r)return o}return null}async downloadTemplateFromStore(e){try{let t=`^${ni.url.replace(/\//g,`\\/`)}\\/template\\/download\\/(?<name>[^/]+)\\/(?<version>\\d+\\.\\d+\\.\\d+)$`;if(!e){let n=await $.Input({title:`Store url`,validations:[{message:`The store url must be `+ni.url+`/template/download/{name}/{version}$`,regex:t}]});if(!n)return;e=n}let n=e.match(new RegExp(t));if(!n){$.showErrorMessage(`The uri provided is wrong`);return}let r=n[1];n[2];let i=(0,f.join)($.savePath,`temp`,`packageTemp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0});let a=(0,f.join)(i,`temp.zip`);if(!await this.downloadFile(a,e)){$.showErrorMessage(`Error downloading package`);return}if(!await this.extractZip(a,i)){$.showErrorMessage(`Error extracting package to analyze`);return}if((0,u.existsSync)((0,f.join)(i,w.Template))){let e=await hf.create((0,f.join)(i,w.Template));if(!e){$.showErrorMessage(`The template contains error`);return}let t=e.isGlobal?this.globalPath[0]:e.isProject?this.projectPath[0]:this.templatePath[0],n=e.installationFolder??r;n=n.replace(/\//g,f.sep).replace(/\\/,f.sep),n.startsWith(f.sep)||(n=f.sep+n);let o=t+n;if(!await this.extractZip(a,o)){$.showErrorMessage(`Error extracting package`);return}e.isGlobal?await this.reloadGlobal():e.isProject?await this.reloadProjects():await this.reloadTemplates(),$.showInformationMessage(`Template `+r+` installed`),(0,u.rmSync)(i,{force:!0,recursive:!0})}else $.showErrorMessage(w.Template+` not found`)}catch(e){$.showErrorMessage(`Error unknown`),console.error(e)}}downloadFile(e,t){return new Promise(n=>{let r=(0,u.createWriteStream)(e);try{(t.startsWith(`https`)?oe.get:b.get)(t,function(t){t.pipe(r),r.on(`finish`,()=>{r.close(),n(!0)}),r.on(`error`,()=>{r.close(),sa(e),n(!1)})})}catch{r.close(),sa(e),n(!1)}})}async extractZip(e,t){try{return await(await se.Open.file(e)).extract({path:t}),!0}catch(e){console.error(`Extract error `,e)}return!1}async readGlobal(){let e=this.getGeneralGlobal(),t=this.getGeneralGlobalLength(),n=$.getWorkspaceUri();if(n){let r=I(n)+`/.aventus/global`;return await this.readTemplates([r],e,t)}return{templates:e,nb:t}}},Af=class e{languageService;filesLoaded={};filesNeeded=[];filesNpm=[];constructor(){Ze(),this.filesNeeded=[F((0,f.join)(Be(),`lib/templateScript/AventusTemplate.d.ts`))];let e=$e((0,f.join)(Be(),`lib/templateScript/AventusTemplate.d.ts`));this.filesLoaded[this.filesNeeded[0]]={contentInternal:e,versionInternal:1},this.languageService=(0,p.createLanguageService)(this.createHost())}createHost(){let e=this;return{getCompilationSettings:()=>jf,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].versionInternal+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].contentInternal:$e(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>`es2025.full`,readFile:(e,t)=>{let n;return n=this.filesLoaded[e]?this.filesLoaded[e].contentInternal:$e(e),n},fileExists:e=>{let t=!1;return t=this.filesLoaded[e]?!0:!!$e(e),t},directoryExists:e=>(0,u.existsSync)(I(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(require("module").builtinModules.includes(r)){let e=(0,f.join)(Ye(),`@types/node/${r}.d.ts`),t={extension:p.Extension.Ts,resolvedFileName:e,isExternalLibraryImport:!0};s.push(t);continue}let t=(0,p.resolveModuleName)(r,n,jf,e);if(t.resolvedModule)s.push(t.resolvedModule);else{let e={extension:p.Extension.Ts,resolvedFileName:r};s.push(e)}}return s}addFile(e){this.filesNeeded.indexOf(e.uri)==-1&&(this.filesNeeded.push(e.uri),this.filesLoaded[e.uri]=e)}removeFile(e){let t=this.filesNeeded.indexOf(e.uri);t!=-1&&(this.filesNeeded.splice(t,1),delete this.filesLoaded[e.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,`
1042
- `)}`;r.reportsUnnecessary?n.push({range:Xi(e.documentInternal,r),severity:m.DiagnosticSeverity.Hint,source:C.TypeScript,message:i,tags:[m.DiagnosticTag.Unnecessary]}):n.push({range:Xi(e.documentInternal,r),severity:m.DiagnosticSeverity.Error,source:C.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=Xi(n,ta(n.getText(),r)),a;try{a=this.languageService.getCompletionsAtPosition(n.uri,r,Mf)}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:C.TypeScript,offset:r,uri:n.uri},u={label:t.name,sortText:t.sortText,kind:Zt(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){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+=`
1041
+ log(t.basicInfo())`,i=(0,f.join)($.savePath,`temp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i);let a=(0,f.join)(i,n+`.ts`);(0,u.writeFileSync)(a,r);let o={name:``,version:`1.0.0`,description:``,isAllow:!0};var s=``,c=``;try{let e=await Fi(`node --no-warnings ${a}`,{cwd:this.folderPath});c=e.stderr.toString(),s=e.stdout.toString();let t=JSON.parse(s.trim());o={...o,...t}}catch(e){$.error(e),$.error(c),$.error(s),this.containsError=!0}ua(a);let l=[...e.preparing[n]];e.preparing[n]=[];for(let e of l)e(o);t(o)})}},yf=class{static cmd=`aventus.template.quick_edit`;static async run(){let e=P.getInstance().settings.quickCreations,t=[],n=r=>{if(r instanceof vf)r.allowQuick&&t.push({label:r.name,detail:r.description,picked:e.includes(r.folderPath),folderPath:r.folderPath});else for(let e in r)n(r[e])};if(n((await $.templateManager?.readGlobal()??{nb:0,templates:{}}).templates),n((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),n((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates),t.length==0){P.getInstance().setSettings({quickCreations:[]},!0),$.showErrorMessage(`No template/project allow quick creation`);return}let r=await $.SelectMultiple(t,{title:`Select quick templates`});if(r){e=[];for(let n of r){let r=t.find(e=>e.label==n.label)?.folderPath;r&&e.push(r)}P.getInstance().setSettings({quickCreations:e},!0)}}},bf=class{static cmd=`aventus.template.quick`;static async run(){let e=P.getInstance().settings.quickCreations;if(e.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let t=$.templateManager?.workspaces??[],n=``;if(t.length==0)return;if(t.length==1)n=t[0];else{let e=[];for(let n of t)e.push({label:n});let r=await $.Select(e,{title:`Select workspace`});if(!r)return;n=r.label}let r=``;if(e.length==1)r=e[0];else{let t=[],n={},i={},a=e=>{if(e instanceof vf)e.allowQuick&&(i[e.folderPath]=e);else for(let t in e)a(e[t])};a((await $.templateManager?.getGeneralGlobal()??{nb:0,templates:{}}).templates),a((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),a((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates);for(let r of e)if(i[r]){let e=i[r];t.push({label:e.name,detail:e.description}),n[e.name]=r}else if(r.endsWith(w.Template)||(r=(0,f.join)(r,w.Template)),(0,u.existsSync)(r)){let e=await vf.create(r);e&&(t.push({label:e.name,detail:e.description}),n[e.name]=r)}if(t.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let o=await $.Select(t,{title:`Select quick template`});if(!o)return;r=n[o.label]}if(r.endsWith(w.Template)||(0,u.existsSync)((0,f.join)(r,w.Template))&&(r=(0,f.join)(r,w.Template)),!(0,u.existsSync)(r)){$.showErrorMessage(`The file doesn't exist : `+r);return}let i=await vf.create(r);i&&await i.init(n,n)}},xf=class{static cmd=`aventus.store.publish_template`;static async run(e){if(!e)return;if(!ni.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let t=I(e);if((0,u.existsSync)(t)&&t.endsWith(w.Template)){let e=await vf.create(t);if(e){let t=await ni.publishTemplate(e);if(t instanceof ri)for(let e of t.errors)$.showErrorMessage(e.message);else $.showInformationMessage(`Template published`)}else $.showErrorMessage(`Your script for the template contains errors`)}}},Sf=class{static cmd=`aventus.store.download_template`;static async run(e){e&&await $.templateManager?.downloadTemplateFromStore(e)}},Cf=class{static cmd=`aventus.template.uninstall_project`;static async run(){await $.templateManager?.selectProjectToUninstall()}},wf=class{static cmd=`aventus.template.uninstall`;static async run(){await $.templateManager?.selectTemplateToUninstall()}},Tf=class{static cmd=`aventus.format`;static async run(e){let t=[];t=e?[e]:R.getInstance().getUris(),$.showLoadingMessage(`Formatting `+t.length+` files`,async()=>{for(let e of t){let t=R.getInstance().getByUri(e);if(t instanceof E)try{let n=t.contentUser,r=await t.getFormatting();await t.applyTextEdits(r),n!=t.contentUser&&(0,u.writeFileSync)(I(e),t.contentUser)}catch(e){console.error(e)}}})}},Ef=class{static cmd=`aventus.ai.dependencies`;static async run(){if(!$.isIDE){let e=await R.getInstance().loadAllAventusConfigFiles([$.getWorkspaceUri()]);for(let t of e){let e=new Di(t,!1);await e.init();for(let t of e.getBuilds())await si.getInstance().loadDependenciesFromBuild(t.buildConfig,t)}}let e=si.getInstance().packages,t=(0,f.join)(I($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t);let n=(0,f.join)(t,`dependencies`);(0,u.existsSync)(n)&&(0,u.rmSync)(n,{force:!0,recursive:!0}),(0,u.mkdirSync)(n);for(let t of e){console.log(`writting : `+(0,f.join)(n,t.name)+`.md`);let e=ai.getMarkdown(t.file.uri);e&&(0,u.writeFileSync)((0,f.join)(n,t.name+`.md`),e)}}},Df=class{static cmd=`aventus.ai.rules`;static async run(){let e=(0,f.join)($.extensionPath,`lib`,`aventusjs-rules.md`),t=(0,f.join)(I($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t),(0,u.copyFileSync)(e,(0,f.join)(t,`aventusjs-rules.md`))}},Of=class{static cmd=`aventus.emmet`;static async run(){await ai.write(!0)}},kf=class{static cmd=`aventus.sharp.update_tools`;static async run(){if(!(0,Qd.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}let e={"csharp-converter":`dotnet tool update --global AventusSharp.Converter`,"db-query":`dotnet tool update --global AventusSharp.DatabaseQuery`},t=[];for(let n in e)(0,Qd.sync)(n)&&await $.showLoadingMessage(`Updating `+n,async()=>{let r=await Fi(e[n]);r.stderr?$.showErrorMessage(r.stderr):t.push(n)});t.length>0&&$.showInformationMessage(`Update done for : `+t.join(`, `))}};const Af={allCommandes:{[bd.cmd]:bd,[kd.cmd]:kd,[Md.cmd]:Md,[Ad.cmd]:Ad,[xd.cmd]:xd,[zd.cmd]:zd,[Bd.cmd]:Bd,[Ed.cmd]:Ed,[Od.cmd]:Od,[jd.cmd]:jd,[yd.cmd]:yd,[af.cmd]:af,[Pd.cmd]:Pd,[Fd.cmd]:Fd,[Id.cmd]:Id,[Ld.cmd]:Ld,[Rd.cmd]:Rd,[Sd.cmd]:Sd,[wd.cmd]:wd,[Cd.cmd]:Cd,[Vd.cmd]:Vd,[Ud.cmd]:Ud,[Gd.cmd]:Gd,[qd.cmd]:qd,[Yd.cmd]:Yd,[Xd.cmd]:Xd,[sf.cmd]:sf,[nf.cmd]:nf,[kf.cmd]:kf,[ff.cmd]:ff,[rf.cmd]:rf,[of.cmd]:of,[cf.cmd]:cf,[lf.cmd]:lf,[pf.cmd]:pf,[mf.cmd]:mf,[hf.cmd]:hf,[xf.cmd]:xf,[Sf.cmd]:Sf,[bf.cmd]:bf,[yf.cmd]:yf,[Cf.cmd]:Cf,[wf.cmd]:wf,[Tf.cmd]:Tf,[Ef.cmd]:Ef,[Df.cmd]:Df,[Of.cmd]:Of},execute:async function(e){let t=this.allCommandes[e.command];if(t){let n=e.arguments??[];await t.run.call(t,...n)}}};var jf=class{templateManager;constructor(e){this.templateManager=e}async createTemplate(e){let t=await this.readTemplates(),n=await this.templateManager.readGlobal(),r=await this.templateManager.query(e,{...n.templates,...t.templates});r&&await r.init(e,this.templateManager.findWorkspace(e))}readTemplates(){let e=this.templateManager.getGeneralTemplates(),t=this.templateManager.getGeneralTemplatesLength(),n=$.getWorkspaceUri();if(n){let r=I(n)+`/.aventus/templates`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}},Mf=class{templatePath=[];projectPath=[];globalPath=[];loadedTemplates={};loadedProjects={};loadedGlobal={};loadedProjectsLength=0;loadedTemplatesLength=0;loadedGlobalLength=0;workspaces=[];getGeneralTemplates(){return this.loadedTemplates}getGeneralTemplatesLength(){return this.loadedTemplatesLength}getGeneralProjects(){return this.loadedProjects}getGeneralProjectsLength(){return this.loadedProjectsLength}getGeneralGlobal(){return this.loadedGlobal}getGeneralGlobalLength(){return this.loadedGlobalLength}constructor(e){this.workspaces=e.map(e=>I(e).replace(/\//g,f.sep))}async init(){$.isIDE?this.loadTemplates():await this.loadTemplates(),P.getInstance().onSettingsChange(()=>{this.loadTemplates()})}async loadTemplates(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e),this.templatePath=P.getInstance().settings.templatePath;let t=(0,f.normalize)(e+f.sep+`templates`);this.prepareFolders(this.templatePath,t),this.globalPath=P.getInstance().settings.globalPath;let n=(0,f.normalize)(e+f.sep+`global`);this.prepareFolders(this.globalPath,n),this.projectPath=P.getInstance().settings.projectPath;let r=(0,f.normalize)(e+f.sep+`projects`),i=!(0,u.existsSync)(r)||(0,u.readdirSync)(r).length==0;this.prepareFolders(this.projectPath,r),i&&await this.askTemplate();let a=[];a.push(this.reloadTemplates()),a.push(this.reloadProjects()),a.push(this.reloadGlobal()),await Promise.all(a)}async reloadTemplates(){let e=await this.readTemplates(this.templatePath);this.loadedTemplates=e.templates,this.loadedTemplatesLength=e.nb}async reloadProjects(){let e=await this.readTemplates(this.projectPath);this.loadedProjects=e.templates,this.loadedProjectsLength=e.nb}async reloadGlobal(){let e=await this.readTemplates(this.globalPath);this.loadedGlobal=e.templates,this.loadedGlobalLength=e.nb}prepareFolders(e,t){e.includes(t)||e.splice(0,0,t);for(let t=0;t<e.length;t++)e[t]=(0,f.normalize)(e[t]),(0,u.existsSync)(e[t])||(0,u.mkdirSync)(e[t])}findWorkspace(e){for(let t of this.workspaces)if(e.startsWith(t))return t;return $.showErrorMessage(`Can't load the workspace`),``}async readTemplates(e,t={},n=0){let r=[],i=e=>{let a=(0,f.join)(e,w.Template);if((0,u.existsSync)(a)){try{r.push(new Promise(async e=>{let r=await vf.create(a);r&&(ra(r.name,t,r),n++),e()}))}catch(e){console.error(e),$.showErrorMessage(`Error when parsing file `+a)}return}let o=(0,u.readdirSync)(e);for(let t of o)try{let n=(0,f.join)(e,t);(0,u.statSync)(n).isDirectory()&&i(n)}catch(e){$.error(e)}};for(let t of e)(0,u.existsSync)(t)&&i(t);return await Promise.all(r),{templates:t,nb:n}}async getGitURL(){return await $.Input({title:`Git url`,validations:[{message:`Provide an http(s):// url ending with .git`,regex:`^https?:\\//\\S*\\.git$`}]})}async askTemplate(){await $.ask(`Do you want to install project templates (recommended)?`)&&await this.selectProjectToImport(!0)}async selectProjectToImport(e){if(this.projectPath.length==0){$.showErrorMessage(`No project path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import projects`});if(t){if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`projects`,n=(0,u.readdirSync)(t),r=new Map,i={};for(let a of n){let n=t+f.sep+a;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+w.Template;if((0,u.existsSync)(t))try{let a=await vf.create(t);if(a){i[n]=a;let t={label:a.name,detail:a.description??``,picked:e};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select projects to import`});if(a){for(let e of a){let t=this.getSelectItem(r,e);if(t){let e=i[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.projectPath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Projects installed`)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await Fi(`git clone `+e,{cwd:this.projectPath[0]})}else t.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadProjects()}}async selectTemplateToImport(){if(this.templatePath.length==0){$.showErrorMessage(`No template path registered`);return}let e=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import templates`});if(e)if(e.label==`Local`){let e=$.extensionPath+f.sep+`templates`+f.sep+`templates`,t=(0,u.readdirSync)(e),n=new Map,r={};if(($.templateManager?.workspaces??[]).length==0)return;for(let i of t){let t=e+f.sep+i;if((0,u.statSync)(t).isDirectory()){let e=t+f.sep+w.Template;if((0,u.existsSync)(e))try{let i=await vf.create(e);if(i){r[t]=i;let e={label:i.name,detail:i.description??``,picked:!1};n.set(e,t)}}catch{}}}let i=await $.SelectMultiple(Array.from(n.keys()),{title:`Select templates to import`});if(i){for(let e of i){let t=this.getSelectItem(n,e);if(t){let e=r[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.templatePath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Templates installed`),await this.reloadTemplates()}}else if(e.label==`Git`){let e=await this.getGitURL();e&&await Fi(`git clone `+e,{cwd:this.templatePath[0]}),await this.reloadTemplates()}else e.label==`Store`&&await this.downloadTemplateFromStore()}async selectGlobalToImport(e){if(this.globalPath.length==0){$.showErrorMessage(`No global template path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import global templates`});if(t){if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`global`,n=(0,u.readdirSync)(t),r=new Map,i={};for(let a of n){let n=t+f.sep+a;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+w.Template;if((0,u.existsSync)(t))try{let a=await vf.create(t);if(a){i[n]=a;let t={label:a.name,detail:a.description??``,picked:e};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select global templates to import`});if(a){for(let e of a){let t=this.getSelectItem(r,e);if(t){let e=i[t].installationFolder??t.split(f.sep).pop();e=e.replace(/\//g,f.sep).replace(/\\/,f.sep),e.startsWith(f.sep)||(e=f.sep+e);let n=this.globalPath[0]+e;(0,u.existsSync)(n)&&(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.cpSync)(t,n,{force:!0,recursive:!0})}}$.showInformationMessage(`Global templates installed`)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await Fi(`git clone `+e,{cwd:this.globalPath[0]})}else t.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadGlobal()}}async selectProjectToUninstall(){let e=this.getGeneralProjects(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof vf?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select projects to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadProjects(),$.showInformationMessage(`Projects deleted`))}}async selectTemplateToUninstall(){let e=this.getGeneralTemplates(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof vf?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select templates to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadTemplates(),$.showInformationMessage(`Templates deleted`))}}async selectGlobalToUninstall(){let e=this.getGeneralGlobal(),t=[],n=[],r=e=>{for(let i in e){let a=e[i];a instanceof vf?(t.push(a),n.push({label:a.name,detail:a.config})):r(a)}};r(e);let i=await $.SelectMultiple(n,{title:`Select global templates to remove`});if(i){for(let e of i)e.detail&&(0,u.rmSync)((0,f.dirname)(e.detail),{recursive:!0,force:!0});i.length>0&&(await this.reloadGlobal(),$.showInformationMessage(`Global templates deleted`))}}getSelectItem(e,t){for(let n of e.keys())if(n.label==t.label)return e.get(n);return null}async query(e,t,n){let r=!0;n||=(r=!1,[]);let i=new Map,a=new Map;for(let r in t){let o=t[r],s;if(o instanceof vf){if(!await o.isAllowed(e,this.findWorkspace(e)))continue;s={label:r,detail:o.description??``},a.set(s,o)}else s={label:r},i.set(s,o);n.push(s)}n.sort((e,t)=>e.label.localeCompare(t.label));let o=await $.Select(n,{title:`What do you want to create?`});if(o){let t=this.getSelectItem(a,o);if(t)return t;let n=this.getSelectItem(i,o);if(n)return this.query(e,n);if(r)return o}return null}async downloadTemplateFromStore(e){try{let t=`^${ni.url.replace(/\//g,`\\/`)}\\/template\\/download\\/(?<name>[^/]+)\\/(?<version>\\d+\\.\\d+\\.\\d+)$`;if(!e){let n=await $.Input({title:`Store url`,validations:[{message:`The store url must be `+ni.url+`/template/download/{name}/{version}$`,regex:t}]});if(!n)return;e=n}let n=e.match(new RegExp(t));if(!n){$.showErrorMessage(`The uri provided is wrong`);return}let r=n[1];n[2];let i=(0,f.join)($.savePath,`temp`,`packageTemp`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0});let a=(0,f.join)(i,`temp.zip`);if(!await this.downloadFile(a,e)){$.showErrorMessage(`Error downloading package`);return}if(!await this.extractZip(a,i)){$.showErrorMessage(`Error extracting package to analyze`);return}if((0,u.existsSync)((0,f.join)(i,w.Template))){let e=await vf.create((0,f.join)(i,w.Template));if(!e){$.showErrorMessage(`The template contains error`);return}let t=e.isGlobal?this.globalPath[0]:e.isProject?this.projectPath[0]:this.templatePath[0],n=e.installationFolder??r;n=n.replace(/\//g,f.sep).replace(/\\/,f.sep),n.startsWith(f.sep)||(n=f.sep+n);let o=t+n;if(!await this.extractZip(a,o)){$.showErrorMessage(`Error extracting package`);return}e.isGlobal?await this.reloadGlobal():e.isProject?await this.reloadProjects():await this.reloadTemplates(),$.showInformationMessage(`Template `+r+` installed`),(0,u.rmSync)(i,{force:!0,recursive:!0})}else $.showErrorMessage(w.Template+` not found`)}catch(e){$.showErrorMessage(`Error unknown`),console.error(e)}}downloadFile(e,t){return new Promise(n=>{let r=(0,u.createWriteStream)(e);try{(t.startsWith(`https`)?oe.get:b.get)(t,function(t){t.pipe(r),r.on(`finish`,()=>{r.close(),n(!0)}),r.on(`error`,()=>{r.close(),ua(e),n(!1)})})}catch{r.close(),ua(e),n(!1)}})}async extractZip(e,t){try{return await(await se.Open.file(e)).extract({path:t}),!0}catch(e){console.error(`Extract error `,e)}return!1}async readGlobal(){let e=this.getGeneralGlobal(),t=this.getGeneralGlobalLength(),n=$.getWorkspaceUri();if(n){let r=I(n)+`/.aventus/global`;return await this.readTemplates([r],e,t)}return{templates:e,nb:t}}},Nf=class e{languageService;filesLoaded={};filesNeeded=[];filesNpm=[];constructor(){Ze(),this.filesNeeded=[F((0,f.join)(Be(),`lib/templateScript/AventusTemplate.d.ts`))];let e=$e((0,f.join)(Be(),`lib/templateScript/AventusTemplate.d.ts`));this.filesLoaded[this.filesNeeded[0]]={contentInternal:e,versionInternal:1},this.languageService=(0,p.createLanguageService)(this.createHost())}createHost(){let e=this;return{getCompilationSettings:()=>Pf,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].versionInternal+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].contentInternal:$e(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>`es2025.full`,readFile:(e,t)=>{let n;return n=this.filesLoaded[e]?this.filesLoaded[e].contentInternal:$e(e),n},fileExists:e=>{let t=!1;return t=this.filesLoaded[e]?!0:!!$e(e),t},directoryExists:e=>(0,u.existsSync)(I(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(require("module").builtinModules.includes(r)){let e=(0,f.join)(Ye(),`@types/node/${r}.d.ts`),t={extension:p.Extension.Ts,resolvedFileName:e,isExternalLibraryImport:!0};s.push(t);continue}let t=(0,p.resolveModuleName)(r,n,Pf,e);if(t.resolvedModule)s.push(t.resolvedModule);else{let e={extension:p.Extension.Ts,resolvedFileName:r};s.push(e)}}return s}addFile(e){this.filesNeeded.indexOf(e.uri)==-1&&(this.filesNeeded.push(e.uri),this.filesLoaded[e.uri]=e)}removeFile(e){let t=this.filesNeeded.indexOf(e.uri);t!=-1&&(this.filesNeeded.splice(t,1),delete this.filesLoaded[e.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,`
1042
+ `)}`;r.reportsUnnecessary?n.push({range:Xi(e.documentInternal,r),severity:m.DiagnosticSeverity.Hint,source:C.TypeScript,message:i,tags:[m.DiagnosticTag.Unnecessary]}):n.push({range:Xi(e.documentInternal,r),severity:m.DiagnosticSeverity.Error,source:C.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=Xi(n,ta(n.getText(),r)),a;try{a=this.languageService.getCompletionsAtPosition(n.uri,r,Ff)}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:C.TypeScript,offset:r,uri:n.uri},u={label:t.name,sortText:t.sortText,kind:Zt(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){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+=`
1043
1043
  \`\`\`
1044
1044
  ***
1045
1045
  `),i+=t.join(`
1046
1046
 
1047
- `),{range:Xi(e.documentInternal,n.textSpan),contents:{kind:`markdown`,value:i}}}}catch(e){this.printCatchError(e)}return null}async findDefinition(e,t){try{let n=this.languageService.getDefinitionAtPosition(e.uri,e.documentInternal.offsetAt(t));if(n&&n.length>0){let e=n[0],t=$e(e.fileName);if(t){let n=d.TextDocument.create(e.fileName,`typescript`,1,t);return[{uri:e.fileName,range:Xi(n,e.textSpan)}]}}}catch(e){this.printCatchError(e)}return null}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||Qt(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={...Nf};r?c.semicolons=p.SemicolonPreference.Insert:c.semicolons=p.SemicolonPreference.Remove;let l=this.languageService.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:Xi(i,t.span),newText:t.newText});return s&&e.push({range:s,newText:$t(0,n)}),e}}catch(e){this.printCatchError(e)}return[]}async doCodeAction(e,t){let n=[];try{let r=e.documentInternal,i=this.languageService.getSyntacticDiagnostics(r.uri),a=this.languageService.getSemanticDiagnostics(r.uri),o=[];for(let e of i)o.push(e.code);for(let e of a)e.code!=6133&&o.push(e.code);let s=[];try{s=this.languageService.getCodeFixesAtPosition(r.uri,r.offsetAt(t.start),r.offsetAt(t.end),o,Nf,Mf)}catch{}for(let e of s){let t=[],i={changes:{[r.uri]:t}};for(let n of e.changes)for(let e of n.textChanges)t.push({newText:e.newText,range:Xi(r,e.span)});n.push({title:e.description,edit:i})}}catch(e){this.printCatchError(e)}return n}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}printCatchError(t){e.printCatchError(t)}static printCatchError(e){/^Debug Failure\. Expected \d+ <= \d+$/g.test(e.message)||console.error(e)}};const jf={types:[`node`],module:p.ModuleKind.ES2022,allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,lib:[`lib.es2025.full.d.ts`],target:p.ScriptTarget.ES2025,moduleDetection:p.ModuleDetectionKind.Force,moduleResolution:p.ModuleResolutionKind.NodeNext,experimentalDecorators:!0,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,noUnusedLocals:!0,strictNullChecks:!0,verbatimModuleSyntax:!1},Mf={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`},Nf={convertTabsToSpaces:!0,tabSize:4,indentSize:4,indentStyle:p.IndentStyle.Smart,newLineCharacter:`
1048
- `,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};var Pf=class extends De{languageService;constructor(e){super(e),this.languageService=new Af,this.languageService.addFile(e)}async onValidate(){return this.languageService.doValidation(this.file)}async onContentChange(){}async onSave(){}onCompletion(e,t){return this.languageService.doComplete(e,t)}onCompletionResolve(e,t){return this.languageService.doResolve(t)}onHover(e,t){return this.languageService.doHover(e,t)}onDefinition(e,t){return this.languageService.findDefinition(e,t)}onFormatting(e,t,n){return this.languageService.format(e,t,n)}onCodeAction(e,t){return this.languageService.doCodeAction(e,t)}onReferences(e,t){return this.languageService.onReferences(e,t)}onCodeLens(e){return this.languageService.onCodeLens(e)}async onRename(e,t,n){return this.languageService.onRename(e,t,n)}async onDelete(){}onGetBuild(){return null}},Ff=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}constructor(){R.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(e){e.documentUser.uri.endsWith(w.Template)&&(new Pf(e),e instanceof E&&await e.validate())}},If=class{};const Lf={allCommunications:{},list:[class extends If{channel(){return`aventus.i18n.getKeyFromPosition`}async run(e){if(e.uri){let t=N.getInstance().getMatchingBuildsByUri(e.uri);for(let n of t){let t=n.i18nComponentsFiles[e.uri]?.getKeyFromLocation(e.range);if(t||(t=n.tsLanguageService.i18nFiles[e.uri]?.getKeyFromLocation(e.range),t))return t}}return null}},class extends If{channel(){return`aventus.i18n.getLocales`}async run(e){if(e.uri){let t=N.getInstance().getMatchingBuildsByUri(e.uri);for(let e of t){let t=e.buildConfig.i18n?.locales,n=e.buildConfig.i18n?.fallback;if(t&&n)return{fallback:n,locales:t}}}return null}}],isInit:!1,init:function(){if(!this.isInit){for(let e of this.list){let t=new e;this.allCommunications[t.channel()]=t}this.isInit=!0}},execute:function(e,t){this.init();let n=this.allCommunications[e];if(n)return t?Array.isArray(t)?n.run.call(n,...t):n.run.call(n,t):n.run.call(n)}};var Rf=class{templateManager;constructor(e){this.templateManager=e}async createGlobal(e){let t=await this.templateManager.readGlobal(),n=await this.templateManager.query(e,t.templates,[{label:`Init`,detail:`Create a project`}]);n instanceof hf?await n.init(e,this.templateManager.findWorkspace(e)):n&&await $.localProjectManager?.createProject(e)}async createProject(e){let t=await this.readProjects(),n=await this.templateManager.query(e,t.templates);n&&await n.init(e,this.templateManager.findWorkspace(e))}readProjects(){let e=this.templateManager.getGeneralProjects(),t=this.templateManager.getGeneralProjectsLength(),n=$.getWorkspaceUri();if(n){let r=I(n)+`/.aventus/projects`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}};function zf(){let e=$.savePath,t=(0,u.readdirSync)(e);for(let n of t)try{(0,u.statSync)((0,f.join)(e,n)).isDirectory()&&(0,u.rmSync)((0,f.join)(e,n),{recursive:!0,force:!0})}catch{}}function Bf(){let e=(0,f.join)($.savePath,`packages`);(0,u.existsSync)(e)&&Vf(e)}function Vf(e){let t=(0,u.readdirSync)(e);for(let n of t)try{let t=(0,f.join)(e,n);if((0,u.lstatSync)(t).isDirectory())Vf(t);else if(n.endsWith(`.avt`)){let e=(0,u.readFileSync)(t,`utf8`);e=e.replace(/dependances/g,`dependencies`),(0,u.writeFileSync)(t,e)}}catch(e){console.error(e)}}const Hf={"1.4.0":zf,"1.4.1":Bf};var $=class e{static instance;static delayBetweenBuild(){return this.instance.connection.delayBetweenBuild()}static logLevel(){return this.instance.logLevel}static get isIDE(){return this.instance.isIDE}static sendNotification(t,...n){e.debug(`sendNotification `+t),this.instance.connection.sendNotification(t,n)}static showErrorMessage(t){e.debug(`showErrorMessage `+t),this.instance.connection.showErrorMessage(t)}static showWarningMessage(t){e.debug(`showWarningMessage `+t),this.instance.connection.showWarningMessage(t)}static showInformationMessage(t){e.debug(`showInformationMessage `+t),this.instance.connection.showInformationMessage(t)}static async showLoadingMessage(t,n){e.debug(`showLoadingMessage `+t),await this.instance.connection.showLoadingMessage(t,n)}static async ask(t){return e.debug(`ask `+t),await this.instance.connection.ask(t)}static sendDiagnostics(t,n){e.debug(`sendDiagnostics`),e.debug(t.uri);for(let n of t.diagnostics)e.debug(` `+n.message);this.instance.connection.sendDiagnostics(t,n?.buildConfig.fullname)}static Input(e){return this.instance.connection.Input(e)}static Select(e,t){return this.instance.connection.Select(e,t)}static SelectMultiple(e,t){return this.instance.connection.SelectMultiple(e,t)}static SelectFolder(e,t){return this.instance.connection.SelectFolder(e,t)}static Popup(e,...t){return this.instance.connection.Popup(e,...t)}static setSettings(e,t){return this.instance.connection.setSettings(e,t)}static get noBuild(){return this.instance._noBuild}static get savePath(){return this.instance._savePath}static get extensionPath(){return this.instance._extensionPath}static getWorkspaceUri(){return this.instance.workspaces[0]??``}static get templateManager(){return this.instance._template}static get localTemplateManager(){return this.instance._localTemplate}static get localProjectManager(){return this.instance._localProject}static refreshSettings(){return this.instance.loadSettings()}static debug(e){this.log(e,0)}static information(e){this.log(e,1)}static warning(e){this.log(e,2)}static error(e){this.writeLog(e)}static log(t,n){n>=e.logLevel()&&this.writeLog(t)}static writeLog(e){console.log(e),this.instance._logFile&&((typeof e==`object`||Array.isArray(e))&&(e=JSON.stringify(e,null,4)),(0,u.appendFileSync)((0,f.join)(this.instance._logFile),`[${new Date().toISOString()}] ${e}\n`))}connection;isLoading=!0;isDown=!1;workspaces=[];get logLevel(){return P.getInstance().settings.logLevel}isIDE=!1;_noBuild=!1;_savePath=``;_extensionPath=``;_logFile;_template;_localTemplate;_localProject;constructor(t){e.instance=this,this.connection=t,this.bindEvent()}start(){this.connection.open()}bindEvent(){this.connection.onInitialize(t=>{this.onInitialize(t),e.debug(`onInitialize`)}),this.connection.onInitialized(async()=>{e.debug(`onInitialized`),await this.onInitialized()}),this.connection.onShutdown(async()=>{e.debug(`onShutdown`),await this.onShutdown()}),this.connection.onCompletion(async(t,n)=>(e.debug(`onCompletion`),await this.onCompletion(t,n))),this.connection.onCompletionResolve(async(t,n)=>(e.debug(`onCompletionResolve`),await this.onCompletionResolve(t,n))),this.connection.onHover(async(t,n)=>(e.debug(`onHover`),await this.onHover(t,n))),this.connection.onDefinition(async(t,n)=>(e.debug(`onDefinition`),await this.onDefinition(t,n))),this.connection.onDocumentFormatting(async(t,n)=>(e.debug(`onDocumentFormatting`),await this.onDocumentFormatting(t,n))),this.connection.onCodeAction(async(t,n)=>(e.debug(`onCodeAction`),await this.onCodeAction(t,n))),this.connection.onCodeLens(async t=>(e.debug(`onCodeLens`),await this.onCodeLens(t))),this.connection.onReferences(async(t,n)=>(e.debug(`onReferences`),await this.onReferences(t,n))),this.connection.onRenameRequest(async(t,n,r)=>(e.debug(`onRenameRequest`),await this.onRenameRequest(t,n,r))),this.connection.onDocumentColor(async t=>(e.debug(`onDocumentColor`),await this.onDocumentColor(t))),this.connection.onColorPresentation(async(t,n,r)=>(e.debug(`onColorPresentation`),await this.onColorPresentation(t,n,r))),this.connection.onExecuteCommand(async t=>(e.debug(`onExecuteCommand`),await this.onExecuteCommand(t))),this.connection.onDidChangeConfiguration(async()=>(e.debug(`onDidChangeConfiguration`),await this.onDidChangeConfiguration())),this.connection.onRequest(async(t,n)=>(e.debug(`onRequest`),await Lf.execute(t,n)))}onInitialize(t){if(t.workspaceFolders)for(let e of t.workspaceFolders)this.workspaces.push(e.uri);if(!t.savePath){let e=process.env.APPDATA||(process.platform==`darwin`?process.env.HOME+`/Library/Preferences`:process.env.HOME+`/.local/share`),n=(0,f.join)(e,`Code`,`User`,`globalStorage`,`cobwebsite.aventus`);(0,u.existsSync)(n)?t.savePath=n:t.savePath=(0,f.join)(e,`aventus`)}t.extensionPath||=(0,f.dirname)(__dirname),this._noBuild=t.noBuild??!1,this.isIDE=t.isIDE,this._savePath=t.savePath,this._extensionPath=t.extensionPath,this._logFile=t.logFile,this._logFile&&(0,u.writeFileSync)(this._logFile,``),this.isIDE&&this.runUpdate(),e.debug(t)}async onInitialized(){await this.checkNodeJs()&&(await this.loadSettings(),await this.startServer())}async onShutdown(){this.isDown=!0;let e=P.getInstance().settings;e.watchFiles&&await ua.getInstance().destroy(),e.useCompilators&&(Zd.getInstance().destroy(),sf.getInstance().destroy()),N.getInstance().destroyAll(),await R.getInstance().onShutdown()}async onCompletion(e,t){return this.isAllowed(e)?await R.getInstance().onCompletion(e,t):null}async onCompletionResolve(e,t){return this.isAllowed(e)?await R.getInstance().onCompletionResolve(e,t):t}async onHover(e,t){return this.isAllowed(e)?await R.getInstance().onHover(e,t):null}async onDefinition(e,t){return this.isAllowed(e)?await R.getInstance().onDefinition(e,t):null}async onDocumentFormatting(e,t){return this.isAllowed(e)?await R.getInstance().onFormatting(e,t):null}async onCodeAction(e,t){return this.isAllowed(e)?await R.getInstance().onCodeAction(e,t):null}async onCodeLens(e){return this.isAllowed(e)?await R.getInstance().onCodeLens(e):null}async onReferences(e,t){return this.isAllowed(e)?await R.getInstance().onReferences(e,t):null}async onRenameRequest(e,t,n){return this.isAllowed(e)?await R.getInstance().onRename(e,t,n):null}async onDocumentColor(e){return e&&this.isStyleDocument(e)?md.onDocumentColor(e):null}async onColorPresentation(e,t,n){return e&&this.isStyleDocument(e)?md.onColorPresentations(e,t,n):null}async onExecuteCommand(e){await Df.execute(e)}async onDidChangeConfiguration(){this.loadSettings()}isAllowed(t){return t?e.isAllowed(t):!1}static isAllowed(e){return this.instance.isDown||this.instance.isLoading?!1:!!(e.uri.endsWith(w.Base)||e.uri.endsWith(w.Config)||e.uri.endsWith(w.Template))}isStyleDocument(e){return!!(e.uri.endsWith(w.ComponentStyle)||e.uri.endsWith(w.Component)||e.uri.endsWith(w.GlobalStyle))}async loadSettings(){let e=await this.connection.getSettings();e||={},P.getInstance().initSettings(e);let t=await this.connection.getSettingsHtml();t||={},P.getInstance().setSettingsHtml(t)}async startServer(){let t=P.getInstance().settings;t.useTemplates&&(this._template=new kf(this.workspaces),await this._template.init(),this._localTemplate=new Of(this._template),this._localProject=new Rf(this._template)),t.useCompilators&&(Zd.getInstance(),sf.getInstance()),N.getInstance(),Ff.getInstance(),t.loadFiles?t.buildOnly?t.configPath?await R.getInstance().loadConfigFile(t.configPath,t.builds,t.statics):await R.getInstance().loadConfigFileNotSet(this.workspaces,t.builds,t.statics):(await R.getInstance().loadAllAventusFiles(this.workspaces),ai.write()):la.sendDone(),this.isLoading=!1,e.debug(`start server done`)}runUpdate(){setTimeout(()=>{let t=`1.4.1`,n=P.getInstance().hiddenSettings.version;if(t==n||!/([0-9]+)\.([0-9]+)\.([0-9]+)/g.test(t)||!/([0-9]+)\.([0-9]+)\.([0-9]+)/g.test(n))return;let r=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number),i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e]||0,i=r[e]||0;if(t>i)return 1;if(t<i)return-1}return 0},i=Hf;for(let a in i)if(/([0-9]+)\.([0-9]+)\.([0-9]+)/g.test(a)&&r(a,n)==1&&r(a,t)!=1)try{e.information(`Running update for `+a+` (old version : `+n+`, current version : 1.4.1)`),i[a]()}catch(e){console.error(e)}P.getInstance().setHiddenSettings({version:t})},5e3)}async checkNodeJs(){let t=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if(n[e]>r[e])return!0;if(n[e]<r[e])return!1}return!0},{stdout:n}=await Fi(`node -v`),r=n.toString().trim(),i=r.match(/^v?(\d+)\.(\d+)\.(\d+)$/),a=r.startsWith(`v`)?r.slice(1):r;return!i||!t(a,`22.18.0`)?(e.showErrorMessage(`To use Aventus, you need at least the nodejs version : 22.18.0`),!1):!0}},Uf=class{static cmd=`aventus/closefile`;static action(e){}},Wf=class e{static cmd=`aventus/compiled`;static timeByBuild={};static removeBuild(t){delete e.timeByBuild[t]}static action(t){let n=new Date,r=n.getHours();r<10&&(r=`0`+r);let i=n.getMinutes();i<10&&(i=`0`+i);let a=n.getSeconds();a<10&&(a=`0`+a);let o=r+`:`+i+`:`+a,s=t+` compiled at `+o;e.timeByBuild[t]=s}},Gf=class{static cmd=`aventus/editFile`;static async action(e){}},Kf=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}},qf=class{static cmd=`aventus/server/stop`;static action(){}},Jf=class{static cmd=`aventus/initStep`;static doneTxt=`Aventus : Done`;static action(e){e=e.replace(`$(loading~spin)`,`◌`),e==this.doneTxt&&dp.started()}},Yf=class{static cmd=`aventus/openfile`;static action(e){}},Xf=class{static cmd=`aventus/openpreview`;static action(e){}},Zf=class{static cmd=`aventus/registerBuild`;static action(e){e.pathConfig,e.buildName}},Qf=class{static cmd=`aventus/registerData`;static action(e){}},$f=class{static cmd=`aventus/registerStatic`;static action(e){}},ep=class e{static info={loadFileTime:0,builds:{},statics:{},files:{}};static loadFileTime={cmd:`aventus/statistics/loadFileTime`,action:t=>{e.info.loadFileTime=t}};static buildTime={cmd:`aventus/statistics/buildTime`,action:(t,n)=>{let r=e.info.builds;r[t]||(r[t]={buildTime:0}),r[t].buildTime=n}};static staticTime={cmd:`aventus/statistics/staticTime`,action:(t,n)=>{let r=e.info.statics;r[t]||(r[t]={buildTime:0}),r[t].buildTime=n}};static sizeFile={cmd:`aventus/statistics/fileSize`,action:(e,t,n,r)=>{this.info.files[e]={path:e,size:t,type:n,typeName:r}}}},tp=class{static cmd=`aventus/unregisterBuild`;static action(e){e.pathConfig,e.buildName}},np=class{static cmd=`aventus/unregisterData`;static action(e){}},rp=class{static cmd=`aventus/unregisterStatic`;static action(e){}};const ip={allNotifications:{[Uf.cmd]:Uf,[Wf.cmd]:Wf,[Kf.cmd]:Kf,[qf.cmd]:qf,[Yf.cmd]:Yf,[Xf.cmd]:Xf,[Zf.cmd]:Zf,[Qf.cmd]:Qf,[$f.cmd]:$f,[tp.cmd]:tp,[np.cmd]:np,[rp.cmd]:rp,[Gf.cmd]:Gf,[Jf.cmd]:Jf,[ep.loadFileTime.cmd]:ep.loadFileTime,[ep.buildTime.cmd]:ep.buildTime,[ep.sizeFile.cmd]:ep.sizeFile,[ep.staticTime.cmd]:ep.staticTime}};function ap(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=op(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function op(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}m.DiagnosticSeverity.Error,m.DiagnosticSeverity.Warning,m.DiagnosticSeverity.Information,m.DiagnosticSeverity.Hint;var sp=class{notifications=ip;errorsByBuildByFile={};cbErrors=[];_connection;config;executeCommand;constructor(e){this._connection=new cp,this.config=e}async open(){this._connection.open()}delayBetweenBuild(){return 0}sendNotification(e,t){this.notifications.allNotifications[e]&&this.notifications.allNotifications[e].action.call(this.notifications.allNotifications[e],...t)}showErrorMessage(e){console.log(`[error] : `+e)}showWarningMessage(e){console.log(`[warning] : `+e)}showInformationMessage(e){console.log(`[info] : `+e)}async showLoadingMessage(e,t){process.stdout.write(e);let n=process.stdout.columns||80,r=e.split(`
1049
- `),i=0;for(let e of r)i+=Math.max(1,Math.ceil(e.length/n));try{await t();for(let e=0;e<i;e++)_e.default.clearLine(process.stdout,0),_e.default.cursorTo(process.stdout,0),e<i-1&&_e.default.moveCursor(process.stdout,0,-1)}catch(e){console.error(e)}}async ask(e){return(await this.Select([{label:`Yes`},{label:`No`}],{title:e}))?.label==`Yes`}subscribeErrors(e){this.cbErrors.push(e)}unsubscribeErrors(e){let t=this.cbErrors.indexOf(e);t>-1&&this.cbErrors.splice(t,1)}emitErrors(){for(let e in this.errorsByBuildByFile)for(let t of this.cbErrors)t(this.errorsByBuildByFile[e],e)}sendDiagnostics(e,t){let n=t=>{e.diagnostics&&e.diagnostics.length>0?t[e.uri]=e.diagnostics:t[e.uri]&&delete t[e.uri]};if(t&&this.config.errorByBuild){this.errorsByBuildByFile[t]||(this.errorsByBuildByFile[t]={});let e=this.errorsByBuildByFile[t];n(e)}else this.errorsByBuildByFile[``]||(this.errorsByBuildByFile[``]={}),n(this.errorsByBuildByFile[``]);this.emitErrors()}onInitialize(e){let t={extensionPath:(0,f.dirname)(__dirname),isIDE:!1,noBuild:this.config.noBuild,workspaceFolders:[{name:``,uri:ap(process.cwd())}]};this._connection.onInitialize(()=>{e(t)})}onInitialized(e){this._connection.onInitialized(()=>{e()})}onShutdown(e){this._connection.onShutdown(()=>{e()})}async getSettings(){return{watchFiles:this.config.watchFiles??!1,useCompilators:this.config.useCompilators??!1,useTemplates:this.config.useTemplates??!1,buildOnly:this.config.buildOnly??!0,loadFiles:this.config.loadFiles??!1,builds:this.config.builds,statics:this.config.statics,configPath:this.config.configPath,logLevel:this.config.logLevel,errorByBuild:this.config.errorByBuild,useStats:this.config.useStats}}async getSettingsHtml(){return{}}async setSettings(e,t){}onRequest(e){}async onCompletion(e){}async onCompletionResolve(e){}async onHover(e){}async onDefinition(e){}async onDocumentFormatting(e){}async onCodeAction(e){}async onCodeLens(e){}async onReferences(e){}async onRenameRequest(e){}async onDocumentColor(e){}async onColorPresentation(e){}onExecuteCommand(e){this.executeCommand=e}onDidChangeConfiguration(e){}async Input(e){let t;if(e.validations){let n=[];if(e.validations){let t=e=>{n.push(t=>t.match(new RegExp(e.regex))?null:e.message)};for(let n of e.validations)t(n)}t=async e=>{for(let t of n){let n=t(e);if(n!==null)return n}return!0}}if(e.password)return await dp.interaction.password(e.title,t);let n=``;return e.title&&(n+=e.title),e.placeHolder&&(n!=``&&(n+=` - `),n+=e.placeHolder),await dp.interaction.input(n,e.value,t)}async Select(e,t){let n=``;t.title&&(n+=t.title),t.placeHolder&&(n!=``&&(n+=` - `),n+=t.placeHolder);let r=[];for(let t of e){let e=t.detail?t.label+` - `+t.detail:t.label;r.push({value:t.label,name:e,checked:t.picked??!1})}let i=await dp.interaction.select(n,r);for(let t of e)if(t.label==i)return t;return null}async SelectMultiple(e,t){let n=``;t.title&&(n+=t.title),t.placeHolder&&(n!=``&&(n+=` - `),n+=t.placeHolder);let r=[];for(let t of e){let e=t.detail?t.label+` - `+t.detail:t.label;r.push({value:t.label,name:e,checked:t.picked??!1})}let i=await dp.interaction.selectMultiple(n,r);if(!i)return null;let a=[];for(let t of i)for(let n of e)n.label==t&&a.push(n);return a.length>0?a:null}async Popup(e,...t){if(t.length>0){let n=[];for(let e of t)n.push({value:e,name:e,checked:!1});return await dp.interaction.select(e,n)}else return console.log(e),null}async SelectFolder(e,t){return await dp.interaction.tree(e,`directory`,t)}},cp=class{open(){this.run(this.onInitializeCb),this.run(this.onInitializedCb)}onInitializeCb=[];onInitialize(e){this.onInitializeCb.push(e)}onInitializedCb=[];onInitialized(e){this.onInitializedCb.push(e)}stop(){this.run(this.onShutdownCb)}onShutdownCb=[];onShutdown(e){this.onShutdownCb.push(e)}run(e){for(let t of e)t()}},lp=class{watcher;stack={created:[],deleted:[],updated:[]};mutex=new up;timeout;constructor(e){this.watcher=(0,me.watch)(e+`/**/*.avt`,{ignored:/(^|[\/\\])\../,persistent:!0}),this.watcher.on(`add`,this.onCreate.bind(this)).on(`change`,this.onChange.bind(this)).on(`unlink`,this.onDelete.bind(this))}async onCreate(e){await this.mutex.waitOne();let t=e.toString();this.stack.created.includes(t)||this.stack.created.push(t);let n=this.stack.updated.indexOf(t);n!=-1&&this.stack.updated.splice(n,1);let r=this.stack.deleted.indexOf(t);r!=-1&&this.stack.deleted.splice(r,1),this.mutex.release(),this.triggerTimer()}async onChange(e){await this.mutex.waitOne();let t=e.toString();!this.stack.created.includes(t)&&!this.stack.updated.includes(t)&&this.stack.updated.push(t);let n=this.stack.deleted.indexOf(t);n!=-1&&this.stack.deleted.splice(n,1),this.mutex.release(),this.triggerTimer()}async onDelete(e){await this.mutex.waitOne();let t=e.toString();this.stack.deleted.includes(t)||this.stack.deleted.push(t);let n=this.stack.updated.indexOf(t);n!=-1&&this.stack.updated.splice(n,1);let r=this.stack.created.indexOf(t);r!=-1&&this.stack.created.splice(r,1),this.mutex.release(),this.triggerTimer()}triggerTimer(){clearTimeout(this.timeout),setTimeout(()=>{this.sendStack()},500)}async sendStack(){await this.mutex.waitOne();for(let e of this.stack.deleted)bd.run(F(e));for(let e of this.stack.created)yd.run(F(e));for(let e of this.stack.updated)xd.run(F(e));this.stack={created:[],deleted:[],updated:[]},this.mutex.release()}},up=class{waitingList=[];isLocked=!1;waitOne(){return new Promise(e=>{this.isLocked?this.waitingList.push(()=>{e()}):(this.isLocked=!0,e())})}release(){let e=this.waitingList.shift();e?e():this.isLocked=!1}dispose(){this.waitingList=[],this.isLocked=!1}},dp=class{static _interaction;static get interaction(){return this._interaction}static server=null;static cliConnection=null;static get connection(){return this.cliConnection?this.cliConnection._connection:null}static get notifications(){return this.cliConnection?.notifications}static waitingStart=null;static start(e){return new Promise(t=>{try{this.server||(this.cliConnection=new sp(e),e.watchFiles&&new lp(process.cwd()),this.server=new $(this.cliConnection),e.noStart?t():(this.waitingStart=()=>{this.waitingStart=null,t()},this.server.start()))}catch(e){console.log(e)}})}static started(){this.waitingStart&&this.waitingStart()}static async create(){await vd.run(F(process.cwd()))}static stop(){this.connection&&this.connection.stop()}static async log(){await this.interaction.log()}static subscribeErrors(e){this.cliConnection?.subscribeErrors(e)}static unsubscribeErrors(e){this.cliConnection?.unsubscribeErrors(e)}static async executeCommand(e,...t){await this.cliConnection.executeCommand({command:e,arguments:t})}static getErrors(){return this.cliConnection?.errorsByBuildByFile??{}}static getStatistics(){return ep.info}static async Input(e){return this.cliConnection.Input(e)}};exports.RealServer=dp;
1047
+ `),{range:Xi(e.documentInternal,n.textSpan),contents:{kind:`markdown`,value:i}}}}catch(e){this.printCatchError(e)}return null}async findDefinition(e,t){try{let n=this.languageService.getDefinitionAtPosition(e.uri,e.documentInternal.offsetAt(t));if(n&&n.length>0){let e=n[0],t=$e(e.fileName);if(t){let n=d.TextDocument.create(e.fileName,`typescript`,1,t);return[{uri:e.fileName,range:Xi(n,e.textSpan)}]}}}catch(e){this.printCatchError(e)}return null}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||Qt(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={...If};r?c.semicolons=p.SemicolonPreference.Insert:c.semicolons=p.SemicolonPreference.Remove;let l=this.languageService.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:Xi(i,t.span),newText:t.newText});return s&&e.push({range:s,newText:$t(0,n)}),e}}catch(e){this.printCatchError(e)}return[]}async doCodeAction(e,t){let n=[];try{let r=e.documentInternal,i=this.languageService.getSyntacticDiagnostics(r.uri),a=this.languageService.getSemanticDiagnostics(r.uri),o=[];for(let e of i)o.push(e.code);for(let e of a)e.code!=6133&&o.push(e.code);let s=[];try{s=this.languageService.getCodeFixesAtPosition(r.uri,r.offsetAt(t.start),r.offsetAt(t.end),o,If,Ff)}catch{}for(let e of s){let t=[],i={changes:{[r.uri]:t}};for(let n of e.changes)for(let e of n.textChanges)t.push({newText:e.newText,range:Xi(r,e.span)});n.push({title:e.description,edit:i})}}catch(e){this.printCatchError(e)}return n}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}printCatchError(t){e.printCatchError(t)}static printCatchError(e){/^Debug Failure\. Expected \d+ <= \d+$/g.test(e.message)||console.error(e)}};const Pf={types:[`node`],module:p.ModuleKind.ES2022,allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,lib:[`lib.es2025.full.d.ts`],target:p.ScriptTarget.ES2025,moduleDetection:p.ModuleDetectionKind.Force,moduleResolution:p.ModuleResolutionKind.NodeNext,experimentalDecorators:!0,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,noUnusedLocals:!0,strictNullChecks:!0,verbatimModuleSyntax:!1},Ff={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`},If={convertTabsToSpaces:!0,tabSize:4,indentSize:4,indentStyle:p.IndentStyle.Smart,newLineCharacter:`
1048
+ `,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};var Lf=class extends De{languageService;constructor(e){super(e),this.languageService=new Nf,this.languageService.addFile(e)}async onValidate(){return this.languageService.doValidation(this.file)}async onContentChange(){}async onSave(){}onCompletion(e,t){return this.languageService.doComplete(e,t)}onCompletionResolve(e,t){return this.languageService.doResolve(t)}onHover(e,t){return this.languageService.doHover(e,t)}onDefinition(e,t){return this.languageService.findDefinition(e,t)}onFormatting(e,t,n){return this.languageService.format(e,t,n)}onCodeAction(e,t){return this.languageService.doCodeAction(e,t)}onReferences(e,t){return this.languageService.onReferences(e,t)}onCodeLens(e){return this.languageService.onCodeLens(e)}async onRename(e,t,n){return this.languageService.onRename(e,t,n)}async onDelete(){}onGetBuild(){return null}},Rf=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}constructor(){R.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(e){e.documentUser.uri.endsWith(w.Template)&&(new Lf(e),e instanceof E&&await e.validate())}},zf=class{};const Bf={allCommunications:{},list:[class extends zf{channel(){return`aventus.i18n.getKeyFromPosition`}async run(e){if(e.uri){let t=N.getInstance().getMatchingBuildsByUri(e.uri);for(let n of t){let t=n.i18nComponentsFiles[e.uri]?.getKeyFromLocation(e.range);if(t||(t=n.tsLanguageService.i18nFiles[e.uri]?.getKeyFromLocation(e.range),t))return t}}return null}},class extends zf{channel(){return`aventus.i18n.getLocales`}async run(e){if(e.uri){let t=N.getInstance().getMatchingBuildsByUri(e.uri);for(let e of t){let t=e.buildConfig.i18n?.locales,n=e.buildConfig.i18n?.fallback;if(t&&n)return{fallback:n,locales:t}}}return null}}],isInit:!1,init:function(){if(!this.isInit){for(let e of this.list){let t=new e;this.allCommunications[t.channel()]=t}this.isInit=!0}},execute:function(e,t){this.init();let n=this.allCommunications[e];if(n)return t?Array.isArray(t)?n.run.call(n,...t):n.run.call(n,t):n.run.call(n)}};var Vf=class{templateManager;constructor(e){this.templateManager=e}async createGlobal(e){let t=await this.templateManager.readGlobal(),n=await this.templateManager.query(e,t.templates,[{label:`Init`,detail:`Create a project`}]);n instanceof vf?await n.init(e,this.templateManager.findWorkspace(e)):n&&await $.localProjectManager?.createProject(e)}async createProject(e){let t=await this.readProjects(),n=await this.templateManager.query(e,t.templates);n&&await n.init(e,this.templateManager.findWorkspace(e))}readProjects(){let e=this.templateManager.getGeneralProjects(),t=this.templateManager.getGeneralProjectsLength(),n=$.getWorkspaceUri();if(n){let r=I(n)+`/.aventus/projects`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}};function Hf(){let e=$.savePath,t=(0,u.readdirSync)(e);for(let n of t)try{(0,u.statSync)((0,f.join)(e,n)).isDirectory()&&(0,u.rmSync)((0,f.join)(e,n),{recursive:!0,force:!0})}catch{}}function Uf(){let e=(0,f.join)($.savePath,`packages`);(0,u.existsSync)(e)&&Wf(e)}function Wf(e){let t=(0,u.readdirSync)(e);for(let n of t)try{let t=(0,f.join)(e,n);if((0,u.lstatSync)(t).isDirectory())Wf(t);else if(n.endsWith(`.avt`)){let e=(0,u.readFileSync)(t,`utf8`);e=e.replace(/dependances/g,`dependencies`),(0,u.writeFileSync)(t,e)}}catch(e){console.error(e)}}const Gf={"1.4.0":Hf,"1.4.1":Uf};var $=class e{static instance;static delayBetweenBuild(){return this.instance.connection.delayBetweenBuild()}static logLevel(){return this.instance.logLevel}static get isIDE(){return this.instance.isIDE}static sendNotification(t,...n){e.debug(`sendNotification `+t),this.instance.connection.sendNotification(t,n)}static showErrorMessage(t){e.debug(`showErrorMessage `+t),this.instance.connection.showErrorMessage(t)}static showWarningMessage(t){e.debug(`showWarningMessage `+t),this.instance.connection.showWarningMessage(t)}static showInformationMessage(t){e.debug(`showInformationMessage `+t),this.instance.connection.showInformationMessage(t)}static async showLoadingMessage(t,n){e.debug(`showLoadingMessage `+t),await this.instance.connection.showLoadingMessage(t,n)}static async ask(t){return e.debug(`ask `+t),await this.instance.connection.ask(t)}static sendDiagnostics(t,n){e.debug(`sendDiagnostics`),e.debug(t.uri);for(let n of t.diagnostics)e.debug(` `+n.message);this.instance.connection.sendDiagnostics(t,n?.buildConfig.fullname)}static Input(e){return this.instance.connection.Input(e)}static Select(e,t){return this.instance.connection.Select(e,t)}static SelectMultiple(e,t){return this.instance.connection.SelectMultiple(e,t)}static SelectFolder(e,t){return this.instance.connection.SelectFolder(e,t)}static Popup(e,...t){return this.instance.connection.Popup(e,...t)}static setSettings(e,t){return this.instance.connection.setSettings(e,t)}static get noBuild(){return this.instance._noBuild}static get savePath(){return this.instance._savePath}static get extensionPath(){return this.instance._extensionPath}static getWorkspaceUri(){return this.instance.workspaces[0]??``}static get templateManager(){return this.instance._template}static get localTemplateManager(){return this.instance._localTemplate}static get localProjectManager(){return this.instance._localProject}static refreshSettings(){return this.instance.loadSettings()}static debug(e){this.log(e,0)}static information(e){this.log(e,1)}static warning(e){this.log(e,2)}static error(e){this.writeLog(e)}static log(t,n){n>=e.logLevel()&&this.writeLog(t)}static writeLog(e){console.log(e),this.instance._logFile&&((typeof e==`object`||Array.isArray(e))&&(e=JSON.stringify(e,null,4)),(0,u.appendFileSync)((0,f.join)(this.instance._logFile),`[${new Date().toISOString()}] ${e}\n`))}connection;isLoading=!0;isDown=!1;workspaces=[];get logLevel(){return P.getInstance().settings.logLevel}isIDE=!1;_noBuild=!1;_savePath=``;_extensionPath=``;_logFile;_template;_localTemplate;_localProject;constructor(t){e.instance=this,this.connection=t,this.bindEvent()}start(){this.connection.open()}bindEvent(){this.connection.onInitialize(t=>{this.onInitialize(t),e.debug(`onInitialize`)}),this.connection.onInitialized(async()=>{e.debug(`onInitialized`),await this.onInitialized()}),this.connection.onShutdown(async()=>{e.debug(`onShutdown`),await this.onShutdown()}),this.connection.onCompletion(async(t,n)=>(e.debug(`onCompletion`),await this.onCompletion(t,n))),this.connection.onCompletionResolve(async(t,n)=>(e.debug(`onCompletionResolve`),await this.onCompletionResolve(t,n))),this.connection.onHover(async(t,n)=>(e.debug(`onHover`),await this.onHover(t,n))),this.connection.onDefinition(async(t,n)=>(e.debug(`onDefinition`),await this.onDefinition(t,n))),this.connection.onDocumentFormatting(async(t,n)=>(e.debug(`onDocumentFormatting`),await this.onDocumentFormatting(t,n))),this.connection.onCodeAction(async(t,n)=>(e.debug(`onCodeAction`),await this.onCodeAction(t,n))),this.connection.onCodeLens(async t=>(e.debug(`onCodeLens`),await this.onCodeLens(t))),this.connection.onReferences(async(t,n)=>(e.debug(`onReferences`),await this.onReferences(t,n))),this.connection.onRenameRequest(async(t,n,r)=>(e.debug(`onRenameRequest`),await this.onRenameRequest(t,n,r))),this.connection.onDocumentColor(async t=>(e.debug(`onDocumentColor`),await this.onDocumentColor(t))),this.connection.onColorPresentation(async(t,n,r)=>(e.debug(`onColorPresentation`),await this.onColorPresentation(t,n,r))),this.connection.onExecuteCommand(async t=>(e.debug(`onExecuteCommand`),await this.onExecuteCommand(t))),this.connection.onDidChangeConfiguration(async()=>(e.debug(`onDidChangeConfiguration`),await this.onDidChangeConfiguration())),this.connection.onRequest(async(t,n)=>(e.debug(`onRequest`),await Bf.execute(t,n)))}onInitialize(t){if(t.workspaceFolders)for(let e of t.workspaceFolders)this.workspaces.push(e.uri);if(!t.savePath){let e=process.env.APPDATA||(process.platform==`darwin`?process.env.HOME+`/Library/Preferences`:process.env.HOME+`/.local/share`),n=(0,f.join)(e,`Code`,`User`,`globalStorage`,`cobwebsite.aventus`);(0,u.existsSync)(n)?t.savePath=n:t.savePath=(0,f.join)(e,`aventus`)}t.extensionPath||=(0,f.dirname)(__dirname),this._noBuild=t.noBuild??!1,this.isIDE=t.isIDE,this._savePath=t.savePath,this._extensionPath=t.extensionPath,this._logFile=t.logFile,this._logFile&&(0,u.writeFileSync)(this._logFile,``),this.isIDE&&this.runUpdate(),e.debug(t)}async onInitialized(){await this.checkNodeJs()&&(await this.loadSettings(),await this.startServer())}async onShutdown(){this.isDown=!0;let e=P.getInstance().settings;e.watchFiles&&await pa.getInstance().destroy(),e.useCompilators&&(ef.getInstance().destroy(),uf.getInstance().destroy()),N.getInstance().destroyAll(),await R.getInstance().onShutdown()}async onCompletion(e,t){return this.isAllowed(e)?await R.getInstance().onCompletion(e,t):null}async onCompletionResolve(e,t){return this.isAllowed(e)?await R.getInstance().onCompletionResolve(e,t):t}async onHover(e,t){return this.isAllowed(e)?await R.getInstance().onHover(e,t):null}async onDefinition(e,t){return this.isAllowed(e)?await R.getInstance().onDefinition(e,t):null}async onDocumentFormatting(e,t){return this.isAllowed(e)?await R.getInstance().onFormatting(e,t):null}async onCodeAction(e,t){return this.isAllowed(e)?await R.getInstance().onCodeAction(e,t):null}async onCodeLens(e){return this.isAllowed(e)?await R.getInstance().onCodeLens(e):null}async onReferences(e,t){return this.isAllowed(e)?await R.getInstance().onReferences(e,t):null}async onRenameRequest(e,t,n){return this.isAllowed(e)?await R.getInstance().onRename(e,t,n):null}async onDocumentColor(e){return e&&this.isStyleDocument(e)?_d.onDocumentColor(e):null}async onColorPresentation(e,t,n){return e&&this.isStyleDocument(e)?_d.onColorPresentations(e,t,n):null}async onExecuteCommand(e){await Af.execute(e)}async onDidChangeConfiguration(){this.loadSettings()}isAllowed(t){return t?e.isAllowed(t):!1}static isAllowed(e){return this.instance.isDown||this.instance.isLoading?!1:!!(e.uri.endsWith(w.Base)||e.uri.endsWith(w.Config)||e.uri.endsWith(w.Template))}isStyleDocument(e){return!!(e.uri.endsWith(w.ComponentStyle)||e.uri.endsWith(w.Component)||e.uri.endsWith(w.GlobalStyle))}async loadSettings(){let e=await this.connection.getSettings();e||={},P.getInstance().initSettings(e);let t=await this.connection.getSettingsHtml();t||={},P.getInstance().setSettingsHtml(t)}async startServer(){let t=P.getInstance().settings;t.useTemplates&&(this._template=new Mf(this.workspaces),await this._template.init(),this._localTemplate=new jf(this._template),this._localProject=new Vf(this._template)),t.useCompilators&&(ef.getInstance(),uf.getInstance()),N.getInstance(),Rf.getInstance(),t.loadFiles?t.buildOnly?t.configPath?await R.getInstance().loadConfigFile(t.configPath,t.builds,t.statics):await R.getInstance().loadConfigFileNotSet(this.workspaces,t.builds,t.statics):(await R.getInstance().loadAllAventusFiles(this.workspaces),await ai.write()):fa.sendDone(),this.isLoading=!1,e.debug(`start server done`)}runUpdate(){setTimeout(()=>{let t=`1.4.1`,n=P.getInstance().hiddenSettings.version;if(t==n||!/([0-9]+)\.([0-9]+)\.([0-9]+)/g.test(t)||!/([0-9]+)\.([0-9]+)\.([0-9]+)/g.test(n))return;let r=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number),i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e]||0,i=r[e]||0;if(t>i)return 1;if(t<i)return-1}return 0},i=Gf;for(let a in i)if(/([0-9]+)\.([0-9]+)\.([0-9]+)/g.test(a)&&r(a,n)==1&&r(a,t)!=1)try{e.information(`Running update for `+a+` (old version : `+n+`, current version : 1.4.1)`),i[a]()}catch(e){console.error(e)}P.getInstance().setHiddenSettings({version:t})},5e3)}async checkNodeJs(){let t=(e,t)=>{let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if(n[e]>r[e])return!0;if(n[e]<r[e])return!1}return!0},{stdout:n}=await Fi(`node -v`),r=n.toString().trim(),i=r.match(/^v?(\d+)\.(\d+)\.(\d+)$/),a=r.startsWith(`v`)?r.slice(1):r;return!i||!t(a,`22.18.0`)?(e.showErrorMessage(`To use Aventus, you need at least the nodejs version : 22.18.0`),!1):!0}},Kf=class{static cmd=`aventus/closefile`;static action(e){}},qf=class e{static cmd=`aventus/compiled`;static timeByBuild={};static removeBuild(t){delete e.timeByBuild[t]}static action(t){let n=new Date,r=n.getHours();r<10&&(r=`0`+r);let i=n.getMinutes();i<10&&(i=`0`+i);let a=n.getSeconds();a<10&&(a=`0`+a);let o=r+`:`+i+`:`+a,s=t+` compiled at `+o;e.timeByBuild[t]=s}},Jf=class{static cmd=`aventus/editFile`;static async action(e){}},Yf=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}},Xf=class{static cmd=`aventus/server/stop`;static action(){}},Zf=class{static cmd=`aventus/initStep`;static doneTxt=`Aventus : Done`;static action(e){e=e.replace(`$(loading~spin)`,`◌`),e==this.doneTxt&&mp.started()}},Qf=class{static cmd=`aventus/openfile`;static action(e){}},$f=class{static cmd=`aventus/openpreview`;static action(e){}},ep=class{static cmd=`aventus/registerBuild`;static action(e){e.pathConfig,e.buildName}},tp=class{static cmd=`aventus/registerData`;static action(e){}},np=class{static cmd=`aventus/registerStatic`;static action(e){}},rp=class e{static info={loadFileTime:0,builds:{},statics:{},files:{}};static loadFileTime={cmd:`aventus/statistics/loadFileTime`,action:t=>{e.info.loadFileTime=t}};static buildTime={cmd:`aventus/statistics/buildTime`,action:(t,n)=>{let r=e.info.builds;r[t]||(r[t]={buildTime:0}),r[t].buildTime=n}};static staticTime={cmd:`aventus/statistics/staticTime`,action:(t,n)=>{let r=e.info.statics;r[t]||(r[t]={buildTime:0}),r[t].buildTime=n}};static sizeFile={cmd:`aventus/statistics/fileSize`,action:(e,t,n,r)=>{this.info.files[e]={path:e,size:t,type:n,typeName:r}}}},ip=class{static cmd=`aventus/unregisterBuild`;static action(e){e.pathConfig,e.buildName}},ap=class{static cmd=`aventus/unregisterData`;static action(e){}},op=class{static cmd=`aventus/unregisterStatic`;static action(e){}};const sp={allNotifications:{[Kf.cmd]:Kf,[qf.cmd]:qf,[Yf.cmd]:Yf,[Xf.cmd]:Xf,[Qf.cmd]:Qf,[$f.cmd]:$f,[ep.cmd]:ep,[tp.cmd]:tp,[np.cmd]:np,[ip.cmd]:ip,[ap.cmd]:ap,[op.cmd]:op,[Jf.cmd]:Jf,[Zf.cmd]:Zf,[rp.loadFileTime.cmd]:rp.loadFileTime,[rp.buildTime.cmd]:rp.buildTime,[rp.sizeFile.cmd]:rp.sizeFile,[rp.staticTime.cmd]:rp.staticTime}};function cp(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=lp(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function lp(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}m.DiagnosticSeverity.Error,m.DiagnosticSeverity.Warning,m.DiagnosticSeverity.Information,m.DiagnosticSeverity.Hint;var up=class{notifications=sp;errorsByBuildByFile={};cbErrors=[];_connection;config;executeCommand;constructor(e){this._connection=new dp,this.config=e}async open(){this._connection.open()}delayBetweenBuild(){return 0}sendNotification(e,t){this.notifications.allNotifications[e]&&this.notifications.allNotifications[e].action.call(this.notifications.allNotifications[e],...t)}showErrorMessage(e){console.log(`[error] : `+e)}showWarningMessage(e){console.log(`[warning] : `+e)}showInformationMessage(e){console.log(`[info] : `+e)}async showLoadingMessage(e,t){process.stdout.write(e);let n=process.stdout.columns||80,r=e.split(`
1049
+ `),i=0;for(let e of r)i+=Math.max(1,Math.ceil(e.length/n));try{await t();for(let e=0;e<i;e++)_e.default.clearLine(process.stdout,0),_e.default.cursorTo(process.stdout,0),e<i-1&&_e.default.moveCursor(process.stdout,0,-1)}catch(e){console.error(e)}}async ask(e){return(await this.Select([{label:`Yes`},{label:`No`}],{title:e}))?.label==`Yes`}subscribeErrors(e){this.cbErrors.push(e)}unsubscribeErrors(e){let t=this.cbErrors.indexOf(e);t>-1&&this.cbErrors.splice(t,1)}emitErrors(){for(let e in this.errorsByBuildByFile)for(let t of this.cbErrors)t(this.errorsByBuildByFile[e],e)}sendDiagnostics(e,t){let n=t=>{e.diagnostics&&e.diagnostics.length>0?t[e.uri]=e.diagnostics:t[e.uri]&&delete t[e.uri]};if(t&&this.config.errorByBuild){this.errorsByBuildByFile[t]||(this.errorsByBuildByFile[t]={});let e=this.errorsByBuildByFile[t];n(e)}else this.errorsByBuildByFile[``]||(this.errorsByBuildByFile[``]={}),n(this.errorsByBuildByFile[``]);this.emitErrors()}onInitialize(e){let t={extensionPath:(0,f.dirname)(__dirname),isIDE:!1,noBuild:this.config.noBuild,workspaceFolders:[{name:``,uri:cp(process.cwd())}]};this._connection.onInitialize(()=>{e(t)})}onInitialized(e){this._connection.onInitialized(()=>{e()})}onShutdown(e){this._connection.onShutdown(()=>{e()})}async getSettings(){return{watchFiles:this.config.watchFiles??!1,useCompilators:this.config.useCompilators??!1,useTemplates:this.config.useTemplates??!1,buildOnly:this.config.buildOnly??!0,loadFiles:this.config.loadFiles??!1,builds:this.config.builds,statics:this.config.statics,configPath:this.config.configPath,logLevel:this.config.logLevel,errorByBuild:this.config.errorByBuild,useStats:this.config.useStats}}async getSettingsHtml(){return{}}async setSettings(e,t){}onRequest(e){}async onCompletion(e){}async onCompletionResolve(e){}async onHover(e){}async onDefinition(e){}async onDocumentFormatting(e){}async onCodeAction(e){}async onCodeLens(e){}async onReferences(e){}async onRenameRequest(e){}async onDocumentColor(e){}async onColorPresentation(e){}onExecuteCommand(e){this.executeCommand=e}onDidChangeConfiguration(e){}async Input(e){let t;if(e.validations){let n=[];if(e.validations){let t=e=>{n.push(t=>t.match(new RegExp(e.regex))?null:e.message)};for(let n of e.validations)t(n)}t=async e=>{for(let t of n){let n=t(e);if(n!==null)return n}return!0}}if(e.password)return await mp.interaction.password(e.title,t);let n=``;return e.title&&(n+=e.title),e.placeHolder&&(n!=``&&(n+=` - `),n+=e.placeHolder),await mp.interaction.input(n,e.value,t)}async Select(e,t){let n=``;t.title&&(n+=t.title),t.placeHolder&&(n!=``&&(n+=` - `),n+=t.placeHolder);let r=[];for(let t of e){let e=t.detail?t.label+` - `+t.detail:t.label;r.push({value:t.label,name:e,checked:t.picked??!1})}let i=await mp.interaction.select(n,r);for(let t of e)if(t.label==i)return t;return null}async SelectMultiple(e,t){let n=``;t.title&&(n+=t.title),t.placeHolder&&(n!=``&&(n+=` - `),n+=t.placeHolder);let r=[];for(let t of e){let e=t.detail?t.label+` - `+t.detail:t.label;r.push({value:t.label,name:e,checked:t.picked??!1})}let i=await mp.interaction.selectMultiple(n,r);if(!i)return null;let a=[];for(let t of i)for(let n of e)n.label==t&&a.push(n);return a.length>0?a:null}async Popup(e,...t){if(t.length>0){let n=[];for(let e of t)n.push({value:e,name:e,checked:!1});return await mp.interaction.select(e,n)}else return console.log(e),null}async SelectFolder(e,t){return await mp.interaction.tree(e,`directory`,t)}},dp=class{open(){this.run(this.onInitializeCb),this.run(this.onInitializedCb)}onInitializeCb=[];onInitialize(e){this.onInitializeCb.push(e)}onInitializedCb=[];onInitialized(e){this.onInitializedCb.push(e)}stop(){this.run(this.onShutdownCb)}onShutdownCb=[];onShutdown(e){this.onShutdownCb.push(e)}run(e){for(let t of e)t()}},fp=class{watcher;stack={created:[],deleted:[],updated:[]};mutex=new pp;timeout;constructor(e){this.watcher=(0,me.watch)(e+`/**/*.avt`,{ignored:/(^|[\/\\])\../,persistent:!0}),this.watcher.on(`add`,this.onCreate.bind(this)).on(`change`,this.onChange.bind(this)).on(`unlink`,this.onDelete.bind(this))}async onCreate(e){await this.mutex.waitOne();let t=e.toString();this.stack.created.includes(t)||this.stack.created.push(t);let n=this.stack.updated.indexOf(t);n!=-1&&this.stack.updated.splice(n,1);let r=this.stack.deleted.indexOf(t);r!=-1&&this.stack.deleted.splice(r,1),this.mutex.release(),this.triggerTimer()}async onChange(e){await this.mutex.waitOne();let t=e.toString();!this.stack.created.includes(t)&&!this.stack.updated.includes(t)&&this.stack.updated.push(t);let n=this.stack.deleted.indexOf(t);n!=-1&&this.stack.deleted.splice(n,1),this.mutex.release(),this.triggerTimer()}async onDelete(e){await this.mutex.waitOne();let t=e.toString();this.stack.deleted.includes(t)||this.stack.deleted.push(t);let n=this.stack.updated.indexOf(t);n!=-1&&this.stack.updated.splice(n,1);let r=this.stack.created.indexOf(t);r!=-1&&this.stack.created.splice(r,1),this.mutex.release(),this.triggerTimer()}triggerTimer(){clearTimeout(this.timeout),setTimeout(()=>{this.sendStack()},500)}async sendStack(){await this.mutex.waitOne();for(let e of this.stack.deleted)Cd.run(F(e));for(let e of this.stack.created)Sd.run(F(e));for(let e of this.stack.updated)wd.run(F(e));this.stack={created:[],deleted:[],updated:[]},this.mutex.release()}},pp=class{waitingList=[];isLocked=!1;waitOne(){return new Promise(e=>{this.isLocked?this.waitingList.push(()=>{e()}):(this.isLocked=!0,e())})}release(){let e=this.waitingList.shift();e?e():this.isLocked=!1}dispose(){this.waitingList=[],this.isLocked=!1}},mp=class{static _interaction;static get interaction(){return this._interaction}static server=null;static cliConnection=null;static get connection(){return this.cliConnection?this.cliConnection._connection:null}static get notifications(){return this.cliConnection?.notifications}static waitingStart=null;static start(e){return new Promise(t=>{try{this.server||(this.cliConnection=new up(e),e.watchFiles&&new fp(process.cwd()),this.server=new $(this.cliConnection),e.noStart?t():(this.waitingStart=()=>{this.waitingStart=null,t()},this.server.start()))}catch(e){console.log(e)}})}static started(){this.waitingStart&&this.waitingStart()}static async create(){await xd.run(F(process.cwd()))}static stop(){this.connection&&this.connection.stop()}static async log(){await this.interaction.log()}static subscribeErrors(e){this.cliConnection?.subscribeErrors(e)}static unsubscribeErrors(e){this.cliConnection?.unsubscribeErrors(e)}static async executeCommand(e,...t){await this.cliConnection.executeCommand({command:e,arguments:t})}static getErrors(){return this.cliConnection?.errorsByBuildByFile??{}}static getStatistics(){return rp.info}static async Input(e){return this.cliConnection.Input(e)}};exports.RealServer=mp;