@aventusjs/cli 0.0.41 → 0.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/RealServer.js +116 -116
- package/out/cli.js +1 -1
- package/package.json +1 -1
package/out/RealServer.js
CHANGED
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
12
12
|
`)return`
|
|
13
13
|
`}return e&&e.eol||`
|
|
14
14
|
`}function Pe(e,t){return`\r
|
|
15
|
-
`.indexOf(e.charAt(t))!==-1}var Fe;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Fe||={});function Ie(e,t=[],n=Fe.DEFAULT){let r=null,i=[],a=[];function o(e){Array.isArray(i)?i.push(e):r!==null&&(i[r]=e)}return ze(e,{onObjectBegin:()=>{let e={};o(e),a.push(i),i=e,r=null},onObjectProperty:e=>{r=e},onObjectEnd:()=>{i=a.pop()},onArrayBegin:()=>{let e=[];o(e),a.push(i),i=e,r=null},onArrayEnd:()=>{i=a.pop()},onLiteralValue:o,onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}},n),i[0]}function Le(e,t=[],n=Fe.DEFAULT){let r={type:`array`,offset:-1,length:-1,children:[],parent:void 0};function i(e){r.type===`property`&&(r.length=e-r.offset,r=r.parent)}function a(e){return r.children.push(e),e}ze(e,{onObjectBegin:e=>{r=a({type:`object`,offset:e,length:-1,parent:r,children:[]})},onObjectProperty:(e,t,n)=>{r=a({type:`property`,offset:t,length:-1,parent:r,children:[]}),r.children.push({type:`string`,value:e,offset:t,length:n,parent:r})},onObjectEnd:(e,t)=>{i(e+t),r.length=e+t-r.offset,r=r.parent,i(e+t)},onArrayBegin:(e,t)=>{r=a({type:`array`,offset:e,length:-1,parent:r,children:[]})},onArrayEnd:(e,t)=>{r.length=e+t-r.offset,r=r.parent,i(e+t)},onLiteralValue:(e,t,n)=>{a({type:Ve(e),offset:t,length:n,parent:r,value:e}),i(t+n)},onSeparator:(e,t,n)=>{r.type===`property`&&(e===`:`?r.colonOffset=t:e===`,`&&i(t))},onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}},n);let o=r.children[0];return o&&delete o.parent,o}function Re(e,t){if(!e)return;let n=e;for(let e of t)if(typeof e==`string`){if(n.type!==`object`||!Array.isArray(n.children))return;let t=!1;for(let r of n.children)if(Array.isArray(r.children)&&r.children[0].value===e&&r.children.length===2){n=r.children[1],t=!0;break}if(!t)return}else{let t=e;if(n.type!==`array`||t<0||!Array.isArray(n.children)||t>=n.children.length)return;n=n.children[t]}return n}function ze(e,t,n=Fe.DEFAULT){let r=Se(e,!1),i=[],a=0;function o(e){return e?()=>a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function s(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function c(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function l(e){return e?()=>{a>0?a++:e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())===!1&&(a=1)}:()=>!0}function u(e){return e?()=>{a>0&&a--,a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}let d=l(t.onObjectBegin),f=c(t.onObjectProperty),p=u(t.onObjectEnd),m=l(t.onArrayBegin),h=u(t.onArrayEnd),g=c(t.onLiteralValue),_=s(t.onSeparator),v=o(t.onComment),y=s(t.onError),b=n&&n.disallowComments,x=n&&n.allowTrailingComma;function S(){for(;;){let e=r.scan();switch(r.getTokenError()){case 4:C(14);break;case 5:C(15);break;case 3:C(13);break;case 1:b||C(11);break;case 2:C(12);break;case 6:C(16);break}switch(e){case 12:case 13:b?C(10):v();break;case 16:C(1);break;case 15:case 14:break;default:return e}}}function C(e,t=[],n=[]){if(y(e),t.length+n.length>0){let e=r.getToken();for(;e!==17;){if(t.indexOf(e)!==-1){S();break}else if(n.indexOf(e)!==-1)break;e=S()}}}function ee(e){let t=r.getTokenValue();return e?g(t):(f(t),i.push(t)),S(),!0}function te(){switch(r.getToken()){case 11:let e=r.getTokenValue(),t=Number(e);isNaN(t)&&(C(2),t=0),g(t);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return S(),!0}function ne(){return r.getToken()===10?(ee(!1),r.getToken()===6?(_(`:`),S(),ie()||C(4,[],[2,5])):C(5,[],[2,5]),i.pop(),!0):(C(3,[],[2,5]),!1)}function w(){d(),S();let e=!1;for(;r.getToken()!==2&&r.getToken()!==17;){if(r.getToken()===5){if(e||C(4,[],[]),_(`,`),S(),r.getToken()===2&&x)break}else e&&C(6,[],[]);ne()||C(4,[],[2,5]),e=!0}return p(),r.getToken()===2?S():C(7,[2],[]),!0}function re(){m(),S();let e=!0,t=!1;for(;r.getToken()!==4&&r.getToken()!==17;){if(r.getToken()===5){if(t||C(4,[],[]),_(`,`),S(),r.getToken()===4&&x)break}else t&&C(6,[],[]);e?(i.push(0),e=!1):i[i.length-1]++,ie()||C(4,[],[4,5]),t=!0}return h(),e||i.pop(),r.getToken()===4?S():C(8,[4],[]),!0}function ie(){switch(r.getToken()){case 3:return re();case 1:return w();case 10:return ee(!0);default:return te()}}return S(),r.getToken()===17?n.allowEmptyContent?!0:(C(4,[],[]),!1):ie()?(r.getToken()!==17&&C(9,[],[]),!0):(C(4,[],[]),!1)}function Be(e,t){let n=Se(e),r=[],i,a=0,o;do switch(o=n.getPosition(),i=n.scan(),i){case 12:case 13:case 17:a!==o&&r.push(e.substring(a,o)),t!==void 0&&r.push(n.getTokenValue().replace(/[^\r\n]/g,t)),a=n.getPosition();break}while(i!==17);return r.join(``)}function Ve(e){switch(typeof e){case`boolean`:return`boolean`;case`number`:return`number`;case`string`:return`string`;case`object`:return e?Array.isArray(e)?`array`:`object`:`null`;default:return`null`}}function He(e,t,n,r){let i=t.slice(),a=Le(e,[]),o,s;for(;i.length>0&&(s=i.pop(),o=Re(a,i),o===void 0&&n!==void 0);)n=typeof s==`string`?{[s]:n}:[n];if(!o){if(n===void 0)throw Error(`Can not delete in empty document`);return Ue(e,{offset:a?a.offset:0,length:a?a.length:0,content:JSON.stringify(n)},r)}else if(o.type===`object`&&typeof s==`string`&&Array.isArray(o.children)){let t=Re(o,[s]);if(t!==void 0)if(n===void 0){if(!t.parent)throw Error(`Malformed AST`);let n=o.children.indexOf(t.parent),i,a=t.parent.offset+t.parent.length;if(n>0){let e=o.children[n-1];i=e.offset+e.length}else i=o.offset+1,o.children.length>1&&(a=o.children[1].offset);return Ue(e,{offset:i,length:a-i,content:``},r)}else return Ue(e,{offset:t.offset,length:t.length,content:JSON.stringify(n)},r);else{if(n===void 0)return[];let t=`${JSON.stringify(s)}: ${JSON.stringify(n)}`,i=r.getInsertionIndex?r.getInsertionIndex(o.children.map(e=>e.children[0].value)):o.children.length,a;if(i>0){let e=o.children[i-1];a={offset:e.offset+e.length,length:0,content:`,`+t}}else a=o.children.length===0?{offset:o.offset+1,length:0,content:t}:{offset:o.offset+1,length:0,content:t+`,`};return Ue(e,a,r)}}else if(o.type===`array`&&typeof s==`number`&&Array.isArray(o.children)){let t=s;if(t===-1){let t=`${JSON.stringify(n)}`,i;if(o.children.length===0)i={offset:o.offset+1,length:0,content:t};else{let e=o.children[o.children.length-1];i={offset:e.offset+e.length,length:0,content:`,`+t}}return Ue(e,i,r)}else if(n===void 0&&o.children.length>=0){let t=s,n=o.children[t],i;if(o.children.length===1)i={offset:o.offset+1,length:o.length-2,content:``};else if(o.children.length-1===t){let e=o.children[t-1],n=e.offset+e.length;i={offset:n,length:o.offset+o.length-2-n,content:``}}else i={offset:n.offset,length:o.children[t+1].offset-n.offset,content:``};return Ue(e,i,r)}else if(n!==void 0){let t,i=`${JSON.stringify(n)}`;if(!r.isArrayInsertion&&o.children.length>s){let e=o.children[s];t={offset:e.offset,length:e.length,content:i}}else if(o.children.length===0||s===0)t={offset:o.offset+1,length:0,content:o.children.length===0?i:i+`,`};else{let e=s>o.children.length?o.children.length:s,n=o.children[e-1];t={offset:n.offset+n.length,length:0,content:`,`+i}}return Ue(e,t,r)}else throw Error(`Can not ${n===void 0?`remove`:r.isArrayInsertion?`insert`:`modify`} Array index ${t} as length is not sufficient`)}else throw Error(`Can not add ${typeof s==`number`?`property`:`index`} to parent of type ${o.type}`)}function Ue(e,t,n){if(!n.formattingOptions)return[t];let r=We(e,t),i=t.offset,a=t.offset+t.content.length;if(t.length===0||t.content.length===0){for(;i>0&&!Pe(r,i-1);)i--;for(;a<r.length&&!Pe(r,a);)a++}let o=Ae(r,{offset:i,length:a-i},{...n.formattingOptions,keepLines:!1});for(let e=o.length-1;e>=0;e--){let t=o[e];r=We(r,t),i=Math.min(i,t.offset),a=Math.max(a,t.offset+t.length),a+=t.content.length-t.length}let s=e.length-(r.length-a)-i;return[{offset:i,length:s,content:r.substring(i,a)}]}function We(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var Ge;(function(e){e[e.None=0]=`None`,e[e.UnexpectedEndOfComment=1]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=2]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=3]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=4]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=5]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=6]=`InvalidCharacter`})(Ge||={});var Ke;(function(e){e[e.OpenBraceToken=1]=`OpenBraceToken`,e[e.CloseBraceToken=2]=`CloseBraceToken`,e[e.OpenBracketToken=3]=`OpenBracketToken`,e[e.CloseBracketToken=4]=`CloseBracketToken`,e[e.CommaToken=5]=`CommaToken`,e[e.ColonToken=6]=`ColonToken`,e[e.NullKeyword=7]=`NullKeyword`,e[e.TrueKeyword=8]=`TrueKeyword`,e[e.FalseKeyword=9]=`FalseKeyword`,e[e.StringLiteral=10]=`StringLiteral`,e[e.NumericLiteral=11]=`NumericLiteral`,e[e.LineCommentTrivia=12]=`LineCommentTrivia`,e[e.BlockCommentTrivia=13]=`BlockCommentTrivia`,e[e.LineBreakTrivia=14]=`LineBreakTrivia`,e[e.Trivia=15]=`Trivia`,e[e.Unknown=16]=`Unknown`,e[e.EOF=17]=`EOF`})(Ke||={});const qe=Ie,Je=Be;var Ye;(function(e){e[e.InvalidSymbol=1]=`InvalidSymbol`,e[e.InvalidNumberFormat=2]=`InvalidNumberFormat`,e[e.PropertyNameExpected=3]=`PropertyNameExpected`,e[e.ValueExpected=4]=`ValueExpected`,e[e.ColonExpected=5]=`ColonExpected`,e[e.CommaExpected=6]=`CommaExpected`,e[e.CloseBraceExpected=7]=`CloseBraceExpected`,e[e.CloseBracketExpected=8]=`CloseBracketExpected`,e[e.EndOfFileExpected=9]=`EndOfFileExpected`,e[e.InvalidCommentToken=10]=`InvalidCommentToken`,e[e.UnexpectedEndOfComment=11]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=12]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=13]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=14]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=15]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=16]=`InvalidCharacter`})(Ye||={});function Xe(e,t,n,r){return He(e,t,n,r)}function Ze(e,t){let n=t.slice(0).sort((e,t)=>{let n=e.offset-t.offset;return n===0?e.length-t.length:n}),r=e.length;for(let t=n.length-1;t>=0;t--){let i=n[t];if(i.offset+i.length<=r)e=We(e,i);else throw Error(`Overlapping edit`);r=i.offset}return e}var Qe=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}languageService;constructor(){this.languageService=(0,h.getLanguageService)({schemaRequestService:async e=>JSON.stringify(ye)}),this.languageService.configure({allowComments:!0,schemas:[{fileMatch:[`**`+E.Config],uri:ye.$schema??``,schema:ye},{fileMatch:[`**`+E.CsharpConfig],uri:be.$schema??``,schema:be},{fileMatch:[`**`+E.PhpConfig],uri:xe.$schema??``,schema:xe}]})}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;if(t.uri.endsWith(E.Config)){let e=[];return await this.getConfig(t,e),e}let n=this.languageService.parseJSONDocument(t),r=await this.languageService.doValidation(t,n);if(r.length==0){let e=Je(t.getText());try{return JSON.parse(e),r}catch{r.push(is(t,`Can't parse the json`,1001))}}for(let e of r)e.severity=m.DiagnosticSeverity.Error;return r}getDependencyKeyRange(e,t,n){let r=e.documentUser,i=this.languageService.parseJSONDocument(r).root;if(i?.type!==`object`)return null;let a=(e,t)=>e.properties.find(e=>e.keyNode.value===t)?.valueNode,o=e=>{let t=a(e,`dependencies`);if(t?.type!==`object`)return null;let i=t.properties.find(e=>e.keyNode.value===n)?.keyNode;return i?m.Range.create(r.positionAt(i.offset),r.positionAt(i.offset+i.length)):null},s=a(i,`build`);if(s?.type===`array`&&t){for(let e of s.items)if(e.type===`object`&&a(e,`name`)?.value===t){let t=o(e);if(t)return t}}return o(i)}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,t=[]){let n=`documentUser`in e?e.documentUser:e,r=this.languageService.parseJSONDocument(n),i=await this.languageService.doValidation(n,r,void 0,ye);if(t.push(...i.map(e=>({...e,severity:m.DiagnosticSeverity.Error}))),i.length==0){let e=Je(n.getText());try{let i=JSON.parse(e);return i=this.prepareConfigFile(n.uri,i,n,r.root,t),t.length===0?i:null}catch{t.push(is(n,`Can't parse the json`,1001))}}return null}getConfigPathRange(e,t,n,r=!1){let i=m.Range.create(e.positionAt(0),e.positionAt(e.getText().length)),a=t=>m.Range.create(e.positionAt(t.offset),e.positionAt(t.offset+t.length)),o=t,s=n,c=!0;for(;s.length>0;){if(s.startsWith(`.`)){if(c||(s=s.slice(1),!s||s.startsWith(`.`)||s.startsWith(`[`)))return i}else if(!c&&!s.startsWith(`[`))return i;let e=/^\[(\d+)\]/.exec(s),t=/^\[("(?:\\.|[^"\\])*")\]/.exec(s),n=/^[^.[\]]+/.exec(s);if(e){if(o?.type===`array`)o=o.items[Number(e[1])];else if(!r||Number(e[1])!==0||!o)return i;s=s.slice(e[0].length)}else if(t||n){if(o?.type!==`object`)return r&&o?a(o):i;let e=n?.[0];if(t)try{e=JSON.parse(t[1])}catch{return i}let c=o.properties.find(t=>t.keyNode.value===e)?.valueNode;if(!c)return r?a(o):i;o=c,s=s.slice((t??n)[0].length)}else return i;if(!o)return i;c=!1}return o?a(o):i}prepareConfigFile(e,t,n,r,i){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`}if(t.dependencies)for(let n in t.dependencies)t.dependencies[n].uri&&(t.dependencies[n].uri=this.replaceEnvVar(t.dependencies[n].uri,fs(e)));let a=(e,t,a)=>{for(let[o,s]of Object.entries(e??{}))typeof s!=`object`||!s?.uri||(a.has(s.uri)&&a.get(s.uri)!==o?i.push({range:this.getConfigPathRange(n,r,`${t}[${JSON.stringify(o)}].uri`),severity:m.DiagnosticSeverity.Error,source:`Aventus`,message:`Dependencies ${a.get(s.uri)} and ${o} use the same URI: ${s.uri}`}):a.set(s.uri,o))},o=new Map;a(t.dependencies,`dependencies`,o);let s=[],c=new Set;for(let l=0;l<t.build.length;l++){let u=this.prepareBuild(e,t.build[l],t);c.has(u.fullname)&&i.push({range:this.getConfigPathRange(n,r,`build[${l}].name`),severity:m.DiagnosticSeverity.Error,source:`Aventus`,message:`Duplicate build: ${u.fullname}`}),c.add(u.fullname),a(u.dependencies,`build[${l}].dependencies`,new Map(o)),s.push(u)}t.build=s;let l=new Map;for(let e=0;e<t.build.length;e++){let n=t.build[e];if(!n.disabled)for(let t=0;t<n.compile.length;t++)for(let r=0;r<n.compile[t].output.length;r++){let i=n.compile[t].output[r],a=new Map;for(let[n,o]of Object.entries(i)){let i=`build[${e}].compile[${t}].output[${r}][${JSON.stringify(n)}].path`,s=o.path.replace(/\\/g,`/`).toLowerCase();a.has(s)||a.set(s,[]),a.get(s).push(i)}for(let[e,t]of a.entries())l.has(e)||l.set(e,[]),l.get(e).push(t)}}for(let[e,t]of l.entries())if(t.length>1)for(let a of t)for(let t of a)i.push({range:this.getConfigPathRange(n,r,t,!0),severity:m.DiagnosticSeverity.Error,source:`Aventus`,message:`Multiple active compilation units write the same JavaScript output: ${e}`});if(t.static){let n=[];for(let r of t.static){let t=this.prepareStatic(e,r),i=(0,f.resolve)(t.inputPathFolder),a=t.outputPathFolder.find(e=>{let t=(0,f.relative)(i,(0,f.resolve)(e));return t===``||t!==`..`&&!t.startsWith(`..`+f.sep)&&!(0,f.isAbsolute)(t)});if(a){$.showErrorMessage(`Static ${t.name}: output ${a} is inside input ${t.inputPathFolder}`);continue}n.push(t)}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=g.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)(L(t)+e)):e=(0,f.normalize)(e)),e}prepareBuild(e,t,n){let r=fs(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)(L(r)+e+n).replace(/\\/g,`/`);a=hs(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)(L($.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)(L($.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)(L(r)+n+e).replace(/\\/g,`/`),s=a.replace(`*`,``);s.endsWith(`/`)&&(s=s.slice(0,-1)),t.srcPath.push(s),a=hs(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)(L(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)(L(r)+t+n).replace(/\\/g,`/`);a=hs(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)(L(r)+t+e).replace(/\\/g,`/`);a=hs(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)(L(r)+e+t.namespaceRoot).replace(/\\/g,`/`)}return t.i18n,t}prepareStatic(e,t){let n=fs(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)(L(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=(0,f.normalize)(e).replace(/\\/g,`/`),t.outputPathFolder.includes(e)||t.outputPathFolder.push(e);return t}defaultConfigValue(){return{module:``,hideWarnings:F.getInstance().settings.defaultHideWarnings,forceDocumentation:F.getInstance().settings.defaultForceDocumentation,version:`1.0.0`,componentPrefix:``,tags:[],dependencies:{},build:[],static:[],avoidParsingInsideTags:[],aliases:{},namespaceRules:{},namespaceRulesRegex:{},namespaceStrategy:`manual`,namespaceRoot:`./`,ideBuild:F.getInstance().settings.ideBuild}}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,forceDocumentation:e.forceDocumentation,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:``,ideBuild:e.ideBuild}}defaultConfigBuildStories(e,t){return{output:e+`/stories`,format:`all`}}defaultConfigBuildDependencyValue(e){return{}}};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 D(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 O=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 L(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 fs(this.uri)}get folderPath(){return fs(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=D();for(;this.onGetBuildCb[t]!=null;)t=D();return this.onGetBuildCb[t]=e,t}removeOnGetBuild(e){delete this.onGetBuildCb[e]}onValidateCb={};validationRequest=0;deleted=!1;get isDeleted(){return this.deleted}async validate(e=!0){if(this.deleted)return[];let t=this.versionUser,n=++this.validationRequest,r={};for(let e in this.onValidateCb){let i=await this.onValidateCb[e](this);if(this.deleted||this.versionUser!==t||n!==this.validationRequest)return[];for(let e of i){let t=e.message+`**`+e.range.start.line+`:`+e.range.start.character+`,`+e.range.end.line+`:`+e.range.end.character;r[t]||(r[t]=e)}}if(this.deleted||this.versionUser!==t||n!==this.validationRequest)return[];if(e)if(F.getInstance().settings.errorByBuild){let e=this.getBuild();if(e==null)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(r)});else for(let t of e)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(r)},t)}else $.sendDiagnostics({uri:this.uri,diagnostics:Object.values(r)});return Object.values(r)}onValidate(e){let t=D();for(;this.onValidateCb[t]!=null;)t=D();return this.onValidateCb[t]=e,t}removeOnValidate(e){delete this.onValidateCb[e]}onContentChangeCb={};delayValidate;waitingDocContentChange={};resolveContentChange={};activeContentChanges=new Set;startContentChange(e){let t=this.triggerContentChangeNoBuffer(e);this.activeContentChanges.add(t),t.then(()=>this.activeContentChanges.delete(t),()=>this.activeContentChanges.delete(t))}triggerContentChange(e){return new Promise(t=>{if(this.deleted||e.version<=this.versionUser){t();return}if(!this.triggerCanContentChange(e)){t();return}setTimeout(()=>{let n=this.waitingDocContentChange[e.uri],r=!0;if((this.deleted||e.version<=this.versionUser||n&&typeof n!=`boolean`&&e.version<=n.version)&&(r=!1),!r){t();return}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.startContentChange(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.deleted||(this.delayValidate&&clearTimeout(this.delayValidate),this.delayValidate=setTimeout(()=>{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`&&r.version>this.versionUser?(this.waitingDocContentChange[e.uri]=!0,this.startContentChange(r)):delete this.waitingDocContentChange[e.uri]}onContentChange(e){let t=D();for(;this.onContentChangeCb[t]!=null;)t=D();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=D();for(;this.onCanContentChangeCb[t]!=null;)t=D();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,T.TypeScript,this.documentUser.version+1,t);await this.triggerContentChange(n)}onSaveCb={};async triggerSave(){for(let e in this.onSaveCb){if(this.deleted)return;await this.onSaveCb[e](this)}}onSave(e){let t=D();for(;this.onSaveCb[t]!=null;)t=D();return this.onSaveCb[t]=e,t}removeOnSave(e){delete this.onSaveCb[e]}onDeleteCb={};async triggerDelete(){this.deleted=!0,this.delayValidate&&=(clearTimeout(this.delayValidate),void 0);for(let e of Object.values(this.resolveContentChange))for(let t of Object.values(e))for(let e of t)e();this.resolveContentChange={},this.waitingDocContentChange={},await Promise.allSettled(this.activeContentChanges);let e=[];for(let t in this.onDeleteCb)e.push(this.onDeleteCb[t](this));try{await Promise.all(e)}finally{this.removeAllCallbacks()}}removeAllCallbacks(){this.onGetBuildCb={},this.onValidateCb={},this.onCanContentChangeCb={},this.onReferencesCb={},this.onCodeLensCb={},this.onRenameCb={},this.onCodeActionCb={},this.onCompletionCb={},this.onCompletionResolveCb={},this.onContentChangeCb={},this.onDefinitionCb={},this.onDeleteCb={},this.onFormattingCb={},this.onHoverCb={},this.onSaveCb={}}onDelete(e){let t=D();for(;this.onDeleteCb[t]!=null;)t=D();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=D();for(;this.onCompletionCb[t]!=null;)t=D();return this.onCompletionCb[t]=e,t}removeOnCompletion(e){delete this.onCompletionCb[e]}onCompletionResolveCb={};async getCompletionResolve(e){let t=e;for(let e in this.onCompletionResolveCb)t=await this.onCompletionResolveCb[e](this,t);return t}onCompletionResolve(e){let t=D();for(;this.onCompletionResolveCb[t]!=null;)t=D();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=D();for(;this.onHoverCb[t]!=null;)t=D();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=D();for(;this.onDefinitionCb[t]!=null;)t=D();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=D();for(;this.onFormattingCb[t]!=null;)t=D();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=D();for(;this.onCodeActionCb[t]!=null;)t=D();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=D();for(;this.onReferencesCb[t]!=null;)t=D();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=D();for(;this.onCodeLensCb[t]!=null;)t=D();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=D();for(;this.onRenameCb[t]!=null;)t=D();return this.onRenameCb[t]=e,t}removeOnRename(e){delete this.onRenameCb[e]}},it=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 O&&await this.file.validate()}async triggerSave(){this.file instanceof O&&await this.file.triggerSave()}async triggerDelete(){this.file instanceof O&&await this.file.triggerDelete()}async triggerContentChange(e){this.file instanceof O&&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._build&&!this.build.forceDocumentation&&(e=e.filter(e=>e.code!=1027)),this.oldResult=e,e}async _onDelete(){await this.onDelete(),this.removeEvents()}},at=o(((e,t)=>{
|
|
15
|
+
`.indexOf(e.charAt(t))!==-1}var Fe;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Fe||={});function Ie(e,t=[],n=Fe.DEFAULT){let r=null,i=[],a=[];function o(e){Array.isArray(i)?i.push(e):r!==null&&(i[r]=e)}return ze(e,{onObjectBegin:()=>{let e={};o(e),a.push(i),i=e,r=null},onObjectProperty:e=>{r=e},onObjectEnd:()=>{i=a.pop()},onArrayBegin:()=>{let e=[];o(e),a.push(i),i=e,r=null},onArrayEnd:()=>{i=a.pop()},onLiteralValue:o,onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}},n),i[0]}function Le(e,t=[],n=Fe.DEFAULT){let r={type:`array`,offset:-1,length:-1,children:[],parent:void 0};function i(e){r.type===`property`&&(r.length=e-r.offset,r=r.parent)}function a(e){return r.children.push(e),e}ze(e,{onObjectBegin:e=>{r=a({type:`object`,offset:e,length:-1,parent:r,children:[]})},onObjectProperty:(e,t,n)=>{r=a({type:`property`,offset:t,length:-1,parent:r,children:[]}),r.children.push({type:`string`,value:e,offset:t,length:n,parent:r})},onObjectEnd:(e,t)=>{i(e+t),r.length=e+t-r.offset,r=r.parent,i(e+t)},onArrayBegin:(e,t)=>{r=a({type:`array`,offset:e,length:-1,parent:r,children:[]})},onArrayEnd:(e,t)=>{r.length=e+t-r.offset,r=r.parent,i(e+t)},onLiteralValue:(e,t,n)=>{a({type:Ve(e),offset:t,length:n,parent:r,value:e}),i(t+n)},onSeparator:(e,t,n)=>{r.type===`property`&&(e===`:`?r.colonOffset=t:e===`,`&&i(t))},onError:(e,n,r)=>{t.push({error:e,offset:n,length:r})}},n);let o=r.children[0];return o&&delete o.parent,o}function Re(e,t){if(!e)return;let n=e;for(let e of t)if(typeof e==`string`){if(n.type!==`object`||!Array.isArray(n.children))return;let t=!1;for(let r of n.children)if(Array.isArray(r.children)&&r.children[0].value===e&&r.children.length===2){n=r.children[1],t=!0;break}if(!t)return}else{let t=e;if(n.type!==`array`||t<0||!Array.isArray(n.children)||t>=n.children.length)return;n=n.children[t]}return n}function ze(e,t,n=Fe.DEFAULT){let r=Se(e,!1),i=[],a=0;function o(e){return e?()=>a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function s(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter()):()=>!0}function c(e){return e?t=>a===0&&e(t,r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice()):()=>!0}function l(e){return e?()=>{a>0?a++:e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter(),()=>i.slice())===!1&&(a=1)}:()=>!0}function u(e){return e?()=>{a>0&&a--,a===0&&e(r.getTokenOffset(),r.getTokenLength(),r.getTokenStartLine(),r.getTokenStartCharacter())}:()=>!0}let d=l(t.onObjectBegin),f=c(t.onObjectProperty),p=u(t.onObjectEnd),m=l(t.onArrayBegin),h=u(t.onArrayEnd),g=c(t.onLiteralValue),_=s(t.onSeparator),v=o(t.onComment),y=s(t.onError),b=n&&n.disallowComments,x=n&&n.allowTrailingComma;function S(){for(;;){let e=r.scan();switch(r.getTokenError()){case 4:C(14);break;case 5:C(15);break;case 3:C(13);break;case 1:b||C(11);break;case 2:C(12);break;case 6:C(16);break}switch(e){case 12:case 13:b?C(10):v();break;case 16:C(1);break;case 15:case 14:break;default:return e}}}function C(e,t=[],n=[]){if(y(e),t.length+n.length>0){let e=r.getToken();for(;e!==17;){if(t.indexOf(e)!==-1){S();break}else if(n.indexOf(e)!==-1)break;e=S()}}}function ee(e){let t=r.getTokenValue();return e?g(t):(f(t),i.push(t)),S(),!0}function te(){switch(r.getToken()){case 11:let e=r.getTokenValue(),t=Number(e);isNaN(t)&&(C(2),t=0),g(t);break;case 7:g(null);break;case 8:g(!0);break;case 9:g(!1);break;default:return!1}return S(),!0}function ne(){return r.getToken()===10?(ee(!1),r.getToken()===6?(_(`:`),S(),ie()||C(4,[],[2,5])):C(5,[],[2,5]),i.pop(),!0):(C(3,[],[2,5]),!1)}function w(){d(),S();let e=!1;for(;r.getToken()!==2&&r.getToken()!==17;){if(r.getToken()===5){if(e||C(4,[],[]),_(`,`),S(),r.getToken()===2&&x)break}else e&&C(6,[],[]);ne()||C(4,[],[2,5]),e=!0}return p(),r.getToken()===2?S():C(7,[2],[]),!0}function re(){m(),S();let e=!0,t=!1;for(;r.getToken()!==4&&r.getToken()!==17;){if(r.getToken()===5){if(t||C(4,[],[]),_(`,`),S(),r.getToken()===4&&x)break}else t&&C(6,[],[]);e?(i.push(0),e=!1):i[i.length-1]++,ie()||C(4,[],[4,5]),t=!0}return h(),e||i.pop(),r.getToken()===4?S():C(8,[4],[]),!0}function ie(){switch(r.getToken()){case 3:return re();case 1:return w();case 10:return ee(!0);default:return te()}}return S(),r.getToken()===17?n.allowEmptyContent?!0:(C(4,[],[]),!1):ie()?(r.getToken()!==17&&C(9,[],[]),!0):(C(4,[],[]),!1)}function Be(e,t){let n=Se(e),r=[],i,a=0,o;do switch(o=n.getPosition(),i=n.scan(),i){case 12:case 13:case 17:a!==o&&r.push(e.substring(a,o)),t!==void 0&&r.push(n.getTokenValue().replace(/[^\r\n]/g,t)),a=n.getPosition();break}while(i!==17);return r.join(``)}function Ve(e){switch(typeof e){case`boolean`:return`boolean`;case`number`:return`number`;case`string`:return`string`;case`object`:return e?Array.isArray(e)?`array`:`object`:`null`;default:return`null`}}function He(e,t,n,r){let i=t.slice(),a=Le(e,[]),o,s;for(;i.length>0&&(s=i.pop(),o=Re(a,i),o===void 0&&n!==void 0);)n=typeof s==`string`?{[s]:n}:[n];if(!o){if(n===void 0)throw Error(`Can not delete in empty document`);return Ue(e,{offset:a?a.offset:0,length:a?a.length:0,content:JSON.stringify(n)},r)}else if(o.type===`object`&&typeof s==`string`&&Array.isArray(o.children)){let t=Re(o,[s]);if(t!==void 0)if(n===void 0){if(!t.parent)throw Error(`Malformed AST`);let n=o.children.indexOf(t.parent),i,a=t.parent.offset+t.parent.length;if(n>0){let e=o.children[n-1];i=e.offset+e.length}else i=o.offset+1,o.children.length>1&&(a=o.children[1].offset);return Ue(e,{offset:i,length:a-i,content:``},r)}else return Ue(e,{offset:t.offset,length:t.length,content:JSON.stringify(n)},r);else{if(n===void 0)return[];let t=`${JSON.stringify(s)}: ${JSON.stringify(n)}`,i=r.getInsertionIndex?r.getInsertionIndex(o.children.map(e=>e.children[0].value)):o.children.length,a;if(i>0){let e=o.children[i-1];a={offset:e.offset+e.length,length:0,content:`,`+t}}else a=o.children.length===0?{offset:o.offset+1,length:0,content:t}:{offset:o.offset+1,length:0,content:t+`,`};return Ue(e,a,r)}}else if(o.type===`array`&&typeof s==`number`&&Array.isArray(o.children)){let t=s;if(t===-1){let t=`${JSON.stringify(n)}`,i;if(o.children.length===0)i={offset:o.offset+1,length:0,content:t};else{let e=o.children[o.children.length-1];i={offset:e.offset+e.length,length:0,content:`,`+t}}return Ue(e,i,r)}else if(n===void 0&&o.children.length>=0){let t=s,n=o.children[t],i;if(o.children.length===1)i={offset:o.offset+1,length:o.length-2,content:``};else if(o.children.length-1===t){let e=o.children[t-1],n=e.offset+e.length;i={offset:n,length:o.offset+o.length-2-n,content:``}}else i={offset:n.offset,length:o.children[t+1].offset-n.offset,content:``};return Ue(e,i,r)}else if(n!==void 0){let t,i=`${JSON.stringify(n)}`;if(!r.isArrayInsertion&&o.children.length>s){let e=o.children[s];t={offset:e.offset,length:e.length,content:i}}else if(o.children.length===0||s===0)t={offset:o.offset+1,length:0,content:o.children.length===0?i:i+`,`};else{let e=s>o.children.length?o.children.length:s,n=o.children[e-1];t={offset:n.offset+n.length,length:0,content:`,`+i}}return Ue(e,t,r)}else throw Error(`Can not ${n===void 0?`remove`:r.isArrayInsertion?`insert`:`modify`} Array index ${t} as length is not sufficient`)}else throw Error(`Can not add ${typeof s==`number`?`property`:`index`} to parent of type ${o.type}`)}function Ue(e,t,n){if(!n.formattingOptions)return[t];let r=We(e,t),i=t.offset,a=t.offset+t.content.length;if(t.length===0||t.content.length===0){for(;i>0&&!Pe(r,i-1);)i--;for(;a<r.length&&!Pe(r,a);)a++}let o=Ae(r,{offset:i,length:a-i},{...n.formattingOptions,keepLines:!1});for(let e=o.length-1;e>=0;e--){let t=o[e];r=We(r,t),i=Math.min(i,t.offset),a=Math.max(a,t.offset+t.length),a+=t.content.length-t.length}let s=e.length-(r.length-a)-i;return[{offset:i,length:s,content:r.substring(i,a)}]}function We(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var Ge;(function(e){e[e.None=0]=`None`,e[e.UnexpectedEndOfComment=1]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=2]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=3]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=4]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=5]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=6]=`InvalidCharacter`})(Ge||={});var Ke;(function(e){e[e.OpenBraceToken=1]=`OpenBraceToken`,e[e.CloseBraceToken=2]=`CloseBraceToken`,e[e.OpenBracketToken=3]=`OpenBracketToken`,e[e.CloseBracketToken=4]=`CloseBracketToken`,e[e.CommaToken=5]=`CommaToken`,e[e.ColonToken=6]=`ColonToken`,e[e.NullKeyword=7]=`NullKeyword`,e[e.TrueKeyword=8]=`TrueKeyword`,e[e.FalseKeyword=9]=`FalseKeyword`,e[e.StringLiteral=10]=`StringLiteral`,e[e.NumericLiteral=11]=`NumericLiteral`,e[e.LineCommentTrivia=12]=`LineCommentTrivia`,e[e.BlockCommentTrivia=13]=`BlockCommentTrivia`,e[e.LineBreakTrivia=14]=`LineBreakTrivia`,e[e.Trivia=15]=`Trivia`,e[e.Unknown=16]=`Unknown`,e[e.EOF=17]=`EOF`})(Ke||={});const qe=Ie,Je=Be;var Ye;(function(e){e[e.InvalidSymbol=1]=`InvalidSymbol`,e[e.InvalidNumberFormat=2]=`InvalidNumberFormat`,e[e.PropertyNameExpected=3]=`PropertyNameExpected`,e[e.ValueExpected=4]=`ValueExpected`,e[e.ColonExpected=5]=`ColonExpected`,e[e.CommaExpected=6]=`CommaExpected`,e[e.CloseBraceExpected=7]=`CloseBraceExpected`,e[e.CloseBracketExpected=8]=`CloseBracketExpected`,e[e.EndOfFileExpected=9]=`EndOfFileExpected`,e[e.InvalidCommentToken=10]=`InvalidCommentToken`,e[e.UnexpectedEndOfComment=11]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=12]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=13]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=14]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=15]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=16]=`InvalidCharacter`})(Ye||={});function Xe(e,t,n,r){return He(e,t,n,r)}function Ze(e,t){let n=t.slice(0).sort((e,t)=>{let n=e.offset-t.offset;return n===0?e.length-t.length:n}),r=e.length;for(let t=n.length-1;t>=0;t--){let i=n[t];if(i.offset+i.length<=r)e=We(e,i);else throw Error(`Overlapping edit`);r=i.offset}return e}var Qe=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}languageService;constructor(){this.languageService=(0,h.getLanguageService)({schemaRequestService:async e=>JSON.stringify(ye)}),this.languageService.configure({allowComments:!0,schemas:[{fileMatch:[`**`+E.Config],uri:ye.$schema??``,schema:ye},{fileMatch:[`**`+E.CsharpConfig],uri:be.$schema??``,schema:be},{fileMatch:[`**`+E.PhpConfig],uri:xe.$schema??``,schema:xe}]})}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;if(t.uri.endsWith(E.Config)){let e=[];return await this.getConfig(t,e),e}let n=this.languageService.parseJSONDocument(t),r=await this.languageService.doValidation(t,n);if(r.length==0){let e=Je(t.getText());try{return JSON.parse(e),r}catch{r.push(ns(t,`Can't parse the json`,1001))}}for(let e of r)e.severity=m.DiagnosticSeverity.Error;return r}getDependencyKeyRange(e,t,n){let r=e.documentUser,i=this.languageService.parseJSONDocument(r).root;if(i?.type!==`object`)return null;let a=(e,t)=>e.properties.find(e=>e.keyNode.value===t)?.valueNode,o=e=>{let t=a(e,`dependencies`);if(t?.type!==`object`)return null;let i=t.properties.find(e=>e.keyNode.value===n)?.keyNode;return i?m.Range.create(r.positionAt(i.offset),r.positionAt(i.offset+i.length)):null},s=a(i,`build`);if(s?.type===`array`&&t){for(let e of s.items)if(e.type===`object`&&a(e,`name`)?.value===t){let t=o(e);if(t)return t}}return o(i)}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,t=[]){let n=`documentUser`in e?e.documentUser:e,r=this.languageService.parseJSONDocument(n),i=await this.languageService.doValidation(n,r,void 0,ye);if(t.push(...i.map(e=>({...e,severity:m.DiagnosticSeverity.Error}))),i.length==0){let e=Je(n.getText());try{let i=JSON.parse(e);return i=this.prepareConfigFile(n.uri,i,n,r.root,t),t.length===0?i:null}catch{t.push(ns(n,`Can't parse the json`,1001))}}return null}getConfigPathRange(e,t,n,r=!1){let i=m.Range.create(e.positionAt(0),e.positionAt(e.getText().length)),a=t=>m.Range.create(e.positionAt(t.offset),e.positionAt(t.offset+t.length)),o=t,s=n,c=!0;for(;s.length>0;){if(s.startsWith(`.`)){if(c||(s=s.slice(1),!s||s.startsWith(`.`)||s.startsWith(`[`)))return i}else if(!c&&!s.startsWith(`[`))return i;let e=/^\[(\d+)\]/.exec(s),t=/^\[("(?:\\.|[^"\\])*")\]/.exec(s),n=/^[^.[\]]+/.exec(s);if(e){if(o?.type===`array`)o=o.items[Number(e[1])];else if(!r||Number(e[1])!==0||!o)return i;s=s.slice(e[0].length)}else if(t||n){if(o?.type!==`object`)return r&&o?a(o):i;let e=n?.[0];if(t)try{e=JSON.parse(t[1])}catch{return i}let c=o.properties.find(t=>t.keyNode.value===e)?.valueNode;if(!c)return r?a(o):i;o=c,s=s.slice((t??n)[0].length)}else return i;if(!o)return i;c=!1}return o?a(o):i}prepareConfigFile(e,t,n,r,i){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`}if(t.dependencies)for(let n in t.dependencies)t.dependencies[n].uri&&(t.dependencies[n].uri=this.replaceEnvVar(t.dependencies[n].uri,us(e)));let a=(e,t,a)=>{for(let[o,s]of Object.entries(e??{}))typeof s!=`object`||!s?.uri||(a.has(s.uri)&&a.get(s.uri)!==o?i.push({range:this.getConfigPathRange(n,r,`${t}[${JSON.stringify(o)}].uri`),severity:m.DiagnosticSeverity.Error,source:`Aventus`,message:`Dependencies ${a.get(s.uri)} and ${o} use the same URI: ${s.uri}`}):a.set(s.uri,o))},o=new Map;a(t.dependencies,`dependencies`,o);let s=[],c=new Set;for(let l=0;l<t.build.length;l++){let u=this.prepareBuild(e,t.build[l],t);c.has(u.fullname)&&i.push({range:this.getConfigPathRange(n,r,`build[${l}].name`),severity:m.DiagnosticSeverity.Error,source:`Aventus`,message:`Duplicate build: ${u.fullname}`}),c.add(u.fullname),a(u.dependencies,`build[${l}].dependencies`,new Map(o)),s.push(u)}t.build=s;let l=new Map;for(let e=0;e<t.build.length;e++){let n=t.build[e];if(!n.disabled)for(let t=0;t<n.compile.length;t++)for(let r=0;r<n.compile[t].output.length;r++){let i=n.compile[t].output[r],a=new Map;for(let[n,o]of Object.entries(i)){let i=`build[${e}].compile[${t}].output[${r}][${JSON.stringify(n)}].path`,s=o.path.replace(/\\/g,`/`).toLowerCase();a.has(s)||a.set(s,[]),a.get(s).push(i)}for(let[e,t]of a.entries())l.has(e)||l.set(e,[]),l.get(e).push(t)}}for(let[e,t]of l.entries())if(t.length>1)for(let a of t)for(let t of a)i.push({range:this.getConfigPathRange(n,r,t,!0),severity:m.DiagnosticSeverity.Error,source:`Aventus`,message:`Multiple active compilation units write the same JavaScript output: ${e}`});if(t.static){let n=[];for(let r of t.static){let t=this.prepareStatic(e,r),i=(0,f.resolve)(t.inputPathFolder),a=t.outputPathFolder.find(e=>{let t=(0,f.relative)(i,(0,f.resolve)(e));return t===``||t!==`..`&&!t.startsWith(`..`+f.sep)&&!(0,f.isAbsolute)(t)});if(a){$.showErrorMessage(`Static ${t.name}: output ${a} is inside input ${t.inputPathFolder}`);continue}n.push(t)}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=g.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)(L(t)+e)):e=(0,f.normalize)(e)),e}prepareBuild(e,t,n){let r=us(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)(L(r)+e+n).replace(/\\/g,`/`);a=ps(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)(L($.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)(L($.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)(L(r)+n+e).replace(/\\/g,`/`),s=a.replace(`*`,``);s.endsWith(`/`)&&(s=s.slice(0,-1)),t.srcPath.push(s),a=ps(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)(L(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)(L(r)+t+n).replace(/\\/g,`/`);a=ps(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)(L(r)+t+e).replace(/\\/g,`/`);a=ps(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)(L(r)+e+t.namespaceRoot).replace(/\\/g,`/`)}return t.i18n,t}prepareStatic(e,t){let n=us(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)(L(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=(0,f.normalize)(e).replace(/\\/g,`/`),t.outputPathFolder.includes(e)||t.outputPathFolder.push(e);return t}defaultConfigValue(){return{module:``,hideWarnings:F.getInstance().settings.defaultHideWarnings,forceDocumentation:F.getInstance().settings.defaultForceDocumentation,version:`1.0.0`,componentPrefix:``,tags:[],dependencies:{},build:[],static:[],avoidParsingInsideTags:[],aliases:{},namespaceRules:{},namespaceRulesRegex:{},namespaceStrategy:`manual`,namespaceRoot:`./`,ideBuild:F.getInstance().settings.ideBuild}}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,forceDocumentation:e.forceDocumentation,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:``,ideBuild:e.ideBuild}}defaultConfigBuildStories(e,t){return{output:e+`/stories`,format:`all`}}defaultConfigBuildDependencyValue(e){return{}}};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 D(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 O=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 L(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 us(this.uri)}get folderPath(){return us(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=D();for(;this.onGetBuildCb[t]!=null;)t=D();return this.onGetBuildCb[t]=e,t}removeOnGetBuild(e){delete this.onGetBuildCb[e]}onValidateCb={};validationRequest=0;deleted=!1;get isDeleted(){return this.deleted}async validate(e=!0){if(this.deleted)return[];let t=this.versionUser,n=++this.validationRequest,r={};for(let e in this.onValidateCb){let i=await this.onValidateCb[e](this);if(this.deleted||this.versionUser!==t||n!==this.validationRequest)return[];for(let e of i){let t=e.message+`**`+e.range.start.line+`:`+e.range.start.character+`,`+e.range.end.line+`:`+e.range.end.character;r[t]||(r[t]=e)}}if(this.deleted||this.versionUser!==t||n!==this.validationRequest)return[];if(e)if(F.getInstance().settings.errorByBuild){let e=this.getBuild();if(e==null)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(r)});else for(let t of e)$.sendDiagnostics({uri:this.uri,diagnostics:Object.values(r)},t)}else $.sendDiagnostics({uri:this.uri,diagnostics:Object.values(r)});return Object.values(r)}onValidate(e){let t=D();for(;this.onValidateCb[t]!=null;)t=D();return this.onValidateCb[t]=e,t}removeOnValidate(e){delete this.onValidateCb[e]}onContentChangeCb={};delayValidate;waitingDocContentChange={};resolveContentChange={};activeContentChanges=new Set;startContentChange(e){let t=this.triggerContentChangeNoBuffer(e);this.activeContentChanges.add(t),t.then(()=>this.activeContentChanges.delete(t),()=>this.activeContentChanges.delete(t))}triggerContentChange(e){return new Promise(t=>{if(this.deleted||e.version<=this.versionUser){t();return}if(!this.triggerCanContentChange(e)){t();return}setTimeout(()=>{let n=this.waitingDocContentChange[e.uri],r=!0;if((this.deleted||e.version<=this.versionUser||n&&typeof n!=`boolean`&&e.version<=n.version)&&(r=!1),!r){t();return}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.startContentChange(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.deleted||(this.delayValidate&&clearTimeout(this.delayValidate),this.delayValidate=setTimeout(()=>{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`&&r.version>this.versionUser?(this.waitingDocContentChange[e.uri]=!0,this.startContentChange(r)):delete this.waitingDocContentChange[e.uri]}onContentChange(e){let t=D();for(;this.onContentChangeCb[t]!=null;)t=D();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=D();for(;this.onCanContentChangeCb[t]!=null;)t=D();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,T.TypeScript,this.documentUser.version+1,t);await this.triggerContentChange(n)}onSaveCb={};async triggerSave(){for(let e in this.onSaveCb){if(this.deleted)return;await this.onSaveCb[e](this)}}onSave(e){let t=D();for(;this.onSaveCb[t]!=null;)t=D();return this.onSaveCb[t]=e,t}removeOnSave(e){delete this.onSaveCb[e]}onDeleteCb={};async triggerDelete(){this.deleted=!0,this.delayValidate&&=(clearTimeout(this.delayValidate),void 0);for(let e of Object.values(this.resolveContentChange))for(let t of Object.values(e))for(let e of t)e();this.resolveContentChange={},this.waitingDocContentChange={},await Promise.allSettled(this.activeContentChanges);let e=[];for(let t in this.onDeleteCb)e.push(this.onDeleteCb[t](this));try{await Promise.all(e)}finally{this.removeAllCallbacks()}}removeAllCallbacks(){this.onGetBuildCb={},this.onValidateCb={},this.onCanContentChangeCb={},this.onReferencesCb={},this.onCodeLensCb={},this.onRenameCb={},this.onCodeActionCb={},this.onCompletionCb={},this.onCompletionResolveCb={},this.onContentChangeCb={},this.onDefinitionCb={},this.onDeleteCb={},this.onFormattingCb={},this.onHoverCb={},this.onSaveCb={}}onDelete(e){let t=D();for(;this.onDeleteCb[t]!=null;)t=D();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=new Map;for(let e of r)for(let t of e.items){let{data:e,...n}=t,r=JSON.stringify(n);i.has(r)||i.set(r,t)}return t.items=Array.from(i.values()),t}onCompletion(e){let t=D();for(;this.onCompletionCb[t]!=null;)t=D();return this.onCompletionCb[t]=e,t}removeOnCompletion(e){delete this.onCompletionCb[e]}onCompletionResolveCb={};async getCompletionResolve(e){let t=e;for(let e in this.onCompletionResolveCb)t=await this.onCompletionResolveCb[e](this,t);return t}onCompletionResolve(e){let t=D();for(;this.onCompletionResolveCb[t]!=null;)t=D();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=D();for(;this.onHoverCb[t]!=null;)t=D();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=D();for(;this.onDefinitionCb[t]!=null;)t=D();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=D();for(;this.onFormattingCb[t]!=null;)t=D();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=D();for(;this.onCodeActionCb[t]!=null;)t=D();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=D();for(;this.onReferencesCb[t]!=null;)t=D();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=D();for(;this.onCodeLensCb[t]!=null;)t=D();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=D();for(;this.onRenameCb[t]!=null;)t=D();return this.onRenameCb[t]=e,t}removeOnRename(e){delete this.onRenameCb[e]}},it=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 O&&await this.file.validate()}async triggerSave(){this.file instanceof O&&await this.file.triggerSave()}async triggerDelete(){this.file instanceof O&&await this.file.triggerDelete()}async triggerContentChange(e){this.file instanceof O&&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._build&&!this.build.forceDocumentation&&(e=e.filter(e=>e.code!=1027)),this.oldResult=e,e}async _onDelete(){await this.onDelete(),this.removeEvents()}},at=o(((e,t)=>{
|
|
16
16
|
/*!
|
|
17
17
|
* etag
|
|
18
18
|
* Copyright(c) 2014-2016 Douglas Christopher Wilson
|
|
@@ -240,7 +240,7 @@ const preview: Preview = {
|
|
|
240
240
|
},
|
|
241
241
|
};
|
|
242
242
|
|
|
243
|
-
export default preview;`}var Zt=class e{static getFullname(e){let t=e.fullName.replace(/\./g,`/`),n=!1,r=e.build.buildConfig,i=e=>{e===``||(t=e.endsWith(`/`)?e+t:e+`/`+t)};return e.storieDecorator&&(e.storieDecorator.group!==void 0&&(t=e.storieDecorator.group?e.storieDecorator.group+`/`+e.name:e.name),e.storieDecorator.prefix!==void 0&&(n=!0,i(e.storieDecorator.prefix))),!n&&r.stories?.prefix!==void 0&&i(r.stories.prefix),t}build;buildConfig;constructor(e,t){this.build=e,this.buildConfig=t}async check(){await this.readEnvStoryBook()}async write(e,t=!1){t&&this.clear();for(let t in e){let n=e[t];if(n.fileParsed){for(let e in n.fileParsed.classes){let t=n.fileParsed.classes[e];await this.writeStory(t,n)}for(let e in n.fileParsed.aliases){let t=n.fileParsed.aliases[e];await this.writeStory(t)}for(let e in n.fileParsed.enums){let t=n.fileParsed.enums[e];await this.writeStory(t)}for(let e in n.fileParsed.functions){let t=n.fileParsed.functions[e];await this.writeStory(t)}for(let e in n.fileParsed.variables){let t=n.fileParsed.variables[e];await this.writeStory(t)}}}}clear(){this.buildConfig.stories&&(0,u.rmSync)((0,f.join)(this.buildConfig.stories.output,`auto`),{recursive:!0,force:!0})}async writeStory(t,n){if(!t.storieContent||!this.buildConfig.stories)return;let r=t.storieContent,i=(0,f.join)(this.buildConfig.stories.output,`generated`),a=(0,f.join)(this.buildConfig.stories.output,`auto`,...t.fullName.split(`.`)),o=L(
|
|
243
|
+
export default preview;`}var Zt=class e{static getFullname(e){let t=e.fullName.replace(/\./g,`/`),n=!1,r=e.build.buildConfig,i=e=>{e===``||(t=e.endsWith(`/`)?e+t:e+`/`+t)};return e.storieDecorator&&(e.storieDecorator.group!==void 0&&(t=e.storieDecorator.group?e.storieDecorator.group+`/`+e.name:e.name),e.storieDecorator.prefix!==void 0&&(n=!0,i(e.storieDecorator.prefix))),!n&&r.stories?.prefix!==void 0&&i(r.stories.prefix),t}build;buildConfig;constructor(e,t){this.build=e,this.buildConfig=t}async check(){await this.readEnvStoryBook()}async write(e,t=!1){t&&this.clear();for(let t in e){let n=e[t];if(n.fileParsed){for(let e in n.fileParsed.classes){let t=n.fileParsed.classes[e];await this.writeStory(t,n)}for(let e in n.fileParsed.aliases){let t=n.fileParsed.aliases[e];await this.writeStory(t)}for(let e in n.fileParsed.enums){let t=n.fileParsed.enums[e];await this.writeStory(t)}for(let e in n.fileParsed.functions){let t=n.fileParsed.functions[e];await this.writeStory(t)}for(let e in n.fileParsed.variables){let t=n.fileParsed.variables[e];await this.writeStory(t)}}}}clear(){this.buildConfig.stories&&(0,u.rmSync)((0,f.join)(this.buildConfig.stories.output,`auto`),{recursive:!0,force:!0})}async writeStory(t,n){if(!t.storieContent||!this.buildConfig.stories)return;let r=t.storieContent,i=(0,f.join)(this.buildConfig.stories.output,`generated`),a=(0,f.join)(this.buildConfig.stories.output,`auto`,...t.fullName.split(`.`)),o=L(us(I(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 N&&n.componentClassName==t.name&&n.fileParsed?.classes[n.componentClassName]&&!n.fileParsed.classes[n.componentClassName].isAbstract&&!e},c=async()=>{let e=qt();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`,`
|
|
244
244
|
<div>
|
|
245
245
|
<Title>Live</Title>
|
|
246
246
|
<Canvas />
|
|
@@ -248,11 +248,11 @@ export default preview;`}var Zt=class e{static getFullname(e){let t=e.fullName.r
|
|
|
248
248
|
</div>`):this.replaceVariable(e,`live`,``),e=this.replaceVariable(e,`blocks`,`import { Canvas, Controls, Title } from '@storybook/addon-docs/blocks'`);let i=r.kind[0].toUpperCase()+r.kind.slice(1);e=this.replaceVariable(e,`render`,`import { Story${i}Render } from '@aventusjs/storybook-render/AventusStorybook'`),await this.writeFile(a+`_.mdx`,e)},l=e=>{let t=`{
|
|
249
249
|
`;for(let n in e){let r=e[n];r==``&&(r=`""`),t+=` "`+n+`":`+r+`,
|
|
250
250
|
`}return t+=`}`,t};await c(),await(async()=>{let o=!0;t.storieDecorator&&t.storieDecorator.noDefaultStory&&(o=!1);let c=s()?Yt():Jt(),u=t.name,d=e.getFullname(t);if(c=this.replaceVariable(c,`name`,u),c=this.replaceVariable(c,`fullname`,d),c=this.replaceVariable(c,`description`,JSON.stringify(t.documentation?.definitions.join(`
|
|
251
|
-
`)??``)),c=this.replaceVariable(c,`aventus`,`aventus: `+JSON.stringify(r,null,2)+`,`),c=this.replaceVariable(c,`defaultStory`,o?`export const DefaultStory: Story = {}`:``),n instanceof N){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=
|
|
252
|
-
`))}else c=this.replaceVariable(c,`argTypes`,``),c=this.replaceVariable(c,`args`,``);await this.writeFile(a+`.stories.ts`,c)})()}async readEnvStoryBook(){if(!this.buildConfig.stories)return;(0,u.existsSync)(this.buildConfig.stories.output)||(0,u.mkdirSync)(this.buildConfig.stories.output,{recursive:!0});let e=this.buildConfig.stories.output,t=`@`+this.buildConfig.module,n=this.buildConfig.module;this.buildConfig.name&&(t+=`/`+this.buildConfig.name,n+=` `+this.buildConfig.name);let r={name:(t+`_storybook`).toLowerCase(),displayName:n+`_storybook`,description:`Aventus storybook for `+t,version:this.buildConfig.version};if((0,u.readdirSync)(this.buildConfig.stories.output).length==0){let t=$.extensionPath+f.sep+`templates`+f.sep+`storybook`,n=(0,u.readdirSync)(t,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).sort(),i=``,a=async t=>{let n=(0,u.readdirSync)(t);for(let o of n){let n=t+f.sep+o,s=n.replace(i,e);for(let e in r){let t=RegExp(`\\$\\{\\{`+e+`\\}\\}`,`gm`);s=s.replace(t,r[e])}if(s=(0,f.normalize)(s),(0,u.statSync)(n).isDirectory()){if(o==`.git`)continue;(0,u.mkdirSync)(s),await a(n)}else if(/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(n.toLowerCase()))(0,u.copyFileSync)(n,s);else{let e=(0,u.readFileSync)(n,`utf-8`);for(let t in r){let n=RegExp(`\\$\\{\\{`+t+`\\}\\}`,`gm`);e=e.replace(n,r[t])}if(o==`package.json`){let t=JSON.parse(e);t.devDependencies||={};for(let e of this.build.externalPackageInformation.filesUri){let n=this.build.externalPackageInformation.getByUri(e);n&&n.npmUri&&n.name!=this.buildConfig.fullname&&(t.devDependencies[n.npmUri]=`^`+n.versionTxt)}t.devDependencies=Object.keys(t.devDependencies).sort().reduce((e,n)=>(e[n]=t.devDependencies[n],e),{}),e=JSON.stringify(t,null,4)}await this.writeFile(s,e)}}};if(n.length===0){$.showErrorMessage(`No Storybook template found in ${t}`);return}let o=n[0];if(n.length>1){let e=await $.Select(n.map(e=>({label:e})),{title:`Select a Storybook template`});if(!e)return;if(!n.includes(e.label)){$.showErrorMessage(`Unknown Storybook template: ${e.label}`);return}o=e.label}i=(0,f.join)(t,o),await a(i)}let i=(0,f.join)(this.buildConfig.stories.workspace?(0,f.resolve)(this.build.project.getConfigFile().folderPath,this.buildConfig.stories.workspace):e,`.storybook`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0});let a=(0,f.join)(i,`main.ts`);if(!(0,u.existsSync)(a)){let e=Kt(),t=
|
|
251
|
+
`)??``)),c=this.replaceVariable(c,`aventus`,`aventus: `+JSON.stringify(r,null,2)+`,`),c=this.replaceVariable(c,`defaultStory`,o?`export const DefaultStory: Story = {}`:``),n instanceof N){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=_s(I((0,f.join)(i,...r.namespace.split(`.`))),I(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(`
|
|
252
|
+
`))}else c=this.replaceVariable(c,`argTypes`,``),c=this.replaceVariable(c,`args`,``);await this.writeFile(a+`.stories.ts`,c)})()}async readEnvStoryBook(){if(!this.buildConfig.stories)return;(0,u.existsSync)(this.buildConfig.stories.output)||(0,u.mkdirSync)(this.buildConfig.stories.output,{recursive:!0});let e=this.buildConfig.stories.output,t=`@`+this.buildConfig.module,n=this.buildConfig.module;this.buildConfig.name&&(t+=`/`+this.buildConfig.name,n+=` `+this.buildConfig.name);let r={name:(t+`_storybook`).toLowerCase(),displayName:n+`_storybook`,description:`Aventus storybook for `+t,version:this.buildConfig.version};if((0,u.readdirSync)(this.buildConfig.stories.output).length==0){let t=$.extensionPath+f.sep+`templates`+f.sep+`storybook`,n=(0,u.readdirSync)(t,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).sort(),i=``,a=async t=>{let n=(0,u.readdirSync)(t);for(let o of n){let n=t+f.sep+o,s=n.replace(i,e);for(let e in r){let t=RegExp(`\\$\\{\\{`+e+`\\}\\}`,`gm`);s=s.replace(t,r[e])}if(s=(0,f.normalize)(s),(0,u.statSync)(n).isDirectory()){if(o==`.git`)continue;(0,u.mkdirSync)(s),await a(n)}else if(/\.(gif|jpe?g|tiff?|png|webp|bmp)$/i.test(n.toLowerCase()))(0,u.copyFileSync)(n,s);else{let e=(0,u.readFileSync)(n,`utf-8`);for(let t in r){let n=RegExp(`\\$\\{\\{`+t+`\\}\\}`,`gm`);e=e.replace(n,r[t])}if(o==`package.json`){let t=JSON.parse(e);t.devDependencies||={};for(let e of this.build.externalPackageInformation.filesUri){let n=this.build.externalPackageInformation.getByUri(e);n&&n.npmUri&&n.name!=this.buildConfig.fullname&&(t.devDependencies[n.npmUri]=`^`+n.versionTxt)}t.devDependencies=Object.keys(t.devDependencies).sort().reduce((e,n)=>(e[n]=t.devDependencies[n],e),{}),e=JSON.stringify(t,null,4)}await this.writeFile(s,e)}}};if(n.length===0){$.showErrorMessage(`No Storybook template found in ${t}`);return}let o=n[0];if(n.length>1){let e=await $.Select(n.map(e=>({label:e})),{title:`Select a Storybook template`});if(!e)return;if(!n.includes(e.label)){$.showErrorMessage(`Unknown Storybook template: ${e.label}`);return}o=e.label}i=(0,f.join)(t,o),await a(i)}let i=(0,f.join)(this.buildConfig.stories.workspace?(0,f.resolve)(this.build.project.getConfigFile().folderPath,this.buildConfig.stories.workspace):e,`.storybook`);(0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0});let a=(0,f.join)(i,`main.ts`);if(!(0,u.existsSync)(a)){let e=Kt(),t=_s(I(this.buildConfig.stories.output),I(a));e=this.replaceVariable(e,`path`,t),await this.writeFile(a,e)}let o=(0,f.join)(i,`preview.ts`);if(!(0,u.existsSync)(o)){let e=Xt();await this.writeFile(o,e)}}replaceVariable(e,t,n){let r=RegExp(`\\$`+t+`\\$`,`g`);return e=e.replace(r,()=>n),e}async writeFile(e,t){await Ts(e,t,`storybook`)}},Qt=class e{static registerNpmImport(e,t,n){let r=m.Range.create(t.document.positionAt(e.getStart()),t.document.positionAt(e.getEnd())),i=t.build.npmBuilder.register(t.document.uri,n,r)??[];return t.errors.push(...i),i.length===0}static Parse(t,n,r){if(t.importClause){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.phaseModifier});r.importsLocal[n.alias??n.name]=n}else if(!t.importClause.phaseModifier){let e=t.importClause.name.text;this.registerNpmImport(t,r,{libName:`default`,uri:i,alias:e})&&(r.npmImports[e]={uri:i,nameInsideLib:`default`})}}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:T.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`error can't use namespace import`,`
|
|
253
253
|
`)});else{let n=t.importClause.namedBindings.name.getText();t.importClause.phaseModifier||this.registerNpmImport(t,r,{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=new e({parserInfo:r,moduleName:i,identifier:n.propertyName?n.propertyName:n.name,alias:n.propertyName?n.name.getText():void 0,isTypeImport:n.isTypeOnly||!!t.importClause.phaseModifier});r.importsLocal[a.alias??a.name]=a}else if(!i.startsWith(`.`)&&i.includes(E.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:T.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`error can't use renamed import`,`
|
|
254
254
|
`)});else{let n=e.name.getText(),a=i.split(`:`);if(a.length>1){let e=a[1].replace(E.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:T.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`The package import is malformated`,`
|
|
255
|
-
`)})}else for(let e of t.importClause.namedBindings.elements){let n=e.name.getText(),a=n;e.propertyName&&(a=e.propertyName.getText()),!t.importClause.phaseModifier&&!e.isTypeOnly&&this.registerNpmImport(t,r,{libName:a,uri:i,alias:n})&&(r.npmImports[n]={uri:i,nameInsideLib:a})}}}}}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;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=I((0,f.normalize)(fs(L(this.parserInfo.document.uri))+`/`+e.moduleName))):(this.name=e.name,this.nameStart=0,this.nameEnd=0,this.isTypeImport=!1,t=e.moduleUri);let n=j.getCached(t,this.parserInfo.build);if(!n){let e=z.getInstance().getByUri(t);if(e)n=j.parse(e,!1,this.parserInfo.build);else{let e=L(t),r=(0,u.existsSync)(e)?(0,u.readFileSync)(e,`utf8`):``,i=new O(d.TextDocument.create(t,T.TypeScript,1,r));n=j.parse(i,!1,this.parserInfo.build)}}if(n.isReady){let e=n.getBaseInfo(this.name);e?this.info=e:j.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]=[],n.onReady(()=>{this.asyncImportLocal(n,this.alias??this.name)})}}asyncImportLocal(e,t){let n=e.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 j.addError(this.nameStart,this.nameEnd,`Can't load `+e.document.uri+` `+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}},A=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=r.getText(),o=j.getBaseInfo(i,this.build);if(o&&a==o.fullName)this.addDependencyName(o.fullName,n,r.getStart(),r.getEnd());else if(this.build.externalPackageInformation.getByFullName(a))this.addDependencyName(a,n,r.getStart(),r.getEnd());else{let e=r.expression.getText();e!=`this`&&!e.includes(`.`)&&(j.hasLocal(e)||j.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(`.`)&&(j.getBaseInfo(t,this.build)||j.hasLocal(t)||j.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 k(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 k(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=ys(I((0,f.join)(i,...t.namespace.split(`.`))),I(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=Os(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=Os(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(E.Config,``),t=L(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 k(e.default),this);r&&(n.default=r);let i=this.transformTypeForStory(new k(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 k(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 k(r.type),t),i=this.transformTypeForStory(new k(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 k(r),t);i&&(n.array=i)}else{let n=t.document.positionAt(e.getStart());$.error(`need implements for `+p.SyntaxKind[e.kind]+` `+t.fileUri+`:`+n.line+`:`+n.character)}}),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 k(e.constraint),this);t&&(r.constraint=t)}if(e.default){let t=this.transformTypeForStory(new k(e.default),this);t&&(r.default=t)}return r}loadParameterForStory(e,t){let n=e.name.getText(),r={name:n},i=this.transformTypeForStory(new k(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(`
|
|
255
|
+
`)})}else for(let e of t.importClause.namedBindings.elements){let n=e.name.getText(),a=n;e.propertyName&&(a=e.propertyName.getText()),!t.importClause.phaseModifier&&!e.isTypeOnly&&this.registerNpmImport(t,r,{libName:a,uri:i,alias:n})&&(r.npmImports[n]={uri:i,nameInsideLib:a})}}}}}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;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=I((0,f.normalize)(us(L(this.parserInfo.document.uri))+`/`+e.moduleName))):(this.name=e.name,this.nameStart=0,this.nameEnd=0,this.isTypeImport=!1,t=e.moduleUri);let n=j.getCached(t,this.parserInfo.build);if(!n){let e=z.getInstance().getByUri(t);if(e)n=j.parse(e,!1,this.parserInfo.build);else{let e=L(t),r=(0,u.existsSync)(e)?(0,u.readFileSync)(e,`utf8`):``,i=new O(d.TextDocument.create(t,T.TypeScript,1,r));n=j.parse(i,!1,this.parserInfo.build)}}if(n.isReady){let e=n.getBaseInfo(this.name);e?this.info=e:j.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]=[],n.onReady(()=>{this.asyncImportLocal(n,this.alias??this.name)})}}asyncImportLocal(e,t){let n=e.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 j.addError(this.nameStart,this.nameEnd,`Can't load `+e.document.uri+` `+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}},A=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=r.getText(),o=j.getBaseInfo(i,this.build);if(o&&a==o.fullName)this.addDependencyName(o.fullName,n,r.getStart(),r.getEnd());else if(this.build.externalPackageInformation.getByFullName(a))this.addDependencyName(a,n,r.getStart(),r.getEnd());else{let e=r.expression.getText();e!=`this`&&!e.includes(`.`)&&(j.hasLocal(e)||j.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(`.`)&&(j.getBaseInfo(t,this.build)||j.hasLocal(t)||j.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 k(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 k(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=_s(I((0,f.join)(i,...t.namespace.split(`.`))),I(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=Es(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=Es(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(E.Config,``),t=L(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 k(e.default),this);r&&(n.default=r);let i=this.transformTypeForStory(new k(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 k(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 k(r.type),t),i=this.transformTypeForStory(new k(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 k(r),t);i&&(n.array=i)}else{let n=t.document.positionAt(e.getStart());$.error(`need implements for `+p.SyntaxKind[e.kind]+` `+t.fileUri+`:`+n.line+`:`+n.character)}}),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 k(e.constraint),this);t&&(r.constraint=t)}if(e.default){let t=this.transformTypeForStory(new k(e.default),this);t&&(r.default=t)}return r}loadParameterForStory(e,t){let n=e.name.getText(),r={name:n},i=this.transformTypeForStory(new k(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(`
|
|
256
256
|
`))}},en=class extends A{node;type;constructor(e,t,n){if(super(e,t,n),!this.documentation){let t=e.getFullText().match(/\/\*\*[\s\S]*?\*\//g)?.at(-1);if(t){let e=new Gt((0,p.createSourceFile)(`alias-doc.ts`,t+`
|
|
257
257
|
type Alias = unknown;`,p.ScriptTarget.Latest,!0).statements[0]);e.hasDoc&&(this.documentation=e)}}this.node=e,this.type=new k(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 k(this.node.type),this);if(t&&(e.type=t),this.node.typeParameters){e.generics=[];for(let t of this.node.typeParameters)e.generics.push(this.loadGenericForStory(t))}return e}},tn=class e{static is(t){return t.name==`NoCompile`?new e:null}},nn=class e{static is(t){return t.name==`BindThis`?new e:null}},rn=class{fullStart=0;start=0;end=0;name=``;nameStart=0;nameEnd=0;content=``;documentation;decorators=[];_class;accessibilityModifierTransformation;mustBeCompiled=!0;isStatic=!1;isOverride=!1;isAbstract=!1;isAsync=!1;isPrivate=!1;isProtected=!1;isBindThis=!1;deprecated=!1;deprecatedMsg=``;node;returnType;get compiledContent(){return A.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return A.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return A.getContentNpm(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}constructor(e,t){this.node=e,this._class=t,this.fullStart=e.getFullStart(),this.start=e.getStart(),this.end=e.getEnd(),this.name=e.name.getText(),this.nameStart=e.name.getStart(),this.nameEnd=e.name.getEnd(),this.content=e.getText(),this.decorators=Bt.buildDecorator(e,t),this.returnType=new k(e.type);let n=new Gt(e);n.hasDoc&&(this.documentation=n),this.loadAccessibilityModifier(e);let r=null;for(let e of this.decorators)tn.is(e)?this.mustBeCompiled=!1:(r=$t.is(e))&&(this.deprecated=!0,this.deprecatedMsg=r.msg)}loadAccessibilityModifier(e){let t=!1,n=null;for(let e of this.decorators){let t=Ht.is(e);if(t){n=t;continue}let r=Ut.is(e);if(r){n=r;continue}if(nn.is(e)){this.isBindThis=!0;continue}}if(e.modifiers)for(let r of e.modifiers)if(r.kind==p.SyntaxKind.PublicKeyword){if(n){let e=n instanceof Ht?`private`:`protected`;this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:e},e==`private`?this.isPrivate=!0:e==`protected`&&(this.isProtected=!0)}t=!0}else r.kind==p.SyntaxKind.ProtectedKeyword?(n instanceof Ht?(this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:`private`},this.isPrivate=!0):this.isProtected=!0,t=!0):r.kind==p.SyntaxKind.PrivateKeyword?(t=!0,this.isPrivate=!0):r.kind==p.SyntaxKind.OverrideKeyword?this.isOverride=!0:r.kind==p.SyntaxKind.StaticKeyword?this.isStatic=!0:r.kind==p.SyntaxKind.AbstractKeyword?this.isAbstract=!0:r.kind==p.SyntaxKind.AsyncKeyword&&(this.isAsync=!0);!this.documentation&&!this.isOverride&&!this.isPrivate&&j.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name,1027),t===!1&&!this._class.isInterface&&j.addError(this.nameStart,this.nameEnd,`A accessibility modifier (public / private / protected) is mandatory for `+this.name)}},an=class e{static is(t){if(t.name==`StoryValue`){if(t.arguments.length>0){let n=t.arguments[0];return new e(n.type===`string`?JSON.stringify(n.value):n.value)}return null}return null}value;constructor(e){this.value=e}},on=class e{static is(t){return t.name==`NoType`?new e:null}},sn=class{name=``;nameStart=0;nameEnd=0;documentation;decorators=[];defaultValueTxt=null;defaultValueStart=0;defaultValueEnd=0;content=``;type;prop;isAbstract=!1;isGet=!1;isSet=!1;isGetSet=!1;isInsideInterface=!1;isStatic=!1;isProtected=!1;isPrivate=!1;isOverride=!1;start=0;end=0;isNullable=!1;overrideNullable=!1;_class;accessibilityModifierTransformation;deprecated=!1;noType=!1;deprecatedMsg=``;get compiledContent(){return A.getContent(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentHotReload(){return A.getContentHotReload(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get compiledContentNpm(){return A.getContentNpm(this.content,this.start,this.end,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValue(){return this.defaultValueTxt===null?null:A.getContent(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueHotReload(){return this.defaultValueTxt===null?null:A.getContentHotReload(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}get defaultValueNpm(){return this.defaultValueTxt===null?null:A.getContentNpm(this.defaultValueTxt,this.defaultValueStart,this.defaultValueEnd,this._class.dependenciesLocations,this._class.compileTransformations)}defaultValueStory=null;constructor(e,t,n){this.isInsideInterface=t,this._class=n,this.prop=e,this.name=e.name.getText(),this.nameStart=e.name.getStart(),this.nameEnd=e.name.getEnd(),this.start=e.getStart(),this.end=e.getEnd(),this.content=e.getText(),this.decorators=Bt.buildDecorator(e,n),e.kind==p.SyntaxKind.GetAccessor?this.isGet=!0:e.kind==p.SyntaxKind.SetAccessor?this.isSet=!0:this.isGetSet=!0;let r=new Gt(e);r.hasDoc&&(this.documentation=r),e.questionToken&&(this.isNullable=!0),e.exclamationToken&&(this.overrideNullable=!0),this.loadAccessibilityModifier(e),this.type=this.loadType(e),this.loadInitializer(e);for(let e of this.decorators){let t=an.is(e);if(t){this.defaultValueStory=t.value;continue}let n=$t.is(e);if(n){this.deprecated=!0,this.deprecatedMsg=n.msg;continue}if(on.is(e)){this.noType=!0;continue}}}loadAccessibilityModifier(e){if(this.isInsideInterface)return;let t=!1,n=null;for(let e of this.decorators){let t=Ht.is(e);if(t){n=t;break}let r=Ut.is(e);if(r){n=r;break}}if(e.modifiers)for(let r of e.modifiers)if(r.kind==p.SyntaxKind.PublicKeyword){if(n){let e=n instanceof Ht?`private`:`protected`;this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:e},e==`private`?this.isPrivate=!0:e==`protected`&&(this.isProtected=!0)}t=!0}else r.kind==p.SyntaxKind.ProtectedKeyword?(n instanceof Ht?(this.accessibilityModifierTransformation={start:r.getStart(),end:r.getEnd(),newText:`private`},this.isPrivate=!0):this.isProtected=!0,t=!0):r.kind==p.SyntaxKind.PrivateKeyword?(t=!0,this.isPrivate=!0):r.kind==p.SyntaxKind.AbstractKeyword?this.isAbstract=!0:r.kind==p.SyntaxKind.OverrideKeyword?this.isOverride=!0:r.kind==p.SyntaxKind.StaticKeyword&&(this.isStatic=!0);!this.documentation&&!this.isOverride&&!this.isPrivate&&j.addWarning(this.nameStart,this.nameEnd,`You should add documentation for `+this.name,1027),t===!1&&j.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 k(t.type):t.initializer&&t.initializer.kind==p.SyntaxKind.ExpressionWithTypeArguments?new k(t.initializer):new k(null),n}loadInitializer(e){let t=e;t.initializer&&(this.defaultValueTxt=t.initializer.getText(),this.defaultValueStart=t.initializer.getStart(),this.defaultValueEnd=t.initializer.getEnd())}},cn=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 ln=[`Callback`,`Aventus.Callback`,`CallbackGroup`,`Aventus.CallbackGroup`];var un=class extends sn{propType=`Simple`;inParent=!1;arguments},dn=class e extends A{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+`);
|
|
258
258
|
`+this.extraConstructorCode.join(`
|
|
@@ -268,14 +268,14 @@ type Alias = unknown;`,p.ScriptTarget.Latest,!0).statements[0]);e.hasDoc&&(this.
|
|
|
268
268
|
`)}}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+`);
|
|
269
269
|
`+this.extraConstructorCode.join(`
|
|
270
270
|
`)+` }`}}else this.compileTransformations[t]={start:e,end:e,newText:`constructor() { `+this.extraConstructorCode.join(`
|
|
271
|
-
`)+` }`}}}loadConvertible(){let e=this;for(;e!=null;){for(let t of e.decorators){let e=cn.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(ln.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(`__`+
|
|
271
|
+
`)+` }`}}}loadConvertible(){let e=this;for(;e!=null;){for(let t of e.decorators){let e=cn.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(ln.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(`__`+Es(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(`
|
|
272
272
|
`)),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 k(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(`
|
|
273
273
|
`));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}},fn=class extends A{node;constructor(e,t,n){super(e,t,n,!1),this.infoType=6,this.node=e}defineStoryContent(){let e={kind:`enum`,name:this.name,properties:[]};this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e);let t=0;for(let n of this.node.members){let r={name:n.name.getText()},i;n.initializer?(i=(0,eval)(n.initializer.getText()),t=i+1):i=t++,r.value=i+``;let a=new Gt(n);a.hasDoc&&(r.documentation=a.definitions.join(`
|
|
274
274
|
`)),e.properties.push(r)}return e}},pn=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)}},mn=class extends A{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 k(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}},hn=class extends A{type=`var`;node;constructor(e,t,n,r){super(e,t,n),this.decorators=Bt.buildDecorator(r,this);let i=new Gt(r);if(!i.hasDoc){let e=r.getFullText().match(/\/\*\*[\s\S]*?\*\//g)?.at(-1);e&&(i=new Gt((0,p.createSourceFile)(`variable-doc.ts`,e+`
|
|
275
275
|
const value = 0;`,p.ScriptTarget.Latest,!0).statements[0]))}i.hasDoc&&(this.documentation=i),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=A.isExported(r),this.isInternalExported=this.isExported;for(let e of this.decorators)if(Ht.is(e)){this.isExported=!1;break}this.loadOnlyDependenciesRecu(e,0,!0)}defineStoryContent(){let e={kind:`variable`,name:this.name,modifier:this.type==`const`?`const`:this.type==`let`?`let`:`var`,value:this.node.initializer?.getText()};if(this.setNamespaceForStroy(e),this.setDocumentationForStroy(e),this.setAccessibilityForStroy(e),this.node.type){let t=new k(this.node.type),n=this.transformTypeForStory(t,this);n&&(e.type=n)}return e}},j=class e{static waitingUri={};static parsedByBuild=new WeakMap;static getCached(e,t,n=!1){let r=this.parsedByBuild.get(t)?.get(e);return n?r?.external:r?.internal}static invalidate(e,t){let n=this.parsedByBuild.get(t)?.get(e);n&&(n.internal=void 0)}static parse(t,n,r){let i=this.getCached(t.uri,r,n);return i&&i.parsedVersion===t.versionInternal?i:new e(t,n,r)}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:T.TypeScript,message:(0,p.flattenDiagnosticMessageText)(n,`
|
|
276
276
|
`)};this.currentParsingDoc.errors.push(r)}}static addWarning(e,t,n,r){if(this.currentParsingDoc&&!this.currentParsingDoc.isExternal){let i={range:m.Range.create(this.currentParsingDoc.document.positionAt(e),this.currentParsingDoc.document.positionAt(t)),severity:m.DiagnosticSeverity.Warning,source:T.TypeScript,message:(0,p.flattenDiagnosticMessageText)(n,`
|
|
277
277
|
`),code:r};this.currentParsingDoc.errors.push(i)}}static getBaseInfo(t,n,r){let i;if(r){let t=e.parsedByBuild.get(n)?.get(r);i=t?.internal??t?.external}else{if(!e.currentParsingDoc)return null;i=e.currentParsingDoc}if(!i)return null;if(i.internalObjects[t]){let e=i.getBaseInfo(t);if(e)return e}if(i.importsLocal[t]?.info)return i.importsLocal[t].info;if(i.packages[t]){let e=i.packages[t].fullname,n=i.build.externalPackageInformation.getByFullName(e);if(n){let t=this.getCached(n.uri,i.build,!0)?.getBaseInfoFullName(e);if(t)return t}}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;parsedVersion;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.parsedVersion=t.versionInternal,this.build=r,this.build.npmBuilder.unregister(t.documentUser.uri),this.file=t;let i=e.parsedByBuild.get(r);i||(i=new Map,e.parsedByBuild.set(r,i));let a=i.get(t.uri)??{};n?a.external=this:a.internal=this,i.set(t.uri,a),e.parsingDocs.push(this),this.content=t.documentInternal.getText(),this._document=t.documentInternal,this.isExternal=n;let o=(0,p.createSourceFile)(`sample.ts`,this.content,p.ScriptTarget.ESNext,!0);this.srcFile=o,this.quickLoadRoot(o),this.loadRoot(o),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;It(t.flags,p.NodeFlags.Namespace)&&t.body?(this.currentNamespace.push(t.name.getText()),this.quickLoadRoot(t),this.currentNamespace.splice(this.currentNamespace.length-1,1)):It(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:A.isExported(t),isStoryExported:this.build.buildConfig.stories?A.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:A.isExported(t),isStoryExported:this.build.buildConfig.stories?A.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:A.isExported(t),isStoryExported:this.build.buildConfig.stories?A.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:A.isExported(t),isStoryExported:this.build.buildConfig.stories?A.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:A.isExported(t),isStoryExported:this.build.buildConfig.stories?A.isStoryExported(t,this.build):!1,isCompiled:!0}}}else e.kind==p.SyntaxKind.ModuleBlock&&this.quickLoadRoot(e)})}loadRoot(t){(0,p.forEachChild)(t,t=>{if(t.kind==p.SyntaxKind.ImportDeclaration)this.loadImport(t);else if(t.kind==p.SyntaxKind.ExportDeclaration){let n=t;n.moduleSpecifier&&e.addError(n.getStart(),n.getEnd(),`Re-exports from another file are not supported by Aventus`)}else t.kind==p.SyntaxKind.ModuleDeclaration?this.loadNamespace(t):t.kind==p.SyntaxKind.ClassDeclaration||t.kind==p.SyntaxKind.InterfaceDeclaration?this.loadClass(t):t.kind==p.SyntaxKind.EnumDeclaration?this.loadEnum(t):t.kind==p.SyntaxKind.TypeAliasDeclaration?this.loadAlias(t):t.kind==p.SyntaxKind.FunctionDeclaration?this.loadFunction(t):t.kind==p.SyntaxKind.VariableStatement?this.loadVariableStatement(t):t.kind==p.SyntaxKind.ModuleBlock?this.loadRoot(t):(t.kind,p.SyntaxKind.EndOfFileToken)})}loadImport(e){Qt.Parse(e,this.file,this)}loadNamespace(t){if(It(t.flags,p.NodeFlags.Namespace)&&t.body){let n=t.modifiers?.find(e=>e.kind===p.SyntaxKind.ExportKeyword);n&&e.addError(n.getStart(),n.getEnd(),`Aventus namespaces cannot be exported; export their members instead`),this.namespaces.push(new pn(t)),this.currentNamespace.push(t.name.getText()),this.loadRoot(t),this.currentNamespace.splice(this.currentNamespace.length-1,1)}else It(t.flags,p.NodeFlags.GlobalAugmentation)&&t.body?this.loadRoot(t):this.errors.push({range:m.Range.create(this.document.positionAt(t.getStart()),this.document.positionAt(t.getEnd())),severity:m.DiagnosticSeverity.Error,source:T.TypeScript,message:(0,p.flattenDiagnosticMessageText)(`Can't use a module, use namespace instead`,`
|
|
278
|
-
`)})}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 dn(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 mn(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 fn(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 en(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){A.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 hn(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,n=this.getBaseInfo(e)??this.getBaseInfo(t);return n?.fullName===e?n:null}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)}},gn=class e extends it{static dependentValidationDelay=2e3;static pendingValidations=new WeakMap;suppressDependentValidation=!1;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=j.parse(this.file,e,this.build),this._contentForLanguageService=this.file.documentInternal.getText(),this.refreshDeprecated(!0),e||this.replaceNamespace()}async revalidateAfterDependencyChange(){j.invalidate(this.file.uri,this.build),this.refreshFileParsed(),await this.file.validate(),this.suppressDependentValidation=!0;try{this.file instanceof O&&await this.file.triggerSave()}finally{this.suppressDependentValidation=!1}}async onSave(){if(!this.build.initDone||this.suppressDependentValidation)return;let t=e.pendingValidations.get(this.build);t||(t={uris:new Set},e.pendingValidations.set(this.build,t)),t.uris.add(this.file.uri),t.timer&&clearTimeout(t.timer),t.timer=setTimeout(()=>{let e=t.uris;t.uris=new Set,t.timer=void 0,this.validateDependents(e).catch(e=>console.error(e))},e.dependentValidationDelay)}async validateDependents(e){for(let t of this.getDependentFiles(e))await t.revalidateAfterDependencyChange()}getDependentFiles(e){let t=new Map;for(let[e,n]of Object.entries(this.build.tsFiles)){let r=n.fileParsed;if(!r)continue;let i=new Set,a=(0,p.createSourceFile)(e,r.document.getText(),p.ScriptTarget.Latest);for(let t of a.statements){if(!(0,p.isImportDeclaration)(t)||!(0,p.isStringLiteral)(t.moduleSpecifier))continue;let r=this.build.project.resolveAlias(t.moduleSpecifier.text,n.file);r.startsWith(`.`)&&i.add(I((0,f.normalize)(
|
|
278
|
+
`)})}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 dn(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 mn(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 fn(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 en(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){A.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 hn(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,n=this.getBaseInfo(e)??this.getBaseInfo(t);return n?.fullName===e?n:null}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)}},gn=class e extends it{static dependentValidationDelay=2e3;static pendingValidations=new WeakMap;suppressDependentValidation=!1;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=j.parse(this.file,e,this.build),this._contentForLanguageService=this.file.documentInternal.getText(),this.refreshDeprecated(!0),e||this.replaceNamespace()}async revalidateAfterDependencyChange(){j.invalidate(this.file.uri,this.build),this.refreshFileParsed(),await this.file.validate(),this.suppressDependentValidation=!0;try{this.file instanceof O&&await this.file.triggerSave()}finally{this.suppressDependentValidation=!1}}async onSave(){if(!this.build.initDone||this.suppressDependentValidation)return;let t=e.pendingValidations.get(this.build);t||(t={uris:new Set},e.pendingValidations.set(this.build,t)),t.uris.add(this.file.uri),t.timer&&clearTimeout(t.timer),t.timer=setTimeout(()=>{let e=t.uris;t.uris=new Set,t.timer=void 0,this.validateDependents(e).catch(e=>console.error(e))},e.dependentValidationDelay)}async validateDependents(e){for(let t of this.getDependentFiles(e))await t.revalidateAfterDependencyChange()}getDependentFiles(e){let t=new Map;for(let[e,n]of Object.entries(this.build.tsFiles)){let r=n.fileParsed;if(!r)continue;let i=new Set,a=(0,p.createSourceFile)(e,r.document.getText(),p.ScriptTarget.Latest);for(let t of a.statements){if(!(0,p.isImportDeclaration)(t)||!(0,p.isStringLiteral)(t.moduleSpecifier))continue;let r=this.build.project.resolveAlias(t.moduleSpecifier.text,n.file);r.startsWith(`.`)&&i.add(I((0,f.normalize)(us(L(e))+`/`+r)))}for(let e of[...Object.values(r.classes),...Object.values(r.functions),...Object.values(r.enums)])for(let t of Object.values(e.dependencies))this.build.tsFiles[t.uri]&&i.add(t.uri);for(let n of i)t.has(n)||t.set(n,new Set),t.get(n).add(e)}let n=new Set(e),r=[...e],i=[];for(;r.length;)for(let a of t.get(r.shift())??[]){if(n.has(a))continue;n.add(a),r.push(a);let t=this.build.tsFiles[a];t&&!e.has(a)&&i.push(t)}return i}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(R(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(R(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(R(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(R(this.file.documentInternal,`Class `+r.name+` must implement `+e.class_implement.join(` or `),r.nameStart,r.nameEnd,1018)),t||this.diagnostics.push(R(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 _n(){return`$namespaceStart$$fullname$ = class $classname$ extends $parentClass$ {
|
|
279
279
|
$watchingAttributes$
|
|
280
280
|
|
|
281
281
|
$getterSetterAttr$
|
|
@@ -323,15 +323,15 @@ $namespaceEnd$
|
|
|
323
323
|
`}const vn=new Map([[`Date`,`Native Date is not available in Aventus. Import Aventus.Date instead.`]]);function yn(e,t){if(vn.has(e.text))return bn(e.text,t.getSymbolAtLocation(e))}function bn(e,t){let n=vn.get(e);if(n)return t?.declarations?.some(e=>{let t=e.getSourceFile();return t.isDeclarationFile&&/(?:^|[/\\])lib\.[^/\\]+\.d\.ts$/.test(t.fileName)})?n:void 0}var xn=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}},Sn=class e{static is(t){return t.name==`Required`?new e:null}},Cn=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 dn&&!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+`
|
|
324
324
|
`,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+`
|
|
325
325
|
`,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+`
|
|
326
|
-
`,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)}},wn=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}},Tn=class e extends it{static headerRegex=/^\/\/ ([a-zA-Z0-9_]+(?:@[a-zA-Z0-9_]+)?):([0-9]+)\.([0-9]+)\.([0-9]+)$/m;static getQuickInfo(e){try{if(/\/\/#region js def \/\/([\s\S]*?)\/\/#endregion js def \/\//.test(e.contentUser)){let t=this.headerRegex.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,T.TypeScript,this.file.versionUser,e.jsDef);this.tsFile?this.tsFile.triggerContentChange(t):(this.tsFile=new O(t),this.tsDef=new En(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 t=e.getQuickInfo(this.file);t&&(this.name=t.name,this.version=t.version);let n=/([\s\S]*?)\/\/#endregion js def \/\//g.exec(this.file.contentUser),r=``;n&&(r=n[0]);let i=/\/\/#region js src \/\/([\s\S]*?)\/\/#endregion js src \/\//g.exec(this.file.contentUser),a=``;i&&(a=i[1]);let o=/\/\/#region css \/\/([\s\S]*?)\/\/#endregion css \/\//g.exec(this.file.contentUser),s=``;o&&(s=o[1]);let c=/\/\/#region css def \/\/([\s\S]*?)\/\/#endregion css def \/\//g.exec(this.file.contentUser),l=``;c&&(l=c[1]);let u=/\/\/#region html \/\/([\s\S]*?)\/\/#endregion html \/\//g.exec(this.file.contentUser),d=``;u&&(d=u[1]);let f=/\/\/#region dependencies \/\/([\s\S]*?)\/\/#endregion dependencies \/\//g.exec(this.file.contentUser),p=``;return f&&(p=f[1]),{jsDef:r,jsSrc:a,scssDefTxt:l,scssTxt:s,htmlTxt:d,depsTxt:p}}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)}},En=class extends gn{_classInfoByName={};packagesFiles=[];get extension(){return E.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};
|
|
327
|
-
`,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(E.Package,``)+`:`+e+E.Package;this.packagesFiles.push(new Dn(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()}},Dn=class extends gn{get extension(){return E.Package}internalFile;info;packageFile;constructor(e,t,n,r){let i=new O(d.TextDocument.create(`file:///`+t,T.TypeScript,1,e.text));super(i,n),this.tsLanguageService.removeFile(this),this.tsLanguageService.addFile(this),this.info=e,this.internalFile=i,this._contentForLanguageService=e.text,this.fileParsed=r.fileParsed,this.packageFile=r}mustBeAddedToLanguageService(){return!1}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}},On=class e{languageService;languageServiceNamespace;build;filesNeeded=[];filesNpm=[];filesNpmLoaded=!1;filesLoaded={};i18nFiles={};constructor(e){this.build=e,Mt(),this.onSettingsChanged(e),F.getInstance().onSettingsChange(()=>{this.onSettingsChanged(e)}),this.languageService=(0,p.createLanguageService)(this.createHost()),this.languageServiceNamespace=(0,p.createLanguageService)(this.createHostNamespace())}onSettingsChanged(e){let t=F.getInstance().settings.readNodeModules;t!=this.filesNpmLoaded&&(t?this.filesNpm=Nt((0,f.join)(e.project.getConfigFile().folderPath,`node_modules`)):this.filesNpm=[],this.filesNpmLoaded=t)}createHostNamespace(){let e=this;return{getCompilationSettings:()=>kn,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].version+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionUser+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:Pt(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:Pt(e),fileExists:e=>(e.endsWith(E.Base+`.ts`)&&(e=e.replace(E.Base+`.ts`,E.Base)),this.filesLoaded[e]||this.i18nFiles[e]?!0:!!Pt(e)),directoryExists:e=>(0,u.existsSync)(L(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}createHost(){let e=this;return{getCompilationSettings:()=>kn,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].versionInternal+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionInternal+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].contentForLanguageService:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:Pt(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>{let n;if(this.filesLoaded[e])n=this.filesLoaded[e].contentForLanguageService;else if(this.i18nFiles[e])return this.i18nFiles[e].file.contentInternal;else n=Pt(e);return n},fileExists:e=>{let t=!1;if(e.endsWith(E.Base+`.ts`)&&(e=e.replace(E.Base+`.ts`,E.Base)),this.filesLoaded[e])t=!0;else if(this.i18nFiles[e])return!0;else t=!!Pt(e);return t},directoryExists:e=>(0,u.existsSync)(L(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(E.Package)){let e={extension:p.Extension.Ts,resolvedFileName:`file:///`+r};s.push(e);continue}let t=z.getInstance().getByUri(n);t&&(r=this.build.project.resolveAlias(r,t));let i=(0,p.resolveModuleName)(r,n,kn,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),o=this.languageService.getProgram(),s=o?.getSourceFile(e.uri);if(o&&s&&!s.isDeclarationFile){let t=o.getTypeChecker(),r=i=>{let a=(0,p.isIdentifier)(i)?yn(i,t):void 0;a&&n.push({range:
|
|
328
|
-
`)}`;r.reportsUnnecessary?n.push({range:
|
|
329
|
-
import from `+i,n.newText=n.newText.replace(r[1],i)}}e.additionalTextEdits.push({newText:n.newText,range:
|
|
326
|
+
`,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)}},wn=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}},Tn=class e extends it{static headerRegex=/^\/\/ ([a-zA-Z0-9_]+(?:@[a-zA-Z0-9_]+)?):([0-9]+)\.([0-9]+)\.([0-9]+)$/m;static getQuickInfo(e){try{if(/\/\/#region js def \/\/([\s\S]*?)\/\/#endregion js def \/\//.test(e.contentUser)){let t=this.headerRegex.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,T.TypeScript,this.file.versionUser,e.jsDef);this.tsFile?this.tsFile.triggerContentChange(t):(this.tsFile=new O(t),this.tsDef=new En(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 t=e.getQuickInfo(this.file);t&&(this.name=t.name,this.version=t.version);let n=/([\s\S]*?)\/\/#endregion js def \/\//g.exec(this.file.contentUser),r=``;n&&(r=n[0]);let i=/\/\/#region js src \/\/([\s\S]*?)\/\/#endregion js src \/\//g.exec(this.file.contentUser),a=``;i&&(a=i[1]);let o=/\/\/#region css \/\/([\s\S]*?)\/\/#endregion css \/\//g.exec(this.file.contentUser),s=``;o&&(s=o[1]);let c=/\/\/#region css def \/\/([\s\S]*?)\/\/#endregion css def \/\//g.exec(this.file.contentUser),l=``;c&&(l=c[1]);let u=/\/\/#region html \/\/([\s\S]*?)\/\/#endregion html \/\//g.exec(this.file.contentUser),d=``;u&&(d=u[1]);let f=/\/\/#region dependencies \/\/([\s\S]*?)\/\/#endregion dependencies \/\//g.exec(this.file.contentUser),p=``;return f&&(p=f[1]),{jsDef:r,jsSrc:a,scssDefTxt:l,scssTxt:s,htmlTxt:d,depsTxt:p}}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(),await this.build.rebuildAll()}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)}},En=class extends gn{_classInfoByName={};packagesFiles=[];get extension(){return E.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};
|
|
327
|
+
`,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(E.Package,``)+`:`+e+E.Package;this.packagesFiles.push(new Dn(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()}},Dn=class extends gn{get extension(){return E.Package}internalFile;info;packageFile;constructor(e,t,n,r){let i=new O(d.TextDocument.create(`file:///`+t,T.TypeScript,1,e.text));super(i,n),this.tsLanguageService.removeFile(this),this.tsLanguageService.addFile(this),this.info=e,this.internalFile=i,this._contentForLanguageService=e.text,this.fileParsed=r.fileParsed,this.packageFile=r}mustBeAddedToLanguageService(){return!1}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}},On=class e{languageService;languageServiceNamespace;build;filesNeeded=[];filesNpm=[];filesNpmLoaded=!1;filesLoaded={};i18nFiles={};constructor(e){this.build=e,Mt(),this.onSettingsChanged(e),F.getInstance().onSettingsChange(()=>{this.onSettingsChanged(e)}),this.languageService=(0,p.createLanguageService)(this.createHost()),this.languageServiceNamespace=(0,p.createLanguageService)(this.createHostNamespace())}onSettingsChanged(e){let t=F.getInstance().settings.readNodeModules;t!=this.filesNpmLoaded&&(t?this.filesNpm=Nt((0,f.join)(e.project.getConfigFile().folderPath,`node_modules`)):this.filesNpm=[],this.filesNpmLoaded=t)}createHostNamespace(){let e=this;return{getCompilationSettings:()=>kn,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].version+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionUser+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:Pt(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>this.filesLoaded[e]?this.filesLoaded[e].file.contentInternal:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:Pt(e),fileExists:e=>(e.endsWith(E.Base+`.ts`)&&(e=e.replace(E.Base+`.ts`,E.Base)),this.filesLoaded[e]||this.i18nFiles[e]?!0:!!Pt(e)),directoryExists:e=>(0,u.existsSync)(L(e)),resolveModuleNames(t,n,r,i,a,o){return e.resolveModuleNames(this,t,n,r,i,a,o)}}}createHost(){let e=this;return{getCompilationSettings:()=>kn,getScriptFileNames:()=>[...this.filesNeeded,...this.filesNpm,...Object.keys(this.i18nFiles)],getScriptKind:e=>p.ScriptKind.TS,getScriptVersion:e=>this.filesLoaded[e]?String(this.filesLoaded[e].versionInternal+1):this.i18nFiles[e]?String(this.i18nFiles[e].file.versionInternal+1):`1`,getScriptSnapshot:e=>{let t=``;if(t=this.filesLoaded[e]?this.filesLoaded[e].contentForLanguageService:this.i18nFiles[e]?this.i18nFiles[e].file.contentInternal:Pt(e),t!==void 0)return{getText:(e,n)=>t?.substring(e,n)||``,getLength:()=>t?.length||0,getChangeRange:()=>void 0}},getCurrentDirectory:()=>``,getDefaultLibFileName:e=>(0,p.getDefaultLibFilePath)(e),readFile:(e,t)=>{let n;if(this.filesLoaded[e])n=this.filesLoaded[e].contentForLanguageService;else if(this.i18nFiles[e])return this.i18nFiles[e].file.contentInternal;else n=Pt(e);return n},fileExists:e=>{let t=!1;if(e.endsWith(E.Base+`.ts`)&&(e=e.replace(E.Base+`.ts`,E.Base)),this.filesLoaded[e])t=!0;else if(this.i18nFiles[e])return!0;else t=!!Pt(e);return t},directoryExists:e=>(0,u.existsSync)(L(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(E.Package)){let e={extension:p.Extension.Ts,resolvedFileName:`file:///`+r};s.push(e);continue}let t=z.getInstance().getByUri(n);t&&(r=this.build.project.resolveAlias(r,t));let i=(0,p.resolveModuleName)(r,n,kn,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),o=this.languageService.getProgram(),s=o?.getSourceFile(e.uri);if(o&&s&&!s.isDeclarationFile){let t=o.getTypeChecker(),r=i=>{let a=(0,p.isIdentifier)(i)?yn(i,t):void 0;a&&n.push({range:ds(e.documentInternal,{start:i.getStart(s),length:i.getWidth(s)}),severity:m.DiagnosticSeverity.Error,source:T.TypeScript,code:`forbidden-native-global`,message:a}),i.forEachChild(r)};r(s)}for(let r of a){if(t.includes(r.code))continue;let i=`${(0,p.flattenDiagnosticMessageText)(r.messageText,`
|
|
328
|
+
`)}`;r.reportsUnnecessary?n.push({range:ds(e.documentInternal,r),severity:m.DiagnosticSeverity.Hint,source:T.TypeScript,code:r.code,message:i,tags:[m.DiagnosticTag.Unnecessary]}):n.push({range:ds(e.documentInternal,r),severity:m.DiagnosticSeverity.Error,source:T.TypeScript,code:r.code,message:i})}return n}catch(e){this.printCatchError(e)}return[]}async doComplete(e,t){try{let n=e.documentInternal,r=n.offsetAt(t),i=ds(n,gs(n.getText(),r)),a;try{a=this.languageService.getCompletionsAtPosition(n.uri,r,jn)}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];if(bn(t.name,t.symbol))continue;let 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:T.TypeScript,offset:r,uri:n.uri},u={label:t.name,sortText:t.sortText,kind:Nn(t.kind),textEdit:m.TextEdit.replace(i,s),additionalTextEdits:c,data:{...t.data,...l,source:t.source}};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{uri:n,offset:r,languageId:i,source:a,...o}=e.data,s=this.languageService.getCompletionEntryDetails(n,r,e.label,{},a,jn,Object.keys(o).length?o:void 0);if(s){if(e.detail=(0,p.displayPartsToString)(s.displayParts),e.documentation=(0,p.displayPartsToString)(s.documentation),e.additionalTextEdits=[],s.codeActions)for(let n=0;n<s.codeActions.length;n++)for(let r of s.codeActions[n].changes)for(let n of r.textChanges){n.newText=Zo(n.newText.replace(/'/g,`"`));let r=/"(.*)"/g.exec(n.newText);if(r&&r.length>1){if(r[0].includes(E.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+=`
|
|
329
|
+
import from `+i,n.newText=n.newText.replace(r[1],i)}}e.additionalTextEdits.push({newText:n.newText,range:ds(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+=`
|
|
330
330
|
\`\`\`
|
|
331
331
|
***
|
|
332
332
|
`),i+=t.join(`
|
|
333
333
|
|
|
334
|
-
`),{range:ps(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 Dn){let r=await t.goToDefinition(ps(t.file.documentInternal,e.textSpan));r&&!Array.isArray(r)&&(r=[r]),r&&(n=[...r])}else if(t)n.push({uri:t.file.uri,range:ps(t.file.documentInternal,e.textSpan)});else{let t=Pt(e.fileName);if(t){let r=d.TextDocument.create(e.fileName,`typescript`,1,t);n.push({uri:e.fileName,range:ps(r,e.textSpan)})}}}return this.mapLocationsToView(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 N&&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 this.mapLocationsToView(n)}mapLocationsToView(e){return e.flatMap(e=>{let t=this.build.tsFiles[e.uri];if(!(t instanceof N))return[e];let n=t.mapGeneratedRangeToView(e.range);if(n===null){let n=t.mapInternalRangeToUser(e.range);return[{...e,range:n??e.range}]}return n.map(e=>({uri:t.HTMLFile.file.uri,range:e}))})}mapWorkspaceEditToView(e){if(!e.changes)return e;let t={},n=new Set;for(let[r,i]of Object.entries(e.changes)){let e=this.build.tsFiles[r];for(let a of i){let i=e instanceof N?e:null,o=i?.mapGeneratedRangeToView(a.range)??null,s=o===null?r:i.HTMLFile.file.uri,c=o===null?i?.mapInternalRangeToUser(a.range):null;for(let e of o??[c??a.range]){let r=JSON.stringify([s,e,a.newText]);n.has(r)||(n.add(r),(t[s]??=[]).push({...a,range:e}))}}}return{...e,changes:t}}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||Pn(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={...Mn};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:ps(i,t.span),newText:t.newText});return s&&e.push({range:s,newText:Fn(0,n)}),e}}catch(e){this.printCatchError(e)}return[]}async doCodeAction(e,t){let n=[];try{let r=j.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,Mn,jn)}catch{}for(let t of c){let a={changes:{}};for(let n of t.changes){let o=this.filesLoaded[n.fileName]?.file.documentInternal;if(!o||!a.changes)continue;let s=a.changes[n.fileName]??=[];for(let a of n.textChanges){if(t.description.startsWith(`Add import from`)){a.newText=a.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(a.newText);if(e&&e.length>1){let n=this.simplifyPath(e[1],i.uri);t.description=`Add import from `+n,a.newText=a.newText.replace(e[1],n)}}else if(t.fixName===`fixClassDoesntImplementInheritedAbstractMember`){let t=!1;for(let e in r.classes){let n=r.classes[e];a.span.start>=n.start&&a.span.start<=n.end&&(t=!0)}if(t){let t=Ln(e,`methods`);t!=-1&&(a.span.start=t),a.newText.match(/ (public|protected) /g)||(a.newText=a.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),a.newText.match(/(public|protected)[ ]*?override/g)||(a.newText=a.newText.replace(/((public|protected)[ ]*?)([a-z])/g,`$1override $3`)),a.newText=a.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(a.newText.startsWith(`import `)){a.newText=a.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(a.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);a.newText=a.newText.replace(e[1],t)}}}else if(t.fixName==`fixClassIncorrectlyImplementsInterface`){let t=!1;for(let e in r.classes){let n=r.classes[e];a.span.start>=n.start&&a.span.start<=n.end&&(t=!0)}if(t){let t=Ln(e,`methods`);t!=-1&&(a.span.start=t),!a.newText.includes(` protected `)&&!a.newText.includes(` public `)&&(a.newText=a.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),a.newText=a.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(a.newText.startsWith(`import `)){a.newText=a.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(a.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);a.newText=a.newText.replace(e[1],t)}}}s.push({newText:a.newText,range:ps(o,a.span)})}}n.push({title:t.description,edit:a})}}catch(e){this.printCatchError(e)}return n.map(e=>e.edit?{...e,edit:this.mapWorkspaceEditToView(e.edit)}:e).filter(e=>!e.edit?.changes||Object.values(e.edit.changes).some(e=>e.length>0))}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 this.mapLocationsToView(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=Ln(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 this.mapWorkspaceEditToView(o)}async onRenameFile(e,t){let n={},r=this.languageService.getFileReferences(e);for(let e of r){let r=z.getInstance().getByUri(e.fileName);if(r){let i=r.folderUri.split(`/`),a=t.split(`/`);for(;i.length>0&&a.length>0&&i[0]==a[0];)i.splice(0,1),a.splice(0,1);let o=[];if(i.length>0)for(let e=0;e<i.length;e++)o.push(`..`);else o.push(`.`);for(let e of a)o.push(e);n[r.uri]||(n[r.uri]=[]),n[r.uri].push({newText:o.join(`/`),range:{start:r.documentInternal.positionAt(e.textSpan.start),end:r.documentInternal.positionAt(e.textSpan.start+e.textSpan.length)}})}}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=wn.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 dn&&!e.isInterface){let t=`Aventus.`;e.build.isCoreBuild&&(t=``);let a=``;e.namespace&&(a=`.`+e.namespace),r+=e.fullName+".Namespace=`"+c+a+`\`;
|
|
334
|
+
`),{range:ds(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 Dn){let r=await t.goToDefinition(ds(t.file.documentInternal,e.textSpan));r&&!Array.isArray(r)&&(r=[r]),r&&(n=[...r])}else if(t)n.push({uri:t.file.uri,range:ds(t.file.documentInternal,e.textSpan)});else{let t=Pt(e.fileName);if(t){let r=d.TextDocument.create(e.fileName,`typescript`,1,t);n.push({uri:e.fileName,range:ds(r,e.textSpan)})}}}return this.mapLocationsToView(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 N&&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 this.mapLocationsToView(n)}mapLocationsToView(e){return e.flatMap(e=>{let t=this.build.tsFiles[e.uri];if(!(t instanceof N))return[e];let n=t.mapGeneratedRangeToView(e.range);if(n===null){let n=t.mapInternalRangeToUser(e.range);return[{...e,range:n??e.range}]}return n.map(e=>({uri:t.HTMLFile.file.uri,range:e}))})}mapWorkspaceEditToView(e){if(!e.changes)return e;let t={},n=new Set;for(let[r,i]of Object.entries(e.changes)){let e=this.build.tsFiles[r];for(let a of i){let i=e instanceof N?e:null,o=i?.mapGeneratedRangeToView(a.range)??null,s=o===null?r:i.HTMLFile.file.uri,c=o===null?i?.mapInternalRangeToUser(a.range):null;for(let e of o??[c??a.range]){let r=JSON.stringify([s,e,a.newText]);n.has(r)||(n.add(r),(t[s]??=[]).push({...a,range:e}))}}}return{...e,changes:t}}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||Pn(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={...Mn};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:ds(i,t.span),newText:t.newText});return s&&e.push({range:s,newText:Fn(0,n)}),e}}catch(e){this.printCatchError(e)}return[]}async doCodeAction(e,t){let n=[];try{let r=j.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,Mn,jn)}catch{}for(let t of c){let a={changes:{}};for(let n of t.changes){let o=this.filesLoaded[n.fileName]?.file.documentInternal;if(!o||!a.changes)continue;let s=a.changes[n.fileName]??=[];for(let a of n.textChanges){if(t.description.startsWith(`Add import from`)){a.newText=a.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(a.newText);if(e&&e.length>1){let n=this.simplifyPath(e[1],i.uri);t.description=`Add import from `+n,a.newText=a.newText.replace(e[1],n)}}else if(t.fixName===`fixClassDoesntImplementInheritedAbstractMember`){let t=!1;for(let e in r.classes){let n=r.classes[e];a.span.start>=n.start&&a.span.start<=n.end&&(t=!0)}if(t){let t=Ln(e,`methods`);t!=-1&&(a.span.start=t),a.newText.match(/ (public|protected) /g)||(a.newText=a.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),a.newText.match(/(public|protected)[ ]*?override/g)||(a.newText=a.newText.replace(/((public|protected)[ ]*?)([a-z])/g,`$1override $3`)),a.newText=a.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(a.newText.startsWith(`import `)){a.newText=a.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(a.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);a.newText=a.newText.replace(e[1],t)}}}else if(t.fixName==`fixClassIncorrectlyImplementsInterface`){let t=!1;for(let e in r.classes){let n=r.classes[e];a.span.start>=n.start&&a.span.start<=n.end&&(t=!0)}if(t){let t=Ln(e,`methods`);t!=-1&&(a.span.start=t),!a.newText.includes(` protected `)&&!a.newText.includes(` public `)&&(a.newText=a.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1public $2`)),a.newText=a.newText.replace(/^([\s|\S]*?)([a-z])/g,`$1/**$1 * @inheritdoc$1 */$1$2`)}else if(a.newText.startsWith(`import `)){a.newText=a.newText.replace(/'/g,`"`);let e=/"(.*)"/g.exec(a.newText);if(e&&e.length>1){let t=this.simplifyPath(e[1],i.uri);a.newText=a.newText.replace(e[1],t)}}}s.push({newText:a.newText,range:ds(o,a.span)})}}n.push({title:t.description,edit:a})}}catch(e){this.printCatchError(e)}return n.map(e=>e.edit?{...e,edit:this.mapWorkspaceEditToView(e.edit)}:e).filter(e=>!e.edit?.changes||Object.values(e.edit.changes).some(e=>e.length>0))}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 this.mapLocationsToView(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=Ln(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 this.mapWorkspaceEditToView(o)}async onRenameFile(e,t){let n={},r=this.languageService.getFileReferences(e);for(let e of r){let r=z.getInstance().getByUri(e.fileName);if(r){let i=r.folderUri.split(`/`),a=t.split(`/`);for(;i.length>0&&a.length>0&&i[0]==a[0];)i.splice(0,1),a.splice(0,1);let o=[];if(i.length>0)for(let e=0;e<i.length;e++)o.push(`..`);else o.push(`.`);for(let e of a)o.push(e);n[r.uri]||(n[r.uri]=[]),n[r.uri].push({newText:o.join(`/`),range:{start:r.documentInternal.positionAt(e.textSpan.start),end:r.documentInternal.positionAt(e.textSpan.start+e.textSpan.length)}})}}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=wn.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 dn&&!e.isInterface){let t=`Aventus.`;e.build.isCoreBuild&&(t=``);let a=``;e.namespace&&(a=`.`+e.namespace),r+=e.fullName+".Namespace=`"+c+a+`\`;
|
|
335
335
|
`,i+=e.name+".Namespace=`"+c+a+`\`;
|
|
336
336
|
`,e.implements.includes(t+`IData`)&&(n.type=2),e.convertibleName?(r+=e.fullName+`.$schema=`+this.prepareDataSchema(e,c)+`;
|
|
337
337
|
`,i+=e.name+`.$schema=`+this.prepareDataSchema(e,c)+`;
|
|
@@ -362,7 +362,7 @@ Object.assign(`+e.fullName+`, _n);
|
|
|
362
362
|
`)+`
|
|
363
363
|
`+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 An}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 kn={allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,lib:[`lib.es2025.full.d.ts`,`lib.esnext.temporal.d.ts`],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},An={allowNonTsExtensions:!0,jsx:p.JsxEmit.None,importHelpers:!1,allowJs:!0,checkJs:!1,lib:[`lib.es2025.full.d.ts`,`lib.esnext.temporal.d.ts`],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},jn={includeSymbol:!0,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`},Mn={convertTabsToSpaces:!0,tabSize:4,indentSize:4,indentStyle:p.IndentStyle.Smart,newLineCharacter:`
|
|
364
364
|
`,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 Nn(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 Pn(e){return/^\s*$/.test(e)}function Fn(e,t){return t.insertSpaces?In(` `,e*t.tabSize):In(` `,e)}function In(e,t){let n=``;for(;t>0;)(t&1)==1&&(n+=e),e+=e,t>>>=1;return n}function Ln(e,t){let n=RegExp(`//#region `+t+`(\\s|\\S)*?//#endregion`).exec(e.documentInternal.getText());return n?n.index+10+t.length:-1}var Rn=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}},zn=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}},Bn=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}},Vn=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}},Hn=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=Un.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},Un=class{static parse(e){let t={stateName:``};try{let n=e.arguments[0].value;if(e.arguments[0].type==`string`)n=JSON.stringify(n);else 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=n.split(/[.(]/,1)[0],i=e.baseInfo?.dependenciesLocations[r]?.replacement;i&&(n=i+n.slice(r.length)),t.managerName=n}}catch{}return t}},Wn=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=Un.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},Gn=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=Un.parse(t);n.stateName=e.stateName,n.managerName=e.managerName??``}catch{}return n}return null}},Kn=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 qn={"@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 Jn=class e{managerName=``;static is(t){if(t.name==`DefaultStateActive`){let n=new e;if(t.arguments.length>0)try{n.managerName=Yn.parse(t).managerName}catch{}return n}return null}},Yn=class{static parse(e){let t={managerName:``};try{let n=e.arguments[0].value,r=n.split(/[.(]/,1)[0],i=e.baseInfo?.dependenciesLocations[r]?.replacement;i&&(n=i+n.slice(r.length)),t.managerName=n}catch{}return t}},Xn=class e{managerName=``;static is(t){if(t.name==`DefaultStateInactive`){let n=new e;if(t.arguments.length>0)try{n.managerName=Yn.parse(t).managerName}catch{}return n}return null}},Zn=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}},Qn=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}},$n=class e{static is(t){return t.name==`Injectable`?new e:null}},er=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(E.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(E.ComponentLogic,E.ComponentStyle)],i=t.htmlFiles[e.file.uri.replace(E.ComponentLogic,E.ComponentView)],a=t.i18nComponentsFiles[e.file.uri.replace(E.ComponentLogic,E.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(E.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(E.ComponentLogic,E.ComponentStyle)],r=t.htmlFiles[e.file.uri.replace(E.ComponentLogic,E.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=_n(),this.templateHotReload=_n(),t.hasNpmOutput&&(this.templateNpm=_n()),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(On.compileTs(this.fileParsed.aliases[e],this.logicalFile));for(let e in this.fileParsed.enums)this.result.result.push(On.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(R(this.document,e,t.nameStart,t.nameEnd,1003)),this.result.diagnostics.push(R(this.document,e,this.classInfo.nameStart,this.classInfo.nameEnd,1003))}else this.classInfo=t;else this.result.result.push(On.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+`
|
|
365
|
-
`);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(
|
|
365
|
+
`);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(ns(this.document,`Can't found a web component class to compile inside`,1002));return this.result}isComponentClassInfo(e){return e instanceof dn&&e.isWebcomponent}compileComponentClassInfo(){if(this.classInfo){this.prepareComponentClassInfo(this.classInfo);let e=On.compileTs(this.classInfo,this.logicalFile);this.componentResult.classScript=e.classScript,this.componentResult.classDoc=e.classDoc,this.componentResult.dependencies=e.dependencies,this.componentResult.docInvisible=e.docInvisible,this.componentResult.docVisible=e.docVisible,this.componentResult.npm=e.npm,this.componentResult.type=e.type,this.componentResult.isExported=e.isExported,this.componentResult.uri=e.uri,this.prepareHTMLDocObject(),this.loadParent(this.classInfo),this.addViewElementToDependency(),this.writeFile(),!this.classInfo.isAbstract&&!this.classInfo.isInterface&&(this.componentResult.tagName=this.tagName),this.componentResult.slots=this.htmlFile?.slotsInfo,this.componentResult.compiled=this.template.replace(`//todelete for hmr °`,``),this.componentResult.npm.src=this.templateNpm?.replace(`//todelete for hmr °`,``)??``,yt.isRunning&&(this.componentResult.hotReload=this.templateHotReload.split(`//todelete for hmr °`)[0],this.componentResult.hotReload=this.componentResult.hotReload.slice(this.componentResult.hotReload.indexOf(`=`)+1)),this.debuggerDecorator&&this.debuggerDecorator.writeCompiled&&(this.componentResult.debugTxt=this.componentResult.compiled),this.result.result.push(this.componentResult)}}prepareComponentClassInfo(e){for(let t of e.decorators){let e=Rn.is(t);if(e){this.overrideViewDecorator=e;continue}let n=xn.is(t);if(n){this.debuggerDecorator=n;continue}let r=zn.is(t);if(r&&r.tagName){r.tagName.indexOf(`-`)==-1||r.tagName.toLowerCase()!=r.tagName?this.result.diagnostics.push(R(this.document,`tag name must be in lower case and have a - inside`,t.contentStart,t.contentEnd,1004)):this.tagName=r.tagName;continue}Sn.is(t)&&(this.componentResult.required=!0)}if(e.extends.length>0&&e.extends[0]==this.AventusWebComponent&&(this.overrideViewDecorator=new Rn),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(`
|
|
366
366
|
`)??``,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(R(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 un(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 N?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+`;
|
|
367
367
|
`),this.writeFileHotReloadReplaceVar(`namespaceStart`,`_n = `+this.fullName+`;
|
|
368
368
|
`),this.writeFileNpmReplaceVar(`namespaceStart`,`_n = `+this.fullName+`;
|
|
@@ -484,14 +484,14 @@ this.clearWatchHistory = () => {
|
|
|
484
484
|
}`),this.writeFileReplaceVar(`watchesChangeCb`,e),this.writeFileHotReloadReplaceVar(`watchesChangeCb`,e),this.writeFileNpmReplaceVar(`watchesChangeCb`,e)}createHtmlDoc(e,t){if(this.htmlDoc){let n=[];if(e.isProtected||e.isPrivate)return;let r=`string`;if(t.kind==`literal`){let e=t.value;(e.startsWith(`'`)||e.startsWith(`"`))&&(e=e.substring(1)),(e.endsWith(`'`)||e.endsWith(`"`))&&(e=e.substring(0,e.length-1)),n.push({name:e,description:``})}else if(t.kind==`union`)for(let e of t.nested){let t=e.value;(t.startsWith(`'`)||t.startsWith(`"`))&&(t=t.substring(1)),(t.endsWith(`'`)||t.endsWith(`"`))&&(t=t.substring(0,t.length-1)),n.push({name:t,description:``})}else t.kind==`boolean`?r=`boolean`:t.kind==`number`?r=`number`:t.kind==`type`&&t.value==`Date`?r=`Date`:t.kind==`type`&&t.value==`DateTime`?r=`DateTime`:t.kind==`type`&&t.value==`Time`&&(r=`Time`);this.htmlDoc[this.tagName].attributes[e.name]={name:e.name,description:e.documentation?.definitions.join(`
|
|
485
485
|
`)??``,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(`
|
|
486
486
|
`)??``,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(`
|
|
487
|
-
`)??``,values:[]}}}writeFileReplaceVar(e,t){let n=RegExp(`\\$`+e+`\\$`,`g`);this.template=this.template.replace(n,t+``)}writeFileHotReloadReplaceVar(e,t){if(yt.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=Ln(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(as(this.document,r,`methods`,1019))),this.htmlFile&&this.htmlFile.tsErrors.push(cs(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(as(this.document,r,`variables`,1011)),this.htmlFile)for(let t of e.positions)this.htmlFile.tsErrors.push(cs(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(R(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(R(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(ln.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,On.getCompilerOptionsCompile()).trim();return t=t.substring(0,t.length-1),t=`(`+t+`)`,t}catch{}return``}_validateTypeForProp(e,t,n){if(n.kind==`boolean`||n.kind==`number`||n.kind==`string`)return n;if(n.kind==`type`){if(n.value==`Date`||n.value==`DateTime`||n.value==`Time`)return n;{let r=j.getBaseInfo(n.value,this.build,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(R(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(R(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(R(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(R(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,``)}},tr=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=xn.is(e);if(t){t.writeHTML&&(this.writeHtml=!0),t.writeComponentTs&&(this.writeTs=!0);continue}if(!this.isAbstract){let t=zn.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}}},M=class e{static languageService=(0,w.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:T.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:T.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=Os(e.txt+`\0`+(e.tagName??``)+`\0`+(e.attributeName??``));if(this.currentParsingDoc.fcts[t])return this.currentParsingDoc.fcts[t].positions.push({start:e.start,end:e.end}),this.currentParsingDoc.fcts[t];{let n=this.getCustomFctName(),r=this.getVariables();if(n){let i={name:n,positions:[{start:e.start,end:e.end}],txt:e.txt,variables:r,tagName:e.tagName,attributeName:e.attributeName};return this.currentParsingDoc.fcts[t]=i,i}}}return null}static fromRawToCompiled(e){return this.currentParsingDoc?this.currentParsingDoc.fromRawToCompiled(e):e}static fromCompiledToRaw(e){return this.currentParsingDoc?this.currentParsingDoc.fromCompiledToRaw(e):e}static addLoopStack(e){if(this.currentParsingDoc){let t=this.currentParsingDoc.loops.find(t=>t.idTemplate==e);if(t)return t.recalculateVariables(),this.currentParsingDoc?.stacks.push(t),t}return null}static addIfStack(e){if(this.currentParsingDoc){for(let t of this.currentParsingDoc.ifs)if(t.idsTemplate.includes(e))return t.recalculateVariables(e),this.currentParsingDoc?.stacks.push({idTemplate:e}),t}return null}static addInjection(e){this.currentParsingDoc?.injections.push(e)}static addBinding(e){this.currentParsingDoc?.bindings.push(e)}static addTagInfoStack(e){this.currentParsingDoc?.stacks.push(e)}static getContextEditing(e){return this.currentParsingDoc?.contextEdits.find(t=>t.id==e)}static removeStack(){this.currentParsingDoc?.stacks.pop()}static getParentId(){if(this.currentParsingDoc&&this.currentParsingDoc.stacks.length>0)for(let e=this.currentParsingDoc.stacks.length-1;e>=0;e--){let t=this.currentParsingDoc.stacks[e];if(t instanceof sr||!(t instanceof nr))return t.idTemplate}}static getVariables(){let e=[];if(this.currentParsingDoc){for(let t of this.currentParsingDoc.stacks)if(t instanceof sr||t instanceof nr)for(let n of t.variableNames)e.includes(n)||e.push(n)}return e}uri;errors=[];document;rootTags=[];get validationRootTags(){return this.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),this.validateExpressions(t.file.documentUser),e.currentParsingDoc=null,this.isReady=!0;for(let e of this.readyCb)e()}validateExpressions(e){let t=[...this.injections,...this.bindings];for(let n of t){let t=(0,p.createSourceFile)(`expression.ts`,`const value = (${n.injectTsTxt});`,p.ScriptTarget.ESNext,!0).parseDiagnostics;for(let r of t)this.errors.push({range:m.Range.create(e.positionAt(n.start+1),e.positionAt(n.end-1)),severity:m.DiagnosticSeverity.Error,source:T.TypeScript,code:r.code,message:(0,p.flattenDiagnosticMessageText)(r.messageText,`
|
|
488
|
-
`)})}}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 cr(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 sr(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 lr(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()!=w.TokenType.EOS;)if(r.length>0){if(a.getTokenType()==w.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 or(i,n,r,e,!1))}}else if(a.getTokenType()==w.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()!=w.TokenType.StartTagOpen){if(a.getTokenType()==w.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()==w.TokenType.StartTagSelfClose){let e=o.pop();e&&(e.validateAllProps(a.getTokenOffset()),e.afterClose(a.getTokenOffset(),a.getTokenEnd()))}else if(a.getTokenType()==w.TokenType.StartTag){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd(),r=new nr(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()!=w.TokenType.EndTagOpen&&a.getTokenType()!=w.TokenType.EndTagClose){if(a.getTokenType()==w.TokenType.EndTag){let e=a.getTokenText(),n=o.pop();if(n&&n.tagName==e)n.afterClose(a.getTokenOffset(),a.getTokenEnd());else if(n){this.errors.push(cs(t,`The tag `+n?.tagName+` isn't correctly closed`,n?.start,n?.end));let r=-1;for(let t=o.length-1;t>=0;t--)if(o[t].tagName==e){r=t;break}r>=0?(o.length=r+1,o.pop()?.afterClose(a.getTokenOffset(),a.getTokenEnd())):o.push(n)}else this.errors.push(cs(t,`No opening tag found for `+e,a.getTokenOffset(),a.getTokenEnd()))}else if(a.getTokenType()!=w.TokenType.DelimiterAssign)if(a.getTokenType()==w.TokenType.AttributeName){let e=a.getTokenText();if(o.length>0){let t=o[o.length-1];s=new ar(e,a.getTokenOffset(),a.getTokenEnd(),t),t.addAttribute(s)}}else if(a.getTokenType()==w.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()==w.TokenType.Content){if(o.length>0){let e=o[o.length-1],t=a.getTokenText(),n=a.getTokenOffset(),r=a.getTokenEnd();e.addContent(new or(t,n,r,e))}}else a.getTokenType()==w.TokenType.Whitespace||a.getTokenType()==w.TokenType.Unknown||a.getTokenType()==w.TokenType.Script||(a.getTokenType(),w.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]}},nr=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==sr.tagName}get isIf(){return this.tagName==cr.tagName}get isContextEditing(){return this.tagName==lr.tagName}loopInfo;ifInfo;contextEdit;constructor(e,t,n,r){if(this.parser=e,this.tagName=t,this.start=n,this.openTagStart=n,this.end=r,this.isLoop){this.createId();return}this.isIf||this.isContextEditing||(M.addInterestPoint({name:t,start:M.fromCompiledToRaw(n),end:M.fromCompiledToRaw(r),type:`tag`}),rr.includes(t)&&(this.selfClosing=!0))}createId(){return this.id||(this.id=this.idBase+M.idElement,M.idElement++),this.id}addAttribute(e){if(e.name==`@for`){M.addError(e.nameStart,e.nameEnd,`Deprecated : use for directly inside template`);return}this.attributes[e.name]?M.addError(e.nameStart,e.nameEnd,`Duplicate attribute `+e.name):this.attributes[e.name]=e}addChild(e){this.children.push(e),e.parent=this}addContent(e){this.children.push(e)}addChanges(e,t,n){let r=this.createId()+`°`+e;this.changes[r]={fct:t,once:n}}validateAllProps(e){if(this.openTagEnd=e,this.alias){let e=this.alias.endsWith(`[]`);e&&(this.alias=this.alias.replace(`[]`,``)),e&&(this.aliasMultiple=e)}if(this.isLoop){this.parentTemplateId=M.getParentId();let e=M.addLoopStack(Number(this.attributes.id.value));e&&(this.loopInfo=e)}else if(this.isIf){this.parentTemplateId=M.getParentId();let e=Number(this.attributes.id.value),t=M.addIfStack(e);t&&(this.ifInfo=t,e==t.idsTemplate[0]&&(t._id=this.createId()))}else if(this.isContextEditing){this.parentTemplateId=M.getParentId();let e=Number(this.attributes.id.value),t=M.getContextEditing(e);if(t&&(this.contextEdit=t,this.parent))for(let e of t.variableNames)this.parent.variableNames.includes(e)||this.parent.variableNames.push(e)}M.addTagInfoStack(this)}afterClose(e,t){this.hasClose=!0,this.selfClosing||M.addInterestPoint({name:this.tagName,start:M.fromCompiledToRaw(e),end:M.fromCompiledToRaw(t),type:`tag`}),this.checkStyle(M.getRules(),e=>M.addStyleLink(e)),M.removeStack(),(this.isLoop||this.isIf)&&M.removeStack()}checkStyle(e,t){for(let[n,r]of e)n(this)&&t([{start:M.fromCompiledToRaw(this.openTagStart),end:M.fromCompiledToRaw(this.openTagEnd)},r])}_render(){let e=[];for(let t in this.attributes){let n=this.attributes[t];n.mustBeAdded&&(n.value==null?e.push(n.name):e.push(n.name+`="`+n.value+`"`))}this.id&&e.push(`_id="`+this.id+`"`);let t=``;return e.length>0&&(t=` `+e.join(` `)),this.selfClosing?`<${this.tagName}${t} />`:`<${this.tagName}${t}>${this.children.map(e=>e.render()).join(``)}</${this.tagName}>`}render(){return this.isContextEditing?``:this.isLoop?`<template _id="`+this.id+`"></template>`:this.isIf?this.id?`<template _id="`+this.id+`"></template>`:``:this._render()}replaceId(t){t.endsWith(`_`)||(t+=`_`),this.id=this.id.replace(this.idBase,t);let n={};for(let e in this.changes){let r=e.replace(this.idBase,t);n[r]=this.changes[e]}this.changes=n,this.ifInfo&&(this.ifInfo._id=this.ifInfo._id.replace(this.idBase,t)),this._idBase=t;for(let n of this.children)n instanceof e&&n.replaceId(t)}getTemplateInfo(t){let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},r=this.id,i=e=>{if(this.alias){let t=this.aliasMultiple?2:1;e.elements.push({name:this.alias,ids:[r],tags:{[this.tagName]:t},useLive:!1,isArray:t>1,positions:[{start:this.attributes[`@element`].valueStart,end:this.attributes[`@element`].valueEnd}]})}for(let t in this.changes)e.content[t]=this.changes[t];for(let t of this.injections){let n={id:r,injectionName:t.attr,inject:`@_@${t.injectTxt}@_@`};t.computedOnce&&(n.once=!0),e.injection.push(n)}for(let t of this.bindings){let n=[];n=t.event?[t.event]:[`input`,`textarea`].includes(this.tagName)?[`change`,`input`]:[`change`];let i={id:r,eventNames:n,injectionName:t.valueName,tagName:this.tagName,inject:`@_@${t.injectTxt}@_@`,extract:`@_@${t.extractTxt}@_@`};t.computedOnce&&(i.once=!0),e.bindings.push(i)}for(let t of this.eventsPerso)e.events.push({eventName:t.event,id:r,fct:t.fct,tagName:this.tagName,position:{start:t.start,end:t.end}});if(this.pressEvent&&e.pressEvents.push({...this.pressEvent,id:r}),this.contextEdit){let t={fct:this.contextEdit.fctJs};this.contextEdit.computedOnce&&(t.once=!0),e.contextEdits.push(t)}};if(this.loopInfo){let r={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},i=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);M.mergeTemplateResult(r,e)}i+=n.render()}let a={templateId:this.loopInfo.idTemplate||0,anchorId:this.id,template:i,actions:r,parentId:this.parentTemplateId};this.loopInfo.isSimple?a.simple=this.loopInfo.simple:a.func=this.loopInfo.complex.fct,n.loops.push(a)}else if(this.isIf&&this.ifInfo){let r=Number(this.attributes.id.value),i={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},a=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);M.mergeTemplateResult(i,e)}a+=n.render()}if(this.ifInfo.registerPart({template:a,templateId:r,templateAction:i,condition:``}),r==this.ifInfo.idsTemplate[this.ifInfo.idsTemplate.length-1]){let e={anchorId:this.ifInfo._id,parts:this.ifInfo.parts,parentId:this.parentTemplateId};n.ifs.push(e)}}else{i(n);for(let r of this.children)if(r instanceof e){let e=r.getTemplateInfo(t);M.mergeTemplateResult(n,e)}}return n}};const rr=[`area`,`base`,`br`,`col`,`embed`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`],ir=[`_id`];var ar=class{name=``;value=null;nameStart=0;nameEnd=0;valueStart=0;valueEnd=0;tag;mustBeAdded=!0;changes=[];constructor(e,t,n,r){this.name=e,this.nameStart=M.fromCompiledToRaw(t),this.nameEnd=M.fromCompiledToRaw(n),this.tag=r,this.manageSpecialAttribute()}manageSpecialAttribute(){this.name.startsWith(`@`)||this.name.startsWith(`:`)?(this.tag.createId(),this.mustBeAdded=!1):ir.includes(this.name)&&(M.addError(this.nameStart,this.nameEnd,`The attribute `+this.name+` is used by Aventus internally`),this.mustBeAdded=!1)}setValue(e,t,n){let r=e[0],i=r===`"`||r===`'`;if(i&&e.endsWith(r)&&(e=e.slice(1,-1)),this.value=e,this.valueStart=M.fromCompiledToRaw(t),this.valueEnd=M.fromCompiledToRaw(n),this.name!=`@for`)if(this.name===`@element`)this.tag.alias=e,M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`property`});else if(this.name.startsWith(`@bind`)||this.name.startsWith(`$`)){let r=new dr(this.tag.tagName,this.name,e,t,n);this.tag.bindings.push(r),M.addBinding(r)}else if(this.name.startsWith(`:`)){let r=new ur(this.tag.tagName,this.name.slice(1),e,t,n);this.tag.injections.push(r),M.addInjection(r)}else if(qn.hasOwnProperty(this.name))this.tag.pressEvent||(this.tag.pressEvent={}),this.tag.pressEvent[qn[this.name]]={value:e,start:this.valueStart,end:this.valueEnd},M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else if(this.name.startsWith(`@`))this.tag.eventsPerso.push({event:this.name.slice(1),fct:e,start:this.valueStart,end:this.valueEnd}),M.addInterestPoint({name:this.name.slice(1),start:this.nameStart,end:this.nameEnd,type:`event`}),M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else{let n=M.fromCompiledToRaw(t+ +!!i),r=fr(e,n,this.tag.tagName,this.name);this.changes=r.changes,r.changes.length>0&&(this.tag.addChanges(this.name,r.txt,r.once),this.mustBeAdded=!1)}}},or=class{content=``;start=0;end=0;tag;mustBeAdded=!0;changes=[];constructor(e,t,n,r,i=!0){this.content=e,this.start=M.fromCompiledToRaw(t),this.end=M.fromCompiledToRaw(n),this.tag=r,i&&this.manageVariables()}manageVariables(){let e=this.content,t=fr(e,this.start);this.changes=t.changes,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:``}},sr=class e{static tagName=`l`;idTemplate=0;isSimple=!1;transformations=[];start=0;startBlock=0;end=0;loopTxt=``;loopName=``;isValid=!0;typeToLoad=[];simple={data:``};complex={init:[],condition:``,transform:[],apply:[],loopName:``,fct:``};get variableNames(){return this.typeToLoad.map(e=>e.txt)}variables=[];sliceText;constructor(e,t){this.sliceText=t,this.idTemplate=M.createIdTemplate(),this.variables=M.getVariables(),e.kind==p.SyntaxKind.ForOfStatement||e.kind==p.SyntaxKind.ForInStatement?(this.isSimple=!0,this.loadForInOf(e)):this.loadFor(e),this.loopName=M.getCustomFctName()??``}loadForInOf(t){let n=0;(0,p.forEachChild)(t,r=>{if(n==0){let e=r.getChildAt(1),n=e.getStart(),i=e.getEnd(),a=this.sliceText(n,i);t.kind==p.SyntaxKind.ForInStatement?this.simple.index=a:this.simple.item=a,this.typeToLoad.push({txt:a,start:n,end:i})}else if(n==1)this.simple.data=this.sliceText(r.getStart(),r.getEnd());else if(n==2){let n=t.getStart(),i=r.getStart()+1;this.loopTxt=this.sliceText(n,i)+` }`;let a=`<`+e.tagName+` id="`+this.idTemplate+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o}),this.start=n,this.startBlock=i,this.end=s}n++})}loadFor(t){let n=[],r=[],i=``,a=[],o=0,s=``;if((0,p.forEachChild)(t,c=>{if(o==0&&c.kind==p.SyntaxKind.VariableDeclarationList)(0,p.forEachChild)(c,e=>{let t=e.getChildAt(0),i=t.getStart(),a=t.getEnd(),o=this.sliceText(i,a);n.push(`let `+e.getText()),r.push(e.getChildAt(0).getText()),this.typeToLoad.push({txt:o,start:i,end:a})});else if(o==1&&c.kind==p.SyntaxKind.BinaryExpression)i=c.getText();else if(o==2){let e=t=>{t.kind==p.SyntaxKind.BinaryExpression&&t.getChildAt(1).getText()==`,`?(e(t.getChildAt(0)),e(t.getChildAt(2))):a.push(t.getText())};e(c)}else if(o==3&&c.kind==p.SyntaxKind.Block){let n=t.getStart(),r=c.getStart()+1;s=this.sliceText(n,r)+` }`,this.loopTxt=s;let i=`<`+e.tagName+` id="`+this.idTemplate+`">`,a=`</`+e.tagName+`>`;this.transformations.push({start:n,end:r,newText:i});let o=c.getEnd();this.transformations.push({start:o-1,end:o,newText:a}),this.start=n,this.startBlock=r,this.end=o}o++}),this.transformations.length==0&&(this.isValid=!1),!this.checkIsSimple(n,i,a)){let e=M.getCustomFctName(1)??``;this.complex={init:n,condition:i,transform:a,apply:r,loopName:e,fct:`(c) => c.comp.${e}`}}}recalculateVariables(){if(this.variables=pr(this.loopTxt,M.getVariables()),!this.isSimple){let e=this.variables.map(e=>`c.data.`+e).join(`,`);this.complex.fct+=`(${e})`}}checkIsSimple(e,t,n){if(e.length!=1)return!1;let r=e[0].split(`=`);if(r.length!=2)return!1;let i=r[0].replace(`let `,``).trim();if(r[1].trim()!=`0`)return!1;let a=RegExp(`\\s*`+i+`\\s*<\\s*([a-zA-Z0-9\\._\\[\\]-]+)\\.length`).exec(t);if(!a)return!1;let o=a[1];return n.length!=1||!RegExp(`\\s*`+i+`\\+\\+\\s*`).exec(n[0])?!1:(this.isSimple=!0,this.simple={data:o,index:i},!0)}},cr=class e{static tagName=`if`;statements=[];idsTemplate=[];defaultVariables=[];transformations=[];end=0;_id=``;parts=[];isValid=!0;conditions=[];sliceText;constructor(e,t){this.sliceText=t,this.defaultVariables=M.getVariables(),this.loadIf(e)}loadIf(t){let n=[],r=()=>{let e=M.createIdTemplate();return this.idsTemplate.push(e),e},i=(t,n,r)=>{let i=r.getStart()+1,a=`<`+e.tagName+` id="`+t+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o})},a=(e,t=0,o)=>{let s=0;o===void 0&&(o=e.getStart());let c=o,l;for(let t of e.getChildren())t.kind==p.SyntaxKind.ElseKeyword&&(l=t.getStart());let u=r();(0,p.forEachChild)(e,o=>{if(o.kind==p.SyntaxKind.Block){if(s++,s==2){if(l==null)throw`impossible`;i(r(),l,o)}else i(u,c,o);n.push(o)}else if(o.kind==p.SyntaxKind.IfStatement){if(l==null)throw`impossible`;a(o,t+1,l)}else if(o===e.expression){let e=M.getCustomFctName(this.conditions.length)??``,n=this.sliceText(o.getStart(),o.getEnd());this.conditions.push({fctName:e,txt:n,fctTxt:`(c) => c.comp.${e}`,start:o.getStart(),end:o.getEnd(),offsetAfter:0,offsetBefore:0,idTemplate:u,type:t==0?`if`:`elif`,variables:[],computedOnce:mr(n)})}}),s==0&&(this.isValid=!1)};a(t)}registerPart(e){this.conditions.length>this.parts.length?(e.condition=this.conditions[this.parts.length].fctTxt,e.once=this.conditions[this.parts.length].computedOnce):(e.condition=`(c) => true`,e.once=!0),this.parts.push(e)}recalculateVariables(e){let t=M.getVariables();for(let n of this.conditions)if(n.idTemplate==e){let e=pr(n.txt,t),r=e.map(e=>`c.data.`+e).join(`,`);n.fctTxt+=`(${r})`,n.variables=e}}},lr=class e{static tagName=`c`;sliceText;variables=[];transformations=[];id;fctTs=``;fctJs=``;editName;start=0;end=0;mapping=[``,``];computedOnce=!1;typeToLoad=[];get variableNames(){return this.typeToLoad.map(e=>e.txt)}constructor(e,t){this.sliceText=t,this.editName=M.getCustomFctName()??``,this.id=M.createIdTemplate(),this.loadContextEditing(e)}loadContextEditing(t){this.start=t.getStart(),this.end=t.getEnd(),this.transformations.push({start:t.getStart(),end:t.getEnd(),newText:`<`+e.tagName+` id="`+this.id+`"></`+e.tagName+`>`}),(0,p.forEachChild)(t,e=>{if(e.kind==p.SyntaxKind.CallExpression){let t=e,n=`{ `,r=0;for(let e of t.arguments)n+=e.getText(),r==0&&(this.typeToLoad.push({txt:e.getText().replace(/['`"]/g,``),start:e.getStart(),end:e.getEnd()}),n+=`: `),this.mapping[r]=e.getText(),r++;n+=` }`,this.fctTs=`return `+n,this.computedOnce=mr(this.fctTs)}}),this.variables=pr(this.fctTs,M.getVariables());let n=this.variables.map(e=>`c.data.`+e).join(`,`);this.fctJs=`@_@(c) => c.comp.${this.editName}(${n})@_@`}},ur=class{start=0;end=0;attr;injectFctName;injectTsTxt;injectTxt;variables=[];computedOnce=!1;tagName;attributeName;constructor(e,t,n,r,i){this.tagName=e,this.attributeName=t,this.attr=t,this.start=M.fromCompiledToRaw(r),this.end=M.fromCompiledToRaw(i),this.injectFctName=M.getCustomFctName()??``,this.injectTsTxt=n,this.computedOnce=mr(n),this.variables=pr(n,M.getVariables());let a=this.variables.map(e=>`c.data.`+e).join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${a})`}},dr=class{start=0;end=0;event;valueName=`value`;injectFctName;extractFctName;injectTsTxt;extractTsCond;extractTsTxt;injectTxt;extractTxt;variables=[];computedOnce=!1;tagName;attributeName;constructor(e,t,n,r,i){this.tagName=e;let a=t.split(`:`),o=a[0];o.startsWith(`@bind_`)?this.event=o.replace(`@bind_`,``):o.startsWith(`$`)&&o.length>0&&(this.event=o.replace(`$`,``)),a.length>1&&(this.valueName=a[1]),this.attributeName=this.valueName,this.start=M.fromCompiledToRaw(r),this.end=M.fromCompiledToRaw(i),this.injectFctName=M.getCustomFctName()??``,this.extractFctName=M.getCustomFctName(1)??``,this.injectTsTxt=n,this.computedOnce=mr(n);let s=n.split(`.`);s.pop(),this.extractTsCond=s.join(`.`).trim(),this.extractTsCond.endsWith(`?`)&&(this.extractTsCond=this.extractTsCond.slice(0,this.extractTsCond.length-1)),this.extractTsTxt=n.replace(/\?/g,``),this.variables=pr(n,M.getVariables());let c=this.variables.map(e=>`c.data.`+e),l=[`v`].concat(c).join(`,`),u=c.join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${u})`,this.extractTxt=`(c, v) => c.comp.${this.extractFctName}(${l})`}};function fr(e,t,n,r){let i=/\{\{([\s|\S]*?)\}\}/g,a,o={changes:[],txt:e,variables:[],once:!0};for(;a=i.exec(e);){let e=t+a.index,i=t+a.index+a[0].length,s=M.createChange({txt:a[1],start:e,end:i,tagName:n,attributeName:r});if(o.once&&!mr(a[1])&&(o.once=!1),s){s.variables=pr(a[1],s.variables);let e=s.variables.map(e=>`c.data.`+e).join(`,`),t="${c.print(c.comp."+s.name+`(`+e+`))}`;o.txt=o.txt.replace(a[0],t).replace(/\r\n?/g,`
|
|
489
|
-
`),o.changes.push(s)}}return o.changes.length>0&&(o.txt="(c) => `"+o.txt+"`"),o}function pr(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 mr(e){return!/if|switch|\?|\[.+?\]|\|\||&&/g.test(e)}var N=class e extends gn{_compilationResult;canUpdateComponent=!0;viewMethodsInfo=[];viewValidationMappings=[];viewValidationStart=-1;viewValidationEnd=-1;viewGeneratedStart=-1;viewGeneratedEnd=-1;viewUserSuffixEnd=-1;viewValidatedMethods=new Map;storyBookInfo={argsTypes:{},args:{}};get compilationResult(){return this._compilationResult}get extension(){return E.ComponentLogic}get version(){let e=er.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(E.Component)?this.build.wcFiles[this.file.uri].view:this.build.htmlFiles[this.file.uri.replace(E.ComponentLogic,E.ComponentView)]}get SCSSFile(){return this.file.uri.endsWith(E.Component)?this.build.wcFiles[this.file.uri].style:this.build.scssFiles[this.file.uri.replace(E.ComponentLogic,E.ComponentStyle)]}get I18nFile(){return this.build.i18nComponentsFiles[this.file.uri.replace(E.ComponentLogic,E.I18n)]}_fullname=``;get fullName(){return this._fullname}get viewMethodName(){return`__`+
|
|
487
|
+
`)??``,values:[]}}}writeFileReplaceVar(e,t){let n=RegExp(`\\$`+e+`\\$`,`g`);this.template=this.template.replace(n,t+``)}writeFileHotReloadReplaceVar(e,t){if(yt.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=Ln(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(rs(this.document,r,`methods`,1019))),this.htmlFile&&this.htmlFile.tsErrors.push(os(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(rs(this.document,r,`variables`,1011)),this.htmlFile)for(let t of e.positions)this.htmlFile.tsErrors.push(os(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(R(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(R(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(ln.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,On.getCompilerOptionsCompile()).trim();return t=t.substring(0,t.length-1),t=`(`+t+`)`,t}catch{}return``}_validateTypeForProp(e,t,n){if(n.kind==`boolean`||n.kind==`number`||n.kind==`string`)return n;if(n.kind==`type`){if(n.value==`Date`||n.value==`DateTime`||n.value==`Time`)return n;{let r=j.getBaseInfo(n.value,this.build,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(R(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(R(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(R(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(R(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,``)}},tr=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=xn.is(e);if(t){t.writeHTML&&(this.writeHtml=!0),t.writeComponentTs&&(this.writeTs=!0);continue}if(!this.isAbstract){let t=zn.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}}},M=class e{static languageService=(0,w.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:T.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:T.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=Es(e.txt+`\0`+(e.tagName??``)+`\0`+(e.attributeName??``));if(this.currentParsingDoc.fcts[t])return this.currentParsingDoc.fcts[t].positions.push({start:e.start,end:e.end}),this.currentParsingDoc.fcts[t];{let n=this.getCustomFctName(),r=this.getVariables();if(n){let i={name:n,positions:[{start:e.start,end:e.end}],txt:e.txt,variables:r,tagName:e.tagName,attributeName:e.attributeName};return this.currentParsingDoc.fcts[t]=i,i}}}return null}static fromRawToCompiled(e){return this.currentParsingDoc?this.currentParsingDoc.fromRawToCompiled(e):e}static fromCompiledToRaw(e){return this.currentParsingDoc?this.currentParsingDoc.fromCompiledToRaw(e):e}static addLoopStack(e){if(this.currentParsingDoc){let t=this.currentParsingDoc.loops.find(t=>t.idTemplate==e);if(t)return t.recalculateVariables(),this.currentParsingDoc?.stacks.push(t),t}return null}static addIfStack(e){if(this.currentParsingDoc){for(let t of this.currentParsingDoc.ifs)if(t.idsTemplate.includes(e))return t.recalculateVariables(e),this.currentParsingDoc?.stacks.push({idTemplate:e}),t}return null}static addInjection(e){this.currentParsingDoc?.injections.push(e)}static addBinding(e){this.currentParsingDoc?.bindings.push(e)}static addTagInfoStack(e){this.currentParsingDoc?.stacks.push(e)}static getContextEditing(e){return this.currentParsingDoc?.contextEdits.find(t=>t.id==e)}static removeStack(){this.currentParsingDoc?.stacks.pop()}static getParentId(){if(this.currentParsingDoc&&this.currentParsingDoc.stacks.length>0)for(let e=this.currentParsingDoc.stacks.length-1;e>=0;e--){let t=this.currentParsingDoc.stacks[e];if(t instanceof sr||!(t instanceof nr))return t.idTemplate}}static getVariables(){let e=[];if(this.currentParsingDoc){for(let t of this.currentParsingDoc.stacks)if(t instanceof sr||t instanceof nr)for(let n of t.variableNames)e.includes(n)||e.push(n)}return e}uri;errors=[];document;rootTags=[];get validationRootTags(){return this.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),this.validateExpressions(t.file.documentUser),e.currentParsingDoc=null,this.isReady=!0;for(let e of this.readyCb)e()}validateExpressions(e){let t=[...this.injections,...this.bindings];for(let n of t){let t=(0,p.createSourceFile)(`expression.ts`,`const value = (${n.injectTsTxt});`,p.ScriptTarget.ESNext,!0).parseDiagnostics;for(let r of t)this.errors.push({range:m.Range.create(e.positionAt(n.start+1),e.positionAt(n.end-1)),severity:m.DiagnosticSeverity.Error,source:T.TypeScript,code:r.code,message:(0,p.flattenDiagnosticMessageText)(r.messageText,`
|
|
488
|
+
`)})}}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 cr(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 sr(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 lr(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()!=w.TokenType.EOS;)if(r.length>0){if(a.getTokenType()==w.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 or(i,n,r,e,!1))}}else if(a.getTokenType()==w.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()!=w.TokenType.StartTagOpen){if(a.getTokenType()==w.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()==w.TokenType.StartTagSelfClose){let e=o.pop();e&&(e.validateAllProps(a.getTokenOffset()),e.afterClose(a.getTokenOffset(),a.getTokenEnd()))}else if(a.getTokenType()==w.TokenType.StartTag){let e=a.getTokenText(),t=a.getTokenOffset(),n=a.getTokenEnd(),r=new nr(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()!=w.TokenType.EndTagOpen&&a.getTokenType()!=w.TokenType.EndTagClose){if(a.getTokenType()==w.TokenType.EndTag){let e=a.getTokenText(),n=o.pop();if(n&&n.tagName==e)n.afterClose(a.getTokenOffset(),a.getTokenEnd());else if(n){this.errors.push(os(t,`The tag `+n?.tagName+` isn't correctly closed`,n?.start,n?.end));let r=-1;for(let t=o.length-1;t>=0;t--)if(o[t].tagName==e){r=t;break}r>=0?(o.length=r+1,o.pop()?.afterClose(a.getTokenOffset(),a.getTokenEnd())):o.push(n)}else this.errors.push(os(t,`No opening tag found for `+e,a.getTokenOffset(),a.getTokenEnd()))}else if(a.getTokenType()!=w.TokenType.DelimiterAssign)if(a.getTokenType()==w.TokenType.AttributeName){let e=a.getTokenText();if(o.length>0){let t=o[o.length-1];s=new ar(e,a.getTokenOffset(),a.getTokenEnd(),t),t.addAttribute(s)}}else if(a.getTokenType()==w.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()==w.TokenType.Content){if(o.length>0){let e=o[o.length-1],t=a.getTokenText(),n=a.getTokenOffset(),r=a.getTokenEnd();e.addContent(new or(t,n,r,e))}}else a.getTokenType()==w.TokenType.Whitespace||a.getTokenType()==w.TokenType.Unknown||a.getTokenType()==w.TokenType.Script||(a.getTokenType(),w.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]}},nr=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==sr.tagName}get isIf(){return this.tagName==cr.tagName}get isContextEditing(){return this.tagName==lr.tagName}loopInfo;ifInfo;contextEdit;constructor(e,t,n,r){if(this.parser=e,this.tagName=t,this.start=n,this.openTagStart=n,this.end=r,this.isLoop){this.createId();return}this.isIf||this.isContextEditing||(M.addInterestPoint({name:t,start:M.fromCompiledToRaw(n),end:M.fromCompiledToRaw(r),type:`tag`}),rr.includes(t)&&(this.selfClosing=!0))}createId(){return this.id||(this.id=this.idBase+M.idElement,M.idElement++),this.id}addAttribute(e){if(e.name==`@for`){M.addError(e.nameStart,e.nameEnd,`Deprecated : use for directly inside template`);return}this.attributes[e.name]?M.addError(e.nameStart,e.nameEnd,`Duplicate attribute `+e.name):this.attributes[e.name]=e}addChild(e){this.children.push(e),e.parent=this}addContent(e){this.children.push(e)}addChanges(e,t,n){let r=this.createId()+`°`+e;this.changes[r]={fct:t,once:n}}validateAllProps(e){if(this.openTagEnd=e,this.alias){let e=this.alias.endsWith(`[]`);e&&(this.alias=this.alias.replace(`[]`,``)),e&&(this.aliasMultiple=e)}if(this.isLoop){this.parentTemplateId=M.getParentId();let e=M.addLoopStack(Number(this.attributes.id.value));e&&(this.loopInfo=e)}else if(this.isIf){this.parentTemplateId=M.getParentId();let e=Number(this.attributes.id.value),t=M.addIfStack(e);t&&(this.ifInfo=t,e==t.idsTemplate[0]&&(t._id=this.createId()))}else if(this.isContextEditing){this.parentTemplateId=M.getParentId();let e=Number(this.attributes.id.value),t=M.getContextEditing(e);if(t&&(this.contextEdit=t,this.parent))for(let e of t.variableNames)this.parent.variableNames.includes(e)||this.parent.variableNames.push(e)}M.addTagInfoStack(this)}afterClose(e,t){this.hasClose=!0,this.selfClosing||M.addInterestPoint({name:this.tagName,start:M.fromCompiledToRaw(e),end:M.fromCompiledToRaw(t),type:`tag`}),this.checkStyle(M.getRules(),e=>M.addStyleLink(e)),M.removeStack(),(this.isLoop||this.isIf)&&M.removeStack()}checkStyle(e,t){for(let[n,r]of e)n(this)&&t([{start:M.fromCompiledToRaw(this.openTagStart),end:M.fromCompiledToRaw(this.openTagEnd)},r])}_render(){let e=[];for(let t in this.attributes){let n=this.attributes[t];n.mustBeAdded&&(n.value==null?e.push(n.name):e.push(n.name+`="`+n.value+`"`))}this.id&&e.push(`_id="`+this.id+`"`);let t=``;return e.length>0&&(t=` `+e.join(` `)),this.selfClosing?`<${this.tagName}${t} />`:`<${this.tagName}${t}>${this.children.map(e=>e.render()).join(``)}</${this.tagName}>`}render(){return this.isContextEditing?``:this.isLoop?`<template _id="`+this.id+`"></template>`:this.isIf?this.id?`<template _id="`+this.id+`"></template>`:``:this._render()}replaceId(t){t.endsWith(`_`)||(t+=`_`),this.id=this.id.replace(this.idBase,t);let n={};for(let e in this.changes){let r=e.replace(this.idBase,t);n[r]=this.changes[e]}this.changes=n,this.ifInfo&&(this.ifInfo._id=this.ifInfo._id.replace(this.idBase,t)),this._idBase=t;for(let n of this.children)n instanceof e&&n.replaceId(t)}getTemplateInfo(t){let n={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},r=this.id,i=e=>{if(this.alias){let t=this.aliasMultiple?2:1;e.elements.push({name:this.alias,ids:[r],tags:{[this.tagName]:t},useLive:!1,isArray:t>1,positions:[{start:this.attributes[`@element`].valueStart,end:this.attributes[`@element`].valueEnd}]})}for(let t in this.changes)e.content[t]=this.changes[t];for(let t of this.injections){let n={id:r,injectionName:t.attr,inject:`@_@${t.injectTxt}@_@`};t.computedOnce&&(n.once=!0),e.injection.push(n)}for(let t of this.bindings){let n=[];n=t.event?[t.event]:[`input`,`textarea`].includes(this.tagName)?[`change`,`input`]:[`change`];let i={id:r,eventNames:n,injectionName:t.valueName,tagName:this.tagName,inject:`@_@${t.injectTxt}@_@`,extract:`@_@${t.extractTxt}@_@`};t.computedOnce&&(i.once=!0),e.bindings.push(i)}for(let t of this.eventsPerso)e.events.push({eventName:t.event,id:r,fct:t.fct,tagName:this.tagName,position:{start:t.start,end:t.end}});if(this.pressEvent&&e.pressEvents.push({...this.pressEvent,id:r}),this.contextEdit){let t={fct:this.contextEdit.fctJs};this.contextEdit.computedOnce&&(t.once=!0),e.contextEdits.push(t)}};if(this.loopInfo){let r={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},i=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);M.mergeTemplateResult(r,e)}i+=n.render()}let a={templateId:this.loopInfo.idTemplate||0,anchorId:this.id,template:i,actions:r,parentId:this.parentTemplateId};this.loopInfo.isSimple?a.simple=this.loopInfo.simple:a.func=this.loopInfo.complex.fct,n.loops.push(a)}else if(this.isIf&&this.ifInfo){let r=Number(this.attributes.id.value),i={elements:[],content:{},injection:[],bindings:[],events:[],pressEvents:[],loops:[],ifs:[],contextEdits:[]},a=``;for(let n of this.children){if(n instanceof e){let e=n.getTemplateInfo(t);M.mergeTemplateResult(i,e)}a+=n.render()}if(this.ifInfo.registerPart({template:a,templateId:r,templateAction:i,condition:``}),r==this.ifInfo.idsTemplate[this.ifInfo.idsTemplate.length-1]){let e={anchorId:this.ifInfo._id,parts:this.ifInfo.parts,parentId:this.parentTemplateId};n.ifs.push(e)}}else{i(n);for(let r of this.children)if(r instanceof e){let e=r.getTemplateInfo(t);M.mergeTemplateResult(n,e)}}return n}};const rr=[`area`,`base`,`br`,`col`,`embed`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`],ir=[`_id`];var ar=class{name=``;value=null;nameStart=0;nameEnd=0;valueStart=0;valueEnd=0;tag;mustBeAdded=!0;changes=[];constructor(e,t,n,r){this.name=e,this.nameStart=M.fromCompiledToRaw(t),this.nameEnd=M.fromCompiledToRaw(n),this.tag=r,this.manageSpecialAttribute()}manageSpecialAttribute(){this.name.startsWith(`@`)||this.name.startsWith(`:`)?(this.tag.createId(),this.mustBeAdded=!1):ir.includes(this.name)&&(M.addError(this.nameStart,this.nameEnd,`The attribute `+this.name+` is used by Aventus internally`),this.mustBeAdded=!1)}setValue(e,t,n){let r=e[0],i=r===`"`||r===`'`;if(i&&e.endsWith(r)&&(e=e.slice(1,-1)),this.value=e,this.valueStart=M.fromCompiledToRaw(t),this.valueEnd=M.fromCompiledToRaw(n),this.name!=`@for`)if(this.name===`@element`)this.tag.alias=e,M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`property`});else if(this.name.startsWith(`@bind`)||this.name.startsWith(`$`)){let r=new dr(this.tag.tagName,this.name,e,t,n);this.tag.bindings.push(r),M.addBinding(r)}else if(this.name.startsWith(`:`)){let r=new ur(this.tag.tagName,this.name.slice(1),e,t,n);this.tag.injections.push(r),M.addInjection(r)}else if(qn.hasOwnProperty(this.name))this.tag.pressEvent||(this.tag.pressEvent={}),this.tag.pressEvent[qn[this.name]]={value:e,start:this.valueStart,end:this.valueEnd},M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else if(this.name.startsWith(`@`))this.tag.eventsPerso.push({event:this.name.slice(1),fct:e,start:this.valueStart,end:this.valueEnd}),M.addInterestPoint({name:this.name.slice(1),start:this.nameStart,end:this.nameEnd,type:`event`}),M.addInterestPoint({name:e,start:this.nameStart,end:this.valueEnd,type:`method`});else{let n=M.fromCompiledToRaw(t+ +!!i),r=fr(e,n,this.tag.tagName,this.name);this.changes=r.changes,r.changes.length>0&&(this.tag.addChanges(this.name,r.txt,r.once),this.mustBeAdded=!1)}}},or=class{content=``;start=0;end=0;tag;mustBeAdded=!0;changes=[];constructor(e,t,n,r,i=!0){this.content=e,this.start=M.fromCompiledToRaw(t),this.end=M.fromCompiledToRaw(n),this.tag=r,i&&this.manageVariables()}manageVariables(){let e=this.content,t=fr(e,this.start);this.changes=t.changes,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:``}},sr=class e{static tagName=`l`;idTemplate=0;isSimple=!1;transformations=[];start=0;startBlock=0;end=0;loopTxt=``;loopName=``;isValid=!0;typeToLoad=[];simple={data:``};complex={init:[],condition:``,transform:[],apply:[],loopName:``,fct:``};get variableNames(){return this.typeToLoad.map(e=>e.txt)}variables=[];sliceText;constructor(e,t){this.sliceText=t,this.idTemplate=M.createIdTemplate(),this.variables=M.getVariables(),e.kind==p.SyntaxKind.ForOfStatement||e.kind==p.SyntaxKind.ForInStatement?(this.isSimple=!0,this.loadForInOf(e)):this.loadFor(e),this.loopName=M.getCustomFctName()??``}loadForInOf(t){let n=0;(0,p.forEachChild)(t,r=>{if(n==0){let e=r.getChildAt(1),n=e.getStart(),i=e.getEnd(),a=this.sliceText(n,i);t.kind==p.SyntaxKind.ForInStatement?this.simple.index=a:this.simple.item=a,this.typeToLoad.push({txt:a,start:n,end:i})}else if(n==1)this.simple.data=this.sliceText(r.getStart(),r.getEnd());else if(n==2){let n=t.getStart(),i=r.getStart()+1;this.loopTxt=this.sliceText(n,i)+` }`;let a=`<`+e.tagName+` id="`+this.idTemplate+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o}),this.start=n,this.startBlock=i,this.end=s}n++})}loadFor(t){let n=[],r=[],i=``,a=[],o=0,s=``;if((0,p.forEachChild)(t,c=>{if(o==0&&c.kind==p.SyntaxKind.VariableDeclarationList)(0,p.forEachChild)(c,e=>{let t=e.getChildAt(0),i=t.getStart(),a=t.getEnd(),o=this.sliceText(i,a);n.push(`let `+e.getText()),r.push(e.getChildAt(0).getText()),this.typeToLoad.push({txt:o,start:i,end:a})});else if(o==1&&c.kind==p.SyntaxKind.BinaryExpression)i=c.getText();else if(o==2){let e=t=>{t.kind==p.SyntaxKind.BinaryExpression&&t.getChildAt(1).getText()==`,`?(e(t.getChildAt(0)),e(t.getChildAt(2))):a.push(t.getText())};e(c)}else if(o==3&&c.kind==p.SyntaxKind.Block){let n=t.getStart(),r=c.getStart()+1;s=this.sliceText(n,r)+` }`,this.loopTxt=s;let i=`<`+e.tagName+` id="`+this.idTemplate+`">`,a=`</`+e.tagName+`>`;this.transformations.push({start:n,end:r,newText:i});let o=c.getEnd();this.transformations.push({start:o-1,end:o,newText:a}),this.start=n,this.startBlock=r,this.end=o}o++}),this.transformations.length==0&&(this.isValid=!1),!this.checkIsSimple(n,i,a)){let e=M.getCustomFctName(1)??``;this.complex={init:n,condition:i,transform:a,apply:r,loopName:e,fct:`(c) => c.comp.${e}`}}}recalculateVariables(){if(this.variables=pr(this.loopTxt,M.getVariables()),!this.isSimple){let e=this.variables.map(e=>`c.data.`+e).join(`,`);this.complex.fct+=`(${e})`}}checkIsSimple(e,t,n){if(e.length!=1)return!1;let r=e[0].split(`=`);if(r.length!=2)return!1;let i=r[0].replace(`let `,``).trim();if(r[1].trim()!=`0`)return!1;let a=RegExp(`\\s*`+i+`\\s*<\\s*([a-zA-Z0-9\\._\\[\\]-]+)\\.length`).exec(t);if(!a)return!1;let o=a[1];return n.length!=1||!RegExp(`\\s*`+i+`\\+\\+\\s*`).exec(n[0])?!1:(this.isSimple=!0,this.simple={data:o,index:i},!0)}},cr=class e{static tagName=`if`;statements=[];idsTemplate=[];defaultVariables=[];transformations=[];end=0;_id=``;parts=[];isValid=!0;conditions=[];sliceText;constructor(e,t){this.sliceText=t,this.defaultVariables=M.getVariables(),this.loadIf(e)}loadIf(t){let n=[],r=()=>{let e=M.createIdTemplate();return this.idsTemplate.push(e),e},i=(t,n,r)=>{let i=r.getStart()+1,a=`<`+e.tagName+` id="`+t+`">`,o=`</`+e.tagName+`>`;this.transformations.push({start:n,end:i,newText:a});let s=r.getEnd();this.transformations.push({start:s-1,end:s,newText:o})},a=(e,t=0,o)=>{let s=0;o===void 0&&(o=e.getStart());let c=o,l;for(let t of e.getChildren())t.kind==p.SyntaxKind.ElseKeyword&&(l=t.getStart());let u=r();(0,p.forEachChild)(e,o=>{if(o.kind==p.SyntaxKind.Block){if(s++,s==2){if(l==null)throw`impossible`;i(r(),l,o)}else i(u,c,o);n.push(o)}else if(o.kind==p.SyntaxKind.IfStatement){if(l==null)throw`impossible`;a(o,t+1,l)}else if(o===e.expression){let e=M.getCustomFctName(this.conditions.length)??``,n=this.sliceText(o.getStart(),o.getEnd());this.conditions.push({fctName:e,txt:n,fctTxt:`(c) => c.comp.${e}`,start:o.getStart(),end:o.getEnd(),offsetAfter:0,offsetBefore:0,idTemplate:u,type:t==0?`if`:`elif`,variables:[],computedOnce:mr(n)})}}),s==0&&(this.isValid=!1)};a(t)}registerPart(e){this.conditions.length>this.parts.length?(e.condition=this.conditions[this.parts.length].fctTxt,e.once=this.conditions[this.parts.length].computedOnce):(e.condition=`(c) => true`,e.once=!0),this.parts.push(e)}recalculateVariables(e){let t=M.getVariables();for(let n of this.conditions)if(n.idTemplate==e){let e=pr(n.txt,t),r=e.map(e=>`c.data.`+e).join(`,`);n.fctTxt+=`(${r})`,n.variables=e}}},lr=class e{static tagName=`c`;sliceText;variables=[];transformations=[];id;fctTs=``;fctJs=``;editName;start=0;end=0;mapping=[``,``];computedOnce=!1;typeToLoad=[];get variableNames(){return this.typeToLoad.map(e=>e.txt)}constructor(e,t){this.sliceText=t,this.editName=M.getCustomFctName()??``,this.id=M.createIdTemplate(),this.loadContextEditing(e)}loadContextEditing(t){this.start=t.getStart(),this.end=t.getEnd(),this.transformations.push({start:t.getStart(),end:t.getEnd(),newText:`<`+e.tagName+` id="`+this.id+`"></`+e.tagName+`>`}),(0,p.forEachChild)(t,e=>{if(e.kind==p.SyntaxKind.CallExpression){let t=e,n=`{ `,r=0;for(let e of t.arguments)n+=e.getText(),r==0&&(this.typeToLoad.push({txt:e.getText().replace(/['`"]/g,``),start:e.getStart(),end:e.getEnd()}),n+=`: `),this.mapping[r]=e.getText(),r++;n+=` }`,this.fctTs=`return `+n,this.computedOnce=mr(this.fctTs)}}),this.variables=pr(this.fctTs,M.getVariables());let n=this.variables.map(e=>`c.data.`+e).join(`,`);this.fctJs=`@_@(c) => c.comp.${this.editName}(${n})@_@`}},ur=class{start=0;end=0;attr;injectFctName;injectTsTxt;injectTxt;variables=[];computedOnce=!1;tagName;attributeName;constructor(e,t,n,r,i){this.tagName=e,this.attributeName=t,this.attr=t,this.start=M.fromCompiledToRaw(r),this.end=M.fromCompiledToRaw(i),this.injectFctName=M.getCustomFctName()??``,this.injectTsTxt=n,this.computedOnce=mr(n),this.variables=pr(n,M.getVariables());let a=this.variables.map(e=>`c.data.`+e).join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${a})`}},dr=class{start=0;end=0;event;valueName=`value`;injectFctName;extractFctName;injectTsTxt;extractTsCond;extractTsTxt;injectTxt;extractTxt;variables=[];computedOnce=!1;tagName;attributeName;constructor(e,t,n,r,i){this.tagName=e;let a=t.split(`:`),o=a[0];o.startsWith(`@bind_`)?this.event=o.replace(`@bind_`,``):o.startsWith(`$`)&&o.length>0&&(this.event=o.replace(`$`,``)),a.length>1&&(this.valueName=a[1]),this.attributeName=this.valueName,this.start=M.fromCompiledToRaw(r),this.end=M.fromCompiledToRaw(i),this.injectFctName=M.getCustomFctName()??``,this.extractFctName=M.getCustomFctName(1)??``,this.injectTsTxt=n,this.computedOnce=mr(n);let s=n.split(`.`);s.pop(),this.extractTsCond=s.join(`.`).trim(),this.extractTsCond.endsWith(`?`)&&(this.extractTsCond=this.extractTsCond.slice(0,this.extractTsCond.length-1)),this.extractTsTxt=n.replace(/\?/g,``),this.variables=pr(n,M.getVariables());let c=this.variables.map(e=>`c.data.`+e),l=[`v`].concat(c).join(`,`),u=c.join(`,`);this.injectTxt=`(c) => c.comp.${this.injectFctName}(${u})`,this.extractTxt=`(c, v) => c.comp.${this.extractFctName}(${l})`}};function fr(e,t,n,r){let i=/\{\{([\s|\S]*?)\}\}/g,a,o={changes:[],txt:e,variables:[],once:!0};for(;a=i.exec(e);){let e=t+a.index,i=t+a.index+a[0].length,s=M.createChange({txt:a[1],start:e,end:i,tagName:n,attributeName:r});if(o.once&&!mr(a[1])&&(o.once=!1),s){s.variables=pr(a[1],s.variables);let e=s.variables.map(e=>`c.data.`+e).join(`,`),t="${c.print(c.comp."+s.name+`(`+e+`))}`;o.txt=o.txt.replace(a[0],t).replace(/\r\n?/g,`
|
|
489
|
+
`),o.changes.push(s)}}return o.changes.length>0&&(o.txt="(c) => `"+o.txt+"`"),o}function pr(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 mr(e){return!/if|switch|\?|\[.+?\]|\|\||&&/g.test(e)}var N=class e extends gn{_compilationResult;canUpdateComponent=!0;viewMethodsInfo=[];viewValidationMappings=[];viewValidationStart=-1;viewValidationEnd=-1;viewGeneratedStart=-1;viewGeneratedEnd=-1;viewUserSuffixEnd=-1;viewValidatedMethods=new Map;storyBookInfo={argsTypes:{},args:{}};get compilationResult(){return this._compilationResult}get extension(){return E.ComponentLogic}get version(){let e=er.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(E.Component)?this.build.wcFiles[this.file.uri].view:this.build.htmlFiles[this.file.uri.replace(E.ComponentLogic,E.ComponentView)]}get SCSSFile(){return this.file.uri.endsWith(E.Component)?this.build.wcFiles[this.file.uri].style:this.build.scssFiles[this.file.uri.replace(E.ComponentLogic,E.ComponentStyle)]}get I18nFile(){return this.build.i18nComponentsFiles[this.file.uri.replace(E.ComponentLogic,E.I18n)]}_fullname=``;get fullName(){return this._fullname}get viewMethodName(){return`__`+Es(this.fullName)+`method`}_componentEnd=0;get componentEnd(){return this._componentEnd}_componentClassName=``;get componentClassName(){return this._componentClassName}_space=``;writeHtml=!1;writeTs=!1;needRebuild=!1;async revalidateAfterDependencyChange(){this.needRebuild=!0,await super.revalidateAfterDependencyChange()}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=er.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 er(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,s=!1;if(this.lastFileVersionCreated.js==this.file.documentUser.version?this.lastFileVersionCreated.html==t?this.lastFileVersionCreated.i18n!=r&&(a=!0):(a=!0,s=!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.viewGeneratedStart=a.length,this.viewMethodsInfo=[],this.viewValidationMappings=[],this.viewValidationStart=-1,this.viewValidationEnd=-1,this.viewValidatedMethods.clear();let c=0,l=``,u=e=>{let t=[];for(let n of e){let e=this.typeInfered[n]??`any`;t.push(n+`:`+e)}return t},m=(e,t)=>{if(!e||!t)return`Aventus.NotVoid`;let n=this.build.getWebComponentDefinition(e),r=n?.class.getField(t);if(!n||!r||r.isPrivate||r.isProtected||r.isStatic)return`Aventus.NotVoid`;let i=n.class.fullName;if(n.class.fileUri==this.file.uri)i=n.class.name;else if(n.isLocal){let e=(0,f.relative)((0,f.dirname)(L(this.file.uri)),L(n.class.fileUri)).replace(/\\/g,`/`);e.startsWith(`.`)||(e=`./`+e),i=`import(${JSON.stringify(e)}).${n.class.name}`}return`InstanceType<typeof ${i}>[${JSON.stringify(t)}]`};(()=>{let t=e.fileParsed?.validationRootTags??[];if(!t.length)return;let n=this._space;this.viewValidationStart=a.length,a+=`\n${n}@NoCompile()\n${n}private ${this.viewMethodName}ValidateView(): void {\n`;let r=(e,t,r,i)=>{let o=a.length;a+=`${n} void ((`;let s=a.length;a+=e;let c=a.length;a+=`) satisfies ${i});\n`,this.viewValidationMappings.push({generatedStart:s,generatedEnd:c,statementStart:o,statementEnd:a.length,sourceStart:t,sourceEnd:r})},i=(e,t,i,o)=>{let s=(0,p.createSourceFile)(`view-expression.ts`,e,p.ScriptTarget.ESNext,!0),c=s.statements;if(!c.length)return!1;if(c.length===1&&(0,p.isExpressionStatement)(c[0])&&c[0].expression.getText(s)===e.trim().replace(/;$/,``))return r(e,t,i,o),!0;let l=c[c.length-1];if(!(0,p.isExpressionStatement)(l)&&!(0,p.isReturnStatement)(l))return!1;let u=(0,p.isExpressionStatement)(l)?l.expression.getStart(s):-1,d=e;u>=0&&(d=e.slice(0,u)+`return `+e.slice(u));let f=a.length;a+=`${n} void (((() => {\n`;let m=a.length;a+=d;let h=a.length;return a+=`\n})()) satisfies ${o});\n`,this.viewValidationMappings.push({generatedStart:m,generatedEnd:h,statementStart:f,statementEnd:a.length,sourceStart:t,sourceEnd:i,insertedAt:u>=0?m+u:void 0,insertedLength:u>=0?7:void 0}),!0},o=(e,t,n,r)=>{let a=t.matchAll(/\{\{([\s\S]*?)\}\}/g),o=0;for(let t of a){let a=e[o++];if(!a)continue;let s=n+t.index+2,c=n+t.index+t[0].length-2;i(a.txt,s,c,r)&&this.viewValidatedMethods.set(a.name,(this.viewValidatedMethods.get(a.name)??0)+1)}},s=e=>{for(let t=0;t<e.length;t++){let r=e[t];if(r instanceof or){o(r.changes,r.content,r.start,`Aventus.NotVoid`);continue}if(r.isIf&&r.ifInfo){let i=r.ifInfo,o=[],c=t;for(let n=t;n<e.length&&o.length<i.idsTemplate.length;n++){let t=e[n];if(t instanceof or){if(t.changes.length)break;continue}o.push(t),c=n}let l=o.some((e,t)=>!e.isIf||e.ifInfo!==i||Number(e.attributes.id?.value)!==i.idsTemplate[t]);if(o.length!==i.idsTemplate.length||l)continue;for(let e=0;e<o.length;e++){let t=o[e],r=i.conditions[e];a+=r?`${n} ${e===0?`if`:`else if`} (${r.txt}) {\n`:`${n} else {\n`,s(t.children),a+=`${n} }\n`}t=c}else if(r.isLoop&&r.loopInfo){let e=r.loopInfo.loopTxt.replace(/\s*}\s*$/,``),t=a.length;a+=`${n} `;let i=a.length;a+=`${e}\n`,this.viewValidationMappings.push({generatedStart:i,generatedEnd:i+e.length,statementStart:t,statementEnd:a.length,sourceStart:r.loopInfo.start,sourceEnd:r.loopInfo.startBlock}),this.viewValidatedMethods.set(r.loopInfo.loopName,1);let o=r.loopInfo.variableNames.filter(e=>/^[A-Za-z_$][\w$]*$/.test(e)),c=o.map((e,t)=>`__avtLoop${r.loopInfo.idTemplate}_${t}`);for(let e=0;e<o.length;e++)a+=`${n} const ${c[e]} = ${o[e]};\n`;if(o.length){let e=o.map((e,t)=>`${e}: typeof ${c[t]}`);a+=`${n} ((${e.join(`, `)}) => {\n`}s(r.children),o.length&&(a+=`${n} })(${c.join(`, `)});\n`),a+=`${n} }\n`}else if(r.isContextEditing&&r.contextEdit){let e=r.contextEdit.mapping[0].replace(/['"`]/g,``),t=r.contextEdit.mapping[1];/^[A-Za-z_$][\w$]*$/.test(e)&&t&&(a+=`${n} const ${e} = ${t};\n`)}else if(!r.isContextEditing){for(let e of r.injections)i(e.injectTsTxt,e.start+1,e.end-1,m(e.tagName,e.attributeName));for(let e of r.bindings)i(e.injectTsTxt,e.start+1,e.end-1,m(e.tagName,e.attributeName));for(let e of Object.values(r.attributes)){let t=m(r.tagName,e.name);o(e.changes,e.value??``,e.valueStart+1,`string extends ${t} ? Aventus.NotVoid : ${t}`)}s(r.children)}}};s(t),a+=`${n}}`,this.viewValidationEnd=a.length})(),(o||s)&&(()=>{if(!e)return;let t=e.fileParsed?.loops??[],n=0;for(let e of t){let t=u(e.variables),r=a;r+=`/** */\n@NoCompile()\nprivate ${e.loopName}(${t.join(`,`)}): void {\n`;let o=r.length;r+=e.loopTxt+`
|
|
490
490
|
`,r+=`}
|
|
491
|
-
`,r+=`}`,this.file instanceof O&&(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=
|
|
491
|
+
`,r+=`}`,this.file instanceof O&&(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=u(e.variables),r=a;r+=`/** */\n@NoCompile()\nprivate ${e.editName}(${t.join(`,`)}): void {\n`;let o=r.length;r+=e.fctTs+`
|
|
492
492
|
`,r+=`}
|
|
493
|
-
`,r+=`}`,this.file instanceof O&&(this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,(i+n)*-1,r)),this._contentForLanguageService=r);for(let t of e.typeToLoad){let n=o+(Math.floor((t.start+t.end)/2)-e.start),r=this.tsLanguageService.getType(this,n)??`any`;this.typeInfered[t.txt]=r}}})();let
|
|
494
|
-
`;let o=a.length;a+=r+`}`,this.viewMethodsInfo.push(
|
|
493
|
+
`,r+=`}`,this.file instanceof O&&(this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,(i+n)*-1,r)),this._contentForLanguageService=r);for(let t of e.typeToLoad){let n=o+(Math.floor((t.start+t.end)/2)-e.start),r=this.tsLanguageService.getType(this,n)??`any`;this.typeInfered[t.txt]=r}}})();let h=e.fileParsed?.loops??[];for(let e of h){let t=a.length,n=u(e.variables),r=this._space;a+=`\n${r}/** */\n${r}@NoCompile()\n${r}private ${e.loopName}(${n.join(`,`)}): void {\n`;let i=a.length;a+=e.loopTxt+`
|
|
494
|
+
`;let o=a.length;a+=r+`}`,this.viewMethodsInfo.push({name:e.loopName,fullStart:t,start:i,end:o,offsetBefore:0,offsetAfter:0,kind:`loop`,validatedExpression:this.viewValidatedMethods.has(e.loopName),fct:{txt:e.loopTxt,positions:[{start:e.start,end:e.startBlock}]},transform(e,t){return t}}),e.isSimple||(a+=`\n${r}/** */\n${r}private ${e.complex.loopName}(${n.join(`,`)}) {\n
|
|
495
495
|
${e.complex.init.join(`;
|
|
496
496
|
`)}
|
|
497
497
|
return {
|
|
@@ -506,24 +506,24 @@ this.clearWatchHistory = () => {
|
|
|
506
506
|
return ({${e.complex.apply}})
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
|
-
}`)}let
|
|
510
|
-
`).length,e?.startsWith(` `)?(r.push(`return`+e),
|
|
511
|
-
`);let i=a.length,o=
|
|
512
|
-
`;let
|
|
513
|
-
`).length,e?.startsWith(` `)?(r.push(`return`+e),
|
|
514
|
-
`);let i=a.length,o=
|
|
515
|
-
`;let d=a.length;a+=
|
|
516
|
-
`;let o=a.length;a+=r+`}`,this.viewMethodsInfo.push(function(){return{name:e.editName,fullStart:t,start:i,end:o,offsetBefore:0,offsetAfter:0,kind:`context`,fct:{txt:e.fctTs,positions:[{start:e.start,end:e.end}]},transform(e,t){return t}}}())}let
|
|
509
|
+
}`)}let g=e.fileParsed?.fcts??{};for(let e of Object.values(g)){let t=e.txt.replace(/\n/g,`;`),n=-1,r=t.split(`;`);if(!t.includes(`return `)&&r.length>0){let e=r.pop();n=r.join(`
|
|
510
|
+
`).length,e?.startsWith(` `)?(r.push(`return`+e),c=6):(r.push(`return `+e),c=7)}t=r.join(`
|
|
511
|
+
`);let i=a.length,o=u(e.variables),s=m(e.tagName,e.attributeName),l=this._space;a+=`\n${l}/** */\n${l}private ${e.name}(${o.join(`,`)}): ${s} {\n`;let d=a.length;a+=t+`
|
|
512
|
+
`;let f=a.length;a+=l+`}`,this.viewMethodsInfo.push(((t,n)=>({name:e.name,fullStart:i,start:d,end:f,fct:e,offsetBefore:2,offsetAfter:2,kind:`fct`,validatedExpression:this.viewValidatedMethods.get(e.name)===e.positions.length,transform(e,r){return e>=t&&(r+=n),r}}))(n,c))}let _=e.fileParsed?.ifs??[];for(let e of _)for(let t of e.conditions){let e=t.txt.replace(/\n/g,`;`),n=-1,r=e.split(`;`);if(!e.includes(`return `)&&r.length>0){let e=r.pop();n=r.join(`
|
|
513
|
+
`).length,e?.startsWith(` `)?(r.push(`return`+e),c=6):(r.push(`return `+e),c=7)}e=r.join(`
|
|
514
|
+
`);let i=a.length,o=u(t.variables),s=this._space;a+=`\n${s}/** */\n${s}private ${t.fctName}(${o.join(`,`)}): Aventus.NotVoid {\n`;let l=a.length;a+=e+`
|
|
515
|
+
`;let d=a.length;a+=s+`}`,this.viewMethodsInfo.push(function(n,r){return{name:t.fctName,fullStart:i,start:l,end:d,kind:`if`,fct:{positions:[{start:t.start,end:t.end}],txt:e},offsetBefore:t.offsetBefore,offsetAfter:t.offsetAfter,transform(e,t){return e>=n&&(t+=r),t}}}(n,c))}let v=e.fileParsed?.contextEdits??[];for(let e of v){let t=a.length,n=u(e.variables),r=this._space;a+=`\n${r}/** */\n${r}private ${e.editName}(${n.join(`,`)}): { [key: string]: any } {\n`;let i=a.length;a+=e.fctTs+`
|
|
516
|
+
`;let o=a.length;a+=r+`}`,this.viewMethodsInfo.push(function(){return{name:e.editName,fullStart:t,start:i,end:o,offsetBefore:0,offsetAfter:0,kind:`context`,fct:{txt:e.fctTs,positions:[{start:e.start,end:e.end}]},transform(e,t){return t}}}())}let y=e=>{let t=e.injectTsTxt.replace(/\n/g,`;`),n=-1,r=0,i=t.split(`;`);if(!t.includes(`return `)&&i.length>0){let e=i.pop();n=i.join(`
|
|
517
517
|
`).length,e?.startsWith(` `)?(i.push(`return`+e),r=6):(i.push(`return `+e),r=7)}t=i.join(`
|
|
518
|
-
`);let o=a.length,s=
|
|
519
|
-
`;let h=a.length;a+=c+`}`,this.viewMethodsInfo.push(((t,n)=>({name:e.injectFctName,fullStart:o,start:
|
|
518
|
+
`);let o=a.length,s=u(e.variables),c=this._space,l=m(e.tagName,e.attributeName),d=this.viewValidationMappings.some(t=>t.sourceStart===e.start+1);if(d){let e=(0,p.createSourceFile)(`view-helper.ts`,t,p.ScriptTarget.ESNext,!0),n=e.statements.filter(p.isReturnStatement);for(let i of n.reverse())if(i.expression){let n=i.expression.getStart(e),a=i.expression.end;t=t.slice(0,n)+`(`+t.slice(n,a)+`) as unknown as ${l}`+t.slice(a),r+=1}}a+=`\n${c}/** */\n${c}private ${e.injectFctName}(${s.join(`,`)}): ${l} {\n`;let f=a.length;a+=t+`
|
|
519
|
+
`;let h=a.length;a+=c+`}`,this.viewMethodsInfo.push(((t,n)=>({name:e.injectFctName,fullStart:o,start:f,end:h,fct:{txt:e.injectTsTxt,positions:[{start:e.start,end:e.end}]},offsetBefore:1,offsetAfter:1,kind:`fct`,validatedExpression:d,transform(e,r){return e>=t&&(r+=n),r}}))(n,r))},b=e.fileParsed?.injections??[];for(let e of b)y(e);let x=e.fileParsed?.bindings??[];for(let e of x){y(e);let t,n=u(e.variables),r=0,i=`v`;for(;e.variables.includes(i);)r++,i=`v`+r;n=[i+`: any`].concat(n),t=e.extractTsCond.length==0?e.extractTsTxt.replace(/\n/g,`;`)+` = `+i:`if( `+e.extractTsCond+` ) { `+e.extractTsTxt.replace(/\n/g,`;`)+` = `+i+` }`;let o=this._space;a+=`\n${o}/** */\n${o}private ${e.extractFctName}(${n.join(`,`)}): void {\n`,a.length,a+=t+`
|
|
520
520
|
`,a.length,a+=o+`}`}this.build.buildConfig.i18n&&n&&(e=>{let t=`\n@NoCompile()\npublic override t(key: keyof ${this.componentClassName}__Generated | keyof Aventus.AventusI18n, params: { [key: string]: string; } = {}): string {
|
|
521
521
|
return super.t(key as keyof Aventus.AventusI18n, params);
|
|
522
522
|
}`;a+=t+`
|
|
523
523
|
`;let n=e.keys.map(e=>`"${e.replace(/"/g,`\\"`)}": string`).join(`,
|
|
524
|
-
`);
|
|
524
|
+
`);l+=`\ntype ${this.componentClassName}__Generated = {
|
|
525
525
|
${n}
|
|
526
|
-
}`})(n),this.viewGeneratedEnd=a.length,a+=t.slice(this.componentEnd-r),this.viewUserSuffixEnd=a.length,a+=c,this.file instanceof O&&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)&&ks(s),this.writeTs?(0,u.writeFileSync)(c,a):(0,u.existsSync)(c)&&ks(c)}}else this.file instanceof O&&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?.file instanceof O?await this.HTMLFile.file.validate(!1):await 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;if(a>=this.viewValidationStart&&a<this.viewValidationEnd){let t=this.viewValidationMappings.find(e=>a<e.statementEnd&&o>e.statementStart);if(t){let r=t.sourceStart,s=t.sourceEnd;if(a>=t.generatedStart&&o<=t.generatedEnd){let e=t.insertedAt??2**53-1,n=t.insertedLength??0;(o<=e||a>=e+n)&&(r=t.sourceStart+a-t.generatedStart-(a>=e?n:0),s=t.sourceStart+o-t.generatedStart-(o>e?n:0))}n.push({...i,source:T.HTML,range:{start:e.file.documentInternal.positionAt(r),end:e.file.documentInternal.positionAt(s)}})}continue}let l=this.viewMethodsInfo.find(e=>a>e.fullStart&&o<e.end);if(!l?.validatedExpression){if(l){i.source=T.HTML;let t=l.fct,c=l.offsetAfter,u=l.offsetBefore;if(r.indexOf(i.range)==-1){let s=l.transform(a,0);r.push(i.range);let d=a-l.start-s,f=o-l.start-s;for(let r=0;r<t.positions.length;r++){let a=t.positions[r].start,o=t.positions[r].end,s=i;r>0&&(s={...i});let l=a+u+d,p=a+u+f;l<a||p>o-c?s.range={start:e.file.documentInternal.positionAt(a),end:e.file.documentInternal.positionAt(o)}:s.range={start:e.file.documentInternal.positionAt(l),end:e.file.documentInternal.positionAt(p)},r>0&&n.push(s)}}s=!0}s?n.push(i):c||t.push(i)}}this.diagnostics=t,this.htmlDiagnostics=n}else this.htmlDiagnostics=[]}quickParse(){let e=tr.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 super.onSave(),await this.runWebCompiler(),this.compilationResult?this.setCompileResult(this.compilationResult.result):this.setCompileResult([]),this.compilationResult?.writeCompiled?(0,u.writeFileSync)(this.file.folderPath+`/compiled.js`,ms(this.compilationResult.debug,this.build.project.getConfig())):(0,u.existsSync)(this.file.folderPath+`/compiled.js`)&&ks(this.file.folderPath+`/compiled.js`),this.canUpdateComponent||=!0}emitToHtttpServer(e){if(!this.canUpdateComponent)return;let t={};for(let n of e)t[n.name]=n.src;let n=!1,r=``,i=``,a;if(this.compilationResult)for(let e of this.compileResult)e.classScript!=``&&t[e.classScript]&&t[e.classScript]!=e.compiled&&(e.classScript==this.compilationResult.componentName?(n=!0,r=e.hotReload,i=e.classScript,a=this.fileParsed?.classes[i]):this.build.reloadPage=!0);if(!this.build.reloadPage&&n&&a){let e=this.buildNamespace;a.namespace&&(e+=a.namespace),e.length>0&&!e.endsWith(`.`)&&(e+=`.`),yt.getInstance().updateComponent(r,e+i,[])}}async onDelete(){let e=this.I18nFile;e&&(e.transformForExport(),await e.validate()),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=T.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=this.viewGeneratedStart>=0&&this.viewGeneratedEnd>=this.viewGeneratedStart,c=t>=this.file.contentUser.length;if(s&&(c=t<this.viewGeneratedEnd&&r>this.viewGeneratedStart||t>=this.viewGeneratedStart&&t<this.viewGeneratedEnd||r>this.viewUserSuffixEnd),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}}if(!i&&!c){if(s&&t>=this.viewGeneratedEnd){let n=this.viewGeneratedEnd-this.viewGeneratedStart;e.range={start:this.file.documentUser.positionAt(t-n),end:this.file.documentUser.positionAt(r-n)}}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)}})}return[...r,...n]}mapGeneratedRangeToView(e){let t=this.HTMLFile;if(!t||this.viewGeneratedStart<0)return null;let n=this._file.documentInternal.offsetAt(e.start),r=this._file.documentInternal.offsetAt(e.end);if(n>=this.viewValidationStart&&n<this.viewValidationEnd){let e=this.viewValidationMappings.find(e=>n>=e.generatedStart&&r<=e.generatedEnd);if(!e)return[];let i=e.insertedAt??2**53-1,a=e.insertedLength??0;if(n<i+a&&r>i)return[];let o=e.sourceStart+n-e.generatedStart-(n>=i?a:0),s=e.sourceStart+r-e.generatedStart-(r>i?a:0);return[{start:t.file.documentInternal.positionAt(o),end:t.file.documentInternal.positionAt(s)}]}let i=this.viewMethodsInfo.find(e=>n>e.fullStart&&r<e.end);if(!i){let e=n>=this.viewGeneratedStart&&n<this.viewGeneratedEnd,t=n>=this.viewUserSuffixEnd;return e||t?[]:null}if(i.validatedExpression)return[];let a=i.transform(n,0),o=n-i.start-a,s=r-i.start-a;return i.fct.positions.flatMap(e=>{let n=e.start+i.offsetBefore+o,r=e.start+i.offsetBefore+s;return n<e.start||r>e.end-i.offsetAfter?[]:[{start:t.file.documentInternal.positionAt(n),end:t.file.documentInternal.positionAt(r)}]})}mapInternalRangeToUser(e){if(this.viewGeneratedStart<0)return null;let t=this._file.documentInternal.offsetAt(e.start),n=this._file.documentInternal.offsetAt(e.end);if(t<this.viewGeneratedEnd||n>this.viewUserSuffixEnd)return null;let r=this.viewGeneratedEnd-this.viewGeneratedStart;return{start:this.file.documentUser.positionAt(t-r),end:this.file.documentUser.positionAt(n-r)}}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){return this.tsLanguageService.onRename(e,t,n)}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()
|
|
526
|
+
}`})(n),this.viewGeneratedEnd=a.length,a+=t.slice(this.componentEnd-r),this.viewUserSuffixEnd=a.length,a+=l,this.file instanceof O&&this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,i,a))}this.refreshFileParsed();let c=(0,f.join)(this.file.folderPath,`compiled.html`),l=(0,f.join)(this.file.folderPath,`compiled.ts`);this.writeHtml?(0,u.writeFileSync)(c,this.HTMLFile?.fileParsed?.compiledTxt??``):(0,u.existsSync)(c)&&Ds(c),this.writeTs?(0,u.writeFileSync)(l,a):(0,u.existsSync)(l)&&Ds(l)}}else this.file instanceof O&&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&&await this.HTMLFile.file.validate(this.HTMLFile.file.uri!==this.file.uri),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;if(a>=this.viewValidationStart&&a<this.viewValidationEnd){let t=this.viewValidationMappings.find(e=>a<e.statementEnd&&o>e.statementStart);if(t){let r=t.sourceStart,s=t.sourceEnd;if(a>=t.generatedStart&&o<=t.generatedEnd){let e=t.insertedAt??2**53-1,n=t.insertedLength??0;(o<=e||a>=e+n)&&(r=t.sourceStart+a-t.generatedStart-(a>=e?n:0),s=t.sourceStart+o-t.generatedStart-(o>e?n:0))}n.push({...i,source:T.HTML,range:{start:e.file.documentInternal.positionAt(r),end:e.file.documentInternal.positionAt(s)}})}continue}let l=this.viewMethodsInfo.find(e=>a>e.fullStart&&o<e.end);if(!l?.validatedExpression){if(l){i.source=T.HTML;let t=l.fct,c=l.offsetAfter,u=l.offsetBefore;if(r.indexOf(i.range)==-1){let s=l.transform(a,0);r.push(i.range);let d=a-l.start-s,f=o-l.start-s;for(let r=0;r<t.positions.length;r++){let a=t.positions[r].start,o=t.positions[r].end,s=i;r>0&&(s={...i});let l=a+u+d,p=a+u+f;l<a||p>o-c?s.range={start:e.file.documentInternal.positionAt(a),end:e.file.documentInternal.positionAt(o)}:s.range={start:e.file.documentInternal.positionAt(l),end:e.file.documentInternal.positionAt(p)},r>0&&n.push(s)}}s=!0}s?n.push(i):c||t.push(i)}}this.diagnostics=t,this.htmlDiagnostics=n}else this.htmlDiagnostics=[]}quickParse(){let e=tr.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 super.onSave(),await this.runWebCompiler(),this.compilationResult?this.setCompileResult(this.compilationResult.result):this.setCompileResult([]),this.compilationResult?.writeCompiled?(0,u.writeFileSync)(this.file.folderPath+`/compiled.js`,fs(this.compilationResult.debug,this.build.project.getConfig())):(0,u.existsSync)(this.file.folderPath+`/compiled.js`)&&Ds(this.file.folderPath+`/compiled.js`),this.canUpdateComponent||=!0}emitToHtttpServer(e){if(!this.canUpdateComponent)return;let t={};for(let n of e)t[n.name]=n.src;let n=!1,r=``,i=``,a;if(this.compilationResult)for(let e of this.compileResult)e.classScript!=``&&t[e.classScript]&&t[e.classScript]!=e.compiled&&(e.classScript==this.compilationResult.componentName?(n=!0,r=e.hotReload,i=e.classScript,a=this.fileParsed?.classes[i]):this.build.reloadPage=!0);if(!this.build.reloadPage&&n&&a){let e=this.buildNamespace;a.namespace&&(e+=a.namespace),e.length>0&&!e.endsWith(`.`)&&(e+=`.`),yt.getInstance().updateComponent(r,e+i,[])}}async onDelete(){let e=this.I18nFile;e&&(e.transformForExport(),await e.validate()),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;await this.runWebCompiler();let n=t.file.documentInternal.offsetAt(e),r=this.viewValidationMappings.find(e=>e.insertedAt===void 0&&n>=e.sourceStart&&n<=e.sourceEnd);if(r){let e=r.generatedStart+n-r.sourceStart,i=this.file.documentInternal.positionAt(e),a=await this.tsLanguageService.doComplete(this.file,i);return a.items=a.items.filter(e=>{if(e.label.startsWith(this.viewMethodName)||e.additionalTextEdits?.length)return!1;e.data?.uri&&(e.data.languageId=T.HTML,e.data.uri=t.file.uri);let n=e.textEdit;if(!n?.range)return!0;let i=this.file.documentInternal.offsetAt(n.range.start),a=this.file.documentInternal.offsetAt(n.range.end);return i<r.generatedStart||a>r.generatedEnd?!1:(n.range={start:t.file.documentInternal.positionAt(r.sourceStart+i-r.generatedStart),end:t.file.documentInternal.positionAt(r.sourceStart+a-r.generatedStart)},!0)}),a}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=T.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=this.viewGeneratedStart>=0&&this.viewGeneratedEnd>=this.viewGeneratedStart,c=t>=this.file.contentUser.length;if(s&&(c=t<this.viewGeneratedEnd&&r>this.viewGeneratedStart||t>=this.viewGeneratedStart&&t<this.viewGeneratedEnd||r>this.viewUserSuffixEnd),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}}if(!i&&!c){if(s&&t>=this.viewGeneratedEnd){let n=this.viewGeneratedEnd-this.viewGeneratedStart;e.range={start:this.file.documentUser.positionAt(t-n),end:this.file.documentUser.positionAt(r-n)}}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)}})}return[...r,...n]}mapGeneratedRangeToView(e){let t=this.HTMLFile;if(!t||this.viewGeneratedStart<0)return null;let n=this._file.documentInternal.offsetAt(e.start),r=this._file.documentInternal.offsetAt(e.end);if(n>=this.viewValidationStart&&n<this.viewValidationEnd){let e=this.viewValidationMappings.find(e=>n>=e.generatedStart&&r<=e.generatedEnd);if(!e)return[];let i=e.insertedAt??2**53-1,a=e.insertedLength??0;if(n<i+a&&r>i)return[];let o=e.sourceStart+n-e.generatedStart-(n>=i?a:0),s=e.sourceStart+r-e.generatedStart-(r>i?a:0);return[{start:t.file.documentInternal.positionAt(o),end:t.file.documentInternal.positionAt(s)}]}let i=this.viewMethodsInfo.find(e=>n>e.fullStart&&r<e.end);if(!i){let e=n>=this.viewGeneratedStart&&n<this.viewGeneratedEnd,t=n>=this.viewUserSuffixEnd;return e||t?[]:null}if(i.validatedExpression)return[];let a=i.transform(n,0),o=n-i.start-a,s=r-i.start-a;return i.fct.positions.flatMap(e=>{let n=e.start+i.offsetBefore+o,r=e.start+i.offsetBefore+s;return n<e.start||r>e.end-i.offsetAfter?[]:[{start:t.file.documentInternal.positionAt(n),end:t.file.documentInternal.positionAt(r)}]})}mapInternalRangeToUser(e){if(this.viewGeneratedStart<0)return null;let t=this._file.documentInternal.offsetAt(e.start),n=this._file.documentInternal.offsetAt(e.end);if(t<this.viewGeneratedEnd||n>this.viewUserSuffixEnd)return null;let r=this.viewGeneratedEnd-this.viewGeneratedStart;return{start:this.file.documentUser.positionAt(t-r),end:this.file.documentUser.positionAt(n-r)}}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){return this.tsLanguageService.onRename(e,t,n)}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()
|
|
527
527
|
protected `+t+`!: `+this.compilationResult.missingViewElements.elements[t]+`;
|
|
528
528
|
`}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+=`/**
|
|
529
529
|
*
|
|
@@ -558,83 +558,83 @@ protected ${t}(){
|
|
|
558
558
|
`?(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]===`
|
|
559
559
|
`?(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})),Zr=o(((e,t)=>{let n=Xr();var r=class extends n{constructor(e){super(e),this.type=`comment`}};t.exports=r,r.default=r})),Qr=o(((e,t)=>{let n=Xr();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})),$r=o(((e,t)=>{let n=Zr(),r=Qr(),i=Xr(),{isClean:a,my:o}=Yr(),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)})}})),ei=o(((e,t)=>{let n=$r();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)})),ti=o(((e,t)=>{let n=$r(),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)})),ni=o(((e,t)=>{let n={comma(e){return n.split(e,[`,`],!0)},space(e){return n.split(e,[` `,`
|
|
560
560
|
`,` `])},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})),ri=o(((e,t)=>{let n=$r(),r=ni();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)})),ii=o(((e,t)=>{let n=ei(),r=Zr(),i=Qr(),a=ti(),o=ri(),s=Gr(),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})}}})),ai=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||=[]}}})),oi=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=[],S;function C(){return y}function ee(t){throw e.error(`Unclosed `+t,y)}function te(){return x.length===0&&y>=v}function ne(){let e=1,t=!1,n=!1;for(;e>0;)u+=1,s.length<=u&&ee(`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 w(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(S=1,m=!1,u=y+1;u<=s.length-1;){if(g=s.charCodeAt(u),g===92)m=!m;else if(g===40)S+=1;else if(g===41&&(--S,S===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&&ee(`string`),l=s.charCodeAt(u),g=s.charCodeAt(u+1),!(!m&&l===d));)l===92?m=!m:m?m=!1:l===35&&g===123&&ne();_=[`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,ne(),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:ee(`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 re(e){x.push(e)}return{back:re,endOfFile:te,nextToken:w,position:C}}})),si=o(((e,t)=>{let{Comment:n}=require("postcss"),r=ii(),i=ai(),a=oi();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(`
|
|
561
|
-
`))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}}}})),ci=o(((e,t)=>{let{Input:n}=require("postcss"),r=si();t.exports=function(e,t){let i=new r(new n(e,t));return i.parse(),i.root}})),li=o(((e,t)=>{let n=Ur();t.exports={parse:ci(),stringify:n}})),ui=l(Br()),di=s({default:()=>pi,parse:()=>hi,stringify:()=>mi}),fi=l(li(),1),pi=fi.default;const mi=fi.default.stringify,hi=fi.default.parse;function gi(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 _i(e,t){let n=gi(e,t),r=[];for(;n;)r.unshift(n),n=n.parent;return r}var vi=class e{static referencedPath(e,t){let n=[e];for(let t of _e)n.push(e+t);let r=(0,f.dirname)(e),i=(0,f.basename)(e);for(let e of _e)n.push((0,f.resolve)(r,`_`+i+e));return n.push((0,f.resolve)(r,`_`+i)),n.some(e=>es(e,t))}static updatedSpecifier(e,t,n){let r=(0,f.relative)((0,f.dirname)(e),n).split(f.sep).join(`/`);if((0,f.isAbsolute)(r))return null;if(!_e.some(e=>t.endsWith(e))){let e=_e.find(e=>r.endsWith(e));e&&(r=r.slice(0,-e.length));let t=r.lastIndexOf(`/`);r[t+1]===`_`&&(r=r.slice(0,t+1)+r.slice(t+2))}return r.startsWith(`.`)||(r=`./`+r),r}static getScssRenameEdits(e,t){let n=e.getText(),r=L(e.uri),i=[];try{hi(n).walkAtRules(a=>{if(![`import`,`use`,`forward`].includes(a.name)||!a.source?.start)return;let o=e.offsetAt({line:a.source.start.line-1,character:a.source.start.column-1}),s=n.indexOf(a.params,o+a.name.length+1);if(s===-1)return;let c=a.params.replace(/\/\*[\s\S]*?\*\//g,e=>` `.repeat(e.length));for(let n of c.matchAll(/(['"])([^'"\r\n]+)\1/g)){let a=n[2];if(/url\(\s*$/i.test(c.slice(0,n.index))||a.startsWith(`@`)||/^([a-z]+:|\/\/)/i.test(a))continue;let o=(0,f.resolve)((0,f.dirname)(r),a);for(let c of t){let t=L(c.oldUri);if(!_e.some(e=>t.endsWith(e))||!this.referencedPath(o,t))continue;let l=this.updatedSpecifier(r,a,L(c.newUri));if(!l||l===a)break;let u=s+n.index+1;i.push({range:{start:e.positionAt(u),end:e.positionAt(u+a.length)},newText:l});break}}})}catch{return[]}return i}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,ie.getSCSSLanguageService)()}getRenameFileEdits(t,n){return e.getScssRenameEdits(t.documentUser,n)}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.languageService.parseStylesheet(e.documentUser);if(this.languageService.findDefinition(e.documentUser,t,n)?.uri===e.documentUser.uri)return this.languageService.doHover(e.documentUser,t,n);let r=this.getElementAtPosition(e,t);if(r?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(r.getText());if(e)return{contents:{kind:`plaintext`,value:e.name+`: `+e.value}}}return this.languageService.doHover(e.documentUser,t,n)}async findDefinition(e,t){let n=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));if(n?.uri===e.documentUser.uri)return[n];let r=this.getElementAtPosition(e,t);if(r?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(r.getText());if(e)return[{uri:e.uri,range:e.range}]}return n&&[n]}async format(e,t,n){let r={...n,preserveNewLines:!0,spaceAroundSelectorSeparator:!0,insertFinalNewline:!0,insertSpaces:!1,tabSize:4},i=e.documentUser,a=await this.languageService.format(i,t,r);if(a.length==1){let e=i.offsetAt(a[0].range.start),t=i.offsetAt(a[0].range.end),n=i.getText().length;if(e==0&&t==n){let e=await(0,re.default)([(0,ui.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:di,syntax:di,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.findDefinition(e.documentUser,t,n)?.uri===e.documentUser.uri?this.languageService.findReferences(e.documentUser,t,n):this.build.globalSCSSLanguageService.getGlobalReferences(e.documentUser,t,this.build)||this.languageService.findReferences(e.documentUser,t,n)}onRename(e,t,n){let r=this.languageService.parseStylesheet(e.documentUser);if(this.languageService.findDefinition(e.documentUser,t,r)?.uri!==e.documentUser.uri)return this.build.globalSCSSLanguageService.onRename(e.documentUser,t,n);let i=n.startsWith(`--`)?n:`--${n}`;if(!/^--[a-zA-Z_][a-zA-Z0-9_-]*$/.test(i))return null;let a=this.languageService.findReferences(e.documentUser,t,r);return{changes:{[e.documentUser.uri]:a.map(e=>({range:e.range,newText:i}))}}}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=_i(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=(n,s=null)=>{if(n.type==3){let o=n.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 n=o[0]?.getChildren()[0],c=null;if(n){for(let t of n.getChildren())if(t.type==5){c?c.start>t.offset?c.start=t.offset:c.end<t.offset+t.length&&(c.end=t.offset+t.length):c={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&&(s=a(s,e))}else{t.getText();let r=e.documentUser.positionAt(n.offset);$.warning(`css node to implement : `+e.documentUser.uri+`:`+r.line+`:`+r.character)}s&&c&&t.set(s,c)}}}else if(n.type==21)return;if(n.hasChildren())for(let e of n.getChildren())o(e,s)},s=_i(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,`
|
|
561
|
+
`))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}}}})),ci=o(((e,t)=>{let{Input:n}=require("postcss"),r=si();t.exports=function(e,t){let i=new r(new n(e,t));return i.parse(),i.root}})),li=o(((e,t)=>{let n=Ur();t.exports={parse:ci(),stringify:n}})),ui=l(Br()),di=s({default:()=>pi,parse:()=>hi,stringify:()=>mi}),fi=l(li(),1),pi=fi.default;const mi=fi.default.stringify,hi=fi.default.parse;function gi(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 _i(e,t){let n=gi(e,t),r=[];for(;n;)r.unshift(n),n=n.parent;return r}var vi=class e{static referencedPath(e,t){let n=[e];for(let t of _e)n.push(e+t);let r=(0,f.dirname)(e),i=(0,f.basename)(e);for(let e of _e)n.push((0,f.resolve)(r,`_`+i+e));return n.push((0,f.resolve)(r,`_`+i)),n.some(e=>Qo(e,t))}static updatedSpecifier(e,t,n){let r=(0,f.relative)((0,f.dirname)(e),n).split(f.sep).join(`/`);if((0,f.isAbsolute)(r))return null;if(!_e.some(e=>t.endsWith(e))){let e=_e.find(e=>r.endsWith(e));e&&(r=r.slice(0,-e.length));let t=r.lastIndexOf(`/`);r[t+1]===`_`&&(r=r.slice(0,t+1)+r.slice(t+2))}return r.startsWith(`.`)||(r=`./`+r),r}static getScssRenameEdits(e,t){let n=e.getText(),r=L(e.uri),i=[];try{hi(n).walkAtRules(a=>{if(![`import`,`use`,`forward`].includes(a.name)||!a.source?.start)return;let o=e.offsetAt({line:a.source.start.line-1,character:a.source.start.column-1}),s=n.indexOf(a.params,o+a.name.length+1);if(s===-1)return;let c=a.params.replace(/\/\*[\s\S]*?\*\//g,e=>` `.repeat(e.length));for(let n of c.matchAll(/(['"])([^'"\r\n]+)\1/g)){let a=n[2];if(/url\(\s*$/i.test(c.slice(0,n.index))||a.startsWith(`@`)||/^([a-z]+:|\/\/)/i.test(a))continue;let o=(0,f.resolve)((0,f.dirname)(r),a);for(let c of t){let t=L(c.oldUri);if(!_e.some(e=>t.endsWith(e))||!this.referencedPath(o,t))continue;let l=this.updatedSpecifier(r,a,L(c.newUri));if(!l||l===a)break;let u=s+n.index+1;i.push({range:{start:e.positionAt(u),end:e.positionAt(u+a.length)},newText:l});break}}})}catch{return[]}return i}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,ie.getSCSSLanguageService)()}getRenameFileEdits(t,n){return e.getScssRenameEdits(t.documentUser,n)}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.languageService.parseStylesheet(e.documentUser);if(this.languageService.findDefinition(e.documentUser,t,n)?.uri===e.documentUser.uri)return this.languageService.doHover(e.documentUser,t,n);let r=this.getElementAtPosition(e,t);if(r?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(r.getText());if(e)return{contents:{kind:`plaintext`,value:e.name+`: `+e.value}}}return this.languageService.doHover(e.documentUser,t,n)}async findDefinition(e,t){let n=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));if(n?.uri===e.documentUser.uri)return[n];let r=this.getElementAtPosition(e,t);if(r?.type==1){let e=this.build.globalSCSSLanguageService.getDefinition(r.getText());if(e)return[{uri:e.uri,range:e.range}]}return n&&[n]}async format(e,t,n){let r={...n,preserveNewLines:!0,spaceAroundSelectorSeparator:!0,insertFinalNewline:!0,insertSpaces:!1,tabSize:4},i=e.documentUser,a=await this.languageService.format(i,t,r);if(a.length==1){let e=i.offsetAt(a[0].range.start),t=i.offsetAt(a[0].range.end),n=i.getText().length;if(e==0&&t==n){let e=await(0,re.default)([(0,ui.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:di,syntax:di,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.findDefinition(e.documentUser,t,n)?.uri===e.documentUser.uri?this.languageService.findReferences(e.documentUser,t,n):this.build.globalSCSSLanguageService.getGlobalReferences(e.documentUser,t,this.build)||this.languageService.findReferences(e.documentUser,t,n)}onRename(e,t,n){let r=this.languageService.parseStylesheet(e.documentUser);if(this.languageService.findDefinition(e.documentUser,t,r)?.uri!==e.documentUser.uri)return this.build.globalSCSSLanguageService.onRename(e.documentUser,t,n);let i=n.startsWith(`--`)?n:`--${n}`;if(!/^--[a-zA-Z_][a-zA-Z0-9_-]*$/.test(i))return null;let a=this.languageService.findReferences(e.documentUser,t,r);return{changes:{[e.documentUser.uri]:a.map(e=>({range:e.range,newText:i}))}}}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=_i(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=(n,s=null)=>{if(n.type==3){let o=n.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 n=o[0]?.getChildren()[0],c=null;if(n){for(let t of n.getChildren())if(t.type==5){c?c.start>t.offset?c.start=t.offset:c.end<t.offset+t.length&&(c.end=t.offset+t.length):c={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&&(s=a(s,e))}else{t.getText();let r=e.documentUser.positionAt(n.offset);$.warning(`css node to implement : `+e.documentUser.uri+`:`+r.line+`:`+r.character)}s&&c&&t.set(s,c)}}}else if(n.type==21)return;if(n.hasChildren())for(let e of n.getChildren())o(e,s)},s=_i(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,`
|
|
562
562
|
`).split(`
|
|
563
563
|
`);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(`
|
|
564
|
-
`).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)};return i((0,ie.getSCSSLanguageService)().parseStylesheet(t)),Object.values(n)}},yi=class e extends it{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(E.ComponentStyle,E.ComponentView)];return e instanceof bi?e:null}get isGlobal(){return this.file.name.startsWith(`@`)}get globalName(){return this.file.name.replace(E.ComponentStyle,``)}constructor(e,t){super(e,t),this.namespace=this.build.getNamespace(e.uri)}getRenameFileEdits(e){return this.build.scssLanguageService.getRenameFileEdits(this.file,e)}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)await 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,o=``,s=0;for(;a=i.exec(t);){o+=t.slice(s,a.index);let c=a[2],l=await this.resolvePath(c,e.folderPath);if(l){let e=await r(l);if(e==n)return e;o+=e,s=i.lastIndex}else return n}return o+t.slice(s)},i=await r(this.file);if(i!=`|error|`)try{this.customProperties=vi.getCustomProperty(i),i=i.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let e=(0,ae.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 ae.Exception){this.diagnosticCompile=os(this.file.documentUser,e.message);let t=[...this.diagnostics,this.diagnosticCompile];$.sendDiagnostics({uri:this.file.uri,diagnostics:t},this.build)}else $.error(e)}else t=``;if(t!=this.compiledTxt)if(this.compiledVersion++,this.compiledTxt=t,this.isGlobal)yt.getInstance().updateGlobalCSS(this.globalName,this.compiledTxt),this.build.build();else{let t=this.build.tsFiles[this.file.uri.replace(E.ComponentStyle,E.ComponentLogic)];if(t instanceof N&&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+=`.`),yt.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(E.ComponentStyle,E.ComponentView)];a instanceof bi&&M.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){let t=this.usedBy[e];delete t.dependencies[this.file.uri],delete this.usedBy[e],!t.file.isDeleted&&(await t.validate(),await t.onSave())}this.build.scssFiles[this.file.uri]===this&&delete this.build.scssFiles[this.file.uri]}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 this.build.scssLanguageService.onRename(e,t,n)}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(ss(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(E.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=z.getInstance().getByPath(e);if(t)return t;if((0,u.existsSync)(e)&&(0,u.lstatSync)(e).isFile()){let t=d.TextDocument.create(I(e),T.SCSS,1,(0,u.readFileSync)(e,`utf-8`));return await z.getInstance().registerFile(t),z.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+E.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+E.ComponentStyle;if(n=await this.getByPath(o),n)return n}},bi=class extends it{fileParsed;tsErrors=[];version=-1;codeactions=[];get compiledVersion(){return this.version}get tsFile(){let e=this.build.tsFiles[this.file.uri.replace(E.ComponentView,E.ComponentLogic)];return e instanceof N?e:null}get scssFile(){let e=this.build.scssFiles[this.file.uri.replace(E.ComponentView,E.ComponentStyle)];return e instanceof yi?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=M.parse(this,this.build);let e=M.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));let i={start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText};t.some(e=>e.start==i.start&&e.end==i.end&&e.txt==i.txt)||t.push(i);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[`<`+sr.tagName+` id="`+n+`">`]=r}for(let e of this.fileParsed.loops)i.has(e)||(o[`<`+sr.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[`<`+cr.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[`<`+cr.tagName+` id="`+t.idTemplate+`">`]=e}e.conditions.length!=e.idsTemplate.length&&(o[`<`+cr.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[`<`+lr.tagName+` id="`+e.id+`"></`+lr.tagName+`>`]=r}return o[`</`+sr.tagName+`>`]=`}`,o[`</`+cr.tagName+`>`]=`}`,o}async applyHtmlFormatting(e,t,n,r){if(!this.fileParsed)return[];let i=this.fileParsed?.compiledTxt;for(let e in r)if(e.startsWith(`{{`)){let t=new RegExp(e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),`g`);i=i.replace(t,r[e])}let a=[];i=i.replace(/\{\{[\s\S]*?\}\}/g,e=>`___AVENTUS_INTERPOLATION_${a.push(e)-1}___`);let o=d.TextDocument.create(e.documentUser.uri,e.documentUser.languageId,e.documentUser.version,i),s={start:o.positionAt(0),end:o.positionAt(i.length)},c=(await this.build.htmlLanguageService.format(o,s,n))[0].newText;for(let e in r){if(e.startsWith(`{{`))continue;let t=new RegExp(e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),`g`);c=c.replace(t,r[e])}return c=c.replace(/___AVENTUS_INTERPOLATION_(\d+)___/g,(e,t)=>a[Number(t)]),c=c.replace(/\{\{\s*([\s\S]*?\S)\s*\}\}/g,`{{ $1 }}`),[{newText:c,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){let n=await this.tsFile?.doReferences(t);return n?.length?n: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 xi=[{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`}],Si={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`},Ci={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}) {
|
|
564
|
+
`).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)};return i((0,ie.getSCSSLanguageService)().parseStylesheet(t)),Object.values(n)}},yi=class e extends it{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(E.ComponentStyle,E.ComponentView)];return e instanceof bi?e:null}get isGlobal(){return this.file.name.startsWith(`@`)}get globalName(){return this.file.name.replace(E.ComponentStyle,``)}constructor(e,t){super(e,t),this.namespace=this.build.getNamespace(e.uri)}getRenameFileEdits(e){return this.build.scssLanguageService.getRenameFileEdits(this.file,e)}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)await 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,o=``,s=0;for(;a=i.exec(t);){o+=t.slice(s,a.index);let c=a[2],l=await this.resolvePath(c,e.folderPath);if(l){let e=await r(l);if(e==n)return e;o+=e,s=i.lastIndex}else return n}return o+t.slice(s)},i=await r(this.file);if(i!=`|error|`)try{this.customProperties=vi.getCustomProperty(i),i=i.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let e=(0,ae.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 ae.Exception){this.diagnosticCompile=is(this.file.documentUser,e.message);let t=[...this.diagnostics,this.diagnosticCompile];$.sendDiagnostics({uri:this.file.uri,diagnostics:t},this.build)}else $.error(e)}else t=``;if(t!=this.compiledTxt)if(this.compiledVersion++,this.compiledTxt=t,this.isGlobal)yt.getInstance().updateGlobalCSS(this.globalName,this.compiledTxt),this.build.build();else{let t=this.build.tsFiles[this.file.uri.replace(E.ComponentStyle,E.ComponentLogic)];if(t instanceof N&&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+=`.`),yt.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(E.ComponentStyle,E.ComponentView)];a instanceof bi&&M.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){let t=this.usedBy[e];delete t.dependencies[this.file.uri],delete this.usedBy[e],!t.file.isDeleted&&(await t.validate(),await t.onSave())}this.build.scssFiles[this.file.uri]===this&&delete this.build.scssFiles[this.file.uri]}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 this.build.scssLanguageService.onRename(e,t,n)}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(as(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(E.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=z.getInstance().getByPath(e);if(t)return t;if((0,u.existsSync)(e)&&(0,u.lstatSync)(e).isFile()){let t=d.TextDocument.create(I(e),T.SCSS,1,(0,u.readFileSync)(e,`utf-8`));return await z.getInstance().registerFile(t),z.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+E.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+E.ComponentStyle;if(n=await this.getByPath(o),n)return n}},bi=class extends it{fileParsed;tsErrors=[];version=-1;codeactions=[];get compiledVersion(){return this.version}get tsFile(){let e=this.build.tsFiles[this.file.uri.replace(E.ComponentView,E.ComponentLogic)];return e instanceof N?e:null}get scssFile(){let e=this.build.scssFiles[this.file.uri.replace(E.ComponentView,E.ComponentStyle)];return e instanceof yi?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=M.parse(this,this.build);let e=M.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));let i={start:e.edit.range.start-e.start,end:e.edit.range.end-e.start,txt:e.edit.newText};t.some(e=>e.start==i.start&&e.end==i.end&&e.txt==i.txt)||t.push(i);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[`<`+sr.tagName+` id="`+n+`">`]=r}for(let e of this.fileParsed.loops)i.has(e)||(o[`<`+sr.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[`<`+cr.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[`<`+cr.tagName+` id="`+t.idTemplate+`">`]=e}e.conditions.length!=e.idsTemplate.length&&(o[`<`+cr.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[`<`+lr.tagName+` id="`+e.id+`"></`+lr.tagName+`>`]=r}return o[`</`+sr.tagName+`>`]=`}`,o[`</`+cr.tagName+`>`]=`}`,o}async applyHtmlFormatting(e,t,n,r){if(!this.fileParsed)return[];let i=this.fileParsed?.compiledTxt;for(let e in r)if(e.startsWith(`{{`)){let t=new RegExp(e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),`g`);i=i.replace(t,r[e])}let a=[];i=i.replace(/\{\{[\s\S]*?\}\}/g,e=>`___AVENTUS_INTERPOLATION_${a.push(e)-1}___`);let o=d.TextDocument.create(e.documentUser.uri,e.documentUser.languageId,e.documentUser.version,i),s={start:o.positionAt(0),end:o.positionAt(i.length)},c=(await this.build.htmlLanguageService.format(o,s,n))[0].newText;for(let e in r){if(e.startsWith(`{{`))continue;let t=new RegExp(e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,`\\$&`),`g`);c=c.replace(t,r[e])}return c=c.replace(/___AVENTUS_INTERPOLATION_(\d+)___/g,(e,t)=>a[Number(t)]),c=c.replace(/\{\{\s*([\s\S]*?\S)\s*\}\}/g,`{{ $1 }}`),[{newText:c,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){let n=await this.tsFile?.doReferences(t);return n?.length?n: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 xi=[{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`}],Si={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`},Ci={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}) {
|
|
565
565
|
\${2}
|
|
566
566
|
}`,"else if":`else if(\${1:true}) {
|
|
567
567
|
\${2}
|
|
568
568
|
}`,else:`else {
|
|
569
569
|
\${1}
|
|
570
|
-
}`,"@Context":"@Context('${1:element}', ${2:this.elements[i]})"};var wi=class{languageService;id=0;isAutoComplete=!1;customTagsData=[];documentationInfo={};extenalDocumentation={};internalDocumentation={};internalDefinitionFiles={};internalDocumentationReverse={};internalTagUri={};_allowRebuildDefinition=!0;build;constructor(e){this.build=e,this.languageService=this.getHTMLLanguageService(),F.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 Si[e]?Si[e]:null}getHTMLLanguageService(){return(0,w.getLanguageService)({useDefaultDataProvider:!0,customDataProviders:[this.defaultProvider(),...this.loadOthersProviders()]})}defaultProvider(){return{getId:this.getId.bind(this),isApplicable(e){return e==T.HTML},provideTags:this.provideTags.bind(this),provideAttributes:this.provideAttributes.bind(this),provideValues:this.provideValues.bind(this)}}loadOthersProviders(){let e=F.getInstance().settingsHtml,t=[];for(let n of e.customData){let e=(0,f.normalize)(L($.getWorkspaceUri()+`/`+n));if((0,u.existsSync)(e)){let r;try{let i=(0,u.readFileSync)(e,`utf8`);r=JSON.parse(i);let a=(0,w.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=[...xi],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=
|
|
571
|
-
`)??``}};{let n=this.languageService.parseHTMLDocument(e.file.documentUser);if(n)return this.currentFile=void 0,this.languageService.doHover(e.file.documentUser,t,n)}return this.currentFile=void 0,null}async format(e,t,n){let r=n;return r.wrapAttributes=`preserve`,this.languageService.format(e,t,n)}async onDefinition(e,t){this.currentFile=e;let n=this.getLinkToLogic(e,t);if(n instanceof rn||n instanceof sn){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 dn)return this.currentFile=void 0,[{uri:n.document.uri,range:{start:n.document.positionAt(n.nameStart),end:n.document.positionAt(n.nameEnd)}}];else{this.currentFile=void 0;let n=e.file.documentUser.offsetAt(t);return e.fileParsed?.interestPoints.some(e=>e.type!=`tag`&&n>=e.start&&n<=e.end)?[]: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,this.internalDefinitionFiles[e]=n,this.rebuildInternalDocumentationReverse(),this.rebuildDefinition()}removeInternalDefinition(e){delete this.internalDocumentation[e],this.internalDefinitionFiles&&delete this.internalDefinitionFiles[e],this.rebuildInternalDocumentationReverse(),this.rebuildDefinition()}rebuildInternalDocumentationReverse(){this.internalDocumentationReverse={};for(let e in this.internalDocumentation){let t=this.internalDefinitionFiles?.[e];if(t)for(let n in this.internalDocumentation[e])this.internalDocumentationReverse[this.internalDocumentation[e][n].class]=t}}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)this.internalTagUri[t].uri==e&&delete this.internalTagUri[t]}};function Ti(e){let t=``,n=[],r=r=>{for(let i of r){let r=On.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)&&ks(i):(0,u.writeFileSync)(i,t),n}var Ei=class extends gn{get extension(){return E.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(R(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(R(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(R(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(){await super.onSave(),this.setCompileResult(Ti(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 gn{get extension(){return E.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)}},Oi=class extends gn{get extension(){return E.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(R(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(){await super.onSave(),this.setCompileResult(Ti(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)}},ki=class extends gn{get extension(){return E.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(){await super.onSave(),this.setCompileResult(Ti(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)}},Ai=class extends gn{get extension(){return E.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(){await super.onSave(),this.setCompileResult(Ti(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)}},ji=class extends gn{get extension(){return E.Static}mustBeAddedToLanguageService(){return!1}async onValidate(){return[]}async onContentChange(){}async onSave(){let e=this.file.path,t=e.replace(this.extension,E.Definition),n=``,r=``;t.endsWith(E.Definition)&&(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`).replace(/declare global \{([\s\S]*)\}/gm,`$1`));let i=e.replace(this.extension,E.DefinitionNpm);r=i.endsWith(E.DefinitionNpm)&&(0,u.existsSync)(i)?(0,u.readFileSync)(i,`utf8`):n;let a=Os(e+this.file.contentUser),o=this.file.path.replace(this.build.project.getConfigFile().path.replace(E.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 Mi(e,t){let n=null;return e.uri.endsWith(E.ComponentLogic)?n=new N(e,t):e.uri.endsWith(E.Data)?n=new Ei(e,t):e.uri.endsWith(E.Lib)?n=new Oi(e,t):e.uri.endsWith(E.RAM)?n=new ki(e,t):e.uri.endsWith(E.State)?n=new Ai(e,t):e.uri.endsWith(E.Static)?n=new ji(e,t):e.uri.endsWith(E.Definition)&&(n=new Di(e,t)),n}var Ni=class{static send(e,t){$.sendNotification(`aventus/compiled`,e,t)}static part(e){$.sendNotification(`aventus/compiled/part`,e)}},Pi=class{static send(e,t){$.sendNotification(`aventus/registerBuild`,{pathConfig:e,buildName:t})}},Fi=class{static send(e,t){$.sendNotification(`aventus/unregisterBuild`,{pathConfig:e,buildName:t})}},Ii=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 S,C,ee,te=function(e){if(!p&&e in ie)return ie[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)}},ne=t+` Iterator`,w=y==g,re=!1,ie=e.prototype,ae=ie[f]||ie[m]||y&&ie[y],oe=ae||te(y),se=y?w?te(`entries`):oe:void 0,ce=t==`Array`&&ie.entries||ae;if(ce&&(ee=d(ce.call(new e)),ee!==Object.prototype&&(u(ee,ne,!0),r||s(ee,f)||o(ee,f,_))),w&&ae&&ae.name!==g&&(re=!0,oe=function(){return ae.call(this)}),r&&!x||!p&&!re&&ie[f]||o(ie,f,oe),c[t]=oe,c[ne]=_,y)if(S={values:w?oe:te(g),keys:b?oe:te(h),entries:se},x)for(C in S)C in ie||a(ie,C,S[C]);else i(i.P+i.F*(p||re),t,S);return S}},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(`
|
|
570
|
+
}`,"@Context":"@Context('${1:element}', ${2:this.elements[i]})"};var wi=class{languageService;id=0;isAutoComplete=!1;customTagsData=[];documentationInfo={};extenalDocumentation={};internalDocumentation={};internalDefinitionFiles={};internalDocumentationReverse={};internalTagUri={};_allowRebuildDefinition=!0;build;constructor(e){this.build=e,this.languageService=this.getHTMLLanguageService(),F.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 Si[e]?Si[e]:null}getHTMLLanguageService(){return(0,w.getLanguageService)({useDefaultDataProvider:!0,customDataProviders:[this.defaultProvider(),...this.loadOthersProviders()]})}defaultProvider(){return{getId:this.getId.bind(this),isApplicable(e){return e==T.HTML},provideTags:this.provideTags.bind(this),provideAttributes:this.provideAttributes.bind(this),provideValues:this.provideValues.bind(this)}}loadOthersProviders(){let e=F.getInstance().settingsHtml,t=[];for(let n of e.customData){let e=(0,f.normalize)(L($.getWorkspaceUri()+`/`+n));if((0,u.existsSync)(e)){let r;try{let i=(0,u.readFileSync)(e,`utf8`);r=JSON.parse(i);let a=(0,w.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=[...xi],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=ds(r,gs(r.getText(),i)),o=r.getText().slice(r.offsetAt(a.start),r.offsetAt(a.end));for(let e in Ci)e.startsWith(o)&&n.push({label:e,kind:m.CompletionItemKind.Snippet,insertText:Ci[e],insertTextFormat:w.InsertTextFormat.Snippet,insertTextMode:w.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(`
|
|
571
|
+
`)??``}};{let n=this.languageService.parseHTMLDocument(e.file.documentUser);if(n)return this.currentFile=void 0,this.languageService.doHover(e.file.documentUser,t,n)}return this.currentFile=void 0,null}async format(e,t,n){let r=n;return r.wrapAttributes=`preserve`,this.languageService.format(e,t,n)}async onDefinition(e,t){this.currentFile=e;let n=this.getLinkToLogic(e,t);if(n instanceof rn||n instanceof sn){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 dn)return this.currentFile=void 0,[{uri:n.document.uri,range:{start:n.document.positionAt(n.nameStart),end:n.document.positionAt(n.nameEnd)}}];else{this.currentFile=void 0;let n=e.file.documentUser.offsetAt(t);return e.fileParsed?.interestPoints.some(e=>e.type!=`tag`&&n>=e.start&&n<=e.end)?[]: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,this.internalDefinitionFiles[e]=n,this.rebuildInternalDocumentationReverse(),this.rebuildDefinition()}removeInternalDefinition(e){delete this.internalDocumentation[e],this.internalDefinitionFiles&&delete this.internalDefinitionFiles[e],this.rebuildInternalDocumentationReverse(),this.rebuildDefinition()}rebuildInternalDocumentationReverse(){this.internalDocumentationReverse={};for(let e in this.internalDocumentation){let t=this.internalDefinitionFiles?.[e];if(t)for(let n in this.internalDocumentation[e])this.internalDocumentationReverse[this.internalDocumentation[e][n].class]=t}}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)this.internalTagUri[t].uri==e&&delete this.internalTagUri[t]}};function Ti(e){let t=``,n=[],r=r=>{for(let i of r){let r=On.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)&&Ds(i):(0,u.writeFileSync)(i,t),n}var Ei=class extends gn{get extension(){return E.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(R(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(R(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(R(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(){await super.onSave(),this.setCompileResult(Ti(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 gn{get extension(){return E.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)}},Oi=class extends gn{get extension(){return E.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(R(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(){await super.onSave(),this.setCompileResult(Ti(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)}},ki=class extends gn{get extension(){return E.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(){await super.onSave(),this.setCompileResult(Ti(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)}},Ai=class extends gn{get extension(){return E.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(){await super.onSave(),this.setCompileResult(Ti(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)}},ji=class extends gn{get extension(){return E.Static}mustBeAddedToLanguageService(){return!1}async onValidate(){return[]}async onContentChange(){}async onSave(){let e=this.file.path,t=e.replace(this.extension,E.Definition),n=``,r=``;t.endsWith(E.Definition)&&(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`).replace(/declare global \{([\s\S]*)\}/gm,`$1`));let i=e.replace(this.extension,E.DefinitionNpm);r=i.endsWith(E.DefinitionNpm)&&(0,u.existsSync)(i)?(0,u.readFileSync)(i,`utf8`):n;let a=Es(e+this.file.contentUser),o=this.file.path.replace(this.build.project.getConfigFile().path.replace(E.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 Mi(e,t){let n=null;return e.uri.endsWith(E.ComponentLogic)?n=new N(e,t):e.uri.endsWith(E.Data)?n=new Ei(e,t):e.uri.endsWith(E.Lib)?n=new Oi(e,t):e.uri.endsWith(E.RAM)?n=new ki(e,t):e.uri.endsWith(E.State)?n=new Ai(e,t):e.uri.endsWith(E.Static)?n=new ji(e,t):e.uri.endsWith(E.Definition)&&(n=new Di(e,t)),n}var Ni=class{static send(e,t){$.sendNotification(`aventus/compiled`,e,t)}static part(e){$.sendNotification(`aventus/compiled/part`,e)}},Pi=class{static send(e,t){$.sendNotification(`aventus/registerBuild`,{pathConfig:e,buildName:t})}},Fi=class{static send(e,t){$.sendNotification(`aventus/unregisterBuild`,{pathConfig:e,buildName:t})}},Ii=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 S,C,ee,te=function(e){if(!p&&e in ie)return ie[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)}},ne=t+` Iterator`,w=y==g,re=!1,ie=e.prototype,ae=ie[f]||ie[m]||y&&ie[y],oe=ae||te(y),se=y?w?te(`entries`):oe:void 0,ce=t==`Array`&&ie.entries||ae;if(ce&&(ee=d(ce.call(new e)),ee!==Object.prototype&&(u(ee,ne,!0),r||s(ee,f)||o(ee,f,_))),w&&ae&&ae.name!==g&&(re=!0,oe=function(){return ae.call(this)}),r&&!x||!p&&!re&&ie[f]||o(ie,f,oe),c[t]=oe,c[ne]=_,y)if(S={values:w?oe:te(g),keys:b?oe:te(h),entries:se},x)for(C in S)C in ie||a(ie,C,S[C]);else i(i.P+i.F*(p||re),t,S);return S}},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(`
|
|
572
572
|
`)[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,S=l(b)==`process`,C=function(){},ee=!!function(){try{var e=x.resolve(1),t=(e.constructor={})[n(1)(`species`)]=function(e){e(C,C)};return(S||typeof PromiseRejectionEvent==`function`)&&e.then(C)instanceof t}catch{}}(),te=function(e,t){return e===t||e===x&&t===a},ne=function(e){var t;return!(!d(e)||typeof(t=e.then)!=`function`)&&t},w=function(e){return te(x,e)?new re(e):new i(e)},re=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)},ie=function(e){try{e()}catch(e){return{error:e}}},ae=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&&ce(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=ne(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&&oe(e)})}},oe=function(e){g.call(s,function(){var t,n,r,i=e._v;if(se(e)&&(t=ie(function(){S?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=S||se(e)?2:1),e._a=void 0,t)throw t.error})},se=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||!se(t.promise))return!1;return!0},ce=function(e){g.call(s,function(){var t;S?b.emit(`rejectionHandled`,e):(t=s.onrejectionhandled)&&t({promise:e,reason:e._v})})},le=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(),ae(t,!0))},ue=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=ne(e))?_(function(){var r={_w:n,_d:!1};try{t.call(e,c(ue,r,1),c(le,r,1))}catch(e){le.call(r,e)}}):(n._v=e,n._s=1,ae(n,!1))}catch(e){le.call({_w:n,_d:!1},e)}}};ee||(x=function(e){p(this,x,v,`_h`),f(e),r.call(this);try{e(c(ue,this,1),c(le,this,1))}catch(e){le.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=w(h(this,x));return n.ok=typeof e!=`function`||e,n.fail=typeof t==`function`&&t,n.domain=S?b.domain:void 0,this._c.push(n),this._a&&this._a.push(n),this._s&&ae(this,!1),n.promise},catch:function(e){return this.then(void 0,e)}}),re=function(){var e=new r;this.promise=e,this.resolve=c(ue,e,1),this.reject=c(le,e,1)}),u(u.G+u.W+u.F*!ee,{Promise:x}),n(18)(x,v),n(59)(v),a=n(6)[v],u(u.S+u.F*!ee,v,{reject:function(e){var t=w(this),n=t.reject;return n(e),t.promise}}),u(u.S+u.F*(o||!ee),v,{resolve:function(e){if(e instanceof x&&te(e.constructor,this))return e;var t=w(this),n=t.resolve;return n(e),t.promise}}),u(u.S+u.F*!(ee&&n(46)(function(e){x.all(e).catch(C)})),v,{all:function(e){var t=this,n=w(t),r=n.resolve,i=n.reject,a=ie(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=w(t),r=n.reject,i=ie(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")}])})}))(),Li=class{static send(e){let t=D();return $.sendNotification(`aventus/progress_start`,t,e),t}},Ri=class{static send(e){$.sendNotification(`aventus/progress_stop`,e)}},zi=class{static send(e){$.sendNotification(`aventus/openfile`,e)}},Bi=class{static cmd=`aventus.addConfigSection`;static async run(e){try{if(!e){let t=[],n=P.getInstance().getAllConfigFiles();if(n.length===0){$.showWarningMessage(`No Aventus configuration was found.`);return}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;if(!t.some(e=>e.label===n.label)){$.showErrorMessage(`The selected Aventus configuration is no longer available.`);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=L(e),r=()=>{let e=(0,u.readFileSync)(n,`utf8`),t=[],r=qe(e,t,{allowTrailingComma:!0});if(t.length||!r||typeof r!=`object`||Array.isArray(r))throw SyntaxError(`Invalid Aventus configuration`);return{content:e,config:r}},i=r().config;if(t.label==`Build`){let e=e=>e.trim().replace(/[^a-zA-Z0-9_]+/g,`_`).replace(/^_+|_+$/g,``),t=i.build.map(t=>e(t.name??``)).filter(Boolean),a=e=>[...e].map(e=>e===`_`?`(?:_|[^A-Za-z0-9_]+)`:/[a-z]/i.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:e).join(``),o=`(?:_|[^A-Za-z0-9_])*`,s=t.map(a).join(`|`),c=await $.Input({title:`Provide a name for your build section`,validations:[{message:`The build name must contain a letter, number or underscore`,regex:`^[\\s\\S]*[A-Za-z0-9_][\\s\\S]*$`},{message:`A build section with this name already exists`,regex:s?`^(?!${o}(?:${s})${o}$)[\\s\\S]+$`:`^[\\s\\S]+$`}]});if(!c)return;let{content:l,config:d}=r(),p=c.trim().replace(/[^a-zA-Z0-9_-]+/g,`-`).replace(/^-+|-+$/g,``),m=e(c);if(!m)return;let h=`./dist/`+p+`.js`,g=(0,f.dirname)(n),_=(0,f.resolve)(g,h).toLowerCase(),v=e=>typeof e==`string`?[e]:Array.isArray(e)?e.flatMap(v):e&&typeof e==`object`?Object.values(e).flatMap(v):[];for(let t of d.build){if(e(t.name??``).toLowerCase()===m.toLowerCase()){$.showErrorMessage(`A build section with the name already exists: ${c}`);return}for(let e of t.compile)for(let t of v(e.output))if((0,f.resolve)(g,t).toLowerCase()===_){$.showErrorMessage(`A build section with the output already exists: ${_}`);return}}let y={name:m,src:[],compile:[{output:h}]},b=Array.isArray(d.build)?d.build:[];(0,u.writeFileSync)(n,Ze(l,Xe(l,Array.isArray(d.build)?[`build`,b.length]:[`build`],Array.isArray(d.build)?y:[y],{formattingOptions:{insertSpaces:!l.includes(` `),tabSize:4,eol:l.includes(`\r
|
|
573
573
|
`)?`\r
|
|
574
574
|
`:`
|
|
575
575
|
`}})))}else if(t.label==`Static`){let e=await $.Input({title:`Provide a name for your static section (optional)`,placeHolder:`Leave blank for an unnamed static section`});if(e===null)return;let{content:t,config:i}=r(),a={name:e,input:``,output:``};a.name?.trim()||delete a.name;let o=Array.isArray(i.static)?i.static:[];(0,u.writeFileSync)(n,Ze(t,Xe(t,Array.isArray(i.static)?[`static`,o.length]:[`static`],Array.isArray(i.static)?a:[a],{formattingOptions:{insertSpaces:!t.includes(` `),tabSize:4,eol:t.includes(`\r
|
|
576
576
|
`)?`\r
|
|
577
577
|
`:`
|
|
578
|
-
`}})))}else return;zi.send(e)}catch(e){console.error(e)}}},Vi=class{static cmd=`aventus.compile`;static async run(){let e=[],t=P.getInstance().getAllBuilds();for(let n of t)e.push({label:n.name,detail:n.uri});if(e.length===0){$.showWarningMessage(`No project to compile was found.`);return}let n=await $.Select(e,{title:`Project to compile`});if(n&&e.some(e=>e.label===n.label&&e.detail===n.detail)){let e=n.detail??``,t=n.label;return await P.getInstance().getProjectByUri(e)?.getBuild(t)?.build()}}},Hi=class e{static cmd=`aventus.create`;static async run(t){if(!t)return;let n=(0,f.normalize)(L(t));if(e.checkIfProject(n)){if(!$.isIDE){let e=await $.SelectFolder(`Select where to create`,n);if(!e)return;t=e,n=L(t)}await $.localTemplateManager?.createTemplate(n)}else await $.localProjectManager?.createGlobal(n)}static checkIfProject(e){for(let t of P.getInstance().getAllConfigFiles()){let n=(0,f.relative)((0,f.dirname)((0,f.normalize)(L(t))),e);if(n===``||n!==`..`&&!n.startsWith(`..`+f.sep)&&!(0,f.isAbsolute)(n))return!0}return!1}},Ui=class{static cmd=`aventus.filesystem.
|
|
578
|
+
`}})))}else return;zi.send(e)}catch(e){console.error(e)}}},Vi=class{static cmd=`aventus.compile`;static async run(){let e=[],t=P.getInstance().getAllBuilds();for(let n of t)e.push({label:n.name,detail:n.uri});if(e.length===0){$.showWarningMessage(`No project to compile was found.`);return}let n=await $.Select(e,{title:`Project to compile`});if(n&&e.some(e=>e.label===n.label&&e.detail===n.detail)){let e=n.detail??``,t=n.label;return await P.getInstance().getProjectByUri(e)?.getBuild(t)?.build()}}},Hi=class e{static cmd=`aventus.create`;static async run(t){if(!t)return;let n=(0,f.normalize)(L(t));if(e.checkIfProject(n)){if(!$.isIDE){let e=await $.SelectFolder(`Select where to create`,n);if(!e)return;t=e,n=L(t)}await $.localTemplateManager?.createTemplate(n)}else await $.localProjectManager?.createGlobal(n)}static checkIfProject(e){for(let t of P.getInstance().getAllConfigFiles()){let n=(0,f.relative)((0,f.dirname)((0,f.normalize)(L(t))),e);if(n===``||n!==`..`&&!n.startsWith(`..`+f.sep)&&!(0,f.isAbsolute)(n))return!0}return!1}},Ui=class{static cmd=`aventus.filesystem.batch`;static async run(e){await z.getInstance().applyBatch(e)}},Wi=class{static send(e){$.sendNotification(`aventus/closefile`,e)}},Gi=class{static cmd=`aventus.component.merge`;static async run(e){if(!e)return;let t=[E.ComponentLogic,E.ComponentView,E.ComponentStyle].find(t=>e.endsWith(t));if(!t)return;let n=e.slice(0,-t.length),r=n.split(`/`),i=r.pop(),a=r.pop(),o=r.join(`/`)+`/`+i,s=o+E.Component;if((0,u.existsSync)(L(s))||z.getInstance().getByUri(s)){$.showErrorMessage(`Cannot merge component because the destination already exists: `+s);return}let c=0,l=z.getInstance().getByUri(n+E.ComponentLogic);l&&l.versionUser>c&&(c=l.versionUser);let f=l?l.contentUser:``,p=z.getInstance().getByUri(n+E.ComponentStyle);p&&p.versionUser>c&&(c=p.versionUser);let m=p?p.contentUser:``,h=z.getInstance().getByUri(n+E.ComponentView);h&&h.versionUser>c&&(c=h.versionUser);let g=h?h.contentUser:``,_=[l,p,h].filter(e=>e!==void 0);if(!_.some(t=>t.uri===e))return;let v=L(r.join(`/`)+`/`+a),y=new Set(_.map(e=>e.path.split(/[\\/]/).pop()));if(!(0,u.existsSync)(v))return;let b=(0,u.readdirSync)(v).filter(e=>!y.has(e));if(b.length>0){$.showErrorMessage(`Cannot merge component because the folder contains other files: `+b.join(`, `));return}if(_.some(e=>!(0,u.existsSync)(e.path)))return;let x=await P.getInstance().onRename([{oldUri:n+E.ComponentLogic,newUri:o+E.Component}]),S=`
|
|
579
579
|
<script>
|
|
580
|
-
${
|
|
580
|
+
${Ki(f)}
|
|
581
581
|
<\/script>
|
|
582
582
|
|
|
583
583
|
<template>
|
|
584
|
-
${
|
|
584
|
+
${Ki(g)}
|
|
585
585
|
</template>
|
|
586
586
|
|
|
587
587
|
<style>
|
|
588
|
-
${
|
|
588
|
+
${Ki(m)}
|
|
589
589
|
</style>
|
|
590
|
-
`,C=d.TextDocument.create(s,T.WebComponent,c+1,S),ee=[],te=_.map(e=>({path:e.path,disk:(0,u.readFileSync)(e.path)})),ne=!1;try{(0,u.writeFileSync)(L(C.uri),S,{flag:`wx`}),ne=!0;for(let e in x){let t=z.getInstance().getByUri(e);t&&(ee.push({file:t,content:t.contentUser,disk:(0,u.readFileSync)(L(e))}),await t.applyTextEdits(x[e]),(0,u.writeFileSync)(L(e),t.contentUser))}for(let e of te)
|
|
590
|
+
`,C=d.TextDocument.create(s,T.WebComponent,c+1,S),ee=[],te=_.map(e=>({path:e.path,disk:(0,u.readFileSync)(e.path)})),ne=!1;try{(0,u.writeFileSync)(L(C.uri),S,{flag:`wx`}),ne=!0;for(let e in x){let t=z.getInstance().getByUri(e);t&&(ee.push({file:t,content:t.contentUser,disk:(0,u.readFileSync)(L(e))}),await t.applyTextEdits(x[e]),(0,u.writeFileSync)(L(e),t.contentUser))}for(let e of te)Ds(e.path);(0,u.rmdirSync)(v)}catch(e){if(!ne&&e&&e.code===`EEXIST`){$.showErrorMessage(`Cannot merge component because the destination already exists: `+s);return}for(let e of te)(0,u.existsSync)(e.path)||(0,u.writeFileSync)(e.path,e.disk);for(let{file:e,content:t,disk:n}of ee.reverse())(0,u.writeFileSync)(e.path,n),e.contentUser!==t&&await e.applyTextEdits([{range:{start:{line:0,character:0},end:e.documentUser.positionAt(e.contentUser.length)},newText:t}]);throw ne&&Ds(L(C.uri)),e}p&&(z.getInstance().onClose(p.documentUser),Wi.send(p.uri)),l&&(z.getInstance().onClose(l.documentUser),Wi.send(l.uri)),h&&(z.getInstance().onClose(h.documentUser),Wi.send(h.uri)),z.getInstance().registerFile(C),zi.send(C.uri)}};function Ki(e){return e.replace(/\r\n?/g,`
|
|
591
591
|
`).split(`
|
|
592
592
|
`).join(`
|
|
593
|
-
`)}var
|
|
593
|
+
`)}var qi=class e extends it{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 E.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(!1),i=n.file.file.documentInternal;for(let a of r)a.source=T.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==T.HTML){let t=new bi(new O(d.TextDocument.create(this.file.uri,T.HTML,this.file.versionUser,n)),this.build);e.file=t,await t.init()}else if(t==T.SCSS){let t=new yi(new O(d.TextDocument.create(this.file.uri,T.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,T.SCSS,n.cssText),n.htmlText===null?this.regionView.file&&(this.regionView.file.triggerDelete(),this.regionView.file=void 0):await r(this.regionView,T.HTML,n.htmlText),n.scriptText!==null&&await r(this.regionLogic,T.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=T.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=`
|
|
594
594
|
`+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,T.SCSS);if(i)return i;let a=await r(this.regionView,T.HTML);if(a)return a;let o=await r(this.regionLogic,T.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(`
|
|
595
595
|
`).join(`
|
|
596
596
|
`+a(1))),t.firstLast&&(n.newText=n.newText.trim(),n.range.start.character==0&&n.range.start.line==0&&(n.newText=t.tab?`
|
|
597
597
|
`+a(1)+n.newText:`
|
|
598
598
|
`+n.newText),e.file.file.documentInternal.offsetAt(n.range.end)==e.file.file.documentInternal.getText().length&&(n.newText+=`
|
|
599
|
-
`)),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(),t;e.htmlText!==null&&(t=new bi(new O(d.TextDocument.create(this.file.uri,T.HTML,this.file.versionUser,e.htmlText)),this.build));let n;e.cssText!==null&&(n=new yi(new O(d.TextDocument.create(this.file.uri,T.SCSS,this.file.versionUser,e.cssText)),this.build));let r=new N(new O(d.TextDocument.create(this.file.uri,T.TypeScript,this.file.versionUser,e.scriptText??``)),this.build),i={html:t,scss:n,ts:r};return this.build.tsFiles[i.ts.file.uri]=i.ts,i}splitDocument(){let t=/<script>([\s\S]*)<\/script>/g,n=/<style>([\s\S]*)<\/style>/g,r={cssText:null,htmlText:null,scriptText:null},i=t.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=e.findTemplateRegion(this.file.contentInternal);return o&&(this.regionView.start=o.start,this.regionView.end=o.end,r.htmlText=this.file.contentInternal.substring(o.start,o.end)),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 findTemplateRegion(e){let t=e.indexOf(`<template>`);if(t<0)return null;let n=/<\/?template>/g,r=t+10;n.lastIndex=r;let i=1,a;for(;a=n.exec(e);)if(i+=a[0]===`<template>`?1:-1,i===0)return{start:r,end:a.index};return null}static getRegion(e){let t=/<script>([\s\S]*?)<\/script>/g,n=/<style>([\s\S]*?)<\/style>/g,r={cssText:null,htmlText:null,scriptText:null},i=t.exec(e.contentInternal);if(i){let t=i.index+8,n=i.index+i[0].length-9;r.scriptText=e.contentInternal.substring(t,n)}let a=n.exec(e.contentInternal);if(a){let t=a.index+7,n=a.index+a[0].length-8;r.cssText=e.contentInternal.substring(t,n)}let o=this.findTemplateRegion(e.contentInternal);return o&&(r.htmlText=e.contentInternal.substring(o.start,o.end)),r}onGetBuild(){return[this.build]}},
|
|
599
|
+
`)),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(),t;e.htmlText!==null&&(t=new bi(new O(d.TextDocument.create(this.file.uri,T.HTML,this.file.versionUser,e.htmlText)),this.build));let n;e.cssText!==null&&(n=new yi(new O(d.TextDocument.create(this.file.uri,T.SCSS,this.file.versionUser,e.cssText)),this.build));let r=new N(new O(d.TextDocument.create(this.file.uri,T.TypeScript,this.file.versionUser,e.scriptText??``)),this.build),i={html:t,scss:n,ts:r};return this.build.tsFiles[i.ts.file.uri]=i.ts,i}splitDocument(){let t=/<script>([\s\S]*)<\/script>/g,n=/<style>([\s\S]*)<\/style>/g,r={cssText:null,htmlText:null,scriptText:null},i=t.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=e.findTemplateRegion(this.file.contentInternal);return o&&(this.regionView.start=o.start,this.regionView.end=o.end,r.htmlText=this.file.contentInternal.substring(o.start,o.end)),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 findTemplateRegion(e){let t=e.indexOf(`<template>`);if(t<0)return null;let n=/<\/?template>/g,r=t+10;n.lastIndex=r;let i=1,a;for(;a=n.exec(e);)if(i+=a[0]===`<template>`?1:-1,i===0)return{start:r,end:a.index};return null}static getRegion(e){let t=/<script>([\s\S]*?)<\/script>/g,n=/<style>([\s\S]*?)<\/style>/g,r={cssText:null,htmlText:null,scriptText:null},i=t.exec(e.contentInternal);if(i){let t=i.index+8,n=i.index+i[0].length-9;r.scriptText=e.contentInternal.substring(t,n)}let a=n.exec(e.contentInternal);if(a){let t=a.index+7,n=a.index+a[0].length-8;r.cssText=e.contentInternal.substring(t,n)}let o=this.findTemplateRegion(e.contentInternal);return o&&(r.htmlText=e.contentInternal.substring(o.start,o.end)),r}onGetBuild(){return[this.build]}},Ji=class{static cmd=`aventus.component.split`;static async run(e){if(!e)return;let t=e.split(`/`).pop()?.replace(E.Component,``),n=z.getInstance().getByUri(e);if(n){let r=L(e.replace(E.Component,``)),i=e.replace(E.Component,``)+`/`+t,a=[i+E.ComponentStyle,i+E.ComponentView,i+E.ComponentLogic],o;for(let e of a)if((0,u.existsSync)(L(e))||z.getInstance().getByUri(e)){o=L(e);break}if(o){$.showErrorMessage(`Cannot split component because the destination already exists: `+o);return}(0,u.existsSync)(r)||(0,u.mkdirSync)(r);let s=qi.getRegion(n),c=i+E.ComponentStyle,l=d.TextDocument.create(c,T.SCSS,n.versionUser+1,s.cssText??``);(0,u.writeFileSync)(L(c),l.getText());let f=i+E.ComponentView,p=d.TextDocument.create(f,T.HTML,n.versionUser+1,s.htmlText??``);(0,u.writeFileSync)(L(f),p.getText());let m=i+E.ComponentLogic,h=d.TextDocument.create(m,T.TypeScript,n.versionUser+1,s.scriptText??``);(0,u.writeFileSync)(L(m),h.getText()),Ds(n.path),z.getInstance().onClose(n.documentUser),Wi.send(n.uri),z.getInstance().registerFile(l),z.getInstance().registerFile(p),z.getInstance().registerFile(h),zi.send(h.uri)}}},Yi=class{static cmd=`aventus.liveserver.start`;static run(){return yt.getInstance().start()}},Xi=class{static cmd=`aventus.liveserver.toggle`;static run(){return yt.getInstance().toggle()}},Zi=class{static cmd=`aventus.static`;static async run(){let e=[],t=P.getInstance().getAllStatics();for(let n of t)e.push({label:n.name??`Static #${n.index}`,detail:n.uri,id:String(n.index)});if(e.length===0){$.showWarningMessage(`No static export was found.`);return}let n=await $.Select(e,{title:`Static to export`}),r=n?e.findIndex(e=>e.label===n.label&&e.detail===n.detail&&e.id===n.id):-1;if(r!==-1){let e=t[r];return await(P.getInstance().getProjectByUri(e.uri)?.getStaticAt(e.index))?.export()}}},Qi=class{static cmd=`aventus.liveserver.stop`;static run(){return yt.getInstance().stop()}},$i=class{static send(e,t){$.sendNotification(`aventus/editFile`,{uri:e,transformations:t})}},ea=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;$o(e.attrType,i);let a=i.detail,o=z.getInstance().getByUri(t);if(o){let e=`?`;(a==`boolean`||a==`number`)&&(e=`!`);let i=o.documentUser.positionAt(o.contentUser.length),s=`@Attribute()
|
|
600
600
|
public `+r+e+`:`+a+`;
|
|
601
|
-
`,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,T.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}}]
|
|
601
|
+
`,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,T.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}}];$i.send(t,[m])}}},ta=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;$o(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=z.getInstance().getByUri(t);if(l){let e=l.documentUser.positionAt(l.contentUser.length),r=z.getInstance().getBuild(l.documentUser)??[],a=``;for(let e of r){let n=e.tsFiles[t];if(n instanceof N){a=n.getComponentName();break}}if(a==``)return;let s=``;c&&(s=`(target: `+a+`) => {
|
|
602
602
|
|
|
603
603
|
}`);let u=`?`;(o==`boolean`||o==`number`)&&(u=`!`);let f=`@Property(`+s+`)
|
|
604
604
|
public `+i+u+`:`+o+`;
|
|
605
|
-
`,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,T.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}}]
|
|
605
|
+
`,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,T.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}}];$i.send(t,[v])}}},na=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=z.getInstance().getByUri(e);if(s){let n=s.documentUser.positionAt(s.contentUser.length),a=z.getInstance().getBuild(s.documentUser)?.find(t=>t.tsFiles[e]instanceof N),c=(a?.tsFiles[e])?.getComponentName()??``;if(c==``)return;let l=``;if(o){let e=`Aventus.`;a?.isCoreBuild&&(e=``),l=`(target: `+c+`, action: `+e+`WatchAction, path: string, value: any) => {
|
|
606
606
|
|
|
607
607
|
}`}let u=`@Watch(`+l+`)
|
|
608
608
|
public `+r+`?:`+i+`;
|
|
609
|
-
`,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,T.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}}];ta.send(e,[_])}}},aa=class{static cmd=`aventus.wc.import.viewElement`;static async run(e,t){let n=z.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=z.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof N){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,T.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}}];ta.send(e,[u])}}}}}},oa=class{static cmd=`aventus.wc.import.viewMethod`;static async run(e,t){let n=z.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=z.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof N){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,T.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}}];ta.send(e,[u])}}}}}},sa=class{static cmd=`aventus.rename`;static async run(e){if(!F.getInstance().settings.updateImportOnRename||!e)return;let t=[];for(let n of e){let e=n.newUri,r=n.oldUri,i=L(e),a=L(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=I(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 P.getInstance().onRename(t),r={},i=z.getInstance();for(let e in n){let t=i.getByUri(e);t&&(await t.applyTextEdits(n[e]),r[L(t.uri)]=t.contentUser)}setTimeout(()=>{for(let e in r)(0,u.writeFileSync)(e,r[e])},500)}},ca=class{static cmd=`aventus.component.rename`;static async run(e){if(!e)return;e=e.toString();for(let t of[E.ComponentView,E.ComponentStyle])if(e.endsWith(t)){e=e.slice(0,-t.length)+E.ComponentLogic;break}let t=e.split(`/`),n=t[t.length-1].replace(E.ComponentLogic,``),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=z.getInstance().getByUri(e);if(i&&i instanceof O){let e=z.getInstance(),t=i.documentUser.uri.split(`/`),n=t[t.length-1].replace(E.ComponentLogic,``),a=hs(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)(L(t))){let n=s+`/`+r+e;f.push({oldUri:t,newUri:n})}};p(E.ComponentLogic),p(E.ComponentStyle),p(E.ComponentView);let m=await P.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)(L(e),l[e].contentUser);(0,u.mkdirSync)(L(s));for(let t of f){let n=t.oldUri,r=t.newUri;(0,u.renameSync)(L(n),L(r)),Ki.send(n);let i=e.getByUri(n);i&&(e.registerFile(d.TextDocument.create(r,ns(r),1,i.contentUser)),e.onClose(i?.documentUser))}let t=L(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)}}},la=class{static cmd=`aventus.filesystem.openAventus`;static async run(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e);let t;switch((0,le.platform)()){case`win32`:t=`explorer`;break;case`linux`:t=`xdg-open`;break;case`darwin`:t=`open`;break}(0,ce.spawn)(t,[e],{detached:!0}).unref()}},ua=class{static waitingResponse={};static send(e,...t){return new Promise(n=>{let r=D();for(;this.waitingResponse[r]!=null;)r=D();this.waitingResponse[r]=e=>{n(e)};try{$.sendNotification(`aventus/popup`,r,e,t)}catch{delete this.waitingResponse[r],n(null)}})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},da=class{static cmd=`aventus.popupresponse`;static run(e,t){ua.resolve(e,t)}},fa=class{static waitingResponse={};static send(e){return new Promise(t=>{let n=D();for(;this.waitingResponse[n]!=null;)n=D();this.waitingResponse[n]=e=>{t(e)};try{$.sendNotification(`aventus/askinput`,n,e)}catch{delete this.waitingResponse[n],t(null)}})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},pa=class{static cmd=`aventus.receiveinput`;static run(e,t){fa.resolve(e,t)}},ma=class{static waitingResponse={};static waitingOptions={};static waitingOptionIds={};static send(e,t){return new Promise(n=>{let r=D();for(;this.waitingResponse[r]!=null;)r=D();this.waitingOptions[r]=e;let i=e.map((e,t)=>`${r}:${t}`);this.waitingOptionIds[r]=i,this.waitingResponse[r]=e=>{n(e)};try{$.sendNotification(`aventus/askselect`,r,e.map((e,t)=>({...e,id:i[t]})),t)}catch{delete this.waitingResponse[r],delete this.waitingOptions[r],delete this.waitingOptionIds[r],n(null)}})}static resolve(e,t){if(this.waitingResponse[e]){if(t){let n=this.waitingOptions[e],r=this.waitingOptionIds[e].indexOf(t.id??``);if(r>=0)t=n[r];else if(t.id)t=null;else{let e=n.filter(e=>e.label===t.label);t=e.length===1?e[0]:null}}this.waitingResponse[e](t),delete this.waitingResponse[e],delete this.waitingOptions[e],delete this.waitingOptionIds[e]}}},ha=class{static cmd=`aventus.receiveselect`;static run(e,t){ma.resolve(e,t)}},ga=class{static waitingResponse={};static waitingOptions={};static waitingOptionIds={};static send(e,t){return new Promise(n=>{let r=D();for(;this.waitingResponse[r]!=null;)r=D();this.waitingOptions[r]=e;let i=e.map((e,t)=>`${r}:${t}`);this.waitingOptionIds[r]=i,this.waitingResponse[r]=e=>{n(e)};try{$.sendNotification(`aventus/askselectmultiple`,r,e.map((e,t)=>({...e,id:i[t]})),t)}catch{delete this.waitingResponse[r],delete this.waitingOptions[r],delete this.waitingOptionIds[r],n(null)}})}static resolve(e,t){if(this.waitingResponse[e]){if(t){let n=this.waitingOptions[e],r=this.waitingOptionIds[e],i=[];for(let e of t){let a=r.indexOf(e.id??``);if(a<0&&!e.id){let t=[];for(let r=0;r<n.length;r++){let i=n[r];i.label===e.label&&i.detail===e.detail&&t.push(r)}t.length===1&&(a=t[0])}if(a<0){t=null;break}i.push(n[a])}t&&=i}this.waitingResponse[e](t),delete this.waitingResponse[e],delete this.waitingOptions[e],delete this.waitingOptionIds[e]}}},_a=class{static cmd=`aventus.receiveselectmultiple`;static run(e,t){ga.resolve(e,t)}},va=class{static cmd=`aventus.template.import`;static async run(){await $.templateManager?.selectTemplateToImport()}},ya=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)}})),ba=o(((e,t)=>{t.exports=ya()}))(),xa=class{static send(e,t,n){$.sendNotification(`aventus/sharp/compiling`,e,t,n)}},Sa=class{static send(e,t){$.sendNotification(`aventus/addDebugFile`,e,t)}},Ca=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=z.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=z.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(E.CsharpConfig)&&(this.files[e.uri]=new wa(e))}async onFileRemove(e){delete this.files[e]}destroy(){z.getInstance().removeOnNewFile(this.onNewFileUUID),z.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},wa=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 O&&await this.file.validate()}triggerSave(){this.file instanceof O&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof O&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return Qe.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return Qe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return Qe.getInstance().doResolve(t)}async onHover(e,t){return Qe.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return Qe.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}},Ta=class{static cmd=`aventus.sharp.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,ba.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}if(!(0,ba.sync)(`csharp-converter`))try{if(await $.ask(`csharp-converter is missing. Can I install it?`)&&await $.showLoadingMessage(`Installing csharp-converter`,async()=>{await Yo(`dotnet tool install --global AventusSharp.Converter`)}),!(0,ba.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(E.CsharpConfig)){let t=Object.keys(Ca.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)(L(e),`utf-8`);t=JSON.parse(n).csProj}catch(e){$.error(e),$.showErrorMessage(`Invalid Sharp project configuration: ${e}`);return}this.isCompiling=!0,xa.send(t,`compiling`);try{let{stdout:n,stderr:r}=await Zo(`csharp-converter`,[L(e)]),i=n.toString(),a=r.toString(),o=i.includes(`Error : `)?i:a.includes(`Error : `)?a:null;if(!o)a.trim()&&$.showWarningMessage(a.trim()),xa.send(t,`success`);else{console.clear(),$.error(o);let e=`csharp_errors`;Sa.send(e,o),xa.send(t,`error`,[{title:`C# error`,file:e}])}}catch(e){let n=e.stderr?.trim()||String(e);$.showErrorMessage(n),Sa.send(`csharp_errors`,n),xa.send(t,`error`,[{title:`C# error`,file:`csharp_errors`}])}this.isCompiling=!1}},Ea=class{static cmd=`aventus.reloadSettings`;static async run(){$.refreshSettings()}},Da=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=z.getInstance().getByUri(e);if(i){let a=/[A-Z]?[a-z]+|[A-Z]+(?![a-z])|[0-9]+[a-z]*/g,o=i.name.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g)?.join(`-`).toLowerCase()??i.name,s=n.match(a)?.join(`-`).toLowerCase()??n,c=r?`, `+r:``,l=i.documentUser.positionAt(i.contentUser.length),u=`--_${o}-${s}: var(--${o}-${s}${c});`,f=i.contentUser.slice(0,t),p=i.contentUser.slice(t+1,i.contentUser.length),m=f+u+p,h=d.TextDocument.create(i.uri,T.SCSS,i.versionUser+1,m);await i.triggerContentChange(h);let g=await i.getFormatting({insertSpaces:!0,tabSize:4});await i.applyTextEdits(g);let _=[{newText:i.contentUser,range:{start:{character:0,line:0},end:l}}];ta.send(e,[_])}}},Oa=class{static cmd=`aventus.storybook.build`;static async run(){let e=[],t=P.getInstance().getAllBuildsWithStory();for(let n of t)e.push({label:n.name,detail:n.uri});if(e.length===0){$.showWarningMessage(`No Storybook build was found.`);return}let n=await $.Select(e,{title:`Story to build`});if(n&&e.some(e=>e.label===n.label&&e.detail===n.detail)){let e=n.detail??``,t=n.label;return await P.getInstance().getProjectByUri(e)?.getBuild(t)?.buildStorybook()}}},ka=class{static cmd=`aventus.template.import_project`;static async run(){await $.templateManager?.selectProjectToImport(!1)}},Aa=class{static cmd=`aventus.npm.build`;static async run(){let e=[],t=P.getInstance().getAllBuildsWithNpm();for(let n of t)e.push({label:n.name,detail:n.uri});if(e.length===0){$.showWarningMessage(`No package to build was found.`);return}let n=e.length==1?e[0]:await $.Select(e,{title:`Package to build`});if(n&&e.some(e=>e.label===n.label&&e.detail===n.detail)){let e=n.detail??``,t=n.label;return await P.getInstance().getProjectByUri(e)?.getBuild(t)?.buildNpm()}}};const ja={$schema:`foo://aventus/i18n.json`,title:`JSON Schema for Aventus I18n`,description:`JSON Schema for Aventus I18n`,type:`object`,additionalProperties:{type:`object`,additionalProperties:{type:`string`}}};var Ma=class e{static empty=`ⵌⵌ`;static instance;static getInstance(){return this.instance||=new e,this.instance}languageService;constructor(){this.languageService=(0,h.getLanguageService)({}),this.languageService.configure({allowComments:!0,schemas:[{fileMatch:[`**`+E.I18n],uri:ja.$schema??``,schema:ja}]})}async validate(t){let n=t.file.documentUser,r=this.languageService.parseJSONDocument(n),i=await this.languageService.doValidation(n,r),a=r.syntaxErrors;if(!r.root||a?.length)return i.length==0&&i.push(ls(n,`Can't parse the json`)),i.map(e=>({...e,severity:h.DiagnosticSeverity.Error}));try{let a=t.parsed??{},o=(t.build.buildConfig.i18n?.locales??[]).filter(e=>!ve.isReservedI18nLocale(e));for(let e of r.root.children??[]){if(e.type!==`property`)continue;let t=e.children?.[0];if(t&&ve.isReservedI18nLocale(String(t.value))&&i.push(us(n,`Translation key ${t.value} is not allowed`,t.offset,t.offset+t.length)),e.children&&e.children.length>1){let t=e.children[1].children??[];for(let e of t){if(e.type!==`property`)continue;let t=e.children[0];t&&ve.isReservedI18nLocale(String(t.value))&&i.push(us(n,`Locale ${t.value} is not allowed`,t.offset,t.offset+t.length))}}}for(let r in a){if(t.isGlobal){let e=t.build.tsLanguageService?.i18nFiles??{};Object.values(e).filter(e=>e!==t&&e.isGlobal&&e.parsed&&Object.hasOwn(e.parsed,r)).length>0&&i.push(us(n,`Duplicate translation key ${r} across global files`,a[r].keyStart,a[r].keyEnd))}for(let n in a[r].locales){let s=a[r].locales[n];o.includes(n)||i.push(ds(t.file.documentUser,`Locale not needed`,s.localeStart,s.localeEnd)),s.value==e.empty&&i.push(ds(t.file.documentUser,`Translation not set`,s.valueStart,s.valueEnd))}let s=[];for(let e of o)a[r].locales[e]===void 0&&s.push(e);s.length>0&&i.push(us(t.file.documentUser,`Missing locales `+s.join(`, `),a[r].keyStart,a[r].keyEnd))}return i}catch{i.length==0&&i.push(ls(n,`Can't parse the json`))}for(let e of i)e.severity=h.DiagnosticSeverity.Error;return i}async format(e,t,n){try{let t;try{let n=JSON.parse(e.contentUser);t=JSON.stringify(this.sortObj(n),null,4)}catch{let n=this.languageService.parseJSONDocument(e.documentUser),r=n.root,i=n.syntaxErrors;if(!r||r.type!==`object`||i?.some(e=>e.code!==h.ErrorCode.TrailingComma))return[];let a=e.contentUser.slice(0,r.offset)+this.sortJsoncObject(e.contentUser,r)+e.contentUser.slice(r.offset+r.length),o=d.TextDocument.create(e.uri,e.documentUser.languageId,e.documentUser.version,a),s=await this.languageService.format(o,void 0,{tabSize:4,insertSpaces:!0});t=d.TextDocument.applyEdits(o,s)}return[{newText:t,range:{start:e.documentUser.positionAt(0),end:e.documentUser.positionAt(e.contentUser.length)}}]}catch{}return[]}sortJsoncObject(e,t){let n=t.properties,r=t.offset+1,i=[];for(let t of n){let n=t.valueNode,a=this.removeJsoncComma(e.slice(r,t.offset));r=t.offset+t.length;let o=e.slice(t.offset,r);if(n?.type===`object`){let r=n.offset-t.offset;o=o.slice(0,r)+this.sortJsoncObject(e,n)+o.slice(r+n.length)}i.push({key:t.keyNode.value,text:a+o})}let a=this.removeJsoncComma(e.slice(r,t.offset+t.length-1));return i.sort((e,t)=>e.key<t.key?-1:+(e.key>t.key)),`{`+i.map(e=>e.text).join(`,`)+a+`}`}removeJsoncComma(e){return e.replace(/^(\s*),/,`$1`)}async codeAction(e,t){let n=[];try{let t=this.actionImportMissingLocales(e);t&&n.push(t)}catch{}return n}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=t.file.documentUser,r=t.file.contentUser,i=this.languageService.parseJSONDocument(n),a=i.syntaxErrors,o=i.root;if(o?.type!==`object`||a?.length){$.showErrorMessage(`The i18n file is malformed. Fix its JSON before importing missing locales.`);return}let s=[],c=(t.build.buildConfig.i18n?.locales??[]).filter(e=>!ve.isReservedI18nLocale(e));for(let t of o.properties){if(ve.isReservedI18nLocale(String(t.keyNode.value)))continue;let i=t.valueNode;if(i?.type!==`object`)continue;let a=c.filter(e=>!i.properties.some(t=>t.keyNode.value===e));if(a.length===0)continue;let o=i.properties[0],l=o?.offset??i.offset+1,u=r.lastIndexOf(`
|
|
609
|
+
`,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,T.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}}];$i.send(e,[_])}}},ra=class{static cmd=`aventus.wc.import.viewElement`;static async run(e,t){let n=z.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=z.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof N){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,T.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}}];$i.send(e,[u])}}}}}},ia=class{static cmd=`aventus.wc.import.viewMethod`;static async run(e,t){let n=z.getInstance().getByUri(e);if(n){let r=n.documentUser.positionAt(n.contentUser.length),i=z.getInstance().getBuild(n.documentUser);if(i&&i.length>0){let a=i[0].tsFiles[e];if(a instanceof N){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,T.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}}];$i.send(e,[u])}}}}}},aa=class{static cmd=`aventus.rename`;static async run(e){if(!F.getInstance().settings.updateImportOnRename||!e)return;let t=[];for(let n of e){let e=n.newUri,r=n.oldUri,i=L(e),a=L(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=I(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 P.getInstance().onRename(t),r={},i=z.getInstance();for(let e in n){let t=i.getByUri(e);t&&(await t.applyTextEdits(n[e]),r[L(t.uri)]=t.contentUser)}setTimeout(()=>{for(let e in r)(0,u.writeFileSync)(e,r[e])},500)}},oa=class{static cmd=`aventus.component.rename`;static async run(e){if(!e)return;e=e.toString();for(let t of[E.ComponentView,E.ComponentStyle])if(e.endsWith(t)){e=e.slice(0,-t.length)+E.ComponentLogic;break}let t=e.split(`/`),n=t[t.length-1].replace(E.ComponentLogic,``),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=z.getInstance().getByUri(e);if(i&&i instanceof O){let e=z.getInstance(),t=i.documentUser.uri.split(`/`),n=t[t.length-1].replace(E.ComponentLogic,``),a=ps(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)(L(t))){let n=s+`/`+r+e;f.push({oldUri:t,newUri:n})}};p(E.ComponentLogic),p(E.ComponentStyle),p(E.ComponentView);let m=await P.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)(L(e),l[e].contentUser);(0,u.mkdirSync)(L(s));for(let t of f){let n=t.oldUri,r=t.newUri;(0,u.renameSync)(L(n),L(r)),Wi.send(n);let i=e.getByUri(n);i&&(e.registerFile(d.TextDocument.create(r,es(r),1,i.contentUser)),e.onClose(i?.documentUser))}let t=L(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)}}},sa=class{static cmd=`aventus.filesystem.openAventus`;static async run(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e);let t;switch((0,le.platform)()){case`win32`:t=`explorer`;break;case`linux`:t=`xdg-open`;break;case`darwin`:t=`open`;break}(0,ce.spawn)(t,[e],{detached:!0}).unref()}},ca=class{static waitingResponse={};static send(e,...t){return new Promise(n=>{let r=D();for(;this.waitingResponse[r]!=null;)r=D();this.waitingResponse[r]=e=>{n(e)};try{$.sendNotification(`aventus/popup`,r,e,t)}catch{delete this.waitingResponse[r],n(null)}})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},la=class{static cmd=`aventus.popupresponse`;static run(e,t){ca.resolve(e,t)}},ua=class{static waitingResponse={};static send(e){return new Promise(t=>{let n=D();for(;this.waitingResponse[n]!=null;)n=D();this.waitingResponse[n]=e=>{t(e)};try{$.sendNotification(`aventus/askinput`,n,e)}catch{delete this.waitingResponse[n],t(null)}})}static resolve(e,t){this.waitingResponse[e]&&(this.waitingResponse[e](t),delete this.waitingResponse[e])}},da=class{static cmd=`aventus.receiveinput`;static run(e,t){ua.resolve(e,t)}},fa=class{static waitingResponse={};static waitingOptions={};static waitingOptionIds={};static send(e,t){return new Promise(n=>{let r=D();for(;this.waitingResponse[r]!=null;)r=D();this.waitingOptions[r]=e;let i=e.map((e,t)=>`${r}:${t}`);this.waitingOptionIds[r]=i,this.waitingResponse[r]=e=>{n(e)};try{$.sendNotification(`aventus/askselect`,r,e.map((e,t)=>({...e,id:i[t]})),t)}catch{delete this.waitingResponse[r],delete this.waitingOptions[r],delete this.waitingOptionIds[r],n(null)}})}static resolve(e,t){if(this.waitingResponse[e]){if(t){let n=this.waitingOptions[e],r=this.waitingOptionIds[e].indexOf(t.id??``);if(r>=0)t=n[r];else if(t.id)t=null;else{let e=n.filter(e=>e.label===t.label);t=e.length===1?e[0]:null}}this.waitingResponse[e](t),delete this.waitingResponse[e],delete this.waitingOptions[e],delete this.waitingOptionIds[e]}}},pa=class{static cmd=`aventus.receiveselect`;static run(e,t){fa.resolve(e,t)}},ma=class{static waitingResponse={};static waitingOptions={};static waitingOptionIds={};static send(e,t){return new Promise(n=>{let r=D();for(;this.waitingResponse[r]!=null;)r=D();this.waitingOptions[r]=e;let i=e.map((e,t)=>`${r}:${t}`);this.waitingOptionIds[r]=i,this.waitingResponse[r]=e=>{n(e)};try{$.sendNotification(`aventus/askselectmultiple`,r,e.map((e,t)=>({...e,id:i[t]})),t)}catch{delete this.waitingResponse[r],delete this.waitingOptions[r],delete this.waitingOptionIds[r],n(null)}})}static resolve(e,t){if(this.waitingResponse[e]){if(t){let n=this.waitingOptions[e],r=this.waitingOptionIds[e],i=[];for(let e of t){let a=r.indexOf(e.id??``);if(a<0&&!e.id){let t=[];for(let r=0;r<n.length;r++){let i=n[r];i.label===e.label&&i.detail===e.detail&&t.push(r)}t.length===1&&(a=t[0])}if(a<0){t=null;break}i.push(n[a])}t&&=i}this.waitingResponse[e](t),delete this.waitingResponse[e],delete this.waitingOptions[e],delete this.waitingOptionIds[e]}}},ha=class{static cmd=`aventus.receiveselectmultiple`;static run(e,t){ma.resolve(e,t)}},ga=class{static cmd=`aventus.template.import`;static async run(){await $.templateManager?.selectTemplateToImport()}},_a=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)}})),va=o(((e,t)=>{t.exports=_a()}))(),ya=class{static send(e,t,n){$.sendNotification(`aventus/sharp/compiling`,e,t,n)}},ba=class{static send(e,t){$.sendNotification(`aventus/addDebugFile`,e,t)}},xa=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=z.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=z.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(E.CsharpConfig)&&(this.files[e.uri]=new Sa(e))}async onFileRemove(e){delete this.files[e]}destroy(){z.getInstance().removeOnNewFile(this.onNewFileUUID),z.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},Sa=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 O&&await this.file.validate()}triggerSave(){this.file instanceof O&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof O&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return Qe.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return Qe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return Qe.getInstance().doResolve(t)}async onHover(e,t){return Qe.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return Qe.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}},Ca=class{static cmd=`aventus.sharp.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,va.sync)(`dotnet`)){$.showErrorMessage(`Dotnet isn't installed on your system`);return}if(!(0,va.sync)(`csharp-converter`))try{if(await $.ask(`csharp-converter is missing. Can I install it?`)&&await $.showLoadingMessage(`Installing csharp-converter`,async()=>{await qo(`dotnet tool install --global AventusSharp.Converter`)}),!(0,va.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(E.CsharpConfig)){let t=Object.keys(xa.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)(L(e),`utf-8`);t=JSON.parse(n).csProj}catch(e){$.error(e),$.showErrorMessage(`Invalid Sharp project configuration: ${e}`);return}this.isCompiling=!0,ya.send(t,`compiling`);try{let{stdout:n,stderr:r}=await Yo(`csharp-converter`,[L(e)]),i=n.toString(),a=r.toString(),o=i.includes(`Error : `)?i:a.includes(`Error : `)?a:null;if(!o)a.trim()&&$.showWarningMessage(a.trim()),ya.send(t,`success`);else{console.clear(),$.error(o);let e=`csharp_errors`;ba.send(e,o),ya.send(t,`error`,[{title:`C# error`,file:e}])}}catch(e){let n=e.stderr?.trim()||String(e);$.showErrorMessage(n),ba.send(`csharp_errors`,n),ya.send(t,`error`,[{title:`C# error`,file:`csharp_errors`}])}this.isCompiling=!1}},wa=class{static cmd=`aventus.reloadSettings`;static async run(){$.refreshSettings()}},Ta=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=z.getInstance().getByUri(e);if(i){let a=/[A-Z]?[a-z]+|[A-Z]+(?![a-z])|[0-9]+[a-z]*/g,o=i.name.match(/([A-Z][a-z]*)|([0-9]+[a-z]*)/g)?.join(`-`).toLowerCase()??i.name,s=n.match(a)?.join(`-`).toLowerCase()??n,c=r?`, `+r:``,l=i.documentUser.positionAt(i.contentUser.length),u=`--_${o}-${s}: var(--${o}-${s}${c});`,f=i.contentUser.slice(0,t),p=i.contentUser.slice(t+1,i.contentUser.length),m=f+u+p,h=d.TextDocument.create(i.uri,T.SCSS,i.versionUser+1,m);await i.triggerContentChange(h);let g=await i.getFormatting({insertSpaces:!0,tabSize:4});await i.applyTextEdits(g);let _=[{newText:i.contentUser,range:{start:{character:0,line:0},end:l}}];$i.send(e,[_])}}},Ea=class{static cmd=`aventus.storybook.build`;static async run(){let e=[],t=P.getInstance().getAllBuildsWithStory();for(let n of t)e.push({label:n.name,detail:n.uri});if(e.length===0){$.showWarningMessage(`No Storybook build was found.`);return}let n=await $.Select(e,{title:`Story to build`});if(n&&e.some(e=>e.label===n.label&&e.detail===n.detail)){let e=n.detail??``,t=n.label;return await P.getInstance().getProjectByUri(e)?.getBuild(t)?.buildStorybook()}}},Da=class{static cmd=`aventus.template.import_project`;static async run(){await $.templateManager?.selectProjectToImport(!1)}},Oa=class{static cmd=`aventus.npm.build`;static async run(){let e=[],t=P.getInstance().getAllBuildsWithNpm();for(let n of t)e.push({label:n.name,detail:n.uri});if(e.length===0){$.showWarningMessage(`No package to build was found.`);return}let n=e.length==1?e[0]:await $.Select(e,{title:`Package to build`});if(n&&e.some(e=>e.label===n.label&&e.detail===n.detail)){let e=n.detail??``,t=n.label;return await P.getInstance().getProjectByUri(e)?.getBuild(t)?.buildNpm()}}};const ka={$schema:`foo://aventus/i18n.json`,title:`JSON Schema for Aventus I18n`,description:`JSON Schema for Aventus I18n`,type:`object`,additionalProperties:{type:`object`,additionalProperties:{type:`string`}}};var Aa=class e{static empty=`ⵌⵌ`;static instance;static getInstance(){return this.instance||=new e,this.instance}languageService;constructor(){this.languageService=(0,h.getLanguageService)({}),this.languageService.configure({allowComments:!0,schemas:[{fileMatch:[`**`+E.I18n],uri:ka.$schema??``,schema:ka}]})}async validate(t){let n=t.file.documentUser,r=this.languageService.parseJSONDocument(n),i=await this.languageService.doValidation(n,r),a=r.syntaxErrors;if(!r.root||a?.length)return i.length==0&&i.push(ss(n,`Can't parse the json`)),i.map(e=>({...e,severity:h.DiagnosticSeverity.Error}));try{let a=t.parsed??{},o=(t.build.buildConfig.i18n?.locales??[]).filter(e=>!ve.isReservedI18nLocale(e));for(let e of r.root.children??[]){if(e.type!==`property`)continue;let t=e.children?.[0];if(t&&ve.isReservedI18nLocale(String(t.value))&&i.push(cs(n,`Translation key ${t.value} is not allowed`,t.offset,t.offset+t.length)),e.children&&e.children.length>1){let t=e.children[1].children??[];for(let e of t){if(e.type!==`property`)continue;let t=e.children[0];t&&ve.isReservedI18nLocale(String(t.value))&&i.push(cs(n,`Locale ${t.value} is not allowed`,t.offset,t.offset+t.length))}}}for(let r in a){if(t.isGlobal){let e=t.build.tsLanguageService?.i18nFiles??{};Object.values(e).filter(e=>e!==t&&e.isGlobal&&e.parsed&&Object.hasOwn(e.parsed,r)).length>0&&i.push(cs(n,`Duplicate translation key ${r} across global files`,a[r].keyStart,a[r].keyEnd))}for(let n in a[r].locales){let s=a[r].locales[n];o.includes(n)||i.push(ls(t.file.documentUser,`Locale not needed`,s.localeStart,s.localeEnd)),s.value==e.empty&&i.push(ls(t.file.documentUser,`Translation not set`,s.valueStart,s.valueEnd))}let s=[];for(let e of o)a[r].locales[e]===void 0&&s.push(e);s.length>0&&i.push(cs(t.file.documentUser,`Missing locales `+s.join(`, `),a[r].keyStart,a[r].keyEnd))}return i}catch{i.length==0&&i.push(ss(n,`Can't parse the json`))}for(let e of i)e.severity=h.DiagnosticSeverity.Error;return i}async format(e,t,n){try{let t;try{let n=JSON.parse(e.contentUser);t=JSON.stringify(this.sortObj(n),null,4)}catch{let n=this.languageService.parseJSONDocument(e.documentUser),r=n.root,i=n.syntaxErrors;if(!r||r.type!==`object`||i?.some(e=>e.code!==h.ErrorCode.TrailingComma))return[];let a=e.contentUser.slice(0,r.offset)+this.sortJsoncObject(e.contentUser,r)+e.contentUser.slice(r.offset+r.length),o=d.TextDocument.create(e.uri,e.documentUser.languageId,e.documentUser.version,a),s=await this.languageService.format(o,void 0,{tabSize:4,insertSpaces:!0});t=d.TextDocument.applyEdits(o,s)}return[{newText:t,range:{start:e.documentUser.positionAt(0),end:e.documentUser.positionAt(e.contentUser.length)}}]}catch{}return[]}sortJsoncObject(e,t){let n=t.properties,r=t.offset+1,i=[];for(let t of n){let n=t.valueNode,a=this.removeJsoncComma(e.slice(r,t.offset));r=t.offset+t.length;let o=e.slice(t.offset,r);if(n?.type===`object`){let r=n.offset-t.offset;o=o.slice(0,r)+this.sortJsoncObject(e,n)+o.slice(r+n.length)}i.push({key:t.keyNode.value,text:a+o})}let a=this.removeJsoncComma(e.slice(r,t.offset+t.length-1));return i.sort((e,t)=>e.key<t.key?-1:+(e.key>t.key)),`{`+i.map(e=>e.text).join(`,`)+a+`}`}removeJsoncComma(e){return e.replace(/^(\s*),/,`$1`)}async codeAction(e,t){let n=[];try{let t=this.actionImportMissingLocales(e);t&&n.push(t)}catch{}return n}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=t.file.documentUser,r=t.file.contentUser,i=this.languageService.parseJSONDocument(n),a=i.syntaxErrors,o=i.root;if(o?.type!==`object`||a?.length){$.showErrorMessage(`The i18n file is malformed. Fix its JSON before importing missing locales.`);return}let s=[],c=(t.build.buildConfig.i18n?.locales??[]).filter(e=>!ve.isReservedI18nLocale(e));for(let t of o.properties){if(ve.isReservedI18nLocale(String(t.keyNode.value)))continue;let i=t.valueNode;if(i?.type!==`object`)continue;let a=c.filter(e=>!i.properties.some(t=>t.keyNode.value===e));if(a.length===0)continue;let o=i.properties[0],l=o?.offset??i.offset+1,u=r.lastIndexOf(`
|
|
610
610
|
`,l-1)+1,d=r.slice(u,l),f=r.slice(i.offset,i.offset+i.length).includes(`
|
|
611
611
|
`),p=o&&/^\s*$/.test(d)?d:` `,m=a.map(t=>`${JSON.stringify(t)}: ${JSON.stringify(e.empty)}`),h;h=o?f&&/^\s*$/.test(d)?m.join(`,
|
|
612
612
|
`+p)+`,
|
|
613
613
|
`+p:m.join(`, `)+`, `:f?`
|
|
614
614
|
`+p+m.join(`,
|
|
615
615
|
`+p)+`
|
|
616
|
-
`:m.join(`, `);let g=n.positionAt(l);s.push({newText:h,range:{start:g,end:g}})}if(s.length!==0)return{title:`Import missing locales`,edit:{changes:{[t.file.uri]:s}}}}},Na=class{static cmd=`aventus.i18n.add`;static async run(e,t,n=!0){try{let r=P.getInstance().getMatchingBuildsByUri(e);if(r.length>0){let i=r[0],a=e.replace(E.ComponentView,E.I18n),o=[];if(n&&i.i18nComponentsFiles[a]){let e=L(a);o.push({label:(0,f.basename)(e),detail:e})}for(let e in i.tsLanguageService.i18nFiles){let t=L(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=I(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:Ma.empty;let l=[{newText:JSON.stringify(Ma.sortObj(a),null,4),range:{start:r.file.documentUser.positionAt(0),end:r.file.documentUser.positionAt(r.file.documentUser.getText().length)}}];ta.send(n,[l]),setTimeout(async()=>{let t=e.replace(E.ComponentView,E.ComponentLogic),n=i.tsFiles[t],r=i.htmlFiles[e];await n?.validate(),await r?.validate()},2e3)}}}catch(e){console.error(e)}}},Pa=class{static send(e,t,n){$.sendNotification(`aventus/php/compiling`,e,t,n)}},Fa=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=z.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=z.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(E.PhpConfig)&&!e.uri.includes(`/vendor/`)&&(this.files[e.uri]=new Ia(e))}async onFileRemove(e){delete this.files[e]}destroy(){z.getInstance().removeOnNewFile(this.onNewFileUUID),z.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},Ia=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 O&&await this.file.validate()}triggerSave(){this.file instanceof O&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof O&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return Qe.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return Qe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return Qe.getInstance().doResolve(t)}async onHover(e,t){return Qe.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return Qe.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}},La=class{static cmd=`aventus.php.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,ba.sync)(`php`)){$.showErrorMessage(`Php isn't installed on your system`);return}if(!(0,ba.sync)(`php-converter`))try{if(!(0,ba.sync)(`composer`)){$.showErrorMessage(`composer isn't installed on your system`);return}if(await $.ask(`php-converter is missing. Can I install it?`)&&await Yo(`composer global require aventus/transpiler`),!(0,ba.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(E.PhpConfig)){let t=Object.keys(Fa.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=L(e.replace(E.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),$.showErrorMessage(`Invalid composer.json: ${e}`);return}this.isCompiling=!0,Pa.send(t,`compiling`);try{let{stdout:n,stderr:r}=await Zo(`php-converter`,[L(e)],{encoding:`utf8`}),i=n.toString(),a=r.toString(),o=i.includes(`Error : `)?i:a.includes(`Error : `)?a:null;if(!o)a.trim()&&$.showWarningMessage(a.trim()),Pa.send(t,`success`);else{console.clear(),$.error(o);let e=`php_errors`;Sa.send(e,o),Pa.send(t,`error`,[{title:`PHP error`,file:e}])}}catch(e){let n=e.stderr?.trim()||String(e);$.showErrorMessage(n),Sa.send(`php_errors`,n),Pa.send(t,`error`,[{title:`PHP error`,file:`php_errors`}])}this.isCompiling=!1}},Ra=class{static cmd=`aventus.store.connect`;static async run(e,t){if(so.isConnected){await $.showInformationMessage(`You are already connected with account `+so.settings.username);return}!e&&(e=await $.Input({title:`Username`}),!e)||!t&&(t=await $.Input({title:`Password`,password:!0}),!t)||(await so.connect(e,t)?await $.showInformationMessage(`Connection successful`):await $.showErrorMessage(`Connection failed`))}},za=class{static cmd=`aventus.store.disconnect`;static async run(){so.isConnected&&(await so.disconnect(),$.showInformationMessage(`You are disconnected`))}},Ba=class{static cmd=`aventus.store.publish_package`;static async run(){if(!so.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let e=P.getInstance().getAllBuilds(),t=[],n=null;if(e.length==1)n={label:e[0].name,detail:e[0].uri};else if(e.length>1){for(let n of e)t.push({label:n.name,detail:n.uri});n=await $.Select(t,{title:`Project to compile`})}if(n){let e=n.detail??``,t=n.label,r=P.getInstance().getProjectByUri(e)?.getBuild(t);if(r){let e=await so.publishPackage(r);if(e instanceof co)for(let t of e.errors)$.showErrorMessage(t.message);else $.showInformationMessage(`Package published`)}}}},Va=class{static cmd=`aventus.template.quick_edit`;static async run(){let e=F.getInstance().settings.quickCreations,t=[],n={},r,i=a=>{if(!r)if(a instanceof ro){if(a.allowQuick){let i=n[a.name];if(i&&i!==a.folderPath){r={first:i,second:a.folderPath};return}n[a.name]=a.folderPath,t.push({label:a.name,detail:a.description,picked:e.includes(a.folderPath),folderPath:a.folderPath})}}else for(let e in a)i(a[e])};if(i((await $.templateManager?.readGlobal()??{nb:0,templates:{}}).templates),i((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),i((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates),r){$.showErrorMessage(`You have 2 templates with the same names : `+r.first+` and `+r.second);return}if(t.length==0){F.getInstance().setSettings({quickCreations:[]},!0),$.showErrorMessage(`No template/project allow quick creation`);return}let a=await $.SelectMultiple(t,{title:`Select quick templates`});if(a){e=[];for(let n of a){let r=t.find(e=>e.label==n.label)?.folderPath;r&&e.push(r)}F.getInstance().setSettings({quickCreations:e},!0)}}},Ha=class{static cmd=`aventus.template.quick`;static async run(){let e=F.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,o=(e,r)=>{let o=e.folderPath??r,s=i[e.name];if(s&&s!==o){a={first:s,second:o};return}s||(i[e.name]=o,t.push({label:e.name,detail:e.description}),n[e.name]=r)},s={},c=e=>{if(e instanceof ro)e.allowQuick&&(s[e.folderPath]=e);else for(let t in e)c(e[t])};c((await $.templateManager?.getGeneralGlobal()??{nb:0,templates:{}}).templates),c((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),c((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates);for(let t of e)if(s[t]){let e=s[t];o(e,t)}else if(t.endsWith(E.Template)||(t=(0,f.join)(t,E.Template)),(0,u.existsSync)(t)){let e=await ro.create(t);e&&o(e,t)}if(a){$.showErrorMessage(`You have 2 templates with the same names : `+a.first+` and `+a.second);return}if(t.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let l=await $.Select(t,{title:`Select quick template`});if(!l)return;r=n[l.label]}if(r.endsWith(E.Template)||(0,u.existsSync)((0,f.join)(r,E.Template))&&(r=(0,f.join)(r,E.Template)),!(0,u.existsSync)(r)){$.showErrorMessage(`The file doesn't exist : `+r);return}let i=await ro.create(r);i&&await i.init(n,n)}},Ua=class{static cmd=`aventus.store.publish_template`;static async run(e){if(!e)return;if(!so.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let t=L(e);if((0,u.existsSync)(t)&&t.endsWith(E.Template)){let e=await ro.create(t);if(e){let t=await so.publishTemplate(e);if(t instanceof co)for(let e of t.errors)$.showErrorMessage(e.message);else $.showInformationMessage(`Template published`)}else $.showErrorMessage(`Your script for the template contains errors`)}}},Wa=class{static cmd=`aventus.store.download_template`;static async run(e){e&&await $.templateManager?.downloadTemplateFromStore(e)}},Ga=class{static cmd=`aventus.template.uninstall_project`;static async run(){await $.templateManager?.selectProjectToUninstall()}},Ka=class{static cmd=`aventus.template.uninstall`;static async run(){await $.templateManager?.selectTemplateToUninstall()}},qa=class{static cmd=`aventus.format`;static async run(e){let t=[];t=e?[e]:z.getInstance().getUris();let n=[],r=[];await $.showLoadingMessage(`Formatting `+t.length+` files`,async()=>{for(let e of t){let t=z.getInstance().getByUri(e);if(t instanceof O)try{let n=t.contentUser,i=t.versionUser,a=await t.getFormatting();if(t.versionUser!==i){r.push(L(e));continue}await t.applyTextEdits(a),n!=t.contentUser&&(0,u.writeFileSync)(L(e),t.contentUser)}catch(t){console.error(t),n.push(L(e))}}}),n.length>0&&$.showErrorMessage(`Formatting failed for ${n.length} file(s):\n${n.join(`
|
|
616
|
+
`:m.join(`, `);let g=n.positionAt(l);s.push({newText:h,range:{start:g,end:g}})}if(s.length!==0)return{title:`Import missing locales`,edit:{changes:{[t.file.uri]:s}}}}},ja=class{static cmd=`aventus.i18n.add`;static async run(e,t,n=!0){try{let r=P.getInstance().getMatchingBuildsByUri(e);if(r.length>0){let i=r[0],a=e.replace(E.ComponentView,E.I18n),o=[];if(n&&i.i18nComponentsFiles[a]){let e=L(a);o.push({label:(0,f.basename)(e),detail:e})}for(let e in i.tsLanguageService.i18nFiles){let t=L(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=I(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:Aa.empty;let l=[{newText:JSON.stringify(Aa.sortObj(a),null,4),range:{start:r.file.documentUser.positionAt(0),end:r.file.documentUser.positionAt(r.file.documentUser.getText().length)}}];$i.send(n,[l]),setTimeout(async()=>{let t=e.replace(E.ComponentView,E.ComponentLogic),n=i.tsFiles[t],r=i.htmlFiles[e];await n?.validate(),await r?.validate()},2e3)}}}catch(e){console.error(e)}}},Ma=class{static send(e,t,n){$.sendNotification(`aventus/php/compiling`,e,t,n)}},Na=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=z.getInstance().onNewFile(this.onNewFile),this.onFileRemoveUUID=z.getInstance().onFileRemove(this.onFileRemove)}async onNewFile(e){e.uri.endsWith(E.PhpConfig)&&!e.uri.includes(`/vendor/`)&&(this.files[e.uri]=new Pa(e))}async onFileRemove(e){delete this.files[e]}destroy(){z.getInstance().removeOnNewFile(this.onNewFileUUID),z.getInstance().removeOnFileRemove(this.onFileRemoveUUID)}},Pa=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 O&&await this.file.validate()}triggerSave(){this.file instanceof O&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof O&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async onContentChange(){}async onValidate(){return Qe.getInstance().validate(this.file)}async onSave(){}async onDelete(){}async _onDelete(){await this.onDelete(),this.removeEvents()}async onCompletion(e,t){return Qe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return Qe.getInstance().doResolve(t)}async onHover(e,t){return Qe.getInstance().doHover(e,t)}async onDefinition(e,t){return null}async onFormatting(e,t,n){return Qe.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}},Fa=class{static cmd=`aventus.php.export`;static isCompiling=!1;static async run(e){if(this.isCompiling)return;if(!(0,va.sync)(`php`)){$.showErrorMessage(`Php isn't installed on your system`);return}if(!(0,va.sync)(`php-converter`))try{if(!(0,va.sync)(`composer`)){$.showErrorMessage(`composer isn't installed on your system`);return}if(await $.ask(`php-converter is missing. Can I install it?`)&&await qo(`composer global require aventus/transpiler`),!(0,va.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(E.PhpConfig)){let t=Object.keys(Na.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=L(e.replace(E.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),$.showErrorMessage(`Invalid composer.json: ${e}`);return}this.isCompiling=!0,Ma.send(t,`compiling`);try{let{stdout:n,stderr:r}=await Yo(`php-converter`,[L(e)],{encoding:`utf8`}),i=n.toString(),a=r.toString(),o=i.includes(`Error : `)?i:a.includes(`Error : `)?a:null;if(!o)a.trim()&&$.showWarningMessage(a.trim()),Ma.send(t,`success`);else{console.clear(),$.error(o);let e=`php_errors`;ba.send(e,o),Ma.send(t,`error`,[{title:`PHP error`,file:e}])}}catch(e){let n=e.stderr?.trim()||String(e);$.showErrorMessage(n),ba.send(`php_errors`,n),Ma.send(t,`error`,[{title:`PHP error`,file:`php_errors`}])}this.isCompiling=!1}},Ia=class{static cmd=`aventus.store.connect`;static async run(e,t){if(ao.isConnected){await $.showInformationMessage(`You are already connected with account `+ao.settings.username);return}!e&&(e=await $.Input({title:`Username`}),!e)||!t&&(t=await $.Input({title:`Password`,password:!0}),!t)||(await ao.connect(e,t)?await $.showInformationMessage(`Connection successful`):await $.showErrorMessage(`Connection failed`))}},La=class{static cmd=`aventus.store.disconnect`;static async run(){ao.isConnected&&(await ao.disconnect(),$.showInformationMessage(`You are disconnected`))}},Ra=class{static cmd=`aventus.store.publish_package`;static async run(){if(!ao.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let e=P.getInstance().getAllBuilds(),t=[],n=null;if(e.length==1)n={label:e[0].name,detail:e[0].uri};else if(e.length>1){for(let n of e)t.push({label:n.name,detail:n.uri});n=await $.Select(t,{title:`Project to compile`})}if(n){let e=n.detail??``,t=n.label,r=P.getInstance().getProjectByUri(e)?.getBuild(t);if(r){let e=await ao.publishPackage(r);if(e instanceof oo)for(let t of e.errors)$.showErrorMessage(t.message);else $.showInformationMessage(`Package published`)}}}},za=class{static cmd=`aventus.template.quick_edit`;static async run(){let e=F.getInstance().settings.quickCreations,t=[],n={},r,i=a=>{if(!r)if(a instanceof to){if(a.allowQuick){let i=n[a.name];if(i&&i!==a.folderPath){r={first:i,second:a.folderPath};return}n[a.name]=a.folderPath,t.push({label:a.name,detail:a.description,picked:e.includes(a.folderPath),folderPath:a.folderPath})}}else for(let e in a)i(a[e])};if(i((await $.templateManager?.readGlobal()??{nb:0,templates:{}}).templates),i((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),i((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates),r){$.showErrorMessage(`You have 2 templates with the same names : `+r.first+` and `+r.second);return}if(t.length==0){F.getInstance().setSettings({quickCreations:[]},!0),$.showErrorMessage(`No template/project allow quick creation`);return}let a=await $.SelectMultiple(t,{title:`Select quick templates`});if(a){e=[];for(let n of a){let r=t.find(e=>e.label==n.label)?.folderPath;r&&e.push(r)}F.getInstance().setSettings({quickCreations:e},!0)}}},Ba=class{static cmd=`aventus.template.quick`;static async run(){let e=F.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,o=(e,r)=>{let o=e.folderPath??r,s=i[e.name];if(s&&s!==o){a={first:s,second:o};return}s||(i[e.name]=o,t.push({label:e.name,detail:e.description}),n[e.name]=r)},s={},c=e=>{if(e instanceof to)e.allowQuick&&(s[e.folderPath]=e);else for(let t in e)c(e[t])};c((await $.templateManager?.getGeneralGlobal()??{nb:0,templates:{}}).templates),c((await $.localProjectManager?.readProjects()??{nb:0,templates:{}}).templates),c((await $.localTemplateManager?.readTemplates()??{nb:0,templates:{}}).templates);for(let t of e)if(s[t]){let e=s[t];o(e,t)}else if(t.endsWith(E.Template)||(t=(0,f.join)(t,E.Template)),(0,u.existsSync)(t)){let e=await to.create(t);e&&o(e,t)}if(a){$.showErrorMessage(`You have 2 templates with the same names : `+a.first+` and `+a.second);return}if(t.length==0){$.showErrorMessage(`No global template set as quick creation. Try to edit quick creation first`);return}let l=await $.Select(t,{title:`Select quick template`});if(!l)return;r=n[l.label]}if(r.endsWith(E.Template)||(0,u.existsSync)((0,f.join)(r,E.Template))&&(r=(0,f.join)(r,E.Template)),!(0,u.existsSync)(r)){$.showErrorMessage(`The file doesn't exist : `+r);return}let i=await to.create(r);i&&await i.init(n,n)}},Va=class{static cmd=`aventus.store.publish_template`;static async run(e){if(!e)return;if(!ao.isConnected){$.showErrorMessage(`You must connect to your account first`);return}let t=L(e);if((0,u.existsSync)(t)&&t.endsWith(E.Template)){let e=await to.create(t);if(e){let t=await ao.publishTemplate(e);if(t instanceof oo)for(let e of t.errors)$.showErrorMessage(e.message);else $.showInformationMessage(`Template published`)}else $.showErrorMessage(`Your script for the template contains errors`)}}},Ha=class{static cmd=`aventus.store.download_template`;static async run(e){e&&await $.templateManager?.downloadTemplateFromStore(e)}},Ua=class{static cmd=`aventus.template.uninstall_project`;static async run(){await $.templateManager?.selectProjectToUninstall()}},Wa=class{static cmd=`aventus.template.uninstall`;static async run(){await $.templateManager?.selectTemplateToUninstall()}},Ga=class{static cmd=`aventus.format`;static async run(e){let t=[];t=e?[e]:z.getInstance().getUris();let n=[],r=[];await $.showLoadingMessage(`Formatting `+t.length+` files`,async()=>{for(let e of t){let t=z.getInstance().getByUri(e);if(t instanceof O)try{let n=t.contentUser,i=t.versionUser,a=await t.getFormatting();if(t.versionUser!==i){r.push(L(e));continue}await t.applyTextEdits(a),n!=t.contentUser&&(0,u.writeFileSync)(L(e),t.contentUser)}catch(t){console.error(t),n.push(L(e))}}}),n.length>0&&$.showErrorMessage(`Formatting failed for ${n.length} file(s):\n${n.join(`
|
|
617
617
|
`)}`),r.length>0&&$.showErrorMessage(`Files changed during formatting; format them again:\n${r.join(`
|
|
618
|
-
`)}`)}},
|
|
618
|
+
`)}`)}},Ka=class e{fctTxt=null;static is(t){return t.name==`Attribute`?new e:null}},qa=class{static files={};static done=!1;static async register(e){this.files[e.file.uri]||(this.files[e.file.uri]=e,this.done&&await this.write())}static async write(e=!1){let t={html:{snippets:{block:'<block name="${1}">${2}</block>'}}};for(let e in this.files){let n=this.files[e].srcInfo.available;for(let e of n)if(e.tagName){let n=e.tagName;t.html.snippets[n]=`<${n}>\${1}</${n}>`}}let n=(0,f.join)(L($.getWorkspaceUri()),`.aventus`,`emmet`),r=(0,f.join)(n,`snippets.json`);if(!e&&!(0,u.existsSync)(r)){this.done=!0;return}(0,u.existsSync)(n)||(0,u.mkdirSync)(n,{recursive:!0}),await Ts(r,JSON.stringify(t,null,2),`manifest`),this.done=!0}static getMarkdown(e){return this.files[e]?new Ja(this.files[e]).getContent():``}},Ja=class{file;checker;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):e.type==6?this.loadEnum(e):e.type==5&&this.loadVariable(e);this.overviews.length>0&&(this.writeOverview(),this.writeContent())}isManifestClass(e){return e.isWebComponent!==void 0}isManifestFunction(e){return e.result!==void 0}anchorFor(e){return`pkg-`+e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)}getType(e){e instanceof k||(e=new k(e));let t=e.getFullTxt().trim();return t.startsWith(`___`)&&(t=t.substring(3)),t=t.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\|/g,`|`),t}getChecker(){if(!this.checker){let e=this.file.fileParsed.srcFile,t={target:p.ScriptTarget.ESNext,noEmit:!0,skipLibCheck:!0},n=(0,p.createCompilerHost)(t),r=n.getSourceFile;n.getSourceFile=(t,n,i,a)=>t===e.fileName?e:r(t,n,i,a),this.checker=(0,p.createProgram)([e.fileName],t,n).getTypeChecker()}return this.checker}getReturnType(e){if(e.type)return this.getType(e.type);let t=this.getChecker().getSignatureFromDeclaration(e);return t?this.getChecker().typeToString(this.getChecker().getReturnTypeOfSignature(t)):`any`}getParameter(e){let t=e.dotDotDotToken?`...`:``,n=e.questionToken?`?`:``;return`${`${t}${e.name.getText()}${n}`}: ${e.type?this.getType(e.type):this.getChecker().typeToString(this.getChecker().getTypeAtLocation(e))}${e.initializer?` = ${e.initializer.getText().replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/\|/g,`|`)}`:``}`}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)r.push(this.getParameter(e));n+=`(${r.join(`, `)})`;let i={name:n,anchor:this.anchorFor(t.fullName),result:this.getReturnType(t.node),description:t.documentation?.definitions.join(`
|
|
619
619
|
`)??``,isAbstract:!1};this.overviews.push({name:t.fullName,anchor:i.anchor,type:`Function`,description:i.description}),this.parts.push(i)}loadEnum(e){let t=this.file.fileParsed.enums[e.fullName],n={name:t.fullName,anchor:this.anchorFor(t.fullName),kind:`enum`,description:t.documentation?.definitions.join(`
|
|
620
620
|
`)??``,members:Array.from(t.node.members,e=>({name:e.name.getText(),value:e.initializer?.getText()??``,description:new Gt(e).definitions.join(`
|
|
621
621
|
`)}))};this.overviews.push({name:n.name,anchor:n.anchor,type:`Enum`,description:n.description}),this.parts.push(n)}loadVariable(e){let t=this.file.fileParsed.variables[e.fullName],n={name:t.fullName,anchor:this.anchorFor(t.fullName),kind:`variable`,declaration:t.type,type:t.node.type?this.getType(t.node.type):`any`,value:t.node.initializer?.getText(),description:t.documentation?.definitions.join(`
|
|
622
622
|
`)??``};this.overviews.push({name:n.name,anchor:n.anchor,type:`Variable`,description:n.description}),this.parts.push(n)}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,anchor:this.anchorFor(t.fullName),isWebComponent:t.isWebcomponent,tag:e.tagName?`<${e.tagName}></${e.tagName}>`:void 0,type:t.isInterface?`Interface`:`Class`,description:t.documentation?.definitions.join(`
|
|
623
|
-
`)??``,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,anchor:r.anchor,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=>Bn.is(e))&&(t=`@Property()`),e.decorators.find(e=>
|
|
623
|
+
`)??``,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,anchor:r.anchor,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=>Bn.is(e))&&(t=`@Property()`),e.decorators.find(e=>Ka.is(e))&&(t=`@Attribute()`),e.decorators.find(e=>Kn.is(e))&&(t=`@Watch()`),e.decorators.find(e=>Qn.is(e))&&(t=`@Signal()`),{name:e.name,type:this.getType(e.type),description:e.documentation?.definitions.join(`
|
|
624
624
|
`)??``,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)n.push(this.getParameter(t));return t+=`(${n.join(`, `)})`,{name:t,result:this.getReturnType(e.node),description:e.documentation?.definitions.join(`
|
|
625
625
|
`)??``,isAbstract:e.isAbstract}}getContent(){return this.content.join(`
|
|
626
|
-
`)}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.anchor})`,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(`<a id="${e.anchor}"></a>`),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):`kind`in e&&e.kind===`enum`?this.writeEnum(e):`kind`in e&&e.kind===`variable`&&this.writeVariable(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}`)}writeEnum(e){this.add(` - Type : Enum`),this.line(),this.addColumnsHeader([`Member`,`Value`,`Description`]);for(let t of e.members)this.addColumns([t.name,t.value,t.description])}writeVariable(e){this.add(` - Declaration : ${e.declaration}`),this.add(` - Type : ${e.type}`),e.value!==void 0&&this.add(` - Initial value : ${e.value}`)}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|\r|\n/g,` `).replace(/ {2,}/g,` `).trim().replace(/\|/g,`\\|`)).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)}},
|
|
626
|
+
`)}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.anchor})`,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(`<a id="${e.anchor}"></a>`),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):`kind`in e&&e.kind===`enum`?this.writeEnum(e):`kind`in e&&e.kind===`variable`&&this.writeVariable(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}`)}writeEnum(e){this.add(` - Type : Enum`),this.line(),this.addColumnsHeader([`Member`,`Value`,`Description`]);for(let t of e.members)this.addColumns([t.name,t.value,t.description])}writeVariable(e){this.add(` - Declaration : ${e.declaration}`),this.add(` - Type : ${e.type}`),e.value!==void 0&&this.add(` - Initial value : ${e.value}`)}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|\r|\n/g,` `).replace(/ {2,}/g,` `).trim().replace(/\|/g,`\\|`)).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)}},Ya=class{static cmd=`aventus.ai.dependencies`;static async run(){if(!$.isIDE){let e=await z.getInstance().loadAllAventusConfigFiles([$.getWorkspaceUri()]);for(let t of e){let e=new Eo(t,!1);await e.init();for(let t of e.getBuilds())await so.getInstance().loadDependenciesFromBuild(t.buildConfig,t)}}let e=so.getInstance().packages,t=(0,f.join)(L($.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=qa.getMarkdown(t.file.uri);e&&(0,u.writeFileSync)((0,f.join)(n,t.name+`.md`),e)}}},Xa=class{static cmd=`aventus.ai.rules`;static async run(){let e=(0,f.join)($.extensionPath,`lib`,`aventusjs-rules.md`),t=(0,f.join)(L($.getWorkspaceUri()),`.aventus`);(0,u.existsSync)(t)||(0,u.mkdirSync)(t),(0,u.copyFileSync)(e,(0,f.join)(t,`aventusjs-rules.md`))}},Za=class{static cmd=`aventus.emmet`;static async run(){await qa.write(!0)}},Qa=class{static cmd=`aventus.sharp.update_tools`;static async run(){if(!(0,va.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,va.sync)(n)&&await $.showLoadingMessage(`Updating `+n,async()=>{try{let r=await qo(e[n]);r.stderr?$.showErrorMessage(r.stderr):t.push(n)}catch(e){let t=e;$.showErrorMessage(`Failed to update ${n}: ${t.stderr?.trim()||t.message}`)}});t.length>0&&$.showInformationMessage(`Update done for : `+t.join(`, `))}},$a=class{static cmd=`aventus.wc.create.signal`;static async run(e,t,n){if(!e||typeof t!=`number`)return;let r=await $.Input({title:`Provide a name for your Signal variable`,value:n});if(!r)return;let i=await $.Input({title:`Provide a type for your Signal`});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=z.getInstance().getByUri(e);if(s){let n=s.documentUser.positionAt(s.contentUser.length),a=z.getInstance().getBuild(s.documentUser)?.find(t=>t.tsFiles[e]instanceof N),c=(a?.tsFiles[e])?.getComponentName()??``;if(c==``)return;let l=``;o&&(a?.isCoreBuild,l=`(target: `+c+`) => {
|
|
627
627
|
|
|
628
628
|
}`);let u=`@Signal(`+l+`)
|
|
629
629
|
public `+r+`?:`+i+`;
|
|
630
|
-
`,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,T.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}}]
|
|
630
|
+
`,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,T.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}}];$i.send(e,[_])}}};const eo={allCommandes:{[Vi.cmd]:Vi,[Yi.cmd]:Yi,[Qi.cmd]:Qi,[Xi.cmd]:Xi,[Hi.cmd]:Hi,[aa.cmd]:aa,[oa.cmd]:oa,[Gi.cmd]:Gi,[Ji.cmd]:Ji,[Zi.cmd]:Zi,[Bi.cmd]:Bi,[Ta.cmd]:Ta,[ea.cmd]:ea,[ta.cmd]:ta,[na.cmd]:na,[$a.cmd]:$a,[ra.cmd]:ra,[ia.cmd]:ia,[Ui.cmd]:Ui,[sa.cmd]:sa,[la.cmd]:la,[da.cmd]:da,[pa.cmd]:pa,[ha.cmd]:ha,[ga.cmd]:ga,[Da.cmd]:Da,[Ca.cmd]:Ca,[Qa.cmd]:Qa,[Fa.cmd]:Fa,[wa.cmd]:wa,[Ea.cmd]:Ea,[Oa.cmd]:Oa,[ja.cmd]:ja,[Ia.cmd]:Ia,[La.cmd]:La,[Ra.cmd]:Ra,[Va.cmd]:Va,[Ha.cmd]:Ha,[Ba.cmd]:Ba,[za.cmd]:za,[Ua.cmd]:Ua,[Wa.cmd]:Wa,[Ga.cmd]:Ga,[Ya.cmd]:Ya,[Xa.cmd]:Xa,[Za.cmd]:Za},execute:async function(e){let t=this.allCommandes[e.command];if(t){let n=e.arguments??[];await t.run.call(t,...n)}}};var to=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){if(!(0,u.existsSync)(t)){delete this.memory[t];return}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=>{let r=!1,i=e=>{r||(r=!0,e&&$.showErrorMessage(String(e)),n())};try{let n=`
|
|
631
631
|
import { AventusTemplate } from 'file://${(0,f.join)(xt(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
|
|
632
632
|
import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
|
|
633
633
|
|
|
634
634
|
const t = new Template();
|
|
635
|
-
await t._run(\`${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 a=(0,f.join)(r,
|
|
636
|
-
`;o.stdin.write(n)};o.stdin.on(`error`,function(e){console.log(e)});let c=``,l=Promise.resolve(),d=async e=>{try{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)z.getInstance().
|
|
637
|
-
`))!==-1;){let e=c.slice(0,t).trim();c=c.slice(t+1),e&&(l=l.then(()=>d(e)))}});let p=``;o.stderr.on(`data`,e=>{p+=e.toString()}),o.on(`error`,i),o.on(`close`,e=>{try{
|
|
635
|
+
await t._run(\`${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 a=(0,f.join)(r,Es(this.config)+`_1.ts`);(0,u.writeFileSync)(a,n);let o=(0,ce.spawn)(`node`,[`--no-warnings`,a],{cwd:this.folderPath,detached:!0}),s=(e,t)=>{let n=JSON.stringify({cmd:e,result:t??`NULL`})+`
|
|
636
|
+
`;o.stdin.write(n)};o.stdin.on(`error`,function(e){console.log(e)});let c=``,l=Promise.resolve(),d=async e=>{try{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)z.getInstance().applyBatch({created:[I(t)],updated:[],deleted:[]})}else if(t.cmd==`openFile`){let e=t.config;for(let t of e)$.sendNotification(`aventus/openfile`,(0,b.pathToFileURL)(t).toString())}else if(t.cmd==`getNamespace`){let e=t.config,n=P.getInstance().getMatchingBuildsByUri(I(e));if(n.length>0){let r=n[0].getNamespaceForUri(I(e));s(t.cmd,r)}else s(t.cmd,null)}else if(t.cmd==`exec`){let e={};e.cwd=L($.getWorkspaceUri());let n=t.config;try{await qo(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=L($.getWorkspaceUri());try{`${n}`,process.platform==`darwin`&&`${n}`,(0,de.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==`aventusCommand`){let e=t.config;try{await eo.execute({command:e.command,arguments:e.arguments})}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=Li.send(e);s(t.cmd,n)}else if(t.cmd==`progressStop`){let e=t.config;Ri.send(e)}else t.cmd==`log`?$.debug(t.config):t.cmd==`error`&&console.error(t.config)}catch(t){$.error(t),$.error(`message `+e)}};o.stdout.on(`data`,e=>{c+=e.toString();let t;for(;(t=c.indexOf(`
|
|
637
|
+
`))!==-1;){let e=c.slice(0,t).trim();c=c.slice(t+1),e&&(l=l.then(()=>d(e)))}});let p=``;o.stderr.on(`data`,e=>{p+=e.toString()}),o.on(`error`,i),o.on(`close`,e=>{try{Ds(a)}catch(e){i(e);return}e===0?i():i(p.trim()||`Template process exited with code ${e}`)})}catch(e){i(e)}})}async isAllowed(e,t){if(!this.hasIsAllow)return!0;let n=`
|
|
638
638
|
import { AventusTemplate, log } from 'file://${(0,f.join)(xt(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
|
|
639
639
|
import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
|
|
640
640
|
|
|
@@ -643,13 +643,13 @@ public `+r+`?:`+i+`;
|
|
|
643
643
|
});
|
|
644
644
|
|
|
645
645
|
const t = new Template();
|
|
646
|
-
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,
|
|
646
|
+
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,Es(this.config)+`.ts`);(0,u.writeFileSync)(i,n);var a=``,o=``;let s=!1;try{let e=await Yo(process.execPath,[`--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 Ds(i),s}static preparing={};prepareScript(){return new Promise(async t=>{let n=Es(this.config);if(e.preparing[n]!==void 0){e.preparing[n].push(e=>{t(e)});return}e.preparing[n]=[];let r=`
|
|
647
647
|
import { AventusTemplate, log } from 'file://${(0,f.join)(xt(),`lib/templateScript/AventusTemplate.ts`).replace(/\\/g,`\\\\`)}';
|
|
648
648
|
import { Template } from 'file://${this.config.replace(/\\/g,`\\\\`)}'
|
|
649
649
|
const t = new Template();
|
|
650
|
-
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 Zo(process.execPath,[`--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}ks(a);let l=[...e.preparing[n]];delete e.preparing[n];for(let e of l)e(o);t(o)})}},io=class extends Error{};function ao(e){let t={};for(let[n,r]of Object.entries(e))t[n]=r instanceof ro||typeof r!=`object`||!r?r:ao(r);return t}var oo=class e{static findInstallationCollision(e){let t=new Map;for(let n of e){let e=process.platform===`win32`?n.destination.toLowerCase():n.destination,r=t.get(e);if(r)return`${r} and ${n.name} use the same installation folder: ${n.destination}`;t.set(e,n.name)}}static replaceLocalInstallation(e,t,n){let r=(0,_.randomUUID)(),i=n+`.staged-`+r,a=n+`.backup-`+r;for(let e of[n,i,a])if(this.getInstallationPath(t,(0,f.relative)((0,f.resolve)(t),e))!==e)throw Error(`Invalid installation path`);let o=!1;try{(0,u.cpSync)(e,i,{force:!0,recursive:!0}),(0,u.existsSync)(n)&&((0,u.renameSync)(n,a),o=!0);try{(0,u.renameSync)(i,n)}catch(e){throw o&&(0,u.renameSync)(a,n),e}o&&(0,u.rmSync)(a,{recursive:!0,force:!0})}finally{(0,u.existsSync)(i)&&(0,u.rmSync)(i,{recursive:!0,force:!0})}}static resolveExistingPath(e){let t=(0,f.resolve)(e),n=[];for(;!(0,u.existsSync)(t);){let e=(0,f.dirname)(t);if(e===t)return t;n.unshift(t.slice(e.length+ +!e.endsWith(f.sep))),t=e}return(0,f.resolve)((0,u.realpathSync)(t),...n)}static getInstallationPath(e,t){if(!t||/^[\\/]/.test(t)||f.win32.isAbsolute(t)||/^[A-Za-z]:/.test(t))return null;let n=(0,f.resolve)(e,t.replace(/[\\/]/g,f.sep)),r=(0,f.relative)((0,f.resolve)(e),n);if(!r||r===`..`||r.startsWith(`..`+f.sep))return null;let i=(0,f.relative)(this.resolveExistingPath(e),this.resolveExistingPath(n));return!i||i===`..`||i.startsWith(`..`+f.sep)||(0,f.isAbsolute)(i)?null:n}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=>L(e).replace(/\//g,f.sep))}async init(){$.isIDE?this.loadTemplates():await this.loadTemplates(),F.getInstance().onSettingsChange(()=>{this.loadTemplates()})}async loadTemplates(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e),this.templatePath=F.getInstance().settings.templatePath;let t=(0,f.normalize)(e+f.sep+`templates`);this.prepareFolders(this.templatePath,t),this.globalPath=F.getInstance().settings.globalPath;let n=(0,f.normalize)(e+f.sep+`global`);this.prepareFolders(this.globalPath,n),this.projectPath=F.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){let t=/^[A-Za-z]:[\\/]|^\\\\/.test(e),n=t?f.win32:e.startsWith(`/`)?f.posix:{resolve:f.resolve,relative:f.relative,isAbsolute:f.isAbsolute,sep:f.sep},r=n.resolve(e),i=``,a=-1;for(let e of this.workspaces){if(/^[A-Za-z]:[\\/]|^\\\\/.test(e)!==t)continue;let o=n.resolve(e),s=n.relative(o,r);s!==`..`&&!s.startsWith(`..`+n.sep)&&!n.isAbsolute(s)&&o.length>a&&(i=e,a=o.length)}return i||($.showErrorMessage(`Can't load the workspace`),``)}async readTemplates(e,t={},n=0){t=ao(t);let r=[],i=e=>{let a=(0,f.join)(e,E.Template);if((0,u.existsSync)(a)){try{r.push(new Promise(async e=>{let r=await ro.create(a);if(r){let i=xs(r.name,t);if(i!=null&&i.folderPath!=r.folderPath){$.showErrorMessage(`You have 2 templates with the same names : `+i?.folderPath+` and `+r.folderPath),e();return}bs(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(t){if(this.projectPath.length==0){$.showErrorMessage(`No project path registered`);return}let n=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import projects`});if(n){if(n.label==`Local`){let n=$.extensionPath+f.sep+`templates`+f.sep+`projects`,r=(0,u.readdirSync)(n),i=new Map,a={};for(let e of r){let r=n+f.sep+e;if((0,u.statSync)(r).isDirectory()){let n=r+f.sep+E.Template;if((0,u.existsSync)(n))try{let o=await ro.create(n);if(o){a[r]=o;let n={label:o.name,detail:[o.description,e].filter(Boolean).join(` - `),picked:t,id:r};i.set(n,r)}}catch{}}}let o=await $.SelectMultiple(Array.from(i.keys()),{title:`Select projects to import`});if(o){let t=!1,n=[];for(let t of o){let r=this.getSelectItem(i,t);if(r){let t=a[r].installationFolder??r.split(f.sep).pop(),i=e.getInstallationPath(this.projectPath[0],t);if(!i){$.showErrorMessage(`Invalid installation folder`);continue}n.push({path:r,name:a[r].name,destination:i})}}let r=e.findInstallationCollision(n);if(r){$.showErrorMessage(`Projects not installed: `+r);return}for(let r of n)e.replaceLocalInstallation(r.path,this.projectPath[0],r.destination),t=!0;t&&$.showInformationMessage(`Projects installed`)}}else if(n.label==`Git`){let e=await this.getGitURL();e&&await Yo(`git clone `+e,{cwd:this.projectPath[0]})}else n.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadProjects()}}async selectTemplateToImport(){if(this.templatePath.length==0){$.showErrorMessage(`No template path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import templates`});if(t)if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`templates`,n=(0,u.readdirSync)(t),r=new Map,i={};if(($.templateManager?.workspaces??[]).length==0)return;for(let e of n){let n=t+f.sep+e;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+E.Template;if((0,u.existsSync)(t))try{let a=await ro.create(t);if(a){i[n]=a;let t={label:a.name,detail:[a.description,e].filter(Boolean).join(` - `),picked:!1,id:n};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select templates to import`});if(a){let t=[],n=[],o=[];for(let t of a){let a=this.getSelectItem(r,t);if(a){let t=i[a].name,r=i[a].installationFolder??a.split(f.sep).pop(),s=e.getInstallationPath(this.templatePath[0],r);if(!s){n.push(`Template ${t} failed: invalid installation folder`);continue}o.push({path:a,name:t,destination:s})}}let s=e.findInstallationCollision(o);if(s){$.showErrorMessage(`Templates not installed: `+s);return}for(let r of o)try{e.replaceLocalInstallation(r.path,this.templatePath[0],r.destination),t.push(r.name)}catch(e){n.push(`Template ${r.name} failed: ${String(e)}`)}if(t.length>0){await this.reloadTemplates();let e=`Templates installed`;n.length>0&&(e+=`: `+t.join(`, `)),$.showInformationMessage(e)}for(let e of n)$.showErrorMessage(e)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await Yo(`git clone `+e,{cwd:this.templatePath[0]}),await this.reloadTemplates()}else t.label==`Store`&&await this.downloadTemplateFromStore()}async selectGlobalToImport(t){if(this.globalPath.length==0){$.showErrorMessage(`No global template path registered`);return}let n=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import global templates`});if(n){if(n.label==`Local`){let n=$.extensionPath+f.sep+`templates`+f.sep+`global`,r=(0,u.readdirSync)(n),i=new Map,a={};for(let e of r){let r=n+f.sep+e;if((0,u.statSync)(r).isDirectory()){let n=r+f.sep+E.Template;if((0,u.existsSync)(n))try{let o=await ro.create(n);if(o){a[r]=o;let n={label:o.name,detail:[o.description,e].filter(Boolean).join(` - `),picked:t,id:r};i.set(n,r)}}catch{}}}let o=await $.SelectMultiple(Array.from(i.keys()),{title:`Select global templates to import`});if(o){let t=!1;for(let n of o){let r=this.getSelectItem(i,n);if(r){let n=a[r].installationFolder??r.split(f.sep).pop(),i=e.getInstallationPath(this.globalPath[0],n);if(!i){$.showErrorMessage(`Invalid installation folder`);continue}(0,u.existsSync)(i)&&(0,u.rmSync)(i,{recursive:!0,force:!0}),(0,u.cpSync)(r,i,{force:!0,recursive:!0}),t=!0}}t&&$.showInformationMessage(`Global templates installed`)}}else if(n.label==`Git`){let e=await this.getGitURL();e&&await Yo(`git clone `+e,{cwd:this.globalPath[0]})}else n.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 ro?(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`});i&&this.removeSelectedInstallations(i,n,t,()=>this.getGeneralProjects(),this.projectPath)>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 ro?(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`});i&&this.removeSelectedInstallations(i,n,t,()=>this.getGeneralTemplates(),this.templatePath)>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 ro?(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`});i&&this.removeSelectedInstallations(i,n,t,()=>this.getGeneralGlobal(),this.globalPath)>0&&(await this.reloadGlobal(),$.showInformationMessage(`Global templates deleted`))}removeSelectedInstallations(e,t,n,r,i){let a=0,o=new Set;for(let s of e){let e=t.findIndex(e=>e.label===s.label&&e.detail===s.detail);if(e<0)continue;let c=n[e];if(o.has(c)||xs(c.name,r())!==c)continue;let l=(0,f.resolve)((0,f.dirname)(c.config));!i.some(e=>{let t=(0,f.relative)((0,f.resolve)(e),l);return t!==``&&t!==`..`&&!t.startsWith(`..`+f.sep)&&!(0,f.isAbsolute)(t)})||!(0,u.existsSync)(c.config)||(o.add(c),(0,u.rmSync)(l,{recursive:!0,force:!0}),a++)}return a}getSelectItem(e,t){if(e.has(t))return e.get(t);for(let n of e.keys())if(t.id?n.id===t.id:n.label===t.label&&n.detail===t.detail)return e.get(n);return null}async query(e,t,n){let r=this.findWorkspace(e),i=async t=>{let n={};for(let[a,o]of Object.entries(t))if(o instanceof ro)await o.isAllowed(e,r)&&(n[a]=o);else{let e=await i(o);Object.keys(e).length>0&&(n[a]=e)}return n},a=await i(t);if(Object.keys(a).length===0&&(!n||n.length===0))throw new io(`No templates available for this location`);return this.queryAllowed(a,n)}async queryAllowed(e,t){let n=!0;t||=(n=!1,[]);let r=new Map,i=new Map;for(let n in e){let a=e[n],o;a instanceof ro?(o={label:n,detail:a.description??``},i.set(o,a)):(o={label:n},r.set(o,a)),t.push(o)}if(t.sort((e,t)=>e.label.localeCompare(t.label)),t.length===0)return null;let a=await $.Select(t,{title:`What do you want to create?`});if(a){let e=this.getSelectItem(i,a);if(e)return e;let t=this.getSelectItem(r,a);if(t)return this.queryAllowed(t);if(n)return a}return null}async downloadTemplateFromStore(t){let n;try{let r=`^${so.url.replace(/\//g,`\\/`)}\\/template\\/download\\/(?<name>[^/]+)\\/(?<version>\\d+\\.\\d+\\.\\d+)$`;if(!t){let e=await $.Input({title:`Store url`,validations:[{message:`The store url must be `+so.url+`/template/download/{name}/{version}$`,regex:r}]});if(!e)return;t=e}let i=t.match(new RegExp(r));if(!i){$.showErrorMessage(`The uri provided is wrong`);return}let a=i[1];i[2],n=(0,f.join)($.savePath,`temp`,`packageTemp`),(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.mkdirSync)(n,{recursive:!0});let o=(0,f.join)(n,`temp.zip`);if(!await this.downloadFile(o,t)){$.showErrorMessage(`Error downloading package`);return}if(!await this.extractZip(o,n)){$.showErrorMessage(`Error extracting package to analyze`);return}if((0,u.existsSync)((0,f.join)(n,E.Template))){let t=await ro.create((0,f.join)(n,E.Template));if(!t){$.showErrorMessage(`The template contains error`);return}let r=t.isGlobal?this.globalPath[0]:t.isProject?this.projectPath[0]:this.templatePath[0],i=t.installationFolder??a,s=e.getInstallationPath(r,i);if(!s){$.showErrorMessage(`Invalid installation folder`);return}if(!await this.extractZip(o,s)){$.showErrorMessage(`Error extracting package`);return}t.isGlobal?await this.reloadGlobal():t.isProject?await this.reloadProjects():await this.reloadTemplates(),$.showInformationMessage(`Template `+a+` installed`)}else $.showErrorMessage(E.Template+` not found`)}catch(e){$.showErrorMessage(`Error unknown`),console.error(e)}finally{n&&(0,u.rmSync)(n,{recursive:!0,force:!0})}}downloadFile(e,t){return new Promise(n=>{try{(t.startsWith(`https`)?oe.get:x.get)(t,t=>{if(!t.statusCode||t.statusCode<200||t.statusCode>=300){t.resume(),n(!1);return}(0,C.pipeline)(t,(0,u.createWriteStream)(e),t=>{t&&(0,u.existsSync)(e)&&ks(e),n(!t)})}).on(`error`,()=>n(!1))}catch{n(!1)}})}async extractZip(e,t){try{return await(await se.Open.file(e)).extract({path:t}),!0}catch(e){console.error(`Extract error `,e)}return!1}async readGlobal(){let e=this.getGeneralGlobal(),t=this.getGeneralGlobalLength(),n=$.getWorkspaceUri();if(n){let r=L(n)+`/.aventus/global`;return await this.readTemplates([r],e,t)}return{templates:e,nb:t}}},so=class e{static url=`https://store.aventusjs.com`;static _settings;static sessionRevision=0;static get settings(){return this._settings||=F.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};F.getInstance().setHiddenSettings({store:t}),this._settings=t}static async connect(e,t){let n=++this.sessionRevision,r=await(0,Ii.machineId)(),i=(0,le.hostname)(),a=await this.post(`/login`,{username:e,password:t,machineId:r,machineName:i},{withoutBearer:!0});return n===this.sessionRevision&&a?(this.setSettings({token:a,username:e}),!0):!1}static async disconnect(){let e=++this.sessionRevision;await this.post(`/logout`),e===this.sessionRevision&&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)(lo.getInstance().getPath(),`@locals`,e.buildConfig.fullname+E.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+E.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 co([{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 co([{code:-1,message:`Readme not found`}])}let r=new Blob([(0,u.readFileSync)(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){if(!oo.getInstallationPath(e.folderPath,e.installationFolder??e.name))return new co([{code:422,message:`Invalid installation folder`}]);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 ks(a),s}static async post(e,t={},n){let r=await this.postWithErrors(e,t,n);if(r instanceof co){for(let e of r.errors)$.error(e.message);return null}return r}static async postWithErrors(t,n={},r){let i=null,a=this.sessionRevision,o=r?.withoutBearer===!0,s=o?void 0:this.token,c=()=>{let e=a===this.sessionRevision,t=o||s===this.token;return e&&t};try{let r={};if(n instanceof FormData||(r[`Content-Type`]=`application/json`),!o){let e=await(0,Ii.machineId)();r.Authorization=`Bearer `+(s+`|`+e)}if(i=await fetch(e.url+`/api/remote`+t,{method:`POST`,body:n instanceof FormData?n:JSON.stringify(n),headers:r}),i.status==401)return c()&&this.setSettings({token:``,username:void 0}),new co([{code:401,message:`No token provided`}]);if(i.status==403)return t!=`/logout`&&c()&&await this.disconnect(),new co([{code:403,message:`You must connect to your account first`}]);if(i.status<200||i.status>=300)return new co([{code:i.status,message:`Store request failed with HTTP ${i.status}`}]);let a=await i.text(),l;try{l=JSON.parse(a)}catch(e){throw $.error(a),e}return!l||!Array.isArray(l.errors)?new co([{code:-500,message:`Wrong response format from the api`}]):l.errors.length>0?new co(l.errors):Object.hasOwn(l,`result`)?l.result:new co([{code:-500,message:`Wrong response format from the api`}])}catch(e){return new co([{code:-500,message:e+``}])}}static zip(e,t){return new Promise(async(n,r)=>{let i=(0,u.createWriteStream)(t),a=(0,ue.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.split(/[\\/]/).includes(`.git`)?!1:e),await a.finalize()})}},co=class{errors;constructor(e){this.errors=e}},lo=class e{path;static instance;static getInstance(){return this.instance||=new e,this.instance}getPath(){return this.path}constructor(){this.path=(0,f.join)($.savePath,`packages`),(0,u.existsSync)(this.path)||(0,u.mkdirSync)(this.path,{recursive:!0})}predefinedPaths={"Aventus@Main":Tt(),"Aventus@UI":Et(),"Aventus@Sharp":Ot(),"Aventus@Php":kt(),"Aventus@I18n":Dt()};predefinedNpm={"Aventus@Main":`@aventusjs/main`,"Aventus@UI":`@aventusjs/ui`,"Aventus@I18n":`@aventusjs/i18n`,"Aventus@Sharp":`@aventussharp/main`,"Aventus@Php":`@aventusphp/main`};loadedPackages={};get packages(){let e=[];for(let t in this.loadedPackages)e.push(this.loadedPackages[t]);return e}async loadDependenciesFromBuild(e,t){let n={files:[],dependencyNeedUris:[],dependencyFullUris:[],dependencyUris:[]},r={},i={},a=new Set;for(let n in e.dependencies){let o=e.dependencies[n],s=await this.loadDependency(n,o,e,t,r);s&&(a.add(s.name),i[s.name]=o.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),r[`Aventus@Main`]&&a.add(`Aventus@Main`),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),t.buildConfig.i18n!==void 0&&r[`Aventus@I18n`]&&a.add(`Aventus@I18n`);let o=new Set,s=e=>{if(!(o.has(e)||!r[e])){o.add(e);for(let t of r[e].dependencies)s(t.name)}};for(let e of a)s(e);for(let e of Object.keys(r))o.has(e)||delete r[e];let c=this.findCycle(r);if(c)return n.cycle=c,n;let l=[];for(let e in r){let t=r[e];this.orderLoop(e,t,r,l)}for(let e of l){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}findCycle(e){let t=new Set,n=[],r=i=>{let a=n.indexOf(i);if(a>=0)return[...n.slice(a),i];if(t.has(i))return null;t.add(i),n.push(i);for(let t of e[i].dependencies)if(e[t.name]){let e=r(t.name);if(e)return e}return n.pop(),null};for(let t of Object.keys(e)){let e=r(t);if(e)return e}return null}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=I(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=I(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]:a.npmUri=``}let c=/\/\* description:(.*) \*\//gm.exec(a.file.contentUser);c?a.description=c[1]:a.description=``;let l=async(e,a)=>{i[e.name]={file:e,uri:a,include:t.include??`need`,version:s,dependencies:[]};for(let a in e.dependencies){let o=e.dependencies[a];typeof o==`string`&&(o={version:o}),t.include==`none`&&(o.include=`none`);let s=await this.loadDependency(a,o,n,r,i);if(s){let n=i[e.name].dependencies.find(e=>e.name==s.name),r=`need`;t.include==`none`&&(r=`none`),o.subDependenciesInclude&&o.subDependenciesInclude[s.name]&&(r=o.subDependenciesInclude[s.name]),n?(n.include==`none`&&r!=`none`||n.include==`need`&&r==`full`)&&(n.include=r):i[e.name].dependencies.push({name:s.name,include:r})}}e.name!=`Aventus@Main`&&(i[e.name].dependencies.find(e=>e.name==`Aventus@Main`)||i[e.name].dependencies.push({name:`Aventus@Main`,include:`need`}))};if(!i[a.name])await l(a,o);else{let e=i[a.name].version;this.compareVersion(e,s,a.name)==s&&await l(a,o)}await Ya.register(a)}return a}async loadByUri(e,t){let n=await z.getInstance().registerFilePackage(t);return this.loadPackage(n,e)}async loadLocal(e,t){let n=I((0,f.join)(this.path,`@locals`,e));n.endsWith(E.Package)||(n+=E.Package);let r=await z.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,so.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=I(c),d=await z.getInstance().registerFilePackage(l);return{uri:l,file:this.loadPackage(d,n)}}extractZip(e,t){return new Promise(n=>{let r=!1,i=e=>{r||(r=!0,n(e))},a=(0,u.createReadStream)(e),o=(0,se.Extract)({path:t});a.on(`error`,t=>{console.error(`Can't read ZIP "${e}":`,t),i(!1)}),o.on(`close`,()=>i(!0)),o.on(`error`,t=>{console.error(`Can't extract ZIP "${e}":`,t),(t+``).includes(`Error: invalid signature: 0x4f44213c`)&&console.log((0,u.readFileSync)(e,`utf8`)),i(!1)}),a.pipe(o)})}findPackage(e){let t=null,n=(0,u.readdirSync)(e);for(let r of n)if(r.endsWith(E.Package)){t=(0,f.join)(e,r);break}return t}loadPackage(e,t){if(!e)return;let n=Tn.getQuickInfo(e);if(!n)return;let r=new Tn(e,t);return this.loadedPackages[n.name]=r,e.onDelete(async()=>{this.loadedPackages[n.name]===r&&delete this.loadedPackages[n.name]}),r}downloadFile(e,t){return new Promise(n=>{let r=`${e}.${(0,_.randomUUID)()}.tmp`,i=!1,a=()=>{try{(0,u.existsSync)(r)&&ks(r)}catch{}},o=e=>{i||(i=!0,e||a(),n(e))};(t.startsWith(`https:`)?oe.get:x.get)(t,n=>{let i=n.statusCode??0;if(i>=300&&i<400&&n.headers.location){n.resume(),this.downloadFile(e,new URL(n.headers.location,t).href).then(o).catch(()=>o(!1));return}if(i<200||i>=300){console.error(`Download failed: HTTP ${i} for ${t}`),n.resume(),o(!1);return}let a=(0,u.createWriteStream)(r,{flags:`wx`}),s=!1;a.on(`error`,t=>{console.error(`File write error for ${e}:`,t),s=!0,n.destroy()}),n.on(`error`,e=>{console.error(`HTTP response error for ${t}:`,e),s=!0,a.destroy()}),n.on(`aborted`,()=>{s=!0,a.destroy()}),a.on(`close`,()=>{if(s||!a.writableFinished||!n.complete){o(!1);return}try{(0,u.renameSync)(r,e),o(!0)}catch(t){console.error(`File replace error for ${e}:`,t),o(!1)}}),n.pipe(a)}).on(`error`,e=>{console.error(`HTTP request error for ${t}:`,e),o(!1)})})}readFirstLine(e){return new Promise(function(t,n){var r=(0,u.createReadStream)(e,{encoding:`utf8`}),i=``;r.on(`data`,function(e){i+=e,i.includes(`
|
|
650
|
+
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 Yo(process.execPath,[`--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}Ds(a);let l=[...e.preparing[n]];delete e.preparing[n];for(let e of l)e(o);t(o)})}},no=class extends Error{};function ro(e){let t={};for(let[n,r]of Object.entries(e))t[n]=r instanceof to||typeof r!=`object`||!r?r:ro(r);return t}var io=class e{static findInstallationCollision(e){let t=new Map;for(let n of e){let e=process.platform===`win32`?n.destination.toLowerCase():n.destination,r=t.get(e);if(r)return`${r} and ${n.name} use the same installation folder: ${n.destination}`;t.set(e,n.name)}}static replaceLocalInstallation(e,t,n){let r=(0,_.randomUUID)(),i=n+`.staged-`+r,a=n+`.backup-`+r;for(let e of[n,i,a])if(this.getInstallationPath(t,(0,f.relative)((0,f.resolve)(t),e))!==e)throw Error(`Invalid installation path`);let o=!1;try{(0,u.cpSync)(e,i,{force:!0,recursive:!0}),(0,u.existsSync)(n)&&((0,u.renameSync)(n,a),o=!0);try{(0,u.renameSync)(i,n)}catch(e){throw o&&(0,u.renameSync)(a,n),e}o&&(0,u.rmSync)(a,{recursive:!0,force:!0})}finally{(0,u.existsSync)(i)&&(0,u.rmSync)(i,{recursive:!0,force:!0})}}static resolveExistingPath(e){let t=(0,f.resolve)(e),n=[];for(;!(0,u.existsSync)(t);){let e=(0,f.dirname)(t);if(e===t)return t;n.unshift(t.slice(e.length+ +!e.endsWith(f.sep))),t=e}return(0,f.resolve)((0,u.realpathSync)(t),...n)}static getInstallationPath(e,t){if(!t||/^[\\/]/.test(t)||f.win32.isAbsolute(t)||/^[A-Za-z]:/.test(t))return null;let n=(0,f.resolve)(e,t.replace(/[\\/]/g,f.sep)),r=(0,f.relative)((0,f.resolve)(e),n);if(!r||r===`..`||r.startsWith(`..`+f.sep))return null;let i=(0,f.relative)(this.resolveExistingPath(e),this.resolveExistingPath(n));return!i||i===`..`||i.startsWith(`..`+f.sep)||(0,f.isAbsolute)(i)?null:n}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=>L(e).replace(/\//g,f.sep))}async init(){$.isIDE?this.loadTemplates():await this.loadTemplates(),F.getInstance().onSettingsChange(()=>{this.loadTemplates()})}async loadTemplates(){let e=$.savePath;(0,u.existsSync)(e)||(0,u.mkdirSync)(e),this.templatePath=F.getInstance().settings.templatePath;let t=(0,f.normalize)(e+f.sep+`templates`);this.prepareFolders(this.templatePath,t),this.globalPath=F.getInstance().settings.globalPath;let n=(0,f.normalize)(e+f.sep+`global`);this.prepareFolders(this.globalPath,n),this.projectPath=F.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){let t=/^[A-Za-z]:[\\/]|^\\\\/.test(e),n=t?f.win32:e.startsWith(`/`)?f.posix:{resolve:f.resolve,relative:f.relative,isAbsolute:f.isAbsolute,sep:f.sep},r=n.resolve(e),i=``,a=-1;for(let e of this.workspaces){if(/^[A-Za-z]:[\\/]|^\\\\/.test(e)!==t)continue;let o=n.resolve(e),s=n.relative(o,r);s!==`..`&&!s.startsWith(`..`+n.sep)&&!n.isAbsolute(s)&&o.length>a&&(i=e,a=o.length)}return i||($.showErrorMessage(`Can't load the workspace`),``)}async readTemplates(e,t={},n=0){t=ro(t);let r=[],i=e=>{let a=(0,f.join)(e,E.Template);if((0,u.existsSync)(a)){try{r.push(new Promise(async e=>{let r=await to.create(a);if(r){let i=ys(r.name,t);if(i!=null&&i.folderPath!=r.folderPath){$.showErrorMessage(`You have 2 templates with the same names : `+i?.folderPath+` and `+r.folderPath),e();return}vs(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(t){if(this.projectPath.length==0){$.showErrorMessage(`No project path registered`);return}let n=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import projects`});if(n){if(n.label==`Local`){let n=$.extensionPath+f.sep+`templates`+f.sep+`projects`,r=(0,u.readdirSync)(n),i=new Map,a={};for(let e of r){let r=n+f.sep+e;if((0,u.statSync)(r).isDirectory()){let n=r+f.sep+E.Template;if((0,u.existsSync)(n))try{let o=await to.create(n);if(o){a[r]=o;let n={label:o.name,detail:[o.description,e].filter(Boolean).join(` - `),picked:t,id:r};i.set(n,r)}}catch{}}}let o=await $.SelectMultiple(Array.from(i.keys()),{title:`Select projects to import`});if(o){let t=!1,n=[];for(let t of o){let r=this.getSelectItem(i,t);if(r){let t=a[r].installationFolder??r.split(f.sep).pop(),i=e.getInstallationPath(this.projectPath[0],t);if(!i){$.showErrorMessage(`Invalid installation folder`);continue}n.push({path:r,name:a[r].name,destination:i})}}let r=e.findInstallationCollision(n);if(r){$.showErrorMessage(`Projects not installed: `+r);return}for(let r of n)e.replaceLocalInstallation(r.path,this.projectPath[0],r.destination),t=!0;t&&$.showInformationMessage(`Projects installed`)}}else if(n.label==`Git`){let e=await this.getGitURL();e&&await qo(`git clone `+e,{cwd:this.projectPath[0]})}else n.label==`Store`&&await this.downloadTemplateFromStore();await this.reloadProjects()}}async selectTemplateToImport(){if(this.templatePath.length==0){$.showErrorMessage(`No template path registered`);return}let t=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import templates`});if(t)if(t.label==`Local`){let t=$.extensionPath+f.sep+`templates`+f.sep+`templates`,n=(0,u.readdirSync)(t),r=new Map,i={};if(($.templateManager?.workspaces??[]).length==0)return;for(let e of n){let n=t+f.sep+e;if((0,u.statSync)(n).isDirectory()){let t=n+f.sep+E.Template;if((0,u.existsSync)(t))try{let a=await to.create(t);if(a){i[n]=a;let t={label:a.name,detail:[a.description,e].filter(Boolean).join(` - `),picked:!1,id:n};r.set(t,n)}}catch{}}}let a=await $.SelectMultiple(Array.from(r.keys()),{title:`Select templates to import`});if(a){let t=[],n=[],o=[];for(let t of a){let a=this.getSelectItem(r,t);if(a){let t=i[a].name,r=i[a].installationFolder??a.split(f.sep).pop(),s=e.getInstallationPath(this.templatePath[0],r);if(!s){n.push(`Template ${t} failed: invalid installation folder`);continue}o.push({path:a,name:t,destination:s})}}let s=e.findInstallationCollision(o);if(s){$.showErrorMessage(`Templates not installed: `+s);return}for(let r of o)try{e.replaceLocalInstallation(r.path,this.templatePath[0],r.destination),t.push(r.name)}catch(e){n.push(`Template ${r.name} failed: ${String(e)}`)}if(t.length>0){await this.reloadTemplates();let e=`Templates installed`;n.length>0&&(e+=`: `+t.join(`, `)),$.showInformationMessage(e)}for(let e of n)$.showErrorMessage(e)}}else if(t.label==`Git`){let e=await this.getGitURL();e&&await qo(`git clone `+e,{cwd:this.templatePath[0]}),await this.reloadTemplates()}else t.label==`Store`&&await this.downloadTemplateFromStore()}async selectGlobalToImport(t){if(this.globalPath.length==0){$.showErrorMessage(`No global template path registered`);return}let n=await $.Select([{label:`Local`},{label:`Git`}],{title:`Select a source from where to import global templates`});if(n){if(n.label==`Local`){let n=$.extensionPath+f.sep+`templates`+f.sep+`global`,r=(0,u.readdirSync)(n),i=new Map,a={};for(let e of r){let r=n+f.sep+e;if((0,u.statSync)(r).isDirectory()){let n=r+f.sep+E.Template;if((0,u.existsSync)(n))try{let o=await to.create(n);if(o){a[r]=o;let n={label:o.name,detail:[o.description,e].filter(Boolean).join(` - `),picked:t,id:r};i.set(n,r)}}catch{}}}let o=await $.SelectMultiple(Array.from(i.keys()),{title:`Select global templates to import`});if(o){let t=!1;for(let n of o){let r=this.getSelectItem(i,n);if(r){let n=a[r].installationFolder??r.split(f.sep).pop(),i=e.getInstallationPath(this.globalPath[0],n);if(!i){$.showErrorMessage(`Invalid installation folder`);continue}(0,u.existsSync)(i)&&(0,u.rmSync)(i,{recursive:!0,force:!0}),(0,u.cpSync)(r,i,{force:!0,recursive:!0}),t=!0}}t&&$.showInformationMessage(`Global templates installed`)}}else if(n.label==`Git`){let e=await this.getGitURL();e&&await qo(`git clone `+e,{cwd:this.globalPath[0]})}else n.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 to?(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`});i&&this.removeSelectedInstallations(i,n,t,()=>this.getGeneralProjects(),this.projectPath)>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 to?(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`});i&&this.removeSelectedInstallations(i,n,t,()=>this.getGeneralTemplates(),this.templatePath)>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 to?(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`});i&&this.removeSelectedInstallations(i,n,t,()=>this.getGeneralGlobal(),this.globalPath)>0&&(await this.reloadGlobal(),$.showInformationMessage(`Global templates deleted`))}removeSelectedInstallations(e,t,n,r,i){let a=0,o=new Set;for(let s of e){let e=t.findIndex(e=>e.label===s.label&&e.detail===s.detail);if(e<0)continue;let c=n[e];if(o.has(c)||ys(c.name,r())!==c)continue;let l=(0,f.resolve)((0,f.dirname)(c.config));!i.some(e=>{let t=(0,f.relative)((0,f.resolve)(e),l);return t!==``&&t!==`..`&&!t.startsWith(`..`+f.sep)&&!(0,f.isAbsolute)(t)})||!(0,u.existsSync)(c.config)||(o.add(c),(0,u.rmSync)(l,{recursive:!0,force:!0}),a++)}return a}getSelectItem(e,t){if(e.has(t))return e.get(t);for(let n of e.keys())if(t.id?n.id===t.id:n.label===t.label&&n.detail===t.detail)return e.get(n);return null}async query(e,t,n){let r=this.findWorkspace(e),i=async t=>{let n={};for(let[a,o]of Object.entries(t))if(o instanceof to)await o.isAllowed(e,r)&&(n[a]=o);else{let e=await i(o);Object.keys(e).length>0&&(n[a]=e)}return n},a=await i(t);if(Object.keys(a).length===0&&(!n||n.length===0))throw new no(`No templates available for this location`);return this.queryAllowed(a,n)}async queryAllowed(e,t){let n=!0;t||=(n=!1,[]);let r=new Map,i=new Map;for(let n in e){let a=e[n],o;a instanceof to?(o={label:n,detail:a.description??``},i.set(o,a)):(o={label:n},r.set(o,a)),t.push(o)}if(t.sort((e,t)=>e.label.localeCompare(t.label)),t.length===0)return null;let a=await $.Select(t,{title:`What do you want to create?`});if(a){let e=this.getSelectItem(i,a);if(e)return e;let t=this.getSelectItem(r,a);if(t)return this.queryAllowed(t);if(n)return a}return null}async downloadTemplateFromStore(t){let n;try{let r=`^${ao.url.replace(/\//g,`\\/`)}\\/template\\/download\\/(?<name>[^/]+)\\/(?<version>\\d+\\.\\d+\\.\\d+)$`;if(!t){let e=await $.Input({title:`Store url`,validations:[{message:`The store url must be `+ao.url+`/template/download/{name}/{version}$`,regex:r}]});if(!e)return;t=e}let i=t.match(new RegExp(r));if(!i){$.showErrorMessage(`The uri provided is wrong`);return}let a=i[1];i[2],n=(0,f.join)($.savePath,`temp`,`packageTemp`),(0,u.rmSync)(n,{recursive:!0,force:!0}),(0,u.mkdirSync)(n,{recursive:!0});let o=(0,f.join)(n,`temp.zip`);if(!await this.downloadFile(o,t)){$.showErrorMessage(`Error downloading package`);return}if(!await this.extractZip(o,n)){$.showErrorMessage(`Error extracting package to analyze`);return}if((0,u.existsSync)((0,f.join)(n,E.Template))){let t=await to.create((0,f.join)(n,E.Template));if(!t){$.showErrorMessage(`The template contains error`);return}let r=t.isGlobal?this.globalPath[0]:t.isProject?this.projectPath[0]:this.templatePath[0],i=t.installationFolder??a,s=e.getInstallationPath(r,i);if(!s){$.showErrorMessage(`Invalid installation folder`);return}if(!await this.extractZip(o,s)){$.showErrorMessage(`Error extracting package`);return}t.isGlobal?await this.reloadGlobal():t.isProject?await this.reloadProjects():await this.reloadTemplates(),$.showInformationMessage(`Template `+a+` installed`)}else $.showErrorMessage(E.Template+` not found`)}catch(e){$.showErrorMessage(`Error unknown`),console.error(e)}finally{n&&(0,u.rmSync)(n,{recursive:!0,force:!0})}}downloadFile(e,t){return new Promise(n=>{try{(t.startsWith(`https`)?oe.get:x.get)(t,t=>{if(!t.statusCode||t.statusCode<200||t.statusCode>=300){t.resume(),n(!1);return}(0,C.pipeline)(t,(0,u.createWriteStream)(e),t=>{t&&(0,u.existsSync)(e)&&Ds(e),n(!t)})}).on(`error`,()=>n(!1))}catch{n(!1)}})}async extractZip(e,t){try{return await(await se.Open.file(e)).extract({path:t}),!0}catch(e){console.error(`Extract error `,e)}return!1}async readGlobal(){let e=this.getGeneralGlobal(),t=this.getGeneralGlobalLength(),n=$.getWorkspaceUri();if(n){let r=L(n)+`/.aventus/global`;return await this.readTemplates([r],e,t)}return{templates:e,nb:t}}},ao=class e{static url=`https://store.aventusjs.com`;static _settings;static sessionRevision=0;static get settings(){return this._settings||=F.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};F.getInstance().setHiddenSettings({store:t}),this._settings=t}static async connect(e,t){let n=++this.sessionRevision,r=await(0,Ii.machineId)(),i=(0,le.hostname)(),a=await this.post(`/login`,{username:e,password:t,machineId:r,machineName:i},{withoutBearer:!0});return n===this.sessionRevision&&a?(this.setSettings({token:a,username:e}),!0):!1}static async disconnect(){let e=++this.sessionRevision;await this.post(`/logout`),e===this.sessionRevision&&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)(so.getInstance().getPath(),`@locals`,e.buildConfig.fullname+E.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+E.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 oo([{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 oo([{code:-1,message:`Readme not found`}])}let r=new Blob([(0,u.readFileSync)(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){if(!io.getInstallationPath(e.folderPath,e.installationFolder??e.name))return new oo([{code:422,message:`Invalid installation folder`}]);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 Ds(a),s}static async post(e,t={},n){let r=await this.postWithErrors(e,t,n);if(r instanceof oo){for(let e of r.errors)$.error(e.message);return null}return r}static async postWithErrors(t,n={},r){let i=null,a=this.sessionRevision,o=r?.withoutBearer===!0,s=o?void 0:this.token,c=()=>{let e=a===this.sessionRevision,t=o||s===this.token;return e&&t};try{let r={};if(n instanceof FormData||(r[`Content-Type`]=`application/json`),!o){let e=await(0,Ii.machineId)();r.Authorization=`Bearer `+(s+`|`+e)}if(i=await fetch(e.url+`/api/remote`+t,{method:`POST`,body:n instanceof FormData?n:JSON.stringify(n),headers:r}),i.status==401)return c()&&this.setSettings({token:``,username:void 0}),new oo([{code:401,message:`No token provided`}]);if(i.status==403)return t!=`/logout`&&c()&&await this.disconnect(),new oo([{code:403,message:`You must connect to your account first`}]);if(i.status<200||i.status>=300)return new oo([{code:i.status,message:`Store request failed with HTTP ${i.status}`}]);let a=await i.text(),l;try{l=JSON.parse(a)}catch(e){throw $.error(a),e}return!l||!Array.isArray(l.errors)?new oo([{code:-500,message:`Wrong response format from the api`}]):l.errors.length>0?new oo(l.errors):Object.hasOwn(l,`result`)?l.result:new oo([{code:-500,message:`Wrong response format from the api`}])}catch(e){return new oo([{code:-500,message:e+``}])}}static zip(e,t){return new Promise(async(n,r)=>{let i=(0,u.createWriteStream)(t),a=(0,ue.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.split(/[\\/]/).includes(`.git`)?!1:e),await a.finalize()})}},oo=class{errors;constructor(e){this.errors=e}},so=class e{path;static instance;static getInstance(){return this.instance||=new e,this.instance}getPath(){return this.path}constructor(){this.path=(0,f.join)($.savePath,`packages`),(0,u.existsSync)(this.path)||(0,u.mkdirSync)(this.path,{recursive:!0})}predefinedPaths={"Aventus@Main":Tt(),"Aventus@UI":Et(),"Aventus@Sharp":Ot(),"Aventus@Php":kt(),"Aventus@I18n":Dt()};predefinedNpm={"Aventus@Main":`@aventusjs/main`,"Aventus@UI":`@aventusjs/ui`,"Aventus@I18n":`@aventusjs/i18n`,"Aventus@Sharp":`@aventussharp/main`,"Aventus@Php":`@aventusphp/main`};loadedPackages={};get packages(){let e=[];for(let t in this.loadedPackages)e.push(this.loadedPackages[t]);return e}async loadDependenciesFromBuild(e,t){let n={files:[],dependencyNeedUris:[],dependencyFullUris:[],dependencyUris:[]},r={},i={},a=new Set;for(let n in e.dependencies){let o=e.dependencies[n],s=await this.loadDependency(n,o,e,t,r);s&&(a.add(s.name),i[s.name]=o.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),r[`Aventus@Main`]&&a.add(`Aventus@Main`),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),t.buildConfig.i18n!==void 0&&r[`Aventus@I18n`]&&a.add(`Aventus@I18n`);let o=new Set,s=e=>{if(!(o.has(e)||!r[e])){o.add(e);for(let t of r[e].dependencies)s(t.name)}};for(let e of a)s(e);for(let e of Object.keys(r))o.has(e)||delete r[e];let c=this.findCycle(r);if(c)return n.cycle=c,n;let l=[];for(let e in r){let t=r[e];this.orderLoop(e,t,r,l)}for(let e of l){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}findCycle(e){let t=new Set,n=[],r=i=>{let a=n.indexOf(i);if(a>=0)return[...n.slice(a),i];if(t.has(i))return null;t.add(i),n.push(i);for(let t of e[i].dependencies)if(e[t.name]){let e=r(t.name);if(e)return e}return n.pop(),null};for(let t of Object.keys(e)){let e=r(t);if(e)return e}return null}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=I(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=I(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]:a.npmUri=``}let c=/\/\* description:(.*) \*\//gm.exec(a.file.contentUser);c?a.description=c[1]:a.description=``;let l=async(e,a)=>{i[e.name]={file:e,uri:a,include:t.include??`need`,version:s,dependencies:[]};for(let a in e.dependencies){let o=e.dependencies[a];typeof o==`string`&&(o={version:o}),t.include==`none`&&(o.include=`none`);let s=await this.loadDependency(a,o,n,r,i);if(s){let n=i[e.name].dependencies.find(e=>e.name==s.name),r=`need`;t.include==`none`&&(r=`none`),o.subDependenciesInclude&&o.subDependenciesInclude[s.name]&&(r=o.subDependenciesInclude[s.name]),n?(n.include==`none`&&r!=`none`||n.include==`need`&&r==`full`)&&(n.include=r):i[e.name].dependencies.push({name:s.name,include:r})}}e.name!=`Aventus@Main`&&(i[e.name].dependencies.find(e=>e.name==`Aventus@Main`)||i[e.name].dependencies.push({name:`Aventus@Main`,include:`need`}))};if(!i[a.name])await l(a,o);else{let e=i[a.name].version;this.compareVersion(e,s,a.name)==s&&await l(a,o)}await qa.register(a)}return a}async loadByUri(e,t){let n=await z.getInstance().registerFilePackage(t);return this.loadPackage(n,e)}async loadLocal(e,t){let n=I((0,f.join)(this.path,`@locals`,e));n.endsWith(E.Package)||(n+=E.Package);let r=await z.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,ao.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=I(c),d=await z.getInstance().registerFilePackage(l);return{uri:l,file:this.loadPackage(d,n)}}extractZip(e,t){return new Promise(n=>{let r=!1,i=e=>{r||(r=!0,n(e))},a=(0,u.createReadStream)(e),o=(0,se.Extract)({path:t});a.on(`error`,t=>{console.error(`Can't read ZIP "${e}":`,t),i(!1)}),o.on(`close`,()=>i(!0)),o.on(`error`,t=>{console.error(`Can't extract ZIP "${e}":`,t),(t+``).includes(`Error: invalid signature: 0x4f44213c`)&&console.log((0,u.readFileSync)(e,`utf8`)),i(!1)}),a.pipe(o)})}findPackage(e){let t=null,n=(0,u.readdirSync)(e);for(let r of n)if(r.endsWith(E.Package)){t=(0,f.join)(e,r);break}return t}loadPackage(e,t){if(!e)return;let n=Tn.getQuickInfo(e);if(!n)return;let r=new Tn(e,t);return this.loadedPackages[n.name]=r,e.onDelete(async()=>{this.loadedPackages[n.name]===r&&delete this.loadedPackages[n.name]}),r}downloadFile(e,t){return new Promise(n=>{let r=`${e}.${(0,_.randomUUID)()}.tmp`,i=!1,a=()=>{try{(0,u.existsSync)(r)&&Ds(r)}catch{}},o=e=>{i||(i=!0,e||a(),n(e))};(t.startsWith(`https:`)?oe.get:x.get)(t,n=>{let i=n.statusCode??0;if(i>=300&&i<400&&n.headers.location){n.resume(),this.downloadFile(e,new URL(n.headers.location,t).href).then(o).catch(()=>o(!1));return}if(i<200||i>=300){console.error(`Download failed: HTTP ${i} for ${t}`),n.resume(),o(!1);return}let a=(0,u.createWriteStream)(r,{flags:`wx`}),s=!1;a.on(`error`,t=>{console.error(`File write error for ${e}:`,t),s=!0,n.destroy()}),n.on(`error`,e=>{console.error(`HTTP response error for ${t}:`,e),s=!0,a.destroy()}),n.on(`aborted`,()=>{s=!0,a.destroy()}),a.on(`close`,()=>{if(s||!a.writableFinished||!n.complete){o(!1);return}try{(0,u.renameSync)(r,e),o(!0)}catch(t){console.error(`File replace error for ${e}:`,t),o(!1)}}),n.pipe(a)}).on(`error`,e=>{console.error(`HTTP request error for ${t}:`,e),o(!1)})})}readFirstLine(e){return new Promise(function(t,n){var r=(0,u.createReadStream)(e,{encoding:`utf8`}),i=``;r.on(`data`,function(e){i+=e,i.includes(`
|
|
651
651
|
`)&&r.close()}).on(`close`,function(){let e=i.indexOf(`
|
|
652
|
-
`);t(e===-1?i:i.slice(0,e))}).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}},
|
|
652
|
+
`);t(e===-1?i:i.slice(0,e))}).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}},co=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,n){if(t.libName==`*`&&!t.alias)return[{range:n??m.Range.create(0,0,0,0),severity:m.DiagnosticSeverity.Error,source:T.TypeScript,message:`The lib ${t.uri} inside the file ${e} has no alias => impossible`}];this.storedInfo[e]||(this.storedInfo[e]=[]);let r=t.alias||t.libName,i=Object.values(this.storedInfo).flat(),a=[],o=new Set;for(let e of i){let i=e.alias||e.libName;e.uri===t.uri&&i==r&&e.libName!==t.libName&&!o.has(e.libName)&&(o.add(e.libName),a.push({range:n??m.Range.create(0,0,0,0),severity:m.DiagnosticSeverity.Error,source:T.TypeScript,message:`The npm alias ${r} for ${t.uri} is used by both ${e.libName} and ${t.libName}`}))}return this.storedInfo[e].push(t),this.rebuildInfo(),a}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:Es(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:[]};compiling;lastDependencies=``;getDependencies(){try{let e=JSON.parse((0,u.readFileSync)((0,f.join)((0,f.dirname)(this.build.nodeModulesDir),`package.json`),`utf8`)),t=(e={})=>Object.entries(e).sort(([e],[t])=>e.localeCompare(t));return JSON.stringify([t(e.dependencies),t(e.devDependencies)])}catch{return``}}async compile(){if(this.compiling)return await this.compiling,await this.compile();let e=this.compileCurrent();this.compiling=e;try{return await e}finally{this.compiling===e&&(this.compiling=void 0)}}async compileCurrent(){if(Object.keys(this.infos).length==0)return this.lastInfo=``,this.lastInfoToCompile=``,this.npmBuildTxt=``,this.lastDependencies=``,{result:``,errors:[]};let e=JSON.stringify(this.infos),t=this.getDependencies(),n=this.lastDependencies!==t;if(this.lastInfo!=e||n){this.lastInfo=e,this.lastDependencies=t;let r=this.writeFileToCompile();(this.lastInfoToCompile!=r.buildTxt||n)&&(Ni.part(`Compiling node modules`),this.lastInfoToCompile=r.buildTxt,this.npmDepBuildTxt=await this.esbuildBuild(this.lastInfoToCompile),this.npmDepBuildTxt.errors.length>0&&(this.lastInfo=``,this.lastInfoToCompile=``),Ni.part(`Compiling node modules done`)),this.npmBuildTxt=`var npmCompilation;
|
|
653
653
|
`,this.npmBuildTxt+=`(npmCompilation||(npmCompilation = {}));
|
|
654
654
|
`,this.npmBuildTxt+=`(function (npmCompilation) {
|
|
655
655
|
${this.npmDepBuildTxt.result+`
|
|
@@ -662,32 +662,32 @@ public `+r+`?:`+i+`;
|
|
|
662
662
|
`;for(let e in r.part)for(let n of r.part[e].externalAlias)t+=`npmCompilation['${r.md5}'][${JSON.stringify(n)}] = _.default['${r.all.internalAlias}'][${JSON.stringify(e)}];
|
|
663
663
|
`}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}'][${JSON.stringify(n)}] = _.default['${r.part[e].internalAlias}'];
|
|
664
664
|
`}e+=`import {${Object.values(a).join(`, `)}} from "${i}";
|
|
665
|
-
`}}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,pe.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,``);
|
|
665
|
+
`}}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,pe.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,``);ba.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}},lo=class{manifest;_package;modulesByUri=new Map;constructor(e){this.manifest=e,this._package={modules:[],schemaVersion:`1.0.0`,readme:``}}async write(e){await Ts((0,f.join)(e,`custom-elements.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(this.unregister(e.file.uri),!e.fileParsed||!(e instanceof N))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(`
|
|
666
666
|
`)),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=A.getInfoByFullName(n.extends[0],n);if(e&&e instanceof dn)if(a.superclass={name:e.name},e.fileUri.endsWith(E.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(`
|
|
667
667
|
`)),e.isOverride){let r=n.getFieldParentClass(e.name);if(r)if(t.inheritedFrom={name:r.name},r.fileUri.endsWith(E.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(`
|
|
668
668
|
`)),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(E.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)}let a;e.isSet&&`parameters`in e.prop&&(a=e.prop.parameters[0]?.type),i.type={text:this.getTypeTxt(a?new k(a):e.type)},c.push(i)},u=[...t.attributes,...t.props];u.sort((e,t)=>e.name.localeCompare(t.name));let d=e=>{let t=new Map;for(let n of e)(!t.get(n.name)||n.isGet)&&t.set(n.name,n);return t.values()};for(let e of d(u))l(e,!1);for(let e of d(t.propsStatic))l(e,!0);let f=(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(`
|
|
669
|
-
`)),e.isPrivate?i.privacy=`private`:e.isProtected?i.privacy=`protected`:i.privacy=`public`,e.node.type){let t=new k(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 k(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(E.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)}c.push(i)};for(let e of t.methods)f(e,!1);for(let e of t.methodsStatic)f(e,!0);c.length>0&&(a.members=c);let p=[];for(let e in t.slots){if(!t.slots[e].local)continue;let n={name:e};p.push(n)}p.length>0&&(a.slots=p),i.declarations.push(a);let m={kind:`custom-element-definition`,name:n.name,declaration:{name:n.name,module:this.getLocalUri(e.file.uri)}};i.exports.push(m),i.declarations?.length==0&&delete i.declarations,i.exports?.length==0&&delete i.exports,this.modulesByUri.set(e.file.uri,i),this._package.modules=Array.from(this.modulesByUri.values())}unregister(e){this.modulesByUri.delete(e),this._package.modules=Array.from(this.modulesByUri.values())}getSourceUri(e){return this.manifest.manifestConfig.srcBaseUrl+`/`+this.getLocalUri(e)}getLocalUri(e){let t=this.manifest.configFile.uri.replace(E.Config,``),n=L(e.replace(t,``)).replace(/\\/g,`/`);return n=n.replace(E.Base,`.js`),`__src/`+n}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},
|
|
669
|
+
`)),e.isPrivate?i.privacy=`private`:e.isProtected?i.privacy=`protected`:i.privacy=`public`,e.node.type){let t=new k(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 k(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(E.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)}c.push(i)};for(let e of t.methods)f(e,!1);for(let e of t.methodsStatic)f(e,!0);c.length>0&&(a.members=c);let p=[];for(let e in t.slots){if(!t.slots[e].local)continue;let n={name:e};p.push(n)}p.length>0&&(a.slots=p),i.declarations.push(a);let m={kind:`custom-element-definition`,name:n.name,declaration:{name:n.name,module:this.getLocalUri(e.file.uri)}};i.exports.push(m),i.declarations?.length==0&&delete i.declarations,i.exports?.length==0&&delete i.exports,this.modulesByUri.set(e.file.uri,i),this._package.modules=Array.from(this.modulesByUri.values())}unregister(e){this.modulesByUri.delete(e),this._package.modules=Array.from(this.modulesByUri.values())}getSourceUri(e){return this.manifest.manifestConfig.srcBaseUrl+`/`+this.getLocalUri(e)}getLocalUri(e){let t=this.manifest.configFile.uri.replace(E.Config,``),n=L(e.replace(t,``)).replace(/\\/g,`/`);return n=n.replace(E.Base,`.js`),`__src/`+n}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},uo=class{manifest;_package;tagsByUri=new Map;constructor(e){this.manifest=e,this._package={html:{snippets:{}}}}async write(e){await Ts((0,f.join)(e,`emmet`,`snippets.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(this.unregister(e.file.uri),!e.fileParsed||!(e instanceof N))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.tagsByUri.set(e.file.uri,i),this.rebuildSnippets()}unregister(e){this.tagsByUri.delete(e),this.rebuildSnippets()}rebuildSnippets(){this._package.html.snippets={};for(let e of this.tagsByUri.values())this._package.html.snippets[e]=`<${e}>\${1}</${e}>`}},fo=class{manifest;_package;tagsByUri=new Map;constructor(e){this.manifest=e,this._package={version:1.1,tags:[]}}async write(e){await Ts((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(this.unregister(e.file.uri),!e.fileParsed||!(e instanceof N))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(`
|
|
670
670
|
`),i=``;n&&(i=n),r&&(i&&(i+=`
|
|
671
671
|
|
|
672
|
-
`),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.tagsByUri.set(e.file.uri,i),this._package.tags=Array.from(this.tagsByUri.values())}unregister(e){this.tagsByUri.delete(e),this._package.tags=Array.from(this.tagsByUri.values())}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},
|
|
672
|
+
`),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.tagsByUri.set(e.file.uri,i),this._package.tags=Array.from(this.tagsByUri.values())}unregister(e){this.tagsByUri.delete(e),this._package.tags=Array.from(this.tagsByUri.values())}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},po=class{manifest;_package;elementsByUri=new Map;constructor(e){this.manifest=e,this._package={$schema:`https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json`,name:``,version:`2.20.0`,"description-markup":`markdown`,contributions:{html:{elements:[]}}}}async write(e){await Ts((0,f.join)(e,`web-types.json`),JSON.stringify(this._package,null,2),`build`,this.manifest.build.buildConfig.fullname)}register(e,t){if(this.unregister(e.file.uri),!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(`
|
|
673
673
|
`),a=``;n&&(a=n),r&&(a&&(a+=`
|
|
674
674
|
|
|
675
675
|
`),a+=r),a&&(t.description=a);let o=[];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)),o.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)),o.push({type:e})}o.length>0&&(t.values=o),i.push(t)}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=[],s=[...t.attributes,...t.props];s.sort((e,t)=>e.name.localeCompare(t.name));for(let e of s){let t={};t.name=e.name,e.isAbstract&&(t.abstract=e.isAbstract),e.documentation&&(t.description=e.documentation.definitions.join(`
|
|
676
|
-
`)),t.type=this.getTypeTxt(e.type),o.push(t)}o.length>0&&(r.js||={},r.js.properties=o),this.elementsByUri.set(e.file.uri,r),this._package.contributions.html.elements=Array.from(this.elementsByUri.values())}unregister(e){this.elementsByUri.delete(e),this._package.contributions?.html?.elements&&(this._package.contributions.html.elements=Array.from(this.elementsByUri.values()))}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},
|
|
676
|
+
`)),t.type=this.getTypeTxt(e.type),o.push(t)}o.length>0&&(r.js||={},r.js.properties=o),this.elementsByUri.set(e.file.uri,r),this._package.contributions.html.elements=Array.from(this.elementsByUri.values())}unregister(e){this.elementsByUri.delete(e),this._package.contributions?.html?.elements&&(this._package.contributions.html.elements=Array.from(this.elementsByUri.values()))}getTypeTxt(e){return this.manifest.getTypeTxt(e)}},mo=class{customElements;htmlCustomData;emmetCustomData;webTypes;configFile;manifestConfig;build;constructor(e,t){this.build=t,this.customElements=new lo(this),this.htmlCustomData=new fo(this),this.emmetCustomData=new uo(this),this.webTypes=new po(this),this.manifestConfig=e,this.configFile=this.build.project.getConfigFile()}register(e){if(e instanceof N&&e.fileParsed){let t=e.fileParsed.classes[e.componentClassName];if(!t){this.unregister(e.file.uri);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],defaultValue:d.properties[e].defaultValue};i.local=d==t,!(i.isPrivate||i.isProtected)&&(i.decorators.find(e=>Bn.is(e)||Ka.is(e))?n.push(i):r.push(i))}for(let e in d.propertiesStatic){let n={...d.propertiesStatic[e],defaultValue:d.propertiesStatic[e].defaultValue};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 N){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=>Rn.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)}else this.unregister(e.file.uri)}unregister(e){this.customElements.unregister(e),this.htmlCustomData.unregister(e),this.emmetCustomData.unregister(e),this.webTypes.unregister(e)}async write(e){await this.customElements.write(e),await this.htmlCustomData.write(e),await this.emmetCustomData.write(e),await this.webTypes.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+=` ${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+=`
|
|
677
677
|
`+e.class.documentation?.definitions.join(`
|
|
678
678
|
`)),t+=`
|
|
679
679
|
`;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(`
|
|
680
680
|
`);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 k(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 k(t.node.type));n+=`: `+e}r(n,t.documentation?.definitions.join(`
|
|
681
681
|
`))}}};return f(a,`Methods`),f(o,`Static Methods`),t.endsWith(`
|
|
682
|
-
`)&&(t=t.substring(0,t.length-1)),t}},
|
|
682
|
+
`)&&(t=t.substring(0,t.length-1)),t}},ho=class extends it{parsedSrc={};parsed;parsedVersion=-1;_exported={};exportedLocales=``;get exported(){return JSON.stringify(this.build.buildConfig.i18n?.locales??[])!==this.exportedLocales&&this.transformForExport(),this._exported}set exported(e){this._exported=e,this.exportedLocales=JSON.stringify(this.build.buildConfig.i18n?.locales??[])}get classInfo(){var e=this.build.tsFiles[this.file.uri.replace(E.I18n,E.ComponentLogic)];if(e instanceof N&&!e.file.isDeleted&&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{let e=JSON.parse(this.file.contentUser);this.parsedSrc=e&&typeof e==`object`&&!Array.isArray(e)?e:{};for(let e of Object.keys(this.parsedSrc))ve.isReservedI18nLocale(e)&&delete this.parsedSrc[e];if(this.parsed=ve.parse(this.file.documentUser),this.parsedVersion=this.file.documentUser.version,this.transformForExport(),this.file instanceof O&&this.isGlobal){let e=`declare global {
|
|
683
683
|
namespace Aventus {
|
|
684
684
|
interface AventusI18n {
|
|
685
685
|
${this.keys.map(e=>`${JSON.stringify(e)}: string`).join(`,
|
|
686
686
|
`)}
|
|
687
687
|
}
|
|
688
688
|
}
|
|
689
|
-
}`;this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,this.file.documentUser.version,e))}}catch{this.parsed=void 0,this.parsedVersion=-1}}transformForExport(){let e={},t=(this.build.buildConfig.i18n?.locales??[]).filter(e=>!ve.isReservedI18nLocale(e));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.classInfo;if(!n){this.exported=e;return}let r=this.build.module+`°`+n.fullName.replace(/\./g,`°`);r&&(r+=`°`);for(let n in this.parsedSrc)for(let i in this.parsedSrc[n])t.includes(i)&&(e[i][r+n]=this.parsedSrc[n][i])}this.exported=e}async onValidate(){let e=await
|
|
690
|
-
`)).digest(`hex`),canDelete:n?.canDelete??!(0,u.existsSync)(e)})}for(let[e,t]of this.publishedI18nOutputs)r.has(e)||this.pendingOutputs.has(e)||this.pendingJsOutputs.has(e)||t.canDelete&&this.pendingDeletions.set(e,t.hash);for(let[e,t]of this.publishedJsOutputs)this.pendingJsOutputs.has(e)||this.pendingOutputs.has(e)||r.has(e)||t.canDelete&&this.pendingDeletions.set(e,t.hash);if(t.length>0)n=!0;else{for(let e of this.diagnostics.values())if(e.some(e=>e.severity===m.DiagnosticSeverity.Error)){n=!0;break}if(!n){for(let e in this.tsFiles)if(this.tsFiles[e].getDiagnostics().some(e=>e.severity===m.DiagnosticSeverity.Error)){n=!0;break}}}this.ensureBuildActive(e),n||(await this.publishOutputs(e),this.publishedI18nOutputs=r,this.publishedJsOutputs=this.pendingJsOutputs),this.ensureBuildActive(e)}catch(e){if(e instanceof
|
|
689
|
+
}`;this.file.setDocumentInternal(d.TextDocument.create(this.file.documentUser.uri,this.file.documentUser.languageId,this.file.documentUser.version,e))}}catch{this.parsed=void 0,this.parsedVersion=-1}}transformForExport(){let e={},t=(this.build.buildConfig.i18n?.locales??[]).filter(e=>!ve.isReservedI18nLocale(e));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.classInfo;if(!n){this.exported=e;return}let r=this.build.module+`°`+n.fullName.replace(/\./g,`°`);r&&(r+=`°`);for(let n in this.parsedSrc)for(let i in this.parsedSrc[n])t.includes(i)&&(e[i][r+n]=this.parsedSrc[n][i])}this.exported=e}async onValidate(){let e=await Aa.getInstance().validate(this);if(this.isGlobal){let t=this.file.name.toLowerCase(),n=[];for(let e of Object.values(this.build.tsLanguageService.i18nFiles))e!=this&&e.isGlobal&&e.file.name.toLowerCase()==t&&n.push(e);if(n.length>0){let r=n.map(e=>e.file.uri).join(`, `),i=`Global i18n files need distinct names. `+t+` is also used by `+r;e.push(ss(this.file.documentUser,i))}}return!this.isGlobal&&!this.classInfo&&e.push(ss(this.file.documentUser,`No matching component class found for this translation file`)),e}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 Aa.getInstance().format(e,t,n)}async onCodeAction(e,t){return await Aa.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||this.parsedVersion!==this.file.documentUser.version)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}},go=class extends Error{},_o=class{project;buildConfig;stories;onNewFileUUID;onFileDeleteUUIDs={};globalComponentSCSSFiles={};scssFiles={};tsFiles={};noNamespaceUri={};htmlFiles={};wcFiles={};i18nComponentsFiles={};namespaces=[];externalPackageInformation=new vo(this);dependencyNeedUris=[];dependencyFullUris=[];dependencyUris=[];dependencyCycle=null;diagnostics=new Map;tsLanguageService;get globalSCSSLanguageService(){return this.project.globalSCSSLanguageService}scssLanguageService;htmlLanguageService;_allowBuild=!0;get allowBuild(){return $.isIDE?this._allowBuild&&this.ideBuild:this._allowBuild}set allowBuild(e){this._allowBuild=e}initDone=!1;_filesLoaded=!1;reloadPage=!1;_outputPathes=[];pendingOutputs;pendingDeletions;pendingI18nOutputs;pendingJsOutputs;publishedI18nOutputs=new Map;publishedJsOutputs=new Map;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 forceDocumentation(){return this.buildConfig.forceDocumentation}get ideBuild(){return this.buildConfig.ideBuild}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=z.getInstance().onNewFile(this.onNewFile.bind(this)),this.tsLanguageService=new On(this),this.scssLanguageService=new vi(this),this.htmlLanguageService=new wi(this),this.stories=new Zt(this,t),this._outputPathes=[(0,f.join)(so.getInstance().getPath(),`@locals`,t.fullname+E.Package).replace(/\\/g,`/`)];for(let e of t.compile)for(let t of e.package)this._outputPathes.push(t.replace(/\\/g,`/`));this.npmBuilder=new co(this),Pi.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 L(e).match(this.buildConfig.srcPathRegex)!=null}getNamespace(e){return this.noNamespaceUri[e]||this.buildConfig.module==``?``:this.buildConfig.module+`.`}enableBuild(){this._allowBuild||(this.allowBuild=!0,this.npmBuilder.rebuildInfo())}disableBuild(){this.allowBuild=!1}get isBuildAllowed(){return this.allowBuild}timerBuild=void 0;destroyed=!1;insideRebuildAll=!1;async rebuildAll(e=!1){this.allowBuild=!1,this.insideRebuildAll=!0,this.scssLanguageService.allowRebuildDefinition(!1),this.htmlLanguageService.allowRebuildDefinition(!1);let t=!1;try{if(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()}t=!0}finally{this.scssLanguageService.allowRebuildDefinition(!0),this.htmlLanguageService.allowRebuildDefinition(!0),this.insideRebuildAll=!1,t||(this.allowBuild=!0)}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.queueBuild()}currentBuild;buildRevision=0;nextBuildRevision(){return this.buildRevision+=1,this.buildRevision}async queueBuild(e=this.nextBuildRevision()){let t=(this.currentBuild??Promise.resolve()).catch(()=>{}).then(()=>this._build(e));this.currentBuild=t;try{await t}finally{this.currentBuild===t&&(this.currentBuild=void 0)}}async build(){if(this.destroyed||!this.initDone||$.noBuild)return;let e=this.nextBuildRevision(),t=$.delayBetweenBuild();t==0?await this.queueBuild(e):(this.timerBuild&&clearTimeout(this.timerBuild),this.timerBuild=setTimeout(async()=>{this.timerBuild=void 0,!(this.destroyed||$.noBuild)&&await this.queueBuild(e)},t))}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 gn&&$.sendDiagnostics({uri:e.file.uri,diagnostics:e.getDiagnostics()},this);this.diagnostics.clear()}emitDiagnostics(){for(let[e,t]of this.diagnostics.entries())if(e instanceof gn){let n=[...t,...e.getDiagnostics()];this.hideWarnings?n=n.filter(e=>e.severity!=m.DiagnosticSeverity.Warning):this.forceDocumentation||(n=n.filter(e=>e.code!=1027)),$.sendDiagnostics({uri:e.file.uri,diagnostics:n},this)}}ensureBuildActive(e){if(this.destroyed||e!==this.buildRevision||$.noBuild)throw new go}async _build(e){if(this.destroyed||!this.allowBuild||e!==this.buildRevision||$.noBuild)return;$.debug(`building `+this.buildConfig.fullname),this.clearDiagnostics();let t=[],n=!1;this.pendingOutputs=new Map,this.pendingDeletions=new Map,this.pendingI18nOutputs=new Map,this.pendingJsOutputs=new Map,this.publishedI18nOutputs??=new Map,this.publishedJsOutputs??=new Map;try{for(let n of this.buildConfig.compile){n.i18n&&(await this.writeBuildI18n(n.i18n),this.ensureBuildActive(e));let r=await this.buildOrderCompilationInfo(n);this.ensureBuildActive(e);let i=await this.buildLocalCode(r.toCompile,this.buildConfig.module);this.ensureBuildActive(e);let a=await this.writeBuildCode(i,r.libSrc,n.output,n.compressed);this.ensureBuildActive(e),t.push(...a,...r.errors);let o={namespace:this.buildConfig.module,available:i.codeRenderInJs,existing:i.codeNotRenderInJs};await this.writeBuildDocumentation(n.package,i,o,n.outputNpm),this.ensureBuildActive(e),n.outputNpm.live&&(await this.writeBuildNpm(n.outputNpm,i),this.ensureBuildActive(e)),this.buildConfig.stories&&this.buildConfig.stories.live&&(await this.stories.check(),this.ensureBuildActive(e),await this.writeBuildNpm({path:[(0,f.join)(this.buildConfig.stories.output,`generated`)],packageJson:!1,npmName:``,live:!1},i),this.ensureBuildActive(e),await this.stories.write(this.tsFiles),this.ensureBuildActive(e))}let r=new Map;for(let[e,t]of this.pendingI18nOutputs){let n=this.publishedI18nOutputs.get(e);r.set(e,{hash:(0,_.createHash)(`sha256`).update(t.replace(/\r\n?/g,`
|
|
690
|
+
`)).digest(`hex`),canDelete:n?.canDelete??!(0,u.existsSync)(e)})}for(let[e,t]of this.publishedI18nOutputs)r.has(e)||this.pendingOutputs.has(e)||this.pendingJsOutputs.has(e)||t.canDelete&&this.pendingDeletions.set(e,t.hash);for(let[e,t]of this.publishedJsOutputs)this.pendingJsOutputs.has(e)||this.pendingOutputs.has(e)||r.has(e)||t.canDelete&&this.pendingDeletions.set(e,t.hash);if(t.length>0)n=!0;else{for(let e of this.diagnostics.values())if(e.some(e=>e.severity===m.DiagnosticSeverity.Error)){n=!0;break}if(!n){for(let e in this.tsFiles)if(this.tsFiles[e].getDiagnostics().some(e=>e.severity===m.DiagnosticSeverity.Error)){n=!0;break}}}this.ensureBuildActive(e),n||(await this.publishOutputs(e),this.publishedI18nOutputs=r,this.publishedJsOutputs=this.pendingJsOutputs),this.ensureBuildActive(e)}catch(e){if(e instanceof go)return;throw e}finally{this.pendingOutputs=void 0,this.pendingDeletions=void 0,this.pendingI18nOutputs=void 0,this.pendingJsOutputs=void 0}Ni.send(this.buildConfig.fullname,t),this.reloadPage&&!n&&(this.reloadPage=!1,yt.getInstance().reload()),this.emitDiagnostics()}_buildStringModule(e,t,n,r,i,a,o){let s=``,c=e.split(`.`),l=e=>e.length===0?``:[`(() => {`,`const _ = globalThis;`,`const __as1 = (o, k, c) => { if (o[k] !== undefined) for (let w in o[k]) { c[w] = o[k][w] } o[k] = c; };`,...e,`})();`].join(`
|
|
691
691
|
`)+`
|
|
692
692
|
`;if(s+=l(t),n.length>0){let t=``;s+=`var `+c[0]+`;
|
|
693
693
|
`;for(let e=0;e<c.length;e++)t==``?t=c[e]:t+=`.`+c[e],s+=`(`+t+`||(`+t+` = {}));
|
|
@@ -745,8 +745,8 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
745
745
|
};
|
|
746
746
|
`);let c=this._buildStringModule(this.buildConfig.module,e.codeNoNamespaceBefore,e.code,e.classesName,e.codeNoNamespaceAfter,o,!1),l=await this.npmBuilder.compile();i=[...i,...l.errors];for(let e of n){let n={};for(let t in e){let i=e[t].path;n[i]||(n[i]={code:s,compressed:(`compressed`in e[t]?e[t].compressed:r)??!1})}e[`@npm`]?n[e[`@npm`].path].code+=l.result:n[e[`@default`].path].code+=l.result;for(let r of t)e[r.lib]?n[e[r.lib].path].code+=r.code+`
|
|
747
747
|
`:n[e[`@default`].path].code+=r.code+`
|
|
748
|
-
`;n[e[`@default`].path].code+=c;for(let e in n){let t=n[e];if(t.compressed)try{t.code=(await(0,fe.minify)({"file1.js":t.code},{compress:!0,format:{comments:!1}})).code??``}catch(t){$.error(t),a.push(`${e}: ${String(t)}`);let n=this.publishedJsOutputs.get(e);n&&!this.pendingJsOutputs?.has(e)&&this.pendingJsOutputs?.set(e,n);continue}let r=this.publishedJsOutputs.get(e)?.canDelete??!(0,u.existsSync)(e),i=
|
|
749
|
-
`)).digest(`hex`),canDelete:r})}}}if(a.length>0){let e=this.buildConfig.fullname+`_minificationErrors`;
|
|
748
|
+
`;n[e[`@default`].path].code+=c;for(let e in n){let t=n[e];if(t.compressed)try{t.code=(await(0,fe.minify)({"file1.js":t.code},{compress:!0,format:{comments:!1}})).code??``}catch(t){$.error(t),a.push(`${e}: ${String(t)}`);let n=this.publishedJsOutputs.get(e);n&&!this.pendingJsOutputs?.has(e)&&this.pendingJsOutputs?.set(e,n);continue}let r=this.publishedJsOutputs.get(e)?.canDelete??!(0,u.existsSync)(e),i=us(e.replace(/\\/g,`/`));(0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0}),await this.writeFile(e,t.code),this.pendingJsOutputs?.set(e,{hash:(0,_.createHash)(`sha256`).update(t.code.replace(/\r\n?/g,`
|
|
749
|
+
`)).digest(`hex`),canDelete:r})}}}if(a.length>0){let e=this.buildConfig.fullname+`_minificationErrors`;ba.send(e,a.join(`
|
|
750
750
|
`)),i.push({file:e,title:`Minification errors`})}return i}async writeBuildDocumentation(e,t,n,r){let i=``;i=`declare global {
|
|
751
751
|
`,i+=`
|
|
752
752
|
namespace `+this.buildConfig.module+`{
|
|
@@ -779,11 +779,11 @@ namespace `+this.buildConfig.module+`{
|
|
|
779
779
|
`,a+=`//#region dependencies //
|
|
780
780
|
`,a+=JSON.stringify(this.buildConfig.rawDependencies)+`
|
|
781
781
|
`,a+=`//#endregion dependencies //
|
|
782
|
-
`;for(let t of e)t?await this.writeFile(t,a):(0,u.existsSync)(t)&&
|
|
783
|
-
`)).digest(`hex`),s=(0,f.join)(L($.getWorkspaceUri()),`.aventus`,`npm`),c=(0,f.join)(s,`register.json`),l=Object.create(null);if((0,u.existsSync)(c))try{let e=JSON.parse((0,u.readFileSync)(c,`utf8`));e&&typeof e==`object`&&!Array.isArray(e)&&(l=e)}catch{}let d=e=>(0,f.resolve)(e).replace(/\\/g,`/`),p=(e,t)=>{let n=(0,f.relative)((0,f.resolve)(e),(0,f.resolve)(t));if(!n||n===`..`||n.startsWith(`..`+f.sep)||n.split(f.sep).includes(`..`))throw Error(`Generated npm output is outside its destination: ${t}`);return n.replace(/\\/g,`/`)},m=async(e,t,r)=>{let i=p(e,t);n.has(e)||n.set(e,Object.create(null)),n.get(e)[i]=o(r),await a(t,r)};try{let r=Object.keys(t.npm);r.includes(``)||r.push(``);for(let e of r){let t=e.split(`.`),n=``;for(let e of t)n=n?`${n}.${e}`:e,r.includes(n)||r.push(n)}r.sort((e,t)=>(e.match(/\./g)||[]).length-(t.match(/\./g)||[]).length);let h={},g=e.manifest?new
|
|
782
|
+
`;for(let t of e)t?await this.writeFile(t,a):(0,u.existsSync)(t)&&Ds(t);let o=(0,f.join)(so.getInstance().getPath(),`@locals`);(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0}),await this.writeFile((0,f.join)(o,this.buildConfig.fullname+E.Package),a)}async writeBuildNpm(e,t){let n=new Map,r=new Map,i=e=>{r.has(e)||r.set(e,(0,u.existsSync)(e)?(0,u.readFileSync)(e):void 0)},a=async(e,t)=>{i(e),await this.writeFile(e,t)},o=e=>(0,_.createHash)(`sha256`).update(e.replace(/\r\n?/g,`
|
|
783
|
+
`)).digest(`hex`),s=(0,f.join)(L($.getWorkspaceUri()),`.aventus`,`npm`),c=(0,f.join)(s,`register.json`),l=Object.create(null);if((0,u.existsSync)(c))try{let e=JSON.parse((0,u.readFileSync)(c,`utf8`));e&&typeof e==`object`&&!Array.isArray(e)&&(l=e)}catch{}let d=e=>(0,f.resolve)(e).replace(/\\/g,`/`),p=(e,t)=>{let n=(0,f.relative)((0,f.resolve)(e),(0,f.resolve)(t));if(!n||n===`..`||n.startsWith(`..`+f.sep)||n.split(f.sep).includes(`..`))throw Error(`Generated npm output is outside its destination: ${t}`);return n.replace(/\\/g,`/`)},m=async(e,t,r)=>{let i=p(e,t);n.has(e)||n.set(e,Object.create(null)),n.get(e)[i]=o(r),await a(t,r)};try{let r=Object.keys(t.npm);r.includes(``)||r.push(``);for(let e of r){let t=e.split(`.`),n=``;for(let e of t)n=n?`${n}.${e}`:e,r.includes(n)||r.push(n)}r.sort((e,t)=>(e.match(/\./g)||[]).length-(t.match(/\./g)||[]).length);let h={},g=e.manifest?new mo(e.manifest,this):null;for(let n in t.npmsrc){let r=``;for(let e in t.npmsrc[n].imports){let i=t.npmsrc[n].imports[e];i.length>0&&(r+=`import { ${i.join(`, `)} } from "${e}";
|
|
784
784
|
`)}if(r!=``&&(r+=`
|
|
785
785
|
`),r+=t.npmsrc[n].content.join(`
|
|
786
|
-
`),r=On.removeUnusedImport(r,t.npmsrc[n].forcedDependencies),g)for(let e of t.npmsrc[n].sourceUri){let t=this.tsFiles[e];t&&g.register(t)}for(let t of e.path){let e=(0,f.join)(t,`__src`,...
|
|
786
|
+
`),r=On.removeUnusedImport(r,t.npmsrc[n].forcedDependencies),g)for(let e of t.npmsrc[n].sourceUri){let t=this.tsFiles[e];t&&g.register(t)}for(let t of e.path){let e=(0,f.join)(t,`__src`,...us(n).split(f.sep)),i=(0,f.join)(t,`__src`,...n.split(f.sep));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0}),await m(t,i,r)}for(let e of t.npmsrc[n].names){let t=e.split(`.`),r=t.pop()??``,i=[];for(let e=0;e<t.length;e++)i.push(`..`);i=[...i,`__src`,...n.split(f.sep)];let a=t.join(`.`);h[a]||(h[a]={});let o=i.join(`/`);h[a][o]||(h[a][o]=[]),h[a][o].push(r)}}let _=async(t,n)=>{n||={content:[],imports:{}};let i=``,a=``,o=t==``?0:t.split(`.`).length,s=[];for(let e of r)if(e.startsWith(t?t+`.`:``)&&e!=t){let t=e.split(`.`);if(t.length==o+1){let e=t[t.length-1];i+=`import * as ${e} from "./${e}";
|
|
787
787
|
`,a+=`export { ${e} };
|
|
788
788
|
`,s.push(`./${e}`)}}for(let e in n.imports){let t=n.imports[e];t.length>0&&(i+=`import { ${t.join(`, `)} } from "${e}";
|
|
789
789
|
`)}i+=`
|
|
@@ -792,7 +792,7 @@ namespace `+this.buildConfig.module+`{
|
|
|
792
792
|
`,i+=a,i=i.replaceAll(`globalThis.Aventus.`,``),i=i.replaceAll(`___Aventus.`,``),i=On.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}),await m(n,(0,f.join)(e,`index.d.ts`),i)}},v=async t=>{let n=``,i=``,a=t==``?0:t.split(`.`).length;for(let e of r)if(e.startsWith(t?t+`.`:``)&&e!=t){let t=e.split(`.`);if(t.length==a+1){let e=t[t.length-1];n+=`import * as ${e} from "./${e}/index.js";
|
|
793
793
|
`,i+=`export { ${e} };
|
|
794
794
|
`}}let o=h[t];if(o)for(let e in o){let t=o[e].join(`, `);n+=`export { ${t} } from "${e}"
|
|
795
|
-
`}n+=i,n=On.removeUnusedImport(n,[]);for(let r of e.path){let e=(0,f.join)(r,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0}),await m(r,(0,f.join)(e,`index.js`),n)}};for(let e of r)await _(e,t.npm[e]),await v(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,s=this.buildConfig.module;this.buildConfig.name&&(i+=`/`+this.buildConfig.name,s+=` `+this.buildConfig.name);let c={name:e.npmName==``?(`@`+this.buildConfig.module+`/`+this.buildConfig.name).toLowerCase():e.npmName,displayName:s,description:i,version:this.buildConfig.version,type:`module`,main:`index.js`,types:`index.d.ts`,dependencies:r};this.buildConfig.organization?c.author={name:this.buildConfig.organization}:so.isConnected&&(c.author={name:so.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={...c,...n};r.name=c.name,r.displayName=c.displayName,r.version=c.version,r.dependencies=c.dependencies;let i=!(0,u.existsSync)(e);if(!i){let n=l[d(t)];i=typeof n?.[`package.json`]==`string`&&n[`package.json`]===o((0,u.readFileSync)(e,`utf8`))}let s=JSON.stringify(r,null,2);i?await m(t,e,s):await a(e,s)}}if(g)for(let t of e.path){(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});for(let e of[`custom-elements.json`,`vscode.html-custom-data.json`,`web-types.json`,(0,f.join)(`emmet`,`snippets.json`)])i((0,f.join)(t,e));await g.write(t)}for(let t of e.path){let e=n.get(t)??Object.create(null),r=d(t),a=l[r]??Object.create(null);for(let[n,r]of Object.entries(a)){if(Object.hasOwn(e,n)||typeof r!=`string`)continue;let a=(0,f.resolve)(t,n);if(!(n.startsWith(`/`)||n.split(`/`).includes(`..`)||!(0,u.existsSync)(a))){try{if(p(t,a)!==n)continue}catch{continue}o((0,u.readFileSync)(a,`utf8`))===r&&(this.pendingDeletions?this.pendingDeletions.set(a,r):(i(a),(0,u.rmSync)(a)))}}l[r]=e}(0,u.mkdirSync)(s,{recursive:!0}),await a(c,JSON.stringify(l,null,2))}catch(e){for(let[e,t]of[...r].reverse())try{t===void 0?(0,u.rmSync)(e,{force:!0}):(0,u.writeFileSync)(e,t)}catch(e){$.error(e)}throw e}}async writeBuildI18n(e){let t=new Map,n=async(e,n)=>{!this.pendingOutputs&&!t.has(e)&&t.set(e,(0,u.existsSync)(e)?(0,u.readFileSync)(e):void 0),await this.writeI18nFile(e,n)};try{let t=(this.buildConfig.i18n?.locales??[]).filter(e=>!ve.isReservedI18nLocale(e));for(let r of e)for(let e of r.output){t.length>0&&!(0,u.existsSync)(e)&&(0,u.mkdirSync)(e,{recursive:!0});for(let i of t)if(r.mode==`singleFile`){let t={};for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e];t={...t,...n.exported[i]}}for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[i]}}await n((0,f.join)(e,i+`.json`).toLowerCase(),JSON.stringify(t,null,4))}else if(r.mode==`oneToOne`){for(let t in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[t];await n((0,f.join)(e,r.file.name.replace(`@`,``).replace(E.I18n,``)+`_`+i+`.json`).toLowerCase(),JSON.stringify(r.exported[i],null,4))}for(let t in this.i18nComponentsFiles){let r=this.i18nComponentsFiles[t],a=this.tsFiles[t.replace(E.I18n,E.ComponentLogic)];if(a instanceof N&&a.fileParsed){let t=a.fileParsed.classes[a.componentClassName],o=r.file.name.replace(E.I18n,``);await n((0,f.join)(e,this.componentI18nFileName(t.namespace,o,i)),JSON.stringify(r.exported[i],null,4))}}}else if(r.mode==`groupComponent`){for(let t in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[t];await n((0,f.join)(e,r.file.name.replace(`@`,``).replace(E.I18n,``)+`_`+i+`.json`).toLowerCase(),JSON.stringify(r.exported[i],null,4))}let t={};for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[i]}}await n((0,f.join)(e,`_components_`+i+`.json`).toLowerCase(),JSON.stringify(t,null,4))}else r.mode==`basedOnAttribute`||r.mode}}catch(e){for(let[e,n]of[...t].reverse())try{n===void 0?(0,u.rmSync)(e,{force:!0}):(0,u.writeFileSync)(e,n)}catch(e){$.error(e)}throw e}}async writeI18nFile(e,t){await this.writeFile(e,t),this.pendingI18nOutputs?.set(e,t)}componentI18nFileName(e,t,n){return((e?e.replace(/\./g,`_`)+`_`:``)+t+`_`+n+`.json`).toLowerCase()}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 N&&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:ms(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(ms(t.compiled,this.project.getConfig()));let e=o+t.classScript;r[e]||(r[e]={code:ms(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=ys(i,s);c=c.replace(E.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,R(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,R(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,f=t=>{if(!this.buildConfig.i18n)return t;d=!1;let n=e.i18n[0];if(t+=`Aventus.I18n.registerLocales(${JSON.stringify(this.buildConfig.i18n.locales.filter(e=>!ve.isReservedI18nLocale(e)))})
|
|
795
|
+
`}n+=i,n=On.removeUnusedImport(n,[]);for(let r of e.path){let e=(0,f.join)(r,...t.split(`.`));(0,u.existsSync)(e)||(0,u.mkdirSync)(e,{recursive:!0}),await m(r,(0,f.join)(e,`index.js`),n)}};for(let e of r)await _(e,t.npm[e]),await v(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,s=this.buildConfig.module;this.buildConfig.name&&(i+=`/`+this.buildConfig.name,s+=` `+this.buildConfig.name);let c={name:e.npmName==``?(`@`+this.buildConfig.module+`/`+this.buildConfig.name).toLowerCase():e.npmName,displayName:s,description:i,version:this.buildConfig.version,type:`module`,main:`index.js`,types:`index.d.ts`,dependencies:r};this.buildConfig.organization?c.author={name:this.buildConfig.organization}:ao.isConnected&&(c.author={name:ao.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={...c,...n};r.name=c.name,r.displayName=c.displayName,r.version=c.version,r.dependencies=c.dependencies;let i=!(0,u.existsSync)(e);if(!i){let n=l[d(t)];i=typeof n?.[`package.json`]==`string`&&n[`package.json`]===o((0,u.readFileSync)(e,`utf8`))}let s=JSON.stringify(r,null,2);i?await m(t,e,s):await a(e,s)}}if(g)for(let t of e.path){(0,u.existsSync)(t)||(0,u.mkdirSync)(t,{recursive:!0});for(let e of[`custom-elements.json`,`vscode.html-custom-data.json`,`web-types.json`,(0,f.join)(`emmet`,`snippets.json`)])i((0,f.join)(t,e));await g.write(t)}for(let t of e.path){let e=n.get(t)??Object.create(null),r=d(t),a=l[r]??Object.create(null);for(let[n,r]of Object.entries(a)){if(Object.hasOwn(e,n)||typeof r!=`string`)continue;let a=(0,f.resolve)(t,n);if(!(n.startsWith(`/`)||n.split(`/`).includes(`..`)||!(0,u.existsSync)(a))){try{if(p(t,a)!==n)continue}catch{continue}o((0,u.readFileSync)(a,`utf8`))===r&&(this.pendingDeletions?this.pendingDeletions.set(a,r):(i(a),(0,u.rmSync)(a)))}}l[r]=e}(0,u.mkdirSync)(s,{recursive:!0}),await a(c,JSON.stringify(l,null,2))}catch(e){for(let[e,t]of[...r].reverse())try{t===void 0?(0,u.rmSync)(e,{force:!0}):(0,u.writeFileSync)(e,t)}catch(e){$.error(e)}throw e}}async writeBuildI18n(e){let t=new Map,n=async(e,n)=>{!this.pendingOutputs&&!t.has(e)&&t.set(e,(0,u.existsSync)(e)?(0,u.readFileSync)(e):void 0),await this.writeI18nFile(e,n)};try{let t=(this.buildConfig.i18n?.locales??[]).filter(e=>!ve.isReservedI18nLocale(e));for(let r of e)for(let e of r.output){t.length>0&&!(0,u.existsSync)(e)&&(0,u.mkdirSync)(e,{recursive:!0});for(let i of t)if(r.mode==`singleFile`){let t={};for(let e in this.tsLanguageService.i18nFiles){let n=this.tsLanguageService.i18nFiles[e];t={...t,...n.exported[i]}}for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[i]}}await n((0,f.join)(e,i+`.json`).toLowerCase(),JSON.stringify(t,null,4))}else if(r.mode==`oneToOne`){for(let t in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[t];await n((0,f.join)(e,r.file.name.replace(`@`,``).replace(E.I18n,``)+`_`+i+`.json`).toLowerCase(),JSON.stringify(r.exported[i],null,4))}for(let t in this.i18nComponentsFiles){let r=this.i18nComponentsFiles[t],a=this.tsFiles[t.replace(E.I18n,E.ComponentLogic)];if(a instanceof N&&a.fileParsed){let t=a.fileParsed.classes[a.componentClassName],o=r.file.name.replace(E.I18n,``);await n((0,f.join)(e,this.componentI18nFileName(t.namespace,o,i)),JSON.stringify(r.exported[i],null,4))}}}else if(r.mode==`groupComponent`){for(let t in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[t];await n((0,f.join)(e,r.file.name.replace(`@`,``).replace(E.I18n,``)+`_`+i+`.json`).toLowerCase(),JSON.stringify(r.exported[i],null,4))}let t={};for(let e in this.i18nComponentsFiles){let n=this.i18nComponentsFiles[e];t={...t,...n.exported[i]}}await n((0,f.join)(e,`_components_`+i+`.json`).toLowerCase(),JSON.stringify(t,null,4))}else r.mode==`basedOnAttribute`||r.mode}}catch(e){for(let[e,n]of[...t].reverse())try{n===void 0?(0,u.rmSync)(e,{force:!0}):(0,u.writeFileSync)(e,n)}catch(e){$.error(e)}throw e}}async writeI18nFile(e,t){await this.writeFile(e,t),this.pendingI18nOutputs?.set(e,t)}componentI18nFileName(e,t,n){return((e?e.replace(/\./g,`_`)+`_`:``)+t+`_`+n+`.json`).toLowerCase()}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 N&&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:fs(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(fs(t.compiled,this.project.getConfig()));let e=o+t.classScript;r[e]||(r[e]={code:fs(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=_s(i,s);c=c.replace(E.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,R(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,R(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,f=t=>{if(!this.buildConfig.i18n)return t;d=!1;let n=e.i18n[0];if(t+=`Aventus.I18n.registerLocales(${JSON.stringify(this.buildConfig.i18n.locales.filter(e=>!ve.isReservedI18nLocale(e)))})
|
|
796
796
|
`,t+=`Aventus.I18n.registerFallback("${this.buildConfig.i18n.fallback}")
|
|
797
797
|
`,n.mode==`singleFile`){let e=(n.mount+`/$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${e}", { load: false })
|
|
798
798
|
`}else if(n.mode==`oneToOne`){for(let e in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(E.I18n,``),i=(n.mount+`/`+r+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${i}", { load: false })
|
|
@@ -800,33 +800,33 @@ namespace `+this.buildConfig.module+`{
|
|
|
800
800
|
`}}}else if(n.mode==`groupComponent`){for(let e in this.tsLanguageService.i18nFiles){let r=this.tsLanguageService.i18nFiles[e].file.name.replace(`@`,``).replace(E.I18n,``),i=(n.mount+`/`+r+`_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${i}", { load: false })
|
|
801
801
|
`}if(Object.keys(this.i18nComponentsFiles).length>0){let e=(n.mount+`/_components_$locale.json`).toLowerCase();t+=`Aventus.I18n.registerFile("${e}", { load: false })
|
|
802
802
|
`}}else n.mode==`basedOnAttribute`||n.mode;return t+=`Aventus.I18n.init()
|
|
803
|
-
`,t};for(let e of this.dependencyUris){let t={namespace:this.externalPackageInformation.getNamespaceByUri(e),before:[],code:[],after:[],classesName:{}};if(!c[e])continue;for(let n of c[e]){let e=this.externalPackageInformation.getByFullName(n);if(e.content!=`noCode`){let n=
|
|
804
|
-
`)),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)&&await this.registerFile(e,!1),this.buildConfig.outsideModulePathRegex&&e.path.match(this.buildConfig.outsideModulePathRegex)&&(await this.registerFile(e,!1),this.noNamespaceUri[e.uri]=!0)}async loadFiles(){
|
|
805
|
-
`)).digest(`hex`)===t&&(r.push({path:e,previous:n}),(0,u.rmSync)(e))}}catch(e){for(let{path:e,previous:t}of r.reverse())try{t===void 0?(0,u.rmSync)(e,{force:!0}):(!(0,u.existsSync)(e)||(0,u.readFileSync)(e,`utf8`)!==t)&&await this.writeFile(e,t)}catch(e){$.error(e)}throw e}}},
|
|
803
|
+
`,t};for(let e of this.dependencyUris){let t={namespace:this.externalPackageInformation.getNamespaceByUri(e),before:[],code:[],after:[],classesName:{}};if(!c[e])continue;for(let n of c[e]){let e=this.externalPackageInformation.getByFullName(n);if(e.content!=`noCode`){let n=fs(e.content.code,this.project.getConfig());if(e.content.noNamespace)e.content.noNamespace==`before`?t.before.push(n):e.content.noNamespace==`after`&&t.after.push(n);else{t.code.push(n);let r=RegExp(`^`+this.externalPackageInformation.getNamespaceByUri(e.uri)+`.`),i=e.content.fullName.replace(r,``);t.classesName[i]={type:e.content.type,isExported:e.content.isExported,convertibleName:e.content.convertibleName}}}}let n=this.externalPackageInformation.getStyleByUri(e),r=[];for(let e in n)r.push(`Aventus.Style.store(${JSON.stringify(e)}, ${JSON.stringify(n[e])})`);let i=this.externalPackageInformation.getNameByUri(e)==`Aventus@Main`,a=this._buildStringModule(t.namespace,t.before,t.code,t.classesName,t.after,r,i);t.namespace==`Aventus`&&t.classesName.I18n&&this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1&&(a=f(a));let o=this.externalPackageInformation.getNameByUri(e);u.push({lib:o,code:a})}if(d){let e=``;this.buildConfig.i18n&&this.buildConfig.i18n.autoRegister!==!1&&(e=f(e)),u.push({lib:`Aventus@I18n`,code:e})}if(t.libSrc=u,r.length>0){let e=this.buildConfig.fullname+`_dependencyErrors`;ba.send(e,r.join(`
|
|
804
|
+
`)),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)&&await this.registerFile(e,!1),this.buildConfig.outsideModulePathRegex&&e.path.match(this.buildConfig.outsideModulePathRegex)&&(await this.registerFile(e,!1),this.noNamespaceUri[e.uri]=!0)}async loadFiles(){No.startSendBuildTime(this.buildConfig.fullname),this.allowBuild=!1;let e=await so.getInstance().loadDependenciesFromBuild(this.buildConfig,this);if(this.dependencyCycle=e.cycle??null,this.dependencyCycle){await this.project.getConfigFile().validate();return}this.dependencyFullUris=e.dependencyFullUris,this.dependencyNeedUris=e.dependencyNeedUris,this.dependencyUris=e.dependencyUris,this.externalPackageInformation.init(e.files);let t=z.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),No.sendBuildTime(this.buildConfig.fullname)}async registerFile(e,t){if(e.uri.endsWith(E.ComponentStyle))this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new yi(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(E.ComponentView))this.htmlFiles[e.uri]||(this.htmlFiles[e.uri]=new bi(e,this),t||await this.htmlFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(E.Component))this.wcFiles[e.uri]||(this.wcFiles[e.uri]=new qi(e,this),t||await this.wcFiles[e.uri].init(),this.registerOnFileDelete(e));else if(e.uri.endsWith(E.I18n))if(e.name.startsWith(`@`)){if(!this.tsLanguageService.i18nFiles[e.uri]){if(this.tsLanguageService.i18nFiles[e.uri]=new ho(e,!0,this),!t)for(let e of Object.values(this.tsLanguageService.i18nFiles))await e.validate();this.registerOnFileDelete(e)}}else this.i18nComponentsFiles[e.uri]||(this.i18nComponentsFiles[e.uri]=new ho(e,!1,this),t||await this.i18nComponentsFiles[e.uri].validate(),this.registerOnFileDelete(e));else if(!this.tsFiles[e.uri]){let t=Mi(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){if(e.removeOnDelete(this.onFileDeleteUUIDs[e.uri]),delete this.onFileDeleteUUIDs[e.uri],e.uri.endsWith(E.ComponentStyle))delete this.scssFiles[e.uri];else if(e.uri.endsWith(E.ComponentView))delete this.htmlFiles[e.uri];else if(e.uri.endsWith(E.Component))delete this.wcFiles[e.uri];else if(e.uri.endsWith(E.I18n))if(e.name.startsWith(`@`)){delete this.tsLanguageService.i18nFiles[e.uri];for(let e of Object.values(this.tsLanguageService.i18nFiles))await e.validate()}else delete this.i18nComponentsFiles[e.uri];else delete this.tsFiles[e.uri]}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(L(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 N&&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=>Rn.is(e))&&(r=!0),i=i.parentClass}return t}getNamespaceForUri(e){if(this.buildConfig.namespaceStrategy==`manual`)return``;if(this.buildConfig.namespaceStrategy==`rules`){let t=L(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(E.ComponentLogic),n=L(e),r=n.split(`/`);r.pop(),t&&r.pop(),n=r.join(`/`)+`/`;let i=this.buildConfig.namespaceRoot.endsWith(`/`)?this.buildConfig.namespaceRoot:this.buildConfig.namespaceRoot+`/`;if(!n.startsWith(i))return``;let a=n.slice(i.length).replace(/\//g,`.`);return a.endsWith(`.`)&&(a=a.slice(0,-1)),a.startsWith(`.`)&&(a=a.slice(1)),a.includes(`:`)?``:this.buildConfig.namespaceStrategy==`followFoldersCamelCase`?(a=a.slice(0,1).toUpperCase()+a.slice(1),a.replace(/(([-_\.]|^)[a-z])/g,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``))):a}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,t){let n={};for(let r of e)if(r.oldUri.endsWith(E.Component)||r.oldUri.endsWith(E.ComponentLogic)||r.oldUri.endsWith(E.Data)||r.oldUri.endsWith(E.Lib)||r.oldUri.endsWith(E.RAM)){let e=await this.tsLanguageService.onRenameFile(r.oldUri,r.newUri);for(let t in e){n[t]||(n[t]=[]);for(let r of e[t])n[t].some(e=>e.newText===r.newText&&e.range.start.line===r.range.start.line&&e.range.start.character===r.range.start.character&&e.range.end.line===r.range.end.line&&e.range.end.character===r.range.end.character)||n[t].push(r)}}else if(r.oldUri.endsWith(E.ComponentStyle)||r.oldUri.endsWith(E.GlobalStyle)){let r={...this.scssFiles,...this.project.scssFiles};for(let i in r){let a=r[i];if(t.has(a.file.uri)||e.some(e=>e.oldUri===a.file.uri))continue;t.add(a.file.uri);let o=a.getRenameFileEdits(e);o.length>0&&(n[a.file.uri]||(n[a.file.uri]=[]),n[a.file.uri]=[...n[a.file.uri],...o])}}return n}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(){if(!this.destroyed){this.destroyed=!0,this.timerBuild&&=(clearTimeout(this.timerBuild),void 0),z.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]);Fi.send(this.project.getConfigFile().path,this.buildConfig.fullname)}}async writeFile(e,t){if(this.pendingOutputs){this.pendingOutputs.set(e,t);return}await Ts(e,t,`build`,this.buildConfig.fullname)}async publishOutputs(e){let t=this.pendingOutputs,n=this.pendingDeletions??[];if(this.pendingOutputs=void 0,!t)return;let r=[];try{this.ensureBuildActive(e);for(let[n,i]of t){this.ensureBuildActive(e);let t=(0,u.existsSync)(n)?(0,u.readFileSync)(n,`utf8`):void 0;r.push({path:n,previous:t}),await this.writeFile(n,i),this.ensureBuildActive(e)}this.ensureBuildActive(e);for(let[e,t]of n){if(!(0,u.existsSync)(e))continue;let n=(0,u.readFileSync)(e,`utf8`);(0,_.createHash)(`sha256`).update(n.replace(/\r\n?/g,`
|
|
805
|
+
`)).digest(`hex`)===t&&(r.push({path:e,previous:n}),(0,u.rmSync)(e))}}catch(e){for(let{path:e,previous:t}of r.reverse())try{t===void 0?(0,u.rmSync)(e,{force:!0}):(!(0,u.existsSync)(e)||(0,u.readFileSync)(e,`utf8`)!==t)&&await this.writeFile(e,t)}catch(e){$.error(e)}throw e}}},vo=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:T.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:T.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}}},yo=class{staticConfig;watcher;isReady=!1;project;exportedBySource=new Map;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){No.startSendStaticTime(this.name);let e=!0,t=e=>{var t=[],n=e=>((0,u.existsSync)(e)&&(0,u.readdirSync)(e).forEach(r=>{let i=e+`/`+r;(0,u.lstatSync)(i).isDirectory()?n(i):t.push(i)}),t);return t=n(e),t},n=async(t,n)=>{try{if(!this.isReady)return null;n=(0,f.normalize)(n);let e=n.split(f.sep),r=e.pop(),i=e.join(f.sep);if((0,u.existsSync)(i)&&(0,u.statSync)(i).isFile()&&(0,u.rmSync)(i),(0,u.existsSync)(i)||(0,u.mkdirSync)(i,{recursive:!0}),r.endsWith(`.scss`)){if(!r.startsWith(`_`)){let e=(0,ae.compile)(t,{style:`compressed`}).css.toString().trim(),r=n.slice(0,-5)+`.css`;return this.isReady?((0,u.existsSync)(r)&&(0,u.statSync)(r).isDirectory()&&(0,u.rmSync)(r,{recursive:!0}),await Ts(r,e,`static`,this.name),r):null}}else return(0,u.existsSync)(n)&&(0,u.statSync)(n).isDirectory()&&(0,u.rmSync)(n,{recursive:!0}),(0,u.copyFileSync)(t,n),No.sendFileSize(n,void 0,`static`,this.name),n}catch(t){e=!1,$.error(t)}return null},r=t(this.staticConfig.inputPathFolder),i=new Set(r.map(e=>e.replace(/\\/g,`/`))),a=new Set,o=new Set;for(let e of this.exportedBySource.values())for(let[t,n]of e)n.canDelete&&o.add(t);for(let e of r){if(!this.isReady)return;e=e.replace(/\\/g,`/`);let t=this.exportedBySource.get(e),r=new Map,i=new Set(this.staticConfig.outputPathFolder.map(e=>(0,f.normalize)(e)));for(let a of i){if(!this.isReady)return;let i=e.replace(this.staticConfig.inputPathFolder,a);if(e.endsWith(E.Base)){if(e.endsWith(E.GlobalStyle)){i=i.replace(E.GlobalStyle,`.css`);let n=this.project.scssFiles[I(e)];if(!n){let t=d.TextDocument.create(I(e),E.GlobalStyle,1,(0,u.readFileSync)(e,`utf8`));if(await z.getInstance().registerFile(t),!this.isReady)return;n=this.project.scssFiles[I(e)]}let a=(0,f.normalize)(i),s=(0,u.existsSync)(a);if(await n.addOutPath(i,this.name),!this.isReady)return;this.rememberOutput(r,t,a,s,o)}}else{let a=(0,f.normalize)(i.endsWith(`.scss`)?i.slice(0,-5)+`.css`:i),s=(0,u.existsSync)(a)&&!(0,u.statSync)(a).isDirectory(),c=await n(e,i);if(!this.isReady)return;c&&this.rememberOutput(r,t,c,s,o)}}(t||r.size>0)&&this.exportedBySource.set(e,new Map([...t??[],...r]));for(let e of r.keys())a.add(e)}if(!this.isReady)return;for(let[e,t]of this.exportedBySource)if(!i.has(e)){for(let[n,r]of t)if(!a.has(n)){e.endsWith(E.GlobalStyle)&&this.project.scssFiles[I(e)]?.removeOutPath(n);try{if(!r.canDelete||!(0,u.existsSync)(n))continue;let e=(0,u.statSync)(n);e.isFile()&&e.size===r.size&&e.mtimeMs===r.mtimeMs&&(0,u.unlinkSync)(n)}catch(e){$.error(e)}}this.exportedBySource.delete(e)}if(!e||!this.isReady)return;yt.getInstance().reload(),No.sendStaticTime(this.name)}}rememberOutput(e,t,n,r,i){if(!(0,u.existsSync)(n))return;let a=(0,u.statSync)(n),o=t?.get(n)?.canDelete===!0||i.has(n)||!r;o&&i.add(n),e.set(n,{size:a.size,mtimeMs:a.mtimeMs,canDelete:o})}registerWatcher(){F.getInstance().settings.watchFiles&&(this.watcher=(0,me.watch)(this.staticConfig.inputPathFolder,{ignored:/^\./,persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:100},ignoreInitial:!0}),this.watcher.on(`add`,e=>{this.export()}),this.watcher.on(`change`,e=>{this.export()}),this.watcher.on(`unlink`,e=>{this.export()}),this.watcher.on(`error`,function(e){}))}destroy(){this.isReady=!1,this.watcher&&this.watcher.close()}};function bo(e){let t=e.split(``),n=n=>{e[n]!==`\r`&&e[n]!==`
|
|
806
806
|
`&&(t[n]=` `)},r=`normal`,i=``,a=`normal`,o=0;for(let t=0;t<e.length;t++){let s=e[t],c=e[t+1];if(r===`normal`){if(s===`/`&&c===`*`)n(t),n(++t),r=`block`;else if(s===`/`&&c===`/`)n(t),n(++t),r=`line`;else if(s===`"`||s===`'`)i=s,a=`normal`,n(t),r=`string`;else if((s===`u`||s===`U`)&&(t===0||!/[\w-]/.test(e[t-1]))){let n=/^url\s*\(/i.exec(e.slice(t));n&&(t+=n[0].length-1,r=`url`,o=1)}}else r===`block`?(n(t),s===`*`&&c===`/`&&(n(++t),r=`normal`)):r===`line`?s===`\r`||s===`
|
|
807
|
-
`?r=`normal`:n(t):r===`string`?(n(t),s===`\\`&&c!==void 0?n(++t):s===i&&(r=a)):s===`"`||s===`'`?(i=s,a=`url`,n(t),r=`string`):s===`(`?(o++,n(t)):s===`)`?(o--,o===0?r=`normal`:n(t)):n(t)}return t.join(``)}var Co=class{languageService;variablesByUri={};variablesByName={};project;constructor(e){this.project=e,this.languageService=(0,ie.getSCSSLanguageService)()}getRenameFileEdits(e,t){return vi.getScssRenameEdits(e.documentUser,t)}async doValidation(e){return this.languageService.doValidation(e.documentUser,this.languageService.parseStylesheet(e.documentUser))}async doComplete(e,t){return this.languageService.doComplete(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async doHover(e,t){return this.languageService.doHover(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async findDefinition(e,t){let n=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));return n&&[n]}async format(e,t,n){let r={...n,preserveNewLines:!0,spaceAroundSelectorSeparator:!0,insertFinalNewline:!0,insertSpaces:!1,tabSize:4},i=e.documentUser,a=await this.languageService.format(i,t,r);if(a.length==1){let e=i.offsetAt(a[0].range.start),t=i.offsetAt(a[0].range.end),n=i.getText().length;if(e==0&&t==n){let e=await(0,re.default)([(0,ui.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:di,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.getGlobalReferences(e.documentUser,t);if(n)return n;let r=this.languageService.parseStylesheet(e.documentUser);return this.languageService.findReferences(e.documentUser,t,r)}getGlobalReferences(e,t,n){let r=e.offsetAt(t),i=So(e.getText()),a=/--[a-zA-Z0-9_-]+/g,o,s;for(;o=a.exec(i);)if(o.index<=r&&r<=o.index+o[0].length){s=o[0];break}if(!s)return null;let c=this.getDefinition(s);if(!c)return null;let l=[{uri:c.uri,range:c.range}],u=new Map,d=this.project,f=n?[n]:d.getBuilds();for(let e of Object.values(d.scssFiles))u.set(e.file.documentUser.uri,e.file.documentUser);for(let e of f)for(let t of Object.values(e.scssFiles))u.set(t.file.documentUser.uri,t.file.documentUser);u.set(e.uri,e);for(let e of u.values()){let t=So(e.getText()),n=/var\(\s*(--[a-zA-Z0-9_-]+)/g,r;for(;r=n.exec(t);){if(r[1]!==s)continue;let t=r.index+r[0].lastIndexOf(s);l.push({uri:e.uri,range:{start:e.positionAt(t),end:e.positionAt(t+s.length)}})}}return l.some(t=>t.uri===e.uri&&e.offsetAt(t.range.start)<=r&&r<e.offsetAt(t.range.end))?l:null}onRename(e,t,n){let r=this.getGlobalReferences(e,t);if(!r)return null;let i=n.startsWith(`--`)?n:`--${n}`;if(!/^--[a-zA-Z_][a-zA-Z0-9_-]*$/.test(i))return null;let a={},o=new Set;for(let e of r){let{uri:t,range:n}=e,r=`${t}:${n.start.line}:${n.start.character}:${n.end.line}:${n.end.character}`;o.has(r)||(o.add(r),a[t]||(a[t]=[]),a[t].push({range:n,newText:i}))}return{changes:a}}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.getChildren().some(e=>e.getText().trim()===`:root`)){let i=e.getChild(0),a=e.getChild(1);if(i&&a){let e=i.getText();e.startsWith(`--`)&&(!r[e]||n.offsetAt(r[e].range.start)<i.offset)&&(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)};i((0,ie.getSCSSLanguageService)().parseStylesheet(n)),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]}},wo=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 O&&await this.file.validate()}triggerSave(){this.file instanceof O&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof O&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async _onDelete(){await this.onDelete(),this.removeEvents()}},To=class e extends wo{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)}getRenameFileEdits(e){return this.project.globalSCSSLanguageService.getRenameFileEdits(this.file,e)}async onContentChange(){this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}async onValidate(){return this.diagnostics=await this.project.globalSCSSLanguageService.doValidation(this.file),this.loadDependencies(),this.diagnosticCompile?[...this.diagnostics,this.diagnosticCompile]:this.diagnostics}async onSave(){this.savedOnce=!0,await this.compileRoot(),this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}async compileRoot(){if(Object.values(this.usedBy).length==0)await this.compile();else for(let e in this.usedBy)this.usedBy[e].onSave()}async compile(){try{let e=this.compiledTxt,t=`|error|`,n=e=>{let r=e.contentUser;r=r.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let i=/@import *?('|")(\S*?)('|");?/g,a=null;for(;a=i.exec(r);){let i=a[2],o=this.resolvePath(i,e.folderPath);if(o){let e=n(o);if(e==t)return e;r=r.replace(a[0],e)}else return t}return r},r=n(this.file);if(r!=`|error|`){let t=e=>{if(F.getInstance().settings.errorByBuild){let t=this.project.getBuilds();for(let n of t)$.sendDiagnostics({uri:this.file.uri,diagnostics:e},n)}else $.sendDiagnostics({uri:this.file.uri,diagnostics:e})};try{let n=(0,ae.compileString)(r,{style:`compressed`}).css.toString().trim();n=n.replace(/\\/g,`\\\\`),e=n,this.diagnosticCompile&&(this.diagnosticCompile=void 0,t(this.diagnostics))}catch(e){e instanceof ae.Exception&&(this.diagnosticCompile=os(this.file.documentUser,e.message),t([...this.diagnostics,this.diagnosticCompile]))}}e!=this.compiledTxt&&(this.compiledVersion++,this.compiledTxt=e,await this.export())}catch(e){console.error(e)}}async onDelete(){for(let e in this.dependencies)this.removeDependency(e);for(let e in this.usedBy)delete this.usedBy[e].dependencies[this.file.uri],delete this.usedBy[e],await this.usedBy[e].onContentChange();this.project.globalSCSSLanguageService.removeVariables(this.file.uri)}async onCompletion(e,t){let n={isIncomplete:!1,items:[]};return n=await this.project.globalSCSSLanguageService.doComplete(e,t),n}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.project.globalSCSSLanguageService.doHover(e,t)}async onDefinition(e,t){return this.project.globalSCSSLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return this.project.globalSCSSLanguageService.format(e,t,n)}async onCodeAction(e,t){return this.project.globalSCSSLanguageService.doCodeAction(e,t)}async onReferences(e,t){return await this.project.globalSCSSLanguageService.onReferences(e,t)}async onCodeLens(e){return[]}async onRename(e,t,n){return this.project.globalSCSSLanguageService.onRename(e.documentUser,t,n)}async addOutPath(e,t){this.file.shortname.startsWith(`_`)||this.staticNamebyOutPath[e]||(this.staticNamebyOutPath[e]=t,this.savedOnce||await this.onSave(),await this.export())}removeOutPath(e){for(let t of Object.keys(this.staticNamebyOutPath))(0,f.normalize)(t)===(0,f.normalize)(e)&&delete this.staticNamebyOutPath[t]}async export(){for(let e in this.staticNamebyOutPath){let t=(0,f.normalize)(e),n=t.split(f.sep);n.pop();let r=n.join(f.sep);(0,u.existsSync)(r)||(0,u.mkdirSync)(r,{recursive:!0}),await Ds(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(ss(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(E.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=z.getInstance().getByPath(e);if(n)return n;let r=e+E.GlobalStyle;if(n=z.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=z.getInstance().getByPath(a),n)return n;let o=a+E.GlobalStyle;if(n=z.getInstance().getByPath(o),n)return n}},Eo=class extends Error{constructor(){super(`Mutex disposed while waiting for the lock`),this.name=`MutexDisposedError`}},Do=class{waitingList=[];isLocked=!1;waitOne(){return new Promise((e,t)=>{this.isLocked?this.waitingList.push({resolve:e,reject:t}):(this.isLocked=!0,e())})}release(){let e=this.waitingList.shift();e?e.resolve():this.isLocked=!1}dispose(){let e=this.waitingList;this.waitingList=[],this.isLocked=!1;for(let t of e)t.reject(new Eo)}},Oo=class{configFile;config=null;builds=[];statics=[];destroyed=!1;_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){let t=a[e]===o[e];if(process.platform===`win32`&&(t=a[e].toLowerCase()===o[e].toLowerCase()),t)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)){let e=n.getLocalWebComponentDefinition(t);if(e)return e}}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=z.getInstance().onNewFile(this.onNewFile.bind(this)),e.folderUri.toLowerCase().endsWith(`/aventus/base/src`)&&(this._isCoreBuild=!0),this.globalSCSSLanguageService=new Co(this),t&&this.loadFiles(),e.validate()}async init(){await this.onConfigSave()}async onValidate(){let e=Qe.getInstance(),t=await e.validate(this.configFile);for(let n of this.builds){let r=n.dependencyCycle;if(!r)continue;let i=r.find(t=>e.getDependencyKeyRange(this.configFile,n.buildConfig.name,t)),a=i?e.getDependencyKeyRange(this.configFile,n.buildConfig.name,i):null;a&&t.push({range:a,severity:m.DiagnosticSeverity.Error,source:`Aventus`,message:`Cycle de dépendances : ${r.join(` → `)}`})}return t}async loadConfig(){let e=[],t=await Qe.getInstance().getConfig(this.configFile,e);if(!this.destroyed){if($.sendDiagnostics({uri:this.configFile.uri,diagnostics:e}),this.config){let e=JSON.stringify(this.config),n=``;if(t&&(n=JSON.stringify(t)),e==n)return;for(let e of this.builds)e.destroy()}this.builds=[],this.config=t}}onConfigSaveMutex=new Do;async onConfigSave(){if(!this.destroyed){await this.onConfigSaveMutex.waitOne();try{if(this.destroyed||(await this.loadConfig(),this.destroyed))return;for(let e of this.statics)e.destroy();this.statics=[];for(let e of this.builds)e.destroy();if(this.builds=[],this.config){for(let e of this.config.build){if(this.destroyed)return;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 yo(this,e);if(this.builds.push(t),await t.init(),this.destroyed)return}if(this.config.static)for(let e of this.config.static){if(this.destroyed)return;if(this.staticsAllowed&&!this.staticsAllowed.includes(e.name??``))continue;let t=new xo(this,e);if(this.statics.push(t),await t.export(),this.destroyed)return}}}catch(e){for(let e of this.builds)e.destroy();for(let e of this.statics)e.destroy();throw this.builds=[],this.statics=[],e}finally{this.onConfigSaveMutex.release()}}}async onFormatting(e,t,n){return await Qe.getInstance().format(e,t,n)}async onCompletion(e,t){return await Qe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return await Qe.getInstance().doResolve(t)}async onHover(e,t){return await Qe.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}getStaticAt(e){return this.statics[e]}loadFiles(){let e=z.getInstance().getFilesWithExtension(E.GlobalStyle);for(let t of e)this.onNewFile(t)}async onNewFile(e){this.destroyed||e.path.endsWith(E.GlobalStyle)&&(this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new To(e,this),this.registerOnFileDelete(e)))}registerOnFileDelete(e){this.destroyed||(this.onFileDeleteUUIDs[e.uri]=e.onDelete(this.onFileDelete.bind(this)))}async onFileDelete(e){if(this.destroyed)return;let t=this.onFileDeleteUUIDs[e.uri];t&&(e.removeOnDelete(t),delete this.onFileDeleteUUIDs[e.uri],e.uri.endsWith(E.GlobalStyle)&&delete this.scssFiles[e.uri])}async onRename(e){let t={},n=new Set;for(let r of this.builds){let i=await r.onRename(e,n);for(let e in i)t[e]||(t[e]=[]),t[e]=t[e].concat(i[e])}return t}async buildAll(){let e=[],t=t=>{try{e.push(Promise.resolve(t()))}catch(t){e.push(Promise.reject(t))}};for(let e of this.builds)t(()=>e.build());for(let e of this.statics)t(()=>e.export());await Promise.all(e)}destroy(){if(!this.destroyed){this.destroyed=!0,z.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,t]of Object.entries(this.onFileDeleteUUIDs??{}))this.scssFiles?.[e]?.file.removeOnDelete(t);this.onFileDeleteUUIDs={},this.scssFiles={}}let e=[],t=[];for(let n of this.builds)try{n.destroy()}catch(r){t.push(n),e.push(`Build: ${String(r)}`)}this.builds=t;let n=[];for(let t of this.statics)try{t.destroy()}catch(r){n.push(t),e.push(`Static: ${String(r)}`)}this.statics=n,e.length>0&&$.showErrorMessage(`Project cleanup failed:\n${e.join(`
|
|
808
|
-
`)}`)}},P=class e{static autoLoad=!0;static instance;static getInstance(){return this.instance||=new e,this.instance}projects={};constructor(){z.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(t){if(t.documentUser.uri.endsWith(`/`+E.Config)){let n=t.documentUser.uri.replace(E.Config,E.Template);if(z.getInstance().getByUri(n))return;if(this.projects[t.documentUser.uri])console.error(`a config file with the uri :`+t.documentUser.uri+` is already inside project manager`);else{let n=new Oo(t,e.autoLoad);this.projects[t.documentUser.uri]=n;try{e.autoLoad&&await n.init()}catch(e){n.destroy(),this.projects[t.documentUser.uri]===n&&delete this.projects[t.documentUser.uri],$.showErrorMessage(`Project initialization failed for ${t.documentUser.uri}: ${String(e)}`);return}if(this.projects[t.documentUser.uri]!==n)return;t.onDelete(this.onDeleteFile.bind(this))}}}async onDeleteFile(e){this.projects[e.documentUser.uri]&&(this.projects[e.documentUser.uri].destroy(),delete this.projects[e.documentUser.uri])}getProjectByUri(e){return this.projects[e]}getMatchingBuildsByUri(e){let t=[];for(let n in this.projects){let r=this.projects[n].getMatchingBuildsByUri(e);for(let e of r)t.push(e)}return t}destroyAll(){for(let e in this.projects)this.projects[e].destroy()}async buildAll(){let e=[];for(let t in this.projects)e.push(this.projects[t].buildAll());await Promise.all(e)}async onRename(e){let t={};for(let n in this.projects){let r=this.projects[n],i=await r.onRename(e);this.projects[n]===r&&this.preventDoubleEdit(t,i)}return t}preventDoubleEdit(e,t){for(let n in t){if(e[n]||(e[n]=[]),!n.endsWith(E.ComponentStyle)&&!n.endsWith(E.GlobalStyle)){e[n]=e[n].concat(t[n]);continue}for(let r of t[n])e[n].some(e=>e.newText===r.newText&&e.range.start.line===r.range.start.line&&e.range.start.character===r.range.start.character&&e.range.end.line===r.range.end.line&&e.range.end.character===r.range.end.character)||e[n].push(r)}}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.some(e=>e.name===t&&e.uri===n.getConfigFile().uri)||e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllBuildsWithStory(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsNameWithStory();for(let t of r)e.some(e=>e.name===t&&e.uri===n.getConfigFile().uri)||e.push({name:t,uri:n.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.some(e=>e.name===t&&e.uri===n.getConfigFile().uri)||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.getStaticsName();for(let t=0;t<r.length;t++){let i={name:r[t],index:t,uri:n.getConfigFile().uri};i.name||delete i.name,e.push(i)}}return e}};const ko={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,defaultForceDocumentation:!1,deeplApiKey:``,quickCreations:[],ideBuild:!0};function Ao(){return JSON.parse(JSON.stringify(ko))}const jo={version:`1.3.7`,store:{token:``,username:``}};function Mo(){return JSON.parse(JSON.stringify(jo))}const No={customData:[]};function Po(){return JSON.parse(JSON.stringify(No))}var F=class e{static instance;_settings=Ao();_settingsHtml=Po();_hiddenSettings=Mo();firstInit=!0;get settings(){return this._settings}get settingsHtml(){return this._settingsHtml}get hiddenSettings(){return this._hiddenSettings}static getInstance(){return this.instance||=new e,this.instance}constructor(){let e=(0,f.join)($.savePath,`config.json`);if((0,u.existsSync)(e)){let t={};try{t=JSON.parse((0,u.readFileSync)(e,`utf8`))}catch{}this._hiddenSettings={...this._hiddenSettings,...t}}}initSettings(e){let t=!1;this.firstInit||`ideBuild`in e&&this._settings.ideBuild!=e.ideBuild&&e.ideBuild&&(t=!0),this._settings=this.mergeDeep(Ao(),e);let n=[...this.cbOnSettingsChange];for(let e of n)e();this.firstInit&&=!1,t&&P.getInstance().buildAll()}setSettings(e,t){$.setSettings(e,t)}setHiddenSettings(e){let{store:t,...n}=e;this._hiddenSettings={...this._hiddenSettings,...n,store:{...this._hiddenSettings.store,...t}},(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(Po(),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)}},Fo=class{static get isEnable(){return F.getInstance().settings.useStats}static startSendLoadFile(){this.isEnable&&As.start(`load_files`)}static sendLoadFile(){this.isEnable&&$.sendNotification(`aventus/statistics/loadFileTime`,As.stop(`load_files`))}static startSendBuildTime(e){this.isEnable&&As.start(`full_build_`+e)}static sendBuildTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/buildTime`,e,As.stop(`full_build_`+e))}static startSendStaticTime(e){this.isEnable&&As.start(`full_static_`+e)}static sendStaticTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/staticTime`,e,As.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)}}},Io=o(((e,t)=>{t.exports=a,a.sync=o;var n=require("fs");function r(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function i(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:r(t,n)}function a(e,t,r){n.stat(e,function(n,a){r(n,n?!1:i(a,e,t))})}function o(e,t){return i(n.statSync(e),e,t)}})),Lo=o(((e,t)=>{t.exports=r,r.sync=i;var n=require("fs");function r(e,t,r){n.stat(e,function(e,n){r(e,e?!1:a(n,t))})}function i(e,t){return a(n.statSync(e),t)}function a(e,t){return e.isFile()&&o(e,t)}function o(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}})),Ro=o(((e,t)=>{require("fs");var n=process.platform===`win32`||global.TESTING_WINDOWS?Io():Lo();t.exports=r,r.sync=i;function r(e,t,i){if(typeof t==`function`&&(i=t,t={}),!i){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,i){r(e,t||{},function(e,t){e?i(e):n(t)})})}n(e,t||{},function(e,n){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,n=!1),i(e,n)})}function i(e,t){try{return n.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}})),zo=o(((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=require("path"),i=n?`;`:`:`,a=Ro(),o=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),s=(e,t)=>{let r=t.colon||i,a=e.match(/\//)||n&&e.match(/\\/)?[``]:[...n?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(r)],o=n?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=n?o.split(r):[``];return n&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:a,pathExt:s,pathExtExe:o}},c=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:i,pathExt:c,pathExtExe:l}=s(e,t),u=[],d=n=>new Promise((a,s)=>{if(n===i.length)return t.all&&u.length?a(u):s(o(e));let c=i[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=r.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,o)=>{if(r===c.length)return i(d(n+1));let s=c[r];a(e+s,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+s);else return i(e+s);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};t.exports=c,c.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:i,pathExtExe:c}=s(e,t),l=[];for(let o=0;o<n.length;o++){let s=n[o],u=/^".*"$/.test(s)?s.slice(1,-1):s,d=r.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<i.length;e++){let n=f+i[e];try{if(a.sync(n,{pathExt:c}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw o(e)}})),Bo=o(((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n})),Vo=o(((e,t)=>{let n=require("path"),r=zo(),i=Bo();function a(e,t){let a=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=r.sync(e.command,{path:a[i({env:a})],pathExt:t?n.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=n.resolve(s?e.options.cwd:``,l),l}function o(e){return a(e)||a(e,!0)}t.exports=o})),Ho=o(((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i})),Uo=o(((e,t)=>{t.exports=/^#!(.*)/})),Wo=o(((e,t)=>{let n=Uo();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}})),Go=o(((e,t)=>{let n=require("fs"),r=Wo();function i(e){let t=Buffer.alloc(150),i;try{i=n.openSync(e,`r`),n.readSync(i,t,0,150,0),n.closeSync(i)}catch{}return r(t.toString())}t.exports=i})),Ko=o(((e,t)=>{let n=require("path"),r=Vo(),i=Ho(),a=Go(),o=process.platform===`win32`,s=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(e){e.file=r(e);let t=e.file&&a(e.file);return t?(e.args.unshift(e.file),e.command=t,r(e)):e.file}function u(e){if(!o)return e;let t=l(e),r=!s.test(t);if(e.options.forceShell||r){let r=c.test(t);e.command=n.normalize(e.command),e.command=i.command(e.command),e.args=e.args.map(e=>i.argument(e,r)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function d(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:u(r)}t.exports=d})),qo=o(((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}})),Jo=l(o(((e,t)=>{let n=require("child_process"),r=Ko(),i=qo();function a(e,t,a){let o=r(e,t,a),s=n.spawn(o.command,o.args,o.options);return i.hookChildProcess(s,o),s}function o(e,t,a){let o=r(e,t,a),s=n.spawnSync(o.command,o.args,o.options);return s.error=s.error||i.verifyENOENTSync(s.status,o),s}t.exports=a,t.exports.spawn=a,t.exports.sync=o,t.exports._parse=r,t.exports._enoent=i}))());const Yo=(0,he.promisify)(ce.exec),Xo=(0,he.promisify)(ce.execFile);async function Zo(e,t,n){try{return await Xo(e,t,n)}catch(r){if(process.platform!==`win32`||![`EINVAL`,`ENOENT`].includes(r.code??``))throw r;return await new Promise((r,i)=>{let a=(0,Jo.default)(e,t,{windowsHide:!0,cwd:n?.cwd}),o=``,s=``;a.stdout?.on(`data`,e=>{o+=e.toString()}),a.stderr?.on(`data`,e=>{s+=e.toString()}),a.on(`error`,i),a.on(`close`,t=>{t===0?r({stdout:o,stderr:s}):i(Object.assign(Error(`${e} exited with code ${t}`),{code:t,stdout:o,stderr:s}))})})}}(0,he.promisify)(u.stat);function I(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=Qo(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function Qo(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function $o(e){return e.replace(/%3A/g,`:`).replace(/%40/g,`@`)}function L(e){return f.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function es(e,t){let n=(0,f.normalize)(e),r=(0,f.normalize)(t);return process.platform===`win32`?n.toLowerCase()===r.toLowerCase():n===r}function ts(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1),e.splice(0,0,t)}function ns(e){let t=Object.keys(E).reverse();for(let n of t)if(e.endsWith(E[n]))return rs(E[n]);return e.endsWith(`.scss`)?T.SCSS:``}function rs(e){return e==E.ComponentView?T.HTML:e==E.ComponentStyle||e==E.GlobalStyle?T.SCSS:T.TypeScript}function is(e,t,n,r){return R(e,t,0,e.getText().length,n,r)}function as(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:T.TypeScript,message:(0,p.flattenDiagnosticMessageText)(t,`
|
|
809
|
-
`),code:r};return i&&(c.data=i),c}return
|
|
810
|
-
`),code:i};return a&&(o.data=a),o}function
|
|
811
|
-
`)}}function
|
|
812
|
-
`)}}function
|
|
813
|
-
`)}}function
|
|
814
|
-
`)}}function
|
|
815
|
-
`);let i=
|
|
807
|
+
`?r=`normal`:n(t):r===`string`?(n(t),s===`\\`&&c!==void 0?n(++t):s===i&&(r=a)):s===`"`||s===`'`?(i=s,a=`url`,n(t),r=`string`):s===`(`?(o++,n(t)):s===`)`?(o--,o===0?r=`normal`:n(t)):n(t)}return t.join(``)}var xo=class{languageService;variablesByUri={};variablesByName={};project;constructor(e){this.project=e,this.languageService=(0,ie.getSCSSLanguageService)()}getRenameFileEdits(e,t){return vi.getScssRenameEdits(e.documentUser,t)}async doValidation(e){return this.languageService.doValidation(e.documentUser,this.languageService.parseStylesheet(e.documentUser))}async doComplete(e,t){return this.languageService.doComplete(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async doHover(e,t){return this.languageService.doHover(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser))}async findDefinition(e,t){let n=this.languageService.findDefinition(e.documentUser,t,this.languageService.parseStylesheet(e.documentUser));return n&&[n]}async format(e,t,n){let r={...n,preserveNewLines:!0,spaceAroundSelectorSeparator:!0,insertFinalNewline:!0,insertSpaces:!1,tabSize:4},i=e.documentUser,a=await this.languageService.format(i,t,r);if(a.length==1){let e=i.offsetAt(a[0].range.start),t=i.offsetAt(a[0].range.end),n=i.getText().length;if(e==0&&t==n){let e=await(0,re.default)([(0,ui.default)({order:[`custom-properties`,`dollar-variables`,`declarations`,`at-rules`,`rules`],"properties-order":`alphabetical`})]).process(a[0].newText,{parser:di,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.getGlobalReferences(e.documentUser,t);if(n)return n;let r=this.languageService.parseStylesheet(e.documentUser);return this.languageService.findReferences(e.documentUser,t,r)}getGlobalReferences(e,t,n){let r=e.offsetAt(t),i=bo(e.getText()),a=/--[a-zA-Z0-9_-]+/g,o,s;for(;o=a.exec(i);)if(o.index<=r&&r<=o.index+o[0].length){s=o[0];break}if(!s)return null;let c=this.getDefinition(s);if(!c)return null;let l=[{uri:c.uri,range:c.range}],u=new Map,d=this.project,f=n?[n]:d.getBuilds();for(let e of Object.values(d.scssFiles))u.set(e.file.documentUser.uri,e.file.documentUser);for(let e of f)for(let t of Object.values(e.scssFiles))u.set(t.file.documentUser.uri,t.file.documentUser);u.set(e.uri,e);for(let e of u.values()){let t=bo(e.getText()),n=/var\(\s*(--[a-zA-Z0-9_-]+)/g,r;for(;r=n.exec(t);){if(r[1]!==s)continue;let t=r.index+r[0].lastIndexOf(s);l.push({uri:e.uri,range:{start:e.positionAt(t),end:e.positionAt(t+s.length)}})}}return l.some(t=>t.uri===e.uri&&e.offsetAt(t.range.start)<=r&&r<e.offsetAt(t.range.end))?l:null}onRename(e,t,n){let r=this.getGlobalReferences(e,t);if(!r)return null;let i=n.startsWith(`--`)?n:`--${n}`;if(!/^--[a-zA-Z_][a-zA-Z0-9_-]*$/.test(i))return null;let a={},o=new Set;for(let e of r){let{uri:t,range:n}=e,r=`${t}:${n.start.line}:${n.start.character}:${n.end.line}:${n.end.character}`;o.has(r)||(o.add(r),a[t]||(a[t]=[]),a[t].push({range:n,newText:i}))}return{changes:a}}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.getChildren().some(e=>e.getText().trim()===`:root`)){let i=e.getChild(0),a=e.getChild(1);if(i&&a){let e=i.getText();e.startsWith(`--`)&&(!r[e]||n.offsetAt(r[e].range.start)<i.offset)&&(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)};i((0,ie.getSCSSLanguageService)().parseStylesheet(n)),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]}},So=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 O&&await this.file.validate()}triggerSave(){this.file instanceof O&&this.file.triggerSave()}async triggerContentChange(){this.file instanceof O&&await this.file.triggerContentChange(this.file.documentUser)}async _onValidate(){return await this.onValidate()}async _onDelete(){await this.onDelete(),this.removeEvents()}},Co=class e extends So{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)}getRenameFileEdits(e){return this.project.globalSCSSLanguageService.getRenameFileEdits(this.file,e)}async onContentChange(){this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}async onValidate(){return this.diagnostics=await this.project.globalSCSSLanguageService.doValidation(this.file),this.loadDependencies(),this.diagnosticCompile?[...this.diagnostics,this.diagnosticCompile]:this.diagnostics}async onSave(){this.savedOnce=!0,await this.compileRoot(),this.project.globalSCSSLanguageService.loadVariables(this,this.file.uri)}async compileRoot(){if(Object.values(this.usedBy).length==0)await this.compile();else for(let e in this.usedBy)this.usedBy[e].onSave()}async compile(){try{let e=this.compiledTxt,t=`|error|`,n=e=>{let r=e.contentUser;r=r.replace(/\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*$/gm,`$1`);let i=/@import *?('|")(\S*?)('|");?/g,a=null;for(;a=i.exec(r);){let i=a[2],o=this.resolvePath(i,e.folderPath);if(o){let e=n(o);if(e==t)return e;r=r.replace(a[0],e)}else return t}return r},r=n(this.file);if(r!=`|error|`){let t=e=>{if(F.getInstance().settings.errorByBuild){let t=this.project.getBuilds();for(let n of t)$.sendDiagnostics({uri:this.file.uri,diagnostics:e},n)}else $.sendDiagnostics({uri:this.file.uri,diagnostics:e})};try{let n=(0,ae.compileString)(r,{style:`compressed`}).css.toString().trim();n=n.replace(/\\/g,`\\\\`),e=n,this.diagnosticCompile&&(this.diagnosticCompile=void 0,t(this.diagnostics))}catch(e){e instanceof ae.Exception&&(this.diagnosticCompile=is(this.file.documentUser,e.message),t([...this.diagnostics,this.diagnosticCompile]))}}e!=this.compiledTxt&&(this.compiledVersion++,this.compiledTxt=e,await this.export())}catch(e){console.error(e)}}async onDelete(){for(let e in this.dependencies)this.removeDependency(e);for(let e in this.usedBy)delete this.usedBy[e].dependencies[this.file.uri],delete this.usedBy[e],await this.usedBy[e].onContentChange();this.project.globalSCSSLanguageService.removeVariables(this.file.uri)}async onCompletion(e,t){let n={isIncomplete:!1,items:[]};return n=await this.project.globalSCSSLanguageService.doComplete(e,t),n}async onCompletionResolve(e,t){return t}async onHover(e,t){return this.project.globalSCSSLanguageService.doHover(e,t)}async onDefinition(e,t){return this.project.globalSCSSLanguageService.findDefinition(e,t)}async onFormatting(e,t,n){return this.project.globalSCSSLanguageService.format(e,t,n)}async onCodeAction(e,t){return this.project.globalSCSSLanguageService.doCodeAction(e,t)}async onReferences(e,t){return await this.project.globalSCSSLanguageService.onReferences(e,t)}async onCodeLens(e){return[]}async onRename(e,t,n){return this.project.globalSCSSLanguageService.onRename(e.documentUser,t,n)}async addOutPath(e,t){this.file.shortname.startsWith(`_`)||this.staticNamebyOutPath[e]||(this.staticNamebyOutPath[e]=t,this.savedOnce||await this.onSave(),await this.export())}removeOutPath(e){for(let t of Object.keys(this.staticNamebyOutPath))(0,f.normalize)(t)===(0,f.normalize)(e)&&delete this.staticNamebyOutPath[t]}async export(){for(let e in this.staticNamebyOutPath){let t=(0,f.normalize)(e),n=t.split(f.sep);n.pop();let r=n.join(f.sep);(0,u.existsSync)(r)||(0,u.mkdirSync)(r,{recursive:!0}),await Ts(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(as(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(E.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=z.getInstance().getByPath(e);if(n)return n;let r=e+E.GlobalStyle;if(n=z.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=z.getInstance().getByPath(a),n)return n;let o=a+E.GlobalStyle;if(n=z.getInstance().getByPath(o),n)return n}},wo=class extends Error{constructor(){super(`Mutex disposed while waiting for the lock`),this.name=`MutexDisposedError`}},To=class{waitingList=[];isLocked=!1;waitOne(){return new Promise((e,t)=>{this.isLocked?this.waitingList.push({resolve:e,reject:t}):(this.isLocked=!0,e())})}release(){let e=this.waitingList.shift();e?e.resolve():this.isLocked=!1}dispose(){let e=this.waitingList;this.waitingList=[],this.isLocked=!1;for(let t of e)t.reject(new wo)}},Eo=class{configFile;config=null;builds=[];statics=[];destroyed=!1;_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){let t=a[e]===o[e];if(process.platform===`win32`&&(t=a[e].toLowerCase()===o[e].toLowerCase()),t)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)){let e=n.getLocalWebComponentDefinition(t);if(e)return e}}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=z.getInstance().onNewFile(this.onNewFile.bind(this)),e.folderUri.toLowerCase().endsWith(`/aventus/base/src`)&&(this._isCoreBuild=!0),this.globalSCSSLanguageService=new xo(this),t&&this.loadFiles(),e.validate()}async init(){await this.onConfigSave()}async onValidate(){let e=Qe.getInstance(),t=await e.validate(this.configFile);for(let n of this.builds){let r=n.dependencyCycle;if(!r)continue;let i=r.find(t=>e.getDependencyKeyRange(this.configFile,n.buildConfig.name,t)),a=i?e.getDependencyKeyRange(this.configFile,n.buildConfig.name,i):null;a&&t.push({range:a,severity:m.DiagnosticSeverity.Error,source:`Aventus`,message:`Cycle de dépendances : ${r.join(` → `)}`})}return t}async loadConfig(){let e=[],t=await Qe.getInstance().getConfig(this.configFile,e);if(!this.destroyed){if($.sendDiagnostics({uri:this.configFile.uri,diagnostics:e}),this.config){let e=JSON.stringify(this.config),n=``;if(t&&(n=JSON.stringify(t)),e==n)return;for(let e of this.builds)e.destroy()}this.builds=[],this.config=t}}onConfigSaveMutex=new To;async onConfigSave(){if(!this.destroyed){await this.onConfigSaveMutex.waitOne();try{if(this.destroyed||(await this.loadConfig(),this.destroyed))return;for(let e of this.statics)e.destroy();this.statics=[];for(let e of this.builds)e.destroy();if(this.builds=[],this.config){for(let e of this.config.build){if(this.destroyed)return;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 _o(this,e);if(this.builds.push(t),await t.init(),this.destroyed)return}if(this.config.static)for(let e of this.config.static){if(this.destroyed)return;if(this.staticsAllowed&&!this.staticsAllowed.includes(e.name??``))continue;let t=new yo(this,e);if(this.statics.push(t),await t.export(),this.destroyed)return}}}catch(e){for(let e of this.builds)e.destroy();for(let e of this.statics)e.destroy();throw this.builds=[],this.statics=[],e}finally{this.onConfigSaveMutex.release()}}}async onFormatting(e,t,n){return await Qe.getInstance().format(e,t,n)}async onCompletion(e,t){return await Qe.getInstance().doComplete(e,t)}async onCompletionResolve(e,t){return await Qe.getInstance().doResolve(t)}async onHover(e,t){return await Qe.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}getStaticAt(e){return this.statics[e]}loadFiles(){let e=z.getInstance().getFilesWithExtension(E.GlobalStyle);for(let t of e)this.onNewFile(t)}async onNewFile(e){this.destroyed||e.path.endsWith(E.GlobalStyle)&&(this.scssFiles[e.uri]||(this.scssFiles[e.uri]=new Co(e,this),this.registerOnFileDelete(e)))}registerOnFileDelete(e){this.destroyed||(this.onFileDeleteUUIDs[e.uri]=e.onDelete(this.onFileDelete.bind(this)))}async onFileDelete(e){if(this.destroyed)return;let t=this.onFileDeleteUUIDs[e.uri];t&&(e.removeOnDelete(t),delete this.onFileDeleteUUIDs[e.uri],e.uri.endsWith(E.GlobalStyle)&&delete this.scssFiles[e.uri])}async onRename(e){let t={},n=new Set;for(let r of this.builds){let i=await r.onRename(e,n);for(let e in i)t[e]||(t[e]=[]),t[e]=t[e].concat(i[e])}return t}async buildAll(){let e=[],t=t=>{try{e.push(Promise.resolve(t()))}catch(t){e.push(Promise.reject(t))}};for(let e of this.builds)t(()=>e.build());for(let e of this.statics)t(()=>e.export());await Promise.all(e)}destroy(){if(!this.destroyed){this.destroyed=!0,z.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,t]of Object.entries(this.onFileDeleteUUIDs??{}))this.scssFiles?.[e]?.file.removeOnDelete(t);this.onFileDeleteUUIDs={},this.scssFiles={}}let e=[],t=[];for(let n of this.builds)try{n.destroy()}catch(r){t.push(n),e.push(`Build: ${String(r)}`)}this.builds=t;let n=[];for(let t of this.statics)try{t.destroy()}catch(r){n.push(t),e.push(`Static: ${String(r)}`)}this.statics=n,e.length>0&&$.showErrorMessage(`Project cleanup failed:\n${e.join(`
|
|
808
|
+
`)}`)}},P=class e{static autoLoad=!0;static instance;static getInstance(){return this.instance||=new e,this.instance}projects={};constructor(){z.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(t){if(t.documentUser.uri.endsWith(`/`+E.Config)){let n=t.documentUser.uri.replace(E.Config,E.Template);if(z.getInstance().getByUri(n))return;if(this.projects[t.documentUser.uri])console.error(`a config file with the uri :`+t.documentUser.uri+` is already inside project manager`);else{let n=new Eo(t,e.autoLoad);this.projects[t.documentUser.uri]=n;try{e.autoLoad&&await n.init()}catch(e){n.destroy(),this.projects[t.documentUser.uri]===n&&delete this.projects[t.documentUser.uri],$.showErrorMessage(`Project initialization failed for ${t.documentUser.uri}: ${String(e)}`);return}if(this.projects[t.documentUser.uri]!==n)return;t.onDelete(this.onDeleteFile.bind(this))}}}async onDeleteFile(e){this.projects[e.documentUser.uri]&&(this.projects[e.documentUser.uri].destroy(),delete this.projects[e.documentUser.uri])}getProjectByUri(e){return this.projects[e]}getMatchingBuildsByUri(e){let t=[];for(let n in this.projects){let r=this.projects[n].getMatchingBuildsByUri(e);for(let e of r)t.push(e)}return t}destroyAll(){for(let e in this.projects)this.projects[e].destroy()}async buildAll(){let e=[];for(let t in this.projects)e.push(this.projects[t].buildAll());await Promise.all(e)}async onRename(e){let t={};for(let n in this.projects){let r=this.projects[n],i=await r.onRename(e);this.projects[n]===r&&this.preventDoubleEdit(t,i)}return t}preventDoubleEdit(e,t){for(let n in t){if(e[n]||(e[n]=[]),!n.endsWith(E.ComponentStyle)&&!n.endsWith(E.GlobalStyle)){e[n]=e[n].concat(t[n]);continue}for(let r of t[n])e[n].some(e=>e.newText===r.newText&&e.range.start.line===r.range.start.line&&e.range.start.character===r.range.start.character&&e.range.end.line===r.range.end.line&&e.range.end.character===r.range.end.character)||e[n].push(r)}}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.some(e=>e.name===t&&e.uri===n.getConfigFile().uri)||e.push({name:t,uri:n.getConfigFile().uri})}return e}getAllBuildsWithStory(){let e=[];for(let t in this.projects){let n=this.projects[t],r=n.getBuildsNameWithStory();for(let t of r)e.some(e=>e.name===t&&e.uri===n.getConfigFile().uri)||e.push({name:t,uri:n.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.some(e=>e.name===t&&e.uri===n.getConfigFile().uri)||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.getStaticsName();for(let t=0;t<r.length;t++){let i={name:r[t],index:t,uri:n.getConfigFile().uri};i.name||delete i.name,e.push(i)}}return e}};const Do={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,defaultForceDocumentation:!1,deeplApiKey:``,quickCreations:[],ideBuild:!0};function Oo(){return JSON.parse(JSON.stringify(Do))}const ko={version:`1.3.7`,store:{token:``,username:``}};function Ao(){return JSON.parse(JSON.stringify(ko))}const jo={customData:[]};function Mo(){return JSON.parse(JSON.stringify(jo))}var F=class e{static instance;_settings=Oo();_settingsHtml=Mo();_hiddenSettings=Ao();firstInit=!0;get settings(){return this._settings}get settingsHtml(){return this._settingsHtml}get hiddenSettings(){return this._hiddenSettings}static getInstance(){return this.instance||=new e,this.instance}constructor(){let e=(0,f.join)($.savePath,`config.json`);if((0,u.existsSync)(e)){let t={};try{t=JSON.parse((0,u.readFileSync)(e,`utf8`))}catch{}this._hiddenSettings={...this._hiddenSettings,...t}}}initSettings(e){let t=!1;this.firstInit||`ideBuild`in e&&this._settings.ideBuild!=e.ideBuild&&e.ideBuild&&(t=!0),this._settings=this.mergeDeep(Oo(),e);let n=[...this.cbOnSettingsChange];for(let e of n)e();this.firstInit&&=!1,t&&P.getInstance().buildAll()}setSettings(e,t){$.setSettings(e,t)}setHiddenSettings(e){let{store:t,...n}=e;this._hiddenSettings={...this._hiddenSettings,...n,store:{...this._hiddenSettings.store,...t}},(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(Mo(),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)}},No=class{static get isEnable(){return F.getInstance().settings.useStats}static startSendLoadFile(){this.isEnable&&Os.start(`load_files`)}static sendLoadFile(){this.isEnable&&$.sendNotification(`aventus/statistics/loadFileTime`,Os.stop(`load_files`))}static startSendBuildTime(e){this.isEnable&&Os.start(`full_build_`+e)}static sendBuildTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/buildTime`,e,Os.stop(`full_build_`+e))}static startSendStaticTime(e){this.isEnable&&Os.start(`full_static_`+e)}static sendStaticTime(e){this.isEnable&&$.sendNotification(`aventus/statistics/staticTime`,e,Os.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)}}},Po=o(((e,t)=>{t.exports=a,a.sync=o;var n=require("fs");function r(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function i(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:r(t,n)}function a(e,t,r){n.stat(e,function(n,a){r(n,n?!1:i(a,e,t))})}function o(e,t){return i(n.statSync(e),e,t)}})),Fo=o(((e,t)=>{t.exports=r,r.sync=i;var n=require("fs");function r(e,t,r){n.stat(e,function(e,n){r(e,e?!1:a(n,t))})}function i(e,t){return a(n.statSync(e),t)}function a(e,t){return e.isFile()&&o(e,t)}function o(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}})),Io=o(((e,t)=>{require("fs");var n=process.platform===`win32`||global.TESTING_WINDOWS?Po():Fo();t.exports=r,r.sync=i;function r(e,t,i){if(typeof t==`function`&&(i=t,t={}),!i){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,i){r(e,t||{},function(e,t){e?i(e):n(t)})})}n(e,t||{},function(e,n){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,n=!1),i(e,n)})}function i(e,t){try{return n.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}})),Lo=o(((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=require("path"),i=n?`;`:`:`,a=Io(),o=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),s=(e,t)=>{let r=t.colon||i,a=e.match(/\//)||n&&e.match(/\\/)?[``]:[...n?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(r)],o=n?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=n?o.split(r):[``];return n&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:a,pathExt:s,pathExtExe:o}},c=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:i,pathExt:c,pathExtExe:l}=s(e,t),u=[],d=n=>new Promise((a,s)=>{if(n===i.length)return t.all&&u.length?a(u):s(o(e));let c=i[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=r.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,o)=>{if(r===c.length)return i(d(n+1));let s=c[r];a(e+s,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+s);else return i(e+s);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};t.exports=c,c.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:i,pathExtExe:c}=s(e,t),l=[];for(let o=0;o<n.length;o++){let s=n[o],u=/^".*"$/.test(s)?s.slice(1,-1):s,d=r.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<i.length;e++){let n=f+i[e];try{if(a.sync(n,{pathExt:c}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw o(e)}})),Ro=o(((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n})),zo=o(((e,t)=>{let n=require("path"),r=Lo(),i=Ro();function a(e,t){let a=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=r.sync(e.command,{path:a[i({env:a})],pathExt:t?n.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=n.resolve(s?e.options.cwd:``,l),l}function o(e){return a(e)||a(e,!0)}t.exports=o})),Bo=o(((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i})),Vo=o(((e,t)=>{t.exports=/^#!(.*)/})),Ho=o(((e,t)=>{let n=Vo();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}})),Uo=o(((e,t)=>{let n=require("fs"),r=Ho();function i(e){let t=Buffer.alloc(150),i;try{i=n.openSync(e,`r`),n.readSync(i,t,0,150,0),n.closeSync(i)}catch{}return r(t.toString())}t.exports=i})),Wo=o(((e,t)=>{let n=require("path"),r=zo(),i=Bo(),a=Uo(),o=process.platform===`win32`,s=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(e){e.file=r(e);let t=e.file&&a(e.file);return t?(e.args.unshift(e.file),e.command=t,r(e)):e.file}function u(e){if(!o)return e;let t=l(e),r=!s.test(t);if(e.options.forceShell||r){let r=c.test(t);e.command=n.normalize(e.command),e.command=i.command(e.command),e.args=e.args.map(e=>i.argument(e,r)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function d(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:u(r)}t.exports=d})),Go=o(((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}})),Ko=l(o(((e,t)=>{let n=require("child_process"),r=Wo(),i=Go();function a(e,t,a){let o=r(e,t,a),s=n.spawn(o.command,o.args,o.options);return i.hookChildProcess(s,o),s}function o(e,t,a){let o=r(e,t,a),s=n.spawnSync(o.command,o.args,o.options);return s.error=s.error||i.verifyENOENTSync(s.status,o),s}t.exports=a,t.exports.spawn=a,t.exports.sync=o,t.exports._parse=r,t.exports._enoent=i}))());const qo=(0,he.promisify)(ce.exec),Jo=(0,he.promisify)(ce.execFile);async function Yo(e,t,n){try{return await Jo(e,t,n)}catch(r){if(process.platform!==`win32`||![`EINVAL`,`ENOENT`].includes(r.code??``))throw r;return await new Promise((r,i)=>{let a=(0,Ko.default)(e,t,{windowsHide:!0,cwd:n?.cwd}),o=``,s=``;a.stdout?.on(`data`,e=>{o+=e.toString()}),a.stderr?.on(`data`,e=>{s+=e.toString()}),a.on(`error`,i),a.on(`close`,t=>{t===0?r({stdout:o,stderr:s}):i(Object.assign(Error(`${e} exited with code ${t}`),{code:t,stdout:o,stderr:s}))})})}}(0,he.promisify)(u.stat);function I(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=Xo(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function Xo(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}function Zo(e){return e.replace(/%3A/g,`:`).replace(/%40/g,`@`)}function L(e){return f.sep===`/`?decodeURIComponent(e.replace(`file://`,``)):decodeURIComponent(e.replace(`file:///`,``))}function Qo(e,t){let n=(0,f.normalize)(e),r=(0,f.normalize)(t);return process.platform===`win32`?n.toLowerCase()===r.toLowerCase():n===r}function $o(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1),e.splice(0,0,t)}function es(e){let t=Object.keys(E).reverse();for(let n of t)if(e.endsWith(E[n]))return ts(E[n]);return e.endsWith(`.scss`)?T.SCSS:``}function ts(e){return e==E.ComponentView?T.HTML:e==E.ComponentStyle||e==E.GlobalStyle?T.SCSS:T.TypeScript}function ns(e,t,n,r){return R(e,t,0,e.getText().length,n,r)}function rs(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:T.TypeScript,message:(0,p.flattenDiagnosticMessageText)(t,`
|
|
809
|
+
`),code:r};return i&&(c.data=i),c}return ns(e,t,r)}function R(e,t,n,r,i,a){let o={range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:T.TypeScript,message:(0,p.flattenDiagnosticMessageText)(t,`
|
|
810
|
+
`),code:i};return a&&(o.data=a),o}function is(e,t){return as(e,t,0,e.getText().length)}function as(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:T.SCSS,message:(0,p.flattenDiagnosticMessageText)(t,`
|
|
811
|
+
`)}}function os(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:T.HTML,message:(0,p.flattenDiagnosticMessageText)(t,`
|
|
812
|
+
`)}}function ss(e,t){return cs(e,t,0,e.getText().length)}function cs(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Error,source:T.I18n,message:(0,p.flattenDiagnosticMessageText)(t,`
|
|
813
|
+
`)}}function ls(e,t,n,r){return{range:m.Range.create(e.positionAt(n),e.positionAt(r)),severity:m.DiagnosticSeverity.Warning,source:T.I18n,message:(0,p.flattenDiagnosticMessageText)(t,`
|
|
814
|
+
`)}}function us(e){let t=e.split(`/`);return t.pop(),t.join(`/`)}function ds(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 fs(e,t){if(!t)return e;let n=t.aliases;for(let t in n)if(!t.startsWith(`@`)){let r=ps(t),i=RegExp(`(?<!\\\\)`+r,`g`);e=e.replace(i,n[t])}return e}function ps(e,t=!1){return t?e.replace(/[\\^$+?.()|[\]{}]/g,`\\$&`):e.replace(/[\\^$*+?.()|[\]{}]/g,`\\$&`)}function ms(e){return e===13||e===10}const hs=/(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g;function gs(e,t){let n=hs,r=t;for(;r>0&&!ms(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 _s(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 vs(e,t,n){e=e.replace(/\[(.*?)\]/g,`.$1`);let r=e.split(`.`);for(let e=0;e<r.length-1;e++){let n=r[e],i=t instanceof Map?t.get(n):t[n];i||(i={},t instanceof Map?t.set(n,i):t[n]=i),t=i}t instanceof Map?t.set(r[r.length-1],n):t[r[r.length-1]]=n}function ys(e,t){if(e===void 0&&(e=``),e=e.replace(/\[(.*?)\]/g,`.$1`),e==``)return t;let n=e=>t instanceof Map?t.get(e):t[e],r=e.split(`.`);for(let e=0;e<r.length-1;e++){let i=r[e],a=n(i);if(!a||typeof a!=`object`)return;t=a}if(!(!t||typeof t!=`object`))return n(r[r.length-1])}function bs(e){return new Promise(t=>setTimeout(t,e))}const xs=new Map;function Ss(e){let t=(0,u.statSync)(e,{bigint:!0});return`${t.size}:${t.mtimeNs}:${t.ctimeNs}`}const Cs=new Map;function ws(e){let t=Cs.get(e);return t||(t=new To,Cs.set(e,t)),t}async function Ts(e,t,n,r,i=5){let a=ws(e);await a.waitOne();for(let o=0;;o++)try{t=t.replace(/\r\n?/g,`
|
|
815
|
+
`);let i=Es(t),o=(0,f.dirname)(e);(0,u.existsSync)(o)||(0,u.mkdirSync)(o,{recursive:!0});let s=xs.get(e),c=(0,u.existsSync)(e),l=!0,d;s?.hash===i&&c&&(d=Ss(e),d===s.signature?l=!1:Es((0,u.readFileSync)(e,`utf8`))===i&&(xs.set(e,{hash:i,signature:d}),l=!1)),l&&((0,u.writeFileSync)(e,t),xs.set(e,{hash:i,signature:d??Ss(e)}),No.sendFileSize(e,t,n,r)),a.release();return}catch(e){if(!(e.code===`EBUSY`||e.code===`EPERM`||e.code===`EACCES`||e.code===`UNKNOWN`)||o>=i)throw a.release(),e;await bs(20*(o+1))}}function Es(e){return(0,_.createHash)(`md5`).update(e).digest(`hex`)}function Ds(e){try{(0,u.existsSync)(e)&&(0,u.unlinkSync)(e)}catch{}}var Os=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]}},ks=class e{static isInit=!1;static send(e){$.sendNotification(`aventus/initStep`,e)}static sendDone(){$.sendNotification(`aventus/initStep`,`Aventus : Done`),e.isInit=!0}},As=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}watcher;pendingEvents=new Map;destroyed=!1;constructor(){F.getInstance().settings.watchFiles&&(this.watcher=(0,me.watch)(` `,{ignored:/(^|[\/\\])\../,persistent:!0}),this.watcher.on(`add`,async e=>void this.onContentChange(e).catch($.error)).on(`change`,async e=>void this.onContentChange(e).catch($.error)).on(`unlink`,async e=>void this.onRemove(e).catch($.error)))}watcheUris=[];watchGeneration=new Map;getWatchGenerationId(e){return this.watchGeneration.get(e)??0}watch(e){if(this.destroyed||this.watcheUris.includes(e)||!this.watcher)return;let t=L(e);this.watcher.add(t),this.watcheUris.push(e)}unwatch(e){let t=this.watcheUris.indexOf(e);t!=-1&&(this.watcheUris.splice(t,1),this.watchGeneration.set(e,this.getWatchGenerationId(e)+1),this.watcher?.unwatch(L(e)))}async onContentChange(e){$.debug(`onContentChange : `+e);let t=I(e);this.watcheUris.includes(t)&&await this.enqueue(t,()=>z.getInstance().applyBatch({created:[],updated:[t],deleted:[]}))}async onRemove(e){let t=I(e);this.watcheUris.includes(t)&&await this.enqueue(t,()=>z.getInstance().applyBatch({created:[],updated:[],deleted:[t]}))}enqueue(e,t){if(this.destroyed)return Promise.resolve();let n=this.pendingEvents,r=n.get(e)??Promise.resolve(),i=this.getWatchGenerationId(e),a=r.catch(()=>{}).then(()=>{if(!this.destroyed&&this.watcheUris.includes(e)&&this.getWatchGenerationId(e)===i)return t()});n.set(e,a);let o=()=>{n.get(e)===a&&n.delete(e)};return a.then(o,o),a}async destroy(){this.destroyed=!0;let t=[...this.pendingEvents.values()];try{await this.watcher?.close()}finally{await Promise.allSettled(t),e.instance=void 0}}},z=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}constructor(){}files={};pendingRegistrations=new Map;pendingTemplateInitializations=new Map;failedTemplateInitializations=new Set;lockedUpdatedUri={};loadingInProgress=!0;mutexPending=new To;pendingTimeout;pendingActions=new Map;clearPendingTimeout(){this.pendingTimeout&&clearTimeout(this.pendingTimeout)}async addPending(e,t){await this.mutexPending.waitOne(),this.pendingActions.set(e,t),this.clearPendingTimeout(),this.pendingTimeout=setTimeout(()=>{this.runPending()},300),this.mutexPending.release()}async runPending(){await this.mutexPending.waitOne();for(let[e,t]of this.pendingActions)try{await t()}catch{}this.pendingActions.clear(),this.mutexPending.release()}preventUpdateUri(e){this.lockedUpdatedUri[e]&&clearTimeout(this.lockedUpdatedUri[e]),this.lockedUpdatedUri[e]=setTimeout(()=>{delete this.lockedUpdatedUri[e]},2e3)}async applyBatch(e){let t=e=>F.getInstance().settings.errorByBuild?e.getBuild():null,n=new Map;for(let r of e.deleted){let e=r.replace(/\/+$/,``)+`/`;for(let i of this.getUris())if(i===r||i.startsWith(e)){let e=this.files[i];e&&n.set(i,t(e))}}try{for(let[e,t]of n)await this.deleteUri(e);let r=new Map;for(let t of e.created){if(this.files[t])continue;let e=es(t);if(!e||!(0,u.existsSync)(L(t)))continue;let i=d.TextDocument.create(t,e,0,(0,u.readFileSync)(L(t),`utf8`));this.clearPendingTimeout(),await this.registerFile(i),r.set(t,i),n.has(t)&&n.delete(t)}for(let i of e.updated){if(this.lockedUpdatedUri[i])continue;let e=es(i);if(!e)continue;let a=L(i);if(!(0,u.existsSync)(a)){let e=this.files[i];e&&n.set(i,t(e)),await this.deleteUri(i);continue}let o=this.files[i]?this.files[i].versionUser+1:0,s=d.TextDocument.create(i,e,o,(0,u.readFileSync)(a,`utf8`));this.clearPendingTimeout(),this.files[i]?await this.onContentChange(s):await this.registerFile(s),r.set(i,s),n.has(i)&&n.delete(i)}for(let e of r.values()){let t=this.files[e.uri];t&&t.versionUser===e.version&&await this.onSave(e)}}finally{for(let[e,t]of n)if(t===null)$.sendDiagnostics({uri:e,diagnostics:[]});else for(let n of t)$.sendDiagnostics({uri:e,diagnostics:[]},n)}}async deleteUri(e){let t=this.files[e];if(t){delete this.files[e];try{await t.triggerDelete()}finally{this.files[e]||As.getInstance().unwatch(e)}}}async loadConfigFileNotSet(e,t,n){for(let r=0;r<e.length;r++){let i=L(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=I(o);if(r[i]==E.Config)return await this.loadConfigFile(e,t,n),!0}}return!1};if(await a(i))return}ks.sendDone()}async loadConfigFile(e,t,n){P.autoLoad=!1;try{let r=L(e);e=I(r);let i=d.TextDocument.create(I(r),E.Config,0,(0,u.readFileSync)(r,`utf8`));this.loadingInProgress=!1,await this.registerFile(i),this.loadingInProgress=!0;let a=P.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=I(i),r=es(e);if(t[n]!=E.Config&&t[n].endsWith(E.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);No.startSendLoadFile(),a.loadFiles(),No.sendLoadFile(),this.loadingInProgress=!1,await a.init()}}}finally{this.loadingInProgress=!1,ks.sendDone()}}async parseWorkspace(e,t){let n=L(e),r=F.getInstance().settings.readDirs,i=e=>!0,a=e=>!0;if(r.length>0){let e=r.map(e=>{let t=e.replace(/\\/g,`/`).replace(/^\/+|\/+$/g,``).split(`/`).filter((e,t)=>e!==`.`||t!==0);return{segments:t.map(e=>RegExp(`^`+ps(e,!0).replace(/\*/g,`[^/]*`)+`$`)),isFile:t[t.length-1].includes(`.`)}}),t=e=>(0,f.relative)(n,e).replace(/\\/g,`/`).split(`/`).filter(Boolean),o=(e,t)=>e.every((e,n)=>t[n]?.test(e)??!1);i=n=>{let r=t(n);for(let t of e)if(r.length<=t.segments.length){if(o(r,t.segments))return!0}else if(!t.isFile&&o(r.slice(0,t.segments.length),t.segments))return!0;return!1},a=n=>{let r=t(n);for(let t of e)if(t.isFile){if(r.length===t.segments.length&&o(r,t.segments))return!0}else if(r.length>t.segments.length&&o(r.slice(0,t.segments.length),t.segments))return!0;return!1}}let o=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 o(i):a(i)&&await t(n[r],i)}};await o(n)}async loadAllAventusConfigFiles(e){let t=[],n=new Set;for(let r=0;r<e.length;r++)await this.parseWorkspace(e[r],async(e,r)=>{let i=I(r),a=es(i);if(e==E.Config){if(n.has(i))return;n.add(i),t.push(new O(d.TextDocument.create(i,a,0,(0,u.readFileSync)(r,`utf8`))))}});return t}async loadAllAventusFiles(e){this.loadingInProgress=!0;let t=[],n=new Set,r=[],i=(e,t)=>{r.push(e+`: `+(t instanceof Error?t.message:String(t)))};try{ks.send(`$(loading~spin) Aventus : Loading files`);for(let r=0;r<e.length;r++)try{await this.parseWorkspace(e[r],async(e,r)=>{let a=I(r);if(!n.has(a)&&!(e!=E.Config&&!e.endsWith(E.Base))){n.add(a);try{let n=es(a),i=(0,u.readFileSync)(r,`utf8`),o=this.files[a];if(o&&o.contentUser===i)return;let s=o?o.versionUser+1:0,c=d.TextDocument.create(a,n,s,i);e==E.Config?t.push(c):await this.registerFile(c)}catch(e){i(a,e)}}})}catch(t){i(e[r],t)}ks.send(`$(loading~spin) Aventus : Register config`),this.loadingInProgress=!1;for(let e of t)try{await this.registerFile(e)}catch(t){i(e.uri,t)}}finally{this.loadingInProgress=!1,ks.sendDone()}r.length>0&&$.showErrorMessage(`Aventus could not load these files:
|
|
816
816
|
`+r.join(`
|
|
817
|
-
`))}async onShutdown(){for(let e in this.files)await this.files[e].triggerDelete(),delete this.files[e],Ms.getInstance().unwatch(e)}async fileExists(e){let t=e.uri;if(t.endsWith(E.Template)){let n=this.pendingTemplateInitializations.get(t);if(n)return n;if(!this.files[t]||this.failedTemplateInitializations.has(t)){let n=(async()=>(this.files[t]||await this.registerFile(e),this.files[t]?(await this.onSave(e),!0):!1))(),r=this.pendingTemplateInitializations;r.set(t,n);try{let e=await n;return this.failedTemplateInitializations.delete(t),e}catch(e){throw this.failedTemplateInitializations.add(t),e}finally{r.delete(t)}}}return!!this.files[t]}async registerFilePackage(e){let t=L(e),n=``;(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`));let r=this.files[e],i=d.TextDocument.create(e,T.Package,r?r.versionUser+1:0,n);return Ms.getInstance().watch(e),r&&r.contentUser===n?r:await this.registerFile(i)}async registerFile(e){$.debug(`registering `+e.uri);let t=this.pendingRegistrations,n=t.get(e.uri),r,i=new Promise(e=>{r=e});t.set(e.uri,i);try{return n&&await n,this.files[e.uri]?await this.files[e.uri].triggerContentChange(e):await this.triggerOnNewFile(e),this.files[e.uri]?($.isIDE||Ms.getInstance().watch(e.uri),this.files[e.uri]):void 0}finally{t.get(e.uri)===i&&t.delete(e.uri),r()}}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.triggerOnNewFile(e),await this.files[e.uri]?.triggerSave()}async onClose(e){(0,u.existsSync)(L(e.uri))||await 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(E.Config))return;let t=new O(e);this.files[e.uri]=t;let n=[];for(let e in this.onNewFileCb)n.push(Promise.resolve().then(()=>this.onNewFileCb[e](t)));let r=(await Promise.allSettled(n)).find(e=>e.status===`rejected`);if(r){try{await t.triggerDelete()}finally{this.files[e.uri]===t&&delete this.files[e.uri]}$.error(`Can't register file `+e.uri+` : `+r.reason)}}onNewFile(e){let t=D();for(;this.onNewFileCb[t]!=null;)t=D();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=D();for(;this.onNewFileCb[t]!=null;)t=D();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[I(e)]}getByUri(e){return this.files[e]}getUris(){return Object.keys(this.files)}},Ns=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}#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`)}};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 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 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 toRgb(t){return this.ic(t,e),{r:t.#e,g:t.#t,b:t.#n}}toHsl(){return e.toHsl(this)}toHex(){return e.toHex(this)}toRgb(){return e.toRgb(this)}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})`;default:return``}}},Ps=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}},Fs=class extends Ps{token;constructor(e,t,n,r,i){super(e,t,n,r),this.token=i}};const Is={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 Ls(...e){let t=``;for(let n=0;n<e.length;n++)t+=e[n][1];return t}const Rs=65533;function zs(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 Bs(e){return e>=48&&e<=57}function Vs(e){return e>=65&&e<=90}function Hs(e){return e>=97&&e<=122}function Us(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function Ws(e){return Hs(e)||Vs(e)}function Gs(e){return Ws(e)||qs(e)||e===95}function Ks(e){return Gs(e)||Bs(e)||e===45}function qs(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||!!Zs(e)||e>=65536}function Js(e){return e===11||e===127||0<=e&&e<=8||14<=e&&e<=31}function Ys(e){return e===10||e===13||e===12}function Xs(e){return e===32||e===10||e===9||e===13||e===12}function Zs(e){return e>=55296&&e<=57343}function Qs(e){return e.source.codePointAt(e.cursor)===92&&!Ys(e.source.codePointAt(e.cursor+1)??-1)}function $s(e,t){return t.source.codePointAt(t.cursor)===45?t.source.codePointAt(t.cursor+1)===45||!!Gs(t.source.codePointAt(t.cursor+1)??-1)||t.source.codePointAt(t.cursor+1)===92&&!Ys(t.source.codePointAt(t.cursor+2)??-1):!!Gs(t.source.codePointAt(t.cursor)??-1)||Qs(t)}function ec(e){return e.source.codePointAt(e.cursor)===43||e.source.codePointAt(e.cursor)===45?!!Bs(e.source.codePointAt(e.cursor+1)??-1)||e.source.codePointAt(e.cursor+1)===46&&Bs(e.source.codePointAt(e.cursor+2)??-1):e.source.codePointAt(e.cursor)===46?Bs(e.source.codePointAt(e.cursor+1)??-1):Bs(e.source.codePointAt(e.cursor)??-1)}function tc(e){return e.source.codePointAt(e.cursor)===47&&e.source.codePointAt(e.cursor+1)===42}function nc(e){return e.source.codePointAt(e.cursor)===45&&e.source.codePointAt(e.cursor+1)===45&&e.source.codePointAt(e.cursor+2)===62}var B,V,rc;function ic(e){switch(e){case B.OpenParen:return B.CloseParen;case B.CloseParen:return B.OpenParen;case B.OpenCurly:return B.CloseCurly;case B.CloseCurly:return B.OpenCurly;case B.OpenSquare:return B.CloseSquare;case B.CloseSquare:return B.OpenSquare;default:return null}}function ac(e){switch(e[0]){case B.OpenParen:return[B.CloseParen,`)`,-1,-1,void 0];case B.CloseParen:return[B.OpenParen,`(`,-1,-1,void 0];case B.OpenCurly:return[B.CloseCurly,`}`,-1,-1,void 0];case B.CloseCurly:return[B.OpenCurly,`{`,-1,-1,void 0];case B.OpenSquare:return[B.CloseSquare,`]`,-1,-1,void 0];case B.CloseSquare:return[B.OpenSquare,`[`,-1,-1,void 0];default:return null}}function oc(e,t){for(t.advanceCodePoint(2);;){let n=t.readCodePoint();if(n===void 0){let n=[B.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new Fs(Is.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[B.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0]}function sc(e,t){let n=t.readCodePoint();if(n===void 0)return e.onParseError(new Ps(Is.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,[`4.3.7. Consume an escaped code point`,`Unexpected EOF`])),Rs;if(Us(n)){let e=[n],r;for(;(r=t.source.codePointAt(t.cursor))!==void 0&&Us(r)&&e.length<6;)e.push(r),t.advanceCodePoint();Xs(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||Zs(i)||i>1114111?Rs:i}return n===0||Zs(n)?Rs:n}function cc(e,t){let n=[];for(;;){let r=t.source.codePointAt(t.cursor)??-1;if(r===0||Zs(r))n.push(Rs),t.advanceCodePoint(+(r>65535)+1);else if(Ks(r))n.push(r),t.advanceCodePoint(+(r>65535)+1);else{if(!Qs(t))return n;t.advanceCodePoint(),n.push(sc(e,t))}}}function lc(e,t){t.advanceCodePoint();let n=t.source.codePointAt(t.cursor);if(n!==void 0&&(Ks(n)||Qs(t))){let n=rc.Unrestricted;$s(0,t)&&(n=rc.ID);let r=cc(e,t);return[B.Hash,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...r),type:n}]}return[B.Delim,`#`,t.representationStart,t.representationEnd,{value:`#`}]}function uc(e,t){let n=V.Integer;for(t.source.codePointAt(t.cursor)!==43&&t.source.codePointAt(t.cursor)!==45||t.advanceCodePoint();Bs(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===46&&Bs(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint(2),n=V.Number;Bs(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===101||t.source.codePointAt(t.cursor)===69){if(Bs(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||!Bs(t.source.codePointAt(t.cursor+2)??-1))return n;t.advanceCodePoint(3)}for(n=V.Number;Bs(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint()}return n}function dc(e,t){let n;{let e=t.source.codePointAt(t.cursor);e===45?n=`-`:e===43&&(n=`+`)}let r=uc(0,t),i=parseFloat(t.source.slice(t.representationStart,t.representationEnd+1));if($s(0,t)){let a=cc(e,t);return[B.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(),[B.Percentage,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n}]):[B.Number,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n,type:r}]}function fc(e){for(;Xs(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return[B.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`})(B||={}),function(e){e.Integer=`integer`,e.Number=`number`}(V||={}),function(e){e.Unrestricted=`unrestricted`,e.ID=`id`}(rc||={});var pc=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 mc(e,t){let n=``,r=t.readCodePoint();for(;;){let i=t.readCodePoint();if(i===void 0){let r=[B.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new Fs(Is.UnexpectedEOFInString,t.representationStart,t.representationEnd,[`4.3.5. Consume a string token`,`Unexpected EOF`],r)),r}if(Ys(i)){t.unreadCodePoint();let n=[B.BadString,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new Fs(Is.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[B.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(i!==92)i===0||Zs(i)?n+=String.fromCodePoint(Rs):n+=String.fromCodePoint(i);else{if(t.source.codePointAt(t.cursor)===void 0)continue;if(Ys(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(sc(e,t))}}}function hc(e){return!(e.length!==3||e[0]!==117&&e[0]!==85||e[1]!==114&&e[1]!==82||e[2]!==108&&e[2]!==76)}function gc(e,t){for(;;){let n=t.source.codePointAt(t.cursor);if(n===void 0)return;if(n===41)return void t.advanceCodePoint();Qs(t)?(t.advanceCodePoint(),sc(e,t)):t.advanceCodePoint()}}function _c(e,t){for(;Xs(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();let n=``;for(;;){if(t.source.codePointAt(t.cursor)===void 0){let r=[B.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new Fs(Is.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(),[B.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(Xs(t.source.codePointAt(t.cursor)??-1)){for(t.advanceCodePoint();Xs(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===void 0){let r=[B.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new Fs(Is.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(),[B.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}]):(gc(e,t),[B.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||Js(r??-1)){gc(e,t);let n=[B.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new Fs(Is.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(Qs(t)){t.advanceCodePoint(),n+=String.fromCodePoint(sc(e,t));continue}gc(e,t);let r=[B.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new Fs(Is.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||Zs(t.source.codePointAt(t.cursor)??-1)?(n+=String.fromCodePoint(Rs),t.advanceCodePoint()):(n+=t.source[t.cursor],t.advanceCodePoint())}}function vc(e,t){let n=cc(e,t);if(t.source.codePointAt(t.cursor)!==40)return[B.Ident,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];if(hc(n)){t.advanceCodePoint();let r=0;for(;;){let e=Xs(t.source.codePointAt(t.cursor)??-1),i=Xs(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),[B.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];break}return _c(e,t)}return t.advanceCodePoint(),[B.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}]}function yc(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&&!Us(e.source.codePointAt(e.cursor+2)??-1))}function bc(e,t){t.advanceCodePoint(2);let n=[],r=[],i;for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&Us(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&&Us(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint();(i=t.source.codePointAt(t.cursor))!==void 0&&r.length<6&&Us(i);)r.push(i),t.advanceCodePoint();if(!r.length){let e=parseInt(String.fromCodePoint(...n),16);return[B.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[B.UnicodeRange,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{startOfRange:a,endOfRange:o}]}function xc(e,t){let n=Sc(e,t),r=[];for(;!n.endOfFile();)r.push(n.nextToken());return r.push(n.nextToken()),r}function Sc(e,t){let n=e.css.valueOf(),r=e.unicodeRangesAllowed??!1,i=new pc(n),a={onParseError:t?.onParseError??Cc};return{nextToken:function(){i.resetRepresentation();let e=i.source.codePointAt(i.cursor);if(e===void 0)return[B.EOF,``,-1,-1,void 0];if(e===47&&tc(i))return oc(a,i);if(r&&(e===117||e===85)&&yc(i))return bc(0,i);if(Gs(e))return vc(a,i);if(Bs(e))return dc(a,i);switch(e){case 44:return i.advanceCodePoint(),[B.Comma,`,`,i.representationStart,i.representationEnd,void 0];case 58:return i.advanceCodePoint(),[B.Colon,`:`,i.representationStart,i.representationEnd,void 0];case 59:return i.advanceCodePoint(),[B.Semicolon,`;`,i.representationStart,i.representationEnd,void 0];case 40:return i.advanceCodePoint(),[B.OpenParen,`(`,i.representationStart,i.representationEnd,void 0];case 41:return i.advanceCodePoint(),[B.CloseParen,`)`,i.representationStart,i.representationEnd,void 0];case 91:return i.advanceCodePoint(),[B.OpenSquare,`[`,i.representationStart,i.representationEnd,void 0];case 93:return i.advanceCodePoint(),[B.CloseSquare,`]`,i.representationStart,i.representationEnd,void 0];case 123:return i.advanceCodePoint(),[B.OpenCurly,`{`,i.representationStart,i.representationEnd,void 0];case 125:return i.advanceCodePoint(),[B.CloseCurly,`}`,i.representationStart,i.representationEnd,void 0];case 39:case 34:return mc(a,i);case 35:return lc(a,i);case 43:case 46:return ec(i)?dc(a,i):(i.advanceCodePoint(),[B.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 fc(i);case 45:return ec(i)?dc(a,i):nc(i)?(i.advanceCodePoint(3),[B.CDC,`-->`,i.representationStart,i.representationEnd,void 0]):$s(0,i)?vc(a,i):(i.advanceCodePoint(),[B.Delim,`-`,i.representationStart,i.representationEnd,{value:`-`}]);case 60:return zs(i)?(i.advanceCodePoint(4),[B.CDO,`<!--`,i.representationStart,i.representationEnd,void 0]):(i.advanceCodePoint(),[B.Delim,`<`,i.representationStart,i.representationEnd,{value:`<`}]);case 64:if(i.advanceCodePoint(),$s(0,i)){let e=cc(a,i);return[B.AtKeyword,i.source.slice(i.representationStart,i.representationEnd+1),i.representationStart,i.representationEnd,{value:String.fromCodePoint(...e)}]}return[B.Delim,`@`,i.representationStart,i.representationEnd,{value:`@`}];case 92:{if(Qs(i))return vc(a,i);i.advanceCodePoint();let e=[B.Delim,`\\`,i.representationStart,i.representationEnd,{value:`\\`}];return a.onParseError(new Fs(Is.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(),[B.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 Cc(){}function wc(e,t){let n=[];for(let e of t)n.push(e.codePointAt(0));let r=Tc(n);r[0]===101&&Dc(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 Tc(e){let t=0;if(e[0]===0)e.splice(0,1,Rs),t=1;else if(e[0]===45&&e[1]===45)t=2;else if(e[0]===45&&e[1])t=2,Gs(e[1])||(t+=Dc(e,1,e[1]));else{if(e[0]===45&&!e[1])return[92,e[0]];Gs(e[0])?t=1:(t=1,t+=Dc(e,0,e[0]))}for(let n=t;n<e.length;n++)e[n]===0?(e.splice(n,1,Rs),n++):Ks(e[n])||(n+=Ec(e,n,e[n]));return e}function Ec(e,t,n){return e.splice(t,1,92,n),1}function Dc(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 Oc=Object.values(B);function kc(e){return!!Array.isArray(e)&&!(e.length<4)&&!!Oc.includes(e[0])&&typeof e[1]==`string`&&typeof e[2]==`number`&&typeof e[3]==`number`}function Ac(e){if(!e)return!1;switch(e[0]){case B.Dimension:case B.Number:case B.Percentage:return!0;default:return!1}}function jc(e){if(!e)return!1;switch(e[0]){case B.Whitespace:case B.Comment:return!0;default:return!1}}function Mc(e){return!!e&&e[0]===B.Colon}function Nc(e){return!!e&&e[0]===B.Comma}function Pc(e){return!!e&&e[0]===B.Comment}function Fc(e){return!!e&&e[0]===B.Delim}function H(e){return!!e&&e[0]===B.Dimension}function Ic(e){return!!e&&e[0]===B.EOF}function Lc(e){return!!e&&e[0]===B.Function}function Rc(e){return!!e&&e[0]===B.Hash}function U(e){return!!e&&e[0]===B.Ident}function W(e){return!!e&&e[0]===B.Number}function G(e){return!!e&&e[0]===B.Percentage}function zc(e){return!!e&&e[0]===B.Semicolon}function Bc(e){return!!e&&e[0]===B.Whitespace}function Vc(e){return!!e&&e[0]===B.OpenParen}function Hc(e){return!!e&&e[0]===B.CloseParen}function Uc(e){return!!e&&e[0]===B.OpenSquare}function Wc(e){return!!e&&e[0]===B.OpenCurly}function Gc(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 Kc=[.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124];
|
|
817
|
+
`))}async onShutdown(){for(let e in this.files)await this.files[e].triggerDelete(),delete this.files[e],As.getInstance().unwatch(e)}async fileExists(e){let t=e.uri;if(t.endsWith(E.Template)){let n=this.pendingTemplateInitializations.get(t);if(n)return n;if(!this.files[t]||this.failedTemplateInitializations.has(t)){let n=(async()=>(this.files[t]||await this.registerFile(e),this.files[t]?(await this.onSave(e),!0):!1))(),r=this.pendingTemplateInitializations;r.set(t,n);try{let e=await n;return this.failedTemplateInitializations.delete(t),e}catch(e){throw this.failedTemplateInitializations.add(t),e}finally{r.delete(t)}}}return!!this.files[t]}async registerFilePackage(e){let t=L(e),n=``;(0,u.existsSync)(t)&&(n=(0,u.readFileSync)(t,`utf8`));let r=this.files[e],i=d.TextDocument.create(e,T.Package,r?r.versionUser+1:0,n);return As.getInstance().watch(e),r&&r.contentUser===n?r:await this.registerFile(i)}async registerFile(e){$.debug(`registering `+e.uri);let t=this.pendingRegistrations,n=t.get(e.uri),r,i=new Promise(e=>{r=e});t.set(e.uri,i);try{return n&&await n,this.files[e.uri]?await this.files[e.uri].triggerContentChange(e):await this.triggerOnNewFile(e),this.files[e.uri]?($.isIDE||As.getInstance().watch(e.uri),this.files[e.uri]):void 0}finally{t.get(e.uri)===i&&t.delete(e.uri),r()}}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.triggerOnNewFile(e),await this.files[e.uri]?.triggerSave(),await this.files[e.uri]?.validate()}async onClose(e){(0,u.existsSync)(L(e.uri))||await this.applyBatch({created:[],updated:[],deleted:[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(E.Config))return;let t=new O(e);this.files[e.uri]=t;let n=[];for(let e in this.onNewFileCb)n.push(Promise.resolve().then(()=>this.onNewFileCb[e](t)));let r=(await Promise.allSettled(n)).find(e=>e.status===`rejected`);if(r){try{await t.triggerDelete()}finally{this.files[e.uri]===t&&delete this.files[e.uri]}$.error(`Can't register file `+e.uri+` : `+r.reason)}}onNewFile(e){let t=D();for(;this.onNewFileCb[t]!=null;)t=D();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=D();for(;this.onNewFileCb[t]!=null;)t=D();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[I(e)]}getByUri(e){return this.files[e]}getUris(){return Object.keys(this.files)}},js=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}#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`)}};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 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 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 toRgb(t){return this.ic(t,e),{r:t.#e,g:t.#t,b:t.#n}}toHsl(){return e.toHsl(this)}toHex(){return e.toHex(this)}toRgb(){return e.toRgb(this)}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})`;default:return``}}},Ms=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}},Ns=class extends Ms{token;constructor(e,t,n,r,i){super(e,t,n,r),this.token=i}};const Ps={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 Fs(...e){let t=``;for(let n=0;n<e.length;n++)t+=e[n][1];return t}const Is=65533;function Ls(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 Rs(e){return e>=48&&e<=57}function zs(e){return e>=65&&e<=90}function Bs(e){return e>=97&&e<=122}function Vs(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function Hs(e){return Bs(e)||zs(e)}function Us(e){return Hs(e)||Gs(e)||e===95}function Ws(e){return Us(e)||Rs(e)||e===45}function Gs(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||!!Ys(e)||e>=65536}function Ks(e){return e===11||e===127||0<=e&&e<=8||14<=e&&e<=31}function qs(e){return e===10||e===13||e===12}function Js(e){return e===32||e===10||e===9||e===13||e===12}function Ys(e){return e>=55296&&e<=57343}function Xs(e){return e.source.codePointAt(e.cursor)===92&&!qs(e.source.codePointAt(e.cursor+1)??-1)}function Zs(e,t){return t.source.codePointAt(t.cursor)===45?t.source.codePointAt(t.cursor+1)===45||!!Us(t.source.codePointAt(t.cursor+1)??-1)||t.source.codePointAt(t.cursor+1)===92&&!qs(t.source.codePointAt(t.cursor+2)??-1):!!Us(t.source.codePointAt(t.cursor)??-1)||Xs(t)}function Qs(e){return e.source.codePointAt(e.cursor)===43||e.source.codePointAt(e.cursor)===45?!!Rs(e.source.codePointAt(e.cursor+1)??-1)||e.source.codePointAt(e.cursor+1)===46&&Rs(e.source.codePointAt(e.cursor+2)??-1):e.source.codePointAt(e.cursor)===46?Rs(e.source.codePointAt(e.cursor+1)??-1):Rs(e.source.codePointAt(e.cursor)??-1)}function $s(e){return e.source.codePointAt(e.cursor)===47&&e.source.codePointAt(e.cursor+1)===42}function ec(e){return e.source.codePointAt(e.cursor)===45&&e.source.codePointAt(e.cursor+1)===45&&e.source.codePointAt(e.cursor+2)===62}var B,V,tc;function nc(e){switch(e){case B.OpenParen:return B.CloseParen;case B.CloseParen:return B.OpenParen;case B.OpenCurly:return B.CloseCurly;case B.CloseCurly:return B.OpenCurly;case B.OpenSquare:return B.CloseSquare;case B.CloseSquare:return B.OpenSquare;default:return null}}function rc(e){switch(e[0]){case B.OpenParen:return[B.CloseParen,`)`,-1,-1,void 0];case B.CloseParen:return[B.OpenParen,`(`,-1,-1,void 0];case B.OpenCurly:return[B.CloseCurly,`}`,-1,-1,void 0];case B.CloseCurly:return[B.OpenCurly,`{`,-1,-1,void 0];case B.OpenSquare:return[B.CloseSquare,`]`,-1,-1,void 0];case B.CloseSquare:return[B.OpenSquare,`[`,-1,-1,void 0];default:return null}}function ic(e,t){for(t.advanceCodePoint(2);;){let n=t.readCodePoint();if(n===void 0){let n=[B.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new Ns(Ps.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[B.Comment,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0]}function ac(e,t){let n=t.readCodePoint();if(n===void 0)return e.onParseError(new Ms(Ps.UnexpectedEOFInEscapedCodePoint,t.representationStart,t.representationEnd,[`4.3.7. Consume an escaped code point`,`Unexpected EOF`])),Is;if(Vs(n)){let e=[n],r;for(;(r=t.source.codePointAt(t.cursor))!==void 0&&Vs(r)&&e.length<6;)e.push(r),t.advanceCodePoint();Js(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||Ys(i)||i>1114111?Is:i}return n===0||Ys(n)?Is:n}function oc(e,t){let n=[];for(;;){let r=t.source.codePointAt(t.cursor)??-1;if(r===0||Ys(r))n.push(Is),t.advanceCodePoint(+(r>65535)+1);else if(Ws(r))n.push(r),t.advanceCodePoint(+(r>65535)+1);else{if(!Xs(t))return n;t.advanceCodePoint(),n.push(ac(e,t))}}}function sc(e,t){t.advanceCodePoint();let n=t.source.codePointAt(t.cursor);if(n!==void 0&&(Ws(n)||Xs(t))){let n=tc.Unrestricted;Zs(0,t)&&(n=tc.ID);let r=oc(e,t);return[B.Hash,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...r),type:n}]}return[B.Delim,`#`,t.representationStart,t.representationEnd,{value:`#`}]}function cc(e,t){let n=V.Integer;for(t.source.codePointAt(t.cursor)!==43&&t.source.codePointAt(t.cursor)!==45||t.advanceCodePoint();Rs(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===46&&Rs(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint(2),n=V.Number;Rs(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===101||t.source.codePointAt(t.cursor)===69){if(Rs(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||!Rs(t.source.codePointAt(t.cursor+2)??-1))return n;t.advanceCodePoint(3)}for(n=V.Number;Rs(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint()}return n}function lc(e,t){let n;{let e=t.source.codePointAt(t.cursor);e===45?n=`-`:e===43&&(n=`+`)}let r=cc(0,t),i=parseFloat(t.source.slice(t.representationStart,t.representationEnd+1));if(Zs(0,t)){let a=oc(e,t);return[B.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(),[B.Percentage,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n}]):[B.Number,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:i,signCharacter:n,type:r}]}function uc(e){for(;Js(e.source.codePointAt(e.cursor)??-1);)e.advanceCodePoint();return[B.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`})(B||={}),function(e){e.Integer=`integer`,e.Number=`number`}(V||={}),function(e){e.Unrestricted=`unrestricted`,e.ID=`id`}(tc||={});var dc=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 fc(e,t){let n=``,r=t.readCodePoint();for(;;){let i=t.readCodePoint();if(i===void 0){let r=[B.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new Ns(Ps.UnexpectedEOFInString,t.representationStart,t.representationEnd,[`4.3.5. Consume a string token`,`Unexpected EOF`],r)),r}if(qs(i)){t.unreadCodePoint();let n=[B.BadString,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new Ns(Ps.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[B.String,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(i!==92)i===0||Ys(i)?n+=String.fromCodePoint(Is):n+=String.fromCodePoint(i);else{if(t.source.codePointAt(t.cursor)===void 0)continue;if(qs(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(ac(e,t))}}}function pc(e){return!(e.length!==3||e[0]!==117&&e[0]!==85||e[1]!==114&&e[1]!==82||e[2]!==108&&e[2]!==76)}function mc(e,t){for(;;){let n=t.source.codePointAt(t.cursor);if(n===void 0)return;if(n===41)return void t.advanceCodePoint();Xs(t)?(t.advanceCodePoint(),ac(e,t)):t.advanceCodePoint()}}function hc(e,t){for(;Js(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();let n=``;for(;;){if(t.source.codePointAt(t.cursor)===void 0){let r=[B.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new Ns(Ps.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(),[B.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];if(Js(t.source.codePointAt(t.cursor)??-1)){for(t.advanceCodePoint();Js(t.source.codePointAt(t.cursor)??-1);)t.advanceCodePoint();if(t.source.codePointAt(t.cursor)===void 0){let r=[B.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}];return e.onParseError(new Ns(Ps.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(),[B.URL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:n}]):(mc(e,t),[B.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||Ks(r??-1)){mc(e,t);let n=[B.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new Ns(Ps.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(Xs(t)){t.advanceCodePoint(),n+=String.fromCodePoint(ac(e,t));continue}mc(e,t);let r=[B.BadURL,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,void 0];return e.onParseError(new Ns(Ps.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||Ys(t.source.codePointAt(t.cursor)??-1)?(n+=String.fromCodePoint(Is),t.advanceCodePoint()):(n+=t.source[t.cursor],t.advanceCodePoint())}}function gc(e,t){let n=oc(e,t);if(t.source.codePointAt(t.cursor)!==40)return[B.Ident,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];if(pc(n)){t.advanceCodePoint();let r=0;for(;;){let e=Js(t.source.codePointAt(t.cursor)??-1),i=Js(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),[B.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}];break}return hc(e,t)}return t.advanceCodePoint(),[B.Function,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCodePoint(...n)}]}function _c(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&&!Vs(e.source.codePointAt(e.cursor+2)??-1))}function vc(e,t){t.advanceCodePoint(2);let n=[],r=[],i;for(;(i=t.source.codePointAt(t.cursor))!==void 0&&n.length<6&&Vs(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&&Vs(t.source.codePointAt(t.cursor+1)??-1))for(t.advanceCodePoint();(i=t.source.codePointAt(t.cursor))!==void 0&&r.length<6&&Vs(i);)r.push(i),t.advanceCodePoint();if(!r.length){let e=parseInt(String.fromCodePoint(...n),16);return[B.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[B.UnicodeRange,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{startOfRange:a,endOfRange:o}]}function yc(e,t){let n=bc(e,t),r=[];for(;!n.endOfFile();)r.push(n.nextToken());return r.push(n.nextToken()),r}function bc(e,t){let n=e.css.valueOf(),r=e.unicodeRangesAllowed??!1,i=new dc(n),a={onParseError:t?.onParseError??xc};return{nextToken:function(){i.resetRepresentation();let e=i.source.codePointAt(i.cursor);if(e===void 0)return[B.EOF,``,-1,-1,void 0];if(e===47&&$s(i))return ic(a,i);if(r&&(e===117||e===85)&&_c(i))return vc(0,i);if(Us(e))return gc(a,i);if(Rs(e))return lc(a,i);switch(e){case 44:return i.advanceCodePoint(),[B.Comma,`,`,i.representationStart,i.representationEnd,void 0];case 58:return i.advanceCodePoint(),[B.Colon,`:`,i.representationStart,i.representationEnd,void 0];case 59:return i.advanceCodePoint(),[B.Semicolon,`;`,i.representationStart,i.representationEnd,void 0];case 40:return i.advanceCodePoint(),[B.OpenParen,`(`,i.representationStart,i.representationEnd,void 0];case 41:return i.advanceCodePoint(),[B.CloseParen,`)`,i.representationStart,i.representationEnd,void 0];case 91:return i.advanceCodePoint(),[B.OpenSquare,`[`,i.representationStart,i.representationEnd,void 0];case 93:return i.advanceCodePoint(),[B.CloseSquare,`]`,i.representationStart,i.representationEnd,void 0];case 123:return i.advanceCodePoint(),[B.OpenCurly,`{`,i.representationStart,i.representationEnd,void 0];case 125:return i.advanceCodePoint(),[B.CloseCurly,`}`,i.representationStart,i.representationEnd,void 0];case 39:case 34:return fc(a,i);case 35:return sc(a,i);case 43:case 46:return Qs(i)?lc(a,i):(i.advanceCodePoint(),[B.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 uc(i);case 45:return Qs(i)?lc(a,i):ec(i)?(i.advanceCodePoint(3),[B.CDC,`-->`,i.representationStart,i.representationEnd,void 0]):Zs(0,i)?gc(a,i):(i.advanceCodePoint(),[B.Delim,`-`,i.representationStart,i.representationEnd,{value:`-`}]);case 60:return Ls(i)?(i.advanceCodePoint(4),[B.CDO,`<!--`,i.representationStart,i.representationEnd,void 0]):(i.advanceCodePoint(),[B.Delim,`<`,i.representationStart,i.representationEnd,{value:`<`}]);case 64:if(i.advanceCodePoint(),Zs(0,i)){let e=oc(a,i);return[B.AtKeyword,i.source.slice(i.representationStart,i.representationEnd+1),i.representationStart,i.representationEnd,{value:String.fromCodePoint(...e)}]}return[B.Delim,`@`,i.representationStart,i.representationEnd,{value:`@`}];case 92:{if(Xs(i))return gc(a,i);i.advanceCodePoint();let e=[B.Delim,`\\`,i.representationStart,i.representationEnd,{value:`\\`}];return a.onParseError(new Ns(Ps.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(),[B.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 xc(){}function Sc(e,t){let n=[];for(let e of t)n.push(e.codePointAt(0));let r=Cc(n);r[0]===101&&Tc(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 Cc(e){let t=0;if(e[0]===0)e.splice(0,1,Is),t=1;else if(e[0]===45&&e[1]===45)t=2;else if(e[0]===45&&e[1])t=2,Us(e[1])||(t+=Tc(e,1,e[1]));else{if(e[0]===45&&!e[1])return[92,e[0]];Us(e[0])?t=1:(t=1,t+=Tc(e,0,e[0]))}for(let n=t;n<e.length;n++)e[n]===0?(e.splice(n,1,Is),n++):Ws(e[n])||(n+=wc(e,n,e[n]));return e}function wc(e,t,n){return e.splice(t,1,92,n),1}function Tc(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 Ec=Object.values(B);function Dc(e){return!!Array.isArray(e)&&!(e.length<4)&&!!Ec.includes(e[0])&&typeof e[1]==`string`&&typeof e[2]==`number`&&typeof e[3]==`number`}function Oc(e){if(!e)return!1;switch(e[0]){case B.Dimension:case B.Number:case B.Percentage:return!0;default:return!1}}function kc(e){if(!e)return!1;switch(e[0]){case B.Whitespace:case B.Comment:return!0;default:return!1}}function Ac(e){return!!e&&e[0]===B.Colon}function jc(e){return!!e&&e[0]===B.Comma}function Mc(e){return!!e&&e[0]===B.Comment}function Nc(e){return!!e&&e[0]===B.Delim}function H(e){return!!e&&e[0]===B.Dimension}function Pc(e){return!!e&&e[0]===B.EOF}function Fc(e){return!!e&&e[0]===B.Function}function Ic(e){return!!e&&e[0]===B.Hash}function U(e){return!!e&&e[0]===B.Ident}function W(e){return!!e&&e[0]===B.Number}function G(e){return!!e&&e[0]===B.Percentage}function Lc(e){return!!e&&e[0]===B.Semicolon}function Rc(e){return!!e&&e[0]===B.Whitespace}function zc(e){return!!e&&e[0]===B.OpenParen}function Bc(e){return!!e&&e[0]===B.CloseParen}function Vc(e){return!!e&&e[0]===B.OpenSquare}function Hc(e){return!!e&&e[0]===B.OpenCurly}function Uc(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 Wc=[.955473421488075,-.02309845494876471,.06325924320057072,-.0283697093338637,1.0099953980813041,.021041441191917323,.012314014864481998,-.020507649298898964,1.330365926242124];
|
|
818
818
|
/**
|
|
819
819
|
* Bradford chromatic adaptation from D50 to D65
|
|
820
820
|
*
|
|
821
821
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
822
822
|
* @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).
|
|
823
|
-
*/function
|
|
823
|
+
*/function Gc(e){return Uc(Wc,e)}const Kc=[1.0479297925449969,.022946870601609652,-.05019226628920524,.02962780877005599,.9904344267538799,-.017073799063418826,-.009243040646204504,.015055191490298152,.7518742814281371];
|
|
824
824
|
/**
|
|
825
825
|
* Bradford chromatic adaptation from D65 to D50
|
|
826
826
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
827
827
|
* @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).
|
|
828
828
|
* @see http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html
|
|
829
|
-
*/function
|
|
829
|
+
*/function qc(e){return Uc(Kc,e)}
|
|
830
830
|
/**
|
|
831
831
|
* @param {number} hue - Hue as degrees 0..360
|
|
832
832
|
* @param {number} sat - Saturation as percentage 0..100
|
|
@@ -836,7 +836,7 @@ namespace `+this.buildConfig.module+`{
|
|
|
836
836
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
837
837
|
* @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).
|
|
838
838
|
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hslToRgb.js
|
|
839
|
-
*/function
|
|
839
|
+
*/function Jc(e){let t=e[0]%360,n=e[1]/100,r=e[2]/100;return t<0&&(t+=360),[Yc(0,t,n,r),Yc(8,t,n,r),Yc(4,t,n,r)]}function Yc(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))}
|
|
840
840
|
/**
|
|
841
841
|
* @param {number} hue - Hue as degrees 0..360
|
|
842
842
|
* @param {number} white - Whiteness as percentage 0..100
|
|
@@ -846,31 +846,31 @@ namespace `+this.buildConfig.module+`{
|
|
|
846
846
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
847
847
|
* @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).
|
|
848
848
|
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/hwbToRgb.js
|
|
849
|
-
*/function
|
|
849
|
+
*/function Xc(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=Jc([t,100,50]),a=1-n-r;return[i[0]*a+n,i[1]*a+n,i[2]*a+n]}
|
|
850
850
|
/**
|
|
851
851
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
852
852
|
* @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).
|
|
853
|
-
*/function
|
|
853
|
+
*/function Zc(e){let t=e[2]*Math.PI/180;return[e[0],e[1]*Math.cos(t),e[1]*Math.sin(t)]}
|
|
854
854
|
/**
|
|
855
855
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
856
856
|
* @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).
|
|
857
|
-
*/function
|
|
857
|
+
*/function Qc(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 $c=[.3457/.3585,1,.2958/.3585];
|
|
858
858
|
/**
|
|
859
859
|
* Convert Lab to D50-adapted XYZ
|
|
860
860
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
861
861
|
* @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).
|
|
862
862
|
* @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
|
863
|
-
*/function
|
|
863
|
+
*/function el(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)*$c[0],(e[0]>8?((e[0]+16)/116)**3:e[0]/t)*$c[1],(a**3>n?a**3:(116*a-16)/t)*$c[2]]}
|
|
864
864
|
/**
|
|
865
865
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
866
866
|
* @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).
|
|
867
867
|
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
|
868
|
-
*/function
|
|
868
|
+
*/function tl(e){let t=e[2]*Math.PI/180;return[e[0],e[1]*Math.cos(t),e[1]*Math.sin(t)]}
|
|
869
869
|
/**
|
|
870
870
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
871
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).
|
|
872
872
|
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
|
873
|
-
*/function
|
|
873
|
+
*/function nl(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 rl=[1.2268798758459243,-.5578149944602171,.2813910456659647,-.0405757452148008,1.112286803280317,-.0717110580655164,-.0763729366746601,-.4214933324022432,1.5869240198367816],il=[1,.3963377773761749,.2158037573099136,1,-.1055613458156586,-.0638541728258133,1,-.0894841775298119,-1.2914855480194092];
|
|
874
874
|
/**
|
|
875
875
|
* Given OKLab, convert to XYZ relative to D65
|
|
876
876
|
*
|
|
@@ -878,14 +878,14 @@ namespace `+this.buildConfig.module+`{
|
|
|
878
878
|
* @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
879
|
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js
|
|
880
880
|
*/
|
|
881
|
-
function
|
|
881
|
+
function al(e){let t=Uc(il,e);return Uc(rl,[t[0]**3,t[1]**3,t[2]**3])}
|
|
882
882
|
/**
|
|
883
883
|
* Assuming XYZ is relative to D50, convert to CIE Lab
|
|
884
884
|
* from CIE standard, which now defines these as a rational fraction
|
|
885
885
|
*
|
|
886
886
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
887
887
|
* @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).
|
|
888
|
-
*/function
|
|
888
|
+
*/function ol(e){let t=sl(e[0]/$c[0]),n=sl(e[1]/$c[1]);return[116*n-16,500*(t-n),200*(n-sl(e[2]/$c[2]))]}function sl(e){return e>.008856451679035631?Math.cbrt(e):(903.2962962962963*e+16)/116}const cl=[.819022437996703,.3619062600528904,-.1288737815209879,.0329836539323885,.9292868615863434,.0361446663506424,.0481771893596242,.2642395317527308,.6335478284694309],ll=[.210454268309314,.7936177747023054,-.0040720430116193,1.9779985324311684,-2.42859224204858,.450593709617411,.0259040424655478,.7827717124575296,-.8086757549230774];
|
|
889
889
|
/**
|
|
890
890
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
891
891
|
* @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).
|
|
@@ -893,7 +893,7 @@ function sl(e){let t=Gc(ol,e);return Gc(al,[t[0]**3,t[1]**3,t[2]**3])}
|
|
|
893
893
|
* XYZ <-> LMS matrices recalculated for consistent reference white
|
|
894
894
|
* @see https://github.com/w3c/csswg-drafts/issues/6642#issuecomment-943521484
|
|
895
895
|
*/
|
|
896
|
-
function
|
|
896
|
+
function ul(e){let t=Uc(cl,e);return Uc(ll,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math.cbrt(t[2])])}const dl=[30757411/17917100,-6372589/17917100,-4539589/17917100,-.666684351832489,1.616481236634939,467509/29648200,792561/44930125,-1921689/44930125,.942103121235474],fl=[446124/178915,-333277/357830,-72051/178915,-14852/17905,63121/35810,423/17905,11844/330415,-50337/660830,316169/330415]
|
|
897
897
|
/**
|
|
898
898
|
* Convert XYZ to linear-light rec2020
|
|
899
899
|
*
|
|
@@ -906,7 +906,7 @@ function fl(e){let t=Gc(ul,e);return Gc(dl,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
|
|
|
906
906
|
*
|
|
907
907
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
908
908
|
* @copyright This software or document includes material copied from or derived from https://github.com/w3c/csswg-drafts/blob/main/css-color-4/conversions.js. Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang).
|
|
909
|
-
*/function
|
|
909
|
+
*/function pl(e){return Uc(fl,e)}const ml=[1.3457868816471583,-.25557208737979464,-.05110186497554526,-.5446307051249019,1.5082477428451468,.02052744743642139,0,0,1.2119675456389452],hl=[1829569/896150,-506331/896150,-308931/896150,-851781/878810,1648619/878810,36519/878810,16779/1248040,-147721/1248040,1266979/1248040],gl=[12831/3959,-329/214,-1974/3959,-851781/878810,1648619/878810,36519/878810,705/12673,-2585/12673,705/667]
|
|
910
910
|
/**
|
|
911
911
|
* Convert D50 XYZ to linear-light prophoto-rgb
|
|
912
912
|
*
|
|
@@ -924,14 +924,14 @@ function fl(e){let t=Gc(ul,e);return Gc(dl,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
|
|
|
924
924
|
/**
|
|
925
925
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
926
926
|
* @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).
|
|
927
|
-
*/function
|
|
927
|
+
*/function _l(e){return Uc(gl,e)}
|
|
928
928
|
/**
|
|
929
929
|
* Convert an array of linear-light rec2020 RGB in the range 0.0-1.0
|
|
930
930
|
* to gamma corrected form ITU-R BT.2020-2 p.4
|
|
931
931
|
*
|
|
932
932
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
933
933
|
* @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).
|
|
934
|
-
*/function
|
|
934
|
+
*/function vl(e){return(e<0?-1:1)*Math.abs(e)**(1/2.4)}
|
|
935
935
|
/**
|
|
936
936
|
* Convert an array of linear-light sRGB values in the range 0.0-1.0 to gamma corrected form
|
|
937
937
|
* Extended transfer function:
|
|
@@ -941,14 +941,14 @@ function fl(e){let t=Gc(ul,e);return Gc(dl,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
|
|
|
941
941
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
942
942
|
* @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).
|
|
943
943
|
* @see https://en.wikipedia.org/wiki/SRGB
|
|
944
|
-
*/function
|
|
944
|
+
*/function yl(e){return[bl(e[0]),bl(e[1]),bl(e[2])]}function bl(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}
|
|
945
945
|
/**
|
|
946
946
|
* Convert an array of linear-light display-p3 RGB in the range 0.0-1.0
|
|
947
947
|
* to gamma corrected form
|
|
948
948
|
*
|
|
949
949
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
950
950
|
* @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).
|
|
951
|
-
*/function
|
|
951
|
+
*/function xl(e){return yl(e)}
|
|
952
952
|
/**
|
|
953
953
|
* Convert an array of linear-light prophoto-rgb in the range 0.0-1.0
|
|
954
954
|
* to gamma corrected form.
|
|
@@ -957,14 +957,14 @@ function fl(e){let t=Gc(ul,e);return Gc(dl,[Math.cbrt(t[0]),Math.cbrt(t[1]),Math
|
|
|
957
957
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
958
958
|
* @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).
|
|
959
959
|
*/
|
|
960
|
-
function
|
|
960
|
+
function Sl(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16*e}
|
|
961
961
|
/**
|
|
962
962
|
* Convert an array of linear-light a98-rgb in the range 0.0-1.0
|
|
963
963
|
* to gamma corrected form. Negative values are also now accepted
|
|
964
964
|
*
|
|
965
965
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
966
966
|
* @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).
|
|
967
|
-
*/function
|
|
967
|
+
*/function Cl(e){return(e<0?-1:1)*Math.abs(e)**(256/563)}
|
|
968
968
|
/**
|
|
969
969
|
* Convert an array of rec2020 RGB values in the range 0.0 - 1.0
|
|
970
970
|
* to linear light (un-companded) form.
|
|
@@ -972,7 +972,7 @@ function wl(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16
|
|
|
972
972
|
*
|
|
973
973
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
974
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).
|
|
975
|
-
*/function
|
|
975
|
+
*/function wl(e){return(e<0?-1:1)*Math.abs(e)**2.4}const Tl=[63426534/99577255,20160776/139408157,47086771/278816314,26158966/99577255,.677998071518871,8267143/139408157,0,19567812/697040785,1.0609850577107909];
|
|
976
976
|
/**
|
|
977
977
|
* Convert an array of linear-light rec2020 values to CIE XYZ
|
|
978
978
|
* using D65 (no chromatic adaptation)
|
|
@@ -992,14 +992,14 @@ function wl(e){let t=e<0?-1:1,n=Math.abs(e);return n>=.001953125?t*n**(1/1.8):16
|
|
|
992
992
|
* @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).
|
|
993
993
|
* @see https://en.wikipedia.org/wiki/SRGB
|
|
994
994
|
*/
|
|
995
|
-
function
|
|
995
|
+
function El(e){return[Dl(e[0]),Dl(e[1]),Dl(e[2])]}function Dl(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.04045?e/12.92:t*((n+.055)/1.055)**2.4}
|
|
996
996
|
/**
|
|
997
997
|
* Convert an array of display-p3 RGB values in the range 0.0 - 1.0
|
|
998
998
|
* to linear light (un-companded) form.
|
|
999
999
|
*
|
|
1000
1000
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
1001
1001
|
* @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).
|
|
1002
|
-
*/function
|
|
1002
|
+
*/function Ol(e){return El(e)}const kl=[608311/1250200,189793/714400,198249/1000160,35783/156275,247089/357200,198249/2500400,0,32229/714400,5220557/5000800];
|
|
1003
1003
|
/**
|
|
1004
1004
|
* Convert an array of linear-light display-p3 values to CIE XYZ
|
|
1005
1005
|
* using D65 (no chromatic adaptation)
|
|
@@ -1007,7 +1007,7 @@ function Ol(e){return[kl(e[0]),kl(e[1]),kl(e[2])]}function kl(e){let t=e<0?-1:1,
|
|
|
1007
1007
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
1008
1008
|
* @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).
|
|
1009
1009
|
* @see http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
|
1010
|
-
*/function
|
|
1010
|
+
*/function Al(e){return Uc(kl,e)}
|
|
1011
1011
|
/**
|
|
1012
1012
|
* Convert an array of prophoto-rgb values where in-gamut Colors are in the
|
|
1013
1013
|
* range [0.0 - 1.0] to linear light (un-companded) form. Transfer curve is
|
|
@@ -1016,7 +1016,7 @@ function Ol(e){return[kl(e[0]),kl(e[1]),kl(e[2])]}function kl(e){let t=e<0?-1:1,
|
|
|
1016
1016
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
1017
1017
|
* @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).
|
|
1018
1018
|
*/
|
|
1019
|
-
function
|
|
1019
|
+
function jl(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const Ml=[.7977666449006423,.13518129740053308,.0313477341283922,.2880748288194013,.711835234241873,8993693872564e-17,0,0,.8251046025104602];
|
|
1020
1020
|
/**
|
|
1021
1021
|
* Convert an array of linear-light prophoto-rgb values to CIE D50 XYZ.
|
|
1022
1022
|
* Matrix cannot be expressed in rational form, but is calculated to 64 bit accuracy.
|
|
@@ -1024,7 +1024,7 @@ function Nl(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
|
|
|
1024
1024
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
1025
1025
|
* @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).
|
|
1026
1026
|
* @see see https://github.com/w3c/csswg-drafts/issues/7675
|
|
1027
|
-
*/function
|
|
1027
|
+
*/function Nl(e){return(e<0?-1:1)*Math.abs(e)**(563/256)}const Pl=[573536/994567,263643/1420810,187206/994567,591459/1989134,6239551/9945670,374412/4972835,53769/1989134,351524/4972835,4929758/4972835],Fl=[506752/1228815,87881/245763,12673/70218,87098/409605,175762/245763,12673/175545,7918/409605,87881/737289,1001167/1053270]
|
|
1028
1028
|
/**
|
|
1029
1029
|
* Convert an array of linear-light a98-rgb values to CIE XYZ
|
|
1030
1030
|
* http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
|
|
@@ -1046,7 +1046,7 @@ function Nl(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
|
|
|
1046
1046
|
*
|
|
1047
1047
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
1048
1048
|
* @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).
|
|
1049
|
-
*/function
|
|
1049
|
+
*/function Il(e){return Uc(Fl,e)}
|
|
1050
1050
|
/**
|
|
1051
1051
|
* Convert an array of gamma-corrected sRGB values in the 0.0 to 1.0 range to HSL.
|
|
1052
1052
|
*
|
|
@@ -1060,7 +1060,7 @@ function Nl(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
|
|
|
1060
1060
|
* @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).
|
|
1061
1061
|
*
|
|
1062
1062
|
* @see https://github.com/w3c/csswg-drafts/blob/main/css-color-4/better-rgbToHsl.js
|
|
1063
|
-
*/function
|
|
1063
|
+
*/function Ll(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 Rl(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 zl(e){let t=e;return t=El(t),t=Il(t),t=qc(t),t}function Bl(e){let t=e;return t=Gc(t),t=_l(t),t=yl(t),t}function Vl(e){let t=e;return t=Jc(t),t=El(t),t=Il(t),t=qc(t),t}function Hl(e){let t=e;return t=Gc(t),t=_l(t),t=yl(t),t=Ll(t),t}function Ul(e){let t=e;return t=Xc(t),t=El(t),t=Il(t),t=qc(t),t}function Wl(e){let t=e;t=Gc(t),t=_l(t);let n=yl(t),r=Math.min(n[0],n[1],n[2]),i=1-Math.max(n[0],n[1],n[2]),a=Rl(n);return r+i>=.99999&&(a=NaN),[a,100*r,100*i]}function Gl(e){let t=e;return t=el(t),t}function Kl(e){let t=e;return t=ol(t),t}function ql(e){let t=e;return t=Zc(t),t=el(t),t}function Jl(e){let t=e;return t=ol(t),t=Qc(t),t}function Yl(e){let t=e;return t=al(t),t=qc(t),t}function Xl(e){let t=e;return t=Gc(t),t=ul(t),t}function Zl(e){let t=e;return t=tl(t),t=al(t),t=qc(t),t}function Ql(e){let t=e;return t=Gc(t),t=ul(t),t=nl(t),t}function $l(e){let t=e;return t=Il(t),t=qc(t),t}function eu(e){let t=e;return t=Gc(t),t=_l(t),t}function tu(e){let t=e;
|
|
1064
1064
|
/**
|
|
1065
1065
|
* Convert an array of a98-rgb values in the range 0.0 - 1.0
|
|
1066
1066
|
* to linear light (un-companded) form. Negative values are also now accepted
|
|
@@ -1068,7 +1068,7 @@ function Nl(e){let t=e<0?-1:1,n=Math.abs(e);return n<=.03125?e/16:t*n**1.8}const
|
|
|
1068
1068
|
* @license W3C https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
1069
1069
|
* @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).
|
|
1070
1070
|
*/
|
|
1071
|
-
var n;return t=[
|
|
1071
|
+
var n;return t=[Nl((n=t)[0]),Nl(n[1]),Nl(n[2])],t=Uc(Pl,t),t=qc(t),t}function nu(e){let t=e;var n;return t=Gc(t),t=Uc(hl,t),t=[Cl((n=t)[0]),Cl(n[1]),Cl(n[2])],t}function ru(e){let t=e;return t=Ol(t),t=Al(t),t=qc(t),t}function iu(e){let t=e;return t=Gc(t),t=pl(t),t=xl(t),t}function au(e){let t=e;return t=Al(t),t=qc(t),t}function ou(e){let t=e;return t=Gc(t),t=pl(t),t}function su(e){let t=e;var n;return t=[wl((n=t)[0]),wl(n[1]),wl(n[2])],t=Uc(Tl,t),t=qc(t),t}function cu(e){let t=e;var n;return t=Gc(t),t=Uc(dl,t),t=[vl((n=t)[0]),vl(n[1]),vl(n[2])],t}function lu(e){let t=e;var n;return t=[jl((n=t)[0]),jl(n[1]),jl(n[2])],t=Uc(Ml,t),t}function uu(e){let t=e;var n;return t=Uc(ml,t),t=[Sl((n=t)[0]),Sl(n[1]),Sl(n[2])],t}function du(e){let t=e;return t=qc(t),t}function fu(e){let t=e;return t=Gc(t),t}function pu(e){return e}function mu(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 hu(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]]}
|
|
1072
1072
|
/**
|
|
1073
1073
|
* @description Calculate deltaE OK which is the simple root sum of squares
|
|
1074
1074
|
* @param {number[]} reference - Array of OKLab values: L as 0..1, a and b as -1..1
|
|
@@ -1081,17 +1081,17 @@ var n;return t=[Fl((n=t)[0]),Fl(n[1]),Fl(n[2])],t=Gc(Il,t),t=Yc(t),t}function iu
|
|
|
1081
1081
|
*/
|
|
1082
1082
|
/**
|
|
1083
1083
|
* @license MIT https://github.com/facelessuser/coloraide/blob/main/LICENSE.md
|
|
1084
|
-
*/function vu(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=yu(o,a);if(!s)break;a=s}return _u(a)}function yu(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 bu={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 xu(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 Su(e,t){let n=xu(e),r=xu(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}var Cu;function wu(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 Tu(e,t){let n=t[0];if(Vc(n)||Wc(n)||Uc(n)){let n=Au(e,t);return{advance:n.advance,node:n.node}}if(Lc(n)){let n=Ou(e,t);return{advance:n.advance,node:n.node}}if(Bc(n)){let n=Mu(e,t);return{advance:n.advance,node:n.node}}if(Pc(n)){let n=Pu(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`})(Cu||={});var Eu=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=wu(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)}},Du=class e extends Eu{type=Cu.Function;name;endToken;constructor(e,t,n){super(),this.name=e,this.endToken=t,this.value=n}getName(){return this.name[4].value}normalize(){Ic(this.endToken)&&(this.endToken=[B.CloseParen,`)`,-1,-1,void 0])}tokens(){return Ic(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=>kc(e)?Ls(e):e.toString()).join(``);return Ls(this.name)+e+Ls(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===Cu.Function}};function Ou(e,t){let n=[],r=1;for(;;){let i=t[r];if(!i||Ic(i))return e.onParseError(new Ps(`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 Du(t[0],i,n)};if(Hc(i))return{advance:r+1,node:new Du(t[0],i,n)};if(jc(i)){let i=Fu(e,t.slice(r));r+=i.advance,n.push(...i.nodes);continue}let a=Tu(e,t.slice(r));r+=a.advance,n.push(a.node)}}var ku=class e extends Eu{type=Cu.SimpleBlock;startToken;endToken;constructor(e,t,n){super(),this.startToken=e,this.endToken=t,this.value=n}normalize(){if(Ic(this.endToken)){let e=ac(this.startToken);e&&(this.endToken=e)}}tokens(){return Ic(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=>kc(e)?Ls(e):e.toString()).join(``);return Ls(this.startToken)+e+Ls(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===Cu.SimpleBlock}};function Au(e,t){let n=ic(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||Ic(a))return e.onParseError(new Ps(`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 ku(t[0],a,r)};if(a[0]===n)return{advance:i+1,node:new ku(t[0],a,r)};if(jc(a)){let n=Fu(e,t.slice(i));i+=n.advance,r.push(...n.nodes);continue}let o=Tu(e,t.slice(i));i+=o.advance,r.push(o.node)}}var ju=class e{type=Cu.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return Ls(...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===Cu.Whitespace}};function Mu(e,t){let n=0;for(;;){let e=t[n];if(!Bc(e))return{advance:n,node:new ju(t.slice(0,n))};n++}}var Nu=class e{type=Cu.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return Ls(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===Cu.Comment}};function Pu(e,t){return{advance:1,node:new Nu(t[0])}}function Fu(e,t){let n=[],r=0;for(;;){if(Bc(t[r])){let e=Mu(0,t.slice(r));r+=e.advance,n.push(e.node);continue}if(!Pc(t[r]))return{advance:r,nodes:n};n.push(new Nu(t[r])),r++}}var K=class e{type=Cu.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===Cu.Token}};function Iu(e,t){let n={onParseError:t?.onParseError??(()=>{})},r=[...e];Ic(r[r.length-1])||r.push([B.EOF,``,r[r.length-1][2],r[r.length-1][3],void 0]);let i=Tu(n,r);if(Ic(r[Math.min(i.advance,r.length-1)]))return i.node;n.onParseError(new Ps(`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 Lu(e,t,n){if(e.length===0)return;let r=wu(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 Ru(e,t,n){e.length!==0&&Lu(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 zu(e,t){for(let n=0;n<e.length;n++)Ru(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 Bu(e){return ku.isSimpleBlockNode(e)}function Vu(e){return Du.isFunctionNode(e)}function Hu(e){return ju.isWhitespaceNode(e)}function Uu(e){return Nu.isCommentNode(e)}function Wu(e){return Hu(e)||Uu(e)}function q(e){return K.isTokenNode(e)}function Gu(e){if(Array.isArray(e)){let t=e[0];if(!t)return[0,0];let n=e[e.length-1]||t;return[Gu(t)[0],Gu(n)[1]]}let t=e.tokens(),n=t[0],r=t[t.length-1];return n&&r?[n[2],r[3]]:[0,0]}var Ku=class extends Error{sourceStart;sourceEnd;constructor(e,t,n){super(e),this.name=`ParseError`,this.sourceStart=t,this.sourceEnd=n}},qu=class extends Ku{componentValues;constructor(e,t){super(e,...Gu(t)),this.componentValues=t}};const Ju={UnexpectedAdditionOfDimensionOrPercentageWithNumber:`Unexpected addition of a dimension or percentage with a number.`,UnexpectedSubtractionOfDimensionOrPercentageWithNumber:`Unexpected subtraction of a dimension or percentage with a number.`},Yu=/[A-Z]/g;function Xu(e){return e.replace(Yu,e=>String.fromCharCode(e.charCodeAt(0)+32))}const Zu={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`},Qu=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]]),$u=new Map([[`deg`,e=>e],[`grad`,e=>e/.9],[`rad`,e=>e/180*Math.PI],[`turn`,e=>e/360]]),ed=new Map([[`deg`,e=>.9*e],[`grad`,e=>e],[`rad`,e=>.9*e/180*Math.PI],[`turn`,e=>.9*e/360]]),td=new Map([[`hz`,e=>e],[`khz`,e=>e/1e3]]),nd=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]]),rd=new Map([[`hz`,e=>1e3*e],[`khz`,e=>e]]),id=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]]),ad=new Map([[`ms`,e=>e],[`s`,e=>e/1e3]]),od=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]]),sd=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]]),cd=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]]),ld=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]]),ud=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]]),dd=new Map([[`ms`,e=>1e3*e],[`s`,e=>e]]),fd=new Map([[`deg`,e=>360*e],[`grad`,e=>360*e/.9],[`rad`,e=>360*e/180*Math.PI],[`turn`,e=>e]]),pd=new Map([[`cm`,Qu],[`mm`,id],[`q`,ld],[`in`,nd],[`pc`,od],[`pt`,sd],[`px`,cd],[`ms`,ad],[`s`,dd],[`deg`,$u],[`grad`,ed],[`rad`,ud],[`turn`,fd],[`hz`,td],[`khz`,rd]]);function md(e,t){if(!H(e)||!H(t))return t;let n=Xu(e[4].unit),r=Xu(t[4].unit);if(n===r)return t;let i=pd.get(r);if(!i)return t;let a=i.get(n);if(!a)return t;let o=a(t[4].value),s=[B.Dimension,``,t[2],t[3],{...t[4],signCharacter:o<0?`-`:void 0,type:Number.isInteger(o)?V.Integer:V.Number,value:o}];return wc(s,e[4].unit),s}function hd(e){if(!H(e))return e;let t=Xu(e[4].unit),n=Zu[t];if(t===n)return e;let r=pd.get(t);if(!r)return e;let i=r.get(n);if(!i)return e;let a=i(e[4].value),o=[B.Dimension,``,e[2],e[3],{...e[4],signCharacter:a<0?`-`:void 0,type:Number.isInteger(a)?V.Integer:V.Number,value:a}];return wc(o,n),o}function gd(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([B.Number,e.toString(),n[2],r[3],{value:e,type:n[4].type===V.Integer&&r[4].type===V.Integer?V.Integer:V.Number}])}if(G(n)&&G(r)){let e=n[4].value+r[4].value;return new K([B.Percentage,e.toString()+`%`,n[2],r[3],{value:e}])}if(H(n)&&H(r)&&(r=md(n,r),Xu(n[4].unit)===Xu(r[4].unit))){let e=n[4].value+r[4].value;return new K([B.Dimension,e.toString()+n[4].unit,n[2],r[3],{value:e,type:n[4].type===V.Integer&&r[4].type===V.Integer?V.Integer:V.Number,unit:n[4].unit}])}return(W(n)&&(H(r)||G(r))||W(r)&&(H(n)||G(n)))&&t.onParseError?.(new qu(Ju.UnexpectedAdditionOfDimensionOrPercentageWithNumber,e)),-1}function _d(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([B.Number,e.toString(),t[2],n[3],{value:e,type:Number.isInteger(e)?V.Integer:V.Number}])}if(G(t)&&W(n)){let e=t[4].value/n[4].value;return new K([B.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([B.Dimension,e.toString()+t[4].unit,t[2],n[3],{value:e,type:Number.isInteger(e)?V.Integer:V.Number,unit:t[4].unit}])}return-1}function vd(e){return!!e&&typeof e==`object`&&`inputs`in e&&Array.isArray(e.inputs)&&`operation`in e}function yd(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=yd(i,t);if(a===-1)return-1;n.push(a)}return e.operation(n,t)}function bd(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([B.Number,e.toString(),t[2],n[3],{value:e,type:t[4].type===V.Integer&&n[4].type===V.Integer?V.Integer:V.Number}])}if(G(t)&&W(n)){let e=t[4].value*n[4].value;return new K([B.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([B.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([B.Dimension,e.toString()+t[4].unit,t[2],n[3],{value:e,type:t[4].type===V.Integer&&n[4].type===V.Integer?V.Integer:V.Number,unit:t[4].unit}])}if(W(t)&&H(n)){let e=t[4].value*n[4].value;return new K([B.Dimension,e.toString()+n[4].unit,t[2],n[3],{value:e,type:t[4].type===V.Integer&&n[4].type===V.Integer?V.Integer:V.Number,unit:n[4].unit}])}return-1}function xd(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=Xu(i[4].value);switch(a){case`e`:e.splice(n,1,new K([B.Number,Math.E.toString(),i[2],i[3],{value:Math.E,type:V.Number}]));break;case`pi`:e.splice(n,1,new K([B.Number,Math.PI.toString(),i[2],i[3],{value:Math.PI,type:V.Number}]));break;case`infinity`:e.splice(n,1,new K([B.Number,`infinity`,i[2],i[3],{value:1/0,type:V.Number}]));break;case`-infinity`:e.splice(n,1,new K([B.Number,`-infinity`,i[2],i[3],{value:-1/0,type:V.Number}]));break;case`nan`:e.splice(n,1,new K([B.Number,`NaN`,i[2],i[3],{value:NaN,type:V.Number}]));break;default:if(t.has(a)){let r=t.get(a);e.splice(n,1,new K(r))}}}return e}function Sd(e){if(e.length!==1)return-1;let t=e[0].value;return Ac(t)?e[0]:-1}function Cd(e,t,n){return H(t)?wd(e,t[4].unit,n):G(t)?Td(e,n):W(t)?Ed(e,n):-1}function wd(e,t,n){let r=e.tokens();return{inputs:[new K([B.Dimension,n.toString()+t,r[0][2],r[r.length-1][3],{value:n,type:Number.isInteger(n)?V.Integer:V.Number,unit:t}])],operation:Sd}}function Td(e,t){let n=e.tokens();return{inputs:[new K([B.Percentage,t.toString()+`%`,n[0][2],n[n.length-1][3],{value:t}])],operation:Sd}}function Ed(e,t){let n=e.tokens();return{inputs:[new K([B.Number,t.toString(),n[0][2],n[n.length-1][3],{value:t,type:Number.isInteger(t)?V.Integer:V.Number}])],operation:Sd}}function Dd(e,t){let n=t.value;return W(n)?wd(e,`rad`,Math.acos(n[4].value)):-1}function Od(e,t){let n=t.value;return W(n)?wd(e,`rad`,Math.asin(n[4].value)):-1}function kd(e,t){let n=t.value;return W(n)?wd(e,`rad`,Math.atan(n[4].value)):-1}function Ad(e){return H(e)||W(e)}function jd(e){if(e.length===0)return!0;let t=e[0];if(!Ac(t))return!1;if(e.length===1)return!0;if(H(t)){let n=Xu(t[4].unit);for(let r=1;r<e.length;r++){let i=e[r];if(t[0]!==i[0]||n!==Xu(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 Md(e,t){return!!Ac(e)&&(H(e)?e[0]===t[0]&&Xu(e[4].unit)===Xu(t[4].unit):e[0]===t[0])}function Nd(e,t,n){let r=t.value;if(!Ad(r))return-1;let i=md(r,n.value);return Md(r,i)?wd(e,`rad`,Math.atan2(r[4].value,i[4].value)):-1}function Pd(e,t,n){let r=t.value;return!Ac(r)||!n.rawPercentages&&G(r)?-1:Cd(e,r,Math.abs(r[4].value))}function Fd(e,t,n,r,i){if(!q(t)||!q(n)||!q(r))return-1;let a=t.value;if(!Ac(a)||!i.rawPercentages&&G(a))return-1;let o=md(a,n.value);if(!Md(a,o))return-1;let s=md(a,r.value);return Md(a,s)?Cd(e,a,Math.max(a[4].value,Math.min(o[4].value,s[4].value))):-1}function Id(e,t){let n=t.value;if(!Ad(n))return-1;let r=n[4].value;if(H(n))switch(n[4].unit.toLowerCase()){case`rad`:break;case`deg`:r=$u.get(`rad`)(n[4].value);break;case`grad`:r=ed.get(`rad`)(n[4].value);break;case`turn`:r=fd.get(`rad`)(n[4].value);break;default:return-1}return r=Math.cos(r),Ed(e,r)}function Ld(e,t){let n=t.value;return W(n)?Ed(e,Math.exp(n[4].value)):-1}function Rd(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!Ac(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>md(r,e.value));if(!jd(i))return-1;let a=i.map(e=>e[4].value);return Cd(e,r,Math.hypot(...a))}function zd(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!Ac(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>md(r,e.value));if(!jd(i))return-1;let a=i.map(e=>e[4].value);return Cd(e,r,Math.max(...a))}function Bd(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!Ac(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>md(r,e.value));if(!jd(i))return-1;let a=i.map(e=>e[4].value);return Cd(e,r,Math.min(...a))}function Vd(e,t,n){let r=t.value;if(!Ac(r))return-1;let i=md(r,n.value);if(!Md(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,Cd(e,r,a)}function Hd(e,t,n){let r=t.value,i=n.value;return!W(r)||!Md(r,i)?-1:Ed(e,r[4].value**+i[4].value)}function Ud(e,t,n){let r=t.value;if(!Ac(r))return-1;let i=md(r,n.value);if(!Md(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,Cd(e,r,a)}function Wd(e,t,n){if(!H(t))return-1;let r=n.devicePixelLength??1,i=[B.Dimension,`${r}px`,t[2],t[3],{value:r,type:V.Integer,unit:`px`}],a=md(i,t);if(!Md(a,i))return-1;if(Number.isInteger(a[4].value/r))return Cd(e,t,t[4].value);if(a[4].value>0){if(a[4].value<r)return Cd(e,t,md(t,i)[4].value);let n=Math.floor(a[4].value/i[4].value)*i[4].value;return a[4].value=n,Cd(e,t,md(t,a)[4].value)}if(Math.abs(a[4].value)<r)return Cd(e,t,-1*md(t,i)[4].value);let o=Math.ceil(a[4].value/i[4].value)*i[4].value;return a[4].value=o,Cd(e,t,md(t,a)[4].value)}function Gd(e,t,n,r,i){let a=n.value;if(!Ac(a)||t===`line-width`&&!H(a)||!i.rawPercentages&&G(a))return-1;let o=md(a,r.value);if(!Md(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=yd(Cd(e,a,s),i);return t===-1?-1:Wd(e,t.value,i)}break}}else s=NaN;return Cd(e,a,s)}function Kd(e,t,n){let r=t.value;return!Ac(r)||!n.rawPercentages&&G(r)?-1:Ed(e,Math.sign(r[4].value))}function qd(e,t){let n=t.value;if(!Ad(n))return-1;let r=n[4].value;if(H(n))switch(Xu(n[4].unit)){case`rad`:break;case`deg`:r=$u.get(`rad`)(n[4].value);break;case`grad`:r=ed.get(`rad`)(n[4].value);break;case`turn`:r=fd.get(`rad`)(n[4].value);break;default:return-1}return r=Math.sin(r),Ed(e,r)}function Jd(e,t){let n=t.value;return W(n)?Ed(e,Math.sqrt(n[4].value)):-1}function Yd(e,t){let n=t.value;if(!Ad(n))return-1;let r=n[4].value,i=0,a=n[4].value;if(H(n))switch(Xu(n[4].unit)){case`rad`:i=ud.get(`deg`)(r);break;case`deg`:i=r,a=$u.get(`rad`)(r);break;case`grad`:i=ed.get(`deg`)(r),a=ed.get(`rad`)(r);break;case`turn`:i=fd.get(`deg`)(r),a=fd.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),Ed(e,a)}function Xd(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([B.Number,e.toString(),n[2],r[3],{value:e,type:n[4].type===V.Integer&&r[4].type===V.Integer?V.Integer:V.Number}])}if(G(n)&&G(r)){let e=n[4].value-r[4].value;return new K([B.Percentage,e.toString()+`%`,n[2],r[3],{value:e}])}if(H(n)&&H(r)&&(r=md(n,r),Xu(n[4].unit)===Xu(r[4].unit))){let e=n[4].value-r[4].value;return new K([B.Dimension,e.toString()+n[4].unit,n[2],r[3],{value:e,type:n[4].type===V.Integer&&r[4].type===V.Integer?V.Integer:V.Number,unit:n[4].unit}])}return(W(n)&&(H(r)||G(r))||W(r)&&(H(n)||G(n)))&&t.onParseError?.(new qu(Ju.UnexpectedSubtractionOfDimensionOrPercentageWithNumber,e)),-1}function Zd(e,t){if(t.length===1){let n=t[0];if(!n||!q(n))return-1;let r=n.value;return W(r)?Ed(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)?Ed(e,Math.log(r[4].value)/Math.log(a[4].value)):-1}return-1}const Qd=/^none$/i;function $d(e){if(Array.isArray(e)){let t=e.filter(e=>!(Hu(e)&&Uu(e)));return t.length===1&&$d(t[0])}if(!q(e))return!1;let t=e.value;return!!U(t)&&Qd.test(t[4].value)}const ef=String.fromCodePoint(0);function tf(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(!Ac(o))return-1;let s=md(o,r.value);if(!Md(o,s))return-1;let c=null;if(i&&(c=md(o,i.value),!Md(o,c)))return-1;if(!Number.isFinite(o[4].value)||!Number.isFinite(s[4].value)||!Number.isFinite(s[4].value-o[4].value))return Cd(e,o,NaN);if(c&&!Number.isFinite(c[4].value))return Cd(e,o,o[4].value);let l=t.fixed===-1?nf(rf([t.dashedIdent?t.dashedIdent:`${a.randomCaching?.propertyName} ${a.randomCaching.propertyN++}`,t.elementShared?``:a.randomCaching.elementID,a.randomCaching.documentID].join(ef))):()=>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 Cd(e,o,Number(n[Math.floor(n.length*i)].toFixed(5)))}let f=l();return Cd(e,o,Number((f*(d-u)+u).toFixed(5)))}function nf(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 rf(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 af=new Map([[`abs`,function(e,t,n){return sf(e,t,n,Pd)}],[`acos`,function(e,t,n){return sf(e,t,n,Dd)}],[`asin`,function(e,t,n){return sf(e,t,n,Od)}],[`atan`,function(e,t,n){return sf(e,t,n,kd)}],[`atan2`,function(e,t,n){return lf(e,t,n,Nd)}],[`calc`,of],[`clamp`,function(e,t,n){let r=xd([...e.value.filter(e=>!Wu(e))],t),i=[],a=[],o=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&Nc(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=$d(i),c=$d(o);if(s&&c)return of(hf(e,a),t,n);let l=yd(of(hf(e,a),t,n),n);if(l===-1)return-1;if(s){let r=yd(of(hf(e,o),t,n),n);return r===-1?-1:Bd((u=e,d=l,f=r,new Du([B.Function,`min(`,u.name[2],u.name[3],{value:`min`}],[B.CloseParen,`)`,u.endToken[2],u.endToken[3],void 0],[d,new K([B.Comma,`,`,...Gu(d),void 0]),f])),[l,r],n)}if(c){let r=yd(of(hf(e,i),t,n),n);return r===-1?-1:zd(gf(e,r,l),[r,l],n)}var u,d,f;let p=yd(of(hf(e,i),t,n),n);if(p===-1)return-1;let m=yd(of(hf(e,o),t,n),n);return m===-1?-1:Fd(e,p,l,m,n)}],[`cos`,function(e,t,n){return sf(e,t,n,Id)}],[`exp`,function(e,t,n){return sf(e,t,n,Ld)}],[`hypot`,function(e,t,n){return df(e,t,n,Rd)}],[`log`,function(e,t,n){return df(e,t,n,Zd)}],[`max`,function(e,t,n){return df(e,t,n,zd)}],[`min`,function(e,t,n){return df(e,t,n,Bd)}],[`mod`,function(e,t,n){return lf(e,t,n,Vd)}],[`pow`,function(e,t,n){return lf(e,t,n,Hd)}],[`random`,function(e,t,n){let r=mf(e,e.value.filter(e=>!Wu(e)),t,n);if(r===-1)return-1;let[i,a]=r,o=ff(e,a,t,n);if(o===-1)return-1;let[s,c,l]=o;return!s||!c?-1:tf(e,i,s,c,l,n)}],[`rem`,function(e,t,n){return lf(e,t,n,Ud)}],[`round`,function(e,t,n){let r=xd([...e.value.filter(e=>!Wu(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(pf.has(e)){i=e;continue}}if(q(n)&&Nc(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=yd(of(hf(e,o),t,n),n);if(c===-1)return-1;if(i===`line-width`){let e=md([B.Dimension,`1px`,c.value[2],c.value[3],{value:1,type:V.Integer,unit:`px`}],c.value);if(!H(e)||e[4].unit!==`px`)return-1}if(!a&&s.length===0){if(i===`line-width`)return Wd(e,c.value,n);s.push(new K([B.Number,`1`,c.value[2],c.value[3],{value:1,type:V.Integer}]))}let l=yd(of(hf(e,s),t,n),n);return l===-1?-1:(i||=`nearest`,Gd(e,i,c,l,n))}],[`sign`,function(e,t,n){return sf(e,t,n,Kd)}],[`sin`,function(e,t,n){return sf(e,t,n,qd)}],[`sqrt`,function(e,t,n){return sf(e,t,n,Jd)}],[`tan`,function(e,t,n){return sf(e,t,n,Yd)}]]);function of(e,t,n){let r=xd([...e.value.filter(e=>!Wu(e))],t);if(r.length===1&&q(r[0]))return{inputs:[r[0]],operation:Sd};let i=0;for(;i<r.length;){let e=r[i];if(Bu(e)&&Vc(e.startToken)){let a=of(e,t,n);if(a===-1)return-1;r.splice(i,1,a);continue}if(Vu(e)){let a=af.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&&vd(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!vd(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!Fc(n)||n[4].value!==`*`&&n[4].value!==`/`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!vd(a))return-1;n[4].value===`*`?r.splice(i,3,{inputs:[e,a],operation:bd}):n[4].value===`/`?r.splice(i,3,{inputs:[e,a],operation:_d}):i++}if(i=0,r.length===1&&vd(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!vd(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!Fc(n)||n[4].value!==`+`&&n[4].value!==`-`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!vd(a))return-1;n[4].value===`+`?r.splice(i,3,{inputs:[e,a],operation:gd}):n[4].value===`-`?r.splice(i,3,{inputs:[e,a],operation:Xd}):i++}return r.length===1&&vd(r[0])?r[0]:-1}function sf(e,t,n,r){let i=cf(e,t,n);return i===-1?-1:r(e,i,n)}function cf(e,t,n){let r=yd(of(hf(e,xd([...e.value.filter(e=>!Wu(e))],t)),t,n),n);return r===-1?-1:r}function lf(e,t,n,r){let i=uf(e,t,n);if(i===-1)return-1;let[a,o]=i;return r(e,a,o,n)}function uf(e,t,n){let r=xd([...e.value.filter(e=>!Wu(e))],t),i=[],a=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&Nc(n.value)){if(e===a)return-1;if(e===i){e=a;continue}return-1}e.push(n)}}let o=yd(of(hf(e,i),t,n),n);if(o===-1)return-1;let s=yd(of(hf(e,a),t,n),n);return s===-1?-1:[o,s]}function df(e,t,n,r){let i=ff(e,e.value,t,n);return i===-1?-1:r(e,i,n)}function ff(e,t,n,r){let i=xd([...t.filter(e=>!Wu(e))],n),a=[];{let t=[],o=[];for(let e=0;e<i.length;e++){let n=i[e];q(n)&&Nc(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=yd(of(hf(e,t[i]),n,r),r);if(o===-1)return-1;a.push(o)}}return a}const pf=new Set([`nearest`,`line-width`,`up`,`down`,`to-zero`]);function mf(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(Nc(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=yd(of(hf(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 hf(e,t){return new Du([B.Function,`calc(`,e.name[2],e.name[3],{value:`calc`}],[B.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],t)}function gf(e,t,n){return new Du([B.Function,`max(`,e.name[2],e.name[3],{value:`max`}],[B.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],[t,new K([B.Comma,`,`,...Gu(t),void 0]),n])}function _f(e){if(e===-1)return-1;if(Vu(e))return e;let t=e.value;return Ac(t)&&Number.isNaN(t[4].value)?W(t)?new Du([B.Function,`calc(`,t[2],t[3],{value:`calc`}],[B.CloseParen,`)`,t[2],t[3],void 0],[new K([B.Ident,`NaN`,t[2],t[3],{value:`NaN`}])]):H(t)?new Du([B.Function,`calc(`,t[2],t[3],{value:`calc`}],[B.CloseParen,`)`,t[2],t[3],void 0],[new K([B.Ident,`NaN`,t[2],t[3],{value:`NaN`}]),new ju([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Delim,`*`,t[2],t[3],{value:`*`}]),new ju([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Dimension,`1`+t[4].unit,t[2],t[3],{value:1,type:V.Integer,unit:t[4].unit}])]):G(t)?new Du([B.Function,`calc(`,t[2],t[3],{value:`calc`}],[B.CloseParen,`)`,t[2],t[3],void 0],[new K([B.Ident,`NaN`,t[2],t[3],{value:`NaN`}]),new ju([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Delim,`*`,t[2],t[3],{value:`*`}]),new ju([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Percentage,`1%`,t[2],t[3],{value:1}])]):-1:e}function vf(e){if(e===-1)return-1;if(Vu(e))return e;let t=e.value;if(!Ac(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 Du([B.Function,`calc(`,t[2],t[3],{value:`calc`}],[B.CloseParen,`)`,t[2],t[3],void 0],[new K([B.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}])]):H(t)?new Du([B.Function,`calc(`,t[2],t[3],{value:`calc`}],[B.CloseParen,`)`,t[2],t[3],void 0],[new K([B.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}]),new ju([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Delim,`*`,t[2],t[3],{value:`*`}]),new ju([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Dimension,`1`+t[4].unit,t[2],t[3],{value:1,type:V.Integer,unit:t[4].unit}])]):new Du([B.Function,`calc(`,t[2],t[3],{value:`calc`}],[B.CloseParen,`)`,t[2],t[3],void 0],[new K([B.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}]),new ju([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Delim,`*`,t[2],t[3],{value:`*`}]),new ju([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Percentage,`1%`,t[2],t[3],{value:1}])])}function yf(e){if(e===-1)return-1;if(Vu(e))return e;let t=e.value;return Ac(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 bf(e,t=13){if(e===-1)return-1;if(t<=0||Vu(e))return e;let n=e.value;if(!Ac(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 xf(e){return e===-1?-1:(Vu(e)||H(e.value)&&(e.value=hd(e.value)),e)}function Sf(e,t){let n=e;return t?.toCanonicalUnits&&(n=xf(n)),n=bf(n,t?.precision),n=yf(n),t?.censorIntoStandardRepresentableValues||(n=_f(n),n=vf(n)),n}function Cf(e){let t=new Map;if(!e)return t;for(let[n,r]of e)if(kc(r))t.set(n,r);else if(typeof r==`string`){let e=Sc({css:r}),i=e.nextToken();if(e.nextToken(),!e.endOfFile()||!Ac(i))continue;t.set(n,i);continue}return t}function wf(e,t){let n=Cf(t?.globals);return Tf(e,e=>{if(!Vu(e))return;let r=af.get(e.getName().toLowerCase());if(!r)return;let i=Sf(yd(r(e,n,t??{}),t??{}),t);return i===-1?void 0:i})}function Tf(e,t){for(let n=0;n<e.length;n++){let r=e[n];Ru(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)&&Fc(a.value)&&(a.value[4].value===`-`||a.value[4].value===`+`)&&i.splice(0,0,new ju([[B.Whitespace,` `,...Gu(e.node),void 0]]));let o=e.parent.value[n+1];!o||Wu(o)||q(o)&&(Nc(o.value)||Mc(o.value)||zc(o.value)||Fc(o.value)&&o.value[4].value!==`-`&&o.value[4].value!==`+`)||i.push(new ju([[B.Whitespace,` `,...Gu(e.node),void 0]])),e.parent.value.splice(n,1,...i)})}return e}const Ef=new Set(af.keys());var J,Y;function Df(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function Of(e){switch(e.colorNotation){case J.HEX:case J.RGB:case J.sRGB:return{...e,colorNotation:J.XYZ_D50,channels:Vl(Df(e.channels))};case J.Linear_sRGB:return{...e,colorNotation:J.XYZ_D50,channels:tu(Df(e.channels))};case J.Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:au(Df(e.channels))};case J.Linear_Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:su(Df(e.channels))};case J.Rec2020:return{...e,colorNotation:J.XYZ_D50,channels:lu(Df(e.channels))};case J.A98_RGB:return{...e,colorNotation:J.XYZ_D50,channels:ru(Df(e.channels))};case J.ProPhoto_RGB:return{...e,colorNotation:J.XYZ_D50,channels:du(Df(e.channels))};case J.HSL:return{...e,colorNotation:J.XYZ_D50,channels:Ul(Df(e.channels))};case J.HWB:return{...e,colorNotation:J.XYZ_D50,channels:Gl(Df(e.channels))};case J.Lab:return{...e,colorNotation:J.XYZ_D50,channels:ql(Df(e.channels))};case J.OKLab:return{...e,colorNotation:J.XYZ_D50,channels:Zl(Df(e.channels))};case J.LCH:return{...e,colorNotation:J.XYZ_D50,channels:Yl(Df(e.channels))};case J.OKLCH:return{...e,colorNotation:J.XYZ_D50,channels:$l(Df(e.channels))};case J.XYZ_D50:return{...e,colorNotation:J.XYZ_D50,channels:hu(Df(e.channels))};case J.XYZ_D65:return{...e,colorNotation:J.XYZ_D50,channels:pu(Df(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 kf=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 Af(e,t){let n={...e};if(e.colorNotation!==t){let e=Of(n);switch(t){case J.HEX:case J.RGB:n.colorNotation=J.RGB,n.channels=Hl(e.channels);break;case J.sRGB:n.colorNotation=J.sRGB,n.channels=Hl(e.channels);break;case J.Linear_sRGB:n.colorNotation=J.Linear_sRGB,n.channels=nu(e.channels);break;case J.Display_P3:n.colorNotation=J.Display_P3,n.channels=ou(e.channels);break;case J.Linear_Display_P3:n.colorNotation=J.Linear_Display_P3,n.channels=cu(e.channels);break;case J.Rec2020:n.colorNotation=J.Rec2020,n.channels=uu(e.channels);break;case J.ProPhoto_RGB:n.colorNotation=J.ProPhoto_RGB,n.channels=fu(e.channels);break;case J.A98_RGB:n.colorNotation=J.A98_RGB,n.channels=iu(e.channels);break;case J.HSL:n.colorNotation=J.HSL,n.channels=Wl(e.channels);break;case J.HWB:n.colorNotation=J.HWB,n.channels=Kl(e.channels);break;case J.Lab:n.colorNotation=J.Lab,n.channels=Jl(e.channels);break;case J.LCH:n.colorNotation=J.LCH,n.channels=Xl(e.channels);break;case J.OKLCH:n.colorNotation=J.OKLCH,n.channels=eu(e.channels);break;case J.OKLab:n.colorNotation=J.OKLab,n.channels=Ql(e.channels);break;case J.XYZ_D50:n.colorNotation=J.XYZ_D50,n.channels=hu(e.channels);break;case J.XYZ_D65:n.colorNotation=J.XYZ_D65,n.channels=mu(e.channels);break;default:throw Error(`Unsupported color notation`)}}else n.channels=Df(e.channels);if(t===e.colorNotation)n.channels=Mf(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else if(kf.has(t)&&kf.has(e.colorNotation))n.channels=Mf(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else switch(t){case J.HSL:switch(e.colorNotation){case J.HWB:n.channels=Mf(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=Mf(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.LCH:case J.OKLCH:n.channels=Mf(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;default:n.channels=Mf(e.channels,[],[],n.channels,[],[])}break;case J.HWB:switch(e.colorNotation){case J.HSL:n.channels=Mf(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=Mf(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;default:n.channels=Mf(e.channels,[],[],n.channels,[],[])}break;case J.Lab:case J.OKLab:switch(e.colorNotation){case J.HSL:n.channels=Mf(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=Mf(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;case J.LCH:case J.OKLCH:n.channels=Mf(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;default:n.channels=Mf(e.channels,[],[],n.channels,[],[])}break;case J.LCH:case J.OKLCH:switch(e.colorNotation){case J.HSL:n.channels=Mf(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;case J.HWB:n.channels=Mf(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.Lab:case J.OKLab:n.channels=Mf(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=Mf(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;default:n.channels=Mf(e.channels,[],[],n.channels,[],[])}break;default:n.channels=Mf(e.channels,[],[],n.channels,[],[])}return n.channels=jf(n.channels,t),n}function jf(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 Mf(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 Nf(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 Pf(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)?[B.Number,`none`,-1,-1,{value:NaN,type:V.Number}]:[B.Number,e.toString(),-1,-1,{value:e,type:V.Number}]}function Z(e,t,n,r){return Math.min(Math.max(e/t,n),r)}const Ff=/[A-Z]/g;function Q(e){return e.replace(Ff,e=>String.fromCharCode(e.charCodeAt(0)+32))}function If(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}const Lf=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`xyz`,`xyz-d50`,`xyz-d65`]);function Rf(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(Hu(p)||Uu(p))for(;Hu(e.value[f+1])||Uu(e.value[f+1]);)f++;else if(d===n&&n.length&&(d=r),d===r&&r.length&&(d=i),q(p)&&Fc(p.value)&&p.value[4].value===`/`){if(d===a)return!1;d=a}else{if(Vu(p)){if(d===a&&Q(p.getName())===`var`){u.syntaxFlags.add(Y.HasVariableAlpha),d.push(p);continue}if(!Ef.has(Q(p.getName())))return!1;let[[e]]=wf([[p]],{censorIntoStandardRepresentableValues:!0,globals:s,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!Ac(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)&&Lf.has(Q(p.value[4].value))){if(c)return!1;c=Q(p.value[4].value),u.colorNotation=zf(c),l&&(l.colorNotation!==u.colorNotation&&(l=Af(l,u.colorNotation)),o=Nf(l),s=Pf(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(;Hu(e.value[f+1])||Uu(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=If(n[0].value,0,u);if(!f||!W(f))return!1;let p=If(r[0].value,1,u);if(!p||!W(p))return!1;let m=If(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=If(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=If(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 zf(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 Bf=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`lab`,`oklab`,`xyz`,`xyz-d50`,`xyz-d65`]),Vf=new Set([`hsl`,`hwb`,`lch`,`oklch`]),Hf=new Set([`shorter`,`longer`,`increasing`,`decreasing`]);function Uf(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(!Wu(s)){if(!(n||q(s)&&U(s.value)&&Q(s.value[4].value)===`in`))return Gf(`oklab`,Wf(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&&Vf.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)||!Nc(s.value))&&!!r&&(i||a?!!(i&&a&&Vf.has(r)&&Hf.has(i))&&qf(r,i,Wf(e.value.slice(o+1),t)):Bf.has(r)?Gf(r,Wf(e.value.slice(o+1),t)):!!Vf.has(r)&&qf(r,`shorter`,Wf(e.value.slice(o+1),t)))}}return!1}function Wf(e,t){let n=[],r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(!Wu(o)){if(!q(o)||!Nc(o.value)){if(!r){let e=t(o);if(e){r=e;continue}}if(!i){if(Vu(o)&&Ef.has(Q(o.getName()))){if([[o]]=wf([[o]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0}),!o||!q(o)||!Ac(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 Gf(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}=$f(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=Af(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=Kf(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 Kf(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=Af(t,e).channels,s=Af(n,e).channels;o[0]=Yf(o[0],s[0]),s[0]=Yf(s[0],o[0]),o[1]=Yf(o[1],s[1]),s[1]=Yf(s[1],o[1]),o[2]=Yf(o[2],s[2]),s[2]=Yf(s[2],o[2]),o[0]=Zf(o[0],i),o[1]=Zf(o[1],i),o[2]=Zf(o[2],i),s[0]=Zf(s[0],a),s[1]=Zf(s[1],a),s[2]=Zf(s[2],a);let c=Xf(i,a,r);return{colorNotation:e,channels:[Qf(Xf(o[0],s[0],r),c),Qf(Xf(o[1],s[1],r),c),Qf(Xf(o[2],s[2],r),c)],alpha:c,syntaxFlags:new Set([Y.ColorMix])}}function qf(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}=$f(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=Af(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=Jf(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 Jf(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=Af(n,e).channels,m=Af(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=Yf(a,o),Number.isNaN(a)&&(a=0),o=Yf(o,a),Number.isNaN(o)&&(o=0),s=Yf(s,c),c=Yf(c,s),l=Yf(l,u),u=Yf(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=Zf(s,d),l=Zf(l,d),c=Zf(c,f),u=Zf(u,f);let g=[0,0,0],_=Xf(d,f,i);switch(e){case J.HSL:case J.HWB:g=[Xf(a,o,i),Qf(Xf(s,c,i),_),Qf(Xf(l,u,i),_)];break;case J.LCH:case J.OKLCH:g=[Qf(Xf(s,c,i),_),Qf(Xf(l,u,i),_),Xf(a,o,i)]}return{colorNotation:e,channels:g,alpha:_,syntaxFlags:new Set([Y.ColorMix])}}function Yf(e,t){return Number.isNaN(e)?t:e}function Xf(e,t,n){return e*(1-n)+t*n}function Zf(e,t){return Number.isNaN(t)?e:Number.isNaN(e)?NaN:e*t}function Qf(e,t){return t===0||Number.isNaN(t)?e:Number.isNaN(e)?NaN:e/t}function $f(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 ep(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 tp(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,[B.Number,t.toString(),e[2],e[3],{value:t,type:V.Number}]}return!1}function np(e,t,n){if(t===0){let t=tp(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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,n.toString(),e[2],e[3],{value:n,type:V.Number}]}return!1}function rp(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.Number}];if(t===0){let t=tp(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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function ip(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(!Hu(n)&&!Uu(n)){if(q(n)&&Nc(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(Vu(n)){if(l===s&&n.getName().toLowerCase()===`var`){c.syntaxFlags.add(Y.HasVariableAlpha),l.push(n);continue}if(!Ef.has(n.getName().toLowerCase()))return!1;let[[e]]=wf([[n]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!Ac(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 ap(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(Hu(r)||Uu(r))for(;Hu(e.value[t+1])||Uu(e.value[t+1]);)t++;else if(p===a&&a.length&&(p=o),p===o&&o.length&&(p=s),q(r)&&Fc(r.value)&&r.value[4].value===`/`){if(p===c)return!1;p=c}else{if(Vu(r)){if(p===c&&r.getName().toLowerCase()===`var`){f.syntaxFlags.add(Y.HasVariableAlpha),p.push(r);continue}if(!Ef.has(r.getName().toLowerCase()))return!1;let[[e]]=wf([[r]],{censorIntoStandardRepresentableValues:!0,globals:u,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!Ac(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(;Hu(e.value[t+1])||Uu(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=Af(d,n)),l=Nf(d),u=Pf(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 op(e,t){if(e.value.some(e=>q(e)&&Nc(e.value))){let t=sp(e);if(!1!==t)return t}{let n=cp(e,t);if(!1!==n)return n}return!1}function sp(e){return ip(e,np,J.HSL,[Y.LegacyHSL])}function cp(e,t){return ap(e,rp,J.HSL,[],t)}function lp(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.Number}];if(t===0){let t=tp(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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function up(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function dp(e,t){return ap(e,up,J.Lab,[],t)}function fp(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.Number}];if(t===2){let t=tp(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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function pp(e,t){return ap(e,fp,J.LCH,[],t)}const mp=new Map;for(let[e,t]of Object.entries(bu))mp.set(e,t);function hp(e){let t=mp.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 gp(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function _p(e,t){return ap(e,gp,J.OKLab,[],t)}function vp(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.Number}];if(t===2){let t=tp(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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function yp(e,t){return ap(e,vp,J.OKLCH,[],t)}function bp(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[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function xp(e,t,n){if(U(e)&&e[4].value.toLowerCase()===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function Sp(e,t){if(e.value.some(e=>q(e)&&Nc(e.value))){let t=Cp(e);if(!1!==t)return(!t.syntaxFlags.has(Y.HasNumberValues)||!t.syntaxFlags.has(Y.HasPercentageValues))&&t}else{let n=wp(e,t);if(!1!==n)return n}return!1}function Cp(e){return ip(e,bp,J.RGB,[Y.LegacyRGB])}function wp(e,t){return ap(e,xp,J.RGB,[],t)}function Tp(e){let t=Hl(e);if(gu(t))return _u(t);let n=e;return n=eu(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),xl(vu(n,Ep,Dp))}function Ep(e){return e=rl(e),e=sl(e),yl(e)}function Dp(e){return e=Rl(e),e=fl(e),il(e)}function Op(e,t){let n=!1;for(let r=0;r<e.value.length;r++){let i=e.value[r];if(!Hu(i)&&!Uu(i)&&(n||(n=t(i),!n)))return!1}if(!n)return!1;n.channels=Df(n.channels),n.channels=Tp(Of(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=Su(n.channels,[1,1,1])>Su(n.channels,[0,0,0])?[1,1,1]:[0,0,0],r}function kp(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(Hu(l)||Uu(l))for(;Hu(e.value[c+1])||Uu(e.value[c+1]);)c++;else if(o&&!i&&!a&&q(l)&&Fc(l.value)&&l.value[4].value===`/`)i=!0;else{if(Vu(l)&&Ef.has(Q(l.getName()))){let[[e]]=wf([[l]],{censorIntoStandardRepresentableValues:!0,globals:r,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!Ac(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=If(l.value,3,s);if(!e||!W(e))return!1;s.alpha=new K(e),a=!0;continue}if(Vu(l)){s.alpha=zu([[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(;Hu(e.value[c+1])||Uu(e.value[c+1]);)c++;if(c++,l=e.value[c],o=t(l),!1===o)return!1;n=Nf(o),r=Pf(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 Ap(e){if(Vu(e))switch(Q(e.getName())){case`rgb`:case`rgba`:return Sp(e,Ap);case`hsl`:case`hsla`:return op(e,Ap);case`hwb`:return t=Ap,ap(e,lp,J.HWB,[],t);case`lab`:return dp(e,Ap);case`lch`:return pp(e,Ap);case`oklab`:return _p(e,Ap);case`oklch`:return yp(e,Ap);case`color`:return Rf(e,Ap);case`color-mix`:return Uf(e,Ap);case`contrast-color`:return Op(e,Ap);case`alpha`:return kp(e,Ap)}var t;if(q(e)){if(Rc(e.value))return ep(e.value);if(U(e.value)){let t=hp(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 jp(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function Mp(e){switch(e.colorNotation){case`hex`:case`rgb`:case`srgb`:return{...e,colorNotation:`xyz-d50`,channels:Vl(jp(e.channels))};case`srgb-linear`:return{...e,colorNotation:`xyz-d50`,channels:tu(jp(e.channels))};case`display-p3`:return{...e,colorNotation:`xyz-d50`,channels:au(jp(e.channels))};case`display-p3-linear`:return{...e,colorNotation:`xyz-d50`,channels:su(jp(e.channels))};case`rec2020`:return{...e,colorNotation:`xyz-d50`,channels:lu(jp(e.channels))};case`a98-rgb`:return{...e,colorNotation:`xyz-d50`,channels:ru(jp(e.channels))};case`prophoto-rgb`:return{...e,colorNotation:`xyz-d50`,channels:du(jp(e.channels))};case`hsl`:return{...e,colorNotation:`xyz-d50`,channels:Ul(jp(e.channels))};case`hwb`:return{...e,colorNotation:`xyz-d50`,channels:Gl(jp(e.channels))};case`lab`:return{...e,colorNotation:`xyz-d50`,channels:ql(jp(e.channels))};case`oklab`:return{...e,colorNotation:`xyz-d50`,channels:Zl(jp(e.channels))};case`lch`:return{...e,colorNotation:`xyz-d50`,channels:Yl(jp(e.channels))};case`oklch`:return{...e,colorNotation:`xyz-d50`,channels:$l(jp(e.channels))};case`xyz-d50`:return{...e,colorNotation:`xyz-d50`,channels:hu(jp(e.channels))};case`xyz-d65`:return{...e,colorNotation:`xyz-d50`,channels:pu(jp(e.channels))};default:throw Error(`Unsupported color notation`)}}function Np(e,t=7){return e=+e,t=+t,Number(e.toPrecision(t))}function Pp(e){let t=Hl(e);if(gu(t))return _u(t);let n=e;return n=eu(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),xl(vu(n,Fp,Ip))}function Fp(e){return e=rl(e),e=sl(e),yl(e)}function Ip(e){return e=Rl(e),e=fl(e),il(e)}var Lp=class e{static colorTxtList=[];static parseColorString(e){try{let t=Iu(xc({css:e}));if(!t)return null;let n=Ap(t);if(n===!1)return null;let r=n.channels;n.colorNotation!==`rgb`&&(r=Pp(Mp(n).channels));let i=Math.min(255,Math.max(0,Math.round(Np(r[0])*255))),a=Math.min(255,Math.max(0,Math.round(Np(r[1])*255))),o=Math.min(255,Math.max(0,Math.round(Np(r[2])*255))),s=1;return typeof n.alpha==`number`&&(s=Math.min(1,Math.max(0,Np(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=e.slice(0,t),r=(n.match(/\n/g)??[]).length,i=n.lastIndexOf(`
|
|
1084
|
+
*/function gu(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=_u(o,a);if(!s)break;a=s}return hu(a)}function _u(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 vu={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 yu(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 bu(e,t){let n=yu(e),r=yu(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}var xu;function Su(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 Cu(e,t){let n=t[0];if(zc(n)||Hc(n)||Vc(n)){let n=Ou(e,t);return{advance:n.advance,node:n.node}}if(Fc(n)){let n=Eu(e,t);return{advance:n.advance,node:n.node}}if(Rc(n)){let n=Au(e,t);return{advance:n.advance,node:n.node}}if(Mc(n)){let n=Mu(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`})(xu||={});var wu=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=Su(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)}},Tu=class e extends wu{type=xu.Function;name;endToken;constructor(e,t,n){super(),this.name=e,this.endToken=t,this.value=n}getName(){return this.name[4].value}normalize(){Pc(this.endToken)&&(this.endToken=[B.CloseParen,`)`,-1,-1,void 0])}tokens(){return Pc(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=>Dc(e)?Fs(e):e.toString()).join(``);return Fs(this.name)+e+Fs(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===xu.Function}};function Eu(e,t){let n=[],r=1;for(;;){let i=t[r];if(!i||Pc(i))return e.onParseError(new Ms(`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 Tu(t[0],i,n)};if(Bc(i))return{advance:r+1,node:new Tu(t[0],i,n)};if(kc(i)){let i=Nu(e,t.slice(r));r+=i.advance,n.push(...i.nodes);continue}let a=Cu(e,t.slice(r));r+=a.advance,n.push(a.node)}}var Du=class e extends wu{type=xu.SimpleBlock;startToken;endToken;constructor(e,t,n){super(),this.startToken=e,this.endToken=t,this.value=n}normalize(){if(Pc(this.endToken)){let e=rc(this.startToken);e&&(this.endToken=e)}}tokens(){return Pc(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=>Dc(e)?Fs(e):e.toString()).join(``);return Fs(this.startToken)+e+Fs(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===xu.SimpleBlock}};function Ou(e,t){let n=nc(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||Pc(a))return e.onParseError(new Ms(`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 Du(t[0],a,r)};if(a[0]===n)return{advance:i+1,node:new Du(t[0],a,r)};if(kc(a)){let n=Nu(e,t.slice(i));i+=n.advance,r.push(...n.nodes);continue}let o=Cu(e,t.slice(i));i+=o.advance,r.push(o.node)}}var ku=class e{type=xu.Whitespace;value;constructor(e){this.value=e}tokens(){return this.value}toString(){return Fs(...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===xu.Whitespace}};function Au(e,t){let n=0;for(;;){let e=t[n];if(!Rc(e))return{advance:n,node:new ku(t.slice(0,n))};n++}}var ju=class e{type=xu.Comment;value;constructor(e){this.value=e}tokens(){return[this.value]}toString(){return Fs(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===xu.Comment}};function Mu(e,t){return{advance:1,node:new ju(t[0])}}function Nu(e,t){let n=[],r=0;for(;;){if(Rc(t[r])){let e=Au(0,t.slice(r));r+=e.advance,n.push(e.node);continue}if(!Mc(t[r]))return{advance:r,nodes:n};n.push(new ju(t[r])),r++}}var K=class e{type=xu.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===xu.Token}};function Pu(e,t){let n={onParseError:t?.onParseError??(()=>{})},r=[...e];Pc(r[r.length-1])||r.push([B.EOF,``,r[r.length-1][2],r[r.length-1][3],void 0]);let i=Cu(n,r);if(Pc(r[Math.min(i.advance,r.length-1)]))return i.node;n.onParseError(new Ms(`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 Fu(e,t,n){if(e.length===0)return;let r=Su(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 Iu(e,t,n){e.length!==0&&Fu(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 Lu(e,t){for(let n=0;n<e.length;n++)Iu(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 Ru(e){return Du.isSimpleBlockNode(e)}function zu(e){return Tu.isFunctionNode(e)}function Bu(e){return ku.isWhitespaceNode(e)}function Vu(e){return ju.isCommentNode(e)}function Hu(e){return Bu(e)||Vu(e)}function q(e){return K.isTokenNode(e)}function Uu(e){if(Array.isArray(e)){let t=e[0];if(!t)return[0,0];let n=e[e.length-1]||t;return[Uu(t)[0],Uu(n)[1]]}let t=e.tokens(),n=t[0],r=t[t.length-1];return n&&r?[n[2],r[3]]:[0,0]}var Wu=class extends Error{sourceStart;sourceEnd;constructor(e,t,n){super(e),this.name=`ParseError`,this.sourceStart=t,this.sourceEnd=n}},Gu=class extends Wu{componentValues;constructor(e,t){super(e,...Uu(t)),this.componentValues=t}};const Ku={UnexpectedAdditionOfDimensionOrPercentageWithNumber:`Unexpected addition of a dimension or percentage with a number.`,UnexpectedSubtractionOfDimensionOrPercentageWithNumber:`Unexpected subtraction of a dimension or percentage with a number.`},qu=/[A-Z]/g;function Ju(e){return e.replace(qu,e=>String.fromCharCode(e.charCodeAt(0)+32))}const Yu={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`},Xu=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]]),Zu=new Map([[`deg`,e=>e],[`grad`,e=>e/.9],[`rad`,e=>e/180*Math.PI],[`turn`,e=>e/360]]),Qu=new Map([[`deg`,e=>.9*e],[`grad`,e=>e],[`rad`,e=>.9*e/180*Math.PI],[`turn`,e=>.9*e/360]]),$u=new Map([[`hz`,e=>e],[`khz`,e=>e/1e3]]),ed=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]]),td=new Map([[`hz`,e=>1e3*e],[`khz`,e=>e]]),nd=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]]),rd=new Map([[`ms`,e=>e],[`s`,e=>e/1e3]]),id=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]]),ad=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]]),od=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]]),sd=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]]),cd=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]]),ld=new Map([[`ms`,e=>1e3*e],[`s`,e=>e]]),ud=new Map([[`deg`,e=>360*e],[`grad`,e=>360*e/.9],[`rad`,e=>360*e/180*Math.PI],[`turn`,e=>e]]),dd=new Map([[`cm`,Xu],[`mm`,nd],[`q`,sd],[`in`,ed],[`pc`,id],[`pt`,ad],[`px`,od],[`ms`,rd],[`s`,ld],[`deg`,Zu],[`grad`,Qu],[`rad`,cd],[`turn`,ud],[`hz`,$u],[`khz`,td]]);function fd(e,t){if(!H(e)||!H(t))return t;let n=Ju(e[4].unit),r=Ju(t[4].unit);if(n===r)return t;let i=dd.get(r);if(!i)return t;let a=i.get(n);if(!a)return t;let o=a(t[4].value),s=[B.Dimension,``,t[2],t[3],{...t[4],signCharacter:o<0?`-`:void 0,type:Number.isInteger(o)?V.Integer:V.Number,value:o}];return Sc(s,e[4].unit),s}function pd(e){if(!H(e))return e;let t=Ju(e[4].unit),n=Yu[t];if(t===n)return e;let r=dd.get(t);if(!r)return e;let i=r.get(n);if(!i)return e;let a=i(e[4].value),o=[B.Dimension,``,e[2],e[3],{...e[4],signCharacter:a<0?`-`:void 0,type:Number.isInteger(a)?V.Integer:V.Number,value:a}];return Sc(o,n),o}function md(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([B.Number,e.toString(),n[2],r[3],{value:e,type:n[4].type===V.Integer&&r[4].type===V.Integer?V.Integer:V.Number}])}if(G(n)&&G(r)){let e=n[4].value+r[4].value;return new K([B.Percentage,e.toString()+`%`,n[2],r[3],{value:e}])}if(H(n)&&H(r)&&(r=fd(n,r),Ju(n[4].unit)===Ju(r[4].unit))){let e=n[4].value+r[4].value;return new K([B.Dimension,e.toString()+n[4].unit,n[2],r[3],{value:e,type:n[4].type===V.Integer&&r[4].type===V.Integer?V.Integer:V.Number,unit:n[4].unit}])}return(W(n)&&(H(r)||G(r))||W(r)&&(H(n)||G(n)))&&t.onParseError?.(new Gu(Ku.UnexpectedAdditionOfDimensionOrPercentageWithNumber,e)),-1}function hd(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([B.Number,e.toString(),t[2],n[3],{value:e,type:Number.isInteger(e)?V.Integer:V.Number}])}if(G(t)&&W(n)){let e=t[4].value/n[4].value;return new K([B.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([B.Dimension,e.toString()+t[4].unit,t[2],n[3],{value:e,type:Number.isInteger(e)?V.Integer:V.Number,unit:t[4].unit}])}return-1}function gd(e){return!!e&&typeof e==`object`&&`inputs`in e&&Array.isArray(e.inputs)&&`operation`in e}function _d(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=_d(i,t);if(a===-1)return-1;n.push(a)}return e.operation(n,t)}function vd(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([B.Number,e.toString(),t[2],n[3],{value:e,type:t[4].type===V.Integer&&n[4].type===V.Integer?V.Integer:V.Number}])}if(G(t)&&W(n)){let e=t[4].value*n[4].value;return new K([B.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([B.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([B.Dimension,e.toString()+t[4].unit,t[2],n[3],{value:e,type:t[4].type===V.Integer&&n[4].type===V.Integer?V.Integer:V.Number,unit:t[4].unit}])}if(W(t)&&H(n)){let e=t[4].value*n[4].value;return new K([B.Dimension,e.toString()+n[4].unit,t[2],n[3],{value:e,type:t[4].type===V.Integer&&n[4].type===V.Integer?V.Integer:V.Number,unit:n[4].unit}])}return-1}function yd(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=Ju(i[4].value);switch(a){case`e`:e.splice(n,1,new K([B.Number,Math.E.toString(),i[2],i[3],{value:Math.E,type:V.Number}]));break;case`pi`:e.splice(n,1,new K([B.Number,Math.PI.toString(),i[2],i[3],{value:Math.PI,type:V.Number}]));break;case`infinity`:e.splice(n,1,new K([B.Number,`infinity`,i[2],i[3],{value:1/0,type:V.Number}]));break;case`-infinity`:e.splice(n,1,new K([B.Number,`-infinity`,i[2],i[3],{value:-1/0,type:V.Number}]));break;case`nan`:e.splice(n,1,new K([B.Number,`NaN`,i[2],i[3],{value:NaN,type:V.Number}]));break;default:if(t.has(a)){let r=t.get(a);e.splice(n,1,new K(r))}}}return e}function bd(e){if(e.length!==1)return-1;let t=e[0].value;return Oc(t)?e[0]:-1}function xd(e,t,n){return H(t)?Sd(e,t[4].unit,n):G(t)?Cd(e,n):W(t)?wd(e,n):-1}function Sd(e,t,n){let r=e.tokens();return{inputs:[new K([B.Dimension,n.toString()+t,r[0][2],r[r.length-1][3],{value:n,type:Number.isInteger(n)?V.Integer:V.Number,unit:t}])],operation:bd}}function Cd(e,t){let n=e.tokens();return{inputs:[new K([B.Percentage,t.toString()+`%`,n[0][2],n[n.length-1][3],{value:t}])],operation:bd}}function wd(e,t){let n=e.tokens();return{inputs:[new K([B.Number,t.toString(),n[0][2],n[n.length-1][3],{value:t,type:Number.isInteger(t)?V.Integer:V.Number}])],operation:bd}}function Td(e,t){let n=t.value;return W(n)?Sd(e,`rad`,Math.acos(n[4].value)):-1}function Ed(e,t){let n=t.value;return W(n)?Sd(e,`rad`,Math.asin(n[4].value)):-1}function Dd(e,t){let n=t.value;return W(n)?Sd(e,`rad`,Math.atan(n[4].value)):-1}function Od(e){return H(e)||W(e)}function kd(e){if(e.length===0)return!0;let t=e[0];if(!Oc(t))return!1;if(e.length===1)return!0;if(H(t)){let n=Ju(t[4].unit);for(let r=1;r<e.length;r++){let i=e[r];if(t[0]!==i[0]||n!==Ju(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 Ad(e,t){return!!Oc(e)&&(H(e)?e[0]===t[0]&&Ju(e[4].unit)===Ju(t[4].unit):e[0]===t[0])}function jd(e,t,n){let r=t.value;if(!Od(r))return-1;let i=fd(r,n.value);return Ad(r,i)?Sd(e,`rad`,Math.atan2(r[4].value,i[4].value)):-1}function Md(e,t,n){let r=t.value;return!Oc(r)||!n.rawPercentages&&G(r)?-1:xd(e,r,Math.abs(r[4].value))}function Nd(e,t,n,r,i){if(!q(t)||!q(n)||!q(r))return-1;let a=t.value;if(!Oc(a)||!i.rawPercentages&&G(a))return-1;let o=fd(a,n.value);if(!Ad(a,o))return-1;let s=fd(a,r.value);return Ad(a,s)?xd(e,a,Math.max(a[4].value,Math.min(o[4].value,s[4].value))):-1}function Pd(e,t){let n=t.value;if(!Od(n))return-1;let r=n[4].value;if(H(n))switch(n[4].unit.toLowerCase()){case`rad`:break;case`deg`:r=Zu.get(`rad`)(n[4].value);break;case`grad`:r=Qu.get(`rad`)(n[4].value);break;case`turn`:r=ud.get(`rad`)(n[4].value);break;default:return-1}return r=Math.cos(r),wd(e,r)}function Fd(e,t){let n=t.value;return W(n)?wd(e,Math.exp(n[4].value)):-1}function Id(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!Oc(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>fd(r,e.value));if(!kd(i))return-1;let a=i.map(e=>e[4].value);return xd(e,r,Math.hypot(...a))}function Ld(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!Oc(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>fd(r,e.value));if(!kd(i))return-1;let a=i.map(e=>e[4].value);return xd(e,r,Math.max(...a))}function Rd(e,t,n){if(!t.every(q))return-1;let r=t[0].value;if(!Oc(r)||!n.rawPercentages&&G(r))return-1;let i=t.map(e=>fd(r,e.value));if(!kd(i))return-1;let a=i.map(e=>e[4].value);return xd(e,r,Math.min(...a))}function zd(e,t,n){let r=t.value;if(!Oc(r))return-1;let i=fd(r,n.value);if(!Ad(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,xd(e,r,a)}function Bd(e,t,n){let r=t.value,i=n.value;return!W(r)||!Ad(r,i)?-1:wd(e,r[4].value**+i[4].value)}function Vd(e,t,n){let r=t.value;if(!Oc(r))return-1;let i=fd(r,n.value);if(!Ad(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,xd(e,r,a)}function Hd(e,t,n){if(!H(t))return-1;let r=n.devicePixelLength??1,i=[B.Dimension,`${r}px`,t[2],t[3],{value:r,type:V.Integer,unit:`px`}],a=fd(i,t);if(!Ad(a,i))return-1;if(Number.isInteger(a[4].value/r))return xd(e,t,t[4].value);if(a[4].value>0){if(a[4].value<r)return xd(e,t,fd(t,i)[4].value);let n=Math.floor(a[4].value/i[4].value)*i[4].value;return a[4].value=n,xd(e,t,fd(t,a)[4].value)}if(Math.abs(a[4].value)<r)return xd(e,t,-1*fd(t,i)[4].value);let o=Math.ceil(a[4].value/i[4].value)*i[4].value;return a[4].value=o,xd(e,t,fd(t,a)[4].value)}function Ud(e,t,n,r,i){let a=n.value;if(!Oc(a)||t===`line-width`&&!H(a)||!i.rawPercentages&&G(a))return-1;let o=fd(a,r.value);if(!Ad(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=_d(xd(e,a,s),i);return t===-1?-1:Hd(e,t.value,i)}break}}else s=NaN;return xd(e,a,s)}function Wd(e,t,n){let r=t.value;return!Oc(r)||!n.rawPercentages&&G(r)?-1:wd(e,Math.sign(r[4].value))}function Gd(e,t){let n=t.value;if(!Od(n))return-1;let r=n[4].value;if(H(n))switch(Ju(n[4].unit)){case`rad`:break;case`deg`:r=Zu.get(`rad`)(n[4].value);break;case`grad`:r=Qu.get(`rad`)(n[4].value);break;case`turn`:r=ud.get(`rad`)(n[4].value);break;default:return-1}return r=Math.sin(r),wd(e,r)}function Kd(e,t){let n=t.value;return W(n)?wd(e,Math.sqrt(n[4].value)):-1}function qd(e,t){let n=t.value;if(!Od(n))return-1;let r=n[4].value,i=0,a=n[4].value;if(H(n))switch(Ju(n[4].unit)){case`rad`:i=cd.get(`deg`)(r);break;case`deg`:i=r,a=Zu.get(`rad`)(r);break;case`grad`:i=Qu.get(`deg`)(r),a=Qu.get(`rad`)(r);break;case`turn`:i=ud.get(`deg`)(r),a=ud.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),wd(e,a)}function Jd(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([B.Number,e.toString(),n[2],r[3],{value:e,type:n[4].type===V.Integer&&r[4].type===V.Integer?V.Integer:V.Number}])}if(G(n)&&G(r)){let e=n[4].value-r[4].value;return new K([B.Percentage,e.toString()+`%`,n[2],r[3],{value:e}])}if(H(n)&&H(r)&&(r=fd(n,r),Ju(n[4].unit)===Ju(r[4].unit))){let e=n[4].value-r[4].value;return new K([B.Dimension,e.toString()+n[4].unit,n[2],r[3],{value:e,type:n[4].type===V.Integer&&r[4].type===V.Integer?V.Integer:V.Number,unit:n[4].unit}])}return(W(n)&&(H(r)||G(r))||W(r)&&(H(n)||G(n)))&&t.onParseError?.(new Gu(Ku.UnexpectedSubtractionOfDimensionOrPercentageWithNumber,e)),-1}function Yd(e,t){if(t.length===1){let n=t[0];if(!n||!q(n))return-1;let r=n.value;return W(r)?wd(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)?wd(e,Math.log(r[4].value)/Math.log(a[4].value)):-1}return-1}const Xd=/^none$/i;function Zd(e){if(Array.isArray(e)){let t=e.filter(e=>!(Bu(e)&&Vu(e)));return t.length===1&&Zd(t[0])}if(!q(e))return!1;let t=e.value;return!!U(t)&&Xd.test(t[4].value)}const Qd=String.fromCodePoint(0);function $d(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(!Oc(o))return-1;let s=fd(o,r.value);if(!Ad(o,s))return-1;let c=null;if(i&&(c=fd(o,i.value),!Ad(o,c)))return-1;if(!Number.isFinite(o[4].value)||!Number.isFinite(s[4].value)||!Number.isFinite(s[4].value-o[4].value))return xd(e,o,NaN);if(c&&!Number.isFinite(c[4].value))return xd(e,o,o[4].value);let l=t.fixed===-1?ef(tf([t.dashedIdent?t.dashedIdent:`${a.randomCaching?.propertyName} ${a.randomCaching.propertyN++}`,t.elementShared?``:a.randomCaching.elementID,a.randomCaching.documentID].join(Qd))):()=>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 xd(e,o,Number(n[Math.floor(n.length*i)].toFixed(5)))}let f=l();return xd(e,o,Number((f*(d-u)+u).toFixed(5)))}function ef(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 tf(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 nf=new Map([[`abs`,function(e,t,n){return af(e,t,n,Md)}],[`acos`,function(e,t,n){return af(e,t,n,Td)}],[`asin`,function(e,t,n){return af(e,t,n,Ed)}],[`atan`,function(e,t,n){return af(e,t,n,Dd)}],[`atan2`,function(e,t,n){return sf(e,t,n,jd)}],[`calc`,rf],[`clamp`,function(e,t,n){let r=yd([...e.value.filter(e=>!Hu(e))],t),i=[],a=[],o=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&jc(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=Zd(i),c=Zd(o);if(s&&c)return rf(pf(e,a),t,n);let l=_d(rf(pf(e,a),t,n),n);if(l===-1)return-1;if(s){let r=_d(rf(pf(e,o),t,n),n);return r===-1?-1:Rd((u=e,d=l,f=r,new Tu([B.Function,`min(`,u.name[2],u.name[3],{value:`min`}],[B.CloseParen,`)`,u.endToken[2],u.endToken[3],void 0],[d,new K([B.Comma,`,`,...Uu(d),void 0]),f])),[l,r],n)}if(c){let r=_d(rf(pf(e,i),t,n),n);return r===-1?-1:Ld(mf(e,r,l),[r,l],n)}var u,d,f;let p=_d(rf(pf(e,i),t,n),n);if(p===-1)return-1;let m=_d(rf(pf(e,o),t,n),n);return m===-1?-1:Nd(e,p,l,m,n)}],[`cos`,function(e,t,n){return af(e,t,n,Pd)}],[`exp`,function(e,t,n){return af(e,t,n,Fd)}],[`hypot`,function(e,t,n){return lf(e,t,n,Id)}],[`log`,function(e,t,n){return lf(e,t,n,Yd)}],[`max`,function(e,t,n){return lf(e,t,n,Ld)}],[`min`,function(e,t,n){return lf(e,t,n,Rd)}],[`mod`,function(e,t,n){return sf(e,t,n,zd)}],[`pow`,function(e,t,n){return sf(e,t,n,Bd)}],[`random`,function(e,t,n){let r=ff(e,e.value.filter(e=>!Hu(e)),t,n);if(r===-1)return-1;let[i,a]=r,o=uf(e,a,t,n);if(o===-1)return-1;let[s,c,l]=o;return!s||!c?-1:$d(e,i,s,c,l,n)}],[`rem`,function(e,t,n){return sf(e,t,n,Vd)}],[`round`,function(e,t,n){let r=yd([...e.value.filter(e=>!Hu(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(df.has(e)){i=e;continue}}if(q(n)&&jc(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=_d(rf(pf(e,o),t,n),n);if(c===-1)return-1;if(i===`line-width`){let e=fd([B.Dimension,`1px`,c.value[2],c.value[3],{value:1,type:V.Integer,unit:`px`}],c.value);if(!H(e)||e[4].unit!==`px`)return-1}if(!a&&s.length===0){if(i===`line-width`)return Hd(e,c.value,n);s.push(new K([B.Number,`1`,c.value[2],c.value[3],{value:1,type:V.Integer}]))}let l=_d(rf(pf(e,s),t,n),n);return l===-1?-1:(i||=`nearest`,Ud(e,i,c,l,n))}],[`sign`,function(e,t,n){return af(e,t,n,Wd)}],[`sin`,function(e,t,n){return af(e,t,n,Gd)}],[`sqrt`,function(e,t,n){return af(e,t,n,Kd)}],[`tan`,function(e,t,n){return af(e,t,n,qd)}]]);function rf(e,t,n){let r=yd([...e.value.filter(e=>!Hu(e))],t);if(r.length===1&&q(r[0]))return{inputs:[r[0]],operation:bd};let i=0;for(;i<r.length;){let e=r[i];if(Ru(e)&&zc(e.startToken)){let a=rf(e,t,n);if(a===-1)return-1;r.splice(i,1,a);continue}if(zu(e)){let a=nf.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&&gd(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!gd(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!Nc(n)||n[4].value!==`*`&&n[4].value!==`/`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!gd(a))return-1;n[4].value===`*`?r.splice(i,3,{inputs:[e,a],operation:vd}):n[4].value===`/`?r.splice(i,3,{inputs:[e,a],operation:hd}):i++}if(i=0,r.length===1&&gd(r[0]))return r[0];for(;i<r.length;){let e=r[i];if(!e||!q(e)&&!gd(e)){i++;continue}let t=r[i+1];if(!t||!q(t)){i++;continue}let n=t.value;if(!Nc(n)||n[4].value!==`+`&&n[4].value!==`-`){i++;continue}let a=r[i+2];if(!a||!q(a)&&!gd(a))return-1;n[4].value===`+`?r.splice(i,3,{inputs:[e,a],operation:md}):n[4].value===`-`?r.splice(i,3,{inputs:[e,a],operation:Jd}):i++}return r.length===1&&gd(r[0])?r[0]:-1}function af(e,t,n,r){let i=of(e,t,n);return i===-1?-1:r(e,i,n)}function of(e,t,n){let r=_d(rf(pf(e,yd([...e.value.filter(e=>!Hu(e))],t)),t,n),n);return r===-1?-1:r}function sf(e,t,n,r){let i=cf(e,t,n);if(i===-1)return-1;let[a,o]=i;return r(e,a,o,n)}function cf(e,t,n){let r=yd([...e.value.filter(e=>!Hu(e))],t),i=[],a=[];{let e=i;for(let t=0;t<r.length;t++){let n=r[t];if(q(n)&&jc(n.value)){if(e===a)return-1;if(e===i){e=a;continue}return-1}e.push(n)}}let o=_d(rf(pf(e,i),t,n),n);if(o===-1)return-1;let s=_d(rf(pf(e,a),t,n),n);return s===-1?-1:[o,s]}function lf(e,t,n,r){let i=uf(e,e.value,t,n);return i===-1?-1:r(e,i,n)}function uf(e,t,n,r){let i=yd([...t.filter(e=>!Hu(e))],n),a=[];{let t=[],o=[];for(let e=0;e<i.length;e++){let n=i[e];q(n)&&jc(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=_d(rf(pf(e,t[i]),n,r),r);if(o===-1)return-1;a.push(o)}}return a}const df=new Set([`nearest`,`line-width`,`up`,`down`,`to-zero`]);function ff(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(jc(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=_d(rf(pf(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 pf(e,t){return new Tu([B.Function,`calc(`,e.name[2],e.name[3],{value:`calc`}],[B.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],t)}function mf(e,t,n){return new Tu([B.Function,`max(`,e.name[2],e.name[3],{value:`max`}],[B.CloseParen,`)`,e.endToken[2],e.endToken[3],void 0],[t,new K([B.Comma,`,`,...Uu(t),void 0]),n])}function hf(e){if(e===-1)return-1;if(zu(e))return e;let t=e.value;return Oc(t)&&Number.isNaN(t[4].value)?W(t)?new Tu([B.Function,`calc(`,t[2],t[3],{value:`calc`}],[B.CloseParen,`)`,t[2],t[3],void 0],[new K([B.Ident,`NaN`,t[2],t[3],{value:`NaN`}])]):H(t)?new Tu([B.Function,`calc(`,t[2],t[3],{value:`calc`}],[B.CloseParen,`)`,t[2],t[3],void 0],[new K([B.Ident,`NaN`,t[2],t[3],{value:`NaN`}]),new ku([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Delim,`*`,t[2],t[3],{value:`*`}]),new ku([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Dimension,`1`+t[4].unit,t[2],t[3],{value:1,type:V.Integer,unit:t[4].unit}])]):G(t)?new Tu([B.Function,`calc(`,t[2],t[3],{value:`calc`}],[B.CloseParen,`)`,t[2],t[3],void 0],[new K([B.Ident,`NaN`,t[2],t[3],{value:`NaN`}]),new ku([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Delim,`*`,t[2],t[3],{value:`*`}]),new ku([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Percentage,`1%`,t[2],t[3],{value:1}])]):-1:e}function gf(e){if(e===-1)return-1;if(zu(e))return e;let t=e.value;if(!Oc(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 Tu([B.Function,`calc(`,t[2],t[3],{value:`calc`}],[B.CloseParen,`)`,t[2],t[3],void 0],[new K([B.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}])]):H(t)?new Tu([B.Function,`calc(`,t[2],t[3],{value:`calc`}],[B.CloseParen,`)`,t[2],t[3],void 0],[new K([B.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}]),new ku([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Delim,`*`,t[2],t[3],{value:`*`}]),new ku([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Dimension,`1`+t[4].unit,t[2],t[3],{value:1,type:V.Integer,unit:t[4].unit}])]):new Tu([B.Function,`calc(`,t[2],t[3],{value:`calc`}],[B.CloseParen,`)`,t[2],t[3],void 0],[new K([B.Ident,n+`infinity`,t[2],t[3],{value:n+`infinity`}]),new ku([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Delim,`*`,t[2],t[3],{value:`*`}]),new ku([[B.Whitespace,` `,t[2],t[3],void 0]]),new K([B.Percentage,`1%`,t[2],t[3],{value:1}])])}function _f(e){if(e===-1)return-1;if(zu(e))return e;let t=e.value;return Oc(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 vf(e,t=13){if(e===-1)return-1;if(t<=0||zu(e))return e;let n=e.value;if(!Oc(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 yf(e){return e===-1?-1:(zu(e)||H(e.value)&&(e.value=pd(e.value)),e)}function bf(e,t){let n=e;return t?.toCanonicalUnits&&(n=yf(n)),n=vf(n,t?.precision),n=_f(n),t?.censorIntoStandardRepresentableValues||(n=hf(n),n=gf(n)),n}function xf(e){let t=new Map;if(!e)return t;for(let[n,r]of e)if(Dc(r))t.set(n,r);else if(typeof r==`string`){let e=bc({css:r}),i=e.nextToken();if(e.nextToken(),!e.endOfFile()||!Oc(i))continue;t.set(n,i);continue}return t}function Sf(e,t){let n=xf(t?.globals);return Cf(e,e=>{if(!zu(e))return;let r=nf.get(e.getName().toLowerCase());if(!r)return;let i=bf(_d(r(e,n,t??{}),t??{}),t);return i===-1?void 0:i})}function Cf(e,t){for(let n=0;n<e.length;n++){let r=e[n];Iu(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)&&Nc(a.value)&&(a.value[4].value===`-`||a.value[4].value===`+`)&&i.splice(0,0,new ku([[B.Whitespace,` `,...Uu(e.node),void 0]]));let o=e.parent.value[n+1];!o||Hu(o)||q(o)&&(jc(o.value)||Ac(o.value)||Lc(o.value)||Nc(o.value)&&o.value[4].value!==`-`&&o.value[4].value!==`+`)||i.push(new ku([[B.Whitespace,` `,...Uu(e.node),void 0]])),e.parent.value.splice(n,1,...i)})}return e}const wf=new Set(nf.keys());var J,Y;function Tf(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function Ef(e){switch(e.colorNotation){case J.HEX:case J.RGB:case J.sRGB:return{...e,colorNotation:J.XYZ_D50,channels:zl(Tf(e.channels))};case J.Linear_sRGB:return{...e,colorNotation:J.XYZ_D50,channels:$l(Tf(e.channels))};case J.Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:ru(Tf(e.channels))};case J.Linear_Display_P3:return{...e,colorNotation:J.XYZ_D50,channels:au(Tf(e.channels))};case J.Rec2020:return{...e,colorNotation:J.XYZ_D50,channels:su(Tf(e.channels))};case J.A98_RGB:return{...e,colorNotation:J.XYZ_D50,channels:tu(Tf(e.channels))};case J.ProPhoto_RGB:return{...e,colorNotation:J.XYZ_D50,channels:lu(Tf(e.channels))};case J.HSL:return{...e,colorNotation:J.XYZ_D50,channels:Vl(Tf(e.channels))};case J.HWB:return{...e,colorNotation:J.XYZ_D50,channels:Ul(Tf(e.channels))};case J.Lab:return{...e,colorNotation:J.XYZ_D50,channels:Gl(Tf(e.channels))};case J.OKLab:return{...e,colorNotation:J.XYZ_D50,channels:Yl(Tf(e.channels))};case J.LCH:return{...e,colorNotation:J.XYZ_D50,channels:ql(Tf(e.channels))};case J.OKLCH:return{...e,colorNotation:J.XYZ_D50,channels:Zl(Tf(e.channels))};case J.XYZ_D50:return{...e,colorNotation:J.XYZ_D50,channels:pu(Tf(e.channels))};case J.XYZ_D65:return{...e,colorNotation:J.XYZ_D50,channels:du(Tf(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 Df=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 Of(e,t){let n={...e};if(e.colorNotation!==t){let e=Ef(n);switch(t){case J.HEX:case J.RGB:n.colorNotation=J.RGB,n.channels=Bl(e.channels);break;case J.sRGB:n.colorNotation=J.sRGB,n.channels=Bl(e.channels);break;case J.Linear_sRGB:n.colorNotation=J.Linear_sRGB,n.channels=eu(e.channels);break;case J.Display_P3:n.colorNotation=J.Display_P3,n.channels=iu(e.channels);break;case J.Linear_Display_P3:n.colorNotation=J.Linear_Display_P3,n.channels=ou(e.channels);break;case J.Rec2020:n.colorNotation=J.Rec2020,n.channels=cu(e.channels);break;case J.ProPhoto_RGB:n.colorNotation=J.ProPhoto_RGB,n.channels=uu(e.channels);break;case J.A98_RGB:n.colorNotation=J.A98_RGB,n.channels=nu(e.channels);break;case J.HSL:n.colorNotation=J.HSL,n.channels=Hl(e.channels);break;case J.HWB:n.colorNotation=J.HWB,n.channels=Wl(e.channels);break;case J.Lab:n.colorNotation=J.Lab,n.channels=Kl(e.channels);break;case J.LCH:n.colorNotation=J.LCH,n.channels=Jl(e.channels);break;case J.OKLCH:n.colorNotation=J.OKLCH,n.channels=Ql(e.channels);break;case J.OKLab:n.colorNotation=J.OKLab,n.channels=Xl(e.channels);break;case J.XYZ_D50:n.colorNotation=J.XYZ_D50,n.channels=pu(e.channels);break;case J.XYZ_D65:n.colorNotation=J.XYZ_D65,n.channels=fu(e.channels);break;default:throw Error(`Unsupported color notation`)}}else n.channels=Tf(e.channels);if(t===e.colorNotation)n.channels=Af(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else if(Df.has(t)&&Df.has(e.colorNotation))n.channels=Af(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);else switch(t){case J.HSL:switch(e.colorNotation){case J.HWB:n.channels=Af(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=Af(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.LCH:case J.OKLCH:n.channels=Af(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;default:n.channels=Af(e.channels,[],[],n.channels,[],[])}break;case J.HWB:switch(e.colorNotation){case J.HSL:n.channels=Af(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=Af(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;default:n.channels=Af(e.channels,[],[],n.channels,[],[])}break;case J.Lab:case J.OKLab:switch(e.colorNotation){case J.HSL:n.channels=Af(e.channels,[2],[0,1],n.channels,[0],[1,2]);break;case J.Lab:case J.OKLab:n.channels=Af(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;case J.LCH:case J.OKLCH:n.channels=Af(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;default:n.channels=Af(e.channels,[],[],n.channels,[],[])}break;case J.LCH:case J.OKLCH:switch(e.colorNotation){case J.HSL:n.channels=Af(e.channels,[0,1,2],[],n.channels,[2,1,0],[]);break;case J.HWB:n.channels=Af(e.channels,[0],[1,2],n.channels,[2],[0,1]);break;case J.Lab:case J.OKLab:n.channels=Af(e.channels,[0],[1,2],n.channels,[0],[1,2]);break;case J.LCH:case J.OKLCH:n.channels=Af(e.channels,[0,1,2],[],n.channels,[0,1,2],[]);break;default:n.channels=Af(e.channels,[],[],n.channels,[],[])}break;default:n.channels=Af(e.channels,[],[],n.channels,[],[])}return n.channels=kf(n.channels,t),n}function kf(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 Af(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 jf(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 Mf(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)?[B.Number,`none`,-1,-1,{value:NaN,type:V.Number}]:[B.Number,e.toString(),-1,-1,{value:e,type:V.Number}]}function Z(e,t,n,r){return Math.min(Math.max(e/t,n),r)}const Nf=/[A-Z]/g;function Q(e){return e.replace(Nf,e=>String.fromCharCode(e.charCodeAt(0)+32))}function Pf(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}const Ff=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`xyz`,`xyz-d50`,`xyz-d65`]);function If(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(Bu(p)||Vu(p))for(;Bu(e.value[f+1])||Vu(e.value[f+1]);)f++;else if(d===n&&n.length&&(d=r),d===r&&r.length&&(d=i),q(p)&&Nc(p.value)&&p.value[4].value===`/`){if(d===a)return!1;d=a}else{if(zu(p)){if(d===a&&Q(p.getName())===`var`){u.syntaxFlags.add(Y.HasVariableAlpha),d.push(p);continue}if(!wf.has(Q(p.getName())))return!1;let[[e]]=Sf([[p]],{censorIntoStandardRepresentableValues:!0,globals:s,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!Oc(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)&&Ff.has(Q(p.value[4].value))){if(c)return!1;c=Q(p.value[4].value),u.colorNotation=Lf(c),l&&(l.colorNotation!==u.colorNotation&&(l=Of(l,u.colorNotation)),o=jf(l),s=Mf(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(;Bu(e.value[f+1])||Vu(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=Pf(n[0].value,0,u);if(!f||!W(f))return!1;let p=Pf(r[0].value,1,u);if(!p||!W(p))return!1;let m=Pf(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=Pf(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=Pf(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 Lf(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 Rf=new Set([`srgb`,`srgb-linear`,`display-p3`,`display-p3-linear`,`a98-rgb`,`prophoto-rgb`,`rec2020`,`lab`,`oklab`,`xyz`,`xyz-d50`,`xyz-d65`]),zf=new Set([`hsl`,`hwb`,`lch`,`oklch`]),Bf=new Set([`shorter`,`longer`,`increasing`,`decreasing`]);function Vf(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(!Hu(s)){if(!(n||q(s)&&U(s.value)&&Q(s.value[4].value)===`in`))return Uf(`oklab`,Hf(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&&zf.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)||!jc(s.value))&&!!r&&(i||a?!!(i&&a&&zf.has(r)&&Bf.has(i))&&Gf(r,i,Hf(e.value.slice(o+1),t)):Rf.has(r)?Uf(r,Hf(e.value.slice(o+1),t)):!!zf.has(r)&&Gf(r,`shorter`,Hf(e.value.slice(o+1),t)))}}return!1}function Hf(e,t){let n=[],r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(!Hu(o)){if(!q(o)||!jc(o.value)){if(!r){let e=t(o);if(e){r=e;continue}}if(!i){if(zu(o)&&wf.has(Q(o.getName()))){if([[o]]=Sf([[o]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0}),!o||!q(o)||!Oc(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 Uf(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}=Zf(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=Of(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=Wf(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 Wf(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=Of(t,e).channels,s=Of(n,e).channels;o[0]=qf(o[0],s[0]),s[0]=qf(s[0],o[0]),o[1]=qf(o[1],s[1]),s[1]=qf(s[1],o[1]),o[2]=qf(o[2],s[2]),s[2]=qf(s[2],o[2]),o[0]=Yf(o[0],i),o[1]=Yf(o[1],i),o[2]=Yf(o[2],i),s[0]=Yf(s[0],a),s[1]=Yf(s[1],a),s[2]=Yf(s[2],a);let c=Jf(i,a,r);return{colorNotation:e,channels:[Xf(Jf(o[0],s[0],r),c),Xf(Jf(o[1],s[1],r),c),Xf(Jf(o[2],s[2],r),c)],alpha:c,syntaxFlags:new Set([Y.ColorMix])}}function Gf(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}=Zf(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=Of(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=Kf(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 Kf(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=Of(n,e).channels,m=Of(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=qf(a,o),Number.isNaN(a)&&(a=0),o=qf(o,a),Number.isNaN(o)&&(o=0),s=qf(s,c),c=qf(c,s),l=qf(l,u),u=qf(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=Yf(s,d),l=Yf(l,d),c=Yf(c,f),u=Yf(u,f);let g=[0,0,0],_=Jf(d,f,i);switch(e){case J.HSL:case J.HWB:g=[Jf(a,o,i),Xf(Jf(s,c,i),_),Xf(Jf(l,u,i),_)];break;case J.LCH:case J.OKLCH:g=[Xf(Jf(s,c,i),_),Xf(Jf(l,u,i),_),Jf(a,o,i)]}return{colorNotation:e,channels:g,alpha:_,syntaxFlags:new Set([Y.ColorMix])}}function qf(e,t){return Number.isNaN(e)?t:e}function Jf(e,t,n){return e*(1-n)+t*n}function Yf(e,t){return Number.isNaN(t)?e:Number.isNaN(e)?NaN:e*t}function Xf(e,t){return t===0||Number.isNaN(t)?e:Number.isNaN(e)?NaN:e/t}function Zf(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 Qf(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 $f(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,[B.Number,t.toString(),e[2],e[3],{value:t,type:V.Number}]}return!1}function ep(e,t,n){if(t===0){let t=$f(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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,n.toString(),e[2],e[3],{value:n,type:V.Number}]}return!1}function tp(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.Number}];if(t===0){let t=$f(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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function np(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(!Bu(n)&&!Vu(n)){if(q(n)&&jc(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(zu(n)){if(l===s&&n.getName().toLowerCase()===`var`){c.syntaxFlags.add(Y.HasVariableAlpha),l.push(n);continue}if(!wf.has(n.getName().toLowerCase()))return!1;let[[e]]=Sf([[n]],{censorIntoStandardRepresentableValues:!0,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!Oc(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 rp(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(Bu(r)||Vu(r))for(;Bu(e.value[t+1])||Vu(e.value[t+1]);)t++;else if(p===a&&a.length&&(p=o),p===o&&o.length&&(p=s),q(r)&&Nc(r.value)&&r.value[4].value===`/`){if(p===c)return!1;p=c}else{if(zu(r)){if(p===c&&r.getName().toLowerCase()===`var`){f.syntaxFlags.add(Y.HasVariableAlpha),p.push(r);continue}if(!wf.has(r.getName().toLowerCase()))return!1;let[[e]]=Sf([[r]],{censorIntoStandardRepresentableValues:!0,globals:u,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!Oc(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(;Bu(e.value[t+1])||Vu(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=Of(d,n)),l=jf(d),u=Mf(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 ip(e,t){if(e.value.some(e=>q(e)&&jc(e.value))){let t=ap(e);if(!1!==t)return t}{let n=op(e,t);if(!1!==n)return n}return!1}function ap(e){return np(e,ep,J.HSL,[Y.LegacyHSL])}function op(e,t){return rp(e,tp,J.HSL,[],t)}function sp(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.Number}];if(t===0){let t=$f(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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function cp(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function lp(e,t){return rp(e,cp,J.Lab,[],t)}function up(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.Number}];if(t===2){let t=$f(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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function dp(e,t){return rp(e,up,J.LCH,[],t)}const fp=new Map;for(let[e,t]of Object.entries(vu))fp.set(e,t);function pp(e){let t=fp.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 mp(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function hp(e,t){return rp(e,mp,J.OKLab,[],t)}function gp(e,t,n){if(U(e)&&Q(e[4].value)===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.Number}];if(t===2){let t=$f(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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function _p(e,t){return rp(e,gp,J.OKLCH,[],t)}function vp(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[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function yp(e,t,n){if(U(e)&&e[4].value.toLowerCase()===`none`)return n.syntaxFlags.add(Y.HasNoneKeywords),[B.Number,`none`,e[2],e[3],{value:NaN,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.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)),[B.Number,r.toString(),e[2],e[3],{value:r,type:V.Number}]}return!1}function bp(e,t){if(e.value.some(e=>q(e)&&jc(e.value))){let t=xp(e);if(!1!==t)return(!t.syntaxFlags.has(Y.HasNumberValues)||!t.syntaxFlags.has(Y.HasPercentageValues))&&t}else{let n=Sp(e,t);if(!1!==n)return n}return!1}function xp(e){return np(e,vp,J.RGB,[Y.LegacyRGB])}function Sp(e,t){return rp(e,yp,J.RGB,[],t)}function Cp(e){let t=Bl(e);if(mu(t))return hu(t);let n=e;return n=Ql(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),yl(gu(n,wp,Tp))}function wp(e){return e=tl(e),e=al(e),_l(e)}function Tp(e){return e=Il(e),e=ul(e),nl(e)}function Ep(e,t){let n=!1;for(let r=0;r<e.value.length;r++){let i=e.value[r];if(!Bu(i)&&!Vu(i)&&(n||(n=t(i),!n)))return!1}if(!n)return!1;n.channels=Tf(n.channels),n.channels=Cp(Ef(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=bu(n.channels,[1,1,1])>bu(n.channels,[0,0,0])?[1,1,1]:[0,0,0],r}function Dp(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(Bu(l)||Vu(l))for(;Bu(e.value[c+1])||Vu(e.value[c+1]);)c++;else if(o&&!i&&!a&&q(l)&&Nc(l.value)&&l.value[4].value===`/`)i=!0;else{if(zu(l)&&wf.has(Q(l.getName()))){let[[e]]=Sf([[l]],{censorIntoStandardRepresentableValues:!0,globals:r,precision:-1,toCanonicalUnits:!0,rawPercentages:!0});if(!e||!q(e)||!Oc(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=Pf(l.value,3,s);if(!e||!W(e))return!1;s.alpha=new K(e),a=!0;continue}if(zu(l)){s.alpha=Lu([[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(;Bu(e.value[c+1])||Vu(e.value[c+1]);)c++;if(c++,l=e.value[c],o=t(l),!1===o)return!1;n=jf(o),r=Mf(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 Op(e){if(zu(e))switch(Q(e.getName())){case`rgb`:case`rgba`:return bp(e,Op);case`hsl`:case`hsla`:return ip(e,Op);case`hwb`:return t=Op,rp(e,sp,J.HWB,[],t);case`lab`:return lp(e,Op);case`lch`:return dp(e,Op);case`oklab`:return hp(e,Op);case`oklch`:return _p(e,Op);case`color`:return If(e,Op);case`color-mix`:return Vf(e,Op);case`contrast-color`:return Ep(e,Op);case`alpha`:return Dp(e,Op)}var t;if(q(e)){if(Ic(e.value))return Qf(e.value);if(U(e.value)){let t=pp(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 kp(e){return[Number.isNaN(e[0])?0:e[0],Number.isNaN(e[1])?0:e[1],Number.isNaN(e[2])?0:e[2]]}function Ap(e){switch(e.colorNotation){case`hex`:case`rgb`:case`srgb`:return{...e,colorNotation:`xyz-d50`,channels:zl(kp(e.channels))};case`srgb-linear`:return{...e,colorNotation:`xyz-d50`,channels:$l(kp(e.channels))};case`display-p3`:return{...e,colorNotation:`xyz-d50`,channels:ru(kp(e.channels))};case`display-p3-linear`:return{...e,colorNotation:`xyz-d50`,channels:au(kp(e.channels))};case`rec2020`:return{...e,colorNotation:`xyz-d50`,channels:su(kp(e.channels))};case`a98-rgb`:return{...e,colorNotation:`xyz-d50`,channels:tu(kp(e.channels))};case`prophoto-rgb`:return{...e,colorNotation:`xyz-d50`,channels:lu(kp(e.channels))};case`hsl`:return{...e,colorNotation:`xyz-d50`,channels:Vl(kp(e.channels))};case`hwb`:return{...e,colorNotation:`xyz-d50`,channels:Ul(kp(e.channels))};case`lab`:return{...e,colorNotation:`xyz-d50`,channels:Gl(kp(e.channels))};case`oklab`:return{...e,colorNotation:`xyz-d50`,channels:Yl(kp(e.channels))};case`lch`:return{...e,colorNotation:`xyz-d50`,channels:ql(kp(e.channels))};case`oklch`:return{...e,colorNotation:`xyz-d50`,channels:Zl(kp(e.channels))};case`xyz-d50`:return{...e,colorNotation:`xyz-d50`,channels:pu(kp(e.channels))};case`xyz-d65`:return{...e,colorNotation:`xyz-d50`,channels:du(kp(e.channels))};default:throw Error(`Unsupported color notation`)}}function jp(e,t=7){return e=+e,t=+t,Number(e.toPrecision(t))}function Mp(e){let t=Bl(e);if(mu(t))return hu(t);let n=e;return n=Ql(n),n[0]<1e-6&&(n=[0,0,0]),n[0]>.999999&&(n=[1,0,0]),yl(gu(n,Np,Pp))}function Np(e){return e=tl(e),e=al(e),_l(e)}function Pp(e){return e=Il(e),e=ul(e),nl(e)}var Fp=class e{static colorTxtList=[];static parseColorString(e){try{let t=Pu(yc({css:e}));if(!t)return null;let n=Op(t);if(n===!1)return null;let r=n.channels;n.colorNotation!==`rgb`&&(r=Mp(Ap(n).channels));let i=Math.min(255,Math.max(0,Math.round(jp(r[0])*255))),a=Math.min(255,Math.max(0,Math.round(jp(r[1])*255))),o=Math.min(255,Math.max(0,Math.round(jp(r[2])*255))),s=1;return typeof n.alpha==`number`&&(s=Math.min(1,Math.max(0,jp(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=e.slice(0,t),r=(n.match(/\n/g)??[]).length,i=n.lastIndexOf(`
|
|
1085
1085
|
`);return m.Position.create(r,t-i-1)}static maskCommentsAndStrings(e,t){let n=e.split(``),r=`code`,i=``,a=0;for(let o=0;o<e.length;o++){let s=e[o],c=e[o+1];r===`code`?a===0&&e.slice(o,o+4).toLowerCase()===`url(`&&(o===0||!/[\w-]/.test(e[o-1]))?(a=1,o+=3):a>0&&s===`(`?a++:a>0&&s===`)`?a--:s===`/`&&c===`*`?(r=`comment`,n[o]=n[++o]=` `):t==T.SCSS&&a===0&&s===`/`&&c===`/`&&e[o-1]!==`:`?(r=`lineComment`,n[o]=n[++o]=` `):s===`"`||s===`'`?(r=`string`,i=s,n[o]=` `):a>0&&(n[o]=s===`
|
|
1086
1086
|
`||s===`\r`?s:` `):(n[o]=s===`
|
|
1087
1087
|
`||s===`\r`?s:` `,r===`lineComment`&&s===`
|
|
1088
1088
|
`?r=`code`:r===`comment`&&s===`*`&&c===`/`?(n[++o]=` `,r=`code`):r===`string`&&s===`\\`?c!==void 0&&(n[++o]=c===`
|
|
1089
|
-
`||c===`\r`?c:` `):r===`string`&&s===i&&(r=`code`))}return n.join(``)}static getMatches(e,t){let n=[],r=this.maskCommentsAndStrings(e,t),i=[],a=[];for(let e of r.matchAll(/#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})\b/gi))i.push({index:e.index,value:e[0]});for(let e of r.matchAll(/\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color-mix|color)\(/gi)){let t=1,n=e.index+e[0].length;for(;n<r.length&&t>0;n++)r[n]===`(`?t++:r[n]===`)`&&t--;t===0&&i.push({index:e.index,value:r.slice(e.index,n)})}i.sort((e,t)=>e.index-t.index);for(let t of i){let r=t.value,i=r.length;if(a.some(e=>t.index>=e.start&&t.index+i<=e.end))continue;let o=r.startsWith(`#`)?`hex`:r.slice(0,r.indexOf(`(`)).toLowerCase(),s=m.Range.create(this.getPos(e,t.index),this.getPos(e,t.index+r.length)),c=this.parseColorString(r);c&&(o!==`hex`&&a.push({start:t.index,end:t.index+i}),n.push({color:c,type:o,length:i,range:s}))}if(this.colorTxtList.length==0){let e=Object.getOwnPropertyNames(
|
|
1090
|
-
`)}`;r.reportsUnnecessary?n.push({range:
|
|
1089
|
+
`||c===`\r`?c:` `):r===`string`&&s===i&&(r=`code`))}return n.join(``)}static getMatches(e,t){let n=[],r=this.maskCommentsAndStrings(e,t),i=[],a=[];for(let e of r.matchAll(/#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})\b/gi))i.push({index:e.index,value:e[0]});for(let e of r.matchAll(/\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color-mix|color)\(/gi)){let t=1,n=e.index+e[0].length;for(;n<r.length&&t>0;n++)r[n]===`(`?t++:r[n]===`)`&&t--;t===0&&i.push({index:e.index,value:r.slice(e.index,n)})}i.sort((e,t)=>e.index-t.index);for(let t of i){let r=t.value,i=r.length;if(a.some(e=>t.index>=e.start&&t.index+i<=e.end))continue;let o=r.startsWith(`#`)?`hex`:r.slice(0,r.indexOf(`(`)).toLowerCase(),s=m.Range.create(this.getPos(e,t.index),this.getPos(e,t.index+r.length)),c=this.parseColorString(r);c&&(o!==`hex`&&a.push({start:t.index,end:t.index+i}),n.push({color:c,type:o,length:i,range:s}))}if(this.colorTxtList.length==0){let e=Object.getOwnPropertyNames(js.Colors),t=[];for(let n of e)n!=`name`&&n!=`length`&&n!=`prototype`&&t.push(n);t.push(`TRANSPARENT`),this.colorTxtList=t}let o=RegExp(`(?<![\\w\\d."'&$-])(`+this.colorTxtList.join(`|`)+`)(?![-\\w\\d])`,`gi`),s=r.matchAll(o);if(s)for(let t of s){let r=t[0];if(t.index===void 0)continue;let i=r.length;if(a.some(e=>t.index>=e.start&&t.index+i<=e.end))continue;let o=m.Range.create(this.getPos(e,t.index),this.getPos(e,t.index+r.length)),s=r.toLowerCase()===`transparent`?r:js.fromName(r).toHex(),c=this.parseColorString(s);c&&n.push({color:c,type:`hex`,length:i,range:o})}return n.sort((e,t)=>e.range.start.line-t.range.start.line||e.range.start.character-t.range.start.character||t.length-e.length)}static onDocumentColor(t){return e.getMatches(t.getText(),es(t.uri)).map(e=>m.ColorInformation.create(e.range,e.color))}static onColorPresentations(e,t,n){let r=js.fromRgb(n.red*255,n.green*255,n.blue*255);r.alpha=n.alpha;let i=e.getText(t).toLowerCase(),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;i.startsWith(`#`)&&(i.length===5||i.length===9)&&(d=!0),i.startsWith(`hsla`)&&(d=!0),i.startsWith(`rgba`)&&(d=!0),n.alpha!==1&&(d=!0);let f=[o,c,u],p=[a,s,l];return n.alpha===0?[m.ColorPresentation.create(`transparent`),...f]:d?f:p}},Ip=class{templateManager;constructor(e){this.templateManager=e}async createTemplate(e){try{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))}catch(e){if(!(e instanceof no))throw e;$.showWarningMessage(`No templates available for this location. Browse templates: https://store.aventusjs.com/templates`)}}readTemplates(){let e=this.templateManager.getGeneralTemplates(),t=this.templateManager.getGeneralTemplatesLength(),n=$.getWorkspaceUri();if(n){let r=L(n)+`/.aventus/templates`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}},Lp=class e{languageService;filesLoaded={};templateFiles={};filesNeeded=[];filesNpm=[];constructor(){Mt(),this.filesNeeded=[I((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:()=>Rp,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)(L(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,Rp,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),this.templateFiles[e.uri]=e}removeFile(e){let t=this.filesNeeded.indexOf(e.uri);t!=-1&&(this.filesNeeded.splice(t,1),delete this.filesLoaded[e.uri]),delete this.templateFiles[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,`
|
|
1090
|
+
`)}`;r.reportsUnnecessary?n.push({range:ds(e.documentInternal,r),severity:m.DiagnosticSeverity.Hint,source:T.TypeScript,message:i,tags:[m.DiagnosticTag.Unnecessary]}):n.push({range:ds(e.documentInternal,r),severity:m.DiagnosticSeverity.Error,source:T.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=ds(n,gs(n.getText(),r)),a;try{a=this.languageService.getCompletionsAtPosition(n.uri,r,zp)}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:T.TypeScript,offset:r,uri:n.uri},u={label:t.name,sortText:t.sortText,kind:Nn(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+=`
|
|
1091
1091
|
\`\`\`
|
|
1092
1092
|
***
|
|
1093
1093
|
`),i+=t.join(`
|
|
1094
1094
|
|
|
1095
|
-
`),{range:
|
|
1096
|
-
`,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 Up=class extends it{languageService;constructor(e){super(e),this.languageService=new zp,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}},Wp=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}constructor(){z.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(e){e.documentUser.uri.endsWith(E.Template)&&(new Up(e),e instanceof O&&await e.validate())}},Gp=class{};const Kp={allCommunications:{},list:[class extends Gp{channel(){return`aventus.i18n.getKeyFromPosition`}async run(e){if(e.uri){let t=P.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 Gp{channel(){return`aventus.i18n.getLocales`}async run(e){if(e.uri){let t=P.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 qp=class{templateManager;constructor(e){this.templateManager=e}async createGlobal(e){try{let t=await this.templateManager.readGlobal(),n=await this.templateManager.query(e,t.templates,[{label:`Init`,detail:`Create a project`}]);n instanceof ro?await n.init(e,this.templateManager.findWorkspace(e)):n&&await this.createProject(e)}catch(e){if(!(e instanceof io))throw e;$.showWarningMessage(`No templates available for this location. Browse templates: https://store.aventusjs.com/templates`)}}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=L(n)+`/.aventus/projects`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}};function Jp(){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 Yp(){let e=(0,f.join)($.savePath,`packages`);(0,u.existsSync)(e)&&Xp(e)}function Xp(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())Xp(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 Zp={"1.4.0":Jp,"1.4.1":Yp};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 F.getInstance().settings.logLevel}isIDE=!1;_noBuild=!1;_savePath=``;_extensionPath=``;_logFile;_template;_localTemplate;_localProject;settingsLoadGeneration=0;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 Kp.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=F.getInstance().settings,t=[],n=async(e,n)=>{try{await n()}catch(n){t.push(Error(`${e}: ${n}`))}};return e.watchFiles&&await n(`FilesWatcher`,()=>Ms.getInstance().destroy()),e.useCompilators&&(await n(`CSharpManager`,()=>Ca.getInstance().destroy()),await n(`PhpManager`,()=>Fa.getInstance().destroy())),await n(`ProjectManager`,()=>P.getInstance().destroyAll()),await n(`FilesManager`,()=>z.getInstance().onShutdown()),t}async onCompletion(e,t){return this.isAllowed(e)?await z.getInstance().onCompletion(e,t):null}async onCompletionResolve(e,t){return this.isAllowed(e)?await z.getInstance().onCompletionResolve(e,t):t}async onHover(e,t){return this.isAllowed(e)?await z.getInstance().onHover(e,t):null}async onDefinition(e,t){return this.isAllowed(e)?await z.getInstance().onDefinition(e,t):null}async onDocumentFormatting(e,t){return this.isAllowed(e)?await z.getInstance().onFormatting(e,t):null}async onCodeAction(e,t){return this.isAllowed(e)?await z.getInstance().onCodeAction(e,t):null}async onCodeLens(e){return this.isAllowed(e)?await z.getInstance().onCodeLens(e):null}async onReferences(e,t){return this.isAllowed(e)?await z.getInstance().onReferences(e,t):null}async onRenameRequest(e,t,n){return this.isAllowed(e)?await z.getInstance().onRename(e,t,n):null}async onDocumentColor(e){return e&&this.isStyleDocument(e)?Lp.onDocumentColor(e):null}async onColorPresentation(e,t,n){return e&&this.isStyleDocument(e)?Lp.onColorPresentations(e,t,n):null}async onExecuteCommand(e){await no.execute(e)}async onDidChangeConfiguration(){await this.loadSettings()}isAllowed(t){return t?e.isAllowed(t):!1}static isAllowed(e){return this.instance.isDown||this.instance.isLoading?!1:!!(e.uri.endsWith(E.Base)||e.uri.endsWith(E.Config)||e.uri.endsWith(E.Template))}isStyleDocument(e){return!!(e.uri.endsWith(E.ComponentStyle)||e.uri.endsWith(E.Component)||e.uri.endsWith(E.GlobalStyle))}async loadSettings(){this.settingsLoadGeneration++;let e=this.settingsLoadGeneration,t=await this.connection.getSettings();t||={};let n=await this.connection.getSettingsHtml();n||={},e===this.settingsLoadGeneration&&(F.getInstance().initSettings(t),F.getInstance().setSettingsHtml(n))}async startServer(){let t=F.getInstance().settings;t.useTemplates&&(this._template=new oo(this.workspaces),await this._template.init(),this._localTemplate=new Rp(this._template),this._localProject=new qp(this._template)),t.useCompilators&&(Ca.getInstance(),Fa.getInstance()),P.getInstance(),Wp.getInstance(),t.loadFiles?t.buildOnly?t.configPath?await z.getInstance().loadConfigFile(t.configPath,t.builds,t.statics):await z.getInstance().loadConfigFileNotSet(this.workspaces,t.builds,t.statics):(await z.getInstance().loadAllAventusFiles(this.workspaces),await Ya.write()):js.sendDone(),this.isLoading=!1,e.debug(`start server done`)}runUpdate(){setTimeout(()=>{let t=`1.5.1`,n=F.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=Zp;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.5.1)`),i[a]()}catch(e){console.error(e)}F.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 Yo(`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}},Qp=class{static cmd=`aventus/closefile`;static action(e){}},$p=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}},em=class{static cmd=`aventus/editFile`;static async action(e){}},tm=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}},nm=class{static cmd=`aventus/server/stop`;static action(){}},rm=class{static cmd=`aventus/initStep`;static doneTxt=`Aventus : Done`;static action(e){e=e.replace(`$(loading~spin)`,`◌`),e==this.doneTxt&&ym.started()}},im=class{static cmd=`aventus/openfile`;static action(e){}},am=class{static cmd=`aventus/registerBuild`;static action(e){e.pathConfig,e.buildName}},om=class{static cmd=`aventus/registerData`;static action(e){}},sm=class{static cmd=`aventus/registerStatic`;static action(e){}},cm=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}}}},lm=class{static cmd=`aventus/unregisterBuild`;static action(e){e.pathConfig,e.buildName}},um=class{static cmd=`aventus/unregisterData`;static action(e){}},dm=class{static cmd=`aventus/unregisterStatic`;static action(e){}};const fm={allNotifications:{[Qp.cmd]:Qp,[$p.cmd]:$p,[tm.cmd]:tm,[nm.cmd]:nm,[im.cmd]:im,[am.cmd]:am,[om.cmd]:om,[sm.cmd]:sm,[lm.cmd]:lm,[um.cmd]:um,[dm.cmd]:dm,[em.cmd]:em,[rm.cmd]:rm,[cm.loadFileTime.cmd]:cm.loadFileTime,[cm.buildTime.cmd]:cm.buildTime,[cm.sizeFile.cmd]:cm.sizeFile,[cm.staticTime.cmd]:cm.staticTime}};function pm(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=mm(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function mm(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}m.DiagnosticSeverity.Error,m.DiagnosticSeverity.Warning,m.DiagnosticSeverity.Information,m.DiagnosticSeverity.Hint;var hm=class{notifications=fm;errorsByBuildByFile={};cbErrors=[];_connection;config;executeCommand;constructor(e){this._connection=new gm,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(`
|
|
1097
|
-
`),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++)ge.default.clearLine(process.stdout,0),ge.default.cursorTo(process.stdout,0),e<i-1&&ge.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:
|
|
1095
|
+
`),{range:ds(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=this.templateFiles[e.fileName];if(t)return[{uri:t.uri,range:ds(t.documentInternal,e.textSpan)}];let r=Pt(e.fileName);if(r){let t=d.TextDocument.create(e.fileName,`typescript`,1,r);return[{uri:e.fileName,range:ds(t,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||Pn(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={...Bp};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:ds(i,t.span),newText:t.newText});return s&&e.push({range:s,newText:Fn(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,Bp,zp)}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:ds(r,e.span)});n.push({title:e.description,edit:i})}}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);for(let e of i??[])for(let t of e.references){let e=this.templateFiles[t.fileName];e&&n.push(m.Location.create(t.fileName,ds(e.documentInternal,t.textSpan)))}}catch(e){this.printCatchError(e)}return n}async onCodeLens(e){return[]}async onRename(e,t,n){try{let r=e.documentInternal.offsetAt(t);if(!this.languageService.getRenameInfo(e.uri,r,{}).canRename)return null;let i=this.languageService.findRenameLocations(e.uri,r,!1,!1,{});if(!i)return null;let a={};for(let e of i){let t=this.templateFiles[e.fileName];t&&(a[e.fileName]??=[]).push(m.TextEdit.replace(ds(t.documentInternal,e.textSpan),n))}return Object.keys(a).length?{changes:a}:null}catch(e){return this.printCatchError(e),null}}printCatchError(t){e.printCatchError(t)}static printCatchError(e){/^Debug Failure\. Expected \d+ <= \d+$/g.test(e.message)||console.error(e)}};const Rp={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},zp={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`},Bp={convertTabsToSpaces:!0,tabSize:4,indentSize:4,indentStyle:p.IndentStyle.Smart,newLineCharacter:`
|
|
1096
|
+
`,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 Vp=class extends it{languageService;constructor(e){super(e),this.languageService=new Lp,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}},Hp=class e{static instance;static getInstance(){return this.instance||=new e,this.instance}constructor(){z.getInstance().onNewFile(this.onNewFile.bind(this))}async onNewFile(e){e.documentUser.uri.endsWith(E.Template)&&(new Vp(e),e instanceof O&&await e.validate())}},Up=class{};const Wp={allCommunications:{},list:[class extends Up{channel(){return`aventus.i18n.getKeyFromPosition`}async run(e){if(e.uri){let t=P.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 Up{channel(){return`aventus.i18n.getLocales`}async run(e){if(e.uri){let t=P.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 Gp=class{templateManager;constructor(e){this.templateManager=e}async createGlobal(e){try{let t=await this.templateManager.readGlobal(),n=await this.templateManager.query(e,t.templates,[{label:`Init`,detail:`Create a project`}]);n instanceof to?await n.init(e,this.templateManager.findWorkspace(e)):n&&await this.createProject(e)}catch(e){if(!(e instanceof no))throw e;$.showWarningMessage(`No templates available for this location. Browse templates: https://store.aventusjs.com/templates`)}}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=L(n)+`/.aventus/projects`;return this.templateManager.readTemplates([r],e,t)}return{templates:e,nb:t}}};function Kp(){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 qp(){let e=(0,f.join)($.savePath,`packages`);(0,u.existsSync)(e)&&Jp(e)}function Jp(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())Jp(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 Yp={"1.4.0":Kp,"1.4.1":qp};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 F.getInstance().settings.logLevel}isIDE=!1;_noBuild=!1;_savePath=``;_extensionPath=``;_logFile;_template;_localTemplate;_localProject;settingsLoadGeneration=0;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 Wp.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=F.getInstance().settings,t=[],n=async(e,n)=>{try{await n()}catch(n){t.push(Error(`${e}: ${n}`))}};return e.watchFiles&&await n(`FilesWatcher`,()=>As.getInstance().destroy()),e.useCompilators&&(await n(`CSharpManager`,()=>xa.getInstance().destroy()),await n(`PhpManager`,()=>Na.getInstance().destroy())),await n(`ProjectManager`,()=>P.getInstance().destroyAll()),await n(`FilesManager`,()=>z.getInstance().onShutdown()),t}async onCompletion(e,t){return this.isAllowed(e)?await z.getInstance().onCompletion(e,t):null}async onCompletionResolve(e,t){return this.isAllowed(e)?await z.getInstance().onCompletionResolve(e,t):t}async onHover(e,t){return this.isAllowed(e)?await z.getInstance().onHover(e,t):null}async onDefinition(e,t){return this.isAllowed(e)?await z.getInstance().onDefinition(e,t):null}async onDocumentFormatting(e,t){return this.isAllowed(e)?await z.getInstance().onFormatting(e,t):null}async onCodeAction(e,t){return this.isAllowed(e)?await z.getInstance().onCodeAction(e,t):null}async onCodeLens(e){return this.isAllowed(e)?await z.getInstance().onCodeLens(e):null}async onReferences(e,t){return this.isAllowed(e)?await z.getInstance().onReferences(e,t):null}async onRenameRequest(e,t,n){return this.isAllowed(e)?await z.getInstance().onRename(e,t,n):null}async onDocumentColor(e){return e&&this.isStyleDocument(e)?Fp.onDocumentColor(e):null}async onColorPresentation(e,t,n){return e&&this.isStyleDocument(e)?Fp.onColorPresentations(e,t,n):null}async onExecuteCommand(e){await eo.execute(e)}async onDidChangeConfiguration(){await this.loadSettings()}isAllowed(t){return t?e.isAllowed(t):!1}static isAllowed(e){return this.instance.isDown||this.instance.isLoading?!1:!!(e.uri.endsWith(E.Base)||e.uri.endsWith(E.Config)||e.uri.endsWith(E.Template))}isStyleDocument(e){return!!(e.uri.endsWith(E.ComponentStyle)||e.uri.endsWith(E.Component)||e.uri.endsWith(E.GlobalStyle))}async loadSettings(){this.settingsLoadGeneration++;let e=this.settingsLoadGeneration,t=await this.connection.getSettings();t||={};let n=await this.connection.getSettingsHtml();n||={},e===this.settingsLoadGeneration&&(F.getInstance().initSettings(t),F.getInstance().setSettingsHtml(n))}async startServer(){let t=F.getInstance().settings;t.useTemplates&&(this._template=new io(this.workspaces),await this._template.init(),this._localTemplate=new Ip(this._template),this._localProject=new Gp(this._template)),t.useCompilators&&(xa.getInstance(),Na.getInstance()),P.getInstance(),Hp.getInstance(),t.loadFiles?t.buildOnly?t.configPath?await z.getInstance().loadConfigFile(t.configPath,t.builds,t.statics):await z.getInstance().loadConfigFileNotSet(this.workspaces,t.builds,t.statics):(await z.getInstance().loadAllAventusFiles(this.workspaces),await qa.write()):ks.sendDone(),this.isLoading=!1,e.debug(`start server done`)}runUpdate(){setTimeout(()=>{let t=`1.5.3`,n=F.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=Yp;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.5.3)`),i[a]()}catch(e){console.error(e)}F.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 qo(`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}},Xp=class{static cmd=`aventus/closefile`;static action(e){}},Zp=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}},Qp=class{static cmd=`aventus/editFile`;static async action(e){}},$p=class{static cmd=`aventus/server/start`;static callbacks=[];static action(e){let t=[...this.callbacks];for(let n of t)n(e)}},em=class{static cmd=`aventus/server/stop`;static action(){}},tm=class{static cmd=`aventus/initStep`;static doneTxt=`Aventus : Done`;static action(e){e=e.replace(`$(loading~spin)`,`◌`),e==this.doneTxt&&_m.started()}},nm=class{static cmd=`aventus/openfile`;static action(e){}},rm=class{static cmd=`aventus/registerBuild`;static action(e){e.pathConfig,e.buildName}},im=class{static cmd=`aventus/registerData`;static action(e){}},am=class{static cmd=`aventus/registerStatic`;static action(e){}},om=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}}}},sm=class{static cmd=`aventus/unregisterBuild`;static action(e){e.pathConfig,e.buildName}},cm=class{static cmd=`aventus/unregisterData`;static action(e){}},lm=class{static cmd=`aventus/unregisterStatic`;static action(e){}};const um={allNotifications:{[Xp.cmd]:Xp,[Zp.cmd]:Zp,[$p.cmd]:$p,[em.cmd]:em,[nm.cmd]:nm,[rm.cmd]:rm,[im.cmd]:im,[am.cmd]:am,[sm.cmd]:sm,[cm.cmd]:cm,[lm.cmd]:lm,[Qp.cmd]:Qp,[tm.cmd]:tm,[om.loadFileTime.cmd]:om.loadFileTime,[om.buildTime.cmd]:om.buildTime,[om.sizeFile.cmd]:om.sizeFile,[om.staticTime.cmd]:om.staticTime}};function dm(e){if(e.startsWith(`file://`))return e;let t=e[0].toLowerCase()+e.substring(1);return t=fm(encodeURI(t.replace(/\\/g,`/`))),f.sep===`/`?`file://`+t:`file:///`+t}function fm(e){return e.replace(/:/g,`%3A`).replace(/@/g,`%40`)}m.DiagnosticSeverity.Error,m.DiagnosticSeverity.Warning,m.DiagnosticSeverity.Information,m.DiagnosticSeverity.Hint;var pm=class{notifications=um;errorsByBuildByFile={};cbErrors=[];_connection;config;executeCommand;constructor(e){this._connection=new mm,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(`
|
|
1097
|
+
`),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++)ge.default.clearLine(process.stdout,0),ge.default.cursorTo(process.stdout,0),e<i-1&&ge.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:dm(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 _m.interaction.password(e.title,t);let n=``;return e.title&&(n+=e.title),e.placeHolder&&(n!=``&&(n+=` - `),n+=e.placeHolder),await _m.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=0;t<e.length;t++){let n=e[t],i=n.detail?n.label+` - `+n.detail:n.label;r.push({value:String(t),name:i,checked:n.picked??!1})}let i=await _m.interaction.select(n,r);return i===null?null:e[Number(i)]??null}async SelectMultiple(e,t){let n=``;t.title&&(n+=t.title),t.placeHolder&&(n!=``&&(n+=` - `),n+=t.placeHolder);let r=[];for(let t=0;t<e.length;t++){let n=e[t],i=n.detail?n.label+` - `+n.detail:n.label;r.push({value:String(t),name:i,checked:n.picked??!1})}let i=await _m.interaction.selectMultiple(n,r);if(!i)return null;let a=[];for(let t of i){let n=e[Number(t)];n!==void 0&&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 _m.interaction.select(e,n)}else return console.log(e),null}async SelectFolder(e,t){return await _m.interaction.tree(e,`directory`,t)}},mm=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()}},hm=class{watcher;stack={created:[],deleted:[],updated:[]};mutex=new gm;timeout;stopped=!1;closing;stop(){return this.closing?this.closing:(this.stopped=!0,clearTimeout(this.timeout),this.timeout=void 0,this.stack={created:[],deleted:[],updated:[]},this.closing=this.watcher.close(),this.closing)}constructor(e){this.watcher=(0,me.watch)(e,{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){if(this.stopped||!e.endsWith(`.avt`))return;if(await this.mutex.waitOne(),this.stopped){this.mutex.release();return}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){if(this.stopped||!e.endsWith(`.avt`))return;if(await this.mutex.waitOne(),this.stopped){this.mutex.release();return}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){if(this.stopped||!e.endsWith(`.avt`))return;if(await this.mutex.waitOne(),this.stopped){this.mutex.release();return}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(){this.stopped||(clearTimeout(this.timeout),this.timeout=setTimeout(()=>{this.timeout=void 0,this.sendStack()},500))}async sendStack(){if(await this.mutex.waitOne(),this.stopped){this.mutex.release();return}try{await Ui.run({deleted:this.stack.deleted.map(I),created:this.stack.created.map(I),updated:this.stack.updated.map(I)}),this.stack={created:[],deleted:[],updated:[]}}finally{this.mutex.release()}}},gm=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}},_m=class{static _interaction;static get interaction(){return this._interaction}static server=null;static cliConnection=null;static filesWatcher=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,n)=>{try{if(!this.server)this.cliConnection=new pm(e),e.watchFiles&&(this.filesWatcher=new hm(process.cwd())),this.server=new $(this.cliConnection),e.noStart?t():(this.waitingStart=()=>{this.waitingStart=null,t()},this.server.start());else if(this.waitingStart){let e=this.waitingStart;this.waitingStart=()=>{e(),t()}}else t()}catch(e){this.waitingStart=null,this.server=null,this.cliConnection=null;let t=this.filesWatcher;this.filesWatcher=null,t?t.stop().then(()=>n(e),()=>n(e)):n(e)}})}static started(){this.waitingStart&&this.waitingStart()}static async create(){await Hi.run(I(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 om.info}static async Input(e){return this.cliConnection.Input(e)}};exports.RealServer=_m;
|