@aventusjs/cli 0.0.29 → 0.0.31
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/lib/Aventus@Main.package.avt +2 -1
- package/lib/Aventus@Sharp.package.avt +295 -282
- package/out/RealServer.js +130 -128
- package/out/cli.js +1 -1
- package/package.json +1 -1
package/out/RealServer.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let u=require("fs"),d=require("vscode-languageserver-textdocument"),f=require("path"),p=require("typescript"),m=require("vscode-languageserver"),h=require("util"),g=require("child_process"),_=require("crypto"),v=require("chokidar"),y=require("vscode-json-languageservice"),b=require("process"),x=require("connect");x=l(x);let ee=require("send");ee=l(ee);let te=require("url");te=l(te);let ne=require("http"),re=require("net"),ie=require("serve-index");ie=l(ie);let ae=require("ws"),oe=require("open");oe=l(oe);let S=require("vscode-html-languageservice"),se=require("postcss");se=l(se);let ce=require("vscode-css-languageservice"),le=require("sass"),ue=require("https"),de=require("unzipper"),fe=require("os"),pe=require("archiver"),me=require("terser"),he=require("esbuild"),ge=require("sudo-prompt");const C={Base:`Aventus`,TypeScript:`Aventus Ts`,HTML:`Aventus HTML`,SCSS:`Aventus SCSS`,WebComponent:`Aventus WebComponent`,Package:`Aventus Ts`,I18n:`Aventus I18n`},w={Base:`.avt`,Config:`aventus.conf.avt`,CsharpConfig:`aventus.sharp.avt`,PhpConfig:`aventus.php.avt`,ComponentLogic:`.wcl.avt`,ComponentView:`.wcv.avt`,ComponentStyle:`.wcs.avt`,Component:`.wc.avt`,GlobalStyle:`.gs.avt`,Data:`.data.avt`,Lib:`.lib.avt`,RAM:`.ram.avt`,State:`.state.avt`,Static:`.static.avt`,Definition:`.def.avt`,DefinitionNpm:`.defnpm.avt`,Template:`template.avt.ts`,ConfigTemplate:`!aventus.conf.avt`,Package:`.package.avt`,I18n:`.i18n.avt`},
|
|
2
|
-
`),code:r};return i&&(c.data=i),c}return
|
|
3
|
-
`),code:i};return a&&(o.data=a),o}function
|
|
4
|
-
`)}}function
|
|
5
|
-
`)}}function
|
|
6
|
-
`)}}function
|
|
7
|
-
`)}}function
|
|
8
|
-
`);let i=Ye(t),a=(0,f.dirname)(e);(0,u.existsSync)(a)||(0,u.mkdirSync)(a,{recursive:!0});let o=(0,u.existsSync)(e);(!qe[e]||qe[e]!=i||!o)&&(qe[e]=i,Ce.sendFileSize(e,t,n,r),(0,u.writeFileSync)(e,t))}function Ye(e){return(0,_.createHash)(`md5`).update(e).digest(`hex`)}var Xe=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]}};const Ze=new Uint8Array(16);function Qe(){return crypto.getRandomValues(Ze)}const $e=[];for(let e=0;e<256;++e)$e.push((e+256).toString(16).slice(1));function et(e,t=0){return($e[e[t+0]]+$e[e[t+1]]+$e[e[t+2]]+$e[e[t+3]]+`-`+$e[e[t+4]]+$e[e[t+5]]+`-`+$e[e[t+6]]+$e[e[t+7]]+`-`+$e[e[t+8]]+$e[e[t+9]]+`-`+$e[e[t+10]]+$e[e[t+11]]+$e[e[t+12]]+$e[e[t+13]]+$e[e[t+14]]+$e[e[t+15]]).toLowerCase()}function k(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():tt(e,t,n)}function tt(e,t,n){e||={};let r=e.random??e.rng?.()??Qe();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return et(r)}var A=class{_documentUser;_documentInternal;get documentUser(){return this._documentUser}get documentInternal(){return this._documentInternal}linkInternalAndUser=!0;setDocumentInternal(e){this._documentInternal=e,this._versionInternal=e.version}constructor(e){this._documentUser=e,this._documentInternal=e,this._versionUser=e.version,this._versionInternal=e.version}get uri(){return this.documentUser.uri}get path(){return D(this.uri)}get name(){return this.path.split(`/`).pop()??``}_versionUser=0;get versionUser(){return this._versionUser}_versionInternal=0;get versionInternal(){return this._versionInternal}get contentUser(){return this.documentUser.getText()}get contentInternal(){return this.documentInternal.getText()}get folderUri(){return Re(this.uri)}get folderPath(){return Re(this.path)}_shortname=``;get shortname(){if(!this._shortname){let e=this.uri.split(`/`);this._shortname=e[e.length-1]}return this._shortname}onGetBuildCb={};getBuild(){let e=[],t=!1;for(let n in this.onGetBuildCb){let r=this.onGetBuildCb[n]();if(r===null)t=!0;else for(let t of r)e.indexOf(t)==-1&&e.push(t)}return e.length==0&&t?null:e}onGetBuild(e){let t=k();for(;this.onGetBuildCb[t]!=null;)t=k();return this.onGetBuildCb[t]=e,t}removeOnGetBuild(e){delete this.onGetBuildCb[e]}onValidateCb={};async validate(e=!0){let t={};for(let e in this.onValidateCb){let n=await this.onValidateCb[e](this);for(let e of n){let n=e.message+`**`+e.range.start.line+`:`+e.range.start.character+`,`+e.range.end.line+`:`+e.range.end.character;t[n]||(t[n]=e)}}if(e)if(T.getInstance().settings.errorByBuild){let e=this.getBuild();if(e==null)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)});else for(let n of e)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)},n)}else $.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)});return Object.values(t)}onValidate(e){let t=k();for(;this.onValidateCb[t]!=null;)t=k();return this.onValidateCb[t]=e,t}removeOnValidate(e){delete this.onValidateCb[e]}onContentChangeCb={};delayValidate;waitingDocContentChange={};resolveContentChange={};triggerContentChange(e){return new Promise(t=>{if(!this.triggerCanContentChange(e)){t();return}setTimeout(()=>{this.waitingDocContentChange[e.uri]?(this.resolveContentChange[e.uri]||(this.resolveContentChange[e.uri]={}),this.resolveContentChange[e.uri][e.version]||(this.resolveContentChange[e.uri][e.version]=[]),this.resolveContentChange[e.uri][e.version].push(t),this.waitingDocContentChange[e.uri]=e):(this.waitingDocContentChange[e.uri]=!0,this.resolveContentChange[e.uri]={[e.version]:[t]},this.triggerContentChangeNoBuffer(e))},0)})}async triggerContentChangeNoBuffer(e){let t=e.version;this._documentUser=e,this._versionUser=e.version,this.linkInternalAndUser&&(this._documentInternal=e,this._versionInternal=e.version);let n=[];for(let e in this.onContentChangeCb)n.push(this.onContentChangeCb[e](this));if(await Promise.all(n),this.delayValidate&&clearTimeout(this.delayValidate),this.delayValidate=setTimeout(async()=>{this.validate()},500),this.resolveContentChange[e.uri]){let n=Object.keys(this.resolveContentChange[e.uri]);for(let r of n){if(Number(r)>t)break;if(this.resolveContentChange[e.uri][r]){for(let t of this.resolveContentChange[e.uri][r])t();delete this.resolveContentChange[e.uri][r]}}Object.keys(this.resolveContentChange[e.uri]).length==0&&delete this.resolveContentChange[e.uri]}let r=this.waitingDocContentChange[e.uri];r&&typeof r!=`boolean`?(this.waitingDocContentChange[e.uri]=!0,this.triggerContentChangeNoBuffer(r)):delete this.waitingDocContentChange[e.uri]}onContentChange(e){let t=k();for(;this.onContentChangeCb[t]!=null;)t=k();return this.onContentChangeCb[t]=e,t}removeOnContentChange(e){delete this.onContentChangeCb[e]}onCanContentChangeCb={};triggerCanContentChange(e){for(let t in this.onCanContentChangeCb)if(!this.onCanContentChangeCb[t](e))return!1;return!0}onCanContentChange(e){let t=k();for(;this.onCanContentChangeCb[t]!=null;)t=k();return this.onCanContentChangeCb[t]=e,t}removeOnCanContentChange(e){delete this.onCanContentChangeCb[e]}async applyTextEdits(e){let t=this.contentUser;e.sort((e,t)=>this.documentUser.offsetAt(t.range.end)-this.documentUser.offsetAt(e.range.end));for(let n of e){let e=this.documentUser.offsetAt(n.range.start),r=this.documentUser.offsetAt(n.range.end);t=t.slice(0,e)+n.newText+t.slice(r,t.length)}let n=d.TextDocument.create(this.uri,C.TypeScript,this.documentUser.version+1,t);await this.triggerContentChange(n)}onSaveCb={};async triggerSave(){for(let e in this.onSaveCb)await this.onSaveCb[e](this)}onSave(e){let t=k();for(;this.onSaveCb[t]!=null;)t=k();return this.onSaveCb[t]=e,t}removeOnSave(e){delete this.onSaveCb[e]}onDeleteCb={};async triggerDelete(){let e=[];for(let t in this.onDeleteCb)e.push(this.onDeleteCb[t](this));await Promise.all(e),this.removeAllCallbacks()}removeAllCallbacks(){this.onCodeActionCb={},this.onCompletionCb={},this.onCompletionResolveCb={},this.onContentChangeCb={},this.onDefinitionCb={},this.onDeleteCb={},this.onFormattingCb={},this.onHoverCb={},this.onSaveCb={}}onDelete(e){let t=k();for(;this.onDeleteCb[t]!=null;)t=k();return this.onDeleteCb[t]=e,t}removeOnDelete(e){delete this.onDeleteCb[e]}onCompletionCb={};async getCompletion(e){let t={isIncomplete:!1,items:[]},n=[];for(let t in this.onCompletionCb)n.push(this.onCompletionCb[t](this,e));let r=await Promise.all(n),i={};for(let e of r)for(let t of e.items){let e=JSON.stringify(t);i[e]||(i[e]=t)}return t.items=Object.values(i),t}onCompletion(e){let t=k();for(;this.onCompletionCb[t]!=null;)t=k();return this.onCompletionCb[t]=e,t}removeOnCompletion(e){delete this.onCompletionCb[e]}onCompletionResolveCb={};async getCompletionResolve(e){let t=e,n=[];for(let t in this.onCompletionResolveCb)n.push(this.onCompletionResolveCb[t](this,e));return t}onCompletionResolve(e){let t=k();for(;this.onCompletionResolveCb[t]!=null;)t=k();return this.onCompletionResolveCb[t]=e,t}removeOnCompletionResolve(e){delete this.onCompletionResolveCb[e]}onHoverCb={};async getHover(e){let t=[];for(let n in this.onHoverCb)t.push(this.onHoverCb[n](this,e));let n=await Promise.all(t);for(let e of n)if(e)return e;return null}onHover(e){let t=k();for(;this.onHoverCb[t]!=null;)t=k();return this.onHoverCb[t]=e,t}removeOnHover(e){delete this.onHoverCb[e]}onDefinitionCb={};async getDefinition(e){let t=[];for(let n in this.onDefinitionCb)t.push(this.onDefinitionCb[n](this,e));let n=await Promise.all(t);for(let e of n)if(e)return e;return null}onDefinition(e){let t=k();for(;this.onDefinitionCb[t]!=null;)t=k();return this.onDefinitionCb[t]=e,t}removeOnDefinition(e){delete this.onDefinitionCb[e]}onFormattingCb={};async getFormatting(e){e||={insertSpaces:!0,tabSize:4};let t={},n=[],r={start:this.documentUser.positionAt(0),end:this.documentUser.positionAt(this.documentUser.getText().length)};for(let t in this.onFormattingCb)n.push(this.onFormattingCb[t](this,r,e));let i=await Promise.all(n);for(let e of i)for(let n of e){let e=JSON.stringify(n);t[e]||(t[e]=n)}return Object.values(t)}onFormatting(e){let t=k();for(;this.onFormattingCb[t]!=null;)t=k();return this.onFormattingCb[t]=e,t}removeOnFormatting(e){delete this.onFormattingCb[e]}onCodeActionCb={};async getCodeAction(e){let t=[],n=[];for(let t in this.onCodeActionCb)n.push(this.onCodeActionCb[t](this,e));let r=await Promise.all(n);for(let e of r)t=[...t,...e];return t}onCodeAction(e){let t=k();for(;this.onCodeActionCb[t]!=null;)t=k();return this.onCodeActionCb[t]=e,t}removeOnCodeAction(e){delete this.onCodeActionCb[e]}onReferencesCb={};async getReferences(e){let t=[],n=[];for(let t in this.onReferencesCb)n.push(this.onReferencesCb[t](this,e));let r=await Promise.all(n);for(let e of r)t=[...t,...e];return t}onReferences(e){let t=k();for(;this.onReferencesCb[t]!=null;)t=k();return this.onReferencesCb[t]=e,t}removeOnReferences(e){delete this.onReferencesCb[e]}onCodeLensCb={};async getCodeLens(){let e=[],t=[];for(let e in this.onCodeLensCb)t.push(this.onCodeLensCb[e](this));let n=await Promise.all(t);for(let t of n)e=[...e,...t];return e}onCodeLens(e){let t=k();for(;this.onCodeLensCb[t]!=null;)t=k();return this.onCodeLensCb[t]=e,t}removeOnCodeLens(e){delete this.onCodeLensCb[e]}onRenameCb={};async getRename(e,t){let n=[];for(let r in this.onRenameCb)n.push(this.onRenameCb[r](this,e,t));let r=await Promise.all(n);for(let e of r)if(e)return e;return null}onRename(e){let t=k();for(;this.onRenameCb[t]!=null;)t=k();return this.onRenameCb[t]=e,t}removeOnRename(e){delete this.onRenameCb[e]}},nt=class e{static isInit=!1;static send(e){$.sendNotification(`aventus/initStep`,e)}static sendDone(){$.sendNotification(`aventus/initStep`,`Aventus : Done`),e.isInit=!0}},rt=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}watcher;constructor(){T.getInstance().settings.watchFiles&&(this.watcher=(0,v.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=D(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=E(e);this.watcheUris.includes(t)&&R.getInstance().onUpdatedUri(t)}async onRemove(e){let t=E(e);this.watcheUris.includes(t)&&R.getInstance().onDeletedUri(t)}async destroy(){await this.watcher?.close(),e.instance=void 0}};const it={$schema:`foo://aventus/conf.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{module:{type:`string`,pattern:`^[a-zA-Z0-9_]+$`,description:`Name of the exported module`},version:{type:`string`,pattern:`^[0-9]+.[0-9]+.[0-9]+$`,description:`Version for all your builds (x.x.x)`},description:{type:`string`,description:`Description of the package`},documentation:{type:`string`,description:`Documentation link for the package`},repository:{type:`string`,description:`Repository link for the package`},tags:{type:`array`,description:`Tags for the package`,items:{type:`string`}},organization:{type:`string`,description:`Name of the organization`,pattern:`^[a-zA-Z0-9_@]+$`},readme:{type:`string`,description:`Path to the readme. By default, Aventus check Readme in the same folder as the configuration`},hideWarnings:{type:`boolean`,description:`Hide warnings for all your builds`},componentPrefix:{type:`string`,description:`Identifier to prefix all your components (in lower case)`,pattern:`^[a-z-]{2,}$`},dependencies:{$ref:`#/$defs/dependencies`},namespaceStrategy:{type:`string`,enum:[`manual`,`followFolders`,`followFoldersCamelCase`,`rules`],description:`Stragety to generate namespace`,default:`manual`},namespaceRules:{type:`object`,description:`Rules to define namespace when namespaceStrategy is rules`},namespaceRoot:{type:`string`,description:`Root directory to define namespace when namespaceStrategy is followFolders`},build:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{name:{type:`string`,description:"Part name for the module. The export file will be ${module}@${name}",pattern:`^[a-zA-Z0-9_]+$`},description:{type:`string`,description:`Description of the package`},tags:{type:`array`,description:`Tags for the package`,items:{type:`string`}},documentation:{type:`string`,description:`Documentation link for the package`},repository:{type:`string`,description:`Repository link for the package`},organization:{type:`string`,description:`Name of the organization`,pattern:`^[a-zA-Z0-9_@]+$`},readme:{type:`string`,description:`Path to the readme. By default, Aventus check Readme in the same folder as the configuration`},version:{type:`string`,pattern:`^[0-9]+.[0-9]+.[0-9]+$`,description:`Version for this build (x.x.x)`},disabled:{type:`boolean`,description:`Disable auto-build`,default:!0},hideWarnings:{type:`boolean`,description:`Hide warnings for this build`},componentPrefix:{type:`string`,description:`Identifier to prefix all your components (in lower case)`,pattern:`^[a-z-]{2,}$`},src:{type:`array`,items:{type:`string`},description:`List of all pathes to listen watch`},stories:{type:`object`,additionalProperties:!1,properties:{output:{type:`string`,description:`Define where to export your stories`},workspace:{type:`string`,description:`Define where to add the .storybook`},live:{type:`boolean`,description:`Define if the story content must be recompiled on change`},format:{type:`string`,enum:[`all`,`public`,`protected`,`manual`],default:`all`,description:`All will export all elements, public only public elements, protected only public and protected elements, manual only elements with tag Storybook`},prefix:{type:`string`,description:`Define a prefix for all your stories name. Allow to group stories`},srcBaseUrl:{type:`string`,description:`Define a base url to link file to your repo`}}},outsideModule:{type:`array`,items:{type:`string`},description:`List of all pathes to import outside the module`},compile:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{input:{type:[`string`,`array`],items:{type:`string`},description:`List of all pathes to import inside this build`},output:{type:[`string`,`array`,`object`],description:`The script file generated path`,pattern:`^\\S+\\.js`,items:{type:[`string`,`object`],pattern:`^\\S+\\.js`,properties:{"@default":{$ref:`#/$defs/compileOutput`},"@npm":{$ref:`#/$defs/compileOutput`}},patternProperties:{"^\\S+$":{$ref:`#/$defs/compileOutput`}},required:[`@default`]},properties:{"@default":{$ref:`#/$defs/compileOutput`},"@npm":{$ref:`#/$defs/compileOutput`}},patternProperties:{"^\\S+$":{$ref:`#/$defs/compileOutput`}},required:[`@default`]},outputNpm:{type:[`string`,`array`,`object`],additionalProperties:!1,properties:{path:{type:[`string`,`array`]},packageJson:{type:`boolean`,description:`Define if you need to generate a package.json`},npmName:{type:`string`,description:`Define the name set inside your package.json`},manifest:{type:`boolean`,description:`Define if you need to generate manifest for your components`},live:{type:`boolean`,description:`Define if the npm content must be recompiled on change. Default is false`}},items:{type:`string`},description:`Define where to export as npm files`},compressed:{type:`boolean`},package:{type:[`string`,`array`],items:{type:`string`,pattern:`^\\S+\\.package\\.avt`},pattern:`^\\S+\\.package\\.avt`,description:`The package file generated path (for lib)`},i18n:{type:[`string`,`array`],items:{type:`object`,additionalProperties:!1,properties:{output:{type:[`string`,`array`],items:{type:`string`}},mount:{type:`string`},mode:{type:`string`,enum:[`singleFile`,`oneToOne`,`groupComponent`,`basedOnAttribute`,`include`],default:`singleFile`}},required:[`output`]}}}}},dependencies:{$ref:`#/$defs/dependencies`},module:{type:`string`,pattern:`^[a-zA-Z0-9_]+$`,description:`Name of the exported module for this build`},namespaceStrategy:{type:`string`,enum:[`manual`,`followFolders`,`followFoldersCamelCase`,`rules`],description:`Stragety to generate namespace`,default:`manual`},namespaceRules:{type:`object`,description:`Rules to define namespace when namespaceStrategy is rules`},namespaceRoot:{type:`string`,description:`Root directory to define namespace when namespaceStrategy is followFolders`},avoidParsingInsideTags:{type:`array`,items:{type:`string`,pattern:`^[a-z-]+$`},description:`List of html tag that mustn't be parsed by the html compiler`},nodeModulesDir:{type:[`string`,`array`],items:{type:`string`},description:`The dirs where node_modules are located`},i18n:{type:`object`,properties:{locales:{type:`array`,items:{type:`string`},description:`Locales that is required inside your project`},fallback:{type:`string`},autoRegister:{type:`boolean`}},description:`Define options for i18n`}},required:[`src`]},minItems:1},static:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{name:{type:`string`,description:`Part name for the static export`,pattern:`^[a-zA-Z0-9_]+$`},input:{type:`string`,description:`Input path to watch to export as static files`},output:{type:[`string`,`array`],items:{type:`string`},description:`Define where to export static files`}},required:[`name`,`input`,`output`]}},avoidParsingInsideTags:{type:`array`,items:{type:`string`,pattern:`^[a-z-]+$`},description:`List of html tag that mustn't be parsed by the html compiler`},aliases:{type:`object`}},required:[`build`,`module`],$defs:{dependencies:{type:`object`,description:`List of dependencies for this build`,patternProperties:{"^\\S+$":{type:[`object`,`string`],additionalProperties:!1,pattern:`^[0-9x]+.[0-9x]+.[0-9x]+$`,properties:{uri:{type:`string`,description:`Where to find the package or the json file`},npm:{type:`string`,description:`The npm package name`},version:{type:`string`,pattern:`^[0-9x]+.[0-9x]+.[0-9x]+$`,description:`The version to use for this file. (default is x.x.x)`,default:`x.x.x`},isLocal:{type:`boolean`,description:`Define if you want to use a local package`},include:{type:`string`,description:`Determine if the package must be included inside the final export. (default is need)`,enum:[`none`,`need`,`full`],default:`need`},subDependenciesInclude:{type:`object`,description:`Inclusion pattern for each lib. You can use a star to select everythink. If nothink find for a lib, the need value ll be used`,patternProperties:{"^\\S+$":{type:`string`,enum:[`none`,`need`,`full`],default:`need`}}}}}}},compileOutput:{type:[`string`,`object`],pattern:`^\\S+\\.js`,additionalProperties:!1,properties:{path:{type:`string`,pattern:`^\\S+\\.js`},compressed:{type:`boolean`}}}}},at={$schema:`foo://aventus/sharp.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{csProj:{type:`string`,pattern:`^\\S+\\.csproj`,description:`Path to your csproj file`},outputPath:{type:`string`,description:`Define the folder where to export the code`},exportEnumByDefault:{type:`boolean`,default:!1,description:`Define if enums must be exported. You can override behaviour with [Export] or [NoExport]`},exportStorableByDefault:{type:`boolean`,default:!0,description:`Define if storable must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRouteByDefault:{type:`boolean`,default:!0,description:`Define if http route must be exported. You can override behaviour with [Export] or [NoExport]`},exportErrorsByDefault:{type:`boolean`,default:!0,description:`Define if errors must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsEndPointByDefault:{type:`boolean`,default:!0,description:`Define if websocket endpoint must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsEventByDefault:{type:`boolean`,default:!0,description:`Define if websocket event must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsRouteByDefault:{type:`boolean`,default:!0,description:`Define if websocket route must be exported. You can override behaviour with [Export] or [NoExport]`},replacer:{type:`object`,additionalProperties:!1,description:`Create replacer to export type`,properties:{all:{$ref:`#/$defs/replacerPart`},genericError:{$ref:`#/$defs/replacerPart`},httpRouter:{$ref:`#/$defs/replacerPart`},normalClass:{$ref:`#/$defs/replacerPart`},storable:{$ref:`#/$defs/replacerPart`},withError:{$ref:`#/$defs/replacerPart`},wsEndPoint:{$ref:`#/$defs/replacerPart`},wsEvent:{$ref:`#/$defs/replacerPart`},wsRouter:{$ref:`#/$defs/replacerPart`}}},httpRouter:{type:`object`,additionalProperties:!1,properties:{useCompiledDll:{type:`boolean`,default:!0,description:"Try to parse route by running the app. You must use `app.UseAventusExport()` to prevent real starting."},createRouter:{type:`boolean`,default:!0,description:`Create a router that your route will use`},routerName:{type:`string`,default:`GeneratedRouter`,description:`The name of the router to generate`},uri:{type:`string`,default:``,pattern:`^(?=s*$)|^(\\/[a-zA-Z0-9_-]+?){1,}$`,description:`Define the base uri for your router (ex: /api)`},host:{type:`string`,default:`https://localhost:5000`,pattern:`^http(s)?:\\/\\/[a-zA-Z0-9_-]*?(:[0-9]{3,4})?$`,description:`Define the host that the router will use`},parent:{type:`string`,default:`Aventus.HttpRouter`,description:`Define the parent type to use for your router`},parentFile:{type:`string`,default:``,description:`Define the parent file to use for your router`},namespace:{type:`string`,default:`Routes`,description:`Define the namespace for your router`},addFormData:{type:`boolean`,default:!0,description:"Add ` | FormData` to the route body"},cacheByDefault:{type:`boolean`,default:!1,description:`Add cache to the function generated`},clearCacheFct:{type:`boolean`,default:!1,description:`Add function to clear cache to the function generated`}}},wsEndpoint:{type:`object`,additionalProperties:!1,properties:{useCompiledDll:{type:`boolean`,default:!0,description:"Try to parse route by running the app. You must use `app.UseAventusExport()` to prevent real starting."},prefix:{type:`string`,default:`Define a prefix for your websocket events`},host:{type:`string`,description:`The host to connect to the websocket`},port:{type:`number`,description:`The port to connect to the websocket`},useHttps:{type:`boolean`,description:`Define if you want to use http or https. Be default, Aventus will check if your connection is secure to use https or not`},parent:{type:`string`,default:`AventusSharp.WebSocket.EndPoint`,description:`Define the parent type to use for your router`}}}},required:[`csProj`,`outputPath`],$defs:{replacerPart:{type:`object`,additionalProperties:!1,properties:{type:{type:`object`,description:`Apply a replacer based on the c# type`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}},result:{type:`object`,description:`Apply a replacer based on the result type (ex: to replace Aventus.IData when IStorable is exported)`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}}}}}},ot={$schema:`foo://aventus/php.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{output:{type:`string`,description:`Define the folder where to export the code`},exportAsTs:{type:`boolean`,description:`Define if the code must be compiled as typescript`},useNamespace:{type:`boolean`,description:`Define if the compiler must used namespace`},exportEnumByDefault:{type:`boolean`,default:!1,description:`Define if enums must be exported. You can override behaviour with [Export] or [NoExport]`},exportStorableByDefault:{type:`boolean`,default:!0,description:`Define if storable must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRouteByDefault:{type:`boolean`,default:!0,description:`Define if http route must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRequestByDefault:{type:`boolean`,default:!0,description:`Define if request must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpResourceByDefault:{type:`boolean`,default:!0,description:`Define if resource must be exported. You can override behaviour with [Export] or [NoExport]`},exportErrorsByDefault:{type:`boolean`,default:!0,description:`Define if erros must be exported. You can override behaviour with [Export] or [NoExport]`},replacer:{type:`object`,additionalProperties:!1,description:`Create replacer to export type`,properties:{all:{$ref:`#/$defs/replacerPart`},genericError:{$ref:`#/$defs/replacerPart`},httpRouter:{$ref:`#/$defs/replacerPart`},normalClass:{$ref:`#/$defs/replacerPart`},storable:{$ref:`#/$defs/replacerPart`},withError:{$ref:`#/$defs/replacerPart`},httpRequest:{$ref:`#/$defs/replacerPart`},httpResource:{$ref:`#/$defs/replacerPart`}}},httpRouter:{type:`object`,additionalProperties:!1,properties:{createRouter:{type:`boolean`,default:!0,description:`Create a router that your route will use`},routerName:{type:`string`,default:`GeneratedRouter`,description:`The name of the router to generate`},uri:{type:`string`,default:``,pattern:`^(?=s*$)|^(\\/[a-zA-Z0-9_-]+?){1,}$`,description:`Define the base uri for your router (ex: /api)`},host:{type:`string`,default:`https://localhost:5000`,pattern:`^http(s)?:\\/\\/[a-zA-Z0-9_-]*?(:[0-9]{3,4})?$`,description:`Define the host that the router will use`},parent:{type:`string`,default:`Aventus.HttpRouter`,description:`Define the parent type to use for your router`},parentFile:{type:`string`,default:``,description:`Define the parent file to load for your router`},namespace:{type:`string`,default:`Routes`,description:`Define the namespace for your router`}}}},required:[`output`],$defs:{replacerPart:{type:`object`,additionalProperties:!1,properties:{type:{type:`object`,description:`Apply a replacer based on the c# type`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}},result:{type:`object`,description:`Apply a replacer based on the result type (ex: to replace Aventus.IData when IStorable is exported)`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}}}}}};var st=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}languageService;constructor(){this.languageService=(0,y.getLanguageService)({schemaRequestService:async e=>JSON.stringify(it)}),this.languageService.configure({allowComments:!0,schemas:[{fileMatch:[`**`+w.Config],uri:it.$schema??``,schema:it},{fileMatch:[`**`+w.CsharpConfig],uri:at.$schema??``,schema:at},{fileMatch:[`**`+w.PhpConfig],uri:ot.$schema??``,schema:ot}]})}async format(e,t,n){let r=e.documentUser;return await this.languageService.format(r,t,n)}async doComplete(e,t){let n=e.documentUser,r=this.languageService.parseJSONDocument(n),i=await this.languageService.doComplete(e.documentUser,t,r),a=r.getNodeFromOffset(n.offsetAt(t));return this.isKeyOfObject(a,`dependencies`)&&(i||={isIncomplete:!1,items:[]},i?.items.push({label:`Aventus@Main`},{label:`Aventus@UI`},{label:`Aventus@I18n`},{label:`Aventus@Sharp`},{label:`Aventus@Php`})),i||{isIncomplete:!1,items:[]}}async doResolve(e){return await this.languageService.doResolve(e)}async doHover(e,t){let n=e.documentUser,r=this.languageService.parseJSONDocument(n);return await this.languageService.doHover(n,t,r)}async validate(e){let t=e.documentUser,n=this.languageService.parseJSONDocument(t),r=await this.languageService.doValidation(t,n);if(r.length==0){let e=this.removeComments(t.getText());try{return JSON.parse(e),r}catch{r.push(Ae(t,`Can't parse the json`,1001))}}for(let e of r)e.severity=m.DiagnosticSeverity.Error;return r}isKeyOfObject(e,t){let n=e?.parent;if(n?.type==`property`&&n.keyNode==e){let n=e?.parent?.parent?.parent;if(n?.type==`property`&&n.keyNode.value==t)return!0}return!1}isValueOfObject(e,t){let n=e?.parent;if(n?.type==`property`&&n.valueNode==e){let n=e?.parent?.parent?.parent;if(n?.type==`property`&&n.keyNode.value==t)return!0}return!1}async getConfig(e){let t=`documentUser`in e?e.documentUser:e,n=this.languageService.parseJSONDocument(t),r=await this.languageService.doValidation(t,n,void 0,it);if(r.length==0){let e=this.removeComments(t.getText());try{let n=JSON.parse(e);return n=this.prepareConfigFile(t.uri,n),n}catch{r.push(Ae(t,`Can't parse the json`,1001))}}return null}prepareConfigFile(e,t){if(t={...this.defaultConfigValue(),...t},t.componentPrefix==``){let e=t.module.match(/([A-Z][a-z]*)|([0-9][a-z]*)/g);e?t.componentPrefix=e.join(`-`).toLowerCase():t.componentPrefix=`av`}let n=[];for(let r of t.build)n.push(this.prepareBuild(e,r,t));if(t.build=n,t.static){let n=[];for(let r of t.static)n.push(this.prepareStatic(e,r));t.static=n}return t}replaceEnvVar(e,t){if(!e||e.startsWith(`@`)||e.startsWith(`Aventus@`))return e;let n=/%(.*?)%/gm,r;for(;r=n.exec(e);){let t=b.env[r[1]]??`undefined`;e=e.replace(r[0],t)}return/^https?:\/\/.*/.exec(e)||(!e.startsWith(`/`)&&!/^[a-zA-Z]:/gm.test(e)?(e=`/`+e,e=(0,f.normalize)(D(t)+e)):e=(0,f.normalize)(e)),e}prepareBuild(e,t,n){let r=Re(e);t={...this.defaultConfigBuildValue(n),...t},t.name?t.fullname=t.module+`@`+t.name:t.fullname=t.module;let i=e=>this.replaceEnvVar(e,r),a=t.compile;for(let e of a){if(!e.input)e.inputPathRegex=RegExp(`.*`);else{Array.isArray(e.input)||(e.input=[e.input]);let t=[];for(let n of e.input){let e=``;n=n.replace(/\\/g,`/`),n.startsWith(`/`)||(e=`/`);let i=n.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),n=i.join(`/`);let a=(0,f.normalize)(D(r)+e+n).replace(/\\/g,`/`);a=Ve(a,!0).replace(`*`,`.*`),t.push(`(^`+a+`$)`)}let n=t.join(`|`);n==``&&(n=`(?!)`),e.inputPathRegex=new RegExp(n)}if(!e.output)e.output=[];else{Array.isArray(e.output)||(e.output=[e.output]);for(let t=0;t<e.output.length;t++){let n=e.output[t];typeof n==`string`&&(e.output[t]={"@default":{path:n}},n=e.output[t]);let r=!1;for(let a in n){a==`@default`&&(r=!0);let o=n[a];typeof o==`string`&&(e.output[t][a]={path:o}),e.output[t][a].path=n[a].path.trim(),n[a].path.length>0&&(e.output[t][a].path=i(n[a].path))}r||(e.output[t][`@default`]={path:`./dist/script.js`})}}if(!e.outputNpm)e.outputNpm={path:[],packageJson:!1,npmName:``,live:!1};else{typeof e.outputNpm==`string`?e.outputNpm={path:[e.outputNpm],packageJson:!0,npmName:``,manifest:{},live:!1}:Array.isArray(e.outputNpm)&&(e.outputNpm={path:e.outputNpm,packageJson:!0,npmName:``,manifest:{},live:!1}),Array.isArray(e.outputNpm.path)||(e.outputNpm.path=[e.outputNpm.path]),e.outputNpm.packageJson===void 0&&(e.outputNpm.packageJson=!0),e.outputNpm.manifest===void 0&&(e.outputNpm.manifest={}),e.outputNpm.npmName===void 0&&(e.outputNpm.npmName=``),e.outputNpm.live===void 0&&(e.outputNpm.live=!1);for(let t=0;t<e.outputNpm.path.length;t++){let n=i(e.outputNpm.path[t]);n.endsWith(`*`)&&(n=n.slice(0,-1)),n.endsWith(`/`)&&(n=n.slice(0,-1)),n=n.replace(/\\/g,`/`),e.outputNpm.path[t]=n}}if(!e.package)e.package=[];else{Array.isArray(e.package)||(e.package=[e.package]);for(let t=0;t<e.package.length;t++)e.package[t]=e.package[t].trim(),e.package[t].length>0&&(e.package[t]=i(e.package[t]))}if(t.i18n)if(e.i18n){Array.isArray(e.i18n)||(e.i18n=[{output:[e.i18n],mount:``,mode:`singleFile`}]);for(let t=0;t<e.i18n.length;t++){if(!Array.isArray(e.i18n[t].output)){let n=e.i18n[t].output;e.i18n[t].output=[n]}for(let n=0;n<e.i18n[t].output.length;n++)e.i18n[t].output[n].endsWith(`/`)&&(e.i18n[t].output[n]=e.i18n[t].output[n].slice(0,-1)),e.i18n[t].output[n]=e.i18n[t].output[n].trim(),e.i18n[t].output[n].length>0&&(e.i18n[t].output[n]=i(e.i18n[t].output[n]));if(!e.i18n[t].mount&&e.i18n[t].output.length>0){let n=(0,f.normalize)(D($.getWorkspaceUri())),r=e.i18n[t].output[0].replace(n,``).replace(/\\/g,`/`);r.startsWith(`/dist`)&&(r=r.replace(`/dist`,``)),e.i18n[t].mount=r}e.i18n[t].mount.endsWith(`/`)&&(e.i18n[t].mount=e.i18n[t].mount.slice(0,-1))}}else{e.i18n=[];for(let t of e.output){let n=t[`@default`].path.split(f.sep);n.pop();let r=(0,f.join)(n.join(f.sep),`locales`),i=(0,f.normalize)(D($.getWorkspaceUri())),a=r.replace(i,``).replace(/\\/g,`/`);a.startsWith(`/dist`)&&(a=a.replace(`/dist`,``)),e.i18n.push({output:[r],mount:a,mode:`singleFile`})}}}let o=[];for(let e of t.src){let n=``;e=e.replace(/\\/g,`/`),e.startsWith(`/`)||(n=`/`);let i=e.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),e=i.join(`/`);let a=(0,f.normalize)(D(r)+n+e).replace(/\\/g,`/`),s=a.replace(`*`,``);s.endsWith(`/`)&&(s=s.slice(0,-1)),t.srcPath.push(s),a=Ve(a,!0).replace(`*`,`.*`),o.push(`(^`+a+`$)`)}if(t.stories){t.stories={...this.defaultConfigBuildStories(r,n),...t.stories};let e=i(t.stories.output);e.endsWith(`*`)&&(e=e.slice(0,-1)),e.endsWith(`/`)&&(e=e.slice(0,-1)),e=e.replace(/\\/g,`/`),t.stories.output=e}let s=o.join(`|`);s==``&&(s=`(?!)`),t.srcPathRegex=new RegExp(s),t.nodeModulesDir=t.nodeModulesDir.trim(),t.nodeModulesDir==``?t.nodeModulesDir=(0,f.normalize)(D(r)+`/node_modules`):t.nodeModulesDir=i(t.nodeModulesDir);let c={};t.rawDependencies=JSON.parse(JSON.stringify(t.dependencies));for(let e in t.dependencies){let n=t.dependencies[e];typeof n==`string`&&(n={version:n}),c[e]={...this.defaultConfigBuildDependencyValue(n),...n};let r=c[e];r.subDependenciesInclude||={},r.subDependenciesInclude[`*`]||(r.subDependenciesInclude[`*`]=n.include??`need`),r.uri&&=i(r.uri)}if(t.dependencies=c,t.outsideModule){let e=[];for(let n of t.outsideModule){let t=``;n=n.replace(/\\/g,`/`),n.startsWith(`/`)||(t=`/`);let i=n.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),n=i.join(`/`);let a=(0,f.normalize)(D(r)+t+n).replace(/\\/g,`/`);a=Ve(a,!0).replace(`*`,`.*`),e.push(`(^`+a+`$)`)}let n=e.join(`|`);n==``&&(n=`(?!)`),t.outsideModulePathRegex=new RegExp(n)}if(t.namespaceStrategy==`rules`)for(let e in t.namespaceRules){let n=[],i=t.namespaceRules[e];for(let e of i){let t=``;e=e.replace(/\\/g,`/`),e.startsWith(`/`)||(t=`/`);let i=e.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),e=i.join(`/`);let a=(0,f.normalize)(D(r)+t+e).replace(/\\/g,`/`);a=Ve(a,!0).replace(`*`,`.*`),n.push(`(^`+a+`$)`)}let a=n.join(`|`);a==``&&(a=`(?!)`),t.namespaceRulesRegex[e]=new RegExp(a)}else if(t.namespaceStrategy==`followFolders`||t.namespaceStrategy==`followFoldersCamelCase`){let e=``;t.namespaceRoot.startsWith(`/`)||(e=`/`),t.namespaceRoot=(0,f.normalize)(D(r)+e+t.namespaceRoot).replace(/\\/g,`/`)}return t.i18n,t}prepareStatic(e,t){let n=Re(e),r=``;t.input.startsWith(`/`)||(r=`/`),t.input.endsWith(`*`)&&(t.input=t.input.slice(0,-1)),t.input.endsWith(`/`)&&(t.input=t.input.slice(0,-1)),t.inputPathFolder=(0,f.normalize)(D(n)+r+t.input),t.inputPathFolder=t.inputPathFolder.replace(/\\/g,`/`),r=``,Array.isArray(t.output)||(t.output=[t.output]),t.outputPathFolder=[];for(let e of t.output)e=this.replaceEnvVar(e,n),e.endsWith(`*`)&&(e=e.slice(0,-1)),e.endsWith(`/`)&&(e=e.slice(0,-1)),e=e.replace(/\\/g,`/`),t.outputPathFolder.push(e);return t}defaultConfigValue(){return{module:``,hideWarnings:T.getInstance().settings.defaultHideWarnings,version:`1.0.0`,componentPrefix:``,tags:[],dependencies:{},build:[],static:[],avoidParsingInsideTags:[],aliases:{},namespaceRules:{},namespaceRulesRegex:{},namespaceStrategy:`manual`,namespaceRoot:`./`}}defaultConfigBuildValue(e){return{fullname:``,name:``,tags:e.tags,version:e.version,organization:e.organization,description:e.description,readme:e.readme,repository:e.repository,documentation:e.documentation,disabled:!1,hideWarnings:e.hideWarnings,src:[],srcPath:[],stories:void 0,compile:[],srcPathRegex:RegExp(`(?!)`),outsideModule:[],outsideModulePathRegex:RegExp(`(?!)`),module:e.module,componentPrefix:e.componentPrefix,namespaceStrategy:e.namespaceStrategy,namespaceRules:{...e.namespaceRules},namespaceRulesRegex:{...e.namespaceRulesRegex},namespaceRoot:e.namespaceRoot,dependencies:{...e.dependencies},rawDependencies:{},avoidParsingInsideTags:[...e.avoidParsingInsideTags],nodeModulesDir:``}}defaultConfigBuildStories(e,t){return{output:e+`/stories`,format:`all`}}defaultConfigBuildDependencyValue(e){return{}}removeComments(e){return e=e.replace(/(\".*?\"|\'.*?\')|(\/\*.*?\*\/|\/\/[^(\r\n|\n)]*$)/gm,(e,t,n)=>{if(n){let e=``;for(let t=0;t<n.length;t++)e+=` `;return e}return t}),e}},ct=class{_file;_build;get file(){return this._file}get build(){if(this._build)return this._build;throw`No build found`}constructor(e,t){this._file=e,this._build=t,this.addEvents()}uuidEvents={onCanContentChange:``,onContentChange:``,onValidate:``,onSave:``,onDelete:``,onCompletion:``,onCompletionResolve:``,onHover:``,onDefinition:``,onFormatting:``,onCodeAction:``,onReferences:``,onCodeLens:``,onGetBuild:``,onRename:``};addEvents(){this.uuidEvents.onCanContentChange=this.file.onCanContentChange(this.onCanContentChange.bind(this)),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.onGetBuild=this.file.onGetBuild(this.onGetBuild.bind(this)),this.uuidEvents.onRename=this.file.onRename(this.onRename.bind(this))}removeEvents(){this.file.removeOnCanContentChange(this.uuidEvents.onCanContentChange),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.removeOnGetBuild(this.uuidEvents.onGetBuild),this.file.removeOnRename(this.uuidEvents.onRename)}async validate(){this.file instanceof A&&await this.file.validate()}async triggerSave(){this.file instanceof A&&await this.file.triggerSave()}async triggerDelete(){this.file instanceof A&&await this.file.triggerDelete()}async triggerContentChange(e){this.file instanceof A&&await this.file.triggerContentChange(e)}onCanContentChange(e){return this._file.versionUser!=e.version}oldResult=[];async _onValidate(){let e=this._build?.diagnostics.get(this)??[];return e=[...e,...await this.onValidate()],this._build&&this.build.hideWarnings&&(e=e.filter(e=>e.severity!=m.DiagnosticSeverity.Warning)),this.oldResult=e,e}async _onDelete(){await this.onDelete(),this.removeEvents()}},lt=o(((e,t)=>{var n=require("stream");e=t.exports=r,r.through=r;function r(e,t,r){e||=function(e){this.queue(e)},t||=function(){this.queue(null)};var i=!1,a=!1,o=[],s=!1,c=new n;c.readable=c.writable=!0,c.paused=!1,c.autoDestroy=!(r&&r.autoDestroy===!1),c.write=function(t){return e.call(this,t),!c.paused};function l(){for(;o.length&&!c.paused;){var e=o.shift();if(e===null)return c.emit(`end`);c.emit(`data`,e)}}c.queue=c.push=function(e){return s?c:(e===null&&(s=!0),o.push(e),l(),c)},c.on(`end`,function(){c.readable=!1,!c.writable&&c.autoDestroy&&process.nextTick(function(){c.destroy()})});function u(){c.writable=!1,t.call(c),!c.readable&&c.autoDestroy&&c.destroy()}return c.end=function(e){if(!i)return i=!0,arguments.length&&c.write(e),u(),c},c.destroy=function(){if(!a)return a=!0,i=!0,o.length=0,c.writable=c.readable=!1,c.emit(`close`),c},c.pause=function(){if(!c.paused)return c.paused=!0,c},c.resume=function(){return c.paused&&(c.paused=!1,c.emit(`resume`)),l(),c.paused||c.emit(`drain`),c},c}})),ut=o(((e,t)=>{var n=require("stream");t.exports=function e(t){if(Array.isArray(t)){var r=0,i=t.length;return e(function(e){return r<i?this.emit(`data`,t[r++]):this.emit(`end`),!0})}var a=new n,o=0;a.ended=!1,a.started=!1,a.readable=!0,a.writable=!1,a.paused=!1,a.ended=!1,a.pause=function(){a.started=!0,a.paused=!0};function s(){if(a.started=!0,!a.ended)for(;!a.ended&&!a.paused&&t.call(a,o++,function(){!a.ended&&!a.paused&&process.nextTick(s)}););}return a.resume=function(){a.started=!0,a.paused=!1,s()},a.on(`end`,function(){a.ended=!0,a.readable=!1,process.nextTick(a.destroy)}),a.destroy=function(){a.ended=!0,a.emit(`close`)},process.nextTick(function(){a.started||a.resume()}),a}})),dt=o(((e,t)=>{var n=require("stream"),r=[`write`,`end`,`destroy`],i=[`resume`,`pause`],a=[`data`,`close`],o=Array.prototype.slice;t.exports=c;function s(e,t){if(e.forEach)return e.forEach(t);for(var n=0;n<e.length;n++)t(e[n],n)}function c(e,t){var c=new n,l=!1;return s(r,u),s(i,d),s(a,f),t.on(`end`,p),e.on(`drain`,function(){c.emit(`drain`)}),e.on(`error`,m),t.on(`error`,m),c.writable=e.writable,c.readable=t.readable,c;function u(t){c[t]=n;function n(){return e[t].apply(e,arguments)}}function d(e){c[e]=n;function n(){c.emit(e);var n=t[e];if(n)return n.apply(t,arguments);t.emit(e)}}function f(e){t.on(e,n);function n(){var t=o.call(arguments);t.unshift(e),c.emit.apply(c,t)}}function p(){if(!l){l=!0;var e=o.call(arguments);e.unshift(`end`),c.emit.apply(c,e)}}function m(e){c.emit(`error`,e)}}})),ft=o(((e,t)=>{var n=require("stream").Stream;t.exports=function(e,t){var r=new n,i=0,a=0,o=!1,s=!1,c=!1,l=0,u=!1;t||={};var d=t.failures?`failure`:`error`,f={};r.writable=!0,r.readable=!0;function p(e,t){var n=l+1;if(t===n?(e!==void 0&&r.emit.apply(r,[`data`,e]),l++,n++):f[t]=e,f.hasOwnProperty(n)){var c=f[n];return delete f[n],p(c,n)}a++,i===a&&(s&&(s=!1,r.emit(`drain`)),o&&g())}function m(e,n,i){c||(u=!0,(!e||t.failures)&&p(n,i),e&&r.emit.apply(r,[d,e]),u=!1)}function h(t,n,r){return e.call(null,t,function(e,t){r(e,t,n)})}r.write=function(e){if(o)throw Error(`map stream is not writable`);u=!1,i++;try{return s=h(e,i,m)===!1,!s}catch(e){if(u)throw e;return m(e),!s}};function g(e){if(o=!0,r.writable=!1,e!==void 0)return p(e,i);i==a&&(r.readable=!1,r.emit(`end`),r.destroy())}return r.end=function(e){o||g(e)},r.destroy=function(){o=c=!0,r.writable=r.readable=s=!1,process.nextTick(function(){r.emit(`close`)})},r.pause=function(){s=!0},r.resume=function(){s=!1},r}})),pt=o(((e,t)=>{t.exports=lt()})),mt=o(((e,t)=>{var n=lt(),r=require("string_decoder").StringDecoder;t.exports=i;function i(e,t,i){var a=new r,o=``,s=i&&i.maxLength,c=!(i&&i.trailing===!1);typeof e==`function`&&(t=e,e=null),e||=/\r?\n/;function l(e,n){if(t){try{n=t(n)}catch(t){return e.emit(`error`,t)}n!==void 0&&e.queue(n)}else e.queue(n)}function u(t,n){var r=((o??``)+n).split(e);if(o=r.pop(),s&&o.length>s)return t.emit(`error`,Error(`maximum buffer reached`));for(var i=0;i<r.length;i++){var a=r[i];l(t,a)}}return n(function(e){u(this,a.write(e))},function(){a.end&&u(this,a.end()),c&&o!=null&&l(this,o),this.queue(null)})}})),ht=o(((e,t)=>{var n=dt(),r=lt();t.exports=function(){var e=arguments.length==1&&Array.isArray(arguments[0])?arguments[0]:[].slice.call(arguments);if(e.length==0)return r();if(e.length==1)return e[0];var t=e[0],i=e[e.length-1],a=n(t,i);function o(e){e.length<2||(e[0].pipe(e[1]),o(e.slice(1)))}o(e);function s(){var e=[].slice.call(arguments);e.unshift(`error`),a.emit.apply(a,e)}for(var c=1;c<e.length-1;c++)e[c].on(`error`,s);return a}})),gt=o((e=>{var t=require("stream").Stream,n=e,r=lt(),i=ut(),a=dt(),o=ft(),s=pt(),c=mt(),l=ht(),u=global.setImmediate||process.nextTick;n.Stream=t,n.through=r,n.from=i,n.duplex=a,n.map=o,n.pause=s,n.split=c,n.pipeline=n.connect=n.pipe=l,n.concat=n.merge=function(){var e=[].slice.call(arguments);e.length===1&&e[0]instanceof Array&&(e=e[0]);var n=new t;n.setMaxListeners(0);var r=0;return n.writable=n.readable=!0,e.length?e.forEach(function(t){t.pipe(n,{end:!1});var i=!1;t.on(`end`,function(){i||(i=!0,r++,r==e.length&&n.emit(`end`))})}):process.nextTick(function(){n.emit(`end`)}),n.write=function(e){this.emit(`data`,e)},n.destroy=function(){e.forEach(function(e){e.destroy&&e.destroy()})},n},n.collect=n.writeArray=function(e){if(typeof e!=`function`)throw Error(`function writeArray (done): done must be function`);var n=new t,r=[],i=!1;return n.write=function(e){r.push(e)},n.end=function(){i=!0,e(null,r)},n.writable=!0,n.readable=!1,n.destroy=function(){n.writable=n.readable=!1,!i&&e(Error(`destroyed before end`),r)},n},n.readArray=function(e){var n=new t,r=0,i=!1,a=!1;if(n.readable=!0,n.writable=!1,!Array.isArray(e))throw Error(`event-stream.read expects an array`);return n.resume=function(){if(!a){i=!1;for(var t=e.length;r<t&&!i&&!a;)n.emit(`data`,e[r++]);r==t&&!a&&(a=!0,n.readable=!1,n.emit(`end`))}},process.nextTick(n.resume),n.pause=function(){i=!0},n.destroy=function(){a=!0,n.emit(`close`)},n},n.readable=function(e,n){var r=new t,i=0,a=!1,o=!1,s=!1;if(r.readable=!0,r.writable=!1,typeof e!=`function`)throw Error(`event-stream.readable expects async function`);r.on(`end`,function(){o=!0});function c(t,l){t?(r.emit(`error`,t),n||r.emit(`end`)):arguments.length>1&&r.emit(`data`,l),u(function(){if(!(o||a||s))try{s=!0,e.call(r,i++,function(){s=!1,c.apply(null,arguments)})}catch(e){r.emit(`error`,e)}})}return r.resume=function(){a=!1,c()},process.nextTick(c),r.pause=function(){a=!0},r.destroy=function(){r.emit(`end`),r.emit(`close`),o=!0},r},n.mapSync=function(e){return n.through(function(t){var n;try{n=e(t)}catch(e){return this.emit(`error`,e)}n!==void 0&&this.emit(`data`,n)})},n.filterSync=function(e){return n.through(function(t){var n=this;e(t)&&n.queue(t)})},n.flatmapSync=function(e){return n.through(function(t){var n=this;t.forEach(function(t){n.queue(e(t))})})},n.log=function(e){return n.through(function(t){[].slice.call(arguments),e?console.error(e,t):console.error(t),this.emit(`data`,t)})},n.child=function(e){return n.duplex(e.stdin,e.stdout)},n.parse=function(e){var t=!!(e&&e.error);return n.through(function(e){var n;try{e&&(n=JSON.parse(e.toString()))}catch(n){return t?this.emit(`error`,n):console.error(n,`attempting to parse:`,e)}n!==void 0&&this.emit(`data`,n)})},n.stringify=function(){var e=require("buffer").Buffer;return n.mapSync(function(t){return JSON.stringify(e.isBuffer(t)?t.toString():t)+`
|
|
9
|
-
`})},n.replace=function(e,t){return n.pipeline(n.split(e),n.join(t))},n.join=function(e){if(typeof e==`function`)return n.wait(e);var t=!0;return n.through(function(n){return t||this.emit(`data`,e),t=!1,this.emit(`data`,n),!0})},n.wait=function(e){var t=[];return n.through(function(e){t.push(e)},function(){var n=Buffer.isBuffer(t[0])?Buffer.concat(t):t.join(``);this.emit(`data`,n),this.emit(`end`),e&&e(null,n)})},n.pipeable=function(){throw Error(`[EVENT-STREAM] es.pipeable is deprecated`)}}))();const
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let u=require("fs"),d=require("vscode-languageserver-textdocument"),f=require("path"),p=require("typescript"),m=require("vscode-languageserver"),h=require("util"),g=require("child_process"),_=require("crypto"),v=require("chokidar"),y=require("vscode-json-languageservice"),b=require("process"),x=require("connect");x=l(x);let ee=require("send");ee=l(ee);let te=require("url");te=l(te);let ne=require("http"),re=require("net"),ie=require("serve-index");ie=l(ie);let ae=require("ws"),oe=require("open");oe=l(oe);let S=require("vscode-html-languageservice"),se=require("postcss");se=l(se);let ce=require("vscode-css-languageservice"),le=require("sass"),ue=require("https"),de=require("unzipper"),fe=require("os"),pe=require("archiver"),me=require("terser"),he=require("esbuild"),ge=require("sudo-prompt"),_e=require("readline");_e=l(_e);const C={Base:`Aventus`,TypeScript:`Aventus Ts`,HTML:`Aventus HTML`,SCSS:`Aventus SCSS`,WebComponent:`Aventus WebComponent`,Package:`Aventus Ts`,I18n:`Aventus I18n`},w={Base:`.avt`,Config:`aventus.conf.avt`,CsharpConfig:`aventus.sharp.avt`,PhpConfig:`aventus.php.avt`,ComponentLogic:`.wcl.avt`,ComponentView:`.wcv.avt`,ComponentStyle:`.wcs.avt`,Component:`.wc.avt`,GlobalStyle:`.gs.avt`,Data:`.data.avt`,Lib:`.lib.avt`,RAM:`.ram.avt`,State:`.state.avt`,Static:`.static.avt`,Definition:`.def.avt`,DefinitionNpm:`.defnpm.avt`,Template:`template.avt.ts`,ConfigTemplate:`!aventus.conf.avt`,Package:`.package.avt`,I18n:`.i18n.avt`},ve={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:[]};function ye(){return JSON.parse(JSON.stringify(ve))}const be={version:`1.3.7`,store:{token:``,username:``}};function xe(){return JSON.parse(JSON.stringify(be))}const Se={customData:[]};function Ce(){return JSON.parse(JSON.stringify(Se))}var T=class e{static instance;_settings=ye();_settingsHtml=Ce();_hiddenSettings=xe();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){this._settings=this.mergeDeep(ye(),e);let t=[...this.cbOnSettingsChange];for(let e of t)e()}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(Ce(),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)}},we=class{static get isEnable(){return T.getInstance().settings.useStats}static startSendLoadFile(){this.isEnable&&Qe.start(`load_files`)}static sendLoadFile(){this.isEnable&&$.sendNotification(`aventus/statistics/loadFileTime`,Qe.stop(`load_files`))}static startSendBuildTime(e){this.isEnable&&Qe.start(`full_build_`+e)}static sendBuildTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/buildTime`,e,Qe.stop(`full_build_`+e))}static startSendStaticTime(e){this.isEnable&&Qe.start(`full_static_`+e)}static sendStaticTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/staticTime`,e,Qe.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 Te=(0,h.promisify)(g.exec);(0,h.promisify)(u.stat);function E(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=Ee(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function Ee(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function De(e){return e.replace(/%3A/g,`:`).replace(/%40/g,`@`)}function D(e){return f.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function Oe(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1),e.splice(0,0,t)}function ke(e){let t=Object.keys(w).reverse();for(let n of t)if(e.endsWith(w[n]))return Ae(w[n]);return``}function Ae(e){return e==`.wcv.avt`?C.HTML:e==`.wcs.avt`?C.SCSS:C.TypeScript}function je(e,t,n,r){return O(e,t,0,e.getText().length,n,r)}function Me(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,`
|
|
2
|
+
`),code:r};return i&&(c.data=i),c}return je(e,t,r)}function O(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,`
|
|
3
|
+
`),code:i};return a&&(o.data=a),o}function Ne(e,t){return Pe(e,t,0,e.getText().length)}function Pe(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,`
|
|
4
|
+
`)}}function Fe(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,`
|
|
5
|
+
`)}}function Ie(e,t){return Le(e,t,0,e.getText().length)}function Le(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,`
|
|
6
|
+
`)}}function Re(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,`
|
|
7
|
+
`)}}function ze(e){let t=e.split(`/`);return t.pop(),t.join(`/`)}function Be(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 Ve(e,t){if(!t)return e;let n=t.aliases;for(let t in n)if(!t.startsWith(`@`)){let r=He(t),i=RegExp(`(?<!\\\\)`+r,`g`);e=e.replace(i,n[t])}return e}function He(e,t=!1){return t?e.replace(/[\\^$+?.()|[\]{}]/g,`\\$&`):e.replace(/[\\^$*+?.()|[\]{}]/g,`\\$&`)}function Ue(e){return e===13||e===10}const We=/(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;function Ge(e,t){let n=We,r=t;for(;r>0&&!Ue(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 Ke(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 qe(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 Je={};function Ye(e,t,n,r){t=t.replace(/\r\n?/g,`
|
|
8
|
+
`);let i=Xe(t),a=(0,f.dirname)(e);(0,u.existsSync)(a)||(0,u.mkdirSync)(a,{recursive:!0});let o=(0,u.existsSync)(e);(!Je[e]||Je[e]!=i||!o)&&(Je[e]=i,we.sendFileSize(e,t,n,r),(0,u.writeFileSync)(e,t))}function Xe(e){return(0,_.createHash)(`md5`).update(e).digest(`hex`)}function Ze(e){try{(0,u.existsSync)(e)&&(0,u.unlinkSync)(e)}catch{}}var Qe=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]}};const $e=new Uint8Array(16);function et(){return crypto.getRandomValues($e)}const tt=[];for(let e=0;e<256;++e)tt.push((e+256).toString(16).slice(1));function nt(e,t=0){return(tt[e[t+0]]+tt[e[t+1]]+tt[e[t+2]]+tt[e[t+3]]+`-`+tt[e[t+4]]+tt[e[t+5]]+`-`+tt[e[t+6]]+tt[e[t+7]]+`-`+tt[e[t+8]]+tt[e[t+9]]+`-`+tt[e[t+10]]+tt[e[t+11]]+tt[e[t+12]]+tt[e[t+13]]+tt[e[t+14]]+tt[e[t+15]]).toLowerCase()}function k(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():rt(e,t,n)}function rt(e,t,n){e||={};let r=e.random??e.rng?.()??et();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return nt(r)}var A=class{_documentUser;_documentInternal;get documentUser(){return this._documentUser}get documentInternal(){return this._documentInternal}linkInternalAndUser=!0;setDocumentInternal(e){this._documentInternal=e,this._versionInternal=e.version}constructor(e){this._documentUser=e,this._documentInternal=e,this._versionUser=e.version,this._versionInternal=e.version}get uri(){return this.documentUser.uri}get path(){return D(this.uri)}get name(){return this.path.split(`/`).pop()??``}_versionUser=0;get versionUser(){return this._versionUser}_versionInternal=0;get versionInternal(){return this._versionInternal}get contentUser(){return this.documentUser.getText()}get contentInternal(){return this.documentInternal.getText()}get folderUri(){return ze(this.uri)}get folderPath(){return ze(this.path)}_shortname=``;get shortname(){if(!this._shortname){let e=this.uri.split(`/`);this._shortname=e[e.length-1]}return this._shortname}onGetBuildCb={};getBuild(){let e=[],t=!1;for(let n in this.onGetBuildCb){let r=this.onGetBuildCb[n]();if(r===null)t=!0;else for(let t of r)e.indexOf(t)==-1&&e.push(t)}return e.length==0&&t?null:e}onGetBuild(e){let t=k();for(;this.onGetBuildCb[t]!=null;)t=k();return this.onGetBuildCb[t]=e,t}removeOnGetBuild(e){delete this.onGetBuildCb[e]}onValidateCb={};async validate(e=!0){let t={};for(let e in this.onValidateCb){let n=await this.onValidateCb[e](this);for(let e of n){let n=e.message+`**`+e.range.start.line+`:`+e.range.start.character+`,`+e.range.end.line+`:`+e.range.end.character;t[n]||(t[n]=e)}}if(e)if(T.getInstance().settings.errorByBuild){let e=this.getBuild();if(e==null)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)});else for(let n of e)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)},n)}else $.sendDiagnostics({uri:this.uri,diagnostics:Object.values(t)});return Object.values(t)}onValidate(e){let t=k();for(;this.onValidateCb[t]!=null;)t=k();return this.onValidateCb[t]=e,t}removeOnValidate(e){delete this.onValidateCb[e]}onContentChangeCb={};delayValidate;waitingDocContentChange={};resolveContentChange={};triggerContentChange(e){return new Promise(t=>{if(!this.triggerCanContentChange(e)){t();return}setTimeout(()=>{this.waitingDocContentChange[e.uri]?(this.resolveContentChange[e.uri]||(this.resolveContentChange[e.uri]={}),this.resolveContentChange[e.uri][e.version]||(this.resolveContentChange[e.uri][e.version]=[]),this.resolveContentChange[e.uri][e.version].push(t),this.waitingDocContentChange[e.uri]=e):(this.waitingDocContentChange[e.uri]=!0,this.resolveContentChange[e.uri]={[e.version]:[t]},this.triggerContentChangeNoBuffer(e))},0)})}async triggerContentChangeNoBuffer(e){let t=e.version;this._documentUser=e,this._versionUser=e.version,this.linkInternalAndUser&&(this._documentInternal=e,this._versionInternal=e.version);let n=[];for(let e in this.onContentChangeCb)n.push(this.onContentChangeCb[e](this));if(await Promise.all(n),this.delayValidate&&clearTimeout(this.delayValidate),this.delayValidate=setTimeout(async()=>{this.validate()},500),this.resolveContentChange[e.uri]){let n=Object.keys(this.resolveContentChange[e.uri]);for(let r of n){if(Number(r)>t)break;if(this.resolveContentChange[e.uri][r]){for(let t of this.resolveContentChange[e.uri][r])t();delete this.resolveContentChange[e.uri][r]}}Object.keys(this.resolveContentChange[e.uri]).length==0&&delete this.resolveContentChange[e.uri]}let r=this.waitingDocContentChange[e.uri];r&&typeof r!=`boolean`?(this.waitingDocContentChange[e.uri]=!0,this.triggerContentChangeNoBuffer(r)):delete this.waitingDocContentChange[e.uri]}onContentChange(e){let t=k();for(;this.onContentChangeCb[t]!=null;)t=k();return this.onContentChangeCb[t]=e,t}removeOnContentChange(e){delete this.onContentChangeCb[e]}onCanContentChangeCb={};triggerCanContentChange(e){for(let t in this.onCanContentChangeCb)if(!this.onCanContentChangeCb[t](e))return!1;return!0}onCanContentChange(e){let t=k();for(;this.onCanContentChangeCb[t]!=null;)t=k();return this.onCanContentChangeCb[t]=e,t}removeOnCanContentChange(e){delete this.onCanContentChangeCb[e]}async applyTextEdits(e){let t=this.contentUser;e.sort((e,t)=>this.documentUser.offsetAt(t.range.end)-this.documentUser.offsetAt(e.range.end));for(let n of e){let e=this.documentUser.offsetAt(n.range.start),r=this.documentUser.offsetAt(n.range.end);t=t.slice(0,e)+n.newText+t.slice(r,t.length)}let n=d.TextDocument.create(this.uri,C.TypeScript,this.documentUser.version+1,t);await this.triggerContentChange(n)}onSaveCb={};async triggerSave(){for(let e in this.onSaveCb)await this.onSaveCb[e](this)}onSave(e){let t=k();for(;this.onSaveCb[t]!=null;)t=k();return this.onSaveCb[t]=e,t}removeOnSave(e){delete this.onSaveCb[e]}onDeleteCb={};async triggerDelete(){let e=[];for(let t in this.onDeleteCb)e.push(this.onDeleteCb[t](this));await Promise.all(e),this.removeAllCallbacks()}removeAllCallbacks(){this.onCodeActionCb={},this.onCompletionCb={},this.onCompletionResolveCb={},this.onContentChangeCb={},this.onDefinitionCb={},this.onDeleteCb={},this.onFormattingCb={},this.onHoverCb={},this.onSaveCb={}}onDelete(e){let t=k();for(;this.onDeleteCb[t]!=null;)t=k();return this.onDeleteCb[t]=e,t}removeOnDelete(e){delete this.onDeleteCb[e]}onCompletionCb={};async getCompletion(e){let t={isIncomplete:!1,items:[]},n=[];for(let t in this.onCompletionCb)n.push(this.onCompletionCb[t](this,e));let r=await Promise.all(n),i={};for(let e of r)for(let t of e.items){let e=JSON.stringify(t);i[e]||(i[e]=t)}return t.items=Object.values(i),t}onCompletion(e){let t=k();for(;this.onCompletionCb[t]!=null;)t=k();return this.onCompletionCb[t]=e,t}removeOnCompletion(e){delete this.onCompletionCb[e]}onCompletionResolveCb={};async getCompletionResolve(e){let t=e,n=[];for(let t in this.onCompletionResolveCb)n.push(this.onCompletionResolveCb[t](this,e));return t}onCompletionResolve(e){let t=k();for(;this.onCompletionResolveCb[t]!=null;)t=k();return this.onCompletionResolveCb[t]=e,t}removeOnCompletionResolve(e){delete this.onCompletionResolveCb[e]}onHoverCb={};async getHover(e){let t=[];for(let n in this.onHoverCb)t.push(this.onHoverCb[n](this,e));let n=await Promise.all(t);for(let e of n)if(e)return e;return null}onHover(e){let t=k();for(;this.onHoverCb[t]!=null;)t=k();return this.onHoverCb[t]=e,t}removeOnHover(e){delete this.onHoverCb[e]}onDefinitionCb={};async getDefinition(e){let t=[];for(let n in this.onDefinitionCb)t.push(this.onDefinitionCb[n](this,e));let n=await Promise.all(t);for(let e of n)if(e)return e;return null}onDefinition(e){let t=k();for(;this.onDefinitionCb[t]!=null;)t=k();return this.onDefinitionCb[t]=e,t}removeOnDefinition(e){delete this.onDefinitionCb[e]}onFormattingCb={};async getFormatting(e){e||={insertSpaces:!0,tabSize:4};let t={},n=[],r={start:this.documentUser.positionAt(0),end:this.documentUser.positionAt(this.documentUser.getText().length)};for(let t in this.onFormattingCb)n.push(this.onFormattingCb[t](this,r,e));let i=await Promise.all(n);for(let e of i)for(let n of e){let e=JSON.stringify(n);t[e]||(t[e]=n)}return Object.values(t)}onFormatting(e){let t=k();for(;this.onFormattingCb[t]!=null;)t=k();return this.onFormattingCb[t]=e,t}removeOnFormatting(e){delete this.onFormattingCb[e]}onCodeActionCb={};async getCodeAction(e){let t=[],n=[];for(let t in this.onCodeActionCb)n.push(this.onCodeActionCb[t](this,e));let r=await Promise.all(n);for(let e of r)t=[...t,...e];return t}onCodeAction(e){let t=k();for(;this.onCodeActionCb[t]!=null;)t=k();return this.onCodeActionCb[t]=e,t}removeOnCodeAction(e){delete this.onCodeActionCb[e]}onReferencesCb={};async getReferences(e){let t=[],n=[];for(let t in this.onReferencesCb)n.push(this.onReferencesCb[t](this,e));let r=await Promise.all(n);for(let e of r)t=[...t,...e];return t}onReferences(e){let t=k();for(;this.onReferencesCb[t]!=null;)t=k();return this.onReferencesCb[t]=e,t}removeOnReferences(e){delete this.onReferencesCb[e]}onCodeLensCb={};async getCodeLens(){let e=[],t=[];for(let e in this.onCodeLensCb)t.push(this.onCodeLensCb[e](this));let n=await Promise.all(t);for(let t of n)e=[...e,...t];return e}onCodeLens(e){let t=k();for(;this.onCodeLensCb[t]!=null;)t=k();return this.onCodeLensCb[t]=e,t}removeOnCodeLens(e){delete this.onCodeLensCb[e]}onRenameCb={};async getRename(e,t){let n=[];for(let r in this.onRenameCb)n.push(this.onRenameCb[r](this,e,t));let r=await Promise.all(n);for(let e of r)if(e)return e;return null}onRename(e){let t=k();for(;this.onRenameCb[t]!=null;)t=k();return this.onRenameCb[t]=e,t}removeOnRename(e){delete this.onRenameCb[e]}},it=class e{static isInit=!1;static send(e){$.sendNotification(`aventus/initStep`,e)}static sendDone(){$.sendNotification(`aventus/initStep`,`Aventus : Done`),e.isInit=!0}},at=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}watcher;constructor(){T.getInstance().settings.watchFiles&&(this.watcher=(0,v.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=D(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=E(e);this.watcheUris.includes(t)&&R.getInstance().onUpdatedUri(t)}async onRemove(e){let t=E(e);this.watcheUris.includes(t)&&R.getInstance().onDeletedUri(t)}async destroy(){await this.watcher?.close(),e.instance=void 0}};const ot={$schema:`foo://aventus/conf.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{module:{type:`string`,pattern:`^[a-zA-Z0-9_]+$`,description:`Name of the exported module`},version:{type:`string`,pattern:`^[0-9]+.[0-9]+.[0-9]+$`,description:`Version for all your builds (x.x.x)`},description:{type:`string`,description:`Description of the package`},documentation:{type:`string`,description:`Documentation link for the package`},repository:{type:`string`,description:`Repository link for the package`},tags:{type:`array`,description:`Tags for the package`,items:{type:`string`}},organization:{type:`string`,description:`Name of the organization`,pattern:`^[a-zA-Z0-9_@]+$`},readme:{type:`string`,description:`Path to the readme. By default, Aventus check Readme in the same folder as the configuration`},hideWarnings:{type:`boolean`,description:`Hide warnings for all your builds`},componentPrefix:{type:`string`,description:`Identifier to prefix all your components (in lower case)`,pattern:`^[a-z-]{2,}$`},dependencies:{$ref:`#/$defs/dependencies`},namespaceStrategy:{type:`string`,enum:[`manual`,`followFolders`,`followFoldersCamelCase`,`rules`],description:`Stragety to generate namespace`,default:`manual`},namespaceRules:{type:`object`,description:`Rules to define namespace when namespaceStrategy is rules`},namespaceRoot:{type:`string`,description:`Root directory to define namespace when namespaceStrategy is followFolders`},build:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{name:{type:`string`,description:"Part name for the module. The export file will be ${module}@${name}",pattern:`^[a-zA-Z0-9_]+$`},description:{type:`string`,description:`Description of the package`},tags:{type:`array`,description:`Tags for the package`,items:{type:`string`}},documentation:{type:`string`,description:`Documentation link for the package`},repository:{type:`string`,description:`Repository link for the package`},organization:{type:`string`,description:`Name of the organization`,pattern:`^[a-zA-Z0-9_@]+$`},readme:{type:`string`,description:`Path to the readme. By default, Aventus check Readme in the same folder as the configuration`},version:{type:`string`,pattern:`^[0-9]+.[0-9]+.[0-9]+$`,description:`Version for this build (x.x.x)`},disabled:{type:`boolean`,description:`Disable auto-build`,default:!0},hideWarnings:{type:`boolean`,description:`Hide warnings for this build`},componentPrefix:{type:`string`,description:`Identifier to prefix all your components (in lower case)`,pattern:`^[a-z-]{2,}$`},src:{type:`array`,items:{type:`string`},description:`List of all pathes to listen watch`},stories:{type:`object`,additionalProperties:!1,properties:{output:{type:`string`,description:`Define where to export your stories`},workspace:{type:`string`,description:`Define where to add the .storybook`},live:{type:`boolean`,description:`Define if the story content must be recompiled on change`},format:{type:`string`,enum:[`all`,`public`,`protected`,`manual`],default:`all`,description:`All will export all elements, public only public elements, protected only public and protected elements, manual only elements with tag Storybook`},prefix:{type:`string`,description:`Define a prefix for all your stories name. Allow to group stories`},srcBaseUrl:{type:`string`,description:`Define a base url to link file to your repo`}}},outsideModule:{type:`array`,items:{type:`string`},description:`List of all pathes to import outside the module`},compile:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{input:{type:[`string`,`array`],items:{type:`string`},description:`List of all pathes to import inside this build`},output:{type:[`string`,`array`,`object`],description:`The script file generated path`,pattern:`^\\S+\\.js`,items:{type:[`string`,`object`],pattern:`^\\S+\\.js`,properties:{"@default":{$ref:`#/$defs/compileOutput`},"@npm":{$ref:`#/$defs/compileOutput`}},patternProperties:{"^\\S+$":{$ref:`#/$defs/compileOutput`}},required:[`@default`]},properties:{"@default":{$ref:`#/$defs/compileOutput`},"@npm":{$ref:`#/$defs/compileOutput`}},patternProperties:{"^\\S+$":{$ref:`#/$defs/compileOutput`}},required:[`@default`]},outputNpm:{type:[`string`,`array`,`object`],additionalProperties:!1,properties:{path:{type:[`string`,`array`]},packageJson:{type:`boolean`,description:`Define if you need to generate a package.json`},npmName:{type:`string`,description:`Define the name set inside your package.json`},manifest:{type:`boolean`,description:`Define if you need to generate manifest for your components`},live:{type:`boolean`,description:`Define if the npm content must be recompiled on change. Default is false`}},items:{type:`string`},description:`Define where to export as npm files`},compressed:{type:`boolean`},package:{type:[`string`,`array`],items:{type:`string`,pattern:`^\\S+\\.package\\.avt`},pattern:`^\\S+\\.package\\.avt`,description:`The package file generated path (for lib)`},i18n:{type:[`string`,`array`],items:{type:`object`,additionalProperties:!1,properties:{output:{type:[`string`,`array`],items:{type:`string`}},mount:{type:`string`},mode:{type:`string`,enum:[`singleFile`,`oneToOne`,`groupComponent`,`basedOnAttribute`,`include`],default:`singleFile`}},required:[`output`]}}}}},dependencies:{$ref:`#/$defs/dependencies`},module:{type:`string`,pattern:`^[a-zA-Z0-9_]+$`,description:`Name of the exported module for this build`},namespaceStrategy:{type:`string`,enum:[`manual`,`followFolders`,`followFoldersCamelCase`,`rules`],description:`Stragety to generate namespace`,default:`manual`},namespaceRules:{type:`object`,description:`Rules to define namespace when namespaceStrategy is rules`},namespaceRoot:{type:`string`,description:`Root directory to define namespace when namespaceStrategy is followFolders`},avoidParsingInsideTags:{type:`array`,items:{type:`string`,pattern:`^[a-z-]+$`},description:`List of html tag that mustn't be parsed by the html compiler`},nodeModulesDir:{type:[`string`,`array`],items:{type:`string`},description:`The dirs where node_modules are located`},i18n:{type:`object`,properties:{locales:{type:`array`,items:{type:`string`},description:`Locales that is required inside your project`},fallback:{type:`string`},autoRegister:{type:`boolean`}},description:`Define options for i18n`}},required:[`src`]},minItems:1},static:{type:`array`,items:{type:`object`,additionalProperties:!1,properties:{name:{type:`string`,description:`Part name for the static export`,pattern:`^[a-zA-Z0-9_]+$`},input:{type:`string`,description:`Input path to watch to export as static files`},output:{type:[`string`,`array`],items:{type:`string`},description:`Define where to export static files`}},required:[`name`,`input`,`output`]}},avoidParsingInsideTags:{type:`array`,items:{type:`string`,pattern:`^[a-z-]+$`},description:`List of html tag that mustn't be parsed by the html compiler`},aliases:{type:`object`}},required:[`build`,`module`],$defs:{dependencies:{type:`object`,description:`List of dependencies for this build`,patternProperties:{"^\\S+$":{type:[`object`,`string`],additionalProperties:!1,pattern:`^[0-9x]+.[0-9x]+.[0-9x]+$`,properties:{uri:{type:`string`,description:`Where to find the package or the json file`},npm:{type:`string`,description:`The npm package name`},version:{type:`string`,pattern:`^[0-9x]+.[0-9x]+.[0-9x]+$`,description:`The version to use for this file. (default is x.x.x)`,default:`x.x.x`},isLocal:{type:`boolean`,description:`Define if you want to use a local package`},include:{type:`string`,description:`Determine if the package must be included inside the final export. (default is need)`,enum:[`none`,`need`,`full`],default:`need`},subDependenciesInclude:{type:`object`,description:`Inclusion pattern for each lib. You can use a star to select everythink. If nothink find for a lib, the need value ll be used`,patternProperties:{"^\\S+$":{type:`string`,enum:[`none`,`need`,`full`],default:`need`}}}}}}},compileOutput:{type:[`string`,`object`],pattern:`^\\S+\\.js`,additionalProperties:!1,properties:{path:{type:`string`,pattern:`^\\S+\\.js`},compressed:{type:`boolean`}}}}},st={$schema:`foo://aventus/sharp.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{csProj:{type:`string`,pattern:`^\\S+\\.csproj`,description:`Path to your csproj file`},outputPath:{type:`string`,description:`Define the folder where to export the code`},exportEnumByDefault:{type:`boolean`,default:!1,description:`Define if enums must be exported. You can override behaviour with [Export] or [NoExport]`},exportStorableByDefault:{type:`boolean`,default:!0,description:`Define if storable must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRouteByDefault:{type:`boolean`,default:!0,description:`Define if http route must be exported. You can override behaviour with [Export] or [NoExport]`},exportErrorsByDefault:{type:`boolean`,default:!0,description:`Define if errors must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsEndPointByDefault:{type:`boolean`,default:!0,description:`Define if websocket endpoint must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsEventByDefault:{type:`boolean`,default:!0,description:`Define if websocket event must be exported. You can override behaviour with [Export] or [NoExport]`},exportWsRouteByDefault:{type:`boolean`,default:!0,description:`Define if websocket route must be exported. You can override behaviour with [Export] or [NoExport]`},replacer:{type:`object`,additionalProperties:!1,description:`Create replacer to export type`,properties:{all:{$ref:`#/$defs/replacerPart`},genericError:{$ref:`#/$defs/replacerPart`},httpRouter:{$ref:`#/$defs/replacerPart`},normalClass:{$ref:`#/$defs/replacerPart`},storable:{$ref:`#/$defs/replacerPart`},withError:{$ref:`#/$defs/replacerPart`},wsEndPoint:{$ref:`#/$defs/replacerPart`},wsEvent:{$ref:`#/$defs/replacerPart`},wsRouter:{$ref:`#/$defs/replacerPart`}}},httpRouter:{type:`object`,additionalProperties:!1,properties:{useCompiledDll:{type:`boolean`,default:!0,description:"Try to parse route by running the app. You must use `app.UseAventusExport()` to prevent real starting."},createRouter:{type:`boolean`,default:!0,description:`Create a router that your route will use`},routerName:{type:`string`,default:`GeneratedRouter`,description:`The name of the router to generate`},uri:{type:`string`,default:``,pattern:`^(?=s*$)|^(\\/[a-zA-Z0-9_-]+?){1,}$`,description:`Define the base uri for your router (ex: /api)`},host:{type:`string`,default:`https://localhost:5000`,description:`Define the host that the router will use`},parent:{type:`string`,default:`Aventus.HttpRouter`,description:`Define the parent type to use for your router`},parentFile:{type:`string`,default:``,description:`Define the parent file to use for your router`},namespace:{type:`string`,default:`Routes`,description:`Define the namespace for your router`},addFormData:{type:`boolean`,default:!0,description:"Add ` | FormData` to the route body"},cacheByDefault:{type:`boolean`,default:!1,description:`Add cache to the function generated`},clearCacheFct:{type:`boolean`,default:!1,description:`Add function to clear cache to the function generated`}}},wsEndpoint:{type:`object`,additionalProperties:!1,properties:{useCompiledDll:{type:`boolean`,default:!0,description:"Try to parse route by running the app. You must use `app.UseAventusExport()` to prevent real starting."},prefix:{type:`string`,default:`Define a prefix for your websocket events`},host:{type:`string`,description:`The host to connect to the websocket`},port:{type:`number`,description:`The port to connect to the websocket`},useHttps:{type:`boolean`,description:`Define if you want to use http or https. Be default, Aventus will check if your connection is secure to use https or not`},parent:{type:`string`,default:`AventusSharp.WebSocket.EndPoint`,description:`Define the parent type to use for your router`}}}},required:[`csProj`,`outputPath`],$defs:{replacerPart:{type:`object`,additionalProperties:!1,properties:{type:{type:`object`,description:`Apply a replacer based on the c# type`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}},result:{type:`object`,description:`Apply a replacer based on the result type (ex: to replace Aventus.IData when IStorable is exported)`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}}}}}},ct={$schema:`foo://aventus/php.json`,title:`JSON Schema for Aventus`,description:`JSON Schema for Aventus`,type:`object`,additionalProperties:!1,properties:{output:{type:`string`,description:`Define the folder where to export the code`},exportAsTs:{type:`boolean`,description:`Define if the code must be compiled as typescript`},useNamespace:{type:`boolean`,description:`Define if the compiler must used namespace`},exportEnumByDefault:{type:`boolean`,default:!1,description:`Define if enums must be exported. You can override behaviour with [Export] or [NoExport]`},exportStorableByDefault:{type:`boolean`,default:!0,description:`Define if storable must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRouteByDefault:{type:`boolean`,default:!0,description:`Define if http route must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpRequestByDefault:{type:`boolean`,default:!0,description:`Define if request must be exported. You can override behaviour with [Export] or [NoExport]`},exportHttpResourceByDefault:{type:`boolean`,default:!0,description:`Define if resource must be exported. You can override behaviour with [Export] or [NoExport]`},exportErrorsByDefault:{type:`boolean`,default:!0,description:`Define if erros must be exported. You can override behaviour with [Export] or [NoExport]`},replacer:{type:`object`,additionalProperties:!1,description:`Create replacer to export type`,properties:{all:{$ref:`#/$defs/replacerPart`},genericError:{$ref:`#/$defs/replacerPart`},httpRouter:{$ref:`#/$defs/replacerPart`},normalClass:{$ref:`#/$defs/replacerPart`},storable:{$ref:`#/$defs/replacerPart`},withError:{$ref:`#/$defs/replacerPart`},httpRequest:{$ref:`#/$defs/replacerPart`},httpResource:{$ref:`#/$defs/replacerPart`}}},httpRouter:{type:`object`,additionalProperties:!1,properties:{createRouter:{type:`boolean`,default:!0,description:`Create a router that your route will use`},routerName:{type:`string`,default:`GeneratedRouter`,description:`The name of the router to generate`},uri:{type:`string`,default:``,pattern:`^(?=s*$)|^(\\/[a-zA-Z0-9_-]+?){1,}$`,description:`Define the base uri for your router (ex: /api)`},host:{type:`string`,default:`https://localhost:5000`,pattern:`^http(s)?:\\/\\/[a-zA-Z0-9_-]*?(:[0-9]{3,4})?$`,description:`Define the host that the router will use`},parent:{type:`string`,default:`Aventus.HttpRouter`,description:`Define the parent type to use for your router`},parentFile:{type:`string`,default:``,description:`Define the parent file to load for your router`},namespace:{type:`string`,default:`Routes`,description:`Define the namespace for your router`}}}},required:[`output`],$defs:{replacerPart:{type:`object`,additionalProperties:!1,properties:{type:{type:`object`,description:`Apply a replacer based on the c# type`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}},result:{type:`object`,description:`Apply a replacer based on the result type (ex: to replace Aventus.IData when IStorable is exported)`,patternProperties:{"^\\S+$":{type:`object`,additionalProperties:!1,properties:{result:{type:`string`},file:{type:`string`},useTypeImport:{type:`boolean`}},required:[`result`]}}}}}}};var lt=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}languageService;constructor(){this.languageService=(0,y.getLanguageService)({schemaRequestService:async e=>JSON.stringify(ot)}),this.languageService.configure({allowComments:!0,schemas:[{fileMatch:[`**`+w.Config],uri:ot.$schema??``,schema:ot},{fileMatch:[`**`+w.CsharpConfig],uri:st.$schema??``,schema:st},{fileMatch:[`**`+w.PhpConfig],uri:ct.$schema??``,schema:ct}]})}async format(e,t,n){let r=e.documentUser;return await this.languageService.format(r,t,n)}async doComplete(e,t){let n=e.documentUser,r=this.languageService.parseJSONDocument(n),i=await this.languageService.doComplete(e.documentUser,t,r),a=r.getNodeFromOffset(n.offsetAt(t));return this.isKeyOfObject(a,`dependencies`)&&(i||={isIncomplete:!1,items:[]},i?.items.push({label:`Aventus@Main`},{label:`Aventus@UI`},{label:`Aventus@I18n`},{label:`Aventus@Sharp`},{label:`Aventus@Php`})),i||{isIncomplete:!1,items:[]}}async doResolve(e){return await this.languageService.doResolve(e)}async doHover(e,t){let n=e.documentUser,r=this.languageService.parseJSONDocument(n);return await this.languageService.doHover(n,t,r)}async validate(e){let t=e.documentUser,n=this.languageService.parseJSONDocument(t),r=await this.languageService.doValidation(t,n);if(r.length==0){let e=this.removeComments(t.getText());try{return JSON.parse(e),r}catch{r.push(je(t,`Can't parse the json`,1001))}}for(let e of r)e.severity=m.DiagnosticSeverity.Error;return r}isKeyOfObject(e,t){let n=e?.parent;if(n?.type==`property`&&n.keyNode==e){let n=e?.parent?.parent?.parent;if(n?.type==`property`&&n.keyNode.value==t)return!0}return!1}isValueOfObject(e,t){let n=e?.parent;if(n?.type==`property`&&n.valueNode==e){let n=e?.parent?.parent?.parent;if(n?.type==`property`&&n.keyNode.value==t)return!0}return!1}async getConfig(e){let t=`documentUser`in e?e.documentUser:e,n=this.languageService.parseJSONDocument(t),r=await this.languageService.doValidation(t,n,void 0,ot);if(r.length==0){let e=this.removeComments(t.getText());try{let n=JSON.parse(e);return n=this.prepareConfigFile(t.uri,n),n}catch{r.push(je(t,`Can't parse the json`,1001))}}return null}prepareConfigFile(e,t){if(t={...this.defaultConfigValue(),...t},t.componentPrefix==``){let e=t.module.match(/([A-Z][a-z]*)|([0-9][a-z]*)/g);e?t.componentPrefix=e.join(`-`).toLowerCase():t.componentPrefix=`av`}let n=[];for(let r of t.build)n.push(this.prepareBuild(e,r,t));if(t.build=n,t.static){let n=[];for(let r of t.static)n.push(this.prepareStatic(e,r));t.static=n}return t}replaceEnvVar(e,t){if(!e||e.startsWith(`@`)||e.startsWith(`Aventus@`))return e;let n=/%(.*?)%/gm,r;for(;r=n.exec(e);){let t=b.env[r[1]]??`undefined`;e=e.replace(r[0],t)}return/^https?:\/\/.*/.exec(e)||(!e.startsWith(`/`)&&!/^[a-zA-Z]:/gm.test(e)?(e=`/`+e,e=(0,f.normalize)(D(t)+e)):e=(0,f.normalize)(e)),e}prepareBuild(e,t,n){let r=ze(e);t={...this.defaultConfigBuildValue(n),...t},t.name?t.fullname=t.module+`@`+t.name:t.fullname=t.module;let i=e=>this.replaceEnvVar(e,r),a=t.compile;for(let e of a){if(!e.input)e.inputPathRegex=RegExp(`.*`);else{Array.isArray(e.input)||(e.input=[e.input]);let t=[];for(let n of e.input){let e=``;n=n.replace(/\\/g,`/`),n.startsWith(`/`)||(e=`/`);let i=n.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),n=i.join(`/`);let a=(0,f.normalize)(D(r)+e+n).replace(/\\/g,`/`);a=He(a,!0).replace(`*`,`.*`),t.push(`(^`+a+`$)`)}let n=t.join(`|`);n==``&&(n=`(?!)`),e.inputPathRegex=new RegExp(n)}if(!e.output)e.output=[];else{Array.isArray(e.output)||(e.output=[e.output]);for(let t=0;t<e.output.length;t++){let n=e.output[t];typeof n==`string`&&(e.output[t]={"@default":{path:n}},n=e.output[t]);let r=!1;for(let a in n){a==`@default`&&(r=!0);let o=n[a];typeof o==`string`&&(e.output[t][a]={path:o}),e.output[t][a].path=n[a].path.trim(),n[a].path.length>0&&(e.output[t][a].path=i(n[a].path))}r||(e.output[t][`@default`]={path:`./dist/script.js`})}}if(!e.outputNpm)e.outputNpm={path:[],packageJson:!1,npmName:``,live:!1};else{typeof e.outputNpm==`string`?e.outputNpm={path:[e.outputNpm],packageJson:!0,npmName:``,manifest:{},live:!1}:Array.isArray(e.outputNpm)&&(e.outputNpm={path:e.outputNpm,packageJson:!0,npmName:``,manifest:{},live:!1}),Array.isArray(e.outputNpm.path)||(e.outputNpm.path=[e.outputNpm.path]),e.outputNpm.packageJson===void 0&&(e.outputNpm.packageJson=!0),e.outputNpm.manifest===void 0&&(e.outputNpm.manifest={}),e.outputNpm.npmName===void 0&&(e.outputNpm.npmName=``),e.outputNpm.live===void 0&&(e.outputNpm.live=!1);for(let t=0;t<e.outputNpm.path.length;t++){let n=i(e.outputNpm.path[t]);n.endsWith(`*`)&&(n=n.slice(0,-1)),n.endsWith(`/`)&&(n=n.slice(0,-1)),n=n.replace(/\\/g,`/`),e.outputNpm.path[t]=n}}if(!e.package)e.package=[];else{Array.isArray(e.package)||(e.package=[e.package]);for(let t=0;t<e.package.length;t++)e.package[t]=e.package[t].trim(),e.package[t].length>0&&(e.package[t]=i(e.package[t]))}if(t.i18n)if(e.i18n){Array.isArray(e.i18n)||(e.i18n=[{output:[e.i18n],mount:``,mode:`singleFile`}]);for(let t=0;t<e.i18n.length;t++){if(!Array.isArray(e.i18n[t].output)){let n=e.i18n[t].output;e.i18n[t].output=[n]}for(let n=0;n<e.i18n[t].output.length;n++)e.i18n[t].output[n].endsWith(`/`)&&(e.i18n[t].output[n]=e.i18n[t].output[n].slice(0,-1)),e.i18n[t].output[n]=e.i18n[t].output[n].trim(),e.i18n[t].output[n].length>0&&(e.i18n[t].output[n]=i(e.i18n[t].output[n]));if(!e.i18n[t].mount&&e.i18n[t].output.length>0){let n=(0,f.normalize)(D($.getWorkspaceUri())),r=e.i18n[t].output[0].replace(n,``).replace(/\\/g,`/`);r.startsWith(`/dist`)&&(r=r.replace(`/dist`,``)),e.i18n[t].mount=r}e.i18n[t].mount.endsWith(`/`)&&(e.i18n[t].mount=e.i18n[t].mount.slice(0,-1))}}else{e.i18n=[];for(let t of e.output){let n=t[`@default`].path.split(f.sep);n.pop();let r=(0,f.join)(n.join(f.sep),`locales`),i=(0,f.normalize)(D($.getWorkspaceUri())),a=r.replace(i,``).replace(/\\/g,`/`);a.startsWith(`/dist`)&&(a=a.replace(`/dist`,``)),e.i18n.push({output:[r],mount:a,mode:`singleFile`})}}}let o=[];for(let e of t.src){let n=``;e=e.replace(/\\/g,`/`),e.startsWith(`/`)||(n=`/`);let i=e.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),e=i.join(`/`);let a=(0,f.normalize)(D(r)+n+e).replace(/\\/g,`/`),s=a.replace(`*`,``);s.endsWith(`/`)&&(s=s.slice(0,-1)),t.srcPath.push(s),a=He(a,!0).replace(`*`,`.*`),o.push(`(^`+a+`$)`)}if(t.stories){t.stories={...this.defaultConfigBuildStories(r,n),...t.stories};let e=i(t.stories.output);e.endsWith(`*`)&&(e=e.slice(0,-1)),e.endsWith(`/`)&&(e=e.slice(0,-1)),e=e.replace(/\\/g,`/`),t.stories.output=e}let s=o.join(`|`);s==``&&(s=`(?!)`),t.srcPathRegex=new RegExp(s),t.nodeModulesDir=t.nodeModulesDir.trim(),t.nodeModulesDir==``?t.nodeModulesDir=(0,f.normalize)(D(r)+`/node_modules`):t.nodeModulesDir=i(t.nodeModulesDir);let c={};t.rawDependencies=JSON.parse(JSON.stringify(t.dependencies));for(let e in t.dependencies){let n=t.dependencies[e];typeof n==`string`&&(n={version:n}),c[e]={...this.defaultConfigBuildDependencyValue(n),...n};let r=c[e];r.subDependenciesInclude||={},r.subDependenciesInclude[`*`]||(r.subDependenciesInclude[`*`]=n.include??`need`),r.uri&&=i(r.uri)}if(t.dependencies=c,t.outsideModule){let e=[];for(let n of t.outsideModule){let t=``;n=n.replace(/\\/g,`/`),n.startsWith(`/`)||(t=`/`);let i=n.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),n=i.join(`/`);let a=(0,f.normalize)(D(r)+t+n).replace(/\\/g,`/`);a=He(a,!0).replace(`*`,`.*`),e.push(`(^`+a+`$)`)}let n=e.join(`|`);n==``&&(n=`(?!)`),t.outsideModulePathRegex=new RegExp(n)}if(t.namespaceStrategy==`rules`)for(let e in t.namespaceRules){let n=[],i=t.namespaceRules[e];for(let e of i){let t=``;e=e.replace(/\\/g,`/`),e.startsWith(`/`)||(t=`/`);let i=e.split(`/`);i[i.length-1]==``||i[i.length-1]==`*`?i[i.length-1]=`*`:i[i.length-1].indexOf(`.`)==-1&&i.push(`*`),e=i.join(`/`);let a=(0,f.normalize)(D(r)+t+e).replace(/\\/g,`/`);a=He(a,!0).replace(`*`,`.*`),n.push(`(^`+a+`$)`)}let a=n.join(`|`);a==``&&(a=`(?!)`),t.namespaceRulesRegex[e]=new RegExp(a)}else if(t.namespaceStrategy==`followFolders`||t.namespaceStrategy==`followFoldersCamelCase`){let e=``;t.namespaceRoot.startsWith(`/`)||(e=`/`),t.namespaceRoot=(0,f.normalize)(D(r)+e+t.namespaceRoot).replace(/\\/g,`/`)}return t.i18n,t}prepareStatic(e,t){let n=ze(e),r=``;t.input.startsWith(`/`)||(r=`/`),t.input.endsWith(`*`)&&(t.input=t.input.slice(0,-1)),t.input.endsWith(`/`)&&(t.input=t.input.slice(0,-1)),t.inputPathFolder=(0,f.normalize)(D(n)+r+t.input),t.inputPathFolder=t.inputPathFolder.replace(/\\/g,`/`),r=``,Array.isArray(t.output)||(t.output=[t.output]),t.outputPathFolder=[];for(let e of t.output)e=this.replaceEnvVar(e,n),e.endsWith(`*`)&&(e=e.slice(0,-1)),e.endsWith(`/`)&&(e=e.slice(0,-1)),e=e.replace(/\\/g,`/`),t.outputPathFolder.push(e);return t}defaultConfigValue(){return{module:``,hideWarnings:T.getInstance().settings.defaultHideWarnings,version:`1.0.0`,componentPrefix:``,tags:[],dependencies:{},build:[],static:[],avoidParsingInsideTags:[],aliases:{},namespaceRules:{},namespaceRulesRegex:{},namespaceStrategy:`manual`,namespaceRoot:`./`}}defaultConfigBuildValue(e){return{fullname:``,name:``,tags:e.tags,version:e.version,organization:e.organization,description:e.description,readme:e.readme,repository:e.repository,documentation:e.documentation,disabled:!1,hideWarnings:e.hideWarnings,src:[],srcPath:[],stories:void 0,compile:[],srcPathRegex:RegExp(`(?!)`),outsideModule:[],outsideModulePathRegex:RegExp(`(?!)`),module:e.module,componentPrefix:e.componentPrefix,namespaceStrategy:e.namespaceStrategy,namespaceRules:{...e.namespaceRules},namespaceRulesRegex:{...e.namespaceRulesRegex},namespaceRoot:e.namespaceRoot,dependencies:{...e.dependencies},rawDependencies:{},avoidParsingInsideTags:[...e.avoidParsingInsideTags],nodeModulesDir:``}}defaultConfigBuildStories(e,t){return{output:e+`/stories`,format:`all`}}defaultConfigBuildDependencyValue(e){return{}}removeComments(e){return e=e.replace(/(\".*?\"|\'.*?\')|(\/\*.*?\*\/|\/\/[^(\r\n|\n)]*$)/gm,(e,t,n)=>{if(n){let e=``;for(let t=0;t<n.length;t++)e+=` `;return e}return t}),e}},ut=class{_file;_build;get file(){return this._file}get build(){if(this._build)return this._build;throw`No build found`}constructor(e,t){this._file=e,this._build=t,this.addEvents()}uuidEvents={onCanContentChange:``,onContentChange:``,onValidate:``,onSave:``,onDelete:``,onCompletion:``,onCompletionResolve:``,onHover:``,onDefinition:``,onFormatting:``,onCodeAction:``,onReferences:``,onCodeLens:``,onGetBuild:``,onRename:``};addEvents(){this.uuidEvents.onCanContentChange=this.file.onCanContentChange(this.onCanContentChange.bind(this)),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.onGetBuild=this.file.onGetBuild(this.onGetBuild.bind(this)),this.uuidEvents.onRename=this.file.onRename(this.onRename.bind(this))}removeEvents(){this.file.removeOnCanContentChange(this.uuidEvents.onCanContentChange),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.removeOnGetBuild(this.uuidEvents.onGetBuild),this.file.removeOnRename(this.uuidEvents.onRename)}async validate(){this.file instanceof A&&await this.file.validate()}async triggerSave(){this.file instanceof A&&await this.file.triggerSave()}async triggerDelete(){this.file instanceof A&&await this.file.triggerDelete()}async triggerContentChange(e){this.file instanceof A&&await this.file.triggerContentChange(e)}onCanContentChange(e){return this._file.versionUser!=e.version}oldResult=[];async _onValidate(){let e=this._build?.diagnostics.get(this)??[];return e=[...e,...await this.onValidate()],this._build&&this.build.hideWarnings&&(e=e.filter(e=>e.severity!=m.DiagnosticSeverity.Warning)),this.oldResult=e,e}async _onDelete(){await this.onDelete(),this.removeEvents()}},dt=o(((e,t)=>{var n=require("stream");e=t.exports=r,r.through=r;function r(e,t,r){e||=function(e){this.queue(e)},t||=function(){this.queue(null)};var i=!1,a=!1,o=[],s=!1,c=new n;c.readable=c.writable=!0,c.paused=!1,c.autoDestroy=!(r&&r.autoDestroy===!1),c.write=function(t){return e.call(this,t),!c.paused};function l(){for(;o.length&&!c.paused;){var e=o.shift();if(e===null)return c.emit(`end`);c.emit(`data`,e)}}c.queue=c.push=function(e){return s?c:(e===null&&(s=!0),o.push(e),l(),c)},c.on(`end`,function(){c.readable=!1,!c.writable&&c.autoDestroy&&process.nextTick(function(){c.destroy()})});function u(){c.writable=!1,t.call(c),!c.readable&&c.autoDestroy&&c.destroy()}return c.end=function(e){if(!i)return i=!0,arguments.length&&c.write(e),u(),c},c.destroy=function(){if(!a)return a=!0,i=!0,o.length=0,c.writable=c.readable=!1,c.emit(`close`),c},c.pause=function(){if(!c.paused)return c.paused=!0,c},c.resume=function(){return c.paused&&(c.paused=!1,c.emit(`resume`)),l(),c.paused||c.emit(`drain`),c},c}})),ft=o(((e,t)=>{var n=require("stream");t.exports=function e(t){if(Array.isArray(t)){var r=0,i=t.length;return e(function(e){return r<i?this.emit(`data`,t[r++]):this.emit(`end`),!0})}var a=new n,o=0;a.ended=!1,a.started=!1,a.readable=!0,a.writable=!1,a.paused=!1,a.ended=!1,a.pause=function(){a.started=!0,a.paused=!0};function s(){if(a.started=!0,!a.ended)for(;!a.ended&&!a.paused&&t.call(a,o++,function(){!a.ended&&!a.paused&&process.nextTick(s)}););}return a.resume=function(){a.started=!0,a.paused=!1,s()},a.on(`end`,function(){a.ended=!0,a.readable=!1,process.nextTick(a.destroy)}),a.destroy=function(){a.ended=!0,a.emit(`close`)},process.nextTick(function(){a.started||a.resume()}),a}})),pt=o(((e,t)=>{var n=require("stream"),r=[`write`,`end`,`destroy`],i=[`resume`,`pause`],a=[`data`,`close`],o=Array.prototype.slice;t.exports=c;function s(e,t){if(e.forEach)return e.forEach(t);for(var n=0;n<e.length;n++)t(e[n],n)}function c(e,t){var c=new n,l=!1;return s(r,u),s(i,d),s(a,f),t.on(`end`,p),e.on(`drain`,function(){c.emit(`drain`)}),e.on(`error`,m),t.on(`error`,m),c.writable=e.writable,c.readable=t.readable,c;function u(t){c[t]=n;function n(){return e[t].apply(e,arguments)}}function d(e){c[e]=n;function n(){c.emit(e);var n=t[e];if(n)return n.apply(t,arguments);t.emit(e)}}function f(e){t.on(e,n);function n(){var t=o.call(arguments);t.unshift(e),c.emit.apply(c,t)}}function p(){if(!l){l=!0;var e=o.call(arguments);e.unshift(`end`),c.emit.apply(c,e)}}function m(e){c.emit(`error`,e)}}})),mt=o(((e,t)=>{var n=require("stream").Stream;t.exports=function(e,t){var r=new n,i=0,a=0,o=!1,s=!1,c=!1,l=0,u=!1;t||={};var d=t.failures?`failure`:`error`,f={};r.writable=!0,r.readable=!0;function p(e,t){var n=l+1;if(t===n?(e!==void 0&&r.emit.apply(r,[`data`,e]),l++,n++):f[t]=e,f.hasOwnProperty(n)){var c=f[n];return delete f[n],p(c,n)}a++,i===a&&(s&&(s=!1,r.emit(`drain`)),o&&g())}function m(e,n,i){c||(u=!0,(!e||t.failures)&&p(n,i),e&&r.emit.apply(r,[d,e]),u=!1)}function h(t,n,r){return e.call(null,t,function(e,t){r(e,t,n)})}r.write=function(e){if(o)throw Error(`map stream is not writable`);u=!1,i++;try{return s=h(e,i,m)===!1,!s}catch(e){if(u)throw e;return m(e),!s}};function g(e){if(o=!0,r.writable=!1,e!==void 0)return p(e,i);i==a&&(r.readable=!1,r.emit(`end`),r.destroy())}return r.end=function(e){o||g(e)},r.destroy=function(){o=c=!0,r.writable=r.readable=s=!1,process.nextTick(function(){r.emit(`close`)})},r.pause=function(){s=!0},r.resume=function(){s=!1},r}})),ht=o(((e,t)=>{t.exports=dt()})),gt=o(((e,t)=>{var n=dt(),r=require("string_decoder").StringDecoder;t.exports=i;function i(e,t,i){var a=new r,o=``,s=i&&i.maxLength,c=!(i&&i.trailing===!1);typeof e==`function`&&(t=e,e=null),e||=/\r?\n/;function l(e,n){if(t){try{n=t(n)}catch(t){return e.emit(`error`,t)}n!==void 0&&e.queue(n)}else e.queue(n)}function u(t,n){var r=((o??``)+n).split(e);if(o=r.pop(),s&&o.length>s)return t.emit(`error`,Error(`maximum buffer reached`));for(var i=0;i<r.length;i++){var a=r[i];l(t,a)}}return n(function(e){u(this,a.write(e))},function(){a.end&&u(this,a.end()),c&&o!=null&&l(this,o),this.queue(null)})}})),_t=o(((e,t)=>{var n=pt(),r=dt();t.exports=function(){var e=arguments.length==1&&Array.isArray(arguments[0])?arguments[0]:[].slice.call(arguments);if(e.length==0)return r();if(e.length==1)return e[0];var t=e[0],i=e[e.length-1],a=n(t,i);function o(e){e.length<2||(e[0].pipe(e[1]),o(e.slice(1)))}o(e);function s(){var e=[].slice.call(arguments);e.unshift(`error`),a.emit.apply(a,e)}for(var c=1;c<e.length-1;c++)e[c].on(`error`,s);return a}})),vt=o((e=>{var t=require("stream").Stream,n=e,r=dt(),i=ft(),a=pt(),o=mt(),s=ht(),c=gt(),l=_t(),u=global.setImmediate||process.nextTick;n.Stream=t,n.through=r,n.from=i,n.duplex=a,n.map=o,n.pause=s,n.split=c,n.pipeline=n.connect=n.pipe=l,n.concat=n.merge=function(){var e=[].slice.call(arguments);e.length===1&&e[0]instanceof Array&&(e=e[0]);var n=new t;n.setMaxListeners(0);var r=0;return n.writable=n.readable=!0,e.length?e.forEach(function(t){t.pipe(n,{end:!1});var i=!1;t.on(`end`,function(){i||(i=!0,r++,r==e.length&&n.emit(`end`))})}):process.nextTick(function(){n.emit(`end`)}),n.write=function(e){this.emit(`data`,e)},n.destroy=function(){e.forEach(function(e){e.destroy&&e.destroy()})},n},n.collect=n.writeArray=function(e){if(typeof e!=`function`)throw Error(`function writeArray (done): done must be function`);var n=new t,r=[],i=!1;return n.write=function(e){r.push(e)},n.end=function(){i=!0,e(null,r)},n.writable=!0,n.readable=!1,n.destroy=function(){n.writable=n.readable=!1,!i&&e(Error(`destroyed before end`),r)},n},n.readArray=function(e){var n=new t,r=0,i=!1,a=!1;if(n.readable=!0,n.writable=!1,!Array.isArray(e))throw Error(`event-stream.read expects an array`);return n.resume=function(){if(!a){i=!1;for(var t=e.length;r<t&&!i&&!a;)n.emit(`data`,e[r++]);r==t&&!a&&(a=!0,n.readable=!1,n.emit(`end`))}},process.nextTick(n.resume),n.pause=function(){i=!0},n.destroy=function(){a=!0,n.emit(`close`)},n},n.readable=function(e,n){var r=new t,i=0,a=!1,o=!1,s=!1;if(r.readable=!0,r.writable=!1,typeof e!=`function`)throw Error(`event-stream.readable expects async function`);r.on(`end`,function(){o=!0});function c(t,l){t?(r.emit(`error`,t),n||r.emit(`end`)):arguments.length>1&&r.emit(`data`,l),u(function(){if(!(o||a||s))try{s=!0,e.call(r,i++,function(){s=!1,c.apply(null,arguments)})}catch(e){r.emit(`error`,e)}})}return r.resume=function(){a=!1,c()},process.nextTick(c),r.pause=function(){a=!0},r.destroy=function(){r.emit(`end`),r.emit(`close`),o=!0},r},n.mapSync=function(e){return n.through(function(t){var n;try{n=e(t)}catch(e){return this.emit(`error`,e)}n!==void 0&&this.emit(`data`,n)})},n.filterSync=function(e){return n.through(function(t){var n=this;e(t)&&n.queue(t)})},n.flatmapSync=function(e){return n.through(function(t){var n=this;t.forEach(function(t){n.queue(e(t))})})},n.log=function(e){return n.through(function(t){[].slice.call(arguments),e?console.error(e,t):console.error(t),this.emit(`data`,t)})},n.child=function(e){return n.duplex(e.stdin,e.stdout)},n.parse=function(e){var t=!!(e&&e.error);return n.through(function(e){var n;try{e&&(n=JSON.parse(e.toString()))}catch(n){return t?this.emit(`error`,n):console.error(n,`attempting to parse:`,e)}n!==void 0&&this.emit(`data`,n)})},n.stringify=function(){var e=require("buffer").Buffer;return n.mapSync(function(t){return JSON.stringify(e.isBuffer(t)?t.toString():t)+`
|
|
9
|
+
`})},n.replace=function(e,t){return n.pipeline(n.split(e),n.join(t))},n.join=function(e){if(typeof e==`function`)return n.wait(e);var t=!0;return n.through(function(n){return t||this.emit(`data`,e),t=!1,this.emit(`data`,n),!0})},n.wait=function(e){var t=[];return n.through(function(e){t.push(e)},function(){var n=Buffer.isBuffer(t[0])?Buffer.concat(t):t.join(``);this.emit(`data`,n),this.emit(`end`),e&&e(null,n)})},n.pipeable=function(){throw Error(`[EVENT-STREAM] es.pipeable is deprecated`)}}))();const yt=`<script type="text/javascript">
|
|
10
10
|
if ('WebSocket' in window) {
|
|
11
11
|
(function () {
|
|
12
12
|
|
|
@@ -129,9 +129,9 @@ if ('WebSocket' in window) {
|
|
|
129
129
|
//onclose
|
|
130
130
|
})();
|
|
131
131
|
}
|
|
132
|
-
<\/script>`;var
|
|
133
|
-
`),e.pipe(e)});i.on(`error`,function(e){n(!0)}),i.on(`listening`,function(e){i.close(),n(!1)}),i.listen(t,e)})}updateCSS(e,t,n){this.send(`update_css`,{css:e,element:t,children:n})}updateComponent(e,t,n){this.send(`update_component`,{js:e,element:t,children:n})}updateGlobalCSS(e,t){this.send(`update_global_css`,{name:e,css:t})}reload(){this.reloadTimeout&&clearTimeout(this.reloadTimeout),this.reloadTimeout=setTimeout(()=>{this._reload()},this.config.delay)}_reload(){this.send(`reload`,{})}send(e,t){let n=JSON.stringify({cmd:e,params:t});for(let e of this.clients)e.readyState==ae.WebSocket.OPEN&&e.send(n)}escape(e){return String(e).replace(/&(?!\w+;)/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}entryPoint(e,t){return function(n,r,i){n.url=`/`+t,e(n,r,i)}}createStaticServer(){return(e,t,n)=>{if(e.method!==`GET`&&e.method!==`HEAD`)return n();var r=te.parse(e.url||``).pathname||``,i=!e.headers.origin,a=[RegExp(`</head>`,`i`),RegExp(`</body>`,`i`)],o=null;if(e.url?.startsWith(`/?get_injected_code`)){let n=e.headers.host;if(!n){n=this.config.host;let t=e.url.split(`&`);t.length>1&&(n=t[1].replace(`host=`,``)),n==`0.0.0.0`&&(n=`127.0.0.1`),n+=`:`+this.port}let r=`ws://`+n+`/ws`,i=_t.replace(`<script type="text/javascript">`,``);i=i.replace(`var address = protocol + window.location.host + window.location.pathname + '/ws';`,`var address = '`+r+`';`),i=i.replace(`<\/script>`,``),t.setHeader(`Content-Length`,i.length),t.setHeader(`Content-type`,`text/javascript`),t.setHeader(`Access-Control-Allow-Origin`,`*`),t.write(i,`utf8`),t.end();return}let s=()=>{var n=te.parse(e.originalUrl||``).pathname;t.statusCode=301,t.setHeader(`Location`,n+`/`),t.end(`Redirecting to `+this.escape(n||``)+`/`)};function c(e){var t=(0,f.extname)(e).toLocaleLowerCase(),n;if(i&&[``,`.html`].indexOf(t)>-1){for(var r=(0,u.readFileSync)(e,`utf8`),s=0;s<a.length;++s)if(n=a[s].exec(r),n){o=n[0];break}}}function l(e){if(e.status===404)return n();n(e)}(0,ee.default)(e,r,{root:this.config.rootFolder}).on(`error`,l).on(`directory`,s).on(`file`,c).on(`stream`,e=>{if(o){let i=o,a=_t;this.config.auto_close&&(a=a.replace(`//onclose`,`socket.onclose = function () { setTimeout(() => window.close(), 100); }`));var n=a.length+Number(t.getHeader(`Content-Length`));t.setHeader(`Content-Length`,n);var r=e.pipe;e.pipe=function(t){r.call(e,(0,gt.replace)(new RegExp(i,`i`),a+o)).pipe(t)}}}).pipe(t)}}};const bt={},xt=()=>$.extensionPath;let St;const Ct=()=>{if(St!==void 0)return St;let e=xt();for(;e!==(0,f.resolve)(e,`..`);){if((0,u.existsSync)((0,f.join)(e,`node_modules/typescript/lib`)))return St=e,St;e=(0,f.resolve)(e,`..`)}return xt()},wt=()=>(0,f.join)(Ct(),`node_modules/typescript/lib`),Tt=()=>(0,f.join)(xt(),`lib/Aventus@Main.package.avt`),Et=()=>(0,f.join)(xt(),`lib/Aventus@UI.package.avt`),Dt=()=>(0,f.join)(xt(),`lib/Aventus@I18n.package.avt`),Ot=()=>(0,f.join)(xt(),`lib/Aventus@Sharp.package.avt`),kt=()=>(0,f.join)(xt(),`lib/Aventus@Php.package.avt`),At=()=>(0,f.join)(Ct(),`node_modules`),jt=[];function Mt(){if(jt.length>0)return;let e=(0,u.readdirSync)(wt());for(let t of e)t.endsWith(`.d.ts`)&&jt.push(t)}function Nt(e){if(!(0,u.existsSync)(e))return[];let t=(0,u.readdirSync)(e),n=[],r=e=>{let t=(0,f.join)(e,`package.json`);if(!(0,u.existsSync)(t))return;let r=JSON.parse((0,u.readFileSync)(t,`utf8`)),i=[],a=!1,o=t=>{try{let n=(0,f.resolve)(e,t);(0,u.existsSync)(n)&&!i.includes(n)&&i.push(n),t.endsWith(`.ts`)&&(a=!0)}catch(e){console.error(e)}};if(r.main&&o(r.main),r.module&&o(r.module),r.types&&o(r.types),r.typings&&o(r.typings),r.exports){let e=(e,t)=>e.startsWith(`<=`)?t<=e.substring(2):e.startsWith(`<`)?t<e.substring(1):e.startsWith(`>=`)?t>=e.substring(2):e.startsWith(`>`)?t>e.substring(1):e===t,t=n=>{if(n)if(typeof n==`object`){let r=null,i=Object.keys(n).some(e=>e.includes(`@`)),a=!1;if(i){for(let i of Object.keys(n)){let o=i.split(`@`);if(o.length===2){let r=o[1];if(e(r,p.version)){t(n[i]),a=!0;break}}else r=i}!a&&r&&t(n[r])}else t(n.node||n.import||n.types||n.require||n.default)}else o(n)};for(let e in r.exports){let n=Array.isArray(r.exports[e])?r.exports[e]:[r.exports[e]];for(let e of n)t(e)}}if(a)for(let e of i)e.endsWith(`.ts`)&&n.push(E(e));else for(let e of i)n.push(E(e))};for(let n of t)if(!n.startsWith(`.`))if(n.startsWith(`@`)){let t=(0,u.readdirSync)((0,f.join)(e,n));for(let i of t)r((0,f.join)(e,n,i))}else r((0,f.join)(e,n));return n}function Pt(e){let t=bt[e];if(typeof t==`string`)return t;let n;return e.startsWith(`custom://@types`)?n=(0,f.join)(At(),e.replace(`custom://@types`,`@types`)):e.startsWith(`file:///`)?(n=f.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``)),n.indexOf(`/node_modules/@typescript`)!=-1||n.indexOf(`/node_modules/@types/typescript__`)):e.startsWith(`node_modules/@types/typescript__`)||(n=jt.includes(e)?(0,f.join)(wt(),e):e),typeof t!=`string`&&(typeof n==`string`&&(0,u.existsSync)(n)&&(0,u.lstatSync)(n).isFile()&&(t=(0,u.readFileSync)(n).toString()),t!==void 0&&(bt[e]=t)),t}var Ft=class{static libInfo=[];static init(){let e=(0,p.createProgram)([(0,f.join)(wt(),`lib.es2025.full.d.ts`)],{}).getSourceFiles();for(let t of e)if(t.statements)for(let e of t.statements)try{if(e.kind==p.SyntaxKind.FunctionDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.EnumDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.ClassDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.MethodDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.VariableDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.InterfaceDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.TypeAliasDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}}catch{}}static exists(e){return this.libInfo.length==0&&this.init(),this.libInfo.includes(e)}},M=class e{kind=`mock`;value=``;isArray=!1;genericValue=[];nested=[];start=0;end=0;endNonGeneric=0;fctType;conditionalType;mappedType;node;constructor(t){if(!t){this.kind=`notype`;return}if(this.node=t,this.start=t.getStart(),this.end=t.getEnd(),this.endNonGeneric=this.end,t.kind==p.SyntaxKind.StringKeyword)this.kind=`string`;else if(t.kind===p.SyntaxKind.NumberKeyword)this.kind=`number`;else if(t.kind===p.SyntaxKind.BooleanKeyword)this.kind=`boolean`;else if(t.kind===p.SyntaxKind.NullKeyword)this.kind=`null`;else if(t.kind===p.SyntaxKind.UndefinedKeyword)this.kind=`undefined`;else if(t.kind===p.SyntaxKind.AnyKeyword)this.kind=`any`;else if(t.kind===p.SyntaxKind.NeverKeyword)this.kind=`never`;else if(t.kind===p.SyntaxKind.VoidKeyword)this.kind=`void`;else if(t.kind===p.SyntaxKind.UnknownKeyword)this.kind=`unknown`;else if(t.kind===p.SyntaxKind.ObjectKeyword)this.kind=`object`;else if(t.kind===p.SyntaxKind.SymbolKeyword)this.kind=`symbol`;else if(t.kind===p.SyntaxKind.ThisType)this.kind=`this`;else if(t.kind===p.SyntaxKind.LiteralType)this.kind=`literal`,this.value=t.literal.getText();else if(t.kind===p.SyntaxKind.TypeReference){this.kind=`type`;let n=t;if(this.value=n.typeName.getText(),this.endNonGeneric=n.typeName.end,this.value==`const`){this.value=``,this.kind=`mock`;return}if(n.typeArguments)for(let t of n.typeArguments)this.genericValue.push(new e(t))}else if(t.kind===p.SyntaxKind.ArrayType){let n=t;this.isArray=!0;let r=new e(n.elementType);this.genericValue=r.genericValue,this.nested=r.nested,this.kind=r.kind,this.value=r.value,this.endNonGeneric=r.endNonGeneric}else if(t.kind===p.SyntaxKind.UnionType){let n=t;this.kind=`union`;for(let t of n.types)this.nested.push(new e(t))}else if(t.kind===p.SyntaxKind.IntersectionType){let n=t;this.kind=`intersection`;for(let t of n.types)this.nested.push(new e(t))}else if(t.kind===p.SyntaxKind.TypeOperator){let n=t;this.kind=`typeOperator`,n.operator==p.SyntaxKind.KeyOfKeyword?this.value=`keyof`:n.operator==p.SyntaxKind.UniqueKeyword?this.value=`unique`:n.operator==p.SyntaxKind.ReadonlyKeyword&&(this.value=`readonly`),this.nested.push(new e(n.type))}else if(t.kind==p.SyntaxKind.TypeQuery){let n=t;this.kind=`typeOperator`,this.value=`typeof`;let r=new e(null);r.kind=`type`,r.value=n.exprName.getText(),this.nested.push(r)}else if(t.kind===p.SyntaxKind.ExpressionWithTypeArguments){let n=t;if(this.kind=`type`,this.value=n.expression.getText(),this.endNonGeneric=n.expression.getEnd(),n.typeArguments)for(let t of n.typeArguments)this.genericValue.push(new e(t))}else if(t.kind===p.SyntaxKind.TypeLiteral){let n=t;this.kind=`typeLiteral`,this.value=n.getText();for(let t of n.members)if(t.kind==p.SyntaxKind.IndexSignature){let n=t;this.nested.push(new e(n.type))}else if(t.kind==p.SyntaxKind.PropertySignature){let n=t;n.type&&this.nested.push(new e(n.type))}}else if(t.kind==p.SyntaxKind.ParenthesizedType){let n=new e(t.type);this.genericValue=n.genericValue,this.nested=n.nested,this.kind=n.kind,this.value=n.value,this.isArray=n.isArray,this.endNonGeneric=n.endNonGeneric}else if(t.kind==p.SyntaxKind.ConstructorType){let n=t;this.kind=`constructor`,this.value=t.getText();let r={};for(let t of n.parameters)if(t.type){let n=new e(t.type);r[t.name.getText()]=n,this.nested.push(n)}this.fctType={return:new e(n.type),parameters:r},this.nested.push(this.fctType.return)}else if(t.kind==p.SyntaxKind.FunctionType){let n=t;this.kind=`function`,this.value=t.getText();let r={};for(let t of n.parameters)if(t.type){let n=new e(t.type);r[t.name.getText()]=n,this.nested.push(n)}this.fctType={return:new e(n.type),parameters:r},this.nested.push(this.fctType.return)}else if(t.kind==p.SyntaxKind.TupleType){let n=t;this.kind=`tuple`;for(let t of n.elements)this.nested.push(new e(t))}else if(t.kind==p.SyntaxKind.ConditionalType){let n=t;this.kind=`conditional`,this.conditionalType={check:new e(n.checkType),extends:new e(n.extendsType),false:new e(n.falseType),true:new e(n.trueType)}}else if(t.kind==p.SyntaxKind.MappedType){this.kind=`mappedType`;let n=t;n.type&&n.typeParameter.constraint?(this.mappedType={parameterName:n.typeParameter.name.getText(),parameterType:new e(n.typeParameter.constraint),type:new e(n.type)},n.questionToken?.kind==p.SyntaxKind.QuestionToken?this.mappedType.modifier=`?`:n.questionToken?.kind==p.SyntaxKind.PlusToken?this.mappedType.modifier=`+`:n.questionToken?.kind==p.SyntaxKind.MinusToken&&(this.mappedType.modifier=`-`)):$.error(`you must add the new type : MappedType like `+t.getText())}else if(t.kind==p.SyntaxKind.IndexedAccessType){this.kind=`indexedAccess`;let n=t;this.nested.push(new e(n.objectType)),this.nested.push(new e(n.indexType))}else if(t.kind==p.SyntaxKind.InferType){let e=t;this.kind=`infer`,this.value=e.typeParameter.name.getText()}else t.kind,t.getText()}getFullTxt(){if(this.kind==`any`||this.kind==`boolean`||this.kind==`never`||this.kind==`null`||this.kind==`number`||this.kind==`object`||this.kind==`string`||this.kind==`symbol`||this.kind==`this`||this.kind==`undefined`||this.kind==`unknown`||this.kind==`void`)return this.kind;if(this.kind==`conditional`){let e=this.conditionalType;return`${e.check.getFullTxt()} extends ${e.extends.getFullTxt} ? ${e.true.getFullTxt()} : ${e.false.getFullTxt()}`}if(this.kind==`constructor`){if(!this.fctType)return this.value;let e=this.fctType,t=[];for(let n in e.parameters)t.push(`${n}: ${e.parameters[n].getFullTxt()}`);return`${this.value}(${t.join(`, `)})`}if(this.kind==`function`){if(!this.fctType)return this.value;let e=this.fctType,t=[];for(let n in e.parameters)t.push(`${n}: ${e.parameters[n].getFullTxt()}`);return`${this.value}(${t.join(`, `)}): ${e.return.getFullTxt()}`}if(this.kind==`indexedAccess`)return`${this.nested[0].getFullTxt()}[${this.nested[1].getFullTxt()}]`;if(this.kind==`infer`)return`infer `+this.value;if(this.kind==`intersection`)return this.nested.map(e=>e.getFullTxt()).join(` & `);if(this.kind==`union`)return this.nested.map(e=>e.getFullTxt()).join(` | `);if(this.kind==`literal`)return this.value;if(this.kind==`mappedType`){let e=this.mappedType;return`{ [${e.parameterName} in ${e.parameterType.getFullTxt()}]${e.modifier??``}: ${e.type.getFullTxt()}; }`}if(this.kind==`mock`||this.kind==`notype`)return`any`;if(this.kind==`tuple`)return`[${this.nested.map(e=>e.getFullTxt()).join(`, `)}]`;if(this.kind==`type`){let e=this.value;return this.genericValue.length>0&&(e+=`<${this.genericValue.map(e=>e.getFullTxt()).join(`, `)}>`),e}return this.kind==`typeLiteral`?this.value:this.kind==`typeOperator`?`typeof ${this.nested[0].getFullTxt()}`:`any`}};function It(e,t){return(e&t)!=0}function Lt(e,t=null){if(e.kind==p.SyntaxKind.ObjectLiteralExpression){t??={};for(let n of e.properties)if(n.kind==p.SyntaxKind.PropertyAssignment){if(n.initializer.kind==p.SyntaxKind.StringLiteral)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.NumericLiteral)t[n.name.getText()]=Number(n.initializer.getText());else if(n.initializer.kind==p.SyntaxKind.FalseKeyword)t[n.name.getText()]=!1;else if(n.initializer.kind==p.SyntaxKind.TrueKeyword)t[n.name.getText()]=!0;else if(n.initializer.kind==p.SyntaxKind.Identifier)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.ObjectLiteralExpression){let e={};Lt(n.initializer,e),t[n.name.getText()]=e}else if(n.initializer.kind==p.SyntaxKind.ArrayLiteralExpression){let e=[];Lt(n.initializer,e),t[n.name.getText()]=e}}}else if(e.kind==p.SyntaxKind.ArrayLiteralExpression){t??=[];for(let n of e.elements)if(n.kind==p.SyntaxKind.StringLiteral)t.push(n.getText());else if(n.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral)t.push(n.getText());else if(n.kind==p.SyntaxKind.NumericLiteral)t.push(Number(n.getText()));else if(n.kind==p.SyntaxKind.FalseKeyword)t.push(!1);else if(n.kind==p.SyntaxKind.TrueKeyword)t.push(!0);else if(n.kind==p.SyntaxKind.ObjectLiteralExpression){let e={};Lt(n,e),t.push(e)}else if(n.kind==p.SyntaxKind.ArrayLiteralExpression){let e=[];Lt(n,e),t.push(e)}else n.kind==p.SyntaxKind.Identifier&&t.push(n.getText())}return JSON.stringify(t)}function Rt(e){return e.kind==p.SyntaxKind.StringLiteral||e.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral?{type:`string`,value:e.getText()}:e.kind==p.SyntaxKind.NumericLiteral?{type:`number`,value:e.getText()}:e.kind==p.SyntaxKind.FalseKeyword?{type:`boolean`,value:`false`}:e.kind==p.SyntaxKind.TrueKeyword?{type:`boolean`,value:`true`}:e.kind==p.SyntaxKind.ObjectLiteralExpression?{type:`object`,value:Lt(e)}:e.kind==p.SyntaxKind.ArrayLiteralExpression?{type:`array`,value:Lt(e)}:e.kind==p.SyntaxKind.Identifier?{type:`identifier`,value:e.getText()}:e.kind==p.SyntaxKind.CallExpression||e.kind==p.SyntaxKind.ArrowFunction||e.kind==p.SyntaxKind.FunctionExpression?{type:`call`,value:e.getText()}:e.kind==p.SyntaxKind.PropertyAccessExpression?{type:`identifier`,value:e.getText()}:null}const zt=`BindThis.Convertible.Debugger.DefaultStateActive.DefaultStateInactive.Dependencies.Deprecated.Effect.ForeignKey.I18n.Injectable.Internal.InternalProtected.NoCompile.OverrideView.Property.Required.Signal.StateActive.StateChange.StateInactive.Storybook.StoryValue.TagName.ViewElement.Watch`.split(`.`);var Bt=class e{name=``;content=``;start=0;end=0;contentStart=0;contentEnd=0;arguments=[];baseInfo;constructor(e){this.baseInfo=e}static buildDecorator(t,n){let r=[];try{let a=(0,p.getDecorators)(t)||[];for(let t of a){let a=t.expression,o=new e(n);if(o.content=`@`+a.getText(),a.kind===p.SyntaxKind.CallExpression){var i=a;o.name=i.expression.getText(),o.start=t.getStart(),o.end=t.getEnd(),o.contentStart=a.getStart(),o.contentEnd=a.getEnd(),n&&(zt.includes(o.name)?n.compileTransformations[o.start+`_`+o.end]={newText:``,start:o.start,end:o.end}:n.useNormalDecorator=!0);for(let e of i.arguments){let t=Rt(e);t&&o.arguments.push(t)}r.push(o)}else P.addError(t.getStart(),t.getEnd(),`Missing paramaters for Decorator`)}}catch(e){$.showErrorMessage(e+``)}return r}},Vt=class e{dependencies=[];static is(t){if(t.name==`Dependencies`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);for(let t of e){let e=t.strong==1;n.dependencies.push({type:t.type,strong:e})}}catch{}return n}return null}},Ht=class e{static is(t){return t.name==`Internal`?new e:null}},Ut=class e{static is(t){return t.name==`InternalProtected`?new e:null}},Wt=class e{prefix;exportType;noLive;noDefaultStory;group;slots;static is(t){if(t.name==`Storybook`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);if(e.prefix&&(n.prefix=e.prefix.replace(/(^('|"))|(('|")$)/g,``)),e.export&&(n.exportType=e.export.replace(/(^('|"))|(('|")$)/g,``)),e.group&&(n.group=e.group.replace(/(^('|"))|(('|")$)/g,``)),e.noLive===!0&&(n.noLive=!0),e.noDefaultStory===!0&&(n.noDefaultStory=!0),e.slots){if(n.slots={},e.slots.values){n.slots.values={};for(let t in e.slots.values)n.slots.values[t.replace(/(^('|"))|(('|")$)/g,``)]=e.slots.values[t]}e.slots.inject&&(n.slots.inject=e.slots.inject)}}catch{}return n}return null}},Gt=class{hasDoc=!1;definitions=[];documentationParameters={};documentationTemplates={};documentationSlots={};documentationReturn;fullDefinitions=[];constructor(e){if(e.jsDoc){this.hasDoc=!0;for(let t of e.jsDoc)if(this.fullDefinitions.push(t.getText().replace(/\n(\t+| +)+/g,`
|
|
134
|
-
`)),typeof t.comment==`string`&&this.definitions.push(t.comment),t.tags){for(let e of t.tags)if(e.kind==p.SyntaxKind.JSDocParameterTag){let t=e;typeof t.comment==`string`&&(this.documentationParameters[t.name.getText()]=t.comment)}else if(e.kind==p.SyntaxKind.JSDocReturnTag){let t=e;typeof t.comment==`string`&&(this.documentationReturn=t.comment)}else if(e.kind==p.SyntaxKind.JSDocTemplateTag){let t=e;if(typeof t.comment==`string`)for(let e of t.typeParameters)this.documentationTemplates[e.name.getText()]=t.comment}else if(e.kind==p.SyntaxKind.JSDocTag){let t=e.getText().trim();if(t.startsWith(`@slot`)){let e=/@slot\s*([a-zA-z\-]*)\s*?(-|$)(.*)/gm.exec(t);if(e){let t=e[1];t||=`default`;let n=e[3];n&&(this.documentationSlots[t]=n.trim())}}}}}}};function
|
|
132
|
+
<\/script>`;var bt=class{static send(e,t){$.sendNotification(`aventus/server/start`,`http://`+e+`:`+t)}},xt=class{static send(){$.sendNotification(`aventus/server/stop`,{})}},j=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}static get isRunning(){return!!(this.instance?.server&&this.instance.server.listening)}config;server;wss;reloadTimeout;clients=[];port=8080;constructor(){this.config=T.getInstance().settings.liveserver}toggle(){this.server&&this.server.listening?this.stop():this.start()}async start(){if(!this.server||!this.server.listening){this.config=T.getInstance().settings.liveserver,this.port=this.config.port;var e=(0,x.default)();let t=this.createStaticServer();if(e.use(t).use(this.entryPoint(t,this.config.indexFile)).use((0,ie.default)(this.config.rootFolder,{icons:!0})),this.server=(0,ne.createServer)(e),this.server.addListener(`listening`,()=>{let e=this.config.host;if(e==`0.0.0.0`&&(e=`127.0.0.1`),bt.send(e,this.port),this.config.launch_browser){let t={};this.config.browser&&(t={app:{name:this.config.browser}}),(0,oe.default)(`http://${e}:${this.port}`,t)}else{let e=`http://${this.config.host}:${this.port}`;$.showInformationMessage(`Liver server started on `+e)}}),this.clients=[],this.wss=new ae.WebSocketServer({server:this.server}),this.wss.on(`connection`,e=>{e.onclose=()=>{this.clients=this.clients.filter(function(t){return t!==e})},this.clients.push(e)}),this.config.autoIncrementPort)for(;await this.portInUse(this.config.host,this.port);)this.port++;else if(await this.portInUse(this.config.host,this.port)){$.showErrorMessage(`The port `+this.port+` is already in use`);return}this.server.listen(this.port,this.config.host)}}stop(){for(let e of this.clients)e.close();this.clients=[],this.server&&=(this.server.close(),void 0),this.wss&&=(this.wss.close(),void 0),xt.send()}portInUse(e,t){return new Promise((n,r)=>{var i=(0,re.createServer)(function(e){e.write(`Echo server
|
|
133
|
+
`),e.pipe(e)});i.on(`error`,function(e){n(!0)}),i.on(`listening`,function(e){i.close(),n(!1)}),i.listen(t,e)})}updateCSS(e,t,n){this.send(`update_css`,{css:e,element:t,children:n})}updateComponent(e,t,n){this.send(`update_component`,{js:e,element:t,children:n})}updateGlobalCSS(e,t){this.send(`update_global_css`,{name:e,css:t})}reload(){this.reloadTimeout&&clearTimeout(this.reloadTimeout),this.reloadTimeout=setTimeout(()=>{this._reload()},this.config.delay)}_reload(){this.send(`reload`,{})}send(e,t){let n=JSON.stringify({cmd:e,params:t});for(let e of this.clients)e.readyState==ae.WebSocket.OPEN&&e.send(n)}escape(e){return String(e).replace(/&(?!\w+;)/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}entryPoint(e,t){return function(n,r,i){n.url=`/`+t,e(n,r,i)}}createStaticServer(){return(e,t,n)=>{if(e.method!==`GET`&&e.method!==`HEAD`)return n();var r=te.parse(e.url||``).pathname||``,i=!e.headers.origin,a=[RegExp(`</head>`,`i`),RegExp(`</body>`,`i`)],o=null;if(e.url?.startsWith(`/?get_injected_code`)){let n=e.headers.host;if(!n){n=this.config.host;let t=e.url.split(`&`);t.length>1&&(n=t[1].replace(`host=`,``)),n==`0.0.0.0`&&(n=`127.0.0.1`),n+=`:`+this.port}let r=`ws://`+n+`/ws`,i=yt.replace(`<script type="text/javascript">`,``);i=i.replace(`var address = protocol + window.location.host + window.location.pathname + '/ws';`,`var address = '`+r+`';`),i=i.replace(`<\/script>`,``),t.setHeader(`Content-Length`,i.length),t.setHeader(`Content-type`,`text/javascript`),t.setHeader(`Access-Control-Allow-Origin`,`*`),t.write(i,`utf8`),t.end();return}let s=()=>{var n=te.parse(e.originalUrl||``).pathname;t.statusCode=301,t.setHeader(`Location`,n+`/`),t.end(`Redirecting to `+this.escape(n||``)+`/`)};function c(e){var t=(0,f.extname)(e).toLocaleLowerCase(),n;if(i&&[``,`.html`].indexOf(t)>-1){for(var r=(0,u.readFileSync)(e,`utf8`),s=0;s<a.length;++s)if(n=a[s].exec(r),n){o=n[0];break}}}function l(e){if(e.status===404)return n();n(e)}(0,ee.default)(e,r,{root:this.config.rootFolder}).on(`error`,l).on(`directory`,s).on(`file`,c).on(`stream`,e=>{if(o){let i=o,a=yt;this.config.auto_close&&(a=a.replace(`//onclose`,`socket.onclose = function () { setTimeout(() => window.close(), 100); }`));var n=a.length+Number(t.getHeader(`Content-Length`));t.setHeader(`Content-Length`,n);var r=e.pipe;e.pipe=function(t){r.call(e,(0,vt.replace)(new RegExp(i,`i`),a+o)).pipe(t)}}}).pipe(t)}}};const St={},Ct=()=>$.extensionPath;let wt;const Tt=()=>{if(wt!==void 0)return wt;let e=Ct();for(;e!==(0,f.resolve)(e,`..`);){if((0,u.existsSync)((0,f.join)(e,`node_modules/typescript/lib`)))return wt=e,wt;e=(0,f.resolve)(e,`..`)}return Ct()},Et=()=>(0,f.join)(Tt(),`node_modules/typescript/lib`),Dt=()=>(0,f.join)(Ct(),`lib/Aventus@Main.package.avt`),Ot=()=>(0,f.join)(Ct(),`lib/Aventus@UI.package.avt`),kt=()=>(0,f.join)(Ct(),`lib/Aventus@I18n.package.avt`),At=()=>(0,f.join)(Ct(),`lib/Aventus@Sharp.package.avt`),jt=()=>(0,f.join)(Ct(),`lib/Aventus@Php.package.avt`),Mt=()=>(0,f.join)(Tt(),`node_modules`),Nt=[];function Pt(){if(Nt.length>0)return;let e=(0,u.readdirSync)(Et());for(let t of e)t.endsWith(`.d.ts`)&&Nt.push(t)}function Ft(e){if(!(0,u.existsSync)(e))return[];let t=(0,u.readdirSync)(e),n=[],r=e=>{let t=(0,f.join)(e,`package.json`);if(!(0,u.existsSync)(t))return;let r=JSON.parse((0,u.readFileSync)(t,`utf8`)),i=[],a=!1,o=t=>{try{let n=(0,f.resolve)(e,t);(0,u.existsSync)(n)&&!i.includes(n)&&i.push(n),t.endsWith(`.ts`)&&(a=!0)}catch(e){console.error(e)}};if(r.main&&o(r.main),r.module&&o(r.module),r.types&&o(r.types),r.typings&&o(r.typings),r.exports){let e=(e,t)=>e.startsWith(`<=`)?t<=e.substring(2):e.startsWith(`<`)?t<e.substring(1):e.startsWith(`>=`)?t>=e.substring(2):e.startsWith(`>`)?t>e.substring(1):e===t,t=n=>{if(n)if(typeof n==`object`){let r=null,i=Object.keys(n).some(e=>e.includes(`@`)),a=!1;if(i){for(let i of Object.keys(n)){let o=i.split(`@`);if(o.length===2){let r=o[1];if(e(r,p.version)){t(n[i]),a=!0;break}}else r=i}!a&&r&&t(n[r])}else t(n.node||n.import||n.types||n.require||n.default)}else o(n)};for(let e in r.exports){let n=Array.isArray(r.exports[e])?r.exports[e]:[r.exports[e]];for(let e of n)t(e)}}if(a)for(let e of i)e.endsWith(`.ts`)&&n.push(E(e));else for(let e of i)n.push(E(e))};for(let n of t)if(!n.startsWith(`.`))if(n.startsWith(`@`)){let t=(0,u.readdirSync)((0,f.join)(e,n));for(let i of t)r((0,f.join)(e,n,i))}else r((0,f.join)(e,n));return n}function It(e){let t=St[e];if(typeof t==`string`)return t;let n;return e.startsWith(`custom://@types`)?n=(0,f.join)(Mt(),e.replace(`custom://@types`,`@types`)):e.startsWith(`file:///`)?(n=f.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``)),n.indexOf(`/node_modules/@typescript`)!=-1||n.indexOf(`/node_modules/@types/typescript__`)):e.startsWith(`node_modules/@types/typescript__`)||(n=Nt.includes(e)?(0,f.join)(Et(),e):e),typeof t!=`string`&&(typeof n==`string`&&(0,u.existsSync)(n)&&(0,u.lstatSync)(n).isFile()&&(t=(0,u.readFileSync)(n).toString()),t!==void 0&&(St[e]=t)),t}var Lt=class{static libInfo=[];static init(){let e=(0,p.createProgram)([(0,f.join)(Et(),`lib.es2025.full.d.ts`)],{}).getSourceFiles();for(let t of e)if(t.statements)for(let e of t.statements)try{if(e.kind==p.SyntaxKind.FunctionDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.EnumDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.ClassDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.MethodDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.VariableDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.InterfaceDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}else if(e.kind==p.SyntaxKind.TypeAliasDeclaration){let n=e.name?.getText(t);n&&(this.libInfo.includes(n)||this.libInfo.push(n))}}catch{}}static exists(e){return this.libInfo.length==0&&this.init(),this.libInfo.includes(e)}},M=class e{kind=`mock`;value=``;isArray=!1;genericValue=[];nested=[];start=0;end=0;endNonGeneric=0;fctType;conditionalType;mappedType;node;constructor(t){if(!t){this.kind=`notype`;return}if(this.node=t,this.start=t.getStart(),this.end=t.getEnd(),this.endNonGeneric=this.end,t.kind==p.SyntaxKind.StringKeyword)this.kind=`string`;else if(t.kind===p.SyntaxKind.NumberKeyword)this.kind=`number`;else if(t.kind===p.SyntaxKind.BooleanKeyword)this.kind=`boolean`;else if(t.kind===p.SyntaxKind.NullKeyword)this.kind=`null`;else if(t.kind===p.SyntaxKind.UndefinedKeyword)this.kind=`undefined`;else if(t.kind===p.SyntaxKind.AnyKeyword)this.kind=`any`;else if(t.kind===p.SyntaxKind.NeverKeyword)this.kind=`never`;else if(t.kind===p.SyntaxKind.VoidKeyword)this.kind=`void`;else if(t.kind===p.SyntaxKind.UnknownKeyword)this.kind=`unknown`;else if(t.kind===p.SyntaxKind.ObjectKeyword)this.kind=`object`;else if(t.kind===p.SyntaxKind.SymbolKeyword)this.kind=`symbol`;else if(t.kind===p.SyntaxKind.ThisType)this.kind=`this`;else if(t.kind===p.SyntaxKind.LiteralType)this.kind=`literal`,this.value=t.literal.getText();else if(t.kind===p.SyntaxKind.TypeReference){this.kind=`type`;let n=t;if(this.value=n.typeName.getText(),this.endNonGeneric=n.typeName.end,this.value==`const`){this.value=``,this.kind=`mock`;return}if(n.typeArguments)for(let t of n.typeArguments)this.genericValue.push(new e(t))}else if(t.kind===p.SyntaxKind.ArrayType){let n=t;this.isArray=!0;let r=new e(n.elementType);this.genericValue=r.genericValue,this.nested=r.nested,this.kind=r.kind,this.value=r.value,this.endNonGeneric=r.endNonGeneric}else if(t.kind===p.SyntaxKind.UnionType){let n=t;this.kind=`union`;for(let t of n.types)this.nested.push(new e(t))}else if(t.kind===p.SyntaxKind.IntersectionType){let n=t;this.kind=`intersection`;for(let t of n.types)this.nested.push(new e(t))}else if(t.kind===p.SyntaxKind.TypeOperator){let n=t;this.kind=`typeOperator`,n.operator==p.SyntaxKind.KeyOfKeyword?this.value=`keyof`:n.operator==p.SyntaxKind.UniqueKeyword?this.value=`unique`:n.operator==p.SyntaxKind.ReadonlyKeyword&&(this.value=`readonly`),this.nested.push(new e(n.type))}else if(t.kind==p.SyntaxKind.TypeQuery){let n=t;this.kind=`typeOperator`,this.value=`typeof`;let r=new e(null);r.kind=`type`,r.value=n.exprName.getText(),this.nested.push(r)}else if(t.kind===p.SyntaxKind.ExpressionWithTypeArguments){let n=t;if(this.kind=`type`,this.value=n.expression.getText(),this.endNonGeneric=n.expression.getEnd(),n.typeArguments)for(let t of n.typeArguments)this.genericValue.push(new e(t))}else if(t.kind===p.SyntaxKind.TypeLiteral){let n=t;this.kind=`typeLiteral`,this.value=n.getText();for(let t of n.members)if(t.kind==p.SyntaxKind.IndexSignature){let n=t;this.nested.push(new e(n.type))}else if(t.kind==p.SyntaxKind.PropertySignature){let n=t;n.type&&this.nested.push(new e(n.type))}}else if(t.kind==p.SyntaxKind.ParenthesizedType){let n=new e(t.type);this.genericValue=n.genericValue,this.nested=n.nested,this.kind=n.kind,this.value=n.value,this.isArray=n.isArray,this.endNonGeneric=n.endNonGeneric}else if(t.kind==p.SyntaxKind.ConstructorType){let n=t;this.kind=`constructor`,this.value=t.getText();let r={};for(let t of n.parameters)if(t.type){let n=new e(t.type);r[t.name.getText()]=n,this.nested.push(n)}this.fctType={return:new e(n.type),parameters:r},this.nested.push(this.fctType.return)}else if(t.kind==p.SyntaxKind.FunctionType){let n=t;this.kind=`function`,this.value=t.getText();let r={};for(let t of n.parameters)if(t.type){let n=new e(t.type);r[t.name.getText()]=n,this.nested.push(n)}this.fctType={return:new e(n.type),parameters:r},this.nested.push(this.fctType.return)}else if(t.kind==p.SyntaxKind.TupleType){let n=t;this.kind=`tuple`;for(let t of n.elements)this.nested.push(new e(t))}else if(t.kind==p.SyntaxKind.ConditionalType){let n=t;this.kind=`conditional`,this.conditionalType={check:new e(n.checkType),extends:new e(n.extendsType),false:new e(n.falseType),true:new e(n.trueType)}}else if(t.kind==p.SyntaxKind.MappedType){this.kind=`mappedType`;let n=t;n.type&&n.typeParameter.constraint?(this.mappedType={parameterName:n.typeParameter.name.getText(),parameterType:new e(n.typeParameter.constraint),type:new e(n.type)},n.questionToken?.kind==p.SyntaxKind.QuestionToken?this.mappedType.modifier=`?`:n.questionToken?.kind==p.SyntaxKind.PlusToken?this.mappedType.modifier=`+`:n.questionToken?.kind==p.SyntaxKind.MinusToken&&(this.mappedType.modifier=`-`)):$.error(`you must add the new type : MappedType like `+t.getText())}else if(t.kind==p.SyntaxKind.IndexedAccessType){this.kind=`indexedAccess`;let n=t;this.nested.push(new e(n.objectType)),this.nested.push(new e(n.indexType))}else if(t.kind==p.SyntaxKind.InferType){let e=t;this.kind=`infer`,this.value=e.typeParameter.name.getText()}else t.kind,t.getText()}getFullTxt(){if(this.kind==`any`||this.kind==`boolean`||this.kind==`never`||this.kind==`null`||this.kind==`number`||this.kind==`object`||this.kind==`string`||this.kind==`symbol`||this.kind==`this`||this.kind==`undefined`||this.kind==`unknown`||this.kind==`void`)return this.kind;if(this.kind==`conditional`){let e=this.conditionalType;return`${e.check.getFullTxt()} extends ${e.extends.getFullTxt} ? ${e.true.getFullTxt()} : ${e.false.getFullTxt()}`}if(this.kind==`constructor`){if(!this.fctType)return this.value;let e=this.fctType,t=[];for(let n in e.parameters)t.push(`${n}: ${e.parameters[n].getFullTxt()}`);return`${this.value}(${t.join(`, `)})`}if(this.kind==`function`){if(!this.fctType)return this.value;let e=this.fctType,t=[];for(let n in e.parameters)t.push(`${n}: ${e.parameters[n].getFullTxt()}`);return`${this.value}(${t.join(`, `)}): ${e.return.getFullTxt()}`}if(this.kind==`indexedAccess`)return`${this.nested[0].getFullTxt()}[${this.nested[1].getFullTxt()}]`;if(this.kind==`infer`)return`infer `+this.value;if(this.kind==`intersection`)return this.nested.map(e=>e.getFullTxt()).join(` & `);if(this.kind==`union`)return this.nested.map(e=>e.getFullTxt()).join(` | `);if(this.kind==`literal`)return this.value;if(this.kind==`mappedType`){let e=this.mappedType;return`{ [${e.parameterName} in ${e.parameterType.getFullTxt()}]${e.modifier??``}: ${e.type.getFullTxt()}; }`}if(this.kind==`mock`||this.kind==`notype`)return`any`;if(this.kind==`tuple`)return`[${this.nested.map(e=>e.getFullTxt()).join(`, `)}]`;if(this.kind==`type`){let e=this.value;return this.genericValue.length>0&&(e+=`<${this.genericValue.map(e=>e.getFullTxt()).join(`, `)}>`),e}return this.kind==`typeLiteral`?this.value:this.kind==`typeOperator`?`typeof ${this.nested[0].getFullTxt()}`:`any`}};function Rt(e,t){return(e&t)!=0}function zt(e,t=null){if(e.kind==p.SyntaxKind.ObjectLiteralExpression){t??={};for(let n of e.properties)if(n.kind==p.SyntaxKind.PropertyAssignment){if(n.initializer.kind==p.SyntaxKind.StringLiteral)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.NumericLiteral)t[n.name.getText()]=Number(n.initializer.getText());else if(n.initializer.kind==p.SyntaxKind.FalseKeyword)t[n.name.getText()]=!1;else if(n.initializer.kind==p.SyntaxKind.TrueKeyword)t[n.name.getText()]=!0;else if(n.initializer.kind==p.SyntaxKind.Identifier)t[n.name.getText()]=n.initializer.getText();else if(n.initializer.kind==p.SyntaxKind.ObjectLiteralExpression){let e={};zt(n.initializer,e),t[n.name.getText()]=e}else if(n.initializer.kind==p.SyntaxKind.ArrayLiteralExpression){let e=[];zt(n.initializer,e),t[n.name.getText()]=e}}}else if(e.kind==p.SyntaxKind.ArrayLiteralExpression){t??=[];for(let n of e.elements)if(n.kind==p.SyntaxKind.StringLiteral)t.push(n.getText());else if(n.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral)t.push(n.getText());else if(n.kind==p.SyntaxKind.NumericLiteral)t.push(Number(n.getText()));else if(n.kind==p.SyntaxKind.FalseKeyword)t.push(!1);else if(n.kind==p.SyntaxKind.TrueKeyword)t.push(!0);else if(n.kind==p.SyntaxKind.ObjectLiteralExpression){let e={};zt(n,e),t.push(e)}else if(n.kind==p.SyntaxKind.ArrayLiteralExpression){let e=[];zt(n,e),t.push(e)}else n.kind==p.SyntaxKind.Identifier&&t.push(n.getText())}return JSON.stringify(t)}function Bt(e){return e.kind==p.SyntaxKind.StringLiteral||e.kind==p.SyntaxKind.NoSubstitutionTemplateLiteral?{type:`string`,value:e.getText()}:e.kind==p.SyntaxKind.NumericLiteral?{type:`number`,value:e.getText()}:e.kind==p.SyntaxKind.FalseKeyword?{type:`boolean`,value:`false`}:e.kind==p.SyntaxKind.TrueKeyword?{type:`boolean`,value:`true`}:e.kind==p.SyntaxKind.ObjectLiteralExpression?{type:`object`,value:zt(e)}:e.kind==p.SyntaxKind.ArrayLiteralExpression?{type:`array`,value:zt(e)}:e.kind==p.SyntaxKind.Identifier?{type:`identifier`,value:e.getText()}:e.kind==p.SyntaxKind.CallExpression||e.kind==p.SyntaxKind.ArrowFunction||e.kind==p.SyntaxKind.FunctionExpression?{type:`call`,value:e.getText()}:e.kind==p.SyntaxKind.PropertyAccessExpression?{type:`identifier`,value:e.getText()}:null}const Vt=`BindThis.Convertible.Debugger.DefaultStateActive.DefaultStateInactive.Dependencies.Deprecated.Effect.ForeignKey.I18n.Injectable.Internal.InternalProtected.NoCompile.OverrideView.Property.Required.Signal.StateActive.StateChange.StateInactive.Storybook.StoryValue.TagName.ViewElement.Watch`.split(`.`);var Ht=class e{name=``;content=``;start=0;end=0;contentStart=0;contentEnd=0;arguments=[];baseInfo;constructor(e){this.baseInfo=e}static buildDecorator(t,n){let r=[];try{let a=(0,p.getDecorators)(t)||[];for(let t of a){let a=t.expression,o=new e(n);if(o.content=`@`+a.getText(),a.kind===p.SyntaxKind.CallExpression){var i=a;o.name=i.expression.getText(),o.start=t.getStart(),o.end=t.getEnd(),o.contentStart=a.getStart(),o.contentEnd=a.getEnd(),n&&(Vt.includes(o.name)?n.compileTransformations[o.start+`_`+o.end]={newText:``,start:o.start,end:o.end}:n.useNormalDecorator=!0);for(let e of i.arguments){let t=Bt(e);t&&o.arguments.push(t)}r.push(o)}else P.addError(t.getStart(),t.getEnd(),`Missing paramaters for Decorator`)}}catch(e){$.showErrorMessage(e+``)}return r}},Ut=class e{dependencies=[];static is(t){if(t.name==`Dependencies`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);for(let t of e){let e=t.strong==1;n.dependencies.push({type:t.type,strong:e})}}catch{}return n}return null}},Wt=class e{static is(t){return t.name==`Internal`?new e:null}},Gt=class e{static is(t){return t.name==`InternalProtected`?new e:null}},Kt=class e{prefix;exportType;noLive;noDefaultStory;group;slots;static is(t){if(t.name==`Storybook`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);if(e.prefix&&(n.prefix=e.prefix.replace(/(^('|"))|(('|")$)/g,``)),e.export&&(n.exportType=e.export.replace(/(^('|"))|(('|")$)/g,``)),e.group&&(n.group=e.group.replace(/(^('|"))|(('|")$)/g,``)),e.noLive===!0&&(n.noLive=!0),e.noDefaultStory===!0&&(n.noDefaultStory=!0),e.slots){if(n.slots={},e.slots.values){n.slots.values={};for(let t in e.slots.values)n.slots.values[t.replace(/(^('|"))|(('|")$)/g,``)]=e.slots.values[t]}e.slots.inject&&(n.slots.inject=e.slots.inject)}}catch{}return n}return null}},qt=class{hasDoc=!1;definitions=[];documentationParameters={};documentationTemplates={};documentationSlots={};documentationReturn;fullDefinitions=[];constructor(e){if(e.jsDoc){this.hasDoc=!0;for(let t of e.jsDoc)if(this.fullDefinitions.push(t.getText().replace(/\n(\t+| +)+/g,`
|
|
134
|
+
`)),typeof t.comment==`string`&&this.definitions.push(t.comment),t.tags){for(let e of t.tags)if(e.kind==p.SyntaxKind.JSDocParameterTag){let t=e;typeof t.comment==`string`&&(this.documentationParameters[t.name.getText()]=t.comment)}else if(e.kind==p.SyntaxKind.JSDocReturnTag){let t=e;typeof t.comment==`string`&&(this.documentationReturn=t.comment)}else if(e.kind==p.SyntaxKind.JSDocTemplateTag){let t=e;if(typeof t.comment==`string`)for(let e of t.typeParameters)this.documentationTemplates[e.name.getText()]=t.comment}else if(e.kind==p.SyntaxKind.JSDocTag){let t=e.getText().trim();if(t.startsWith(`@slot`)){let e=/@slot\s*([a-zA-z\-]*)\s*?(-|$)(.*)/gm.exec(t);if(e){let t=e[1];t||=`default`;let n=e[3];n&&(this.documentationSlots[t]=n.trim())}}}}}}};function Jt(){return`import type { StorybookConfig } from "@storybook/web-components-vite";
|
|
135
135
|
import remarkGfm from 'remark-gfm';
|
|
136
136
|
|
|
137
137
|
const config: StorybookConfig = {
|
|
@@ -166,14 +166,14 @@ const config: StorybookConfig = {
|
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
168
|
export default config;
|
|
169
|
-
`}function
|
|
169
|
+
`}function Yt(){return`import Meta from './$name$.stories'
|
|
170
170
|
$blocks$
|
|
171
171
|
$render$
|
|
172
172
|
|
|
173
173
|
$tag$
|
|
174
174
|
|
|
175
175
|
$live$
|
|
176
|
-
`}function
|
|
176
|
+
`}function Xt(){return`import type { Meta, Story } from '@aventusjs/storybook'
|
|
177
177
|
import Template from './$name$_.mdx'
|
|
178
178
|
|
|
179
179
|
const meta: Meta = {
|
|
@@ -194,7 +194,7 @@ const meta: Meta = {
|
|
|
194
194
|
export default meta;
|
|
195
195
|
|
|
196
196
|
$defaultStory$
|
|
197
|
-
`}function
|
|
197
|
+
`}function Zt(){return`import { type Meta, type Story, render } from '@aventusjs/storybook'
|
|
198
198
|
import Template from './$name$_.mdx'
|
|
199
199
|
$importPathes$
|
|
200
200
|
|
|
@@ -217,7 +217,7 @@ const meta: Meta = {
|
|
|
217
217
|
export default meta;
|
|
218
218
|
|
|
219
219
|
$defaultStory$
|
|
220
|
-
`}function
|
|
220
|
+
`}function Qt(){return`import { Preview } from '@storybook/web-components';
|
|
221
221
|
|
|
222
222
|
const preview: Preview = {
|
|
223
223
|
parameters: {
|
|
@@ -227,20 +227,20 @@ const preview: Preview = {
|
|
|
227
227
|
},
|
|
228
228
|
};
|
|
229
229
|
|
|
230
|
-
export default preview;`}var
|
|
230
|
+
export default preview;`}var $t=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=D(ze(E(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 F&&n.componentClassName==t.name&&n.fileParsed?.classes[n.componentClassName]&&!n.fileParsed.classes[n.componentClassName].isAbstract&&!e},c=()=>{let e=Yt();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`,`
|
|
231
231
|
<div>
|
|
232
232
|
<Title>Live</Title>
|
|
233
233
|
<Canvas />
|
|
234
234
|
<Controls />
|
|
235
235
|
</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=`{
|
|
236
236
|
`;for(let n in e){let r=e[n];typeof r==`string`&&(r=r.replace(/\\"/g,``)),r==``&&(r=`""`),t+=` "`+n+`":`+r+`,
|
|
237
|
-
`}return t+=`}`,t};c(),(()=>{let o=!0;t.storieDecorator&&t.storieDecorator.noDefaultStory&&(o=!1);let c=s()?
|
|
238
|
-
`).replace(/`/g,"\\`")??``),c=this.replaceVariable(c,`aventus`,`aventus: `+JSON.stringify(r,null,2)+`,`),c=this.replaceVariable(c,`defaultStory`,o?`export const DefaultStory: Story = {}`:``),n instanceof F){c=this.replaceVariable(c,`argTypes`,`argTypes: `+JSON.stringify(n.storyBookInfo.argsTypes,null,2)+`,`),c=this.replaceVariable(c,`args`,`args: `+l(n.storyBookInfo.args)+`,`);let e=n.fileParsed?.classes[n.componentClassName].storieInject??{},t=
|
|
239
|
-
`))}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=
|
|
237
|
+
`}return t+=`}`,t};c(),(()=>{let o=!0;t.storieDecorator&&t.storieDecorator.noDefaultStory&&(o=!1);let c=s()?Zt():Xt(),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(`
|
|
238
|
+
`).replace(/`/g,"\\`")??``),c=this.replaceVariable(c,`aventus`,`aventus: `+JSON.stringify(r,null,2)+`,`),c=this.replaceVariable(c,`defaultStory`,o?`export const DefaultStory: Story = {}`:``),n instanceof F){c=this.replaceVariable(c,`argTypes`,`argTypes: `+JSON.stringify(n.storyBookInfo.argsTypes,null,2)+`,`),c=this.replaceVariable(c,`args`,`args: `+l(n.storyBookInfo.args)+`,`);let e=n.fileParsed?.classes[n.componentClassName].storieInject??{},t=Ke(E((0,f.join)(i,...r.namespace.split(`.`))),E(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(`
|
|
239
|
+
`))}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=Jt(),t=Ke(E(this.buildConfig.stories.output),E(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=Qt();this.writeFile(o,e)}}replaceVariable(e,t,n){let r=RegExp(`\\$`+t+`\\$`,`g`);return e=e.replace(r,n),e}writeFile(e,t){Ye(e,t,`storybook`)}},en=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`,`
|
|
240
240
|
`)});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`,`
|
|
241
241
|
`)});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`,`
|
|
242
|
-
`)})}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=E((0,f.normalize)(Re(D(this.parserInfo.document.uri))+`/`+e.moduleName))):(this.name=e.name,this.nameStart=0,this.nameEnd=0,this.isTypeImport=!1,t=e.moduleUri),!P.parsedDoc[t]){let e=R.getInstance().getByUri(t);if(e)P.parse(e,!1,this.parserInfo.build);else{let e=D(t),n=(0,u.existsSync)(e)?(0,u.readFileSync)(e,`utf8`):``,r=new A(d.TextDocument.create(t,C.TypeScript,1,n));P.parse(r,!1,this.parserInfo.build)}}if(P.parsedDoc[t]?.result.isReady){let e=P.parsedDoc[t].result.getBaseInfo(this.name);e?this.info=e:P.addError(this.nameStart,this.nameEnd,`Can't load `+t+` `+this.name+` from `+this.parserInfo.document.uri)}else{if(this.parserInfo.waitingImports[this.alias??this.name])return;this.parserInfo.waitingImports[this.alias??this.name]=[],P.parsedDoc[t].result.onReady(()=>{this.asyncImportLocal(t,this.alias??this.name)})}}asyncImportLocal(e,t){let n=P.parsedDoc[e].result.getBaseInfo(t);if(n){this.info=n;let e=[this.parserInfo.classes,this.parserInfo.enums,this.parserInfo.aliases,this.parserInfo.functions,this.parserInfo.variables];for(let r of e)for(let e in r){let i=r[e],a=Object.values(i.dependencies);for(let e of a)e.uri==`@external`&&e.fullName==t&&(e.uri=`@local`,e.fullName=`$namespace$`+n.fullName)}for(let e of this.parserInfo.waitingImports[t])e(n);delete this.parserInfo.waitingImports[t]}else P.addError(this.nameStart,this.nameEnd,`Can't load `+e+` `+t+` from `+this.parserInfo.document.uri)}},$t=class e{msg=`This code is deprecated`;static is(t){if(t.name==`Deprecated`){let n=new e;if(t.arguments.length>0)try{n.msg=t.arguments[0].value}catch{}return n}return null}},N=class e{static infoByShortName={};static infoByFullName={};static getInfoByShortName(e){return this.infoByShortName[e]}static getInfoByFullName(e,t){e=e.replace(/<.*>/,``);let n=this.infoByFullName[e];return n||=this.infoByFullName[t.fullName.split(`.`)[0]+`.`+e],n}static isExported(e){if(e.modifiers){for(let t of e.modifiers)if(t.kind==p.SyntaxKind.ExportKeyword)return!0}return!1}static isStoryExported(e,t){if(!t.buildConfig.stories)return!1;let n=Bt.buildDecorator(e).find(e=>e.name==`Storybook`);if(n){let e=Wt.is(n);if(e)return e.exportType?e.exportType==`all`||e.exportType==`public`||e.exportType==`protected`:!0}return t.buildConfig.stories.format==`all`||t.buildConfig.stories.format==`public`||t.buildConfig.stories.format==`protected`}name=``;nameStart=0;nameEnd=0;start=0;end=0;fullName=``;namespace=``;decorators=[];useNormalDecorator=!1;storieContent;storieInject={};storieDecorator;storyType=`none`;dependencies={};compiled=``;documentation;isExported=!1;isInternalExported=!1;_parserInfo;content=``;deprecated=!1;deprecatedMsg=``;compileTransformations={};get compiledContent(){return e.getContent(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get compiledContentHotReload(){return e.getContentHotReload(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get compiledContentNpm(){return e.getContentNpm(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get compiledContentDoc(){return e.getContentDoc(this.content,this.start,this.end,this.dependenciesLocations,this.compileTransformations)}get fileUri(){return this.document.uri}document;dependenciesPrevented=[];dependenciesLocations={};infoType=0;build;willBeCompiled;get parserInfo(){return this._parserInfo}constructor(t,n,r,i=!0){if(this._parserInfo=r,this.document=r.document,this.decorators=Bt.buildDecorator(t,this),this.dependenciesLocations={},this.build=r.build,this.willBeCompiled=t.kind!=p.SyntaxKind.InterfaceDeclaration&&t.kind!=p.SyntaxKind.TypeAliasDeclaration,t.name){this.start=t.getStart(),this.end=t.getEnd(),this.name=t.name.getText(),this.nameStart=t.name.getStart(),this.nameEnd=t.name.getEnd(),this.namespace=n.join(`.`),this.fullName=[...n,this.name].join(`.`),this.content=t.getText(),r.isExternal||(e.infoByShortName[this.name]=this);let a=new Gt(t);if(a.hasDoc&&(this.documentation=a),i&&this.loadDecorators(),t.kind!=p.SyntaxKind.VariableDeclaration){this.isExported=e.isExported(t),this.isInternalExported=this.isExported;for(let e of this.decorators)if(Ht.is(e)){this.isExported=!1;break}}e.infoByFullName[this.fullName]=this}}loadDecorators(){for(let e of this.decorators){let t=Vt.is(e);if(t)for(let e of t.dependencies)this.addDependencyName(e.type,e.strong,0,0);let n=$t.is(e);n&&(this.deprecated=!0,this.deprecatedMsg=n.msg)}}preventDependencyAdd(e){this.dependenciesPrevented.includes(e)||this.dependenciesPrevented.push(e)}loadExpression(e,t=0,n=!1){if($.debug(`***`+t+`. `+e.getText()),$.debug(p.SyntaxKind[e.kind]),e.kind==p.SyntaxKind.ExpressionWithTypeArguments)this.addDependency(e,n);else if(e.kind==p.SyntaxKind.NewExpression){let r=e;this.loadExpression(r.expression,t+1,n)}else if(e.kind==p.SyntaxKind.PropertyAccessExpression){let r=e,i=r.name.getText(),a=P.getBaseInfo(i);if(a&&r.expression.getText()+`.`+i==a.fullName)this.addDependencyName(a.fullName,n,r.getStart(),r.getEnd());else{let e=r.expression.getText();e!=`this`&&!e.includes(`.`)&&(P.hasLocal(e)||P.hasImport(e))&&this.addDependencyName(e,n,r.expression.getStart(),r.expression.getEnd())}this.loadExpression(r.expression,t+1,n)}else if(e.kind==p.SyntaxKind.Identifier){if(e.parent.kind==p.SyntaxKind.PropertyAccessExpression||e.parent.kind==p.SyntaxKind.GetAccessor||e.parent.kind==p.SyntaxKind.SetAccessor||!this.checkParentIdentifier(e))return;let t=e.getText();t!=`this`&&!t.includes(`.`)&&(P.getBaseInfo(t)||P.hasLocal(t)||P.hasImport(t))&&this.addDependencyName(t,n,e.getStart(),e.getEnd())}else if(e.kind==p.SyntaxKind.CallExpression){let r=e;this.loadExpression(r.expression,t+1,n)}}checkParentIdentifier(e){let t=[p.SyntaxKind.VariableDeclaration,p.SyntaxKind.FunctionDeclaration,p.SyntaxKind.ClassDeclaration,p.SyntaxKind.InterfaceDeclaration,p.SyntaxKind.TypeAliasDeclaration,p.SyntaxKind.EnumDeclaration,p.SyntaxKind.ModuleDeclaration,p.SyntaxKind.NamespaceExportDeclaration,p.SyntaxKind.ImportEqualsDeclaration,p.SyntaxKind.ExportAssignment,p.SyntaxKind.ExportDeclaration,p.SyntaxKind.NamespaceExport,p.SyntaxKind.ExportSpecifier,p.SyntaxKind.MissingDeclaration,p.SyntaxKind.MethodDeclaration,p.SyntaxKind.ClassStaticBlockDeclaration],n=[p.SyntaxKind.ImportDeclaration,p.SyntaxKind.ImportClause,p.SyntaxKind.NamespaceImport,p.SyntaxKind.NamedImports,p.SyntaxKind.ImportSpecifier];return t.includes(e.parent.kind)?e.parent.name!=e:n.includes(e.parent.kind)?!1:!(e.parent.kind>=p.SyntaxKind.JsxElement&&e.parent.kind<=p.SyntaxKind.JsxExpression)}loadDependencyContext=void 0;maybeDependencies={};loadOnlyDependenciesRecu(e,t=0,n=!1){this.parserInfo.isExternal||(e.kind==p.SyntaxKind.Decorator&&(this.loadDependencyContext=`Decorator`),(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.TypeReference){this.addDependency(e,n);return}else this.loadExpression(e,t,n);this.loadOnlyDependenciesRecu(e,t+1,n)}),e.kind==p.SyntaxKind.Decorator&&(this.loadDependencyContext=void 0))}addDependency(e,t){if(this.parserInfo.isExternal)return;let n=e=>{if(e.kind==`type`){this.addDependencyName(e.value,t,e.start,e.endNonGeneric);for(let t of e.nested)n(t);for(let t of e.genericValue)n(t)}else if(e.kind==`typeLiteral`||e.kind==`function`)for(let t of e.nested)n(t);else if(e.kind==`union`)for(let t of e.nested)n(t)};n(new M(e))}addDependencyWaitName(e,t,n){if(this.parserInfo.isExternal){n([e.getText()],[e.getText()]);return}let r=[],i=[],a=0,o=!1,s=()=>{!o&&a==0&&(o=!0,n(r,i))},c=(e,n)=>{if(e.kind==`type`){a++,this.addDependencyName(e.value,t,e.start,e.endNonGeneric,(e,t)=>{n==0&&(e&&r.push(e),t&&i.push(t)),a--,s()});for(let t of e.nested)c(t,n+1);for(let r of e.genericValue)t=!1,c(r,n+1)}else if(e.kind==`typeLiteral`||e.kind==`function`)for(let t of e.nested)c(t,n+1);else if(e.kind==`union`)for(let t of e.nested)c(t,n+1)};c(new M(e),0),s()}loadStoryBookInject(){let e=this.build.buildConfig.stories;if(!e)return;let t=this.storieContent;if(!t)return;let n=(e,t)=>{this.storieInject[e]?this.storieInject[e].includes(t)||this.storieInject[e].push(t):this.storieInject[e]=[t]},r=r=>{let i=(0,f.join)(e.output,`generated`),a=(0,f.join)(e.output,`auto`,...this.fullName.split(`.`)),o=Ge(E((0,f.join)(i,...t.namespace.split(`.`))),E(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=Ye(this.parserInfo.npmImports[e].uri),r=this.getNpmReplacementName(t+`.`+e);this._parserInfo.registerGeneratedImport({uri:this.parserInfo.npmImports[e].uri,name:e,compiled:!0,alias:r,forced:!0})}else{let e=Qt.manualLocalImport(this,n.fullName,n.uri),t=n.fullName,r=this.fullName.split(`.`);r.pop();let i=t.split(`.`),a=i.pop()??``;for(let e=0;e<r.length;e++)if(i.length>e)if(i[e]==r[e])i.splice(e,1),r.splice(e,1),e--;else break;let o=r.length==0&&i.length==0,s=``;for(let e=0;e<r.length;e++)s+=`../`;s==``&&(s+=`./`),s+=i.join(`/`);let c=this.getNpmReplacementName([this.build.module,t].join(`.`));this._parserInfo.registerGeneratedImport({uri:s,nameAlias:e?.alias,name:a,compiled:!0,alias:c,onlySrc:o,forced:!0})}t.dependencies.push(n)}}addDependencyName(e,t,n,r,i){if(this.parserInfo.isExternal)return;let a;if(a=i||(()=>{}),!e||e==`constructor`||e==`toString`){a();return}$.debug(`try add dendency `+e);let o=/<.*>/g.exec(e);if(o&&(r-=o[0].length,e=e.replace(o[0],``)),e==this.fullName){a();return}if(Ft.exists(e)&&!this.parserInfo.internalObjects[e]&&!this.parserInfo.importsLocal[e]&&!this.parserInfo.waitingImports[e]&&!this.parserInfo.npmImports[e]&&!this.parserInfo.packages[e]){a();return}if(n>0&&r>0){this.dependenciesLocations[e]||(this.dependenciesLocations[e]={locations:{},typeRemplacement:null,replacement:null,docReplacement:null,hotReloadReplacement:null,npmReplacement:null});let t=n+`_`+r;if(!this.dependenciesLocations[e].locations){$.showErrorMessage(`For the admin : you can add `+e+` as dependency to avoid`),a();return}if(!this.dependenciesLocations[e].locations[t]){let i=(0,p.getTokenAtPosition)(this.parserInfo.srcFile,(n+r)/2),a=(0,p.isTypeReferenceNode)(i)||(0,p.isTypeReferenceNode)(i.parent);this.dependenciesLocations[e].locations[t]={start:n,end:r,isType:a}}}if(!this.addDependencyNameCustomCheck(e)){a();return}if(this.dependenciesPrevented.includes(e)){a();return}if(this.dependencies[e]){if(a(),this.loadDependencyContext===void 0&&this.maybeDependencies[e]){let t=this.getNpmReplacementName(this.maybeDependencies[e].name);this._parserInfo.registerGeneratedImport({uri:this.maybeDependencies[e].uri,name:this.maybeDependencies[e].name,compiled:this.maybeDependencies[e].compiled,alias:t,forced:!1})}return}if(e.includes(`.`)){this.dependencies[e]={fullName:e,uri:`@external`,isStrong:t};let n=this.build.externalPackageInformation.getNpmUri(e),r=this.getNpmReplacementName(e);n&&(this.dependenciesLocations[e].npmReplacement=r,this.loadDependencyContext===void 0?this._parserInfo.registerGeneratedImport({uri:n.uri,name:n.name,compiled:n.compiled,alias:r,forced:!1}):this.maybeDependencies[e]=n),a(e,r);return}let s=(t,n,r)=>{let i=this.fullName.split(`.`);i.pop();let a=t.split(`.`),o=a.pop()??``;for(let e=0;e<i.length;e++)if(a.length>e)if(a[e]==i[e])a.splice(e,1),i.splice(e,1),e--;else break;let s=i.length==0&&a.length==0,c=``;for(let e=0;e<i.length;e++)c+=`../`;c==``&&(c+=`./`),c+=a.join(`/`),this.loadDependencyContext===void 0?this._parserInfo.registerGeneratedImport({uri:c,name:o,compiled:n,alias:r,onlySrc:s,forced:!1}):this.maybeDependencies[e]={uri:c,name:o,compiled:n}};if(this.parserInfo.internalObjects[e]){let n=this.parserInfo.internalObjects[e].fullname,r=[this.build.module,...this.build.namespaces,n].join(`.`);if(n==this.fullName&&(t=!1),this.dependencies[e]={fullName:`$namespace$`+n,uri:`@local`,isStrong:t},$.debug(`add dependence `+e+` : same file`),this.dependenciesLocations[e]){let t=this.build.module+`.`+n;this.isExported!=this.parserInfo.internalObjects[e].isExported&&(t=this.isExported?[`___`+this.build.module,n].join(`.`):[`globalThis`,this.build.module,n].join(`.`)),this.dependenciesLocations[e].typeRemplacement=t,this.dependenciesLocations[e].replacement=n,this.dependenciesLocations[e].docReplacement=this.build.module+`.`+n,this.dependenciesLocations[e].npmReplacement=e,this.dependenciesLocations[e].hotReloadReplacement=r,s(n,this.parserInfo.internalObjects[e].isCompiled,e)}a(n,e);return}let c=this.parserInfo.importsLocal[e]?.info;if(c){let n=c.fullName,r=[this.build.module,...this.build.namespaces,n].join(`.`);this.dependencies[e]={fullName:`$namespace$`+n,uri:c.fileUri,isStrong:t},$.debug(`add dependency `+e+` : imported file`);let i=this.getNpmReplacementName([this.build.module,n].join(`.`));if(this.dependenciesLocations[e]){let t=this.build.module+`.`+n;this.isExported!=c.isExported&&(t=this.isExported?[`___`+this.build.module,n].join(`.`):[`globalThis`,this.build.module,n].join(`.`));let a=n,o=this.fullName.split(`.`);o.slice(0,1);let l=n.split(`.`)[0];o.includes(l)&&(a=`_.`+a),this.dependenciesLocations[e].typeRemplacement=t,this.dependenciesLocations[e].replacement=a,this.dependenciesLocations[e].docReplacement=this.build.module+`.`+n,this.dependenciesLocations[e].npmReplacement=i,this.dependenciesLocations[e].hotReloadReplacement=r,s(n,c.willBeCompiled,i)}a(n,i);return}else if(this.parserInfo.waitingImports[e]){$.debug(`add dependency `+e+` : but waiting import file`),this.parserInfo.waitingImports[e].push(n=>{let r=n.fullName,i=[this.build.module,...this.build.namespaces,r].join(`.`),o=this.getNpmReplacementName([this.build.module,r].join(`.`));if(this.dependenciesLocations[e]){let t=this.build.module+`.`+r;this.isExported!=n.isExported&&(t=this.isExported?[`___`+this.build.module,r].join(`.`):[`globalThis`,this.build.module,r].join(`.`)),this.dependenciesLocations[e].typeRemplacement=t,this.dependenciesLocations[e].replacement=r,this.dependenciesLocations[e].docReplacement=this.build.module+`.`+r,this.dependenciesLocations[e].npmReplacement=o,this.dependenciesLocations[e].hotReloadReplacement=i,s(r,n.willBeCompiled,o)}this.dependencies[e]={fullName:`$namespace$`+r,uri:n.fileUri,isStrong:t},a(r,o)});return}else if(this.parserInfo.packages[e]){let n=this.parserInfo.packages[e].fullname,r=this.build.externalPackageInformation.getNpmUri(n);this.dependencies[e]={fullName:n,uri:`@external`,isStrong:t};let i=this.getNpmReplacementName(n);this.dependenciesLocations[e]&&(this.dependenciesLocations[e].typeRemplacement=n,this.dependenciesLocations[e].replacement=n,this.dependenciesLocations[e].docReplacement=n,this.dependenciesLocations[e].npmReplacement=i,this.dependenciesLocations[e].hotReloadReplacement=n),r&&this._parserInfo.registerGeneratedImport({uri:r.uri,name:r.name,compiled:r.compiled,alias:i,forced:!1}),a(n,i);return}if(this.parserInfo.npmImports[e]){this.dependencies[e]={fullName:e,uri:`@npm`,isStrong:t},$.debug(`add dependency `+e+` : npm`);let i=Ye(this.parserInfo.npmImports[e].uri),o=this.getNpmReplacementName(i+`.`+e);this.dependenciesLocations[e]&&(this.dependenciesLocations[e].replacement=`npmCompilation['`+i+`'].`+e,this.dependenciesLocations[e].docReplacement=`npmCompilation['`+i+`'].`+e,o!=e&&(this.dependenciesLocations[e].npmReplacement=o),this.loadDependencyContext===void 0?this._parserInfo.registerGeneratedImport({uri:this.parserInfo.npmImports[e].uri,name:e,compiled:!0,alias:o,forced:!1}):this.maybeDependencies[e]={uri:this.parserInfo.npmImports[e].uri,name:e,compiled:!0}),n>0&&r>0&&(this.dependenciesLocations[e].locations[n+`_`+r].isNpm=!0),a(e,o);return}this.dependencies[e]={fullName:e,uri:`@external`,isStrong:t},$.debug(`add dependency `+e+` : external`),a(e,e)}addDependencyNameCustomCheck(e){return!0}static getContent(e,t,n,r,i){return this._getContent(e,t,n,r,i,1)}static getContentHotReload(e,t,n,r,i){return this._getContent(e,t,n,r,i,2)}static getContentNpm(e,t,n,r,i){return this._getContent(e,t,n,r,i,3)}static getContentDoc(e,t,n,r,i){return this._getContent(e,t,n,r,i,4)}static _getContent(e,t,n,r,i,a){let o=[];for(let e in r){let i=null;a==1?i=r[e].replacement:a==2?i=r[e].hotReloadReplacement:a==3?i=r[e].npmReplacement:a==4&&(i=r[e].docReplacement);let s=r[e].typeRemplacement;if(i)for(let c in r[e].locations){let l=r[e].locations[c];if(l.start>=t&&l.end<=n)if(l.isType&&s&&a!=3)o.push({newText:s,start:l.start-t,end:l.end-t});else if(l.isNpm&&l.isType)continue;else o.push({newText:i,start:l.start-t,end:l.end-t})}}for(let e in i){let r=i[e];r.start>=t&&r.end<=n&&o.push({newText:r.newText,start:r.start-t,end:r.end-t})}o.sort((e,t)=>t.end-e.end);let s=e.length;for(let t of o)t.end>s||(e=e.slice(0,t.start)+t.newText+e.slice(t.end,e.length),s=t.start);return e.replace(/^\s*export\s+(class|interface|enum|type|abstract|function|async)/m,`$1`)}loadStorieContent(){if(this.build.buildConfig.stories&&!this._parserInfo.isExternal){for(let e of this.decorators){let t=Wt.is(e);if(t){this.storieDecorator=t;break}}let e=this.build.buildConfig.stories.format;if(this.storieDecorator?this.storieDecorator.exportType?this.storyType=this.storieDecorator.exportType:e?this.storyType=e==`manual`?`all`:e:this.storyType=`none`:e?this.storyType=e==`manual`?`none`:e:this.storyType=`none`,this.storyType==`public`||this.storyType==`protected`?(this.storieDecorator||this.isExported)&&(this.storieContent=this.defineStoryContent(this.storieDecorator)):this.storyType==`all`&&(this.storieContent=this.defineStoryContent(this.storieDecorator)),this.storieContent&&this.build.buildConfig.stories.srcBaseUrl){let e=this.build.project.getConfigFile().uri.replace(w.Config,``),t=D(this.fileUri.replace(e,``)).replace(/\\/g,`/`);this.storieContent.srcUrl=this.build.buildConfig.stories.srcBaseUrl+`/`+t}}}transformTypeForStory(e,t){if(e){if(e.kind==`type`){let n={kind:`simple`,name:e.value};if(e.isArray&&(n.isArray=!0),e.genericValue.length>0){let r=[];for(let n of e.genericValue){let e=this.transformTypeForStory(n,t);e&&r.push(e)}r.length>0&&(n.generics=r)}let r=t.parserInfo.importsLocal[e.value]?.info;if(r)r.storyType!=`none`&&(n.ref=Zt.getFullname(r));else{let r=t.parserInfo.internalObjects[e.value];r?.isStoryExported&&(n.ref=r.fullname)}return n}if(e.kind==`any`||e.kind==`never`||e.kind==`unknown`||e.kind==`boolean`||e.kind==`null`||e.kind==`number`||e.kind==`string`||e.kind==`undefined`||e.kind==`void`||e.kind==`object`||e.kind==`symbol`||e.kind==`this`)return{kind:`simple`,name:e.kind};if(e.kind==`literal`)return{kind:`simple`,name:e.value.slice(1,-1)};if(e.kind==`function`||e.kind==`constructor`){if(!e.fctType)return;let t={kind:`function`};if(Object.keys(e.fctType.parameters).length>0){t.parameters=[];for(let n in e.fctType.parameters){let r={name:n},i=this.transformTypeForStory(e.fctType.parameters[n],this);i&&(r.type=i),t.parameters.push(r)}}let n=this.transformTypeForStory(e.fctType.return,this);n&&(t.return=n),e.kind==`constructor`&&(t.isConstructor=!0);let r=e.node;if(r.typeParameters){t.generics=[];for(let e of r.typeParameters){let n={name:e.name.getText()},r=this.transformTypeForStory(new M(e.default),this);r&&(n.default=r);let i=this.transformTypeForStory(new M(e.constraint),this);i&&(n.constraint=i),t.generics.push(n)}}return t}if(e.kind==`tuple`){let n={kind:`tupple`,tupples:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.tupples.push(e)}return n}if(e.kind==`typeLiteral`){let n={kind:`object`},r=e.node;return(0,p.forEachChild)(r,e=>{if(e.kind==p.SyntaxKind.PropertySignature){let r=e;if(r.type){let e=r.name.getText(),i=new M(r.type),a=this.transformTypeForStory(i,t);a&&(n.keys||={},n.keys[e]=a)}else $.error(`need implements property signature no type `+p.SyntaxKind[e.kind]+` `+t.fileUri)}else if(e.kind==p.SyntaxKind.IndexSignature){let r=e;if(r.parameters.length>0&&r.parameters[0].type){n.indexSignatures||=[];let e=this.transformTypeForStory(new M(r.type),t),i=this.transformTypeForStory(new M(r.parameters[0].type),t);e&&i&&n.indexSignatures.push({keyName:r.parameters[0].name.getText(),keyType:i,type:e})}}else if(e.kind==p.SyntaxKind.TypeLiteral){let r=e,i=this.transformTypeForStory(new M(r),t);i&&(n.array=i)}else $.error(`need implements for `+p.SyntaxKind[e.kind]+` `+t.fileUri)}),n}if(e.kind==`union`){let n={kind:`union`,types:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.types.push(e)}return n}if(e.kind==`intersection`){let n={kind:`intersection`,types:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.types.push(e)}return n}if(e.kind==`typeOperator`){if(e.nested.length>0){let n=this.transformTypeForStory(e.nested[0],t);if(n)return{kind:`typeOperator`,value:e.value,type:n}}return}if(e.kind==`indexedAccess`){if(e.nested.length==2){let n=this.transformTypeForStory(e.nested[0],t),r=this.transformTypeForStory(e.nested[1],t);if(r&&n)return{kind:`indexAccess`,obj:n,key:r}}return}if(e.kind==`mappedType`){if(e.mappedType){let n=this.transformTypeForStory(e.mappedType.parameterType,t),r=this.transformTypeForStory(e.mappedType.type,t);if(n&&r){let t={kind:`mappedType`,parameterName:e.mappedType.parameterName,parameterType:n,type:r};return e.mappedType.modifier&&(t.modifier=e.mappedType.modifier),t}}return}if(e.kind==`infer`)return{kind:`infer`,name:e.value};if(e.kind==`conditional`){if(e.conditionalType){let n=this.transformTypeForStory(e.conditionalType.check,t),r=this.transformTypeForStory(e.conditionalType.extends,t),i=this.transformTypeForStory(e.conditionalType.true,t),a=this.transformTypeForStory(e.conditionalType.false,t);if(r&&i&&a&&n)return{kind:`conditional`,check:n,extends:r,true:i,false:a}}return}e.kind==`mock`&&$.warning(`mock type`)}}loadGenericForStory(e,t){let n=e.name.getText(),r={name:n};if(t||=this.documentation,t?.documentationTemplates[n]&&(r.documentation=t.documentationTemplates[n]),e.constraint){let t=this.transformTypeForStory(new M(e.constraint),this);t&&(r.constraint=t)}if(e.default){let t=this.transformTypeForStory(new M(e.default),this);t&&(r.default=t)}return r}loadParameterForStory(e,t){let n=e.name.getText(),r={name:n},i=this.transformTypeForStory(new M(e.type),this);return i&&(r.type=i),t||=this.documentation,t?.documentationParameters[n]&&(r.documentation=t.documentationParameters[n]),r}setAccessibilityForStroy(e){this.isExported||(e.accessibility=`internal`)}setNamespaceForStroy(e){this.build.noNamespaceUri[this.fileUri]?this.namespace.length>0&&(e.namespace=this.namespace):(e.namespace=this.build.module,this.namespace.length>0&&(e.namespace+=`.`+this.namespace))}setDocumentationForStroy(e){this.documentation&&(e.documentation=this.documentation.definitions.join(`
|
|
243
|
-
`))}},
|
|
242
|
+
`)})}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=E((0,f.normalize)(ze(D(this.parserInfo.document.uri))+`/`+e.moduleName))):(this.name=e.name,this.nameStart=0,this.nameEnd=0,this.isTypeImport=!1,t=e.moduleUri),!P.parsedDoc[t]){let e=R.getInstance().getByUri(t);if(e)P.parse(e,!1,this.parserInfo.build);else{let e=D(t),n=(0,u.existsSync)(e)?(0,u.readFileSync)(e,`utf8`):``,r=new A(d.TextDocument.create(t,C.TypeScript,1,n));P.parse(r,!1,this.parserInfo.build)}}if(P.parsedDoc[t]?.result.isReady){let e=P.parsedDoc[t].result.getBaseInfo(this.name);e?this.info=e:P.addError(this.nameStart,this.nameEnd,`Can't load `+t+` `+this.name+` from `+this.parserInfo.document.uri)}else{if(this.parserInfo.waitingImports[this.alias??this.name])return;this.parserInfo.waitingImports[this.alias??this.name]=[],P.parsedDoc[t].result.onReady(()=>{this.asyncImportLocal(t,this.alias??this.name)})}}asyncImportLocal(e,t){let n=P.parsedDoc[e].result.getBaseInfo(t);if(n){this.info=n;let e=[this.parserInfo.classes,this.parserInfo.enums,this.parserInfo.aliases,this.parserInfo.functions,this.parserInfo.variables];for(let r of e)for(let e in r){let i=r[e],a=Object.values(i.dependencies);for(let e of a)e.uri==`@external`&&e.fullName==t&&(e.uri=`@local`,e.fullName=`$namespace$`+n.fullName)}for(let e of this.parserInfo.waitingImports[t])e(n);delete this.parserInfo.waitingImports[t]}else P.addError(this.nameStart,this.nameEnd,`Can't load `+e+` `+t+` from `+this.parserInfo.document.uri)}},tn=class e{msg=`This code is deprecated`;static is(t){if(t.name==`Deprecated`){let n=new e;if(t.arguments.length>0)try{n.msg=t.arguments[0].value}catch{}return n}return null}},N=class e{static infoByShortName={};static infoByFullName={};static getInfoByShortName(e){return this.infoByShortName[e]}static getInfoByFullName(e,t){e=e.replace(/<.*>/,``);let n=this.infoByFullName[e];return n||=this.infoByFullName[t.fullName.split(`.`)[0]+`.`+e],n}static isExported(e){if(e.modifiers){for(let t of e.modifiers)if(t.kind==p.SyntaxKind.ExportKeyword)return!0}return!1}static isStoryExported(e,t){if(!t.buildConfig.stories)return!1;let n=Ht.buildDecorator(e).find(e=>e.name==`Storybook`);if(n){let e=Kt.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=Ht.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 qt(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(Wt.is(e)){this.isExported=!1;break}}e.infoByFullName[this.fullName]=this}}loadDecorators(){for(let e of this.decorators){let t=Ut.is(e);if(t)for(let e of t.dependencies)this.addDependencyName(e.type,e.strong,0,0);let n=tn.is(e);n&&(this.deprecated=!0,this.deprecatedMsg=n.msg)}}preventDependencyAdd(e){this.dependenciesPrevented.includes(e)||this.dependenciesPrevented.push(e)}loadExpression(e,t=0,n=!1){if($.debug(`***`+t+`. `+e.getText()),$.debug(p.SyntaxKind[e.kind]),e.kind==p.SyntaxKind.ExpressionWithTypeArguments)this.addDependency(e,n);else if(e.kind==p.SyntaxKind.NewExpression){let r=e;this.loadExpression(r.expression,t+1,n)}else if(e.kind==p.SyntaxKind.PropertyAccessExpression){let r=e,i=r.name.getText(),a=P.getBaseInfo(i);if(a&&r.expression.getText()+`.`+i==a.fullName)this.addDependencyName(a.fullName,n,r.getStart(),r.getEnd());else{let e=r.expression.getText();e!=`this`&&!e.includes(`.`)&&(P.hasLocal(e)||P.hasImport(e))&&this.addDependencyName(e,n,r.expression.getStart(),r.expression.getEnd())}this.loadExpression(r.expression,t+1,n)}else if(e.kind==p.SyntaxKind.Identifier){if(e.parent.kind==p.SyntaxKind.PropertyAccessExpression||e.parent.kind==p.SyntaxKind.GetAccessor||e.parent.kind==p.SyntaxKind.SetAccessor||!this.checkParentIdentifier(e))return;let t=e.getText();t!=`this`&&!t.includes(`.`)&&(P.getBaseInfo(t)||P.hasLocal(t)||P.hasImport(t))&&this.addDependencyName(t,n,e.getStart(),e.getEnd())}else if(e.kind==p.SyntaxKind.CallExpression){let r=e;this.loadExpression(r.expression,t+1,n)}}checkParentIdentifier(e){let t=[p.SyntaxKind.VariableDeclaration,p.SyntaxKind.FunctionDeclaration,p.SyntaxKind.ClassDeclaration,p.SyntaxKind.InterfaceDeclaration,p.SyntaxKind.TypeAliasDeclaration,p.SyntaxKind.EnumDeclaration,p.SyntaxKind.ModuleDeclaration,p.SyntaxKind.NamespaceExportDeclaration,p.SyntaxKind.ImportEqualsDeclaration,p.SyntaxKind.ExportAssignment,p.SyntaxKind.ExportDeclaration,p.SyntaxKind.NamespaceExport,p.SyntaxKind.ExportSpecifier,p.SyntaxKind.MissingDeclaration,p.SyntaxKind.MethodDeclaration,p.SyntaxKind.ClassStaticBlockDeclaration],n=[p.SyntaxKind.ImportDeclaration,p.SyntaxKind.ImportClause,p.SyntaxKind.NamespaceImport,p.SyntaxKind.NamedImports,p.SyntaxKind.ImportSpecifier];return t.includes(e.parent.kind)?e.parent.name!=e:n.includes(e.parent.kind)?!1:!(e.parent.kind>=p.SyntaxKind.JsxElement&&e.parent.kind<=p.SyntaxKind.JsxExpression)}loadDependencyContext=void 0;maybeDependencies={};loadOnlyDependenciesRecu(e,t=0,n=!1){this.parserInfo.isExternal||(e.kind==p.SyntaxKind.Decorator&&(this.loadDependencyContext=`Decorator`),(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.TypeReference){this.addDependency(e,n);return}else this.loadExpression(e,t,n);this.loadOnlyDependenciesRecu(e,t+1,n)}),e.kind==p.SyntaxKind.Decorator&&(this.loadDependencyContext=void 0))}addDependency(e,t){if(this.parserInfo.isExternal)return;let n=e=>{if(e.kind==`type`){this.addDependencyName(e.value,t,e.start,e.endNonGeneric);for(let t of e.nested)n(t);for(let t of e.genericValue)n(t)}else if(e.kind==`typeLiteral`||e.kind==`function`)for(let t of e.nested)n(t);else if(e.kind==`union`)for(let t of e.nested)n(t)};n(new M(e))}addDependencyWaitName(e,t,n){if(this.parserInfo.isExternal){n([e.getText()],[e.getText()]);return}let r=[],i=[],a=0,o=!1,s=()=>{!o&&a==0&&(o=!0,n(r,i))},c=(e,n)=>{if(e.kind==`type`){a++,this.addDependencyName(e.value,t,e.start,e.endNonGeneric,(e,t)=>{n==0&&(e&&r.push(e),t&&i.push(t)),a--,s()});for(let t of e.nested)c(t,n+1);for(let r of e.genericValue)t=!1,c(r,n+1)}else if(e.kind==`typeLiteral`||e.kind==`function`)for(let t of e.nested)c(t,n+1);else if(e.kind==`union`)for(let t of e.nested)c(t,n+1)};c(new M(e),0),s()}loadStoryBookInject(){let e=this.build.buildConfig.stories;if(!e)return;let t=this.storieContent;if(!t)return;let n=(e,t)=>{this.storieInject[e]?this.storieInject[e].includes(t)||this.storieInject[e].push(t):this.storieInject[e]=[t]},r=r=>{let i=(0,f.join)(e.output,`generated`),a=(0,f.join)(e.output,`auto`,...this.fullName.split(`.`)),o=Ke(E((0,f.join)(i,...t.namespace.split(`.`))),E(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=Xe(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=en.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(Lt.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=Xe(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=Kt.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=D(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=$t.getFullname(r));else{let r=t.parserInfo.internalObjects[e.value];r?.isStoryExported&&(n.ref=r.fullname)}return n}if(e.kind==`any`||e.kind==`never`||e.kind==`unknown`||e.kind==`boolean`||e.kind==`null`||e.kind==`number`||e.kind==`string`||e.kind==`undefined`||e.kind==`void`||e.kind==`object`||e.kind==`symbol`||e.kind==`this`)return{kind:`simple`,name:e.kind};if(e.kind==`literal`)return{kind:`simple`,name:e.value.slice(1,-1)};if(e.kind==`function`||e.kind==`constructor`){if(!e.fctType)return;let t={kind:`function`};if(Object.keys(e.fctType.parameters).length>0){t.parameters=[];for(let n in e.fctType.parameters){let r={name:n},i=this.transformTypeForStory(e.fctType.parameters[n],this);i&&(r.type=i),t.parameters.push(r)}}let n=this.transformTypeForStory(e.fctType.return,this);n&&(t.return=n),e.kind==`constructor`&&(t.isConstructor=!0);let r=e.node;if(r.typeParameters){t.generics=[];for(let e of r.typeParameters){let n={name:e.name.getText()},r=this.transformTypeForStory(new M(e.default),this);r&&(n.default=r);let i=this.transformTypeForStory(new M(e.constraint),this);i&&(n.constraint=i),t.generics.push(n)}}return t}if(e.kind==`tuple`){let n={kind:`tupple`,tupples:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.tupples.push(e)}return n}if(e.kind==`typeLiteral`){let n={kind:`object`},r=e.node;return(0,p.forEachChild)(r,e=>{if(e.kind==p.SyntaxKind.PropertySignature){let r=e;if(r.type){let e=r.name.getText(),i=new M(r.type),a=this.transformTypeForStory(i,t);a&&(n.keys||={},n.keys[e]=a)}else $.error(`need implements property signature no type `+p.SyntaxKind[e.kind]+` `+t.fileUri)}else if(e.kind==p.SyntaxKind.IndexSignature){let r=e;if(r.parameters.length>0&&r.parameters[0].type){n.indexSignatures||=[];let e=this.transformTypeForStory(new M(r.type),t),i=this.transformTypeForStory(new M(r.parameters[0].type),t);e&&i&&n.indexSignatures.push({keyName:r.parameters[0].name.getText(),keyType:i,type:e})}}else if(e.kind==p.SyntaxKind.TypeLiteral){let r=e,i=this.transformTypeForStory(new M(r),t);i&&(n.array=i)}else $.error(`need implements for `+p.SyntaxKind[e.kind]+` `+t.fileUri)}),n}if(e.kind==`union`){let n={kind:`union`,types:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.types.push(e)}return n}if(e.kind==`intersection`){let n={kind:`intersection`,types:[]};for(let r of e.nested){let e=this.transformTypeForStory(r,t);e&&n.types.push(e)}return n}if(e.kind==`typeOperator`){if(e.nested.length>0){let n=this.transformTypeForStory(e.nested[0],t);if(n)return{kind:`typeOperator`,value:e.value,type:n}}return}if(e.kind==`indexedAccess`){if(e.nested.length==2){let n=this.transformTypeForStory(e.nested[0],t),r=this.transformTypeForStory(e.nested[1],t);if(r&&n)return{kind:`indexAccess`,obj:n,key:r}}return}if(e.kind==`mappedType`){if(e.mappedType){let n=this.transformTypeForStory(e.mappedType.parameterType,t),r=this.transformTypeForStory(e.mappedType.type,t);if(n&&r){let t={kind:`mappedType`,parameterName:e.mappedType.parameterName,parameterType:n,type:r};return e.mappedType.modifier&&(t.modifier=e.mappedType.modifier),t}}return}if(e.kind==`infer`)return{kind:`infer`,name:e.value};if(e.kind==`conditional`){if(e.conditionalType){let n=this.transformTypeForStory(e.conditionalType.check,t),r=this.transformTypeForStory(e.conditionalType.extends,t),i=this.transformTypeForStory(e.conditionalType.true,t),a=this.transformTypeForStory(e.conditionalType.false,t);if(r&&i&&a&&n)return{kind:`conditional`,check:n,extends:r,true:i,false:a}}return}e.kind==`mock`&&$.warning(`mock type`)}}loadGenericForStory(e,t){let n=e.name.getText(),r={name:n};if(t||=this.documentation,t?.documentationTemplates[n]&&(r.documentation=t.documentationTemplates[n]),e.constraint){let t=this.transformTypeForStory(new M(e.constraint),this);t&&(r.constraint=t)}if(e.default){let t=this.transformTypeForStory(new M(e.default),this);t&&(r.default=t)}return r}loadParameterForStory(e,t){let n=e.name.getText(),r={name:n},i=this.transformTypeForStory(new M(e.type),this);return i&&(r.type=i),t||=this.documentation,t?.documentationParameters[n]&&(r.documentation=t.documentationParameters[n]),r}setAccessibilityForStroy(e){this.isExported||(e.accessibility=`internal`)}setNamespaceForStroy(e){this.build.noNamespaceUri[this.fileUri]?this.namespace.length>0&&(e.namespace=this.namespace):(e.namespace=this.build.module,this.namespace.length>0&&(e.namespace+=`.`+this.namespace))}setDocumentationForStroy(e){this.documentation&&(e.documentation=this.documentation.definitions.join(`
|
|
243
|
+
`))}},nn=class extends N{node;type;constructor(e,t,n){super(e,t,n),this.node=e,this.type=new M(this.node.type),this.loadOnlyDependenciesRecu(e)}defineStoryContent(){let e={kind:`type`,name:this.name};this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e);let t=this.transformTypeForStory(new M(this.node.type),this);if(t&&(e.type=t),this.node.typeParameters){e.generics=[];for(let t of this.node.typeParameters)e.generics.push(this.loadGenericForStory(t))}return e}},rn=class e{static is(t){return t.name==`NoCompile`?new e:null}},an=class e{static is(t){return t.name==`BindThis`?new e:null}},on=class{fullStart=0;start=0;end=0;name=``;nameStart=0;nameEnd=0;content=``;documentation;decorators=[];_class;accessibilityModifierTransformation;mustBeCompiled=!0;isStatic=!1;isOverride=!1;isAbstract=!1;isAsync=!1;isPrivate=!1;isProtected=!1;isBindThis=!1;deprecated=!1;deprecatedMsg=``;node;returnType;get compiledContent(){return N.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return N.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return N.getContentNpm(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}constructor(e,t){this.node=e,this._class=t,this.fullStart=e.getFullStart(),this.start=e.getStart(),this.end=e.getEnd(),this.name=e.name.getText(),this.nameStart=e.name.getStart(),this.nameEnd=e.name.getEnd(),this.content=e.getText(),this.decorators=Ht.buildDecorator(e,t),this.returnType=new M(e.type);let n=new qt(e);n.hasDoc&&(this.documentation=n),this.loadAccessibilityModifier(e);let r=null;for(let e of this.decorators)rn.is(e)?this.mustBeCompiled=!1:(r=tn.is(e))&&(this.deprecated=!0,this.deprecatedMsg=r.msg)}loadAccessibilityModifier(e){let t=!1,n=null;for(let e of this.decorators){let t=Wt.is(e);if(t){n=t;continue}let r=Gt.is(e);if(r){n=r;continue}if(an.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 Wt?`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 Wt?(this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:`private`},this.isPrivate=!0):this.isProtected=!0,t=!0):r.kind==p.SyntaxKind.PrivateKeyword?(t=!0,this.isPrivate=!0):r.kind==p.SyntaxKind.OverrideKeyword?this.isOverride=!0:r.kind==p.SyntaxKind.StaticKeyword?this.isStatic=!0:r.kind==p.SyntaxKind.AbstractKeyword?this.isAbstract=!0:r.kind==p.SyntaxKind.AsyncKeyword&&(this.isAsync=!0);!this.documentation&&!this.isOverride&&!this.isPrivate&&P.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name),t===!1&&!this._class.isInterface&&P.addError(this.nameStart,this.nameEnd,`A accessibility modifier (public / private / protected) is mandatory for `+this.name)}},sn=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}},cn=class{name=``;nameStart=0;nameEnd=0;documentation;decorators=[];defaultValueTxt=null;defaultValueStart=0;defaultValueEnd=0;content=``;type;prop;isAbstract=!1;isGet=!1;isSet=!1;isGetSet=!1;isInsideInterface=!1;isStatic=!1;isProtected=!1;isPrivate=!1;isOverride=!1;start=0;end=0;isNullable=!1;overrideNullable=!1;_class;accessibilityModifierTransformation;deprecated=!1;deprecatedMsg=``;get compiledContent(){return N.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return N.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return N.getContentNpm(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValue(){return this.defaultValueTxt===null?null:N.getContent(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueHotReload(){return this.defaultValueTxt===null?null:N.getContentHotReload(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueNpm(){return this.defaultValueTxt===null?null:N.getContentNpm(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}defaultValueStory=null;constructor(e,t,n){this.isInsideInterface=t,this._class=n,this.prop=e,this.name=e.name.getText(),this.nameStart=e.name.getStart(),this.nameEnd=e.name.getEnd(),this.start=e.getStart(),this.end=e.getEnd(),this.content=e.getText(),this.decorators=Ht.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 qt(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=sn.is(e);t&&(this.defaultValueStory=t.value);let n=tn.is(e);n&&(this.deprecated=!0,this.deprecatedMsg=n.msg)}}loadAccessibilityModifier(e){if(this.isInsideInterface)return;let t=!1,n=null;for(let e of this.decorators){let t=Wt.is(e);if(t){n=t;break}let r=Gt.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 Wt?`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 Wt?(this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:`private`},this.isPrivate=!0):this.isProtected=!0,t=!0):r.kind==p.SyntaxKind.PrivateKeyword?(t=!0,this.isPrivate=!0):r.kind==p.SyntaxKind.AbstractKeyword?this.isAbstract=!0:r.kind==p.SyntaxKind.OverrideKeyword?this.isOverride=!0:r.kind==p.SyntaxKind.StaticKeyword&&(this.isStatic=!0);!this.documentation&&!this.isOverride&&!this.isPrivate&&P.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name),t===!1&&P.addError(e.getStart(),e.getEnd(),`A accessibility modifier (public / private / protected) is mandatory for `+this.name)}loadType(e){let t=e,n;return n=t.type?new M(t.type):t.initializer&&t.initializer.kind==p.SyntaxKind.ExpressionWithTypeArguments?new M(t.initializer):new M(null),n}loadInitializer(e){let t=e;t.initializer&&(this.defaultValueTxt=t.initializer.getText(),this.defaultValueStart=t.initializer.getStart(),this.defaultValueEnd=t.initializer.getEnd())}},ln=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 un=[`Callback`,`Aventus.Callback`,`CallbackGroup`,`Aventus.CallbackGroup`];var dn=class extends cn{propType=`Simple`;inParent=!1;arguments},fn=class e extends N{extends=[];extendsNpm=[];implements=[];parentClass=null;methods={};methodsStatic={};properties={};propertiesStatic={};isInterface=!1;isAbstract=!1;constructorBody;constructorParams=[];parameters=[];methodParameters=[];convertibleName=``;extendsType;implementsType=[];extraConstructorCode=[];get isWebcomponent(){return this.implements.includes(`Aventus.DefaultComponent`)&&!this.isInterface}get constructorContent(){if(!this.constructorBody){if(this.extraConstructorCode.length>0){let e=this.parentClass?this.parentClass.constructorParams.map(e=>e.getText()).join():``,t=this.parentClass?this.parentClass.constructorParams.map(e=>e.name.getText()).join():``;return this.parentClass?`constructor(`+e+`) { super(`+t+`);
|
|
244
244
|
`+this.extraConstructorCode.join(`
|
|
245
245
|
`)+` }`:`constructor(`+e+`) {`+this.extraConstructorCode.join(`
|
|
246
246
|
`)+` }`}return``}let e=this.constructorBody.getText();return e=N.getContent(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}get constructorContentHotReload(){if(!this.constructorBody){if(this.extraConstructorCode.length>0){let e=this.parentClass?this.parentClass.constructorParams.map(e=>e.getText()).join():``,t=this.parentClass?this.parentClass.constructorParams.map(e=>e.name.getText()).join():``;return this.parentClass?`constructor(`+e+`) { super(`+t+`);
|
|
@@ -249,18 +249,18 @@ export default preview;`}var Zt=class e{static getFullname(e){let t=e.fullName.r
|
|
|
249
249
|
`)+` }`}return``}let e=this.constructorBody.getText();return e=N.getContentHotReload(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}get constructorContentNpm(){if(!this.constructorBody){if(this.extraConstructorCode.length>0){let e=this.parentClass?this.parentClass.constructorParams.map(e=>e.getText()).join():``,t=this.parentClass?this.parentClass.constructorParams.map(e=>e.name.getText()).join():``;return this.parentClass?`constructor(`+e+`) { super(`+t+`);
|
|
250
250
|
`+this.extraConstructorCode.join(`
|
|
251
251
|
`)+` }`:`constructor(`+e+`) {`+this.extraConstructorCode.join(`
|
|
252
|
-
`)+` }`}return``}let e=this.constructorBody.getText();return e=N.getContentNpm(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}node;constructor(e,t,n){if(super(e,t,n,!1),this.node=e,this.isInterface=e.kind==p.SyntaxKind.InterfaceDeclaration,this.infoType=this.isInterface?3:1,e.typeParameters)for(let t of e.typeParameters)this.parameters.push(t.name.getText());if(e.modifiers)for(let t of e.modifiers)t.kind==p.SyntaxKind.AbstractKeyword&&(this.isAbstract=!0);if(e.heritageClauses)for(let t of e.heritageClauses)this.getClassInheritance(t);(0,p.forEachChild)(e,e=>{let t=!1,n=null;if(e.kind==p.SyntaxKind.Constructor){let t=e;t.body&&(this.constructorBody=t.body),this.constructorParams=Array.from(t.parameters)}else if(e.kind==p.SyntaxKind.PropertyDeclaration){let r=new
|
|
252
|
+
`)+` }`}return``}let e=this.constructorBody.getText();return e=N.getContentNpm(e,this.constructorBody.getStart(),this.constructorBody.getEnd(),this.dependenciesLocations,this.compileTransformations),`constructor(${this.constructorBody.parent.parameters.map(e=>e.getText()).join(`, `)}) `+e}node;constructor(e,t,n){if(super(e,t,n,!1),this.node=e,this.isInterface=e.kind==p.SyntaxKind.InterfaceDeclaration,this.infoType=this.isInterface?3:1,e.typeParameters)for(let t of e.typeParameters)this.parameters.push(t.name.getText());if(e.modifiers)for(let t of e.modifiers)t.kind==p.SyntaxKind.AbstractKeyword&&(this.isAbstract=!0);if(e.heritageClauses)for(let t of e.heritageClauses)this.getClassInheritance(t);(0,p.forEachChild)(e,e=>{let t=!1,n=null;if(e.kind==p.SyntaxKind.Constructor){let t=e;t.body&&(this.constructorBody=t.body),this.constructorParams=Array.from(t.parameters)}else if(e.kind==p.SyntaxKind.PropertyDeclaration){let r=new cn(e,this.isInterface,this);r.isStatic?(this.propertiesStatic[r.name]=r,t=!0):this.properties[r.name]=r;let i=e;i.type||P.addError(i.getStart(),i.getEnd(),`You must define a type for the prop `+r.name),n=r}else if(e.kind==p.SyntaxKind.GetAccessor){let t=e,r=new cn(t,this.isInterface,this);r.isStatic?this.propertiesStatic[r.name]=r:this.properties[r.name]=r,t.type||P.addError(t.getStart(),t.getEnd(),`You must define a type for the prop `+r.name),n=r}else if(e.kind==p.SyntaxKind.SetAccessor){let t=new cn(e,this.isInterface,this);t.isStatic?this.propertiesStatic[`°set°`+t.name]=t:this.properties[`°set°`+t.name]=t,n=t}else if(e.kind==p.SyntaxKind.MethodDeclaration){let t=e;if(t.typeParameters)for(let e of t.typeParameters)this.methodParameters.push(e.name.getText());let r=new on(e,this);r.isStatic?this.methodsStatic[r.name]=r:this.methods[r.name]=r,this.methodParameters=[],n=r}else if(e.kind==p.SyntaxKind.MethodSignature){let t=e;if(t.typeParameters)for(let e of t.typeParameters)this.methodParameters.push(e.name.getText());let r=new on(e,this);r.isStatic?this.methodsStatic[r.name]=r:this.methods[r.name]=r,this.methodParameters=[],n=r}else if(e.kind==p.SyntaxKind.PropertySignature){let r=new cn(e,this.isInterface,this);r.isStatic?(this.propertiesStatic[r.name]=r,t=!0):this.properties[r.name]=r;let i=e;i.type||P.addError(i.getStart(),i.getEnd(),`You must define a type for the prop `+r.name),n=r}if(n&&n.accessibilityModifierTransformation){let e=n.accessibilityModifierTransformation.start+`_`+n.accessibilityModifierTransformation.end;this.compileTransformations[e]=n.accessibilityModifierTransformation}this.loadOnlyDependenciesRecu(e,0,t)}),this.loadConvertible(),this.loadDecorators(),this.addConstructor()}getClassInheritance(t){t.token==p.SyntaxKind.ExtendsKeyword?(0,p.forEachChild)(t,t=>{t.kind==p.SyntaxKind.ExpressionWithTypeArguments&&(this.build.hasStories&&(this.extendsType=new M(t)),this.addDependencyWaitName(t,!0,(t,n)=>{if(t.length>0&&(this.extends.push(t[0]),this.extends.length==1)){let n=N.getInfoByFullName(t[0],this);if(n&&n instanceof e&&(this.parentClass=n,this.parentClass==this))throw this.parentClass=null,`The parent is the child => impossible. Please send it to an admin`}n.length>0&&this.extendsNpm.push(n[0])}),(0,p.forEachChild)(t,e=>{this.loadOnlyDependenciesRecu(e,0,!0)}))}):t.token==p.SyntaxKind.ImplementsKeyword&&(0,p.forEachChild)(t,e=>{e.kind==p.SyntaxKind.ExpressionWithTypeArguments&&(this.build.hasStories&&this.implementsType.push(new M(e)),this.addDependencyWaitName(e,!0,e=>{if(e.length>0)for(let t of e)this.implements.push(t)}))})}addConstructor(){this.extraConstructorCode=[];let e=this.build.isCoreBuild?`DefaultComponent`:`Aventus.DefaultComponent`;this.implements.includes(e)&&!this.isInterface&&this.isAbstract&&this.extraConstructorCode.push(`if (this.constructor == `+this.name+`) { throw "can't instanciate an abstract class"; }`);for(let e in this.methods)this.methods[e].isBindThis&&this.extraConstructorCode.push(`this.${e}=this.${e}.bind(this)`);if(this.extraConstructorCode.length>0)if(this.constructorBody){let e=this.constructorBody.getEnd()-1,t=e+`_`+e;this.compileTransformations[t]={start:e,end:e,newText:`
|
|
253
253
|
`+this.extraConstructorCode.join(`
|
|
254
254
|
`)}}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+`);
|
|
255
255
|
`+this.extraConstructorCode.join(`
|
|
256
256
|
`)+` }`}}else this.compileTransformations[t]={start:e,end:e,newText:`constructor() { `+this.extraConstructorCode.join(`
|
|
257
|
-
`)+` }`}}}loadConvertible(){let e=this;for(;e!=null;){for(let t of e.decorators){let e=
|
|
257
|
+
`)+` }`}}}loadConvertible(){let e=this;for(;e!=null;){for(let t of e.decorators){let e=ln.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(un.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(`__`+Xe(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(`
|
|
258
258
|
`)),t.isAbstract&&i(`abstract`),t.isOverride&&i(`override`),t.isStatic&&i(`static`),t.node.typeParameters){r.generics=[];for(let e of t.node.typeParameters)r.generics.push(this.loadGenericForStory(e,t.documentation))}if(t.node.parameters.length>0){r.parameters=[];for(let e of t.node.parameters)r.parameters.push(this.loadParameterForStory(e,t.documentation))}if(t.node.type){let e=new M(t.node.type),n=this.transformTypeForStory(e,this);if(n){let e={type:n};t.documentation?.documentationReturn&&(e.documentation=t.documentation?.documentationReturn),r.return=e}}}addPropertyStoryContent(e,t){if(!this.canAddToStory(t))return;e.properties||=[];let n={name:t.name,accessibility:t.isPrivate?`private`:t.isProtected?`protected`:`public`};e.properties.push(n),t.documentation&&(n.documentation=t.documentation.definitions.join(`
|
|
259
|
-
`));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}},
|
|
260
|
-
`)),e.properties.push(r)}return e}},
|
|
259
|
+
`));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}},pn=class extends N{node;constructor(e,t,n){super(e,t,n,!1),this.infoType=6,this.node=e}defineStoryContent(){let e={kind:`enum`,name:this.name,properties:[]};this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e);let t=0;for(let n of this.node.members){let r={name:n.name.getText()},i;n.initializer?(i=(0,eval)(n.initializer.getText()),t=i+1):i=t++,r.value=i+``;let a=new qt(n);a.hasDoc&&(r.documentation=a.definitions.join(`
|
|
260
|
+
`)),e.properties.push(r)}return e}},mn=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)}},hn=class extends N{node;constructor(e,t,n){if(super(e,t,n),this.node=e,this.infoType=4,e.typeParameters)for(let t of e.typeParameters)this.preventDependencyAdd(t.name.getText()),t.constraint&&this.addDependency(t.constraint,!0);for(let t of e.parameters)t.type&&this.addDependency(t.type,!1);(0,p.forEachChild)(e,e=>{e.kind==p.SyntaxKind.Block&&this.loadOnlyDependenciesRecu(e,0,!1)})}defineStoryContent(){let e={kind:`function`,name:this.name};if(this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e),this.node.typeParameters){e.generics=[];for(let t of this.node.typeParameters)e.generics.push(this.loadGenericForStory(t))}if(this.node.parameters.length>0){e.parameters=[];for(let t of this.node.parameters)e.parameters.push(this.loadParameterForStory(t))}if(this.node.type){let t=new M(this.node.type),n=this.transformTypeForStory(t,this);if(n){let t={type:n};this.documentation?.documentationReturn&&(t.documentation=this.documentation.documentationReturn),e.return=t}}return e}},gn=class extends N{type=`var`;node;constructor(e,t,n,r){super(e,t,n),this.decorators=Ht.buildDecorator(r,this),this.node=e,this.infoType=5,e.parent.flags==p.NodeFlags.Let?this.type=`let`:e.parent.flags==p.NodeFlags.Const&&(this.type=`const`),this.isExported=N.isExported(r),this.isInternalExported=this.isExported;for(let e of this.decorators)if(Wt.is(e)){this.isExported=!1;break}this.loadOnlyDependenciesRecu(e,0,!0)}defineStoryContent(){let e={kind:`variable`,name:this.name,modifier:this.type==`const`?`const`:this.type==`let`?`let`:`var`};if(this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e),this.node.type){let t=new M(this.node.type),n=this.transformTypeForStory(t,this);n&&(e.type=n)}return e}},P=class e{static waitingUri={};static parsedDoc={};static parse(t,n,r){return e.parsedDoc[t.uri]&&this.parsedDoc[t.uri].version==t.versionInternal?this.parsedDoc[t.uri].result:(new e(t,n,r),e.parsedDoc[t.uri].result)}static parsingDocs=[];static get currentParsingDoc(){return this.parsingDocs.length>0?this.parsingDocs[this.parsingDocs.length-1]:null}static addError(e,t,n){if(this.currentParsingDoc&&!this.currentParsingDoc.isExternal){let r={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(n,`
|
|
261
261
|
`)};this.currentParsingDoc.errors.push(r)}}static addWarning(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.Warning,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(n,`
|
|
262
|
-
`)};this.currentParsingDoc.errors.push(r)}}static getBaseInfo(t,n){let r;if(n)r=this.parsedDoc[n]?.result;else{if(!e.currentParsingDoc)return null;r=e.currentParsingDoc}if(!r)return null;if(r.internalObjects[t]){let e=r.getBaseInfo(t);if(e)return e}if(r.importsLocal[t]?.info)return r.importsLocal[t].info;if(r.packages[t]){let e=r.packages[t].fullname,n=r.build.externalPackageInformation.getByFullName(e);if(n){let t=this.parsedDoc[n.uri].result.getBaseInfo(e);if(t)return t}}for(let e in this.parsedDoc){let n=this.parsedDoc[e].result.getBaseInfo(t);if(n)return n}return null}static hasImport(t){return e.currentParsingDoc?!!(e.currentParsingDoc.importsLocal[t]||e.currentParsingDoc.waitingImports[t]||e.currentParsingDoc.npmImports[t]||e.currentParsingDoc.packages[t]):!1}static hasLocal(t){return e.currentParsingDoc?!!e.currentParsingDoc.internalObjects[t]:!1}content;errors=[];_document;get document(){return this._document}currentNamespace=[];namespaces=[];classes={};functions={};enums={};importsLocal={};manualImportLocal={};packages={};npmImports={};npmGeneratedImport={};internalObjects={};waitingImports={};aliases={};variables={};isExternal=!1;isReady=!1;build;file;srcFile;npmAliases={};deprecated=[];constructor(t,n,r){this.build=r,this.build.npmBuilder.unregister(t.documentUser.uri),this.file=t,e.parsedDoc[t.uri]={version:t.versionInternal,result:this},e.parsingDocs.push(this),this.content=t.documentInternal.getText(),this._document=t.documentInternal,this.isExternal=n;let i=(0,p.createSourceFile)(`sample.ts`,this.content,p.ScriptTarget.ESNext,!0);this.srcFile=i,this.quickLoadRoot(i),this.loadRoot(i),e.parsingDocs.pop(),this.isReady=!0;for(let e of this.readyCb)e();if(this.readyCb=[],e.waitingUri[t.uri]){for(let n of e.waitingUri[t.uri])n();delete e.waitingUri[t.uri]}}readyCb=[];onReady(e){this.isReady||this.readyCb.push(e)}quickLoadRoot(e){(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.ModuleDeclaration){let t=e;
|
|
263
|
-
`)})}loadDeprecated(e){for(let t in e){let n=e[t];n.deprecated&&this.deprecated.push({start:n.nameStart,end:n.nameEnd,msg:n.deprecatedMsg})}}loadClass(e){if(e.name){let t=new
|
|
262
|
+
`)};this.currentParsingDoc.errors.push(r)}}static getBaseInfo(t,n){let r;if(n)r=this.parsedDoc[n]?.result;else{if(!e.currentParsingDoc)return null;r=e.currentParsingDoc}if(!r)return null;if(r.internalObjects[t]){let e=r.getBaseInfo(t);if(e)return e}if(r.importsLocal[t]?.info)return r.importsLocal[t].info;if(r.packages[t]){let e=r.packages[t].fullname,n=r.build.externalPackageInformation.getByFullName(e);if(n){let t=this.parsedDoc[n.uri].result.getBaseInfo(e);if(t)return t}}for(let e in this.parsedDoc){let n=this.parsedDoc[e].result.getBaseInfo(t);if(n)return n}return null}static hasImport(t){return e.currentParsingDoc?!!(e.currentParsingDoc.importsLocal[t]||e.currentParsingDoc.waitingImports[t]||e.currentParsingDoc.npmImports[t]||e.currentParsingDoc.packages[t]):!1}static hasLocal(t){return e.currentParsingDoc?!!e.currentParsingDoc.internalObjects[t]:!1}content;errors=[];_document;get document(){return this._document}currentNamespace=[];namespaces=[];classes={};functions={};enums={};importsLocal={};manualImportLocal={};packages={};npmImports={};npmGeneratedImport={};internalObjects={};waitingImports={};aliases={};variables={};isExternal=!1;isReady=!1;build;file;srcFile;npmAliases={};deprecated=[];constructor(t,n,r){this.build=r,this.build.npmBuilder.unregister(t.documentUser.uri),this.file=t,e.parsedDoc[t.uri]={version:t.versionInternal,result:this},e.parsingDocs.push(this),this.content=t.documentInternal.getText(),this._document=t.documentInternal,this.isExternal=n;let i=(0,p.createSourceFile)(`sample.ts`,this.content,p.ScriptTarget.ESNext,!0);this.srcFile=i,this.quickLoadRoot(i),this.loadRoot(i),e.parsingDocs.pop(),this.isReady=!0;for(let e of this.readyCb)e();if(this.readyCb=[],e.waitingUri[t.uri]){for(let n of e.waitingUri[t.uri])n();delete e.waitingUri[t.uri]}}readyCb=[];onReady(e){this.isReady||this.readyCb.push(e)}quickLoadRoot(e){(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.ModuleDeclaration){let t=e;Rt(t.flags,p.NodeFlags.Namespace)&&t.body?(this.currentNamespace.push(t.name.getText()),this.quickLoadRoot(t),this.currentNamespace.splice(this.currentNamespace.length-1,1)):Rt(t.flags,p.NodeFlags.GlobalAugmentation)&&t.body&&this.quickLoadRoot(t)}else if(e.kind==p.SyntaxKind.ClassDeclaration||e.kind==p.SyntaxKind.InterfaceDeclaration){let t=e;if(t.name){let n=t.name.getText();this.internalObjects[n]={fullname:[...this.currentNamespace,n].join(`.`),isExported:N.isExported(t),isStoryExported:this.build.buildConfig.stories?N.isStoryExported(t,this.build):!1,isCompiled:e.kind==p.SyntaxKind.ClassDeclaration}}}else if(e.kind==p.SyntaxKind.EnumDeclaration){let t=e,n=t.name.getText();this.internalObjects[n]={fullname:[...this.currentNamespace,n].join(`.`),isExported:N.isExported(t),isStoryExported:this.build.buildConfig.stories?N.isStoryExported(t,this.build):!1,isCompiled:!0}}else if(e.kind==p.SyntaxKind.TypeAliasDeclaration){let t=e,n=t.name.getText();this.internalObjects[n]={fullname:[...this.currentNamespace,n].join(`.`),isExported:N.isExported(t),isStoryExported:this.build.buildConfig.stories?N.isStoryExported(t,this.build):!1,isCompiled:!1}}else if(e.kind==p.SyntaxKind.FunctionDeclaration){let t=e;if(t.name){let e=t.name.getText();this.internalObjects[e]={fullname:[...this.currentNamespace,e].join(`.`),isExported:N.isExported(t),isStoryExported:this.build.buildConfig.stories?N.isStoryExported(t,this.build):!1,isCompiled:!0}}}else if(e.kind==p.SyntaxKind.VariableStatement){let t=e;for(let e of t.declarationList.declarations)if(e.kind==p.SyntaxKind.VariableDeclaration){let n=e.name.getText();this.internalObjects[n]={fullname:[...this.currentNamespace,n].join(`.`),isExported:N.isExported(t),isStoryExported:this.build.buildConfig.stories?N.isStoryExported(t,this.build):!1,isCompiled:!0}}}else e.kind==p.SyntaxKind.ModuleBlock&&this.quickLoadRoot(e)})}loadRoot(e){(0,p.forEachChild)(e,e=>{e.kind==p.SyntaxKind.ImportDeclaration?this.loadImport(e):e.kind==p.SyntaxKind.ModuleDeclaration?this.loadNamespace(e):e.kind==p.SyntaxKind.ClassDeclaration||e.kind==p.SyntaxKind.InterfaceDeclaration?this.loadClass(e):e.kind==p.SyntaxKind.EnumDeclaration?this.loadEnum(e):e.kind==p.SyntaxKind.TypeAliasDeclaration?this.loadAlias(e):e.kind==p.SyntaxKind.FunctionDeclaration?this.loadFunction(e):e.kind==p.SyntaxKind.VariableStatement?this.loadVariableStatement(e):e.kind==p.SyntaxKind.ModuleBlock?this.loadRoot(e):(e.kind,p.SyntaxKind.EndOfFileToken)})}loadImport(e){en.Parse(e,this.file,this)}loadNamespace(e){Rt(e.flags,p.NodeFlags.Namespace)&&e.body?(this.namespaces.push(new mn(e)),this.currentNamespace.push(e.name.getText()),this.loadRoot(e),this.currentNamespace.splice(this.currentNamespace.length-1,1)):Rt(e.flags,p.NodeFlags.GlobalAugmentation)&&e.body?this.loadRoot(e):this.errors.push({range:m.Range.create(this.document.positionAt(e.getStart()),this.document.positionAt(e.getEnd())),severity:m.DiagnosticSeverity.Error,source:C.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`Can't use a module, use namespace instead`,`
|
|
263
|
+
`)})}loadDeprecated(e){for(let t in e){let n=e[t];n.deprecated&&this.deprecated.push({start:n.nameStart,end:n.nameEnd,msg:n.deprecatedMsg})}}loadClass(e){if(e.name){let t=new fn(e,this.currentNamespace,this),n=this.isExternal?t.fullName:t.name;this.classes[n]?t.isInterface?this.classes[n].mergeClassInfo(t):(t.mergeClassInfo(this.classes[n]),this.classes[n]=t):this.classes[n]=t,this.defineStorie(this.classes[n]),this.loadDeprecated({[t.name]:t}),this.loadDeprecated(t.methods),this.loadDeprecated(t.methodsStatic),this.loadDeprecated(t.properties),this.loadDeprecated(t.propertiesStatic)}}loadFunction(e){if(e.name){let t=new hn(e,this.currentNamespace,this);this.defineStorie(t);let n=this.isExternal?t.fullName:t.name;this.functions[n]=t,this.loadDeprecated({[t.name]:t})}}loadEnum(e){let t=new pn(e,this.currentNamespace,this);this.defineStorie(t);let n=this.isExternal?t.fullName:t.name;this.enums[n]=t,this.loadDeprecated({[t.name]:t})}loadAlias(e){let t=new nn(e,this.currentNamespace,this);this.defineStorie(t);let n=this.isExternal?t.fullName:t.name;this.aliases[n]=t,this.loadDeprecated({[t.name]:t})}loadVariableStatement(e){N.isExported(e);for(let t of e.declarationList.declarations)t.kind==p.SyntaxKind.VariableDeclaration&&(t.jsDoc=e.jsDoc,this.loadVariable(t,e))}loadVariable(e,t){let n=new gn(e,this.currentNamespace,this,t);this.defineStorie(n);let r=this.isExternal?n.fullName:n.name;this.variables[r]=n,this.loadDeprecated({[n.name]:n})}defineStorie(e){e.loadStorieContent()}getBaseInfo(e){return this.classes[e]?this.classes[e]:this.aliases[e]?this.aliases[e]:this.enums[e]?this.enums[e]:this.functions[e]?this.functions[e]:this.variables[e]?this.variables[e]:null}getBaseInfoFullName(e){let t=e.split(`.`).pop()??e;return this.getBaseInfo(t)}registerGeneratedImport(e){if(!this.build.hasNpmOutput)return;let{uri:t,name:n,compiled:r,alias:i,onlySrc:a,nameAlias:o,forced:s}=e,c=n==i?void 0:i;this.npmGeneratedImport[t]?this.npmGeneratedImport[t].findIndex(e=>e.name==n)==-1&&this.npmGeneratedImport[t].push({name:n,nameAlias:o,compiled:r,alias:c,onlySrc:a,forced:s}):this.npmGeneratedImport[t]=[{name:n,nameAlias:o,compiled:r,alias:c,onlySrc:a,forced:s}]}getNpmReplacementName(e,t){return this.build.getNpmReplacementName(e,t)}},_n=class extends ut{get tsLanguageService(){return this.build.tsLanguageService}_compileResult=[];get compileResult(){return this._compileResult}diagnostics=[];getDiagnostics(){return[...this.diagnostics]}get version(){return this.file.versionUser}get versionInternal(){return this.file.versionInternal}fileParsed=null;get contentForLanguageService(){return this._contentForLanguageService}_contentForLanguageService=``;buildNamespace=``;deprecated={};deprecatedUris=[];constructor(e,t){super(e,t),this.buildNamespace=this.build.getNamespace(e.uri),this.mustBeAddedToLanguageService()&&this.tsLanguageService.addFile(this)}refreshFileParsed(e=!1){this.fileParsed=P.parse(this.file,e,this.build),this._contentForLanguageService=this.file.documentInternal.getText(),this.refreshDeprecated(!0),e||this.replaceNamespace()}async refreshDeprecated(e){}getDeprecated(){let e=[];for(let t in this.deprecated)for(let n of this.deprecated[t])e.push({message:n.msg,range:n.range});return e}replaceNamespace(){if(this.fileParsed)for(let e of this.fileParsed.namespaces){let t=e.bodyStart-e.start,n=``;for(let e=0;e<t;e++)n+=` `;let r=this._contentForLanguageService.substring(0,e.start),i=this._contentForLanguageService.substring(e.bodyStart,this._contentForLanguageService.length);this._contentForLanguageService=r+n+i,t=e.end-e.bodyEnd,n=``;for(let e=0;e<t;e++)n+=` `;r=this._contentForLanguageService.substring(0,e.bodyEnd),i=this._contentForLanguageService.substring(e.end,this._contentForLanguageService.length),this._contentForLanguageService=r+n+i}}validateRules(e){let t=this.fileParsed;if(t){if(!e.allow_function)for(let e in t.functions){let n=t.functions[e];this.diagnostics.push(O(this.file.documentInternal,`Function can only be used inside lib.avt file`,n.nameStart,n.nameEnd,1020))}if(!e.allow_variables)for(let e in t.variables){let n=t.variables[e];this.diagnostics.push(O(this.file.documentInternal,`Variables can only be used inside lib.avt file`,n.nameStart,n.nameEnd,1021))}if(e.class_extend||e.class_implement||e.interface||e.customClassRules){e.class_extend||=[],e.class_implement||=[],e.interface||=[],e.customClassRules||=[];for(let n in t.classes){let r=t.classes[n];for(let t of e.customClassRules)t(r);if(r.isInterface){let t=e.interface.length==0;for(let n of r.extends)if(e.interface.indexOf(n)!=-1){t=!0;break}t||this.diagnostics.push(O(this.file.documentInternal,`Interface `+r.name+` must extend `+e.interface.join(` or `),r.nameStart,r.nameEnd,1017))}else{let t=e.class_extend.length==0,n=e.class_implement.length==0;for(let t of r.implements)if(e.class_implement.indexOf(t)!=-1){n=!0;break}for(let n of r.extends)if(e.class_extend.indexOf(n)!=-1){t=!0;break}n||this.diagnostics.push(O(this.file.documentInternal,`Class `+r.name+` must implement `+e.class_implement.join(` or `),r.nameStart,r.nameEnd,1018)),t||this.diagnostics.push(O(this.file.documentInternal,`Class `+r.name+` must extend `+e.class_extend.join(` or `),r.nameStart,r.nameEnd,1017))}}}e.enum,e.alias}}async onDelete(){this.mustBeAddedToLanguageService()&&this.tsLanguageService.removeFile(this),this.build.npmBuilder.unregister(this.file.uri)}oldFullSrc=[];oldFullDocVisible=``;oldFullDocInvisible=``;oldFullClassScript=``;setCompileResult(e){let t=!1,n=``,r=[],i=``,a=``,o=``;for(let t of e)n+=t.compiled,t.classScript!=``&&r.push({name:t.classScript,src:t.compiled}),i+=t.docVisible,a+=t.docInvisible,o+=t.classScript+`#`;let s=``;for(let e of this.oldFullSrc)s+=e.src;e.length==this.compileResult.length&&this.oldFullClassScript==o&&s==n&&this.oldFullDocVisible==i?this.oldFullDocInvisible!=a&&(t=!0):t=!0;let c=this.oldFullSrc;t&&(this.oldFullDocInvisible=a,this.oldFullDocVisible=i,this.oldFullSrc=r,this.oldFullClassScript=o),this._compileResult=e,t&&(this.emitToHtttpServer(c),this.build.build())}mustBeAddedToLanguageService(){return!0}emitToHtttpServer(e){this.build.reloadPage=!0}onGetBuild(){return[this.build]}};function vn(){return`$namespaceStart$$fullname$ = class $classname$ extends $parentClass$ {
|
|
264
264
|
$watchingAttributes$
|
|
265
265
|
|
|
266
266
|
$getterSetterAttr$
|
|
@@ -305,18 +305,18 @@ $tag$
|
|
|
305
305
|
$exported$
|
|
306
306
|
$definition$
|
|
307
307
|
$namespaceEnd$
|
|
308
|
-
`}var
|
|
308
|
+
`}var yn=class e{writeCompiled=!1;enableWatchHistory=!1;writeHTML=!1;writeComponentTs=!1;static is(t){if(t.name==`Debugger`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);n.writeCompiled=e.writeCompiled==1,n.enableWatchHistory=e.enableWatchHistory==1,n.writeHTML=e.writeHTML==1,n.writeComponentTs=e.writeComponentTs==1}catch{}return n}return null}},bn=class e{static is(t){return t.name==`Required`?new e:null}},xn=class{static allChanges=[];static currentElement;static correct(e,t){var n=(0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0);if(this.allChanges=[],t instanceof fn&&!this.currentElement){this.currentElement=t,(0,p.forEachChild)(n,e=>{var n=e.kind===p.SyntaxKind.InterfaceDeclaration,r=e.kind===p.SyntaxKind.ClassDeclaration;if(!(!n&&!r)){var i=e;for(let e of t.decorators)e.name!=`Debugger`&&this.addChange(e.content+`
|
|
309
309
|
`,i.getStart(),i.getStart());if(i.typeParameters&&i.typeParameters.forEach(e=>{e.constraint&&this.correctType(e.constraint)}),i.heritageClauses)for(let e of i.heritageClauses)this.correctClassInheritance(e);(0,p.forEachChild)(i,e=>{e.kind==p.SyntaxKind.Constructor||e.kind==p.SyntaxKind.MethodDeclaration?this.correctMethod(e):(e.kind==p.SyntaxKind.PropertyDeclaration||e.kind==p.SyntaxKind.GetAccessor||e.kind==p.SyntaxKind.SetAccessor)&&this.correctProperty(e)})}}),this.allChanges.sort((e,t)=>t.end-e.end);for(let t of this.allChanges)e=e.slice(0,t.start)+t.value+e.slice(t.end,e.length);this.currentElement=null}return e}static correctClassInheritance(e){(e.token==p.SyntaxKind.ExtendsKeyword||e.token==p.SyntaxKind.ImplementsKeyword)&&(0,p.forEachChild)(e,e=>{e.kind==p.SyntaxKind.ExpressionWithTypeArguments&&this.correctType(e)})}static correctMethod(e){if(e.type&&this.correctType(e.type),e.typeParameters&&e.typeParameters.forEach(e=>{e.constraint&&this.correctType(e.constraint)}),e.parameters.forEach(e=>{this.correctType(e.type)}),e.name){if(!this.currentElement)return;let t=e.name.getText(),n=this.currentElement.methods[t]??this.currentElement.methodsStatic[t];if(n){let t=n.decorators;for(let n of t)this.addChange(n.content+`
|
|
310
310
|
`,e.getStart(),e.getStart())}}}static correctProperty(e){if(e.type&&this.correctType(e.type),!this.currentElement)return;let t=e.name.getText(),n=this.currentElement.properties[t]??this.currentElement.propertiesStatic[t];if(n){let t=n.decorators;for(let n of t)this.addChange(n.content+`
|
|
311
|
-
`,e.getStart(),e.getStart())}}static addChange(e,t,n){this.allChanges.push({start:t,end:n,value:e})}static addChangeType(e,t,n){if(this.currentElement){let r=this.currentElement.parserInfo.getBaseInfo(e);r&&e!=r.fullName&&this.addChange(r.fullName,t,n)}}static correctType(e){if(e){if(e.kind===p.SyntaxKind.TypeReference){var t=e;let n=this.parseQualified(t.typeName);n&&(this.addChangeType(n,t.getStart(),t.getEnd()),t.typeArguments&&t.typeArguments.forEach(e=>{this.correctType(e)}))}else if(e.kind===p.SyntaxKind.ArrayType){var n=e;this.correctType(n.elementType)}else if(e.kind===p.SyntaxKind.UnionType){var r=e;for(let e of r.types)this.correctType(e)}else if(e.kind===p.SyntaxKind.ExpressionWithTypeArguments){var i=e;let t=this.parseQualified2(i.expression);t&&(this.addChangeType(t,i.expression.getStart(),i.expression.getEnd()),i.typeArguments&&i.typeArguments.forEach(e=>{this.correctType(e)}))}}}static parseQualified2(e){let t=``;if(e.expression)if(e.expression.kind===p.SyntaxKind.PropertyAccessExpression){let n=this.parseQualified2(e.expression);n&&(t=n+`.`)}else e.expression.kind===p.SyntaxKind.Identifier&&(t=e.expression.text+`.`);return e.name?t+e.name.text:t+e.text}static parseQualified(e){if(e.kind===p.SyntaxKind.Identifier)return e.text;var t=e;return this.parseQualified(t.left)+`.`+this.parseQualified(t.right)}},
|
|
312
|
-
`,t[a].parts.push({startDef:r.start,endDef:r.end,startVirtual:o,endVirtual:t[a].text.length})}};n(e.classes),n(e.aliases),n(e.enums),n(e.functions),n(e.variables);for(let e in t)if(e){let n=this.file.name.replace(w.Package,``)+`:`+e+w.Package;this.packagesFiles.push(new
|
|
313
|
-
`)}`;r.reportsUnnecessary?n.push({range:
|
|
314
|
-
import from `+i,n.newText=n.newText.replace(r[1],i)}}e.additionalTextEdits.push({newText:n.newText,range:
|
|
311
|
+
`,e.getStart(),e.getStart())}}static addChange(e,t,n){this.allChanges.push({start:t,end:n,value:e})}static addChangeType(e,t,n){if(this.currentElement){let r=this.currentElement.parserInfo.getBaseInfo(e);r&&e!=r.fullName&&this.addChange(r.fullName,t,n)}}static correctType(e){if(e){if(e.kind===p.SyntaxKind.TypeReference){var t=e;let n=this.parseQualified(t.typeName);n&&(this.addChangeType(n,t.getStart(),t.getEnd()),t.typeArguments&&t.typeArguments.forEach(e=>{this.correctType(e)}))}else if(e.kind===p.SyntaxKind.ArrayType){var n=e;this.correctType(n.elementType)}else if(e.kind===p.SyntaxKind.UnionType){var r=e;for(let e of r.types)this.correctType(e)}else if(e.kind===p.SyntaxKind.ExpressionWithTypeArguments){var i=e;let t=this.parseQualified2(i.expression);t&&(this.addChangeType(t,i.expression.getStart(),i.expression.getEnd()),i.typeArguments&&i.typeArguments.forEach(e=>{this.correctType(e)}))}}}static parseQualified2(e){let t=``;if(e.expression)if(e.expression.kind===p.SyntaxKind.PropertyAccessExpression){let n=this.parseQualified2(e.expression);n&&(t=n+`.`)}else e.expression.kind===p.SyntaxKind.Identifier&&(t=e.expression.text+`.`);return e.name?t+e.name.text:t+e.text}static parseQualified(e){if(e.kind===p.SyntaxKind.Identifier)return e.text;var t=e;return this.parseQualified(t.left)+`.`+this.parseQualified(t.right)}},Sn=class e{refType=``;constructor(e){this.refType=e}static is(t){if(t.name==`ForeignKey`&&t.arguments.length>0)try{if(t.arguments[0].type==`identifier`)return new e(t.arguments[0].value)}catch{}return null}},Cn=class extends ut{static getQuickInfo(e){try{if(/\/\/#region js def \/\/([\s\S]*?)\/\/#endregion js def \/\//.test(e.contentUser)){let t=/^\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)$/gm.exec(e.contentUser);if(t)return{name:t[1],version:{major:Number(t[2]),minor:Number(t[3]),patch:Number(t[4])}}}}catch(e){console.error(e)}}tsFile=null;tsDef=null;srcInfo={namespace:``,available:[],existing:[]};externalCSS={};name=``;npmUri=``;description=``;version={major:1,minor:0,patch:0};get versionTxt(){return this.version.major+`.`+this.version.minor+`.`+this.version.patch}get classInfoByName(){return this.tsDef?.classInfoByName||{}}get fileParsed(){return this.tsDef?.fileParsed||null}get definition(){return this.tsFile.contentUser}dependencies={};constructor(e,t){super(e,t),this.prepareFile()}async refreshDeprecated(e){this.tsDef&&await this.tsDef.refreshDeprecated(e)}loadWebComponents(){this.tsDef?.loadWebComponents()}prepareFile(){let e=this.separeSection();if(e){let t=d.TextDocument.create(this.file.uri,C.TypeScript,this.file.versionUser,e.jsDef);this.tsFile?this.tsFile.triggerContentChange(t):(this.tsFile=new A(t),this.tsDef=new wn(this.tsFile,this.build));try{this.srcInfo=JSON.parse(e.jsSrc)}catch{}try{let t=JSON.parse(e.scssDefTxt);this.build.scssLanguageService.addExternalDefinition(this.file.uri,t)}catch{}try{this.externalCSS=JSON.parse(e.scssTxt)}catch{}try{let t=JSON.parse(e.htmlTxt);this.build.htmlLanguageService.addExternalDefinition(this.file.uri,t)}catch{}try{this.dependencies=JSON.parse(e.depsTxt)}catch{}this.build.externalPackageInformation.rebuild()}}separeSection(){if(this.file.contentUser.match(/\/\/#region js def \/\/([\s\S]*?)\/\/#endregion js def \/\//g)){let e=/^\/\/ (\S+):([0-9]+)\.([0-9]+)\.([0-9]+)$/gm.exec(this.file.contentUser);e&&(this.name=e[1],this.version.major=Number(e[2]),this.version.minor=Number(e[3]),this.version.patch=Number(e[4]));let t=/([\s\S]*?)\/\/#endregion js def \/\//g.exec(this.file.contentUser),n=``;t&&(n=t[0]);let r=/\/\/#region js src \/\/([\s\S]*?)\/\/#endregion js src \/\//g.exec(this.file.contentUser),i=``;r&&(i=r[1]);let a=/\/\/#region css \/\/([\s\S]*?)\/\/#endregion css \/\//g.exec(this.file.contentUser),o=``;a&&(o=a[1]);let s=/\/\/#region css def \/\/([\s\S]*?)\/\/#endregion css def \/\//g.exec(this.file.contentUser),c=``;s&&(c=s[1]);let l=/\/\/#region html \/\/([\s\S]*?)\/\/#endregion html \/\//g.exec(this.file.contentUser),u=``;l&&(u=l[1]);let d=/\/\/#region dependencies \/\/([\s\S]*?)\/\/#endregion dependencies \/\//g.exec(this.file.contentUser),f=``;return d&&(f=d[1]),{jsDef:n,jsSrc:i,scssDefTxt:c,scssTxt:o,htmlTxt:u,depsTxt:f}}return null}async onContentChange(){this.prepareFile(),this.build.reloadPage=!0,this.build.build()}async onValidate(){return[]}async onSave(){}async onDelete(){this.build.scssLanguageService.removeExternalDefinition(this.file.uri),this.build.htmlLanguageService.removeExternalDefinition(this.file.uri),this.tsFile&&this.tsFile.triggerDelete()}async onCompletion(e,t){return{isIncomplete:!0,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.tsFile?this.tsFile.getHover(t):null}async onDefinition(e,t){return this.tsFile?await this.tsFile.getDefinition(t):null}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return this.tsFile?this.tsFile.getReferences(t):[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}onGetBuild(){return[this.build]}transformPosition(e,t,n,r){let i=e.file.documentUser.offsetAt(t);return n.file.documentUser.positionAt(i-r)}},wn=class extends _n{_classInfoByName={};packagesFiles=[];get extension(){return w.Package}get classInfoByName(){return this._classInfoByName}constructor(e,t){super(e,t)}loadWebComponents(){try{this.refreshFileParsed(!0);let e=this.fileParsed;if(e){this.loadFilePackage();for(let t in e.classes){let n=e.classes[t],r=!1;for(let e of n.implements){if(e==`Aventus.DefaultComponent`){r=!0;break}if(e==`Aventus.IData`)break}r&&(this._classInfoByName[n.fullName]=n)}}}catch(e){let t=this.file.uri.split(`/`),n=t[t.length-1];$.showErrorMessage(`There is an error inside file :`+n),$.error(e)}}loadFilePackage(){try{this.deletePackageFile();let e=this.fileParsed;if(e){let t={},n=e=>{for(let n in e){let r=e[n],i=r.fullName.split(`.`);i.pop();let a=i.join(`.`);t[a]||(t[a]={text:``,parts:[]});let o=t[a].text.length;t[a].text+=`export import ${r.name} = ${r.fullName};
|
|
312
|
+
`,t[a].parts.push({startDef:r.start,endDef:r.end,startVirtual:o,endVirtual:t[a].text.length})}};n(e.classes),n(e.aliases),n(e.enums),n(e.functions),n(e.variables);for(let e in t)if(e){let n=this.file.name.replace(w.Package,``)+`:`+e+w.Package;this.packagesFiles.push(new Tn(t[e],n,this.build,this))}}}catch(e){$.error(e)}}deletePackageFile(){let e=[...this.packagesFiles];this.packagesFiles=[];for(let t of e)t.internalFile.triggerDelete()}async onContentChange(){this.loadWebComponents()}async onValidate(){return[]}async onSave(){}async onCompletion(e,t){return{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return null}async onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}async onDelete(){await super.onDelete()}},Tn=class extends _n{get extension(){return w.Package}internalFile;info;packageFile;constructor(e,t,n,r){let i=new A(d.TextDocument.create(`file:///`+t,C.TypeScript,1,e.text));i.triggerDelete(),super(i,n),this.info=e,this.internalFile=i,this._contentForLanguageService=e.text,this.fileParsed=r.fileParsed,this.packageFile=r}async goToDefinition(e){let t=this.file.documentInternal.offsetAt(e.start),n=this.file.documentInternal.offsetAt(e.end),r=n-t;for(let e of this.info.parts)if(t>=e.startVirtual&&n<=e.endVirtual){let n=t-e.startVirtual,i=e.startDef+n-7,a=i+r,o=this.packageFile.file.documentInternal.positionAt(i),s=this.packageFile.file.documentInternal.positionAt(a);return[{uri:this.packageFile.file.uri,range:{start:o,end:s}}]}return null}async onContentChange(){}async onValidate(){return[]}async onSave(){}async onCompletion(e,t){return{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){return t}async onHover(e,t){return null}async onDefinition(e,t){return null}async onFormatting(e,t,n){return[]}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}},En=class e{languageService;languageServiceNamespace;build;filesNeeded=[];filesNpm=[];filesNpmLoaded=!1;filesLoaded={};i18nFiles={};constructor(e){this.build=e,Pt(),this.onSettingsChanged(e),T.getInstance().onSettingsChange(()=>{this.onSettingsChanged(e)}),this.languageService=(0,p.createLanguageService)(this.createHost()),this.languageServiceNamespace=(0,p.createLanguageService)(this.createHostNamespace())}onSettingsChanged(e){let t=T.getInstance().settings.readNodeModules;t!=this.filesNpmLoaded&&(t?this.filesNpm=Ft((0,f.join)(e.project.getConfigFile().folderPath,`node_modules`)):this.filesNpm=[],this.filesNpmLoaded=t)}createHostNamespace(){let e=this;return{getCompilationSettings:()=>Dn,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].version+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionUser+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:It(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:It(e),fileExists:e=>(e.endsWith(w.Base+`.ts`)&&(e=e.replace(w.Base+`.ts`,w.Base)),this.filesLoaded[e]||this.i18nFiles[e]?!0:!!It(e)),directoryExists:e=>(0,u.existsSync)(D(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}createHost(){let e=this;return{getCompilationSettings:()=>Dn,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].versionInternal+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionInternal+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].contentForLanguageService:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:It(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>{let n;if(this.filesLoaded[e])n=this.filesLoaded[e].contentForLanguageService;else if(this.i18nFiles[e])return this.i18nFiles[e].file.contentInternal;else n=It(e);return n},fileExists:e=>{let t=!1;if(e.endsWith(w.Base+`.ts`)&&(e=e.replace(w.Base+`.ts`,w.Base)),this.filesLoaded[e])t=!0;else if(this.i18nFiles[e])return!0;else t=!!It(e);return t},directoryExists:e=>(0,u.existsSync)(D(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}resolveModuleNames(e,t,n,r,i,a,o){let s=[];for(let r of t){if(!r.startsWith(`.`)&&r.endsWith(w.Package)){let e={extension:p.Extension.Ts,resolvedFileName:`file:///`+r};s.push(e);continue}let t=R.getInstance().getByUri(n);t&&(r=this.build.project.resolveAlias(r,t));let i=(0,p.resolveModuleName)(r,n,Dn,e);if(i.resolvedModule)i.resolvedModule.resolvedFileName.endsWith(`.avt.ts`)&&(i.resolvedModule.resolvedFileName=i.resolvedModule.resolvedFileName.replace(`.avt.ts`,`.avt`)),s.push(i.resolvedModule);else{let e={extension:p.Extension.Ts,resolvedFileName:r};s.push(e)}}return s}addFile(e){this.filesNeeded.indexOf(e.file.uri)==-1&&(this.filesNeeded.push(e.file.uri),this.filesLoaded[e.file.uri]=e)}removeFile(e){let t=this.filesNeeded.indexOf(e.file.uri);t!=-1&&(this.filesNeeded.splice(t,1),delete this.filesLoaded[e.file.uri])}doValidation(e){try{let t=[1206,1249,2612],n=[],r=this.languageService.getSyntacticDiagnostics(e.uri),i=this.languageService.getSemanticDiagnostics(e.uri),a=r.concat(i);for(let r of a){if(t.includes(r.code))continue;let i=`${(0,p.flattenDiagnosticMessageText)(r.messageText,`
|
|
313
|
+
`)}`;r.reportsUnnecessary?n.push({range:Be(e.documentInternal,r),severity:m.DiagnosticSeverity.Hint,source:C.TypeScript,message:i,tags:[m.DiagnosticTag.Unnecessary]}):n.push({range:Be(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=Be(n,Ge(n.getText(),r)),a;try{a=this.languageService.getCompletionsAtPosition(n.uri,r,kn)}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:jn(t.kind),textEdit:m.TextEdit.replace(i,s),additionalTextEdits:c,data:{...t.data,...l}};o.push(u)}return{isIncomplete:!1,items:o}}catch(e){this.printCatchError(e)}return{isIncomplete:!1,items:[]}}async doResolve(e){try{if(e.data){let t=this.build.tsFiles[e.data.uri];if(t!=null){let n={languageId:e.data.languageIdJs,offset:e.data.offset,uri:e.data.uri};delete e.data.languageId,delete e.data.offset,delete e.data.uri,Object.keys(e.data).length==0&&(e.data=void 0);let r=this.languageService.getCompletionEntryDetails(n.uri,n.offset,e.label,{},t.file.contentInternal,kn,e.data);if(r){if(e.detail=(0,p.displayPartsToString)(r.displayParts),e.documentation=(0,p.displayPartsToString)(r.documentation),e.additionalTextEdits=[],r.codeActions)for(let n=0;n<r.codeActions.length;n++)for(let i of r.codeActions[n].changes)for(let n of i.textChanges){n.newText=De(n.newText.replace(/'/g,`"`));let r=/"(.*)"/g.exec(n.newText);if(r&&r.length>1){if(r[0].includes(w.Package)){let e=r[1];e=this.filesNeeded.find(t=>t.toLowerCase()==e)??e,e=e.replace(`file:///`,``).replace(/\.\.\//g,``),n.newText=n.newText.replace(r[1],e)}else if(r[1].startsWith(`.`)){let i=this.simplifyPath(r[1],t.file.uri);e.detail+=`
|
|
314
|
+
import from `+i,n.newText=n.newText.replace(r[1],i)}}e.additionalTextEdits.push({newText:n.newText,range:Be(t.file.documentInternal,n.span)})}delete e.data}}}}catch(e){this.printCatchError(e)}return e}async doHover(e,t){try{let n=this.languageService.getQuickInfoAtPosition(e.uri,e.documentInternal.offsetAt(t));if(n){let t=[],r=[];if(n.documentation)for(let e of n.documentation)t.push(`${e.text.trim()}`),r.push(e.text.trim());if(n.tags){r.push(` `);for(let e of n.tags){if(e.name===`inheritdoc`)continue;let n=!0,i=[];if(e.text)for(let t of e.text){if(t.kind==`text`&&t.text==r.join(``)){n=!1;break}i.push(t.text)}if(!n)continue;let a=i.join(``).trim();e.name===`example`?t.push(`\`@${e.name}\`\n\`\`\`typescript\n${a}\n\`\`\``):t.push(`\`@${e.name}\` ${a}`)}}let i=``;return n.displayParts&&(i+="\n```typescript\n",i+=(0,p.displayPartsToString)(n.displayParts).trim(),i+=`
|
|
315
315
|
\`\`\`
|
|
316
316
|
***
|
|
317
317
|
`),i+=t.join(`
|
|
318
318
|
|
|
319
|
-
`),{range:
|
|
319
|
+
`),{range:Be(e.documentInternal,n.textSpan),contents:{kind:`markdown`,value:i}}}}catch(e){this.printCatchError(e)}return null}getType(e,t){try{let n=this.languageService.getProgram();if(!n)return;let r=n.getSourceFile(e.file.uri);if(!r)return;let i=n.getTypeChecker(),a=(0,p.getTokenAtPosition)(r,t),o=i.getTypeAtLocation(a),s=e=>{if(e.isUnion()){let t=[];for(let n of e.types)t.push(s(n));return t.join(` | `)}else if(e.isIntersection()){let t=[];for(let n of e.types)t.push(s(n));return t.join(` & `)}else if(e.isNumberLiteral())return e.value+``;else if(e.isStringLiteral())return`"`+e.value+`"`;else if(e.isLiteral())return e.value+``;return i.typeToString(e,a,p.TypeFormatFlags.UseFullyQualifiedType)},c=s(o);if(c.includes(`.`))return c;if(e.fileParsed)for(let t in e.fileParsed.importsLocal){if(t==c)return c;let n=e.fileParsed.importsLocal[t];if(n.realName===void 0){let e=(0,p.getTokenAtPosition)(r,(n.nameEnd+n.nameStart)/2),t=i.getTypeAtLocation(e);n.realName=i.typeToString(t)}if(c==n.realName)return t}return c}catch(e){this.printCatchError(e)}}async findDefinition(e,t){let n=[];try{let r=e.documentInternal.offsetAt(t),i=this.languageService.getDefinitionAtPosition(e.uri,r);if(i&&i.length>0){for(let e of i){e.fileName.endsWith(`.avt.ts`)&&(e.fileName=e.fileName.replace(`.avt.ts`,`.avt`));let t=this.filesLoaded[e.fileName];if(t instanceof Tn){let r=await t.goToDefinition(Be(t.file.documentInternal,e.textSpan));r&&!Array.isArray(r)&&(r=[r]),r&&(n=[...r])}else if(t)n.push({uri:t.file.uri,range:Be(t.file.documentInternal,e.textSpan)});else{let t=It(e.fileName);if(t){let r=d.TextDocument.create(e.fileName,`typescript`,1,t);n.push({uri:e.fileName,range:Be(r,e.textSpan)})}}}return n}else if(i&&i.length==0){let t=this.languageService.getProgram();if(t){let i=t.getSourceFile(e.uri);if(i){let a=t.getTypeChecker(),o=(0,p.getTokenAtPosition)(i,r),s=a.getTypeAtLocation(o);if(s.isStringLiteral()){let t=e=>{for(let t in this.i18nFiles){let r=this.i18nFiles[t];if(r.parsed&&r.parsed[e]){let i=r.file.documentUser.positionAt(r.parsed[e].keyStart),a=r.file.documentUser.positionAt(r.parsed[e].keyEnd);n.push({uri:t,range:m.Range.create(i,a)})}}},r=o.parent.getText();if(r.startsWith(`t(`)){let e=s.value;t(e)}else if(r.startsWith(`this.t(`)){let r=s.value,i=this.build.tsFiles[e.uri];if(i instanceof F&&i.I18nFile?.parsed&&i.I18nFile?.parsed[r]){let e=i.I18nFile,t=i.I18nFile.parsed[r],a=e.file.documentUser.positionAt(t.keyStart),o=e.file.documentUser.positionAt(t.keyEnd);n.push({uri:i.I18nFile.file.uri,range:m.Range.create(a,o)})}t(r)}}}}}}catch(e){this.printCatchError(e)}return n}async format(e,t,n,r=!0){try{let i=e.documentInternal,a=i.offsetAt(t.start),o=i.offsetAt(t.end),s=null;t.end.line>t.start.line&&(t.end.character===0||Mn(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={...An};r?c.semicolons=p.SemicolonPreference.Insert:c.semicolons=p.SemicolonPreference.Remove;let l=this.languageServiceNamespace.getFormattingEditsForRange(i.uri,a,o,c);if(l){let e=[];for(let t of l)t.span.start>=a&&t.span.start+t.span.length<=o&&e.push({range:Be(i,t.span),newText:t.newText});return s&&e.push({range:s,newText:Nn(0,n)}),e}}catch(e){this.printCatchError(e)}return[]}async doCodeAction(e,t){let n=[];try{let r=P.parse(e,!1,this.build),i=e.documentInternal,a=this.languageService.getSyntacticDiagnostics(i.uri),o=this.languageService.getSemanticDiagnostics(i.uri),s=[];for(let e of a)s.push(e.code);for(let e of o)e.code!=6133&&s.push(e.code);let c=[];try{c=this.languageService.getCodeFixesAtPosition(i.uri,i.offsetAt(t.start),i.offsetAt(t.end),s,An,kn)}catch{}for(let t of c){let a=[],o={changes:{[i.uri]:a}};for(let n of t.changes)for(let o of n.textChanges){if(t.description.startsWith(`Add import from`)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let n=this.simplifyPath(e[1],i.uri);t.description=`Add import from `+n,o.newText=o.newText.replace(e[1],n)}}else if(t.fixName===`fixClassDoesntImplementInheritedAbstractMember`){let t=!1;for(let e in r.classes){let n=r.classes[e];o.span.start>=n.start&&o.span.start<=n.end&&(t=!0)}if(t){let t=Fn(e,`methods`);t!=-1&&(o.span.start=t),o.newText.match(/ (public|protected) /g)||(o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),o.newText.match(/(public|protected)[ ]*?override/g)||(o.newText=o.newText.replace(/((public|protected)[ ]*?)([a-z])/g,`$1override $3`)),o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(o.newText.startsWith(`import `)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);o.newText=o.newText.replace(e[1],t)}}}else if(t.fixName==`fixClassIncorrectlyImplementsInterface`){let t=!1;for(let e in r.classes){let n=r.classes[e];o.span.start>=n.start&&o.span.start<=n.end&&(t=!0)}if(t){let t=Fn(e,`methods`);t!=-1&&(o.span.start=t),!o.newText.includes(` protected `)&&!o.newText.includes(` public `)&&(o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),o.newText=o.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(o.newText.startsWith(`import `)){o.newText=o.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(o.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);o.newText=o.newText.replace(e[1],t)}}}a.push({newText:o.newText,range:Be(i,o.span)})}n.push({title:t.description,edit:o})}}catch(e){this.printCatchError(e)}return n}async onReferences(e,t){let n=[];try{let r=e.documentInternal.offsetAt(t),i=this.languageService.findReferences(e.uri,r);if(i){for(let e of i)for(let t of e.references)if(this.filesLoaded[t.fileName]){let e=this.filesLoaded[t.fileName].file.documentInternal.positionAt(t.textSpan.start),r=this.filesLoaded[t.fileName].file.documentInternal.positionAt(t.textSpan.start+t.textSpan.length);n.push(m.Location.create(t.fileName,{start:e,end:r}))}}}catch(e){this.printCatchError(e)}return n}async onCodeLens(e){let t=[];try{let n=this.filesLoaded[e.uri];if(n&&n.fileParsed){let r=async n=>{for(let r of n){let n=e.documentInternal.positionAt(r.start),i=await this.onReferences(e,n),a=i.length>1?i.length+` references`:i.length+` reference`;t.push({range:{start:n,end:n},command:{title:a,command:i.length?`editor.action.showReferences`:``,arguments:[e.uri,n,i]}})}};await r(Object.values(n.fileParsed.classes)),await r(Object.values(n.fileParsed.enums)),await r(Object.values(n.fileParsed.aliases))}let r=Fn(e,`props`);if(r!=-1){let n=e.documentInternal.positionAt(r);t.push({range:{start:n,end:n},command:{title:`Add property | attribute`,command:`editor.action.showReferences`,arguments:[e.uri]}})}}catch(e){this.printCatchError(e)}return t}async onRename(e,t,n){this.languageService.getFileReferences(e.uri);let r=e.documentInternal.offsetAt(t),i={};if(!this.languageService.getRenameInfo(e.uri,r,i).canRename)return null;let a=this.languageService.findRenameLocations(e.uri,r,!1,!1,i);if(!a)return null;let o={changes:{}};if(o.changes){for(let e of a)if(this.filesLoaded[e.fileName]){o.changes[e.fileName]||(o.changes[e.fileName]=[]);let t={newText:n,range:{start:this.filesLoaded[e.fileName].file.documentInternal.positionAt(e.textSpan.start),end:this.filesLoaded[e.fileName].file.documentInternal.positionAt(e.textSpan.start+e.textSpan.length)}};o.changes[e.fileName].push(t)}}return o}async onRenameFile(e,t){let n={},r=this.languageService.getFileReferences(e);for(let e of r){let r=R.getInstance().getByUri(e.fileName);if(r){let i=[],a=r.folderUri.split(`/`),o=t.split(`/`);for(;a.length>0&&o.length>0&&a[0]==o[0];)a.splice(0,1),o.splice(0,1);let s=[];if(a.length>0)for(let e=0;e<a.length;e++)s.push(`..`);else s.push(`.`);for(let e of o)s.push(e);i.push({newText:s.join(`/`),range:{start:r.documentInternal.positionAt(e.textSpan.start),end:r.documentInternal.positionAt(e.textSpan.start+e.textSpan.length)}}),n[r.uri]=i}}return n}static removeComments(e){return e=e.replace(/(\".*?\"|\'.*?\')|(\/\*.*?\*\/|\/\/[^(\r\n|\n)]*$)/gm,(e,t,n)=>n?``:t),e}static removeEmptyComments(e){return e=e.replace(/\/\*. \*\//gm,(e,t,n)=>n?``:t),e}static prepareDataSchema(e,t,n){let r={},i=r=>{let i=(()=>{if(r.kind==`boolean`)return`boolean`;if(r.kind==`number`)return`number`;if(r.kind==`string`)return`string`;if(r.kind==`type`){if(r.value.includes(`.`))return r.value;{let i=e.parserInfo.importsLocal[r.value]?.info;return i?n?i.name:t+`.`+i.fullName:r.value}}else if(r.kind==`literal`||r.kind==`typeLiteral`)return`literal`;return null})();return i&&r.isArray&&(i+=`[]`),i};for(let a in e.properties){let o=e.properties[a];if(o.isStatic)continue;let s=!1;for(let i of o.decorators){let o=Sn.is(i);if(o){s=!0;let i=e.parserInfo.importsLocal[o.refType]?.info;o.refType.includes(`.`)?r[a]=`ref:`+o.refType:i?r[a]=`ref:`+(n?i.name:t+`.`+i.fullName):r[a]=`ref:`+o.refType}}if(!s){let e=i(o.type);e&&(r[a]=e)}}let a=JSON.stringify(r).replace(/\\"/g,`"`);return e.parentClass&&(a=`{...(${n?e.extendsNpm[0]:e.parentClass.fullName}?.$schema ?? {}), ${a.slice(1)}`),a}static compileTs(e,t){let n={compiled:``,hotReload:``,docVisible:``,docInvisible:``,dependencies:Object.values(e.dependencies),classScript:``,classDoc:``,debugTxt:``,uri:t.file.uri,required:!1,type:e.infoType,isExported:{external:e.isExported,internal:e.isInternalExported},convertibleName:``,npm:{defTs:``,namespace:``,exportPath:``,uri:t.file.uri,src:``},useDecorator:!1};try{let r=``,i=``,a=e.compiledContent,o=e.compiledContentDoc,s=e.compiledContentHotReload,c=t.build.module;if(e instanceof fn&&!e.isInterface){let t=`Aventus.`;e.build.isCoreBuild&&(t=``);let a=``;e.namespace&&(a=`.`+e.namespace),r+=e.fullName+".Namespace=`"+c+a+`\`;
|
|
320
320
|
`,i+=e.name+".Namespace=`"+c+a+`\`;
|
|
321
321
|
`,e.implements.includes(t+`IData`)&&(n.type=2),e.convertibleName?(r+=e.fullName+`.$schema=`+this.prepareDataSchema(e,c)+`;
|
|
322
322
|
`,i+=e.name+`.$schema=`+this.prepareDataSchema(e,c)+`;
|
|
@@ -326,29 +326,29 @@ import from `+i,n.newText=n.newText.replace(r[1],i)}}e.additionalTextEdits.push(
|
|
|
326
326
|
`,i+=e.name+`.$schema=`+this.prepareDataSchema(e,c)+`;
|
|
327
327
|
`,r+=t+`Converter.register(`+e.fullName+`.Fullname, `+e.fullName+`);
|
|
328
328
|
`,i+=t+`Converter.register(`+e.fullName+`.Fullname, `+e.fullName+`);
|
|
329
|
-
`),n.convertibleName=e.convertibleName}else e instanceof
|
|
329
|
+
`),n.convertibleName=e.convertibleName}else e instanceof gn&&(a=e.type+` `+e.compiledContent,o=e.type+` `+e.compiledContentDoc,s=e.type+` `+e.compiledContentHotReload);if(e.name==`MainState`)debugger;a=this.removeComments(a);let l=(0,p.transpile)(a,On);if(e.useNormalDecorator){let t=RegExp(`^var(\\s|\\S)*?let `+e.name+` = `,`gm`);l=l.replace(t,``),n.useDecorator=!0}n.compiled=l+r,j.isRunning&&(s=this.removeComments(s),n.hotReload=(0,p.transpile)(s,On)),o=this.removeEmptyComments(o);let u=this.compileDocTs(o,e),d=xn.correct(u,e),f=this.compileTsToNpm(e,t);if(f&&(n.npm=f),d.length>0){let t=e.namespace;t.length>0&&(u=`namespace `+t+` {
|
|
330
330
|
`+u+`}
|
|
331
331
|
`,d=`namespace `+t+` {
|
|
332
332
|
`+d+`}
|
|
333
333
|
`),e.isExported?n.docVisible=d:n.docInvisible=d}let m=()=>{let r=``,i=t.build.namespaces.includes(e.fullName);i&&(r+=`_n = `+e.fullName+`;
|
|
334
|
-
`);let a=n.compiled;if(e instanceof
|
|
334
|
+
`);let a=n.compiled;if(e instanceof gn)a=a.slice(a.indexOf(`=`)+1),a=e.fullName.includes(`.`)?e.fullName+`=`+a:`let `+e.fullName+`=`+a;else if(e instanceof pn){let t=`})(${e.name} || (${e.name} = {}))`,n=`})(${e.fullName} || (${e.fullName} = {}))`;if(a=a.replaceAll(t,n),e.fullName.includes(`.`)){let e=a.replace(/\r\n?/g,`
|
|
335
335
|
`).split(`
|
|
336
336
|
`);e.splice(0,1),a=e.join(`
|
|
337
337
|
`)}}else a=e.fullName+`=`+n.compiled,e.fullName.includes(`.`)||(a=`let ${a}`);return e.isExported&&(a+=`__as1(_${e.namespace==``?``:`.`+e.namespace}, '${e.name}', ${e.fullName});`,a+=`
|
|
338
338
|
`),r+=a,i&&(r+=`
|
|
339
339
|
Object.assign(`+e.fullName+`, _n);
|
|
340
|
-
`),r},h=n.compiled;n.compiled.length>0&&(n.classScript=e.fullName,n.compiled=m()),(n.docVisible.length>0||n.docInvisible.length>0)&&(n.classDoc=e.fullName);for(let t of e.decorators){let e=
|
|
340
|
+
`),r},h=n.compiled;n.compiled.length>0&&(n.classScript=e.fullName,n.compiled=m()),(n.docVisible.length>0||n.docInvisible.length>0)&&(n.classDoc=e.fullName);for(let t of e.decorators){let e=yn.is(t);e&&e.writeCompiled&&(n.debugTxt=h),bn.is(t)&&(n.required=!0)}}catch(e){this.printCatchError(e)}return n}static compileTsToNpm(e,t){try{if(!t.build.hasNpmOutput)return null;let n={defTs:``,namespace:``,exportPath:``,uri:t.file.uri,src:``},r=``,i=e.compiledContentNpm,a=t.build.module;if(e instanceof fn&&!e.isInterface){let n=`Aventus.`;e.build.isCoreBuild&&(n=``);let i=``;if(e.namespace&&(i=`.`+e.namespace),r+=e.name+".Namespace=`"+a+i+`\`;
|
|
341
341
|
`,e.convertibleName){r+=e.name+`.$schema=`+this.prepareDataSchema(e,a,!0)+`;
|
|
342
342
|
`;let i=t.build.getNpmReplacementName(``,n+`Converter`);r+=i+`.register(`+e.name+`.`+e.convertibleName+`, `+e.name+`);
|
|
343
343
|
`,t.fileParsed&&t.fileParsed.registerGeneratedImport({uri:`@aventusjs/main/Aventus`,name:`Converter`,compiled:!0,alias:i,forced:!1})}else if(e.implements.includes(n+`IData`)){r+=e.name+`.$schema=`+this.prepareDataSchema(e,a,!0)+`;
|
|
344
344
|
`;let i=t.build.getNpmReplacementName(``,n+`Converter`);r+=i+`.register(`+e.name+`.Fullname, `+e.name+`);
|
|
345
|
-
`,t.fileParsed&&t.fileParsed.registerGeneratedImport({uri:`@aventusjs/main/Aventus`,name:`Converter`,compiled:!0,alias:i,forced:!1})}}else e instanceof
|
|
345
|
+
`,t.fileParsed&&t.fileParsed.registerGeneratedImport({uri:`@aventusjs/main/Aventus`,name:`Converter`,compiled:!0,alias:i,forced:!1})}}else e instanceof gn&&(i=e.type+` `+e.compiledContentNpm);i=this.removeComments(i);let o=(0,p.transpile)(i,On),s=this.compileDocTs(i,e);n.namespace=t.build.module,e.namespace.length>0&&(n.namespace+=`.`+e.namespace),n.defTs=s,n.src=o+r;let c=t.file.path.replace(t.build.project.getConfigFile().path.replace(w.Config,``),``);return c=c.replace(w.Base,`.js`),n.exportPath=c,n}catch(e){this.printCatchError(e)}return null}static compileDocTs(e,t){try{let n=(0,p.createLanguageService)({getCompilationSettings:()=>({allowJs:!0,declaration:!0}),getScriptFileNames:()=>[`temp.js`],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>`1`,getScriptSnapshot:t=>{let n=e;return{getText:(e,t)=>n?.substring(e,t)||``,getLength:()=>n?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>``,readFile:(t,n)=>e,fileExists:e=>!0,directoryExists:e=>!e.startsWith(`node_modules`)}).getEmitOutput(`temp.js`,!0,!0).outputFiles[0].text.replace(/^declare /g,``);if(t instanceof fn&&!t.constructorBody&&t.extraConstructorCode.length>0&&(n=n.replace(/^ *constructor\(.*\);$/gm,``)),t instanceof fn&&t.isWebcomponent){let e=t.build.tsFiles[t.fileUri];if(e instanceof F){let t=RegExp(`^ *private `+e.viewMethodName+`[0-9]+?;
|
|
346
346
|
`,`gm`);n=n.replace(t,``)}}return t?.documentation&&(n=t.documentation.fullDefinitions.join(`
|
|
347
347
|
`)+`
|
|
348
|
-
`+n),n}catch(e){this.printCatchError(e)}return``}static removeUnusedImport(e,t){try{let n=d.TextDocument.create(`temp.js`,`js`,1,e),r=(0,p.createLanguageService)({getCompilationSettings:()=>({noUnusedLocals:!0,allowNonTsExtensions:!0,allowJs:!0}),getScriptFileNames:()=>[`temp.js`],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>`1`,getScriptSnapshot:t=>{let n=e;return{getText:(e,t)=>n?.substring(e,t)||``,getLength:()=>n?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>``,readFile:(t,n)=>t==`temp.js`?e:``,fileExists:e=>!1,directoryExists:e=>!1}).getSemanticDiagnostics(`temp.js`),i=[];for(let a of r)if(a.reportsUnnecessary&&a.start!=null){let r=n.positionAt(a.start),o={line:r.line,character:0},s={line:r.line,character:6};if(e.slice(n.offsetAt(o),n.offsetAt(s))==`import`){let e=/'(\S*)'/.exec(a.messageText+``);if(e&&e[1]&&t.includes(e[1]))continue;i.push({start:a.start,length:a.length})}}i.sort((e,t)=>t.start-e.start);for(let t of i)e=e.slice(0,t.start)+e.slice(t.start+t.length);return e=e.replace(/import\s*\{[^}]*\}\s*from\s*['"][^'"]*['"];\s*/g,e=>{let t=e.replace(/(,|{)(?:\s*(\S+)\s+as\s+)(?=,|})/g,`$1`);return t=t.replace(/(,\s*)+/g,`, `).replace(/,\s*}/g,` }`).replace(/{\s*,/g,`{ `),t.match(/\{\s*\}/)?``:t}),e}catch(e){this.printCatchError(e)}return``}static getCompilerOptionsCompile(){return
|
|
349
|
-
`,baseIndentSize:0,insertSpaceAfterCommaDelimiter:!0,insertSpaceAfterConstructor:!1,insertSpaceAfterSemicolonInForStatements:!0,insertSpaceBeforeAndAfterBinaryOperators:!0,insertSpaceAfterKeywordsInControlFlowStatements:!1,insertSpaceAfterFunctionKeywordForAnonymousFunctions:!0,insertSpaceBeforeFunctionParenthesis:!1,insertSpaceAfterTypeAssertion:!0,placeOpenBraceOnNewLineForControlBlocks:!1,placeOpenBraceOnNewLineForFunctions:!1,semicolons:p.SemicolonPreference.Insert,insertSpaceBeforeTypeAnnotation:!1};function
|
|
350
|
-
`);if(this.htmlParsed&&this.hasStory&&this.classInfo.storieContent){let e=this.classInfo.storieContent;delete e.slots;let t=[];this.classInfo.storieDecorator?.slots?.inject&&this.classInfo.storieDecorator.slots.inject;for(let e in this.htmlParsed.slotsInfo){let n={name:e};this.storyArgTypes[`@`+e]={control:`text`,table:{category:`Slot`}},this.classInfo.documentation?.documentationSlots[e]&&(n.documentation=this.classInfo.documentation.documentationSlots[e],this.storyArgTypes[`@`+e].description=n.documentation),this.classInfo.storieDecorator?.slots?.values&&this.classInfo.storieDecorator.slots.values[e]?this.storyArgs[`@`+e]=this.classInfo.storieDecorator.slots.values[e]:this.storyArgs[`@`+e]=``,t.push(n)}this.classInfo.loadStoryBookInject(),t.length>0&&(e.slots=t)}}else this.result.diagnostics.push(
|
|
351
|
-
`)??``,attributes:{}}})}getClassName(e){let t=e.name.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g);if(t){let n=this.build.getComponentPrefix().split(`-`);for(let e=0;e<n.length;e++){let r=n[e];if(r.length>0&&t[e].toLowerCase()!=r.toLowerCase()){t.splice(0,0,n.join(`-`).toLowerCase());break}}this.tagName==``&&(this.tagName=t.join(`-`).toLowerCase()),this.className=e.name,this.fullName=e.fullName,this.parentClassName=`Aventus.WebComponent`,this.parentClassNameNpm=this.build.getNpmReplacementName([this.build.module,this.fullName].join(`.`),`Aventus.WebComponent`),e.extends.length>0&&e.extends[0]&&(this.parentClassName=e.extends[0],this.parentClassNameNpm=e.extendsNpm[0])}}loadParent(e,t=!0){let n=this.loadFields(e,t);this.allFields={...n,...this.allFields};for(let t in e.methods)this.methodsName.includes(t)||this.methodsName.push(t);if(e.extends.length>0&&e.extends[0]!=this.AventusWebComponent){let t=e.parentClass;t?this.loadParent(t,!1):this.classInfo&&this.result.diagnostics.push(O(this.document,`can't found the path for parent `+e.extends[0],this.classInfo.nameStart,this.classInfo.nameEnd,1007))}}loadFields(e,t){let n={};for(let r in e.properties){let i=e.properties[r];if(this.allFields[i.name])continue;let a=!1,o=new
|
|
348
|
+
`+n),n}catch(e){this.printCatchError(e)}return``}static removeUnusedImport(e,t){try{let n=d.TextDocument.create(`temp.js`,`js`,1,e),r=(0,p.createLanguageService)({getCompilationSettings:()=>({noUnusedLocals:!0,allowNonTsExtensions:!0,allowJs:!0}),getScriptFileNames:()=>[`temp.js`],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>`1`,getScriptSnapshot:t=>{let n=e;return{getText:(e,t)=>n?.substring(e,t)||``,getLength:()=>n?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>``,readFile:(t,n)=>t==`temp.js`?e:``,fileExists:e=>!1,directoryExists:e=>!1}).getSemanticDiagnostics(`temp.js`),i=[];for(let a of r)if(a.reportsUnnecessary&&a.start!=null){let r=n.positionAt(a.start),o={line:r.line,character:0},s={line:r.line,character:6};if(e.slice(n.offsetAt(o),n.offsetAt(s))==`import`){let e=/'(\S*)'/.exec(a.messageText+``);if(e&&e[1]&&t.includes(e[1]))continue;i.push({start:a.start,length:a.length})}}i.sort((e,t)=>t.start-e.start);for(let t of i)e=e.slice(0,t.start)+e.slice(t.start+t.length);return e=e.replace(/import\s*\{[^}]*\}\s*from\s*['"][^'"]*['"];\s*/g,e=>{let t=e.replace(/(,|{)(?:\s*(\S+)\s+as\s+)(?=,|})/g,`$1`);return t=t.replace(/(,\s*)+/g,`, `).replace(/,\s*}/g,` }`).replace(/{\s*,/g,`{ `),t.match(/\{\s*\}/)?``:t}),e}catch(e){this.printCatchError(e)}return``}static getCompilerOptionsCompile(){return On}simplifyPath(e,t){if(e=decodeURIComponent(e),e.startsWith(`custom://`))return e;let n=[];n=f.sep===`/`?decodeURIComponent(t).replace(`file://`,``).split(`/`):decodeURIComponent(t).replace(`file:///`,``).split(`/`),n.pop();let r=(0,f.normalize)(n.join(`/`)).split(f.sep),i=(0,f.normalize)(n.join(`/`)+`/`+e).split(f.sep);for(let e=0;e<r.length;e++)if(i.length>e)if(r[e]==i[e])r.splice(e,1),i.splice(e,1),e--;else break;let a=``;for(let e=0;e<r.length;e++)a+=`../`;a==``&&(a+=`./`),a+=i.join(`/`);let o=(0,f.normalize)((0,f.join)(...n,a)),s=this.build.getAliases();for(let e in s){let t=s[e],n=(0,f.normalize)((0,f.join)(this.build.project.getConfigFile().folderPath,t));if(o.startsWith(n)){a=o.replace(n,e).replace(/\\/g,`/`);break}}return a}printCatchError(t){e.printCatchError(t)}static printCatchError(e){/^Debug Failure\. Expected \d+ <= \d+$/g.test(e.message)||console.error(e)}};const Dn={allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,target:p.ScriptTarget.ES2025,module:p.ModuleKind.NodeNext,moduleDetection:p.ModuleDetectionKind.Force,moduleResolution:p.ModuleResolutionKind.NodeNext,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,noUnusedLocals:!0,strictNullChecks:!0,verbatimModuleSyntax:!0,baseUrl:`./`,alwaysStrict:!1},On={allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,target:p.ScriptTarget.ES2025,module:p.ModuleKind.NodeNext,moduleDetection:p.ModuleDetectionKind.Auto,moduleResolution:p.ModuleResolutionKind.NodeNext,noImplicitOverride:!0,strictPropertyInitialization:!0,noImplicitReturns:!0,strictNullChecks:!0,verbatimModuleSyntax:!0,baseUrl:`./`,alwaysStrict:!1},kn={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`},An={convertTabsToSpaces:!0,tabSize:4,indentSize:4,indentStyle:p.IndentStyle.Smart,newLineCharacter:`
|
|
349
|
+
`,baseIndentSize:0,insertSpaceAfterCommaDelimiter:!0,insertSpaceAfterConstructor:!1,insertSpaceAfterSemicolonInForStatements:!0,insertSpaceBeforeAndAfterBinaryOperators:!0,insertSpaceAfterKeywordsInControlFlowStatements:!1,insertSpaceAfterFunctionKeywordForAnonymousFunctions:!0,insertSpaceBeforeFunctionParenthesis:!1,insertSpaceAfterTypeAssertion:!0,placeOpenBraceOnNewLineForControlBlocks:!1,placeOpenBraceOnNewLineForFunctions:!1,semicolons:p.SemicolonPreference.Insert,insertSpaceBeforeTypeAnnotation:!1};function jn(e){switch(e){case`primitive type`:case`keyword`:return m.CompletionItemKind.Keyword;case`const`:case`let`:case`var`:case`local var`:case`alias`:case`parameter`:return m.CompletionItemKind.Variable;case`property`:case`getter`:case`setter`:return m.CompletionItemKind.Field;case`function`:case`local function`:return m.CompletionItemKind.Function;case`method`:case`construct`:case`call`:case`index`:return m.CompletionItemKind.Method;case`enum`:return m.CompletionItemKind.Enum;case`enum member`:return m.CompletionItemKind.EnumMember;case`module`:case`external module name`:return m.CompletionItemKind.Module;case`class`:case`type`:return m.CompletionItemKind.Class;case`interface`:return m.CompletionItemKind.Interface;case`warning`:return m.CompletionItemKind.Text;case`script`:return m.CompletionItemKind.File;case`directory`:return m.CompletionItemKind.Folder;case`string`:return m.CompletionItemKind.Constant;default:return m.CompletionItemKind.Property}}function Mn(e){return/^\s*$/.test(e)}function Nn(e,t){return t.insertSpaces?Pn(` `,e*t.tabSize):Pn(` `,e)}function Pn(e,t){let n=``;for(;t>0;)(t&1)==1&&(n+=e),e+=e,t>>>=1;return n}function Fn(e,t){let n=RegExp(`//#region `+t+`(\\s|\\S)*?//#endregion`).exec(e.documentInternal.getText());return n?n.index+10+t.length:-1}var In=class e{removeViewVariables=[];static is(t){if(t.name==`OverrideView`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);e.removeViewVariables&&(n.removeViewVariables=e.removeViewVariables)}catch{}return n}return null}},Ln=class e{tagName=``;static is(t){if(t.name==`TagName`){let n=new e;return t.arguments.length>0&&(n.tagName=t.arguments[0].value),n}return null}},Rn=class e{fctTxt=null;static is(t){if(t.name==`Property`){let n=new e;if(t.arguments.length>0)try{t.arguments[0].type==`call`&&(n.fctTxt=t.arguments[0].value)}catch{}return n}return null}},zn=class e{useLive=void 0;static is(t){if(t.name==`ViewElement`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);e.useLive===!0?n.useLive=!0:e.useLive===!1&&(n.useLive=!1)}catch{}return n}return null}},Bn=class e{stateName=``;managerName=``;functionName=`active`;static is(t){if(t.name==`StateActive`){let n=new e;if(t.arguments.length>0)try{let e=Vn.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},Vn=class{static parse(e){let t={stateName:``};try{let n=e.arguments[0].value;if(e.arguments[0].type==`identifier`){let t=e.arguments[0].value.split(`.`),r=e.baseInfo?.dependenciesLocations[t[0]]?.replacement;r&&(t[0]=r),n=t.join(`.`)}if(t.stateName=n,e.arguments.length>1){let n=e.arguments[1].value,r=e.baseInfo?.dependenciesLocations[n]?.replacement;r&&(n=r),t.managerName=n}}catch{}return t}},Hn=class e{stateName=``;managerName=``;functionName=`askChange`;static is(t){if(t.name==`StateChange`){let n=new e;if(t.arguments.length>0)try{let e=Vn.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},Un=class e{stateName=``;managerName=``;functionName=`inactive`;static is(t){if(t.name==`StateInactive`){let n=new e;if(t.arguments.length>0)try{let e=Vn.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},Wn=class e{fctTxt=null;static is(t){if(t.name==`Watch`){let n=new e;if(t.arguments.length>0)try{t.arguments[0].type==`call`&&(n.fctTxt=t.arguments[0].value)}catch{}return n}return null}};const Gn={"@press":`onPress`,"@press-start":`onPressStart`,"@press-stop":`onPressEnd`,"@longpress":`onLongPress`,"@longpress-delay":`delayLongPress`,"@dblpress":`onDblPress`,"@dblpress-delay":`delayDblPress`,"@drag":`onDrag`,"@drag-start":`onDragStart`,"@drag-end":`onDragEnd`};var Kn=class e{managerName=``;static is(t){if(t.name==`DefaultStateActive`){let n=new e;if(t.arguments.length>0)try{n.managerName=qn.parse(t).managerName}catch{}return n}return null}},qn=class{static parse(e){let t={managerName:``};try{let n=e.arguments[0].value,r=e.baseInfo?.dependenciesLocations[n]?.replacement;r&&(n=r),t.managerName=n}catch{}return t}},Jn=class e{managerName=``;static is(t){if(t.name==`DefaultStateInactive`){let n=new e;if(t.arguments.length>0)try{n.managerName=qn.parse(t).managerName}catch{}return n}return null}},Yn=class e{options={autoInit:!0};static is(t){if(t.name==`Effect`){let n=new e;if(t.arguments.length>0)try{let e=JSON.parse(t.arguments[0].value);e.autoInit!==void 0&&(n.options.autoInit=e.autoInit)}catch{}return n}return null}},Xn=class e{fctTxt=null;static is(t){if(t.name==`Signal`){let n=new e;if(t.arguments.length>0)try{t.arguments[0].type==`call`&&(n.fctTxt=t.arguments[0].value)}catch{}return n}return null}},Zn=class e{static is(t){return t.name==`Injectable`?new e:null}},Qn=class{static getVersion(e,t){let n={ts:e.file.documentUser.version,scss:-1,html:-1,i18n:-1},r,i,a;return e.file.uri.endsWith(w.Component)?(r=t.wcFiles[e.file.uri].style,i=t.wcFiles[e.file.uri].view,a=t.wcFiles[e.file.uri].i18n):(r=t.scssFiles[e.file.uri.replace(w.ComponentLogic,w.ComponentStyle)],i=t.htmlFiles[e.file.uri.replace(w.ComponentLogic,w.ComponentView)],a=t.i18nComponentsFiles[e.file.uri.replace(w.ComponentLogic,w.I18n)]),r&&(n.scss=r.compiledVersion),i&&(n.html=i.compiledVersion),a&&(n.i18n=a.file.versionUser),n}file;logicalFile;scssTxt=``;template;templateHotReload;templateNpm;document;build;fileParsed;classInfo;className=``;fullName=``;tagName=``;htmlParsed;htmlParsedResult;htmlDoc;htmlFile;scssFile;allFields={};methodsName=[];listBoolProperties=[];defaultValueTxt=``;defaultValueHotReloadTxt=``;defaultValueNpmTxt=``;result={diagnostics:[],writeCompiled:!1,missingViewElements:{position:-1,elements:{}},missingMethods:{position:-1,elements:[]},componentName:``,result:[],htmlDoc:{},scssDoc:{},debug:``,needRebuild:!1};componentResult={hotReload:``,compiled:``,docVisible:``,npm:{defTs:``,namespace:``,exportPath:``,uri:``,src:``},docInvisible:``,dependencies:[],classScript:``,classDoc:``,debugTxt:``,uri:``,required:!1,type:1,isExported:{internal:!0,external:!0},convertibleName:``,tagName:``,useDecorator:!1};parentClassName=``;parentClassNameNpm=``;overrideViewDecorator=null;debuggerDecorator=null;AventusWebComponent=`Aventus.WebComponent`;AventusDefaultComponent=`Aventus.DefaultComponent`;hasStory;constructor(e,t){this.logicalFile=e,this.hasStory=t.hasStories,t.isCoreBuild&&(this.AventusDefaultComponent=`DefaultComponent`,this.AventusWebComponent=`WebComponent`);let n,r;e.file.uri.endsWith(w.Component)?(this.file=t.wcFiles[e.file.uri].logic.file,n=t.wcFiles[e.file.uri].style,r=t.wcFiles[e.file.uri].view):(this.file=e.file,n=t.scssFiles[e.file.uri.replace(w.ComponentLogic,w.ComponentStyle)],r=t.htmlFiles[e.file.uri.replace(w.ComponentLogic,w.ComponentView)]),this.scssFile=n,this.scssTxt=n?n.compileResult:``,this.htmlFile=r,this.htmlFile&&(this.htmlParsed=this.htmlFile.fileParsed,this.htmlFile.tsErrors=[]);let i=t.tsLanguageService.doValidation(this.file),a=this.logicalFile.viewMethodName;for(let e=0;e<i.length;e++)i[e].message.startsWith(`'`+a)&&(i.splice(e,1),e--);this.result.diagnostics=i,this.template=vn(),this.templateHotReload=vn(),t.hasNpmOutput&&(this.templateNpm=vn()),this.document=e.file.documentInternal,this.build=t,this.fileParsed=e.fileParsed}compile(){if(this.fileParsed){for(let e in this.fileParsed.aliases)this.result.result.push(En.compileTs(this.fileParsed.aliases[e],this.logicalFile));for(let e in this.fileParsed.enums)this.result.result.push(En.compileTs(this.fileParsed.enums[e],this.logicalFile));for(let e in this.fileParsed.classes){let t=this.fileParsed.classes[e];if(this.isComponentClassInfo(t))if(this.classInfo!=null){let e=`Only one class is allowed inside a file. Get `+t.name+` and `+this.classInfo.name;this.result.diagnostics.push(O(this.document,e,t.nameStart,t.nameEnd,1003)),this.result.diagnostics.push(O(this.document,e,this.classInfo.nameStart,this.classInfo.nameEnd,1003))}else this.classInfo=t;else this.result.result.push(En.compileTs(t,this.logicalFile))}}if(this.classInfo){this.logicalFile.build.addNamespace(this.classInfo.namespace),this.compileComponentClassInfo(),this.result.htmlDoc=this.htmlDoc??{},this.result.scssDoc=this.prepareDocSCSS(),this.result.componentName=this.className,this.result.writeCompiled=this.debuggerDecorator!==null&&this.debuggerDecorator.writeCompiled;for(let e of this.result.result)e.debugTxt&&(this.result.debug+=e.debugTxt+`
|
|
350
|
+
`);if(this.htmlParsed&&this.hasStory&&this.classInfo.storieContent){let e=this.classInfo.storieContent;delete e.slots;let t=[];this.classInfo.storieDecorator?.slots?.inject&&this.classInfo.storieDecorator.slots.inject;for(let e in this.htmlParsed.slotsInfo){let n={name:e};this.storyArgTypes[`@`+e]={control:`text`,table:{category:`Slot`}},this.classInfo.documentation?.documentationSlots[e]&&(n.documentation=this.classInfo.documentation.documentationSlots[e],this.storyArgTypes[`@`+e].description=n.documentation),this.classInfo.storieDecorator?.slots?.values&&this.classInfo.storieDecorator.slots.values[e]?this.storyArgs[`@`+e]=this.classInfo.storieDecorator.slots.values[e]:this.storyArgs[`@`+e]=``,t.push(n)}this.classInfo.loadStoryBookInject(),t.length>0&&(e.slots=t)}}else this.result.diagnostics.push(je(this.document,`Can't found a web component class to compile inside`,1002));return this.result}isComponentClassInfo(e){return e instanceof fn&&e.isWebcomponent}compileComponentClassInfo(){if(this.classInfo){this.prepareComponentClassInfo(this.classInfo);let e=En.compileTs(this.classInfo,this.logicalFile);this.componentResult.classScript=e.classScript,this.componentResult.classDoc=e.classDoc,this.componentResult.dependencies=e.dependencies,this.componentResult.docInvisible=e.docInvisible,this.componentResult.docVisible=e.docVisible,this.componentResult.npm=e.npm,this.componentResult.type=e.type,this.componentResult.isExported=e.isExported,this.componentResult.uri=e.uri,this.prepareHTMLDocObject(),this.loadParent(this.classInfo),this.addViewElementToDependency(),this.writeFile(),!this.classInfo.isAbstract&&!this.classInfo.isInterface&&(this.componentResult.tagName=this.tagName),this.componentResult.slots=this.htmlFile?.slotsInfo,this.componentResult.compiled=this.template.replace(`//todelete for hmr °`,``),this.componentResult.npm.src=this.templateNpm?.replace(`//todelete for hmr °`,``)??``,j.isRunning&&(this.componentResult.hotReload=this.templateHotReload.split(`//todelete for hmr °`)[0],this.componentResult.hotReload=this.componentResult.hotReload.slice(this.componentResult.hotReload.indexOf(`=`)+1)),this.debuggerDecorator&&this.debuggerDecorator.writeCompiled&&(this.componentResult.debugTxt=this.componentResult.compiled),this.result.result.push(this.componentResult)}}prepareComponentClassInfo(e){for(let t of e.decorators){let e=In.is(t);if(e){this.overrideViewDecorator=e;continue}let n=yn.is(t);if(n){this.debuggerDecorator=n;continue}let r=Ln.is(t);if(r&&r.tagName){r.tagName.indexOf(`-`)==-1||r.tagName.toLowerCase()!=r.tagName?this.result.diagnostics.push(O(this.document,`tag name must be in lower case and have a - inside`,t.contentStart,t.contentEnd,1004)):this.tagName=r.tagName;continue}bn.is(t)&&(this.componentResult.required=!0)}if(e.extends.length>0&&e.extends[0]==this.AventusWebComponent&&(this.overrideViewDecorator=new In),this.getClassName(e),this.htmlParsed){let e=this.className.toLowerCase(),t=[],n=null,r=this.classInfo?.parentClass;for(;r;){let i=r.name.toLowerCase();if(t.push(i),n==null&&t.includes(e)&&(n=e+`1`),n&&t.includes(n)){let r=1;for(;t.includes(n);)r++,n=e+r}r=r.parentClass}n&&this.htmlParsed.replaceId(n),this.htmlParsedResult=this.htmlParsed.getParsedInfo(this.className)}}prepareHTMLDocObject(){this.classInfo&&!this.classInfo.isAbstract&&(this.htmlDoc={[this.tagName]:{class:this.classInfo.fullName,name:this.tagName,description:this.classInfo.documentation?.fullDefinitions.join(`
|
|
351
|
+
`)??``,attributes:{}}})}getClassName(e){let t=e.name.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g);if(t){let n=this.build.getComponentPrefix().split(`-`);for(let e=0;e<n.length;e++){let r=n[e];if(r.length>0&&t[e].toLowerCase()!=r.toLowerCase()){t.splice(0,0,n.join(`-`).toLowerCase());break}}this.tagName==``&&(this.tagName=t.join(`-`).toLowerCase()),this.className=e.name,this.fullName=e.fullName,this.parentClassName=`Aventus.WebComponent`,this.parentClassNameNpm=this.build.getNpmReplacementName([this.build.module,this.fullName].join(`.`),`Aventus.WebComponent`),e.extends.length>0&&e.extends[0]&&(this.parentClassName=e.extends[0],this.parentClassNameNpm=e.extendsNpm[0])}}loadParent(e,t=!0){let n=this.loadFields(e,t);this.allFields={...n,...this.allFields};for(let t in e.methods)this.methodsName.includes(t)||this.methodsName.push(t);if(e.extends.length>0&&e.extends[0]!=this.AventusWebComponent){let t=e.parentClass;t?this.loadParent(t,!1):this.classInfo&&this.result.diagnostics.push(O(this.document,`can't found the path for parent `+e.extends[0],this.classInfo.nameStart,this.classInfo.nameEnd,1007))}}loadFields(e,t){let n={};for(let r in e.properties){let i=e.properties[r];if(this.allFields[i.name])continue;let a=!1,o=new dn(i.prop,i.isInsideInterface,e);for(let e of i.decorators)if([`Attribute`,`Property`,`Watch`,`Signal`,`ViewElement`].includes(e.name)&&(o.propType=e.name,a=!0),a){n[i.name]=o,o.inParent=!t;break}a||(o.propType=`Simple`,o.inParent=!t,n[r]=o)}return n}addViewElementToDependency(){if(this.htmlParsed&&this.htmlFile&&this.classInfo){this.logicalFile.resetViewClassInfoDep();let e=[],t={};for(let n of this.htmlParsed.interestPoints)if(n.type==`tag`){if(e.includes(n.name)||(e.push(n.name),this.classInfo.addDependencyTag(n.name,this.componentResult)),!t.hasOwnProperty(n.name)){let e=this.build.getWebComponentDefinitionFile(n.name);e instanceof F?t[n.name]=e:(this.build.htmlLanguageService.getInternalTagUri(n.name)&&(this.result.needRebuild=!0),t[n.name]=null)}let r=t[n.name];r&&this.logicalFile.addViewClassInfoDep(r,n.start,n.end)}}}writeFile(){this.writeFileName(),this.writeFileTemplateHtml(),this.writeFileReplaceVar(`style`,this.scssTxt),this.writeFileHotReloadReplaceVar(`style`,this.scssTxt),this.writeFileNpmReplaceVar(`style`,this.scssTxt),this.writeFileFields(),this.writeFileMethods(),this.writeWatchableElements(),this.writeFileConstructor(),this.template=this.template.replace(/\|\!\*(.*?)\*\!\|/g,`{{$1}}`),this.template=this.removeWhiteSpaceLines(this.template),this.templateHotReload=this.templateHotReload.replace(/\|\!\*(.*?)\*\!\|/g,`{{$1}}`),this.templateHotReload=this.removeWhiteSpaceLines(this.templateHotReload),this.templateNpm&&=(this.templateNpm=this.templateNpm.replace(/\|\!\*(.*?)\*\!\|/g,`{{$1}}`),this.removeWhiteSpaceLines(this.templateNpm))}writeFileName(){this.writeFileReplaceVar(`classname`,this.className),this.writeFileHotReloadReplaceVar(`classname`,this.className),this.writeFileNpmReplaceVar(`classname`,this.className),this.writeFileReplaceVar(`parentClass`,this.parentClassName),this.writeFileHotReloadReplaceVar(`parentClass`,this.parentClassName),this.writeFileNpmReplaceVar(`parentClass`,this.parentClassNameNpm);let e=this.build.module;if(this.fullName.includes(`.`)){this.writeFileReplaceVar(`fullname`,this.fullName),this.writeFileHotReloadReplaceVar(`fullname`,this.fullName),this.writeFileNpmReplaceVar(`fullname`,`const `+this.className);let t=`.`+this.classInfo?.namespace;this.writeFileReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+t+"`;"),this.writeFileHotReloadReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+t+"`;"),this.writeFileNpmReplaceVar(`namespace`,this.className+".Namespace=`"+e+t+"`;")}else this.writeFileReplaceVar(`fullname`,`const `+this.fullName),this.writeFileHotReloadReplaceVar(`fullname`,`const `+this.fullName),this.writeFileNpmReplaceVar(`fullname`,`const `+this.fullName),this.writeFileReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+"`;"),this.writeFileHotReloadReplaceVar(`namespace`,this.fullName+".Namespace=`"+e+"`;"),this.writeFileNpmReplaceVar(`namespace`,this.className+".Namespace=`"+e+"`;");if(this.classInfo?.isAbstract?(this.writeFileReplaceVar(`tag`,``),this.writeFileHotReloadReplaceVar(`tag`,``),this.writeFileNpmReplaceVar(`tag`,``)):(this.writeFileReplaceVar(`tag`,this.fullName+".Tag=`"+this.tagName+"`;"),this.writeFileHotReloadReplaceVar(`tag`,this.fullName+".Tag=`"+this.tagName+"`;"),this.writeFileNpmReplaceVar(`tag`,this.className+".Tag=`"+this.tagName+"`;")),this.build.namespaces.includes(this.fullName)?(this.writeFileReplaceVar(`namespaceStart`,`_n = `+this.fullName+`;
|
|
352
352
|
`),this.writeFileHotReloadReplaceVar(`namespaceStart`,`_n = `+this.fullName+`;
|
|
353
353
|
`),this.writeFileNpmReplaceVar(`namespaceStart`,`_n = `+this.fullName+`;
|
|
354
354
|
`),this.writeFileReplaceVar(`namespaceEnd`,`
|
|
@@ -363,14 +363,14 @@ super.__getHtml();`,i=``,a=``;t.length>0&&(i=`slots: { ${t} },`),n.length>0&&(a=
|
|
|
363
363
|
${i}
|
|
364
364
|
${a}
|
|
365
365
|
});
|
|
366
|
-
}`}}this.writeFileReplaceVar(`slotBlock`,e),this.writeFileHotReloadReplaceVar(`slotBlock`,e),this.writeFileNpmReplaceVar(`slotBlock`,e)}writeFileConstructor(){if(this.classInfo){let e=``,t=``,n=``,r=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContent}}`,
|
|
366
|
+
}`}}this.writeFileReplaceVar(`slotBlock`,e),this.writeFileHotReloadReplaceVar(`slotBlock`,e),this.writeFileNpmReplaceVar(`slotBlock`,e)}writeFileConstructor(){if(this.classInfo){let e=``,t=``,n=``,r=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContent}}`,En.getCompilerOptionsCompile()),i=/\{([\s\S]*)\}/gm.exec(r);if(i&&(e=i[1].trim()),j.isRunning){let e=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContentHotReload}}`,En.getCompilerOptionsCompile()),n=/\{([\s\S]*)\}/gm.exec(e);n&&(t=n[1].trim())}if(this.templateNpm){let e=(0,p.transpile)(`class MyCompilationClassAventus {${this.classInfo.constructorContentNpm}}`,En.getCompilerOptionsCompile()),t=/\{([\s\S]*)\}/gm.exec(e);t&&(n=t[1].trim())}this.writeFileReplaceVar(`constructor`,e),this.writeFileHotReloadReplaceVar(`constructor`,t),this.writeFileNpmReplaceVar(`constructor`,n)}}viewsElements={};upgradeAttributes=``;storyArgTypes={};storyArgs={};addStoryField(e){if(e.propType==`Simple`||!this.hasStory||!this.classInfo?.storieContent)return;let t=``;if(e.propType==`Attribute`?t=`Attributes`:e.propType==`Property`?t=`Properties`:e.propType==`Watch`?t=`Watches`:e.propType==`Signal`&&(t=`Signals`),this.classInfo.storieContent.kind==`class`){let t=this.classInfo.storieContent.properties?.find(t=>t.name==e.name);t&&(t.modifiers?t.modifiers.includes(e.propType)||t.modifiers.push(e.propType):t.modifiers=[e.propType])}if(e.propType==`ViewElement`)return;let n=e.type;if(!n)return;let r=`text`,i=[],a=e.defaultValue??void 0,o,s=e=>{if(e.kind==`string`)r=`text`,o=`string`;else if(e.kind==`literal`){r=`select`;let t=e.value;(t.startsWith(`'`)||t.startsWith(`"`))&&(t=t.substring(1)),(t.endsWith(`'`)||t.endsWith(`"`))&&(t=t.substring(0,t.length-1)),i.push(t),o=`string`}else if(e.kind==`union`){r=`select`;for(let t of e.nested){let e=t.value;(e.startsWith(`'`)||e.startsWith(`"`))&&(e=e.substring(1)),(e.endsWith(`'`)||e.endsWith(`"`))&&(e=e.substring(0,e.length-1)),i.push(e)}o=`string`}else if(e.kind==`number`)r=`number`,o=`number`;else if(e.kind==`boolean`)r=`boolean`,o=`boolean`;else if(e.kind==`type`)if(e.value==`Date`||e.value==`DateTime`)r=`date`;else{let t=P.getBaseInfo(e.value,this.document.uri);t&&t instanceof nn?s(t.type):r=`object`}else r=`object`};s(n),this.storyArgTypes[e.name]={control:r,table:{category:t}},o&&(this.storyArgTypes[e.name].type=o),i.length>0&&(this.storyArgTypes[e.name].options=i),e.defaultValueStory!==null&&(a=e.defaultValueStory),this.storyArgs[e.name]=a}writeFileFields(){let e=[],t=[],n=[],r=[],i=[],a=[],o=[],s={};for(let c in this.allFields){let l=this.allFields[c];for(let e of l.decorators)Zn.is(e)&&a.push(l);if(un.includes(l.type.value)&&o.push(l),l.inParent){(l.propType==`Attribute`||l.propType==`Property`)&&this.createHtmlDoc(l,l.type);continue}if(this.addStoryField(l),l.propType==`Attribute`){t.push(l);continue}else if(l.propType==`Property`){for(let e of l.decorators){let t=Rn.is(e);t&&n.push({field:l,fctTxt:t.fctTxt})}continue}else if(l.propType==`Signal`){for(let e of l.decorators){let t=Xn.is(e);t&&r.push({field:l,fctTxt:t.fctTxt})}continue}else if(l.propType==`Watch`)for(let e of l.decorators){let t=Wn.is(e);t&&i.push({field:l,fctTxt:t.fctTxt})}else l.propType==`ViewElement`?(s[l.name]=l,!l.overrideNullable&&l.defaultValue===null&&!l.isNullable&&this.result.diagnostics.push(O(this.document,`You must add ! after the name to avoid undefined value`,l.nameStart,l.nameEnd,1025))):l.propType==`Simple`&&e.push(l)}if(this.viewsElements=s,this.writeFileFieldsSimpleVariable(e),this.writeFileFieldsAttribute(t),this.writeFileFieldsProperty(n),this.writeFileFieldsSignal(r),this.writeFileFieldsWatch(i),this.createInjectableHtmlDoc(a),this.createEventsHtmlDoc(o),this.upgradeAttributes.length>0&&(this.upgradeAttributes=`__upgradeAttributes() { super.__upgradeAttributes(); ${this.upgradeAttributes} }`),this.writeFileReplaceVar(`upgradeAttributes`,this.upgradeAttributes),this.writeFileHotReloadReplaceVar(`upgradeAttributes`,this.upgradeAttributes),this.writeFileNpmReplaceVar(`upgradeAttributes`,this.upgradeAttributes),this.htmlParsedResult){this.writeViewInfo(this.htmlParsedResult,!0);for(let e in s)this.createUnusedViewElement(s[e])}else this.writeFileReplaceVar(`templateAction`,``),this.writeFileHotReloadReplaceVar(`templateAction`,``),this.writeFileNpmReplaceVar(`templateAction`,``),this.writeFileReplaceVar(`variablesInViewDynamic`,``),this.writeFileHotReloadReplaceVar(`variablesInViewDynamic`,``),this.writeFileNpmReplaceVar(`variablesInViewDynamic`,``);this.writeViewGlobalVariables()}writeFileFieldsSimpleVariable(e){if(!this.htmlParsedResult){this.writeFileReplaceVar(`variables`,``),this.writeFileHotReloadReplaceVar(`variables`,``),this.writeFileNpmReplaceVar(`variables`,``);return}let t=``,n=``,r=``,i=[],a=``,o=``,s=``;if(this.classInfo)for(let e in this.classInfo.propertiesStatic){let t=this.classInfo.propertiesStatic[e];a+=t.compiledContent+`
|
|
367
367
|
`,o+=t.compiledContentHotReload+`
|
|
368
368
|
`,this.templateNpm&&(s+=t.compiledContentNpm+`
|
|
369
369
|
`)}for(let t of e)a+=t.compiledContent+`
|
|
370
370
|
`,o+=t.compiledContentHotReload+`
|
|
371
371
|
`,this.templateNpm&&(s+=t.compiledContentNpm+`
|
|
372
372
|
`),(t.isGet||t.isSet)&&(i.includes(t.name)||(i.push(t.name),this.upgradeAttributes+=`this.__correctGetter('`+t.name+`');
|
|
373
|
-
`));let c=`class MyCompilationClassAventus {${a}}`,l=``;try{l=(0,p.transpile)(c,
|
|
373
|
+
`));let c=`class MyCompilationClassAventus {${a}}`,l=``;try{l=(0,p.transpile)(c,En.getCompilerOptionsCompile())}catch{}let u=/\{([\s\S]*)\}/gm.exec(l);if(u&&(t=u[1].trim()),this.writeFileReplaceVar(`variables`,t),j.isRunning){let e=`class MyCompilationClassAventus {${o}}`,t=``;try{t=(0,p.transpile)(e,En.getCompilerOptionsCompile())}catch{}let r=/\{([\s\S]*)\}/gm.exec(t);r&&(n=r[1].trim()),this.writeFileHotReloadReplaceVar(`variables`,n)}if(this.templateNpm){let e=`class MyCompilationClassAventus {${s}}`,t=``;try{t=(0,p.transpile)(e,En.getCompilerOptionsCompile())}catch{}let n=/\{([\s\S]*)\}/gm.exec(t);n&&(r=n[1].trim()),this.writeFileNpmReplaceVar(`variables`,r)}}getGetterAndSetter(e,t,n){let r=``,i=e.name,a=n?`Prop`:`Attr`;return t.kind==`string`||t.kind==`literal`||t.kind==`union`?r+=`get '${i}'() { return this.getString${a}('${i}') }
|
|
374
374
|
set '${i}'(val) { this.setStringAttr('${i}', val) }
|
|
375
375
|
`:t.kind==`number`?r+=`get '${i}'() { return this.getNumber${a}('${i}') }
|
|
376
376
|
set '${i}'(val) { this.setNumberAttr('${i}', val) }
|
|
@@ -413,15 +413,15 @@ super.__getHtml();`,i=``,a=``;t.length>0&&(i=`slots: { ${t} },`),n.length>0&&(a=
|
|
|
413
413
|
`)}n.length>0&&(n=`__defaultValuesWatch(w) { super.__defaultValuesWatch(w); ${n} }`),this.writeFileReplaceVar(`defaultValueWatch`,n),r.length>0&&(r=`__defaultValuesWatch(w) { super.__defaultValuesWatch(w); ${r} }`),this.writeFileHotReloadReplaceVar(`defaultValueWatch`,r),i.length>0&&(i=`__defaultValuesWatch(w) { super.__defaultValuesWatch(w); ${i} }`),this.writeFileNpmReplaceVar(`defaultValueWatch`,i),this.writeFileReplaceVar(`getterSetterWatch`,t),this.writeFileHotReloadReplaceVar(`getterSetterWatch`,t),this.writeFileNpmReplaceVar(`getterSetterWatch`,t)}writeViewGlobalVariables(){let e=``;if(this.defaultValueTxt.length>0&&(e=`__defaultValues() { super.__defaultValues(); ${this.defaultValueTxt} }`),this.writeFileReplaceVar(`defaultValue`,e),j.isRunning){let e=``;this.defaultValueHotReloadTxt.length>0&&(e=`__defaultValues() { super.__defaultValues(); ${this.defaultValueHotReloadTxt} }`),this.writeFileHotReloadReplaceVar(`defaultValue`,e)}if(this.templateNpm){let e=``;this.defaultValueNpmTxt.length>0&&(e=`__defaultValues() { super.__defaultValues(); ${this.defaultValueNpmTxt} }`),this.writeFileNpmReplaceVar(`defaultValue`,e)}let t=``;this.listBoolProperties.length>0&&(t=`__listBoolProps() { return [${this.listBoolProperties.join(`,`)}].concat(super.__listBoolProps()).filter((v, i, a) => a.indexOf(v) === i); }`),this.writeFileReplaceVar(`listBool`,t),this.writeFileHotReloadReplaceVar(`listBool`,t),this.writeFileNpmReplaceVar(`listBool`,t)}writeFileMethods(){try{let e={},t=``,n=``,r=``,i=``;if(this.classInfo){let a=``,o=``,s=``,c=[...Object.values(this.classInfo.methods),...Object.values(this.classInfo.methodsStatic)];for(let t of c){if(!t.mustBeCompiled)continue;let n=t.name;if(a+=t.compiledContent+`
|
|
414
414
|
`,j.isRunning&&(o+=t.compiledContentHotReload+`
|
|
415
415
|
`),this.templateNpm&&(s+=t.compiledContentNpm+`
|
|
416
|
-
`),!t.isStatic)for(let r of t.decorators){let a=
|
|
417
|
-
`:(l=
|
|
418
|
-
`):r.arguments.length>0&&(e[o.stateName]||(e[o.stateName]={}),e[o.stateName][o.managerName]||(e[o.stateName][o.managerName]={active:[],inactive:[],askChange:[]}),e[o.stateName][o.managerName][o.functionName].push(t.name))}}let l=(0,p.transpile)(`class MyCompilationClassAventus {${a}}`,
|
|
416
|
+
`),!t.isStatic)for(let r of t.decorators){let a=Yn.is(r);if(a){this.watchFunctions[n]=a.options;continue}let o=null,s=Hn.is(r);if(s)o=s;else{let e=Bn.is(r);if(e)o=e;else{let e=Un.is(r);e&&(o=e)}}let c,l;o===null?(c=Kn.is(r))?i+=`this.__addActiveDefState(${c.managerName}, this.${t.name});
|
|
417
|
+
`:(l=Jn.is(r))&&(i+=`this.__addInactiveDefState(${l.managerName}, this.${t.name});
|
|
418
|
+
`):r.arguments.length>0&&(e[o.stateName]||(e[o.stateName]={}),e[o.stateName][o.managerName]||(e[o.stateName][o.managerName]={active:[],inactive:[],askChange:[]}),e[o.stateName][o.managerName][o.functionName].push(t.name))}}let l=(0,p.transpile)(`class MyCompilationClassAventus {${a}}`,En.getCompilerOptionsCompile()),u=/\{([\s\S]*)\}/gm.exec(l);if(u&&(t=u[1].trim()),j.isRunning){let e=(0,p.transpile)(`class MyCompilationClassAventus {${o}}`,En.getCompilerOptionsCompile()),t=/\{([\s\S]*)\}/gm.exec(e);t&&(n=t[1].trim())}if(this.templateNpm){let e=(0,p.transpile)(`class MyCompilationClassAventus {${s}}`,En.getCompilerOptionsCompile()),t=/\{([\s\S]*)\}/gm.exec(e);t&&(r=t[1].trim())}}this.writeFileReplaceVar(`methods`,t),this.writeFileHotReloadReplaceVar(`methods`,n),this.writeFileNpmReplaceVar(`methods`,r);let a=``;for(let t in e)for(let n in e[t]){let r=e[t][n];if(a+=`this.__createStatesList(${t}, ${n});`,r.active.length>0){let e=``;for(let t of r.active)e+=`that.`+t+`(state, slugs);`;a+=`this.__addActiveState(${t}, ${n}, (state, slugs) => { that.__inactiveDefaultState(${n}); ${e}})
|
|
419
419
|
`}if(r.inactive.length>0){let e=``;for(let t of r.inactive)e+=`that.`+t+`(state, nextState, slugs);`;a+=`this.__addInactiveState(${t}, ${n}, (state, nextState, slugs) => { ${e}that.__activeDefaultState(nextState, ${n});})
|
|
420
420
|
`}if(r.askChange.length>0){let e=``;for(let t of r.askChange)e+=`if(!await that.`+t+`(state, nextState, slugs)){return false;}
|
|
421
421
|
`;a+=`this.__addAskChangeState(${t}, ${n}, async (state, nextState, slugs) => { ${e} return true;})
|
|
422
|
-
`}}(a.length>0||i.length>0)&&(a=`__createStates() { super.__createStates(); let that = this; ${i} ${a} }`),this.writeFileReplaceVar(`states`,a),this.writeFileHotReloadReplaceVar(`states`,a),this.writeFileNpmReplaceVar(`states`,a)}catch{}}variablesInViewDynamic=``;writeViewInfo(e,t,n,r){let i={},a=``,o=``,s=e.elements,c=[];for(let e of s){let n=e.name;if(this.allFields[n]){let r=this.allFields[n];if(r.propType==`ViewElement`){e.useLive=!t;for(let t of r.decorators){let n=
|
|
422
|
+
`}}(a.length>0||i.length>0)&&(a=`__createStates() { super.__createStates(); let that = this; ${i} ${a} }`),this.writeFileReplaceVar(`states`,a),this.writeFileHotReloadReplaceVar(`states`,a),this.writeFileNpmReplaceVar(`states`,a)}catch{}}variablesInViewDynamic=``;writeViewInfo(e,t,n,r){let i={},a=``,o=``,s=e.elements,c=[];for(let e of s){let n=e.name;if(this.allFields[n]){let r=this.allFields[n];if(r.propType==`ViewElement`){e.useLive=!t;for(let t of r.decorators){let n=zn.is(t);if(n&&n.useLive!==void 0){e.useLive=n.useLive;break}}if(e.useLive){let t=e.ids.map(e=>`[_id="${e}"]`).join(`|`);r.type.isArray||e.isArray?this.variablesInViewDynamic+=`get ${n} () { var list = Array.from(this.shadowRoot.querySelectorAll('${t}')); return list; }
|
|
423
423
|
`:this.variablesInViewDynamic+=`get ${n} () { return this.shadowRoot.querySelector('${t}'); }
|
|
424
|
-
`}else e.isArray?c.push({name:e.name,ids:e.ids,isArray:!0}):c.push({name:e.name,ids:e.ids})}else this.result.diagnostics.push(O(this.document,`You must add the decorator @ViewElement for `+n,r.nameStart,r.nameEnd,1011));delete this.viewsElements[n]}else this.createMissingViewElement(e)}c.length>0&&(i.elements=c);let l=e.content,u={};for(let e in l)u[e]={fct:`@_@${l[e].fct}@_@`},l[e].once&&(u[e].once=!0);Object.keys(u).length>0&&(i.content=u),e.injection.length>0&&(i.injection=e.injection);let d=e.bindings,f=[];for(let e of d){let t={id:e.id,injectionName:e.injectionName,eventNames:e.eventNames,inject:e.inject,extract:e.extract};if(e.once&&(t.once=e.once),e.eventNames.length==1&&e.tagName){let n=this.build.getWebComponentDefinition(e.tagName);if(n){let r=this.isCallback(n.class,e.eventNames[0]);r!=null&&(t.isCallback=!0,t.eventNames[0]=r)}else this.build.htmlLanguageService.getInternalTagUri(e.tagName)&&(this.result.needRebuild=!0)}f.push(t)}f.length>0&&(i.bindings=f);let p=[];for(let t of e.events)if(this.methodsName.includes(t.fct)){let e={eventName:t.eventName,id:t.id,fct:`@_@(e, c) => c.comp.${t.fct}(e)@_@`};if(t.tagName){let n=this.build.getWebComponentDefinition(t.tagName);if(n){let r=this.isCallback(n.class,t.eventName);r!=null&&(e.isCallback=!0,e.eventName=r,e.fct=`@_@(c, ...args) => c.comp.${t.fct}.apply(c.comp, ...args)@_@`)}else this.build.htmlLanguageService.getInternalTagUri(t.tagName)&&(this.result.needRebuild=!0)}p.push(e)}else t.position&&this.createMissingMethod(t.fct,t.position.start,t.position.end);p.length>0&&(i.events=p);let m=[],h=[
|
|
424
|
+
`}else e.isArray?c.push({name:e.name,ids:e.ids,isArray:!0}):c.push({name:e.name,ids:e.ids})}else this.result.diagnostics.push(O(this.document,`You must add the decorator @ViewElement for `+n,r.nameStart,r.nameEnd,1011));delete this.viewsElements[n]}else this.createMissingViewElement(e)}c.length>0&&(i.elements=c);let l=e.content,u={};for(let e in l)u[e]={fct:`@_@${l[e].fct}@_@`},l[e].once&&(u[e].once=!0);Object.keys(u).length>0&&(i.content=u),e.injection.length>0&&(i.injection=e.injection);let d=e.bindings,f=[];for(let e of d){let t={id:e.id,injectionName:e.injectionName,eventNames:e.eventNames,inject:e.inject,extract:e.extract};if(e.once&&(t.once=e.once),e.eventNames.length==1&&e.tagName){let n=this.build.getWebComponentDefinition(e.tagName);if(n){let r=this.isCallback(n.class,e.eventNames[0]);r!=null&&(t.isCallback=!0,t.eventNames[0]=r)}else this.build.htmlLanguageService.getInternalTagUri(e.tagName)&&(this.result.needRebuild=!0)}f.push(t)}f.length>0&&(i.bindings=f);let p=[];for(let t of e.events)if(this.methodsName.includes(t.fct)){let e={eventName:t.eventName,id:t.id,fct:`@_@(e, c) => c.comp.${t.fct}(e)@_@`};if(t.tagName){let n=this.build.getWebComponentDefinition(t.tagName);if(n){let r=this.isCallback(n.class,t.eventName);r!=null&&(e.isCallback=!0,e.eventName=r,e.fct=`@_@(c, ...args) => c.comp.${t.fct}.apply(c.comp, ...args)@_@`)}else this.build.htmlLanguageService.getInternalTagUri(t.tagName)&&(this.result.needRebuild=!0)}p.push(e)}else t.position&&this.createMissingMethod(t.fct,t.position.start,t.position.end);p.length>0&&(i.events=p);let m=[],h=[Gn[`@dblpress`],Gn[`@drag`],Gn[`@drag-end`],Gn[`@drag-start`],Gn[`@longpress`],Gn[`@press`],Gn[`@press-start`],Gn[`@press-stop`]],g=[Gn[`@dblpress-delay`],Gn[`@longpress-delay`]];for(let t of e.pressEvents){let e={id:t.id};for(let n in t){let r=t[n];r instanceof Object&&(h.includes(n)?this.methodsName.includes(r.value)?e[n]=`@_@(e, pressInstance, c) => { c.comp.${r.value}(e, pressInstance); }@_@`:this.createMissingMethod(r.value,r.start,r.end):g.includes(n)&&(e[n]=`@_@${r.value}@_@`))}m.push(e)}if(m.length>0&&(i.pressEvents=m),e.contextEdits.length>0&&(i.contextEdits=e.contextEdits),Object.keys(i).length>0||n||r){let e=JSON.stringify(i,null,2).replace(/"@_@(.*?)@_@"/g,`$1`).replace(/\\"/g,`"`);if(t)a=`this.__getStatic().__template.setActions(${e});
|
|
425
425
|
`;else if(n){a=`const templ${n.templateId} = new Aventus.Template(this);
|
|
426
426
|
`,a+=`templ${n.templateId}.setTemplate(\`${n.template}\`);
|
|
427
427
|
`,Object.keys(i).length>0&&(a+=`templ${n.templateId}.setActions(${e});
|
|
@@ -467,7 +467,7 @@ this.clearWatchHistory = () => {
|
|
|
467
467
|
}`),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`);this.htmlDoc[this.tagName].attributes[e.name]={name:e.name,description:e.documentation?.definitions.join(`
|
|
468
468
|
`)??``,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(`
|
|
469
469
|
`)??``,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(`
|
|
470
|
-
`)??``,values:[]}}}writeFileReplaceVar(e,t){let n=RegExp(`\\$`+e+`\\$`,`g`);this.template=this.template.replace(n,t+``)}writeFileHotReloadReplaceVar(e,t){if(j.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=Nn(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(je(this.document,r,`methods`,1019))),this.htmlFile&&this.htmlFile.tsErrors.push(Pe(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(je(this.document,r,`variables`,1011)),this.htmlFile)for(let t of e.positions)this.htmlFile.tsErrors.push(Pe(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(O(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(O(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(cn.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,wn.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`)return n;{let r=P.getBaseInfo(n.value,e.uri);if(r&&r instanceof en)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(O(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(O(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(O(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(O(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,``)}},Zn=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(It(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(It(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=Bt.buildDecorator(e);for(let e of n){let t=_n.is(e);if(t){t.writeHTML&&(this.writeHtml=!0),t.writeComponentTs&&(this.writeTs=!0);continue}if(!this.isAbstract){let t=Fn.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}}},F=class e extends hn{_compilationResult;canUpdateComponent=!0;viewMethodsInfo=[];storyBookInfo={argsTypes:{},args:{}};get compilationResult(){return this._compilationResult}get extension(){return w.ComponentLogic}get version(){let e=Xn.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`__`+Ye(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=Xn.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 Xn(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+`
|
|
470
|
+
`)??``,values:[]}}}writeFileReplaceVar(e,t){let n=RegExp(`\\$`+e+`\\$`,`g`);this.template=this.template.replace(n,t+``)}writeFileHotReloadReplaceVar(e,t){if(j.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=Fn(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(Me(this.document,r,`methods`,1019))),this.htmlFile&&this.htmlFile.tsErrors.push(Fe(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(Me(this.document,r,`variables`,1011)),this.htmlFile)for(let t of e.positions)this.htmlFile.tsErrors.push(Fe(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(O(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(O(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(un.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,En.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`)return n;{let r=P.getBaseInfo(n.value,e.uri);if(r&&r instanceof nn)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(O(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(O(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(O(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(O(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,``)}},$n=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(Rt(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(Rt(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=Ht.buildDecorator(e);for(let e of n){let t=yn.is(e);if(t){t.writeHTML&&(this.writeHtml=!0),t.writeComponentTs&&(this.writeTs=!0);continue}if(!this.isAbstract){let t=Ln.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}}},F=class e extends _n{_compilationResult;canUpdateComponent=!0;viewMethodsInfo=[];storyBookInfo={argsTypes:{},args:{}};get compilationResult(){return this._compilationResult}get extension(){return w.ComponentLogic}get version(){let e=Qn.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`__`+Xe(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=Qn.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 Qn(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+`
|
|
471
471
|
`,r+=`}
|
|
472
472
|
`,r+=`}`,this.file instanceof A&&(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+`
|
|
473
473
|
`,r+=`}
|
|
@@ -504,7 +504,7 @@ this.clearWatchHistory = () => {
|
|
|
504
504
|
`;let n=e.keys.map(e=>`"${e.replace(/"/g,`\\"`)}": string`).join(`,
|
|
505
505
|
`);c+=`\ntype ${this.componentClassName}__Generated = {
|
|
506
506
|
${n}
|
|
507
|
-
}`})(n),a+=t.slice(this.componentEnd-r),a+=c,this.file instanceof A&&this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,i,a))}this.refreshFileParsed();let s=(0,f.join)(this.file.folderPath,`compiled.html`),c=(0,f.join)(this.file.folderPath,`compiled.ts`);this.writeHtml?(0,u.writeFileSync)(s,this.HTMLFile?.fileParsed?.compiledTxt??``):(0,u.existsSync)(s)&&(0,u.unlinkSync)(s),this.writeTs?(0,u.writeFileSync)(c,a):(0,u.existsSync)(c)&&(0,u.unlinkSync)(c)}}else this.file instanceof A&&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=Zn.parse(this.file.documentUser.getText(),this.build);this._componentEnd=e.end,this._fullname=e.fullname,this._componentClassName=e.className,this.writeHtml=e.writeHtml,this.writeTs=e.writeTs,e.tagName&&this.build.htmlLanguageService.addInternalTagUri(e.tagName,this.file.uri,this._fullname);let t=``;for(let n=0;n<e.whiteSpaceBefore+4;n++)t+=` `;this._space=t}async onContentChange(){this.quickParse(),await this.runWebCompiler()}async onSave(){await this.runWebCompiler(),this.compilationResult?this.setCompileResult(this.compilationResult.result):this.setCompileResult([]),this.compilationResult?.writeCompiled?(0,u.writeFileSync)(this.file.folderPath+`/compiled.js`,Be(this.compilationResult.debug,this.build.project.getConfig())):(0,u.existsSync)(this.file.folderPath+`/compiled.js`)&&(0,u.unlinkSync)(this.file.folderPath+`/compiled.js`),this.canUpdateComponent||=!0}emitToHtttpServer(e){if(!this.canUpdateComponent)return;let t={};for(let n of e)t[n.name]=n.src;let n=!1,r=``,i=``,a;if(this.compilationResult)for(let e of this.compileResult)e.classScript!=``&&t[e.classScript]&&t[e.classScript]!=e.compiled&&(e.classScript==this.compilationResult.componentName?(n=!0,r=e.hotReload,i=e.classScript,a=this.fileParsed?.classes[i]):this.build.reloadPage=!0);if(!this.build.reloadPage&&n&&a){let e=this.buildNamespace;a.namespace&&(e+=a.namespace),e.length>0&&!e.endsWith(`.`)&&(e+=`.`),j.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()
|
|
507
|
+
}`})(n),a+=t.slice(this.componentEnd-r),a+=c,this.file instanceof A&&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)&&Ze(s),this.writeTs?(0,u.writeFileSync)(c,a):(0,u.existsSync)(c)&&Ze(c)}}else this.file instanceof A&&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=$n.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`,Ve(this.compilationResult.debug,this.build.project.getConfig())):(0,u.existsSync)(this.file.folderPath+`/compiled.js`)&&Ze(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+=`.`),j.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()
|
|
508
508
|
protected `+t+`!: `+this.compilationResult.missingViewElements.elements[t]+`;
|
|
509
509
|
`}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+=`/**
|
|
510
510
|
*
|
|
@@ -513,11 +513,12 @@ protected ${t}(){
|
|
|
513
513
|
throw new Error("Method not implemented.");
|
|
514
514
|
}
|
|
515
515
|
`}return e!=``&&(e=`
|
|
516
|
-
`+e),{start:t,text:e}}getComponentName(){return this.compilationResult?.componentName||``}viewClassInfoDependencies=[];reverseViewClassInfoDependencies=new Map;resetViewClassInfoDep(){let t=this.HTMLFile;if(t){for(let n of this.viewClassInfoDependencies)n instanceof e&&n.reverseViewClassInfoDependencies.delete(t);this.viewClassInfoDependencies=[]}}addViewClassInfoDep(t,n,r){let i=this.HTMLFile;i&&(this.viewClassInfoDependencies.includes(t)||this.viewClassInfoDependencies.push(t),t instanceof e&&(t.reverseViewClassInfoDependencies.has(i)||t.reverseViewClassInfoDependencies.set(i,[]),t.reverseViewClassInfoDependencies.get(i)?.push({start:n,end:r})))}},Qn=class e{tagName=``;children=[];attributes={};hasClose=!1;selfClosing=!1;id=``;start=0;end=0;parent=null;parentTemplateId;openTagStart=0;openTagEnd=0;alias=null;aliasMultiple=void 0;pressEvent=null;eventsPerso=[];injections=[];bindings=[];changes={};variableNames=[];parser;_idBase;get idBase(){return this._idBase||=this.componentClassName+`_`,this._idBase}get componentClassName(){return this.parser.htmlFile.tsFile?.componentClassName.toLowerCase()??``}get isLoop(){return this.tagName==rr.tagName}get isIf(){return this.tagName==ir.tagName}get isContextEditing(){return this.tagName==ar.tagName}loopInfo;ifInfo;contextEdit;constructor(e,t,n,r){if(this.parser=e,this.tagName=t,this.start=n,this.openTagStart=n,this.end=r,this.isLoop){this.createId();return}this.isIf||this.isContextEditing||(I.addInterestPoint({name:t,start:n,end:r,type:`tag`}),$n.includes(t)&&(this.selfClosing=!0))}createId(){return this.id||(this.id=this.idBase+I.idElement,I.idElement++),this.id}addAttribute(e){if(e.name==`@for`){I.addError(e.nameStart,e.nameEnd,`Deprecated : use for directly inside template`);return}this.attributes[e.name]?I.addError(e.nameStart,e.nameEnd,`Duplicate attribute `+e.name):this.attributes[e.name]=e}addChild(e){this.children.push(e),e.parent=this}addContent(e){this.children.push(e)}addChanges(e,t,n){let r=this.createId()+`°`+e;this.changes[r]={fct:t,once:n}}validateAllProps(e){if(this.openTagEnd=e,this.alias){let e=this.alias.endsWith(`[]`);e&&(this.alias=this.alias.replace(`[]`,``)),e&&(this.aliasMultiple=e)}if(this.isLoop){this.parentTemplateId=I.getParentId();let e=I.addLoopStack(Number(this.attributes.id.value));e&&(this.loopInfo=e)}else if(this.isIf){this.parentTemplateId=I.getParentId();let e=Number(this.attributes.id.value),t=I.addIfStack(e);t&&(this.ifInfo=t,e==t.idsTemplate[0]&&(t._id=this.createId()))}else if(this.isContextEditing){this.parentTemplateId=I.getParentId();let e=Number(this.attributes.id.value),t=I.getContextEditing(e);if(t&&(this.contextEdit=t,this.parent))for(let e of t.variableNames)this.parent.variableNames.includes(e)||this.parent.variableNames.push(e)}I.addTagInfoStack(this)}afterClose(e,t){this.hasClose=!0,this.selfClosing||I.addInterestPoint({name:this.tagName,start:e,end:t,type:`tag`}),this.checkStyle(I.getRules(),e=>I.addStyleLink(e)),I.removeStack(),(this.isLoop||this.isIf)&&I.removeStack()}checkStyle(e,t){for(let[n,r]of e)n(this)&&t([{start:this.openTagStart,end:this.openTagEnd},r])}_render(){let e=[];for(let t in this.attributes){let n=this.attributes[t];n.mustBeAdded&&(n.value==null?e.push(n.name):e.push(n.name+`="`+n.value+`"`))}this.id&&e.push(`_id="`+this.id+`"`);let t=``;return e.length>0&&(t=` `+e.join(` `)),this.selfClosing?`<${this.tagName}${t} />`:`<${this.tagName}${t}>${this.children.map(e=>e.render()).join(``)}</${this.tagName}>`}render(){return this.isContextEditing?``:this.isLoop?`<template _id="`+this.id+`"></template>`:this.isIf?this.id?`<template _id="`+this.id+`"></template>`:``:this._render()}replaceId(t){t.endsWith(`_`)||(t+=`_`),this.id=this.id.replace(this.idBase,t);let n={};for(let e in this.changes){let r=e.replace(this.idBase,t);n[r]=this.changes[e]}this.changes=n,this.ifInfo&&(this.ifInfo._id=this.ifInfo._id.replace(this.idBase,t)),this._idBase=t;for(let n of this.children)n instanceof e&&n.replaceId(t)}getTemplateInfo(t){let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},r=this.id,i=e=>{if(this.alias){let t=this.aliasMultiple?2:1;e.elements.push({name:this.alias,ids:[r],tags:{[this.tagName]:t},useLive:!1,isArray:t>1,positions:[{start:this.attributes[`@element`].valueStart,end:this.attributes[`@element`].valueEnd}]})}for(let t in this.changes)e.content[t]=this.changes[t];for(let t of this.injections){let n={id:r,injectionName:t.attr,inject:`@_@${t.injectTxt}@_@`};t.computedOnce&&(n.once=!0),e.injection.push(n)}for(let t of this.bindings){let n=[];n=t.event?[t.event]:[`input`,`textarea`].includes(this.tagName)?[`change`,`input`]:[`change`];let i={id:r,eventNames:n,injectionName:t.valueName,tagName:this.tagName,inject:`@_@${t.injectTxt}@_@`,extract:`@_@${t.extractTxt}@_@`};t.computedOnce&&(i.once=!0),e.bindings.push(i)}for(let t of this.eventsPerso)e.events.push({eventName:t.event,id:r,fct:t.fct,tagName:this.tagName,position:{start:t.start,end:t.end}});if(this.pressEvent&&e.pressEvents.push({...this.pressEvent,id:r}),this.contextEdit){let t={fct:this.contextEdit.fctJs};this.contextEdit.computedOnce&&(t.once=!0),e.contextEdits.push(t)}};if(this.loopInfo){let r={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},i=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);I.mergeTemplateResult(r,e)}i+=n.render()}let a={templateId:this.loopInfo.idTemplate||0,anchorId:this.id,template:i,actions:r,parentId:this.parentTemplateId};this.loopInfo.isSimple?a.simple=this.loopInfo.simple:a.func=this.loopInfo.complex.fct,n.loops.push(a)}else if(this.isIf&&this.ifInfo){let r=Number(this.attributes.id.value),i={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},a=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);I.mergeTemplateResult(i,e)}a+=n.render()}if(this.ifInfo.registerPart({template:a,templateId:r,templateAction:i,condition:``}),r==this.ifInfo.idsTemplate[this.ifInfo.idsTemplate.length-1]){let e={anchorId:this.ifInfo._id,parts:this.ifInfo.parts,parentId:this.parentTemplateId};n.ifs.push(e)}}else{i(n);for(let r of this.children)if(r instanceof e){let e=r.getTemplateInfo(t);I.mergeTemplateResult(n,e)}}return n}};const $n=[`area`,`base`,`br`,`col`,`embed`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`],er=[`_id`];var tr=class{name=``;value=null;nameStart=0;nameEnd=0;valueStart=0;valueEnd=0;tag;mustBeAdded=!0;constructor(e,t,n,r){this.name=e,this.nameStart=I.fromCompiledToRaw(t),this.nameEnd=I.fromCompiledToRaw(n),this.tag=r,this.manageSpecialAttribute()}manageSpecialAttribute(){this.name.startsWith(`@`)||this.name.startsWith(`:`)?(this.tag.createId(),this.mustBeAdded=!1):er.includes(this.name)&&(I.addError(this.nameStart,this.nameEnd,`The attribute `+this.name+` is used by Aventus internally`),this.mustBeAdded=!1)}setValue(e,t,n){if(e=e.replace(/"/g,``),this.value=e,this.valueStart=I.fromCompiledToRaw(t),this.valueEnd=I.fromCompiledToRaw(n),this.name!=`@for`)if(this.name===`@element`)this.tag.alias=e,I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`property`});else if(this.name.startsWith(`@bind`)||this.name.startsWith(`$`)){let r=new sr(this.name,e,t,n);this.tag.bindings.push(r),I.addBinding(r)}else if(this.name.startsWith(`:`)){let r=new or(this.name.slice(1),e,t,n);this.tag.injections.push(r),I.addInjection(r)}else if(Un.hasOwnProperty(this.name))this.tag.pressEvent||(this.tag.pressEvent={}),this.tag.pressEvent[Un[this.name]]={value:e,start:this.valueStart,end:this.valueEnd},I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else if(this.name.startsWith(`@`))this.tag.eventsPerso.push({event:this.name.slice(1),fct:e,start:this.valueStart,end:this.valueEnd}),I.addInterestPoint({name:this.name.slice(1),start:this.nameStart,end:this.nameEnd,type:`event`}),I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else{let t=cr(e,this.valueStart);t.changes.length>0&&(this.tag.addChanges(this.name,t.txt,t.once),this.mustBeAdded=!1)}}},nr=class{content=``;start=0;end=0;tag;mustBeAdded=!0;constructor(e,t,n,r,i=!0){this.content=e,this.start=I.fromCompiledToRaw(t),this.end=I.fromCompiledToRaw(n),this.tag=r,i&&this.manageVariables()}manageVariables(){let e=this.content,t=cr(e,this.start);t.changes.length>0&&(this.tag.addChanges(`@HTML`,t.txt,t.once),this.mustBeAdded=!1);for(let e of t.variables)this.tag.variableNames.includes(e)||this.tag.variableNames.push(e)}render(){return this.mustBeAdded?this.content:``}},rr=class e{static tagName=`l`;idTemplate=0;isSimple=!1;transformations=[];start=0;startBlock=0;end=0;loopTxt=``;loopName=``;isValid=!0;typeToLoad=[];simple={data:``};complex={init:[],condition:``,transform:[],apply:[],loopName:``,fct:``};get variableNames(){return this.typeToLoad.map(e=>e.txt)}variables=[];sliceText;constructor(e,t){this.sliceText=t,this.idTemplate=I.createIdTemplate(),this.variables=I.getVariables(),e.kind==p.SyntaxKind.ForOfStatement||e.kind==p.SyntaxKind.ForInStatement?(this.isSimple=!0,this.loadForInOf(e)):this.loadFor(e),this.loopName=I.getCustomFctName()??``}loadForInOf(t){let n=0;(0,p.forEachChild)(t,r=>{if(n==0){let e=r.getChildAt(1),n=e.getStart(),i=e.getEnd(),a=this.sliceText(n,i);t.kind==p.SyntaxKind.ForInStatement?this.simple.index=a:this.simple.item=a,this.typeToLoad.push({txt:a,start:n,end:i})}else if(n==1)this.simple.data=this.sliceText(r.getStart(),r.getEnd());else if(n==2){let n=t.getStart(),i=r.getStart()+1;this.loopTxt=this.sliceText(n,i)+` }`;let a=`<`+e.tagName+` id="`+this.idTemplate+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o}),this.start=n,this.startBlock=i,this.end=s}n++})}loadFor(t){let n=[],r=[],i=``,a=[],o=0,s=``;if((0,p.forEachChild)(t,c=>{if(o==0&&c.kind==p.SyntaxKind.VariableDeclarationList)(0,p.forEachChild)(c,e=>{let t=e.getChildAt(0),i=t.getStart(),a=t.getEnd(),o=this.sliceText(i,a);n.push(`let `+e.getText()),r.push(e.getChildAt(0).getText()),this.typeToLoad.push({txt:o,start:i,end:a})});else if(o==1&&c.kind==p.SyntaxKind.BinaryExpression)i=c.getText();else if(o==2){let e=t=>{t.kind==p.SyntaxKind.BinaryExpression&&t.getChildAt(1).getText()==`,`?(e(t.getChildAt(0)),e(t.getChildAt(2))):a.push(t.getText())};e(c)}else if(o==3&&c.kind==p.SyntaxKind.Block){let n=t.getStart(),r=c.getStart()+1;s=this.sliceText(n,r)+` }`,this.loopTxt=s;let i=`<`+e.tagName+` id="`+this.idTemplate+`">`,a=`</`+e.tagName+`>`;this.transformations.push({start:n,end:r,newText:i});let o=c.getEnd();this.transformations.push({start:o-1,end:o,newText:a}),this.start=n,this.startBlock=r,this.end=o}o++}),this.transformations.length==0&&(this.isValid=!1),!this.checkIsSimple(n,i,a)){let e=I.getCustomFctName(1)??``;this.complex={init:n,condition:i,transform:a,apply:r,loopName:e,fct:`(c) => c.comp.${e}`}}}recalculateVariables(){if(this.variables=lr(this.loopTxt,I.getVariables()),!this.isSimple){let e=this.variables.map(e=>`c.data.`+e).join(`,`);this.complex.fct+=`(${e})`}}checkIsSimple(e,t,n){if(e.length!=1)return!1;let r=e[0].split(`=`);if(r.length!=2)return!1;let i=r[0].replace(`let `,``).trim();if(r[1].trim()!=`0`)return!1;let a=RegExp(`\\s*`+i+`\\s*<\\s*([a-zA-Z0-9\\._\\[\\]-]+)\\.length`).exec(t);if(!a)return!1;let o=a[1];return n.length!=1||!RegExp(`\\s*`+i+`\\+\\+\\s*`).exec(n[0])?!1:(this.isSimple=!0,this.simple={data:o,index:i},!0)}},ir=class e{static tagName=`if`;statements=[];idsTemplate=[];defaultVariables=[];transformations=[];end=0;_id=``;parts=[];isValid=!0;conditions=[];sliceText;constructor(e,t){this.sliceText=t,this.defaultVariables=I.getVariables(),this.loadIf(e)}loadIf(t){let n=[],r=()=>{let e=I.createIdTemplate();return this.idsTemplate.push(e),e},i=(t,n,r)=>{let i=r.getStart()+1,a=`<`+e.tagName+` id="`+t+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o})},a=(e,t=0,o)=>{let s=0;o===void 0&&(o=e.getStart());let c=o,l;for(let t of e.getChildren())t.kind==p.SyntaxKind.ElseKeyword&&(l=t.getStart());let u=r();(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Block){if(s++,s==2){if(l==null)throw`impossible`;i(r(),l,e)}else i(u,c,e);n.push(e)}else if(e.kind==p.SyntaxKind.IfStatement){if(l==null)throw`impossible`;a(e,t+1,l)}else if(p.SyntaxKind[e.kind].includes(`Expression`)){let n=I.getCustomFctName(this.conditions.length)??``,r=this.sliceText(e.getStart(),e.getEnd());this.conditions.push({fctName:n,txt:r,fctTxt:`(c) => c.comp.${n}`,start:e.getStart(),end:e.getEnd(),offsetAfter:0,offsetBefore:0,idTemplate:u,type:t==0?`if`:`elif`,variables:[],computedOnce:ur(r)})}}),s==0&&(this.isValid=!1)};a(t)}registerPart(e){this.conditions.length>this.parts.length?(e.condition=this.conditions[this.parts.length].fctTxt,e.once=this.conditions[this.parts.length].computedOnce):(e.condition=`(c) => true`,e.once=!0),this.parts.push(e)}recalculateVariables(e){let t=I.getVariables();for(let n of this.conditions)if(n.idTemplate==e){let e=lr(n.txt,t),r=e.map(e=>`c.data.`+e).join(`,`);n.fctTxt+=`(${r})`,n.variables=e}}},ar=class e{static tagName=`c`;sliceText;variables=[];transformations=[];id;fctTs=``;fctJs=``;editName;start=0;end=0;mapping=[``,``];computedOnce=!1;typeToLoad=[];get variableNames(){return this.typeToLoad.map(e=>e.txt)}constructor(e,t){this.sliceText=t,this.editName=I.getCustomFctName()??``,this.id=I.createIdTemplate(),this.loadContextEditing(e)}loadContextEditing(t){this.start=t.getStart(),this.end=t.getEnd(),this.transformations.push({start:t.getStart(),end:t.getEnd(),newText:`<`+e.tagName+` id="`+this.id+`"></`+e.tagName+`>`}),(0,p.forEachChild)(t,e=>{if(e.kind==p.SyntaxKind.CallExpression){let t=e,n=`{ `,r=0;for(let e of t.arguments)n+=e.getText(),r==0&&(this.typeToLoad.push({txt:e.getText().replace(/['`"]/g,``),start:e.getStart(),end:e.getEnd()}),n+=`: `),this.mapping[r]=e.getText(),r++;n+=` }`,this.fctTs=`return `+n,this.computedOnce=ur(this.fctTs)}}),this.variables=lr(this.fctTs,I.getVariables());let n=this.variables.map(e=>`c.data.`+e).join(`,`);this.fctJs=`@_@(c) => c.comp.${this.editName}(${n})@_@`}},or=class{start=0;end=0;attr;injectFctName;injectTsTxt;injectTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){this.attr=e,this.start=I.fromCompiledToRaw(n),this.end=I.fromCompiledToRaw(r),this.injectFctName=I.getCustomFctName()??``,this.injectTsTxt=t,this.computedOnce=ur(t),this.variables=lr(t,I.getVariables());let i=this.variables.map(e=>`c.data.`+e).join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${i})`}},sr=class{start=0;end=0;event;valueName=`value`;injectFctName;extractFctName;injectTsTxt;extractTsCond;extractTsTxt;injectTxt;extractTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){let i=e.split(`:`),a=i[0];a.startsWith(`@bind_`)?this.event=a.replace(`@bind_`,``):a.startsWith(`$`)&&a.length>0&&(this.event=a.replace(`$`,``)),i.length>1&&(this.valueName=i[1]),this.start=I.fromCompiledToRaw(n),this.end=I.fromCompiledToRaw(r),this.injectFctName=I.getCustomFctName()??``,this.extractFctName=I.getCustomFctName(1)??``,this.injectTsTxt=t,this.computedOnce=ur(t);let o=t.split(`.`);o.pop(),this.extractTsCond=o.join(`.`).trim(),this.extractTsCond.endsWith(`?`)&&(this.extractTsCond=this.extractTsCond.slice(0,this.extractTsCond.length-1)),this.extractTsTxt=t.replace(/\?/g,``),this.variables=lr(t,I.getVariables());let s=this.variables.map(e=>`c.data.`+e),c=[`v`].concat(s).join(`,`),l=s.join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${l})`,this.extractTxt=`(c, v) => c.comp.${this.extractFctName}(${c})`}};function cr(e,t){let n=/\{\{([\s|\S]*?)\}\}/g,r,i={changes:[],txt:e,variables:[],once:!0};for(;r=n.exec(e);){let e=t+r.index,n=t+r.index+r[0].length,a=I.createChange({txt:r[1],start:e,end:n});if(i.once&&!ur(r[1])&&(i.once=!1),a){a.variables=lr(r[1],a.variables);let e=a.variables.map(e=>`c.data.`+e).join(`,`),t="${c.print(c.comp."+a.name+`(`+e+`))}`;i.txt=i.txt.replace(r[0],t),i.changes.push(a)}}return i.changes.length>0&&(i.txt="(c) => `"+i.txt+"`"),i}function lr(e,t){if(t.length==0)return t;let n=[],r=(0,p.createSourceFile)(`sample.ts`,e,p.ScriptTarget.ESNext,!0),i=e=>{(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Identifier){if(e.parent.kind!=p.SyntaxKind.PropertyAccessExpression){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}else if(e.parent.getChildAt(0)==e){let r=e.getText();t.includes(r)&&!n.includes(r)&&n.push(r)}}i(e)})};return i(r),n}function ur(e){return!/if|switch|\?|\[.+?\]/g.test(e)}var I=class e{static languageService=(0,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=Ye(e.txt);if(this.currentParsingDoc.fcts[t])return this.currentParsingDoc.fcts[t].positions.push({start:e.start,end:e.end}),this.currentParsingDoc.fcts[t];{let n=this.getCustomFctName(),r=this.getVariables();if(n){let i={name:n,positions:[{start:e.start,end:e.end}],txt:e.txt,variables:r};return this.currentParsingDoc.fcts[t]=i,i}}}return null}static fromRawToCompiled(e){return this.currentParsingDoc?this.currentParsingDoc.fromRawToCompiled(e):e}static fromCompiledToRaw(e){return this.currentParsingDoc?this.currentParsingDoc.fromCompiledToRaw(e):e}static addLoopStack(e){if(this.currentParsingDoc){let t=this.currentParsingDoc.loops.find(t=>t.idTemplate==e);if(t)return t.recalculateVariables(),this.currentParsingDoc?.stacks.push(t),t}return null}static addIfStack(e){if(this.currentParsingDoc){for(let t of this.currentParsingDoc.ifs)if(t.idsTemplate.includes(e))return t.recalculateVariables(e),this.currentParsingDoc?.stacks.push({idTemplate:e}),t}return null}static addInjection(e){this.currentParsingDoc?.injections.push(e)}static addBinding(e){this.currentParsingDoc?.bindings.push(e)}static addTagInfoStack(e){this.currentParsingDoc?.stacks.push(e)}static getContextEditing(e){return this.currentParsingDoc?.contextEdits.find(t=>t.id==e)}static removeStack(){this.currentParsingDoc?.stacks.pop()}static getParentId(){if(this.currentParsingDoc&&this.currentParsingDoc.stacks.length>0)for(let e=this.currentParsingDoc.stacks.length-1;e>=0;e--){let t=this.currentParsingDoc.stacks[e];if(t instanceof rr||!(t instanceof Qn))return t.idTemplate}}static getVariables(){let e=[];if(this.currentParsingDoc){for(let t of this.currentParsingDoc.stacks)if(t instanceof rr||t instanceof Qn)for(let n of t.variableNames)e.includes(n)||e.push(n)}return e}uri;errors=[];document;rootTags=[];tags=[];blocksInfo={};slotsInfo={};resultsByClassName={};interestPoints=[];rules;styleLinks=[];fcts={};htmlFile;loops=[];ifs=[];injections=[];bindings=[];contextEdits=[];diffRawToCompiled={};diffCompiledToRaw={};stacks=[];compiledTxt=``;fromRawToCompiled(e){let t=e;for(let n in this.diffRawToCompiled){if(Number(n)>e)break;t+=this.diffRawToCompiled[n]}return t}fromCompiledToRaw(e){let t=e;for(let n in this.diffCompiledToRaw){if(Number(n)>e)break;t+=this.diffCompiledToRaw[n]}return t}getBlocksInfoTxt(){let e=[];for(let t in this.blocksInfo)e.push(`'`+t+"':`"+this.blocksInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}getSlotsInfoTxt(){let e=[];for(let t in this.slotsInfo)e.push(`'`+t+"':`"+this.slotsInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}isReady=!1;build;constructor(t,n){this.build=n,this.htmlFile=t,e.parsedDoc[t.file.uri]={version:t.file.versionUser,result:this};let r=this.getFileContent(t.file.documentUser);this.rules=t.scssFile?.rules??new Map,this.document=d.TextDocument.create(t.file.uri,t.file.documentUser.languageId,t.file.versionUser,r),e.currentParsingDoc=this,this.uri=t.file.uri,e.idElement=0,e.idTemplate=0,e.idTemplate=0,this.parse(this.document),e.currentParsingDoc=null,this.isReady=!0;for(let e of this.readyCb)e()}getFileContent(e){let t=e.getText();return t=t.replace(/\\\{\{(.*?)\}\}/g,`{{$1}}`),t=t.replace(/\\if/g,`if`),t=t.replace(/\\else/g,`else`),t=t.replace(/\\for/g,`for`),t=t.replace(/\\@Context/g,`@Context`),t}readyCb=[];onReady(e){this.isReady||this.readyCb.push(e)}parseJs(e){let t=e.getText(),n={},r=/<!--(.|\s)*?-->/g,i;for(;i=r.exec(t);){let e=``;for(let t=0;t<i[0].length;t++)e+=` `;n[i.index]=i[0],t=t.slice(0,i.index)+e+t.slice(i.index+i[0].length)}let a=t,o=(e,t)=>a.slice(e,t),s=(0,p.createSourceFile)(`sample.ts`,t.replace(/\{\{|\}\}/g,` `).replace(/<\/?[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 ir(n,o);e.isValid&&(this.ifs.push(e),c=[...c,...e.transformations])}}else if([p.SyntaxKind.ForInStatement,p.SyntaxKind.ForOfStatement,p.SyntaxKind.ForStatement].includes(n.kind)){if(n.getText()!==`for`){let e=new rr(n,o);e.isValid&&(r=e,c=[...c,...r.transformations],this.loops.push(r),this.stacks.push(r))}}else if(n.kind==p.SyntaxKind.Decorator&&n.getText().startsWith(`@Context(`)){let e=new ar(n,o);c=[...c,...e.transformations],this.contextEdits.push(e)}n.kind==p.SyntaxKind.Block&&e.kind==p.SyntaxKind.Block||(l(n,t+1),r&&this.stacks.pop())})};l(s,0),c.sort((e,t)=>t.end-e.end);let u=t.length;this.diffRawToCompiled={};for(let e of c){if(e.end>u)continue;let n=Math.min(e.newText.length,e.end-e.start);this.diffRawToCompiled[e.start+n]=e.newText.length-(e.end-e.start),t=t.slice(0,e.start)+e.newText+t.slice(e.end,t.length),u=e.start}let d=0;for(let e in this.diffRawToCompiled){let t=Number(e)+d,n=this.diffRawToCompiled[e]*-1;d+=this.diffRawToCompiled[e],this.diffCompiledToRaw[t]=n}for(let e in n){let r=n[e],i=this.fromRawToCompiled(Number(e));t=t.slice(0,i)+r+t.slice(i+r.length)}return t}parse(t){let n=this.parseJs(t);this.compiledTxt=n;let r=[],i=!1,a=e.languageService.createScanner(n,0),o=[],s=null;try{for(;a.scan()!=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 nr(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 Qn(this,e,t,n);o.length>0?o[o.length-1].addChild(r):this.rootTags.push(r),this.tags.push(r),o.push(r)}else if(a.getTokenType()!=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(Pe(t,`The tag `+n?.tagName+` isn't correctly closed`,n?.start,n?.end)):this.errors.push(Pe(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 tr(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 nr(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]}},dr=o(((e,t)=>{t.exports=function(e){return e&&typeof e.valueOf()==`string`}})),fr=o(((e,t)=>{let n=dr();t.exports=function(e){if(e==null)return!1;if(!u(e))return r(`Options should be an object.`);if(e.order!==void 0&&e.order!==null){let{isValid:t,message:n}=o(e.order);if(!t)return i(`order`,n)}if(e[`properties-order`]!==void 0&&e[`properties-order`]!==null){let{isValid:t,message:n}=s(e[`properties-order`]);if(!t)return i(`properties-order`,n)}if(e[`unspecified-properties-position`]!==void 0&&e[`unspecified-properties-position`]!==null){let{isValid:t,message:n}=c(e[`unspecified-properties-position`]);if(!t)return i(`unspecified-properties-position`,n)}return!0};function r(e){return`postcss-sorting: ${e}`}function i(e,t=`Invalid value`){return r(`${e}: ${t}`)}function a(e){return e.join(`, `)}function o(e){if(!Array.isArray(e))return{isValid:!1,message:`Should be an array`};let t=[`custom-properties`,`dollar-variables`,`at-variables`,`declarations`,`rules`,`at-rules`];if(!e.every(e=>n(e)?t.includes(e):u(e)&&e.type!==void 0))return{isValid:!1,message:`Every item in the array must be an object with a "type" property, or one of keywords: ${a(t)}.`};let r=e.filter(u),i;return r.every(e=>{let t=!0;if(e.type!==`at-rule`&&e.type!==`rule`)return i=`"type" could be 'at-rule' or 'rule' only`,!1;if(e.type===`at-rule`){if(e.parameter!==void 0&&e.name===void 0)return i=`"at-rule" with "parameter" should also has a "name"`,!1;e.hasBlock!==void 0&&(t=e.hasBlock===!0||e.hasBlock===!1),e.name!==void 0&&(t=n(e.name)&&e.name.length),e.parameter!==void 0&&(t=n(e.parameter)&&e.parameter.length||l(e.parameter))}return e.type===`rule`&&e.selector!==void 0&&(t=n(e.selector)&&e.selector.length||l(e.selector)),t||(i=`Following option is incorrect: ${JSON.stringify(e)}`),t})?{isValid:!0}:{isValid:!1,message:i}}function s(e){return e===`alphabetical`?{isValid:!0}:Array.isArray(e)?e.every(e=>n(e))?{isValid:!0}:{isValid:!1,message:`Array should contain strings only`}:{isValid:!1,message:`Should be an array`}}function c(e){let t=[`top`,`bottom`,`bottomAlphabetical`];return n(e)&&t.includes(e)?{isValid:!0}:{isValid:!1,message:`Option should be one of the following values: ${a(t)}.`}}function l(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function u(e){return typeof e==`object`&&!!e}})),pr=o(((e,t)=>{t.exports=function(e){return e.type===`rule`||e.type===`atrule`?e:e.parent?.type===`root`&&e.parent?.raws.isRuleLike||e.parent?.document?.nodes?.some(e=>e.type===`root`)?e.parent:e}})),mr=o(((e,t)=>{let n=dr();t.exports=function(e){let t={},r=0;return e.forEach(e=>{let i=e;if(r+=1,n(i)&&i!==`at-rules`&&i!==`rules`&&(t[i]={position:r}),i===`rules`||i.type===`rule`){i===`rules`&&(i={type:`rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.selector&&(e.selector=i.selector,n(i.selector)&&(e.selector=new RegExp(i.selector))),t[i.type].push(e)}if(i===`at-rules`||i.type===`at-rule`){i===`at-rules`&&(i={type:`at-rule`}),t[i.type]||(t[i.type]=[]);let e={position:r};i.name&&(e.name=i.name),i.parameter&&(e.parameter=i.parameter,n(i.parameter)&&(e.parameter=new RegExp(i.parameter))),i.hasBlock!==void 0&&(e.hasBlock=i.hasBlock),t[i.type].push(e)}}),t}})),hr=o(((e,t)=>{let n=[`function`,`if`,`else`,`for`,`each`,`while`];t.exports=function(e,t){return!(e.type===`atrule`&&n.includes(e.name)||!e?.nodes?.length||!(t&&t.ignoreInterpolations)&&(e.raws.after?.includes("${")||e.nodes.some(e=>e.raws.before.includes("${"))))}})),gr=o(((e,t)=>{t.exports=function(e,t,n){return e.type===`comment`&&!e.hasOwnProperty(`position`)?(e.position=1/0,e.initialIndex=t,[...n,e]):n}})),_r=o(((e,t)=>{t.exports=function(e){return!(e[0]===`$`||e[0]===`@`||/#{.+?}|@{.+?}|\$\(.+?\)/.test(e))}})),vr=o(((e,t)=>{t.exports=function(e){return e.slice(0,2)===`--`}})),yr=o(((e,t)=>{t.exports=function(e){return e[0]===`$`}})),br=o(((e,t)=>{t.exports=function(e){return e.type===`atrule`&&e.variable}})),xr=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`hasBlock`)&&t.hasBlock===e.hasBlock&&(n+=10,n+=1e4),e.hasOwnProperty(`name`)&&t.name===e.name&&(n+=100,n+=1e4),e.hasOwnProperty(`parameter`)&&e.parameter.test(t.parameter)&&(n+=1100,n+=1e4),!e.hasOwnProperty(`hasBlock`)&&!e.hasOwnProperty(`name`)&&!e.hasOwnProperty(`paremeter`)&&(n=1),e.hasOwnProperty(`hasBlock`)&&e.hasOwnProperty(`name`)&&n<2e4&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&n<21100&&(n=0),e.hasOwnProperty(`name`)&&e.hasOwnProperty(`parameter`)&&e.hasOwnProperty(`hasBlock`)&&n<3e4&&(n=0),n}})),Sr=o(((e,t)=>{t.exports=function(e,t){let n=0;return e.hasOwnProperty(`selector`)||(n=1),e.hasOwnProperty(`selector`)&&e.selector.test(t.selector)&&(n=2),n}})),Cr=o(((e,t)=>{let n=_r(),r=vr(),i=yr(),a=br(),o=xr(),s=Sr();t.exports=function(e,t){let c;if(a(t))c=`at-variables`;else if(t.type===`decl`)r(t.prop)?c=`custom-properties`:i(t.prop)?c=`dollar-variables`:n(t.prop)&&(c=`declarations`);else if(t.type===`rule`){c={type:`rule`,selector:t.selector};let n=e.rule;if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=s(n,c);r>t&&(t=r,e=n)}),t)return e}}else if(t.type===`atrule`){c={type:`at-rule`,name:t.name,hasBlock:!1},t.nodes&&t.nodes.length&&(c.hasBlock=!0),t.params&&t.params.length&&(c.parameter=t.params);let n=e[`at-rule`];if(n&&n.length){let e,t=0;if(n.forEach(n=>{let r=o(n,c);r>t&&(t=r,e=n)}),t)return e}}return e[c]?e[c]:null}})),wr=o(((e,t)=>{t.exports={beforeNode:n,afterNode:r,beforeDeclaration:i,afterDeclaration:a};function n(e,t,r,i){if(!t||t.type!==`comment`||!t.raws.before||!t.raws.before.includes(`
|
|
516
|
+
`+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})))}},er=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==ar.tagName}get isIf(){return this.tagName==or.tagName}get isContextEditing(){return this.tagName==sr.tagName}loopInfo;ifInfo;contextEdit;constructor(e,t,n,r){if(this.parser=e,this.tagName=t,this.start=n,this.openTagStart=n,this.end=r,this.isLoop){this.createId();return}this.isIf||this.isContextEditing||(I.addInterestPoint({name:t,start:n,end:r,type:`tag`}),tr.includes(t)&&(this.selfClosing=!0))}createId(){return this.id||(this.id=this.idBase+I.idElement,I.idElement++),this.id}addAttribute(e){if(e.name==`@for`){I.addError(e.nameStart,e.nameEnd,`Deprecated : use for directly inside template`);return}this.attributes[e.name]?I.addError(e.nameStart,e.nameEnd,`Duplicate attribute `+e.name):this.attributes[e.name]=e}addChild(e){this.children.push(e),e.parent=this}addContent(e){this.children.push(e)}addChanges(e,t,n){let r=this.createId()+`°`+e;this.changes[r]={fct:t,once:n}}validateAllProps(e){if(this.openTagEnd=e,this.alias){let e=this.alias.endsWith(`[]`);e&&(this.alias=this.alias.replace(`[]`,``)),e&&(this.aliasMultiple=e)}if(this.isLoop){this.parentTemplateId=I.getParentId();let e=I.addLoopStack(Number(this.attributes.id.value));e&&(this.loopInfo=e)}else if(this.isIf){this.parentTemplateId=I.getParentId();let e=Number(this.attributes.id.value),t=I.addIfStack(e);t&&(this.ifInfo=t,e==t.idsTemplate[0]&&(t._id=this.createId()))}else if(this.isContextEditing){this.parentTemplateId=I.getParentId();let e=Number(this.attributes.id.value),t=I.getContextEditing(e);if(t&&(this.contextEdit=t,this.parent))for(let e of t.variableNames)this.parent.variableNames.includes(e)||this.parent.variableNames.push(e)}I.addTagInfoStack(this)}afterClose(e,t){this.hasClose=!0,this.selfClosing||I.addInterestPoint({name:this.tagName,start:e,end:t,type:`tag`}),this.checkStyle(I.getRules(),e=>I.addStyleLink(e)),I.removeStack(),(this.isLoop||this.isIf)&&I.removeStack()}checkStyle(e,t){for(let[n,r]of e)n(this)&&t([{start:this.openTagStart,end:this.openTagEnd},r])}_render(){let e=[];for(let t in this.attributes){let n=this.attributes[t];n.mustBeAdded&&(n.value==null?e.push(n.name):e.push(n.name+`="`+n.value+`"`))}this.id&&e.push(`_id="`+this.id+`"`);let t=``;return e.length>0&&(t=` `+e.join(` `)),this.selfClosing?`<${this.tagName}${t} />`:`<${this.tagName}${t}>${this.children.map(e=>e.render()).join(``)}</${this.tagName}>`}render(){return this.isContextEditing?``:this.isLoop?`<template _id="`+this.id+`"></template>`:this.isIf?this.id?`<template _id="`+this.id+`"></template>`:``:this._render()}replaceId(t){t.endsWith(`_`)||(t+=`_`),this.id=this.id.replace(this.idBase,t);let n={};for(let e in this.changes){let r=e.replace(this.idBase,t);n[r]=this.changes[e]}this.changes=n,this.ifInfo&&(this.ifInfo._id=this.ifInfo._id.replace(this.idBase,t)),this._idBase=t;for(let n of this.children)n instanceof e&&n.replaceId(t)}getTemplateInfo(t){let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},r=this.id,i=e=>{if(this.alias){let t=this.aliasMultiple?2:1;e.elements.push({name:this.alias,ids:[r],tags:{[this.tagName]:t},useLive:!1,isArray:t>1,positions:[{start:this.attributes[`@element`].valueStart,end:this.attributes[`@element`].valueEnd}]})}for(let t in this.changes)e.content[t]=this.changes[t];for(let t of this.injections){let n={id:r,injectionName:t.attr,inject:`@_@${t.injectTxt}@_@`};t.computedOnce&&(n.once=!0),e.injection.push(n)}for(let t of this.bindings){let n=[];n=t.event?[t.event]:[`input`,`textarea`].includes(this.tagName)?[`change`,`input`]:[`change`];let i={id:r,eventNames:n,injectionName:t.valueName,tagName:this.tagName,inject:`@_@${t.injectTxt}@_@`,extract:`@_@${t.extractTxt}@_@`};t.computedOnce&&(i.once=!0),e.bindings.push(i)}for(let t of this.eventsPerso)e.events.push({eventName:t.event,id:r,fct:t.fct,tagName:this.tagName,position:{start:t.start,end:t.end}});if(this.pressEvent&&e.pressEvents.push({...this.pressEvent,id:r}),this.contextEdit){let t={fct:this.contextEdit.fctJs};this.contextEdit.computedOnce&&(t.once=!0),e.contextEdits.push(t)}};if(this.loopInfo){let r={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},i=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);I.mergeTemplateResult(r,e)}i+=n.render()}let a={templateId:this.loopInfo.idTemplate||0,anchorId:this.id,template:i,actions:r,parentId:this.parentTemplateId};this.loopInfo.isSimple?a.simple=this.loopInfo.simple:a.func=this.loopInfo.complex.fct,n.loops.push(a)}else if(this.isIf&&this.ifInfo){let r=Number(this.attributes.id.value),i={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},a=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);I.mergeTemplateResult(i,e)}a+=n.render()}if(this.ifInfo.registerPart({template:a,templateId:r,templateAction:i,condition:``}),r==this.ifInfo.idsTemplate[this.ifInfo.idsTemplate.length-1]){let e={anchorId:this.ifInfo._id,parts:this.ifInfo.parts,parentId:this.parentTemplateId};n.ifs.push(e)}}else{i(n);for(let r of this.children)if(r instanceof e){let e=r.getTemplateInfo(t);I.mergeTemplateResult(n,e)}}return n}};const tr=[`area`,`base`,`br`,`col`,`embed`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`],nr=[`_id`];var rr=class{name=``;value=null;nameStart=0;nameEnd=0;valueStart=0;valueEnd=0;tag;mustBeAdded=!0;constructor(e,t,n,r){this.name=e,this.nameStart=I.fromCompiledToRaw(t),this.nameEnd=I.fromCompiledToRaw(n),this.tag=r,this.manageSpecialAttribute()}manageSpecialAttribute(){this.name.startsWith(`@`)||this.name.startsWith(`:`)?(this.tag.createId(),this.mustBeAdded=!1):nr.includes(this.name)&&(I.addError(this.nameStart,this.nameEnd,`The attribute `+this.name+` is used by Aventus internally`),this.mustBeAdded=!1)}setValue(e,t,n){if(e=e.replace(/"/g,``),this.value=e,this.valueStart=I.fromCompiledToRaw(t),this.valueEnd=I.fromCompiledToRaw(n),this.name!=`@for`)if(this.name===`@element`)this.tag.alias=e,I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`property`});else if(this.name.startsWith(`@bind`)||this.name.startsWith(`$`)){let r=new lr(this.name,e,t,n);this.tag.bindings.push(r),I.addBinding(r)}else if(this.name.startsWith(`:`)){let r=new cr(this.name.slice(1),e,t,n);this.tag.injections.push(r),I.addInjection(r)}else if(Gn.hasOwnProperty(this.name))this.tag.pressEvent||(this.tag.pressEvent={}),this.tag.pressEvent[Gn[this.name]]={value:e,start:this.valueStart,end:this.valueEnd},I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else if(this.name.startsWith(`@`))this.tag.eventsPerso.push({event:this.name.slice(1),fct:e,start:this.valueStart,end:this.valueEnd}),I.addInterestPoint({name:this.name.slice(1),start:this.nameStart,end:this.nameEnd,type:`event`}),I.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else{let t=ur(e,this.valueStart);t.changes.length>0&&(this.tag.addChanges(this.name,t.txt,t.once),this.mustBeAdded=!1)}}},ir=class{content=``;start=0;end=0;tag;mustBeAdded=!0;constructor(e,t,n,r,i=!0){this.content=e,this.start=I.fromCompiledToRaw(t),this.end=I.fromCompiledToRaw(n),this.tag=r,i&&this.manageVariables()}manageVariables(){let e=this.content,t=ur(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:``}},ar=class e{static tagName=`l`;idTemplate=0;isSimple=!1;transformations=[];start=0;startBlock=0;end=0;loopTxt=``;loopName=``;isValid=!0;typeToLoad=[];simple={data:``};complex={init:[],condition:``,transform:[],apply:[],loopName:``,fct:``};get variableNames(){return this.typeToLoad.map(e=>e.txt)}variables=[];sliceText;constructor(e,t){this.sliceText=t,this.idTemplate=I.createIdTemplate(),this.variables=I.getVariables(),e.kind==p.SyntaxKind.ForOfStatement||e.kind==p.SyntaxKind.ForInStatement?(this.isSimple=!0,this.loadForInOf(e)):this.loadFor(e),this.loopName=I.getCustomFctName()??``}loadForInOf(t){let n=0;(0,p.forEachChild)(t,r=>{if(n==0){let e=r.getChildAt(1),n=e.getStart(),i=e.getEnd(),a=this.sliceText(n,i);t.kind==p.SyntaxKind.ForInStatement?this.simple.index=a:this.simple.item=a,this.typeToLoad.push({txt:a,start:n,end:i})}else if(n==1)this.simple.data=this.sliceText(r.getStart(),r.getEnd());else if(n==2){let n=t.getStart(),i=r.getStart()+1;this.loopTxt=this.sliceText(n,i)+` }`;let a=`<`+e.tagName+` id="`+this.idTemplate+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o}),this.start=n,this.startBlock=i,this.end=s}n++})}loadFor(t){let n=[],r=[],i=``,a=[],o=0,s=``;if((0,p.forEachChild)(t,c=>{if(o==0&&c.kind==p.SyntaxKind.VariableDeclarationList)(0,p.forEachChild)(c,e=>{let t=e.getChildAt(0),i=t.getStart(),a=t.getEnd(),o=this.sliceText(i,a);n.push(`let `+e.getText()),r.push(e.getChildAt(0).getText()),this.typeToLoad.push({txt:o,start:i,end:a})});else if(o==1&&c.kind==p.SyntaxKind.BinaryExpression)i=c.getText();else if(o==2){let e=t=>{t.kind==p.SyntaxKind.BinaryExpression&&t.getChildAt(1).getText()==`,`?(e(t.getChildAt(0)),e(t.getChildAt(2))):a.push(t.getText())};e(c)}else if(o==3&&c.kind==p.SyntaxKind.Block){let n=t.getStart(),r=c.getStart()+1;s=this.sliceText(n,r)+` }`,this.loopTxt=s;let i=`<`+e.tagName+` id="`+this.idTemplate+`">`,a=`</`+e.tagName+`>`;this.transformations.push({start:n,end:r,newText:i});let o=c.getEnd();this.transformations.push({start:o-1,end:o,newText:a}),this.start=n,this.startBlock=r,this.end=o}o++}),this.transformations.length==0&&(this.isValid=!1),!this.checkIsSimple(n,i,a)){let e=I.getCustomFctName(1)??``;this.complex={init:n,condition:i,transform:a,apply:r,loopName:e,fct:`(c) => c.comp.${e}`}}}recalculateVariables(){if(this.variables=dr(this.loopTxt,I.getVariables()),!this.isSimple){let e=this.variables.map(e=>`c.data.`+e).join(`,`);this.complex.fct+=`(${e})`}}checkIsSimple(e,t,n){if(e.length!=1)return!1;let r=e[0].split(`=`);if(r.length!=2)return!1;let i=r[0].replace(`let `,``).trim();if(r[1].trim()!=`0`)return!1;let a=RegExp(`\\s*`+i+`\\s*<\\s*([a-zA-Z0-9\\._\\[\\]-]+)\\.length`).exec(t);if(!a)return!1;let o=a[1];return n.length!=1||!RegExp(`\\s*`+i+`\\+\\+\\s*`).exec(n[0])?!1:(this.isSimple=!0,this.simple={data:o,index:i},!0)}},or=class e{static tagName=`if`;statements=[];idsTemplate=[];defaultVariables=[];transformations=[];end=0;_id=``;parts=[];isValid=!0;conditions=[];sliceText;constructor(e,t){this.sliceText=t,this.defaultVariables=I.getVariables(),this.loadIf(e)}loadIf(t){let n=[],r=()=>{let e=I.createIdTemplate();return this.idsTemplate.push(e),e},i=(t,n,r)=>{let i=r.getStart()+1,a=`<`+e.tagName+` id="`+t+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o})},a=(e,t=0,o)=>{let s=0;o===void 0&&(o=e.getStart());let c=o,l;for(let t of e.getChildren())t.kind==p.SyntaxKind.ElseKeyword&&(l=t.getStart());let u=r();(0,p.forEachChild)(e,e=>{if(e.kind==p.SyntaxKind.Block){if(s++,s==2){if(l==null)throw`impossible`;i(r(),l,e)}else i(u,c,e);n.push(e)}else if(e.kind==p.SyntaxKind.IfStatement){if(l==null)throw`impossible`;a(e,t+1,l)}else if(p.SyntaxKind[e.kind].includes(`Expression`)){let n=I.getCustomFctName(this.conditions.length)??``,r=this.sliceText(e.getStart(),e.getEnd());this.conditions.push({fctName:n,txt:r,fctTxt:`(c) => c.comp.${n}`,start:e.getStart(),end:e.getEnd(),offsetAfter:0,offsetBefore:0,idTemplate:u,type:t==0?`if`:`elif`,variables:[],computedOnce:fr(r)})}}),s==0&&(this.isValid=!1)};a(t)}registerPart(e){this.conditions.length>this.parts.length?(e.condition=this.conditions[this.parts.length].fctTxt,e.once=this.conditions[this.parts.length].computedOnce):(e.condition=`(c) => true`,e.once=!0),this.parts.push(e)}recalculateVariables(e){let t=I.getVariables();for(let n of this.conditions)if(n.idTemplate==e){let e=dr(n.txt,t),r=e.map(e=>`c.data.`+e).join(`,`);n.fctTxt+=`(${r})`,n.variables=e}}},sr=class e{static tagName=`c`;sliceText;variables=[];transformations=[];id;fctTs=``;fctJs=``;editName;start=0;end=0;mapping=[``,``];computedOnce=!1;typeToLoad=[];get variableNames(){return this.typeToLoad.map(e=>e.txt)}constructor(e,t){this.sliceText=t,this.editName=I.getCustomFctName()??``,this.id=I.createIdTemplate(),this.loadContextEditing(e)}loadContextEditing(t){this.start=t.getStart(),this.end=t.getEnd(),this.transformations.push({start:t.getStart(),end:t.getEnd(),newText:`<`+e.tagName+` id="`+this.id+`"></`+e.tagName+`>`}),(0,p.forEachChild)(t,e=>{if(e.kind==p.SyntaxKind.CallExpression){let t=e,n=`{ `,r=0;for(let e of t.arguments)n+=e.getText(),r==0&&(this.typeToLoad.push({txt:e.getText().replace(/['`"]/g,``),start:e.getStart(),end:e.getEnd()}),n+=`: `),this.mapping[r]=e.getText(),r++;n+=` }`,this.fctTs=`return `+n,this.computedOnce=fr(this.fctTs)}}),this.variables=dr(this.fctTs,I.getVariables());let n=this.variables.map(e=>`c.data.`+e).join(`,`);this.fctJs=`@_@(c) => c.comp.${this.editName}(${n})@_@`}},cr=class{start=0;end=0;attr;injectFctName;injectTsTxt;injectTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){this.attr=e,this.start=I.fromCompiledToRaw(n),this.end=I.fromCompiledToRaw(r),this.injectFctName=I.getCustomFctName()??``,this.injectTsTxt=t,this.computedOnce=fr(t),this.variables=dr(t,I.getVariables());let i=this.variables.map(e=>`c.data.`+e).join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${i})`}},lr=class{start=0;end=0;event;valueName=`value`;injectFctName;extractFctName;injectTsTxt;extractTsCond;extractTsTxt;injectTxt;extractTxt;variables=[];computedOnce=!1;constructor(e,t,n,r){let i=e.split(`:`),a=i[0];a.startsWith(`@bind_`)?this.event=a.replace(`@bind_`,``):a.startsWith(`$`)&&a.length>0&&(this.event=a.replace(`$`,``)),i.length>1&&(this.valueName=i[1]),this.start=I.fromCompiledToRaw(n),this.end=I.fromCompiledToRaw(r),this.injectFctName=I.getCustomFctName()??``,this.extractFctName=I.getCustomFctName(1)??``,this.injectTsTxt=t,this.computedOnce=fr(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=dr(t,I.getVariables());let s=this.variables.map(e=>`c.data.`+e),c=[`v`].concat(s).join(`,`),l=s.join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${l})`,this.extractTxt=`(c, v) => c.comp.${this.extractFctName}(${c})`}};function ur(e,t){let n=/\{\{([\s|\S]*?)\}\}/g,r,i={changes:[],txt:e,variables:[],once:!0};for(;r=n.exec(e);){let e=t+r.index,n=t+r.index+r[0].length,a=I.createChange({txt:r[1],start:e,end:n});if(i.once&&!fr(r[1])&&(i.once=!1),a){a.variables=dr(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,`
|
|
517
|
+
`),i.changes.push(a)}}return i.changes.length>0&&(i.txt="(c) => `"+i.txt+"`"),i}function dr(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 fr(e){return!/if|switch|\?|\[.+?\]/g.test(e)}var I=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=Xe(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 ar||!(t instanceof er))return t.idTemplate}}static getVariables(){let e=[];if(this.currentParsingDoc){for(let t of this.currentParsingDoc.stacks)if(t instanceof ar||t instanceof er)for(let n of t.variableNames)e.includes(n)||e.push(n)}return e}uri;errors=[];document;rootTags=[];tags=[];blocksInfo={};slotsInfo={};resultsByClassName={};interestPoints=[];rules;styleLinks=[];fcts={};htmlFile;loops=[];ifs=[];injections=[];bindings=[];contextEdits=[];diffRawToCompiled={};diffCompiledToRaw={};stacks=[];compiledTxt=``;fromRawToCompiled(e){let t=e;for(let n in this.diffRawToCompiled){if(Number(n)>e)break;t+=this.diffRawToCompiled[n]}return t}fromCompiledToRaw(e){let t=e;for(let n in this.diffCompiledToRaw){if(Number(n)>e)break;t+=this.diffCompiledToRaw[n]}return t}getBlocksInfoTxt(){let e=[];for(let t in this.blocksInfo)e.push(`'`+t+"':`"+this.blocksInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}getSlotsInfoTxt(){let e=[];for(let t in this.slotsInfo)e.push(`'`+t+"':`"+this.slotsInfo[t].replace(/`/g,"\\`")+"`");return e.join(`,`)}isReady=!1;build;constructor(t,n){this.build=n,this.htmlFile=t,e.parsedDoc[t.file.uri]={version:t.file.versionUser,result:this};let r=this.getFileContent(t.file.documentUser);this.rules=t.scssFile?.rules??new Map,this.document=d.TextDocument.create(t.file.uri,t.file.documentUser.languageId,t.file.versionUser,r),e.currentParsingDoc=this,this.uri=t.file.uri,e.idElement=0,e.idTemplate=0,e.idTemplate=0,this.parse(this.document),e.currentParsingDoc=null,this.isReady=!0;for(let e of this.readyCb)e()}getFileContent(e){let t=e.getText();return t=t.replace(/\\\{\{(.*?)\}\}/g,`{{$1}}`),t=t.replace(/\\if/g,`if`),t=t.replace(/\\else/g,`else`),t=t.replace(/\\for/g,`for`),t=t.replace(/\\@Context/g,`@Context`),t}readyCb=[];onReady(e){this.isReady||this.readyCb.push(e)}parseJs(e){let t=e.getText(),n={},r=/<!--(.|\s)*?-->/g,i;for(;i=r.exec(t);){let e=``;for(let t=0;t<i[0].length;t++)e+=` `;n[i.index]=i[0],t=t.slice(0,i.index)+e+t.slice(i.index+i[0].length)}let a=t,o=(e,t)=>a.slice(e,t),s=(0,p.createSourceFile)(`sample.ts`,t.replace(/\{\{|\}\}/g,` `).replace(/<\/?[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 or(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 ar(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 sr(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 ir(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 er(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(Fe(t,`The tag `+n?.tagName+` isn't correctly closed`,n?.start,n?.end)):this.errors.push(Fe(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 rr(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 ir(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]}},pr=o(((e,t)=>{t.exports=function(e){return e&&typeof e.valueOf()==`string`}})),mr=o(((e,t)=>{let n=pr();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}})),hr=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}})),gr=o(((e,t)=>{let n=pr();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}})),_r=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("${"))))}})),vr=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}})),yr=o(((e,t)=>{t.exports=function(e){return!(e[0]===`$`||e[0]===`@`||/#{.+?}|@{.+?}|\$\(.+?\)/.test(e))}})),br=o(((e,t)=>{t.exports=function(e){return e.slice(0,2)===`--`}})),xr=o(((e,t)=>{t.exports=function(e){return e[0]===`$`}})),Sr=o(((e,t)=>{t.exports=function(e){return e.type===`atrule`&&e.variable}})),Cr=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}})),wr=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}})),Tr=o(((e,t)=>{let n=yr(),r=br(),i=xr(),a=Sr(),o=Cr(),s=wr();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}})),Er=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(`
|
|
517
518
|
`)&&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(`
|
|
518
519
|
`))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(`
|
|
519
520
|
`))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(`
|
|
520
|
-
`))return e;let i=r||n.initialIndex,o={orderData:n.orderData,node:t,unprefixedName:n.unprefixedName,unspecifiedPropertiesPosition:n.unspecifiedPropertiesPosition};return o.initialIndex=i+1e-4,a([...e,o],t.next(),n,o.initialIndex)}})),Tr=o(((e,t)=>{let n=Cr(),r=wr();t.exports=function(e,t,i,a){if(e.type===`comment`)return a;let o=n(i,e);e.position=o&&o.position?o.position:1/0,e.initialIndex=t;let s=r.beforeNode([],e.prev(),e),c=r.afterNode([],e.next(),e);return[...a,...s,e,...c]}})),Er=o(((e,t)=>{t.exports=function(e,t){return e.position===t.position?e.initialIndex-t.initialIndex:e.position-t.position}})),Dr=o(((e,t)=>{let n=mr(),r=hr(),i=gr(),a=Tr(),o=Er();t.exports=function(e,t){if(!r(e))return;let s=n(t),c=[];e.each((e,t)=>{c=a(e,t,s,c)}),e.each((e,t)=>{c=i(e,t,c)}),c.sort(o),e.raws.semicolon=!0,e.removeAll(),e.append(c)}})),Or=o(((e,t)=>{t.exports=function(e){let t={};return e.forEach((e,n)=>{t[e]={propertyIndex:n}}),t}})),kr=o(((e,t)=>{t.exports=function(e,t){return e[t]}})),Ar=o(((e,t)=>{t.exports={margin:[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`,`margin-block`,`margin-inline`],"margin-block":[`margin-block-start`,`margin-block-end`],"margin-block-start":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],"margin-block-end":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],"margin-inline":[`margin-inline-start`,`margin-inline-end`],"margin-inline-start":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],"margin-inline-end":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],padding:[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`,`padding-block`,`padding-block-start`,`padding-block-end`,`padding-inline`,`padding-inline-start`,`padding-inline-end`],"padding-block":[`padding-block-start`,`padding-block-end`,`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-block-start":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-block-end":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-inline":[`padding-inline-start`,`padding-inline-end`,`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-inline-start":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-inline-end":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],background:[`background-image`,`background-size`,`background-position`,`background-repeat`,`background-origin`,`background-clip`,`background-attachment`,`background-color`],font:[`font-style`,`font-variant`,`font-weight`,`font-stretch`,`font-size`,`font-family`,`line-height`],border:[`border-inline`,`border-block`,`border-top`,`border-bottom`,`border-left`,`border-right`,`border-width`,`border-style`,`border-color`],"border-inline":[`border-inline-start`,`border-inline-end`,`border-inline-width`,`border-inline-style`,`border-inline-color`],"border-inline-width":[`border-inline-start-width`,`border-inline-end-width`],"border-inline-style":[`border-inline-start-style`,`border-inline-end-style`],"border-inline-color":[`border-inline-start-color`,`border-inline-end-color`],"border-inline-start":[`border-inline-start-width`,`border-inline-start-style`,`border-inline-start-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-inline-start-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-inline-start-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-inline-start-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-inline-end":[`border-inline-end-width`,`border-inline-end-style`,`border-inline-end-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-inline-end-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-inline-end-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-inline-end-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-block":[`border-block-start`,`border-block-end`,`border-block-width`,`border-block-style`,`border-block-color`],"border-block-width":[`border-block-start-width`,`border-block-end-width`],"border-block-style":[`border-block-start-style`,`border-block-end-style`],"border-block-color":[`border-block-start-color`,`border-block-end-color`],"border-block-start":[`border-block-start-width`,`border-block-start-style`,`border-block-start-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-block-start-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-block-start-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-block-start-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-block-end":[`border-block-end-width`,`border-block-end-style`,`border-block-end-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-block-end-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-block-end-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-block-end-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-top":[`border-top-width`,`border-top-style`,`border-top-color`],"border-bottom":[`border-bottom-width`,`border-bottom-style`,`border-bottom-color`],"border-left":[`border-left-width`,`border-left-style`,`border-left-color`],"border-right":[`border-right-width`,`border-right-style`,`border-right-color`],"border-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-image":[`border-image-source`,`border-image-slice`,`border-image-width`,`border-image-outset`,`border-image-repeat`],"border-radius":[`border-top-right-radius`,`border-top-left-radius`,`border-bottom-right-radius`,`border-bottom-left-radius`],"list-style":[`list-style-type`,`list-style-position`,`list-style-image`],transition:[`transition-delay`,`transition-duration`,`transition-property`,`transition-timing-function`],animation:[`animation-name`,`animation-duration`,`animation-timing-function`,`animation-delay`,`animation-iteration-count`,`animation-direction`,`animation-fill-mode`,`animation-play-state`],"column-rule":[`column-rule-width`,`column-rule-style`,`column-rule-color`],columns:[`column-width`,`column-count`],flex:[`flex-grow`,`flex-shrink`,`flex-basis`],"flex-flow":[`flex-direction`,`flex-wrap`],grid:[`grid-template-rows`,`grid-template-columns`,`grid-template-areas`,`grid-auto-rows`,`grid-auto-columns`,`grid-auto-flow`,`grid-column-gap`,`grid-row-gap`],"grid-area":[`grid-row-start`,`grid-column-start`,`grid-row-end`,`grid-column-end`],"grid-column":[`grid-column-start`,`grid-column-end`],"grid-gap":[`grid-row-gap`,`grid-column-gap`],"grid-row":[`grid-row-start`,`grid-row-end`],"grid-template":[`grid-template-columns`,`grid-template-rows`,`grid-template-areas`],offset:[`offset-anchor`,`offset-distance`,`offset-path`,`offset-position`,`offset-rotate`],outline:[`outline-color`,`outline-style`,`outline-width`],overflow:[`overflow-block`,`overflow-inline`,`overflow-x`,`overflow-y`],"overflow-block":[`overflow-x`,`overflow-y`],"overflow-inline":[`overflow-x`,`overflow-y`],"overscroll-behavior":[`overscroll-behavior-x`,`overscroll-behavior-y`,`overscroll-behavior-block`,`overscroll-behavior-inline`],"overscroll-behavior-block":[`overscroll-behavior-x`,`overscroll-behavior-y`],"overscroll-behavior-inline":[`overscroll-behavior-x`,`overscroll-behavior-y`],"text-decoration":[`text-decoration-color`,`text-decoration-style`,`text-decoration-line`],"text-emphasis":[`text-emphasis-style`,`text-emphasis-color`],mask:[`mask-image`,`mask-mode`,`mask-position`,`mask-size`,`mask-repeat`,`mask-origin`,`mask-clip`,`mask-composite`],"mask-border":[`mask-border-mode`,`mask-border-outset`,`mask-border-repeat`,`mask-border-slice`,`mask-border-source`,`mask-border-width`],inset:[`top`,`right`,`bottom`,`left`,`inset-block`,`inset-inline`],"inset-block":[`inset-block-end`,`inset-block-start`],"inset-inline":[`inset-inline-end`,`inset-inline-start`],"inset-block-start":[`top`,`bottom`,`left`,`right`],"inset-block-end":[`top`,`bottom`,`left`,`right`],"inset-inline-start":[`top`,`bottom`,`left`,`right`],"inset-inline-end":[`top`,`bottom`,`left`,`right`]}})),jr=o((e=>{let t=Ar();e.isShorthand=function e(n,r){if(!t[n])return!1;if(t[n].includes(r))return!0;for(let i of t[n])if(e(i,r))return!0;return!1}})),Mr=o(((e,t)=>{t.exports={prefix(e){let t=e.match(/^(-\w+-)/);return t?t[0]:``},unprefixed(e){return e.replace(/^-\w+-/,``)}}})),Nr=o(((e,t)=>{let{isShorthand:n}=jr(),r=Mr();t.exports=function(e,t){if(n(e.unprefixedName,t.unprefixedName))return-1;if(n(t.unprefixedName,e.unprefixedName))return 1;if(e.unprefixedName===t.unprefixedName){if(e.node.type===`decl`&&t.node.type===`decl`){if(!r.prefix(e.name).length&&r.prefix(t.name).length)return 1;if(r.prefix(e.name).length&&!r.prefix(t.name).length)return-1}return e.initialIndex-t.initialIndex}return e.unprefixedName<=t.unprefixedName?-1:1}})),Pr=o(((e,t)=>{let n=Nr(),r=Mr();t.exports=function(e,t){if(e.node.type===`decl`&&t.node.type===`decl`&&e.unprefixedName===t.unprefixedName){if(!r.prefix(e.name).length&&r.prefix(t.name).length)return 1;if(r.prefix(e.name).length&&!r.prefix(t.name).length)return-1}if(e.orderData&&t.orderData!==void 0&&e.orderData.propertyIndex!==t.orderData.propertyIndex)return e.orderData.propertyIndex-t.orderData.propertyIndex;if(e.unspecifiedPropertiesPosition===`bottom`||e.unspecifiedPropertiesPosition===`bottomAlphabetical`||t.unspecifiedPropertiesPosition===`bottomAlphabetical`){if(e.orderData!==void 0&&t.orderData===void 0)return-1;if(e.orderData===void 0&&t.orderData!==void 0)return 1}if(e.unspecifiedPropertiesPosition===`top`){if(e.orderData!==void 0&&t.orderData===void 0)return 1;if(e.orderData===void 0&&t.orderData!==void 0)return-1}return e.unspecifiedPropertiesPosition===`bottomAlphabetical`&&e.orderData===void 0&&t.orderData===void 0?n(e,t):e.initialIndex-t.initialIndex}})),Fr=o(((e,t)=>{let n=Or(),r=wr(),i=kr(),a=vr(),o=hr(),s=_r(),c=Pr(),l=Nr(),u=Mr();function d(e){return e.type===`decl`&&s(e.prop)&&!a(e.prop)}function f(e){let t=u.unprefixed(e).toLowerCase();return t.indexOf(`osx-`)===0?t.slice(4):t}function p(e,t,n,r){if(n.length)for(let r=1;r<=n.length;r++)e.add(t-r);if(r.length)for(let n=1;n<=r.length;n++)e.add(t+n)}function m(e,t){e.removeAll(),e.append(t)}t.exports=function(e,{order:t,unspecifiedPropertiesPosition:a}){if(!o(e,{ignoreInterpolations:!0}))return;let s=t===`alphabetical`,u=s?null:n(t),h=[],g=new Set,_=new Map;if(e.each((e,t)=>{if(!d(e))return;let n=f(e.prop),o={name:e.prop,unprefixedName:n,orderData:s?null:i(u,n),node:e,initialIndex:t,unspecifiedPropertiesPosition:a};g.add(t),_.set(t,o);let c=r.beforeDeclaration([],e.prev(),o),l=r.afterDeclaration([],e.next(),o);p(g,t,c,l),h=[...h,...c,o,...l]}),o(e)){s?h.sort(l):h.sort(c);let t=[],n=!1;e.each((e,r)=>{g.has(r)?n||(n=!0,h.forEach(e=>{t.push(e.node)})):t.push(e)}),m(e,t);return}let v=[],y=[];function b(){if(!y.length)return;let e=y[0].node,t=e.raws.before;s?y.sort(l):y.sort(c);let n=y[0].node;if(n!==e){let r=n.raws.before;n.raws.before=t,e.raws.before=r}y.forEach(e=>{v.push(e.node)}),y=[]}e.each((e,t)=>{let n=_.get(t);n&&e.type===`decl`?(e.raws.before&&e.raws.before.includes("${")&&b(),y.push(n)):(b(),v.push(e))}),b(),m(e,v)}})),Ir=o(((e,t)=>{let n=fr(),r=dr(),i=pr(),a=Dr(),o=Fr();t.exports=function(e){return{postcssPlugin:`postcss-sorting`,Root(t){s(t,e)}}},t.exports.postcss=!0;function s(e,t){let s=n(t);if(s!==!0){if(t&&t[`throw-validate-errors`])throw r(s)?Error(s):Error(`postcss-sorting: Invalid config.`);console&&console.warn&&r(s)&&console.warn(s);return}t.order&&e.walk(e=>{a(i(e),t.order)}),t[`properties-order`]&&e.walk(e=>{o(i(e),{order:t[`properties-order`],unspecifiedPropertiesPosition:t[`unspecified-properties-position`]||`bottom`})})}})),Lr=o(((e,t)=>{let n=/(<)(\/?style\b)/gi,r=/(<)(!--)/g;function i(e){return typeof e!=`string`||!e.includes(`<`)?e:e.replace(n,`\\3c $2`).replace(r,`\\3c $2`)}let a={after:`
|
|
521
|
+
`))return e;let i=r||n.initialIndex,o={orderData:n.orderData,node:t,unprefixedName:n.unprefixedName,unspecifiedPropertiesPosition:n.unspecifiedPropertiesPosition};return o.initialIndex=i+1e-4,a([...e,o],t.next(),n,o.initialIndex)}})),Dr=o(((e,t)=>{let n=Tr(),r=Er();t.exports=function(e,t,i,a){if(e.type===`comment`)return a;let o=n(i,e);e.position=o&&o.position?o.position:1/0,e.initialIndex=t;let s=r.beforeNode([],e.prev(),e),c=r.afterNode([],e.next(),e);return[...a,...s,e,...c]}})),Or=o(((e,t)=>{t.exports=function(e,t){return e.position===t.position?e.initialIndex-t.initialIndex:e.position-t.position}})),kr=o(((e,t)=>{let n=gr(),r=_r(),i=vr(),a=Dr(),o=Or();t.exports=function(e,t){if(!r(e))return;let s=n(t),c=[];e.each((e,t)=>{c=a(e,t,s,c)}),e.each((e,t)=>{c=i(e,t,c)}),c.sort(o),e.raws.semicolon=!0,e.removeAll(),e.append(c)}})),Ar=o(((e,t)=>{t.exports=function(e){let t={};return e.forEach((e,n)=>{t[e]={propertyIndex:n}}),t}})),jr=o(((e,t)=>{t.exports=function(e,t){return e[t]}})),Mr=o(((e,t)=>{t.exports={margin:[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`,`margin-block`,`margin-inline`],"margin-block":[`margin-block-start`,`margin-block-end`],"margin-block-start":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],"margin-block-end":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],"margin-inline":[`margin-inline-start`,`margin-inline-end`],"margin-inline-start":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],"margin-inline-end":[`margin-top`,`margin-bottom`,`margin-left`,`margin-right`],padding:[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`,`padding-block`,`padding-block-start`,`padding-block-end`,`padding-inline`,`padding-inline-start`,`padding-inline-end`],"padding-block":[`padding-block-start`,`padding-block-end`,`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-block-start":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-block-end":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-inline":[`padding-inline-start`,`padding-inline-end`,`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-inline-start":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],"padding-inline-end":[`padding-top`,`padding-bottom`,`padding-left`,`padding-right`],background:[`background-image`,`background-size`,`background-position`,`background-repeat`,`background-origin`,`background-clip`,`background-attachment`,`background-color`],font:[`font-style`,`font-variant`,`font-weight`,`font-stretch`,`font-size`,`font-family`,`line-height`],border:[`border-inline`,`border-block`,`border-top`,`border-bottom`,`border-left`,`border-right`,`border-width`,`border-style`,`border-color`],"border-inline":[`border-inline-start`,`border-inline-end`,`border-inline-width`,`border-inline-style`,`border-inline-color`],"border-inline-width":[`border-inline-start-width`,`border-inline-end-width`],"border-inline-style":[`border-inline-start-style`,`border-inline-end-style`],"border-inline-color":[`border-inline-start-color`,`border-inline-end-color`],"border-inline-start":[`border-inline-start-width`,`border-inline-start-style`,`border-inline-start-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-inline-start-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-inline-start-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-inline-start-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-inline-end":[`border-inline-end-width`,`border-inline-end-style`,`border-inline-end-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-inline-end-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-inline-end-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-inline-end-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-block":[`border-block-start`,`border-block-end`,`border-block-width`,`border-block-style`,`border-block-color`],"border-block-width":[`border-block-start-width`,`border-block-end-width`],"border-block-style":[`border-block-start-style`,`border-block-end-style`],"border-block-color":[`border-block-start-color`,`border-block-end-color`],"border-block-start":[`border-block-start-width`,`border-block-start-style`,`border-block-start-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-block-start-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-block-start-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-block-start-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-block-end":[`border-block-end-width`,`border-block-end-style`,`border-block-end-color`,`border-top`,`border-bottom`,`border-left`,`border-right`],"border-block-end-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-block-end-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-block-end-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-top":[`border-top-width`,`border-top-style`,`border-top-color`],"border-bottom":[`border-bottom-width`,`border-bottom-style`,`border-bottom-color`],"border-left":[`border-left-width`,`border-left-style`,`border-left-color`],"border-right":[`border-right-width`,`border-right-style`,`border-right-color`],"border-width":[`border-top-width`,`border-bottom-width`,`border-left-width`,`border-right-width`],"border-style":[`border-top-style`,`border-bottom-style`,`border-left-style`,`border-right-style`],"border-color":[`border-top-color`,`border-bottom-color`,`border-left-color`,`border-right-color`],"border-image":[`border-image-source`,`border-image-slice`,`border-image-width`,`border-image-outset`,`border-image-repeat`],"border-radius":[`border-top-right-radius`,`border-top-left-radius`,`border-bottom-right-radius`,`border-bottom-left-radius`],"list-style":[`list-style-type`,`list-style-position`,`list-style-image`],transition:[`transition-delay`,`transition-duration`,`transition-property`,`transition-timing-function`],animation:[`animation-name`,`animation-duration`,`animation-timing-function`,`animation-delay`,`animation-iteration-count`,`animation-direction`,`animation-fill-mode`,`animation-play-state`],"column-rule":[`column-rule-width`,`column-rule-style`,`column-rule-color`],columns:[`column-width`,`column-count`],flex:[`flex-grow`,`flex-shrink`,`flex-basis`],"flex-flow":[`flex-direction`,`flex-wrap`],grid:[`grid-template-rows`,`grid-template-columns`,`grid-template-areas`,`grid-auto-rows`,`grid-auto-columns`,`grid-auto-flow`,`grid-column-gap`,`grid-row-gap`],"grid-area":[`grid-row-start`,`grid-column-start`,`grid-row-end`,`grid-column-end`],"grid-column":[`grid-column-start`,`grid-column-end`],"grid-gap":[`grid-row-gap`,`grid-column-gap`],"grid-row":[`grid-row-start`,`grid-row-end`],"grid-template":[`grid-template-columns`,`grid-template-rows`,`grid-template-areas`],offset:[`offset-anchor`,`offset-distance`,`offset-path`,`offset-position`,`offset-rotate`],outline:[`outline-color`,`outline-style`,`outline-width`],overflow:[`overflow-block`,`overflow-inline`,`overflow-x`,`overflow-y`],"overflow-block":[`overflow-x`,`overflow-y`],"overflow-inline":[`overflow-x`,`overflow-y`],"overscroll-behavior":[`overscroll-behavior-x`,`overscroll-behavior-y`,`overscroll-behavior-block`,`overscroll-behavior-inline`],"overscroll-behavior-block":[`overscroll-behavior-x`,`overscroll-behavior-y`],"overscroll-behavior-inline":[`overscroll-behavior-x`,`overscroll-behavior-y`],"text-decoration":[`text-decoration-color`,`text-decoration-style`,`text-decoration-line`],"text-emphasis":[`text-emphasis-style`,`text-emphasis-color`],mask:[`mask-image`,`mask-mode`,`mask-position`,`mask-size`,`mask-repeat`,`mask-origin`,`mask-clip`,`mask-composite`],"mask-border":[`mask-border-mode`,`mask-border-outset`,`mask-border-repeat`,`mask-border-slice`,`mask-border-source`,`mask-border-width`],inset:[`top`,`right`,`bottom`,`left`,`inset-block`,`inset-inline`],"inset-block":[`inset-block-end`,`inset-block-start`],"inset-inline":[`inset-inline-end`,`inset-inline-start`],"inset-block-start":[`top`,`bottom`,`left`,`right`],"inset-block-end":[`top`,`bottom`,`left`,`right`],"inset-inline-start":[`top`,`bottom`,`left`,`right`],"inset-inline-end":[`top`,`bottom`,`left`,`right`]}})),Nr=o((e=>{let t=Mr();e.isShorthand=function e(n,r){if(!t[n])return!1;if(t[n].includes(r))return!0;for(let i of t[n])if(e(i,r))return!0;return!1}})),Pr=o(((e,t)=>{t.exports={prefix(e){let t=e.match(/^(-\w+-)/);return t?t[0]:``},unprefixed(e){return e.replace(/^-\w+-/,``)}}})),Fr=o(((e,t)=>{let{isShorthand:n}=Nr(),r=Pr();t.exports=function(e,t){if(n(e.unprefixedName,t.unprefixedName))return-1;if(n(t.unprefixedName,e.unprefixedName))return 1;if(e.unprefixedName===t.unprefixedName){if(e.node.type===`decl`&&t.node.type===`decl`){if(!r.prefix(e.name).length&&r.prefix(t.name).length)return 1;if(r.prefix(e.name).length&&!r.prefix(t.name).length)return-1}return e.initialIndex-t.initialIndex}return e.unprefixedName<=t.unprefixedName?-1:1}})),Ir=o(((e,t)=>{let n=Fr(),r=Pr();t.exports=function(e,t){if(e.node.type===`decl`&&t.node.type===`decl`&&e.unprefixedName===t.unprefixedName){if(!r.prefix(e.name).length&&r.prefix(t.name).length)return 1;if(r.prefix(e.name).length&&!r.prefix(t.name).length)return-1}if(e.orderData&&t.orderData!==void 0&&e.orderData.propertyIndex!==t.orderData.propertyIndex)return e.orderData.propertyIndex-t.orderData.propertyIndex;if(e.unspecifiedPropertiesPosition===`bottom`||e.unspecifiedPropertiesPosition===`bottomAlphabetical`||t.unspecifiedPropertiesPosition===`bottomAlphabetical`){if(e.orderData!==void 0&&t.orderData===void 0)return-1;if(e.orderData===void 0&&t.orderData!==void 0)return 1}if(e.unspecifiedPropertiesPosition===`top`){if(e.orderData!==void 0&&t.orderData===void 0)return 1;if(e.orderData===void 0&&t.orderData!==void 0)return-1}return e.unspecifiedPropertiesPosition===`bottomAlphabetical`&&e.orderData===void 0&&t.orderData===void 0?n(e,t):e.initialIndex-t.initialIndex}})),Lr=o(((e,t)=>{let n=Ar(),r=Er(),i=jr(),a=br(),o=_r(),s=yr(),c=Ir(),l=Fr(),u=Pr();function d(e){return e.type===`decl`&&s(e.prop)&&!a(e.prop)}function f(e){let t=u.unprefixed(e).toLowerCase();return t.indexOf(`osx-`)===0?t.slice(4):t}function p(e,t,n,r){if(n.length)for(let r=1;r<=n.length;r++)e.add(t-r);if(r.length)for(let n=1;n<=r.length;n++)e.add(t+n)}function m(e,t){e.removeAll(),e.append(t)}t.exports=function(e,{order:t,unspecifiedPropertiesPosition:a}){if(!o(e,{ignoreInterpolations:!0}))return;let s=t===`alphabetical`,u=s?null:n(t),h=[],g=new Set,_=new Map;if(e.each((e,t)=>{if(!d(e))return;let n=f(e.prop),o={name:e.prop,unprefixedName:n,orderData:s?null:i(u,n),node:e,initialIndex:t,unspecifiedPropertiesPosition:a};g.add(t),_.set(t,o);let c=r.beforeDeclaration([],e.prev(),o),l=r.afterDeclaration([],e.next(),o);p(g,t,c,l),h=[...h,...c,o,...l]}),o(e)){s?h.sort(l):h.sort(c);let t=[],n=!1;e.each((e,r)=>{g.has(r)?n||(n=!0,h.forEach(e=>{t.push(e.node)})):t.push(e)}),m(e,t);return}let v=[],y=[];function b(){if(!y.length)return;let e=y[0].node,t=e.raws.before;s?y.sort(l):y.sort(c);let n=y[0].node;if(n!==e){let r=n.raws.before;n.raws.before=t,e.raws.before=r}y.forEach(e=>{v.push(e.node)}),y=[]}e.each((e,t)=>{let n=_.get(t);n&&e.type===`decl`?(e.raws.before&&e.raws.before.includes("${")&&b(),y.push(n)):(b(),v.push(e))}),b(),m(e,v)}})),Rr=o(((e,t)=>{let n=mr(),r=pr(),i=hr(),a=kr(),o=Lr();t.exports=function(e){return{postcssPlugin:`postcss-sorting`,Root(t){s(t,e)}}},t.exports.postcss=!0;function s(e,t){let s=n(t);if(s!==!0){if(t&&t[`throw-validate-errors`])throw r(s)?Error(s):Error(`postcss-sorting: Invalid config.`);console&&console.warn&&r(s)&&console.warn(s);return}t.order&&e.walk(e=>{a(i(e),t.order)}),t[`properties-order`]&&e.walk(e=>{o(i(e),{order:t[`properties-order`],unspecifiedPropertiesPosition:t[`unspecified-properties-position`]||`bottom`})})}})),zr=o(((e,t)=>{let n=/(<)(\/?style\b)/gi,r=/(<)(!--)/g;function i(e){return typeof e!=`string`||!e.includes(`<`)?e:e.replace(n,`\\3c $2`).replace(r,`\\3c $2`)}let a={after:`
|
|
521
522
|
`,beforeClose:`
|
|
522
523
|
`,beforeComment:`
|
|
523
524
|
`,beforeDecl:`
|
|
@@ -528,35 +529,35 @@ protected ${t}(){
|
|
|
528
529
|
`)&&(n=n.replace(/[^\n]+$/,``)),!1}),n===void 0?n=this.raw(t,null,`beforeDecl`):n&&=n.replace(/\S/g,``),n}rawBeforeDecl(e,t){let n;return e.walkDecls(e=>{if(e.raws.before!==void 0)return n=e.raws.before,n.includes(`
|
|
529
530
|
`)&&(n=n.replace(/[^\n]+$/,``)),!1}),n===void 0?n=this.raw(t,null,`beforeRule`):n&&=n.replace(/\S/g,``),n}rawBeforeOpen(e){let t;return e.walk(e=>{if(e.type!==`decl`&&(t=e.raws.between,t!==void 0))return!1}),t}rawBeforeRule(e){let t;return e.walk(n=>{if(n.nodes&&(n.parent!==e||e.first!==n)&&n.raws.before!==void 0)return t=n.raws.before,t.includes(`
|
|
530
531
|
`)&&(t=t.replace(/[^\n]+$/,``)),!1}),t&&=t.replace(/\S/g,``),t}rawColon(e){let t;return e.walkDecls(e=>{if(e.raws.between!==void 0)return t=e.raws.between.replace(/[^\s:]/g,``),!1}),t}rawEmptyBody(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length===0&&(t=e.raws.after,t!==void 0))return!1}),t}rawIndent(e){if(e.raws.indent)return e.raws.indent;let t;return e.walk(n=>{let r=n.parent;if(r&&r!==e&&r.parent&&r.parent===e&&n.raws.before!==void 0){let e=n.raws.before.split(`
|
|
531
|
-
`);return t=e[e.length-1],t=t.replace(/\S/g,``),!1}}),t}rawSemicolon(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length&&e.last.type===`decl`&&(t=e.raws.semicolon,t!==void 0))return!1}),t}rawValue(e,t){let n=e[t],r=e.raws[t];return r&&r.value===n?r.raw:n}root(e){if(this.body(e),e.raws.after){let t=e.raws.after,n=e.parent&&e.parent.type===`document`;this.builder(n?t:i(t))}}rule(e){this.block(e,this.rawValue(e,`selector`)),e.raws.ownSemicolon&&this.builder(i(e.raws.ownSemicolon),e,`end`)}stringify(e,t){if(!this[e.type])throw Error(`Unknown AST node type `+e.type+`. Maybe you need to change PostCSS stringifier.`);this[e.type](e,t)}};t.exports=s,s.default=s})),
|
|
532
|
-
`):n+=e[1]}return n}c.registerInput=a,t.exports=c})),
|
|
532
|
+
`);return t=e[e.length-1],t=t.replace(/\S/g,``),!1}}),t}rawSemicolon(e){let t;return e.walk(e=>{if(e.nodes&&e.nodes.length&&e.last.type===`decl`&&(t=e.raws.semicolon,t!==void 0))return!1}),t}rawValue(e,t){let n=e[t],r=e.raws[t];return r&&r.value===n?r.raw:n}root(e){if(this.body(e),e.raws.after){let t=e.raws.after,n=e.parent&&e.parent.type===`document`;this.builder(n?t:i(t))}}rule(e){this.block(e,this.rawValue(e,`selector`)),e.raws.ownSemicolon&&this.builder(i(e.raws.ownSemicolon),e,`end`)}stringify(e,t){if(!this[e.type])throw Error(`Unknown AST node type `+e.type+`. Maybe you need to change PostCSS stringifier.`);this[e.type](e,t)}};t.exports=s,s.default=s})),Br=o(((e,t)=>{let n=zr();t.exports=class extends n{comment(e){let t=this.raw(e,`left`,`commentLeft`),n=this.raw(e,`right`,`commentRight`);if(e.raws.inline){let r=e.raws.text||e.text;this.builder(`//`+t+r+n,e)}else this.builder(`/*`+t+e.text+n+`*/`,e)}decl(e,t){if(!e.isNested)super.decl(e,t);else{let t=this.raw(e,`between`,`colon`),n=e.prop+t+this.rawValue(e,`value`);e.important&&(n+=e.raws.important||` !important`),this.builder(n+`{`,e,`start`);let r;e.nodes&&e.nodes.length?(this.body(e),r=this.raw(e,`after`)):r=this.raw(e,`after`,`emptyBody`),r&&this.builder(r),this.builder(`}`,e,`end`)}}rawValue(e,t){let n=e[t],r=e.raws[t];return r&&r.value===n?r.scss?r.scss:r.raw:n}}})),Vr=o(((e,t)=>{let n=Br();t.exports=function(e,t){new n(t).stringify(e)}})),Hr=o(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),Ur=o(((e,t)=>{let n=/[\t\n\f\r "#'()/;[\\\]{}]/g,r=/[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,i=/.[\r\n"'(/\\]/,a=/[\da-f]/i;t.exports=function(e,t={}){let o=e.css.valueOf(),s=t.ignoreErrors,c,l,u,d,f,p,m,h,g,_,v=o.length,y=0,b=[],x=[],ee=-1;function te(){return y}function ne(t){throw e.error(`Unclosed `+t,y)}function re(){return x.length===0&&y>=v}function ie(e){if(x.length)return x.pop();if(y>=v)return;let t=e?e.ignoreUnclosed:!1;switch(c=o.charCodeAt(y),c){case 10:case 32:case 9:case 13:case 12:d=y;do d+=1,c=o.charCodeAt(d);while(c===32||c===10||c===9||c===13||c===12);p=[`space`,o.slice(y,d)],y=d-1;break;case 91:case 93:case 123:case 125:case 58:case 59:case 41:{let e=String.fromCharCode(c);p=[e,e,y];break}case 40:if(_=b.length?b.pop()[1]:``,g=o.charCodeAt(y+1),_===`url`&&g!==39&&g!==34&&g!==32&&g!==10&&g!==9&&g!==12&&g!==13){d=y;do{if(m=!1,d=o.indexOf(`)`,d+1),d===-1)if(s||t){d=y;break}else ne(`bracket`);for(h=d;o.charCodeAt(h-1)===92;)--h,m=!m}while(m);p=[`brackets`,o.slice(y,d+1),y,d],y=d}else y<=ee?p=[`(`,`(`,y]:(d=o.indexOf(`)`,y+1),l=o.slice(y,d+1),d===-1||i.test(l)?(ee=d===-1?v:d,p=[`(`,`(`,y]):(p=[`brackets`,l,y,d],y=d));break;case 39:case 34:f=c===39?`'`:`"`,d=y;do{if(m=!1,d=o.indexOf(f,d+1),d===-1)if(s||t){d=y+1;break}else ne(`string`);for(h=d;o.charCodeAt(h-1)===92;)--h,m=!m}while(m);p=[`string`,o.slice(y,d+1),y,d],y=d;break;case 64:n.lastIndex=y+1,n.test(o),d=n.lastIndex===0?o.length-1:n.lastIndex-2,p=[`at-word`,o.slice(y,d+1),y,d],y=d;break;case 92:for(d=y,u=!0;o.charCodeAt(d+1)===92;)d+=1,u=!u;if(c=o.charCodeAt(d+1),u&&c!==47&&c!==32&&c!==10&&c!==9&&c!==13&&c!==12&&(d+=1,a.test(o.charAt(d)))){for(;a.test(o.charAt(d+1));)d+=1;o.charCodeAt(d+1)===32&&(d+=1)}p=[`word`,o.slice(y,d+1),y,d],y=d;break;default:c===47&&o.charCodeAt(y+1)===42?(d=o.indexOf(`*/`,y+2)+1,d===0&&(s||t?d=o.length:ne(`comment`)),p=[`comment`,o.slice(y,d+1),y,d],y=d):(r.lastIndex=y+1,r.test(o),d=r.lastIndex===0?o.length-1:r.lastIndex-2,p=[`word`,o.slice(y,d+1),y,d],b.push(p),y=d);break}return y++,p}function ae(e){x.push(e)}return{back:ae,endOfFile:re,nextToken:ie,position:te}}})),Wr=o(((e,t)=>{let n=Hr(),r=Ur(),i;function a(e){i=e}let o={";":n.yellow,":":n.yellow,"(":n.cyan,")":n.cyan,"[":n.yellow,"]":n.yellow,"{":n.yellow,"}":n.yellow,"at-word":n.cyan,brackets:n.cyan,call:n.cyan,class:n.yellow,comment:n.gray,hash:n.magenta,string:n.green};function s([e,t],n){if(e===`word`){if(t[0]===`.`)return`class`;if(t[0]===`#`)return`hash`}if(!n.endOfFile()){let e=n.nextToken();if(n.back(e),e[0]===`brackets`||e[0]===`(`)return`call`}return e}function c(e){let t=r(new i(e),{ignoreErrors:!0}),n=``;for(;!t.endOfFile();){let e=t.nextToken(),r=o[s(e,t)];r?n+=e[1].split(/\r?\n/).map(e=>r(e)).join(`
|
|
533
|
+
`):n+=e[1]}return n}c.registerInput=a,t.exports=c})),Gr=o(((e,t)=>{let n=Hr(),r=Wr();var i=class e extends Error{constructor(t,n,r,i,a,o){super(t),this.name=`CssSyntaxError`,this.reason=t,a&&(this.file=a),i&&(this.source=i),o&&(this.plugin=o),n!==void 0&&r!==void 0&&(typeof n==`number`?(this.line=n,this.column=r):(this.line=n.line,this.column=n.column,this.endLine=r.line,this.endColumn=r.column)),this.setMessage(),Error.captureStackTrace&&Error.captureStackTrace(this,e)}setMessage(){this.message=this.plugin?this.plugin+`: `:``,this.message+=this.file?this.file:`<css input>`,this.line!==void 0&&(this.message+=`:`+this.line+`:`+this.column),this.message+=`: `+this.reason}showSourceCode(e){if(!this.source)return``;let t=this.source;e??=n.isColorSupported;let i=e=>e,a=e=>e,o=e=>e;if(e){let{bold:e,gray:t,red:s}=n.createColors(!0);a=t=>e(s(t)),i=e=>t(e),r&&(o=e=>r(e))}let s=t.split(/\r?\n/),c=Math.max(this.line-3,0),l=Math.min(this.line+2,s.length),u=String(l).length;return s.slice(c,l).map((e,t)=>{let n=c+1+t,r=` `+(` `+n).slice(-u)+` | `;if(n===this.line){if(e.length>160){let t=Math.max(0,this.column-20),n=Math.max(this.column+20,this.endColumn+20),s=e.slice(t,n),c=i(r.replace(/\d/g,` `))+e.slice(0,Math.min(this.column-1,19)).replace(/[^\t]/g,` `);return a(`>`)+i(r)+o(s)+`
|
|
533
534
|
`+c+a(`^`)}let t=i(r.replace(/\d/g,` `))+e.slice(0,this.column-1).replace(/[^\t]/g,` `);return a(`>`)+i(r)+o(e)+`
|
|
534
535
|
`+t+a(`^`)}return` `+i(r)+o(e)}).join(`
|
|
535
536
|
`)}toString(){let e=this.showSourceCode();return e&&=`
|
|
536
537
|
|
|
537
538
|
`+e+`
|
|
538
|
-
`,this.name+`: `+this.message+e}};t.exports=i,i.default=i})),
|
|
539
|
+
`,this.name+`: `+this.message+e}};t.exports=i,i.default=i})),Kr=o(((e,t)=>{let n=zr();function r(e,t){new n(t).stringify(e)}t.exports=r,r.default=r})),qr=o(((e,t)=>{t.exports.isClean=Symbol(`isClean`),t.exports.my=Symbol(`my`)})),Jr=o(((e,t)=>{let n=Gr(),r=zr(),i=Kr(),{isClean:a,my:o}=qr();function s(e,t){let n=new e.constructor;for(let r in e){if(!Object.prototype.hasOwnProperty.call(e,r)||r===`proxyCache`)continue;let i=e[r],a=typeof i;r===`parent`&&a===`object`?t&&(n[r]=t):r===`source`?n[r]=i:Array.isArray(i)?n[r]=i.map(e=>s(e,n)):(a===`object`&&i!==null&&(i=s(i)),n[r]=i)}return n}function c(e,t){if(t&&t.offset!==void 0)return t.offset;let n=1,r=1,i=0;for(let a=0;a<e.length;a++){if(r===t.line&&n===t.column){i=a;break}e[a]===`
|
|
539
540
|
`?(n=1,r+=1):n+=1}return i}var l=class{get proxyOf(){return this}constructor(e={}){this.raws={},this[a]=!1,this[o]=!0;for(let t in e)if(t===`nodes`){this.nodes=[];for(let n of e[t])typeof n.clone==`function`?this.append(n.clone()):this.append(n)}else this[t]=e[t]}addToError(e){if(e.postcssNode=this,e.stack&&this.source&&/\n\s{4}at /.test(e.stack)){let t=this.source;e.stack=e.stack.replace(/\n\s{4}at /,`$&${t.input.from}:${t.start.line}:${t.start.column}$&`)}return e}after(e){return this.parent.insertAfter(this,e),this}assign(e={}){for(let t in e)this[t]=e[t];return this}before(e){return this.parent.insertBefore(this,e),this}cleanRaws(e){delete this.raws.before,delete this.raws.after,e||delete this.raws.between}clone(e={}){let t=s(this);for(let n in e)t[n]=e[n];return t}cloneAfter(e={}){let t=this.clone(e);return this.parent.insertAfter(this,t),t}cloneBefore(e={}){let t=this.clone(e);return this.parent.insertBefore(this,t),t}error(e,t={}){if(this.source){let{end:n,start:r}=this.rangeBy(t);return this.source.input.error(e,{column:r.column,line:r.line},{column:n.column,line:n.line},t)}return new n(e)}getProxyProcessor(){return{get(e,t){return t===`proxyOf`?e:t===`root`?()=>e.root().toProxy():e[t]},set(e,t,n){return e[t]===n?!0:(e[t]=n,(t===`prop`||t===`value`||t===`name`||t===`params`||t===`important`||t===`text`)&&e.markDirty(),!0)}}}markClean(){this[a]=!0}markDirty(){if(this[a]){this[a]=!1;let e=this;for(;e=e.parent;)e[a]=!1}}next(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e+1]}positionBy(e={}){let t=this.source.start;if(e.index)t=this.positionInside(e.index);else if(e.word){let n=`document`in this.source.input?this.source.input.document:this.source.input.css,r=n.slice(c(n,this.source.start),c(n,this.source.end)).indexOf(e.word);r!==-1&&(t=this.positionInside(r))}return t}positionInside(e){let t=this.source.start.column,n=this.source.start.line,r=`document`in this.source.input?this.source.input.document:this.source.input.css,i=c(r,this.source.start),a=i+e;for(let e=i;e<a;e++)r[e]===`
|
|
540
|
-
`?(t=1,n+=1):t+=1;return{column:t,line:n,offset:a}}prev(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e-1]}rangeBy(e={}){let t=`document`in this.source.input?this.source.input.document:this.source.input.css,n={column:this.source.start.column,line:this.source.start.line,offset:c(t,this.source.start)},r=this.source.end?{column:this.source.end.column+1,line:this.source.end.line,offset:typeof this.source.end.offset==`number`?this.source.end.offset:c(t,this.source.end)+1}:{column:n.column+1,line:n.line,offset:n.offset+1};if(e.word){let i=t.slice(c(t,this.source.start),c(t,this.source.end)).indexOf(e.word);i!==-1&&(n=this.positionInside(i),r=this.positionInside(i+e.word.length))}else e.start?n={column:e.start.column,line:e.start.line,offset:c(t,e.start)}:e.index&&(n=this.positionInside(e.index)),e.end?r={column:e.end.column,line:e.end.line,offset:c(t,e.end)}:typeof e.endIndex==`number`?r=this.positionInside(e.endIndex):e.index&&(r=this.positionInside(e.index+1));return(r.line<n.line||r.line===n.line&&r.column<=n.column)&&(r={column:n.column+1,line:n.line,offset:n.offset+1}),{end:r,start:n}}raw(e,t){return new r().raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...e){if(this.parent){let t=this,n=!1;for(let r of e)r===this?n=!0:n?(this.parent.insertAfter(t,r),t=r):this.parent.insertBefore(t,r);n||this.remove()}return this}root(){let e=this;for(;e.parent&&e.parent.type!==`document`;)e=e.parent;return e}toJSON(e,t){let n={},r=t==null;t||=new Map;let i=0;for(let e in this){if(!Object.prototype.hasOwnProperty.call(this,e)||e===`parent`||e===`proxyCache`)continue;let r=this[e];if(Array.isArray(r))n[e]=r.map(e=>typeof e==`object`&&e.toJSON?e.toJSON(null,t):e);else if(typeof r==`object`&&r.toJSON)n[e]=r.toJSON(null,t);else if(e===`source`){if(r==null)continue;let a=t.get(r.input);a??(a=i,t.set(r.input,i),i++),n[e]={end:r.end,inputId:a,start:r.start}}else n[e]=r}return r&&(n.inputs=[...t.keys()].map(e=>e.toJSON())),n}toProxy(){return this.proxyCache||=new Proxy(this,this.getProxyProcessor()),this.proxyCache}toString(e=i){e.stringify&&(e=e.stringify);let t=``;return e(this,e=>{t+=e}),t}warn(e,t,n={}){let r={node:this};for(let e in n)r[e]=n[e];return e.warn(t,r)}};t.exports=l,l.default=l})),
|
|
541
|
-
`,` `])},split(e,t,n){let r=[],i=``,a=!1,o=0,s=!1,c=``,l=!1;for(let n of e)l?l=!1:n===`\\`?l=!0:s?n===c&&(s=!1):n===`"`||n===`'`?(s=!0,c=n):n===`(`?o+=1:n===`)`?o>0&&--o:o===0&&t.includes(n)&&(a=!0),a?(i!==``&&r.push(i.trim()),i=``,a=!1):i+=n;return(n||i!==``)&&r.push(i.trim()),r}};t.exports=n,n.default=n})),$r=o(((e,t)=>{let n=Yr(),r=Qr();var i=class extends n{get selectors(){return r.comma(this.selector)}set selectors(e){let t=this.selector?this.selector.match(/,\s*/):null,n=t?t[0]:`,`+this.raw(`between`,`beforeOpen`);this.selector=e.join(n)}constructor(e){super(e),this.type=`rule`,this.nodes||=[]}};t.exports=i,i.default=i,n.registerRule(i)})),ei=o(((e,t)=>{let n=Xr(),r=qr(),i=Jr(),a=Zr(),o=$r(),s=Vr(),c={empty:!0,space:!0};function l(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n[3]||n[2];if(r)return r}}function u(e,t,n){let r=``;for(let i=t;i<n;i++)r+=e[i][1];return r}t.exports=class{constructor(e){this.input=e,this.root=new a,this.current=this.root,this.spaces=``,this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let t=new n;t.name=e[1].slice(1),t.name===``&&this.unnamedAtrule(t,e),this.init(t,e[2]);let r,i,a,o=!1,s=!1,c=[],l=[];for(;!this.tokenizer.endOfFile();){if(e=this.tokenizer.nextToken(),r=e[0],r===`(`||r===`[`?l.push(r===`(`?`)`:`]`):r===`{`&&l.length>0?l.push(`}`):r===l[l.length-1]&&l.pop(),l.length===0)if(r===`;`){t.source.end=this.getPosition(e[2]),t.source.end.offset++,this.semicolon=!0;break}else if(r===`{`){s=!0;break}else if(r===`}`){if(c.length>0){for(a=c.length-1,i=c[a];i&&i[0]===`space`;)i=c[--a];i&&(t.source.end=this.getPosition(i[3]||i[2]),t.source.end.offset++)}this.end(e);break}else c.push(e);else c.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}t.raws.between=this.spacesAndCommentsFromEnd(c),c.length?(t.raws.afterName=this.spacesAndCommentsFromStart(c),this.raw(t,`params`,c),o&&(e=c[c.length-1],t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++,this.spaces=t.raws.between,t.raws.between=``)):(t.raws.afterName=``,t.params=``),s&&(t.nodes=[],this.current=t)}checkMissedSemicolon(e){let t=this.colon(e);if(t===!1)return;let n=0,r;for(let i=t-1;i>=0&&(r=e[i],!(r[0]!==`space`&&(n+=1,n===2)));i--);throw this.input.error(`Missed semicolon`,r[0]===`word`?r[3]+1:r[2])}colon(e){let t=0,n,r,i;for(let[a,o]of e.entries()){if(r=o,i=r[0],i===`(`&&(t+=1),i===`)`&&--t,t===0&&i===`:`)if(!n)this.doubleColon(r);else if(n[0]===`word`&&n[1]===`progid`)continue;else return a;n=r}return!1}comment(e){let t=new r;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;let n=e[1].slice(2,-2);if(!n.trim())t.text=``,t.raws.left=n,t.raws.right=``;else{let e=n.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2],t.raws.left=e[1],t.raws.right=e[3]}}createTokenizer(){this.tokenizer=s(this.input)}decl(e,t){let n=new i;this.init(n,e[0][2]);let r=e[e.length-1];r[0]===`;`&&(this.semicolon=!0,e.pop()),n.source.end=this.getPosition(r[3]||r[2]||l(e)),n.source.end.offset++;let a=0;for(;e[a][0]!==`word`;)a===e.length-1&&this.unknownWord([e[a]]),a++;n.raws.before+=u(e,0,a),n.source.start=this.getPosition(e[a][2]);let o=a;for(;a<e.length;){let t=e[a][0];if(t===`:`||t===`space`||t===`comment`)break;a++}n.prop=u(e,o,a);let s=a,c;for(;a<e.length&&(c=e[a],a++,c[0]!==`:`);)c[0]===`word`&&/\w/.test(c[1])&&this.unknownWord([c]);n.raws.between=u(e,s,a),(n.prop[0]===`_`||n.prop[0]===`*`)&&(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));let d=a;for(;a<e.length;){let t=e[a][0];if(t!==`space`&&t!==`comment`)break;a++}let f=e.slice(d,a);e=e.slice(a),this.precheckMissedSemicolon(e);for(let t=e.length-1;t>=0;t--){if(c=e[t],c[1].toLowerCase()===`!important`){n.important=!0;let r=this.stringFrom(e,t);r=this.spacesFromEnd(e)+r,r!==` !important`&&(n.raws.important=r);break}else if(c[1].toLowerCase()===`important`){let r=e.slice(0),i=``;for(let e=t;e>0;e--){let t=r[e][0];if(i.trim().startsWith(`!`)&&t!==`space`)break;i=r.pop()[1]+i}i.trim().startsWith(`!`)&&(n.important=!0,n.raws.important=i,e=r)}if(c[0]!==`space`&&c[0]!==`comment`)break}e.some(e=>e[0]!==`space`&&e[0]!==`comment`)&&(n.raws.between+=f.map(e=>e[1]).join(``),f=[]),this.raw(n,`value`,f.concat(e),t),n.value.includes(`:`)&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error(`Double colon`,{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let t=new o;this.init(t,e[2]),t.selector=``,t.raws.between=``,this.current=t}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||``)+this.spaces,this.spaces=``,this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||``)+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let t=this.current.nodes[this.current.nodes.length-1];t&&t.type===`rule`&&!t.raws.ownSemicolon&&(t.raws.ownSemicolon=this.spaces,this.spaces=``,t.source.end=this.getPosition(e[2]),t.source.end.offset+=t.raws.ownSemicolon.length)}}getPosition(e){let t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces=``,e.type!==`comment`&&(this.semicolon=!1)}other(e){let t=!1,n=null,r=!1,i=null,a=[],o=e[1].startsWith(`--`),s=[],c=e;for(;c;){if(n=c[0],s.push(c),n===`(`||n===`[`)i||=c,a.push(n===`(`?`)`:`]`);else if(o&&r&&n===`{`)i||=c,a.push(`}`);else if(a.length===0)if(n===`;`)if(r){this.decl(s,o);return}else break;else if(n===`{`){this.rule(s);return}else if(n===`}`){this.tokenizer.back(s.pop()),t=!0;break}else n===`:`&&(r=!0);else n===a[a.length-1]&&(a.pop(),a.length===0&&(i=null));c=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),a.length>0&&this.unclosedBracket(i),t&&r){if(!o)for(;s.length&&(c=s[s.length-1][0],!(c!==`space`&&c!==`comment`));)this.tokenizer.back(s.pop());this.decl(s,o)}else this.unknownWord(s)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case`space`:this.spaces+=e[1];break;case`;`:this.freeSemicolon(e);break;case`}`:this.end(e);break;case`comment`:this.comment(e);break;case`at-word`:this.atrule(e);break;case`{`:this.emptyRule(e);break;default:this.other(e);break}this.endFile()}precheckMissedSemicolon(){}raw(e,t,n,r){let i,a,o=n.length,s=``,l=!0,u,d;for(let e=0;e<o;e+=1)i=n[e],a=i[0],a===`space`&&e===o-1&&!r?l=!1:a===`comment`?(d=n[e-1]?n[e-1][0]:`empty`,u=n[e+1]?n[e+1][0]:`empty`,!c[d]&&!c[u]?s.slice(-1)===`,`?l=!1:s+=i[1]:l=!1):s+=i[1];if(!l){let r=n.reduce((e,t)=>e+t[1],``);e.raws[t]={raw:r,value:s}}e[t]=s}rule(e){e.pop();let t=new o;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,`selector`,e),this.current=t}spacesAndCommentsFromEnd(e){let t,n=``;for(;e.length&&(t=e[e.length-1][0],!(t!==`space`&&t!==`comment`));)n=e.pop()[1]+n;return n}spacesAndCommentsFromStart(e){let t,n=``;for(;e.length&&(t=e[0][0],!(t!==`space`&&t!==`comment`));)n+=e.shift()[1];return n}spacesFromEnd(e){let t,n=``;for(;e.length&&(t=e[e.length-1][0],t===`space`);)n=e.pop()[1]+n;return n}stringFrom(e,t){let n=``;for(let r=t;r<e.length;r++)n+=e[r][1];return e.splice(t,e.length-t),n}unclosedBlock(){let e=this.current.source.start;throw this.input.error(`Unclosed block`,e.line,e.column)}unclosedBracket(e){throw this.input.error(`Unclosed bracket`,{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error(`Unexpected }`,{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error(`Unknown word `+e[0][1],{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error(`At-rule without name`,{offset:t[2]},{offset:t[2]+t[1].length})}}})),ti=o(((e,t)=>{let{Container:n}=require("postcss");t.exports=class extends n{constructor(e){super(e),this.type=`decl`,this.isNested=!0,this.nodes||=[]}}})),ni=o(((e,t)=>{let n=/[\t\n\f\r "#'()/;[\\\]{}]/g,r=/[,\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,i=/.[\r\n"'(/\\]/,a=/[\da-f]/i,o=/[\n\f\r]/g;t.exports=function(e,t={}){let s=e.css.valueOf(),c=t.ignoreErrors,l,u,d,f,p,m,h,g,_,v=s.length,y=0,b=[],x=[],ee;function te(){return y}function ne(t){throw e.error(`Unclosed `+t,y)}function re(){return x.length===0&&y>=v}function ie(){let e=1,t=!1,n=!1;for(;e>0;)u+=1,s.length<=u&&ne(`interpolation`),l=s.charCodeAt(u),g=s.charCodeAt(u+1),t?!n&&l===t?(t=!1,n=!1):l===92?n=!n:n&&=!1:l===39||l===34?t=l:l===125?--e:l===35&&g===123&&(e+=1)}function ae(e){if(x.length)return x.pop();if(y>=v)return;let t=e?e.ignoreUnclosed:!1;switch(l=s.charCodeAt(y),l){case 10:case 32:case 9:case 13:case 12:u=y;do u+=1,l=s.charCodeAt(u);while(l===32||l===10||l===9||l===13||l===12);_=[`space`,s.slice(y,u)],y=u-1;break;case 91:case 93:case 123:case 125:case 58:case 59:case 41:{let e=String.fromCharCode(l);_=[e,e,y];break}case 44:_=[`word`,`,`,y,y+1];break;case 40:if(h=b.length?b.pop()[1]:``,g=s.charCodeAt(y+1),h===`url`&&g!==39&&g!==34){for(ee=1,m=!1,u=y+1;u<=s.length-1;){if(g=s.charCodeAt(u),g===92)m=!m;else if(g===40)ee+=1;else if(g===41&&(--ee,ee===0))break;u+=1}f=s.slice(y,u+1),_=[`brackets`,f,y,u],y=u}else u=s.indexOf(`)`,y+1),f=s.slice(y,u+1),u===-1||i.test(f)?_=[`(`,`(`,y]:(_=[`brackets`,f,y,u],y=u);break;case 39:case 34:for(d=l,u=y,m=!1;u<v&&(u++,u===v&&ne(`string`),l=s.charCodeAt(u),g=s.charCodeAt(u+1),!(!m&&l===d));)l===92?m=!m:m?m=!1:l===35&&g===123&&ie();_=[`string`,s.slice(y,u+1),y,u],y=u;break;case 64:n.lastIndex=y+1,n.test(s),u=n.lastIndex===0?s.length-1:n.lastIndex-2,_=[`at-word`,s.slice(y,u+1),y,u],y=u;break;case 92:for(u=y,p=!0;s.charCodeAt(u+1)===92;)u+=1,p=!p;if(l=s.charCodeAt(u+1),p&&l!==47&&l!==32&&l!==10&&l!==9&&l!==13&&l!==12&&(u+=1,a.test(s.charAt(u)))){for(;a.test(s.charAt(u+1));)u+=1;s.charCodeAt(u+1)===32&&(u+=1)}_=[`word`,s.slice(y,u+1),y,u],y=u;break;default:g=s.charCodeAt(y+1),l===35&&g===123?(u=y,ie(),f=s.slice(y,u+1),_=[`word`,f,y,u],y=u):l===47&&g===42?(u=s.indexOf(`*/`,y+2)+1,u===0&&(c||t?u=s.length:ne(`comment`)),_=[`comment`,s.slice(y,u+1),y,u],y=u):l===47&&g===47?(o.lastIndex=y+1,o.test(s),u=o.lastIndex===0?s.length-1:o.lastIndex-2,f=s.slice(y,u+1),_=[`comment`,f,y,u,`inline`],y=u):(r.lastIndex=y+1,r.test(s),u=r.lastIndex===0?s.length-1:r.lastIndex-2,_=[`word`,s.slice(y,u+1),y,u],b.push(_),y=u);break}return y++,_}function oe(e){x.push(e)}return{back:oe,endOfFile:re,nextToken:ae,position:te}}})),ri=o(((e,t)=>{let{Comment:n}=require("postcss"),r=ei(),i=ti(),a=ni();t.exports=class extends r{atrule(e){let t=e[1],n=e;for(;!this.tokenizer.endOfFile();){let e=this.tokenizer.nextToken();if(e[0]===`word`&&e[2]===n[3]+1)t+=e[1],n=e;else{this.tokenizer.back(e);break}}super.atrule([`at-word`,t,e[2],n[3]])}comment(e){if(e[4]===`inline`){let t=new n;this.init(t,e[2]),t.raws.inline=!0;let r=this.input.fromOffset(e[3]);t.source.end={column:r.col,line:r.line,offset:e[3]+1};let i=e[1].slice(2);if(/^\s*$/.test(i))t.text=``,t.raws.left=i,t.raws.right=``;else{let e=i.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2].replace(/(\*\/|\/\*)/g,`*//*`),t.raws.left=e[1],t.raws.right=e[3],t.raws.text=e[2]}}else super.comment(e)}createTokenizer(){this.tokenizer=a(this.input)}raw(e,t,n,r){if(super.raw(e,t,n,r),e.raws[t]){let r=e.raws[t].raw;e.raws[t].raw=n.reduce((e,t)=>{if(t[0]===`comment`&&t[4]===`inline`){let n=t[1].slice(2).replace(/(\*\/|\/\*)/g,`*//*`);return e+`/*`+n+`*/`}else return e+t[1]},``),r!==e.raws[t].raw&&(e.raws[t].scss=r)}}rule(e){let t=!1,n=0,r=``;for(let i of e)if(t)i[0]!==`comment`&&i[0]!==`{`&&(r+=i[1]);else if(i[0]===`space`&&i[1].includes(`
|
|
542
|
-
`))break;else i[0]===`(`?n+=1:i[0]===`)`?--n:n===0&&i[0]===`:`&&(t=!0);if(!t||r.trim()===``||/^[#:A-Za-z-]/.test(r))super.rule(e);else{e.pop();let t=new i;this.init(t,e[0][2]);let n;for(let t=e.length-1;t>=0;t--)if(e[t][0]!==`space`){n=e[t];break}if(n[3]){let e=this.input.fromOffset(n[3]);t.source.end={column:e.col,line:e.line,offset:n[3]+1}}else{let e=this.input.fromOffset(n[2]);t.source.end={column:e.col,line:e.line,offset:n[2]+1}}for(;e[0][0]!==`word`;)t.raws.before+=e.shift()[1];if(e[0][2]){let n=this.input.fromOffset(e[0][2]);t.source.start={column:n.col,line:n.line,offset:e[0][2]}}for(t.prop=``;e.length;){let n=e[0][0];if(n===`:`||n===`space`||n===`comment`)break;t.prop+=e.shift()[1]}t.raws.between=``;let r;for(;e.length;)if(r=e.shift(),r[0]===`:`){t.raws.between+=r[1];break}else t.raws.between+=r[1];(t.prop[0]===`_`||t.prop[0]===`*`)&&(t.raws.before+=t.prop[0],t.prop=t.prop.slice(1)),t.raws.between+=this.spacesAndCommentsFromStart(e),this.precheckMissedSemicolon(e);for(let n=e.length-1;n>0;n--){if(r=e[n],r[1]===`!important`){t.important=!0;let r=this.stringFrom(e,n);r=this.spacesFromEnd(e)+r,r!==` !important`&&(t.raws.important=r);break}else if(r[1]===`important`){let r=e.slice(0),i=``;for(let e=n;e>0;e--){let t=r[e][0];if(i.trim().indexOf(`!`)===0&&t!==`space`)break;i=r.pop()[1]+i}i.trim().indexOf(`!`)===0&&(t.important=!0,t.raws.important=i,e=r)}if(r[0]!==`space`&&r[0]!==`comment`)break}this.raw(t,`value`,e),t.value.includes(`:`)&&this.checkMissedSemicolon(e),this.current=t}}}})),
|
|
541
|
+
`?(t=1,n+=1):t+=1;return{column:t,line:n,offset:a}}prev(){if(!this.parent)return;let e=this.parent.index(this);return this.parent.nodes[e-1]}rangeBy(e={}){let t=`document`in this.source.input?this.source.input.document:this.source.input.css,n={column:this.source.start.column,line:this.source.start.line,offset:c(t,this.source.start)},r=this.source.end?{column:this.source.end.column+1,line:this.source.end.line,offset:typeof this.source.end.offset==`number`?this.source.end.offset:c(t,this.source.end)+1}:{column:n.column+1,line:n.line,offset:n.offset+1};if(e.word){let i=t.slice(c(t,this.source.start),c(t,this.source.end)).indexOf(e.word);i!==-1&&(n=this.positionInside(i),r=this.positionInside(i+e.word.length))}else e.start?n={column:e.start.column,line:e.start.line,offset:c(t,e.start)}:e.index&&(n=this.positionInside(e.index)),e.end?r={column:e.end.column,line:e.end.line,offset:c(t,e.end)}:typeof e.endIndex==`number`?r=this.positionInside(e.endIndex):e.index&&(r=this.positionInside(e.index+1));return(r.line<n.line||r.line===n.line&&r.column<=n.column)&&(r={column:n.column+1,line:n.line,offset:n.offset+1}),{end:r,start:n}}raw(e,t){return new r().raw(this,e,t)}remove(){return this.parent&&this.parent.removeChild(this),this.parent=void 0,this}replaceWith(...e){if(this.parent){let t=this,n=!1;for(let r of e)r===this?n=!0:n?(this.parent.insertAfter(t,r),t=r):this.parent.insertBefore(t,r);n||this.remove()}return this}root(){let e=this;for(;e.parent&&e.parent.type!==`document`;)e=e.parent;return e}toJSON(e,t){let n={},r=t==null;t||=new Map;let i=0;for(let e in this){if(!Object.prototype.hasOwnProperty.call(this,e)||e===`parent`||e===`proxyCache`)continue;let r=this[e];if(Array.isArray(r))n[e]=r.map(e=>typeof e==`object`&&e.toJSON?e.toJSON(null,t):e);else if(typeof r==`object`&&r.toJSON)n[e]=r.toJSON(null,t);else if(e===`source`){if(r==null)continue;let a=t.get(r.input);a??(a=i,t.set(r.input,i),i++),n[e]={end:r.end,inputId:a,start:r.start}}else n[e]=r}return r&&(n.inputs=[...t.keys()].map(e=>e.toJSON())),n}toProxy(){return this.proxyCache||=new Proxy(this,this.getProxyProcessor()),this.proxyCache}toString(e=i){e.stringify&&(e=e.stringify);let t=``;return e(this,e=>{t+=e}),t}warn(e,t,n={}){let r={node:this};for(let e in n)r[e]=n[e];return e.warn(t,r)}};t.exports=l,l.default=l})),Yr=o(((e,t)=>{let n=Jr();var r=class extends n{constructor(e){super(e),this.type=`comment`}};t.exports=r,r.default=r})),Xr=o(((e,t)=>{let n=Jr();var r=class extends n{get variable(){return this.prop.startsWith(`--`)||this.prop[0]===`$`}constructor(e){e&&e.value!==void 0&&typeof e.value!=`string`&&(e={...e,value:String(e.value)}),super(e),this.type=`decl`}};t.exports=r,r.default=r})),Zr=o(((e,t)=>{let n=Yr(),r=Xr(),i=Jr(),{isClean:a,my:o}=qr(),s,c,l,u;function d(e){return e.map(e=>(e.nodes&&=d(e.nodes),delete e.source,e))}function f(e){if(e[a]=!1,e.proxyOf.nodes)for(let t of e.proxyOf.nodes)f(t)}var p=class e extends i{get first(){if(this.proxyOf.nodes)return this.proxyOf.nodes[0]}get last(){if(this.proxyOf.nodes)return this.proxyOf.nodes[this.proxyOf.nodes.length-1]}append(...e){for(let t of e){let e=this.normalize(t,this.last);for(let t of e)this.proxyOf.nodes.push(t)}return this.markDirty(),this}cleanRaws(e){if(super.cleanRaws(e),this.nodes)for(let t of this.nodes)t.cleanRaws(e)}each(e){if(!this.proxyOf.nodes)return;let t=this.getIterator(),n,r;for(;this.indexes[t]<this.proxyOf.nodes.length&&(n=this.indexes[t],r=e(this.proxyOf.nodes[n],n),r!==!1);)this.indexes[t]+=1;return delete this.indexes[t],r}every(e){return this.nodes.every(e)}getIterator(){this.lastEach||=0,this.indexes||={},this.lastEach+=1;let e=this.lastEach;return this.indexes[e]=0,e}getProxyProcessor(){return{get(e,t){return t===`proxyOf`?e:e[t]?t===`each`||typeof t==`string`&&t.startsWith(`walk`)?(...n)=>e[t](...n.map(e=>typeof e==`function`?(t,n)=>e(t.toProxy(),n):e)):t===`every`||t===`some`?n=>e[t]((e,...t)=>n(e.toProxy(),...t)):t===`root`?()=>e.root().toProxy():t===`nodes`?e.nodes.map(e=>e.toProxy()):t===`first`||t===`last`?e[t].toProxy():e[t]:e[t]},set(e,t,n){return e[t]===n?!0:(e[t]=n,(t===`name`||t===`params`||t===`selector`)&&e.markDirty(),!0)}}}index(e){return typeof e==`number`?e:(e.proxyOf&&(e=e.proxyOf),this.proxyOf.nodes.indexOf(e))}insertAfter(e,t){let n=this.index(e),r=this.normalize(t,this.proxyOf.nodes[n]).reverse();n=this.index(e);for(let e of r)this.proxyOf.nodes.splice(n+1,0,e);let i;for(let e in this.indexes)i=this.indexes[e],n<i&&(this.indexes[e]=i+r.length);return this.markDirty(),this}insertBefore(e,t){let n=this.index(e),r=n===0?`prepend`:!1,i=this.normalize(t,this.proxyOf.nodes[n],r).reverse();n=this.index(e);for(let e of i)this.proxyOf.nodes.splice(n,0,e);let a;for(let e in this.indexes)a=this.indexes[e],n<=a&&(this.indexes[e]=a+i.length);return this.markDirty(),this}normalize(t,i){if(typeof t==`string`)t=d(c(t).nodes);else if(t===void 0)t=[];else if(Array.isArray(t)){t=t.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,`ignore`)}else if(t.type===`root`&&this.type!==`document`){t=t.nodes.slice(0);for(let e of t)e.parent&&e.parent.removeChild(e,`ignore`)}else if(t.type)t=[t];else if(t.prop){if(t.value===void 0)throw Error(`Value field is missed in node creation`);typeof t.value!=`string`&&(t.value=String(t.value)),t=[new r(t)]}else if(t.selector||t.selectors)t=[new u(t)];else if(t.name)t=[new s(t)];else if(t.text)t=[new n(t)];else throw Error(`Unknown node type in node creation`);return t.map(t=>(t[o]||e.rebuild(t),t=t.proxyOf,t.parent&&t.parent.removeChild(t),t[a]&&f(t),t.raws||={},t.raws.before===void 0&&i&&i.raws.before!==void 0&&(t.raws.before=i.raws.before.replace(/\S/g,``)),t.parent=this.proxyOf,t))}prepend(...e){e=e.reverse();for(let t of e){let e=this.normalize(t,this.first,`prepend`).reverse();for(let t of e)this.proxyOf.nodes.unshift(t);for(let t in this.indexes)this.indexes[t]=this.indexes[t]+e.length}return this.markDirty(),this}push(e){return e.parent=this,this.proxyOf.nodes.push(e),this}removeAll(){for(let e of this.proxyOf.nodes)e.parent=void 0;return this.proxyOf.nodes=[],this.markDirty(),this}removeChild(e){e=this.index(e),this.proxyOf.nodes[e].parent=void 0,this.proxyOf.nodes.splice(e,1);let t;for(let n in this.indexes)t=this.indexes[n],t>=e&&(this.indexes[n]=t-1);return this.markDirty(),this}replaceValues(e,t,n){return n||(n=t,t={}),this.walkDecls(r=>{t.props&&!t.props.includes(r.prop)||t.fast&&!r.value.includes(t.fast)||(r.value=r.value.replace(e,n))}),this.markDirty(),this}some(e){return this.nodes.some(e)}walk(e){return this.each((t,n)=>{let r;try{r=e(t,n)}catch(e){throw t.addToError(e)}return r!==!1&&t.walk&&(r=t.walk(e)),r})}walkAtRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if(n.type===`atrule`&&e.test(n.name))return t(n,r)}):this.walk((n,r)=>{if(n.type===`atrule`&&n.name===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if(e.type===`atrule`)return t(e,n)}))}walkComments(e){return this.walk((t,n)=>{if(t.type===`comment`)return e(t,n)})}walkDecls(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if(n.type===`decl`&&e.test(n.prop))return t(n,r)}):this.walk((n,r)=>{if(n.type===`decl`&&n.prop===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if(e.type===`decl`)return t(e,n)}))}walkRules(e,t){return t?e instanceof RegExp?this.walk((n,r)=>{if(n.type===`rule`&&e.test(n.selector))return t(n,r)}):this.walk((n,r)=>{if(n.type===`rule`&&n.selector===e)return t(n,r)}):(t=e,this.walk((e,n)=>{if(e.type===`rule`)return t(e,n)}))}};p.registerParse=e=>{c=e},p.registerRule=e=>{u=e},p.registerAtRule=e=>{s=e},p.registerRoot=e=>{l=e},t.exports=p,p.default=p,p.rebuild=e=>{e.type===`atrule`?Object.setPrototypeOf(e,s.prototype):e.type===`rule`?Object.setPrototypeOf(e,u.prototype):e.type===`decl`?Object.setPrototypeOf(e,r.prototype):e.type===`comment`?Object.setPrototypeOf(e,n.prototype):e.type===`root`&&Object.setPrototypeOf(e,l.prototype),e[o]=!0,e.nodes&&e.nodes.forEach(e=>{p.rebuild(e)})}})),Qr=o(((e,t)=>{let n=Zr();var r=class extends n{constructor(e){super(e),this.type=`atrule`}append(...e){return this.proxyOf.nodes||(this.nodes=[]),super.append(...e)}prepend(...e){return this.proxyOf.nodes||(this.nodes=[]),super.prepend(...e)}};t.exports=r,r.default=r,n.registerAtRule(r)})),$r=o(((e,t)=>{let n=Zr(),r,i;var a=class extends n{constructor(e){super(e),this.type=`root`,this.nodes||=[]}normalize(e,t,n){let r=super.normalize(e);if(t){if(n===`prepend`)this.nodes.length>1?t.raws.before=this.nodes[1].raws.before:delete t.raws.before;else if(this.first!==t)for(let e of r)e.raws.before=t.raws.before}return r}removeChild(e,t){let n=this.index(e);return!t&&n===0&&this.nodes.length>1&&(this.nodes[1].raws.before=this.nodes[n].raws.before),super.removeChild(e)}toResult(e={}){return new r(new i,this,e).stringify()}};a.registerLazyResult=e=>{r=e},a.registerProcessor=e=>{i=e},t.exports=a,a.default=a,n.registerRoot(a)})),ei=o(((e,t)=>{let n={comma(e){return n.split(e,[`,`],!0)},space(e){return n.split(e,[` `,`
|
|
542
|
+
`,` `])},split(e,t,n){let r=[],i=``,a=!1,o=0,s=!1,c=``,l=!1;for(let n of e)l?l=!1:n===`\\`?l=!0:s?n===c&&(s=!1):n===`"`||n===`'`?(s=!0,c=n):n===`(`?o+=1:n===`)`?o>0&&--o:o===0&&t.includes(n)&&(a=!0),a?(i!==``&&r.push(i.trim()),i=``,a=!1):i+=n;return(n||i!==``)&&r.push(i.trim()),r}};t.exports=n,n.default=n})),ti=o(((e,t)=>{let n=Zr(),r=ei();var i=class extends n{get selectors(){return r.comma(this.selector)}set selectors(e){let t=this.selector?this.selector.match(/,\s*/):null,n=t?t[0]:`,`+this.raw(`between`,`beforeOpen`);this.selector=e.join(n)}constructor(e){super(e),this.type=`rule`,this.nodes||=[]}};t.exports=i,i.default=i,n.registerRule(i)})),ni=o(((e,t)=>{let n=Qr(),r=Yr(),i=Xr(),a=$r(),o=ti(),s=Ur(),c={empty:!0,space:!0};function l(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n[3]||n[2];if(r)return r}}function u(e,t,n){let r=``;for(let i=t;i<n;i++)r+=e[i][1];return r}t.exports=class{constructor(e){this.input=e,this.root=new a,this.current=this.root,this.spaces=``,this.semicolon=!1,this.createTokenizer(),this.root.source={input:e,start:{column:1,line:1,offset:0}}}atrule(e){let t=new n;t.name=e[1].slice(1),t.name===``&&this.unnamedAtrule(t,e),this.init(t,e[2]);let r,i,a,o=!1,s=!1,c=[],l=[];for(;!this.tokenizer.endOfFile();){if(e=this.tokenizer.nextToken(),r=e[0],r===`(`||r===`[`?l.push(r===`(`?`)`:`]`):r===`{`&&l.length>0?l.push(`}`):r===l[l.length-1]&&l.pop(),l.length===0)if(r===`;`){t.source.end=this.getPosition(e[2]),t.source.end.offset++,this.semicolon=!0;break}else if(r===`{`){s=!0;break}else if(r===`}`){if(c.length>0){for(a=c.length-1,i=c[a];i&&i[0]===`space`;)i=c[--a];i&&(t.source.end=this.getPosition(i[3]||i[2]),t.source.end.offset++)}this.end(e);break}else c.push(e);else c.push(e);if(this.tokenizer.endOfFile()){o=!0;break}}t.raws.between=this.spacesAndCommentsFromEnd(c),c.length?(t.raws.afterName=this.spacesAndCommentsFromStart(c),this.raw(t,`params`,c),o&&(e=c[c.length-1],t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++,this.spaces=t.raws.between,t.raws.between=``)):(t.raws.afterName=``,t.params=``),s&&(t.nodes=[],this.current=t)}checkMissedSemicolon(e){let t=this.colon(e);if(t===!1)return;let n=0,r;for(let i=t-1;i>=0&&(r=e[i],!(r[0]!==`space`&&(n+=1,n===2)));i--);throw this.input.error(`Missed semicolon`,r[0]===`word`?r[3]+1:r[2])}colon(e){let t=0,n,r,i;for(let[a,o]of e.entries()){if(r=o,i=r[0],i===`(`&&(t+=1),i===`)`&&--t,t===0&&i===`:`)if(!n)this.doubleColon(r);else if(n[0]===`word`&&n[1]===`progid`)continue;else return a;n=r}return!1}comment(e){let t=new r;this.init(t,e[2]),t.source.end=this.getPosition(e[3]||e[2]),t.source.end.offset++;let n=e[1].slice(2,-2);if(!n.trim())t.text=``,t.raws.left=n,t.raws.right=``;else{let e=n.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2],t.raws.left=e[1],t.raws.right=e[3]}}createTokenizer(){this.tokenizer=s(this.input)}decl(e,t){let n=new i;this.init(n,e[0][2]);let r=e[e.length-1];r[0]===`;`&&(this.semicolon=!0,e.pop()),n.source.end=this.getPosition(r[3]||r[2]||l(e)),n.source.end.offset++;let a=0;for(;e[a][0]!==`word`;)a===e.length-1&&this.unknownWord([e[a]]),a++;n.raws.before+=u(e,0,a),n.source.start=this.getPosition(e[a][2]);let o=a;for(;a<e.length;){let t=e[a][0];if(t===`:`||t===`space`||t===`comment`)break;a++}n.prop=u(e,o,a);let s=a,c;for(;a<e.length&&(c=e[a],a++,c[0]!==`:`);)c[0]===`word`&&/\w/.test(c[1])&&this.unknownWord([c]);n.raws.between=u(e,s,a),(n.prop[0]===`_`||n.prop[0]===`*`)&&(n.raws.before+=n.prop[0],n.prop=n.prop.slice(1));let d=a;for(;a<e.length;){let t=e[a][0];if(t!==`space`&&t!==`comment`)break;a++}let f=e.slice(d,a);e=e.slice(a),this.precheckMissedSemicolon(e);for(let t=e.length-1;t>=0;t--){if(c=e[t],c[1].toLowerCase()===`!important`){n.important=!0;let r=this.stringFrom(e,t);r=this.spacesFromEnd(e)+r,r!==` !important`&&(n.raws.important=r);break}else if(c[1].toLowerCase()===`important`){let r=e.slice(0),i=``;for(let e=t;e>0;e--){let t=r[e][0];if(i.trim().startsWith(`!`)&&t!==`space`)break;i=r.pop()[1]+i}i.trim().startsWith(`!`)&&(n.important=!0,n.raws.important=i,e=r)}if(c[0]!==`space`&&c[0]!==`comment`)break}e.some(e=>e[0]!==`space`&&e[0]!==`comment`)&&(n.raws.between+=f.map(e=>e[1]).join(``),f=[]),this.raw(n,`value`,f.concat(e),t),n.value.includes(`:`)&&!t&&this.checkMissedSemicolon(e)}doubleColon(e){throw this.input.error(`Double colon`,{offset:e[2]},{offset:e[2]+e[1].length})}emptyRule(e){let t=new o;this.init(t,e[2]),t.selector=``,t.raws.between=``,this.current=t}end(e){this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.semicolon=!1,this.current.raws.after=(this.current.raws.after||``)+this.spaces,this.spaces=``,this.current.parent?(this.current.source.end=this.getPosition(e[2]),this.current.source.end.offset++,this.current=this.current.parent):this.unexpectedClose(e)}endFile(){this.current.parent&&this.unclosedBlock(),this.current.nodes&&this.current.nodes.length&&(this.current.raws.semicolon=this.semicolon),this.current.raws.after=(this.current.raws.after||``)+this.spaces,this.root.source.end=this.getPosition(this.tokenizer.position())}freeSemicolon(e){if(this.spaces+=e[1],this.current.nodes){let t=this.current.nodes[this.current.nodes.length-1];t&&t.type===`rule`&&!t.raws.ownSemicolon&&(t.raws.ownSemicolon=this.spaces,this.spaces=``,t.source.end=this.getPosition(e[2]),t.source.end.offset+=t.raws.ownSemicolon.length)}}getPosition(e){let t=this.input.fromOffset(e);return{column:t.col,line:t.line,offset:e}}init(e,t){this.current.push(e),e.source={input:this.input,start:this.getPosition(t)},e.raws.before=this.spaces,this.spaces=``,e.type!==`comment`&&(this.semicolon=!1)}other(e){let t=!1,n=null,r=!1,i=null,a=[],o=e[1].startsWith(`--`),s=[],c=e;for(;c;){if(n=c[0],s.push(c),n===`(`||n===`[`)i||=c,a.push(n===`(`?`)`:`]`);else if(o&&r&&n===`{`)i||=c,a.push(`}`);else if(a.length===0)if(n===`;`)if(r){this.decl(s,o);return}else break;else if(n===`{`){this.rule(s);return}else if(n===`}`){this.tokenizer.back(s.pop()),t=!0;break}else n===`:`&&(r=!0);else n===a[a.length-1]&&(a.pop(),a.length===0&&(i=null));c=this.tokenizer.nextToken()}if(this.tokenizer.endOfFile()&&(t=!0),a.length>0&&this.unclosedBracket(i),t&&r){if(!o)for(;s.length&&(c=s[s.length-1][0],!(c!==`space`&&c!==`comment`));)this.tokenizer.back(s.pop());this.decl(s,o)}else this.unknownWord(s)}parse(){let e;for(;!this.tokenizer.endOfFile();)switch(e=this.tokenizer.nextToken(),e[0]){case`space`:this.spaces+=e[1];break;case`;`:this.freeSemicolon(e);break;case`}`:this.end(e);break;case`comment`:this.comment(e);break;case`at-word`:this.atrule(e);break;case`{`:this.emptyRule(e);break;default:this.other(e);break}this.endFile()}precheckMissedSemicolon(){}raw(e,t,n,r){let i,a,o=n.length,s=``,l=!0,u,d;for(let e=0;e<o;e+=1)i=n[e],a=i[0],a===`space`&&e===o-1&&!r?l=!1:a===`comment`?(d=n[e-1]?n[e-1][0]:`empty`,u=n[e+1]?n[e+1][0]:`empty`,!c[d]&&!c[u]?s.slice(-1)===`,`?l=!1:s+=i[1]:l=!1):s+=i[1];if(!l){let r=n.reduce((e,t)=>e+t[1],``);e.raws[t]={raw:r,value:s}}e[t]=s}rule(e){e.pop();let t=new o;this.init(t,e[0][2]),t.raws.between=this.spacesAndCommentsFromEnd(e),this.raw(t,`selector`,e),this.current=t}spacesAndCommentsFromEnd(e){let t,n=``;for(;e.length&&(t=e[e.length-1][0],!(t!==`space`&&t!==`comment`));)n=e.pop()[1]+n;return n}spacesAndCommentsFromStart(e){let t,n=``;for(;e.length&&(t=e[0][0],!(t!==`space`&&t!==`comment`));)n+=e.shift()[1];return n}spacesFromEnd(e){let t,n=``;for(;e.length&&(t=e[e.length-1][0],t===`space`);)n=e.pop()[1]+n;return n}stringFrom(e,t){let n=``;for(let r=t;r<e.length;r++)n+=e[r][1];return e.splice(t,e.length-t),n}unclosedBlock(){let e=this.current.source.start;throw this.input.error(`Unclosed block`,e.line,e.column)}unclosedBracket(e){throw this.input.error(`Unclosed bracket`,{offset:e[2]},{offset:e[2]+1})}unexpectedClose(e){throw this.input.error(`Unexpected }`,{offset:e[2]},{offset:e[2]+1})}unknownWord(e){throw this.input.error(`Unknown word `+e[0][1],{offset:e[0][2]},{offset:e[0][2]+e[0][1].length})}unnamedAtrule(e,t){throw this.input.error(`At-rule without name`,{offset:t[2]},{offset:t[2]+t[1].length})}}})),ri=o(((e,t)=>{let{Container:n}=require("postcss");t.exports=class extends n{constructor(e){super(e),this.type=`decl`,this.isNested=!0,this.nodes||=[]}}})),ii=o(((e,t)=>{let n=/[\t\n\f\r "#'()/;[\\\]{}]/g,r=/[,\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g,i=/.[\r\n"'(/\\]/,a=/[\da-f]/i,o=/[\n\f\r]/g;t.exports=function(e,t={}){let s=e.css.valueOf(),c=t.ignoreErrors,l,u,d,f,p,m,h,g,_,v=s.length,y=0,b=[],x=[],ee;function te(){return y}function ne(t){throw e.error(`Unclosed `+t,y)}function re(){return x.length===0&&y>=v}function ie(){let e=1,t=!1,n=!1;for(;e>0;)u+=1,s.length<=u&&ne(`interpolation`),l=s.charCodeAt(u),g=s.charCodeAt(u+1),t?!n&&l===t?(t=!1,n=!1):l===92?n=!n:n&&=!1:l===39||l===34?t=l:l===125?--e:l===35&&g===123&&(e+=1)}function ae(e){if(x.length)return x.pop();if(y>=v)return;let t=e?e.ignoreUnclosed:!1;switch(l=s.charCodeAt(y),l){case 10:case 32:case 9:case 13:case 12:u=y;do u+=1,l=s.charCodeAt(u);while(l===32||l===10||l===9||l===13||l===12);_=[`space`,s.slice(y,u)],y=u-1;break;case 91:case 93:case 123:case 125:case 58:case 59:case 41:{let e=String.fromCharCode(l);_=[e,e,y];break}case 44:_=[`word`,`,`,y,y+1];break;case 40:if(h=b.length?b.pop()[1]:``,g=s.charCodeAt(y+1),h===`url`&&g!==39&&g!==34){for(ee=1,m=!1,u=y+1;u<=s.length-1;){if(g=s.charCodeAt(u),g===92)m=!m;else if(g===40)ee+=1;else if(g===41&&(--ee,ee===0))break;u+=1}f=s.slice(y,u+1),_=[`brackets`,f,y,u],y=u}else u=s.indexOf(`)`,y+1),f=s.slice(y,u+1),u===-1||i.test(f)?_=[`(`,`(`,y]:(_=[`brackets`,f,y,u],y=u);break;case 39:case 34:for(d=l,u=y,m=!1;u<v&&(u++,u===v&&ne(`string`),l=s.charCodeAt(u),g=s.charCodeAt(u+1),!(!m&&l===d));)l===92?m=!m:m?m=!1:l===35&&g===123&&ie();_=[`string`,s.slice(y,u+1),y,u],y=u;break;case 64:n.lastIndex=y+1,n.test(s),u=n.lastIndex===0?s.length-1:n.lastIndex-2,_=[`at-word`,s.slice(y,u+1),y,u],y=u;break;case 92:for(u=y,p=!0;s.charCodeAt(u+1)===92;)u+=1,p=!p;if(l=s.charCodeAt(u+1),p&&l!==47&&l!==32&&l!==10&&l!==9&&l!==13&&l!==12&&(u+=1,a.test(s.charAt(u)))){for(;a.test(s.charAt(u+1));)u+=1;s.charCodeAt(u+1)===32&&(u+=1)}_=[`word`,s.slice(y,u+1),y,u],y=u;break;default:g=s.charCodeAt(y+1),l===35&&g===123?(u=y,ie(),f=s.slice(y,u+1),_=[`word`,f,y,u],y=u):l===47&&g===42?(u=s.indexOf(`*/`,y+2)+1,u===0&&(c||t?u=s.length:ne(`comment`)),_=[`comment`,s.slice(y,u+1),y,u],y=u):l===47&&g===47?(o.lastIndex=y+1,o.test(s),u=o.lastIndex===0?s.length-1:o.lastIndex-2,f=s.slice(y,u+1),_=[`comment`,f,y,u,`inline`],y=u):(r.lastIndex=y+1,r.test(s),u=r.lastIndex===0?s.length-1:r.lastIndex-2,_=[`word`,s.slice(y,u+1),y,u],b.push(_),y=u);break}return y++,_}function oe(e){x.push(e)}return{back:oe,endOfFile:re,nextToken:ae,position:te}}})),ai=o(((e,t)=>{let{Comment:n}=require("postcss"),r=ni(),i=ri(),a=ii();t.exports=class extends r{atrule(e){let t=e[1],n=e;for(;!this.tokenizer.endOfFile();){let e=this.tokenizer.nextToken();if(e[0]===`word`&&e[2]===n[3]+1)t+=e[1],n=e;else{this.tokenizer.back(e);break}}super.atrule([`at-word`,t,e[2],n[3]])}comment(e){if(e[4]===`inline`){let t=new n;this.init(t,e[2]),t.raws.inline=!0;let r=this.input.fromOffset(e[3]);t.source.end={column:r.col,line:r.line,offset:e[3]+1};let i=e[1].slice(2);if(/^\s*$/.test(i))t.text=``,t.raws.left=i,t.raws.right=``;else{let e=i.match(/^(\s*)([^]*\S)(\s*)$/);t.text=e[2].replace(/(\*\/|\/\*)/g,`*//*`),t.raws.left=e[1],t.raws.right=e[3],t.raws.text=e[2]}}else super.comment(e)}createTokenizer(){this.tokenizer=a(this.input)}raw(e,t,n,r){if(super.raw(e,t,n,r),e.raws[t]){let r=e.raws[t].raw;e.raws[t].raw=n.reduce((e,t)=>{if(t[0]===`comment`&&t[4]===`inline`){let n=t[1].slice(2).replace(/(\*\/|\/\*)/g,`*//*`);return e+`/*`+n+`*/`}else return e+t[1]},``),r!==e.raws[t].raw&&(e.raws[t].scss=r)}}rule(e){let t=!1,n=0,r=``;for(let i of e)if(t)i[0]!==`comment`&&i[0]!==`{`&&(r+=i[1]);else if(i[0]===`space`&&i[1].includes(`
|
|
543
|
+
`))break;else i[0]===`(`?n+=1:i[0]===`)`?--n:n===0&&i[0]===`:`&&(t=!0);if(!t||r.trim()===``||/^[#:A-Za-z-]/.test(r))super.rule(e);else{e.pop();let t=new i;this.init(t,e[0][2]);let n;for(let t=e.length-1;t>=0;t--)if(e[t][0]!==`space`){n=e[t];break}if(n[3]){let e=this.input.fromOffset(n[3]);t.source.end={column:e.col,line:e.line,offset:n[3]+1}}else{let e=this.input.fromOffset(n[2]);t.source.end={column:e.col,line:e.line,offset:n[2]+1}}for(;e[0][0]!==`word`;)t.raws.before+=e.shift()[1];if(e[0][2]){let n=this.input.fromOffset(e[0][2]);t.source.start={column:n.col,line:n.line,offset:e[0][2]}}for(t.prop=``;e.length;){let n=e[0][0];if(n===`:`||n===`space`||n===`comment`)break;t.prop+=e.shift()[1]}t.raws.between=``;let r;for(;e.length;)if(r=e.shift(),r[0]===`:`){t.raws.between+=r[1];break}else t.raws.between+=r[1];(t.prop[0]===`_`||t.prop[0]===`*`)&&(t.raws.before+=t.prop[0],t.prop=t.prop.slice(1)),t.raws.between+=this.spacesAndCommentsFromStart(e),this.precheckMissedSemicolon(e);for(let n=e.length-1;n>0;n--){if(r=e[n],r[1]===`!important`){t.important=!0;let r=this.stringFrom(e,n);r=this.spacesFromEnd(e)+r,r!==` !important`&&(t.raws.important=r);break}else if(r[1]===`important`){let r=e.slice(0),i=``;for(let e=n;e>0;e--){let t=r[e][0];if(i.trim().indexOf(`!`)===0&&t!==`space`)break;i=r.pop()[1]+i}i.trim().indexOf(`!`)===0&&(t.important=!0,t.raws.important=i,e=r)}if(r[0]!==`space`&&r[0]!==`comment`)break}this.raw(t,`value`,e),t.value.includes(`:`)&&this.checkMissedSemicolon(e),this.current=t}}}})),oi=o(((e,t)=>{let{Input:n}=require("postcss"),r=ai();t.exports=function(e,t){let i=new r(new n(e,t));return i.parse(),i.root}})),si=o(((e,t)=>{let n=Vr();t.exports={parse:oi(),stringify:n}})),ci=l(Rr()),li=s({default:()=>di,parse:()=>pi,stringify:()=>fi}),ui=l(si(),1),di=ui.default;const fi=ui.default.stringify,pi=ui.default.parse;function mi(e,t){let n=null;return!e||t<e.offset||t>e.end?null:(e.accept(e=>e.offset===-1&&e.length===-1?!0:e.offset<=t&&e.end>=t?(n?e.length<=n.length&&(n=e):n=e,!0):!1),n)}function hi(e,t){let n=mi(e,t),r=[];for(;n;)r.unshift(n),n=n.parent;return r}var gi=class{languageService;documentationInfo={};externalDocumentation={};internalDocumentation={};build;_allowRebuildDefinition=!0;getInternalDocumentation(){let e={};for(let t in this.internalDocumentation)try{e={...e,...this.internalDocumentation[t]}}catch{}return e}constructor(e){this.build=e,this.languageService=(0,ce.getSCSSLanguageService)()}async doValidation(e){let t=[];t=this.languageService.doValidation(e.documentUser,this.languageService.parseStylesheet(e.documentUser));for(let e=0;e<t.length;e++)t[e].code==`emptyRules`&&(t.splice(e,1),e--);return t}async doComplete(e,t){let n=[],r={isIncomplete:!1,items:[]};r=this.languageService.doComplete(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));let i={};for(let e of r.items)i[e.label]=e;let a=this.getTree(e,t).reverse()[0];if(this.documentationInfo[a])for(let e of this.documentationInfo[a])n.indexOf(e.name)==-1&&(n.push(e.name),i[e.name]={label:e.name});let o=/^(#([\da-f]{3}){1,2}|(rgb|hsl)a\(\s*(\d{1,3}%?\s*,\s*){3}(1|0?\.\d+)\)|(rgb|hsl)\(\s*\d{1,3}%?(\s*,\s*\d{1,3}%?){2}\s*\))$/i;for(let e in this.build.globalSCSSLanguageService.variablesByName)this.build.globalSCSSLanguageService.variablesByName[e].value.match(o)?i[e]={label:e}:i[``+e]={label:``+e};return r.items=Object.values(i),r}async doHover(e,t){let n=this.getElementAtPosition(e,t);if(n?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(n.getText());if(e)return{contents:{kind:`plaintext`,value:e.name+`: `+e.value}}}return this.languageService.doHover(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async findDefinition(e,t){let n=this.getElementAtPosition(e,t);if(n?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(n.getText());if(e)return[{uri:e.uri,range:e.range}]}let r=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));return r&&[r]}async format(e,t,n){let r={...n,preserveNewLines:!0,spaceAroundSelectorSeparator:!0,insertFinalNewline:!0,insertSpaces:!1,tabSize:4},i=e.documentUser,a=await this.languageService.format(i,t,r);if(a.length==1){let e=i.offsetAt(a[0].range.start),t=i.offsetAt(a[0].range.end),n=i.getText().length;if(e==0&&t==n){let e=await(0,se.default)([(0,ci.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:li,syntax:li,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)}allowRebuildDefinition(e){this._allowRebuildDefinition=e,this.rebuildDefinition()}rebuildDefinition(){if(this._allowRebuildDefinition){this.documentationInfo={};for(let e in this.externalDocumentation){let t=this.externalDocumentation[e];this.documentationInfo={...this.documentationInfo,...t}}for(let e in this.internalDocumentation){let t=this.internalDocumentation[e];try{this.documentationInfo={...this.documentationInfo,...t}}catch{}}}}addExternalDefinition(e,t){this.externalDocumentation[e]=t,this.rebuildDefinition()}getExternalDefinition(e){return this.externalDocumentation[e]}removeExternalDefinition(e){delete this.externalDocumentation[e],this.rebuildDefinition()}addInternalDefinition(e,t){this.internalDocumentation[e]=t,this.rebuildDefinition()}removeInternalDefinition(e){delete this.internalDocumentation[e],this.rebuildDefinition()}getLinkToHtml(e,t){let n=[],r=e.file.documentUser.offsetAt(t),i=e.htmlFile;if(i&&i.fileParsed)for(let e of i.fileParsed.styleLinks){let t=e[1];r>=t.start&&r<=t.end&&n.push({uri:i.file.uri,range:{start:i.file.documentUser.positionAt(e[0].start),end:i.file.documentUser.positionAt(e[0].end)}})}return n}getTree(e,t){let n=[];if(this.languageService){let r=hi(this.languageService.parseStylesheet(e.documentUser),e.documentUser.offsetAt(t));for(let e of r)if(e.type==3){let t=e.getChild(0);if(t){let e=t.getText();n.push(e)}}}return n}getRules(e){let t=new Map,n=this.languageService.parseStylesheet(e.documentUser),r=e=>t=>{let n=e.getText().replace(`.`,``),r=RegExp(`((?:^|\\W))(`+n+`)(?:$|\\W)`,`gi`);return!!t.attributes.class?.value?.match(r)},i=e=>t=>{let n=e.getText();return t.tagName==n},a=(e=null,t)=>n=>{if(e){let t=!1,r=n.parent;for(;r;){if(e(r)){t=!0;break}r=r.parent}if(!t)return!1}for(let e of t)if(!e(n))return!1;return!0},o=(e,n=null)=>{if(e.type==3){let o=e.getChildren();if(o.length>1){for(let e of o[1].getChildren())if(e.type==19||e.type==69||e.type==34||e.type==58||e.type==37)break}if(o.length>0){let e=o[0]?.getChildren()[0],s=null;if(e){for(let t of e.getChildren())if(t.type==5){s?s.start>t.offset?s.start=t.offset:s.end<t.offset+t.length&&(s.end=t.offset+t.length):s={start:t.offset,end:t.offset+t.length};let e=[];for(let n of t.getChildren())n.type==14?e.push(r(n)):n.type==16&&e.push(i(n));e.length>0&&(n=a(n,e))}else t.getText(),$.warning(`css node to implement`);n&&s&&t.set(n,s)}}}else if(e.type==21)return;if(e.hasChildren())for(let t of e.getChildren())o(t,n)},s=hi(n,0);return s.length>0&&o(s[0]),t}getElementAtPosition(e,t){if(this.languageService){let n=this.languageService.parseStylesheet(e.documentUser),r=e.documentUser.offsetAt(t),i=e=>{let t=e.getChildren();for(let e of t)if(e.offset<=r&&e.end>=r)return e.hasChildren()?i(e):e;return null};return i(n)}return null}static getCustomProperty(e){let t=d.TextDocument.create(`temp.scss`,`scss`,1,e),n={},r=(e,t)=>{let n=e.parent?.getText()??``,r=RegExp(`\/\\*([\\s\\S]*?)\\*\/\\s*${t}\\s*:\\s*[^;]+;`,`g`).exec(n);if(r&&r[1]){let e={documentation:[],type:`*`},t=r[1].trim().replace(/\r\n?/g,`
|
|
543
544
|
`).split(`
|
|
544
545
|
`);for(let n of t){let t=!1;n=n.replace(`*`,``).trim(),n.startsWith(`@`)?(t=!0,n.startsWith(`@type`)&&(e.type=n.replace(`@type`,``).trim()),n.startsWith(`@default`)&&(e.default=n.replace(`@default`,``).trim())):t||e.documentation.push(n.trim())}return e}return null},i=e=>{if(e.type==69){let t=e;for(;t&&t.selectors==null;)t=t.parent;if(t&&t.selectors.getText()==`:host`){let t=e.getChild(0),i=e.getChild(1);if(t&&i){let a=null;t.getText().startsWith(`--internal`)?a=t.getText().replace(`--internal-`,`--`):t.getText().startsWith(`--_`)&&(a=t.getText().replace(`--_`,`--`));let o=r(e,t.getText());if(a&&i.getText().indexOf(a)!=-1){let e={name:a};o?.documentation&&(e.documentation=o.documentation.join(`
|
|
545
|
-
`).trim()),o?.type&&(e.type=o.type),o?.default&&(e.defaultValue=o.default);let t=i,r=[],s=``;for(;t&&t.getChildren().length>0;){let e=t.getChildren(),n=t.getText();n&&n.startsWith(`--`)&&(n=n.split(`,`)[0],s!=n&&n!=a&&(s=n,r.push(n))),t=e[e.length-1]}let c=t.getText()??``;c&&(c.startsWith(`--`)||r.push(c)),r.length>0&&(e.chainValues=r,e.defaultValue??=e.chainValues[e.chainValues.length-1]),n[e.name]=e}}}}else if(e.hasChildren())for(let t of e.getChildren())i(t)},a=pi((0,ce.getSCSSLanguageService)().parseStylesheet(t),0);for(let e of a)i(e);return Object.values(n)}},hi=class e extends ct{compiledVersion=-1;usedBy={};dependencies={};diagnostics=[];diagnosticCompile;compiledTxt=``;namespace=``;_rules=new Map;customProperties=[];get compileResult(){return this.compiledTxt}get rules(){return this._rules}get htmlFile(){let e=this.build.htmlFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentView)];return e instanceof gi?e:null}get isGlobal(){return this.file.name.startsWith(`@`)}get globalName(){return this.file.name.replace(w.ComponentStyle,``)}constructor(e,t){super(e,t),this.namespace=this.build.getNamespace(e.uri)}async init(){await this.loadDependencies(),await this.compile(!1)}async onValidate(){return this.diagnostics=await this.build.scssLanguageService.doValidation(this.file),await this.loadDependencies(),this.diagnosticCompile?[...this.diagnostics,this.diagnosticCompile]:this.diagnostics}async onContentChange(){}async onSave(){await this.compileRoot()}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(e=!0){try{let t=this.compiledTxt,n=`|error|`,r=async e=>{let t=e.contentUser;t=t.replace(/\/\*[\s\S]*?@import[\s\S]*?\*\/|\/\/.*@import.*/g,``);let i=/@import *?('|")(\S*?)('|");?/g,a=null;for(;a=i.exec(t);){let i=a[2],o=await this.resolvePath(i,e.folderPath);if(o){let e=await r(o);if(e==n)return e;t=t.replace(a[0],e)}else return n}return t},i=await r(this.file);if(i!=`|error|`)try{this.customProperties=mi.getCustomProperty(i),i=i.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let e=(0,le.compileString)(i,{style:`compressed`}).css.toString().trim();e=e.replace(/\\/g,`\\\\`),t=e,this.diagnosticCompile&&(this.diagnosticCompile=void 0,$.sendDiagnostics({uri:this.file.uri,diagnostics:this.diagnostics},this.build))}catch(e){if(e instanceof le.Exception){this.diagnosticCompile=Me(this.file.documentUser,e.message);let t=[...this.diagnostics,this.diagnosticCompile];$.sendDiagnostics({uri:this.file.uri,diagnostics:t},this.build)}else $.error(e)}if(t!=this.compiledTxt)if(this.compiledVersion++,this.compiledTxt=t,this.isGlobal)j.getInstance().updateGlobalCSS(this.globalName,this.compiledTxt),this.build.build();else{let t=this.build.tsFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentLogic)];if(t instanceof F&&e&&(t.canUpdateComponent=!1,await t.triggerSave(),t.compilationResult)){let e=this.namespace,n=t.fileParsed?.classes[t.compilationResult.componentName].namespace;n&&(e+=n),e.length>0&&!e.endsWith(`.`)&&(e+=`.`),j.getInstance().updateCSS(this.compiledTxt,e+t.compilationResult.componentName,[])}}this._rules=this.build.scssLanguageService.getRules(this.file);let a=this.build.htmlFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentView)];a instanceof gi&&I.refreshStyle(a,this.build)}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()}async onCompletion(e,t){let n={isIncomplete:!1,items:[]};return n=await this.build.scssLanguageService.doComplete(e,t),n}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.build.scssLanguageService.doHover(e,t)}async onDefinition(e,t){return this.build.scssLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return this.build.scssLanguageService.format(e,t,n)}async onCodeAction(e,t){return this.build.scssLanguageService.doCodeAction(e,t)}async onReferences(e,t){let n=await this.build.scssLanguageService.onReferences(e,t);return n=[...n,...this.build.scssLanguageService.getLinkToHtml(this,t)],n}async onCodeLens(e){return[]}onGetBuild(){return[this.build]}async onRename(e,t,n){return null}async 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=await this.resolvePath(t,this.file.folderPath);if(n)await this.addDependency(n);else{let t=e.indexOf(r[0]),n=t+r[0].length;this.diagnostics.push(Ne(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])}async addDependency(t){this.build.scssFiles[t.uri]?(this.dependencies[t.uri]=this.build.scssFiles[t.uri],this.build.scssFiles[t.uri].usedBy[this.file.uri]=this):t.uri.endsWith(w.ComponentStyle)&&(this.build.scssFiles[t.uri]=new e(t,this.build),await this.build.scssFiles[t.uri].init(),this.dependencies[t.uri]=this.build.scssFiles[t.uri],this.build.scssFiles[t.uri].usedBy[this.file.uri]=this)}async getByPath(e){let t=R.getInstance().getByPath(e);if(t)return t;if((0,u.existsSync)(e)&&(0,u.lstatSync)(e).isFile()){let t=d.TextDocument.create(E(e),C.SCSS,1,(0,u.readFileSync)(e,`utf-8`));return await R.getInstance().registerFile(t),R.getInstance().getByPath(e)}}async resolvePath(e,t){e=this.build.project.resolveAlias(e,t),e=(0,f.normalize)(t+`/`+e);let n=await this.getByPath(e);if(n)return n;let r=e+w.ComponentStyle;if(n=await this.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=await this.getByPath(a),n)return n;let o=a+w.ComponentStyle;if(n=await this.getByPath(o),n)return n}},gi=class extends ct{fileParsed;tsErrors=[];version=-1;codeactions=[];get compiledVersion(){return this.version}get tsFile(){let e=this.build.tsFiles[this.file.uri.replace(w.ComponentView,w.ComponentLogic)];return e instanceof F?e:null}get scssFile(){let e=this.build.scssFiles[this.file.uri.replace(w.ComponentView,w.ComponentStyle)];return e instanceof hi?e:null}_slotsInfo;slotsInfoVersion=0;get slotsInfo(){return(this.slotsInfoVersion!=this.file.versionInternal||!this._slotsInfo)&&(this._slotsInfo=this.getSlotsInfo(),this.slotsInfoVersion=this.file.versionInternal),this._slotsInfo}constructor(e,t){super(e,t)}async init(){await this.refreshFileParsed()}refreshFileParsed(){this.fileParsed=I.parse(this,this.build);let e=I.getVersion(this);return this.version==e?!1:(this.version=e,this.file.validate(),!0)}async onValidate(){let e=await this.build.htmlLanguageService.doValidation(this.file);this.fileParsed&&(e=[...e,...this.fileParsed.errors]),e=[...e,...this.tsErrors],this.tsFile&&(e=[...e,...this.tsFile.htmlDiagnostics]),this.codeactions=[];let t=e=>{let t=this.file.documentUser.offsetAt(e.range.start),n=this.file.contentUser.slice(t-3,t-1),r=n==`.t`;if(n!=` t`&&n!=`.t`&&n!=`{t`)return;let i=this.file.documentUser.getText(e.range).slice(1,-1),a={title:`Add value into translation file`,command:{command:`aventus.i18n.add`,title:`Add value into translation file`,arguments:[this.file.uri,i,r]},diagnostics:[e],range:{start:t,end:this.file.documentUser.offsetAt(e.range.end)}};this.codeactions.push(a)};for(let n of e)(n.message.endsWith(`keyof AventusI18n'.`)||/Argument of type .*? is not assignable to parameter of type .*?\./.test(n.message))&&t(n);return e}async onContentChange(){await this.compile()}async onSave(){await this.tsFile?.triggerSave()}async compile(){try{this.refreshFileParsed()&&await this.tsFile?.validate()}catch(e){console.error(e)}}async onDelete(){}async onCompletion(e,t){return await this.tsFile?.doViewCompletion(t)||this.build.htmlLanguageService.doComplete(this,t)}async onCompletionResolve(e,t){return t}async getHover(e){return this.onHover(this.file,this.file.documentUser.positionAt(e))}async onHover(e,t){return await this.tsFile?.doHover(t)||await this.build.htmlLanguageService.doHover(this,t)}async onDefinition(e,t){return await this.tsFile?.doDefinition(t)||this.build.htmlLanguageService.onDefinition(this,t)}async onFormatting(e,t,n){await this.compile();let r=await this.applyJsFormatting(t,n);return this.applyHtmlFormatting(e,t,n,r)}async applyJsFormatting(e,t){let n=await this.tsFile?.doFormatting(e,t)??[];if(!this.fileParsed)return{};let r=new Map,i=new Map,a=new Map;for(let e of n)if(e.kind==`fct`)for(let t in this.fileParsed.fcts){let n=this.fileParsed.fcts[t];if(n.positions.find(t=>t.start==e.start&&t.end==e.end)){let t=r.get(n);t||(t=[],r.set(n,t)),t.push({start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText});break}}else if(e.kind==`loop`){for(let t of this.fileParsed.loops)if(t.start==e.start&&t.startBlock==e.end){let n=i.get(t);n||(n=[],i.set(t,n)),n.push({start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText})}}else if(e.kind==`if`){for(let t of this.fileParsed.ifs)for(let n of t.conditions)if(n.start==e.start&&n.end==e.end){let t=a.get(n);t||(t=[],a.set(n,t)),t.push({start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText})}}let o={};for(let[e,t]of r){let n=`{{`+e.txt+`}}`;o[n]=n,t.sort((e,t)=>t.end-e.end);for(let e of t)o[n]=o[n].slice(0,e.start)+e.txt+o[n].slice(e.end)}for(let[e,t]of i){let n=e.idTemplate,r=e.loopTxt;t.sort((e,t)=>t.end-e.end);for(let e of t)r=r.slice(0,e.start)+e.txt+r.slice(e.end);r=r.slice(0,r.length-1),o[`<`+rr.tagName+` id="`+n+`">`]=r}for(let e of this.fileParsed.loops)i.has(e)||(o[`<`+rr.tagName+` id="`+e.idTemplate+`">`]=e.loopTxt.slice(0,e.loopTxt.length-1));for(let[e,t]of a){let n=e.idTemplate,r=e.txt;t.sort((e,t)=>t.end-e.end);for(let e of t)r=r.slice(0,e.start)+e.txt+r.slice(e.end);e.type==`if`?r=`if(`+r+`) {`:e.type==`elif`&&(r=`else if(`+r+`) {`),o[`<`+ir.tagName+` id="`+n+`">`]=r}for(let e of this.fileParsed.ifs){for(let t of e.conditions)if(!a.has(t)){let e=t.txt;t.type==`if`?e=`if(`+e+`) {`:t.type==`elif`&&(e=`else if(`+e+`) {`),o[`<`+ir.tagName+` id="`+t.idTemplate+`">`]=e}e.conditions.length!=e.idsTemplate.length&&(o[`<`+ir.tagName+` id="`+e.idsTemplate[e.idsTemplate.length-1]+`">`]=`else {`)}for(let e of this.fileParsed.contextEdits){let t=e.mapping.length>0?e.mapping[0]:``,n=e.mapping.length>1?e.mapping[1]:``,r=`@Context(`+t+`, `+n+`)`;o[`<`+ar.tagName+` id="`+e.id+`"></`+ar.tagName+`>`]=r}return o[`</`+rr.tagName+`>`]=`}`,o[`</`+ir.tagName+`>`]=`}`,o}async applyHtmlFormatting(e,t,n,r){if(!this.fileParsed)return[];let i=this.fileParsed?.compiledTxt,a=d.TextDocument.create(e.documentUser.uri,e.documentUser.languageId,e.documentUser.version,i),o=(await this.build.htmlLanguageService.format(a,t,n))[0].newText;for(let e in r){let t=new RegExp(e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),`g`);o=o.replace(t,r[e])}return o=o.replace(/\{\{ *([^\n][\s|\S]*?) *\n?\}\}/g,`{{ $1 }}`),[{newText:o,range:{start:e.documentUser.positionAt(0),end:e.documentUser.positionAt(e.contentUser.length)}}]}async onCodeAction(e,t){let n=e.documentUser.offsetAt(t.start),r=e.documentUser.offsetAt(t.end);return this.codeactions.filter(e=>e.range.start<=n&&e.range.end>=r)}async onReferences(e,t){return await this.tsFile?.doReferences(t)||this.build.htmlLanguageService.getLinkToStyle(this,t)}async onCodeLens(e){return[]}onGetBuild(){return[this.build]}async onRename(e,t,n){return await this.tsFile?.doRename(t,n)||null}getSlotsInfo(){let e=this.tsFile?.fileParsed?.classes[this.tsFile.componentClassName]??null;return e?this.build.getSlotsInfo(e):{}}};const _i=[{name:`@element`,description:`Add a selector for the element inside your logical part`},{name:`@bind`,description:`Bind a watcher to a variable`},{name:`@press`,description:`Add an event for when the element is clicked`},{name:`@press-start`,description:`Add an event for when mouse down or touch start on the element`},{name:`@press-stop`,description:`Add an event for when mouse up or touch start on the element`},{name:`@longpress`,description:`Add an event for when the element is long pressed`},{name:`@longpress-delay`,description:`Add the delay for the long press`},{name:`@dblpress`,description:`Add an event for when the element is double press`},{name:`@dblpress-delay`,description:`Add the delay for the double press`},{name:`@drag`,description:`Add an event for when the element is dragged`},{name:`@drag-start`,description:`Add an event for when the element first drag`},{name:`@drag-end`,description:`Add an event for when the element drag end`}],vi={a:`HTMLAnchorElement`,abbr:`HTMLElement`,address:`HTMLElement`,area:`HTMLAreaElement`,article:`HTMLElement`,aside:`HTMLElement`,audio:`HTMLAudioElement`,b:`HTMLElement`,base:`HTMLBaseElement`,bdi:`HTMLElement`,bdo:`HTMLElement`,blockquote:`HTMLQuoteElement`,body:`HTMLBodyElement`,br:`HTMLBRElement`,button:`HTMLButtonElement`,canvas:`HTMLCanvasElement`,caption:`HTMLTableCaptionElement`,cite:`HTMLElement`,code:`HTMLElement`,col:`HTMLTableColElement`,colgroup:`HTMLTableColElement`,data:`HTMLDataElement`,datalist:`HTMLDataListElement`,dd:`HTMLElement`,del:`HTMLModElement`,details:`HTMLDetailsElement`,dfn:`HTMLElement`,dialog:`HTMLDialogElement`,div:`HTMLDivElement`,dl:`HTMLDListElement`,dt:`HTMLElement`,em:`HTMLElement`,embed:`HTMLEmbedElement`,fieldset:`HTMLFieldSetElement`,figcaption:`HTMLElement`,figure:`HTMLElement`,footer:`HTMLElement`,form:`HTMLFormElement`,h1:`HTMLHeadingElement`,h2:`HTMLHeadingElement`,h3:`HTMLHeadingElement`,h4:`HTMLHeadingElement`,h5:`HTMLHeadingElement`,h6:`HTMLHeadingElement`,head:`HTMLHeadElement`,header:`HTMLElement`,hgroup:`HTMLElement`,hr:`HTMLHRElement`,html:`HTMLHtmlElement`,i:`HTMLElement`,iframe:`HTMLIFrameElement`,img:`HTMLImageElement`,input:`HTMLInputElement`,ins:`HTMLModElement`,kbd:`HTMLElement`,label:`HTMLLabelElement`,legend:`HTMLLegendElement`,li:`HTMLLIElement`,link:`HTMLLinkElement`,main:`HTMLElement`,map:`HTMLMapElement`,mark:`HTMLElement`,menu:`HTMLMenuElement`,meta:`HTMLMetaElement`,meter:`HTMLMeterElement`,nav:`HTMLElement`,noscript:`HTMLElement`,object:`HTMLObjectElement`,ol:`HTMLOListElement`,optgroup:`HTMLOptGroupElement`,option:`HTMLOptionElement`,output:`HTMLOutputElement`,p:`HTMLParagraphElement`,picture:`HTMLPictureElement`,pre:`HTMLPreElement`,progress:`HTMLProgressElement`,q:`HTMLQuoteElement`,rp:`HTMLElement`,rt:`HTMLElement`,ruby:`HTMLElement`,s:`HTMLElement`,samp:`HTMLElement`,script:`HTMLScriptElement`,section:`HTMLElement`,select:`HTMLSelectElement`,slot:`HTMLSlotElement`,small:`HTMLElement`,source:`HTMLSourceElement`,span:`HTMLSpanElement`,strong:`HTMLElement`,style:`HTMLStyleElement`,sub:`HTMLElement`,summary:`HTMLElement`,sup:`HTMLElement`,table:`HTMLTableElement`,tbody:`HTMLTableSectionElement`,td:`HTMLTableCellElement`,template:`HTMLTemplateElement`,textarea:`HTMLTextAreaElement`,tfoot:`HTMLTableSectionElement`,th:`HTMLTableCellElement`,thead:`HTMLTableSectionElement`,time:`HTMLTimeElement`,title:`HTMLTitleElement`,tr:`HTMLTableRowElement`,track:`HTMLTrackElement`,u:`HTMLElement`,ul:`HTMLUListElement`,var:`HTMLElement`,video:`HTMLVideoElement`,wbr:`HTMLElement`,acronym:`HTMLElement`,applet:`HTMLUnknownElement`,basefont:`HTMLElement`,bgsound:`HTMLUnknownElement`,big:`HTMLElement`,blink:`HTMLUnknownElement`,center:`HTMLElement`,dir:`HTMLDirectoryElement`,font:`HTMLFontElement`,frame:`HTMLFrameElement`,frameset:`HTMLFrameSetElement`,isindex:`HTMLUnknownElement`,keygen:`HTMLUnknownElement`,listing:`HTMLPreElement`,marquee:`HTMLMarqueeElement`,menuitem:`HTMLElement`,multicol:`HTMLUnknownElement`,nextid:`HTMLUnknownElement`,nobr:`HTMLElement`,noembed:`HTMLElement`,noframes:`HTMLElement`,param:`HTMLParamElement`,plaintext:`HTMLElement`,rb:`HTMLElement`,rtc:`HTMLElement`,spacer:`HTMLUnknownElement`,strike:`HTMLElement`,tt:`HTMLElement`,xmp:`HTMLPreElement`,animate:`SVGAnimateElement`,animateMotion:`SVGAnimateMotionElement`,animateTransform:`SVGAnimateTransformElement`,circle:`SVGCircleElement`,clipPath:`SVGClipPathElement`,defs:`SVGDefsElement`,desc:`SVGDescElement`,ellipse:`SVGEllipseElement`,feBlend:`SVGFEBlendElement`,feColorMatrix:`SVGFEColorMatrixElement`,feComponentTransfer:`SVGFEComponentTransferElement`,feComposite:`SVGFECompositeElement`,feConvolveMatrix:`SVGFEConvolveMatrixElement`,feDiffuseLighting:`SVGFEDiffuseLightingElement`,feDisplacementMap:`SVGFEDisplacementMapElement`,feDistantLight:`SVGFEDistantLightElement`,feDropShadow:`SVGFEDropShadowElement`,feFlood:`SVGFEFloodElement`,feFuncA:`SVGFEFuncAElement`,feFuncB:`SVGFEFuncBElement`,feFuncG:`SVGFEFuncGElement`,feFuncR:`SVGFEFuncRElement`,feGaussianBlur:`SVGFEGaussianBlurElement`,feImage:`SVGFEImageElement`,feMerge:`SVGFEMergeElement`,feMergeNode:`SVGFEMergeNodeElement`,feMorphology:`SVGFEMorphologyElement`,feOffset:`SVGFEOffsetElement`,fePointLight:`SVGFEPointLightElement`,feSpecularLighting:`SVGFESpecularLightingElement`,feSpotLight:`SVGFESpotLightElement`,feTile:`SVGFETileElement`,feTurbulence:`SVGFETurbulenceElement`,filter:`SVGFilterElement`,foreignObject:`SVGForeignObjectElement`,g:`SVGGElement`,image:`SVGImageElement`,line:`SVGLineElement`,linearGradient:`SVGLinearGradientElement`,marker:`SVGMarkerElement`,mask:`SVGMaskElement`,metadata:`SVGMetadataElement`,mpath:`SVGMPathElement`,path:`SVGPathElement`,pattern:`SVGPatternElement`,polygon:`SVGPolygonElement`,polyline:`SVGPolylineElement`,radialGradient:`SVGRadialGradientElement`,rect:`SVGRectElement`,set:`SVGSetElement`,stop:`SVGStopElement`,svg:`SVGSVGElement`,switch:`SVGSwitchElement`,symbol:`SVGSymbolElement`,text:`SVGTextElement`,textPath:`SVGTextPathElement`,tspan:`SVGTSpanElement`,use:`SVGUseElement`,view:`SVGViewElement`},yi={for:"for(let ${1:i} = 0; ${1:i} < ${2:this.elements}; ${1:i}++) {\n ${3}\n}",forIn:"for(let ${1:index} in ${2:this.elements}) {\n ${3}\n}",forOf:"for(let ${1:element} of ${2:this.elements}) {\n ${3}\n}",if:`if(\${1:true}) {
|
|
546
|
+
`).trim()),o?.type&&(e.type=o.type),o?.default&&(e.defaultValue=o.default);let t=i,r=[],s=``;for(;t&&t.getChildren().length>0;){let e=t.getChildren(),n=t.getText();n&&n.startsWith(`--`)&&(n=n.split(`,`)[0],s!=n&&n!=a&&(s=n,r.push(n))),t=e[e.length-1]}let c=t.getText()??``;c&&(c.startsWith(`--`)||r.push(c)),r.length>0&&(e.chainValues=r,e.defaultValue??=e.chainValues[e.chainValues.length-1]),n[e.name]=e}}}}else if(e.hasChildren())for(let t of e.getChildren())i(t)},a=hi((0,ce.getSCSSLanguageService)().parseStylesheet(t),0);for(let e of a)i(e);return Object.values(n)}},_i=class e extends ut{compiledVersion=-1;usedBy={};dependencies={};diagnostics=[];diagnosticCompile;compiledTxt=``;namespace=``;_rules=new Map;customProperties=[];get compileResult(){return this.compiledTxt}get rules(){return this._rules}get htmlFile(){let e=this.build.htmlFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentView)];return e instanceof vi?e:null}get isGlobal(){return this.file.name.startsWith(`@`)}get globalName(){return this.file.name.replace(w.ComponentStyle,``)}constructor(e,t){super(e,t),this.namespace=this.build.getNamespace(e.uri)}async init(){await this.loadDependencies(),await this.compile(!1)}async onValidate(){return this.diagnostics=await this.build.scssLanguageService.doValidation(this.file),await this.loadDependencies(),this.diagnosticCompile?[...this.diagnostics,this.diagnosticCompile]:this.diagnostics}async onContentChange(){}async onSave(){await this.compileRoot()}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(e=!0){try{let t=this.compiledTxt,n=`|error|`,r=async e=>{let t=e.contentUser;t=t.replace(/\/\*[\s\S]*?@import[\s\S]*?\*\/|\/\/.*@import.*/g,``);let i=/@import *?('|")(\S*?)('|");?/g,a=null;for(;a=i.exec(t);){let i=a[2],o=await this.resolvePath(i,e.folderPath);if(o){let e=await r(o);if(e==n)return e;t=t.replace(a[0],e)}else return n}return t},i=await r(this.file);if(i!=`|error|`)try{this.customProperties=gi.getCustomProperty(i),i=i.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let e=(0,le.compileString)(i,{style:`compressed`}).css.toString().trim();e=e.replace(/\\/g,`\\\\`),t=e,this.diagnosticCompile&&(this.diagnosticCompile=void 0,$.sendDiagnostics({uri:this.file.uri,diagnostics:this.diagnostics},this.build))}catch(e){if(e instanceof le.Exception){this.diagnosticCompile=Ne(this.file.documentUser,e.message);let t=[...this.diagnostics,this.diagnosticCompile];$.sendDiagnostics({uri:this.file.uri,diagnostics:t},this.build)}else $.error(e)}if(t!=this.compiledTxt)if(this.compiledVersion++,this.compiledTxt=t,this.isGlobal)j.getInstance().updateGlobalCSS(this.globalName,this.compiledTxt),this.build.build();else{let t=this.build.tsFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentLogic)];if(t instanceof F&&e&&(t.canUpdateComponent=!1,await t.triggerSave(),t.compilationResult)){let e=this.namespace,n=t.fileParsed?.classes[t.compilationResult.componentName].namespace;n&&(e+=n),e.length>0&&!e.endsWith(`.`)&&(e+=`.`),j.getInstance().updateCSS(this.compiledTxt,e+t.compilationResult.componentName,[])}}this._rules=this.build.scssLanguageService.getRules(this.file);let a=this.build.htmlFiles[this.file.uri.replace(w.ComponentStyle,w.ComponentView)];a instanceof vi&&I.refreshStyle(a,this.build)}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()}async onCompletion(e,t){let n={isIncomplete:!1,items:[]};return n=await this.build.scssLanguageService.doComplete(e,t),n}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.build.scssLanguageService.doHover(e,t)}async onDefinition(e,t){return this.build.scssLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return this.build.scssLanguageService.format(e,t,n)}async onCodeAction(e,t){return this.build.scssLanguageService.doCodeAction(e,t)}async onReferences(e,t){let n=await this.build.scssLanguageService.onReferences(e,t);return n=[...n,...this.build.scssLanguageService.getLinkToHtml(this,t)],n}async onCodeLens(e){return[]}onGetBuild(){return[this.build]}async onRename(e,t,n){return null}async 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=await this.resolvePath(t,this.file.folderPath);if(n)await this.addDependency(n);else{let t=e.indexOf(r[0]),n=t+r[0].length;this.diagnostics.push(Pe(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])}async addDependency(t){this.build.scssFiles[t.uri]?(this.dependencies[t.uri]=this.build.scssFiles[t.uri],this.build.scssFiles[t.uri].usedBy[this.file.uri]=this):t.uri.endsWith(w.ComponentStyle)&&(this.build.scssFiles[t.uri]=new e(t,this.build),await this.build.scssFiles[t.uri].init(),this.dependencies[t.uri]=this.build.scssFiles[t.uri],this.build.scssFiles[t.uri].usedBy[this.file.uri]=this)}async getByPath(e){let t=R.getInstance().getByPath(e);if(t)return t;if((0,u.existsSync)(e)&&(0,u.lstatSync)(e).isFile()){let t=d.TextDocument.create(E(e),C.SCSS,1,(0,u.readFileSync)(e,`utf-8`));return await R.getInstance().registerFile(t),R.getInstance().getByPath(e)}}async resolvePath(e,t){e=this.build.project.resolveAlias(e,t),e=(0,f.normalize)(t+`/`+e);let n=await this.getByPath(e);if(n)return n;let r=e+w.ComponentStyle;if(n=await this.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=await this.getByPath(a),n)return n;let o=a+w.ComponentStyle;if(n=await this.getByPath(o),n)return n}},vi=class extends ut{fileParsed;tsErrors=[];version=-1;codeactions=[];get compiledVersion(){return this.version}get tsFile(){let e=this.build.tsFiles[this.file.uri.replace(w.ComponentView,w.ComponentLogic)];return e instanceof F?e:null}get scssFile(){let e=this.build.scssFiles[this.file.uri.replace(w.ComponentView,w.ComponentStyle)];return e instanceof _i?e:null}_slotsInfo;slotsInfoVersion=0;get slotsInfo(){return(this.slotsInfoVersion!=this.file.versionInternal||!this._slotsInfo)&&(this._slotsInfo=this.getSlotsInfo(),this.slotsInfoVersion=this.file.versionInternal),this._slotsInfo}constructor(e,t){super(e,t)}async init(){await this.refreshFileParsed()}refreshFileParsed(){this.fileParsed=I.parse(this,this.build);let e=I.getVersion(this);return this.version==e?!1:(this.version=e,this.file.validate(),!0)}async onValidate(){let e=await this.build.htmlLanguageService.doValidation(this.file);this.fileParsed&&(e=[...e,...this.fileParsed.errors]),e=[...e,...this.tsErrors],this.tsFile&&(e=[...e,...this.tsFile.htmlDiagnostics]),this.codeactions=[];let t=e=>{let t=this.file.documentUser.offsetAt(e.range.start),n=this.file.contentUser.slice(t-3,t-1),r=n==`.t`;if(n!=` t`&&n!=`.t`&&n!=`{t`)return;let i=this.file.documentUser.getText(e.range).slice(1,-1),a={title:`Add value into translation file`,command:{command:`aventus.i18n.add`,title:`Add value into translation file`,arguments:[this.file.uri,i,r]},diagnostics:[e],range:{start:t,end:this.file.documentUser.offsetAt(e.range.end)}};this.codeactions.push(a)};for(let n of e)(n.message.endsWith(`keyof AventusI18n'.`)||/Argument of type .*? is not assignable to parameter of type .*?\./.test(n.message))&&t(n);return e}async onContentChange(){await this.compile()}async onSave(){await this.tsFile?.triggerSave()}async compile(){try{this.refreshFileParsed()&&await this.tsFile?.validate()}catch(e){console.error(e)}}async onDelete(){}async onCompletion(e,t){return await this.tsFile?.doViewCompletion(t)||this.build.htmlLanguageService.doComplete(this,t)}async onCompletionResolve(e,t){return t}async getHover(e){return this.onHover(this.file,this.file.documentUser.positionAt(e))}async onHover(e,t){return await this.tsFile?.doHover(t)||await this.build.htmlLanguageService.doHover(this,t)}async onDefinition(e,t){return await this.tsFile?.doDefinition(t)||this.build.htmlLanguageService.onDefinition(this,t)}async onFormatting(e,t,n){await this.compile();let r=await this.applyJsFormatting(t,n);return this.applyHtmlFormatting(e,t,n,r)}async applyJsFormatting(e,t){let n=await this.tsFile?.doFormatting(e,t)??[];if(!this.fileParsed)return{};let r=new Map,i=new Map,a=new Map;for(let e of n)if(e.kind==`fct`)for(let t in this.fileParsed.fcts){let n=this.fileParsed.fcts[t];if(n.positions.find(t=>t.start==e.start&&t.end==e.end)){let t=r.get(n);t||(t=[],r.set(n,t)),t.push({start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText});break}}else if(e.kind==`loop`){for(let t of this.fileParsed.loops)if(t.start==e.start&&t.startBlock==e.end){let n=i.get(t);n||(n=[],i.set(t,n)),n.push({start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText})}}else if(e.kind==`if`){for(let t of this.fileParsed.ifs)for(let n of t.conditions)if(n.start==e.start&&n.end==e.end){let t=a.get(n);t||(t=[],a.set(n,t)),t.push({start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText})}}let o={};for(let[e,t]of r){let n=`{{`+e.txt+`}}`;o[n]=n,t.sort((e,t)=>t.end-e.end);for(let e of t)o[n]=o[n].slice(0,e.start)+e.txt+o[n].slice(e.end)}for(let[e,t]of i){let n=e.idTemplate,r=e.loopTxt;t.sort((e,t)=>t.end-e.end);for(let e of t)r=r.slice(0,e.start)+e.txt+r.slice(e.end);r=r.slice(0,r.length-1),o[`<`+ar.tagName+` id="`+n+`">`]=r}for(let e of this.fileParsed.loops)i.has(e)||(o[`<`+ar.tagName+` id="`+e.idTemplate+`">`]=e.loopTxt.slice(0,e.loopTxt.length-1));for(let[e,t]of a){let n=e.idTemplate,r=e.txt;t.sort((e,t)=>t.end-e.end);for(let e of t)r=r.slice(0,e.start)+e.txt+r.slice(e.end);e.type==`if`?r=`if(`+r+`) {`:e.type==`elif`&&(r=`else if(`+r+`) {`),o[`<`+or.tagName+` id="`+n+`">`]=r}for(let e of this.fileParsed.ifs){for(let t of e.conditions)if(!a.has(t)){let e=t.txt;t.type==`if`?e=`if(`+e+`) {`:t.type==`elif`&&(e=`else if(`+e+`) {`),o[`<`+or.tagName+` id="`+t.idTemplate+`">`]=e}e.conditions.length!=e.idsTemplate.length&&(o[`<`+or.tagName+` id="`+e.idsTemplate[e.idsTemplate.length-1]+`">`]=`else {`)}for(let e of this.fileParsed.contextEdits){let t=e.mapping.length>0?e.mapping[0]:``,n=e.mapping.length>1?e.mapping[1]:``,r=`@Context(`+t+`, `+n+`)`;o[`<`+sr.tagName+` id="`+e.id+`"></`+sr.tagName+`>`]=r}return o[`</`+ar.tagName+`>`]=`}`,o[`</`+or.tagName+`>`]=`}`,o}async applyHtmlFormatting(e,t,n,r){if(!this.fileParsed)return[];let i=this.fileParsed?.compiledTxt,a=d.TextDocument.create(e.documentUser.uri,e.documentUser.languageId,e.documentUser.version,i),o=(await this.build.htmlLanguageService.format(a,t,n))[0].newText;for(let e in r){let t=new RegExp(e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),`g`);o=o.replace(t,r[e])}return o=o.replace(/\{\{ *([^\n][\s|\S]*?) *\n?\}\}/g,`{{ $1 }}`),[{newText:o,range:{start:e.documentUser.positionAt(0),end:e.documentUser.positionAt(e.contentUser.length)}}]}async onCodeAction(e,t){let n=e.documentUser.offsetAt(t.start),r=e.documentUser.offsetAt(t.end);return this.codeactions.filter(e=>e.range.start<=n&&e.range.end>=r)}async onReferences(e,t){return await this.tsFile?.doReferences(t)||this.build.htmlLanguageService.getLinkToStyle(this,t)}async onCodeLens(e){return[]}onGetBuild(){return[this.build]}async onRename(e,t,n){return await this.tsFile?.doRename(t,n)||null}getSlotsInfo(){let e=this.tsFile?.fileParsed?.classes[this.tsFile.componentClassName]??null;return e?this.build.getSlotsInfo(e):{}}};const yi=[{name:`@element`,description:`Add a selector for the element inside your logical part`},{name:`@bind`,description:`Bind a watcher to a variable`},{name:`@press`,description:`Add an event for when the element is clicked`},{name:`@press-start`,description:`Add an event for when mouse down or touch start on the element`},{name:`@press-stop`,description:`Add an event for when mouse up or touch start on the element`},{name:`@longpress`,description:`Add an event for when the element is long pressed`},{name:`@longpress-delay`,description:`Add the delay for the long press`},{name:`@dblpress`,description:`Add an event for when the element is double press`},{name:`@dblpress-delay`,description:`Add the delay for the double press`},{name:`@drag`,description:`Add an event for when the element is dragged`},{name:`@drag-start`,description:`Add an event for when the element first drag`},{name:`@drag-end`,description:`Add an event for when the element drag end`}],bi={a:`HTMLAnchorElement`,abbr:`HTMLElement`,address:`HTMLElement`,area:`HTMLAreaElement`,article:`HTMLElement`,aside:`HTMLElement`,audio:`HTMLAudioElement`,b:`HTMLElement`,base:`HTMLBaseElement`,bdi:`HTMLElement`,bdo:`HTMLElement`,blockquote:`HTMLQuoteElement`,body:`HTMLBodyElement`,br:`HTMLBRElement`,button:`HTMLButtonElement`,canvas:`HTMLCanvasElement`,caption:`HTMLTableCaptionElement`,cite:`HTMLElement`,code:`HTMLElement`,col:`HTMLTableColElement`,colgroup:`HTMLTableColElement`,data:`HTMLDataElement`,datalist:`HTMLDataListElement`,dd:`HTMLElement`,del:`HTMLModElement`,details:`HTMLDetailsElement`,dfn:`HTMLElement`,dialog:`HTMLDialogElement`,div:`HTMLDivElement`,dl:`HTMLDListElement`,dt:`HTMLElement`,em:`HTMLElement`,embed:`HTMLEmbedElement`,fieldset:`HTMLFieldSetElement`,figcaption:`HTMLElement`,figure:`HTMLElement`,footer:`HTMLElement`,form:`HTMLFormElement`,h1:`HTMLHeadingElement`,h2:`HTMLHeadingElement`,h3:`HTMLHeadingElement`,h4:`HTMLHeadingElement`,h5:`HTMLHeadingElement`,h6:`HTMLHeadingElement`,head:`HTMLHeadElement`,header:`HTMLElement`,hgroup:`HTMLElement`,hr:`HTMLHRElement`,html:`HTMLHtmlElement`,i:`HTMLElement`,iframe:`HTMLIFrameElement`,img:`HTMLImageElement`,input:`HTMLInputElement`,ins:`HTMLModElement`,kbd:`HTMLElement`,label:`HTMLLabelElement`,legend:`HTMLLegendElement`,li:`HTMLLIElement`,link:`HTMLLinkElement`,main:`HTMLElement`,map:`HTMLMapElement`,mark:`HTMLElement`,menu:`HTMLMenuElement`,meta:`HTMLMetaElement`,meter:`HTMLMeterElement`,nav:`HTMLElement`,noscript:`HTMLElement`,object:`HTMLObjectElement`,ol:`HTMLOListElement`,optgroup:`HTMLOptGroupElement`,option:`HTMLOptionElement`,output:`HTMLOutputElement`,p:`HTMLParagraphElement`,picture:`HTMLPictureElement`,pre:`HTMLPreElement`,progress:`HTMLProgressElement`,q:`HTMLQuoteElement`,rp:`HTMLElement`,rt:`HTMLElement`,ruby:`HTMLElement`,s:`HTMLElement`,samp:`HTMLElement`,script:`HTMLScriptElement`,section:`HTMLElement`,select:`HTMLSelectElement`,slot:`HTMLSlotElement`,small:`HTMLElement`,source:`HTMLSourceElement`,span:`HTMLSpanElement`,strong:`HTMLElement`,style:`HTMLStyleElement`,sub:`HTMLElement`,summary:`HTMLElement`,sup:`HTMLElement`,table:`HTMLTableElement`,tbody:`HTMLTableSectionElement`,td:`HTMLTableCellElement`,template:`HTMLTemplateElement`,textarea:`HTMLTextAreaElement`,tfoot:`HTMLTableSectionElement`,th:`HTMLTableCellElement`,thead:`HTMLTableSectionElement`,time:`HTMLTimeElement`,title:`HTMLTitleElement`,tr:`HTMLTableRowElement`,track:`HTMLTrackElement`,u:`HTMLElement`,ul:`HTMLUListElement`,var:`HTMLElement`,video:`HTMLVideoElement`,wbr:`HTMLElement`,acronym:`HTMLElement`,applet:`HTMLUnknownElement`,basefont:`HTMLElement`,bgsound:`HTMLUnknownElement`,big:`HTMLElement`,blink:`HTMLUnknownElement`,center:`HTMLElement`,dir:`HTMLDirectoryElement`,font:`HTMLFontElement`,frame:`HTMLFrameElement`,frameset:`HTMLFrameSetElement`,isindex:`HTMLUnknownElement`,keygen:`HTMLUnknownElement`,listing:`HTMLPreElement`,marquee:`HTMLMarqueeElement`,menuitem:`HTMLElement`,multicol:`HTMLUnknownElement`,nextid:`HTMLUnknownElement`,nobr:`HTMLElement`,noembed:`HTMLElement`,noframes:`HTMLElement`,param:`HTMLParamElement`,plaintext:`HTMLElement`,rb:`HTMLElement`,rtc:`HTMLElement`,spacer:`HTMLUnknownElement`,strike:`HTMLElement`,tt:`HTMLElement`,xmp:`HTMLPreElement`,animate:`SVGAnimateElement`,animateMotion:`SVGAnimateMotionElement`,animateTransform:`SVGAnimateTransformElement`,circle:`SVGCircleElement`,clipPath:`SVGClipPathElement`,defs:`SVGDefsElement`,desc:`SVGDescElement`,ellipse:`SVGEllipseElement`,feBlend:`SVGFEBlendElement`,feColorMatrix:`SVGFEColorMatrixElement`,feComponentTransfer:`SVGFEComponentTransferElement`,feComposite:`SVGFECompositeElement`,feConvolveMatrix:`SVGFEConvolveMatrixElement`,feDiffuseLighting:`SVGFEDiffuseLightingElement`,feDisplacementMap:`SVGFEDisplacementMapElement`,feDistantLight:`SVGFEDistantLightElement`,feDropShadow:`SVGFEDropShadowElement`,feFlood:`SVGFEFloodElement`,feFuncA:`SVGFEFuncAElement`,feFuncB:`SVGFEFuncBElement`,feFuncG:`SVGFEFuncGElement`,feFuncR:`SVGFEFuncRElement`,feGaussianBlur:`SVGFEGaussianBlurElement`,feImage:`SVGFEImageElement`,feMerge:`SVGFEMergeElement`,feMergeNode:`SVGFEMergeNodeElement`,feMorphology:`SVGFEMorphologyElement`,feOffset:`SVGFEOffsetElement`,fePointLight:`SVGFEPointLightElement`,feSpecularLighting:`SVGFESpecularLightingElement`,feSpotLight:`SVGFESpotLightElement`,feTile:`SVGFETileElement`,feTurbulence:`SVGFETurbulenceElement`,filter:`SVGFilterElement`,foreignObject:`SVGForeignObjectElement`,g:`SVGGElement`,image:`SVGImageElement`,line:`SVGLineElement`,linearGradient:`SVGLinearGradientElement`,marker:`SVGMarkerElement`,mask:`SVGMaskElement`,metadata:`SVGMetadataElement`,mpath:`SVGMPathElement`,path:`SVGPathElement`,pattern:`SVGPatternElement`,polygon:`SVGPolygonElement`,polyline:`SVGPolylineElement`,radialGradient:`SVGRadialGradientElement`,rect:`SVGRectElement`,set:`SVGSetElement`,stop:`SVGStopElement`,svg:`SVGSVGElement`,switch:`SVGSwitchElement`,symbol:`SVGSymbolElement`,text:`SVGTextElement`,textPath:`SVGTextPathElement`,tspan:`SVGTSpanElement`,use:`SVGUseElement`,view:`SVGViewElement`},xi={for:"for(let ${1:i} = 0; ${1:i} < ${2:this.elements}; ${1:i}++) {\n ${3}\n}",forIn:"for(let ${1:index} in ${2:this.elements}) {\n ${3}\n}",forOf:"for(let ${1:element} of ${2:this.elements}) {\n ${3}\n}",if:`if(\${1:true}) {
|
|
546
547
|
\${2}
|
|
547
548
|
}`,"else if":`else if(\${1:true}) {
|
|
548
549
|
\${2}
|
|
549
550
|
}`,else:`else {
|
|
550
551
|
\${1}
|
|
551
|
-
}`,"@Context":"@Context('${1:element}', ${2:this.elements[i]})"};var
|
|
552
|
-
`)??``}};{let n=this.languageService.parseHTMLDocument(e.file.documentUser);if(n)return this.currentFile=void 0,this.languageService.doHover(e.file.documentUser,t,n)}return this.currentFile=void 0,null}async format(e,t,n){return this.languageService.format(e,t,n)}async onDefinition(e,t){this.currentFile=e;let n=this.getLinkToLogic(e,t);if(n instanceof rn||n instanceof on){let t=e.build.tsFiles[n._class.fileUri];return this.currentFile=void 0,[{uri:t.file.uri,range:{start:t.file.documentUser.positionAt(n.nameStart),end:t.file.documentUser.positionAt(n.nameEnd)}}]}else if(n instanceof un)return this.currentFile=void 0,[{uri:n.document.uri,range:{start:n.document.positionAt(n.nameStart),end:n.document.positionAt(n.nameEnd)}}];else return this.currentFile=void 0,this.build.htmlLanguageService.getLinkToStyle(e,t)}getLinkToLogic(e,t){let n=e.file.documentUser.offsetAt(t),r=e.tsFile,i=r?.fileParsed?.classes[r.getComponentName()];if(r&&i&&e.fileParsed){for(let t of e.fileParsed.interestPoints)if(n>=t.start&&n<=t.end){let r=null;if(t.type==`event`){let r=this.getTag(e,n);if(r){let n=e.build.getWebComponentDefinition(r.tagName);if(n){let e=n.class.getEvent(t.name);if(e)return e}}}if(t.type==`method`)r=i.methods[t.name];else if(t.type==`property`)r=i.properties[t.name];else if(t.type==`tag`){let n=this.documentationInfo[t.name];if(n){let t=this.internalDocumentationReverse[n.class];if(t&&t.fileParsed){for(let e in t.fileParsed.classes)if(e==n.class)return t.fileParsed.classes[e]}let r=e.build.getWebComponentDefinition(n.name,!0);if(r)return r.class}}return r}else if(t.end>=n)return null}return null}getLinkToStyle(e,t){let n=[],r=e.file.documentUser.offsetAt(t),i=e.scssFile;if(i&&e.fileParsed)for(let t of e.fileParsed.styleLinks){let e=t[0];r>=e.start&&r<=e.end&&n.push({uri:i.file.uri,range:{start:i.file.documentUser.positionAt(t[1].start),end:i.file.documentUser.positionAt(t[1].end)}})}return n}allowRebuildDefinition(e){this._allowRebuildDefinition=e,this.rebuildDefinition()}rebuildDefinition(){if(!this._allowRebuildDefinition)return;this.documentationInfo={};for(let e in this.extenalDocumentation){let t=this.extenalDocumentation[e];this.documentationInfo={...this.documentationInfo,...t}}for(let e in this.internalDocumentation){let t=this.internalDocumentation[e];try{this.documentationInfo={...this.documentationInfo,...t}}catch{}}this.customTagsData=[{name:`block`,attributes:[{name:`name`}]}];let e=[];for(let t in this.documentationInfo){let n=this.documentationInfo[t];if(e.indexOf(n.name)==-1){e.push(n.name);let t=[],r={name:n.name,description:n.description,attributes:t};for(let e in n.attributes){let r=n.attributes[e];t.push({name:r.name,description:r.description,values:r.values})}this.customTagsData.push(r)}}}addExternalDefinition(e,t){this.extenalDocumentation[e]=t,this.rebuildDefinition()}removeExternalDefinition(e){delete this.extenalDocumentation[e],this.rebuildDefinition()}getInternalDefinition(e){let t=this.documentationInfo[e];if(t)return this.internalDocumentationReverse[t.class]}addInternalDefinition(e,t,n){this.internalDocumentation[e]=t;for(let e in t)this.internalDocumentationReverse[t[e].class]=n;this.rebuildDefinition()}removeInternalDefinition(e){let t=this.internalDocumentation[e];if(t)for(let e in t)delete this.internalDocumentationReverse[t[e].class];delete this.internalDocumentation[e],this.rebuildDefinition()}getInternalTagUri(e){return this.internalTagUri[e]}addInternalTagUri(e,t,n){this.internalTagUri[e]={uri:t,fullname:n}}removeInternalTagUri(e){for(let t in this.internalTagUri)if(this.internalTagUri[t].uri==e){delete this.internalTagUri[t];return}}};function xi(e){let t=``,n=[],r=r=>{for(let i of r){let r=wn.compileTs(i,e);e.build.addNamespace(i.namespace),n.push(r),t+=r.debugTxt}};e.fileParsed&&(r(Object.values(e.fileParsed.classes)),r(Object.values(e.fileParsed.enums)),r(Object.values(e.fileParsed.aliases)),r(Object.values(e.fileParsed.functions)),r(Object.values(e.fileParsed.variables)));let i=e.file.path.replace(`.avt`,`.js`);return t==``?(0,u.existsSync)(i)&&(0,u.unlinkSync)(i):(0,u.writeFileSync)(i,t),n}var Si=class extends hn{get extension(){return 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(O(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(O(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(O(e,`Missing static property Fullname`,r.nameStart,r.nameEnd,1022))}}return this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return await this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Ci=class extends hn{get extension(){return 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)}},wi=class extends hn{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(O(this.file.documentUser,`Missing static property ${e.convertibleName}`,e.nameStart,e.nameEnd,1022)))}]}),this.diagnostics=this.diagnostics.concat(this.getDeprecated()),this.diagnostics}async onContentChange(){this.refreshFileParsed()}async onSave(){this.setCompileResult(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}onFormatting(e,t,n){return this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Ti=class extends hn{get extension(){return 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(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}onFormatting(e,t,n){return this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Ei=class extends hn{get extension(){return 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(xi(this))}onCompletion(e,t){return this.tsLanguageService.doComplete(e,t)}onCompletionResolve(e,t){return this.tsLanguageService.doResolve(t)}onHover(e,t){return this.tsLanguageService.doHover(e,t)}onDefinition(e,t){return this.tsLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return await this.tsLanguageService.format(e,t,n)}onCodeAction(e,t){return this.tsLanguageService.doCodeAction(e,t)}onReferences(e,t){return this.tsLanguageService.onReferences(e,t)}onCodeLens(e){return this.tsLanguageService.onCodeLens(e)}async onRename(e,t,n){return this.tsLanguageService.onRename(e,t,n)}},Di=class extends hn{get extension(){return 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=Ye(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 Oi(e,t){let n=null;return e.uri.endsWith(w.ComponentLogic)?n=new F(e,t):e.uri.endsWith(w.Data)?n=new Si(e,t):e.uri.endsWith(w.Lib)?n=new wi(e,t):e.uri.endsWith(w.RAM)?n=new Ti(e,t):e.uri.endsWith(w.State)?n=new Ei(e,t):e.uri.endsWith(w.Static)?n=new Di(e,t):e.uri.endsWith(w.Definition)&&(n=new Ci(e,t)),n}var ki=class{static send(e,t){$.sendNotification(`aventus/compiled`,e,t)}static part(e){$.sendNotification(`aventus/compiled/part`,e)}},Ai=class{static send(e,t){$.sendNotification(`aventus/registerBuild`,{pathConfig:e,buildName:t})}},ji=class{static send(e,t){$.sendNotification(`aventus/unregisterBuild`,{pathConfig:e,buildName:t})}},Mi=o(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r(require("child_process"),require("crypto")):typeof define==`function`&&define.amd?define([`child_process`,`crypto`],r):typeof e==`object`?e["electron-machine-id"]=r(require("child_process"),require("crypto")):n[`electron-machine-id`]=r(n.child_process,n.crypto)})(e,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p=``,t(0)}([function(e,t,n){e.exports=n(34)},function(e,t,n){var r=n(29)(`wks`),i=n(33),a=n(2).Symbol,o=typeof a==`function`,s=e.exports=function(e){return r[e]||(r[e]=o&&a[e]||(o?a:i)(`Symbol.`+e))};s.store=r},function(e,t){var n=e.exports=typeof window<`u`&&window.Math==Math?window:typeof self<`u`&&self.Math==Math?self:Function(`return this`)();typeof __g==`number`&&(__g=n)},function(e,t,n){var r=n(9);e.exports=function(e){if(!r(e))throw TypeError(e+` is not an object!`);return e}},function(e,t,n){e.exports=!n(24)(function(){return Object.defineProperty({},"a",{get:function(){return 7}}).a!=7})},function(e,t,n){var r=n(12),i=n(17);e.exports=n(4)?function(e,t,n){return r.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},function(e,t){var n=e.exports={version:`2.4.0`};typeof __e==`number`&&(__e=n)},function(e,t,n){var r=n(14);e.exports=function(e,t,n){if(r(e),t===void 0)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}}},function(e,t){var n={}.hasOwnProperty;e.exports=function(e,t){return n.call(e,t)}},function(e,t){e.exports=function(e){return typeof e==`object`?e!==null:typeof e==`function`}},function(e,t){e.exports={}},function(e,t){var n={}.toString;e.exports=function(e){return n.call(e).slice(8,-1)}},function(e,t,n){var r=n(3),i=n(26),a=n(32),o=Object.defineProperty;t.f=n(4)?Object.defineProperty:function(e,t,n){if(r(e),t=a(t,!0),r(n),i)try{return o(e,t,n)}catch{}if(`get`in n||`set`in n)throw TypeError(`Accessors not supported!`);return`value`in n&&(e[t]=n.value),e}},function(e,t,n){var r=n(42),i=n(15);e.exports=function(e){return r(i(e))}},function(e,t){e.exports=function(e){if(typeof e!=`function`)throw TypeError(e+` is not a function!`);return e}},function(e,t){e.exports=function(e){if(e==null)throw TypeError(`Can't call method on `+e);return e}},function(e,t,n){var r=n(9),i=n(2).document,a=r(i)&&r(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,n){var r=n(12).f,i=n(8),a=n(1)(`toStringTag`);e.exports=function(e,t,n){e&&!i(e=n?e:e.prototype,a)&&r(e,a,{configurable:!0,value:t})}},function(e,t,n){var r=n(29)(`keys`),i=n(33);e.exports=function(e){return r[e]||(r[e]=i(e))}},function(e,t){var n=Math.ceil,r=Math.floor;e.exports=function(e){return isNaN(e=+e)?0:(e>0?r:n)(e)}},function(e,t,n){var r=n(11),i=n(1)(`toStringTag`),a=r(function(){return arguments}())==`Arguments`,o=function(e,t){try{return e[t]}catch{}};e.exports=function(e){var t,n,s;return e===void 0?`Undefined`:e===null?`Null`:typeof(n=o(t=Object(e),i))==`string`?n:a?r(t):(s=r(t))==`Object`&&typeof t.callee==`function`?`Arguments`:s}},function(e,t){e.exports=`constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf`.split(`,`)},function(e,t,n){var r=n(2),i=n(6),a=n(7),o=n(5),s=`prototype`,c=function(e,t,n){var l,u,d,f=e&c.F,p=e&c.G,m=e&c.S,h=e&c.P,g=e&c.B,_=e&c.W,v=p?i:i[t]||(i[t]={}),y=v[s],b=p?r:m?r[t]:(r[t]||{})[s];for(l in p&&(n=t),n)u=!f&&b&&b[l]!==void 0,u&&l in v||(d=u?b[l]:n[l],v[l]=p&&typeof b[l]!=`function`?n[l]:g&&u?a(d,r):_&&b[l]==d?function(e){var t=function(t,n,r){if(this instanceof e){switch(arguments.length){case 0:return new e;case 1:return new e(t);case 2:return new e(t,n)}return new e(t,n,r)}return e.apply(this,arguments)};return t[s]=e[s],t}(d):h&&typeof d==`function`?a(Function.call,d):d,h&&((v.virtual||={})[l]=d,e&c.R&&y&&!y[l]&&o(y,l,d)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,e.exports=c},function(e,t){e.exports=function(e){try{return!!e()}catch{return!0}}},function(e,t,n){e.exports=n(2).document&&document.documentElement},function(e,t,n){e.exports=!n(4)&&!n(24)(function(){return Object.defineProperty(n(16)(`div`),"a",{get:function(){return 7}}).a!=7})},function(e,t,n){"use strict";var r=n(28),i=n(23),a=n(57),o=n(5),s=n(8),c=n(10),l=n(45),u=n(18),d=n(52),f=n(1)(`iterator`),p=!([].keys&&`next`in[].keys()),m=`@@iterator`,h=`keys`,g=`values`,_=function(){return this};e.exports=function(e,t,n,v,y,b,x){l(n,t,v);var ee,te,ne,re=function(e){if(!p&&e in S)return S[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)}},ie=t+` Iterator`,ae=y==g,oe=!1,S=e.prototype,se=S[f]||S[m]||y&&S[y],ce=se||re(y),le=y?ae?re(`entries`):ce:void 0,ue=t==`Array`&&S.entries||se;if(ue&&(ne=d(ue.call(new e)),ne!==Object.prototype&&(u(ne,ie,!0),r||s(ne,f)||o(ne,f,_))),ae&&se&&se.name!==g&&(oe=!0,ce=function(){return se.call(this)}),r&&!x||!p&&!oe&&S[f]||o(S,f,ce),c[t]=ce,c[ie]=_,y)if(ee={values:ae?ce:re(g),keys:b?ce:re(h),entries:le},x)for(te in ee)te in S||a(S,te,ee[te]);else i(i.P+i.F*(p||oe),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(`
|
|
553
|
-
`)[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{}}(),re=function(e,t){return e===t||e===x&&t===a},ie=function(e){var t;return!(!d(e)||typeof(t=e.then)!=`function`)&&t},ae=function(e){return re(x,e)?new oe(e):new i(e)},oe=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)},S=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=ie(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=S(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=ie(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=ae(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)}}),oe=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=ae(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!ne),v,{resolve:function(e){if(e instanceof x&&re(e.constructor,this))return e;var t=ae(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=ae(t),r=n.resolve,i=n.reject,a=S(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=ae(t),r=n.reject,i=S(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||=T.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};T.getInstance().setHiddenSettings({store:t}),this._settings=t}static async connect(e,t){let n=await(0,Mi.machineId)(),r=(0,fe.hostname)(),i=await this.post(`/login`,{username:e,password:t,machineId:n,machineName:r},{withoutBearer:!0});return i?(this.setSettings({token:i,username:e}),!0):!1}static async disconnect(){await this.post(`/logout`),this.setSettings({token:``,username:void 0})}static async publishPackage(e){let t=new FormData;t.append(`name`,e.buildConfig.fullname),t.append(`description`,e.buildConfig.description??``),t.append(`version`,e.buildConfig.version),e.buildConfig.organization&&t.append(`organization`,e.buildConfig.organization),e.buildConfig.documentation&&t.append(`documentation`,e.buildConfig.documentation),e.buildConfig.repository&&t.append(`repository`,e.buildConfig.repository);for(let n of e.buildConfig.tags)t.append(`tags[]`,n);let n=(0,f.join)(Ri.getInstance().getPath(),`@locals`,e.buildConfig.fullname+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 Pi([{code:-1,message:`Readme not found`}])}else if((0,u.existsSync)(e.buildConfig.readme))n=e.buildConfig.readme;else{let t=(0,f.normalize)((0,f.join)(i,e.buildConfig.readme));if((0,u.existsSync)(t))n=t;else return new Pi([{code:-1,message:`Readme not found`}])}let r=new Blob([(0,u.readFileSync)((0,f.join)(i,n))],{type:`text/plain`});t.append(`readMe`,r,`README.md`)}else{let e=(0,u.readdirSync)(i).find(e=>e.toLowerCase()===`readme.md`);if(e){let n=new Blob([(0,u.readFileSync)((0,f.join)(i,e))],{type:`text/plain`});t.append(`readMe`,n,`README.md`)}}return await this.postWithErrors(`/package/publish`,t)}static async publishTemplate(e){let t=new FormData;t.append(`name`,e.name),t.append(`description`,e.description),t.append(`version`,e.version),t.append(`is_project`,e.isProject?`1`:`0`),t.append(`is_global`,e.isGlobal?`1`:`0`),e.organization&&t.append(`organization`,e.organization),e.documentation&&t.append(`documentation`,e.documentation),e.repository&&t.append(`repository`,e.repository);for(let n of e.tags)t.append(`tags[]`,n);let n=e.folderPath,r=(0,u.readdirSync)(n).find(e=>e.toLowerCase()===`readme.md`);if(r){let e=new Blob([(0,u.readFileSync)((0,f.join)(n,r))],{type:`text/plain`});t.append(`readMe`,e,`README.md`)}let i=(0,f.dirname)(e.config),a=(0,f.join)($.savePath,`temp`,e.name+`.zip`);await this.zip(i,a);let o=new Blob([(0,u.readFileSync)(a)],{type:`application/zip`});t.append(`templateFile`,o,e.name+`.zip`);let s=await this.postWithErrors(`/template/publish`,t);return(0,u.unlinkSync)(a),s}static async post(e,t={},n){let r=await this.postWithErrors(e,t,n);if(r instanceof Pi){for(let e of r.errors)$.error(e.message);return null}return r}static async postWithErrors(t,n={},r){let i=null;try{let a={};if(n instanceof FormData||(a[`Content-Type`]=`application/json`),!r?.withoutBearer){let e=await(0,Mi.machineId)();a.Authorization=`Bearer `+(this.token+`|`+e)}if(i=await fetch(e.url+`/api/remote`+t,{method:`POST`,body:n instanceof FormData?n:JSON.stringify(n),headers:a}),i.status==401)return new Pi([{code:401,message:`No token provided`}]);if(i.status==403)return t!=`/logout`&&this.disconnect(),new Pi([{code:403,message:`You must connect to your account first`}]);let o=await i.text(),s;try{s=JSON.parse(o)}catch(e){throw $.error(o),e}return s.errors?s.errors.length>0?new Pi(s.errors):s.result:new Pi([{code:-500,message:`Wrong response format from the api`}])}catch(e){return new Pi([{code:-500,message:e+``}])}}static zip(e,t){return new Promise(async(n,r)=>{let i=(0,u.createWriteStream)(t),a=(0,pe.create)(`zip`,{zlib:{level:9}});i.on(`close`,()=>{n()}),a.on(`error`,e=>{r(e)}),a.pipe(i),a.directory(e,!1,e=>e.name.startsWith(`.git/`)||e.name===`.git`?!1:e),await a.finalize()})}},Pi=class{errors;constructor(e){this.errors=e}},Fi=class e{fctTxt=null;static is(t){return t.name==`Attribute`?new e:null}},Ii=class{static files={};static done=!1;static register(e){this.files[e.file.uri]||(this.files[e.file.uri]=e,this.done&&this.write())}static write(e=!1){let t={html:{snippets:{block:'<block name="${1}">${2}</block>'}}},n=!1;for(let e in this.files){let r=this.files[e].srcInfo.available;for(let e of r)if(e.tagName){let r=e.tagName;t.html.snippets[r]=`<${r}>\${1}</${r}>`,n=!0}}if(n){let n=(0,f.join)(D($.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}),Je(r,JSON.stringify(t,null,2),`manifest`),this.done=!0}}static getMarkdown(e){return this.files[e]?new Li(this.files[e]).getContent():``}},Li=class{file;content=[];overviews=[];parts=[];scss;constructor(e){this.file=e,this.scss=e.build.scssLanguageService.getExternalDefinition(this.file.file.uri)??{};let t=this.file.srcInfo.available;if(this.file.fileParsed)for(let e of t)e.type==1||e.type==2||e.type==3?this.loadClass(e):e.type==4&&this.loadFunction(e);this.overviews.length>0&&(this.writeOverview(),this.writeContent())}isManifestClass(e){return e.isWebComponent!==void 0}isManifestFunction(e){return e.result!==void 0}getType(e){e instanceof M||(e=new M(e));let t=e.getFullTxt().trim();return t.startsWith(`___`)&&(t=t.substring(3)),t=t.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\|/g,`|`),t}loadFunction(e){let t=this.file.fileParsed.functions[e.fullName],n=t.fullName;if(t.node.typeParameters){let e=[];for(let n of t.node.typeParameters){let t=n.name.getText();n.constraint&&(t+=` extends `+this.getType(n.constraint)),n.default&&(t+=` = `+this.getType(n.default)),e.push(t)}e.length>0&&(n+=`<${e.join(`, `)}>`)}let r=[];for(let e of t.node.parameters){let t=e.name.getText();e.type?t+=`: `+this.getType(e.type):t+=`: any`,r.push(t)}n+=`(${r.join(`, `)})`;let i={name:n,result:t.node.type?this.getType(t.node.type):`any`,description:t.documentation?.definitions.join(`
|
|
552
|
+
}`,"@Context":"@Context('${1:element}', ${2:this.elements[i]})"};var Si=class{languageService;id=0;isAutoComplete=!1;customTagsData=[];documentationInfo={};extenalDocumentation={};internalDocumentation={};internalDocumentationReverse={};internalTagUri={};_allowRebuildDefinition=!0;build;constructor(e){this.build=e,this.languageService=this.getHTMLLanguageService(),T.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 bi[e]?bi[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=T.getInstance().settingsHtml,t=[];for(let n of e.customData){let e=(0,f.normalize)(D($.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=[...yi],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=Be(r,Ge(r.getText(),i)),o=r.getText().slice(r.offsetAt(a.start),r.offsetAt(a.end));for(let e in xi)e.startsWith(o)&&n.push({label:e,kind:m.CompletionItemKind.Snippet,insertText:xi[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(`
|
|
553
|
+
`)??``}};{let n=this.languageService.parseHTMLDocument(e.file.documentUser);if(n)return this.currentFile=void 0,this.languageService.doHover(e.file.documentUser,t,n)}return this.currentFile=void 0,null}async format(e,t,n){return this.languageService.format(e,t,n)}async onDefinition(e,t){this.currentFile=e;let n=this.getLinkToLogic(e,t);if(n instanceof on||n instanceof cn){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 fn)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 Ci(e){let t=``,n=[],r=r=>{for(let i of r){let r=En.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)&&Ze(i):(0,u.writeFileSync)(i,t),n}var wi=class extends _n{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(O(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(O(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(O(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(Ci(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)}},Ti=class extends _n{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)}},Ei=class extends _n{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(O(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(Ci(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)}},Di=class extends _n{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(Ci(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)}},Oi=class extends _n{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(Ci(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)}},ki=class extends _n{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=Xe(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 Ai(e,t){let n=null;return e.uri.endsWith(w.ComponentLogic)?n=new F(e,t):e.uri.endsWith(w.Data)?n=new wi(e,t):e.uri.endsWith(w.Lib)?n=new Ei(e,t):e.uri.endsWith(w.RAM)?n=new Di(e,t):e.uri.endsWith(w.State)?n=new Oi(e,t):e.uri.endsWith(w.Static)?n=new ki(e,t):e.uri.endsWith(w.Definition)&&(n=new Ti(e,t)),n}var ji=class{static send(e,t){$.sendNotification(`aventus/compiled`,e,t)}static part(e){$.sendNotification(`aventus/compiled/part`,e)}},Mi=class{static send(e,t){$.sendNotification(`aventus/registerBuild`,{pathConfig:e,buildName:t})}},Ni=class{static send(e,t){$.sendNotification(`aventus/unregisterBuild`,{pathConfig:e,buildName:t})}},Pi=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,re=function(e){if(!p&&e in S)return S[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)}},ie=t+` Iterator`,ae=y==g,oe=!1,S=e.prototype,se=S[f]||S[m]||y&&S[y],ce=se||re(y),le=y?ae?re(`entries`):ce:void 0,ue=t==`Array`&&S.entries||se;if(ue&&(ne=d(ue.call(new e)),ne!==Object.prototype&&(u(ne,ie,!0),r||s(ne,f)||o(ne,f,_))),ae&&se&&se.name!==g&&(oe=!0,ce=function(){return se.call(this)}),r&&!x||!p&&!oe&&S[f]||o(S,f,ce),c[t]=ce,c[ie]=_,y)if(ee={values:ae?ce:re(g),keys:b?ce:re(h),entries:le},x)for(te in ee)te in S||a(S,te,ee[te]);else i(i.P+i.F*(p||oe),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(`
|
|
554
|
+
`)[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{}}(),re=function(e,t){return e===t||e===x&&t===a},ie=function(e){var t;return!(!d(e)||typeof(t=e.then)!=`function`)&&t},ae=function(e){return re(x,e)?new oe(e):new i(e)},oe=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)},S=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=ie(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=S(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=ie(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=ae(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)}}),oe=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=ae(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!ne),v,{resolve:function(e){if(e instanceof x&&re(e.constructor,this))return e;var t=ae(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=ae(t),r=n.resolve,i=n.reject,a=S(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=ae(t),r=n.reject,i=S(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")}])})}))(),Fi=class e{static url=`https://store.aventusjs.com`;static _settings;static get settings(){return this._settings||=T.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};T.getInstance().setHiddenSettings({store:t}),this._settings=t}static async connect(e,t){let n=await(0,Pi.machineId)(),r=(0,fe.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)(Bi.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 Ii([{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 Ii([{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 Ze(a),s}static async post(e,t={},n){let r=await this.postWithErrors(e,t,n);if(r instanceof Ii){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,Pi.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 Ii([{code:401,message:`No token provided`}]);if(i.status==403)return t!=`/logout`&&this.disconnect(),new Ii([{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 Ii(s.errors):s.result:new Ii([{code:-500,message:`Wrong response format from the api`}])}catch(e){return new Ii([{code:-500,message:e+``}])}}static zip(e,t){return new Promise(async(n,r)=>{let i=(0,u.createWriteStream)(t),a=(0,pe.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()})}},Ii=class{errors;constructor(e){this.errors=e}},Li=class e{fctTxt=null;static is(t){return t.name==`Attribute`?new e:null}},Ri=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)(D($.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}),Ye(r,JSON.stringify(t,null,2),`manifest`),this.done=!0}}static getMarkdown(e){return this.files[e]?new zi(this.files[e]).getContent():``}},zi=class{file;content=[];overviews=[];parts=[];scss;constructor(e){this.file=e,this.scss=e.build.scssLanguageService.getExternalDefinition(this.file.file.uri)??{};let t=this.file.srcInfo.available;if(this.file.fileParsed)for(let e of t)e.type==1||e.type==2||e.type==3?this.loadClass(e):e.type==4&&this.loadFunction(e);this.overviews.length>0&&(this.writeOverview(),this.writeContent())}isManifestClass(e){return e.isWebComponent!==void 0}isManifestFunction(e){return e.result!==void 0}getType(e){e instanceof M||(e=new M(e));let t=e.getFullTxt().trim();return t.startsWith(`___`)&&(t=t.substring(3)),t=t.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\|/g,`|`),t}loadFunction(e){let t=this.file.fileParsed.functions[e.fullName],n=t.fullName;if(t.node.typeParameters){let e=[];for(let n of t.node.typeParameters){let t=n.name.getText();n.constraint&&(t+=` extends `+this.getType(n.constraint)),n.default&&(t+=` = `+this.getType(n.default)),e.push(t)}e.length>0&&(n+=`<${e.join(`, `)}>`)}let r=[];for(let e of t.node.parameters){let t=e.name.getText();e.type?t+=`: `+this.getType(e.type):t+=`: any`,r.push(t)}n+=`(${r.join(`, `)})`;let i={name:n,result:t.node.type?this.getType(t.node.type):`any`,description:t.documentation?.definitions.join(`
|
|
554
555
|
`)??``,isAbstract:!1};this.parts.push(i)}loadClass(e){let t=this.file.fileParsed.classes[e.fullName],n=t.fullName;if(t.node.typeParameters){let e=[];for(let n of t.node.typeParameters){let t=n.name.getText();n.constraint&&(t+=` extends `+this.getType(n.constraint)),n.default&&(t+=` = `+this.getType(n.default)),e.push(t)}e.length>0&&(n+=`<${e.join(`, `)}>`)}let r={name:n,isWebComponent:t.isWebcomponent,tag:e.tagName?`<${e.tagName}></${e.tagName}>`:void 0,type:t.isInterface?`Interface`:`Class`,description:t.documentation?.definitions.join(`
|
|
555
|
-
`)??``,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=>
|
|
556
|
+
`)??``,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=>Rn.is(e))&&(t=`@Property()`),e.decorators.find(e=>Li.is(e))&&(t=`@Attribute()`),e.decorators.find(e=>Wn.is(e))&&(t=`@Watch()`),e.decorators.find(e=>Xn.is(e))&&(t=`@Signal()`),{name:e.name,type:this.getType(e.type),description:e.documentation?.definitions.join(`
|
|
556
557
|
`)??``,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(`
|
|
557
558
|
`)??``,isAbstract:e.isAbstract}}getContent(){return this.content.join(`
|
|
558
|
-
`)}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)}},
|
|
559
|
-
`),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}},
|
|
559
|
+
`)}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)}},Bi=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":Dt(),"Aventus@UI":Ot(),"Aventus@Sharp":At(),"Aventus@Php":jt(),"Aventus@I18n":kt()};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=E(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=E(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)}Ri.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=E((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,Fi.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=E(c),d=await R.getInstance().registerFilePackage(l);return{uri:l,file:this.loadPackage(d,n)}}extractZip(e,t){return new Promise(n=>{let r=!1,i=e=>{r||(r=!0,n(e))},a=(0,u.createReadStream)(e),o=(0,de.Extract)({path:t});a.on(`error`,t=>{console.error(`Can't read ZIP "${e}":`,t),i(!1)}),o.on(`close`,()=>i(!0)),o.on(`error`,t=>{console.error(`Can't extract ZIP "${e}":`,t),(t+``).includes(`Error: invalid signature: 0x4f44213c`)&&console.log((0,u.readFileSync)(e,`utf8`)),i(!1)}),a.pipe(o)})}findPackage(e){let t=null,n=(0,u.readdirSync)(e);for(let r of n)if(r.endsWith(w.Package)){t=(0,f.join)(e,r);break}return t}loadPackage(e,t){let n=Cn.getQuickInfo(e);if(n)return this.loadedPackages[n.name]=new Cn(e,t),this.loadedPackages[n.name]}downloadFile(e,t){return new Promise(n=>{let r=()=>{try{(0,u.existsSync)(e)&&Ze(e)}catch{}};(t.startsWith(`https:`)?ue.get:ne.get)(t,i=>{let a=i.statusCode??0;if(a>=300&&a<400&&i.headers.location){i.resume(),this.downloadFile(e,i.headers.location).then(n).catch(()=>n(!1));return}if(a<200||a>=300){console.error(`Download failed: HTTP ${a} for ${t}`),i.resume(),r(),n(!1);return}let o=(0,u.createWriteStream)(e);o.on(`error`,t=>{console.error(`File write error for ${e}:`,t),i.destroy(),r(),n(!1)}),i.on(`error`,e=>{console.error(`HTTP response error for ${t}:`,e),o.destroy(),r(),n(!1)}),o.on(`finish`,()=>{o.close(t=>{if(t){console.error(`File close error for ${e}:`,t),r(),n(!1);return}n(!0)})}),i.pipe(o)}).on(`error`,e=>{console.error(`HTTP request error for ${t}:`,e),r(),n(!1)})})}readFirstLine(e){return new Promise(function(t,n){var r=(0,u.createReadStream)(e,{encoding:`utf8`}),i=``,a=0,o;r.on(`data`,function(e){o=e.indexOf(`
|
|
560
|
+
`),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}},Vi=class{static send(e,t){$.sendNotification(`aventus/addDebugFile`,e,t)}},Hi=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:Xe(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&&(ji.part(`Compiling node modules`),this.lastInfoToCompile=t.buildTxt,this.npmDepBuildTxt=await this.esbuildBuild(this.lastInfoToCompile),ji.part(`Compiling node modules done`)),this.npmBuildTxt=`var npmCompilation;
|
|
560
561
|
`,this.npmBuildTxt+=`(npmCompilation||(npmCompilation = {}));
|
|
561
562
|
`,this.npmBuildTxt+=`(function (npmCompilation) {
|
|
562
563
|
${this.npmDepBuildTxt.result+`
|
|
@@ -569,37 +570,37 @@ protected ${t}(){
|
|
|
569
570
|
`;for(let e in r.part)for(let n of r.part[e].externalAlias)t+=`npmCompilation['${r.md5}']['${n}'] = _.default['${r.all.internalAlias}'];
|
|
570
571
|
`}else{let a=[],o=Object.keys(r.part);o.sort();for(let e of o){a.push(`${e} as ${r.part[e].internalAlias}`),n.push(r.part[e].internalAlias);for(let n of r.part[e].externalAlias)t+=`npmCompilation['${r.md5}']['${n}'] = _.default['${r.part[e].internalAlias}'];
|
|
571
572
|
`}e+=`import {${Object.values(a).join(`, `)}} from "${i}";
|
|
572
|
-
`}}return e+=`export default { ${n.join(`, `)} }`,{buildTxt:e,toExport:t}}async esbuildBuild(e){let t={result:``,errors:[]};try{let n=(0,f.dirname)(this.build.nodeModulesDir),r=this.getPotentialNodeModulesPaths(n);t.result=(await(0,he.build)({stdin:{contents:e,resolveDir:n,sourcefile:`index.js`},bundle:!0,format:`iife`,globalName:`_`,nodePaths:r,minify:!0,define:{"process.env.NODE_ENV":`"production"`},legalComments:`none`,write:!1})).outputFiles?.[0].text||``}catch(e){let n=this.build.fullname+`_npmErrors`,r=(e+``).replace(/\0/g,``);
|
|
573
|
+
`}}return e+=`export default { ${n.join(`, `)} }`,{buildTxt:e,toExport:t}}async esbuildBuild(e){let t={result:``,errors:[]};try{let n=(0,f.dirname)(this.build.nodeModulesDir),r=this.getPotentialNodeModulesPaths(n);t.result=(await(0,he.build)({stdin:{contents:e,resolveDir:n,sourcefile:`index.js`},bundle:!0,format:`iife`,globalName:`_`,nodePaths:r,minify:!0,define:{"process.env.NODE_ENV":`"production"`},legalComments:`none`,write:!1})).outputFiles?.[0].text||``}catch(e){let n=this.build.fullname+`_npmErrors`,r=(e+``).replace(/\0/g,``);Vi.send(n,r),t.errors.push({title:`Npm compilation errors`,file:n})}return t}getPotentialNodeModulesPaths(e){let t=[],n=(0,f.resolve)(e);for(;;){let e=(0,f.join)(n,`node_modules`);(0,u.existsSync)(e)&&t.push(e);let r=(0,f.dirname)(n);if(r===n)break;n=r}return t}},Ui=class extends ut{regionLogic={start:0,end:0};regionStyle={start:0,end:0};regionView={start:0,end:0};regionI18n={start:0,end:0};get logic(){if(this.regionLogic.file)return this.regionLogic.file;throw`should not append`}get style(){return this.regionStyle.file}get view(){return this.regionView.file}get i18n(){return this.regionI18n.file}get extension(){return w.Component}constructor(e,t){super(e,t);let n=this.getDocuments();this.regionLogic.file=n.ts,this.regionStyle.file=n.scss,this.regionView.file=n.html}async init(){await this.regionView.file?.init(),await this.regionStyle.file?.init(),(!this.regionView.file||!this.regionStyle.file)&&await this.file.validate()}async onValidate(){await this.transformDocument();let e=[],t=[],n=async n=>{if(n.file){let r=await n.file.file.validate(),i=n.file.file.documentInternal;for(let a of r)a.source=C.WebComponent,t.indexOf(a.range)==-1&&(t.push(a.range),a.range.start=this.file.documentInternal.positionAt(i.offsetAt(a.range.start)+n.start),a.range.end=this.file.documentInternal.positionAt(i.offsetAt(a.range.end)+n.start)),e.push(a)}};return await n(this.regionStyle),await n(this.regionView),await n(this.regionLogic),e}waitingFct={};currentVersion=``;isCompiling=!1;transformDocument(){return new Promise(async e=>{let t=this.file.versionInternal+``,n=this.build.insideRebuildAll;if(t==this.currentVersion&&!n)e();else if(this.isCompiling)this.waitingFct[t]||(this.waitingFct[t]=[]),this.waitingFct[t].push(()=>{e()});else{this.isCompiling=!0;let n=this.splitDocument(),r=async(e,t,n)=>{let r=d.TextDocument.create(this.file.uri,t,this.file.versionUser,n);if(e.file)await e.file.triggerContentChange(r);else if(t==C.HTML){let t=new vi(new A(d.TextDocument.create(this.file.uri,C.HTML,this.file.versionUser,n)),this.build);e.file=t,await t.init()}else if(t==C.SCSS){let t=new _i(new A(d.TextDocument.create(this.file.uri,C.SCSS,this.file.versionUser,n)),this.build);e.file=t,await t.init()}};if(n.cssText===null?this.regionStyle.file&&(this.regionStyle.file.triggerDelete(),this.regionStyle.file=void 0):await r(this.regionStyle,C.SCSS,n.cssText),n.htmlText===null?this.regionView.file&&(this.regionView.file.triggerDelete(),this.regionView.file=void 0):await r(this.regionView,C.HTML,n.htmlText),n.scriptText!==null&&await r(this.regionLogic,C.TypeScript,n.scriptText),this.isCompiling=!1,this.currentVersion=t,this.waitingFct[t])for(let e of this.waitingFct[t])e();e()}})}async onContentChange(){await this.transformDocument()}async onSave(){this.build.disableBuild(),this.style&&await this.style.file.triggerSave(),this.view&&await this.view.file.triggerSave(),this.build.enableBuild(),await this.logic.file.triggerSave()}async onCompletion(e,t){await this.transformDocument();let n=e.documentInternal.offsetAt(t),r=[],i=async e=>{if(n>=e.start&&n<=e.end&&e.file){let t=await(e.file?.file).getCompletion(e.file.file.documentInternal.positionAt(n-e.start));for(let n of t.items)if(n.data&&n.data.uri&&(n.data.previousLanguageId=n.data.languageId,n.data.languageId=C.WebComponent),n.textEdit){let t=n.textEdit;t.range&&r.indexOf(t.range)==-1&&(r.push(t.range),t.range.start=this.transformPosition(e.file,t.range.start,this,e.start*-1),t.range.end=this.transformPosition(e.file,t.range.end,this,e.start*-1))}return t}};return await i(this.regionStyle)||await i(this.regionView)||await i(this.regionLogic)||{isIncomplete:!1,items:[]}}async onCompletionResolve(e,t){let n=[];if(t.data&&t.data.previousLanguageId){let e=t.data.previousLanguageId;delete t.data.previousLanguageId;let r=async(r,i)=>{if(e==i){let e=r.file;if(e){let i=await e.file.getCompletionResolve(t);if(i.additionalTextEdits)for(let t of i.additionalTextEdits)e.file.documentInternal.offsetAt(t.range.start)==0&&(t.newText=`
|
|
573
574
|
`+t.newText),n.indexOf(t.range)==-1&&!t.range.wc_transformed&&(n.push(t.range),t.range.wc_transformed=!0,t.range.start=this.transformPosition(e,t.range.start,this,r.start*-1),t.range.end=this.transformPosition(e,t.range.end,this,r.start*-1));return i}}},i=await r(this.regionStyle,C.SCSS);if(i)return i;let a=await r(this.regionView,C.HTML);if(a)return a;let o=await r(this.regionLogic,C.TypeScript);if(o)return o}return t}async onHover(e,t){let n=e.documentInternal.offsetAt(t),r=[],i=async e=>{if(n>=e.start&&n<=e.end&&e.file){let t=await e.file.file.getHover(e.file.file.documentInternal.positionAt(n-e.start));return t?.range&&r.indexOf(t.range)==-1&&(r.push(t.range),t.range.start=this.transformPosition(e.file,t.range.start,this,e.start*-1),t.range.end=this.transformPosition(e.file,t.range.end,this,e.start*-1)),t}return null};return await i(this.regionStyle)||await i(this.regionView)||await i(this.regionLogic)||null}async onDefinition(e,t){let n=e.documentInternal.offsetAt(t),r=null;return this.style&&n>=this.regionStyle.start&&n<=this.regionStyle.end?r=await this.style.file.getDefinition(this.style.file.documentInternal.positionAt(n-this.regionStyle.start)):this.view&&n>=this.regionView.start&&n<=this.regionView.end?r=await this.view.file.getDefinition(this.view.file.documentInternal.positionAt(n-this.regionView.start)):n>=this.regionLogic.start&&n<=this.regionLogic.end&&(r=await this.logic.file.getDefinition(this.logic.file.documentInternal.positionAt(n-this.regionLogic.start))),r}async onFormatting(e,t,n){let r=[],i=[],a=e=>{let t=``;for(let n=0;n<e*4;n++)t+=` `;return t},o=async(e,t)=>{if(e.file){let o=await e.file.file.getFormatting(n);for(let n of o)t.tab&&(n.newText=n.newText.split(`
|
|
574
575
|
`).join(`
|
|
575
576
|
`+a(1))),t.firstLast&&(n.newText=n.newText.trim(),n.range.start.character==0&&n.range.start.line==0&&(n.newText=t.tab?`
|
|
576
577
|
`+a(1)+n.newText:`
|
|
577
578
|
`+n.newText),e.file.file.documentInternal.offsetAt(n.range.end)==e.file.file.documentInternal.getText().length&&(n.newText+=`
|
|
578
|
-
`)),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
|
|
579
|
-
`)),r.tagName&&(a.tagName=r.tagName),this.manifest.manifestConfig.srcBaseUrl&&(a.source={href:this.getSourceUri(e.file.uri)}),n.extends&&n.extends.length>0){let e=N.getInfoByFullName(n.extends[0],n);if(e&&e instanceof
|
|
579
|
+
`)),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 vi(new A(d.TextDocument.create(this.file.uri,C.HTML,this.file.versionUser,e.htmlText)),this.build);let t;e.cssText!==null&&(t=new _i(new A(d.TextDocument.create(this.file.uri,C.SCSS,this.file.versionUser,e.cssText)),this.build));let n=new F(new A(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]}},Wi=class{manifest;_package;constructor(e){this.manifest=e,this._package={modules:[],schemaVersion:`1.0.0`,readme:``}}write(e){Ye((0,f.join)(e,`custom-elements.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(!e.fileParsed||!(e instanceof F))return;let n=t.class,r=e.compileResult.find(t=>t.classScript.split(`.`).pop()==e.componentClassName);if(!r)return;let i={kind:`javascript-module`,path:this.getLocalUri(e.file.uri),declarations:[],exports:[]},a={kind:`class`,description:``,name:n.name,customElement:!0};if(n.documentation&&(a.summary=n.documentation?.definitions.join(`
|
|
580
|
+
`)),r.tagName&&(a.tagName=r.tagName),this.manifest.manifestConfig.srcBaseUrl&&(a.source={href:this.getSourceUri(e.file.uri)}),n.extends&&n.extends.length>0){let e=N.getInfoByFullName(n.extends[0],n);if(e&&e instanceof fn)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(`
|
|
580
581
|
`)),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(`
|
|
581
582
|
`)),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(`
|
|
582
|
-
`)),e.isPrivate?i.privacy=`private`:e.isProtected?i.privacy=`protected`:i.privacy=`public`,e.node.type){let t=new M(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 M(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=D(e.replace(t,``)).replace(/\\/g,`/`);return n=n.replace(w.Base,`.js`),`__src/`+n}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},
|
|
583
|
+
`)),e.isPrivate?i.privacy=`private`:e.isProtected?i.privacy=`protected`:i.privacy=`public`,e.node.type){let t=new M(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 M(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=D(e.replace(t,``)).replace(/\\/g,`/`);return n=n.replace(w.Base,`.js`),`__src/`+n}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},Gi=class{manifest;_package;constructor(e){this.manifest=e,this._package={html:{snippets:{}}}}write(e){Ye((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 F))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}>`}},Ki=class{manifest;_package;constructor(e){this.manifest=e,this._package={version:1.1,tags:[]}}write(e){Ye((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 F))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(`
|
|
583
584
|
`),i=``;n&&(i=n),r&&(i&&(i+=`
|
|
584
585
|
|
|
585
|
-
`),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)}},
|
|
586
|
+
`),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)}},qi=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){Ye((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(`
|
|
586
587
|
`),i=``;n&&(i=n),r&&(i&&(i+=`
|
|
587
588
|
|
|
588
589
|
`),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(`
|
|
589
|
-
`)),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)}},
|
|
590
|
+
`)),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)}},Ji=class{customElements;htmlCustomData;emmetCustomData;webTypes;configFile;manifestConfig;build;constructor(e,t){this.build=t,this.customElements=new Wi(this),this.htmlCustomData=new Ki(this),this.emmetCustomData=new Gi(this),this.webTypes=new qi(this),this.manifestConfig=e,this.configFile=this.build.project.getConfigFile()}register(e){if(e instanceof F&&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=>Rn.is(e)||Li.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 F){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=>In.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+=`
|
|
590
591
|
`+e.class.documentation?.definitions.join(`
|
|
591
592
|
`)),t+=`
|
|
592
593
|
`;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(`
|
|
593
594
|
`);r(e?t.name+`: `+e:t.name,n)}}};if(d(i,`Attributes`),d(s,`Properties`),d(c,`Static Properties`),Object.keys(l).length>0){n(`Slots`);for(let e in l)r(e,l[e].doc)}if(u.length>0){n(`CSS Variables`);for(let e of u){let n=e.name;e.type&&(e.type==`literal`&&e.typeValues?n+=`: `+e.typeValues.join(` | `):n+=`: `+e.type),r(n,e.documentation),e.chainValues&&(t+=` - ${e.chainValues.join(` < `)}\n`)}}let f=(e,t)=>{if(e.length>0){n(t);for(let t of e){let e=[];if(t.node.parameters.length>0)for(let n of t.node.parameters){let t=n.name.getText();n.questionToken&&(t+=`?`),n.type&&(t+=`: `+this.getTypeTxt(new M(n.type))),n.initializer&&(t+=` = `+n.initializer.getText()),e.push(t)}let n=`${t.name}(${e.join(`, `)})`;if(t.node.type){let e=this.getTypeTxt(new M(t.node.type));n+=`: `+e}r(n,t.documentation?.definitions.join(`
|
|
594
595
|
`))}}};return f(a,`Methods`),f(o,`Static Methods`),t.endsWith(`
|
|
595
|
-
`)&&(t=t.substring(0,t.length-1)),t}};const
|
|
596
|
+
`)&&(t=t.substring(0,t.length-1)),t}};const Yi={$schema:`foo://aventus/i18n.json`,title:`JSON Schema for Aventus I18n`,description:`JSON Schema for Aventus I18n`,type:`object`};var Xi=class e{static empty=`ⵌⵌ`;static instance;static getInstance(){return this.instance||=new e,this.instance}languageService;constructor(){this.languageService=(0,y.getLanguageService)({}),this.languageService.configure({allowComments:!0,schemas:[{fileMatch:[`**`+w.I18n],uri:Yi.$schema??``,schema:Yi}]})}async validate(t){let n=t.file.documentUser,r=this.languageService.parseJSONDocument(n),i=await this.languageService.doValidation(n,r);if(i.length==0){let r=this.removeComments(n.getText());try{JSON.parse(r);let n=t.parsed??{},a=t.build.buildConfig.i18n?.locales??[];for(let r in n){for(let o in n[r].locales){let s=n[r].locales[o];a.includes(o)||i.push(Re(t.file.documentUser,`Locale not needed`,s.localeStart,s.localeEnd)),s.value==e.empty&&i.push(Re(t.file.documentUser,`Translation not set`,s.valueStart,s.valueEnd))}let o=[];for(let e of a)n[r].locales[e]===void 0&&o.push(e);o.length>0&&i.push(Le(t.file.documentUser,`Missing locales `+o.join(`, `),n[r].keyStart,n[r].keyEnd))}return i}catch{i.push(Ie(n,`Can't parse the json`))}}for(let e of i)e.severity=y.DiagnosticSeverity.Error;return i}async format(e,t,n){try{let t=JSON.parse(e.contentUser);return[{newText:JSON.stringify(this.sortObj(t),null,4),range:{start:e.documentUser.positionAt(0),end:e.documentUser.positionAt(e.contentUser.length)}}]}catch{}return[]}async codeAction(e,t){let n=[];try{let t=this.actionImportMissingLocales(e);t&&n.push(t)}catch{}return n}removeComments(e){return e=e.replace(/(\".*?\"|\'.*?\')|(\/\*.*?\*\/|\/\/[^(\r\n|\n)]*$)/gm,(e,t,n)=>{if(n){let e=``;for(let t=0;t<n.length;t++)e+=` `;return e}return t}),e}sortObj(t){return e.sortObj(t)}static sortObj(e){return Object.keys(e).sort().reduce((t,n)=>{let r=e[n];return t[n]=Object.keys(r).sort().reduce((e,t)=>(e[t]=r[t],e),{}),t},{})}actionImportMissingLocales(t){let n=!1,r=JSON.parse(JSON.stringify(t.parsedSrc));for(let i in t.parsedSrc){let a=t.parsedSrc[i],o=t.build.buildConfig.i18n?.locales??[];for(let t of o)a[t]===void 0&&(n=!0,r[i][t]=e.empty)}if(n){let e=JSON.stringify(this.sortObj(r),null,4);return{title:`Import missing locales`,edit:{changes:{[t.file.uri]:[{newText:e,range:{start:t.file.documentUser.positionAt(0),end:t.file.documentUser.positionAt(t.file.contentUser.length)}}]}}}}}addValueToFile(t,n){let r=JSON.parse(JSON.stringify(t.parsedSrc));r[n]={};let i=t.build.buildConfig.i18n?.locales??[],a=t.build.buildConfig.i18n?.fallback??`en-GB`;for(let t of i)r[n][t]=t==a?n:e.empty;let o=JSON.stringify(this.sortObj(r),null,4);y.TextDocument.create(t.file.uri,C.I18n,t.file.versionUser+1,o)}},Zi=class{static parse(e){let t={},n=(0,y.getLanguageService)({}).parseJSONDocument(e).root?.children??[];for(let e of n)if(e.type==`property`){let n=e.children[0],r=e.children[1].children??[],i={key:n.value+``,keyStart:n.offset,keyEnd:n.offset+n.length,locales:{}};for(let e of r)if(e.type==`property`){let t=e.children[0].value+``,n=e.children[0].offset,r=n+e.children[0].length,a=e.children[1].value+``,o=e.children[1].offset,s=o+e.children[1].length;i.locales[t]={locale:t,localeStart:n,localeEnd:r,value:a,valueStart:o,valueEnd:s}}t[i.key]=i}return t}},Qi=class extends ut{parsedSrc={};parsed;exported={};get classInfo(){var e=this.build.tsFiles[this.file.uri.replace(w.I18n,w.ComponentLogic)];if(e instanceof F&&e.fileParsed)return e.fileParsed.classes[e.componentClassName]}isGlobal=!1;get keys(){return Object.keys(this.parsedSrc)}constructor(e,t,n){super(e,n),this.isGlobal=t,this.onContentChange()}async onContentChange(){try{if(this.parsedSrc=JSON.parse(this.file.contentUser),this.parsed=Zi.parse(this.file.documentUser),this.transformForExport(),this.file instanceof A&&this.isGlobal){let e=`declare global {
|
|
596
597
|
namespace Aventus {
|
|
597
598
|
interface AventusI18n {
|
|
598
599
|
${this.keys.map(e=>`"${e.replace(/"/g,`\\"`)}": string`).join(`,
|
|
599
600
|
`)}
|
|
600
601
|
}
|
|
601
602
|
}
|
|
602
|
-
}`;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
|
|
603
|
+
}`;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 Xi.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 Xi.getInstance().format(e,t,n)}async onCodeAction(e,t){return await Xi.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}},$i=class{project;buildConfig;stories;onNewFileUUID;onFileDeleteUUIDs={};globalComponentSCSSFiles={};scssFiles={};tsFiles={};noNamespaceUri={};htmlFiles={};wcFiles={};i18nComponentsFiles={};namespaces=[];externalPackageInformation=new ea(this);dependencyNeedUris=[];dependencyFullUris=[];dependencyUris=[];diagnostics=new Map;tsLanguageService;get globalSCSSLanguageService(){return this.project.globalSCSSLanguageService}scssLanguageService;htmlLanguageService;allowBuild=!0;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 En(this),this.scssLanguageService=new gi(this),this.htmlLanguageService=new Si(this),this.stories=new $t(this,t),this._outputPathes=[(0,f.join)(Bi.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 Hi(this),Mi.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 D(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 _n&&$.sendDiagnostics({uri:e.file.uri,diagnostics:e.getDiagnostics()},this);this.diagnostics.clear()}emitDiagnostics(){for(let[e,t]of this.diagnostics.entries())if(e instanceof _n){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))}ji.send(this.buildConfig.fullname,e),this.reloadPage&&(this.reloadPage=!1,j.getInstance().reload()),this.emitDiagnostics()}_buildStringModule(e,t,n,r,i,a){let o=``,s=e.split(`.`);if(o+=t.join(`
|
|
603
604
|
`)+`
|
|
604
605
|
`,n.length>0){let t=``;o+=`var `+s[0]+`;
|
|
605
606
|
`;for(let e=0;e<s.length;e++)t==``?t=s[e]:t+=`.`+s[e],o+=`(`+t+`||(`+t+` = {}));
|
|
@@ -657,7 +658,7 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
657
658
|
};
|
|
658
659
|
`);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+`
|
|
659
660
|
`:n[e[`@default`].path].code+=r.code+`
|
|
660
|
-
`;n[e[`@default`].path].code+=s;for(let e in n){let t=
|
|
661
|
+
`;n[e[`@default`].path].code+=s;for(let e in n){let t=ze(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,me.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 {
|
|
661
662
|
`,i+=`
|
|
662
663
|
namespace `+this.buildConfig.module+`{
|
|
663
664
|
`,i+=t.doc.join(`
|
|
@@ -689,19 +690,19 @@ namespace `+this.buildConfig.module+`{
|
|
|
689
690
|
`,a+=`//#region dependencies //
|
|
690
691
|
`,a+=JSON.stringify(this.buildConfig.rawDependencies)+`
|
|
691
692
|
`,a+=`//#endregion dependencies //
|
|
692
|
-
`;for(let t of e)t?this.writeFile(t,a):(0,u.existsSync)(t)&&(
|
|
693
|
+
`;for(let t of e)t?this.writeFile(t,a):(0,u.existsSync)(t)&&Ze(t);let o=(0,f.join)(Bi.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 Ji(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}";
|
|
693
694
|
`)}if(a!=``&&(a+=`
|
|
694
695
|
`),a+=t.npmsrc[n].content.join(`
|
|
695
|
-
`),a=
|
|
696
|
+
`),a=En.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`,...ze(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}";
|
|
696
697
|
`,a+=`export { ${e} };
|
|
697
698
|
`,s.push(`./${e}`)}}for(let e in r.imports){let t=r.imports[e];t.length>0&&(i+=`import { ${t.join(`, `)} } from "${e}";
|
|
698
699
|
`)}i+=`
|
|
699
700
|
`+r.content.join(`
|
|
700
701
|
`)+`
|
|
701
|
-
`,i+=a,i=i.replaceAll(`globalThis.Aventus.`,``),i=i.replaceAll(`___Aventus.`,``),i=
|
|
702
|
+
`,i+=a,i=i.replaceAll(`globalThis.Aventus.`,``),i=i.replaceAll(`___Aventus.`,``),i=En.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";
|
|
702
703
|
`,a+=`export { ${e} };
|
|
703
704
|
`}}let s=r[t];if(s)for(let e in s){let t=s[e].join(`, `);i+=`export { ${t} } from "${e}"
|
|
704
|
-
`}i+=a,i=wn.removeUnusedImport(i,[]);for(let n of e.path){let e=(0,f.join)(n,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0});let r=(0,f.join)(e,`index.js`);this.writeFile(r,i)}};for(let e of n)a(e,t.npm[e]),o(e);if(e.packageJson){let t=(0,f.join)(this.project.getConfigFile().folderPath,`package.json`),n={};(0,u.existsSync)(t)&&(n=JSON.parse((0,u.readFileSync)(t,`utf-8`)));let r={};for(let e of this.externalPackageInformation.filesUri){let t=this.externalPackageInformation.getByUri(e);t&&t.npmUri&&t.name!=this.buildConfig.fullname&&(n.dependencies&&n.dependencies[t.npmUri]?r[t.npmUri]=n.dependencies[t.npmUri]:r[t.npmUri]=`^`+t.versionTxt)}let i=`Aventus build for @`+this.buildConfig.module,a=this.buildConfig.module;this.buildConfig.name&&(i+=`/`+this.buildConfig.name,a+=` `+this.buildConfig.name);let o={name:e.npmName==``?(`@`+this.buildConfig.module+`/`+this.buildConfig.name).toLowerCase():e.npmName,displayName:a,description:i,version:this.buildConfig.version,type:`module`,main:`index.js`,types:`index.d.ts`,dependencies:r};this.buildConfig.organization?o.author={name:this.buildConfig.organization}:Ni.isConnected&&(o.author={name:Ni.settings.username});for(let t of e.path){(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let e=(0,f.join)(t,`package.json`),n={};if((0,u.existsSync)(e))try{n=JSON.parse((0,u.readFileSync)(e,`utf8`))}catch{}let r={...o,...n};r.name=o.name,r.displayName=o.displayName,r.version=o.version,this.writeFile(e,JSON.stringify(r,null,2))}}if(i)for(let t of e.path)(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0}),i.write(t)}writeBuildI18n(e){let t=this.buildConfig.i18n?.locales??[];for(let n of e)for(let e of n.output){t.length>0&&!(0,u.existsSync)(e)&&(0,u.mkdirSync)(e,{recursive:!0});for(let r of t)if(n.mode==`singleFile`){let t={};for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e];t={...t,...n.exported[r]}}for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[r]}}let n=(0,f.join)(e,r+`.json`).toLowerCase();this.writeFile(n,JSON.stringify(t,null,4))}else if(n.mode==`oneToOne`){for(let t in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[t],i=(0,f.join)(e,n.file.name.replace(`@`,``).replace(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 F&&i.fileParsed){let t=(0,f.join)(e,i.fileParsed.classes[i.componentClassName].namespace.replace(/\./g,f.sep));(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let a=(0,f.join)(e,n.file.name.replace(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 F&&r.compilationResult)if(t){let e=JSON.parse(JSON.stringify(r.compilationResult.htmlDoc));for(let t in e)e[t].class=this.buildConfig.module+`.`+e[t].class,n.htmlDoc[t]=e[t]}else n.htmlDoc={...n.htmlDoc,...r.compilationResult.htmlDoc}};for(let t of e)if(t.useDecorator&&(n.useDecorator=!0),this.noNamespaceUri[t.uri]){if(t.compiled!=``){let e;t.compiled.startsWith(`@After()`)?(n.codeNoNamespaceAfter.push(t.compiled.slice(8)),e=`after`):t.compiled.startsWith(`@Before()`)?(n.codeNoNamespaceBefore.push(t.compiled.slice(9)),e=`before`):a?(n.codeNoNamespaceAfter.push(t.compiled),e=`after`):(n.codeNoNamespaceBefore.push(t.compiled),e=`before`),r[t.classScript]||(r[t.classScript]={code:Be(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(Be(t.compiled,this.project.getConfig()));let e=o+t.classScript;r[e]||(r[e]={code:Be(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=Ge(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,O(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,O(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=Be(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)})
|
|
705
|
+
`}i+=a,i=En.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}:Fi.isConnected&&(o.author={name:Fi.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 F&&i.fileParsed){let t=(0,f.join)(e,i.fileParsed.classes[i.componentClassName].namespace.replace(/\./g,f.sep));(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});let a=(0,f.join)(e,n.file.name.replace(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 F&&r.compilationResult)if(t){let e=JSON.parse(JSON.stringify(r.compilationResult.htmlDoc));for(let t in e)e[t].class=this.buildConfig.module+`.`+e[t].class,n.htmlDoc[t]=e[t]}else n.htmlDoc={...n.htmlDoc,...r.compilationResult.htmlDoc}};for(let t of e)if(t.useDecorator&&(n.useDecorator=!0),this.noNamespaceUri[t.uri]){if(t.compiled!=``){let e;t.compiled.startsWith(`@After()`)?(n.codeNoNamespaceAfter.push(t.compiled.slice(8)),e=`after`):t.compiled.startsWith(`@Before()`)?(n.codeNoNamespaceBefore.push(t.compiled.slice(9)),e=`before`):a?(n.codeNoNamespaceAfter.push(t.compiled),e=`after`):(n.codeNoNamespaceBefore.push(t.compiled),e=`before`),r[t.classScript]||(r[t.classScript]={code:Ve(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(Ve(t.compiled,this.project.getConfig()));let e=o+t.classScript;r[e]||(r[e]={code:Ve(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=Ke(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,O(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,O(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=Ve(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)})
|
|
705
706
|
`,a+=`Aventus.I18n.registerFallback("${this.buildConfig.i18n.fallback}")
|
|
706
707
|
`,t.mode==`singleFile`){let e=(t.mount+`/$locale.json`).toLowerCase();a+=`Aventus.I18n.registerFile("${e}", { load: false })
|
|
707
708
|
`}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 })
|
|
@@ -717,20 +718,20 @@ namespace `+this.buildConfig.module+`{
|
|
|
717
718
|
`}}}else if(n.mode==`groupComponent`){for(let e in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(w.I18n,``),i=(n.mount+`/`+r+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${i}", { load: false })
|
|
718
719
|
`}if(Object.keys(this.i18nComponentsFiles).length>0){let e=(n.mount+`/_components_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${e}", { load: false })
|
|
719
720
|
`}}else n.mode==`basedOnAttribute`||n.mode;t+=`Aventus.I18n.init()
|
|
720
|
-
`}u.push({lib:`Aventus@I18n`,code:t})}if(t.libSrc=u,r.length>0){let e=this.buildConfig.fullname+`_dependencyErrors`;
|
|
721
|
-
`)),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(){Ce.startSendBuildTime(this.buildConfig.fullname),this.allowBuild=!1;let e=await Ri.getInstance().loadDependenciesFromBuild(this.buildConfig,this);this.dependencyFullUris=e.dependencyFullUris,this.dependencyNeedUris=e.dependencyNeedUris,this.dependencyUris=e.dependencyUris,this.externalPackageInformation.init(e.files);let t=R.getInstance();if(this.buildConfig.srcPathRegex){let e=t.getFilesMatching(this.buildConfig.srcPathRegex);for(let t of e)this.registerFile(t,!0)}if(this.buildConfig.outsideModulePathRegex){let e=t.getFilesMatching(this.buildConfig.outsideModulePathRegex);for(let t of e)this.registerFile(t,!0),this.noNamespaceUri[t.uri]=!0}$.debug(`loaded all files needed`),this.allowBuild=!0,this._filesLoaded=!0,await this.rebuildAll(!0),Ce.sendBuildTime(this.buildConfig.fullname)}async registerFile(e,t){if(e.uri.endsWith(w.ComponentStyle))this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new hi(e,this),t||await this.scssFiles[e.uri].init(),this.registerOnFileDelete(e),this.scssFiles[e.uri].isGlobal&&(this.globalComponentSCSSFiles[e.uri]=this.scssFiles[e.uri]));else if(e.uri.endsWith(w.ComponentView))this.htmlFiles[e.uri]||(this.htmlFiles[e.uri]=new gi(e,this),t||await this.htmlFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(w.Component))this.wcFiles[e.uri]||(this.wcFiles[e.uri]=new Vi(e,this),t||await this.wcFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(w.I18n))e.name.startsWith(`@`)?this.tsLanguageService.i18nFiles[e.uri]||(this.tsLanguageService.i18nFiles[e.uri]=new Xi(e,!0,this),t||await this.tsLanguageService.i18nFiles[e.uri].validate(),this.registerOnFileDelete(e)):this.i18nComponentsFiles[e.uri]||(this.i18nComponentsFiles[e.uri]=new Xi(e,!1,this),t||await this.i18nComponentsFiles[e.uri].validate(),this.registerOnFileDelete(e));else if(!this.tsFiles[e.uri]){let t=Oi(e,this);t&&(this.tsFiles[e.uri]=t,this.registerOnFileDelete(e))}}registerOnFileDelete(e){this.onFileDeleteUUIDs[e.uri]=e.onDelete(this.onFileDelete.bind(this))}async onFileDelete(e){e.removeOnDelete(this.onFileDeleteUUIDs[e.uri]),delete this.onFileDeleteUUIDs[e.uri],e.uri.endsWith(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(D(n.fileUri),e);if(t)return{class:t,isLocal:!1}}return{class:n,isLocal:!1}}}}getWebComponentDefinitionFile(e){let t=this.htmlLanguageService.getInternalDefinition(e);if(t)return t;let n=this.htmlLanguageService.getClassByTag(e);if(n)return this.externalPackageInformation.getExternalWebComponentDefinitionFile(n)}getSlotsInfo(e){let t={},n=[],r=!1,i=e;for(;i&&i.fullName!=`Aventus.WebComponent`;){let a=this.tsFiles[i.fileUri];if(!a){let a=this.externalPackageInformation.getByFullName(i.fullName);if(a&&a.content!=`noCode`&&a.content.slots&&!r)for(let r in a.content.slots)n.includes(r)||(t[r]||(t[r]={local:i==e}),!t[r].doc&&i.documentation?.documentationSlots[r]&&(t[r].doc=i.documentation?.documentationSlots[r]))}else if(a instanceof F&&a.HTMLFile?.fileParsed?.slotsInfo&&!r){for(let r in a.HTMLFile.fileParsed.slotsInfo)n.includes(r)||(t[r]||(t[r]={local:i==e}),!t[r].doc&&i.documentation?.documentationSlots[r]&&(t[r].doc=i.documentation?.documentationSlots[r]));for(let e in a.HTMLFile.fileParsed.blocksInfo)t[e]||n.push(e)}i.decorators.find(e=>Pn.is(e))&&(r=!0),i=i.parentClass}return t}getNamespaceForUri(e){if(this.buildConfig.namespaceStrategy==`manual`)return``;if(this.buildConfig.namespaceStrategy==`rules`){let t=D(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=D(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]);ji.send(this.project.getConfigFile().path,this.buildConfig.fullname)}writeFile(e,t){Je(e,t,`build`,this.buildConfig.fullname)}},Qi=class{files={};informations={};informationsRequired={};webComponentByName={};build;constructor(e){this.build=e}get filesUri(){return Object.keys(this.files)}init(e){for(let t of e)this.files[t.file.uri]=t;this.rebuild()}getByFullName(e){return this.informations[e]}getByUri(e){return this.files[e]}getNpmUri(e){if(!this.build.hasNpmOutput)return null;if(this.informations[e]){let t=this.files[this.informations[e].uri];!t.npmUri&&this.build.initDone&&$.showErrorMessage(`Can't find a npm package for `+t.name+`. You must define the npm field inside the dependencies section of your aventus.conf.avt. Otherwise, you can disable storybook or remove npm export.`);let n=e.split(`.`),r=n.pop();n.splice(0,0,t.npmUri);let i=t.fileParsed?.getBaseInfo(r)?.willBeCompiled??!1;return{name:r,uri:n.join(`/`),compiled:i}}return null}getNamespaceByUri(e){return this.files[e].srcInfo.namespace}getNameByUri(e){return this.files[e].name}getInformationsRequired(e){return this.informationsRequired[e]}getFullInformations(e){return this.files[e]?.srcInfo.available||[]}getStyleByUri(e){return this.files[e]?this.files[e].externalCSS:{}}rebuild(){this.informations={},this.webComponentByName={};let e=[];for(let t in this.files){let n=this.files[t];this.informationsRequired[t]=[];for(let r of n.srcInfo.available)(r.required||this.build.buildConfig.i18n&&r.fullName==`Aventus.I18n`)&&this.informationsRequired[t].push(r),r.fullName&&(this.informations[r.fullName]?this.informations[r.fullName].uri!=t&&e.push({range:{start:{line:0,character:0},end:{line:0,character:0}},severity:m.DiagnosticSeverity.Error,source: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}}},$i=class{staticConfig;watcher;isReady=!1;project;get name(){return this.staticConfig.name}constructor(e,t){this.project=e,this.staticConfig=t,this.registerWatcher(),this.isReady=!0}async export(){if(this.isReady){Ce.startSendStaticTime(this.name);let e=e=>{var t=[],n=e=>((0,u.existsSync)(e)&&(0,u.readdirSync)(e).forEach(r=>{let i=e+`/`+r;if((0,u.lstatSync)(i).isDirectory()){let e=n(i);e.length>0&&t.concat(e)}else t.push(i)}),t);return t=n(e),t},t=(e,t)=>{try{t=(0,f.normalize)(t);let n=t.split(f.sep),r=n.pop(),i=n.join(f.sep);if((0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0}),r.endsWith(`.scss`)){if(!r.startsWith(`_`)){let n=(0,le.compile)(e,{style:`compressed`}).css.toString().trim();Je(t.replace(`.scss`,`.css`),n,`static`,this.name)}}else (0,u.copyFileSync)(e,t),Ce.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[E(e)];if(!t){let n=d.TextDocument.create(E(e),w.GlobalStyle,1,(0,u.readFileSync)(e,`utf8`));await R.getInstance().registerFile(n),t=this.project.scssFiles[E(e)]}await t.addOutPath(r,this.name)}}else t(e,r)}}j.getInstance().reload(),Ce.sendStaticTime(this.name)}}registerWatcher(){T.getInstance().settings.watchFiles&&(this.watcher=(0,v.watch)(this.staticConfig.inputPathFolder,{ignored:/^\./,persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:100},ignoreInitial:!0}),this.watcher.on(`add`,e=>{this.export()}),this.watcher.on(`change`,e=>{this.export()}),this.watcher.on(`unlink`,e=>{this.export()}),this.watcher.on(`error`,function(e){}))}destroy(){this.watcher&&this.watcher.close()}},ea=class{languageService;variablesByUri={};variablesByName={};constructor(){this.languageService=(0,ce.getSCSSLanguageService)()}async doValidation(e){return this.languageService.doValidation(e.documentUser,this.languageService.parseStylesheet(e.documentUser))}async doComplete(e,t){return this.languageService.doComplete(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async doHover(e,t){return this.languageService.doHover(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async findDefinition(e,t){let n=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));return n&&[n]}async format(e,t,n){let r={...n,preserveNewLines:!0,spaceAroundSelectorSeparator:!0,insertFinalNewline:!0,insertSpaces:!1,tabSize:4},i=e.documentUser,a=await this.languageService.format(i,t,r);if(a.length==1){let e=i.offsetAt(a[0].range.start),t=i.offsetAt(a[0].range.end),n=i.getText().length;if(e==0&&t==n){let e=await(0,se.default)([(0,oi.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:si,from:`./temp.scss`,to:`./temp.scss`});a[0].newText=e.css}}return a}async doCodeAction(e,t){let n=this.languageService.parseStylesheet(e.documentUser),r=m.CodeActionContext.create(this.languageService.doValidation(e.documentUser,n));return this.languageService.doCodeActions2(e.documentUser,t,r,n)}async onReferences(e,t){let n=this.languageService.parseStylesheet(e.documentUser);return this.languageService.findReferences(e.documentUser,t,n)}loadVariables(e,t){let n=e.file.documentUser,r={},i=e=>{if(e.type==69){let i=e;for(;i&&i.selectors==null;)i=i.parent;if(i&&i.selectors.getText()==`:root`){let i=e.getChild(0),a=e.getChild(1);if(i&&a){let e=i.getText();e.startsWith(`--`)&&(i.offset,r[e]||(r[e]={name:e,uri:t,range:{start:n.positionAt(i.offset),end:n.positionAt(i.end)},value:a.getText()}))}}}else if(e.hasChildren())for(let t of e.getChildren())i(t)},a=pi((0,ce.getSCSSLanguageService)().parseStylesheet(n),0);for(let e of a)i(e);this.variablesByUri[t]=Object.values(r),this.reloadVariables()}reloadVariables(){this.variablesByName={};for(let e in this.variablesByUri)for(let t of this.variablesByUri[e])this.variablesByName[t.name]||(this.variablesByName[t.name]=t)}removeVariables(e){delete this.variablesByUri[e],this.reloadVariables()}getDefinition(e){return this.variablesByName[e]}},ta=class{_file;_project;get file(){return this._file}get project(){return this._project}constructor(e,t){this._file=e,this._project=t,this.addEvents()}uuidEvents={onContentChange:``,onValidate:``,onSave:``,onDelete:``,onCompletion:``,onCompletionResolve:``,onHover:``,onDefinition:``,onFormatting:``,onCodeAction:``,onReferences:``,onCodeLens:``,onRename:``};addEvents(){this.uuidEvents.onContentChange=this.file.onContentChange(this.onContentChange.bind(this)),this.uuidEvents.onValidate=this.file.onValidate(this._onValidate.bind(this)),this.uuidEvents.onSave=this.file.onSave(this.onSave.bind(this)),this.uuidEvents.onDelete=this.file.onDelete(this._onDelete.bind(this)),this.uuidEvents.onCompletion=this.file.onCompletion(this.onCompletion.bind(this)),this.uuidEvents.onCompletionResolve=this.file.onCompletionResolve(this.onCompletionResolve.bind(this)),this.uuidEvents.onHover=this.file.onHover(this.onHover.bind(this)),this.uuidEvents.onDefinition=this.file.onDefinition(this.onDefinition.bind(this)),this.uuidEvents.onFormatting=this.file.onFormatting(this.onFormatting.bind(this)),this.uuidEvents.onCodeAction=this.file.onCodeAction(this.onCodeAction.bind(this)),this.uuidEvents.onReferences=this.file.onReferences(this.onReferences.bind(this)),this.uuidEvents.onCodeLens=this.file.onCodeLens(this.onCodeLens.bind(this)),this.uuidEvents.onRename=this.file.onRename(this.onRename.bind(this))}removeEvents(){this.file.removeOnContentChange(this.uuidEvents.onContentChange),this.file.removeOnValidate(this.uuidEvents.onValidate),this.file.removeOnSave(this.uuidEvents.onSave),this.file.removeOnDelete(this.uuidEvents.onDelete),this.file.removeOnCompletion(this.uuidEvents.onCompletion),this.file.removeOnCompletionResolve(this.uuidEvents.onCompletionResolve),this.file.removeOnHover(this.uuidEvents.onHover),this.file.removeOnDefinition(this.uuidEvents.onDefinition),this.file.removeOnFormatting(this.uuidEvents.onFormatting),this.file.removeOnCodeAction(this.uuidEvents.onCodeAction),this.file.removeOnReferences(this.uuidEvents.onReferences),this.file.removeOnCodeLens(this.uuidEvents.onCodeLens),this.file.removeOnRename(this.uuidEvents.onRename)}async validate(){this.file instanceof A&&await this.file.validate()}triggerSave(){this.file instanceof A&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof A&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async _onDelete(){await this.onDelete(),this.removeEvents()}},na=class e extends ta{compiledVersion=-1;usedBy={};dependencies={};diagnostics=[];diagnosticCompile;compiledTxt=``;savedOnce=!1;staticNamebyOutPath={};get resultCompiled(){return this.compiledTxt}constructor(e,t){super(e,t),this.loadDependencies(),this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}async onContentChange(){}async onValidate(){return this.diagnostics=await this.project.globalSCSSLanguageService.doValidation(this.file),this.loadDependencies(),this.diagnosticCompile?[...this.diagnostics,this.diagnosticCompile]:this.diagnostics}async onSave(){this.savedOnce=!0,this.compileRoot(),this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}compileRoot(){if(Object.values(this.usedBy).length==0)this.compile();else for(let e in this.usedBy)this.usedBy[e].onSave()}compile(){try{let e=this.compiledTxt,t=`|error|`,n=e=>{let r=e.contentUser;r=r.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let i=/@import *?('|")(\S*?)('|");?/g,a=null;for(;a=i.exec(r);){let i=a[2],o=this.resolvePath(i,e.folderPath);if(o){let e=n(o);if(e==t)return e;r=r.replace(a[0],e)}else return t}return r},r=n(this.file);if(r!=`|error|`){let t=e=>{if(T.getInstance().settings.errorByBuild){let t=this.project.getBuilds();for(let n of t)$.sendDiagnostics({uri:this.file.uri,diagnostics:e},n)}else $.sendDiagnostics({uri:this.file.uri,diagnostics:e})};try{let n=(0,le.compileString)(r,{style:`compressed`}).css.toString().trim();n=n.replace(/\\/g,`\\\\`),e=n,this.diagnosticCompile&&(this.diagnosticCompile=void 0,t(this.diagnostics))}catch(e){e instanceof le.Exception&&(this.diagnosticCompile=Me(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}),Je(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(Ne(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}},ra=class{waitingList=[];isLocked=!1;waitOne(){return new Promise(e=>{this.isLocked?this.waitingList.push(()=>{e()}):(this.isLocked=!0,e())})}release(){let e=this.waitingList.shift();e?e():this.isLocked=!1}dispose(){this.waitingList=[],this.isLocked=!1}},ia=class{configFile;config=null;builds=[];statics=[];_isCoreBuild=!1;scssFiles={};onValidateUUID;onSaveUUID;onFormattingUUID;onCompletionUUID;onCompletionResolveUUID;onHoverUUID;onNewFileUUID;onFileDeleteUUIDs={};buildsAllowed;staticsAllowed;globalSCSSLanguageService;get isCoreBuild(){return this._isCoreBuild}getConfigFile(){return this.configFile}getConfig(){return this.config}resolveAlias(e,t){if(e.startsWith(`@`)){let n=e.split(`/`),r=n[0],i=this.config?.aliases[r];if(i){let e=(0,f.normalize)(this.configFile.folderPath+`/`+i);typeof t!=`string`&&(t=t.folderPath);let r=(0,f.normalize)(t);e.endsWith(f.sep)&&(e=e.substring(0,e.length-1)),r.endsWith(f.sep)&&(r=r.substring(0,r.length-1));let a=e.split(f.sep),o=r.split(f.sep);for(let e=0;e<a.length;e++)if(o.length>e)if(a[e]==o[e])a.splice(e,1),o.splice(e,1),e--;else break;let s=``;for(let e=0;e<o.length;e++)s+=`../`;return s==``&&(s+=`./`),s+=a.join(`/`),n.splice(0,1,s),n.join(`/`).replace(/\/\//g,`/`)}}return e}getInternalWebComponentDefinition(e,t){for(let n of this.builds)if(n.outputPathes.includes(e))return n.getLocalWebComponentDefinition(t)}constructor(e,t){this.configFile=e,this.onValidateUUID=this.configFile.onValidate(this.onValidate.bind(this)),this.onSaveUUID=this.configFile.onSave(this.onConfigSave.bind(this)),this.onFormattingUUID=this.configFile.onFormatting(this.onFormatting.bind(this)),this.onCompletionUUID=this.configFile.onCompletion(this.onCompletion.bind(this)),this.onCompletionResolveUUID=this.configFile.onCompletionResolve(this.onCompletionResolve.bind(this)),this.onHoverUUID=this.configFile.onHover(this.onHover.bind(this)),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile.bind(this)),e.folderUri.toLowerCase().endsWith(`/aventus/base/src`)&&(this._isCoreBuild=!0),this.globalSCSSLanguageService=new ea,t&&this.loadFiles(),e.validate()}async init(){await this.onConfigSave()}async onValidate(){return await st.getInstance().validate(this.configFile)}async loadConfig(){let e=await st.getInstance().getConfig(this.configFile);if(this.config){let t=JSON.stringify(this.config),n=``;if(e&&(n=JSON.stringify(e)),t==n)return;for(let e of this.builds)e.destroy()}this.builds=[],this.config=e}onConfigSaveMutex=new ra;async onConfigSave(){if(await this.onConfigSaveMutex.waitOne(),await this.loadConfig(),this.config){for(let e of this.builds)e.destroy();for(let e of this.statics)e.destroy();for(let e of this.config.build){if(this.buildsAllowed){if(!this.buildsAllowed.includes(e.name??``)){let t=this.builds.find(t=>t.buildConfig.name==e.name);t&&t.build();continue}}else if(e.disabled)continue;let t=new Zi(this,e);this.builds.push(t),await t.init()}if(this.config.static)for(let e of this.config.static){if(this.staticsAllowed&&!this.staticsAllowed.includes(e.name))continue;let t=new $i(this,e);await t.export(),this.statics.push(t)}}this.onConfigSaveMutex.release()}async onFormatting(e,t,n){return await st.getInstance().format(e,t,n)}async onCompletion(e,t){return await st.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return await st.getInstance().doResolve(t)}async onHover(e,t){return await st.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 na(e,this),this.registerOnFileDelete(e)))}registerOnFileDelete(e){this.onFileDeleteUUIDs[e.uri]=e.onDelete(this.onFileDelete.bind(this))}async onFileDelete(e){e.removeOnDelete(this.onFileDeleteUUIDs[e.uri]),delete this.onFileDeleteUUIDs[e.uri],e.uri.endsWith(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}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),this.configFile.removeOnSave(this.onSaveUUID),this.configFile.removeOnValidate(this.onValidateUUID),this.configFile.removeOnFormatting(this.onFormattingUUID),this.configFile.removeOnCompletion(this.onCompletionUUID),this.configFile.removeOnCompletionResolve(this.onCompletionResolveUUID),this.configFile.removeOnHover(this.onHoverUUID);for(let e of this.builds)e.destroy();for(let e of this.statics)e.destroy()}},L=class e{static autoLoad=!0;static instance;static getInstance(){return this.instance||=new e,this.instance}projects={};constructor(){R.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(t){if(t.documentUser.uri.endsWith(`/`+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 ia(t,e.autoLoad),e.autoLoad&&await this.projects[t.documentUser.uri].init(),t.onDelete(this.onDeleteFile.bind(this)))}}async onDeleteFile(e){this.projects[e.documentUser.uri]&&(this.projects[e.documentUser.uri].destroy(),delete this.projects[e.documentUser.uri])}getProjectByUri(e){return this.projects[e]}getMatchingBuildsByUri(e){let t=[];for(let n in this.projects){let r=this.projects[n].getMatchingBuildsByUri(e);for(let e of r)t.push(e)}return t}destroyAll(){for(let e in this.projects)this.projects[e].destroy()}async onRename(e){let t={};for(let n in this.projects){let r=await this.projects[n].onRename(e);for(let e in r)t[e]||(t[e]=[]),t[e]=t[e].concat(r[e])}return t}getAllConfigFiles(){let e=[];for(let t in this.projects)e.push(this.projects[t].getConfigFile().uri);return e}getAllBuilds(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsName();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllBuildsWithStory(){let e=[],t=[];for(let n in this.projects){let r=this.projects[n],i=r.getBuildsNameWithStory();for(let n of i){let i=n+`_`+r.getConfigFile().uri;t.includes(i)||(t.push(i),e.push({name:n,uri:r.getConfigFile().uri}))}}return e}getAllBuildsWithNpm(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsNameWithNpm();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllStatics(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsName();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}},R=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}constructor(){}files={};lockedUpdatedUri={};loadingInProgress=!0;preventUpdateUri(e){this.lockedUpdatedUri[e]&&clearTimeout(this.lockedUpdatedUri[e]),this.lockedUpdatedUri[e]=setTimeout(()=>{delete this.lockedUpdatedUri[e]},2e3)}async onCreatedUri(e){if(!this.files[e]){let t=Oe(e);if(t){let n=D(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=Oe(e),n=D(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(T.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],rt.getInstance().unwatch(e)}}async loadConfigFileNotSet(e,t,n){for(let r=0;r<e.length;r++){let i=D(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=E(o);if(r[i]==w.Config)return await this.loadConfigFile(e,t,n),!0}}return!1};if(await a(i))return}nt.sendDone()}async loadConfigFile(e,t,n){L.autoLoad=!1;let r=D(e);e=E(r);let i=d.TextDocument.create(E(r),w.Config,0,(0,u.readFileSync)(r,`utf8`));this.loadingInProgress=!1,await this.registerFile(i),this.loadingInProgress=!0;let a=L.getInstance().getProjectByUri(e);if(a){await a.loadConfig(),a.buildsAllowed=t,a.staticsAllowed=n;let e=a.getConfig();if(e){let r=async e=>{if(!(0,u.existsSync)(e))return;let t=(0,u.readdirSync)(e);for(let n=0;n<t.length;n++){let i=e+`/`+t[n];if((0,u.lstatSync)(i).isDirectory())t[n]!=`node_modules`&&await r(i);else{let e=E(i),r=Oe(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);Ce.startSendLoadFile(),a.loadFiles(),Ce.sendLoadFile(),this.loadingInProgress=!1,await a.init(),nt.sendDone()}}}async parseWorkspace(e,t){let n=D(e),r=T.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)(D(e)+r+a).replace(/\\/g,`/`);s=Ve(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=E(n),i=Oe(r);e==w.Config&&t.push(new A(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`))))});return t}async loadAllAventusFiles(e){this.loadingInProgress=!0;let t=[];nt.send(`$(loading~spin) Aventus : Loading files`);for(let n=0;n<e.length;n++)await this.parseWorkspace(e[n],async(e,n)=>{let r=E(n),i=Oe(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)}});nt.send(`$(loading~spin) Aventus : Register config`),this.loadingInProgress=!1;for(let e of t)await this.registerFile(e);nt.sendDone()}async onShutdown(){for(let e in this.files)await this.files[e].triggerDelete(),delete this.files[e],rt.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=D(e),n=``;(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`));let r=d.TextDocument.create(e,C.Package,0,n);return rt.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||rt.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)(D(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 A(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=k();for(;this.onNewFileCb[t]!=null;)t=k();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=k();for(;this.onNewFileCb[t]!=null;)t=k();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[E(e)]}getByUri(e){return this.files[e]}getUris(){return Object.keys(this.files)}},aa=class e{static tc(e,t){if(typeof e!=t)throw TypeError(`required type ${t} got ${typeof e}`);return e}static ic(e,t){if(!(e instanceof t))throw TypeError(`required type ${t} got ${typeof e}`);return e}static nc(e){return isNaN(e)?0:e}static oc(e){return{angle:e&&e.angle?e.angle:15,results:e&&e.results?e.results:3}}static clmp(e,t,n){return n!==void 0&&e<n?n:e>t?t:e}static shift(e,t){for(e+=t;e>=360;)e-=360;for(;e<0;)e+=360;return e}#e;#t;#n;alpha;static Colors=class{static get BLACK(){return e.fromHex(`#000000`)}static get SILVER(){return e.fromHex(`#c0c0c0`)}static get GRAY(){return e.fromHex(`#808080`)}static get WHITE(){return e.fromHex(`#ffffff`)}static get MAROON(){return e.fromHex(`#800000`)}static get RED(){return e.fromHex(`#ff0000`)}static get PURPLE(){return e.fromHex(`#800080`)}static get GREEN(){return e.fromHex(`#008000`)}static get LIME(){return e.fromHex(`#00ff00`)}static get OLIVE(){return e.fromHex(`#808000`)}static get YELLOW(){return e.fromHex(`#ffff00`)}static get NAVY(){return e.fromHex(`#000080`)}static get BLUE(){return e.fromHex(`#0000ff`)}static get TEAL(){return e.fromHex(`#008080`)}static get AQUA(){return e.fromHex(`#00ffff`)}static get ORANGE(){return e.fromHex(`#ffa500`)}static get ALICEBLUE(){return e.fromHex(`#f0f8ff`)}static get ANTIQUEWHITE(){return e.fromHex(`#faebd7`)}static get AQUAMARINE(){return e.fromHex(`#7fffd4`)}static get AZURE(){return e.fromHex(`#f0ffff`)}static get BEIGE(){return e.fromHex(`#f5f5dc`)}static get BISQUE(){return e.fromHex(`#ffe4c4`)}static get BLANCHEDALMOND(){return e.fromHex(`#ffebcd`)}static get BLUEVIOLET(){return e.fromHex(`#8a2be2`)}static get BROWN(){return e.fromHex(`#a52a2a`)}static get BURLYWOOD(){return e.fromHex(`#deb887`)}static get CADETBLUE(){return e.fromHex(`#5f9ea0`)}static get CHARTREUSE(){return e.fromHex(`#7fff00`)}static get CHOCOLATE(){return e.fromHex(`#d2691e`)}static get CORAL(){return e.fromHex(`#ff7f50`)}static get CORNFLOWERBLUE(){return e.fromHex(`#6495ed`)}static get CORNSILK(){return e.fromHex(`#fff8dc`)}static get CRIMSON(){return e.fromHex(`#dc143c`)}static get CYAN(){return e.fromHex(`#00ffff`)}static get DARKBLUE(){return e.fromHex(`#00008b`)}static get DARKCYAN(){return e.fromHex(`#008b8b`)}static get DARKGOLDENROD(){return e.fromHex(`#b8860b`)}static get DARKGRAY(){return e.fromHex(`#a9a9a9`)}static get DARKGREEN(){return e.fromHex(`#006400`)}static get DARKGREY(){return e.fromHex(`#a9a9a9`)}static get DARKKHAKI(){return e.fromHex(`#bdb76b`)}static get DARKMAGENTA(){return e.fromHex(`#8b008b`)}static get DARKOLIVEGREEN(){return e.fromHex(`#556b2f`)}static get DARKORANGE(){return e.fromHex(`#ff8c00`)}static get DARKORCHID(){return e.fromHex(`#9932cc`)}static get DARKRED(){return e.fromHex(`#8b0000`)}static get DARKSALMON(){return e.fromHex(`#e9967a`)}static get DARKSEAGREEN(){return e.fromHex(`#8fbc8f`)}static get DARKSLATEBLUE(){return e.fromHex(`#483d8b`)}static get DARKSLATEGRAY(){return e.fromHex(`#2f4f4f`)}static get DARKSLATEGREY(){return e.fromHex(`#2f4f4f`)}static get DARKTURQUOISE(){return e.fromHex(`#00ced1`)}static get DARKVIOLET(){return e.fromHex(`#9400d3`)}static get DEEPPINK(){return e.fromHex(`#ff1493`)}static get DEEPSKYBLUE(){return e.fromHex(`#00bfff`)}static get DIMGRAY(){return e.fromHex(`#696969`)}static get DIMGREY(){return e.fromHex(`#696969`)}static get DODGERBLUE(){return e.fromHex(`#1e90ff`)}static get FIREBRICK(){return e.fromHex(`#b22222`)}static get FLORALWHITE(){return e.fromHex(`#fffaf0`)}static get FORESTGREEN(){return e.fromHex(`#228b22`)}static get GAINSBORO(){return e.fromHex(`#dcdcdc`)}static get GHOSTWHITE(){return e.fromHex(`#f8f8ff`)}static get GOLD(){return e.fromHex(`#ffd700`)}static get GOLDENROD(){return e.fromHex(`#daa520`)}static get GREENYELLOW(){return e.fromHex(`#adff2f`)}static get GREY(){return e.fromHex(`#808080`)}static get HONEYDEW(){return e.fromHex(`#f0fff0`)}static get HOTPINK(){return e.fromHex(`#ff69b4`)}static get INDIANRED(){return e.fromHex(`#cd5c5c`)}static get INDIGO(){return e.fromHex(`#4b0082`)}static get IVORY(){return e.fromHex(`#fffff0`)}static get KHAKI(){return e.fromHex(`#f0e68c`)}static get LAVENDER(){return e.fromHex(`#e6e6fa`)}static get LAVENDERBLUSH(){return e.fromHex(`#fff0f5`)}static get LAWNGREEN(){return e.fromHex(`#7cfc00`)}static get LEMONCHIFFON(){return e.fromHex(`#fffacd`)}static get LIGHTBLUE(){return e.fromHex(`#add8e6`)}static get LIGHTCORAL(){return e.fromHex(`#f08080`)}static get LIGHTCYAN(){return e.fromHex(`#e0ffff`)}static get LIGHTGOLDENRODYELLOW(){return e.fromHex(`#fafad2`)}static get LIGHTGRAY(){return e.fromHex(`#d3d3d3`)}static get LIGHTGREEN(){return e.fromHex(`#90ee90`)}static get LIGHTGREY(){return e.fromHex(`#d3d3d3`)}static get LIGHTPINK(){return e.fromHex(`#ffb6c1`)}static get LIGHTSALMON(){return e.fromHex(`#ffa07a`)}static get LIGHTSEAGREEN(){return e.fromHex(`#20b2aa`)}static get LIGHTSKYBLUE(){return e.fromHex(`#87cefa`)}static get LIGHTSLATEGRAY(){return e.fromHex(`#778899`)}static get LIGHTSLATEGREY(){return e.fromHex(`#778899`)}static get LIGHTSTEELBLUE(){return e.fromHex(`#b0c4de`)}static get LIGHTYELLOW(){return e.fromHex(`#ffffe0`)}static get LIMEGREEN(){return e.fromHex(`#32cd32`)}static get LINEN(){return e.fromHex(`#faf0e6`)}static get MAGENTA(){return e.fromHex(`#ff00ff`)}static get FUCHSIA(){return e.fromHex(`#ff00ff`)}static get MEDIUMAQUAMARINE(){return e.fromHex(`#66cdaa`)}static get MEDIUMBLUE(){return e.fromHex(`#0000cd`)}static get MEDIUMORCHID(){return e.fromHex(`#ba55d3`)}static get MEDIUMPURPLE(){return e.fromHex(`#9370db`)}static get MEDIUMSEAGREEN(){return e.fromHex(`#3cb371`)}static get MEDIUMSLATEBLUE(){return e.fromHex(`#7b68ee`)}static get MEDIUMSPRINGGREEN(){return e.fromHex(`#00fa9a`)}static get MEDIUMTURQUOISE(){return e.fromHex(`#48d1cc`)}static get MEDIUMVIOLETRED(){return e.fromHex(`#c71585`)}static get MIDNIGHTBLUE(){return e.fromHex(`#191970`)}static get MINTCREAM(){return e.fromHex(`#f5fffa`)}static get MISTYROSE(){return e.fromHex(`#ffe4e1`)}static get MOCCASIN(){return e.fromHex(`#ffe4b5`)}static get NAVAJOWHITE(){return e.fromHex(`#ffdead`)}static get OLDLACE(){return e.fromHex(`#fdf5e6`)}static get OLIVEDRAB(){return e.fromHex(`#6b8e23`)}static get ORANGERED(){return e.fromHex(`#ff4500`)}static get ORCHID(){return e.fromHex(`#da70d6`)}static get PALEGOLDENROD(){return e.fromHex(`#eee8aa`)}static get PALEGREEN(){return e.fromHex(`#98fb98`)}static get PALETURQUOISE(){return e.fromHex(`#afeeee`)}static get PALEVIOLETRED(){return e.fromHex(`#db7093`)}static get PAPAYAWHIP(){return e.fromHex(`#ffefd5`)}static get PEACHPUFF(){return e.fromHex(`#ffdab9`)}static get PERU(){return e.fromHex(`#cd853f`)}static get PINK(){return e.fromHex(`#ffc0cb`)}static get PLUM(){return e.fromHex(`#dda0dd`)}static get POWDERBLUE(){return e.fromHex(`#b0e0e6`)}static get ROSYBROWN(){return e.fromHex(`#bc8f8f`)}static get ROYALBLUE(){return e.fromHex(`#4169e1`)}static get SADDLEBROWN(){return e.fromHex(`#8b4513`)}static get SALMON(){return e.fromHex(`#fa8072`)}static get SANDYBROWN(){return e.fromHex(`#f4a460`)}static get SEAGREEN(){return e.fromHex(`#2e8b57`)}static get SEASHELL(){return e.fromHex(`#fff5ee`)}static get SIENNA(){return e.fromHex(`#a0522d`)}static get SKYBLUE(){return e.fromHex(`#87ceeb`)}static get SLATEBLUE(){return e.fromHex(`#6a5acd`)}static get SLATEGRAY(){return e.fromHex(`#708090`)}static get SLATEGREY(){return e.fromHex(`#708090`)}static get SNOW(){return e.fromHex(`#fffafa`)}static get SPRINGGREEN(){return e.fromHex(`#00ff7f`)}static get STEELBLUE(){return e.fromHex(`#4682b4`)}static get TAN(){return e.fromHex(`#d2b48c`)}static get THISTLE(){return e.fromHex(`#d8bfd8`)}static get TOMATO(){return e.fromHex(`#ff6347`)}static get TURQUOISE(){return e.fromHex(`#40e0d0`)}static get VIOLET(){return e.fromHex(`#ee82ee`)}static get WHEAT(){return e.fromHex(`#f5deb3`)}static get WHITESMOKE(){return e.fromHex(`#f5f5f5`)}static get YELLOWGREEN(){return e.fromHex(`#9acd32`)}static get REBECCAPURPLE(){return e.fromHex(`#663399`)}};getScheme(t,n){return e.createScheme(this,t,n)}static getScheme(t,n,r){return e.createScheme(t,n,r)}static monochromatic(t,n){this.ic(t,e);let r=this.oc(n).results||3,i=e.toHsv(t),a=i.h,o=i.s,s=i.v/100,c=[],l=1/r;for(;r--;)c.push(e.fromHsv(a,o,this.clmp(s*100,100,0))),s=(s-l)%1;return c}monochromatic(t){return e.monochromatic(this,t)}static complementary(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l;return e.fromHsl(this.shift(r,180),i,a)}complementary(){return e.complementary(this)}static splitComplementary(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle||15,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180+i),o,s),e.fromHsl(this.shift(a,180-i),o,s)]}splitComplementary(t){return e.splitComplementary(this,t)}static doubleComplementary(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle||15,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180),o,s),e.fromHsl(this.shift(a,i),o,s),e.fromHsl(this.shift(a,180+i),o,s)]}doubleComplementary(t){return e.doubleComplementary(this,t)}static square(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l,o=[t];for(let t=1;t<4;t++)r=this.shift(r,90),o.push(e.fromHsl(r,i,a));return o}square(){return e.square(this)}static tetradic(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,180),o,s),e.fromHsl(this.shift(a,180-i),o,s),e.fromHsl(this.shift(a,-i),o,s)]}tetradic(t){return e.tetradic(this,t)}static triadic(t){this.ic(t,e);let n=e.toHsl(t),r=n.h,i=n.s,a=n.l;return[t,e.fromHsl(this.shift(r,120),i,a),e.fromHsl(this.shift(r,240),i,a)]}triadic(){return e.triadic(this)}static analogous(t,n){this.ic(t,e);let r=e.toHsl(t),i=this.oc(n).angle,a=r.h,o=r.s,s=r.l;return[t,e.fromHsl(this.shift(a,-i),o,s),e.fromHsl(this.shift(a,+i),o,s)]}analogous(t){return e.analogous(this,t)}static createScheme(t,n,r){switch(n.toLowerCase()){case`analogous`:case`analog`:return e.analogous(t,r);case`triadic`:case`triad`:return e.triadic(t);case`tetradic`:case`tetra`:return e.tetradic(t,r);case`monochromatic`:case`monochrome`:case`mono`:return e.monochromatic(t,r);case`complementary`:case`complement`:case`comp`:return e.complementary(t);case`double-complementary`:case`double-complement`:case`double`:return e.doubleComplementary(t,r);case`split-complementary`:case`split-complement`:case`split`:return e.splitComplementary(t,r);case`square`:return e.square(t)}return null}constructor(t,n,r){if(!(0<=t&&t<=255&&0<=n&&n<=255&&0<=r&&r<=255))throw Error(`Color values out of bounds (0 - 255)`);this.#e=e.nc(e.tc(t,`number`)),this.#t=e.nc(e.tc(n,`number`)),this.#n=e.nc(e.tc(r,`number`)),this.alpha=1}static saturate(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=this.clmp(r.s+n,100,0),o=r.l;return e.fromHsl(i,a,o)}saturate(t){return e.saturate(this,t)}static desaturate(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=this.clmp(r.s-n,100,0),o=r.l;return e.fromHsl(i,a,o)}desaturate(t){return e.desaturate(this,t)}static grayscale(t){return e.desaturate(t,100)}grayscale(){return e.greyscale(this)}static greyscale(t){return e.desaturate(t,100)}greyscale(){return e.greyscale(this)}static lighten(t,n){this.ic(t,e),this.tc(n,`number`);let r=t.toHsl(),i=r.h,a=r.s,o=this.clmp(r.l+n,100,0);return e.fromHsl(i,a,o)}lighten(t){return e.lighten(this,t)}static darken(t,n){return e.lighten(t,-n)}darken(t){return e.darken(this,t)}static brighten(t,n){let r=t.toRgb();return r.r=Math.max(0,Math.min(255,r.r-Math.round(255*-(n/100)))),r.g=Math.max(0,Math.min(255,r.g-Math.round(255*-(n/100)))),r.b=Math.max(0,Math.min(255,r.b-Math.round(255*-(n/100)))),new e(r.r,r.g,r.b)}brighten(t){return e.brighten(this,t)}static shiftHue(t,n){this.ic(t,e),this.tc(n,Number);let{h:r,s:i,l:a}=t.toHsl();return r=this.shift(r,n),e.fromHsl(r,i,a)}shiftHue(t){return e.shiftHue(this,t)}static multiply(t,n){this.ic(t,e),this.ic(n,e);let{r1:r,g1:i,b1:a}=t.toRgb(),{r2:o,g2:s,b2:c}=n.toRgb();return e.fromRgb(r*o/255,i*s/255,a*c/255)}multiply(t){return e.multiply(this,t)}static mix(t,n,r=50){this.ic(t,e),this.ic(t,e),this.tc(r,`number`);let i=t.toRgb(),a=n.toRgb(),o=this.clmp(r,100,0)/100,s=Math.round((a.r-i.r)*o+i.r),c=Math.round((a.g-i.g)*o+i.g),l=Math.round((a.b-i.b)*o+i.b);return e.fromRgb(s,c,l)}mix(t,n){return e.mix(this,t,n)}static lerp(t,n,r=.5){this.tc(r,`number`),this.ic(t,e),this.ic(n,e),r=this.clmp(r,1,0);let i=t.toRgb(),a=n.toRgb(),o=i.r/255,s=i.g/255,c=i.b/255,l=a.r/255,u=a.g/255,d=a.b/255;return e.fromRgb((o+(l-o)*r)*255,(s+(u-s)*r)*255,(c+(d-c)*r)*255)}lerp(t,n){return e.lerp(this,t,n)}static add(t,n){this.ic(t,e),this.ic(n,e);let r=t.toRgb(),i=n.toRgb(),a=r.r,o=r.g,s=r.b,c=i.r,l=i.g,u=i.b;return e.fromRgb(Math.round((a+c)/2),Math.round((o+l)/2),Math.round((s+u)/2))}add(t){return e.add(this,t)}static fromHex(t){if(!t.match(/^#?(?:[0-9a-fA-F]{3}){1,2}$/i))throw Error(`Invalid Hex code: "`+t+`"`);let n=`0x00`,r=`0x00`,i=`0x00`;return t.length==4?(n=`0x`+t[1]+t[1],r=`0x`+t[2]+t[2],i=`0x`+t[3]+t[3]):t.length==3?(n=`0x`+t[0]+t[0],r=`0x`+t[1]+t[1],i=`0x`+t[2]+t[2]):t.length==7?(n=`0x`+t[1]+t[2],r=`0x`+t[3]+t[4],i=`0x`+t[5]+t[6]):t.length==6&&(n=`0x`+t[0]+t[1],r=`0x`+t[2]+t[3],i=`0x`+t[4]+t[5]),new e(parseInt(n,16),parseInt(r,16),parseInt(i,16))}static fromRgb(t,n,r){return new e(t,n,r)}static fromHsl(t,n,r){if(t=this.tc(t,`number`),n=this.tc(n,`number`),r=this.tc(r,`number`),!(0<=t&&t<=360))throw Error(`HSL color values out of range, hue (0 - 360)`);if(!(0<=n&&n<=100))throw Error(`HSL color values out of range, sat (0 - 100)`);if(!(0<=r&&r<=100))throw Error(`HSL color values out of range, lum (0 - 100)`);n/=100,r/=100;let i=(1-Math.abs(2*r-1))*n,a=i*(1-Math.abs(t/60%2-1)),o=r-i/2,s=0,c=0,l=0;return 0<=t&&t<60?(s=i,c=a,l=0):60<=t&&t<120?(s=a,c=i,l=0):120<=t&&t<180?(s=0,c=i,l=a):180<=t&&t<240?(s=0,c=a,l=i):240<=t&&t<300?(s=a,c=0,l=i):300<=t&&t<=360&&(s=i,c=0,l=a),new e(Math.round((s+o)*255),Math.round((c+o)*255),Math.round((l+o)*255))}static fromHsv(t,n,r){if(t=this.tc(t,`number`),n=this.tc(n,`number`),r=this.tc(r,`number`),!(0<=t&&t<=360))throw Error(`HSL color values out of range, hue (0 - 360)`);if(!(0<=n&&n<=100))throw Error(`HSL color values out of range, sat (0 - 100)`);if(!(0<=r&&r<=100))throw Error(`HSL color values out of range, lum (0 - 100)`);n/=100,r/=100;let i=r*n,a=i*(1-Math.abs(t/60%2-1)),o=r-i,s=0,c=0,l=0;return 0<=t&&t<60?(s=i,c=a,l=0):60<=t&&t<120?(s=a,c=i,l=0):120<=t&&t<180?(s=0,c=i,l=a):180<=t&&t<240?(s=0,c=a,l=i):240<=t&&t<300?(s=a,c=0,l=i):300<=t&&t<=360&&(s=i,c=0,l=a),new e((s+o)*255,(c+o)*255,(l+o)*255)}static fromCssString(t){this.tc(t,`string`);var n=document.createElement(`canvas`).getContext(`2d`);let r;if(n&&(n.fillStyle=t,r=n.fillStyle),!r)throw Error(`Invalid Color string`);return e.fromHex(r)}static fromName(e){e=this.tc(e,`string`);let t=this.Colors[e.toUpperCase()];if(!t)throw Error(`Invalid Color name`);return t}static toHex(t){t=this.ic(t,e);let n=Math.round(t.#e).toString(16),r=Math.round(t.#t).toString(16),i=Math.round(t.#n).toString(16);return n.length==1&&(n=`0`+n),r.length==1&&(r=`0`+r),i.length==1&&(i=`0`+i),`#`+n+r+i}static toHsl(t){t=this.ic(t,e);let n=0,r=0,i=0,a=t.#e/255,o=t.#t/255,s=t.#n/255,c=Math.min(Math.min(a,o),s),l=Math.max(Math.max(a,o),s),u=l-c;return n=u===0?0:l===a?(o-s)/u%6:l===o?(s-a)/u+2:(a-o)/u+4,n=Math.round(n*60),n<0&&(n+=360),i=(l+c)/2,r=u===0?0:u/(1-Math.abs(2*i-1)),r=parseFloat(Math.abs(r*100)+``),i=parseFloat(Math.abs(i*100)+``),{h:this.nc(n),s:this.nc(r),l:this.nc(i)}}static toHsv(e){let t=0,n=0,r=0,i=e.#e/255,a=e.#t/255,o=e.#n/255,s=Math.min(Math.min(i,a),o),c=Math.max(Math.max(i,a),o),l=c-s;return t=l===0?0:c===i?(a-o)/l%6:c===a?(o-i)/l+2:(i-a)/l+4,t=Math.round(t*60),t<0&&(t+=360),c!==0&&(n=l/c*100),r=c*100,{h:this.nc(t),s:this.nc(n),v:this.nc(r)}}static toRgb(t){return this.ic(t,e),{r:t.#e,g:t.#t,b:t.#n}}static toCmyk(t){this.ic(t,e);let{r:n,g:r,b:i}=t.toRgb(),a=1-n/255,o=1-r/255,s=1-i/255,c=Math.min(a,Math.min(o,s));return a=(a-c)/(1-c),o=(o-c)/(1-c),s=(s-c)/(1-c),a=this.nc(Math.round(a*1e4)/100),o=this.nc(Math.round(o*1e4)/100),s=this.nc(Math.round(s*1e4)/100),c=this.nc(Math.round(c*1e4)/100),{c:a,m:o,y:s,k:c}}toHsl(){return e.toHsl(this)}toHsv(){return e.toHsv(this)}toHex(){return e.toHex(this)}toRgb(){return e.toRgb(this)}toCmyk(){return e.toCmyk(this)}static random(){return new e(Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255))}toString(t=`hex`){e.tc(t,`string`);let n=this.toRgb(),r=this.toHsl();switch(t.toLowerCase()){case`hex`:return this.toHex();case`hexa`:let e=Math.round(this.alpha*255).toString(16);return e.length===1&&(e=`0`+e),this.toHex()+e;case`rgb`:return`rgb(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)})`;case`rgba`:return`rgba(${Math.round(n.r)}, ${Math.round(n.g)}, ${Math.round(n.b)}, ${this.alpha})`;case`hsl`:return`hsl(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(r.l)}%)`;case`hsla`:return`hsla(${Math.round(r.h)}, ${Math.round(r.s)}%, ${Math.round(r.l)}%, ${this.alpha})`;case`hsv`:let t=this.toHsv();return`hsv(${Math.round(t.h)}, ${Math.round(t.s)}%, ${Math.round(t.v)}%)`;case`cmyk`:let i=this.toCmyk();return`cmyk(${Math.round(i.c)}%, ${Math.round(i.m)}%, ${Math.round(i.y)}%, ${Math.round(i.k)}%)`;default:}return``}valueOf(){return parseInt(`0x`+this.toHex().slice(1))}},oa=class extends Error{sourceStart;sourceEnd;parserState;constructor(e,t,n,r){super(e),this.name=`ParseError`,this.sourceStart=t,this.sourceEnd=n,this.parserState=r}},sa=class extends oa{token;constructor(e,t,n,r,i){super(e,t,n,r),this.token=i}};const ca={UnexpectedNewLineInString:`Unexpected newline while consuming a string token.`,UnexpectedEOFInString:`Unexpected EOF while consuming a string token.`,UnexpectedEOFInComment:`Unexpected EOF while consuming a comment.`,UnexpectedEOFInURL:`Unexpected EOF while consuming a url token.`,UnexpectedEOFInEscapedCodePoint:`Unexpected EOF while consuming an escaped code point.`,UnexpectedCharacterInURL:`Unexpected character while consuming a url token.`,InvalidEscapeSequenceInURL:`Invalid escape sequence while consuming a url token.`,InvalidEscapeSequenceAfterBackslash:`Invalid escape sequence after "\\"`};typeof globalThis<`u`&&`structuredClone`in globalThis;function la(...e){let t=``;for(let n=0;n<e.length;n++)t+=e[n][1];return t}const ua=65533;function da(e){return e.source.codePointAt(e.cursor)===60&&e.source.codePointAt(e.cursor+1)===33&&e.source.codePointAt(e.cursor+2)===45&&e.source.codePointAt(e.cursor+3)===45}function fa(e){return e>=48&&e<=57}function pa(e){return e>=65&&e<=90}function ma(e){return e>=97&&e<=122}function ha(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function ga(e){return ma(e)||pa(e)}function _a(e){return ga(e)||ya(e)||e===95}function va(e){return _a(e)||fa(e)||e===45}function ya(e){return e===183||e===8204||e===8205||e===8255||e===8256||e===8204||192<=e&&e<=214||216<=e&&e<=246||248<=e&&e<=893||895<=e&&e<=8191||8304<=e&&e<=8591||11264<=e&&e<=12271||12289<=e&&e<=55295||63744<=e&&e<=64975||65008<=e&&e<=65533||e===0||!!Ca(e)||e>=65536}function ba(e){return e===11||e===127||0<=e&&e<=8||14<=e&&e<=31}function xa(e){return e===10||e===13||e===12}function Sa(e){return e===32||e===10||e===9||e===13||e===12}function Ca(e){return e>=55296&&e<=57343}function wa(e){return e.source.codePointAt(e.cursor)===92&&!xa(e.source.codePointAt(e.cursor+1)??-1)}function Ta(e,t){return t.source.codePointAt(t.cursor)===45?t.source.codePointAt(t.cursor+1)===45||!!_a(t.source.codePointAt(t.cursor+1)??-1)||t.source.codePointAt(t.cursor+1)===92&&!xa(t.source.codePointAt(t.cursor+2)??-1):!!_a(t.source.codePointAt(t.cursor)??-1)||wa(t)}function Ea(e){return e.source.codePointAt(e.cursor)===43||e.source.codePointAt(e.cursor)===45?!!fa(e.source.codePointAt(e.cursor+1)??-1)||e.source.codePointAt(e.cursor+1)===46&&fa(e.source.codePointAt(e.cursor+2)??-1):e.source.codePointAt(e.cursor)===46?fa(e.source.codePointAt(e.cursor+1)??-1):fa(e.source.codePointAt(e.cursor)??-1)}function Da(e){return e.source.codePointAt(e.cursor)===47&&e.source.codePointAt(e.cursor+1)===42}function Oa(e){return e.source.codePointAt(e.cursor)===45&&e.source.codePointAt(e.cursor+1)===45&&e.source.codePointAt(e.cursor+2)===62}var z,B,ka;function Aa(e){switch(e){case z.OpenParen:return z.CloseParen;case z.CloseParen:return z.OpenParen;case z.OpenCurly:return z.CloseCurly;case z.CloseCurly:return z.OpenCurly;case z.OpenSquare:return z.CloseSquare;case z.CloseSquare:return z.OpenSquare;default:return null}}function ja(e){switch(e[0]){case z.OpenParen:return[z.CloseParen,`)`,-1,-1,void 0];case z.CloseParen:return[z.OpenParen,`(`,-1,-1,void 0];case z.OpenCurly:return[z.CloseCurly,`}`,-1,-1,void 0];case z.CloseCurly:return[z.OpenCurly,`{`,-1,-1,void 0];case z.OpenSquare:return[z.CloseSquare,`]`,-1,-1,void 0];case z.CloseSquare:return[z.OpenSquare,`[`,-1,-1,void 0];default:return null}}function Ma(e,t){for(t.advanceCodePoint(2);;){let n=t.readCodePoint();if(n===void 0){let n=[z.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new sa(ca.UnexpectedEOFInComment,t.representationStart,t.representationEnd,[`4.3.2. Consume comments`,`Unexpected EOF`],n)),n}if(n===42&&t.source.codePointAt(t.cursor)!==void 0&&t.source.codePointAt(t.cursor)===47){t.advanceCodePoint();break}}return[z.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0]}function Na(e,t){let n=t.readCodePoint();if(n===void 0)return e.onParseError(new oa(ca.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,[`4.3.7. Consume an escaped code point`,`Unexpected EOF`])),ua;if(ha(n)){let e=[n],r;for(;(r=t.source.codePointAt(t.cursor))!==void 0&&ha(r)&&e.length<6;)e.push(r),t.advanceCodePoint();Sa(t.source.codePointAt(t.cursor)??-1)&&(t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10&&t.advanceCodePoint(),t.advanceCodePoint());let i=parseInt(String.fromCodePoint(...e),16);return i===0||Ca(i)||i>1114111?ua:i}return n===0||Ca(n)?ua:n}function Pa(e,t){let n=[];for(;;){let r=t.source.codePointAt(t.cursor)??-1;if(r===0||Ca(r))n.push(ua),t.advanceCodePoint(+(r>65535)+1);else if(va(r))n.push(r),t.advanceCodePoint(+(r>65535)+1);else{if(!wa(t))return n;t.advanceCodePoint(),n.push(Na(e,t))}}}function Fa(e,t){t.advanceCodePoint();let n=t.source.codePointAt(t.cursor);if(n!==void 0&&(va(n)||wa(t))){let n=ka.Unrestricted;Ta(0,t)&&(n=ka.ID);let r=Pa(e,t);return[z.Hash,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...r),type:n}]}return[z.Delim,`#`,t.representationStart,t.representationEnd,{value:`#`}]}function Ia(e,t){let n=B.Integer;for(t.source.codePointAt(t.cursor)!==43&&t.source.codePointAt(t.cursor)!==45||t.advanceCodePoint();fa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===46&&fa(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint(2),n=B.Number;fa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===101||t.source.codePointAt(t.cursor)===69){if(fa(t.source.codePointAt(t.cursor+1)??-1))t.advanceCodePoint(2);else{if(t.source.codePointAt(t.cursor+1)!==45&&t.source.codePointAt(t.cursor+1)!==43||!fa(t.source.codePointAt(t.cursor+2)??-1))return n;t.advanceCodePoint(3)}for(n=B.Number;fa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint()}return n}function La(e,t){let n;{let e=t.source.codePointAt(t.cursor);e===45?n=`-`:e===43&&(n=`+`)}let r=Ia(0,t),i=parseFloat(t.source.slice(t.representationStart,t.representationEnd+1));if(Ta(0,t)){let a=Pa(e,t);return[z.Dimension,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n,type:r,unit:String.fromCodePoint(...a)}]}return t.source.codePointAt(t.cursor)===37?(t.advanceCodePoint(),[z.Percentage,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n}]):[z.Number,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n,type:r}]}function Ra(e){for(;Sa(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return[z.Whitespace,e.source.slice(e.representationStart,e.representationEnd+1),e.representationStart,e.representationEnd,void 0]}(function(e){e.Comment=`comment`,e.AtKeyword=`at-keyword-token`,e.BadString=`bad-string-token`,e.BadURL=`bad-url-token`,e.CDC=`CDC-token`,e.CDO=`CDO-token`,e.Colon=`colon-token`,e.Comma=`comma-token`,e.Delim=`delim-token`,e.Dimension=`dimension-token`,e.EOF=`EOF-token`,e.Function=`function-token`,e.Hash=`hash-token`,e.Ident=`ident-token`,e.Number=`number-token`,e.Percentage=`percentage-token`,e.Semicolon=`semicolon-token`,e.String=`string-token`,e.URL=`url-token`,e.Whitespace=`whitespace-token`,e.OpenParen=`(-token`,e.CloseParen=`)-token`,e.OpenSquare=`[-token`,e.CloseSquare=`]-token`,e.OpenCurly=`{-token`,e.CloseCurly=`}-token`,e.UnicodeRange=`unicode-range-token`})(z||={}),function(e){e.Integer=`integer`,e.Number=`number`}(B||={}),function(e){e.Unrestricted=`unrestricted`,e.ID=`id`}(ka||={});var za=class{cursor=0;source=``;representationStart=0;representationEnd=-1;constructor(e){this.source=e}advanceCodePoint(e=1){this.cursor+=e,this.representationEnd=this.cursor-1}readCodePoint(){let e=this.source.codePointAt(this.cursor);if(e!==void 0)return this.cursor+=1,this.representationEnd=this.cursor-1,e}unreadCodePoint(e=1){this.cursor-=e,this.representationEnd=this.cursor-1}resetRepresentation(){this.representationStart=this.cursor,this.representationEnd=-1}};function Ba(e,t){let n=``,r=t.readCodePoint();for(;;){let i=t.readCodePoint();if(i===void 0){let r=[z.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new sa(ca.UnexpectedEOFInString,t.representationStart,t.representationEnd,[`4.3.5. Consume a string token`,`Unexpected EOF`],r)),r}if(xa(i)){t.unreadCodePoint();let n=[z.BadString,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new sa(ca.UnexpectedNewLineInString,t.representationStart,t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10?t.representationEnd+2:t.representationEnd+1,[`4.3.5. Consume a string token`,`Unexpected newline`],n)),n}if(i===r)return[z.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(i!==92)i===0||Ca(i)?n+=String.fromCodePoint(ua):n+=String.fromCodePoint(i);else{if(t.source.codePointAt(t.cursor)===void 0)continue;if(xa(t.source.codePointAt(t.cursor)??-1)){t.source.codePointAt(t.cursor)===13&&t.source.codePointAt(t.cursor+1)===10&&t.advanceCodePoint(),t.advanceCodePoint();continue}n+=String.fromCodePoint(Na(e,t))}}}function Va(e){return!(e.length!==3||e[0]!==117&&e[0]!==85||e[1]!==114&&e[1]!==82||e[2]!==108&&e[2]!==76)}function Ha(e,t){for(;;){let n=t.source.codePointAt(t.cursor);if(n===void 0)return;if(n===41)return void t.advanceCodePoint();wa(t)?(t.advanceCodePoint(),Na(e,t)):t.advanceCodePoint()}}function Ua(e,t){for(;Sa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();let n=``;for(;;){if(t.source.codePointAt(t.cursor)===void 0){let r=[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new sa(ca.UnexpectedEOFInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Unexpected EOF`],r)),r}if(t.source.codePointAt(t.cursor)===41)return t.advanceCodePoint(),[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(Sa(t.source.codePointAt(t.cursor)??-1)){for(t.advanceCodePoint();Sa(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===void 0){let r=[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new sa(ca.UnexpectedEOFInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Consume as much whitespace as possible`,`Unexpected EOF`],r)),r}return t.source.codePointAt(t.cursor)===41?(t.advanceCodePoint(),[z.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}]):(Ha(e,t),[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0])}let r=t.source.codePointAt(t.cursor);if(r===34||r===39||r===40||ba(r??-1)){Ha(e,t);let n=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new sa(ca.UnexpectedCharacterInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`Unexpected U+0022 QUOTATION MARK ("), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point`],n)),n}if(r===92){if(wa(t)){t.advanceCodePoint(),n+=String.fromCodePoint(Na(e,t));continue}Ha(e,t);let r=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new sa(ca.InvalidEscapeSequenceInURL,t.representationStart,t.representationEnd,[`4.3.6. Consume a url token`,`U+005C REVERSE SOLIDUS (\\)`,`The input stream does not start with a valid escape sequence`],r)),r}t.source.codePointAt(t.cursor)===0||Ca(t.source.codePointAt(t.cursor)??-1)?(n+=String.fromCodePoint(ua),t.advanceCodePoint()):(n+=t.source[t.cursor],t.advanceCodePoint())}}function Wa(e,t){let n=Pa(e,t);if(t.source.codePointAt(t.cursor)!==40)return[z.Ident,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];if(Va(n)){t.advanceCodePoint();let r=0;for(;;){let e=Sa(t.source.codePointAt(t.cursor)??-1),i=Sa(t.source.codePointAt(t.cursor+1)??-1);if(e&&i){r+=1,t.advanceCodePoint(1);continue}let a=e?t.source.codePointAt(t.cursor+1):t.source.codePointAt(t.cursor);if(a===34||a===39)return r>0&&t.unreadCodePoint(r),[z.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];break}return Ua(e,t)}return t.advanceCodePoint(),[z.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}]}function Ga(e){return!(e.source.codePointAt(e.cursor)!==117&&e.source.codePointAt(e.cursor)!==85||e.source.codePointAt(e.cursor+1)!==43||e.source.codePointAt(e.cursor+2)!==63&&!ha(e.source.codePointAt(e.cursor+2)??-1))}function Ka(e,t){t.advanceCodePoint(2);let n=[],r=[],i;for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&ha(i);)n.push(i),t.advanceCodePoint();for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&i===63;)r.length===0&&r.push(...n),n.push(48),r.push(70),t.advanceCodePoint();if(!r.length&&t.source.codePointAt(t.cursor)===45&&ha(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint();(i=t.source.codePointAt(t.cursor))!==void 0&&r.length<6&&ha(i);)r.push(i),t.advanceCodePoint();if(!r.length){let e=parseInt(String.fromCodePoint(...n),16);return[z.UnicodeRange,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{startOfRange:e,endOfRange:e}]}let a=parseInt(String.fromCodePoint(...n),16),o=parseInt(String.fromCodePoint(...r),16);return[z.UnicodeRange,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{startOfRange:a,endOfRange:o}]}function qa(e,t){let n=Ja(e,t),r=[];for(;!n.endOfFile();)r.push(n.nextToken());return r.push(n.nextToken()),r}function Ja(e,t){let n=e.css.valueOf(),r=e.unicodeRangesAllowed??!1,i=new za(n),a={onParseError:t?.onParseError??Ya};return{nextToken:function(){i.resetRepresentation();let e=i.source.codePointAt(i.cursor);if(e===void 0)return[z.EOF,``,-1,-1,void 0];if(e===47&&Da(i))return Ma(a,i);if(r&&(e===117||e===85)&&Ga(i))return Ka(0,i);if(_a(e))return Wa(a,i);if(fa(e))return La(a,i);switch(e){case 44:return i.advanceCodePoint(),[z.Comma,`,`,i.representationStart,i.representationEnd,void 0];case 58:return i.advanceCodePoint(),[z.Colon,`:`,i.representationStart,i.representationEnd,void 0];case 59:return i.advanceCodePoint(),[z.Semicolon,`;`,i.representationStart,i.representationEnd,void 0];case 40:return i.advanceCodePoint(),[z.OpenParen,`(`,i.representationStart,i.representationEnd,void 0];case 41:return i.advanceCodePoint(),[z.CloseParen,`)`,i.representationStart,i.representationEnd,void 0];case 91:return i.advanceCodePoint(),[z.OpenSquare,`[`,i.representationStart,i.representationEnd,void 0];case 93:return i.advanceCodePoint(),[z.CloseSquare,`]`,i.representationStart,i.representationEnd,void 0];case 123:return i.advanceCodePoint(),[z.OpenCurly,`{`,i.representationStart,i.representationEnd,void 0];case 125:return i.advanceCodePoint(),[z.CloseCurly,`}`,i.representationStart,i.representationEnd,void 0];case 39:case 34:return Ba(a,i);case 35:return Fa(a,i);case 43:case 46:return Ea(i)?La(a,i):(i.advanceCodePoint(),[z.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]);case 10:case 13:case 12:case 9:case 32:return Ra(i);case 45:return Ea(i)?La(a,i):Oa(i)?(i.advanceCodePoint(3),[z.CDC,`-->`,i.representationStart,i.representationEnd,void 0]):Ta(0,i)?Wa(a,i):(i.advanceCodePoint(),[z.Delim,`-`,i.representationStart,i.representationEnd,{value:`-`}]);case 60:return da(i)?(i.advanceCodePoint(4),[z.CDO,`<!--`,i.representationStart,i.representationEnd,void 0]):(i.advanceCodePoint(),[z.Delim,`<`,i.representationStart,i.representationEnd,{value:`<`}]);case 64:if(i.advanceCodePoint(),Ta(0,i)){let e=Pa(a,i);return[z.AtKeyword,i.source.slice(i.representationStart,i.representationEnd+1),i.representationStart,i.representationEnd,{value:String.fromCodePoint(...e)}]}return[z.Delim,`@`,i.representationStart,i.representationEnd,{value:`@`}];case 92:{if(wa(i))return Wa(a,i);i.advanceCodePoint();let e=[z.Delim,`\\`,i.representationStart,i.representationEnd,{value:`\\`}];return a.onParseError(new sa(ca.InvalidEscapeSequenceAfterBackslash,i.representationStart,i.representationEnd,[`4.3.1. Consume a token`,`U+005C REVERSE SOLIDUS (\\)`,`The input stream does not start with a valid escape sequence`],e)),e}}return i.advanceCodePoint(),[z.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]},endOfFile:function(){return i.source.codePointAt(i.cursor)===void 0}}}function Ya(){}function Xa(e,t){let n=[];for(let e of t)n.push(e.codePointAt(0));let r=Za(n);r[0]===101&&$a(r,0,r[0]);let i=String.fromCodePoint(...r);e[1]=`${e[4].signCharacter===`+`?e[4].signCharacter:``}${e[4].value.toString()}${i}`,e[4].unit=t}function Za(e){let t=0;if(e[0]===0)e.splice(0,1,ua),t=1;else if(e[0]===45&&e[1]===45)t=2;else if(e[0]===45&&e[1])t=2,_a(e[1])||(t+=$a(e,1,e[1]));else{if(e[0]===45&&!e[1])return[92,e[0]];_a(e[0])?t=1:(t=1,t+=$a(e,0,e[0]))}for(let n=t;n<e.length;n++)e[n]===0?(e.splice(n,1,ua),n++):va(e[n])||(n+=Qa(e,n,e[n]));return e}function Qa(e,t,n){return e.splice(t,1,92,n),1}function $a(e,t,n){let r=n.toString(16),i=[];for(let e of r)i.push(e.codePointAt(0));return e.splice(t,1,92,...i,32),1+i.length}const eo=Object.values(z);function to(e){return!!Array.isArray(e)&&!(e.length<4)&&!!eo.includes(e[0])&&typeof e[1]==`string`&&typeof e[2]==`number`&&typeof e[3]==`number`}function V(e){if(!e)return!1;switch(e[0]){case z.Dimension:case z.Number:case z.Percentage:return!0;default:return!1}}function no(e){if(!e)return!1;switch(e[0]){case z.Whitespace:case z.Comment:return!0;default:return!1}}function ro(e){return!!e&&e[0]===z.Colon}function io(e){return!!e&&e[0]===z.Comma}function ao(e){return!!e&&e[0]===z.Comment}function oo(e){return!!e&&e[0]===z.Delim}function H(e){return!!e&&e[0]===z.Dimension}function so(e){return!!e&&e[0]===z.EOF}function co(e){return!!e&&e[0]===z.Function}function lo(e){return!!e&&e[0]===z.Hash}function U(e){return!!e&&e[0]===z.Ident}function W(e){return!!e&&e[0]===z.Number}function G(e){return!!e&&e[0]===z.Percentage}function uo(e){return!!e&&e[0]===z.Semicolon}function fo(e){return!!e&&e[0]===z.Whitespace}function po(e){return!!e&&e[0]===z.OpenParen}function mo(e){return!!e&&e[0]===z.CloseParen}function ho(e){return!!e&&e[0]===z.OpenSquare}function go(e){return!!e&&e[0]===z.OpenCurly}function _o(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}const vo=[.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124];
|
|
721
|
+
`}u.push({lib:`Aventus@I18n`,code:t})}if(t.libSrc=u,r.length>0){let e=this.buildConfig.fullname+`_dependencyErrors`;Vi.send(e,r.join(`
|
|
722
|
+
`)),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(){we.startSendBuildTime(this.buildConfig.fullname),this.allowBuild=!1;let e=await Bi.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),we.sendBuildTime(this.buildConfig.fullname)}async registerFile(e,t){if(e.uri.endsWith(w.ComponentStyle))this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new _i(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 vi(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 Qi(e,!0,this),t||await this.tsLanguageService.i18nFiles[e.uri].validate(),this.registerOnFileDelete(e)):this.i18nComponentsFiles[e.uri]||(this.i18nComponentsFiles[e.uri]=new Qi(e,!1,this),t||await this.i18nComponentsFiles[e.uri].validate(),this.registerOnFileDelete(e));else if(!this.tsFiles[e.uri]){let t=Ai(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(D(n.fileUri),e);if(t)return{class:t,isLocal:!1}}return{class:n,isLocal:!1}}}}getWebComponentDefinitionFile(e){let t=this.htmlLanguageService.getInternalDefinition(e);if(t)return t;let n=this.htmlLanguageService.getClassByTag(e);if(n)return this.externalPackageInformation.getExternalWebComponentDefinitionFile(n)}getSlotsInfo(e){let t={},n=[],r=!1,i=e;for(;i&&i.fullName!=`Aventus.WebComponent`;){let a=this.tsFiles[i.fileUri];if(!a){let a=this.externalPackageInformation.getByFullName(i.fullName);if(a&&a.content!=`noCode`&&a.content.slots&&!r)for(let r in a.content.slots)n.includes(r)||(t[r]||(t[r]={local:i==e}),!t[r].doc&&i.documentation?.documentationSlots[r]&&(t[r].doc=i.documentation?.documentationSlots[r]))}else if(a instanceof F&&a.HTMLFile?.fileParsed?.slotsInfo&&!r){for(let r in a.HTMLFile.fileParsed.slotsInfo)n.includes(r)||(t[r]||(t[r]={local:i==e}),!t[r].doc&&i.documentation?.documentationSlots[r]&&(t[r].doc=i.documentation?.documentationSlots[r]));for(let e in a.HTMLFile.fileParsed.blocksInfo)t[e]||n.push(e)}i.decorators.find(e=>In.is(e))&&(r=!0),i=i.parentClass}return t}getNamespaceForUri(e){if(this.buildConfig.namespaceStrategy==`manual`)return``;if(this.buildConfig.namespaceStrategy==`rules`){let t=D(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=D(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]);Ni.send(this.project.getConfigFile().path,this.buildConfig.fullname)}writeFile(e,t){Ye(e,t,`build`,this.buildConfig.fullname)}},ea=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}}},ta=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){we.startSendStaticTime(this.name);let e=e=>{var t=[],n=e=>((0,u.existsSync)(e)&&(0,u.readdirSync)(e).forEach(r=>{let i=e+`/`+r;if((0,u.lstatSync)(i).isDirectory()){let e=n(i);e.length>0&&t.concat(e)}else t.push(i)}),t);return t=n(e),t},t=(e,t)=>{try{t=(0,f.normalize)(t);let n=t.split(f.sep),r=n.pop(),i=n.join(f.sep);if((0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0}),r.endsWith(`.scss`)){if(!r.startsWith(`_`)){let n=(0,le.compile)(e,{style:`compressed`}).css.toString().trim();Ye(t.replace(`.scss`,`.css`),n,`static`,this.name)}}else (0,u.copyFileSync)(e,t),we.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[E(e)];if(!t){let n=d.TextDocument.create(E(e),w.GlobalStyle,1,(0,u.readFileSync)(e,`utf8`));await R.getInstance().registerFile(n),t=this.project.scssFiles[E(e)]}await t.addOutPath(r,this.name)}}else t(e,r)}}j.getInstance().reload(),we.sendStaticTime(this.name)}}registerWatcher(){T.getInstance().settings.watchFiles&&(this.watcher=(0,v.watch)(this.staticConfig.inputPathFolder,{ignored:/^\./,persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:100},ignoreInitial:!0}),this.watcher.on(`add`,e=>{this.export()}),this.watcher.on(`change`,e=>{this.export()}),this.watcher.on(`unlink`,e=>{this.export()}),this.watcher.on(`error`,function(e){}))}destroy(){this.watcher&&this.watcher.close()}},na=class{languageService;variablesByUri={};variablesByName={};constructor(){this.languageService=(0,ce.getSCSSLanguageService)()}async doValidation(e){return this.languageService.doValidation(e.documentUser,this.languageService.parseStylesheet(e.documentUser))}async doComplete(e,t){return this.languageService.doComplete(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async doHover(e,t){return this.languageService.doHover(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async findDefinition(e,t){let n=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));return n&&[n]}async format(e,t,n){let r={...n,preserveNewLines:!0,spaceAroundSelectorSeparator:!0,insertFinalNewline:!0,insertSpaces:!1,tabSize:4},i=e.documentUser,a=await this.languageService.format(i,t,r);if(a.length==1){let e=i.offsetAt(a[0].range.start),t=i.offsetAt(a[0].range.end),n=i.getText().length;if(e==0&&t==n){let e=await(0,se.default)([(0,ci.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:li,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=hi((0,ce.getSCSSLanguageService)().parseStylesheet(n),0);for(let e of a)i(e);this.variablesByUri[t]=Object.values(r),this.reloadVariables()}reloadVariables(){this.variablesByName={};for(let e in this.variablesByUri)for(let t of this.variablesByUri[e])this.variablesByName[t.name]||(this.variablesByName[t.name]=t)}removeVariables(e){delete this.variablesByUri[e],this.reloadVariables()}getDefinition(e){return this.variablesByName[e]}},ra=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 A&&await this.file.validate()}triggerSave(){this.file instanceof A&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof A&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async _onDelete(){await this.onDelete(),this.removeEvents()}},ia=class e extends ra{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(T.getInstance().settings.errorByBuild){let t=this.project.getBuilds();for(let n of t)$.sendDiagnostics({uri:this.file.uri,diagnostics:e},n)}else $.sendDiagnostics({uri:this.file.uri,diagnostics:e})};try{let n=(0,le.compileString)(r,{style:`compressed`}).css.toString().trim();n=n.replace(/\\/g,`\\\\`),e=n,this.diagnosticCompile&&(this.diagnosticCompile=void 0,t(this.diagnostics))}catch(e){e instanceof le.Exception&&(this.diagnosticCompile=Ne(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}),Ye(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(Pe(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}},aa=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}},oa=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 na,t&&this.loadFiles(),e.validate()}async init(){await this.onConfigSave()}async onValidate(){return await lt.getInstance().validate(this.configFile)}async loadConfig(){let e=await lt.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 aa;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 $i(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 ta(this,e);await t.export(),this.statics.push(t)}}this.onConfigSaveMutex.release()}async onFormatting(e,t,n){return await lt.getInstance().format(e,t,n)}async onCompletion(e,t){return await lt.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return await lt.getInstance().doResolve(t)}async onHover(e,t){return await lt.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 ia(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}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),this.configFile.removeOnSave(this.onSaveUUID),this.configFile.removeOnValidate(this.onValidateUUID),this.configFile.removeOnFormatting(this.onFormattingUUID),this.configFile.removeOnCompletion(this.onCompletionUUID),this.configFile.removeOnCompletionResolve(this.onCompletionResolveUUID),this.configFile.removeOnHover(this.onHoverUUID);for(let e of this.builds)e.destroy();for(let e of this.statics)e.destroy()}},L=class e{static autoLoad=!0;static instance;static getInstance(){return this.instance||=new e,this.instance}projects={};constructor(){R.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(t){if(t.documentUser.uri.endsWith(`/`+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 oa(t,e.autoLoad),e.autoLoad&&await this.projects[t.documentUser.uri].init(),t.onDelete(this.onDeleteFile.bind(this)))}}async onDeleteFile(e){this.projects[e.documentUser.uri]&&(this.projects[e.documentUser.uri].destroy(),delete this.projects[e.documentUser.uri])}getProjectByUri(e){return this.projects[e]}getMatchingBuildsByUri(e){let t=[];for(let n in this.projects){let r=this.projects[n].getMatchingBuildsByUri(e);for(let e of r)t.push(e)}return t}destroyAll(){for(let e in this.projects)this.projects[e].destroy()}async onRename(e){let t={};for(let n in this.projects){let r=await this.projects[n].onRename(e);for(let e in r)t[e]||(t[e]=[]),t[e]=t[e].concat(r[e])}return t}getAllConfigFiles(){let e=[];for(let t in this.projects)e.push(this.projects[t].getConfigFile().uri);return e}getAllBuilds(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsName();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllBuildsWithStory(){let e=[],t=[];for(let n in this.projects){let r=this.projects[n],i=r.getBuildsNameWithStory();for(let n of i){let i=n+`_`+r.getConfigFile().uri;t.includes(i)||(t.push(i),e.push({name:n,uri:r.getConfigFile().uri}))}}return e}getAllBuildsWithNpm(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsNameWithNpm();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllStatics(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsName();for(let t of r)e.push({name:t,uri:n.getConfigFile().uri})}return e}},R=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}constructor(){}files={};lockedUpdatedUri={};loadingInProgress=!0;preventUpdateUri(e){this.lockedUpdatedUri[e]&&clearTimeout(this.lockedUpdatedUri[e]),this.lockedUpdatedUri[e]=setTimeout(()=>{delete this.lockedUpdatedUri[e]},2e3)}async onCreatedUri(e){if(!this.files[e]){let t=ke(e);if(t){let n=D(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=ke(e),n=D(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(T.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],at.getInstance().unwatch(e)}}async loadConfigFileNotSet(e,t,n){for(let r=0;r<e.length;r++){let i=D(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=E(o);if(r[i]==w.Config)return await this.loadConfigFile(e,t,n),!0}}return!1};if(await a(i))return}it.sendDone()}async loadConfigFile(e,t,n){L.autoLoad=!1;let r=D(e);e=E(r);let i=d.TextDocument.create(E(r),w.Config,0,(0,u.readFileSync)(r,`utf8`));this.loadingInProgress=!1,await this.registerFile(i),this.loadingInProgress=!0;let a=L.getInstance().getProjectByUri(e);if(a){await a.loadConfig(),a.buildsAllowed=t,a.staticsAllowed=n;let e=a.getConfig();if(e){let r=async e=>{if(!(0,u.existsSync)(e))return;let t=(0,u.readdirSync)(e);for(let n=0;n<t.length;n++){let i=e+`/`+t[n];if((0,u.lstatSync)(i).isDirectory())t[n]!=`node_modules`&&await r(i);else{let e=E(i),r=ke(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);we.startSendLoadFile(),a.loadFiles(),we.sendLoadFile(),this.loadingInProgress=!1,await a.init(),it.sendDone()}}}async parseWorkspace(e,t){let n=D(e),r=T.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)(D(e)+r+a).replace(/\\/g,`/`);s=He(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=E(n),i=ke(r);e==w.Config&&t.push(new A(d.TextDocument.create(r,i,0,(0,u.readFileSync)(n,`utf8`))))});return t}async loadAllAventusFiles(e){this.loadingInProgress=!0;let t=[];it.send(`$(loading~spin) Aventus : Loading files`);for(let n=0;n<e.length;n++)await this.parseWorkspace(e[n],async(e,n)=>{let r=E(n),i=ke(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)}});it.send(`$(loading~spin) Aventus : Register config`),this.loadingInProgress=!1;for(let e of t)await this.registerFile(e);it.sendDone()}async onShutdown(){for(let e in this.files)await this.files[e].triggerDelete(),delete this.files[e],at.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=D(e),n=``;(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`));let r=d.TextDocument.create(e,C.Package,0,n);return at.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||at.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)(D(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 A(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=k();for(;this.onNewFileCb[t]!=null;)t=k();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=k();for(;this.onNewFileCb[t]!=null;)t=k();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[E(e)]}getByUri(e){return this.files[e]}getUris(){return Object.keys(this.files)}},sa=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))}},ca=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}},la=class extends ca{token;constructor(e,t,n,r,i){super(e,t,n,r),this.token=i}};const ua={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 da(...e){let t=``;for(let n=0;n<e.length;n++)t+=e[n][1];return t}const fa=65533;function pa(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 ma(e){return e>=48&&e<=57}function ha(e){return e>=65&&e<=90}function ga(e){return e>=97&&e<=122}function _a(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function va(e){return ga(e)||ha(e)}function ya(e){return va(e)||xa(e)||e===95}function ba(e){return ya(e)||ma(e)||e===45}function xa(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||!!Ta(e)||e>=65536}function Sa(e){return e===11||e===127||0<=e&&e<=8||14<=e&&e<=31}function Ca(e){return e===10||e===13||e===12}function wa(e){return e===32||e===10||e===9||e===13||e===12}function Ta(e){return e>=55296&&e<=57343}function Ea(e){return e.source.codePointAt(e.cursor)===92&&!Ca(e.source.codePointAt(e.cursor+1)??-1)}function Da(e,t){return t.source.codePointAt(t.cursor)===45?t.source.codePointAt(t.cursor+1)===45||!!ya(t.source.codePointAt(t.cursor+1)??-1)||t.source.codePointAt(t.cursor+1)===92&&!Ca(t.source.codePointAt(t.cursor+2)??-1):!!ya(t.source.codePointAt(t.cursor)??-1)||Ea(t)}function Oa(e){return e.source.codePointAt(e.cursor)===43||e.source.codePointAt(e.cursor)===45?!!ma(e.source.codePointAt(e.cursor+1)??-1)||e.source.codePointAt(e.cursor+1)===46&&ma(e.source.codePointAt(e.cursor+2)??-1):e.source.codePointAt(e.cursor)===46?ma(e.source.codePointAt(e.cursor+1)??-1):ma(e.source.codePointAt(e.cursor)??-1)}function ka(e){return e.source.codePointAt(e.cursor)===47&&e.source.codePointAt(e.cursor+1)===42}function Aa(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,ja;function Ma(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 Na(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 Pa(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 la(ua.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 Fa(e,t){let n=t.readCodePoint();if(n===void 0)return e.onParseError(new ca(ua.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,[`4.3.7. Consume an escaped code point`,`Unexpected EOF`])),fa;if(_a(n)){let e=[n],r;for(;(r=t.source.codePointAt(t.cursor))!==void 0&&_a(r)&&e.length<6;)e.push(r),t.advanceCodePoint();wa(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||Ta(i)||i>1114111?fa:i}return n===0||Ta(n)?fa:n}function Ia(e,t){let n=[];for(;;){let r=t.source.codePointAt(t.cursor)??-1;if(r===0||Ta(r))n.push(fa),t.advanceCodePoint(+(r>65535)+1);else if(ba(r))n.push(r),t.advanceCodePoint(+(r>65535)+1);else{if(!Ea(t))return n;t.advanceCodePoint(),n.push(Fa(e,t))}}}function La(e,t){t.advanceCodePoint();let n=t.source.codePointAt(t.cursor);if(n!==void 0&&(ba(n)||Ea(t))){let n=ja.Unrestricted;Da(0,t)&&(n=ja.ID);let r=Ia(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 Ra(e,t){let n=B.Integer;for(t.source.codePointAt(t.cursor)!==43&&t.source.codePointAt(t.cursor)!==45||t.advanceCodePoint();ma(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===46&&ma(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint(2),n=B.Number;ma(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===101||t.source.codePointAt(t.cursor)===69){if(ma(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||!ma(t.source.codePointAt(t.cursor+2)??-1))return n;t.advanceCodePoint(3)}for(n=B.Number;ma(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint()}return n}function za(e,t){let n;{let e=t.source.codePointAt(t.cursor);e===45?n=`-`:e===43&&(n=`+`)}let r=Ra(0,t),i=parseFloat(t.source.slice(t.representationStart,t.representationEnd+1));if(Da(0,t)){let a=Ia(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 Ba(e){for(;wa(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`}(ja||={});var Va=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 Ha(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 la(ua.UnexpectedEOFInString,t.representationStart,t.representationEnd,[`4.3.5. Consume a string token`,`Unexpected EOF`],r)),r}if(Ca(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 la(ua.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||Ta(i)?n+=String.fromCodePoint(fa):n+=String.fromCodePoint(i);else{if(t.source.codePointAt(t.cursor)===void 0)continue;if(Ca(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(Fa(e,t))}}}function Ua(e){return!(e.length!==3||e[0]!==117&&e[0]!==85||e[1]!==114&&e[1]!==82||e[2]!==108&&e[2]!==76)}function Wa(e,t){for(;;){let n=t.source.codePointAt(t.cursor);if(n===void 0)return;if(n===41)return void t.advanceCodePoint();Ea(t)?(t.advanceCodePoint(),Fa(e,t)):t.advanceCodePoint()}}function Ga(e,t){for(;wa(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 la(ua.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(wa(t.source.codePointAt(t.cursor)??-1)){for(t.advanceCodePoint();wa(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 la(ua.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}]):(Wa(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||Sa(r??-1)){Wa(e,t);let n=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new la(ua.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(Ea(t)){t.advanceCodePoint(),n+=String.fromCodePoint(Fa(e,t));continue}Wa(e,t);let r=[z.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new la(ua.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||Ta(t.source.codePointAt(t.cursor)??-1)?(n+=String.fromCodePoint(fa),t.advanceCodePoint()):(n+=t.source[t.cursor],t.advanceCodePoint())}}function Ka(e,t){let n=Ia(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(Ua(n)){t.advanceCodePoint();let r=0;for(;;){let e=wa(t.source.codePointAt(t.cursor)??-1),i=wa(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 Ga(e,t)}return t.advanceCodePoint(),[z.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}]}function qa(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&&!_a(e.source.codePointAt(e.cursor+2)??-1))}function Ja(e,t){t.advanceCodePoint(2);let n=[],r=[],i;for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&_a(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&&_a(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint();(i=t.source.codePointAt(t.cursor))!==void 0&&r.length<6&&_a(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 Ya(e,t){let n=Xa(e,t),r=[];for(;!n.endOfFile();)r.push(n.nextToken());return r.push(n.nextToken()),r}function Xa(e,t){let n=e.css.valueOf(),r=e.unicodeRangesAllowed??!1,i=new Va(n),a={onParseError:t?.onParseError??Za};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&&ka(i))return Pa(a,i);if(r&&(e===117||e===85)&&qa(i))return Ja(0,i);if(ya(e))return Ka(a,i);if(ma(e))return za(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 Ha(a,i);case 35:return La(a,i);case 43:case 46:return Oa(i)?za(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 Ba(i);case 45:return Oa(i)?za(a,i):Aa(i)?(i.advanceCodePoint(3),[z.CDC,`-->`,i.representationStart,i.representationEnd,void 0]):Da(0,i)?Ka(a,i):(i.advanceCodePoint(),[z.Delim,`-`,i.representationStart,i.representationEnd,{value:`-`}]);case 60:return pa(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(),Da(0,i)){let e=Ia(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(Ea(i))return Ka(a,i);i.advanceCodePoint();let e=[z.Delim,`\\`,i.representationStart,i.representationEnd,{value:`\\`}];return a.onParseError(new la(ua.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 Za(){}function Qa(e,t){let n=[];for(let e of t)n.push(e.codePointAt(0));let r=$a(n);r[0]===101&&to(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 $a(e){let t=0;if(e[0]===0)e.splice(0,1,fa),t=1;else if(e[0]===45&&e[1]===45)t=2;else if(e[0]===45&&e[1])t=2,ya(e[1])||(t+=to(e,1,e[1]));else{if(e[0]===45&&!e[1])return[92,e[0]];ya(e[0])?t=1:(t=1,t+=to(e,0,e[0]))}for(let n=t;n<e.length;n++)e[n]===0?(e.splice(n,1,fa),n++):ba(e[n])||(n+=eo(e,n,e[n]));return e}function eo(e,t,n){return e.splice(t,1,92,n),1}function to(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 no=Object.values(z);function ro(e){return!!Array.isArray(e)&&!(e.length<4)&&!!no.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 io(e){if(!e)return!1;switch(e[0]){case z.Whitespace:case z.Comment:return!0;default:return!1}}function ao(e){return!!e&&e[0]===z.Colon}function oo(e){return!!e&&e[0]===z.Comma}function so(e){return!!e&&e[0]===z.Comment}function co(e){return!!e&&e[0]===z.Delim}function H(e){return!!e&&e[0]===z.Dimension}function lo(e){return!!e&&e[0]===z.EOF}function uo(e){return!!e&&e[0]===z.Function}function fo(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 po(e){return!!e&&e[0]===z.Semicolon}function mo(e){return!!e&&e[0]===z.Whitespace}function ho(e){return!!e&&e[0]===z.OpenParen}function go(e){return!!e&&e[0]===z.CloseParen}function _o(e){return!!e&&e[0]===z.OpenSquare}function vo(e){return!!e&&e[0]===z.OpenCurly}function yo(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 bo=[.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124];
|
|
722
723
|
/**
|
|
723
724
|
* Bradford chromatic adaptation from D50 to D65
|
|
724
725
|
*
|
|
725
726
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
726
727
|
* @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).
|
|
727
|
-
*/function
|
|
728
|
+
*/function xo(e){return yo(bo,e)}const So=[1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371];
|
|
728
729
|
/**
|
|
729
730
|
* Bradford chromatic adaptation from D65 to D50
|
|
730
731
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
731
732
|
* @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).
|
|
732
733
|
* @see http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html
|
|
733
|
-
*/function
|
|
734
|
+
*/function Co(e){return yo(So,e)}
|
|
734
735
|
/**
|
|
735
736
|
* @param {number} hue - Hue as degrees 0..360
|
|
736
737
|
* @param {number} sat - Saturation as percentage 0..100
|
|
@@ -740,7 +741,7 @@ namespace `+this.buildConfig.module+`{
|
|
|
740
741
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
741
742
|
* @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).
|
|
742
743
|
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js
|
|
743
|
-
*/function
|
|
744
|
+
*/function wo(e){let t=e[0]%360,n=e[1]/100,r=e[2]/100;return t<0&&(t+=360),[To(0,t,n,r),To(8,t,n,r),To(4,t,n,r)]}function To(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))}
|
|
744
745
|
/**
|
|
745
746
|
* @param {number} hue - Hue as degrees 0..360
|
|
746
747
|
* @param {number} white - Whiteness as percentage 0..100
|
|
@@ -750,31 +751,31 @@ namespace `+this.buildConfig.module+`{
|
|
|
750
751
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
751
752
|
* @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).
|
|
752
753
|
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js
|
|
753
|
-
*/function
|
|
754
|
+
*/function Eo(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=wo([t,100,50]),a=1-n-r;return[i[0]*a+n,i[1]*a+n,i[2]*a+n]}
|
|
754
755
|
/**
|
|
755
756
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
756
757
|
* @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).
|
|
757
|
-
*/function
|
|
758
|
+
*/function Do(e){let t=e[2]*Math.PI/180;return[e[0],e[1]*Math.cos(t),e[1]*Math.sin(t)]}
|
|
758
759
|
/**
|
|
759
760
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
760
761
|
* @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).
|
|
761
|
-
*/function
|
|
762
|
+
*/function Oo(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 ko=[.3457/.3585,1,.2958/.3585];
|
|
762
763
|
/**
|
|
763
764
|
* Convert Lab to D50-adapted XYZ
|
|
764
765
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
765
766
|
* @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).
|
|
766
767
|
* @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
|
767
|
-
*/function
|
|
768
|
+
*/function Ao(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)*ko[0],(e[0]>8?((e[0]+16)/116)**3:e[0]/t)*ko[1],(a**3>n?a**3:(116*a-16)/t)*ko[2]]}
|
|
768
769
|
/**
|
|
769
770
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
770
771
|
* @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).
|
|
771
772
|
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
|
772
|
-
*/function
|
|
773
|
+
*/function jo(e){let t=e[2]*Math.PI/180;return[e[0],e[1]*Math.cos(t),e[1]*Math.sin(t)]}
|
|
773
774
|
/**
|
|
774
775
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
775
776
|
* @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).
|
|
776
777
|
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
|
777
|
-
*/function
|
|
778
|
+
*/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<=4e-6&&(n=NaN),[e[0],t,n]}const No=[1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],Po=[1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092];
|
|
778
779
|
/**
|
|
779
780
|
* Given OKLab, convert to XYZ relative to D65
|
|
780
781
|
*
|
|
@@ -782,14 +783,14 @@ namespace `+this.buildConfig.module+`{
|
|
|
782
783
|
* @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).
|
|
783
784
|
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
|
784
785
|
*/
|
|
785
|
-
function
|
|
786
|
+
function Fo(e){let t=yo(Po,e);return yo(No,[t[0]**3,t[1]**3,t[2]**3])}
|
|
786
787
|
/**
|
|
787
788
|
* Assuming XYZ is relative to D50, convert to CIE Lab
|
|
788
789
|
* from CIE standard, which now defines these as a rational fraction
|
|
789
790
|
*
|
|
790
791
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
791
792
|
* @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).
|
|
792
|
-
*/function
|
|
793
|
+
*/function Io(e){let t=Lo(e[0]/ko[0]),n=Lo(e[1]/ko[1]);return[116*n-16,500*(t-n),200*(n-Lo(e[2]/ko[2]))]}function Lo(e){return e>.008856451679035631?Math.cbrt(e):(903.2962962962963*e+16)/116}const Ro=[.819022437996703,.3619062600528904,-.1288737815209879,.0329836539323885,.9292868615863434,.0361446663506424,.0481771893596242,.2642395317527308,.6335478284694309],zo=[.210454268309314,.7936177747023054,-.0040720430116193,1.9779985324311684,-2.42859224204858,.450593709617411,.0259040424655478,.7827717124575296,-.8086757549230774];
|
|
793
794
|
/**
|
|
794
795
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
795
796
|
* @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).
|
|
@@ -797,7 +798,7 @@ function No(e){let t=_o(Mo,e);return _o(jo,[t[0]**3,t[1]**3,t[2]**3])}
|
|
|
797
798
|
* XYZ <-> LMS matrices recalculated for consistent reference white
|
|
798
799
|
* @see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484
|
|
799
800
|
*/
|
|
800
|
-
function
|
|
801
|
+
function Bo(e){let t=yo(Ro,e);return yo(zo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math.cbrt(t[2])])}const Vo=[30757411/17917100,-6372589/17917100,-4539589/17917100,-.666684351832489,1.616481236634939,467509/29648200,792561/44930125,-1921689/44930125,.942103121235474],Ho=[446124/178915,-333277/357830,-72051/178915,-14852/17905,63121/35810,423/17905,11844/330415,-50337/660830,316169/330415]
|
|
801
802
|
/**
|
|
802
803
|
* Convert XYZ to linear-light rec2020
|
|
803
804
|
*
|
|
@@ -810,7 +811,7 @@ function Ro(e){let t=_o(Io,e);return _o(Lo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
|
|
|
810
811
|
*
|
|
811
812
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
812
813
|
* @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).
|
|
813
|
-
*/function
|
|
814
|
+
*/function Uo(e){return yo(Ho,e)}const Wo=[1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],Go=[1829569/896150,-506331/896150,-308931/896150,-851781/878810,1648619/878810,36519/878810,16779/1248040,-147721/1248040,1266979/1248040],Ko=[12831/3959,-329/214,-1974/3959,-851781/878810,1648619/878810,36519/878810,705/12673,-2585/12673,705/667]
|
|
814
815
|
/**
|
|
815
816
|
* Convert D50 XYZ to linear-light prophoto-rgb
|
|
816
817
|
*
|
|
@@ -828,14 +829,14 @@ function Ro(e){let t=_o(Io,e);return _o(Lo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
|
|
|
828
829
|
/**
|
|
829
830
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
830
831
|
* @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).
|
|
831
|
-
*/function
|
|
832
|
+
*/function qo(e){return yo(Ko,e)}
|
|
832
833
|
/**
|
|
833
834
|
* Convert an array of linear-light rec2020 RGB in the range 0.0-1.0
|
|
834
835
|
* to gamma corrected form ITU-R BT.2020-2 p.4
|
|
835
836
|
*
|
|
836
837
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
837
838
|
* @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).
|
|
838
|
-
*/function
|
|
839
|
+
*/function Jo(e){return(e<0?-1:1)*Math.abs(e)**(1/2.4)}
|
|
839
840
|
/**
|
|
840
841
|
* Convert an array of linear-light sRGB values in the range 0.0-1.0 to gamma corrected form
|
|
841
842
|
* Extended transfer function:
|
|
@@ -845,14 +846,14 @@ function Ro(e){let t=_o(Io,e);return _o(Lo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
|
|
|
845
846
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
846
847
|
* @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).
|
|
847
848
|
* @see https://en.wikipedia.org/wiki/SRGB
|
|
848
|
-
*/function
|
|
849
|
+
*/function Yo(e){return[Xo(e[0]),Xo(e[1]),Xo(e[2])]}function Xo(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}
|
|
849
850
|
/**
|
|
850
851
|
* Convert an array of linear-light display-p3 RGB in the range 0.0-1.0
|
|
851
852
|
* to gamma corrected form
|
|
852
853
|
*
|
|
853
854
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
854
855
|
* @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).
|
|
855
|
-
*/function
|
|
856
|
+
*/function Zo(e){return Yo(e)}
|
|
856
857
|
/**
|
|
857
858
|
* Convert an array of linear-light prophoto-rgb in the range 0.0-1.0
|
|
858
859
|
* to gamma corrected form.
|
|
@@ -861,14 +862,14 @@ function Ro(e){let t=_o(Io,e);return _o(Lo,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
|
|
|
861
862
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
862
863
|
* @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).
|
|
863
864
|
*/
|
|
864
|
-
function
|
|
865
|
+
function Qo(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16*e}
|
|
865
866
|
/**
|
|
866
867
|
* Convert an array of linear-light a98-rgb in the range 0.0-1.0
|
|
867
868
|
* to gamma corrected form. Negative values are also now accepted
|
|
868
869
|
*
|
|
869
870
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
870
871
|
* @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).
|
|
871
|
-
*/function
|
|
872
|
+
*/function $o(e){return(e<0?-1:1)*Math.abs(e)**(256/563)}
|
|
872
873
|
/**
|
|
873
874
|
* Convert an array of rec2020 RGB values in the range 0.0 - 1.0
|
|
874
875
|
* to linear light (un-companded) form.
|
|
@@ -876,7 +877,7 @@ function Xo(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16
|
|
|
876
877
|
*
|
|
877
878
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
878
879
|
* @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).
|
|
879
|
-
*/function
|
|
880
|
+
*/function es(e){return(e<0?-1:1)*Math.abs(e)**2.4}const ts=[63426534/99577255,20160776/139408157,47086771/278816314,26158966/99577255,.677998071518871,8267143/139408157,0,19567812/697040785,1.0609850577107909];
|
|
880
881
|
/**
|
|
881
882
|
* Convert an array of linear-light rec2020 values to CIE XYZ
|
|
882
883
|
* using D65 (no chromatic adaptation)
|
|
@@ -896,14 +897,14 @@ function Xo(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16
|
|
|
896
897
|
* @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).
|
|
897
898
|
* @see https://en.wikipedia.org/wiki/SRGB
|
|
898
899
|
*/
|
|
899
|
-
function
|
|
900
|
+
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<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}
|
|
900
901
|
/**
|
|
901
902
|
* Convert an array of display-p3 RGB values in the range 0.0 - 1.0
|
|
902
903
|
* to linear light (un-companded) form.
|
|
903
904
|
*
|
|
904
905
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
905
906
|
* @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).
|
|
906
|
-
*/function
|
|
907
|
+
*/function is(e){return ns(e)}const as=[608311/1250200,189793/714400,198249/1000160,35783/156275,247089/357200,198249/2500400,0,32229/714400,5220557/5000800];
|
|
907
908
|
/**
|
|
908
909
|
* Convert an array of linear-light display-p3 values to CIE XYZ
|
|
909
910
|
* using D65 (no chromatic adaptation)
|
|
@@ -911,7 +912,7 @@ function es(e){return[ts(e[0]),ts(e[1]),ts(e[2])]}function ts(e){let t=e<0?-1:1,
|
|
|
911
912
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
912
913
|
* @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).
|
|
913
914
|
* @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
|
914
|
-
*/function
|
|
915
|
+
*/function os(e){return yo(as,e)}
|
|
915
916
|
/**
|
|
916
917
|
* Convert an array of prophoto-rgb values where in-gamut Colors are in the
|
|
917
918
|
* range [0.0 - 1.0] to linear light (un-companded) form. Transfer curve is
|
|
@@ -920,7 +921,7 @@ function es(e){return[ts(e[0]),ts(e[1]),ts(e[2])]}function ts(e){let t=e<0?-1:1,
|
|
|
920
921
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
921
922
|
* @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).
|
|
922
923
|
*/
|
|
923
|
-
function
|
|
924
|
+
function ss(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const cs=[.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602];
|
|
924
925
|
/**
|
|
925
926
|
* Convert an array of linear-light prophoto-rgb values to CIE D50 XYZ.
|
|
926
927
|
* Matrix cannot be expressed in rational form, but is calculated to 64 bit accuracy.
|
|
@@ -928,7 +929,7 @@ function as(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
|
|
|
928
929
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
929
930
|
* @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).
|
|
930
931
|
* @see see https://github.com/w3c/csswg-drafts/issues/7675
|
|
931
|
-
*/function
|
|
932
|
+
*/function ls(e){return(e<0?-1:1)*Math.abs(e)**(563/256)}const us=[573536/994567,263643/1420810,187206/994567,591459/1989134,6239551/9945670,374412/4972835,53769/1989134,351524/4972835,4929758/4972835],ds=[506752/1228815,87881/245763,12673/70218,87098/409605,175762/245763,12673/175545,7918/409605,87881/737289,1001167/1053270]
|
|
932
933
|
/**
|
|
933
934
|
* Convert an array of linear-light a98-rgb values to CIE XYZ
|
|
934
935
|
* http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
|
@@ -950,7 +951,7 @@ function as(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
|
|
|
950
951
|
*
|
|
951
952
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
952
953
|
* @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).
|
|
953
|
-
*/function
|
|
954
|
+
*/function fs(e){return yo(ds,e)}
|
|
954
955
|
/**
|
|
955
956
|
* Convert an array of gamma-corrected sRGB values in the 0.0 to 1.0 range to HSL.
|
|
956
957
|
*
|
|
@@ -964,7 +965,7 @@ function as(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
|
|
|
964
965
|
* @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).
|
|
965
966
|
*
|
|
966
967
|
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/better-rgbToHsl.js
|
|
967
|
-
*/function
|
|
968
|
+
*/function ps(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 ms(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 hs(e){let t=e;return t=ns(t),t=fs(t),t=Co(t),t}function gs(e){let t=e;return t=xo(t),t=qo(t),t=Yo(t),t}function _s(e){let t=e;return t=wo(t),t=ns(t),t=fs(t),t=Co(t),t}function vs(e){let t=e;return t=xo(t),t=qo(t),t=Yo(t),t=ps(t),t}function ys(e){let t=e;return t=Eo(t),t=ns(t),t=fs(t),t=Co(t),t}function bs(e){let t=e;t=xo(t),t=qo(t);let n=Yo(t),r=Math.min(n[0],n[1],n[2]),i=1-Math.max(n[0],n[1],n[2]),a=ms(n);return r+i>=.99999&&(a=NaN),[a,100*r,100*i]}function xs(e){let t=e;return t=Ao(t),t}function Ss(e){let t=e;return t=Io(t),t}function Cs(e){let t=e;return t=Do(t),t=Ao(t),t}function ws(e){let t=e;return t=Io(t),t=Oo(t),t}function Ts(e){let t=e;return t=Fo(t),t=Co(t),t}function Es(e){let t=e;return t=xo(t),t=Bo(t),t}function Ds(e){let t=e;return t=jo(t),t=Fo(t),t=Co(t),t}function Os(e){let t=e;return t=xo(t),t=Bo(t),t=Mo(t),t}function ks(e){let t=e;return t=fs(t),t=Co(t),t}function As(e){let t=e;return t=xo(t),t=qo(t),t}function js(e){let t=e;
|
|
968
969
|
/**
|
|
969
970
|
* Convert an array of a98-rgb values in the range 0.0 - 1.0
|
|
970
971
|
* to linear light (un-companded) form. Negative values are also now accepted
|
|
@@ -972,7 +973,7 @@ function as(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
|
|
|
972
973
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
973
974
|
* @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).
|
|
974
975
|
*/
|
|
975
|
-
var n;return t=[
|
|
976
|
+
var n;return t=[ls((n=t)[0]),ls(n[1]),ls(n[2])],t=yo(us,t),t=Co(t),t}function Ms(e){let t=e;var n;return t=xo(t),t=yo(Go,t),t=[$o((n=t)[0]),$o(n[1]),$o(n[2])],t}function Ns(e){let t=e;return t=is(t),t=os(t),t=Co(t),t}function Ps(e){let t=e;return t=xo(t),t=Uo(t),t=Zo(t),t}function Fs(e){let t=e;return t=os(t),t=Co(t),t}function Is(e){let t=e;return t=xo(t),t=Uo(t),t}function Ls(e){let t=e;var n;return t=[es((n=t)[0]),es(n[1]),es(n[2])],t=yo(ts,t),t=Co(t),t}function Rs(e){let t=e;var n;return t=xo(t),t=yo(Vo,t),t=[Jo((n=t)[0]),Jo(n[1]),Jo(n[2])],t}function zs(e){let t=e;var n;return t=[ss((n=t)[0]),ss(n[1]),ss(n[2])],t=yo(cs,t),t}function Bs(e){let t=e;var n;return t=yo(Wo,t),t=[Qo((n=t)[0]),Qo(n[1]),Qo(n[2])],t}function Vs(e){let t=e;return t=Co(t),t}function Hs(e){let t=e;return t=xo(t),t}function Us(e){return e}function Ws(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 Gs(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]]}
|
|
976
977
|
/**
|
|
977
978
|
* @description Calculate deltaE OK which is the simple root sum of squares
|
|
978
979
|
* @param {number[]} reference - Array of OKLab values: L as 0..1, a and b as -1..1
|
|
@@ -985,33 +986,33 @@ var n;return t=[ss((n=t)[0]),ss(n[1]),ss(n[2])],t=_o(cs,t),t=xo(t),t}function As
|
|
|
985
986
|
*/
|
|
986
987
|
/**
|
|
987
988
|
* @license MIT https://github.com/facelessuser/coloraide/blob/main/LICENSE.md
|
|
988
|
-
*/function Ws(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=Gs(o,a);if(!s)break;a=s}return Us(a)}function Gs(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 Ks={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 qs(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 Js(e,t){let n=qs(e),r=qs(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}var Ys;function Xs(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 Zs(e,t){let n=t[0];if(po(n)||go(n)||ho(n)){let n=nc(e,t);return{advance:n.advance,node:n.node}}if(co(n)){let n=ec(e,t);return{advance:n.advance,node:n.node}}if(fo(n)){let n=ic(e,t);return{advance:n.advance,node:n.node}}if(ao(n)){let n=oc(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`})(Ys||={});var Qs=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=Xs(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)}},$s=class e extends Qs{type=Ys.Function;name;endToken;constructor(e,t,n){super(),this.name=e,this.endToken=t,this.value=n}getName(){return this.name[4].value}normalize(){so(this.endToken)&&(this.endToken=[z.CloseParen,`)`,-1,-1,void 0])}tokens(){return so(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=>to(e)?la(e):e.toString()).join(``);return la(this.name)+e+la(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===Ys.Function}};function ec(e,t){let n=[],r=1;for(;;){let i=t[r];if(!i||so(i))return e.onParseError(new oa(`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 $s(t[0],i,n)};if(mo(i))return{advance:r+1,node:new $s(t[0],i,n)};if(no(i)){let i=sc(e,t.slice(r));r+=i.advance,n.push(...i.nodes);continue}let a=Zs(e,t.slice(r));r+=a.advance,n.push(a.node)}}var tc=class e extends Qs{type=Ys.SimpleBlock;startToken;endToken;constructor(e,t,n){super(),this.startToken=e,this.endToken=t,this.value=n}normalize(){if(so(this.endToken)){let e=ja(this.startToken);e&&(this.endToken=e)}}tokens(){return so(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=>to(e)?la(e):e.toString()).join(``);return la(this.startToken)+e+la(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===Ys.SimpleBlock}};function nc(e,t){let n=Aa(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||so(a))return e.onParseError(new oa(`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 tc(t[0],a,r)};if(a[0]===n)return{advance:i+1,node:new tc(t[0],a,r)};if(no(a)){let n=sc(e,t.slice(i));i+=n.advance,r.push(...n.nodes);continue}let o=Zs(e,t.slice(i));i+=o.advance,r.push(o.node)}}var rc=class e{type=Ys.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return la(...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===Ys.Whitespace}};function ic(e,t){let n=0;for(;;){let e=t[n];if(!fo(e))return{advance:n,node:new rc(t.slice(0,n))};n++}}var ac=class e{type=Ys.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return la(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===Ys.Comment}};function oc(e,t){return{advance:1,node:new ac(t[0])}}function sc(e,t){let n=[],r=0;for(;;){if(fo(t[r])){let e=ic(0,t.slice(r));r+=e.advance,n.push(e.node);continue}if(!ao(t[r]))return{advance:r,nodes:n};n.push(new ac(t[r])),r++}}var K=class e{type=Ys.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===Ys.Token}};function cc(e,t){let n={onParseError:t?.onParseError??(()=>{})},r=[...e];so(r[r.length-1])||r.push([z.EOF,``,r[r.length-1][2],r[r.length-1][3],void 0]);let i=Zs(n,r);if(so(r[Math.min(i.advance,r.length-1)]))return i.node;n.onParseError(new oa(`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 lc(e,t,n){if(e.length===0)return;let r=Xs(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 uc(e,t,n){e.length!==0&&lc(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 dc(e,t){for(let n=0;n<e.length;n++)uc(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 fc(e){return tc.isSimpleBlockNode(e)}function pc(e){return $s.isFunctionNode(e)}function mc(e){return rc.isWhitespaceNode(e)}function hc(e){return ac.isCommentNode(e)}function gc(e){return mc(e)||hc(e)}function q(e){return K.isTokenNode(e)}function _c(e){if(Array.isArray(e)){let t=e[0];if(!t)return[0,0];let n=e[e.length-1]||t;return[_c(t)[0],_c(n)[1]]}let t=e.tokens(),n=t[0],r=t[t.length-1];return n&&r?[n[2],r[3]]:[0,0]}var vc=class extends Error{sourceStart;sourceEnd;constructor(e,t,n){super(e),this.name=`ParseError`,this.sourceStart=t,this.sourceEnd=n}},yc=class extends vc{componentValues;constructor(e,t){super(e,..._c(t)),this.componentValues=t}};const bc={UnexpectedAdditionOfDimensionOrPercentageWithNumber:`Unexpected addition of a dimension or percentage with a number.`,UnexpectedSubtractionOfDimensionOrPercentageWithNumber:`Unexpected subtraction of a dimension or percentage with a number.`},xc=/[A-Z]/g;function Sc(e){return e.replace(xc,e=>String.fromCharCode(e.charCodeAt(0)+32))}const Cc={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`},wc=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]]),Tc=new Map([[`deg`,e=>e],[`grad`,e=>e/.9],[`rad`,e=>e/180*Math.PI],[`turn`,e=>e/360]]),Ec=new Map([[`deg`,e=>.9*e],[`grad`,e=>e],[`rad`,e=>.9*e/180*Math.PI],[`turn`,e=>.9*e/360]]),Dc=new Map([[`hz`,e=>e],[`khz`,e=>e/1e3]]),Oc=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]]),kc=new Map([[`hz`,e=>1e3*e],[`khz`,e=>e]]),Ac=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]]),jc=new Map([[`ms`,e=>e],[`s`,e=>e/1e3]]),Mc=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]]),Nc=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]]),Pc=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]]),Fc=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]]),Ic=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]]),Lc=new Map([[`ms`,e=>1e3*e],[`s`,e=>e]]),Rc=new Map([[`deg`,e=>360*e],[`grad`,e=>360*e/.9],[`rad`,e=>360*e/180*Math.PI],[`turn`,e=>e]]),zc=new Map([[`cm`,wc],[`mm`,Ac],[`q`,Fc],[`in`,Oc],[`pc`,Mc],[`pt`,Nc],[`px`,Pc],[`ms`,jc],[`s`,Lc],[`deg`,Tc],[`grad`,Ec],[`rad`,Ic],[`turn`,Rc],[`hz`,Dc],[`khz`,kc]]);function Bc(e,t){if(!H(e)||!H(t))return t;let n=Sc(e[4].unit),r=Sc(t[4].unit);if(n===r)return t;let i=zc.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 Xa(s,e[4].unit),s}function Vc(e){if(!H(e))return e;let t=Sc(e[4].unit),n=Cc[t];if(t===n)return e;let r=zc.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 Xa(o,n),o}function Hc(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=Bc(n,r),Sc(n[4].unit)===Sc(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 yc(bc.UnexpectedAdditionOfDimensionOrPercentageWithNumber,e)),-1}function Uc(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 Wc(e){return!!e&&typeof e==`object`&&`inputs`in e&&Array.isArray(e.inputs)&&`operation`in e}function Gc(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=Gc(i,t);if(a===-1)return-1;n.push(a)}return e.operation(n,t)}function Kc(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 qc(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=Sc(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 Jc(e){if(e.length!==1)return-1;let t=e[0].value;return V(t)?e[0]:-1}function Yc(e,t,n){return H(t)?Xc(e,t[4].unit,n):G(t)?Zc(e,n):W(t)?Qc(e,n):-1}function Xc(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:Jc}}function Zc(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:Jc}}function Qc(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:Jc}}function $c(e,t){let n=t.value;return W(n)?Xc(e,`rad`,Math.acos(n[4].value)):-1}function el(e,t){let n=t.value;return W(n)?Xc(e,`rad`,Math.asin(n[4].value)):-1}function tl(e,t){let n=t.value;return W(n)?Xc(e,`rad`,Math.atan(n[4].value)):-1}function nl(e){return H(e)||W(e)}function rl(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=Sc(t[4].unit);for(let r=1;r<e.length;r++){let i=e[r];if(t[0]!==i[0]||n!==Sc(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 il(e,t){return!!V(e)&&(H(e)?e[0]===t[0]&&Sc(e[4].unit)===Sc(t[4].unit):e[0]===t[0])}function al(e,t,n){let r=t.value;if(!nl(r))return-1;let i=Bc(r,n.value);return il(r,i)?Xc(e,`rad`,Math.atan2(r[4].value,i[4].value)):-1}function ol(e,t,n){let r=t.value;return!V(r)||!n.rawPercentages&&G(r)?-1:Yc(e,r,Math.abs(r[4].value))}function sl(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=Bc(a,n.value);if(!il(a,o))return-1;let s=Bc(a,r.value);return il(a,s)?Yc(e,a,Math.max(a[4].value,Math.min(o[4].value,s[4].value))):-1}function cl(e,t){let n=t.value;if(!nl(n))return-1;let r=n[4].value;if(H(n))switch(n[4].unit.toLowerCase()){case`rad`:break;case`deg`:r=Tc.get(`rad`)(n[4].value);break;case`grad`:r=Ec.get(`rad`)(n[4].value);break;case`turn`:r=Rc.get(`rad`)(n[4].value);break;default:return-1}return r=Math.cos(r),Qc(e,r)}function ll(e,t){let n=t.value;return W(n)?Qc(e,Math.exp(n[4].value)):-1}function ul(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=>Bc(r,e.value));if(!rl(i))return-1;let a=i.map(e=>e[4].value);return Yc(e,r,Math.hypot(...a))}function dl(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=>Bc(r,e.value));if(!rl(i))return-1;let a=i.map(e=>e[4].value);return Yc(e,r,Math.max(...a))}function fl(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=>Bc(r,e.value));if(!rl(i))return-1;let a=i.map(e=>e[4].value);return Yc(e,r,Math.min(...a))}function pl(e,t,n){let r=t.value;if(!V(r))return-1;let i=Bc(r,n.value);if(!il(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,Yc(e,r,a)}function ml(e,t,n){let r=t.value,i=n.value;return!W(r)||!il(r,i)?-1:Qc(e,r[4].value**+i[4].value)}function hl(e,t,n){let r=t.value;if(!V(r))return-1;let i=Bc(r,n.value);if(!il(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,Yc(e,r,a)}function gl(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=Bc(i,t);if(!il(a,i))return-1;if(Number.isInteger(a[4].value/r))return Yc(e,t,t[4].value);if(a[4].value>0){if(a[4].value<r)return Yc(e,t,Bc(t,i)[4].value);let n=Math.floor(a[4].value/i[4].value)*i[4].value;return a[4].value=n,Yc(e,t,Bc(t,a)[4].value)}if(Math.abs(a[4].value)<r)return Yc(e,t,-1*Bc(t,i)[4].value);let o=Math.ceil(a[4].value/i[4].value)*i[4].value;return a[4].value=o,Yc(e,t,Bc(t,a)[4].value)}function _l(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=Bc(a,r.value);if(!il(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=Gc(Yc(e,a,s),i);return t===-1?-1:gl(e,t.value,i)}break}}else s=NaN;return Yc(e,a,s)}function vl(e,t,n){let r=t.value;return!V(r)||!n.rawPercentages&&G(r)?-1:Qc(e,Math.sign(r[4].value))}function yl(e,t){let n=t.value;if(!nl(n))return-1;let r=n[4].value;if(H(n))switch(Sc(n[4].unit)){case`rad`:break;case`deg`:r=Tc.get(`rad`)(n[4].value);break;case`grad`:r=Ec.get(`rad`)(n[4].value);break;case`turn`:r=Rc.get(`rad`)(n[4].value);break;default:return-1}return r=Math.sin(r),Qc(e,r)}function bl(e,t){let n=t.value;return W(n)?Qc(e,Math.sqrt(n[4].value)):-1}function xl(e,t){let n=t.value;if(!nl(n))return-1;let r=n[4].value,i=0,a=n[4].value;if(H(n))switch(Sc(n[4].unit)){case`rad`:i=Ic.get(`deg`)(r);break;case`deg`:i=r,a=Tc.get(`rad`)(r);break;case`grad`:i=Ec.get(`deg`)(r),a=Ec.get(`rad`)(r);break;case`turn`:i=Rc.get(`deg`)(r),a=Rc.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),Qc(e,a)}function Sl(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=Bc(n,r),Sc(n[4].unit)===Sc(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 yc(bc.UnexpectedSubtractionOfDimensionOrPercentageWithNumber,e)),-1}function Cl(e,t){if(t.length===1){let n=t[0];if(!n||!q(n))return-1;let r=n.value;return W(r)?Qc(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)?Qc(e,Math.log(r[4].value)/Math.log(a[4].value)):-1}return-1}const wl=/^none$/i;function Tl(e){if(Array.isArray(e)){let t=e.filter(e=>!(mc(e)&&hc(e)));return t.length===1&&Tl(t[0])}if(!q(e))return!1;let t=e.value;return!!U(t)&&wl.test(t[4].value)}const El=String.fromCodePoint(0);function Dl(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=Bc(o,r.value);if(!il(o,s))return-1;let c=null;if(i&&(c=Bc(o,i.value),!il(o,c)))return-1;if(!Number.isFinite(o[4].value)||!Number.isFinite(s[4].value)||!Number.isFinite(s[4].value-o[4].value))return Yc(e,o,NaN);if(c&&!Number.isFinite(c[4].value))return Yc(e,o,o[4].value);let l=t.fixed===-1?Ol(kl([t.dashedIdent?t.dashedIdent:`${a.randomCaching?.propertyName} ${a.randomCaching.propertyN++}`,t.elementShared?``:a.randomCaching.elementID,a.randomCaching.documentID].join(El))):()=>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 Yc(e,o,Number(n[Math.floor(n.length*i)].toFixed(5)))}let f=l();return Yc(e,o,Number((f*(d-u)+u).toFixed(5)))}function Ol(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 kl(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 Al=new Map([[`abs`,function(e,t,n){return Ml(e,t,n,ol)}],[`acos`,function(e,t,n){return Ml(e,t,n,$c)}],[`asin`,function(e,t,n){return Ml(e,t,n,el)}],[`atan`,function(e,t,n){return Ml(e,t,n,tl)}],[`atan2`,function(e,t,n){return Pl(e,t,n,al)}],[`calc`,jl],[`clamp`,function(e,t,n){let r=qc([...e.value.filter(e=>!gc(e))],t),i=[],a=[],o=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&io(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=Tl(i),c=Tl(o);if(s&&c)return jl(Bl(e,a),t,n);let l=Gc(jl(Bl(e,a),t,n),n);if(l===-1)return-1;if(s){let r=Gc(jl(Bl(e,o),t,n),n);return r===-1?-1:fl((u=e,d=l,f=r,new $s([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,`,`,..._c(d),void 0]),f])),[l,r],n)}if(c){let r=Gc(jl(Bl(e,i),t,n),n);return r===-1?-1:dl(Vl(e,r,l),[r,l],n)}var u,d,f;let p=Gc(jl(Bl(e,i),t,n),n);if(p===-1)return-1;let m=Gc(jl(Bl(e,o),t,n),n);return m===-1?-1:sl(e,p,l,m,n)}],[`cos`,function(e,t,n){return Ml(e,t,n,cl)}],[`exp`,function(e,t,n){return Ml(e,t,n,ll)}],[`hypot`,function(e,t,n){return Il(e,t,n,ul)}],[`log`,function(e,t,n){return Il(e,t,n,Cl)}],[`max`,function(e,t,n){return Il(e,t,n,dl)}],[`min`,function(e,t,n){return Il(e,t,n,fl)}],[`mod`,function(e,t,n){return Pl(e,t,n,pl)}],[`pow`,function(e,t,n){return Pl(e,t,n,ml)}],[`random`,function(e,t,n){let r=zl(e,e.value.filter(e=>!gc(e)),t,n);if(r===-1)return-1;let[i,a]=r,o=Ll(e,a,t,n);if(o===-1)return-1;let[s,c,l]=o;return!s||!c?-1:Dl(e,i,s,c,l,n)}],[`rem`,function(e,t,n){return Pl(e,t,n,hl)}],[`round`,function(e,t,n){let r=qc([...e.value.filter(e=>!gc(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(Rl.has(e)){i=e;continue}}if(q(n)&&io(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=Gc(jl(Bl(e,o),t,n),n);if(c===-1)return-1;if(i===`line-width`){let e=Bc([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 gl(e,c.value,n);s.push(new K([z.Number,`1`,c.value[2],c.value[3],{value:1,type:B.Integer}]))}let l=Gc(jl(Bl(e,s),t,n),n);return l===-1?-1:(i||=`nearest`,_l(e,i,c,l,n))}],[`sign`,function(e,t,n){return Ml(e,t,n,vl)}],[`sin`,function(e,t,n){return Ml(e,t,n,yl)}],[`sqrt`,function(e,t,n){return Ml(e,t,n,bl)}],[`tan`,function(e,t,n){return Ml(e,t,n,xl)}]]);function jl(e,t,n){let r=qc([...e.value.filter(e=>!gc(e))],t);if(r.length===1&&q(r[0]))return{inputs:[r[0]],operation:Jc};let i=0;for(;i<r.length;){let e=r[i];if(fc(e)&&po(e.startToken)){let a=jl(e,t,n);if(a===-1)return-1;r.splice(i,1,a);continue}if(pc(e)){let a=Al.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&&Wc(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!Wc(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!oo(n)||n[4].value!==`*`&&n[4].value!==`/`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!Wc(a))return-1;n[4].value===`*`?r.splice(i,3,{inputs:[e,a],operation:Kc}):n[4].value===`/`?r.splice(i,3,{inputs:[e,a],operation:Uc}):i++}if(i=0,r.length===1&&Wc(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!Wc(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!oo(n)||n[4].value!==`+`&&n[4].value!==`-`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!Wc(a))return-1;n[4].value===`+`?r.splice(i,3,{inputs:[e,a],operation:Hc}):n[4].value===`-`?r.splice(i,3,{inputs:[e,a],operation:Sl}):i++}return r.length===1&&Wc(r[0])?r[0]:-1}function Ml(e,t,n,r){let i=Nl(e,t,n);return i===-1?-1:r(e,i,n)}function Nl(e,t,n){let r=Gc(jl(Bl(e,qc([...e.value.filter(e=>!gc(e))],t)),t,n),n);return r===-1?-1:r}function Pl(e,t,n,r){let i=Fl(e,t,n);if(i===-1)return-1;let[a,o]=i;return r(e,a,o,n)}function Fl(e,t,n){let r=qc([...e.value.filter(e=>!gc(e))],t),i=[],a=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&io(n.value)){if(e===a)return-1;if(e===i){e=a;continue}return-1}e.push(n)}}let o=Gc(jl(Bl(e,i),t,n),n);if(o===-1)return-1;let s=Gc(jl(Bl(e,a),t,n),n);return s===-1?-1:[o,s]}function Il(e,t,n,r){let i=Ll(e,e.value,t,n);return i===-1?-1:r(e,i,n)}function Ll(e,t,n,r){let i=qc([...t.filter(e=>!gc(e))],n),a=[];{let t=[],o=[];for(let e=0;e<i.length;e++){let n=i[e];q(n)&&io(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=Gc(jl(Bl(e,t[i]),n,r),r);if(o===-1)return-1;a.push(o)}}return a}const Rl=new Set([`nearest`,`line-width`,`up`,`down`,`to-zero`]);function zl(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(io(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=Gc(jl(Bl(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 Bl(e,t){return new $s([z.Function,`calc(`,e.name[2],e.name[3],{value:`calc`}],[z.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],t)}function Vl(e,t,n){return new $s([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,`,`,..._c(t),void 0]),n])}function Hl(e){if(e===-1)return-1;if(pc(e))return e;let t=e.value;return V(t)&&Number.isNaN(t[4].value)?W(t)?new $s([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 $s([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 rc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new rc([[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 $s([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 rc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new rc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Percentage,`1%`,t[2],t[3],{value:1}])]):-1:e}function Ul(e){if(e===-1)return-1;if(pc(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 $s([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 $s([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 rc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new rc([[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 $s([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 rc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new rc([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Percentage,`1%`,t[2],t[3],{value:1}])])}function Wl(e){if(e===-1)return-1;if(pc(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 Gl(e,t=13){if(e===-1)return-1;if(t<=0||pc(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 Kl(e){return e===-1?-1:(pc(e)||H(e.value)&&(e.value=Vc(e.value)),e)}function ql(e,t){let n=e;return t?.toCanonicalUnits&&(n=Kl(n)),n=Gl(n,t?.precision),n=Wl(n),t?.censorIntoStandardRepresentableValues||(n=Hl(n),n=Ul(n)),n}function Jl(e){let t=new Map;if(!e)return t;for(let[n,r]of e)if(to(r))t.set(n,r);else if(typeof r==`string`){let e=Ja({css:r}),i=e.nextToken();if(e.nextToken(),!e.endOfFile()||!V(i))continue;t.set(n,i);continue}return t}function Yl(e,t){let n=Jl(t?.globals);return Xl(e,e=>{if(!pc(e))return;let r=Al.get(e.getName().toLowerCase());if(!r)return;let i=ql(Gc(r(e,n,t??{}),t??{}),t);return i===-1?void 0:i})}function Xl(e,t){for(let n=0;n<e.length;n++){let r=e[n];uc(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)&&oo(a.value)&&(a.value[4].value===`-`||a.value[4].value===`+`)&&i.splice(0,0,new rc([[z.Whitespace,` `,..._c(e.node),void 0]]));let o=e.parent.value[n+1];!o||gc(o)||q(o)&&(io(o.value)||ro(o.value)||uo(o.value)||oo(o.value)&&o.value[4].value!==`-`&&o.value[4].value!==`+`)||i.push(new rc([[z.Whitespace,` `,..._c(e.node),void 0]])),e.parent.value.splice(n,1,...i)})}return e}const Zl=new Set(Al.keys());var J,Y;function Ql(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function $l(e){switch(e.colorNotation){case J.HEX:case J.RGB:case J.sRGB:return{...e,colorNotation:J.XYZ_D50,channels:ps(Ql(e.channels))};case J.Linear_sRGB:return{...e,colorNotation:J.XYZ_D50,channels:Ds(Ql(e.channels))};case J.Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:js(Ql(e.channels))};case J.Linear_Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:Ns(Ql(e.channels))};case J.Rec2020:return{...e,colorNotation:J.XYZ_D50,channels:Fs(Ql(e.channels))};case J.A98_RGB:return{...e,colorNotation:J.XYZ_D50,channels:ks(Ql(e.channels))};case J.ProPhoto_RGB:return{...e,colorNotation:J.XYZ_D50,channels:Ls(Ql(e.channels))};case J.HSL:return{...e,colorNotation:J.XYZ_D50,channels:hs(Ql(e.channels))};case J.HWB:return{...e,colorNotation:J.XYZ_D50,channels:_s(Ql(e.channels))};case J.Lab:return{...e,colorNotation:J.XYZ_D50,channels:ys(Ql(e.channels))};case J.OKLab:return{...e,colorNotation:J.XYZ_D50,channels:Cs(Ql(e.channels))};case J.LCH:return{...e,colorNotation:J.XYZ_D50,channels:xs(Ql(e.channels))};case J.OKLCH:return{...e,colorNotation:J.XYZ_D50,channels:Ts(Ql(e.channels))};case J.XYZ_D50:return{...e,colorNotation:J.XYZ_D50,channels:Vs(Ql(e.channels))};case J.XYZ_D65:return{...e,colorNotation:J.XYZ_D50,channels:zs(Ql(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 eu=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 tu(e,t){let n={...e};if(e.colorNotation!==t){let e=$l(n);switch(t){case J.HEX:case J.RGB:n.colorNotation=J.RGB,n.channels=ms(e.channels);break;case J.sRGB:n.colorNotation=J.sRGB,n.channels=ms(e.channels);break;case J.Linear_sRGB:n.colorNotation=J.Linear_sRGB,n.channels=Os(e.channels);break;case J.Display_P3:n.colorNotation=J.Display_P3,n.channels=Ms(e.channels);break;case J.Linear_Display_P3:n.colorNotation=J.Linear_Display_P3,n.channels=Ps(e.channels);break;case J.Rec2020:n.colorNotation=J.Rec2020,n.channels=Is(e.channels);break;case J.ProPhoto_RGB:n.colorNotation=J.ProPhoto_RGB,n.channels=Rs(e.channels);break;case J.A98_RGB:n.colorNotation=J.A98_RGB,n.channels=As(e.channels);break;case J.HSL:n.colorNotation=J.HSL,n.channels=gs(e.channels);break;case J.HWB:n.colorNotation=J.HWB,n.channels=vs(e.channels);break;case J.Lab:n.colorNotation=J.Lab,n.channels=bs(e.channels);break;case J.LCH:n.colorNotation=J.LCH,n.channels=Ss(e.channels);break;case J.OKLCH:n.colorNotation=J.OKLCH,n.channels=Es(e.channels);break;case J.OKLab:n.colorNotation=J.OKLab,n.channels=ws(e.channels);break;case J.XYZ_D50:n.colorNotation=J.XYZ_D50,n.channels=Vs(e.channels);break;case J.XYZ_D65:n.colorNotation=J.XYZ_D65,n.channels=Bs(e.channels);break;default:throw Error(`Unsupported color notation`)}}else n.channels=Ql(e.channels);if(t===e.colorNotation)n.channels=ru(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else if(eu.has(t)&&eu.has(e.colorNotation))n.channels=ru(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else switch(t){case J.HSL:switch(e.colorNotation){case J.HWB:n.channels=ru(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=ru(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.LCH:case J.OKLCH:n.channels=ru(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;default:n.channels=ru(e.channels,[],[],n.channels,[],[])}break;case J.HWB:switch(e.colorNotation){case J.HSL:n.channels=ru(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=ru(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;default:n.channels=ru(e.channels,[],[],n.channels,[],[])}break;case J.Lab:case J.OKLab:switch(e.colorNotation){case J.HSL:n.channels=ru(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=ru(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;case J.LCH:case J.OKLCH:n.channels=ru(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;default:n.channels=ru(e.channels,[],[],n.channels,[],[])}break;case J.LCH:case J.OKLCH:switch(e.colorNotation){case J.HSL:n.channels=ru(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;case J.HWB:n.channels=ru(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.Lab:case J.OKLab:n.channels=ru(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=ru(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;default:n.channels=ru(e.channels,[],[],n.channels,[],[])}break;default:n.channels=ru(e.channels,[],[],n.channels,[],[])}return n.channels=nu(n.channels,t),n}function nu(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 ru(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 iu(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 au(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 ou=/[A-Z]/g;function Q(e){return e.replace(ou,e=>String.fromCharCode(e.charCodeAt(0)+32))}function su(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 cu=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`xyz`,`xyz-d50`,`xyz-d65`]);function lu(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(mc(p)||hc(p))for(;mc(e.value[f+1])||hc(e.value[f+1]);)f++;else if(d===n&&n.length&&(d=r),d===r&&r.length&&(d=i),q(p)&&oo(p.value)&&p.value[4].value===`/`){if(d===a)return!1;d=a}else{if(pc(p)){if(d===a&&Q(p.getName())===`var`){u.syntaxFlags.add(Y.HasVariableAlpha),d.push(p);continue}if(!Zl.has(Q(p.getName())))return!1;let[[e]]=Yl([[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)&&cu.has(Q(p.value[4].value))){if(c)return!1;c=Q(p.value[4].value),u.colorNotation=uu(c),l&&(l.colorNotation!==u.colorNotation&&(l=tu(l,u.colorNotation)),o=iu(l),s=au(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(;mc(e.value[f+1])||hc(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=su(n[0].value,0,u);if(!f||!W(f))return!1;let p=su(r[0].value,1,u);if(!p||!W(p))return!1;let m=su(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=su(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=su(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 uu(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 du=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`lab`,`oklab`,`xyz`,`xyz-d50`,`xyz-d65`]),fu=new Set([`hsl`,`hwb`,`lch`,`oklch`]),pu=new Set([`shorter`,`longer`,`increasing`,`decreasing`]);function mu(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(!gc(s)){if(!(n||q(s)&&U(s.value)&&Q(s.value[4].value)===`in`))return gu(`oklab`,hu(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&&fu.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)||!io(s.value))&&!!r&&(i||a?!!(i&&a&&fu.has(r)&&pu.has(i))&&vu(r,i,hu(e.value.slice(o+1),t)):du.has(r)?gu(r,hu(e.value.slice(o+1),t)):!!fu.has(r)&&vu(r,`shorter`,hu(e.value.slice(o+1),t)))}}return!1}function hu(e,t){let n=[],r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(!gc(o)){if(!q(o)||!io(o.value)){if(!r){let e=t(o);if(e){r=e;continue}}if(!i){if(pc(o)&&Zl.has(Q(o.getName()))){if([[o]]=Yl([[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 gu(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}=wu(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=tu(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=_u(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 _u(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=tu(t,e).channels,s=tu(n,e).channels;o[0]=bu(o[0],s[0]),s[0]=bu(s[0],o[0]),o[1]=bu(o[1],s[1]),s[1]=bu(s[1],o[1]),o[2]=bu(o[2],s[2]),s[2]=bu(s[2],o[2]),o[0]=Su(o[0],i),o[1]=Su(o[1],i),o[2]=Su(o[2],i),s[0]=Su(s[0],a),s[1]=Su(s[1],a),s[2]=Su(s[2],a);let c=xu(i,a,r);return{colorNotation:e,channels:[Cu(xu(o[0],s[0],r),c),Cu(xu(o[1],s[1],r),c),Cu(xu(o[2],s[2],r),c)],alpha:c,syntaxFlags:new Set([Y.ColorMix])}}function vu(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}=wu(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=tu(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=yu(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 yu(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=tu(n,e).channels,m=tu(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=bu(a,o),Number.isNaN(a)&&(a=0),o=bu(o,a),Number.isNaN(o)&&(o=0),s=bu(s,c),c=bu(c,s),l=bu(l,u),u=bu(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=Su(s,d),l=Su(l,d),c=Su(c,f),u=Su(u,f);let g=[0,0,0],_=xu(d,f,i);switch(e){case J.HSL:case J.HWB:g=[xu(a,o,i),Cu(xu(s,c,i),_),Cu(xu(l,u,i),_)];break;case J.LCH:case J.OKLCH:g=[Cu(xu(s,c,i),_),Cu(xu(l,u,i),_),xu(a,o,i)]}return{colorNotation:e,channels:g,alpha:_,syntaxFlags:new Set([Y.ColorMix])}}function bu(e,t){return Number.isNaN(e)?t:e}function xu(e,t,n){return e*(1-n)+t*n}function Su(e,t){return Number.isNaN(t)?e:Number.isNaN(e)?NaN:e*t}function Cu(e,t){return t===0||Number.isNaN(t)?e:Number.isNaN(e)?NaN:e/t}function wu(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 Tu(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 Eu(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 Du(e,t,n){if(t===0){let t=Eu(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 Ou(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=Eu(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 ku(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(!mc(n)&&!hc(n)){if(q(n)&&io(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(pc(n)){if(l===s&&n.getName().toLowerCase()===`var`){c.syntaxFlags.add(Y.HasVariableAlpha),l.push(n);continue}if(!Zl.has(n.getName().toLowerCase()))return!1;let[[e]]=Yl([[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 Au(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(mc(r)||hc(r))for(;mc(e.value[t+1])||hc(e.value[t+1]);)t++;else if(p===a&&a.length&&(p=o),p===o&&o.length&&(p=s),q(r)&&oo(r.value)&&r.value[4].value===`/`){if(p===c)return!1;p=c}else{if(pc(r)){if(p===c&&r.getName().toLowerCase()===`var`){f.syntaxFlags.add(Y.HasVariableAlpha),p.push(r);continue}if(!Zl.has(r.getName().toLowerCase()))return!1;let[[e]]=Yl([[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(;mc(e.value[t+1])||hc(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=tu(d,n)),l=iu(d),u=au(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 ju(e,t){if(e.value.some(e=>q(e)&&io(e.value))){let t=Mu(e);if(!1!==t)return t}{let n=Nu(e,t);if(!1!==n)return n}return!1}function Mu(e){return ku(e,Du,J.HSL,[Y.LegacyHSL])}function Nu(e,t){return Au(e,Ou,J.HSL,[],t)}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=Eu(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 Fu(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 Iu(e,t){return Au(e,Fu,J.Lab,[],t)}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===2){let t=Eu(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 Ru(e,t){return Au(e,Lu,J.LCH,[],t)}const zu=new Map;for(let[e,t]of Object.entries(Ks))zu.set(e,t);function Bu(e){let t=zu.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 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,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 Hu(e,t){return Au(e,Vu,J.OKLab,[],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=Eu(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 Wu(e,t){return Au(e,Uu,J.OKLCH,[],t)}function Gu(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 Ku(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 qu(e,t){if(e.value.some(e=>q(e)&&io(e.value))){let t=Ju(e);if(!1!==t)return(!t.syntaxFlags.has(Y.HasNumberValues)||!t.syntaxFlags.has(Y.HasPercentageValues))&&t}else{let n=Yu(e,t);if(!1!==n)return n}return!1}function Ju(e){return ku(e,Gu,J.RGB,[Y.LegacyRGB])}function Yu(e,t){return Au(e,Ku,J.RGB,[],t)}function Xu(e){let t=ms(e);if(Hs(t))return Us(t);let n=e;return n=Es(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),qo(Ws(n,Zu,Qu))}function Zu(e){return e=ko(e),e=No(e),Go(e)}function Qu(e){return e=us(e),e=Ro(e),Ao(e)}function $u(e,t){let n=!1;for(let r=0;r<e.value.length;r++){let i=e.value[r];if(!mc(i)&&!hc(i)&&(n||(n=t(i),!n)))return!1}if(!n)return!1;n.channels=Ql(n.channels),n.channels=Xu($l(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=Js(n.channels,[1,1,1])>Js(n.channels,[0,0,0])?[1,1,1]:[0,0,0],r}function ed(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(mc(l)||hc(l))for(;mc(e.value[c+1])||hc(e.value[c+1]);)c++;else if(o&&!i&&!a&&q(l)&&oo(l.value)&&l.value[4].value===`/`)i=!0;else{if(pc(l)&&Zl.has(Q(l.getName()))){let[[e]]=Yl([[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=su(l.value,3,s);if(!e||!W(e))return!1;s.alpha=new K(e),a=!0;continue}if(pc(l)){s.alpha=dc([[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(;mc(e.value[c+1])||hc(e.value[c+1]);)c++;if(c++,l=e.value[c],o=t(l),!1===o)return!1;n=iu(o),r=au(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 td(e){if(pc(e))switch(Q(e.getName())){case`rgb`:case`rgba`:return qu(e,td);case`hsl`:case`hsla`:return ju(e,td);case`hwb`:return t=td,Au(e,Pu,J.HWB,[],t);case`lab`:return Iu(e,td);case`lch`:return Ru(e,td);case`oklab`:return Hu(e,td);case`oklch`:return Wu(e,td);case`color`:return lu(e,td);case`color-mix`:return mu(e,td);case`contrast-color`:return $u(e,td);case`alpha`:return ed(e,td)}var t;if(q(e)){if(lo(e.value))return Tu(e.value);if(U(e.value)){let t=Bu(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 nd(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function rd(e){switch(e.colorNotation){case`hex`:case`rgb`:case`srgb`:return{...e,colorNotation:`xyz-d50`,channels:ps(nd(e.channels))};case`srgb-linear`:return{...e,colorNotation:`xyz-d50`,channels:Ds(nd(e.channels))};case`display-p3`:return{...e,colorNotation:`xyz-d50`,channels:js(nd(e.channels))};case`display-p3-linear`:return{...e,colorNotation:`xyz-d50`,channels:Ns(nd(e.channels))};case`rec2020`:return{...e,colorNotation:`xyz-d50`,channels:Fs(nd(e.channels))};case`a98-rgb`:return{...e,colorNotation:`xyz-d50`,channels:ks(nd(e.channels))};case`prophoto-rgb`:return{...e,colorNotation:`xyz-d50`,channels:Ls(nd(e.channels))};case`hsl`:return{...e,colorNotation:`xyz-d50`,channels:hs(nd(e.channels))};case`hwb`:return{...e,colorNotation:`xyz-d50`,channels:_s(nd(e.channels))};case`lab`:return{...e,colorNotation:`xyz-d50`,channels:ys(nd(e.channels))};case`oklab`:return{...e,colorNotation:`xyz-d50`,channels:Cs(nd(e.channels))};case`lch`:return{...e,colorNotation:`xyz-d50`,channels:xs(nd(e.channels))};case`oklch`:return{...e,colorNotation:`xyz-d50`,channels:Ts(nd(e.channels))};case`xyz-d50`:return{...e,colorNotation:`xyz-d50`,channels:Vs(nd(e.channels))};case`xyz-d65`:return{...e,colorNotation:`xyz-d50`,channels:zs(nd(e.channels))};default:throw Error(`Unsupported color notation`)}}function id(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 ad(e){let t=ms(e);if(Hs(t))return Us(t);let n=e;return n=Es(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),qo(Ws(n,od,sd))}function od(e){return e=ko(e),e=No(e),Go(e)}function sd(e){return e=us(e),e=Ro(e),Ao(e)}var cd=class e{static colorTxtList=[];static parseColorString(e){try{let t=cc(qa({css:e}));if(!t)return null;let n=td(t);if(n===!1)return null;let r=ad(rd(n).channels),i=Math.min(255,Math.max(0,Math.round(id(r[0])*255))),a=Math.min(255,Math.max(0,Math.round(id(r[1])*255))),o=Math.min(255,Math.max(0,Math.round(id(r[2])*255))),s=1;return typeof n.alpha==`number`&&(s=Math.min(1,Math.max(0,id(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(aa.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(aa.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=aa.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]}},ld=class{static send(e){$.sendNotification(`aventus/openfile`,e)}},ud=class{static cmd=`aventus.addConfigSection`;static async run(e){try{if(!e){let t=[],n=L.getInstance().getAllConfigFiles();for(let e of n)t.push({label:e});if(t.length>1){let n=await $.Select(t,{placeHolder:`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)(D(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)(D(e),JSON.stringify(r,null,4)),ld.send(e)}catch(e){console.error(e)}}},dd=class{static cmd=`aventus.compile`;static async run(){let e=[],t=L.getInstance().getAllBuilds();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{placeHolder:`Project to compile`});if(n){let e=n.detail??``,t=n.label;L.getInstance().getProjectByUri(e)?.getBuild(t)?.build()}}},fd=class e{static cmd=`aventus.create`;static async run(t){if(!t)return;let n=(0,f.normalize)(D(t));if(e.checkIfProject(t)){if(!$.isIDE){let e=await $.SelectFolder(`Select where to create`,n);if(!e)return;t=e,n=D(t)}await $.localTemplateManager?.createTemplate(n)}else await $.localProjectManager?.createGlobal(n)}static checkIfProject(e){let t=L.getInstance().getAllConfigFiles(),n=e.replace(/\\/g,`/`);for(let e of t)if(n.startsWith(e.replace(`/`+w.Config,``)))return!0;return!1}},pd=class{static cmd=`aventus.filesystem.created`;static run(e){e&&R.getInstance().onCreatedUri(e)}},md=class{static cmd=`aventus.filesystem.deleted`;static async run(e){e&&R.getInstance().onDeletedUri(e)}},hd=class{static cmd=`aventus.filesystem.updated`;static async run(e){e&&R.getInstance().onUpdatedUri(e)}},gd=class{static send(e){$.sendNotification(`aventus/closefile`,e)}},_d=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=`
|
|
989
|
+
*/function Ks(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=qs(o,a);if(!s)break;a=s}return Gs(a)}function qs(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 Js={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 Ys(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 Xs(e,t){let n=Ys(e),r=Ys(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}var Zs;function Qs(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 $s(e,t){let n=t[0];if(ho(n)||vo(n)||_o(n)){let n=ic(e,t);return{advance:n.advance,node:n.node}}if(uo(n)){let n=nc(e,t);return{advance:n.advance,node:n.node}}if(mo(n)){let n=oc(e,t);return{advance:n.advance,node:n.node}}if(so(n)){let n=cc(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`})(Zs||={});var ec=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=Qs(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)}},tc=class e extends ec{type=Zs.Function;name;endToken;constructor(e,t,n){super(),this.name=e,this.endToken=t,this.value=n}getName(){return this.name[4].value}normalize(){lo(this.endToken)&&(this.endToken=[z.CloseParen,`)`,-1,-1,void 0])}tokens(){return lo(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=>ro(e)?da(e):e.toString()).join(``);return da(this.name)+e+da(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===Zs.Function}};function nc(e,t){let n=[],r=1;for(;;){let i=t[r];if(!i||lo(i))return e.onParseError(new ca(`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 tc(t[0],i,n)};if(go(i))return{advance:r+1,node:new tc(t[0],i,n)};if(io(i)){let i=lc(e,t.slice(r));r+=i.advance,n.push(...i.nodes);continue}let a=$s(e,t.slice(r));r+=a.advance,n.push(a.node)}}var rc=class e extends ec{type=Zs.SimpleBlock;startToken;endToken;constructor(e,t,n){super(),this.startToken=e,this.endToken=t,this.value=n}normalize(){if(lo(this.endToken)){let e=Na(this.startToken);e&&(this.endToken=e)}}tokens(){return lo(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=>ro(e)?da(e):e.toString()).join(``);return da(this.startToken)+e+da(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===Zs.SimpleBlock}};function ic(e,t){let n=Ma(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||lo(a))return e.onParseError(new ca(`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 rc(t[0],a,r)};if(a[0]===n)return{advance:i+1,node:new rc(t[0],a,r)};if(io(a)){let n=lc(e,t.slice(i));i+=n.advance,r.push(...n.nodes);continue}let o=$s(e,t.slice(i));i+=o.advance,r.push(o.node)}}var ac=class e{type=Zs.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return da(...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===Zs.Whitespace}};function oc(e,t){let n=0;for(;;){let e=t[n];if(!mo(e))return{advance:n,node:new ac(t.slice(0,n))};n++}}var sc=class e{type=Zs.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return da(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===Zs.Comment}};function cc(e,t){return{advance:1,node:new sc(t[0])}}function lc(e,t){let n=[],r=0;for(;;){if(mo(t[r])){let e=oc(0,t.slice(r));r+=e.advance,n.push(e.node);continue}if(!so(t[r]))return{advance:r,nodes:n};n.push(new sc(t[r])),r++}}var K=class e{type=Zs.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===Zs.Token}};function uc(e,t){let n={onParseError:t?.onParseError??(()=>{})},r=[...e];lo(r[r.length-1])||r.push([z.EOF,``,r[r.length-1][2],r[r.length-1][3],void 0]);let i=$s(n,r);if(lo(r[Math.min(i.advance,r.length-1)]))return i.node;n.onParseError(new ca(`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 dc(e,t,n){if(e.length===0)return;let r=Qs(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 fc(e,t,n){e.length!==0&&dc(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 pc(e,t){for(let n=0;n<e.length;n++)fc(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 mc(e){return rc.isSimpleBlockNode(e)}function hc(e){return tc.isFunctionNode(e)}function gc(e){return ac.isWhitespaceNode(e)}function _c(e){return sc.isCommentNode(e)}function vc(e){return gc(e)||_c(e)}function q(e){return K.isTokenNode(e)}function yc(e){if(Array.isArray(e)){let t=e[0];if(!t)return[0,0];let n=e[e.length-1]||t;return[yc(t)[0],yc(n)[1]]}let t=e.tokens(),n=t[0],r=t[t.length-1];return n&&r?[n[2],r[3]]:[0,0]}var bc=class extends Error{sourceStart;sourceEnd;constructor(e,t,n){super(e),this.name=`ParseError`,this.sourceStart=t,this.sourceEnd=n}},xc=class extends bc{componentValues;constructor(e,t){super(e,...yc(t)),this.componentValues=t}};const Sc={UnexpectedAdditionOfDimensionOrPercentageWithNumber:`Unexpected addition of a dimension or percentage with a number.`,UnexpectedSubtractionOfDimensionOrPercentageWithNumber:`Unexpected subtraction of a dimension or percentage with a number.`},Cc=/[A-Z]/g;function wc(e){return e.replace(Cc,e=>String.fromCharCode(e.charCodeAt(0)+32))}const Tc={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`},Ec=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]]),Dc=new Map([[`deg`,e=>e],[`grad`,e=>e/.9],[`rad`,e=>e/180*Math.PI],[`turn`,e=>e/360]]),Oc=new Map([[`deg`,e=>.9*e],[`grad`,e=>e],[`rad`,e=>.9*e/180*Math.PI],[`turn`,e=>.9*e/360]]),kc=new Map([[`hz`,e=>e],[`khz`,e=>e/1e3]]),Ac=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]]),jc=new Map([[`hz`,e=>1e3*e],[`khz`,e=>e]]),Mc=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]]),Nc=new Map([[`ms`,e=>e],[`s`,e=>e/1e3]]),Pc=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]]),Fc=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]]),Ic=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]]),Lc=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]]),Rc=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]]),zc=new Map([[`ms`,e=>1e3*e],[`s`,e=>e]]),Bc=new Map([[`deg`,e=>360*e],[`grad`,e=>360*e/.9],[`rad`,e=>360*e/180*Math.PI],[`turn`,e=>e]]),Vc=new Map([[`cm`,Ec],[`mm`,Mc],[`q`,Lc],[`in`,Ac],[`pc`,Pc],[`pt`,Fc],[`px`,Ic],[`ms`,Nc],[`s`,zc],[`deg`,Dc],[`grad`,Oc],[`rad`,Rc],[`turn`,Bc],[`hz`,kc],[`khz`,jc]]);function Hc(e,t){if(!H(e)||!H(t))return t;let n=wc(e[4].unit),r=wc(t[4].unit);if(n===r)return t;let i=Vc.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 Qa(s,e[4].unit),s}function Uc(e){if(!H(e))return e;let t=wc(e[4].unit),n=Tc[t];if(t===n)return e;let r=Vc.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 Qa(o,n),o}function Wc(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=Hc(n,r),wc(n[4].unit)===wc(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 xc(Sc.UnexpectedAdditionOfDimensionOrPercentageWithNumber,e)),-1}function Gc(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 Kc(e){return!!e&&typeof e==`object`&&`inputs`in e&&Array.isArray(e.inputs)&&`operation`in e}function qc(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=qc(i,t);if(a===-1)return-1;n.push(a)}return e.operation(n,t)}function Jc(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 Yc(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=wc(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 Xc(e){if(e.length!==1)return-1;let t=e[0].value;return V(t)?e[0]:-1}function Zc(e,t,n){return H(t)?Qc(e,t[4].unit,n):G(t)?$c(e,n):W(t)?el(e,n):-1}function Qc(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:Xc}}function $c(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:Xc}}function el(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:Xc}}function tl(e,t){let n=t.value;return W(n)?Qc(e,`rad`,Math.acos(n[4].value)):-1}function nl(e,t){let n=t.value;return W(n)?Qc(e,`rad`,Math.asin(n[4].value)):-1}function rl(e,t){let n=t.value;return W(n)?Qc(e,`rad`,Math.atan(n[4].value)):-1}function il(e){return H(e)||W(e)}function al(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=wc(t[4].unit);for(let r=1;r<e.length;r++){let i=e[r];if(t[0]!==i[0]||n!==wc(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 ol(e,t){return!!V(e)&&(H(e)?e[0]===t[0]&&wc(e[4].unit)===wc(t[4].unit):e[0]===t[0])}function sl(e,t,n){let r=t.value;if(!il(r))return-1;let i=Hc(r,n.value);return ol(r,i)?Qc(e,`rad`,Math.atan2(r[4].value,i[4].value)):-1}function cl(e,t,n){let r=t.value;return!V(r)||!n.rawPercentages&&G(r)?-1:Zc(e,r,Math.abs(r[4].value))}function ll(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=Hc(a,n.value);if(!ol(a,o))return-1;let s=Hc(a,r.value);return ol(a,s)?Zc(e,a,Math.max(a[4].value,Math.min(o[4].value,s[4].value))):-1}function ul(e,t){let n=t.value;if(!il(n))return-1;let r=n[4].value;if(H(n))switch(n[4].unit.toLowerCase()){case`rad`:break;case`deg`:r=Dc.get(`rad`)(n[4].value);break;case`grad`:r=Oc.get(`rad`)(n[4].value);break;case`turn`:r=Bc.get(`rad`)(n[4].value);break;default:return-1}return r=Math.cos(r),el(e,r)}function dl(e,t){let n=t.value;return W(n)?el(e,Math.exp(n[4].value)):-1}function fl(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=>Hc(r,e.value));if(!al(i))return-1;let a=i.map(e=>e[4].value);return Zc(e,r,Math.hypot(...a))}function pl(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=>Hc(r,e.value));if(!al(i))return-1;let a=i.map(e=>e[4].value);return Zc(e,r,Math.max(...a))}function ml(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=>Hc(r,e.value));if(!al(i))return-1;let a=i.map(e=>e[4].value);return Zc(e,r,Math.min(...a))}function hl(e,t,n){let r=t.value;if(!V(r))return-1;let i=Hc(r,n.value);if(!ol(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,Zc(e,r,a)}function gl(e,t,n){let r=t.value,i=n.value;return!W(r)||!ol(r,i)?-1:el(e,r[4].value**+i[4].value)}function _l(e,t,n){let r=t.value;if(!V(r))return-1;let i=Hc(r,n.value);if(!ol(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,Zc(e,r,a)}function vl(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=Hc(i,t);if(!ol(a,i))return-1;if(Number.isInteger(a[4].value/r))return Zc(e,t,t[4].value);if(a[4].value>0){if(a[4].value<r)return Zc(e,t,Hc(t,i)[4].value);let n=Math.floor(a[4].value/i[4].value)*i[4].value;return a[4].value=n,Zc(e,t,Hc(t,a)[4].value)}if(Math.abs(a[4].value)<r)return Zc(e,t,-1*Hc(t,i)[4].value);let o=Math.ceil(a[4].value/i[4].value)*i[4].value;return a[4].value=o,Zc(e,t,Hc(t,a)[4].value)}function yl(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=Hc(a,r.value);if(!ol(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=qc(Zc(e,a,s),i);return t===-1?-1:vl(e,t.value,i)}break}}else s=NaN;return Zc(e,a,s)}function bl(e,t,n){let r=t.value;return!V(r)||!n.rawPercentages&&G(r)?-1:el(e,Math.sign(r[4].value))}function xl(e,t){let n=t.value;if(!il(n))return-1;let r=n[4].value;if(H(n))switch(wc(n[4].unit)){case`rad`:break;case`deg`:r=Dc.get(`rad`)(n[4].value);break;case`grad`:r=Oc.get(`rad`)(n[4].value);break;case`turn`:r=Bc.get(`rad`)(n[4].value);break;default:return-1}return r=Math.sin(r),el(e,r)}function Sl(e,t){let n=t.value;return W(n)?el(e,Math.sqrt(n[4].value)):-1}function Cl(e,t){let n=t.value;if(!il(n))return-1;let r=n[4].value,i=0,a=n[4].value;if(H(n))switch(wc(n[4].unit)){case`rad`:i=Rc.get(`deg`)(r);break;case`deg`:i=r,a=Dc.get(`rad`)(r);break;case`grad`:i=Oc.get(`deg`)(r),a=Oc.get(`rad`)(r);break;case`turn`:i=Bc.get(`deg`)(r),a=Bc.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),el(e,a)}function wl(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=Hc(n,r),wc(n[4].unit)===wc(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 xc(Sc.UnexpectedSubtractionOfDimensionOrPercentageWithNumber,e)),-1}function Tl(e,t){if(t.length===1){let n=t[0];if(!n||!q(n))return-1;let r=n.value;return W(r)?el(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)?el(e,Math.log(r[4].value)/Math.log(a[4].value)):-1}return-1}const El=/^none$/i;function Dl(e){if(Array.isArray(e)){let t=e.filter(e=>!(gc(e)&&_c(e)));return t.length===1&&Dl(t[0])}if(!q(e))return!1;let t=e.value;return!!U(t)&&El.test(t[4].value)}const Ol=String.fromCodePoint(0);function kl(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=Hc(o,r.value);if(!ol(o,s))return-1;let c=null;if(i&&(c=Hc(o,i.value),!ol(o,c)))return-1;if(!Number.isFinite(o[4].value)||!Number.isFinite(s[4].value)||!Number.isFinite(s[4].value-o[4].value))return Zc(e,o,NaN);if(c&&!Number.isFinite(c[4].value))return Zc(e,o,o[4].value);let l=t.fixed===-1?Al(jl([t.dashedIdent?t.dashedIdent:`${a.randomCaching?.propertyName} ${a.randomCaching.propertyN++}`,t.elementShared?``:a.randomCaching.elementID,a.randomCaching.documentID].join(Ol))):()=>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 Zc(e,o,Number(n[Math.floor(n.length*i)].toFixed(5)))}let f=l();return Zc(e,o,Number((f*(d-u)+u).toFixed(5)))}function Al(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 jl(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 Ml=new Map([[`abs`,function(e,t,n){return Pl(e,t,n,cl)}],[`acos`,function(e,t,n){return Pl(e,t,n,tl)}],[`asin`,function(e,t,n){return Pl(e,t,n,nl)}],[`atan`,function(e,t,n){return Pl(e,t,n,rl)}],[`atan2`,function(e,t,n){return Il(e,t,n,sl)}],[`calc`,Nl],[`clamp`,function(e,t,n){let r=Yc([...e.value.filter(e=>!vc(e))],t),i=[],a=[],o=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&oo(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=Dl(i),c=Dl(o);if(s&&c)return Nl(Hl(e,a),t,n);let l=qc(Nl(Hl(e,a),t,n),n);if(l===-1)return-1;if(s){let r=qc(Nl(Hl(e,o),t,n),n);return r===-1?-1:ml((u=e,d=l,f=r,new tc([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,`,`,...yc(d),void 0]),f])),[l,r],n)}if(c){let r=qc(Nl(Hl(e,i),t,n),n);return r===-1?-1:pl(Ul(e,r,l),[r,l],n)}var u,d,f;let p=qc(Nl(Hl(e,i),t,n),n);if(p===-1)return-1;let m=qc(Nl(Hl(e,o),t,n),n);return m===-1?-1:ll(e,p,l,m,n)}],[`cos`,function(e,t,n){return Pl(e,t,n,ul)}],[`exp`,function(e,t,n){return Pl(e,t,n,dl)}],[`hypot`,function(e,t,n){return Rl(e,t,n,fl)}],[`log`,function(e,t,n){return Rl(e,t,n,Tl)}],[`max`,function(e,t,n){return Rl(e,t,n,pl)}],[`min`,function(e,t,n){return Rl(e,t,n,ml)}],[`mod`,function(e,t,n){return Il(e,t,n,hl)}],[`pow`,function(e,t,n){return Il(e,t,n,gl)}],[`random`,function(e,t,n){let r=Vl(e,e.value.filter(e=>!vc(e)),t,n);if(r===-1)return-1;let[i,a]=r,o=zl(e,a,t,n);if(o===-1)return-1;let[s,c,l]=o;return!s||!c?-1:kl(e,i,s,c,l,n)}],[`rem`,function(e,t,n){return Il(e,t,n,_l)}],[`round`,function(e,t,n){let r=Yc([...e.value.filter(e=>!vc(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(Bl.has(e)){i=e;continue}}if(q(n)&&oo(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=qc(Nl(Hl(e,o),t,n),n);if(c===-1)return-1;if(i===`line-width`){let e=Hc([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 vl(e,c.value,n);s.push(new K([z.Number,`1`,c.value[2],c.value[3],{value:1,type:B.Integer}]))}let l=qc(Nl(Hl(e,s),t,n),n);return l===-1?-1:(i||=`nearest`,yl(e,i,c,l,n))}],[`sign`,function(e,t,n){return Pl(e,t,n,bl)}],[`sin`,function(e,t,n){return Pl(e,t,n,xl)}],[`sqrt`,function(e,t,n){return Pl(e,t,n,Sl)}],[`tan`,function(e,t,n){return Pl(e,t,n,Cl)}]]);function Nl(e,t,n){let r=Yc([...e.value.filter(e=>!vc(e))],t);if(r.length===1&&q(r[0]))return{inputs:[r[0]],operation:Xc};let i=0;for(;i<r.length;){let e=r[i];if(mc(e)&&ho(e.startToken)){let a=Nl(e,t,n);if(a===-1)return-1;r.splice(i,1,a);continue}if(hc(e)){let a=Ml.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&&Kc(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!Kc(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!co(n)||n[4].value!==`*`&&n[4].value!==`/`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!Kc(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:Gc}):i++}if(i=0,r.length===1&&Kc(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!Kc(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!co(n)||n[4].value!==`+`&&n[4].value!==`-`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!Kc(a))return-1;n[4].value===`+`?r.splice(i,3,{inputs:[e,a],operation:Wc}):n[4].value===`-`?r.splice(i,3,{inputs:[e,a],operation:wl}):i++}return r.length===1&&Kc(r[0])?r[0]:-1}function Pl(e,t,n,r){let i=Fl(e,t,n);return i===-1?-1:r(e,i,n)}function Fl(e,t,n){let r=qc(Nl(Hl(e,Yc([...e.value.filter(e=>!vc(e))],t)),t,n),n);return r===-1?-1:r}function Il(e,t,n,r){let i=Ll(e,t,n);if(i===-1)return-1;let[a,o]=i;return r(e,a,o,n)}function Ll(e,t,n){let r=Yc([...e.value.filter(e=>!vc(e))],t),i=[],a=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&oo(n.value)){if(e===a)return-1;if(e===i){e=a;continue}return-1}e.push(n)}}let o=qc(Nl(Hl(e,i),t,n),n);if(o===-1)return-1;let s=qc(Nl(Hl(e,a),t,n),n);return s===-1?-1:[o,s]}function Rl(e,t,n,r){let i=zl(e,e.value,t,n);return i===-1?-1:r(e,i,n)}function zl(e,t,n,r){let i=Yc([...t.filter(e=>!vc(e))],n),a=[];{let t=[],o=[];for(let e=0;e<i.length;e++){let n=i[e];q(n)&&oo(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=qc(Nl(Hl(e,t[i]),n,r),r);if(o===-1)return-1;a.push(o)}}return a}const Bl=new Set([`nearest`,`line-width`,`up`,`down`,`to-zero`]);function Vl(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(oo(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=qc(Nl(Hl(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 Hl(e,t){return new tc([z.Function,`calc(`,e.name[2],e.name[3],{value:`calc`}],[z.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],t)}function Ul(e,t,n){return new tc([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,`,`,...yc(t),void 0]),n])}function Wl(e){if(e===-1)return-1;if(hc(e))return e;let t=e.value;return V(t)&&Number.isNaN(t[4].value)?W(t)?new tc([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 tc([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 ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new ac([[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 tc([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 ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Percentage,`1%`,t[2],t[3],{value:1}])]):-1:e}function Gl(e){if(e===-1)return-1;if(hc(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 tc([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 tc([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 ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new ac([[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 tc([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 ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Delim,`*`,t[2],t[3],{value:`*`}]),new ac([[z.Whitespace,` `,t[2],t[3],void 0]]),new K([z.Percentage,`1%`,t[2],t[3],{value:1}])])}function Kl(e){if(e===-1)return-1;if(hc(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 ql(e,t=13){if(e===-1)return-1;if(t<=0||hc(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 Jl(e){return e===-1?-1:(hc(e)||H(e.value)&&(e.value=Uc(e.value)),e)}function Yl(e,t){let n=e;return t?.toCanonicalUnits&&(n=Jl(n)),n=ql(n,t?.precision),n=Kl(n),t?.censorIntoStandardRepresentableValues||(n=Wl(n),n=Gl(n)),n}function Xl(e){let t=new Map;if(!e)return t;for(let[n,r]of e)if(ro(r))t.set(n,r);else if(typeof r==`string`){let e=Xa({css:r}),i=e.nextToken();if(e.nextToken(),!e.endOfFile()||!V(i))continue;t.set(n,i);continue}return t}function Zl(e,t){let n=Xl(t?.globals);return Ql(e,e=>{if(!hc(e))return;let r=Ml.get(e.getName().toLowerCase());if(!r)return;let i=Yl(qc(r(e,n,t??{}),t??{}),t);return i===-1?void 0:i})}function Ql(e,t){for(let n=0;n<e.length;n++){let r=e[n];fc(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)&&co(a.value)&&(a.value[4].value===`-`||a.value[4].value===`+`)&&i.splice(0,0,new ac([[z.Whitespace,` `,...yc(e.node),void 0]]));let o=e.parent.value[n+1];!o||vc(o)||q(o)&&(oo(o.value)||ao(o.value)||po(o.value)||co(o.value)&&o.value[4].value!==`-`&&o.value[4].value!==`+`)||i.push(new ac([[z.Whitespace,` `,...yc(e.node),void 0]])),e.parent.value.splice(n,1,...i)})}return e}const $l=new Set(Ml.keys());var J,Y;function eu(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function tu(e){switch(e.colorNotation){case J.HEX:case J.RGB:case J.sRGB:return{...e,colorNotation:J.XYZ_D50,channels:hs(eu(e.channels))};case J.Linear_sRGB:return{...e,colorNotation:J.XYZ_D50,channels:ks(eu(e.channels))};case J.Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:Ns(eu(e.channels))};case J.Linear_Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:Fs(eu(e.channels))};case J.Rec2020:return{...e,colorNotation:J.XYZ_D50,channels:Ls(eu(e.channels))};case J.A98_RGB:return{...e,colorNotation:J.XYZ_D50,channels:js(eu(e.channels))};case J.ProPhoto_RGB:return{...e,colorNotation:J.XYZ_D50,channels:zs(eu(e.channels))};case J.HSL:return{...e,colorNotation:J.XYZ_D50,channels:_s(eu(e.channels))};case J.HWB:return{...e,colorNotation:J.XYZ_D50,channels:ys(eu(e.channels))};case J.Lab:return{...e,colorNotation:J.XYZ_D50,channels:xs(eu(e.channels))};case J.OKLab:return{...e,colorNotation:J.XYZ_D50,channels:Ts(eu(e.channels))};case J.LCH:return{...e,colorNotation:J.XYZ_D50,channels:Cs(eu(e.channels))};case J.OKLCH:return{...e,colorNotation:J.XYZ_D50,channels:Ds(eu(e.channels))};case J.XYZ_D50:return{...e,colorNotation:J.XYZ_D50,channels:Us(eu(e.channels))};case J.XYZ_D65:return{...e,colorNotation:J.XYZ_D50,channels:Vs(eu(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 nu=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 ru(e,t){let n={...e};if(e.colorNotation!==t){let e=tu(n);switch(t){case J.HEX:case J.RGB:n.colorNotation=J.RGB,n.channels=gs(e.channels);break;case J.sRGB:n.colorNotation=J.sRGB,n.channels=gs(e.channels);break;case J.Linear_sRGB:n.colorNotation=J.Linear_sRGB,n.channels=As(e.channels);break;case J.Display_P3:n.colorNotation=J.Display_P3,n.channels=Ps(e.channels);break;case J.Linear_Display_P3:n.colorNotation=J.Linear_Display_P3,n.channels=Is(e.channels);break;case J.Rec2020:n.colorNotation=J.Rec2020,n.channels=Rs(e.channels);break;case J.ProPhoto_RGB:n.colorNotation=J.ProPhoto_RGB,n.channels=Bs(e.channels);break;case J.A98_RGB:n.colorNotation=J.A98_RGB,n.channels=Ms(e.channels);break;case J.HSL:n.colorNotation=J.HSL,n.channels=vs(e.channels);break;case J.HWB:n.colorNotation=J.HWB,n.channels=bs(e.channels);break;case J.Lab:n.colorNotation=J.Lab,n.channels=Ss(e.channels);break;case J.LCH:n.colorNotation=J.LCH,n.channels=ws(e.channels);break;case J.OKLCH:n.colorNotation=J.OKLCH,n.channels=Os(e.channels);break;case J.OKLab:n.colorNotation=J.OKLab,n.channels=Es(e.channels);break;case J.XYZ_D50:n.colorNotation=J.XYZ_D50,n.channels=Us(e.channels);break;case J.XYZ_D65:n.colorNotation=J.XYZ_D65,n.channels=Hs(e.channels);break;default:throw Error(`Unsupported color notation`)}}else n.channels=eu(e.channels);if(t===e.colorNotation)n.channels=au(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else if(nu.has(t)&&nu.has(e.colorNotation))n.channels=au(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else switch(t){case J.HSL:switch(e.colorNotation){case J.HWB:n.channels=au(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=au(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.LCH:case J.OKLCH:n.channels=au(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;default:n.channels=au(e.channels,[],[],n.channels,[],[])}break;case J.HWB:switch(e.colorNotation){case J.HSL:n.channels=au(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=au(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;default:n.channels=au(e.channels,[],[],n.channels,[],[])}break;case J.Lab:case J.OKLab:switch(e.colorNotation){case J.HSL:n.channels=au(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=au(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;case J.LCH:case J.OKLCH:n.channels=au(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;default:n.channels=au(e.channels,[],[],n.channels,[],[])}break;case J.LCH:case J.OKLCH:switch(e.colorNotation){case J.HSL:n.channels=au(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;case J.HWB:n.channels=au(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.Lab:case J.OKLab:n.channels=au(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=au(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;default:n.channels=au(e.channels,[],[],n.channels,[],[])}break;default:n.channels=au(e.channels,[],[],n.channels,[],[])}return n.channels=iu(n.channels,t),n}function iu(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 au(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 ou(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 su(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 cu=/[A-Z]/g;function Q(e){return e.replace(cu,e=>String.fromCharCode(e.charCodeAt(0)+32))}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(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 uu=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`xyz`,`xyz-d50`,`xyz-d65`]);function du(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(gc(p)||_c(p))for(;gc(e.value[f+1])||_c(e.value[f+1]);)f++;else if(d===n&&n.length&&(d=r),d===r&&r.length&&(d=i),q(p)&&co(p.value)&&p.value[4].value===`/`){if(d===a)return!1;d=a}else{if(hc(p)){if(d===a&&Q(p.getName())===`var`){u.syntaxFlags.add(Y.HasVariableAlpha),d.push(p);continue}if(!$l.has(Q(p.getName())))return!1;let[[e]]=Zl([[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)&&uu.has(Q(p.value[4].value))){if(c)return!1;c=Q(p.value[4].value),u.colorNotation=fu(c),l&&(l.colorNotation!==u.colorNotation&&(l=ru(l,u.colorNotation)),o=ou(l),s=su(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(;gc(e.value[f+1])||_c(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=lu(n[0].value,0,u);if(!f||!W(f))return!1;let p=lu(r[0].value,1,u);if(!p||!W(p))return!1;let m=lu(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=lu(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=lu(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 fu(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 pu=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`lab`,`oklab`,`xyz`,`xyz-d50`,`xyz-d65`]),mu=new Set([`hsl`,`hwb`,`lch`,`oklch`]),hu=new Set([`shorter`,`longer`,`increasing`,`decreasing`]);function gu(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(!vc(s)){if(!(n||q(s)&&U(s.value)&&Q(s.value[4].value)===`in`))return vu(`oklab`,_u(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&&mu.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)||!oo(s.value))&&!!r&&(i||a?!!(i&&a&&mu.has(r)&&hu.has(i))&&bu(r,i,_u(e.value.slice(o+1),t)):pu.has(r)?vu(r,_u(e.value.slice(o+1),t)):!!mu.has(r)&&bu(r,`shorter`,_u(e.value.slice(o+1),t)))}}return!1}function _u(e,t){let n=[],r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(!vc(o)){if(!q(o)||!oo(o.value)){if(!r){let e=t(o);if(e){r=e;continue}}if(!i){if(hc(o)&&$l.has(Q(o.getName()))){if([[o]]=Zl([[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 vu(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}=Eu(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=ru(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=yu(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 yu(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=ru(t,e).channels,s=ru(n,e).channels;o[0]=Su(o[0],s[0]),s[0]=Su(s[0],o[0]),o[1]=Su(o[1],s[1]),s[1]=Su(s[1],o[1]),o[2]=Su(o[2],s[2]),s[2]=Su(s[2],o[2]),o[0]=wu(o[0],i),o[1]=wu(o[1],i),o[2]=wu(o[2],i),s[0]=wu(s[0],a),s[1]=wu(s[1],a),s[2]=wu(s[2],a);let c=Cu(i,a,r);return{colorNotation:e,channels:[Tu(Cu(o[0],s[0],r),c),Tu(Cu(o[1],s[1],r),c),Tu(Cu(o[2],s[2],r),c)],alpha:c,syntaxFlags:new Set([Y.ColorMix])}}function bu(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}=Eu(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=ru(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=xu(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 xu(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=ru(n,e).channels,m=ru(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=Su(a,o),Number.isNaN(a)&&(a=0),o=Su(o,a),Number.isNaN(o)&&(o=0),s=Su(s,c),c=Su(c,s),l=Su(l,u),u=Su(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=wu(s,d),l=wu(l,d),c=wu(c,f),u=wu(u,f);let g=[0,0,0],_=Cu(d,f,i);switch(e){case J.HSL:case J.HWB:g=[Cu(a,o,i),Tu(Cu(s,c,i),_),Tu(Cu(l,u,i),_)];break;case J.LCH:case J.OKLCH:g=[Tu(Cu(s,c,i),_),Tu(Cu(l,u,i),_),Cu(a,o,i)]}return{colorNotation:e,channels:g,alpha:_,syntaxFlags:new Set([Y.ColorMix])}}function Su(e,t){return Number.isNaN(e)?t:e}function Cu(e,t,n){return e*(1-n)+t*n}function wu(e,t){return Number.isNaN(t)?e:Number.isNaN(e)?NaN:e*t}function Tu(e,t){return t===0||Number.isNaN(t)?e:Number.isNaN(e)?NaN:e/t}function Eu(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 Du(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 Ou(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 ku(e,t,n){if(t===0){let t=Ou(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 Au(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=Ou(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 ju(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(!gc(n)&&!_c(n)){if(q(n)&&oo(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(hc(n)){if(l===s&&n.getName().toLowerCase()===`var`){c.syntaxFlags.add(Y.HasVariableAlpha),l.push(n);continue}if(!$l.has(n.getName().toLowerCase()))return!1;let[[e]]=Zl([[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 Mu(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(gc(r)||_c(r))for(;gc(e.value[t+1])||_c(e.value[t+1]);)t++;else if(p===a&&a.length&&(p=o),p===o&&o.length&&(p=s),q(r)&&co(r.value)&&r.value[4].value===`/`){if(p===c)return!1;p=c}else{if(hc(r)){if(p===c&&r.getName().toLowerCase()===`var`){f.syntaxFlags.add(Y.HasVariableAlpha),p.push(r);continue}if(!$l.has(r.getName().toLowerCase()))return!1;let[[e]]=Zl([[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(;gc(e.value[t+1])||_c(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=ru(d,n)),l=ou(d),u=su(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 Nu(e,t){if(e.value.some(e=>q(e)&&oo(e.value))){let t=Pu(e);if(!1!==t)return t}{let n=Fu(e,t);if(!1!==n)return n}return!1}function Pu(e){return ju(e,ku,J.HSL,[Y.LegacyHSL])}function Fu(e,t){return Mu(e,Au,J.HSL,[],t)}function Iu(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=Ou(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 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(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 Ru(e,t){return Mu(e,Lu,J.Lab,[],t)}function zu(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=Ou(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 Bu(e,t){return Mu(e,zu,J.LCH,[],t)}const Vu=new Map;for(let[e,t]of Object.entries(Js))Vu.set(e,t);function Hu(e){let t=Vu.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 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(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 Wu(e,t){return Mu(e,Uu,J.OKLab,[],t)}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(t===2){let t=Ou(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 Ku(e,t){return Mu(e,Gu,J.OKLCH,[],t)}function qu(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 Ju(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 Yu(e,t){if(e.value.some(e=>q(e)&&oo(e.value))){let t=Xu(e);if(!1!==t)return(!t.syntaxFlags.has(Y.HasNumberValues)||!t.syntaxFlags.has(Y.HasPercentageValues))&&t}else{let n=Zu(e,t);if(!1!==n)return n}return!1}function Xu(e){return ju(e,qu,J.RGB,[Y.LegacyRGB])}function Zu(e,t){return Mu(e,Ju,J.RGB,[],t)}function Qu(e){let t=gs(e);if(Ws(t))return Gs(t);let n=e;return n=Os(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),Yo(Ks(n,$u,ed))}function $u(e){return e=jo(e),e=Fo(e),qo(e)}function ed(e){return e=fs(e),e=Bo(e),Mo(e)}function td(e,t){let n=!1;for(let r=0;r<e.value.length;r++){let i=e.value[r];if(!gc(i)&&!_c(i)&&(n||(n=t(i),!n)))return!1}if(!n)return!1;n.channels=eu(n.channels),n.channels=Qu(tu(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=Xs(n.channels,[1,1,1])>Xs(n.channels,[0,0,0])?[1,1,1]:[0,0,0],r}function nd(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(gc(l)||_c(l))for(;gc(e.value[c+1])||_c(e.value[c+1]);)c++;else if(o&&!i&&!a&&q(l)&&co(l.value)&&l.value[4].value===`/`)i=!0;else{if(hc(l)&&$l.has(Q(l.getName()))){let[[e]]=Zl([[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=lu(l.value,3,s);if(!e||!W(e))return!1;s.alpha=new K(e),a=!0;continue}if(hc(l)){s.alpha=pc([[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(;gc(e.value[c+1])||_c(e.value[c+1]);)c++;if(c++,l=e.value[c],o=t(l),!1===o)return!1;n=ou(o),r=su(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 rd(e){if(hc(e))switch(Q(e.getName())){case`rgb`:case`rgba`:return Yu(e,rd);case`hsl`:case`hsla`:return Nu(e,rd);case`hwb`:return t=rd,Mu(e,Iu,J.HWB,[],t);case`lab`:return Ru(e,rd);case`lch`:return Bu(e,rd);case`oklab`:return Wu(e,rd);case`oklch`:return Ku(e,rd);case`color`:return du(e,rd);case`color-mix`:return gu(e,rd);case`contrast-color`:return td(e,rd);case`alpha`:return nd(e,rd)}var t;if(q(e)){if(fo(e.value))return Du(e.value);if(U(e.value)){let t=Hu(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 id(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function ad(e){switch(e.colorNotation){case`hex`:case`rgb`:case`srgb`:return{...e,colorNotation:`xyz-d50`,channels:hs(id(e.channels))};case`srgb-linear`:return{...e,colorNotation:`xyz-d50`,channels:ks(id(e.channels))};case`display-p3`:return{...e,colorNotation:`xyz-d50`,channels:Ns(id(e.channels))};case`display-p3-linear`:return{...e,colorNotation:`xyz-d50`,channels:Fs(id(e.channels))};case`rec2020`:return{...e,colorNotation:`xyz-d50`,channels:Ls(id(e.channels))};case`a98-rgb`:return{...e,colorNotation:`xyz-d50`,channels:js(id(e.channels))};case`prophoto-rgb`:return{...e,colorNotation:`xyz-d50`,channels:zs(id(e.channels))};case`hsl`:return{...e,colorNotation:`xyz-d50`,channels:_s(id(e.channels))};case`hwb`:return{...e,colorNotation:`xyz-d50`,channels:ys(id(e.channels))};case`lab`:return{...e,colorNotation:`xyz-d50`,channels:xs(id(e.channels))};case`oklab`:return{...e,colorNotation:`xyz-d50`,channels:Ts(id(e.channels))};case`lch`:return{...e,colorNotation:`xyz-d50`,channels:Cs(id(e.channels))};case`oklch`:return{...e,colorNotation:`xyz-d50`,channels:Ds(id(e.channels))};case`xyz-d50`:return{...e,colorNotation:`xyz-d50`,channels:Us(id(e.channels))};case`xyz-d65`:return{...e,colorNotation:`xyz-d50`,channels:Vs(id(e.channels))};default:throw Error(`Unsupported color notation`)}}function od(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 sd(e){let t=gs(e);if(Ws(t))return Gs(t);let n=e;return n=Os(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),Yo(Ks(n,cd,ld))}function cd(e){return e=jo(e),e=Fo(e),qo(e)}function ld(e){return e=fs(e),e=Bo(e),Mo(e)}var ud=class e{static colorTxtList=[];static parseColorString(e){try{let t=uc(Ya({css:e}));if(!t)return null;let n=rd(t);if(n===!1)return null;let r=sd(ad(n).channels),i=Math.min(255,Math.max(0,Math.round(od(r[0])*255))),a=Math.min(255,Math.max(0,Math.round(od(r[1])*255))),o=Math.min(255,Math.max(0,Math.round(od(r[2])*255))),s=1;return typeof n.alpha==`number`&&(s=Math.min(1,Math.max(0,od(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(sa.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(sa.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=sa.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]}},dd=class{static send(e){$.sendNotification(`aventus/openfile`,e)}},fd=class{static cmd=`aventus.addConfigSection`;static async run(e){try{if(!e){let t=[],n=L.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)(D(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)(D(e),JSON.stringify(r,null,4)),dd.send(e)}catch(e){console.error(e)}}},pd=class{static cmd=`aventus.compile`;static async run(){let e=[],t=L.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;L.getInstance().getProjectByUri(e)?.getBuild(t)?.build()}}},md=class e{static cmd=`aventus.create`;static async run(t){if(!t)return;let n=(0,f.normalize)(D(t));if(e.checkIfProject(t)){if(!$.isIDE){let e=await $.SelectFolder(`Select where to create`,n);if(!e)return;t=e,n=D(t)}await $.localTemplateManager?.createTemplate(n)}else await $.localProjectManager?.createGlobal(n)}static checkIfProject(e){let t=L.getInstance().getAllConfigFiles(),n=e.replace(/\\/g,`/`);for(let e of t)if(n.startsWith(e.replace(`/`+w.Config,``)))return!0;return!1}},hd=class{static cmd=`aventus.filesystem.created`;static run(e){e&&R.getInstance().onCreatedUri(e)}},gd=class{static cmd=`aventus.filesystem.deleted`;static async run(e){e&&R.getInstance().onDeletedUri(e)}},_d=class{static cmd=`aventus.filesystem.updated`;static async run(e){e&&R.getInstance().onUpdatedUri(e)}},vd=class{static send(e){$.sendNotification(`aventus/closefile`,e)}},yd=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=`
|
|
989
990
|
<script>
|
|
990
|
-
${
|
|
991
|
+
${bd(l)}
|
|
991
992
|
<\/script>
|
|
992
993
|
|
|
993
994
|
<template>
|
|
994
|
-
${
|
|
995
|
+
${bd(h)}
|
|
995
996
|
</template>
|
|
996
997
|
|
|
997
998
|
<style>
|
|
998
|
-
${
|
|
999
|
+
${bd(p)}
|
|
999
1000
|
</style>
|
|
1000
|
-
`,_=d.TextDocument.create(o+w.Component,C.WebComponent,s+1,g);(0,u.writeFileSync)(D(_.uri),g),f&&((
|
|
1001
|
+
`,_=d.TextDocument.create(o+w.Component,C.WebComponent,s+1,g);(0,u.writeFileSync)(D(_.uri),g),f&&(Ze(f.path),R.getInstance().onClose(f.documentUser),vd.send(f.uri)),c&&(Ze(c.path),R.getInstance().onClose(c.documentUser),vd.send(c.uri)),m&&(Ze(m.path),R.getInstance().onClose(m.documentUser),vd.send(m.uri)),(0,u.rmdirSync)(D(r.join(`/`)+`/`+a)),R.getInstance().registerFile(_),dd.send(_.uri)}};function bd(e){return e.replace(/\r\n?/g,`
|
|
1001
1002
|
`).split(`
|
|
1002
1003
|
`).join(`
|
|
1003
|
-
`)}var
|
|
1004
|
+
`)}var xd=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=D(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)(D(o),s.getText());let c=i+w.ComponentView,l=d.TextDocument.create(c,C.HTML,n.versionUser+1,a.htmlText??``);(0,u.writeFileSync)(D(c),l.getText());let f=i+w.ComponentLogic,p=d.TextDocument.create(f,C.TypeScript,n.versionUser+1,a.scriptText??``);(0,u.writeFileSync)(D(f),p.getText()),Ze(n.path),R.getInstance().onClose(n.documentUser),vd.send(n.uri),R.getInstance().registerFile(s),R.getInstance().registerFile(l),R.getInstance().registerFile(p),dd.send(p.uri)}}},Sd=class{static cmd=`aventus.liveserver.start`;static run(){j.getInstance().start()}},Cd=class{static cmd=`aventus.liveserver.toggle`;static run(){j.getInstance().toggle()}},wd=class{static cmd=`aventus.static`;static async run(){let e=[],t=L.getInstance().getAllStatics();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Static to export`});if(n){let e=n.detail??``,t=n.label;await L.getInstance().getProjectByUri(e)?.getStatic(t)?.export()}}},Td=class{static cmd=`aventus.liveserver.stop`;static run(){j.getInstance().stop()}},Ed=class{static send(e,t){$.sendNotification(`aventus/editFile`,{uri:e,transformations:t})}},Dd=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;Oe(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()
|
|
1004
1005
|
public `+r+e+`:`+a+`;
|
|
1005
|
-
`,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}}];
|
|
1006
|
+
`,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}}];Ed.send(t,[m])}}},Od=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;Oe(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 F&&(a=e.getComponentName())}if(a==``)return;let s=``;c&&(s=`(target: `+a+`) => {
|
|
1006
1007
|
|
|
1007
1008
|
}`);let u=`?`;(o==`boolean`||o==`number`)&&(u=`!`);let f=`@Property(`+s+`)
|
|
1008
1009
|
public `+i+u+`:`+o+`;
|
|
1009
|
-
`,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}}];
|
|
1010
|
+
`,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}}];Ed.send(t,[v])}}},kd=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 F&&(c=t.getComponentName())}if(c==``)return;let l=``;if(o){let e=`Aventus.`;a&&a.length>0&&a[0].isCoreBuild&&(e=``),l=`(target: `+c+`, action: `+e+`WatchAction, path: string, value: any) => {
|
|
1010
1011
|
|
|
1011
1012
|
}`}let u=`@Watch(`+l+`)
|
|
1012
1013
|
public `+r+`?:`+i+`;
|
|
1013
|
-
`,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}}];wd.send(e,[_])}}},Od=class{static cmd=`aventus.wc.import.viewElement`;static async run(e,t){let n=R.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=R.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof F){let i=a.getMissingVariablesInfo();if(t==-1&&(t=i.start),t==-1)return;if(i.text!=``){let a=n.contentUser.slice(0,t),o=n.contentUser.slice(t+1,n.contentUser.length),s=a+i.text+o,c=d.TextDocument.create(n.uri,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}}];wd.send(e,[u])}}}}}},kd=class{static cmd=`aventus.wc.import.viewMethod`;static async run(e,t){let n=R.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=R.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof F){let i=a.getMissingMethodsInfo();if(t==-1&&(t=i.start),t==-1)return;if(i.text!=``){let a=n.contentUser.slice(0,t),o=n.contentUser.slice(t+1,n.contentUser.length),s=a+i.text+o,c=d.TextDocument.create(n.uri,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}}];wd.send(e,[u])}}}}}},Ad=class{static cmd=`aventus.rename`;static async run(e){if(!T.getInstance().settings.updateImportOnRename||!e)return;let t=[];for(let n of e){let e=n.newUri,r=n.oldUri,i=D(e),a=D(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=E(a);s?t.push({newUri:n,oldUri:n.replace(e,r)}):t.push({newUri:n.replace(r,e),oldUri:n})}}};n(o)}else t.push({oldUri:r,newUri:e})}let n=await L.getInstance().onRename(t),r={},i=R.getInstance();for(let e in n){let t=i.getByUri(e);t&&(await t.applyTextEdits(n[e]),r[D(t.uri)]=t.contentUser)}setTimeout(()=>{for(let e in r)(0,u.writeFileSync)(e,r[e])},500)}},jd=class{static cmd=`aventus.component.rename`;static async run(e){if(!e)return;e=e.toString().replace(/\.wcv\.avt$/,`.wcl.avt`).replace(/\.wcs\.avt$/,`.wcl.avt`);let t=e.split(`/`),n=t[t.length-1].replace(`.wcl.avt`,``),r=await $.Input({title:`New name`,value:n,validations:[{message:`Your name isn't valid`,regex:`^[_A-Za-z0-9-]+$`}]});if(!r)return;let i=R.getInstance().getByUri(e);if(i&&i instanceof A){let e=R.getInstance(),t=i.documentUser.uri.split(`/`),n=t[t.length-1].replace(w.ComponentLogic,``),a=Ve(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)(D(t))){let n=s+`/`+r+e;f.push({oldUri:t,newUri:n})}};p(w.ComponentLogic),p(w.ComponentStyle),p(w.ComponentView);let m=await L.getInstance().onRename(f);for(let t in m){if(!l[t]){let n=e.getByUri(t);if(!n)continue;l[t]=n}await l[t].applyTextEdits(m[t])}setTimeout(()=>{for(let e in l)(0,u.writeFileSync)(D(e),l[e].contentUser);(0,u.mkdirSync)(D(s));for(let t of f){let n=t.oldUri,r=t.newUri;(0,u.renameSync)(D(n),D(r)),gd.send(n);let i=e.getByUri(n);i&&(e.registerFile(d.TextDocument.create(r,Oe(r),1,i.contentUser)),e.onClose(i?.documentUser))}let t=D(o),n=(0,u.readdirSync)(t);n.length==0?(0,u.rmdirSync)(t):n.length==1&&n[0].endsWith(`.js`)&&(0,u.rmSync)(t,{recursive:!0,force:!0})},500)}}},Md=class{static cmd=`aventus.filesystem.openAventus`;static async run(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e);let t;switch((0,fe.platform)()){case`win32`:t=`explorer`;break;case`linux`:t=`xdg-open`;break;case`darwin`:t=`open`;break}(0,g.spawn)(t,[e],{detached:!0}).unref()}},Nd=class{static waitingResponse={};static send(e,...t){return new Promise(n=>{let r=k();for(;this.waitingResponse[r]!=null;)r=k();this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/popup`,r,e,t)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Pd=class{static cmd=`aventus.popupresponse`;static run(e,t){Nd.resolve(e,t)}},Fd=class{static waitingResponse={};static send(e){return new Promise(t=>{let n=k();for(;this.waitingResponse[n]!=null;)n=k();this.waitingResponse[n]=e=>{t(e)},$.sendNotification(`aventus/askinput`,n,e)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Id=class{static cmd=`aventus.receiveinput`;static run(e,t){Fd.resolve(e,t)}},Ld=class{static waitingResponse={};static waitingOptions={};static send(e,t){return new Promise(n=>{let r=k();for(;this.waitingResponse[r]!=null;)r=k();this.waitingOptions[r]=e,this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/askselect`,r,e,t)})}static resolve(e,t){if(this.waitingResponse[e]){if(t)for(let n of this.waitingOptions[e])n.label==t.label&&(t=n);this.waitingResponse[e](t),delete this.waitingResponse[e],delete this.waitingOptions[e]}}},Rd=class{static cmd=`aventus.receiveselect`;static run(e,t){Ld.resolve(e,t)}},zd=class{static waitingResponse={};static send(e,t){return new Promise(n=>{let r=k();for(;this.waitingResponse[r]!=null;)r=k();this.waitingResponse[r]=e=>{n(e)},$.sendNotification(`aventus/askselectmultiple`,r,e,t)})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},Bd=class{static cmd=`aventus.receiveselectmultiple`;static run(e,t){zd.resolve(e,t)}},Vd=class{static cmd=`aventus.template.import`;static async run(){await $.templateManager?.selectTemplateToImport()}},Hd=o(((e,t)=>{var n=require("child_process").exec,r=require("child_process").execSync,i=require("fs"),a=require("path"),o=i.access,s=i.accessSync,c=i.constants||i,l=process.platform==`win32`,u=function(e,t){o(e,c.F_OK,function(e){t(!e)})},d=function(e){try{return s(e,c.F_OK),!1}catch{return!0}},f=function(e,t){o(e,c.F_OK|c.X_OK,function(e){t(null,!e)})},p=function(e){try{return s(e,c.F_OK|c.X_OK),!0}catch{return!1}},m=function(e,t,r){u(e,function(i){if(!i){n(`command -v `+t+` 2>/dev/null && { echo >&1 `+t+`; exit 0; }`,function(e,t,n){r(null,!!t)});return}f(e,r)})},h=function(e,t,r){if(!/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(e)){r(null,!1);return}n(`where `+t,function(e){e===null?r(null,!0):r(null,!1)})},g=function(e,t){if(d(e))try{return!!r(`command -v `+t+` 2>/dev/null && { echo >&1 `+t+`; exit 0; }`)}catch{return!1}return p(e)},_=function(e,t,n){if(!/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(e))return!1;try{return!!r(`where `+t,{stdio:[]})}catch{return!1}},v=function(e){return/[^A-Za-z0-9_\/:=-]/.test(e)&&(e=`'`+e.replace(/'/g,`'\\''`)+`'`,e=e.replace(/^(?:'')+/g,``).replace(/\\'''/g,`\\'`)),e};l&&(v=function(e){if(/[\\]/.test(e)){var t=`"`+a.dirname(e)+`"`,n=`"`+a.basename(e)+`"`;return t+`:`+n}return`"`+e+`"`}),t.exports=function e(t,n){var r=v(t);if(!n&&typeof Promise<`u`)return new Promise(function(n,r){e(t,function(e,i){i?n(t):r(e)})});l?h(t,r,n):m(t,r,n)},t.exports.sync=function(e){var t=v(e);return l?_(e,t):g(e,t)}})),Ud=o(((e,t)=>{t.exports=Hd()}))(),Wd=class{static send(e,t,n){$.sendNotification(`aventus/sharp/compiling`,e,t,n)}},Gd=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}files={};onNewFileUUID;onFileRemoveUUID;constructor(){this.onNewFile=this.onNewFile.bind(this),this.onFileRemove=this.onFileRemove.bind(this),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=R.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(w.CsharpConfig)&&(this.files[e.uri]=new Kd(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},Kd=class{_file;get file(){return this._file}constructor(e){this._file=e,this.addEvents()}uuidEvents={onContentChange:``,onValidate:``,onSave:``,onDelete:``,onCompletion:``,onCompletionResolve:``,onHover:``,onDefinition:``,onFormatting:``,onCodeAction:``,onReferences:``,onCodeLens:``,onRename:``};addEvents(){this.uuidEvents.onContentChange=this.file.onContentChange(this.onContentChange.bind(this)),this.uuidEvents.onValidate=this.file.onValidate(this._onValidate.bind(this)),this.uuidEvents.onSave=this.file.onSave(this.onSave.bind(this)),this.uuidEvents.onDelete=this.file.onDelete(this._onDelete.bind(this)),this.uuidEvents.onCompletion=this.file.onCompletion(this.onCompletion.bind(this)),this.uuidEvents.onCompletionResolve=this.file.onCompletionResolve(this.onCompletionResolve.bind(this)),this.uuidEvents.onHover=this.file.onHover(this.onHover.bind(this)),this.uuidEvents.onDefinition=this.file.onDefinition(this.onDefinition.bind(this)),this.uuidEvents.onFormatting=this.file.onFormatting(this.onFormatting.bind(this)),this.uuidEvents.onCodeAction=this.file.onCodeAction(this.onCodeAction.bind(this)),this.uuidEvents.onReferences=this.file.onReferences(this.onReferences.bind(this)),this.uuidEvents.onCodeLens=this.file.onCodeLens(this.onCodeLens.bind(this)),this.uuidEvents.onRename=this.file.onRename(this.onRename.bind(this))}removeEvents(){this.file.removeOnContentChange(this.uuidEvents.onContentChange),this.file.removeOnValidate(this.uuidEvents.onValidate),this.file.removeOnSave(this.uuidEvents.onSave),this.file.removeOnDelete(this.uuidEvents.onDelete),this.file.removeOnCompletion(this.uuidEvents.onCompletion),this.file.removeOnCompletionResolve(this.uuidEvents.onCompletionResolve),this.file.removeOnHover(this.uuidEvents.onHover),this.file.removeOnDefinition(this.uuidEvents.onDefinition),this.file.removeOnFormatting(this.uuidEvents.onFormatting),this.file.removeOnCodeAction(this.uuidEvents.onCodeAction),this.file.removeOnReferences(this.uuidEvents.onReferences),this.file.removeOnCodeLens(this.uuidEvents.onCodeLens),this.file.removeOnRename(this.uuidEvents.onRename)}async validate(){this.file instanceof A&&await this.file.validate()}triggerSave(){this.file instanceof A&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof A&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return st.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return st.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return st.getInstance().doResolve(t)}async onHover(e,t){return st.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return st.getInstance().format(e,t,n)}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}},qd=class{static cmd=`aventus.sharp.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Ud.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}if(!(0,Ud.sync)(`csharp-converter`))try{if(await $.ask(`csharp-converter is missing. Can I install it?`)&&await we(`dotnet tool install --global AventusSharp.Converter`),!(0,Ud.sync)(`csharp-converter`)){$.showErrorMessage(`Can't find the converter. Run the command : dotnet tool install --global AventusSharp.Converter`);return}}catch(e){$.showErrorMessage(e+``);return}if(!e||!e.endsWith(w.CsharpConfig)){let t=Object.keys(Gd.getInstance().files);if(t.length==1)e=t[0];else if(t.length>1){let n=[];for(let e of t)n.push({label:e});let r=await $.Select(n,{placeHolder:`Project to compile`});if(r)e=r.label;else return}else{$.showErrorMessage(`No aventus.sharp.avt found`);return}}let t=``;try{let n=(0,u.readFileSync)(D(e),`utf-8`);t=JSON.parse(n).csProj}catch(e){$.error(e)}this.isCompiling=!0,Wd.send(t,`compiling`);try{let{stdout:n}=await we(`csharp-converter `+D(e)),r=n.toString();if(r.indexOf(`Error : `)==-1)Wd.send(t,`success`);else{console.clear(),$.error(r);let e=`csharp_errors`;zi.send(e,r),Wd.send(t,`error`,[{title:`C# error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},Jd=class{static cmd=`aventus.reloadSettings`;static async run(){$.refreshSettings()}},Yd=class{static cmd=`aventus.wc.create.cssvar`;static async run(e,t){if(!e||typeof t!=`number`)return;let n=await $.Input({title:`Provide a name for your variable`});if(!n)return;let r=await $.Input({title:`Provide a default value for your variable`}),i=R.getInstance().getByUri(e);if(i){let a=i.name.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g)?.join(`-`).toLowerCase()??i.name,o=n.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g)?.join(`-`).toLowerCase()??n,s=r?`, `+r:``,c=i.documentUser.positionAt(i.contentUser.length),l=`--_${a}-${o}: var(--${a}-${o}${s});`,u=i.contentUser.slice(0,t),f=i.contentUser.slice(t+1,i.contentUser.length),p=u+l+f,m=d.TextDocument.create(i.uri,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}}];wd.send(e,[g])}}},Xd=class{static cmd=`aventus.storybook.build`;static async run(){let e=[],t=L.getInstance().getAllBuildsWithStory();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{placeHolder:`Story to build`});if(n){let e=n.detail??``,t=n.label;L.getInstance().getProjectByUri(e)?.getBuild(t)?.buildStorybook()}}},Zd=class{static cmd=`aventus.template.import_project`;static async run(){await $.templateManager?.selectProjectToImport(!1)}},Qd=class{static cmd=`aventus.npm.build`;static async run(){let e=[],t=L.getInstance().getAllBuildsWithNpm();for(let n of t)e.push({label:n.name,detail:n.uri});let n=e.length==1?e[0]:await $.Select(e,{placeHolder:`Package to build`});if(n){let e=n.detail??``,t=n.label;L.getInstance().getProjectByUri(e)?.getBuild(t)?.buildNpm()}}},$d=class{static cmd=`aventus.i18n.add`;static async run(e,t,n=!0){try{let r=L.getInstance().getMatchingBuildsByUri(e);if(r.length>0){let i=r[0],a=e.replace(w.ComponentView,w.I18n),o=[];if(n&&i.i18nComponentsFiles[a]){let e=D(a);o.push({label:(0,f.basename)(e),detail:e})}for(let e in i.tsLanguageService.i18nFiles){let t=D(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=E(s.detail),r=i.i18nComponentsFiles[n]??i.tsLanguageService.i18nFiles[n],a=JSON.parse(JSON.stringify(r.parsedSrc));a[t]={};let o=r.build.buildConfig.i18n?.locales??[],c=r.build.buildConfig.i18n?.fallback??`en-GB`;for(let e of o)a[t][e]=e==c?t:Ji.empty;let l=[{newText:JSON.stringify(Ji.sortObj(a),null,4),range:{start:r.file.documentUser.positionAt(0),end:r.file.documentUser.positionAt(r.file.documentUser.getText().length)}}];wd.send(n,[l]),setTimeout(async()=>{let t=e.replace(w.ComponentView,w.ComponentLogic),n=i.tsFiles[t],r=i.htmlFiles[e];await n?.validate(),await r?.validate()},2e3)}}}catch(e){console.error(e)}}},ef=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}files={};onNewFileUUID;onFileRemoveUUID;constructor(){this.onNewFile=this.onNewFile.bind(this),this.onFileRemove=this.onFileRemove.bind(this),this.onNewFileUUID=R.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=R.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(w.PhpConfig)&&!e.uri.includes(`/vendor/`)&&(this.files[e.uri]=new tf(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},tf=class{_file;get file(){return this._file}constructor(e){this._file=e,this.addEvents()}uuidEvents={onContentChange:``,onValidate:``,onSave:``,onDelete:``,onCompletion:``,onCompletionResolve:``,onHover:``,onDefinition:``,onFormatting:``,onCodeAction:``,onReferences:``,onCodeLens:``,onRename:``};addEvents(){this.uuidEvents.onContentChange=this.file.onContentChange(this.onContentChange.bind(this)),this.uuidEvents.onValidate=this.file.onValidate(this._onValidate.bind(this)),this.uuidEvents.onSave=this.file.onSave(this.onSave.bind(this)),this.uuidEvents.onDelete=this.file.onDelete(this._onDelete.bind(this)),this.uuidEvents.onCompletion=this.file.onCompletion(this.onCompletion.bind(this)),this.uuidEvents.onCompletionResolve=this.file.onCompletionResolve(this.onCompletionResolve.bind(this)),this.uuidEvents.onHover=this.file.onHover(this.onHover.bind(this)),this.uuidEvents.onDefinition=this.file.onDefinition(this.onDefinition.bind(this)),this.uuidEvents.onFormatting=this.file.onFormatting(this.onFormatting.bind(this)),this.uuidEvents.onCodeAction=this.file.onCodeAction(this.onCodeAction.bind(this)),this.uuidEvents.onReferences=this.file.onReferences(this.onReferences.bind(this)),this.uuidEvents.onCodeLens=this.file.onCodeLens(this.onCodeLens.bind(this)),this.uuidEvents.onRename=this.file.onRename(this.onRename.bind(this))}removeEvents(){this.file.removeOnContentChange(this.uuidEvents.onContentChange),this.file.removeOnValidate(this.uuidEvents.onValidate),this.file.removeOnSave(this.uuidEvents.onSave),this.file.removeOnDelete(this.uuidEvents.onDelete),this.file.removeOnCompletion(this.uuidEvents.onCompletion),this.file.removeOnCompletionResolve(this.uuidEvents.onCompletionResolve),this.file.removeOnHover(this.uuidEvents.onHover),this.file.removeOnDefinition(this.uuidEvents.onDefinition),this.file.removeOnFormatting(this.uuidEvents.onFormatting),this.file.removeOnCodeAction(this.uuidEvents.onCodeAction),this.file.removeOnReferences(this.uuidEvents.onReferences),this.file.removeOnCodeLens(this.uuidEvents.onCodeLens),this.file.removeOnRename(this.uuidEvents.onRename)}async validate(){this.file instanceof A&&await this.file.validate()}triggerSave(){this.file instanceof A&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof A&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return st.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return st.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return st.getInstance().doResolve(t)}async onHover(e,t){return st.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return st.getInstance().format(e,t,n)}async onCodeAction(e,t){return[]}async onReferences(e,t){return[]}async onCodeLens(e){return[]}async onRename(e,t,n){return null}},nf=class{static cmd=`aventus.php.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Ud.sync)(`php`)){$.showErrorMessage(`Php isn't installed on your system`);return}if(!(0,Ud.sync)(`php-converter`))try{if(!(0,Ud.sync)(`composer`)){$.showErrorMessage(`composer isn't installed on your system`);return}if(await $.ask(`php-converter is missing. Can I install it?`)&&await we(`composer global require aventus/transpiler`),!(0,Ud.sync)(`php-converter`)){$.showErrorMessage(`Can't find the converter. Run the command : composer global require aventus/transpiler`);return}}catch(e){$.showErrorMessage(e+``);return}if(!e||!e.endsWith(w.PhpConfig)){let t=Object.keys(ef.getInstance().files);if(t.length==1)e=t[0];else if(t.length>1){let n=[];for(let e of t)n.push({label:e});let r=await $.Select(n,{placeHolder:`Project to compile`});if(r)e=r.label;else return}else{$.showErrorMessage(`No aventus.php.avt found`);return}}let t=``;try{let n=D(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,Wd.send(t,`compiling`);try{let n=(0,f.join)($.extensionPath,`lib`,`bin`,`PhpToTypescript`,`PhpToTypescript.phar`),r=D(e),{stdout:i}=await we(`php `+n+` `+r+` 2>&1`,{encoding:`utf8`}),a=i.toString();if(a.indexOf(`Error : `)==-1)Wd.send(t,`success`);else{console.clear(),$.error(a);let e=`php_errors`;zi.send(e,a),Wd.send(t,`error`,[{title:`PHP error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},rf=class{static cmd=`aventus.store.connect`;static async run(e,t){if(Ni.isConnected){await $.showInformationMessage(`You are already connected with account `+Ni.settings.username);return}!e&&(e=await $.Input({title:`Username`}),!e)||!t&&(t=await $.Input({title:`Password`,password:!0}),!t)||(console.log(e),console.log(t),await Ni.connect(e,t)?await $.showInformationMessage(`Connection successful`):await $.showErrorMessage(`Connection failed`))}},af=class{static cmd=`aventus.store.disconnect`;static async run(){Ni.isConnected&&(await Ni.disconnect(),$.showInformationMessage(`You are disconnected`))}},of=class{static cmd=`aventus.store.publish_package`;static async run(){if(!Ni.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let e=L.getInstance().getAllBuilds(),t=[],n=null;if(e.length==1)n={label:e[0].name,detail:e[0].uri};else for(let r of e)t.push({label:r.name,detail:r.uri}),n=await $.Select(t,{placeHolder:`Project to compile`});if(n){let e=n.detail??``,t=n.label,r=L.getInstance().getProjectByUri(e)?.getBuild(t);if(r){let e=await Ni.publishPackage(r);if(e instanceof Pi)for(let t of e.errors)$.showErrorMessage(t.message);else $.showInformationMessage(`Package published`)}}}},sf=class{static send(e){let t=k();return $.sendNotification(`aventus/progress_start`,t,e),t}},cf=class{static send(e){$.sendNotification(`aventus/progress_stop`,e)}},lf=class e{config;folderPath;name=``;version=`1.0.0`;description=``;organization;tags=[];lastModified;allowQuick=!1;isProject=!1;isGlobal=!1;hasIsAllow=!1;containsError=!1;installationFolder;documentation;repository;static memory={};static async create(t){let n=(0,f.dirname)(t);if(this.memory[t]){if((0,u.statSync)(t).mtime.getTime()>this.memory[t].lastModified.getTime()){let r=new e(t,n);await r.postConstructor(),r.containsError||(this.memory[t]=r)}}else{let r=new e(t,n);await r.postConstructor(),r.containsError||(this.memory[t]=r)}return this.memory[t]}constructor(e,t){this.config=e,this.folderPath=t,this.lastModified=(0,u.statSync)(this.config).mtime}async postConstructor(){let e=await this.prepareScript();for(let t in e)e[t]&&(this[t]=e[t]);this.lastModified=(0,u.statSync)(this.config).mtime}init(e,t){return new Promise(n=>{try{let r=`
|
|
1014
|
-
import { AventusTemplate } from 'file://${(0,f.join)(
|
|
1014
|
+
`,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}}];Ed.send(e,[_])}}},Ad=class{static cmd=`aventus.wc.import.viewElement`;static async run(e,t){let n=R.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=R.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof F){let i=a.getMissingVariablesInfo();if(t==-1&&(t=i.start),t==-1)return;if(i.text!=``){let a=n.contentUser.slice(0,t),o=n.contentUser.slice(t+1,n.contentUser.length),s=a+i.text+o,c=d.TextDocument.create(n.uri,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}}];Ed.send(e,[u])}}}}}},jd=class{static cmd=`aventus.wc.import.viewMethod`;static async run(e,t){let n=R.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=R.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof F){let i=a.getMissingMethodsInfo();if(t==-1&&(t=i.start),t==-1)return;if(i.text!=``){let a=n.contentUser.slice(0,t),o=n.contentUser.slice(t+1,n.contentUser.length),s=a+i.text+o,c=d.TextDocument.create(n.uri,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}}];Ed.send(e,[u])}}}}}},Md=class{static cmd=`aventus.rename`;static async run(e){if(!T.getInstance().settings.updateImportOnRename||!e)return;let t=[];for(let n of e){let e=n.newUri,r=n.oldUri,i=D(e),a=D(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=E(a);s?t.push({newUri:n,oldUri:n.replace(e,r)}):t.push({newUri:n.replace(r,e),oldUri:n})}}};n(o)}else t.push({oldUri:r,newUri:e})}let n=await L.getInstance().onRename(t),r={},i=R.getInstance();for(let e in n){let t=i.getByUri(e);t&&(await t.applyTextEdits(n[e]),r[D(t.uri)]=t.contentUser)}setTimeout(()=>{for(let e in r)(0,u.writeFileSync)(e,r[e])},500)}},Nd=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 A){let e=R.getInstance(),t=i.documentUser.uri.split(`/`),n=t[t.length-1].replace(w.ComponentLogic,``),a=He(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)(D(t))){let n=s+`/`+r+e;f.push({oldUri:t,newUri:n})}};p(w.ComponentLogic),p(w.ComponentStyle),p(w.ComponentView);let m=await L.getInstance().onRename(f);for(let t in m){if(!l[t]){let n=e.getByUri(t);if(!n)continue;l[t]=n}await l[t].applyTextEdits(m[t])}setTimeout(()=>{for(let e in l)(0,u.writeFileSync)(D(e),l[e].contentUser);(0,u.mkdirSync)(D(s));for(let t of f){let n=t.oldUri,r=t.newUri;(0,u.renameSync)(D(n),D(r)),vd.send(n);let i=e.getByUri(n);i&&(e.registerFile(d.TextDocument.create(r,ke(r),1,i.contentUser)),e.onClose(i?.documentUser))}let t=D(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)}}},Pd=class{static cmd=`aventus.filesystem.openAventus`;static async run(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e);let t;switch((0,fe.platform)()){case`win32`:t=`explorer`;break;case`linux`:t=`xdg-open`;break;case`darwin`:t=`open`;break}(0,g.spawn)(t,[e],{detached:!0}).unref()}},Fd=class{static waitingResponse={};static send(e,...t){return new Promise(n=>{let r=k();for(;this.waitingResponse[r]!=null;)r=k();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])}},Id=class{static cmd=`aventus.popupresponse`;static run(e,t){Fd.resolve(e,t)}},Ld=class{static waitingResponse={};static send(e){return new Promise(t=>{let n=k();for(;this.waitingResponse[n]!=null;)n=k();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])}},Rd=class{static cmd=`aventus.receiveinput`;static run(e,t){Ld.resolve(e,t)}},zd=class{static waitingResponse={};static waitingOptions={};static send(e,t){return new Promise(n=>{let r=k();for(;this.waitingResponse[r]!=null;)r=k();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]}}},Bd=class{static cmd=`aventus.receiveselect`;static run(e,t){zd.resolve(e,t)}},Vd=class{static waitingResponse={};static send(e,t){return new Promise(n=>{let r=k();for(;this.waitingResponse[r]!=null;)r=k();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])}},Hd=class{static cmd=`aventus.receiveselectmultiple`;static run(e,t){Vd.resolve(e,t)}},Ud=class{static cmd=`aventus.template.import`;static async run(){await $.templateManager?.selectTemplateToImport()}},Wd=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)}})),Gd=o(((e,t)=>{t.exports=Wd()}))(),Kd=class{static send(e,t,n){$.sendNotification(`aventus/sharp/compiling`,e,t,n)}},qd=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 Jd(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},Jd=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 A&&await this.file.validate()}triggerSave(){this.file instanceof A&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof A&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return lt.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return lt.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return lt.getInstance().doResolve(t)}async onHover(e,t){return lt.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return lt.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}},Yd=class{static cmd=`aventus.sharp.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Gd.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}if(!(0,Gd.sync)(`csharp-converter`))try{if(await $.ask(`csharp-converter is missing. Can I install it?`)&&await $.showLoadingMessage(`Installing csharp-converter`,async()=>{await Te(`dotnet tool install --global AventusSharp.Converter`)}),!(0,Gd.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(qd.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)(D(e),`utf-8`);t=JSON.parse(n).csProj}catch(e){$.error(e)}this.isCompiling=!0,Kd.send(t,`compiling`);try{let{stdout:n}=await Te(`csharp-converter `+D(e)),r=n.toString();if(r.indexOf(`Error : `)==-1)Kd.send(t,`success`);else{console.clear(),$.error(r);let e=`csharp_errors`;Vi.send(e,r),Kd.send(t,`error`,[{title:`C# error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},Xd=class{static cmd=`aventus.reloadSettings`;static async run(){$.refreshSettings()}},Zd=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}}];Ed.send(e,[g])}}},Qd=class{static cmd=`aventus.storybook.build`;static async run(){let e=[],t=L.getInstance().getAllBuildsWithStory();for(let n of t)e.push({label:n.name,detail:n.uri});let n=await $.Select(e,{title:`Story to build`});if(n){let e=n.detail??``,t=n.label;L.getInstance().getProjectByUri(e)?.getBuild(t)?.buildStorybook()}}},$d=class{static cmd=`aventus.template.import_project`;static async run(){await $.templateManager?.selectProjectToImport(!1)}},ef=class{static cmd=`aventus.npm.build`;static async run(){let e=[],t=L.getInstance().getAllBuildsWithNpm();for(let n of t)e.push({label:n.name,detail:n.uri});let n=e.length==1?e[0]:await $.Select(e,{title:`Package to build`});if(n){let e=n.detail??``,t=n.label;L.getInstance().getProjectByUri(e)?.getBuild(t)?.buildNpm()}}},tf=class{static cmd=`aventus.i18n.add`;static async run(e,t,n=!0){try{let r=L.getInstance().getMatchingBuildsByUri(e);if(r.length>0){let i=r[0],a=e.replace(w.ComponentView,w.I18n),o=[];if(n&&i.i18nComponentsFiles[a]){let e=D(a);o.push({label:(0,f.basename)(e),detail:e})}for(let e in i.tsLanguageService.i18nFiles){let t=D(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=E(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:Xi.empty;let l=[{newText:JSON.stringify(Xi.sortObj(a),null,4),range:{start:r.file.documentUser.positionAt(0),end:r.file.documentUser.positionAt(r.file.documentUser.getText().length)}}];Ed.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)}}},nf=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 rf(e))}async onFileRemove(e){delete this.files[e]}destroy(){R.getInstance().removeOnNewFile(this.onNewFileUUID),R.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},rf=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 A&&await this.file.validate()}triggerSave(){this.file instanceof A&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof A&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return lt.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return lt.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return lt.getInstance().doResolve(t)}async onHover(e,t){return lt.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return lt.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}},af=class{static cmd=`aventus.php.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,Gd.sync)(`php`)){$.showErrorMessage(`Php isn't installed on your system`);return}if(!(0,Gd.sync)(`php-converter`))try{if(!(0,Gd.sync)(`composer`)){$.showErrorMessage(`composer isn't installed on your system`);return}if(await $.ask(`php-converter is missing. Can I install it?`)&&await Te(`composer global require aventus/transpiler`),!(0,Gd.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(nf.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=D(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,Kd.send(t,`compiling`);try{let n=(0,f.join)($.extensionPath,`lib`,`bin`,`PhpToTypescript`,`PhpToTypescript.phar`),r=D(e),{stdout:i}=await Te(`php `+n+` `+r+` 2>&1`,{encoding:`utf8`}),a=i.toString();if(a.indexOf(`Error : `)==-1)Kd.send(t,`success`);else{console.clear(),$.error(a);let e=`php_errors`;Vi.send(e,a),Kd.send(t,`error`,[{title:`PHP error`,file:e}])}}catch(e){$.showErrorMessage(e+``)}this.isCompiling=!1}},of=class{static cmd=`aventus.store.connect`;static async run(e,t){if(Fi.isConnected){await $.showInformationMessage(`You are already connected with account `+Fi.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 Fi.connect(e,t)?await $.showInformationMessage(`Connection successful`):await $.showErrorMessage(`Connection failed`))}},sf=class{static cmd=`aventus.store.disconnect`;static async run(){Fi.isConnected&&(await Fi.disconnect(),$.showInformationMessage(`You are disconnected`))}},cf=class{static cmd=`aventus.store.publish_package`;static async run(){if(!Fi.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let e=L.getInstance().getAllBuilds(),t=[],n=null;if(e.length==1)n={label:e[0].name,detail:e[0].uri};else for(let r of e)t.push({label:r.name,detail:r.uri}),n=await $.Select(t,{title:`Project to compile`});if(n){let e=n.detail??``,t=n.label,r=L.getInstance().getProjectByUri(e)?.getBuild(t);if(r){let e=await Fi.publishPackage(r);if(e instanceof Ii)for(let t of e.errors)$.showErrorMessage(t.message);else $.showInformationMessage(`Package published`)}}}},lf=class{static send(e){let t=k();return $.sendNotification(`aventus/progress_start`,t,e),t}},uf=class{static send(e){$.sendNotification(`aventus/progress_stop`,e)}},df=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=`
|
|
1015
|
+
import { AventusTemplate } from 'file://${(0,f.join)(Ct(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
|
|
1015
1016
|
import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
|
|
1016
1017
|
|
|
1017
1018
|
process.on('uncaughtException', function(err) {
|
|
@@ -1019,11 +1020,11 @@ public `+r+`?:`+i+`;
|
|
|
1019
1020
|
});
|
|
1020
1021
|
|
|
1021
1022
|
const t = new Template();
|
|
1022
|
-
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,
|
|
1023
|
+
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,Xe(this.config)+`_1.ts`);(0,u.writeFileSync)(a,r);let o=(0,g.spawn)(`node`,[`--no-warnings`,a],{cwd:this.folderPath,detached:!0}),s=(e,t)=>{let n=JSON.stringify({cmd:e,result:t??`NULL`})+`
|
|
1023
1024
|
`;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(`}
|
|
1024
1025
|
{`)!=-1){n=t.split(`}
|
|
1025
|
-
{`);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(E(t))}else if(t.cmd==`openFile`){let e=t.config;for(let t of e)$.sendNotification(`aventus/openfile`,(0,te.pathToFileURL)(t).toString())}else if(t.cmd==`getNamespace`){let e=t.config,n=L.getInstance().getMatchingBuildsByUri(E(e));if(n.length>0){let r=n[0].getNamespaceForUri(E(e));s(t.cmd,r)}else s(t.cmd,null)}else if(t.cmd==`exec`){let e={};e.cwd=D($.getWorkspaceUri());let n=t.config;try{await
|
|
1026
|
-
import { AventusTemplate, log } from 'file://${(0,f.join)(
|
|
1026
|
+
{`);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(E(t))}else if(t.cmd==`openFile`){let e=t.config;for(let t of e)$.sendNotification(`aventus/openfile`,(0,te.pathToFileURL)(t).toString())}else if(t.cmd==`getNamespace`){let e=t.config,n=L.getInstance().getMatchingBuildsByUri(E(e));if(n.length>0){let r=n[0].getNamespaceForUri(E(e));s(t.cmd,r)}else s(t.cmd,null)}else if(t.cmd==`exec`){let e={};e.cwd=D($.getWorkspaceUri());let n=t.config;try{await Te(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=D($.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=lf.send(e);s(t.cmd,n)}else if(t.cmd==`progressStop`){let e=t.config;uf.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=>{Ze(a),n()})}catch{n()}})}async isAllowed(e,t){if(!this.hasIsAllow)return!0;let n=`
|
|
1027
|
+
import { AventusTemplate, log } from 'file://${(0,f.join)(Ct(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
|
|
1027
1028
|
import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
|
|
1028
1029
|
|
|
1029
1030
|
process.on('uncaughtException', function(err) {
|
|
@@ -1031,15 +1032,16 @@ public `+r+`?:`+i+`;
|
|
|
1031
1032
|
});
|
|
1032
1033
|
|
|
1033
1034
|
const t = new Template();
|
|
1034
|
-
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,
|
|
1035
|
-
import { AventusTemplate, log } from 'file://${(0,f.join)(
|
|
1035
|
+
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,Xe(this.config)+`.ts`);(0,u.writeFileSync)(i,n);var a=``,o=``;let s=!1;try{let e=await Te(`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 Ze(i),s}static preparing={};prepareScript(){return new Promise(async t=>{let n=Xe(this.config);if(e.preparing[n]!==void 0){e.preparing[n].push(e=>{t(e)});return}e.preparing[n]=[];let r=`
|
|
1036
|
+
import { AventusTemplate, log } from 'file://${(0,f.join)(Ct(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
|
|
1036
1037
|
import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
|
|
1037
1038
|
const t = new Template();
|
|
1038
|
-
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 we(`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}(0,u.unlinkSync)(a);let l=[...e.preparing[n]];e.preparing[n]=[];for(let e of l)e(o);t(o)})}},uf=class{static cmd=`aventus.template.quick_edit`;static async run(){let e=T.getInstance().settings.quickCreations,t=[],n=r=>{if(r instanceof lf)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){T.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)}T.getInstance().setSettings({quickCreations:e},!0)}}},df=class{static cmd=`aventus.template.quick`;static async run(){let e=T.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 lf)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 lf.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 lf.create(r);i&&await i.init(n,n)}},ff=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=D(e);if((0,u.existsSync)(t)&&t.endsWith(w.Template)){let e=await lf.create(t);if(e){let t=await Ni.publishTemplate(e);if(t instanceof Pi)for(let e of t.errors)$.showErrorMessage(e.message);else $.showInformationMessage(`Template published`)}else $.showErrorMessage(`Your script for the template contains errors`)}}},pf=class{static cmd=`aventus.store.download_template`;static async run(e){e&&await $.templateManager?.downloadTemplateFromStore(e)}},mf=class{static cmd=`aventus.template.uninstall_project`;static async run(){await $.templateManager?.selectProjectToUninstall()}},hf=class{static cmd=`aventus.template.uninstall`;static async run(){await $.templateManager?.selectTemplateToUninstall()}},gf=class{static cmd=`aventus.format`;static async run(e){let t=[];t=e?[e]:R.getInstance().getUris();for(let e of t){let t=R.getInstance().getByUri(e);if(t instanceof A)try{let n=t.contentUser,r=await t.getFormatting();await t.applyTextEdits(r),n!=t.contentUser&&(0,u.writeFileSync)(D(e),t.contentUser)}catch(e){console.error(e)}}}},_f=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 ia(t,!1);await e.init();for(let t of e.getBuilds())await Ri.getInstance().loadDependenciesFromBuild(t.buildConfig,t)}}let e=Ri.getInstance().packages,t=(0,f.join)(D($.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=Ii.getMarkdown(t.file.uri);e&&(0,u.writeFileSync)((0,f.join)(n,t.name+`.md`),e)}}},vf=class{static cmd=`aventus.ai.rules`;static async run(){let e=(0,f.join)($.extensionPath,`lib`,`aventusjs-rules.md`),t=(0,f.join)(D($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t),(0,u.copyFileSync)(e,(0,f.join)(t,`aventusjs-rules.md`))}},yf=class{static cmd=`aventus.emmet`;static async run(){Ii.write(!0)}};const bf={allCommandes:{[dd.cmd]:dd,[bd.cmd]:bd,[Cd.cmd]:Cd,[xd.cmd]:xd,[fd.cmd]:fd,[Ad.cmd]:Ad,[jd.cmd]:jd,[_d.cmd]:_d,[yd.cmd]:yd,[Sd.cmd]:Sd,[ud.cmd]:ud,[Yd.cmd]:Yd,[Td.cmd]:Td,[Ed.cmd]:Ed,[Dd.cmd]:Dd,[Od.cmd]:Od,[kd.cmd]:kd,[pd.cmd]:pd,[hd.cmd]:hd,[md.cmd]:md,[Md.cmd]:Md,[Pd.cmd]:Pd,[Id.cmd]:Id,[Rd.cmd]:Rd,[Bd.cmd]:Bd,[Vd.cmd]:Vd,[Zd.cmd]:Zd,[qd.cmd]:qd,[nf.cmd]:nf,[Jd.cmd]:Jd,[Xd.cmd]:Xd,[Qd.cmd]:Qd,[$d.cmd]:$d,[rf.cmd]:rf,[af.cmd]:af,[of.cmd]:of,[ff.cmd]:ff,[pf.cmd]:pf,[df.cmd]:df,[uf.cmd]:uf,[mf.cmd]:mf,[hf.cmd]:hf,[gf.cmd]:gf,[_f.cmd]:_f,[vf.cmd]:vf,[yf.cmd]:yf},execute:async function(e){let t=this.allCommandes[e.command];if(t){let n=e.arguments??[];await t.run.call(t,...n)}}};var xf=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=D(n)+`/.aventus/templates`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}},Sf=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=>D(e).replace(/\//g,f.sep))}async init(){$.isIDE?this.loadTemplates():await this.loadTemplates(),T.getInstance().onSettingsChange(()=>{this.loadTemplates()})}async loadTemplates(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e),this.templatePath=T.getInstance().settings.templatePath;let t=(0,f.normalize)(e+f.sep+`templates`);this.prepareFolders(this.templatePath,t),this.globalPath=T.getInstance().settings.globalPath;let n=(0,f.normalize)(e+f.sep+`global`);this.prepareFolders(this.globalPath,n),this.projectPath=T.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 lf.create(a);r&&(Ke(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`}],{placeHolder:`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 lf.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 we(`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`}],{placeHolder:`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 lf.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 we(`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`}],{placeHolder:`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 lf.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 we(`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 lf?(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 lf?(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 lf?(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 lf){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,{placeHolder:`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 lf.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`)?ue.get:ne.get)(t,function(t){t.pipe(r),r.on(`finish`,()=>{r.close(),n(!0)}),r.on(`error`,()=>{r.close(),(0,u.unlinkSync)(e),n(!1)})})}catch{r.close(),(0,u.unlinkSync)(e),n(!1)}})}async extractZip(e,t){try{return await(await de.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=D(n)+`/.aventus/global`;return await this.readTemplates([r],e,t)}return{templates:e,nb:t}}},Cf=class e{languageService;filesLoaded={};filesNeeded=[];filesNpm=[];constructor(){Mt(),this.filesNeeded=[E((0,f.join)(xt(),`lib/templateScript/AventusTemplate.d.ts`))];let e=Pt((0,f.join)(xt(),`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:()=>wf,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:Pt(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:Pt(e),n},fileExists:e=>{let t=!1;return t=this.filesLoaded[e]?!0:!!Pt(e),t},directoryExists:e=>(0,u.existsSync)(D(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)(At(),`@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,wf,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,`
|
|
1039
|
-
`)}`;r.reportsUnnecessary?n.push({range:
|
|
1039
|
+
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 Te(`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}Ze(a);let l=[...e.preparing[n]];e.preparing[n]=[];for(let e of l)e(o);t(o)})}},ff=class{static cmd=`aventus.template.quick_edit`;static async run(){let e=T.getInstance().settings.quickCreations,t=[],n=r=>{if(r instanceof df)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){T.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)}T.getInstance().setSettings({quickCreations:e},!0)}}},pf=class{static cmd=`aventus.template.quick`;static async run(){let e=T.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 df)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 df.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 df.create(r);i&&await i.init(n,n)}},mf=class{static cmd=`aventus.store.publish_template`;static async run(e){if(!e)return;if(!Fi.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let t=D(e);if((0,u.existsSync)(t)&&t.endsWith(w.Template)){let e=await df.create(t);if(e){let t=await Fi.publishTemplate(e);if(t instanceof Ii)for(let e of t.errors)$.showErrorMessage(e.message);else $.showInformationMessage(`Template published`)}else $.showErrorMessage(`Your script for the template contains errors`)}}},hf=class{static cmd=`aventus.store.download_template`;static async run(e){e&&await $.templateManager?.downloadTemplateFromStore(e)}},gf=class{static cmd=`aventus.template.uninstall_project`;static async run(){await $.templateManager?.selectProjectToUninstall()}},_f=class{static cmd=`aventus.template.uninstall`;static async run(){await $.templateManager?.selectTemplateToUninstall()}},vf=class{static cmd=`aventus.format`;static async run(e){let t=[];t=e?[e]:R.getInstance().getUris();for(let e of t){let t=R.getInstance().getByUri(e);if(t instanceof A)try{let n=t.contentUser,r=await t.getFormatting();await t.applyTextEdits(r),n!=t.contentUser&&(0,u.writeFileSync)(D(e),t.contentUser)}catch(e){console.error(e)}}}},yf=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 oa(t,!1);await e.init();for(let t of e.getBuilds())await Bi.getInstance().loadDependenciesFromBuild(t.buildConfig,t)}}let e=Bi.getInstance().packages,t=(0,f.join)(D($.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=Ri.getMarkdown(t.file.uri);e&&(0,u.writeFileSync)((0,f.join)(n,t.name+`.md`),e)}}},bf=class{static cmd=`aventus.ai.rules`;static async run(){let e=(0,f.join)($.extensionPath,`lib`,`aventusjs-rules.md`),t=(0,f.join)(D($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t),(0,u.copyFileSync)(e,(0,f.join)(t,`aventusjs-rules.md`))}},xf=class{static cmd=`aventus.emmet`;static async run(){Ri.write(!0)}},Sf=class{static cmd=`aventus.sharp.update_tools`;static async run(){if(!(0,Gd.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,Gd.sync)(n)&&await $.showLoadingMessage(`Updating `+n,async()=>{let r=await Te(e[n]);r.stderr?$.showErrorMessage(r.stderr):t.push(n)});t.length>0&&$.showInformationMessage(`Update done for : `+t.join(`, `))}};const Cf={allCommandes:{[pd.cmd]:pd,[Sd.cmd]:Sd,[Td.cmd]:Td,[Cd.cmd]:Cd,[md.cmd]:md,[Md.cmd]:Md,[Nd.cmd]:Nd,[yd.cmd]:yd,[xd.cmd]:xd,[wd.cmd]:wd,[fd.cmd]:fd,[Zd.cmd]:Zd,[Dd.cmd]:Dd,[Od.cmd]:Od,[kd.cmd]:kd,[Ad.cmd]:Ad,[jd.cmd]:jd,[hd.cmd]:hd,[_d.cmd]:_d,[gd.cmd]:gd,[Pd.cmd]:Pd,[Id.cmd]:Id,[Rd.cmd]:Rd,[Bd.cmd]:Bd,[Hd.cmd]:Hd,[Ud.cmd]:Ud,[$d.cmd]:$d,[Yd.cmd]:Yd,[Sf.cmd]:Sf,[af.cmd]:af,[Xd.cmd]:Xd,[Qd.cmd]:Qd,[ef.cmd]:ef,[tf.cmd]:tf,[of.cmd]:of,[sf.cmd]:sf,[cf.cmd]:cf,[mf.cmd]:mf,[hf.cmd]:hf,[pf.cmd]:pf,[ff.cmd]:ff,[gf.cmd]:gf,[_f.cmd]:_f,[vf.cmd]:vf,[yf.cmd]:yf,[bf.cmd]:bf,[xf.cmd]:xf},execute:async function(e){let t=this.allCommandes[e.command];if(t){let n=e.arguments??[];await t.run.call(t,...n)}}};var wf=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=D(n)+`/.aventus/templates`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}},Tf=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=>D(e).replace(/\//g,f.sep))}async init(){$.isIDE?this.loadTemplates():await this.loadTemplates(),T.getInstance().onSettingsChange(()=>{this.loadTemplates()})}async loadTemplates(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e),this.templatePath=T.getInstance().settings.templatePath;let t=(0,f.normalize)(e+f.sep+`templates`);this.prepareFolders(this.templatePath,t),this.globalPath=T.getInstance().settings.globalPath;let n=(0,f.normalize)(e+f.sep+`global`);this.prepareFolders(this.globalPath,n),this.projectPath=T.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 df.create(a);r&&(qe(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 df.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 Te(`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 df.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 Te(`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 df.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 Te(`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 df?(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 df?(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 df?(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 df){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=`^${Fi.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 `+Fi.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 df.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`)?ue.get:ne.get)(t,function(t){t.pipe(r),r.on(`finish`,()=>{r.close(),n(!0)}),r.on(`error`,()=>{r.close(),Ze(e),n(!1)})})}catch{r.close(),Ze(e),n(!1)}})}async extractZip(e,t){try{return await(await de.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=D(n)+`/.aventus/global`;return await this.readTemplates([r],e,t)}return{templates:e,nb:t}}},Ef=class e{languageService;filesLoaded={};filesNeeded=[];filesNpm=[];constructor(){Pt(),this.filesNeeded=[E((0,f.join)(Ct(),`lib/templateScript/AventusTemplate.d.ts`))];let e=It((0,f.join)(Ct(),`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:()=>Df,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:It(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:It(e),n},fileExists:e=>{let t=!1;return t=this.filesLoaded[e]?!0:!!It(e),t},directoryExists:e=>(0,u.existsSync)(D(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)(Mt(),`@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,Df,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,`
|
|
1040
|
+
`)}`;r.reportsUnnecessary?n.push({range:Be(e.documentInternal,r),severity:m.DiagnosticSeverity.Hint,source:C.TypeScript,message:i,tags:[m.DiagnosticTag.Unnecessary]}):n.push({range:Be(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=Be(n,Ge(n.getText(),r)),a;try{a=this.languageService.getCompletionsAtPosition(n.uri,r,Of)}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:jn(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(` `);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+=`
|
|
1040
1041
|
\`\`\`
|
|
1041
1042
|
***
|
|
1042
1043
|
`),i+=t.join(`
|
|
1043
1044
|
|
|
1044
|
-
`),{range:
|
|
1045
|
-
`,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 Df=class extends ct{languageService;constructor(e){super(e),this.languageService=new Cf,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}},Of=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 Df(e),e instanceof A&&await e.validate())}},kf=class{};const Af={allCommunications:{},list:[class extends kf{channel(){return`aventus.i18n.getKeyFromPosition`}async run(e){if(e.uri){let t=L.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 kf{channel(){return`aventus.i18n.getLocales`}async run(e){if(e.uri){let t=L.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 jf=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 lf?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=D(n)+`/.aventus/projects`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}};function Mf(){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 Nf(){let e=(0,f.join)($.savePath,`packages`);(0,u.existsSync)(e)&&Pf(e)}function Pf(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())Pf(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 Ff={"1.4.0":Mf,"1.4.1":Nf};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 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 T.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 Af.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=T.getInstance().settings;e.watchFiles&&await rt.getInstance().destroy(),e.useCompilators&&(Gd.getInstance().destroy(),ef.getInstance().destroy()),L.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)?cd.onDocumentColor(e):null}async onColorPresentation(e,t,n){return e&&this.isStyleDocument(e)?cd.onColorPresentations(e,t,n):null}async onExecuteCommand(e){await bf.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||={},T.getInstance().initSettings(e);let t=await this.connection.getSettingsHtml();t||={},T.getInstance().setSettingsHtml(t)}async startServer(){let t=T.getInstance().settings;t.useTemplates&&(this._template=new Sf(this.workspaces),await this._template.init(),this._localTemplate=new xf(this._template),this._localProject=new jf(this._template)),t.useCompilators&&(Gd.getInstance(),ef.getInstance()),L.getInstance(),Of.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),Ii.write()):nt.sendDone(),this.isLoading=!1,e.debug(`start server done`)}runUpdate(){setTimeout(()=>{let t=`1.4.1`,n=T.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=Ff;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)}T.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 we(`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}},If=class{static cmd=`aventus/closefile`;static action(e){}},Lf=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}},Rf=class{static cmd=`aventus/editFile`;static async action(e){}},zf=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}},Bf=class{static cmd=`aventus/server/stop`;static action(){}},Vf=class{static cmd=`aventus/initStep`;static doneTxt=`Aventus : Done`;static action(e){e=e.replace(`$(loading~spin)`,`◌`),e==this.doneTxt&&ip.started()}},Hf=class{static cmd=`aventus/openfile`;static action(e){}},Uf=class{static cmd=`aventus/openpreview`;static action(e){}},Wf=class{static cmd=`aventus/registerBuild`;static action(e){e.pathConfig,e.buildName}},Gf=class{static cmd=`aventus/registerData`;static action(e){}},Kf=class{static cmd=`aventus/registerStatic`;static action(e){}},qf=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}}}},Jf=class{static cmd=`aventus/unregisterBuild`;static action(e){e.pathConfig,e.buildName}},Yf=class{static cmd=`aventus/unregisterData`;static action(e){}},Xf=class{static cmd=`aventus/unregisterStatic`;static action(e){}};const Zf={allNotifications:{[If.cmd]:If,[Lf.cmd]:Lf,[zf.cmd]:zf,[Bf.cmd]:Bf,[Hf.cmd]:Hf,[Uf.cmd]:Uf,[Wf.cmd]:Wf,[Gf.cmd]:Gf,[Kf.cmd]:Kf,[Jf.cmd]:Jf,[Yf.cmd]:Yf,[Xf.cmd]:Xf,[Rf.cmd]:Rf,[Vf.cmd]:Vf,[qf.loadFileTime.cmd]:qf.loadFileTime,[qf.buildTime.cmd]:qf.buildTime,[qf.sizeFile.cmd]:qf.sizeFile,[qf.staticTime.cmd]:qf.staticTime}};function Qf(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=$f(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function $f(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}m.DiagnosticSeverity.Error,m.DiagnosticSeverity.Warning,m.DiagnosticSeverity.Information,m.DiagnosticSeverity.Hint;var ep=class{notifications=Zf;errorsByBuildByFile={};cbErrors=[];_connection;config;executeCommand;constructor(e){this._connection=new tp,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 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:Qf(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 ip.interaction.password(e.title,t);let n=``;return e.title&&(n+=e.title),e.placeHolder&&(n!=``&&(n+=` - `),n+=e.placeHolder),await ip.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 ip.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 ip.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 ip.interaction.select(e,n)}else return console.log(e),null}async SelectFolder(e,t){return await ip.interaction.tree(e,`directory`,t)}},tp=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()}},np=class{watcher;stack={created:[],deleted:[],updated:[]};mutex=new rp;timeout;constructor(e){this.watcher=(0,v.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)md.run(E(e));for(let e of this.stack.created)pd.run(E(e));for(let e of this.stack.updated)hd.run(E(e));this.stack={created:[],deleted:[],updated:[]},this.mutex.release()}},rp=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}},ip=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 ep(e),e.watchFiles&&new np(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 fd.run(E(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 qf.info}static async Input(e){return this.cliConnection.Input(e)}};exports.RealServer=ip;
|
|
1045
|
+
`),{range:Be(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=It(e.fileName);if(t){let n=d.TextDocument.create(e.fileName,`typescript`,1,t);return[{uri:e.fileName,range:Be(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||Mn(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={...kf};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:Be(i,t.span),newText:t.newText});return s&&e.push({range:s,newText:Nn(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,kf,Of)}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:Be(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 Df={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},Of={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`},kf={convertTabsToSpaces:!0,tabSize:4,indentSize:4,indentStyle:p.IndentStyle.Smart,newLineCharacter:`
|
|
1046
|
+
`,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 Af=class extends ut{languageService;constructor(e){super(e),this.languageService=new Ef,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}},jf=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 Af(e),e instanceof A&&await e.validate())}},Mf=class{};const Nf={allCommunications:{},list:[class extends Mf{channel(){return`aventus.i18n.getKeyFromPosition`}async run(e){if(e.uri){let t=L.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 Mf{channel(){return`aventus.i18n.getLocales`}async run(e){if(e.uri){let t=L.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 Pf=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 df?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=D(n)+`/.aventus/projects`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}};function Ff(){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 If(){let e=(0,f.join)($.savePath,`packages`);(0,u.existsSync)(e)&&Lf(e)}function Lf(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())Lf(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 Rf={"1.4.0":Ff,"1.4.1":If};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 T.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 Nf.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=T.getInstance().settings;e.watchFiles&&await at.getInstance().destroy(),e.useCompilators&&(qd.getInstance().destroy(),nf.getInstance().destroy()),L.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)?ud.onDocumentColor(e):null}async onColorPresentation(e,t,n){return e&&this.isStyleDocument(e)?ud.onColorPresentations(e,t,n):null}async onExecuteCommand(e){await Cf.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||={},T.getInstance().initSettings(e);let t=await this.connection.getSettingsHtml();t||={},T.getInstance().setSettingsHtml(t)}async startServer(){let t=T.getInstance().settings;t.useTemplates&&(this._template=new Tf(this.workspaces),await this._template.init(),this._localTemplate=new wf(this._template),this._localProject=new Pf(this._template)),t.useCompilators&&(qd.getInstance(),nf.getInstance()),L.getInstance(),jf.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),Ri.write()):it.sendDone(),this.isLoading=!1,e.debug(`start server done`)}runUpdate(){setTimeout(()=>{let t=`1.4.1`,n=T.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=Rf;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)}T.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 Te(`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}},zf=class{static cmd=`aventus/closefile`;static action(e){}},Bf=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}},Vf=class{static cmd=`aventus/editFile`;static async action(e){}},Hf=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}},Uf=class{static cmd=`aventus/server/stop`;static action(){}},Wf=class{static cmd=`aventus/initStep`;static doneTxt=`Aventus : Done`;static action(e){e=e.replace(`$(loading~spin)`,`◌`),e==this.doneTxt&&sp.started()}},Gf=class{static cmd=`aventus/openfile`;static action(e){}},Kf=class{static cmd=`aventus/openpreview`;static action(e){}},qf=class{static cmd=`aventus/registerBuild`;static action(e){e.pathConfig,e.buildName}},Jf=class{static cmd=`aventus/registerData`;static action(e){}},Yf=class{static cmd=`aventus/registerStatic`;static action(e){}},Xf=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}}}},Zf=class{static cmd=`aventus/unregisterBuild`;static action(e){e.pathConfig,e.buildName}},Qf=class{static cmd=`aventus/unregisterData`;static action(e){}},$f=class{static cmd=`aventus/unregisterStatic`;static action(e){}};const ep={allNotifications:{[zf.cmd]:zf,[Bf.cmd]:Bf,[Hf.cmd]:Hf,[Uf.cmd]:Uf,[Gf.cmd]:Gf,[Kf.cmd]:Kf,[qf.cmd]:qf,[Jf.cmd]:Jf,[Yf.cmd]:Yf,[Zf.cmd]:Zf,[Qf.cmd]:Qf,[$f.cmd]:$f,[Vf.cmd]:Vf,[Wf.cmd]:Wf,[Xf.loadFileTime.cmd]:Xf.loadFileTime,[Xf.buildTime.cmd]:Xf.buildTime,[Xf.sizeFile.cmd]:Xf.sizeFile,[Xf.staticTime.cmd]:Xf.staticTime}};function tp(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=np(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function np(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}m.DiagnosticSeverity.Error,m.DiagnosticSeverity.Warning,m.DiagnosticSeverity.Information,m.DiagnosticSeverity.Hint;var rp=class{notifications=ep;errorsByBuildByFile={};cbErrors=[];_connection;config;executeCommand;constructor(e){this._connection=new ip,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(`
|
|
1047
|
+
`),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:tp(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 sp.interaction.password(e.title,t);let n=``;return e.title&&(n+=e.title),e.placeHolder&&(n!=``&&(n+=` - `),n+=e.placeHolder),await sp.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 sp.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 sp.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 sp.interaction.select(e,n)}else return console.log(e),null}async SelectFolder(e,t){return await sp.interaction.tree(e,`directory`,t)}},ip=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()}},ap=class{watcher;stack={created:[],deleted:[],updated:[]};mutex=new op;timeout;constructor(e){this.watcher=(0,v.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)gd.run(E(e));for(let e of this.stack.created)hd.run(E(e));for(let e of this.stack.updated)_d.run(E(e));this.stack={created:[],deleted:[],updated:[]},this.mutex.release()}},op=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}},sp=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 rp(e),e.watchFiles&&new ap(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 md.run(E(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 Xf.info}static async Input(e){return this.cliConnection.Input(e)}};exports.RealServer=sp;
|