devicetree-language-server 0.2.4 → 0.2.5
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/dist/server.js +4 -4
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -179,7 +179,7 @@ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.pus
|
|
|
179
179
|
|| ${o} === "boolean" || ${s} === null`).assign(a,(0,ae._)`[${s}]`)}}}function aB({gen:r,parentData:e,parentDataProperty:t},n){r.if((0,ae._)`${e} !== undefined`,()=>r.assign((0,ae._)`${e}[${t}]`,n))}function rv(r,e,t,n=Uo.Correct){let s=n===Uo.Correct?ae.operators.EQ:ae.operators.NEQ,i;switch(r){case"null":return(0,ae._)`${e} ${s} null`;case"array":i=(0,ae._)`Array.isArray(${e})`;break;case"object":i=(0,ae._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":i=o((0,ae._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":i=o();break;default:return(0,ae._)`typeof ${e} ${s} ${r}`}return n===Uo.Correct?i:(0,ae.not)(i);function o(a=ae.nil){return(0,ae.and)((0,ae._)`typeof ${e} == "number"`,a,t?(0,ae._)`isFinite(${e})`:ae.nil)}}Jt.checkDataType=rv;function nv(r,e,t,n){if(r.length===1)return rv(r[0],e,t,n);let s,i=(0,lC.toHash)(r);if(i.array&&i.object){let o=(0,ae._)`typeof ${e} != "object"`;s=i.null?o:(0,ae._)`!${e} || ${o}`,delete i.null,delete i.array,delete i.object}else s=ae.nil;i.number&&delete i.integer;for(let o in i)s=(0,ae.and)(s,rv(o,e,t,n));return s}Jt.checkDataTypes=nv;var cB={message:({schema:r})=>`must be ${r}`,params:({schema:r,schemaValue:e})=>typeof r=="string"?(0,ae._)`{type: ${r}}`:(0,ae._)`{type: ${e}}`};function sv(r){let e=lB(r);(0,rB.reportError)(e,cB)}Jt.reportTypeError=sv;function lB(r){let{gen:e,data:t,schema:n}=r,s=(0,lC.schemaRefOrVal)(r,n,"type");return{gen:e,keyword:"type",data:t,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:r}}});var hC=k(qf=>{"use strict";Object.defineProperty(qf,"__esModule",{value:!0});qf.assignDefaults=void 0;var Vo=oe(),uB=he();function dB(r,e){let{properties:t,items:n}=r.schema;if(e==="object"&&t)for(let s in t)fC(r,s,t[s].default);else e==="array"&&Array.isArray(n)&&n.forEach((s,i)=>fC(r,i,s.default))}qf.assignDefaults=dB;function fC(r,e,t){let{gen:n,compositeRule:s,data:i,opts:o}=r;if(t===void 0)return;let a=(0,Vo._)`${i}${(0,Vo.getProperty)(e)}`;if(s){(0,uB.checkStrictMode)(r,`default is ignored for: ${a}`);return}let c=(0,Vo._)`${a} === undefined`;o.useDefaults==="empty"&&(c=(0,Vo._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Vo._)`${a} = ${(0,Vo.stringify)(t)}`)}});var qr=k(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.validateUnion=Fe.validateArray=Fe.usePattern=Fe.callValidateCode=Fe.schemaProperties=Fe.allSchemaProperties=Fe.noPropertyInData=Fe.propertyInData=Fe.isOwnProperty=Fe.hasPropFunc=Fe.reportMissingProp=Fe.checkMissingProp=Fe.checkReportMissingProp=void 0;var Ze=oe(),iv=he(),Os=$r(),fB=he();function hB(r,e){let{gen:t,data:n,it:s}=r;t.if(av(t,n,e,s.opts.ownProperties),()=>{r.setParams({missingProperty:(0,Ze._)`${e}`},!0),r.error()})}Fe.checkReportMissingProp=hB;function pB({gen:r,data:e,it:{opts:t}},n,s){return(0,Ze.or)(...n.map(i=>(0,Ze.and)(av(r,e,i,t.ownProperties),(0,Ze._)`${s} = ${i}`)))}Fe.checkMissingProp=pB;function mB(r,e){r.setParams({missingProperty:e},!0),r.error()}Fe.reportMissingProp=mB;function pC(r){return r.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Ze._)`Object.prototype.hasOwnProperty`})}Fe.hasPropFunc=pC;function ov(r,e,t){return(0,Ze._)`${pC(r)}.call(${e}, ${t})`}Fe.isOwnProperty=ov;function gB(r,e,t,n){let s=(0,Ze._)`${e}${(0,Ze.getProperty)(t)} !== undefined`;return n?(0,Ze._)`${s} && ${ov(r,e,t)}`:s}Fe.propertyInData=gB;function av(r,e,t,n){let s=(0,Ze._)`${e}${(0,Ze.getProperty)(t)} === undefined`;return n?(0,Ze.or)(s,(0,Ze.not)(ov(r,e,t))):s}Fe.noPropertyInData=av;function mC(r){return r?Object.keys(r).filter(e=>e!=="__proto__"):[]}Fe.allSchemaProperties=mC;function yB(r,e){return mC(e).filter(t=>!(0,iv.alwaysValidSchema)(r,e[t]))}Fe.schemaProperties=yB;function vB({schemaCode:r,data:e,it:{gen:t,topSchemaRef:n,schemaPath:s,errorPath:i},it:o},a,c,l){let u=l?(0,Ze._)`${r}, ${e}, ${n}${s}`:e,d=[[Os.default.instancePath,(0,Ze.strConcat)(Os.default.instancePath,i)],[Os.default.parentData,o.parentData],[Os.default.parentDataProperty,o.parentDataProperty],[Os.default.rootData,Os.default.rootData]];o.opts.dynamicRef&&d.push([Os.default.dynamicAnchors,Os.default.dynamicAnchors]);let f=(0,Ze._)`${u}, ${t.object(...d)}`;return c!==Ze.nil?(0,Ze._)`${a}.call(${c}, ${f})`:(0,Ze._)`${a}(${f})`}Fe.callValidateCode=vB;var bB=(0,Ze._)`new RegExp`;function TB({gen:r,it:{opts:e}},t){let n=e.unicodeRegExp?"u":"",{regExp:s}=e.code,i=s(t,n);return r.scopeValue("pattern",{key:i.toString(),ref:i,code:(0,Ze._)`${s.code==="new RegExp"?bB:(0,fB.useFunc)(r,s)}(${t}, ${n})`})}Fe.usePattern=TB;function _B(r){let{gen:e,data:t,keyword:n,it:s}=r,i=e.name("valid");if(s.allErrors){let a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(i,!0),o(()=>e.break()),i;function o(a){let c=e.const("len",(0,Ze._)`${t}.length`);e.forRange("i",0,c,l=>{r.subschema({keyword:n,dataProp:l,dataPropType:iv.Type.Num},i),e.if((0,Ze.not)(i),a)})}}Fe.validateArray=_B;function SB(r){let{gen:e,schema:t,keyword:n,it:s}=r;if(!Array.isArray(t))throw new Error("ajv implementation error");if(t.some(c=>(0,iv.alwaysValidSchema)(s,c))&&!s.opts.unevaluated)return;let o=e.let("valid",!1),a=e.name("_valid");e.block(()=>t.forEach((c,l)=>{let u=r.subschema({keyword:n,schemaProp:l,compositeRule:!0},a);e.assign(o,(0,Ze._)`${o} || ${a}`),r.mergeValidEvaluated(u,a)||e.if((0,Ze.not)(o))})),r.result(o,()=>r.reset(),()=>r.error(!0))}Fe.validateUnion=SB});var vC=k(wn=>{"use strict";Object.defineProperty(wn,"__esModule",{value:!0});wn.validateKeywordUsage=wn.validSchemaType=wn.funcKeywordCode=wn.macroKeywordCode=void 0;var sr=oe(),vi=$r(),kB=qr(),wB=Ac();function EB(r,e){let{gen:t,keyword:n,schema:s,parentSchema:i,it:o}=r,a=e.macro.call(o.self,s,i,o),c=yC(t,n,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);let l=t.name("valid");r.subschema({schema:a,schemaPath:sr.nil,errSchemaPath:`${o.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),r.pass(l,()=>r.error(!0))}wn.macroKeywordCode=EB;function NB(r,e){var t;let{gen:n,keyword:s,schema:i,parentSchema:o,$data:a,it:c}=r;RB(c,e);let l=!a&&e.compile?e.compile.call(c.self,i,o,c):e.validate,u=yC(n,s,l),d=n.let("valid");r.block$data(d,f),r.ok((t=e.valid)!==null&&t!==void 0?t:d);function f(){if(e.errors===!1)g(),e.modifying&&gC(r),_(()=>r.error());else{let w=e.async?p():b();e.modifying&&gC(r),_(()=>PB(r,w))}}function p(){let w=n.let("ruleErrs",null);return n.try(()=>g((0,sr._)`await `),T=>n.assign(d,!1).if((0,sr._)`${T} instanceof ${c.ValidationError}`,()=>n.assign(w,(0,sr._)`${T}.errors`),()=>n.throw(T))),w}function b(){let w=(0,sr._)`${u}.errors`;return n.assign(w,null),g(sr.nil),w}function g(w=e.async?(0,sr._)`await `:sr.nil){let T=c.opts.passContext?vi.default.this:vi.default.self,v=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,sr._)`${w}${(0,kB.callValidateCode)(r,u,T,v)}`,e.modifying)}function _(w){var T;n.if((0,sr.not)((T=e.valid)!==null&&T!==void 0?T:d),w)}}wn.funcKeywordCode=NB;function gC(r){let{gen:e,data:t,it:n}=r;e.if(n.parentData,()=>e.assign(t,(0,sr._)`${n.parentData}[${n.parentDataProperty}]`))}function PB(r,e){let{gen:t}=r;t.if((0,sr._)`Array.isArray(${e})`,()=>{t.assign(vi.default.vErrors,(0,sr._)`${vi.default.vErrors} === null ? ${e} : ${vi.default.vErrors}.concat(${e})`).assign(vi.default.errors,(0,sr._)`${vi.default.vErrors}.length`),(0,wB.extendErrors)(r)},()=>r.error())}function RB({schemaEnv:r},e){if(e.async&&!r.$async)throw new Error("async keyword in sync schema")}function yC(r,e,t){if(t===void 0)throw new Error(`keyword "${e}" failed to compile`);return r.scopeValue("keyword",typeof t=="function"?{ref:t}:{ref:t,code:(0,sr.stringify)(t)})}function CB(r,e,t=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(r):n==="object"?r&&typeof r=="object"&&!Array.isArray(r):typeof r==n||t&&typeof r>"u")}wn.validSchemaType=CB;function DB({schema:r,opts:e,self:t,errSchemaPath:n},s,i){if(Array.isArray(s.keyword)?!s.keyword.includes(i):s.keyword!==i)throw new Error("ajv implementation error");let o=s.dependencies;if(o?.some(a=>!Object.prototype.hasOwnProperty.call(r,a)))throw new Error(`parent schema must have dependencies of ${i}: ${o.join(",")}`);if(s.validateSchema&&!s.validateSchema(r[i])){let c=`keyword "${i}" value is invalid at path "${n}": `+t.errorsText(s.validateSchema.errors);if(e.validateSchema==="log")t.logger.error(c);else throw new Error(c)}}wn.validateKeywordUsage=DB});var TC=k(As=>{"use strict";Object.defineProperty(As,"__esModule",{value:!0});As.extendSubschemaMode=As.extendSubschemaData=As.getSubschema=void 0;var En=oe(),bC=he();function OB(r,{keyword:e,schemaProp:t,schema:n,schemaPath:s,errSchemaPath:i,topSchemaRef:o}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=r.schema[e];return t===void 0?{schema:a,schemaPath:(0,En._)`${r.schemaPath}${(0,En.getProperty)(e)}`,errSchemaPath:`${r.errSchemaPath}/${e}`}:{schema:a[t],schemaPath:(0,En._)`${r.schemaPath}${(0,En.getProperty)(e)}${(0,En.getProperty)(t)}`,errSchemaPath:`${r.errSchemaPath}/${e}/${(0,bC.escapeFragment)(t)}`}}if(n!==void 0){if(s===void 0||i===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:s,topSchemaRef:o,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')}As.getSubschema=OB;function AB(r,e,{dataProp:t,dataPropType:n,data:s,dataTypes:i,propertyName:o}){if(s!==void 0&&t!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(t!==void 0){let{errorPath:l,dataPathArr:u,opts:d}=e,f=a.let("data",(0,En._)`${e.data}${(0,En.getProperty)(t)}`,!0);c(f),r.errorPath=(0,En.str)`${l}${(0,bC.getErrorPath)(t,n,d.jsPropertySyntax)}`,r.parentDataProperty=(0,En._)`${t}`,r.dataPathArr=[...u,r.parentDataProperty]}if(s!==void 0){let l=s instanceof En.Name?s:a.let("data",s,!0);c(l),o!==void 0&&(r.propertyName=o)}i&&(r.dataTypes=i);function c(l){r.data=l,r.dataLevel=e.dataLevel+1,r.dataTypes=[],e.definedProperties=new Set,r.parentData=e.data,r.dataNames=[...e.dataNames,l]}}As.extendSubschemaData=AB;function IB(r,{jtdDiscriminator:e,jtdMetadata:t,compositeRule:n,createErrors:s,allErrors:i}){n!==void 0&&(r.compositeRule=n),s!==void 0&&(r.createErrors=s),i!==void 0&&(r.allErrors=i),r.jtdDiscriminator=e,r.jtdMetadata=t}As.extendSubschemaMode=IB});var cv=k((S7,_C)=>{"use strict";_C.exports=function r(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var n,s,i;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(s=n;s--!==0;)if(!r(e[s],t[s]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(s=n;s--!==0;)if(!Object.prototype.hasOwnProperty.call(t,i[s]))return!1;for(s=n;s--!==0;){var o=i[s];if(!r(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}});var kC=k((k7,SC)=>{"use strict";var Is=SC.exports=function(r,e,t){typeof e=="function"&&(t=e,e={}),t=e.cb||t;var n=typeof t=="function"?t:t.pre||function(){},s=t.post||function(){};jf(e,n,s,r,"",r)};Is.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Is.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Is.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Is.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function jf(r,e,t,n,s,i,o,a,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,s,i,o,a,c,l);for(var u in n){var d=n[u];if(Array.isArray(d)){if(u in Is.arrayKeywords)for(var f=0;f<d.length;f++)jf(r,e,t,d[f],s+"/"+u+"/"+f,i,s,u,n,f)}else if(u in Is.propsKeywords){if(d&&typeof d=="object")for(var p in d)jf(r,e,t,d[p],s+"/"+u+"/"+MB(p),i,s,u,n,p)}else(u in Is.keywords||r.allKeys&&!(u in Is.skipKeywords))&&jf(r,e,t,d,s+"/"+u,i,s,u,n)}t(n,s,i,o,a,c,l)}}function MB(r){return r.replace(/~/g,"~0").replace(/\//g,"~1")}});var Mc=k(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.getSchemaRefs=mr.resolveUrl=mr.normalizeId=mr._getFullPath=mr.getFullPath=mr.inlineRef=void 0;var xB=he(),LB=cv(),$B=kC(),qB=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function jB(r,e=!0){return typeof r=="boolean"?!0:e===!0?!lv(r):e?wC(r)<=e:!1}mr.inlineRef=jB;var FB=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function lv(r){for(let e in r){if(FB.has(e))return!0;let t=r[e];if(Array.isArray(t)&&t.some(lv)||typeof t=="object"&&lv(t))return!0}return!1}function wC(r){let e=0;for(let t in r){if(t==="$ref")return 1/0;if(e++,!qB.has(t)&&(typeof r[t]=="object"&&(0,xB.eachItem)(r[t],n=>e+=wC(n)),e===1/0))return 1/0}return e}function EC(r,e="",t){t!==!1&&(e=Wo(e));let n=r.parse(e);return NC(r,n)}mr.getFullPath=EC;function NC(r,e){return r.serialize(e).split("#")[0]+"#"}mr._getFullPath=NC;var BB=/#\/?$/;function Wo(r){return r?r.replace(BB,""):""}mr.normalizeId=Wo;function UB(r,e,t){return t=Wo(t),r.resolve(e,t)}mr.resolveUrl=UB;var VB=/^[a-z_][-a-z0-9._]*$/i;function WB(r,e){if(typeof r=="boolean")return{};let{schemaId:t,uriResolver:n}=this.opts,s=Wo(r[t]||e),i={"":s},o=EC(n,s,!1),a={},c=new Set;return $B(r,{allKeys:!0},(d,f,p,b)=>{if(b===void 0)return;let g=o+f,_=i[b];typeof d[t]=="string"&&(_=w.call(this,d[t])),T.call(this,d.$anchor),T.call(this,d.$dynamicAnchor),i[f]=_;function w(v){let R=this.opts.uriResolver.resolve;if(v=Wo(_?R(_,v):v),c.has(v))throw u(v);c.add(v);let A=this.refs[v];return typeof A=="string"&&(A=this.refs[A]),typeof A=="object"?l(d,A.schema,v):v!==Wo(g)&&(v[0]==="#"?(l(d,a[v],v),a[v]=d):this.refs[v]=g),v}function T(v){if(typeof v=="string"){if(!VB.test(v))throw new Error(`invalid anchor "${v}"`);w.call(this,`#${v}`)}}}),a;function l(d,f,p){if(f!==void 0&&!LB(d,f))throw u(p)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}mr.getSchemaRefs=WB});var $c=k(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});Ms.getData=Ms.KeywordCxt=Ms.validateFunctionCode=void 0;var OC=oC(),PC=Ic(),dv=tv(),Ff=Ic(),HB=hC(),Lc=vC(),uv=TC(),Y=oe(),te=$r(),KB=Mc(),Hn=he(),xc=Ac();function zB(r){if(MC(r)&&(xC(r),IC(r))){JB(r);return}AC(r,()=>(0,OC.topBoolOrEmptySchema)(r))}Ms.validateFunctionCode=zB;function AC({gen:r,validateName:e,schema:t,schemaEnv:n,opts:s},i){s.code.es5?r.func(e,(0,Y._)`${te.default.data}, ${te.default.valCxt}`,n.$async,()=>{r.code((0,Y._)`"use strict"; ${RC(t,s)}`),YB(r,s),r.code(i)}):r.func(e,(0,Y._)`${te.default.data}, ${GB(s)}`,n.$async,()=>r.code(RC(t,s)).code(i))}function GB(r){return(0,Y._)`{${te.default.instancePath}="", ${te.default.parentData}, ${te.default.parentDataProperty}, ${te.default.rootData}=${te.default.data}${r.dynamicRef?(0,Y._)`, ${te.default.dynamicAnchors}={}`:Y.nil}}={}`}function YB(r,e){r.if(te.default.valCxt,()=>{r.var(te.default.instancePath,(0,Y._)`${te.default.valCxt}.${te.default.instancePath}`),r.var(te.default.parentData,(0,Y._)`${te.default.valCxt}.${te.default.parentData}`),r.var(te.default.parentDataProperty,(0,Y._)`${te.default.valCxt}.${te.default.parentDataProperty}`),r.var(te.default.rootData,(0,Y._)`${te.default.valCxt}.${te.default.rootData}`),e.dynamicRef&&r.var(te.default.dynamicAnchors,(0,Y._)`${te.default.valCxt}.${te.default.dynamicAnchors}`)},()=>{r.var(te.default.instancePath,(0,Y._)`""`),r.var(te.default.parentData,(0,Y._)`undefined`),r.var(te.default.parentDataProperty,(0,Y._)`undefined`),r.var(te.default.rootData,te.default.data),e.dynamicRef&&r.var(te.default.dynamicAnchors,(0,Y._)`{}`)})}function JB(r){let{schema:e,opts:t,gen:n}=r;AC(r,()=>{t.$comment&&e.$comment&&$C(r),tU(r),n.let(te.default.vErrors,null),n.let(te.default.errors,0),t.unevaluated&&XB(r),LC(r),sU(r)})}function XB(r){let{gen:e,validateName:t}=r;r.evaluated=e.const("evaluated",(0,Y._)`${t}.evaluated`),e.if((0,Y._)`${r.evaluated}.dynamicProps`,()=>e.assign((0,Y._)`${r.evaluated}.props`,(0,Y._)`undefined`)),e.if((0,Y._)`${r.evaluated}.dynamicItems`,()=>e.assign((0,Y._)`${r.evaluated}.items`,(0,Y._)`undefined`))}function RC(r,e){let t=typeof r=="object"&&r[e.schemaId];return t&&(e.code.source||e.code.process)?(0,Y._)`/*# sourceURL=${t} */`:Y.nil}function QB(r,e){if(MC(r)&&(xC(r),IC(r))){ZB(r,e);return}(0,OC.boolOrEmptySchema)(r,e)}function IC({schema:r,self:e}){if(typeof r=="boolean")return!r;for(let t in r)if(e.RULES.all[t])return!0;return!1}function MC(r){return typeof r.schema!="boolean"}function ZB(r,e){let{schema:t,gen:n,opts:s}=r;s.$comment&&t.$comment&&$C(r),rU(r),nU(r);let i=n.const("_errs",te.default.errors);LC(r,i),n.var(e,(0,Y._)`${i} === ${te.default.errors}`)}function xC(r){(0,Hn.checkUnknownRules)(r),eU(r)}function LC(r,e){if(r.opts.jtd)return CC(r,[],!1,e);let t=(0,PC.getSchemaTypes)(r.schema),n=(0,PC.coerceAndCheckDataType)(r,t);CC(r,t,!n,e)}function eU(r){let{schema:e,errSchemaPath:t,opts:n,self:s}=r;e.$ref&&n.ignoreKeywordsWithRef&&(0,Hn.schemaHasRulesButRef)(e,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${t}"`)}function tU(r){let{schema:e,opts:t}=r;e.default!==void 0&&t.useDefaults&&t.strictSchema&&(0,Hn.checkStrictMode)(r,"default is ignored in the schema root")}function rU(r){let e=r.schema[r.opts.schemaId];e&&(r.baseId=(0,KB.resolveUrl)(r.opts.uriResolver,r.baseId,e))}function nU(r){if(r.schema.$async&&!r.schemaEnv.$async)throw new Error("async schema in sync schema")}function $C({gen:r,schemaEnv:e,schema:t,errSchemaPath:n,opts:s}){let i=t.$comment;if(s.$comment===!0)r.code((0,Y._)`${te.default.self}.logger.log(${i})`);else if(typeof s.$comment=="function"){let o=(0,Y.str)`${n}/$comment`,a=r.scopeValue("root",{ref:e.root});r.code((0,Y._)`${te.default.self}.opts.$comment(${i}, ${o}, ${a}.schema)`)}}function sU(r){let{gen:e,schemaEnv:t,validateName:n,ValidationError:s,opts:i}=r;t.$async?e.if((0,Y._)`${te.default.errors} === 0`,()=>e.return(te.default.data),()=>e.throw((0,Y._)`new ${s}(${te.default.vErrors})`)):(e.assign((0,Y._)`${n}.errors`,te.default.vErrors),i.unevaluated&&iU(r),e.return((0,Y._)`${te.default.errors} === 0`))}function iU({gen:r,evaluated:e,props:t,items:n}){t instanceof Y.Name&&r.assign((0,Y._)`${e}.props`,t),n instanceof Y.Name&&r.assign((0,Y._)`${e}.items`,n)}function CC(r,e,t,n){let{gen:s,schema:i,data:o,allErrors:a,opts:c,self:l}=r,{RULES:u}=l;if(i.$ref&&(c.ignoreKeywordsWithRef||!(0,Hn.schemaHasRulesButRef)(i,u))){s.block(()=>jC(r,"$ref",u.all.$ref.definition));return}c.jtd||oU(r,e),s.block(()=>{for(let f of u.rules)d(f);d(u.post)});function d(f){(0,dv.shouldUseGroup)(i,f)&&(f.type?(s.if((0,Ff.checkDataType)(f.type,o,c.strictNumbers)),DC(r,f),e.length===1&&e[0]===f.type&&t&&(s.else(),(0,Ff.reportTypeError)(r)),s.endIf()):DC(r,f),a||s.if((0,Y._)`${te.default.errors} === ${n||0}`))}}function DC(r,e){let{gen:t,schema:n,opts:{useDefaults:s}}=r;s&&(0,HB.assignDefaults)(r,e.type),t.block(()=>{for(let i of e.rules)(0,dv.shouldUseRule)(n,i)&&jC(r,i.keyword,i.definition,e.type)})}function oU(r,e){r.schemaEnv.meta||!r.opts.strictTypes||(aU(r,e),r.opts.allowUnionTypes||cU(r,e),lU(r,r.dataTypes))}function aU(r,e){if(e.length){if(!r.dataTypes.length){r.dataTypes=e;return}e.forEach(t=>{qC(r.dataTypes,t)||fv(r,`type "${t}" not allowed by context "${r.dataTypes.join(",")}"`)}),dU(r,e)}}function cU(r,e){e.length>1&&!(e.length===2&&e.includes("null"))&&fv(r,"use allowUnionTypes to allow union type keyword")}function lU(r,e){let t=r.self.RULES.all;for(let n in t){let s=t[n];if(typeof s=="object"&&(0,dv.shouldUseRule)(r.schema,s)){let{type:i}=s.definition;i.length&&!i.some(o=>uU(e,o))&&fv(r,`missing type "${i.join(",")}" for keyword "${n}"`)}}}function uU(r,e){return r.includes(e)||e==="number"&&r.includes("integer")}function qC(r,e){return r.includes(e)||e==="integer"&&r.includes("number")}function dU(r,e){let t=[];for(let n of r.dataTypes)qC(e,n)?t.push(n):e.includes("integer")&&n==="number"&&t.push("integer");r.dataTypes=t}function fv(r,e){let t=r.schemaEnv.baseId+r.errSchemaPath;e+=` at "${t}" (strictTypes)`,(0,Hn.checkStrictMode)(r,e,r.opts.strictTypes)}var Bf=class{constructor(e,t,n){if((0,Lc.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Hn.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",FC(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Lc.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const("_errs",te.default.errors))}result(e,t,n){this.failResult((0,Y.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,Y.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,Y._)`${t} !== undefined && (${(0,Y.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?xc.reportExtraError:xc.reportError)(this,this.def.error,t)}$dataError(){(0,xc.reportError)(this,this.def.$dataError||xc.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,xc.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=Y.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=Y.nil,t=Y.nil){if(!this.$data)return;let{gen:n,schemaCode:s,schemaType:i,def:o}=this;n.if((0,Y.or)((0,Y._)`${s} === undefined`,t)),e!==Y.nil&&n.assign(e,!0),(i.length||o.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==Y.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:s,it:i}=this;return(0,Y.or)(o(),a());function o(){if(n.length){if(!(t instanceof Y.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,Y._)`${(0,Ff.checkDataTypes)(c,t,i.opts.strictNumbers,Ff.DataType.Wrong)}`}return Y.nil}function a(){if(s.validateSchema){let c=e.scopeValue("validate$data",{ref:s.validateSchema});return(0,Y._)`!${c}(${t})`}return Y.nil}}subschema(e,t){let n=(0,uv.getSubschema)(this.it,e);(0,uv.extendSubschemaData)(n,this.it,e),(0,uv.extendSubschemaMode)(n,e);let s={...this.it,...n,items:void 0,props:void 0};return QB(s,t),s}mergeEvaluated(e,t){let{it:n,gen:s}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Hn.mergeEvaluated.props(s,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=Hn.mergeEvaluated.items(s,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:s}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return s.if(t,()=>this.mergeEvaluated(e,Y.Name)),!0}};Ms.KeywordCxt=Bf;function jC(r,e,t,n){let s=new Bf(r,t,e);"code"in t?t.code(s,n):s.$data&&t.validate?(0,Lc.funcKeywordCode)(s,t):"macro"in t?(0,Lc.macroKeywordCode)(s,t):(t.compile||t.validate)&&(0,Lc.funcKeywordCode)(s,t)}var fU=/^\/(?:[^~]|~0|~1)*$/,hU=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function FC(r,{dataLevel:e,dataNames:t,dataPathArr:n}){let s,i;if(r==="")return te.default.rootData;if(r[0]==="/"){if(!fU.test(r))throw new Error(`Invalid JSON-pointer: ${r}`);s=r,i=te.default.rootData}else{let l=hU.exec(r);if(!l)throw new Error(`Invalid JSON-pointer: ${r}`);let u=+l[1];if(s=l[2],s==="#"){if(u>=e)throw new Error(c("property/index",u));return n[e-u]}if(u>e)throw new Error(c("data",u));if(i=t[e-u],!s)return i}let o=i,a=s.split("/");for(let l of a)l&&(i=(0,Y._)`${i}${(0,Y.getProperty)((0,Hn.unescapeJsonPointer)(l))}`,o=(0,Y._)`${o} && ${i}`);return o;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${e}`}}Ms.getData=FC});var Uf=k(pv=>{"use strict";Object.defineProperty(pv,"__esModule",{value:!0});var hv=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};pv.default=hv});var qc=k(yv=>{"use strict";Object.defineProperty(yv,"__esModule",{value:!0});var mv=Mc(),gv=class extends Error{constructor(e,t,n,s){super(s||`can't resolve reference ${n} from id ${t}`),this.missingRef=(0,mv.resolveUrl)(e,t,n),this.missingSchema=(0,mv.normalizeId)((0,mv.getFullPath)(e,this.missingRef))}};yv.default=gv});var jc=k(jr=>{"use strict";Object.defineProperty(jr,"__esModule",{value:!0});jr.resolveSchema=jr.getCompilingSchema=jr.resolveRef=jr.compileSchema=jr.SchemaEnv=void 0;var on=oe(),pU=Uf(),bi=$r(),an=Mc(),BC=he(),mU=$c(),Ho=class{constructor(e){var t;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(t=e.baseId)!==null&&t!==void 0?t:(0,an.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};jr.SchemaEnv=Ho;function bv(r){let e=UC.call(this,r);if(e)return e;let t=(0,an.getFullPath)(this.opts.uriResolver,r.root.baseId),{es5:n,lines:s}=this.opts.code,{ownProperties:i}=this.opts,o=new on.CodeGen(this.scope,{es5:n,lines:s,ownProperties:i}),a;r.$async&&(a=o.scopeValue("Error",{ref:pU.default,code:(0,on._)`require("ajv/dist/runtime/validation_error").default`}));let c=o.scopeName("validate");r.validateName=c;let l={gen:o,allErrors:this.opts.allErrors,data:bi.default.data,parentData:bi.default.parentData,parentDataProperty:bi.default.parentDataProperty,dataNames:[bi.default.data],dataPathArr:[on.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:r.schema,code:(0,on.stringify)(r.schema)}:{ref:r.schema}),validateName:c,ValidationError:a,schema:r.schema,schemaEnv:r,rootId:t,baseId:r.baseId||t,schemaPath:on.nil,errSchemaPath:r.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,on._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(r),(0,mU.validateFunctionCode)(l),o.optimize(this.opts.code.optimize);let d=o.toString();u=`${o.scopeRefs(bi.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,r));let p=new Function(`${bi.default.self}`,`${bi.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=r.schema,p.schemaEnv=r,r.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:o._values}),this.opts.unevaluated){let{props:b,items:g}=l;p.evaluated={props:b instanceof on.Name?void 0:b,items:g instanceof on.Name?void 0:g,dynamicProps:b instanceof on.Name,dynamicItems:g instanceof on.Name},p.source&&(p.source.evaluated=(0,on.stringify)(p.evaluated))}return r.validate=p,r}catch(d){throw delete r.validate,delete r.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(r)}}jr.compileSchema=bv;function gU(r,e,t){var n;t=(0,an.resolveUrl)(this.opts.uriResolver,e,t);let s=r.refs[t];if(s)return s;let i=bU.call(this,r,t);if(i===void 0){let o=(n=r.localRefs)===null||n===void 0?void 0:n[t],{schemaId:a}=this.opts;o&&(i=new Ho({schema:o,schemaId:a,root:r,baseId:e}))}if(i!==void 0)return r.refs[t]=yU.call(this,i)}jr.resolveRef=gU;function yU(r){return(0,an.inlineRef)(r.schema,this.opts.inlineRefs)?r.schema:r.validate?r:bv.call(this,r)}function UC(r){for(let e of this._compilations)if(vU(e,r))return e}jr.getCompilingSchema=UC;function vU(r,e){return r.schema===e.schema&&r.root===e.root&&r.baseId===e.baseId}function bU(r,e){let t;for(;typeof(t=this.refs[e])=="string";)e=t;return t||this.schemas[e]||Vf.call(this,r,e)}function Vf(r,e){let t=this.opts.uriResolver.parse(e),n=(0,an._getFullPath)(this.opts.uriResolver,t),s=(0,an.getFullPath)(this.opts.uriResolver,r.baseId,void 0);if(Object.keys(r.schema).length>0&&n===s)return vv.call(this,t,r);let i=(0,an.normalizeId)(n),o=this.refs[i]||this.schemas[i];if(typeof o=="string"){let a=Vf.call(this,r,o);return typeof a?.schema!="object"?void 0:vv.call(this,t,a)}if(typeof o?.schema=="object"){if(o.validate||bv.call(this,o),i===(0,an.normalizeId)(e)){let{schema:a}=o,{schemaId:c}=this.opts,l=a[c];return l&&(s=(0,an.resolveUrl)(this.opts.uriResolver,s,l)),new Ho({schema:a,schemaId:c,root:r,baseId:s})}return vv.call(this,t,o)}}jr.resolveSchema=Vf;var TU=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function vv(r,{baseId:e,schema:t,root:n}){var s;if(((s=r.fragment)===null||s===void 0?void 0:s[0])!=="/")return;for(let a of r.fragment.slice(1).split("/")){if(typeof t=="boolean")return;let c=t[(0,BC.unescapeFragment)(a)];if(c===void 0)return;t=c;let l=typeof t=="object"&&t[this.opts.schemaId];!TU.has(a)&&l&&(e=(0,an.resolveUrl)(this.opts.uriResolver,e,l))}let i;if(typeof t!="boolean"&&t.$ref&&!(0,BC.schemaHasRulesButRef)(t,this.RULES)){let a=(0,an.resolveUrl)(this.opts.uriResolver,e,t.$ref);i=Vf.call(this,n,a)}let{schemaId:o}=this.opts;if(i=i||new Ho({schema:t,schemaId:o,root:n,baseId:e}),i.schema!==i.root.schema)return i}});var VC=k((C7,_U)=>{_U.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var HC=k((D7,WC)=>{"use strict";var SU={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};WC.exports={HEX:SU}});var ZC=k((O7,QC)=>{"use strict";var{HEX:kU}=HC(),wU=/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u;function YC(r){if(XC(r,".")<3)return{host:r,isIPV4:!1};let e=r.match(wU)||[],[t]=e;return t?{host:NU(t,"."),isIPV4:!0}:{host:r,isIPV4:!1}}function Tv(r,e=!1){let t="",n=!0;for(let s of r){if(kU[s]===void 0)return;s!=="0"&&n===!0&&(n=!1),n||(t+=s)}return e&&t.length===0&&(t="0"),t}function EU(r){let e=0,t={error:!1,address:"",zone:""},n=[],s=[],i=!1,o=!1,a=!1;function c(){if(s.length){if(i===!1){let l=Tv(s);if(l!==void 0)n.push(l);else return t.error=!0,!1}s.length=0}return!0}for(let l=0;l<r.length;l++){let u=r[l];if(!(u==="["||u==="]"))if(u===":"){if(o===!0&&(a=!0),!c())break;if(e++,n.push(":"),e>7){t.error=!0;break}l-1>=0&&r[l-1]===":"&&(o=!0);continue}else if(u==="%"){if(!c())break;i=!0}else{s.push(u);continue}}return s.length&&(i?t.zone=s.join(""):a?n.push(s.join("")):n.push(Tv(s))),t.address=n.join(""),t}function JC(r){if(XC(r,":")<2)return{host:r,isIPV6:!1};let e=EU(r);if(e.error)return{host:r,isIPV6:!1};{let t=e.address,n=e.address;return e.zone&&(t+="%"+e.zone,n+="%25"+e.zone),{host:t,escapedHost:n,isIPV6:!0}}}function NU(r,e){let t="",n=!0,s=r.length;for(let i=0;i<s;i++){let o=r[i];o==="0"&&n?(i+1<=s&&r[i+1]===e||i+1===s)&&(t+=o,n=!1):(o===e?n=!0:n=!1,t+=o)}return t}function XC(r,e){let t=0;for(let n=0;n<r.length;n++)r[n]===e&&t++;return t}var KC=/^\.\.?\//u,zC=/^\/\.(?:\/|$)/u,GC=/^\/\.\.(?:\/|$)/u,PU=/^\/?(?:.|\n)*?(?=\/|$)/u;function RU(r){let e=[];for(;r.length;)if(r.match(KC))r=r.replace(KC,"");else if(r.match(zC))r=r.replace(zC,"/");else if(r.match(GC))r=r.replace(GC,"/"),e.pop();else if(r==="."||r==="..")r="";else{let t=r.match(PU);if(t){let n=t[0];r=r.slice(n.length),e.push(n)}else throw new Error("Unexpected dot segment condition")}return e.join("")}function CU(r,e){let t=e!==!0?escape:unescape;return r.scheme!==void 0&&(r.scheme=t(r.scheme)),r.userinfo!==void 0&&(r.userinfo=t(r.userinfo)),r.host!==void 0&&(r.host=t(r.host)),r.path!==void 0&&(r.path=t(r.path)),r.query!==void 0&&(r.query=t(r.query)),r.fragment!==void 0&&(r.fragment=t(r.fragment)),r}function DU(r){let e=[];if(r.userinfo!==void 0&&(e.push(r.userinfo),e.push("@")),r.host!==void 0){let t=unescape(r.host),n=YC(t);if(n.isIPV4)t=n.host;else{let s=JC(n.host);s.isIPV6===!0?t=`[${s.escapedHost}]`:t=r.host}e.push(t)}return(typeof r.port=="number"||typeof r.port=="string")&&(e.push(":"),e.push(String(r.port))),e.length?e.join(""):void 0}QC.exports={recomposeAuthority:DU,normalizeComponentEncoding:CU,removeDotSegments:RU,normalizeIPv4:YC,normalizeIPv6:JC,stringArrayToHexStripped:Tv}});var iD=k((A7,sD)=>{"use strict";var OU=/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu,AU=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function eD(r){return typeof r.secure=="boolean"?r.secure:String(r.scheme).toLowerCase()==="wss"}function tD(r){return r.host||(r.error=r.error||"HTTP URIs must have a host."),r}function rD(r){let e=String(r.scheme).toLowerCase()==="https";return(r.port===(e?443:80)||r.port==="")&&(r.port=void 0),r.path||(r.path="/"),r}function IU(r){return r.secure=eD(r),r.resourceName=(r.path||"/")+(r.query?"?"+r.query:""),r.path=void 0,r.query=void 0,r}function MU(r){if((r.port===(eD(r)?443:80)||r.port==="")&&(r.port=void 0),typeof r.secure=="boolean"&&(r.scheme=r.secure?"wss":"ws",r.secure=void 0),r.resourceName){let[e,t]=r.resourceName.split("?");r.path=e&&e!=="/"?e:void 0,r.query=t,r.resourceName=void 0}return r.fragment=void 0,r}function xU(r,e){if(!r.path)return r.error="URN can not be parsed",r;let t=r.path.match(AU);if(t){let n=e.scheme||r.scheme||"urn";r.nid=t[1].toLowerCase(),r.nss=t[2];let s=`${n}:${e.nid||r.nid}`,i=_v[s];r.path=void 0,i&&(r=i.parse(r,e))}else r.error=r.error||"URN can not be parsed.";return r}function LU(r,e){let t=e.scheme||r.scheme||"urn",n=r.nid.toLowerCase(),s=`${t}:${e.nid||n}`,i=_v[s];i&&(r=i.serialize(r,e));let o=r,a=r.nss;return o.path=`${n||e.nid}:${a}`,e.skipEscape=!0,o}function $U(r,e){let t=r;return t.uuid=t.nss,t.nss=void 0,!e.tolerant&&(!t.uuid||!OU.test(t.uuid))&&(t.error=t.error||"UUID is not valid."),t}function qU(r){let e=r;return e.nss=(r.uuid||"").toLowerCase(),e}var nD={scheme:"http",domainHost:!0,parse:tD,serialize:rD},jU={scheme:"https",domainHost:nD.domainHost,parse:tD,serialize:rD},Wf={scheme:"ws",domainHost:!0,parse:IU,serialize:MU},FU={scheme:"wss",domainHost:Wf.domainHost,parse:Wf.parse,serialize:Wf.serialize},BU={scheme:"urn",parse:xU,serialize:LU,skipNormalize:!0},UU={scheme:"urn:uuid",parse:$U,serialize:qU,skipNormalize:!0},_v={http:nD,https:jU,ws:Wf,wss:FU,urn:BU,"urn:uuid":UU};sD.exports=_v});var aD=k((I7,Kf)=>{"use strict";var{normalizeIPv6:VU,normalizeIPv4:WU,removeDotSegments:Fc,recomposeAuthority:HU,normalizeComponentEncoding:Hf}=ZC(),Sv=iD();function KU(r,e){return typeof r=="string"?r=Nn(Kn(r,e),e):typeof r=="object"&&(r=Kn(Nn(r,e),e)),r}function zU(r,e,t){let n=Object.assign({scheme:"null"},t),s=oD(Kn(r,n),Kn(e,n),n,!0);return Nn(s,{...n,skipEscape:!0})}function oD(r,e,t,n){let s={};return n||(r=Kn(Nn(r,t),t),e=Kn(Nn(e,t),t)),t=t||{},!t.tolerant&&e.scheme?(s.scheme=e.scheme,s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=Fc(e.path||""),s.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(s.userinfo=e.userinfo,s.host=e.host,s.port=e.port,s.path=Fc(e.path||""),s.query=e.query):(e.path?(e.path.charAt(0)==="/"?s.path=Fc(e.path):((r.userinfo!==void 0||r.host!==void 0||r.port!==void 0)&&!r.path?s.path="/"+e.path:r.path?s.path=r.path.slice(0,r.path.lastIndexOf("/")+1)+e.path:s.path=e.path,s.path=Fc(s.path)),s.query=e.query):(s.path=r.path,e.query!==void 0?s.query=e.query:s.query=r.query),s.userinfo=r.userinfo,s.host=r.host,s.port=r.port),s.scheme=r.scheme),s.fragment=e.fragment,s}function GU(r,e,t){return typeof r=="string"?(r=unescape(r),r=Nn(Hf(Kn(r,t),!0),{...t,skipEscape:!0})):typeof r=="object"&&(r=Nn(Hf(r,!0),{...t,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=Nn(Hf(Kn(e,t),!0),{...t,skipEscape:!0})):typeof e=="object"&&(e=Nn(Hf(e,!0),{...t,skipEscape:!0})),r.toLowerCase()===e.toLowerCase()}function Nn(r,e){let t={host:r.host,scheme:r.scheme,userinfo:r.userinfo,port:r.port,path:r.path,query:r.query,nid:r.nid,nss:r.nss,uuid:r.uuid,fragment:r.fragment,reference:r.reference,resourceName:r.resourceName,secure:r.secure,error:""},n=Object.assign({},e),s=[],i=Sv[(n.scheme||t.scheme||"").toLowerCase()];i&&i.serialize&&i.serialize(t,n),t.path!==void 0&&(n.skipEscape?t.path=unescape(t.path):(t.path=escape(t.path),t.scheme!==void 0&&(t.path=t.path.split("%3A").join(":")))),n.reference!=="suffix"&&t.scheme&&s.push(t.scheme,":");let o=HU(t);if(o!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(o),t.path&&t.path.charAt(0)!=="/"&&s.push("/")),t.path!==void 0){let a=t.path;!n.absolutePath&&(!i||!i.absolutePath)&&(a=Fc(a)),o===void 0&&(a=a.replace(/^\/\//u,"/%2F")),s.push(a)}return t.query!==void 0&&s.push("?",t.query),t.fragment!==void 0&&s.push("#",t.fragment),s.join("")}var YU=Array.from({length:127},(r,e)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(e)));function JU(r){let e=0;for(let t=0,n=r.length;t<n;++t)if(e=r.charCodeAt(t),e>126||YU[e])return!0;return!1}var XU=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Kn(r,e){let t=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},s=r.indexOf("%")!==-1,i=!1;t.reference==="suffix"&&(r=(t.scheme?t.scheme+":":"")+"//"+r);let o=r.match(XU);if(o){if(n.scheme=o[1],n.userinfo=o[3],n.host=o[4],n.port=parseInt(o[5],10),n.path=o[6]||"",n.query=o[7],n.fragment=o[8],isNaN(n.port)&&(n.port=o[5]),n.host){let c=WU(n.host);if(c.isIPV4===!1){let l=VU(c.host);n.host=l.host.toLowerCase(),i=l.isIPV6}else n.host=c.host,i=!0}n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",t.reference&&t.reference!=="suffix"&&t.reference!==n.reference&&(n.error=n.error||"URI is not a "+t.reference+" reference.");let a=Sv[(t.scheme||n.scheme||"").toLowerCase()];if(!t.unicodeSupport&&(!a||!a.unicodeSupport)&&n.host&&(t.domainHost||a&&a.domainHost)&&i===!1&&JU(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(c){n.error=n.error||"Host's domain name can not be converted to ASCII: "+c}(!a||a&&!a.skipNormalize)&&(s&&n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),s&&n.host!==void 0&&(n.host=unescape(n.host)),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),a&&a.parse&&a.parse(n,t)}else n.error=n.error||"URI can not be parsed.";return n}var kv={SCHEMES:Sv,normalize:KU,resolve:zU,resolveComponents:oD,equal:GU,serialize:Nn,parse:Kn};Kf.exports=kv;Kf.exports.default=kv;Kf.exports.fastUri=kv});var lD=k(wv=>{"use strict";Object.defineProperty(wv,"__esModule",{value:!0});var cD=aD();cD.code='require("ajv/dist/runtime/uri").default';wv.default=cD});var yD=k(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});Ft.CodeGen=Ft.Name=Ft.nil=Ft.stringify=Ft.str=Ft._=Ft.KeywordCxt=void 0;var QU=$c();Object.defineProperty(Ft,"KeywordCxt",{enumerable:!0,get:function(){return QU.KeywordCxt}});var Ko=oe();Object.defineProperty(Ft,"_",{enumerable:!0,get:function(){return Ko._}});Object.defineProperty(Ft,"str",{enumerable:!0,get:function(){return Ko.str}});Object.defineProperty(Ft,"stringify",{enumerable:!0,get:function(){return Ko.stringify}});Object.defineProperty(Ft,"nil",{enumerable:!0,get:function(){return Ko.nil}});Object.defineProperty(Ft,"Name",{enumerable:!0,get:function(){return Ko.Name}});Object.defineProperty(Ft,"CodeGen",{enumerable:!0,get:function(){return Ko.CodeGen}});var ZU=Uf(),pD=qc(),eV=ev(),Bc=jc(),tV=oe(),Uc=Mc(),zf=Ic(),Nv=he(),uD=VC(),rV=lD(),mD=(r,e)=>new RegExp(r,e);mD.code="new RegExp";var nV=["removeAdditional","useDefaults","coerceTypes"],sV=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),iV={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},oV={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},dD=200;function aV(r){var e,t,n,s,i,o,a,c,l,u,d,f,p,b,g,_,w,T,v,R,A,L,W,j,ne;let Le=r.strict,Tt=(e=r.code)===null||e===void 0?void 0:e.optimize,de=Tt===!0||Tt===void 0?1:Tt||0,kr=(n=(t=r.code)===null||t===void 0?void 0:t.regExp)!==null&&n!==void 0?n:mD,zn=(s=r.uriResolver)!==null&&s!==void 0?s:rV.default;return{strictSchema:(o=(i=r.strictSchema)!==null&&i!==void 0?i:Le)!==null&&o!==void 0?o:!0,strictNumbers:(c=(a=r.strictNumbers)!==null&&a!==void 0?a:Le)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=r.strictTypes)!==null&&l!==void 0?l:Le)!==null&&u!==void 0?u:"log",strictTuples:(f=(d=r.strictTuples)!==null&&d!==void 0?d:Le)!==null&&f!==void 0?f:"log",strictRequired:(b=(p=r.strictRequired)!==null&&p!==void 0?p:Le)!==null&&b!==void 0?b:!1,code:r.code?{...r.code,optimize:de,regExp:kr}:{optimize:de,regExp:kr},loopRequired:(g=r.loopRequired)!==null&&g!==void 0?g:dD,loopEnum:(_=r.loopEnum)!==null&&_!==void 0?_:dD,meta:(w=r.meta)!==null&&w!==void 0?w:!0,messages:(T=r.messages)!==null&&T!==void 0?T:!0,inlineRefs:(v=r.inlineRefs)!==null&&v!==void 0?v:!0,schemaId:(R=r.schemaId)!==null&&R!==void 0?R:"$id",addUsedSchema:(A=r.addUsedSchema)!==null&&A!==void 0?A:!0,validateSchema:(L=r.validateSchema)!==null&&L!==void 0?L:!0,validateFormats:(W=r.validateFormats)!==null&&W!==void 0?W:!0,unicodeRegExp:(j=r.unicodeRegExp)!==null&&j!==void 0?j:!0,int32range:(ne=r.int32range)!==null&&ne!==void 0?ne:!0,uriResolver:zn}}var Vc=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...aV(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new tV.ValueScope({scope:{},prefixes:sV,es5:t,lines:n}),this.logger=hV(e.logger);let s=e.validateFormats;e.validateFormats=!1,this.RULES=(0,eV.getRules)(),fD.call(this,iV,e,"NOT SUPPORTED"),fD.call(this,oV,e,"DEPRECATED","warn"),this._metaOpts=dV.call(this),e.formats&&lV.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&uV.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),cV.call(this),e.validateFormats=s}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,s=uD;n==="id"&&(s={...uD},s.id=s.$id,delete s.$id),t&&e&&this.addMetaSchema(s,s[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[t]||e:void 0}validate(e,t){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let s=n(t);return"$async"in n||(this.errors=n.errors),s}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return s.call(this,e,t);async function s(u,d){await i.call(this,u.$schema);let f=this._addSchema(u,d);return f.validate||o.call(this,f)}async function i(u){u&&!this.getSchema(u)&&await s.call(this,{$ref:u},!0)}async function o(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof pD.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),o.call(this,u)}}function a({missingSchema:u,missingRef:d}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}async function c(u){let d=await l.call(this,u);this.refs[u]||await i.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,t)}async function l(u){let d=this._loading[u];if(d)return d;try{return await(this._loading[u]=n(u))}finally{delete this._loading[u]}}}addSchema(e,t,n,s=this.opts.validateSchema){if(Array.isArray(e)){for(let o of e)this.addSchema(o,void 0,n,s);return this}let i;if(typeof e=="object"){let{schemaId:o}=this.opts;if(i=e[o],i!==void 0&&typeof i!="string")throw new Error(`schema ${o} must be string`)}return t=(0,Uc.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,s,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let s=this.validate(n,e);if(!s&&t){let i="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(i);else throw new Error(i)}return s}getSchema(e){let t;for(;typeof(t=hD.call(this,e))=="string";)e=t;if(t===void 0){let{schemaId:n}=this.opts,s=new Bc.SchemaEnv({schema:{},schemaId:n});if(t=Bc.resolveSchema.call(this,s,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let t=hD.call(this,e);return typeof t=="object"&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,Uc.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e=="string")n=e,typeof t=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=n);else if(typeof e=="object"&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(mV.call(this,n,t),!t)return(0,Nv.eachItem)(n,i=>Ev.call(this,i)),this;yV.call(this,t);let s={...t,type:(0,zf.getJSONTypes)(t.type),schemaType:(0,zf.getJSONTypes)(t.schemaType)};return(0,Nv.eachItem)(n,s.type.length===0?i=>Ev.call(this,i,s):i=>s.type.forEach(o=>Ev.call(this,i,s,o))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t=="object"?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let s=n.rules.findIndex(i=>i.keyword===e);s>=0&&n.rules.splice(s,1)}return this}addFormat(e,t){return typeof t=="string"&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(s=>`${n}${s.instancePath} ${s.message}`).reduce((s,i)=>s+t+i)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let s of t){let i=s.split("/").slice(1),o=e;for(let a of i)o=o[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:l}=c.definition,u=o[a];l&&u&&(o[a]=gD(u))}}return e}_removeAllSchemas(e,t){for(let n in e){let s=e[n];(!t||t.test(n))&&(typeof s=="string"?delete e[n]:s&&!s.meta&&(this._cache.delete(s.schema),delete e[n]))}}_addSchema(e,t,n,s=this.opts.validateSchema,i=this.opts.addUsedSchema){let o,{schemaId:a}=this.opts;if(typeof e=="object")o=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,Uc.normalizeId)(o||n);let l=Uc.getSchemaRefs.call(this,e,n);return c=new Bc.SchemaEnv({schema:e,schemaId:a,meta:t,baseId:n,localRefs:l}),this._cache.set(c.schema,c),i&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),s&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):Bc.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{Bc.compileSchema.call(this,e)}finally{this.opts=t}}};Vc.ValidationError=ZU.default;Vc.MissingRefError=pD.default;Ft.default=Vc;function fD(r,e,t,n="error"){for(let s in r){let i=s;i in e&&this.logger[n](`${t}: option ${s}. ${r[i]}`)}}function hD(r){return r=(0,Uc.normalizeId)(r),this.schemas[r]||this.refs[r]}function cV(){let r=this.opts.schemas;if(r)if(Array.isArray(r))this.addSchema(r);else for(let e in r)this.addSchema(r[e],e)}function lV(){for(let r in this.opts.formats){let e=this.opts.formats[r];e&&this.addFormat(r,e)}}function uV(r){if(Array.isArray(r)){this.addVocabulary(r);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in r){let t=r[e];t.keyword||(t.keyword=e),this.addKeyword(t)}}function dV(){let r={...this.opts};for(let e of nV)delete r[e];return r}var fV={log(){},warn(){},error(){}};function hV(r){if(r===!1)return fV;if(r===void 0)return console;if(r.log&&r.warn&&r.error)return r;throw new Error("logger must implement log, warn and error methods")}var pV=/^[a-z_$][a-z0-9_$:-]*$/i;function mV(r,e){let{RULES:t}=this;if((0,Nv.eachItem)(r,n=>{if(t.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!pV.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function Ev(r,e,t){var n;let s=e?.post;if(t&&s)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:i}=this,o=s?i.post:i.rules.find(({type:c})=>c===t);if(o||(o={type:t,rules:[]},i.rules.push(o)),i.keywords[r]=!0,!e)return;let a={keyword:r,definition:{...e,type:(0,zf.getJSONTypes)(e.type),schemaType:(0,zf.getJSONTypes)(e.schemaType)}};e.before?gV.call(this,o,a,e.before):o.rules.push(a),i.all[r]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function gV(r,e,t){let n=r.rules.findIndex(s=>s.keyword===t);n>=0?r.rules.splice(n,0,e):(r.rules.push(e),this.logger.warn(`rule ${t} is not defined`))}function yV(r){let{metaSchema:e}=r;e!==void 0&&(r.$data&&this.opts.$data&&(e=gD(e)),r.validateSchema=this.compile(e,!0))}var vV={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function gD(r){return{anyOf:[r,vV]}}});var vD=k(Pv=>{"use strict";Object.defineProperty(Pv,"__esModule",{value:!0});var bV={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Pv.default=bV});var Jf=k(Ti=>{"use strict";Object.defineProperty(Ti,"__esModule",{value:!0});Ti.callRef=Ti.getValidate=void 0;var TV=qc(),bD=qr(),gr=oe(),zo=$r(),TD=jc(),Gf=he(),_V={keyword:"$ref",schemaType:"string",code(r){let{gen:e,schema:t,it:n}=r,{baseId:s,schemaEnv:i,validateName:o,opts:a,self:c}=n,{root:l}=i;if((t==="#"||t==="#/")&&s===l.baseId)return d();let u=TD.resolveRef.call(c,l,s,t);if(u===void 0)throw new TV.default(n.opts.uriResolver,s,t);if(u instanceof TD.SchemaEnv)return f(u);return p(u);function d(){if(i===l)return Yf(r,o,i,i.$async);let b=e.scopeValue("root",{ref:l});return Yf(r,(0,gr._)`${b}.validate`,l,l.$async)}function f(b){let g=_D(r,b);Yf(r,g,b,b.$async)}function p(b){let g=e.scopeValue("schema",a.code.source===!0?{ref:b,code:(0,gr.stringify)(b)}:{ref:b}),_=e.name("valid"),w=r.subschema({schema:b,dataTypes:[],schemaPath:gr.nil,topSchemaRef:g,errSchemaPath:t},_);r.mergeEvaluated(w),r.ok(_)}}};function _D(r,e){let{gen:t}=r;return e.validate?t.scopeValue("validate",{ref:e.validate}):(0,gr._)`${t.scopeValue("wrapper",{ref:e})}.validate`}Ti.getValidate=_D;function Yf(r,e,t,n){let{gen:s,it:i}=r,{allErrors:o,schemaEnv:a,opts:c}=i,l=c.passContext?zo.default.this:gr.nil;n?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let b=s.let("valid");s.try(()=>{s.code((0,gr._)`await ${(0,bD.callValidateCode)(r,e,l)}`),p(e),o||s.assign(b,!0)},g=>{s.if((0,gr._)`!(${g} instanceof ${i.ValidationError})`,()=>s.throw(g)),f(g),o||s.assign(b,!1)}),r.ok(b)}function d(){r.result((0,bD.callValidateCode)(r,e,l),()=>p(e),()=>f(e))}function f(b){let g=(0,gr._)`${b}.errors`;s.assign(zo.default.vErrors,(0,gr._)`${zo.default.vErrors} === null ? ${g} : ${zo.default.vErrors}.concat(${g})`),s.assign(zo.default.errors,(0,gr._)`${zo.default.vErrors}.length`)}function p(b){var g;if(!i.opts.unevaluated)return;let _=(g=t?.validate)===null||g===void 0?void 0:g.evaluated;if(i.props!==!0)if(_&&!_.dynamicProps)_.props!==void 0&&(i.props=Gf.mergeEvaluated.props(s,_.props,i.props));else{let w=s.var("props",(0,gr._)`${b}.evaluated.props`);i.props=Gf.mergeEvaluated.props(s,w,i.props,gr.Name)}if(i.items!==!0)if(_&&!_.dynamicItems)_.items!==void 0&&(i.items=Gf.mergeEvaluated.items(s,_.items,i.items));else{let w=s.var("items",(0,gr._)`${b}.evaluated.items`);i.items=Gf.mergeEvaluated.items(s,w,i.items,gr.Name)}}}Ti.callRef=Yf;Ti.default=_V});var SD=k(Rv=>{"use strict";Object.defineProperty(Rv,"__esModule",{value:!0});var SV=vD(),kV=Jf(),wV=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",SV.default,kV.default];Rv.default=wV});var kD=k(Cv=>{"use strict";Object.defineProperty(Cv,"__esModule",{value:!0});var Xf=oe(),xs=Xf.operators,Qf={maximum:{okStr:"<=",ok:xs.LTE,fail:xs.GT},minimum:{okStr:">=",ok:xs.GTE,fail:xs.LT},exclusiveMaximum:{okStr:"<",ok:xs.LT,fail:xs.GTE},exclusiveMinimum:{okStr:">",ok:xs.GT,fail:xs.LTE}},EV={message:({keyword:r,schemaCode:e})=>(0,Xf.str)`must be ${Qf[r].okStr} ${e}`,params:({keyword:r,schemaCode:e})=>(0,Xf._)`{comparison: ${Qf[r].okStr}, limit: ${e}}`},NV={keyword:Object.keys(Qf),type:"number",schemaType:"number",$data:!0,error:EV,code(r){let{keyword:e,data:t,schemaCode:n}=r;r.fail$data((0,Xf._)`${t} ${Qf[e].fail} ${n} || isNaN(${t})`)}};Cv.default=NV});var wD=k(Dv=>{"use strict";Object.defineProperty(Dv,"__esModule",{value:!0});var Wc=oe(),PV={message:({schemaCode:r})=>(0,Wc.str)`must be multiple of ${r}`,params:({schemaCode:r})=>(0,Wc._)`{multipleOf: ${r}}`},RV={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:PV,code(r){let{gen:e,data:t,schemaCode:n,it:s}=r,i=s.opts.multipleOfPrecision,o=e.let("res"),a=i?(0,Wc._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${i}`:(0,Wc._)`${o} !== parseInt(${o})`;r.fail$data((0,Wc._)`(${n} === 0 || (${o} = ${t}/${n}, ${a}))`)}};Dv.default=RV});var ND=k(Ov=>{"use strict";Object.defineProperty(Ov,"__esModule",{value:!0});function ED(r){let e=r.length,t=0,n=0,s;for(;n<e;)t++,s=r.charCodeAt(n++),s>=55296&&s<=56319&&n<e&&(s=r.charCodeAt(n),(s&64512)===56320&&n++);return t}Ov.default=ED;ED.code='require("ajv/dist/runtime/ucs2length").default'});var PD=k(Av=>{"use strict";Object.defineProperty(Av,"__esModule",{value:!0});var _i=oe(),CV=he(),DV=ND(),OV={message({keyword:r,schemaCode:e}){let t=r==="maxLength"?"more":"fewer";return(0,_i.str)`must NOT have ${t} than ${e} characters`},params:({schemaCode:r})=>(0,_i._)`{limit: ${r}}`},AV={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:OV,code(r){let{keyword:e,data:t,schemaCode:n,it:s}=r,i=e==="maxLength"?_i.operators.GT:_i.operators.LT,o=s.opts.unicode===!1?(0,_i._)`${t}.length`:(0,_i._)`${(0,CV.useFunc)(r.gen,DV.default)}(${t})`;r.fail$data((0,_i._)`${o} ${i} ${n}`)}};Av.default=AV});var RD=k(Iv=>{"use strict";Object.defineProperty(Iv,"__esModule",{value:!0});var IV=qr(),Zf=oe(),MV={message:({schemaCode:r})=>(0,Zf.str)`must match pattern "${r}"`,params:({schemaCode:r})=>(0,Zf._)`{pattern: ${r}}`},xV={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:MV,code(r){let{data:e,$data:t,schema:n,schemaCode:s,it:i}=r,o=i.opts.unicodeRegExp?"u":"",a=t?(0,Zf._)`(new RegExp(${s}, ${o}))`:(0,IV.usePattern)(r,n);r.fail$data((0,Zf._)`!${a}.test(${e})`)}};Iv.default=xV});var CD=k(Mv=>{"use strict";Object.defineProperty(Mv,"__esModule",{value:!0});var Hc=oe(),LV={message({keyword:r,schemaCode:e}){let t=r==="maxProperties"?"more":"fewer";return(0,Hc.str)`must NOT have ${t} than ${e} properties`},params:({schemaCode:r})=>(0,Hc._)`{limit: ${r}}`},$V={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:LV,code(r){let{keyword:e,data:t,schemaCode:n}=r,s=e==="maxProperties"?Hc.operators.GT:Hc.operators.LT;r.fail$data((0,Hc._)`Object.keys(${t}).length ${s} ${n}`)}};Mv.default=$V});var DD=k(xv=>{"use strict";Object.defineProperty(xv,"__esModule",{value:!0});var Kc=qr(),zc=oe(),qV=he(),jV={message:({params:{missingProperty:r}})=>(0,zc.str)`must have required property '${r}'`,params:({params:{missingProperty:r}})=>(0,zc._)`{missingProperty: ${r}}`},FV={keyword:"required",type:"object",schemaType:"array",$data:!0,error:jV,code(r){let{gen:e,schema:t,schemaCode:n,data:s,$data:i,it:o}=r,{opts:a}=o;if(!i&&t.length===0)return;let c=t.length>=a.loopRequired;if(o.allErrors?l():u(),a.strictRequired){let p=r.parentSchema.properties,{definedProperties:b}=r.it;for(let g of t)if(p?.[g]===void 0&&!b.has(g)){let _=o.schemaEnv.baseId+o.errSchemaPath,w=`required property "${g}" is not defined at "${_}" (strictRequired)`;(0,qV.checkStrictMode)(o,w,o.opts.strictRequired)}}function l(){if(c||i)r.block$data(zc.nil,d);else for(let p of t)(0,Kc.checkReportMissingProp)(r,p)}function u(){let p=e.let("missing");if(c||i){let b=e.let("valid",!0);r.block$data(b,()=>f(p,b)),r.ok(b)}else e.if((0,Kc.checkMissingProp)(r,t,p)),(0,Kc.reportMissingProp)(r,p),e.else()}function d(){e.forOf("prop",n,p=>{r.setParams({missingProperty:p}),e.if((0,Kc.noPropertyInData)(e,s,p,a.ownProperties),()=>r.error())})}function f(p,b){r.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(b,(0,Kc.propertyInData)(e,s,p,a.ownProperties)),e.if((0,zc.not)(b),()=>{r.error(),e.break()})},zc.nil)}}};xv.default=FV});var OD=k(Lv=>{"use strict";Object.defineProperty(Lv,"__esModule",{value:!0});var Gc=oe(),BV={message({keyword:r,schemaCode:e}){let t=r==="maxItems"?"more":"fewer";return(0,Gc.str)`must NOT have ${t} than ${e} items`},params:({schemaCode:r})=>(0,Gc._)`{limit: ${r}}`},UV={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:BV,code(r){let{keyword:e,data:t,schemaCode:n}=r,s=e==="maxItems"?Gc.operators.GT:Gc.operators.LT;r.fail$data((0,Gc._)`${t}.length ${s} ${n}`)}};Lv.default=UV});var eh=k($v=>{"use strict";Object.defineProperty($v,"__esModule",{value:!0});var AD=cv();AD.code='require("ajv/dist/runtime/equal").default';$v.default=AD});var ID=k(jv=>{"use strict";Object.defineProperty(jv,"__esModule",{value:!0});var qv=Ic(),Bt=oe(),VV=he(),WV=eh(),HV={message:({params:{i:r,j:e}})=>(0,Bt.str)`must NOT have duplicate items (items ## ${e} and ${r} are identical)`,params:({params:{i:r,j:e}})=>(0,Bt._)`{i: ${r}, j: ${e}}`},KV={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:HV,code(r){let{gen:e,data:t,$data:n,schema:s,parentSchema:i,schemaCode:o,it:a}=r;if(!n&&!s)return;let c=e.let("valid"),l=i.items?(0,qv.getSchemaTypes)(i.items):[];r.block$data(c,u,(0,Bt._)`${o} === false`),r.ok(c);function u(){let b=e.let("i",(0,Bt._)`${t}.length`),g=e.let("j");r.setParams({i:b,j:g}),e.assign(c,!0),e.if((0,Bt._)`${b} > 1`,()=>(d()?f:p)(b,g))}function d(){return l.length>0&&!l.some(b=>b==="object"||b==="array")}function f(b,g){let _=e.name("item"),w=(0,qv.checkDataTypes)(l,_,a.opts.strictNumbers,qv.DataType.Wrong),T=e.const("indices",(0,Bt._)`{}`);e.for((0,Bt._)`;${b}--;`,()=>{e.let(_,(0,Bt._)`${t}[${b}]`),e.if(w,(0,Bt._)`continue`),l.length>1&&e.if((0,Bt._)`typeof ${_} == "string"`,(0,Bt._)`${_} += "_"`),e.if((0,Bt._)`typeof ${T}[${_}] == "number"`,()=>{e.assign(g,(0,Bt._)`${T}[${_}]`),r.error(),e.assign(c,!1).break()}).code((0,Bt._)`${T}[${_}] = ${b}`)})}function p(b,g){let _=(0,VV.useFunc)(e,WV.default),w=e.name("outer");e.label(w).for((0,Bt._)`;${b}--;`,()=>e.for((0,Bt._)`${g} = ${b}; ${g}--;`,()=>e.if((0,Bt._)`${_}(${t}[${b}], ${t}[${g}])`,()=>{r.error(),e.assign(c,!1).break(w)})))}}};jv.default=KV});var MD=k(Bv=>{"use strict";Object.defineProperty(Bv,"__esModule",{value:!0});var Fv=oe(),zV=he(),GV=eh(),YV={message:"must be equal to constant",params:({schemaCode:r})=>(0,Fv._)`{allowedValue: ${r}}`},JV={keyword:"const",$data:!0,error:YV,code(r){let{gen:e,data:t,$data:n,schemaCode:s,schema:i}=r;n||i&&typeof i=="object"?r.fail$data((0,Fv._)`!${(0,zV.useFunc)(e,GV.default)}(${t}, ${s})`):r.fail((0,Fv._)`${i} !== ${t}`)}};Bv.default=JV});var xD=k(Uv=>{"use strict";Object.defineProperty(Uv,"__esModule",{value:!0});var Yc=oe(),XV=he(),QV=eh(),ZV={message:"must be equal to one of the allowed values",params:({schemaCode:r})=>(0,Yc._)`{allowedValues: ${r}}`},eW={keyword:"enum",schemaType:"array",$data:!0,error:ZV,code(r){let{gen:e,data:t,$data:n,schema:s,schemaCode:i,it:o}=r;if(!n&&s.length===0)throw new Error("enum must have non-empty array");let a=s.length>=o.opts.loopEnum,c,l=()=>c??(c=(0,XV.useFunc)(e,QV.default)),u;if(a||n)u=e.let("valid"),r.block$data(u,d);else{if(!Array.isArray(s))throw new Error("ajv implementation error");let p=e.const("vSchema",i);u=(0,Yc.or)(...s.map((b,g)=>f(p,g)))}r.pass(u);function d(){e.assign(u,!1),e.forOf("v",i,p=>e.if((0,Yc._)`${l()}(${t}, ${p})`,()=>e.assign(u,!0).break()))}function f(p,b){let g=s[b];return typeof g=="object"&&g!==null?(0,Yc._)`${l()}(${t}, ${p}[${b}])`:(0,Yc._)`${t} === ${g}`}}};Uv.default=eW});var LD=k(Vv=>{"use strict";Object.defineProperty(Vv,"__esModule",{value:!0});var tW=kD(),rW=wD(),nW=PD(),sW=RD(),iW=CD(),oW=DD(),aW=OD(),cW=ID(),lW=MD(),uW=xD(),dW=[tW.default,rW.default,nW.default,sW.default,iW.default,oW.default,aW.default,cW.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},lW.default,uW.default];Vv.default=dW});var Hv=k(Jc=>{"use strict";Object.defineProperty(Jc,"__esModule",{value:!0});Jc.validateAdditionalItems=void 0;var Si=oe(),Wv=he(),fW={message:({params:{len:r}})=>(0,Si.str)`must NOT have more than ${r} items`,params:({params:{len:r}})=>(0,Si._)`{limit: ${r}}`},hW={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:fW,code(r){let{parentSchema:e,it:t}=r,{items:n}=e;if(!Array.isArray(n)){(0,Wv.checkStrictMode)(t,'"additionalItems" is ignored when "items" is not an array of schemas');return}$D(r,n)}};function $D(r,e){let{gen:t,schema:n,data:s,keyword:i,it:o}=r;o.items=!0;let a=t.const("len",(0,Si._)`${s}.length`);if(n===!1)r.setParams({len:e.length}),r.pass((0,Si._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Wv.alwaysValidSchema)(o,n)){let l=t.var("valid",(0,Si._)`${a} <= ${e.length}`);t.if((0,Si.not)(l),()=>c(l)),r.ok(l)}function c(l){t.forRange("i",e.length,a,u=>{r.subschema({keyword:i,dataProp:u,dataPropType:Wv.Type.Num},l),o.allErrors||t.if((0,Si.not)(l),()=>t.break())})}}Jc.validateAdditionalItems=$D;Jc.default=hW});var Kv=k(Xc=>{"use strict";Object.defineProperty(Xc,"__esModule",{value:!0});Xc.validateTuple=void 0;var qD=oe(),th=he(),pW=qr(),mW={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(r){let{schema:e,it:t}=r;if(Array.isArray(e))return jD(r,"additionalItems",e);t.items=!0,!(0,th.alwaysValidSchema)(t,e)&&r.ok((0,pW.validateArray)(r))}};function jD(r,e,t=r.schema){let{gen:n,parentSchema:s,data:i,keyword:o,it:a}=r;u(s),a.opts.unevaluated&&t.length&&a.items!==!0&&(a.items=th.mergeEvaluated.items(n,t.length,a.items));let c=n.name("valid"),l=n.const("len",(0,qD._)`${i}.length`);t.forEach((d,f)=>{(0,th.alwaysValidSchema)(a,d)||(n.if((0,qD._)`${l} > ${f}`,()=>r.subschema({keyword:o,schemaProp:f,dataProp:f},c)),r.ok(c))});function u(d){let{opts:f,errSchemaPath:p}=a,b=t.length,g=b===d.minItems&&(b===d.maxItems||d[e]===!1);if(f.strictTuples&&!g){let _=`"${o}" is ${b}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,th.checkStrictMode)(a,_,f.strictTuples)}}}Xc.validateTuple=jD;Xc.default=mW});var FD=k(zv=>{"use strict";Object.defineProperty(zv,"__esModule",{value:!0});var gW=Kv(),yW={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:r=>(0,gW.validateTuple)(r,"items")};zv.default=yW});var UD=k(Gv=>{"use strict";Object.defineProperty(Gv,"__esModule",{value:!0});var BD=oe(),vW=he(),bW=qr(),TW=Hv(),_W={message:({params:{len:r}})=>(0,BD.str)`must NOT have more than ${r} items`,params:({params:{len:r}})=>(0,BD._)`{limit: ${r}}`},SW={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:_W,code(r){let{schema:e,parentSchema:t,it:n}=r,{prefixItems:s}=t;n.items=!0,!(0,vW.alwaysValidSchema)(n,e)&&(s?(0,TW.validateAdditionalItems)(r,s):r.ok((0,bW.validateArray)(r)))}};Gv.default=SW});var VD=k(Yv=>{"use strict";Object.defineProperty(Yv,"__esModule",{value:!0});var Fr=oe(),rh=he(),kW={message:({params:{min:r,max:e}})=>e===void 0?(0,Fr.str)`must contain at least ${r} valid item(s)`:(0,Fr.str)`must contain at least ${r} and no more than ${e} valid item(s)`,params:({params:{min:r,max:e}})=>e===void 0?(0,Fr._)`{minContains: ${r}}`:(0,Fr._)`{minContains: ${r}, maxContains: ${e}}`},wW={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:kW,code(r){let{gen:e,schema:t,parentSchema:n,data:s,it:i}=r,o,a,{minContains:c,maxContains:l}=n;i.opts.next?(o=c===void 0?1:c,a=l):o=1;let u=e.const("len",(0,Fr._)`${s}.length`);if(r.setParams({min:o,max:a}),a===void 0&&o===0){(0,rh.checkStrictMode)(i,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,rh.checkStrictMode)(i,'"minContains" > "maxContains" is always invalid'),r.fail();return}if((0,rh.alwaysValidSchema)(i,t)){let g=(0,Fr._)`${u} >= ${o}`;a!==void 0&&(g=(0,Fr._)`${g} && ${u} <= ${a}`),r.pass(g);return}i.items=!0;let d=e.name("valid");a===void 0&&o===1?p(d,()=>e.if(d,()=>e.break())):o===0?(e.let(d,!0),a!==void 0&&e.if((0,Fr._)`${s}.length > 0`,f)):(e.let(d,!1),f()),r.result(d,()=>r.reset());function f(){let g=e.name("_valid"),_=e.let("count",0);p(g,()=>e.if(g,()=>b(_)))}function p(g,_){e.forRange("i",0,u,w=>{r.subschema({keyword:"contains",dataProp:w,dataPropType:rh.Type.Num,compositeRule:!0},g),_()})}function b(g){e.code((0,Fr._)`${g}++`),a===void 0?e.if((0,Fr._)`${g} >= ${o}`,()=>e.assign(d,!0).break()):(e.if((0,Fr._)`${g} > ${a}`,()=>e.assign(d,!1).break()),o===1?e.assign(d,!0):e.if((0,Fr._)`${g} >= ${o}`,()=>e.assign(d,!0)))}}};Yv.default=wW});var nh=k(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:!0});Pn.validateSchemaDeps=Pn.validatePropertyDeps=Pn.error=void 0;var Jv=oe(),EW=he(),Qc=qr();Pn.error={message:({params:{property:r,depsCount:e,deps:t}})=>{let n=e===1?"property":"properties";return(0,Jv.str)`must have ${n} ${t} when property ${r} is present`},params:({params:{property:r,depsCount:e,deps:t,missingProperty:n}})=>(0,Jv._)`{property: ${r},
|
|
180
180
|
missingProperty: ${n},
|
|
181
181
|
depsCount: ${e},
|
|
182
|
-
deps: ${t}}`};var NW={keyword:"dependencies",type:"object",schemaType:"object",error:Pn.error,code(r){let[e,t]=PW(r);WD(r,e),HD(r,t)}};function PW({schema:r}){let e={},t={};for(let n in r){if(n==="__proto__")continue;let s=Array.isArray(r[n])?e:t;s[n]=r[n]}return[e,t]}function WD(r,e=r.schema){let{gen:t,data:n,it:s}=r;if(Object.keys(e).length===0)return;let i=t.let("missing");for(let o in e){let a=e[o];if(a.length===0)continue;let c=(0,Qc.propertyInData)(t,n,o,s.opts.ownProperties);r.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),s.allErrors?t.if(c,()=>{for(let l of a)(0,Qc.checkReportMissingProp)(r,l)}):(t.if((0,Jv._)`${c} && (${(0,Qc.checkMissingProp)(r,a,i)})`),(0,Qc.reportMissingProp)(r,i),t.else())}}Pn.validatePropertyDeps=WD;function HD(r,e=r.schema){let{gen:t,data:n,keyword:s,it:i}=r,o=t.name("valid");for(let a in e)(0,EW.alwaysValidSchema)(i,e[a])||(t.if((0,Qc.propertyInData)(t,n,a,i.opts.ownProperties),()=>{let c=r.subschema({keyword:s,schemaProp:a},o);r.mergeValidEvaluated(c,o)},()=>t.var(o,!0)),r.ok(o))}Pn.validateSchemaDeps=HD;Pn.default=NW});var zD=k(Xv=>{"use strict";Object.defineProperty(Xv,"__esModule",{value:!0});var KD=oe(),RW=he(),CW={message:"property name must be valid",params:({params:r})=>(0,KD._)`{propertyName: ${r.propertyName}}`},DW={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:CW,code(r){let{gen:e,schema:t,data:n,it:s}=r;if((0,RW.alwaysValidSchema)(s,t))return;let i=e.name("valid");e.forIn("key",n,o=>{r.setParams({propertyName:o}),r.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},i),e.if((0,KD.not)(i),()=>{r.error(!0),s.allErrors||e.break()})}),r.ok(i)}};Xv.default=DW});var Zv=k(Qv=>{"use strict";Object.defineProperty(Qv,"__esModule",{value:!0});var sh=qr(),cn=oe(),OW=$r(),ih=he(),AW={message:"must NOT have additional properties",params:({params:r})=>(0,cn._)`{additionalProperty: ${r.additionalProperty}}`},IW={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:AW,code(r){let{gen:e,schema:t,parentSchema:n,data:s,errsCount:i,it:o}=r;if(!i)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=o;if(o.props=!0,c.removeAdditional!=="all"&&(0,ih.alwaysValidSchema)(o,t))return;let l=(0,sh.allSchemaProperties)(n.properties),u=(0,sh.allSchemaProperties)(n.patternProperties);d(),r.ok((0,cn._)`${i} === ${OW.default.errors}`);function d(){e.forIn("key",s,_=>{!l.length&&!u.length?b(_):e.if(f(_),()=>b(_))})}function f(_){let w;if(l.length>8){let T=(0,ih.schemaRefOrVal)(o,n.properties,"properties");w=(0,sh.isOwnProperty)(e,T,_)}else l.length?w=(0,cn.or)(...l.map(T=>(0,cn._)`${_} === ${T}`)):w=cn.nil;return u.length&&(w=(0,cn.or)(w,...u.map(T=>(0,cn._)`${(0,sh.usePattern)(r,T)}.test(${_})`))),(0,cn.not)(w)}function p(_){e.code((0,cn._)`delete ${s}[${_}]`)}function b(_){if(c.removeAdditional==="all"||c.removeAdditional&&t===!1){p(_);return}if(t===!1){r.setParams({additionalProperty:_}),r.error(),a||e.break();return}if(typeof t=="object"&&!(0,ih.alwaysValidSchema)(o,t)){let w=e.name("valid");c.removeAdditional==="failing"?(g(_,w,!1),e.if((0,cn.not)(w),()=>{r.reset(),p(_)})):(g(_,w),a||e.if((0,cn.not)(w),()=>e.break()))}}function g(_,w,T){let v={keyword:"additionalProperties",dataProp:_,dataPropType:ih.Type.Str};T===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),r.subschema(v,w)}}};Qv.default=IW});var JD=k(tb=>{"use strict";Object.defineProperty(tb,"__esModule",{value:!0});var MW=$c(),GD=qr(),eb=he(),YD=Zv(),xW={keyword:"properties",type:"object",schemaType:"object",code(r){let{gen:e,schema:t,parentSchema:n,data:s,it:i}=r;i.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&YD.default.code(new MW.KeywordCxt(i,YD.default,"additionalProperties"));let o=(0,GD.allSchemaProperties)(t);for(let d of o)i.definedProperties.add(d);i.opts.unevaluated&&o.length&&i.props!==!0&&(i.props=eb.mergeEvaluated.props(e,(0,eb.toHash)(o),i.props));let a=o.filter(d=>!(0,eb.alwaysValidSchema)(i,t[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,GD.propertyInData)(e,s,d,i.opts.ownProperties)),u(d),i.allErrors||e.else().var(c,!0),e.endIf()),r.it.definedProperties.add(d),r.ok(c);function l(d){return i.opts.useDefaults&&!i.compositeRule&&t[d].default!==void 0}function u(d){r.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};tb.default=xW});var eO=k(rb=>{"use strict";Object.defineProperty(rb,"__esModule",{value:!0});var XD=qr(),oh=oe(),QD=he(),ZD=he(),LW={keyword:"patternProperties",type:"object",schemaType:"object",code(r){let{gen:e,schema:t,data:n,parentSchema:s,it:i}=r,{opts:o}=i,a=(0,XD.allSchemaProperties)(t),c=a.filter(g=>(0,QD.alwaysValidSchema)(i,t[g]));if(a.length===0||c.length===a.length&&(!i.opts.unevaluated||i.props===!0))return;let l=o.strictSchema&&!o.allowMatchingProperties&&s.properties,u=e.name("valid");i.props!==!0&&!(i.props instanceof oh.Name)&&(i.props=(0,ZD.evaluatedPropsToName)(e,i.props));let{props:d}=i;f();function f(){for(let g of a)l&&p(g),i.allErrors?b(g):(e.var(u,!0),b(g),e.if(u))}function p(g){for(let _ in l)new RegExp(g).test(_)&&(0,QD.checkStrictMode)(i,`property ${_} matches pattern ${g} (use allowMatchingProperties)`)}function b(g){e.forIn("key",n,_=>{e.if((0,oh._)`${(0,XD.usePattern)(r,g)}.test(${_})`,()=>{let w=c.includes(g);w||r.subschema({keyword:"patternProperties",schemaProp:g,dataProp:_,dataPropType:ZD.Type.Str},u),i.opts.unevaluated&&d!==!0?e.assign((0,oh._)`${d}[${_}]`,!0):!w&&!i.allErrors&&e.if((0,oh.not)(u),()=>e.break())})})}}};rb.default=LW});var tO=k(nb=>{"use strict";Object.defineProperty(nb,"__esModule",{value:!0});var $W=he(),qW={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(r){let{gen:e,schema:t,it:n}=r;if((0,$W.alwaysValidSchema)(n,t)){r.fail();return}let s=e.name("valid");r.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),r.failResult(s,()=>r.reset(),()=>r.error())},error:{message:"must NOT be valid"}};nb.default=qW});var rO=k(sb=>{"use strict";Object.defineProperty(sb,"__esModule",{value:!0});var jW=qr(),FW={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:jW.validateUnion,error:{message:"must match a schema in anyOf"}};sb.default=FW});var nO=k(ib=>{"use strict";Object.defineProperty(ib,"__esModule",{value:!0});var ah=oe(),BW=he(),UW={message:"must match exactly one schema in oneOf",params:({params:r})=>(0,ah._)`{passingSchemas: ${r.passing}}`},VW={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:UW,code(r){let{gen:e,schema:t,parentSchema:n,it:s}=r;if(!Array.isArray(t))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let i=t,o=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");r.setParams({passing:a}),e.block(l),r.result(o,()=>r.reset(),()=>r.error(!0));function l(){i.forEach((u,d)=>{let f;(0,BW.alwaysValidSchema)(s,u)?e.var(c,!0):f=r.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,ah._)`${c} && ${o}`).assign(o,!1).assign(a,(0,ah._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(o,!0),e.assign(a,d),f&&r.mergeEvaluated(f,ah.Name)})})}}};ib.default=VW});var sO=k(ob=>{"use strict";Object.defineProperty(ob,"__esModule",{value:!0});var WW=he(),HW={keyword:"allOf",schemaType:"array",code(r){let{gen:e,schema:t,it:n}=r;if(!Array.isArray(t))throw new Error("ajv implementation error");let s=e.name("valid");t.forEach((i,o)=>{if((0,WW.alwaysValidSchema)(n,i))return;let a=r.subschema({keyword:"allOf",schemaProp:o},s);r.ok(s),r.mergeEvaluated(a)})}};ob.default=HW});var aO=k(ab=>{"use strict";Object.defineProperty(ab,"__esModule",{value:!0});var ch=oe(),oO=he(),KW={message:({params:r})=>(0,ch.str)`must match "${r.ifClause}" schema`,params:({params:r})=>(0,ch._)`{failingKeyword: ${r.ifClause}}`},zW={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:KW,code(r){let{gen:e,parentSchema:t,it:n}=r;t.then===void 0&&t.else===void 0&&(0,oO.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=iO(n,"then"),i=iO(n,"else");if(!s&&!i)return;let o=e.let("valid",!0),a=e.name("_valid");if(c(),r.reset(),s&&i){let u=e.let("ifClause");r.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else s?e.if(a,l("then")):e.if((0,ch.not)(a),l("else"));r.pass(o,()=>r.error(!0));function c(){let u=r.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);r.mergeEvaluated(u)}function l(u,d){return()=>{let f=r.subschema({keyword:u},a);e.assign(o,a),r.mergeValidEvaluated(f,o),d?e.assign(d,(0,ch._)`${u}`):r.setParams({ifClause:u})}}}};function iO(r,e){let t=r.schema[e];return t!==void 0&&!(0,oO.alwaysValidSchema)(r,t)}ab.default=zW});var cO=k(cb=>{"use strict";Object.defineProperty(cb,"__esModule",{value:!0});var GW=he(),YW={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:r,parentSchema:e,it:t}){e.if===void 0&&(0,GW.checkStrictMode)(t,`"${r}" without "if" is ignored`)}};cb.default=YW});var lO=k(lb=>{"use strict";Object.defineProperty(lb,"__esModule",{value:!0});var JW=Hv(),XW=FD(),QW=Kv(),ZW=UD(),e2=VD(),t2=nh(),r2=zD(),n2=Zv(),s2=JD(),i2=eO(),o2=tO(),a2=rO(),c2=nO(),l2=sO(),u2=aO(),d2=cO();function f2(r=!1){let e=[o2.default,a2.default,c2.default,l2.default,u2.default,d2.default,r2.default,n2.default,t2.default,s2.default,i2.default];return r?e.push(XW.default,ZW.default):e.push(JW.default,QW.default),e.push(e2.default),e}lb.default=f2});var uO=k(ub=>{"use strict";Object.defineProperty(ub,"__esModule",{value:!0});var pt=oe(),h2={message:({schemaCode:r})=>(0,pt.str)`must match format "${r}"`,params:({schemaCode:r})=>(0,pt._)`{format: ${r}}`},p2={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:h2,code(r,e){let{gen:t,data:n,$data:s,schema:i,schemaCode:o,it:a}=r,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;s?f():p();function f(){let b=t.scopeValue("formats",{ref:d.formats,code:c.code.formats}),g=t.const("fDef",(0,pt._)`${b}[${o}]`),_=t.let("fType"),w=t.let("format");t.if((0,pt._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>t.assign(_,(0,pt._)`${g}.type || "string"`).assign(w,(0,pt._)`${g}.validate`),()=>t.assign(_,(0,pt._)`"string"`).assign(w,g)),r.fail$data((0,pt.or)(T(),v()));function T(){return c.strictSchema===!1?pt.nil:(0,pt._)`${o} && !${w}`}function v(){let R=u.$async?(0,pt._)`(${g}.async ? await ${w}(${n}) : ${w}(${n}))`:(0,pt._)`${w}(${n})`,A=(0,pt._)`(typeof ${w} == "function" ? ${R} : ${w}.test(${n}))`;return(0,pt._)`${w} && ${w} !== true && ${_} === ${e} && !${A}`}}function p(){let b=d.formats[i];if(!b){T();return}if(b===!0)return;let[g,_,w]=v(b);g===e&&r.pass(R());function T(){if(c.strictSchema===!1){d.logger.warn(A());return}throw new Error(A());function A(){return`unknown format "${i}" ignored in schema at path "${l}"`}}function v(A){let L=A instanceof RegExp?(0,pt.regexpCode)(A):c.code.formats?(0,pt._)`${c.code.formats}${(0,pt.getProperty)(i)}`:void 0,W=t.scopeValue("formats",{key:i,ref:A,code:L});return typeof A=="object"&&!(A instanceof RegExp)?[A.type||"string",A.validate,(0,pt._)`${W}.validate`]:["string",A,W]}function R(){if(typeof b=="object"&&!(b instanceof RegExp)&&b.async){if(!u.$async)throw new Error("async format in sync schema");return(0,pt._)`await ${w}(${n})`}return typeof _=="function"?(0,pt._)`${w}(${n})`:(0,pt._)`${w}.test(${n})`}}}};ub.default=p2});var dO=k(db=>{"use strict";Object.defineProperty(db,"__esModule",{value:!0});var m2=uO(),g2=[m2.default];db.default=g2});var fO=k(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.contentVocabulary=Go.metadataVocabulary=void 0;Go.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Go.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var pO=k(fb=>{"use strict";Object.defineProperty(fb,"__esModule",{value:!0});var y2=SD(),v2=LD(),b2=lO(),T2=dO(),hO=fO(),_2=[y2.default,v2.default,(0,b2.default)(),T2.default,hO.metadataVocabulary,hO.contentVocabulary];fb.default=_2});var pb=k(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});Zc.dynamicAnchor=void 0;var hb=oe(),S2=$r(),mO=jc(),k2=Jf(),w2={keyword:"$dynamicAnchor",schemaType:"string",code:r=>gO(r,r.schema)};function gO(r,e){let{gen:t,it:n}=r;n.schemaEnv.root.dynamicAnchors[e]=!0;let s=(0,hb._)`${S2.default.dynamicAnchors}${(0,hb.getProperty)(e)}`,i=n.errSchemaPath==="#"?n.validateName:E2(r);t.if((0,hb._)`!${s}`,()=>t.assign(s,i))}Zc.dynamicAnchor=gO;function E2(r){let{schemaEnv:e,schema:t,self:n}=r.it,{root:s,baseId:i,localRefs:o,meta:a}=e.root,{schemaId:c}=n.opts,l=new mO.SchemaEnv({schema:t,schemaId:c,root:s,baseId:i,localRefs:o,meta:a});return mO.compileSchema.call(n,l),(0,k2.getValidate)(r,l)}Zc.default=w2});var mb=k(el=>{"use strict";Object.defineProperty(el,"__esModule",{value:!0});el.dynamicRef=void 0;var yO=oe(),N2=$r(),vO=Jf(),P2={keyword:"$dynamicRef",schemaType:"string",code:r=>bO(r,r.schema)};function bO(r,e){let{gen:t,keyword:n,it:s}=r;if(e[0]!=="#")throw new Error(`"${n}" only supports hash fragment reference`);let i=e.slice(1);if(s.allErrors)o();else{let c=t.let("valid",!1);o(c),r.ok(c)}function o(c){if(s.schemaEnv.root.dynamicAnchors[i]){let l=t.let("_v",(0,yO._)`${N2.default.dynamicAnchors}${(0,yO.getProperty)(i)}`);t.if(l,a(l,c),a(s.validateName,c))}else a(s.validateName,c)()}function a(c,l){return l?()=>t.block(()=>{(0,vO.callRef)(r,c),t.let(l,!0)}):()=>(0,vO.callRef)(r,c)}}el.dynamicRef=bO;el.default=P2});var TO=k(gb=>{"use strict";Object.defineProperty(gb,"__esModule",{value:!0});var R2=pb(),C2=he(),D2={keyword:"$recursiveAnchor",schemaType:"boolean",code(r){r.schema?(0,R2.dynamicAnchor)(r,""):(0,C2.checkStrictMode)(r.it,"$recursiveAnchor: false is ignored")}};gb.default=D2});var _O=k(yb=>{"use strict";Object.defineProperty(yb,"__esModule",{value:!0});var O2=mb(),A2={keyword:"$recursiveRef",schemaType:"string",code:r=>(0,O2.dynamicRef)(r,r.schema)};yb.default=A2});var SO=k(vb=>{"use strict";Object.defineProperty(vb,"__esModule",{value:!0});var I2=pb(),M2=mb(),x2=TO(),L2=_O(),$2=[I2.default,M2.default,x2.default,L2.default];vb.default=$2});var wO=k(bb=>{"use strict";Object.defineProperty(bb,"__esModule",{value:!0});var kO=nh(),q2={keyword:"dependentRequired",type:"object",schemaType:"object",error:kO.error,code:r=>(0,kO.validatePropertyDeps)(r)};bb.default=q2});var EO=k(Tb=>{"use strict";Object.defineProperty(Tb,"__esModule",{value:!0});var j2=nh(),F2={keyword:"dependentSchemas",type:"object",schemaType:"object",code:r=>(0,j2.validateSchemaDeps)(r)};Tb.default=F2});var NO=k(_b=>{"use strict";Object.defineProperty(_b,"__esModule",{value:!0});var B2=he(),U2={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:r,parentSchema:e,it:t}){e.contains===void 0&&(0,B2.checkStrictMode)(t,`"${r}" without "contains" is ignored`)}};_b.default=U2});var PO=k(Sb=>{"use strict";Object.defineProperty(Sb,"__esModule",{value:!0});var V2=wO(),W2=EO(),H2=NO(),K2=[V2.default,W2.default,H2.default];Sb.default=K2});var CO=k(kb=>{"use strict";Object.defineProperty(kb,"__esModule",{value:!0});var Ls=oe(),RO=he(),z2=$r(),G2={message:"must NOT have unevaluated properties",params:({params:r})=>(0,Ls._)`{unevaluatedProperty: ${r.unevaluatedProperty}}`},Y2={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:G2,code(r){let{gen:e,schema:t,data:n,errsCount:s,it:i}=r;if(!s)throw new Error("ajv implementation error");let{allErrors:o,props:a}=i;a instanceof Ls.Name?e.if((0,Ls._)`${a} !== true`,()=>e.forIn("key",n,d=>e.if(l(a,d),()=>c(d)))):a!==!0&&e.forIn("key",n,d=>a===void 0?c(d):e.if(u(a,d),()=>c(d))),i.props=!0,r.ok((0,Ls._)`${s} === ${z2.default.errors}`);function c(d){if(t===!1){r.setParams({unevaluatedProperty:d}),r.error(),o||e.break();return}if(!(0,RO.alwaysValidSchema)(i,t)){let f=e.name("valid");r.subschema({keyword:"unevaluatedProperties",dataProp:d,dataPropType:RO.Type.Str},f),o||e.if((0,Ls.not)(f),()=>e.break())}}function l(d,f){return(0,Ls._)`!${d} || !${d}[${f}]`}function u(d,f){let p=[];for(let b in d)d[b]===!0&&p.push((0,Ls._)`${f} !== ${b}`);return(0,Ls.and)(...p)}}};kb.default=Y2});var OO=k(wb=>{"use strict";Object.defineProperty(wb,"__esModule",{value:!0});var ki=oe(),DO=he(),J2={message:({params:{len:r}})=>(0,ki.str)`must NOT have more than ${r} items`,params:({params:{len:r}})=>(0,ki._)`{limit: ${r}}`},X2={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:J2,code(r){let{gen:e,schema:t,data:n,it:s}=r,i=s.items||0;if(i===!0)return;let o=e.const("len",(0,ki._)`${n}.length`);if(t===!1)r.setParams({len:i}),r.fail((0,ki._)`${o} > ${i}`);else if(typeof t=="object"&&!(0,DO.alwaysValidSchema)(s,t)){let c=e.var("valid",(0,ki._)`${o} <= ${i}`);e.if((0,ki.not)(c),()=>a(c,i)),r.ok(c)}s.items=!0;function a(c,l){e.forRange("i",l,o,u=>{r.subschema({keyword:"unevaluatedItems",dataProp:u,dataPropType:DO.Type.Num},c),s.allErrors||e.if((0,ki.not)(c),()=>e.break())})}}};wb.default=X2});var AO=k(Eb=>{"use strict";Object.defineProperty(Eb,"__esModule",{value:!0});var Q2=CO(),Z2=OO(),eH=[Q2.default,Z2.default];Eb.default=eH});var MO=k(lh=>{"use strict";Object.defineProperty(lh,"__esModule",{value:!0});lh.DiscrError=void 0;var IO;(function(r){r.Tag="tag",r.Mapping="mapping"})(IO||(lh.DiscrError=IO={}))});var LO=k(Pb=>{"use strict";Object.defineProperty(Pb,"__esModule",{value:!0});var Yo=oe(),Nb=MO(),xO=jc(),tH=qc(),rH=he(),nH={message:({params:{discrError:r,tagName:e}})=>r===Nb.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:r,tag:e,tagName:t}})=>(0,Yo._)`{error: ${r}, tag: ${t}, tagValue: ${e}}`},sH={keyword:"discriminator",type:"object",schemaType:"object",error:nH,code(r){let{gen:e,data:t,schema:n,parentSchema:s,it:i}=r,{oneOf:o}=s;if(!i.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),l=e.const("tag",(0,Yo._)`${t}${(0,Yo.getProperty)(a)}`);e.if((0,Yo._)`typeof ${l} == "string"`,()=>u(),()=>r.error(!1,{discrError:Nb.DiscrError.Tag,tag:l,tagName:a})),r.ok(c);function u(){let p=f();e.if(!1);for(let b in p)e.elseIf((0,Yo._)`${l} === ${b}`),e.assign(c,d(p[b]));e.else(),r.error(!1,{discrError:Nb.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(p){let b=e.name("valid"),g=r.subschema({keyword:"oneOf",schemaProp:p},b);return r.mergeEvaluated(g,Yo.Name),b}function f(){var p;let b={},g=w(s),_=!0;for(let R=0;R<o.length;R++){let A=o[R];if(A?.$ref&&!(0,rH.schemaHasRulesButRef)(A,i.self.RULES)){let W=A.$ref;if(A=xO.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,W),A instanceof xO.SchemaEnv&&(A=A.schema),A===void 0)throw new tH.default(i.opts.uriResolver,i.baseId,W)}let L=(p=A?.properties)===null||p===void 0?void 0:p[a];if(typeof L!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);_=_&&(g||w(A)),T(L,R)}if(!_)throw new Error(`discriminator: "${a}" must be required`);return b;function w({required:R}){return Array.isArray(R)&&R.includes(a)}function T(R,A){if(R.const)v(R.const,A);else if(R.enum)for(let L of R.enum)v(L,A);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v(R,A){if(typeof R!="string"||R in b)throw new Error(`discriminator: "${a}" values must be unique strings`);b[R]=A}}}};Pb.default=sH});var $O=k((Iee,iH)=>{iH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/schema",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0,"https://json-schema.org/draft/2019-09/vocab/applicator":!0,"https://json-schema.org/draft/2019-09/vocab/validation":!0,"https://json-schema.org/draft/2019-09/vocab/meta-data":!0,"https://json-schema.org/draft/2019-09/vocab/format":!1,"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format"},{$ref:"meta/content"}],type:["object","boolean"],properties:{definitions:{$comment:"While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.",type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},dependencies:{$comment:'"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"',type:"object",additionalProperties:{anyOf:[{$recursiveRef:"#"},{$ref:"meta/validation#/$defs/stringArray"}]}}}}});var qO=k((Mee,oH)=>{oH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/applicator":!0},$recursiveAnchor:!0,title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{additionalItems:{$recursiveRef:"#"},unevaluatedItems:{$recursiveRef:"#"},items:{anyOf:[{$recursiveRef:"#"},{$ref:"#/$defs/schemaArray"}]},contains:{$recursiveRef:"#"},additionalProperties:{$recursiveRef:"#"},unevaluatedProperties:{$recursiveRef:"#"},properties:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$recursiveRef:"#"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$recursiveRef:"#"}},propertyNames:{$recursiveRef:"#"},if:{$recursiveRef:"#"},then:{$recursiveRef:"#"},else:{$recursiveRef:"#"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$recursiveRef:"#"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$recursiveRef:"#"}}}}});var jO=k((xee,aH)=>{aH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/content",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentMediaType:{type:"string"},contentEncoding:{type:"string"},contentSchema:{$recursiveRef:"#"}}}});var FO=k((Lee,cH)=>{cH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/core",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0},$recursiveAnchor:!0,title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{type:"string",format:"uri"},$anchor:{type:"string",pattern:"^[A-Za-z][-A-Za-z0-9.:_]*$"},$ref:{type:"string",format:"uri-reference"},$recursiveRef:{type:"string",format:"uri-reference"},$recursiveAnchor:{type:"boolean",default:!1},$vocabulary:{type:"object",propertyNames:{type:"string",format:"uri"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}}}}});var BO=k(($ee,lH)=>{lH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/format",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/format":!0},$recursiveAnchor:!0,title:"Format vocabulary meta-schema",type:["object","boolean"],properties:{format:{type:"string"}}}});var UO=k((qee,uH)=>{uH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/meta-data":!0},$recursiveAnchor:!0,title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}});var VO=k((jee,dH)=>{dH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/validation",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/validation":!0},$recursiveAnchor:!0,title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}},const:!0,enum:{type:"array",items:!0},type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}});var WO=k(Rb=>{"use strict";Object.defineProperty(Rb,"__esModule",{value:!0});var fH=$O(),hH=qO(),pH=jO(),mH=FO(),gH=BO(),yH=UO(),vH=VO(),bH=["/properties"];function TH(r){return[fH,hH,pH,mH,e(this,gH),yH,e(this,vH)].forEach(t=>this.addMetaSchema(t,void 0,!1)),this;function e(t,n){return r?t.$dataMetaSchema(n,bH):n}}Rb.default=TH});var HO=k((et,Db)=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.MissingRefError=et.ValidationError=et.CodeGen=et.Name=et.nil=et.stringify=et.str=et._=et.KeywordCxt=et.Ajv2019=void 0;var _H=yD(),SH=pO(),kH=SO(),wH=PO(),EH=AO(),NH=LO(),PH=WO(),Cb="https://json-schema.org/draft/2019-09/schema",Jo=class extends _H.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(kH.default),SH.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(wH.default),this.addVocabulary(EH.default),this.opts.discriminator&&this.addKeyword(NH.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(PH.default.call(this,e),this.refs["http://json-schema.org/schema"]=Cb)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Cb)?Cb:void 0)}};et.Ajv2019=Jo;Db.exports=et=Jo;Db.exports.Ajv2019=Jo;Object.defineProperty(et,"__esModule",{value:!0});et.default=Jo;var RH=$c();Object.defineProperty(et,"KeywordCxt",{enumerable:!0,get:function(){return RH.KeywordCxt}});var Xo=oe();Object.defineProperty(et,"_",{enumerable:!0,get:function(){return Xo._}});Object.defineProperty(et,"str",{enumerable:!0,get:function(){return Xo.str}});Object.defineProperty(et,"stringify",{enumerable:!0,get:function(){return Xo.stringify}});Object.defineProperty(et,"nil",{enumerable:!0,get:function(){return Xo.nil}});Object.defineProperty(et,"Name",{enumerable:!0,get:function(){return Xo.Name}});Object.defineProperty(et,"CodeGen",{enumerable:!0,get:function(){return Xo.CodeGen}});var CH=Uf();Object.defineProperty(et,"ValidationError",{enumerable:!0,get:function(){return CH.default}});var DH=qc();Object.defineProperty(et,"MissingRefError",{enumerable:!0,get:function(){return DH.default}})});var xe=z(Sw());var xu=class r{constructor(e,t,n,s){this._uri=e,this._languageId=t,this._version=n,this._content=s,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){let t=this.offsetAt(e.start),n=this.offsetAt(e.end);return this._content.substring(t,n)}return this._content}update(e,t){for(let n of e)if(r.isIncremental(n)){let s=ww(n.range),i=this.offsetAt(s.start),o=this.offsetAt(s.end);this._content=this._content.substring(0,i)+n.text+this._content.substring(o,this._content.length);let a=Math.max(s.start.line,0),c=Math.max(s.end.line,0),l=this._lineOffsets,u=kw(n.text,!1,i);if(c-a===u.length)for(let f=0,p=u.length;f<p;f++)l[f+a+1]=u[f];else u.length<1e4?l.splice(a+1,c-a,...u):this._lineOffsets=l=l.slice(0,a+1).concat(u,l.slice(c+1));let d=n.text.length-(o-i);if(d!==0)for(let f=a+1+u.length,p=l.length;f<p;f++)l[f]=l[f]+d}else if(r.isFull(n))this._content=n.text,this._lineOffsets=void 0;else throw new Error("Unknown change event received");this._version=t}getLineOffsets(){return this._lineOffsets===void 0&&(this._lineOffsets=kw(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let t=this.getLineOffsets(),n=0,s=t.length;if(s===0)return{line:0,character:e};for(;n<s;){let o=Math.floor((n+s)/2);t[o]>e?s=o:n=o+1}let i=n-1;return{line:i,character:e-t[i]}}offsetAt(e){let t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;let n=t[e.line],s=e.line+1<t.length?t[e.line+1]:this._content.length;return Math.max(Math.min(n+e.character,s),n)}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){let t=e;return t!=null&&typeof t.text=="string"&&t.range!==void 0&&(t.rangeLength===void 0||typeof t.rangeLength=="number")}static isFull(e){let t=e;return t!=null&&typeof t.text=="string"&&t.range===void 0&&t.rangeLength===void 0}},Lu;(function(r){function e(s,i,o,a){return new xu(s,i,o,a)}r.create=e;function t(s,i,o){if(s instanceof xu)return s.update(i,o),s;throw new Error("TextDocument.update: document must be created by TextDocument.create")}r.update=t;function n(s,i){let o=s.getText(),a=bm(i.map(FM),(u,d)=>{let f=u.range.start.line-d.range.start.line;return f===0?u.range.start.character-d.range.start.character:f}),c=0,l=[];for(let u of a){let d=s.offsetAt(u.range.start);if(d<c)throw new Error("Overlapping edit");d>c&&l.push(o.substring(c,d)),u.newText.length&&l.push(u.newText),c=s.offsetAt(u.range.end)}return l.push(o.substr(c)),l.join("")}r.applyEdits=n})(Lu||(Lu={}));function bm(r,e){if(r.length<=1)return r;let t=r.length/2|0,n=r.slice(0,t),s=r.slice(t);bm(n,e),bm(s,e);let i=0,o=0,a=0;for(;i<n.length&&o<s.length;)e(n[i],s[o])<=0?r[a++]=n[i++]:r[a++]=s[o++];for(;i<n.length;)r[a++]=n[i++];for(;o<s.length;)r[a++]=s[o++];return r}function kw(r,e,t=0){let n=e?[t]:[];for(let s=0;s<r.length;s++){let i=r.charCodeAt(s);(i===13||i===10)&&(i===13&&s+1<r.length&&r.charCodeAt(s+1)===10&&s++,n.push(t+s+1))}return n}function ww(r){let e=r.start,t=r.end;return e.line>t.line||e.line===t.line&&e.character>t.character?{start:t,end:e}:r}function FM(r){let e=ww(r.range);return e!==r.range?{newText:r.newText,range:e}:r}var $u=["namespace","class","enum","interface","struct","typeParameter","type","parameter","variable","property","enumMember","decorator","event","function","method","macro","label","comment","string","keyword","number","regexp","operator"],qu=["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"];var Ew=z(J());var Tm=z(require("url")),Ys=(r,e,t=!0,n=!0)=>({start:{line:r?.pos.line??0,character:t?r?.pos.col??0:(r?.pos.col??0)+(r?.pos.len??0)},end:{line:e?.pos.line??0,character:n?(e?.pos.col??0)+(e?.pos.len??0):e?.pos.col??0}});var Q=r=>Ys(r.tokenIndexes.start,r.tokenIndexes.end),Nw=" ",Pw=r=>{Nw=r},Zi=()=>Nw,Js=r=>$u.findIndex(e=>e===r),Xs=r=>qu.findIndex(e=>e===r),_m=(r,e,t)=>r.uri!==e||t.line<r.pos.line?!1:t.line>r.pos.line?!0:t.character>r.pos.col+r.pos.len,BM=(r,e,t)=>r.uri!==e?!1:t.line<r.pos.line?!0:t.line>r.pos.line?!1:t.character<r.pos.col,Tr=(r,e,t)=>!!(r.uri===e&&r.tokenIndexes?.start&&r.tokenIndexes?.end&&(r.tokenIndexes.start.pos.line<t.line||r.tokenIndexes.start.pos.line===t.line&&r.tokenIndexes.start.pos.col<=t.character)&&(r.tokenIndexes.end.pos.line>t.line||r.tokenIndexes.end.pos.line===t.line&&r.tokenIndexes.end.pos.col+r.tokenIndexes.end.pos.len>=t.character)),Rw=(r,e,t)=>!!(r.uri===e&&r.lastToken.value!==";"&&r.tokenIndexes?.start&&r.tokenIndexes?.end&&(r.tokenIndexes.start.pos.line===t.line||r.tokenIndexes.end.pos.line===t.line)&&t.character>=r.tokenIndexes.end.pos.col+r.tokenIndexes.end.pos.len),Cw=(r,e,t)=>{if(!r)return!1;let s=r.filter(i=>i.pos.line===t.line).at(-1);return s&&s.pos.col>=t.character?!1:e.tokenIndexes?.end===s};var hn=(r,e,t)=>{let n=r,s=r;for(;s;)n=s,s=[...n.children].reverse().find(i=>Tr(i,e,t));return n},_a=(r,e,t)=>{let n=r,s=r;for(;s;)n=s,s=[...n.children].find(i=>BM(i.lastToken,e,t));return n===r?void 0:n},Sa=(r,e,t)=>{let n=r,s=r;for(;s;)n=s,s=[...n.children].reverse().find(i=>_m(i.firstToken,e,t));return n===r?void 0:n},C=(r,e,t=Ew.DiagnosticSeverity.Error,n=[],s=void 0,i=[],o,a)=>({issues:Array.isArray(r)?r:[r],astElement:e,severity:t,linkedTo:n,tags:s,templateStrings:i,edit:o,codeActionTitle:a}),Dw=r=>[...r].sort((t,n)=>{if(t.sortKey===void 0||n.sortKey===void 0)throw new Error("Sort keys must be set");if(t.sortKey!==n.sortKey)return t.sortKey-n.sortKey;if(!t.tokenIndexes?.end||!n.tokenIndexes?.end)throw new Error("Must have token indexes");return t.tokenIndexes.end.pos.line!==n.tokenIndexes.end.pos.line?t.tokenIndexes.end.pos.line-n.tokenIndexes.end.pos.line:t.tokenIndexes.end.pos.col-n.tokenIndexes.end.pos.col});async function Mt(r,e,t,n,s){let i=xt(r.textDocument.uri),o=Qs(e,i,n,s);if(!o)return[];console.time("search");let c=(await o.context.getRuntime()).getDeepestAstNode(i,r.position),l=c?.ast?.firstToken.sortKey;return console.timeEnd("search"),t(c,d=>{let f=r.position;return d.uri===i?!!(d.tokenIndexes?.end&&(d.tokenIndexes.end.pos.line<f.line||d.tokenIndexes.end.pos.line===f.line&&d.tokenIndexes.end.pos.col+d.tokenIndexes.end.pos.len<=f.character)):l!==void 0&&d.sortKey<=l})}function G(r,e){return{start:r,end:e??r}}var $=(r,e)=>r?.tokens.some(t=>t===e),Je=r=>e=>e?.value&&r===e.value?"yes":UM(r)(e),Pe=r=>e=>e?.tokens.some(t=>t===r)?"yes":"no",UM=r=>e=>e?.value&&r.startsWith(e.value)?"partial":"no",pn=(r,e)=>!!r&&!!e&&r.pos.line===e.pos.line&&r.uri===e.uri,Xt=(r,e)=>!!r&&!!e&&pn(r,e)&&r.pos.col+r.pos.len===e.pos.col,ju=r=>r.map((e,t)=>({index:t,context:e,files:e.getContextFiles()})),Qs=(r,e,t,n)=>t?.getContextFiles().find(i=>i===e)?{context:t}:ju(r).sort(i=>i.context.name===n?-1:0).find(i=>i.files.some(o=>o===e)),Ow=(r,e)=>ju(r).filter(n=>n.files.some(s=>s===e)),Aw=r=>{let e=/^(\w+)\s+(.+)$/,t=/^(\w+)\(([^)]*)\)\s+(.+)$/,n=/^(\w+)\(([^)]*),\s*\.\.\.\)\s+(.+)$/,s;if(s=n.exec(r)){let[,,i,o]=s,a=i.split(",").map(c=>c.trim());return(...c)=>{let l=o;return a.forEach((u,d)=>{let f=new RegExp(`\\b${u}\\b`,"g");l=l.replace(f,c[d])}),l=l.replace(/__VA_ARGS__/g,c.slice(a.length).join(", ")),l}}else if(s=t.exec(r)){let[,,i,o]=s,a=i.split(",").map(c=>c.trim());return(...c)=>{let l=o;return a.forEach((u,d)=>{let f=new RegExp(`\\b${u}\\b`,"g");l=l.replace(f,c[d])}),l}}else if(s=e.exec(r)){let[,,i]=s;return i.trim()}},Iw=(r,e)=>{let t=o=>o.replace(/(\w+)\s*##\s*(\w+)/g,(a,c,l)=>c+l),n=o=>o.replace(/#(\w+)/g,(a,c)=>`"${c}"`),s=r,i;do i=s,s=t(i),s=n(s),s=s.replace(/\b(\w+)\(([^)]*)\)|\b(\w+)\b/g,(o,a,c,l)=>{if(a==="defined"){let u=c.split(",").map(d=>d.trim());return u[0]?e.get(u[0])?.resolver:u}else if(a&&typeof e.get(a)?.resolver=="function"){let u=c.split(",").map(d=>d.trim());return(e.get(a)?.resolver)(...u)}else if(l&&typeof e.get(l)?.resolver=="string")return e.get(l)?.resolver;return o});while(s!==i);return s},ce=r=>Tm.default.pathToFileURL(r).toString(),xt=r=>Tm.default.fileURLToPath(r),Mw=(r,e)=>r===e;var Ln=z(J()),F=class{constructor(e){this._children=[];this._fisrtToken=e?.start,this._lastToken=e?.end}get sortKey(){return this.firstToken.sortKey??this.parentNode?.sortKey??-1}get firstToken(){return this._fisrtToken??this._children[0].tokenIndexes.start}set firstToken(e){this._fisrtToken=e}get lastToken(){return this._lastToken??this._children.at(-1)?.lastToken??this.firstToken}set lastToken(e){this._lastToken=e}get uri(){return this.firstToken.uri}get tokenIndexes(){return{start:this.firstToken,end:this.lastToken}}getDocumentSymbols(e){if(!this.docSymbolsMeta)return this.children.flatMap(n=>n.getDocumentSymbols(e)??[]);if(this.uri!==e)return[];let t=Q(this);return[{name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind,range:t,selectionRange:t,children:[...this.children.flatMap(n=>n.getDocumentSymbols(e)??[])]}]}getWorkspaceSymbols(){if(!this.docSymbolsMeta)return this.children.flatMap(n=>n.getWorkspaceSymbols()??[]);let e=this.docSymbolsMeta.kind;if(![Ln.SymbolKind.File,Ln.SymbolKind.Class,Ln.SymbolKind.Namespace].some(n=>n===e))return[];let t=Q(this);return[{location:Ln.Location.create(ce(this.uri),t),name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind},...this.children.flatMap(n=>n.getWorkspaceSymbols()??[]).filter(n=>n.kind===Ln.SymbolKind.File||n.kind===Ln.SymbolKind.Class||n.kind===Ln.SymbolKind.Namespace)]}buildSemanticTokens(e){this._children.forEach(t=>t.buildSemanticTokens(e)),!(!this.semanticTokenType||!this.semanticTokenModifiers)&&e(Js(this.semanticTokenType),Xs(this.semanticTokenModifiers),this.tokenIndexes)}get children(){return this._children}get allDescendants(){return[...this._children,...this._children.flatMap(e=>e.allDescendants)]}addChild(e){e&&(e.parentNode=this,this.children.push(e))}};var eo=z(J());var jw=z(J());var xw=z(J()),Oe=class extends F{constructor(t,n){super(n);this.value=t;this.semanticTokenType="string",this.semanticTokenModifiers="declaration",this.docSymbolsMeta={name:this.value,kind:xw.SymbolKind.String}}toString(){return`"${this.value.toString()}"`}toJson(){return this.value}};var $w=z(J());var Lw=z(J());function VM(r){return r.replace(/'(.)'/g,(e,t)=>t.charCodeAt(0).toString()).replace(/(0x[a-f\d]+|\d+)[ul]*/gi,"$1")}function Sm(r){try{return(0,eval)(VM(r))}catch(e){console.log(e)}return r}var zr=class extends F{toJson(){return-1}resolve(e){return Iw(this.toString(),e)}evaluate(e){return Sm(this.resolve(e))}isTrue(e){return Sm(`!!(${this.resolve(e)})`)}},Zs=class extends zr{constructor(t,n,s){super();this.expression=t;this.wrapped=n;this.join=s;this.addChild(t),s&&(this.addChild(s.operator),this.addChild(s.expression))}addExpression(t,n){this.addChild(t),this.addChild(n)}toString(){let t=this.children.map(n=>n.toString()).join(" ");return this.wrapped?`(${t})`:`${t}`}isTrue(t){let n=`(${this.children.map(s=>s instanceof zr?s.resolve(t):s.toString()).join(" ")})`;return Sm(`!!${n}`)}};var _t=class extends zr{constructor(t,n){super(n);this.value=t;this.docSymbolsMeta={name:this.value.toString(),kind:Lw.SymbolKind.Number},this.semanticTokenType="number",this.semanticTokenModifiers="declaration"}toString(){return this.value.toString()}toJson(){return this.value}};var yt=class extends F{constructor(t){super();this.values=t;this.docSymbolsMeta={name:"Cell Array",kind:$w.SymbolKind.Array},this.values.forEach(n=>this.addChild(n))}toString(){return`<${this.values.map(t=>t.toString()).join(" ")}>`}toJson(){if(this.values.length===1)return this.values[0].value?.toJson();if(this.values.length===2&&this.values.every(t=>t.value instanceof _t)){let t=new ArrayBuffer(8),n=new DataView(t);return this.values.map(s=>s.value.value).forEach((s,i)=>{n.setUint32(i*4,s)}),n.getBigUint64(0)}return this.values.map(t=>t.value?.toJson()??NaN)}};var qw=z(J()),as=class extends F{constructor(t){super();this.values=t;this.docSymbolsMeta={name:"Byte String Value",kind:qw.SymbolKind.Array},this.values.forEach(n=>this.addChild(n))}toString(){return`[${this.values.map(t=>t.toString()).join(" ")}]`}toJson(){return this.values.map(t=>t.value?.toJson()??NaN)}};var ze=class extends F{constructor(t,n){super(n);this.name=t;this.semanticTokenType="property",this.semanticTokenModifiers="declaration"}toString(){return this.name}},Ae=class extends F{constructor(t,n=[]){super();this.propertyName=t;this.labels=n;this._values=void 0;this.docSymbolsMeta={name:this.propertyName?.name??"Unknown",kind:jw.SymbolKind.Property},this.labels.forEach(s=>this.addChild(s)),this.addChild(t)}set values(t){if(this._values)throw new Error("Only one property name is allowed");this._values=t,this.addChild(t)}get values(){return this._values}get quickValues(){return this.values?.values.map(t=>t?t.value instanceof Oe?t.value.value:t.value instanceof yt?t.value.values.map(n=>n.value instanceof _t?n.value.value:NaN):t.value instanceof as?t.value.values.map(n=>n.value?.value??NaN):NaN:null)}toString(){return`${this.propertyName?.toString()??"__UNSET__"}${this.assignOperatorToken?` = ${this._values?.values.map(t=>t?.toString()??"NULL").join(", ")??"NULL"}`:""};`}};var Fw=z(J()),Qt=class extends F{constructor(t,n){super();this.keyword=n;this.addChild(n),this.docSymbolsMeta={name:t,kind:Fw.SymbolKind.Function}}};var ur=class extends Qt{constructor(t){super("Delete Node",t);this._nodeNameOrRef=null}set nodeNameOrRef(t){if(this._nodeNameOrRef)throw new Error("Only one property name is allowed");this._nodeNameOrRef=t,this.addChild(t)}get nodeNameOrRef(){return this._nodeNameOrRef}};var Ue=class extends Qt{constructor(t){super("Delete Property",t);this._propertyName=null}set propertyName(t){if(this._propertyName)throw new Error("Only only property name is allowed");this._propertyName=t,this.addChild(t)}get propertyName(){return this._propertyName}};var qe=class r extends F{constructor(){super()}get path(){if(!this.pathName)return["__UNDEFINED__"];if(!this.parentNode||this instanceof dt)return[this.pathName];if(!(this.parentNode instanceof r))return;let e=this.parentNode.path;return e?[...e,this.pathName]:[this.pathName]}get pathName(){}get nodes(){return this.children.filter(e=>e instanceof r)}get deleteNodes(){return this.children.filter(e=>e instanceof ur)}addNodeChild(e){this.addChild(e)}},dt=class extends qe{constructor(){super(),this.docSymbolsMeta={name:"/",kind:eo.SymbolKind.Class}}get properties(){return this.children.filter(e=>e instanceof Ae)}get name(){return new je("/",G(this.firstToken))}get deleteProperties(){return this.children.filter(e=>e instanceof Ue)}get nodes(){return this.children.filter(e=>e instanceof Re)}get pathName(){return"/"}},Rt=class extends qe{constructor(t=[]){super();this.labels=t;this._labelReference=null;this.docSymbolsMeta={name:"DTC Name",kind:eo.SymbolKind.Class},t.forEach(n=>{super.addChild(n)})}set labelReference(t){if(this._labelReference)throw new Error("Only on label reference is allowed");this._labelReference=t,this.docSymbolsMeta={name:this.labelReference?.value??"DTC Name",kind:eo.SymbolKind.Class},this.addChild(t)}get path(){return this.resolveNodePath?this.resolveNodePath:super.path}get labelReference(){return this._labelReference}get nodes(){return this.children.filter(t=>t instanceof Re)}get pathName(){return this.labelReference?.label?`&${this.labelReference?.label?.value}`:void 0}get properties(){return this.children.filter(t=>t instanceof Ae)}get deleteProperties(){return this.children.filter(t=>t instanceof Ue)}},Re=class r extends qe{constructor(t=[],n){super();this.labels=t;this.omitIfNoRef=n;this._name=null;this.docSymbolsMeta={name:"DTC Name",kind:eo.SymbolKind.Class},n&&this.addChild(n),t.forEach(s=>{this.addChild(s)})}set name(t){if(this._name)throw new Error("Only on label reference is allowed");this._name=t,this.docSymbolsMeta={name:this._name?.toString()??"DTC Name",kind:eo.SymbolKind.Class},this.addChild(t)}get name(){return this._name}get nodes(){return this.children.filter(t=>t instanceof r)}get pathName(){return this._name?.toString()}get properties(){return this.children.filter(t=>t instanceof Ae)}get deleteProperties(){return this.children.filter(t=>t instanceof Ue)}},Fu=class extends F{constructor(t,n){super(n);this.address=t;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.address.toString(16)}},je=class extends F{constructor(t,n,s){super(n);this.name=t;this._address=s;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}get value(){return this.name}get address(){return this._address}set address(t){if(this._address)throw new Error("Address can only be set once");t&&(this.lastToken=void 0,this._address=t,t.forEach(n=>this.addChild(n)))}toString(){return this._address!==void 0?`${this.name}@${this._address.map(t=>t.toString()).join(",")}`:this.name}buildSemanticTokens(t){if(!this.tokenIndexes?.start||!this.tokenIndexes.start.value)return;let n={...this.tokenIndexes.start,pos:{...this.tokenIndexes.start.pos,len:this.name.length}};t(Js("type"),Xs("declaration"),{start:n,end:n}),this.address!==void 0&&this.address.forEach(s=>{t(Js("decorator"),Xs("declaration"),{start:s.lastToken.prevToken,end:s.lastToken.prevToken}),s.buildSemanticTokens(t)})}};var Bw=z(J()),_e=class extends F{constructor(t){super();this.label=t;this.docSymbolsMeta={name:`&${this.label?.value??"NULL"}`,kind:Bw.SymbolKind.Key},this.addChild(t)}get value(){return this.label?.value}toString(){return`&${this.label?.value??"NULL"}`}toJson(){return-1}};var Jr=z(J());var St=r=>r instanceof Qt?!0:r instanceof qe?!1:r.parentNode?St(r.parentNode):!1;var to=r=>[...r.map(e=>{if(e instanceof Re||e instanceof dt)return e.name;if(e instanceof Rt)return e.labelReference})].filter(e=>!!e),km=(r,e)=>e?e.parentNode===r||km(r,e.parentNode):!1;var lt=z(J());var Uw=z(J());var $n=class extends F{constructor(){super();this._pathParts=[]}addPath(t,n){this._pathParts.push(t),n&&this.addChild(n),this.addChild(t)}get pathParts(){return[...this._pathParts]}toString(){return this._pathParts.map(t=>t?.toString()??"<NULL>").join("/")}},Gr=class extends F{constructor(t){super();this.path=t;this.docSymbolsMeta={name:`/${this.path?.toString()??""}`,kind:Uw.SymbolKind.Namespace},this.semanticTokenType="variable",this.semanticTokenModifiers="declaration",this.addChild(t)}toString(){return`&${this.path?.toString()??"NULL"}`}toJson(){return-1}};var it=z(J());var Bu=z(J());var Vw=require("path"),cs=class extends F{constructor(t,n){super();this.keyword=t;this.path=n;this.docSymbolsMeta={name:`Include ${n}`,kind:Bu.SymbolKind.File},this.addChild(t),this.addChild(n)}get resolvedPath(){return this._resolvedPath}set resolvedPath(t){this.docSymbolsMeta={name:`Include ${t}`,kind:Bu.SymbolKind.File},this._resolvedPath=t}},ro=class extends F{constructor(t,n,s){super(s);this._path=t;this.relative=n;this.docSymbolsMeta={name:(0,Vw.basename)(this.path),kind:Bu.SymbolKind.File},this.semanticTokenType="string",this.semanticTokenModifiers="declaration"}get path(){return this.relative?this._path.slice(1,-1):this._path}};var mn=class extends F{constructor(e){super(e),this.semanticTokenType="comment",this.semanticTokenModifiers="documentation"}};var WM=async(r,e,t)=>{let n=it.Position.create(r.pos.line,r.pos.col),s=t.find(i=>Tr(i,e,n));if(s)return hn(s,e,n)},wm=r=>{if(r)return r instanceof qe?r:wm(r?.parentNode)},so=(r,e,t=0)=>!e||e.uri!==r?t:so(r,wm(e.parentNode),t+1),HM=(r,e)=>async t=>{let n=await WM(t.firstToken,e,r);return!n||n===t||t.allDescendants.some(i=>i===n)?0:n instanceof qe?so(e,wm(n)):void 0};async function Ww(r,e){let t=[],n=xt(r.textDocument.uri),s=(await e.getRuntime()).fileTopMostAst(n);return t.push(...(await Promise.all(s.flatMap(async i=>await Hw(r,i,n,HM(s,n))))).flat()),t}var ei=(r,e=1)=>{if(r.prevToken){let t=r.pos.line-r.prevToken.pos.line;if(t-e&&(t!==2&&e!==0||e===0))return it.TextEdit.replace(it.Range.create(it.Position.create(r.prevToken.pos.line,r.prevToken.pos.col+r.prevToken.pos.len),it.Position.create(r.pos.line-e,r.pos.col)),"".padEnd(e-1,`
|
|
182
|
+
deps: ${t}}`};var NW={keyword:"dependencies",type:"object",schemaType:"object",error:Pn.error,code(r){let[e,t]=PW(r);WD(r,e),HD(r,t)}};function PW({schema:r}){let e={},t={};for(let n in r){if(n==="__proto__")continue;let s=Array.isArray(r[n])?e:t;s[n]=r[n]}return[e,t]}function WD(r,e=r.schema){let{gen:t,data:n,it:s}=r;if(Object.keys(e).length===0)return;let i=t.let("missing");for(let o in e){let a=e[o];if(a.length===0)continue;let c=(0,Qc.propertyInData)(t,n,o,s.opts.ownProperties);r.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),s.allErrors?t.if(c,()=>{for(let l of a)(0,Qc.checkReportMissingProp)(r,l)}):(t.if((0,Jv._)`${c} && (${(0,Qc.checkMissingProp)(r,a,i)})`),(0,Qc.reportMissingProp)(r,i),t.else())}}Pn.validatePropertyDeps=WD;function HD(r,e=r.schema){let{gen:t,data:n,keyword:s,it:i}=r,o=t.name("valid");for(let a in e)(0,EW.alwaysValidSchema)(i,e[a])||(t.if((0,Qc.propertyInData)(t,n,a,i.opts.ownProperties),()=>{let c=r.subschema({keyword:s,schemaProp:a},o);r.mergeValidEvaluated(c,o)},()=>t.var(o,!0)),r.ok(o))}Pn.validateSchemaDeps=HD;Pn.default=NW});var zD=k(Xv=>{"use strict";Object.defineProperty(Xv,"__esModule",{value:!0});var KD=oe(),RW=he(),CW={message:"property name must be valid",params:({params:r})=>(0,KD._)`{propertyName: ${r.propertyName}}`},DW={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:CW,code(r){let{gen:e,schema:t,data:n,it:s}=r;if((0,RW.alwaysValidSchema)(s,t))return;let i=e.name("valid");e.forIn("key",n,o=>{r.setParams({propertyName:o}),r.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},i),e.if((0,KD.not)(i),()=>{r.error(!0),s.allErrors||e.break()})}),r.ok(i)}};Xv.default=DW});var Zv=k(Qv=>{"use strict";Object.defineProperty(Qv,"__esModule",{value:!0});var sh=qr(),cn=oe(),OW=$r(),ih=he(),AW={message:"must NOT have additional properties",params:({params:r})=>(0,cn._)`{additionalProperty: ${r.additionalProperty}}`},IW={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:AW,code(r){let{gen:e,schema:t,parentSchema:n,data:s,errsCount:i,it:o}=r;if(!i)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=o;if(o.props=!0,c.removeAdditional!=="all"&&(0,ih.alwaysValidSchema)(o,t))return;let l=(0,sh.allSchemaProperties)(n.properties),u=(0,sh.allSchemaProperties)(n.patternProperties);d(),r.ok((0,cn._)`${i} === ${OW.default.errors}`);function d(){e.forIn("key",s,_=>{!l.length&&!u.length?b(_):e.if(f(_),()=>b(_))})}function f(_){let w;if(l.length>8){let T=(0,ih.schemaRefOrVal)(o,n.properties,"properties");w=(0,sh.isOwnProperty)(e,T,_)}else l.length?w=(0,cn.or)(...l.map(T=>(0,cn._)`${_} === ${T}`)):w=cn.nil;return u.length&&(w=(0,cn.or)(w,...u.map(T=>(0,cn._)`${(0,sh.usePattern)(r,T)}.test(${_})`))),(0,cn.not)(w)}function p(_){e.code((0,cn._)`delete ${s}[${_}]`)}function b(_){if(c.removeAdditional==="all"||c.removeAdditional&&t===!1){p(_);return}if(t===!1){r.setParams({additionalProperty:_}),r.error(),a||e.break();return}if(typeof t=="object"&&!(0,ih.alwaysValidSchema)(o,t)){let w=e.name("valid");c.removeAdditional==="failing"?(g(_,w,!1),e.if((0,cn.not)(w),()=>{r.reset(),p(_)})):(g(_,w),a||e.if((0,cn.not)(w),()=>e.break()))}}function g(_,w,T){let v={keyword:"additionalProperties",dataProp:_,dataPropType:ih.Type.Str};T===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),r.subschema(v,w)}}};Qv.default=IW});var JD=k(tb=>{"use strict";Object.defineProperty(tb,"__esModule",{value:!0});var MW=$c(),GD=qr(),eb=he(),YD=Zv(),xW={keyword:"properties",type:"object",schemaType:"object",code(r){let{gen:e,schema:t,parentSchema:n,data:s,it:i}=r;i.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&YD.default.code(new MW.KeywordCxt(i,YD.default,"additionalProperties"));let o=(0,GD.allSchemaProperties)(t);for(let d of o)i.definedProperties.add(d);i.opts.unevaluated&&o.length&&i.props!==!0&&(i.props=eb.mergeEvaluated.props(e,(0,eb.toHash)(o),i.props));let a=o.filter(d=>!(0,eb.alwaysValidSchema)(i,t[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,GD.propertyInData)(e,s,d,i.opts.ownProperties)),u(d),i.allErrors||e.else().var(c,!0),e.endIf()),r.it.definedProperties.add(d),r.ok(c);function l(d){return i.opts.useDefaults&&!i.compositeRule&&t[d].default!==void 0}function u(d){r.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};tb.default=xW});var eO=k(rb=>{"use strict";Object.defineProperty(rb,"__esModule",{value:!0});var XD=qr(),oh=oe(),QD=he(),ZD=he(),LW={keyword:"patternProperties",type:"object",schemaType:"object",code(r){let{gen:e,schema:t,data:n,parentSchema:s,it:i}=r,{opts:o}=i,a=(0,XD.allSchemaProperties)(t),c=a.filter(g=>(0,QD.alwaysValidSchema)(i,t[g]));if(a.length===0||c.length===a.length&&(!i.opts.unevaluated||i.props===!0))return;let l=o.strictSchema&&!o.allowMatchingProperties&&s.properties,u=e.name("valid");i.props!==!0&&!(i.props instanceof oh.Name)&&(i.props=(0,ZD.evaluatedPropsToName)(e,i.props));let{props:d}=i;f();function f(){for(let g of a)l&&p(g),i.allErrors?b(g):(e.var(u,!0),b(g),e.if(u))}function p(g){for(let _ in l)new RegExp(g).test(_)&&(0,QD.checkStrictMode)(i,`property ${_} matches pattern ${g} (use allowMatchingProperties)`)}function b(g){e.forIn("key",n,_=>{e.if((0,oh._)`${(0,XD.usePattern)(r,g)}.test(${_})`,()=>{let w=c.includes(g);w||r.subschema({keyword:"patternProperties",schemaProp:g,dataProp:_,dataPropType:ZD.Type.Str},u),i.opts.unevaluated&&d!==!0?e.assign((0,oh._)`${d}[${_}]`,!0):!w&&!i.allErrors&&e.if((0,oh.not)(u),()=>e.break())})})}}};rb.default=LW});var tO=k(nb=>{"use strict";Object.defineProperty(nb,"__esModule",{value:!0});var $W=he(),qW={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(r){let{gen:e,schema:t,it:n}=r;if((0,$W.alwaysValidSchema)(n,t)){r.fail();return}let s=e.name("valid");r.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),r.failResult(s,()=>r.reset(),()=>r.error())},error:{message:"must NOT be valid"}};nb.default=qW});var rO=k(sb=>{"use strict";Object.defineProperty(sb,"__esModule",{value:!0});var jW=qr(),FW={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:jW.validateUnion,error:{message:"must match a schema in anyOf"}};sb.default=FW});var nO=k(ib=>{"use strict";Object.defineProperty(ib,"__esModule",{value:!0});var ah=oe(),BW=he(),UW={message:"must match exactly one schema in oneOf",params:({params:r})=>(0,ah._)`{passingSchemas: ${r.passing}}`},VW={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:UW,code(r){let{gen:e,schema:t,parentSchema:n,it:s}=r;if(!Array.isArray(t))throw new Error("ajv implementation error");if(s.opts.discriminator&&n.discriminator)return;let i=t,o=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");r.setParams({passing:a}),e.block(l),r.result(o,()=>r.reset(),()=>r.error(!0));function l(){i.forEach((u,d)=>{let f;(0,BW.alwaysValidSchema)(s,u)?e.var(c,!0):f=r.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,ah._)`${c} && ${o}`).assign(o,!1).assign(a,(0,ah._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(o,!0),e.assign(a,d),f&&r.mergeEvaluated(f,ah.Name)})})}}};ib.default=VW});var sO=k(ob=>{"use strict";Object.defineProperty(ob,"__esModule",{value:!0});var WW=he(),HW={keyword:"allOf",schemaType:"array",code(r){let{gen:e,schema:t,it:n}=r;if(!Array.isArray(t))throw new Error("ajv implementation error");let s=e.name("valid");t.forEach((i,o)=>{if((0,WW.alwaysValidSchema)(n,i))return;let a=r.subschema({keyword:"allOf",schemaProp:o},s);r.ok(s),r.mergeEvaluated(a)})}};ob.default=HW});var aO=k(ab=>{"use strict";Object.defineProperty(ab,"__esModule",{value:!0});var ch=oe(),oO=he(),KW={message:({params:r})=>(0,ch.str)`must match "${r.ifClause}" schema`,params:({params:r})=>(0,ch._)`{failingKeyword: ${r.ifClause}}`},zW={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:KW,code(r){let{gen:e,parentSchema:t,it:n}=r;t.then===void 0&&t.else===void 0&&(0,oO.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let s=iO(n,"then"),i=iO(n,"else");if(!s&&!i)return;let o=e.let("valid",!0),a=e.name("_valid");if(c(),r.reset(),s&&i){let u=e.let("ifClause");r.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else s?e.if(a,l("then")):e.if((0,ch.not)(a),l("else"));r.pass(o,()=>r.error(!0));function c(){let u=r.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);r.mergeEvaluated(u)}function l(u,d){return()=>{let f=r.subschema({keyword:u},a);e.assign(o,a),r.mergeValidEvaluated(f,o),d?e.assign(d,(0,ch._)`${u}`):r.setParams({ifClause:u})}}}};function iO(r,e){let t=r.schema[e];return t!==void 0&&!(0,oO.alwaysValidSchema)(r,t)}ab.default=zW});var cO=k(cb=>{"use strict";Object.defineProperty(cb,"__esModule",{value:!0});var GW=he(),YW={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:r,parentSchema:e,it:t}){e.if===void 0&&(0,GW.checkStrictMode)(t,`"${r}" without "if" is ignored`)}};cb.default=YW});var lO=k(lb=>{"use strict";Object.defineProperty(lb,"__esModule",{value:!0});var JW=Hv(),XW=FD(),QW=Kv(),ZW=UD(),e2=VD(),t2=nh(),r2=zD(),n2=Zv(),s2=JD(),i2=eO(),o2=tO(),a2=rO(),c2=nO(),l2=sO(),u2=aO(),d2=cO();function f2(r=!1){let e=[o2.default,a2.default,c2.default,l2.default,u2.default,d2.default,r2.default,n2.default,t2.default,s2.default,i2.default];return r?e.push(XW.default,ZW.default):e.push(JW.default,QW.default),e.push(e2.default),e}lb.default=f2});var uO=k(ub=>{"use strict";Object.defineProperty(ub,"__esModule",{value:!0});var pt=oe(),h2={message:({schemaCode:r})=>(0,pt.str)`must match format "${r}"`,params:({schemaCode:r})=>(0,pt._)`{format: ${r}}`},p2={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:h2,code(r,e){let{gen:t,data:n,$data:s,schema:i,schemaCode:o,it:a}=r,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;s?f():p();function f(){let b=t.scopeValue("formats",{ref:d.formats,code:c.code.formats}),g=t.const("fDef",(0,pt._)`${b}[${o}]`),_=t.let("fType"),w=t.let("format");t.if((0,pt._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>t.assign(_,(0,pt._)`${g}.type || "string"`).assign(w,(0,pt._)`${g}.validate`),()=>t.assign(_,(0,pt._)`"string"`).assign(w,g)),r.fail$data((0,pt.or)(T(),v()));function T(){return c.strictSchema===!1?pt.nil:(0,pt._)`${o} && !${w}`}function v(){let R=u.$async?(0,pt._)`(${g}.async ? await ${w}(${n}) : ${w}(${n}))`:(0,pt._)`${w}(${n})`,A=(0,pt._)`(typeof ${w} == "function" ? ${R} : ${w}.test(${n}))`;return(0,pt._)`${w} && ${w} !== true && ${_} === ${e} && !${A}`}}function p(){let b=d.formats[i];if(!b){T();return}if(b===!0)return;let[g,_,w]=v(b);g===e&&r.pass(R());function T(){if(c.strictSchema===!1){d.logger.warn(A());return}throw new Error(A());function A(){return`unknown format "${i}" ignored in schema at path "${l}"`}}function v(A){let L=A instanceof RegExp?(0,pt.regexpCode)(A):c.code.formats?(0,pt._)`${c.code.formats}${(0,pt.getProperty)(i)}`:void 0,W=t.scopeValue("formats",{key:i,ref:A,code:L});return typeof A=="object"&&!(A instanceof RegExp)?[A.type||"string",A.validate,(0,pt._)`${W}.validate`]:["string",A,W]}function R(){if(typeof b=="object"&&!(b instanceof RegExp)&&b.async){if(!u.$async)throw new Error("async format in sync schema");return(0,pt._)`await ${w}(${n})`}return typeof _=="function"?(0,pt._)`${w}(${n})`:(0,pt._)`${w}.test(${n})`}}}};ub.default=p2});var dO=k(db=>{"use strict";Object.defineProperty(db,"__esModule",{value:!0});var m2=uO(),g2=[m2.default];db.default=g2});var fO=k(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.contentVocabulary=Go.metadataVocabulary=void 0;Go.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Go.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var pO=k(fb=>{"use strict";Object.defineProperty(fb,"__esModule",{value:!0});var y2=SD(),v2=LD(),b2=lO(),T2=dO(),hO=fO(),_2=[y2.default,v2.default,(0,b2.default)(),T2.default,hO.metadataVocabulary,hO.contentVocabulary];fb.default=_2});var pb=k(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});Zc.dynamicAnchor=void 0;var hb=oe(),S2=$r(),mO=jc(),k2=Jf(),w2={keyword:"$dynamicAnchor",schemaType:"string",code:r=>gO(r,r.schema)};function gO(r,e){let{gen:t,it:n}=r;n.schemaEnv.root.dynamicAnchors[e]=!0;let s=(0,hb._)`${S2.default.dynamicAnchors}${(0,hb.getProperty)(e)}`,i=n.errSchemaPath==="#"?n.validateName:E2(r);t.if((0,hb._)`!${s}`,()=>t.assign(s,i))}Zc.dynamicAnchor=gO;function E2(r){let{schemaEnv:e,schema:t,self:n}=r.it,{root:s,baseId:i,localRefs:o,meta:a}=e.root,{schemaId:c}=n.opts,l=new mO.SchemaEnv({schema:t,schemaId:c,root:s,baseId:i,localRefs:o,meta:a});return mO.compileSchema.call(n,l),(0,k2.getValidate)(r,l)}Zc.default=w2});var mb=k(el=>{"use strict";Object.defineProperty(el,"__esModule",{value:!0});el.dynamicRef=void 0;var yO=oe(),N2=$r(),vO=Jf(),P2={keyword:"$dynamicRef",schemaType:"string",code:r=>bO(r,r.schema)};function bO(r,e){let{gen:t,keyword:n,it:s}=r;if(e[0]!=="#")throw new Error(`"${n}" only supports hash fragment reference`);let i=e.slice(1);if(s.allErrors)o();else{let c=t.let("valid",!1);o(c),r.ok(c)}function o(c){if(s.schemaEnv.root.dynamicAnchors[i]){let l=t.let("_v",(0,yO._)`${N2.default.dynamicAnchors}${(0,yO.getProperty)(i)}`);t.if(l,a(l,c),a(s.validateName,c))}else a(s.validateName,c)()}function a(c,l){return l?()=>t.block(()=>{(0,vO.callRef)(r,c),t.let(l,!0)}):()=>(0,vO.callRef)(r,c)}}el.dynamicRef=bO;el.default=P2});var TO=k(gb=>{"use strict";Object.defineProperty(gb,"__esModule",{value:!0});var R2=pb(),C2=he(),D2={keyword:"$recursiveAnchor",schemaType:"boolean",code(r){r.schema?(0,R2.dynamicAnchor)(r,""):(0,C2.checkStrictMode)(r.it,"$recursiveAnchor: false is ignored")}};gb.default=D2});var _O=k(yb=>{"use strict";Object.defineProperty(yb,"__esModule",{value:!0});var O2=mb(),A2={keyword:"$recursiveRef",schemaType:"string",code:r=>(0,O2.dynamicRef)(r,r.schema)};yb.default=A2});var SO=k(vb=>{"use strict";Object.defineProperty(vb,"__esModule",{value:!0});var I2=pb(),M2=mb(),x2=TO(),L2=_O(),$2=[I2.default,M2.default,x2.default,L2.default];vb.default=$2});var wO=k(bb=>{"use strict";Object.defineProperty(bb,"__esModule",{value:!0});var kO=nh(),q2={keyword:"dependentRequired",type:"object",schemaType:"object",error:kO.error,code:r=>(0,kO.validatePropertyDeps)(r)};bb.default=q2});var EO=k(Tb=>{"use strict";Object.defineProperty(Tb,"__esModule",{value:!0});var j2=nh(),F2={keyword:"dependentSchemas",type:"object",schemaType:"object",code:r=>(0,j2.validateSchemaDeps)(r)};Tb.default=F2});var NO=k(_b=>{"use strict";Object.defineProperty(_b,"__esModule",{value:!0});var B2=he(),U2={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:r,parentSchema:e,it:t}){e.contains===void 0&&(0,B2.checkStrictMode)(t,`"${r}" without "contains" is ignored`)}};_b.default=U2});var PO=k(Sb=>{"use strict";Object.defineProperty(Sb,"__esModule",{value:!0});var V2=wO(),W2=EO(),H2=NO(),K2=[V2.default,W2.default,H2.default];Sb.default=K2});var CO=k(kb=>{"use strict";Object.defineProperty(kb,"__esModule",{value:!0});var Ls=oe(),RO=he(),z2=$r(),G2={message:"must NOT have unevaluated properties",params:({params:r})=>(0,Ls._)`{unevaluatedProperty: ${r.unevaluatedProperty}}`},Y2={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:G2,code(r){let{gen:e,schema:t,data:n,errsCount:s,it:i}=r;if(!s)throw new Error("ajv implementation error");let{allErrors:o,props:a}=i;a instanceof Ls.Name?e.if((0,Ls._)`${a} !== true`,()=>e.forIn("key",n,d=>e.if(l(a,d),()=>c(d)))):a!==!0&&e.forIn("key",n,d=>a===void 0?c(d):e.if(u(a,d),()=>c(d))),i.props=!0,r.ok((0,Ls._)`${s} === ${z2.default.errors}`);function c(d){if(t===!1){r.setParams({unevaluatedProperty:d}),r.error(),o||e.break();return}if(!(0,RO.alwaysValidSchema)(i,t)){let f=e.name("valid");r.subschema({keyword:"unevaluatedProperties",dataProp:d,dataPropType:RO.Type.Str},f),o||e.if((0,Ls.not)(f),()=>e.break())}}function l(d,f){return(0,Ls._)`!${d} || !${d}[${f}]`}function u(d,f){let p=[];for(let b in d)d[b]===!0&&p.push((0,Ls._)`${f} !== ${b}`);return(0,Ls.and)(...p)}}};kb.default=Y2});var OO=k(wb=>{"use strict";Object.defineProperty(wb,"__esModule",{value:!0});var ki=oe(),DO=he(),J2={message:({params:{len:r}})=>(0,ki.str)`must NOT have more than ${r} items`,params:({params:{len:r}})=>(0,ki._)`{limit: ${r}}`},X2={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:J2,code(r){let{gen:e,schema:t,data:n,it:s}=r,i=s.items||0;if(i===!0)return;let o=e.const("len",(0,ki._)`${n}.length`);if(t===!1)r.setParams({len:i}),r.fail((0,ki._)`${o} > ${i}`);else if(typeof t=="object"&&!(0,DO.alwaysValidSchema)(s,t)){let c=e.var("valid",(0,ki._)`${o} <= ${i}`);e.if((0,ki.not)(c),()=>a(c,i)),r.ok(c)}s.items=!0;function a(c,l){e.forRange("i",l,o,u=>{r.subschema({keyword:"unevaluatedItems",dataProp:u,dataPropType:DO.Type.Num},c),s.allErrors||e.if((0,ki.not)(c),()=>e.break())})}}};wb.default=X2});var AO=k(Eb=>{"use strict";Object.defineProperty(Eb,"__esModule",{value:!0});var Q2=CO(),Z2=OO(),eH=[Q2.default,Z2.default];Eb.default=eH});var MO=k(lh=>{"use strict";Object.defineProperty(lh,"__esModule",{value:!0});lh.DiscrError=void 0;var IO;(function(r){r.Tag="tag",r.Mapping="mapping"})(IO||(lh.DiscrError=IO={}))});var LO=k(Pb=>{"use strict";Object.defineProperty(Pb,"__esModule",{value:!0});var Yo=oe(),Nb=MO(),xO=jc(),tH=qc(),rH=he(),nH={message:({params:{discrError:r,tagName:e}})=>r===Nb.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:r,tag:e,tagName:t}})=>(0,Yo._)`{error: ${r}, tag: ${t}, tagValue: ${e}}`},sH={keyword:"discriminator",type:"object",schemaType:"object",error:nH,code(r){let{gen:e,data:t,schema:n,parentSchema:s,it:i}=r,{oneOf:o}=s;if(!i.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!o)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),l=e.const("tag",(0,Yo._)`${t}${(0,Yo.getProperty)(a)}`);e.if((0,Yo._)`typeof ${l} == "string"`,()=>u(),()=>r.error(!1,{discrError:Nb.DiscrError.Tag,tag:l,tagName:a})),r.ok(c);function u(){let p=f();e.if(!1);for(let b in p)e.elseIf((0,Yo._)`${l} === ${b}`),e.assign(c,d(p[b]));e.else(),r.error(!1,{discrError:Nb.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(p){let b=e.name("valid"),g=r.subschema({keyword:"oneOf",schemaProp:p},b);return r.mergeEvaluated(g,Yo.Name),b}function f(){var p;let b={},g=w(s),_=!0;for(let R=0;R<o.length;R++){let A=o[R];if(A?.$ref&&!(0,rH.schemaHasRulesButRef)(A,i.self.RULES)){let W=A.$ref;if(A=xO.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,W),A instanceof xO.SchemaEnv&&(A=A.schema),A===void 0)throw new tH.default(i.opts.uriResolver,i.baseId,W)}let L=(p=A?.properties)===null||p===void 0?void 0:p[a];if(typeof L!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);_=_&&(g||w(A)),T(L,R)}if(!_)throw new Error(`discriminator: "${a}" must be required`);return b;function w({required:R}){return Array.isArray(R)&&R.includes(a)}function T(R,A){if(R.const)v(R.const,A);else if(R.enum)for(let L of R.enum)v(L,A);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v(R,A){if(typeof R!="string"||R in b)throw new Error(`discriminator: "${a}" values must be unique strings`);b[R]=A}}}};Pb.default=sH});var $O=k((Iee,iH)=>{iH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/schema",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0,"https://json-schema.org/draft/2019-09/vocab/applicator":!0,"https://json-schema.org/draft/2019-09/vocab/validation":!0,"https://json-schema.org/draft/2019-09/vocab/meta-data":!0,"https://json-schema.org/draft/2019-09/vocab/format":!1,"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format"},{$ref:"meta/content"}],type:["object","boolean"],properties:{definitions:{$comment:"While no longer an official keyword as it is replaced by $defs, this keyword is retained in the meta-schema to prevent incompatible extensions as it remains in common use.",type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},dependencies:{$comment:'"dependencies" is no longer a keyword, but schema authors should avoid redefining it to facilitate a smooth transition to "dependentSchemas" and "dependentRequired"',type:"object",additionalProperties:{anyOf:[{$recursiveRef:"#"},{$ref:"meta/validation#/$defs/stringArray"}]}}}}});var qO=k((Mee,oH)=>{oH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/applicator":!0},$recursiveAnchor:!0,title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{additionalItems:{$recursiveRef:"#"},unevaluatedItems:{$recursiveRef:"#"},items:{anyOf:[{$recursiveRef:"#"},{$ref:"#/$defs/schemaArray"}]},contains:{$recursiveRef:"#"},additionalProperties:{$recursiveRef:"#"},unevaluatedProperties:{$recursiveRef:"#"},properties:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$recursiveRef:"#"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$recursiveRef:"#"}},propertyNames:{$recursiveRef:"#"},if:{$recursiveRef:"#"},then:{$recursiveRef:"#"},else:{$recursiveRef:"#"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$recursiveRef:"#"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$recursiveRef:"#"}}}}});var jO=k((xee,aH)=>{aH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/content",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/content":!0},$recursiveAnchor:!0,title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentMediaType:{type:"string"},contentEncoding:{type:"string"},contentSchema:{$recursiveRef:"#"}}}});var FO=k((Lee,cH)=>{cH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/core",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/core":!0},$recursiveAnchor:!0,title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{type:"string",format:"uri"},$anchor:{type:"string",pattern:"^[A-Za-z][-A-Za-z0-9.:_]*$"},$ref:{type:"string",format:"uri-reference"},$recursiveRef:{type:"string",format:"uri-reference"},$recursiveAnchor:{type:"boolean",default:!1},$vocabulary:{type:"object",propertyNames:{type:"string",format:"uri"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$recursiveRef:"#"},default:{}}}}});var BO=k(($ee,lH)=>{lH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/format",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/format":!0},$recursiveAnchor:!0,title:"Format vocabulary meta-schema",type:["object","boolean"],properties:{format:{type:"string"}}}});var UO=k((qee,uH)=>{uH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/meta-data":!0},$recursiveAnchor:!0,title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}});var VO=k((jee,dH)=>{dH.exports={$schema:"https://json-schema.org/draft/2019-09/schema",$id:"https://json-schema.org/draft/2019-09/meta/validation",$vocabulary:{"https://json-schema.org/draft/2019-09/vocab/validation":!0},$recursiveAnchor:!0,title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}},const:!0,enum:{type:"array",items:!0},type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}});var WO=k(Rb=>{"use strict";Object.defineProperty(Rb,"__esModule",{value:!0});var fH=$O(),hH=qO(),pH=jO(),mH=FO(),gH=BO(),yH=UO(),vH=VO(),bH=["/properties"];function TH(r){return[fH,hH,pH,mH,e(this,gH),yH,e(this,vH)].forEach(t=>this.addMetaSchema(t,void 0,!1)),this;function e(t,n){return r?t.$dataMetaSchema(n,bH):n}}Rb.default=TH});var HO=k((et,Db)=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.MissingRefError=et.ValidationError=et.CodeGen=et.Name=et.nil=et.stringify=et.str=et._=et.KeywordCxt=et.Ajv2019=void 0;var _H=yD(),SH=pO(),kH=SO(),wH=PO(),EH=AO(),NH=LO(),PH=WO(),Cb="https://json-schema.org/draft/2019-09/schema",Jo=class extends _H.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(kH.default),SH.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(wH.default),this.addVocabulary(EH.default),this.opts.discriminator&&this.addKeyword(NH.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:t}=this.opts;t&&(PH.default.call(this,e),this.refs["http://json-schema.org/schema"]=Cb)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Cb)?Cb:void 0)}};et.Ajv2019=Jo;Db.exports=et=Jo;Db.exports.Ajv2019=Jo;Object.defineProperty(et,"__esModule",{value:!0});et.default=Jo;var RH=$c();Object.defineProperty(et,"KeywordCxt",{enumerable:!0,get:function(){return RH.KeywordCxt}});var Xo=oe();Object.defineProperty(et,"_",{enumerable:!0,get:function(){return Xo._}});Object.defineProperty(et,"str",{enumerable:!0,get:function(){return Xo.str}});Object.defineProperty(et,"stringify",{enumerable:!0,get:function(){return Xo.stringify}});Object.defineProperty(et,"nil",{enumerable:!0,get:function(){return Xo.nil}});Object.defineProperty(et,"Name",{enumerable:!0,get:function(){return Xo.Name}});Object.defineProperty(et,"CodeGen",{enumerable:!0,get:function(){return Xo.CodeGen}});var CH=Uf();Object.defineProperty(et,"ValidationError",{enumerable:!0,get:function(){return CH.default}});var DH=qc();Object.defineProperty(et,"MissingRefError",{enumerable:!0,get:function(){return DH.default}})});var xe=z(Sw());var xu=class r{constructor(e,t,n,s){this._uri=e,this._languageId=t,this._version=n,this._content=s,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){let t=this.offsetAt(e.start),n=this.offsetAt(e.end);return this._content.substring(t,n)}return this._content}update(e,t){for(let n of e)if(r.isIncremental(n)){let s=ww(n.range),i=this.offsetAt(s.start),o=this.offsetAt(s.end);this._content=this._content.substring(0,i)+n.text+this._content.substring(o,this._content.length);let a=Math.max(s.start.line,0),c=Math.max(s.end.line,0),l=this._lineOffsets,u=kw(n.text,!1,i);if(c-a===u.length)for(let f=0,p=u.length;f<p;f++)l[f+a+1]=u[f];else u.length<1e4?l.splice(a+1,c-a,...u):this._lineOffsets=l=l.slice(0,a+1).concat(u,l.slice(c+1));let d=n.text.length-(o-i);if(d!==0)for(let f=a+1+u.length,p=l.length;f<p;f++)l[f]=l[f]+d}else if(r.isFull(n))this._content=n.text,this._lineOffsets=void 0;else throw new Error("Unknown change event received");this._version=t}getLineOffsets(){return this._lineOffsets===void 0&&(this._lineOffsets=kw(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let t=this.getLineOffsets(),n=0,s=t.length;if(s===0)return{line:0,character:e};for(;n<s;){let o=Math.floor((n+s)/2);t[o]>e?s=o:n=o+1}let i=n-1;return{line:i,character:e-t[i]}}offsetAt(e){let t=this.getLineOffsets();if(e.line>=t.length)return this._content.length;if(e.line<0)return 0;let n=t[e.line],s=e.line+1<t.length?t[e.line+1]:this._content.length;return Math.max(Math.min(n+e.character,s),n)}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){let t=e;return t!=null&&typeof t.text=="string"&&t.range!==void 0&&(t.rangeLength===void 0||typeof t.rangeLength=="number")}static isFull(e){let t=e;return t!=null&&typeof t.text=="string"&&t.range===void 0&&t.rangeLength===void 0}},Lu;(function(r){function e(s,i,o,a){return new xu(s,i,o,a)}r.create=e;function t(s,i,o){if(s instanceof xu)return s.update(i,o),s;throw new Error("TextDocument.update: document must be created by TextDocument.create")}r.update=t;function n(s,i){let o=s.getText(),a=bm(i.map(FM),(u,d)=>{let f=u.range.start.line-d.range.start.line;return f===0?u.range.start.character-d.range.start.character:f}),c=0,l=[];for(let u of a){let d=s.offsetAt(u.range.start);if(d<c)throw new Error("Overlapping edit");d>c&&l.push(o.substring(c,d)),u.newText.length&&l.push(u.newText),c=s.offsetAt(u.range.end)}return l.push(o.substr(c)),l.join("")}r.applyEdits=n})(Lu||(Lu={}));function bm(r,e){if(r.length<=1)return r;let t=r.length/2|0,n=r.slice(0,t),s=r.slice(t);bm(n,e),bm(s,e);let i=0,o=0,a=0;for(;i<n.length&&o<s.length;)e(n[i],s[o])<=0?r[a++]=n[i++]:r[a++]=s[o++];for(;i<n.length;)r[a++]=n[i++];for(;o<s.length;)r[a++]=s[o++];return r}function kw(r,e,t=0){let n=e?[t]:[];for(let s=0;s<r.length;s++){let i=r.charCodeAt(s);(i===13||i===10)&&(i===13&&s+1<r.length&&r.charCodeAt(s+1)===10&&s++,n.push(t+s+1))}return n}function ww(r){let e=r.start,t=r.end;return e.line>t.line||e.line===t.line&&e.character>t.character?{start:t,end:e}:r}function FM(r){let e=ww(r.range);return e!==r.range?{newText:r.newText,range:e}:r}var $u=["namespace","class","enum","interface","struct","typeParameter","type","parameter","variable","property","enumMember","decorator","event","function","method","macro","label","comment","string","keyword","number","regexp","operator"],qu=["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"];var Ew=z(J());var Tm=z(require("url")),Ys=(r,e,t=!0,n=!0)=>({start:{line:r?.pos.line??0,character:t?r?.pos.col??0:(r?.pos.col??0)+(r?.pos.len??0)},end:{line:e?.pos.line??0,character:n?(e?.pos.col??0)+(e?.pos.len??0):e?.pos.col??0}});var Q=r=>Ys(r.tokenIndexes.start,r.tokenIndexes.end),Nw=" ",Pw=r=>{Nw=r},Zi=()=>Nw,Js=r=>$u.findIndex(e=>e===r),Xs=r=>qu.findIndex(e=>e===r),_m=(r,e,t)=>r.uri!==e||t.line<r.pos.line?!1:t.line>r.pos.line?!0:t.character>r.pos.col+r.pos.len,BM=(r,e,t)=>r.uri!==e?!1:t.line<r.pos.line?!0:t.line>r.pos.line?!1:t.character<r.pos.col,Tr=(r,e,t)=>!!(r.uri===e&&r.tokenIndexes?.start&&r.tokenIndexes?.end&&(r.tokenIndexes.start.pos.line<t.line||r.tokenIndexes.start.pos.line===t.line&&r.tokenIndexes.start.pos.col<=t.character)&&(r.tokenIndexes.end.pos.line>t.line||r.tokenIndexes.end.pos.line===t.line&&r.tokenIndexes.end.pos.col+r.tokenIndexes.end.pos.len>=t.character)),Rw=(r,e,t)=>!!(r.uri===e&&r.lastToken.value!==";"&&r.tokenIndexes?.start&&r.tokenIndexes?.end&&(r.tokenIndexes.start.pos.line===t.line||r.tokenIndexes.end.pos.line===t.line)&&t.character>=r.tokenIndexes.end.pos.col+r.tokenIndexes.end.pos.len),Cw=(r,e,t)=>{if(!r)return!1;let s=r.filter(i=>i.pos.line===t.line).at(-1);return s&&s.pos.col>=t.character?!1:e.tokenIndexes?.end===s};var hn=(r,e,t)=>{let n=r,s=r;for(;s;)n=s,s=[...n.children].reverse().find(i=>Tr(i,e,t));return n},_a=(r,e,t)=>{let n=r,s=r;for(;s;)n=s,s=[...n.children].find(i=>BM(i.lastToken,e,t));return n===r?void 0:n},Sa=(r,e,t)=>{let n=r,s=r;for(;s;)n=s,s=[...n.children].reverse().find(i=>_m(i.firstToken,e,t));return n===r?void 0:n},C=(r,e,t=Ew.DiagnosticSeverity.Error,n=[],s=void 0,i=[],o,a)=>({issues:Array.isArray(r)?r:[r],astElement:e,severity:t,linkedTo:n,tags:s,templateStrings:i,edit:o,codeActionTitle:a}),Dw=r=>[...r].sort((t,n)=>{if(t.sortKey===void 0||n.sortKey===void 0)throw new Error("Sort keys must be set");if(t.sortKey!==n.sortKey)return t.sortKey-n.sortKey;if(!t.tokenIndexes?.end||!n.tokenIndexes?.end)throw new Error("Must have token indexes");return t.tokenIndexes.end.pos.line!==n.tokenIndexes.end.pos.line?t.tokenIndexes.end.pos.line-n.tokenIndexes.end.pos.line:t.tokenIndexes.end.pos.col-n.tokenIndexes.end.pos.col});async function Mt(r,e,t,n,s){let i=xt(r.textDocument.uri),o=Qs(e,i,n,s);if(!o)return[];console.time("search");let c=(await o.context.getRuntime()).getDeepestAstNode(i,r.position),l=c?.ast?.firstToken.sortKey;return console.timeEnd("search"),t(c,d=>{let f=r.position;return d.uri===i?!!(d.tokenIndexes?.end&&(d.tokenIndexes.end.pos.line<f.line||d.tokenIndexes.end.pos.line===f.line&&d.tokenIndexes.end.pos.col+d.tokenIndexes.end.pos.len<=f.character)):l!==void 0&&d.sortKey<=l})}function G(r,e){return{start:r,end:e??r}}var $=(r,e)=>r?.tokens.some(t=>t===e),Je=r=>e=>e?.value&&r===e.value?"yes":UM(r)(e),Pe=r=>e=>e?.tokens.some(t=>t===r)?"yes":"no",UM=r=>e=>e?.value&&r.startsWith(e.value)?"partial":"no",pn=(r,e)=>!!r&&!!e&&r.pos.line===e.pos.line&&r.uri===e.uri,Xt=(r,e)=>!!r&&!!e&&pn(r,e)&&r.pos.col+r.pos.len===e.pos.col,ju=r=>r.map((e,t)=>({index:t,context:e,files:e.getContextFiles()})),Qs=(r,e,t,n)=>t?.getContextFiles().find(i=>i===e)?{context:t}:ju(r).sort(i=>i.context.name===n?-1:0).find(i=>i.files.some(o=>o===e)),Ow=(r,e)=>ju(r).filter(n=>n.files.some(s=>s===e)),Aw=r=>{let e=/^(\w+)\s+(.+)$/,t=/^(\w+)\(([^)]*)\)\s+(.+)$/,n=/^(\w+)\(([^)]*),\s*\.\.\.\)\s+(.+)$/,s;if(s=n.exec(r)){let[,,i,o]=s,a=i.split(",").map(c=>c.trim());return(...c)=>{let l=o;return a.forEach((u,d)=>{let f=new RegExp(`\\b${u}\\b`,"g");l=l.replace(f,c[d])}),l=l.replace(/__VA_ARGS__/g,c.slice(a.length).join(", ")),l}}else if(s=t.exec(r)){let[,,i,o]=s,a=i.split(",").map(c=>c.trim());return(...c)=>{let l=o;return a.forEach((u,d)=>{let f=new RegExp(`\\b${u}\\b`,"g");l=l.replace(f,c[d])}),l}}else if(s=e.exec(r)){let[,,i]=s;return i.trim()}},Iw=(r,e)=>{let t=o=>o.replace(/(\w+)\s*##\s*(\w+)/g,(a,c,l)=>c+l),n=o=>o.replace(/#(\w+)/g,(a,c)=>`"${c}"`),s=r,i;do i=s,s=t(i),s=n(s),s=s.replace(/\b(\w+)\(([^)]*)\)|\b(\w+)\b/g,(o,a,c,l)=>{if(a==="defined"){let u=c.split(",").map(d=>d.trim());return u[0]?e.get(u[0])?.resolver:u}else if(a&&typeof e.get(a)?.resolver=="function"){let u=c.split(",").map(d=>d.trim());return(e.get(a)?.resolver)(...u)}else if(l&&typeof e.get(l)?.resolver=="string")return e.get(l)?.resolver;return o});while(s!==i);return s},ce=r=>Tm.default.pathToFileURL(r).toString(),xt=r=>Tm.default.fileURLToPath(r),Mw=(r,e)=>r===e;var Ln=z(J()),F=class{constructor(e){this._children=[];this._fisrtToken=e?.start,this._lastToken=e?.end}get sortKey(){return this.firstToken.sortKey??this.parentNode?.sortKey??-1}get firstToken(){return this._fisrtToken??this._children[0].tokenIndexes.start}set firstToken(e){this._fisrtToken=e}get lastToken(){return this._lastToken??this._children.at(-1)?.lastToken??this.firstToken}set lastToken(e){this._lastToken=e}get uri(){return this.firstToken.uri}get tokenIndexes(){return{start:this.firstToken,end:this.lastToken}}getDocumentSymbols(e){if(!this.docSymbolsMeta)return this.children.flatMap(n=>n.getDocumentSymbols(e)??[]);if(this.uri!==e)return[];let t=Q(this);return[{name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind,range:t,selectionRange:t,children:[...this.children.flatMap(n=>n.getDocumentSymbols(e)??[])]}]}getWorkspaceSymbols(){if(!this.docSymbolsMeta)return this.children.flatMap(n=>n.getWorkspaceSymbols()??[]);let e=this.docSymbolsMeta.kind;if(![Ln.SymbolKind.File,Ln.SymbolKind.Class,Ln.SymbolKind.Namespace].some(n=>n===e))return[];let t=Q(this);return[{location:Ln.Location.create(ce(this.uri),t),name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind},...this.children.flatMap(n=>n.getWorkspaceSymbols()??[]).filter(n=>n.kind===Ln.SymbolKind.File||n.kind===Ln.SymbolKind.Class||n.kind===Ln.SymbolKind.Namespace)]}buildSemanticTokens(e){this._children.forEach(t=>t.buildSemanticTokens(e)),!(!this.semanticTokenType||!this.semanticTokenModifiers)&&e(Js(this.semanticTokenType),Xs(this.semanticTokenModifiers),this.tokenIndexes)}get children(){return this._children}get allDescendants(){return this.allDescendantsCache??=[...this._children,...this._children.flatMap(e=>e.allDescendants)],this.allDescendantsCache}addChild(e){e&&(e.parentNode=this,this.children.push(e)),this.allDescendantsCache=void 0}};var eo=z(J());var jw=z(J());var xw=z(J()),Oe=class extends F{constructor(t,n){super(n);this.value=t;this.semanticTokenType="string",this.semanticTokenModifiers="declaration",this.docSymbolsMeta={name:this.value,kind:xw.SymbolKind.String}}toString(){return`"${this.value.toString()}"`}toJson(){return this.value}};var $w=z(J());var Lw=z(J());function VM(r){return r.replace(/'(.)'/g,(e,t)=>t.charCodeAt(0).toString()).replace(/(0x[a-f\d]+|\d+)[ul]*/gi,"$1")}function Sm(r){try{return(0,eval)(VM(r))}catch(e){console.log(e)}return r}var zr=class extends F{toJson(){return-1}resolve(e){return Iw(this.toString(),e)}evaluate(e){return Sm(this.resolve(e))}isTrue(e){return Sm(`!!(${this.resolve(e)})`)}},Zs=class extends zr{constructor(t,n,s){super();this.expression=t;this.wrapped=n;this.join=s;this.addChild(t),s&&(this.addChild(s.operator),this.addChild(s.expression))}addExpression(t,n){this.addChild(t),this.addChild(n)}toString(){let t=this.children.map(n=>n.toString()).join(" ");return this.wrapped?`(${t})`:`${t}`}isTrue(t){let n=`(${this.children.map(s=>s instanceof zr?s.resolve(t):s.toString()).join(" ")})`;return Sm(`!!${n}`)}};var _t=class extends zr{constructor(t,n){super(n);this.value=t;this.docSymbolsMeta={name:this.value.toString(),kind:Lw.SymbolKind.Number},this.semanticTokenType="number",this.semanticTokenModifiers="declaration"}toString(){return this.value.toString()}toJson(){return this.value}};var yt=class extends F{constructor(t){super();this.values=t;this.docSymbolsMeta={name:"Cell Array",kind:$w.SymbolKind.Array},this.values.forEach(n=>this.addChild(n))}toString(){return`<${this.values.map(t=>t.toString()).join(" ")}>`}toJson(){if(this.values.length===1)return this.values[0].value?.toJson();if(this.values.length===2&&this.values.every(t=>t.value instanceof _t)){let t=new ArrayBuffer(8),n=new DataView(t);return this.values.map(s=>s.value.value).forEach((s,i)=>{n.setUint32(i*4,s)}),n.getBigUint64(0)}return this.values.map(t=>t.value?.toJson()??NaN)}};var qw=z(J()),as=class extends F{constructor(t){super();this.values=t;this.docSymbolsMeta={name:"Byte String Value",kind:qw.SymbolKind.Array},this.values.forEach(n=>this.addChild(n))}toString(){return`[${this.values.map(t=>t.toString()).join(" ")}]`}toJson(){return this.values.map(t=>t.value?.toJson()??NaN)}};var ze=class extends F{constructor(t,n){super(n);this.name=t;this.semanticTokenType="property",this.semanticTokenModifiers="declaration"}toString(){return this.name}},Ae=class extends F{constructor(t,n=[]){super();this.propertyName=t;this.labels=n;this._values=void 0;this.docSymbolsMeta={name:this.propertyName?.name??"Unknown",kind:jw.SymbolKind.Property},this.labels.forEach(s=>this.addChild(s)),this.addChild(t)}set values(t){if(this._values)throw new Error("Only one property name is allowed");this._values=t,this.addChild(t)}get values(){return this._values}get quickValues(){return this.values?.values.map(t=>t?t.value instanceof Oe?t.value.value:t.value instanceof yt?t.value.values.map(n=>n.value instanceof _t?n.value.value:NaN):t.value instanceof as?t.value.values.map(n=>n.value?.value??NaN):NaN:null)}toString(){return`${this.propertyName?.toString()??"__UNSET__"}${this.assignOperatorToken?` = ${this._values?.values.map(t=>t?.toString()??"NULL").join(", ")??"NULL"}`:""};`}};var Fw=z(J()),Qt=class extends F{constructor(t,n){super();this.keyword=n;this.addChild(n),this.docSymbolsMeta={name:t,kind:Fw.SymbolKind.Function}}};var ur=class extends Qt{constructor(t){super("Delete Node",t);this._nodeNameOrRef=null}set nodeNameOrRef(t){if(this._nodeNameOrRef)throw new Error("Only one property name is allowed");this._nodeNameOrRef=t,this.addChild(t)}get nodeNameOrRef(){return this._nodeNameOrRef}};var Ue=class extends Qt{constructor(t){super("Delete Property",t);this._propertyName=null}set propertyName(t){if(this._propertyName)throw new Error("Only only property name is allowed");this._propertyName=t,this.addChild(t)}get propertyName(){return this._propertyName}};var qe=class r extends F{constructor(){super()}get path(){if(!this.pathName)return["__UNDEFINED__"];if(!this.parentNode||this instanceof dt)return[this.pathName];if(!(this.parentNode instanceof r))return;let e=this.parentNode.path;return e?[...e,this.pathName]:[this.pathName]}get pathName(){}get nodes(){return this.children.filter(e=>e instanceof r)}get deleteNodes(){return this.children.filter(e=>e instanceof ur)}addNodeChild(e){this.addChild(e)}},dt=class extends qe{constructor(){super(),this.docSymbolsMeta={name:"/",kind:eo.SymbolKind.Class}}get properties(){return this.children.filter(e=>e instanceof Ae)}get name(){return new je("/",G(this.firstToken))}get deleteProperties(){return this.children.filter(e=>e instanceof Ue)}get nodes(){return this.children.filter(e=>e instanceof Re)}get pathName(){return"/"}},Rt=class extends qe{constructor(t=[]){super();this.labels=t;this._labelReference=null;this.docSymbolsMeta={name:"DTC Name",kind:eo.SymbolKind.Class},t.forEach(n=>{super.addChild(n)})}set labelReference(t){if(this._labelReference)throw new Error("Only on label reference is allowed");this._labelReference=t,this.docSymbolsMeta={name:this.labelReference?.value??"DTC Name",kind:eo.SymbolKind.Class},this.addChild(t)}get path(){return this.resolveNodePath?this.resolveNodePath:super.path}get labelReference(){return this._labelReference}get nodes(){return this.children.filter(t=>t instanceof Re)}get pathName(){return this.labelReference?.label?`&${this.labelReference?.label?.value}`:void 0}get properties(){return this.children.filter(t=>t instanceof Ae)}get deleteProperties(){return this.children.filter(t=>t instanceof Ue)}},Re=class r extends qe{constructor(t=[],n){super();this.labels=t;this.omitIfNoRef=n;this._name=null;this.docSymbolsMeta={name:"DTC Name",kind:eo.SymbolKind.Class},n&&this.addChild(n),t.forEach(s=>{this.addChild(s)})}set name(t){if(this._name)throw new Error("Only on label reference is allowed");this._name=t,this.docSymbolsMeta={name:this._name?.toString()??"DTC Name",kind:eo.SymbolKind.Class},this.addChild(t)}get name(){return this._name}get nodes(){return this.children.filter(t=>t instanceof r)}get pathName(){return this._name?.toString()}get properties(){return this.children.filter(t=>t instanceof Ae)}get deleteProperties(){return this.children.filter(t=>t instanceof Ue)}},Fu=class extends F{constructor(t,n){super(n);this.address=t;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.address.toString(16)}},je=class extends F{constructor(t,n,s){super(n);this.name=t;this._address=s;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}get value(){return this.name}get address(){return this._address}set address(t){if(this._address)throw new Error("Address can only be set once");t&&(this.lastToken=void 0,this._address=t,t.forEach(n=>this.addChild(n)))}toString(){return this._address!==void 0?`${this.name}@${this._address.map(t=>t.toString()).join(",")}`:this.name}buildSemanticTokens(t){if(!this.tokenIndexes?.start||!this.tokenIndexes.start.value)return;let n={...this.tokenIndexes.start,pos:{...this.tokenIndexes.start.pos,len:this.name.length}};t(Js("type"),Xs("declaration"),{start:n,end:n}),this.address!==void 0&&this.address.forEach(s=>{t(Js("decorator"),Xs("declaration"),{start:s.lastToken.prevToken,end:s.lastToken.prevToken}),s.buildSemanticTokens(t)})}};var Bw=z(J()),_e=class extends F{constructor(t){super();this.label=t;this.docSymbolsMeta={name:`&${this.label?.value??"NULL"}`,kind:Bw.SymbolKind.Key},this.addChild(t)}get value(){return this.label?.value}toString(){return`&${this.label?.value??"NULL"}`}toJson(){return-1}};var Jr=z(J());var St=r=>r instanceof Qt?!0:r instanceof qe?!1:r.parentNode?St(r.parentNode):!1;var to=r=>[...r.map(e=>{if(e instanceof Re||e instanceof dt)return e.name;if(e instanceof Rt)return e.labelReference})].filter(e=>!!e),km=(r,e)=>e?e.parentNode===r||km(r,e.parentNode):!1;var lt=z(J());var Uw=z(J());var $n=class extends F{constructor(){super();this._pathParts=[]}addPath(t,n){this._pathParts.push(t),n&&this.addChild(n),this.addChild(t)}get pathParts(){return[...this._pathParts]}toString(){return this._pathParts.map(t=>t?.toString()??"<NULL>").join("/")}},Gr=class extends F{constructor(t){super();this.path=t;this.docSymbolsMeta={name:`/${this.path?.toString()??""}`,kind:Uw.SymbolKind.Namespace},this.semanticTokenType="variable",this.semanticTokenModifiers="declaration",this.addChild(t)}toString(){return`&${this.path?.toString()??"NULL"}`}toJson(){return-1}};var it=z(J());var Bu=z(J());var Vw=require("path"),cs=class extends F{constructor(t,n){super();this.keyword=t;this.path=n;this.docSymbolsMeta={name:`Include ${n}`,kind:Bu.SymbolKind.File},this.addChild(t),this.addChild(n)}get resolvedPath(){return this._resolvedPath}set resolvedPath(t){this.docSymbolsMeta={name:`Include ${t}`,kind:Bu.SymbolKind.File},this._resolvedPath=t}},ro=class extends F{constructor(t,n,s){super(s);this._path=t;this.relative=n;this.docSymbolsMeta={name:(0,Vw.basename)(this.path),kind:Bu.SymbolKind.File},this.semanticTokenType="string",this.semanticTokenModifiers="declaration"}get path(){return this.relative?this._path.slice(1,-1):this._path}};var mn=class extends F{constructor(e){super(e),this.semanticTokenType="comment",this.semanticTokenModifiers="documentation"}};var WM=async(r,e,t)=>{let n=it.Position.create(r.pos.line,r.pos.col),s=t.find(i=>Tr(i,e,n));if(s)return hn(s,e,n)},wm=r=>{if(r)return r instanceof qe?r:wm(r?.parentNode)},so=(r,e,t=0)=>!e||e.uri!==r?t:so(r,wm(e.parentNode),t+1),HM=(r,e)=>async t=>{let n=await WM(t.firstToken,e,r);return!n||n===t||t.allDescendants.some(i=>i===n)?0:n instanceof qe?so(e,wm(n)):void 0};async function Ww(r,e){let t=[],n=xt(r.textDocument.uri),s=(await e.getRuntime()).fileTopMostAst(n);return t.push(...(await Promise.all(s.flatMap(async i=>await Hw(r,i,n,HM(s,n))))).flat()),t}var ei=(r,e=1)=>{if(r.prevToken){let t=r.pos.line-r.prevToken.pos.line;if(t-e&&(t!==2&&e!==0||e===0))return it.TextEdit.replace(it.Range.create(it.Position.create(r.prevToken.pos.line,r.prevToken.pos.col+r.prevToken.pos.len),it.Position.create(r.pos.line-e,r.pos.col)),"".padEnd(e-1,`
|
|
183
183
|
`))}},no=(r,e,t,n="")=>{if(r.pos.line===r.prevToken?.pos.line)return it.TextEdit.replace(it.Range.create(it.Position.create(r.pos.line,r.pos.col),it.Position.create(r.pos.line,r.pos.col)),`
|
|
184
184
|
${n}${"".padStart(e*t.length,t)}`)},ls=(r,e,t,n="")=>it.TextEdit.replace(it.Range.create(it.Position.create(r.pos.line,0),it.Position.create(r.pos.line,r.pos.col)),`${"".padStart(e*t.length,t)}${n}`),vt=(r,e=1)=>{if(!r.nextToken)return[];if(r.nextToken?.pos.line!==r.pos.line){let n=ei(r.nextToken,0);if(!n)throw new Error("remove new LinesEdit must be defined");return[it.TextEdit.insert(it.Position.create(r.pos.line,r.pos.col+r.pos.len),"".padEnd(e," ")),n]}return r.nextToken.pos.col-(r.pos.col+r.pos.len)===e?[]:[it.TextEdit.replace(it.Range.create(it.Position.create(r.pos.line,r.pos.col+r.pos.len),it.Position.create(r.nextToken.pos.line,r.nextToken.pos.col)),"".padEnd(e," "))]},KM=async(r,e,t,n,s,i)=>{if(e.uri!==t)return[];let o=[],a=no(e.firstToken,n,s);if(a)o.push(a);else{o.push(ls(e.firstToken,n,s));let l=ei(e.firstToken);l&&o.push(l)}if(e instanceof Re||e instanceof Rt)if(o.push(...e.labels.flatMap(l=>vt(l.lastToken))),e instanceof Re){let l=e.name&&e.openScope?vt(e.name.lastToken):[];o.push(...l)}else{let l=e.labelReference&&e.openScope?vt(e.labelReference.lastToken):[];o.push(...l)}if(o.push(...(await Promise.all(e.children.flatMap(l=>Hw(r,l,t,i,n+1)))).flat()),e.closeScope){let l=no(e.closeScope,n,s);if(l)o.push(l);else{o.push(ls(e.closeScope,n,s));let u=ei(e.closeScope);u&&o.push(u)}}let c=e.lastToken.value===";"&&e.lastToken.prevToken?vt(e.lastToken.prevToken,0):[];return o.push(...c),o},zM=(r,e,t,n)=>{let s=[];if(s.push(...vt(r.lastToken,n?0:1)),r.firstToken.pos.line!==r.firstToken.prevToken?.pos.line){let i=ei(r.firstToken);i&&s.push(i),s.push(ls(r.firstToken,e+1,t))}return r.value,s},GM=(r,e,t,n)=>{let s=[];return r instanceof yt||r instanceof as?(r.openBracket&&s.push(...vt(r.openBracket,0)),s.push(...r.values.flatMap((i,o)=>zM(i,e,t,o+1===r.values.length&&r.lastToken.nextToken===r.closeBracket))),r.closeBracket&&r.closeBracket?.nextToken?.value!==";"&&r.openBracket&&s.push(...vt(r.closeBracket,0))):r?.lastToken&&n&&s.push(...vt(r.lastToken,r?.lastToken.nextToken?.value===","?0:1)),s},YM=(r,e,t,n)=>{let s=[];return s.push(...r.startLabels.flatMap((i,o)=>o+1===r.startLabels.length?[]:vt(i.lastToken))),s.push(...GM(r.value,e,t,!n||r.endLabels.length>0)),s.push(...r.endLabels.flatMap((i,o)=>o+1===r.endLabels.length?[]:vt(i.lastToken))),s},JM=(r,e,t)=>{let n=[],s=i=>{if(i&&Tr(r,r.uri,it.Position.create(i.pos.line,i.pos.col)))return i.value===","?i:s(i.nextToken)};return r.values.forEach((i,o)=>{if(!i)return[];let a=s(i.lastToken),c=r.values.at(o+1);if(a){if(a.pos.line===c?.firstToken?.pos.line)n.push(...vt(a,1));else if(c?.firstToken){let l=ei(c?.firstToken);l&&n.push(l),n.push(ls(c?.firstToken,e+1,t))}}}),[...n,...r.values.flatMap((i,o)=>i?YM(i,e,t,o+1===r.values.length):[])]},XM=(r,e,t)=>{let n=[],s=no(r.firstToken,e,t);if(s)n.push(s);else{n.push(ls(r.firstToken,e,t));let o=ei(r.firstToken);o&&n.push(o)}if(n.push(...r.labels.flatMap(o=>vt(o.lastToken))),r.values){if(r.propertyName){n.push(...vt(r.propertyName?.lastToken));let o=c=>c?c.value==="="?c:o(c.nextToken):void 0,a=o(r.propertyName?.lastToken.nextToken);a&&n.push(...vt(a))}n.push(...JM(r.values,e,t))}let i=r.lastToken.value===";"&&r.lastToken.prevToken?vt(r.lastToken.prevToken,0):[];return n.push(...i),n},QM=(r,e,t)=>{let n=[],s=no(r.firstToken,e,t);s?n.push(s):n.push(ls(r.firstToken,e,t));let i=vt(r.keyword.lastToken);n.push(...i);let o=r.lastToken.value===";"&&r.lastToken.prevToken?vt(r.lastToken.prevToken,0):[];return n.push(...o),n},ZM=(r,e,t,n)=>{if(t===void 0)return[];if(r.uri!==e)return[];let s=[],i=no(r.firstToken,t,n);i?s.push(i):s.push(ls(r.firstToken,t,n));let o=vt(r.keyword.lastToken);return s.push(...o),s},ex=(r,e,t)=>{let n=[];if(r.lastToken.pos.line===r.lastToken.nextToken?.pos.line&&r.lastToken.nextToken.value!==";"&&n.push(...vt(r.lastToken)),e!==void 0&&r.firstToken.pos.line===r.firstToken.prevToken?.pos.line&&r.firstToken.pos.line===r.lastToken.pos.line)return n.push(...vt(r.firstToken.prevToken)),n;if(e===void 0)return n;let s=r.firstToken.value.startsWith("*")?" ":"",i=no(r.firstToken,e,t,s);if(i)n.push(i);else{n.push(ls(r.firstToken,e,t,s));let o=ei(r.firstToken);o&&n.push(o)}return n},Hw=async(r,e,t,n,s=0)=>{let i=r.options.tabSize,a=r.options.insertSpaces?"".padStart(i," "):" ";return Pw(a),e instanceof qe?KM(r,e,t,s,a,n):e instanceof Ae?XM(e,s,a):e instanceof Qt?QM(e,s,a):e instanceof cs?ZM(e,t,await n(e),a):e instanceof mn?ex(e,await n(e),a):[]};var H=class{constructor(e,t,n="optional",s=void 0,i=[],o){this.name=e;this.type=t;this.def=s;this.additionalTypeCheck=o;this.hideAutoComplete=!1;this.list=!1;this.onHover=()=>({kind:lt.MarkupKind.Markdown,value:[...this.description?["### Description",this.description.join(`
|
|
185
185
|
|
|
@@ -253,8 +253,8 @@ If PIR cannot be modified and the PIR value is distinct from the interrupt contr
|
|
|
253
253
|
`,`
|
|
254
254
|
`).split(/\n/).map(n=>`${n}
|
|
255
255
|
`),this.lines[this.lines.length-1]=this.lines[this.lines.length-1].slice(0,-1),e.endsWith(`
|
|
256
|
-
`)&&this.lines.splice(-1,1),this.lexIt()}get tokens(){return this._tokens}isWhiteSpace(){return!!this.currentChar?.match(/\s/)}get endOfFile(){return this.isOnLastLine&&this.isOnLastCharOfLine}get isOnLastLine(){return this.lineNumber===this.lines.length-1}get isOnLastCharOfLine(){return this.lines[this.lineNumber].length<=this.columnNumber}moveToNextLine(){return this.isOnLastLine?!1:(this.columnNumber=0,this.lineNumberOfEscapedChars=0,this.lineNumber++,this.lines[this.lineNumber].length===0&&this.moveToNextLine(),!0)}moveOnLine(){return this.isOnLastCharOfLine?this.moveToNextLine():(this.columnNumber++,this.isOnLastCharOfLine&&this.moveToNextLine(),!0)}move(){return this.endOfFile?!1:this.moveOnLine()}get currentChar(){return this.endOfFile?null:this.lines[this.lineNumber].at(this.columnNumber)}static isSyntaxChar(e){return e==="^"||e==="~"||e==="|"||e==="!"||e==="\\"||e==="<"||e===">"||e===";"||e==="="||e==="/"||e==="{"||e==="}"||e==="["||e==="]"||e==="("||e===")"||e==="*"||e==="%"||e==="&"||e==="."||e===":"||e==="+"||e==="@"||e==="-"||e==="_"||e===","||e==="x"||e==="?"}getWord(){let e="";for(;!this.isWhiteSpace()&&(e.length&&!r.isSyntaxChar(this.currentChar)||!e.length);){if(e+=this.currentChar??"",e.length===1&&r.isSyntaxChar(this.currentChar)){this.move();break}let t=this.lineNumber;if(!this.move()||this.lineNumber!==t)return e}return e==="/"&&this.currentChar==="*"?this.inComment=!0:this.inComment&&e==="*"&&this.currentChar==="/"&&(this.inComment=!1),e}getString(e){let t=e;for(this.numberOfEscapedCharsLastString=0;this.currentChar!==e;){if(t+=this.currentChar??"",this.currentChar==="\\"){let n=this.lineNumber;if(this.move())this.lineNumberOfEscapedChars++,this.numberOfEscapedCharsLastString++,n===this.lineNumber&&(t+=this.currentChar??"");else return t}if(!this.move())return t}return this.move(),t+=e,t}lexIt(){for(;!this.endOfFile&&(this.whiteSpace(),!this.endOfFile);){let e=this.getWord();e&&this.process(e)}}process(e){let t=this.isString(e)||this.isCDefine(e)||this.isCInclude(e)||this.isCLine(e)||this.isCUndef(e)||this.isCError(e)||this.isCPragma(e)||this.isCDefined(e)||this.isCIfDef(e)||this.isCIfNDef(e)||this.isCIf(e)||this.isCElIf(e)||this.isCElse(e)||this.isCEndIf(e)||this.isCFalse(e)||this.isCTrue(e)||this.isDigit(e)||this.isHexDigit(e)||this.isLetters(e)||this.isComma(e)||this.isBitwiseNot(e)||this.isBitwiseXOr(e)||this.isBitwiseOr(e)||this.isLogicalNot(e)||this.isGtSym(e)||this.isLtSym(e)||this.isSemicolon(e)||this.isColon(e)||this.isAssignOperator(e)||this.isForwardSlash(e)||this.isRoundOpen(e)||this.isRoundClose(e)||this.isCurlyOpen(e)||this.isCurlyClose(e)||this.isSquareOpen(e)||this.isSquareClose(e)||this.isBackSlash(e)||this.isMultiplicationOperator(e)||this.isModulusOperator(e)||this.isAmpersand(e)||this.isNegateOperator(e)||this.isAddOperator(e)||this.isQuestionMark(e)||this.isPeriod(e)||this.isHash(e)||this.isUnderScore(e)||this.isAt(e)||this.unknownToken(e);if(!t)throw new Error(`Lexer is not complete!!! Could not find token for "${e}"`);let n=this._tokens.at(-1);return t&&!n?.tokens.some(s=>s===21)&&n&&n.pos.len<e.length?this.process(e.slice(n.pos.len)):!0}whiteSpace(){for(;this.isWhiteSpace();)this.move()}pushToken(e){let t={...e,uri:this.uri},n=this._tokens.at(-1);t.prevToken=n,n&&(n.nextToken=t),this._tokens.push(t)}isLetters(e){let t=e.match(/^[A-Za-z]+/);return t?.[0]?(this.pushToken({tokens:[47],value:t?.[0],pos:this.generatePos(e,t?.[0])}),!0):!1}isDigit(e){let t=e.match(/^[0-9]/);return t?.[0]?(this.pushToken({tokens:[20,19],value:t[0],pos:this.generatePos(e,t[0])}),!0):!1}isHexDigit(e){let t=e.match(/^[A-Fa-f]/);return t?.[0]?(this.pushToken({tokens:[20,47],value:t[0],pos:this.generatePos(e,t[0])}),!0):!1}isCurlyOpen(e){let t="{";return e===t?(this.pushToken({tokens:[2],pos:this.generatePos(e,t),value:"{"}),!0):!1}isCurlyClose(e){let t="}";return e===t?(this.pushToken({tokens:[3],pos:this.generatePos(e,t),value:"}"}),!0):!1}isSemicolon(e){let t=";";return e===t?(this.pushToken({tokens:[1],pos:this.generatePos(e,t),value:t}),!0):!1}isColon(e){let t=":";return e===t?(this.pushToken({tokens:[50],pos:this.generatePos(e,t),value:t}),!0):!1}isHash(e){let t="#";return e.startsWith(t)?(this.pushToken({tokens:[46],pos:this.generatePos(e,t),value:t}),!0):!1}unknownToken(e){return this.pushToken({tokens:[41],pos:this.generatePos(e," "),value:e}),!0}isAssignOperator(e){let t="=";return e===t?(this.pushToken({tokens:[0],pos:this.generatePos(e,t),value:t}),!0):!1}isGtSym(e){let t=">";return e===t?(this.pushToken({tokens:[4],pos:this.generatePos(e,t),value:t}),!0):!1}isLtSym(e){let t="<";return e===t?(this.pushToken({tokens:[5],pos:this.generatePos(e,t),value:t}),!0):!1}isLogicalNot(e){let t="!";return e===t?(this.pushToken({tokens:[6],pos:this.generatePos(e,t),value:t}),!0):!1}isBitwiseOr(e){let t="|";return e===t?(this.pushToken({tokens:[8],pos:this.generatePos(e,t),value:t}),!0):!1}isBitwiseXOr(e){let t="^";return e===t?(this.pushToken({tokens:[9],pos:this.generatePos(e,t),value:t}),!0):!1}isAmpersand(e){let t="&";return e===t?(this.pushToken({tokens:[40,7],pos:this.generatePos(e,t),value:t}),!0):!1}isBitwiseNot(e){let t="~";return e===t?(this.pushToken({tokens:[10],pos:this.generatePos(e,t),value:t}),!0):!1}isRoundOpen(e){let t="(";return e===t?(this.pushToken({tokens:[42],pos:this.generatePos(e,t),value:t}),!0):!1}isRoundClose(e){let t=")";return e===t?(this.pushToken({tokens:[43],pos:this.generatePos(e,t),value:t}),!0):!1}isSquareOpen(e){let t="[";return e===t?(this.pushToken({tokens:[11],pos:this.generatePos(e,t),value:t}),!0):!1}isSquareClose(e){let t="]";return e===t?(this.pushToken({tokens:[12],pos:this.generatePos(e,t),value:t}),!0):!1}isComma(e){let t=",";return e===t?(this.pushToken({tokens:[24],pos:this.generatePos(e,t),value:t}),!0):!1}rewind(e){if(this.columnNumber+1<e.length)throw new Error("Error while rewinding");this.columnNumber-=e.length}isString(e){if(this.inComment)return!1;let t=e.match(/^["']/);if(t?.[0]){this.rewind(e.slice(1));let n=this.lineNumber,s=this.columnNumber,i=this.getString(t[0]);return this.pushToken({tokens:[21],value:i,pos:{col:s-1,line:n,len:i.length+this.numberOfEscapedCharsLastString}}),!0}return!1}isForwardSlash(e){let t="/";return e===t?(this.pushToken({tokens:[13],pos:this.generatePos(e,t),value:"/"}),!0):!1}isBackSlash(e){let t="\\";return e===t?(this.pushToken({tokens:[14],pos:this.generatePos(e,t),value:"\\"}),!0):!1}isAddOperator(e){let t="+";return e===t?(this.pushToken({tokens:[15],pos:this.generatePos(e,t),value:t}),!0):!1}isQuestionMark(e){let t="?";return e===t?(this.pushToken({tokens:[44],pos:this.generatePos(e,t),value:t}),!0):!1}isPeriod(e){let t=".";return e===t?(this.pushToken({tokens:[45],pos:this.generatePos(e,t),value:t}),!0):!1}isNegateOperator(e){let t="-";return e===t?(this.pushToken({tokens:[16],pos:this.generatePos(e,t),value:t}),!0):!1}isUnderScore(e){let t="_";return e===t?(this.pushToken({tokens:[48],pos:this.generatePos(e,t),value:t}),!0):!1}isAt(e){let t="@";return e===t?(this.pushToken({tokens:[49],pos:this.generatePos(e,t),value:t}),!0):!1}isMultiplicationOperator(e){let t="*";return e===t?(this.pushToken({tokens:[17],pos:this.generatePos(e,t),value:t}),!0):!1}isModulusOperator(e){let t="%";return e===t?(this.pushToken({tokens:[18],pos:this.generatePos(e,t),value:t}),!0):!1}isCDefine(e){let t="#define";return e.toLowerCase()===t?(this.pushToken({tokens:[25],pos:this.generatePos(e,t),value:t}),!0):!1}isCInclude(e){let t="#include";return e.toLowerCase()===t?(this.pushToken({tokens:[26],pos:this.generatePos(e,t),value:t}),!0):!1}isCLine(e){let t="#line";return e.toLowerCase()===t?(this.pushToken({tokens:[27],pos:this.generatePos(e,t),value:t}),!0):!1}isCUndef(e){let t="#undef";return e.toLowerCase()===t?(this.pushToken({tokens:[28],pos:this.generatePos(e,t),value:t}),!0):!1}isCError(e){let t="#error";return e.toLowerCase()===t?(this.pushToken({tokens:[29],pos:this.generatePos(e,t),value:t}),!0):!1}isCPragma(e){let t="#pragma";return e.toLowerCase()===t?(this.pushToken({tokens:[30],pos:this.generatePos(e,t),value:t}),!0):!1}isCDefined(e){let t="#defined";return e.toLowerCase()===t?(this.pushToken({tokens:[31],pos:this.generatePos(e,t),value:t}),!0):!1}isCIf(e){let t="#if";return e.toLowerCase()===t?(this.pushToken({tokens:[32],pos:this.generatePos(e,t),value:t}),!0):!1}isCIfDef(e){let t="#ifdef";return e.toLowerCase()===t?(this.pushToken({tokens:[33],pos:this.generatePos(e,t),value:t}),!0):!1}isCIfNDef(e){let t="#ifndef";return e.toLowerCase()===t?(this.pushToken({tokens:[34],pos:this.generatePos(e,t),value:t}),!0):!1}isCElIf(e){let t="#elif";return e.toLowerCase()===t?(this.pushToken({tokens:[35],pos:this.generatePos(e,t),value:t}),!0):!1}isCElse(e){let t="#else";return e.toLowerCase()===t?(this.pushToken({tokens:[36],pos:this.generatePos(e,t),value:t}),!0):!1}isCEndIf(e){let t="#endif";return e.toLowerCase()===t?(this.pushToken({tokens:[37],pos:this.generatePos(e,t),value:t}),!0):!1}isCTrue(e){let t="true";return e==t?(this.pushToken({tokens:[38],value:t,pos:this.generatePos(e,t)}),!0):!1}isCFalse(e){let t="false";return e==t?(this.pushToken({tokens:[39],value:t,pos:this.generatePos(e,t)}),!0):!1}generatePos(e,t){return{line:this.lineNumber,col:this.columnNumber-e.length+this.lineNumberOfEscapedChars,len:t.length}}};var Qe=class extends F{constructor(e){super(e),this.semanticTokenType="keyword",this.semanticTokenModifiers="declaration"}};var Rm=require("fs"),uo=require("path");var AE=z(J());var $t=class extends zr{constructor(t,n){super(n);this.name=t;this.docSymbolsMeta={name:this.name.toString(),kind:AE.SymbolKind.Variable},this.semanticTokenType="macro",this.semanticTokenModifiers="declaration"}toString(){return this.name}};var Ju=class extends F{constructor(t,n){super(n);this.operator=t;this.semanticTokenType="operator",this.semanticTokenModifiers="declaration"}toString(){return this.operator}};var IE=z(J());var Xu=class extends Qe{toString(){return"..."}},fs=class extends F{constructor(t,n){super();this.functionName=t;this.params=n;this.addChild(t),this.params.forEach(s=>this.addChild(s))}getDocumentSymbols(t){return this.uri!==t?[]:[{name:this.functionName.name,kind:IE.SymbolKind.Function,range:Q(this),selectionRange:Q(this),children:this.params.flatMap(n=>n.getDocumentSymbols(t))}]}toString(){return`${this.functionName}(${this.params.map(t=>t.toString()).join(",")})`}};var Pm=z(J());var gn=class extends zr{constructor(t,n,s){super(n);this.value=t;this.docSymbolsMeta={name:`param${s+1}`,kind:Pm.SymbolKind.Variable},this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.value}},hs=class extends zr{constructor(t,n){super();this.functionName=t;this.params=n;this.addChild(t),this.params.forEach(s=>this.addChild(s))}getDocumentSymbols(t){return this.uri!==t?[]:[{name:this.functionName.name,kind:Pm.SymbolKind.Function,range:Q(this),selectionRange:Q(this),children:this.params.flatMap(n=>n?.getDocumentSymbols(t)??[])}]}toString(){return`${this.functionName.toString()}(${this.params.map(t=>t?.toString()??"<NULL>").join(",")})`}isTrue(t){return this.functionName.name==="defined"?!!(this.params.length===1&&this.params[0]&&t.has(this.params[0].value)):super.isTrue(t)}};var ps=class{constructor(){this.positionStack=[];this._issues=[];this.issueLengthPositionStack=[];this.moveEndOfLine=(e,t=!0)=>{let n=e.pos.line;if(this.currentToken?.pos.line!==n||this.currentToken?.uri!==e.uri)return;let s=this.currentToken,i=s;for(;this.currentToken?.pos.line===n;)i=this.moveToNextToken;if(t){let o=new F(G(s,i));this._issues.push(C(22,o))}return i};this.parsing=new Promise(e=>{setTimeout(()=>{this.parse().then(e)})})}reset(){this.issueLengthPositionStack=[],this.positionStack=[],this._issues=[]}get issues(){return this._issues}get stable(){return this.parsing}get done(){return this.peekIndex()>=this.tokens.length}get moveToNextToken(){let e=this.currentToken;if(e)return this.moveStackIndex(),e}enqueueToStack(){this.issueLengthPositionStack.push(this._issues.length),this.positionStack.push(this.peekIndex())}popStack(){let e=this.issueLengthPositionStack.pop()??0;e!==this._issues.length&&this._issues.splice(e),this.positionStack.pop()}mergeStack(){let e=this.issueLengthPositionStack.pop(),t=this.positionStack.pop();if(t===void 0||e===void 0)throw new Error("Index out of bounds");this.positionStack[this.positionStack.length-1]=t}peekIndex(e=1){let t=this.positionStack.at(-1*e);if(t===void 0)throw new Error("Index out of bounds");return t}get currentToken(){return this.tokens.at(this.peekIndex())}get prevToken(){let e=this.peekIndex()-1;if(e!==-1)return this.tokens[e]}moveStackIndex(){let e=this.positionStack.length-1;if(this.positionStack[e]===void 0)throw new Error("Index out of bounds");this.positionStack[e]!==this.tokens.length&&this.positionStack[e]++}checkConcurrentTokens(e){this.enqueueToStack();let t=[];return e.every(n=>{let s=this.currentToken,i=n(s),o=!1;return i!=="no"&&s&&(t.push(s),this.moveToNextToken,o=Xt(s,this.currentToken)),i==="yes"&&o}),this.mergeStack(),t}consumeAnyConcurrentTokens(e){this.enqueueToStack();let t=[],n,s=!0;for(;e.some(i=>i(this.currentToken)==="yes"&&s);)t.push(this.currentToken),n=this.currentToken,this.moveToNextToken,s=Xt(n,this.currentToken);return this.mergeStack(),t}getDocumentSymbols(e){return this.allAstItems.flatMap(t=>t.getDocumentSymbols(e))}getWorkspaceSymbols(){return this.allAstItems.flatMap(e=>e.getWorkspaceSymbols())}buildSemanticTokens(e,t){let n=[],s=(i,o,a)=>{if(!a?.start||!a?.end||a.start.uri!==t||a.end.uri!==t)return;let c=a.end.pos.col-a.start.pos.col+a.end.pos.len;n.push({line:a.start.pos.line,char:a.start.pos.col,length:a.end===a.start?a.end.pos.len:c,tokenType:i,tokenModifiers:o})};this.allAstItems.forEach(i=>{i.buildSemanticTokens(s)}),n.sort((i,o)=>i.line===o.line?i.char-o.char:i.line-o.line).forEach(i=>e.push(i.line,i.char,i.length,i.tokenType,i.tokenModifiers))}processCIdentifier(e,t){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,48].map(Pe));if(!n.length){this.popStack();return}let s=n.map(o=>o.value).join("");if(!s.match(/^[_A-Za-z]/)){this.popStack();return}let i=new $t(s,G(n[0],n.at(-1)));return!t&&i.name!=="defined"&&(e.get(i.name)||this._issues.push(C(42,i))),this.mergeStack(),i}isOperator(){this.enqueueToStack();let e=this.moveToNextToken;if(!e){this.popStack();return}let t=e,n;if($(e,40)?(n="&",$(this.currentToken,40)&&(n="&&",t=this.moveToNextToken)):$(e,10)?(n="!",$(this.currentToken,0)&&(n="!=",t=this.moveToNextToken)):$(e,8)?(n="|",$(this.currentToken,8)&&(n="||",t=this.moveToNextToken)):$(e,9)?n="^":$(e,4)?(n=">",$(this.currentToken,4)?(n="<<",t=this.moveToNextToken):$(this.currentToken,0)&&(n=">=",t=this.moveToNextToken)):$(e,5)?(n="<",$(this.currentToken,5)?(n=">>",t=this.moveToNextToken):$(this.currentToken,0)&&(n="<=",t=this.moveToNextToken)):$(e,15)?n="+":$(e,16)?n="-":$(e,17)?n="*":$(e,13)?n="/":$(e,18)?n="%":$(e,46)?$(this.currentToken,46)&&(n="##",t=this.moveToNextToken):$(e,0)&&$(this.currentToken,0)&&(n="==",t=this.moveToNextToken),n){let s=new Ju(n,G(e,t));return this.mergeStack(),s}this.popStack()}parseScopedBlock(e,t,n){this.enqueueToStack();let s=this.moveToNextToken;if(!s||!e(s)){this.popStack();return}let i=this.peekIndex(),o=()=>{this.positionStack[this.positionStack.length-1]=i},a=p=>p.flatMap(b=>"items"in b?a(b.items):b),c=[s],l=[];l[0]={rewind:o,tokens:[]};let u=this.currentToken;for(;u&&!t(u);){if(n?.(u)){let p=this.peekIndex()+1,b=()=>{this.positionStack[this.positionStack.length-1]=p};c.push(u),l[l.length]={rewind:b,tokens:[]}}else if(e(u)){let p=this.parseScopedBlock(e,t,n);p&&(c.push(p),l[l.length-1].tokens.push(...a(p.items))),u=this.currentToken;continue}else c.push(u),l[l.length-1].tokens.push(u);this.moveToNextToken,u=this.currentToken}let d=u;d&&t(d)&&(this.moveToNextToken,c.push(d));let f={startToken:s,items:c,splitTokens:l,endToken:d};return this.mergeStack(),f}isFunctionCall(e){this.enqueueToStack();let t=this.processCIdentifier(e,!1);if(!t){this.popStack();return}let n=this.processMacroCallParams();if(!n){this.popStack();return}if(t.name==="defined")n.length>1?this._issues.push(C(44,t)):n.length<1&&this._issues.push(C(45,t));else{let i=e.get(t.name)?.macro;i&&(i?.identifier instanceof fs?n.length>i.identifier.params.length?this._issues.push(C(44,t,void 0,[i])):n.length<i.identifier.params.length&&this._issues.push(C(45,t,void 0,[i])):this._issues.push(C(43,t)))}let s=new hs(t,n);return s.lastToken=this.prevToken,this.mergeStack(),s}processHex(){this.enqueueToStack();let e=this.checkConcurrentTokens([Je("0"),Je("x")]);if(e.length!==2){this.popStack();return}let t=this.consumeAnyConcurrentTokens([19,20].map(Pe));if(!t.length){this.popStack();return}let n=Number.parseInt(t.map(i=>i.value).join(""),16),s=new _t(n,G(e[0],t.at(-1)));return this.mergeStack(),s}processDec(){this.enqueueToStack();let e=this.consumeAnyConcurrentTokens([19].map(Pe));if(!e.length){this.popStack();return}let t=Number.parseInt(e.map(s=>s.value).join(""),10),n=new _t(t,G(e[0],e.at(-1)));return this.mergeStack(),n}processEnclosedExpression(e){this.enqueueToStack();let t,n,s;if($(this.currentToken,42))return t=this.moveToNextToken,n=t,s=this.processExpression(e,!0),s&&(s=new Zs(new Zs(s,!0),!1)),$(this.currentToken,43)?n=this.moveToNextToken:this._issues.push(C(26,new F(G(t)))),this.mergeStack(),s;this.popStack()}processExpression(e,t=!1){this.enqueueToStack();let n;if(n=this.processEnclosedExpression(e)||this.isFunctionCall(e)||this.processCIdentifier(e,!1)||this.processHex()||this.processDec(),!n){this.popStack();return}if(t){let s=this.isOperator();for(;s;){let i=this.processExpression(e);i?n instanceof Zs?n.addExpression(s,i):n=new Zs(n,!1,{operator:s,expression:i}):this._issues.push(C(27,s)),s=this.isOperator()}}return this.mergeStack(),n}processMacroCallParams(){if(!$(this.currentToken,42))return;let e=this.parseScopedBlock(n=>!!$(n,42),n=>!!$(n,43),n=>!!$(n,24));return e?.items.length===2&&$(e.endToken,43)?[]:e?.splitTokens.map((n,s)=>n.tokens.length===0?null:new gn(n.tokens.map((i,o)=>{let a=i.value;return i.pos.line===n.tokens.at(o+1)?.pos.line&&(a=a.padEnd(n.tokens[o+1].pos.col-i.pos.col," ")),a}).join(""),G(n.tokens[0],n.tokens.at(-1)),s))}};var Zu=class r extends ps{constructor(t){super();this.uri=t;this.comments=[];this.tokens=[]}cleanUpComments(){let t=[];for(let n=0;n<this.tokens.length;n++){let s=r.processBlockComments(this.tokens,n)||r.processLineComments(this.tokens,n);s&&(n=s.index,t.push(...s.tokenUsed),this.comments.push(...s.comments))}t.reverse().forEach(n=>this.tokens.splice(n,1))}get allAstItems(){return this.comments}reset(){super.reset(),this.comments=[]}reparse(){return this.reset(),this.parse()}async parse(){this.tokens=Xr().requestTokens(this.uri,!0),this.cleanUpComments()}static processBlockComments(t,n){let s=[],i=()=>(s.push(n++),t[n]),o=()=>t[n],a=()=>t[n-1],c=o(),l=c;if(!c||!$(c,13)||(l=i(),!$(l,17)||c.pos.line!==l.pos.line||c.pos.col+1!==l.pos.col))return;let u=()=>!(!$(a(),17)||!$(o(),13)||!Xt(a(),o())),d=l.pos.line,f=c,p=[];l=i();do{if(o()?.pos.line!==d){let g=new mn(G(f,a()));p.push(g),d=o().pos.line??0,f=o()}l=i()}while(n<t.length&&!u());let b=new mn(G(f,o()));return p.push(b),i(),{comments:p,tokenUsed:s,index:n-1}}static processLineComments(t,n){let s=[];if(!$(t[n],13)||t.length===n+1||!$(t[n+1],13)||!Xt(t[n],t[n+1]))return;let i=[];for(;t[n].pos.line===t.at(n+1)?.pos.line;)s.push(n++);s.push(n++);let o=t[s.at(-1)],a=new mn(G(t[s[0]],t[s.at(-1)]));return i.push(a),{comments:i,tokenUsed:s,index:n-1}}};var ME=z(J()),ed=class extends F{constructor(t,n){super(t);this.content=n}toString(){let t=this.content.filter(n=>!$(n,14));return t.map((n,s)=>{let i=n.value;return n.pos.line===t.at(s+1)?.pos.line?i=i.padEnd(t[s+1].pos.col-n.pos.col," "):t.at(s+1)&&(i=i.padEnd(i.length+1," ")),i}).join("")}},Ea=class extends F{constructor(t,n,s){super();this.keyword=t;this.identifier=n;this.content=s;this.addChild(t),this.addChild(this.identifier),this.content&&this.addChild(this.content)}get name(){return this.identifier instanceof $t?this.identifier.name:this.identifier.functionName.name}toString(){return[this.identifier.toString(),...this.content?[this.content?.toString()]:[]].join(" ")}toMarkupContent(){return{kind:ME.MarkupKind.Markdown,value:["```cpp",`#define ${this.toString()}`,"```"].join(`
|
|
257
|
-
`)}}};var ri=class extends F{constructor(e){super(e)}},Na=class extends F{constructor(t,n){super();this.keyword=t;this.content=n;this.active=!1;this.addChild(t)}},Pa=class extends Na{constructor(t,n,s){super(t,s);this.identifier=n;this.addChild(n),this.addChild(s)}useBlock(t){return this.identifier&&t.has(this.identifier.name)}},td=class extends Na{constructor(t,n,s){super(t,s);this.expression=n;this.addChild(n),this.addChild(s)}useBlock(t){return this.expression instanceof hs?this.expression.functionName.name==="defined"?this.expression&&t.has(this.expression.params.at(0)?.value??""):this.expression.isTrue(t):this.expression?.isTrue(t)}},rd=class extends Pa{useBlock(e){return this.identifier&&!e.has(this.identifier.name)}},Ra=class extends Na{};var lo=class extends F{constructor(t,n,s){super();this.ifDef=t;this.endIf=n;this.elseOption=s;this.addChild(t),s&&this.addChild(s),this.addChild(n)}getInValidTokenRange(t,n){let s=[],i=a=>n.findIndex(c=>c===a);if(!this.ifDef.identifier)return[{start:i(this.tokenIndexes.start),end:i(this.tokenIndexes.end)}];s.push({start:i(this.ifDef.tokenIndexes.start),end:i(this.ifDef.identifier.tokenIndexes.end)});let o=this.ifDef.useBlock(t);return o?this.ifDef.active=!0:this.elseOption&&(this.elseOption.active=!0),!o&&this.ifDef.content&&s.push({start:i(this.ifDef.content.tokenIndexes.start),end:i(this.ifDef.content.tokenIndexes.end)}),this.elseOption&&(s.push({start:i(this.elseOption.tokenIndexes.start),end:i(this.elseOption.keyword.tokenIndexes.end)}),o&&this.elseOption.content&&s.push({start:i(this.elseOption.content.tokenIndexes.start),end:i(this.elseOption.content.tokenIndexes.end)})),this.endIf&&s.push({start:i(this.endIf.tokenIndexes.start),end:i(this.endIf.tokenIndexes.end)}),s}},ms=class extends F{constructor(t,n,s){super();this.ifBlocks=t;this.endIf=n;this.elseOption=s;t.forEach(i=>this.addChild(i)),s&&this.addChild(s),this.addChild(n)}getInValidTokenRange(t,n){let s=[],i=a=>n.findIndex(c=>c===a),o=!1;return this.ifBlocks.forEach((a,c)=>{s.push({start:i(a.tokenIndexes.start),end:i(a.expression?.tokenIndexes.end??a.keyword.tokenIndexes.end)}),!o&&a.useBlock(t)?(a.active=!0,o=!0):a.content&&s.push({start:i(a.content.tokenIndexes.start),end:i(a.content.tokenIndexes.end)})}),this.elseOption&&(s.push({start:i(this.elseOption.keyword.tokenIndexes.start),end:i(this.elseOption.keyword.tokenIndexes.end)}),o&&this.elseOption.content?s.push({start:i(this.elseOption.content.tokenIndexes.start),end:i(this.elseOption.content.tokenIndexes.end)}):this.elseOption.active=!0),this.endIf&&s.push({start:i(this.endIf.tokenIndexes.start),end:i(this.endIf.tokenIndexes.end)}),s}};var Ca=z(J());var fo=class extends ps{constructor(t,n,s){super();this.uri=t;this.incudes=n;this.tokens=[];this.nodes=[];this.dtsIncludes=[];this.macroSnapShot=new Map;this.macros=new Map;this.macroStart=!1;s&&(Array.from(s).forEach(([i,o])=>this.macroSnapShot.set(i,o)),Array.from(s).forEach(([i,o])=>this.macros.set(i,o)))}get currentToken(){let t=this.prevToken,n=pn(t,this.tokens.at(this.peekIndex()))||!t||$(t,14)&&t.pos.line+1===this.tokens.at(this.peekIndex())?.pos.line;if(!(this.macroStart&&!n))return this.macroStart&&$(this.tokens.at(this.peekIndex()),14)?(this.moveStackIndex(),this.currentToken):this.tokens.at(this.peekIndex())}reset(t){super.reset(),this.macros.clear(),t?(this.macroSnapShot.clear(),Array.from(t).forEach(([n,s])=>this.macroSnapShot.set(n,s)),Array.from(t).forEach(([n,s])=>this.macros.set(n,s))):Array.from(this.macroSnapShot).forEach(([n,s])=>this.macros.set(n,s)),this.nodes=[],this.dtsIncludes=[]}async reparse(t){let n=this.stable;return this.parsing=new Promise(s=>{n.then(()=>{if(t&&t.size===this.macroSnapShot.size){let i=Array.from(t);if(Array.from(this.macroSnapShot).every(([o,a],c)=>{let[l,u]=i[c];return l===o&&u.macro.toString()===a.macro.toString()})){console.log("header file cache hit",this.uri),s();return}}this.reset(t),this.parse().then(s)})}),this.parsing}async parse(){let t=new Zu(this.uri);if(await t.stable,this.tokens=t.tokens,this.nodes.push(...t.allAstItems),this.positionStack.push(0),this.tokens.length!==0){for(;!this.done;)await this.lineProcessor();if(this.positionStack.length!==1)throw new Error("Incorrect final stack size")}}async lineProcessor(){if(this.enqueueToStack(),!(!this.prevToken||this.prevToken.pos.line!==this.currentToken?.pos.line||this.prevToken.uri!==this.currentToken?.uri)){this.moveEndOfLine(this.prevToken,!1),this.mergeStack();return}let n=this.currentToken,s=await this.processInclude()||this.processDefinitions()||this.processUndef()||this.processIfDefBlocks();n&&this.moveEndOfLine(n,!!s),this.mergeStack()}processDefinitions(){this.enqueueToStack();let t=this.peekIndex(),n=this.moveToNextToken;if(!n||!$(n,25))return this.popStack(),!1;this.macroStart=!0;let s=new Qe(G(n)),i=this.isFunctionDefinition()||this.processCIdentifier(this.macros,!0);if(!i)return this._issues.push(C(30,s)),this.mergeStack(),this.macroStart=!1,!0;let o=this.consumeDefinitionContent(),a;o.length&&(a=new ed(G(o[0],o.at(-1)),o));let c=new Ea(s,i,a);this.macros.set(c.name,{macro:c,resolver:Aw(c.toString())}),this.nodes.push(c);let l=this.peekIndex();return this.tokens.splice(t,l-t),this.positionStack[this.positionStack.length-1]=t,this.mergeStack(),this.macroStart=!1,!0}processUndef(){this.enqueueToStack();let t=this.peekIndex(),n=this.moveToNextToken;if(!n||!$(n,28))return this.popStack(),!1;this.macroStart=!0;let s=new Qe(G(n)),i=this.processCIdentifier(this.macros,!0);if(!i)return this._issues.push(C(30,s)),this.mergeStack(),this.macroStart=!1,!0;let o=new Ea(s,i);this.macros.delete(i.name),this.nodes.push(o);let a=this.peekIndex();return this.tokens.splice(t,a-t),this.positionStack[this.positionStack.length-1]=t,this.mergeStack(),this.macroStart=!1,!0}consumeDefinitionContent(){let t=[];for(;this.currentToken;){let n=this.moveToNextToken;n&&t.push(n)}return t}isFunctionDefinition(){this.enqueueToStack();let t=this.processCIdentifier(this.macros,!0);if(!t){this.popStack();return}let n=this.moveToNextToken;if(!$(n,42)||!Xt(t.lastToken,n)){this.popStack();return}let s=[],i=this.processCIdentifier(this.macros,!0)||this.processVariadic();for(;i;)s.push(i),!$(this.currentToken,24)&&!$(this.currentToken,43)?this._issues.push(C(28,i)):$(this.currentToken,43)||(n=this.moveToNextToken),i=this.processCIdentifier(this.macros,!0)||this.processVariadic();let o=new fs(t,s);return $(this.currentToken,43)?(n=this.moveToNextToken,o.lastToken=n):(o.lastToken=this.prevToken,this._issues.push(C(26,s.at(-1)??o))),this.mergeStack(),o}processVariadic(){this.enqueueToStack();let t=this.checkConcurrentTokens([Pe(45),Pe(45),Pe(45)]);if(t.length!==3){this.popStack();return}let n=new Xu(G(t[0],t.at(-1)));return this.mergeStack(),n}processIfDefBlocks(){let t=this.peekIndex(),n=this.parseScopedBlock(o=>!!o&&[33,34,32].some(a=>$(o,a))&&!pn(o.prevToken,o),o=>!!o&&[37].some(a=>$(o,a))&&!pn(o.prevToken,o),o=>!!o&&[36,35].some(a=>$(o,a))&&!pn(o.prevToken,o));if(!n)return;let s;$(n.startToken,32)?s=this.processIfBlock(n,(o,a,c)=>new td(o,a??null,c)):s=this.processIfDefBlock(n,(o,a,c)=>$(n.startToken,33)?new Pa(o,a??null,c):new rd(o,a??null,c)),this.nodes.push(s),s.getInValidTokenRange(this.macros,this.tokens).reverse().forEach(o=>{this.tokens.splice(o.start,o.end-o.start+1)}),[...s instanceof ms?s.ifBlocks:[s.ifDef],...s.elseOption?[s.elseOption]:[]].forEach(o=>{!o.active&&o.content&&this._issues.push(C(47,o.content,Ca.DiagnosticSeverity.Hint,[],[Ca.DiagnosticTag.Unnecessary]))}),this.positionStack[this.positionStack.length-1]=t}processIfDefBlock(t,n){this.enqueueToStack(),this.macroStart=!0;let s=new Qe(G(t.startToken));t.splitTokens[0].rewind();let i=this.processCIdentifier(this.macros,!0);i||this._issues.push(C(31,s)),this.macroStart=!1;let o,a=i?.lastToken.nextToken??s.lastToken.nextToken;a&&t.splitTokens[0].tokens.find(f=>f===a)&&(o=new ri(G(a,t.splitTokens[0].tokens.at(-1))));let c=n(s,i??null,o??null),l;if(t.splitTokens.length>1){let f=t.splitTokens[1].tokens[0].prevToken,p=new Qe(G(f)),b;t.splitTokens[1].tokens.length&&(b=new ri(G(t.splitTokens[1].tokens[0],t.splitTokens[1].tokens.at(-1)))),l=new Ra(p,b??null)}let u;t.endToken?u=new Qe(G(t.endToken)):this._issues.push(C(46,s));let d=new lo(c,u??null,l);return this.mergeStack(),d}processIfBlock(t,n){this.enqueueToStack();let s=new Qe(G(t.startToken)),i=[],o;t.splitTokens.forEach((l,u)=>{l.rewind();let d=this.prevToken,f=new Qe(G(d));this.macroStart=!0;let p=this.processExpression(this.macros,!0)||this.processCIdentifier(this.macros,!0);if(this.macroStart=!1,u===t.splitTokens.length-1&&$(d,36)){let g=d,_=new Qe(G(g)),w;l.tokens.length&&(w=new ri(G(l.tokens[0],l.tokens.at(-1)))),o=new Ra(_,w??null)}else{p||this._issues.push(C(31,s));let g,_=p?.lastToken.nextToken??s.lastToken.nextToken;_&&l.tokens.find(T=>T===_)&&(g=new ri(G(_,t.splitTokens[u].tokens.at(-1))));let w=n(f,p??null,g??null);i.push(w)}});let a;t.endToken?a=new Qe(G(t.endToken)):this._issues.push(C(46,s));let c=new ms(i,a??null,o);return this.mergeStack(),c}get allAstItems(){return[...this.dtsIncludes,...this.nodes]}resolveInclude(t){if(t.path.path)return t.path.relative?[(0,uo.resolve)((0,uo.dirname)(t.uri),t.path.path),...this.incudes.map(n=>(0,uo.resolve)(n,t.path.path))].find(n=>(0,Rm.existsSync)(n)):this.incudes.map(n=>(0,uo.resolve)(n,t.path.path)).find(n=>(0,Rm.existsSync)(n))}async processInclude(){this.enqueueToStack();let t=this.peekIndex(),n=this.currentToken;if(!n)return this.popStack(),!1;let s=n,i=n;if($(n,26))this.moveToNextToken;else{let g=this.checkConcurrentTokens([Pe(13),Je("include"),Pe(13)]);if(g.length!==3)return this.popStack(),!1;s=g[0],i=g.at(-1)}let o=s,a=new Qe(G(s,i));n=this.moveToNextToken;let c=n,l=!!$(n,21);if(!c||!l&&!$(n,5))return o&&this.moveEndOfLine(o),this.mergeStack(),!0;let u="";if(l)u=n?.value??"";else for(;this.currentToken?.pos.line===o.pos.line&&!$(this.currentToken,4);)u+=this.currentToken?.value??"",n=this.moveToNextToken;let d=new ro(u,l,G(c,n)),f=new cs(a,d);this.dtsIncludes.push(f),l||(this.currentToken?.pos.line!==o.pos.line||!$(this.currentToken,4)?this._issues.push(C(12,f)):(n=this.moveToNextToken,d.lastToken=n)),this.mergeStack();let p=this.peekIndex(),b=this.resolveInclude(f);if(f.resolvedPath=b,b||this._issues.push(C(36,f.path,Ca.DiagnosticSeverity.Warning)),b){Xr().requestTokens(b,!0);let g=await Da().getCPreprocessorParser(b,this.incudes,this.macros,this.uri);await g.stable,this._issues.push(...g.issues),this.macros.clear(),Array.from(g.macros).forEach(([_,w])=>this.macros.set(_,w)),b.endsWith(".h")?this.tokens.splice(t,p-t):this.tokens.splice(t,p-t,...g.tokens),this.nodes.push(...g.nodes),this.dtsIncludes.push(...g.dtsIncludes)}else this.tokens.splice(t,p-t);return this.positionStack[this.positionStack.length-1]=t,!0}};var xE,Cm=class{constructor(){this.headerFiles=new Map;this.includeOwners=new WeakMap}getCPreprocessorParser(e,t,n,s){let i=`${Array.from(n).map(l=>l[1].macro.toString()).join("::")}`,o=this.headerFiles.get(e)?.get(i);if(o)return o.reparse(n),o;console.log("No cpreprocess cache",e);let a=new fo(e,t,n),c=this.includeOwners.get(a)??new Set;return c.add(s),this.includeOwners.set(a,c),this.headerFiles.has(e)||this.headerFiles.set(e,new Map),this.headerFiles.get(e)?.set(i,a),a}reset(e){let t=this.headerFiles.get(e);t&&Array.from(t).forEach(n=>{n[1]&&(console.log("disposing cpreprocessor cache for",e),Array.from(this.includeOwners.get(n[1])??[]).forEach(this.reset.bind(this)),this.headerFiles.delete(e))})}};function Da(){return xE??=new Cm,xE}var LE,Dm=class r{constructor(){this.fileMap=new Map}static clone(e){let t=e.map(n=>({...n}));return t.forEach((n,s)=>{n.prevToken=t[s-1],n.nextToken=t[s+1]}),t}needsRenew(e,t){return this.fileMap.get(e)?.text!==t}renewLexer(e,t){if(Da().reset(e),!e||!(0,nd.existsSync)(e))return[];try{t??=(0,nd.readFileSync)(e).toString();let n=new Yu(t,e);return this.fileMap.set(e,n),r.clone(n.tokens)}catch{}return[]}requestTokens(e,t){let n=this.fileMap.get(e)?.tokens;return!n&&t?[...this.renewLexer(e)]:r.clone(n??[])}reset(e){Da().reset(e),this.fileMap.delete(e)}};function Xr(){return LE??=new Dm,LE}var sd=class r{constructor(e){this.context=e;this.comments=[];this.includes=[];this.roots=[];this.references=[];this.unlinkedDeletes=[];this.unlinkedRefNodes=[];this.globalDeletes=[];this.rootNode=new Ee(this.context.bindingLoader,"/");this.labelsUsedCache=new Map}static{this.getFileTopMostAst=(e,t)=>e.uri===t?[e]:e.children.flatMap(n=>r.getFileTopMostAst(n,t))}fileTopMostAst(e){return[...this.roots,...this.references,...this.unlinkedDeletes,...this.unlinkedRefNodes,...this.globalDeletes,...this.context.parser.cPreprocessorParser.allAstItems,...this.context.overlayParsers.flatMap(t=>t.cPreprocessorParser.allAstItems)].flatMap(t=>r.getFileTopMostAst(t,e))}getDeepestAstNode(e,t){let s=this.fileTopMostAst(e).find(i=>Tr(i,e,t)||Cw(Xr().requestTokens(e,!1),i,t));if(s instanceof Rt){let o=this.rootNode.getReferenceBy(s)?.getDeepestAstNode(e,t);return o?{...o,runtime:this}:{item:null,runtime:this,ast:hn(s,e,t)}}else if(s instanceof dt&&s.path){let i=this.rootNode.getDeepestAstNode(e,t);return i?{...i,runtime:this}:void 0}else if(s instanceof Re&&s.path){let i=r.getNodeFromPath(s.path.slice(1),this.rootNode)?.getDeepestAstNode(e,t);return i?{...i,runtime:this}:void 0}else if(s)return{runtime:this,item:null,ast:hn(s,e,t)}}static getNodeFromPath(e,t,n=!0){if(e.length===0)return t;let s=e[0].split("@"),i=s[0],a=s.at(1)?.split(",").map(u=>Number.parseInt(u,16)),c=e.slice(1),l=t.getNode(i,a,n);return l?r.getNodeFromPath(c,l,n):void 0}resolvePath(e,t){if(!e.at(0)?.startsWith("&"))return e;let n=this.labelsUsedCache.get(e[0].slice(1));return n||(t??=this.rootNode.allDescendantsLabels,t.find(i=>i.label.value===e.at(0)?.slice(1)&&i.parentNode instanceof qe)?.lastLinkedTo?.path)}get issues(){return[...this.labelIssues(),...this.rootNode.issues]}labelIssues(){let e=[],t=new Map;return this.rootNode.allDescendantsLabelsMapped.forEach(n=>{t.has(n.label.label.value)?t.get(n.label.label.value)?.push(n):t.set(n.label.label.value,[n])}),Array.from(t).forEach(n=>{let s=n[1];if(s.length>1){let i=s.find(a=>a.owner instanceof Ee);if(!s.every(a=>a&&a.owner===i?.owner)||!i){let a=s.filter(c=>!(c&&c.owner===i?.owner));e.push(C(4,s.at(0).label,$E.DiagnosticSeverity.Error,s.slice(1).map(c=>c.label),[],[s.at(0).label.label.value]))}}}),e}get typesIssues(){let e=t=>[...t.nodeType?.getIssue(this,t)??[],...t.nodes.flatMap(n=>e(n))];return e(this.rootNode)}getOrderedNodeAst(e){return Dw([...e.definitions,...e.referencedBy])}};var qE=z(J()),id=class extends F{constructor(t){super();this.values=t;this.docSymbolsMeta={name:"Values",kind:qE.SymbolKind.String},this.values.forEach(n=>this.addChild(n))}toString(){return this.values.map(t=>t?.toString()).join(",")}toJson(){return this.values.length===1?this.values[0]?.toJson():this.values.map(t=>t?.toJson())}};var jE=z(J()),od=class extends F{constructor(t){super();this.keyword=t;this.addChild(t),this.docSymbolsMeta={name:"DTS Document version",kind:jE.SymbolKind.Function}}};var yn=class extends F{constructor(t,n){super();this.value=t;this.labels=n;this.labels.forEach(s=>{this.addChild(s)}),this.addChild(this.value)}toString(){return`${this.labels.map(t=>t.toString()).join(" ")}${this.value?.toString()??"NULL"}`}};var FE=z(J()),ad=class extends F{constructor(t,n,s){super();this.keyword=t;this.startAddress=n;this.endAddress=s;this.addChild(t),this.docSymbolsMeta={name:"Memreserve",kind:FE.SymbolKind.Function},this.addChild(n),this.addChild(s)}toString(){return`/memreserve/ 0x${this.startAddress?.value?.toString(16)} 0x${this.endAddress?.value?.toString(16)}`}};var BE=z(J()),cd=class extends F{constructor(t,n){super();this.keyword=t;this.bitsSize=n;this.addChild(t),this.docSymbolsMeta={name:"bits",kind:BE.SymbolKind.Function},this.addChild(n)}toString(){return`/bits/ ${this.bitsSize?.value?.toString()}`}};var UE=z(J()),Oa=class extends ps{constructor(t,n,s){super();this.uri=t;this.incudes=n;this.tokens=[];this.others=[];this.rootDocument=new qe;this.unhandledStatements=new dt;this.cPreprocessorParser=new fo(this.uri,this.incudes,s)}get issues(){return[...this._issues,...this.cPreprocessorParser.issues]}getFiles(){return[this.uri,...this.cPreprocessorParser.dtsIncludes.flatMap(t=>t.resolvedPath).filter(t=>!!t)]}reset(){super.reset(),this.others=[],this.rootDocument=new qe,this._issues=[],this.unhandledStatements=new dt}async reparse(){let t=performance.now(),n=this.stable;return this.parsing=new Promise(s=>{n.then(async()=>{this.reset(),await this.cPreprocessorParser.reparse(),await this.parse(),console.log("parsing",performance.now()-t),s()})}),this.parsing}async parse(){let t=performance.now();if(await this.cPreprocessorParser.stable,this.tokens=this.cPreprocessorParser.tokens,this.uri.endsWith(".h")||(this.positionStack.push(0),this.tokens.length===0))return;let n=async()=>{if(!(this.isDtsDocumentVersion()||this.isMemreserve()||this.isRootNodeDefinition(this.rootDocument)||this.isDeleteNode(this.rootDocument,"Ref")||this.isChildNode(this.rootDocument,"Ref")||this.isProperty(this.unhandledStatements)||this.isDeleteProperty(this.unhandledStatements))){let s=this.moveToNextToken;if(s){let i=new F(G(s));this._issues.push(C(22,i)),this.reportExtraEndStatements()}}};for(;!this.done;)await n();if(this.unhandledStatements.properties.forEach(s=>{this._issues.push(C(32,s))}),this.unhandledStatements.deleteProperties.forEach(s=>{this._issues.push(C(33,s))}),this.positionStack.length!==1)throw new Error("Incorrect final stack size")}isRootNodeDefinition(t){this.enqueueToStack();let n=this.moveToNextToken,s=n,i=13;if(!n||!$(n,i))return this.popStack(),!1;if(s=this.moveToNextToken,i=2,!s||!$(s,i))return this.popStack(),!1;let o=new dt;o.openScope=s,t.addNodeChild(o),this.processNode(o,"Name");let a=this.nodeEnd(o)??s;return o.firstToken=n,o.lastToken=a,this.mergeStack(),!0}nodeEnd(t){let n=this.currentToken;if($(n,3))this.moveToNextToken;else{let s=this.prevToken;if(s){let i=new F(G(s));this._issues.push(C(3,i))}return this.endStatement(!1)}return this.prevToken?.value==="}"&&(t.closeScope=this.prevToken),this.endStatement()}isNodeEnd(){return $(this.currentToken,3)||$(this.currentToken,1)}endStatement(t=!0){let n=this.currentToken;if(!$(n,1)){let s=this.prevToken;if(s&&t){let i=new F(G(this.prevToken));return this._issues.push(C(1,i)),s}}return this.moveToNextToken,this.reportExtraEndStatements(),n}reportExtraEndStatements(){for(;$(this.currentToken,1);){let t=this.moveToNextToken;if(t){let n=new F(G(t));this._issues.push(C(23,n))}}}processNode(t,n){if(this.done)return!1;let s=!1,i=!1;do{if(i=this.isChildNode(t,n)||this.isProperty(t)||this.isDeleteNode(t,n)||this.isDeleteProperty(t),!i&&!this.isNodeEnd()&&!this.done){let o=this.moveToNextToken;if(o){let a=new F(G(o));this._issues.push(C(22,a)),this.reportExtraEndStatements()}}else if(this.done)break;s=s||i}while(!this.isNodeEnd());return s}processOptionalLabelAssign(t=!1){let n=[],s=this.isLabelAssign(t);for(;s;)n.push(s),s=this.isLabelAssign(t);return n}isChildNode(t,n){this.enqueueToStack();let s;n==="Name"&&(s=this.isOmitIfNoRefNode());let i=this.processOptionalLabelAssign(),o,a,c=n==="Ref"?new Rt(i):new Re(i,s);if(n==="Ref"?a=this.isLabelRef():n==="Name"&&(o=this.isNodeName()),!a&&!o){if(!$(this.currentToken,2))return this.popStack(),!1;c.firstToken=this.currentToken,this._issues.push(C(n==="Name"?[7]:[10,11],c))}let l=!1;if(a&&c instanceof Rt?(c.labelReference=a,l=!0):o&&c instanceof Re&&(l=o.address!==void 0,c.name=o),$(this.currentToken,2)){this.moveToNextToken,c.openScope=this.prevToken;let u=!1;do u=this.processNode(c,"Name");while(u);let d=this.nodeEnd(c);c.lastToken=d}else if(l){let u=a??o;u&&this._issues.push(C(2,u))}else return this.popStack(),!1;return t.addNodeChild(c),this.mergeStack(),!0}processNodeAddress(){let t=this.prevToken,n=this.consumeAnyConcurrentTokens([19,20].map(Pe)),s=n.length?Number.parseInt(n.map(o=>o.value).join(""),16):NaN;if(t){if(Number.isNaN(s)){let o=new F(G(t));this._issues.push(C(8,o))}else if(!Number.isNaN(s)&&!Xt(t,n[0])){let o=new F(G(t,n.at(0)));this._issues.push(C(29,o))}}return new Fu(s,G(n[0]??this.prevToken,n.at(-1)))}processNodeAddresse(t){this.enqueueToStack();let n=this.checkConcurrentTokens([Pe(49)]);if(n.length){if(!Xt(t.lastToken,n[0])){let o=new F(G(t.lastToken,n[0]));this._issues.push(C(29,o))}let s=[],i=()=>{if(s.push(this.processNodeAddress()),$(this.currentToken,24)){if(this.prevToken&&!Xt(this.prevToken,this.currentToken)){let o=new F(G(this.prevToken,this.currentToken));this._issues.push(C(29,o))}this.moveToNextToken,i()}};return i(),this.mergeStack(),s}this.popStack()}isNodeName(){this.enqueueToStack();let t=this.consumeAnyConcurrentTokens([19,47,24,45,48,15,16].map(Pe));if(!t.length){this.popStack();return}let n=t.map(o=>o.value).join("");if(!n.match(/^[A-Za-z]/)){this.popStack();return}let s=new je(n,G(t[0],t.at(-1))),i=this.processNodeAddresse(s);return s.address=i,this.mergeStack(),s}isPropertyName(){this.enqueueToStack();let t=this.consumeAnyConcurrentTokens([19,47,24,45,48,15,16,44,46].map(Pe));if(!t.length){this.popStack();return}let n=new ze(t.map(s=>s.value).join(""),G(t[0],t.at(-1)));return this.mergeStack(),n}isLabelName(){this.enqueueToStack();let t=this.consumeAnyConcurrentTokens([19,47,48].map(Pe));if(!t.length){this.popStack();return}let n=t.map(i=>i.value).join("");if(!n.match(/^[A-Za-z]/)){this.popStack();return}let s=new Lt(n,G(t[0],t.at(-1)));return this.mergeStack(),s}isLabelAssign(t){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,48].map(Pe));if(!n.length){this.popStack();return}let s=n.map(c=>c.value).join("");if(!s.match(/^[A-Za-z]/)){this.popStack();return}let i=this.currentToken,o=i&&$(i,50),a=new ds(new Lt(s,G(n[0],n.at(-1))),G(n[0],o?i:n.at(-1)));if(o){let c=n.at(-1);c&&(i.pos.line!==a.firstToken.pos.line||i.pos.col!==c.pos.col+c.pos.len)&&this._issues.push(C(29,new F(G(c,i)))),this.moveToNextToken}else if(t)this._issues.push(C(24,a));else{this.popStack();return}return this.mergeStack(),a}isProperty(t){this.enqueueToStack();let n=this.processOptionalLabelAssign(),s=this.isPropertyName();if(!s)return this.popStack(),!1;if($(this.currentToken,2)||$(this.currentToken,49))return this.popStack(),!1;let i=new Ae(s,n),o;$(this.currentToken,0)?(i.assignOperatorToken=this.currentToken,this.moveToNextToken,o=this.processValue(i),o?.values.filter(c=>!!c).length||this._issues.push(C(0,i)),i.values=o??null):i.values=void 0;let a=this.endStatement();return i.lastToken=a,t.addNodeChild(i),this.mergeStack(),!0}isDtsDocumentVersion(){this.enqueueToStack();let t=this.checkConcurrentTokens([Pe(13),Je("d"),Je("ts"),Pe(16),Je("v"),Je("1")]);if(t.length!==6)return this.popStack(),!1;let n=t[0],s=n,i=new Qe;i.firstToken=n;let o=new od(i);if(this.others.push(o),$(this.currentToken,13))s=this.moveToNextToken;else return i.lastToken=t.at(-1),this._issues.push(C(21,o)),this.mergeStack(),!0;return i.lastToken=s,o.lastToken=this.endStatement(),this.mergeStack(),!0}isMemreserve(){this.enqueueToStack();let t=this.checkConcurrentTokens([Pe(13),Je("memreserve")]);if(t.length!==2)return this.popStack(),!1;let n=new Qe;n.firstToken=t[0];let i=t[0];$(this.currentToken,13)?(i=this.moveToNextToken,n.lastToken=i):(n.lastToken=t.at(-1),this._issues.push(C(21,n)));let o=this.processHex()||this.processDec(),a=o&&(this.processHex()||this.processDec()),c=new ad(n,o,a);return this.others.push(c),o||this._issues.push(C(37,n)),a||this._issues.push(C(38,o??n)),c.lastToken=this.endStatement(),this.mergeStack(),!0}processBits(){this.enqueueToStack();let t=this.checkConcurrentTokens([Pe(13),Je("b"),Je("its")]);if(t.length!==3){this.popStack();return}let n=new Qe;n.firstToken=t[0];let i=t[0];$(this.currentToken,13)?(i=this.moveToNextToken,n.lastToken=i):(n.lastToken=t.at(-1),this._issues.push(C(21,n)));let o=this.processDec(),a=new cd(n,o);return this.others.push(a),o?o.value!==8&&o.value!==16&&o.value!==32&&o.value!==64&&this._issues.push(C(40,o)):this._issues.push(C(39,n)),this._issues.push(C(41,a,UE.DiagnosticSeverity.Warning)),this.mergeStack(),a}isOmitIfNoRefNode(){this.enqueueToStack();let t=this.checkConcurrentTokens([Pe(13),Je("omit"),Pe(16),Je("if"),Pe(16),Je("no"),Pe(16),Je("ref"),Pe(13)]);if(t.length!==9){this.popStack();return}let n=new Qe(G(t[0],t.at(-1)));return this.mergeStack(),n}isDeleteNode(t,n){this.enqueueToStack();let s=this.checkConcurrentTokens([Pe(13),Je("d"),Je("e"),Je("lete"),Pe(16),Je("node")]);if(!s.length)return this.popStack(),!1;let i=s[0],o=i,a=new Qe;if(a.firstToken=i,s.length===1&&!$(this.currentToken,2)){this._issues.push(C(25,a)),a.lastToken=s.at(-1);let d=new ur(a);return t.addNodeChild(d),this.mergeStack(),!0}let c=s.map(d=>d.value??"").join("");if(!"/delete-node/".startsWith(c)||c.endsWith("-"))return this.popStack(),!1;a.lastToken=s.at(-1),c!=="/delete-node"?this._issues.push(C(c.startsWith("/delete-n")?34:25,a)):$(this.currentToken,13)?(o=this.moveToNextToken,a.lastToken=o):this._issues.push(C(21,a));let l=new ur(a);if(pn(a.tokenIndexes?.end,i)){let d=this.processNodePathRef();d&&n==="Name"&&this._issues.push(C(7,d));let f=d?void 0:this.isLabelRef();f&&n==="Name"&&this._issues.push(C(7,f));let p=d||f?void 0:this.isNodeName();p&&n==="Ref"&&this._issues.push(C(10,p)),!d&&!p&&!f&&this._issues.push(C([7,10],l)),l.nodeNameOrRef=d??f??p??null}else n==="Name"?this._issues.push(C(7,a)):n==="Ref"&&this._issues.push(C(10,a));let u=this.endStatement();return l.lastToken=u,t.addNodeChild(l),this.mergeStack(),!0}isDeleteProperty(t){this.enqueueToStack();let n=this.checkConcurrentTokens([Pe(13),Je("d"),Je("e"),Je("lete"),Pe(16),Je("property")]);if(!n.length)return this.popStack(),!1;let s=n[0],i=s,o=new Qe;if(o.firstToken=s,n.length===1&&!$(this.currentToken,2)){this._issues.push(C(25,o)),o.lastToken=n.at(-1);let u=new Ue(o);return t.addNodeChild(u),this.mergeStack(),!0}let a=n.map(u=>u.value??"").join("");if(!"/delete-property/".startsWith(a)||a.endsWith("-"))return this.popStack(),!1;o.lastToken=n.at(-1),a!=="/delete-property"?this._issues.push(C(a.startsWith("/delete-p")?35:25,o)):$(this.currentToken,13)?(i=this.moveToNextToken,o.lastToken=i):this._issues.push(C(21,o));let c=new Ue(o);if(pn(o.tokenIndexes?.end,s)){let u=this.isPropertyName();u||this._issues.push(C(6,c)),c.propertyName=u??null}else this._issues.push(C(6,o));let l=this.endStatement();return c.lastToken=l,t.addNodeChild(c),this.mergeStack(),!0}isNodePathRef(){this.enqueueToStack();let t=this.processOptionalLabelAssign(!0),n=this.processNodePathRef();if(!n){this.popStack();return}let s=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&s.push(...this.processOptionalLabelAssign(!0));let i=new Zt(t,n,s);return this.mergeStack(),i}processValue(t){this.enqueueToStack();let s=(()=>{let o=()=>(this.processStringValue()||this.isNodePathRef()||this.isLabelRefValue(t)||this.arrayValues(t)||this.processByteStringValue()||this.isExpressionValue())??null,a=o();if(!a)return[];let c=[a];for(;!$(this.currentToken,1);){let l=this.prevToken,u=this.currentToken,d=$(this.currentToken,24);if(d)this.moveToNextToken;else if(!pn(this.prevToken,this.currentToken))break;let f=o();if(u&&f===null&&d){let p=new F(G(u,this.currentToken));this._issues.push(C(0,p))}if(!d&&f===null)break;if(l&&!d&&f){let p=new F(G(l));this._issues.push(C(28,p))}c.push(f)}return c})();if(s.length===0){this.popStack();return}return this.mergeStack(),new id(s)}processStringValue(){this.enqueueToStack();let t=this.processOptionalLabelAssign(!0),n=this.moveToNextToken;if(!$(n,21)){this.popStack();return}if(!n?.value)throw new Error("Token must have value");let s=n.value;s.match(/["']$/)&&(s=s.slice(1,-1));let i=new Oe(s,G(n));n.value.match(/["']$/)||this._issues.push(C(n.value.startsWith('"')?16:17,i));let o=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(o=this.processOptionalLabelAssign(!0));let a=new Zt(t,i,o);return this.mergeStack(),a}arrayValues(t){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),s=this.processBits(),i=this.currentToken;if($(i,5))this.moveToNextToken;else{this.popStack();return}let o=this.processArrayValues(t)??null;o.openBracket=i;let a=this.processOptionalLabelAssign(!0)??[],c=new Zt(n,o,a,s);$(this.currentToken,4)?(o&&(o.closeBracket=this.currentToken),this.moveToNextToken):this._issues.push(C(12,c));let l=[];return this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(l=this.processOptionalLabelAssign(!0)),this.mergeStack(),c.endLabels.push(...l),c.firstToken=i,c.lastToken=this.prevToken,c}processByteStringValue(){this.enqueueToStack();let t=this.processOptionalLabelAssign(!0),n=this.moveToNextToken,s=n;if(!$(s,11)){this.popStack();return}let i=this.processLabeledValue(()=>this.processHexString()),o=this.processOptionalLabelAssign(!0)??[];i.forEach(u=>{let d=0;u.value?.tokenIndexes?.start===u.value?.tokenIndexes?.end&&(d=u.value?.tokenIndexes?.start?.pos.len??0),d%2!==0&&this._issues.push(C(15,u))});let a=new as(i??[]);a.openBracket=s,a.values.length===0&&(a.firstToken=n,this._issues.push(C(14,a)));let c=new Zt(t,a,o);$(this.currentToken,12)?a.openBracket=this.moveToNextToken:this._issues.push(C(5,c));let l=[];return this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(l=this.processOptionalLabelAssign(!0)),this.mergeStack(),c.endLabels.push(...l),c.firstToken=n,a.lastToken=this.prevToken,c}processLabeledValue(t){this.enqueueToStack();let n=t(),s=[];if(!n)return this.popStack(),[];for(;n;)s=[...s,n],n=t();if(s){let i=t();i&&(s=[...s,i])}return this.mergeStack(),s}processArrayValues(t){this.enqueueToStack();let n=this.processLabeledValue(()=>this.processRefValue(!1,t)||this.processLabeledHex(!1)||this.processLabeledDec(!1)||this.processLabeledExpression(!0,!1)),s=new yt(n);return n.length===0&&(s.firstToken=this.currentToken),this.mergeStack(),s}processLabeledHex(t){this.enqueueToStack();let n=this.processOptionalLabelAssign(t),s=this.processHex();if(!s){this.popStack();return}let i=new yn(s,n);return this.mergeStack(),i}processHexString(){this.enqueueToStack();let t=this.processOptionalLabelAssign(!1),n=this.checkConcurrentTokens([20,20].map(Pe));if(!n.length){this.popStack();return}let s=Number.parseInt(n.map(a=>a.value).join(""),16),i=new _t(s,G(n[0],n.at(-1))),o=new yn(i,t);return this.mergeStack(),o}processLabeledDec(t){this.enqueueToStack();let n=this.processOptionalLabelAssign(t),s=this.processDec();if(!s){this.popStack();return}let i=new yn(s,n);return this.mergeStack(),i}processLabeledExpression(t=!0,n=t){this.enqueueToStack();let s=[];t&&(s=this.processOptionalLabelAssign(n));let i=this.processExpression(this.cPreprocessorParser.macros);if(!i){this.popStack();return}let o=new yn(i,s);return this.mergeStack(),o}isExpressionValue(){this.enqueueToStack();let t=this.processOptionalLabelAssign(!1),n=this.processExpression(this.cPreprocessorParser.macros);if(!n){this.popStack();return}let s=this.processOptionalLabelAssign(!0),i=new Zt(t,n,s);return this.mergeStack(),i}isLabelRef(t){this.enqueueToStack();let n=this.currentToken;if($(n,40))this.moveToNextToken;else{this.popStack();return}let s=this.isLabelName();if(!s){let o=new _e(null);return this._issues.push(C(18,t??o)),o.firstToken=n,this.mergeStack(),o}n&&(s.firstToken.pos.line!==n.pos.line||s.firstToken.pos.col!==n.pos.col+n.pos.len)&&this._issues.push(C(29,new F(G(n,s.firstToken))));let i=new _e(s);return i.firstToken=n,this.mergeStack(),i}isLabelRefValue(t){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),s=this.isLabelRef(t);if(!s){this.popStack();return}let i=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(i=this.processOptionalLabelAssign(!0));let o=new Zt(n,s,i);return this.mergeStack(),o}processRefValue(t,n){this.enqueueToStack();let s=this.processOptionalLabelAssign(t),i=this.currentToken;if(!$(this.currentToken,40)){this.popStack();return}let o=this.processNodePathRef();if(o!==void 0){let l=new yn(o,s);return this.mergeStack(),l}let a=this.isLabelRef(n);if(a===void 0){this._issues.push(C([18,9],n));let l=new yn(null,s);return l.firstToken=s.at(0)?.firstToken??i,this.mergeStack(),l}let c=new yn(a,s);return c.firstToken=s.at(0)?.firstToken??i,this.mergeStack(),c}processNodePath(t=!0,n=new $n){this.enqueueToStack();let s;if($(this.currentToken,13))s=this.moveToNextToken;else{if(!t){this.popStack();return}this.prevToken&&this._issues.push(C(19,new F(G(this.prevToken))))}let i=this.isNodeName();return i||this._issues.push(C(7,new F(G(s??this.prevToken)))),n.addPath(i??null,s?new F(G(s)):void 0),this.processNodePath(!1,n),this.mergeStack(),n}processNodePathRef(){this.enqueueToStack();let t=this.moveToNextToken,n=t;if(!$(n,40)){this.popStack();return}let s=this.moveToNextToken;if(n=s,!$(n,2)){this.popStack();return}let i=this.processNodePath(),o=new Gr(i??null),a=this.currentToken??this.prevToken,c=a;return i?.children.forEach((l,u)=>{if(u===i?.children.length-1&&l&&c&&!Xt(l.lastToken,c)){this._issues.push(C(29,new F(G(l.lastToken,c))));return}if(u===0&&s&&!Xt(s,l?.firstToken)){this._issues.push(C(29,new F(G(s,l?.firstToken))));return}let d=i?.children[u+1];l&&d&&!Xt(l.lastToken,d.firstToken)&&this._issues.push(C(29,new F(G(l.lastToken,d?.firstToken))))}),$(a,3)?this.moveToNextToken:this.prevToken&&this._issues.push(C(3,new F(G(this.prevToken)))),o.firstToken=t,o.lastToken=a??this.prevToken,this.mergeStack(),o}get includes(){return this.allAstItems.filter(t=>t instanceof cs)}get allAstItems(){return[...this.cPreprocessorParser.allAstItems,...this.rootDocument.children,...this.others,...this.unhandledStatements.properties,...this.unhandledStatements.deleteProperties]}};var ho=z(J());var VE=require("fs"),WE=require("path");var po=class{constructor(e,t,n,s=[],i){this.includePaths=t;this.bindingLoader=n;this._issues=[];this.overlayParsers=[];this.overlays=[];this.overlays=Array.isArray(s)?s:[s],this.overlays.filter(VE.existsSync),this.parser=new Oa(e,t),this.name=i??(0,WE.basename)(e),this.parser.stable.then(()=>{this.overlayParsers=this.overlays?.map(o=>new Oa(o,t,this.parser.cPreprocessorParser.macros))??[]})}async getContextIssues(){return[...(await this.getRuntime()).issues,...this._issues]}async stable(){await Promise.all([this.parser.stable,...this.overlayParsers.map(e=>e.stable)])}async getRuntime(){return await this.stable(),this._runtime??=this.evaluate(),this._runtime}getContextFiles(){return[...this.overlayParsers.map(e=>e.uri),this.parser.uri,...this.parser.cPreprocessorParser.dtsIncludes.flatMap(e=>e.resolvedPath).filter(e=>!!e)]}isInContext(e){return this.getContextFiles().some(t=>t===e)}async getAllParsers(){return await this.stable(),[this.parser,...this.overlayParsers]}async getDocumentLinks(e,t){if(!this.isInContext(e))return[];let s=(await this.getRuntime()).rootNode.allBindingsProperties.filter(i=>i.ast.uri===e&&(!t||Tr(i.ast,e,t))).flatMap(i=>i.ast.values?.values.flatMap(o=>{let c=i.parent?.nodeTypes.find(l=>o?.value instanceof Oe&&l.compatible===o.value.value);return c?{range:Q(o.value),target:ce(c.bindingsPath)}:void 0})).filter(i=>i)??[];return[...this.parser.cPreprocessorParser.dtsIncludes.filter(i=>i.uri===e&&(!t||Tr(i,e,t))).map(i=>{let o=this.parser.cPreprocessorParser.resolveInclude(i);if(o)return{range:Q(i.path),target:ce(o)}}).filter(i=>i)??[],...s]}linkPropertiesLabelsAndNodePaths(e){let t=i=>[...i.property,...i.nodes.flatMap(t)],n=t(e.rootNode),s=e.rootNode.allDescendantsLabels;n.forEach(i=>i.ast.allDescendants.forEach(o=>{if(o instanceof _e){let a=e.resolvePath([`&${o.label?.value}`],s);if(a){let c=e.rootNode.getChild(a);o.linksTo=c,c?.linkedRefLabels.push(o)}else o.value&&this._issues.push(C(3,o,ho.DiagnosticSeverity.Error,[],[],[o.value]))}else if(o instanceof $n){let a=e.rootNode,c=o.pathParts;for(let l=0;l<c.length&&c[l];l++){let u=!1,d=c[l];if(d){let f=a?.getNode(d.name,d.address?.map(p=>p.address),!1);d.linksTo=f,!u&&!f&&(u=!0,this._issues.push(C(8,d,ho.DiagnosticSeverity.Error,[],[],[d.toString(),`${o.pathParts.filter(p=>p?.linksTo).map(p=>p?.toString()).join("/")}`]))),f?.linkedNodeNamePaths.push(d),a=f}else break}}}))}async reevaluate(e){return this.isInContext(e)?(await this.parser.reparse(),this._runtime=this.evaluate(),this._runtime):this._runtime}async evaluate(){let e=performance.now();await this.stable();let t=new sd(this);this._issues=[],this.processRoot(this.parser.rootDocument,t);for(let n=0;n<this.overlayParsers.length;n++)this.processRoot(this.overlayParsers[n].rootDocument,t);return t.includes=this.parser.includes,t.comments=this.parser.cPreprocessorParser.allAstItems.filter(n=>n instanceof mn),(await this.getAllParsers()).flatMap(n=>n.tokens).forEach((n,s)=>n.sortKey=s),this.linkPropertiesLabelsAndNodePaths(t),console.log("evaluate",performance.now()-e),t}processRoot(e,t){for(let n=0;n<e.children.length;n++){let s=e.children[n];this.processChild(s,t.rootNode,t)}}processChild(e,t,n){e instanceof qe?this.processDtcBaseNode(e,t,n):e instanceof Ae?this.processDtcProperty(e,t,n):e instanceof ur?this.processDeleteNode(e,t,n):e instanceof Ue&&this.processDeleteProperty(e,t,n)}checkNodeUniqueNames(e,t){let n=(o,a)=>o.some(c=>c.name===a.name&&(c.address===void 0||a.address===void 0||c.address.every((l,u)=>a.address?.at(u)?.address===l))),s=t.nodes.map(o=>({name:o.name,address:o.address})),i=[];e.children.forEach(o=>{if(o instanceof Re&&o.name)n(i.map(a=>({name:a.name,address:a.address?.map(c=>c.address)})),o.name)&&this._issues.push(C(2,o.name)),i.push(o.name);else if(o instanceof ur&&o.nodeNameOrRef instanceof je){let a=o.nodeNameOrRef;n(s,a)&&(i=i.filter(c=>n(i.map(l=>({name:l.name,address:l.address?.map(u=>u.address)})),c)))}})}processDtcBaseNode(e,t,n){e instanceof dt?this.processDtcRootNode(e,n):e instanceof Re?this.processDtcChildNode(e,t,n):e instanceof Rt&&this.processDtcRefNode(e,n)}processDtcRootNode(e,t){t.roots.push(e),t.rootNode.definitions.push(e),this.checkNodeUniqueNames(e,t.rootNode),[...e.children].sort((n,s)=>n instanceof Ae&&s instanceof Ue||s instanceof Ae&&n instanceof Ue?0:s instanceof Ae?1:0).forEach(n=>this.processChild(n,t.rootNode,t))}processDtcChildNode(e,t,n){if(e.name?.name){let s=e.path?n.resolvePath(e.path):void 0,o=(s?n.rootNode.getChild(s):void 0)??new Ee(this.bindingLoader,e.name.name,e.name.address?.map(a=>a.address),t);o.definitions.push(e),e.labels.forEach(a=>a.lastLinkedTo=o),t=o,this.checkNodeUniqueNames(e,o)}[...e.children].sort((s,i)=>s instanceof qe&&i instanceof qe?0:s instanceof qe?-1:0).forEach(s=>this.processChild(s,t,n))}processDtcRefNode(e,t){let n;if(e.labelReference){let s=e.resolveNodePath??(e.pathName?t.resolvePath([e.pathName]):void 0);s?(e.resolveNodePath??=[...s],n=t.rootNode.getChild(s),e.labelReference.linksTo=n,e.labels.forEach(i=>i.lastLinkedTo=n),n?.linkedRefLabels.push(e.labelReference),n?.referencedBy.push(e),e.labels.forEach(i=>{t.labelsUsedCache.set(i.label.value,s)}),n?(t.references.push(e),this.checkNodeUniqueNames(e,n)):t.unlinkedRefNodes.push(e)):(this._issues.push(C(3,e.labelReference,ho.DiagnosticSeverity.Error,[],[],[e.labelReference.label?.value??""])),t.unlinkedRefNodes.push(e))}else t.unlinkedRefNodes.push(e);[...e.children].sort((s,i)=>s instanceof qe&&i instanceof qe?0:s instanceof qe?-1:0).forEach(s=>this.processChild(s,n??new Ee(this.bindingLoader,""),t))}processDtcProperty(e,t,n){e.propertyName?.name&&t.addProperty(new Xe(e,t)),e.children.forEach(s=>this.processChild(s,t,n))}processDeleteNode(e,t,n){if(e.nodeNameOrRef instanceof je&&e.nodeNameOrRef.value){if(e.parentNode?.parentNode)if(!t.hasNode(e.nodeNameOrRef.name,e.nodeNameOrRef.address?.map(s=>s.address)))this._issues.push(C(5,e.nodeNameOrRef));else{t.deletes.push(e);let s=t.getNode(e.nodeNameOrRef.name,e.nodeNameOrRef.address?.map(i=>i.address));e.nodeNameOrRef.linksTo=s,t.deleteNode(e.nodeNameOrRef.name,e,e.nodeNameOrRef.address?.map(i=>i.address)),s?.labels.forEach(i=>{n.labelsUsedCache.delete(i.label.value)})}}else if(e.nodeNameOrRef instanceof _e&&e.nodeNameOrRef.value){let s=n.resolvePath([`&${e.nodeNameOrRef.value}`]),i;s?(i=n.rootNode.getChild(s),t.deletes.push(e),e.nodeNameOrRef.linksTo=i,i?.labels.forEach(o=>{n.labelsUsedCache.delete(o.label.value)}),i?.linkedRefLabels.push(e.nodeNameOrRef),i?.parent?.deleteNode(i.name,e,i.address),e.parentNode instanceof qe&&!e.parentNode.pathName&&n.globalDeletes.push(e)):(n.unlinkedDeletes.push(e),this._issues.push(C(3,e.nodeNameOrRef,ho.DiagnosticSeverity.Error,[],[],[e.nodeNameOrRef.value])))}else if(e.nodeNameOrRef instanceof Gr&&e.nodeNameOrRef.path&&!e.nodeNameOrRef.path.pathParts.some(s=>!s)){let s=["/",...e.nodeNameOrRef.path.pathParts.map(u=>u.toString())],i=n.rootNode,o=e.nodeNameOrRef.path.pathParts;for(let u=0;u<o.length&&o[u];u++){let d=o[u];if(d){let f=i?.getNode(d.name,d.address?.map(p=>p.address),!1);d.linksTo=f,f?.linkedNodeNamePaths.push(d),i=f}}let a=e.nodeNameOrRef.path.pathParts.every(u=>u),c=e.nodeNameOrRef.path.pathParts.find(u=>u&&!u.linksTo),l=e.nodeNameOrRef.path.pathParts.at(-1)?.linksTo;l||(n.unlinkedDeletes.push(e),c&&this._issues.push(C(8,c,ho.DiagnosticSeverity.Error,[],[],[c.toString(),`${e.nodeNameOrRef.path.pathParts.filter(u=>u?.linksTo).map(u=>u?.toString()).join("/")}`]))),t.deletes.push(e),l?.labels.forEach(u=>{n.labelsUsedCache.delete(u.label.value)}),l?.parent?.deleteNode(l.name,e,l.address),e.parentNode instanceof qe&&!e.parentNode.pathName&&n.globalDeletes.push(e)}else n.unlinkedDeletes.push(e);e.children.forEach(s=>this.processChild(s,t,n))}processDeleteProperty(e,t,n){e.propertyName?.name&&!t.hasProperty(e.propertyName.name)?this._issues.push(C(1,e.propertyName)):e.propertyName?.name&&(t.deletes.push(e),t.deleteProperty(e.propertyName.name,e)),e.children.forEach(s=>this.processChild(s,t,n))}};var ft=z(J());var HE=require("fs"),mo=require("path");function nx(r){if(!r||!(r.ast instanceof ro))return[];let e=n=>n.flatMap(s=>(0,HE.readdirSync)(s,{withFileTypes:!0,recursive:!0}).filter(i=>i.name.toLowerCase().endsWith(".dtsi")||i.name.toLowerCase().endsWith(".h")).map(i=>({label:`${(0,mo.join)((0,mo.relative)(s,i.parentPath),i.name)}`,kind:ft.CompletionItemKind.File})));if(r.ast.relative)return e([(0,mo.dirname)(r.ast.uri)]);let t=r.runtime.context.includePaths;return e(t)}var ud=(r,e)=>[...r.labels.filter(e),...r.deletedNodes.filter(t=>!e(t.by)).flatMap(t=>ud(t.node,e)),...r.nodes.flatMap(t=>ud(t,e))],Om=(r,e)=>[...r.labels,...r.deletedNodes.filter(t=>!e(t.by)).flatMap(t=>Om(t.node,e)),...r.nodes.flatMap(t=>Om(t,e))];function sx(r,e){if(!r||!(r.item instanceof Xe)||!(r.ast instanceof _e))return[];let t=n=>Om(n,e);return Array.from(new Set(t(r.runtime.rootNode).map(n=>n.label.value))).map(n=>({label:`${n}`,kind:ft.CompletionItemKind.Method}))}function ix(r,e){if(!r||r.item!==null||!(r.ast instanceof _e)||!(r.ast.parentNode instanceof Rt))return[];let t=n=>ud(n,e).filter(s=>e(s));return[...Array.from(new Set(t(r.runtime.rootNode).map(n=>n.label.value))).map(n=>({label:n,insertText:`${n} {
|
|
256
|
+
`)&&this.lines.splice(-1,1),this.lexIt()}get tokens(){return this._tokens}isWhiteSpace(){return!!this.currentChar?.match(/\s/)}get endOfFile(){return this.isOnLastLine&&this.isOnLastCharOfLine}get isOnLastLine(){return this.lineNumber===this.lines.length-1}get isOnLastCharOfLine(){return this.lines[this.lineNumber].length<=this.columnNumber}moveToNextLine(){return this.isOnLastLine?!1:(this.columnNumber=0,this.lineNumberOfEscapedChars=0,this.lineNumber++,this.lines[this.lineNumber].length===0&&this.moveToNextLine(),!0)}moveOnLine(){return this.isOnLastCharOfLine?this.moveToNextLine():(this.columnNumber++,this.isOnLastCharOfLine&&this.moveToNextLine(),!0)}move(){return this.endOfFile?!1:this.moveOnLine()}get currentChar(){return this.endOfFile?null:this.lines[this.lineNumber].at(this.columnNumber)}static isSyntaxChar(e){return e==="^"||e==="~"||e==="|"||e==="!"||e==="\\"||e==="<"||e===">"||e===";"||e==="="||e==="/"||e==="{"||e==="}"||e==="["||e==="]"||e==="("||e===")"||e==="*"||e==="%"||e==="&"||e==="."||e===":"||e==="+"||e==="@"||e==="-"||e==="_"||e===","||e==="x"||e==="?"}getWord(){let e="";for(;!this.isWhiteSpace()&&(e.length&&!r.isSyntaxChar(this.currentChar)||!e.length);){if(e+=this.currentChar??"",e.length===1&&r.isSyntaxChar(this.currentChar)){this.move();break}let t=this.lineNumber;if(!this.move()||this.lineNumber!==t)return e}return e==="/"&&this.currentChar==="*"?this.inComment=!0:this.inComment&&e==="*"&&this.currentChar==="/"&&(this.inComment=!1),e}getString(e){let t=e;for(this.numberOfEscapedCharsLastString=0;this.currentChar!==e;){if(t+=this.currentChar??"",this.currentChar==="\\"){let n=this.lineNumber;if(this.move())this.lineNumberOfEscapedChars++,this.numberOfEscapedCharsLastString++,n===this.lineNumber&&(t+=this.currentChar??"");else return t}if(!this.move())return t}return this.move(),t+=e,t}lexIt(){for(;!this.endOfFile&&(this.whiteSpace(),!this.endOfFile);){let e=this.getWord();e&&this.process(e)}}process(e){let t=this.isString(e)||this.isCDefine(e)||this.isCInclude(e)||this.isCLine(e)||this.isCUndef(e)||this.isCError(e)||this.isCPragma(e)||this.isCDefined(e)||this.isCIfDef(e)||this.isCIfNDef(e)||this.isCIf(e)||this.isCElIf(e)||this.isCElse(e)||this.isCEndIf(e)||this.isCFalse(e)||this.isCTrue(e)||this.isDigit(e)||this.isHexDigit(e)||this.isLetters(e)||this.isComma(e)||this.isBitwiseNot(e)||this.isBitwiseXOr(e)||this.isBitwiseOr(e)||this.isLogicalNot(e)||this.isGtSym(e)||this.isLtSym(e)||this.isSemicolon(e)||this.isColon(e)||this.isAssignOperator(e)||this.isForwardSlash(e)||this.isRoundOpen(e)||this.isRoundClose(e)||this.isCurlyOpen(e)||this.isCurlyClose(e)||this.isSquareOpen(e)||this.isSquareClose(e)||this.isBackSlash(e)||this.isMultiplicationOperator(e)||this.isModulusOperator(e)||this.isAmpersand(e)||this.isNegateOperator(e)||this.isAddOperator(e)||this.isQuestionMark(e)||this.isPeriod(e)||this.isHash(e)||this.isUnderScore(e)||this.isAt(e)||this.unknownToken(e);if(!t)throw new Error(`Lexer is not complete!!! Could not find token for "${e}"`);let n=this._tokens.at(-1);return t&&!n?.tokens.some(s=>s===21)&&n&&n.pos.len<e.length?this.process(e.slice(n.pos.len)):!0}whiteSpace(){for(;this.isWhiteSpace();)this.move()}pushToken(e){let t={...e,uri:this.uri},n=this._tokens.at(-1);t.prevToken=n,n&&(n.nextToken=t),this._tokens.push(t)}isLetters(e){let t=e.match(/^[A-Za-z]+/);return t?.[0]?(this.pushToken({tokens:[47],value:t?.[0],pos:this.generatePos(e,t?.[0])}),!0):!1}isDigit(e){let t=e.match(/^[0-9]/);return t?.[0]?(this.pushToken({tokens:[20,19],value:t[0],pos:this.generatePos(e,t[0])}),!0):!1}isHexDigit(e){let t=e.match(/^[A-Fa-f]/);return t?.[0]?(this.pushToken({tokens:[20,47],value:t[0],pos:this.generatePos(e,t[0])}),!0):!1}isCurlyOpen(e){let t="{";return e===t?(this.pushToken({tokens:[2],pos:this.generatePos(e,t),value:"{"}),!0):!1}isCurlyClose(e){let t="}";return e===t?(this.pushToken({tokens:[3],pos:this.generatePos(e,t),value:"}"}),!0):!1}isSemicolon(e){let t=";";return e===t?(this.pushToken({tokens:[1],pos:this.generatePos(e,t),value:t}),!0):!1}isColon(e){let t=":";return e===t?(this.pushToken({tokens:[50],pos:this.generatePos(e,t),value:t}),!0):!1}isHash(e){let t="#";return e.startsWith(t)?(this.pushToken({tokens:[46],pos:this.generatePos(e,t),value:t}),!0):!1}unknownToken(e){return this.pushToken({tokens:[41],pos:this.generatePos(e," "),value:e}),!0}isAssignOperator(e){let t="=";return e===t?(this.pushToken({tokens:[0],pos:this.generatePos(e,t),value:t}),!0):!1}isGtSym(e){let t=">";return e===t?(this.pushToken({tokens:[4],pos:this.generatePos(e,t),value:t}),!0):!1}isLtSym(e){let t="<";return e===t?(this.pushToken({tokens:[5],pos:this.generatePos(e,t),value:t}),!0):!1}isLogicalNot(e){let t="!";return e===t?(this.pushToken({tokens:[6],pos:this.generatePos(e,t),value:t}),!0):!1}isBitwiseOr(e){let t="|";return e===t?(this.pushToken({tokens:[8],pos:this.generatePos(e,t),value:t}),!0):!1}isBitwiseXOr(e){let t="^";return e===t?(this.pushToken({tokens:[9],pos:this.generatePos(e,t),value:t}),!0):!1}isAmpersand(e){let t="&";return e===t?(this.pushToken({tokens:[40,7],pos:this.generatePos(e,t),value:t}),!0):!1}isBitwiseNot(e){let t="~";return e===t?(this.pushToken({tokens:[10],pos:this.generatePos(e,t),value:t}),!0):!1}isRoundOpen(e){let t="(";return e===t?(this.pushToken({tokens:[42],pos:this.generatePos(e,t),value:t}),!0):!1}isRoundClose(e){let t=")";return e===t?(this.pushToken({tokens:[43],pos:this.generatePos(e,t),value:t}),!0):!1}isSquareOpen(e){let t="[";return e===t?(this.pushToken({tokens:[11],pos:this.generatePos(e,t),value:t}),!0):!1}isSquareClose(e){let t="]";return e===t?(this.pushToken({tokens:[12],pos:this.generatePos(e,t),value:t}),!0):!1}isComma(e){let t=",";return e===t?(this.pushToken({tokens:[24],pos:this.generatePos(e,t),value:t}),!0):!1}rewind(e){if(this.columnNumber+1<e.length)throw new Error("Error while rewinding");this.columnNumber-=e.length}isString(e){if(this.inComment)return!1;let t=e.match(/^["']/);if(t?.[0]){this.rewind(e.slice(1));let n=this.lineNumber,s=this.columnNumber,i=this.getString(t[0]);return this.pushToken({tokens:[21],value:i,pos:{col:s-1,line:n,len:i.length+this.numberOfEscapedCharsLastString}}),!0}return!1}isForwardSlash(e){let t="/";return e===t?(this.pushToken({tokens:[13],pos:this.generatePos(e,t),value:"/"}),!0):!1}isBackSlash(e){let t="\\";return e===t?(this.pushToken({tokens:[14],pos:this.generatePos(e,t),value:"\\"}),!0):!1}isAddOperator(e){let t="+";return e===t?(this.pushToken({tokens:[15],pos:this.generatePos(e,t),value:t}),!0):!1}isQuestionMark(e){let t="?";return e===t?(this.pushToken({tokens:[44],pos:this.generatePos(e,t),value:t}),!0):!1}isPeriod(e){let t=".";return e===t?(this.pushToken({tokens:[45],pos:this.generatePos(e,t),value:t}),!0):!1}isNegateOperator(e){let t="-";return e===t?(this.pushToken({tokens:[16],pos:this.generatePos(e,t),value:t}),!0):!1}isUnderScore(e){let t="_";return e===t?(this.pushToken({tokens:[48],pos:this.generatePos(e,t),value:t}),!0):!1}isAt(e){let t="@";return e===t?(this.pushToken({tokens:[49],pos:this.generatePos(e,t),value:t}),!0):!1}isMultiplicationOperator(e){let t="*";return e===t?(this.pushToken({tokens:[17],pos:this.generatePos(e,t),value:t}),!0):!1}isModulusOperator(e){let t="%";return e===t?(this.pushToken({tokens:[18],pos:this.generatePos(e,t),value:t}),!0):!1}isCDefine(e){let t="#define";return e.toLowerCase()===t?(this.pushToken({tokens:[25],pos:this.generatePos(e,t),value:t}),!0):!1}isCInclude(e){let t="#include";return e.toLowerCase()===t?(this.pushToken({tokens:[26],pos:this.generatePos(e,t),value:t}),!0):!1}isCLine(e){let t="#line";return e.toLowerCase()===t?(this.pushToken({tokens:[27],pos:this.generatePos(e,t),value:t}),!0):!1}isCUndef(e){let t="#undef";return e.toLowerCase()===t?(this.pushToken({tokens:[28],pos:this.generatePos(e,t),value:t}),!0):!1}isCError(e){let t="#error";return e.toLowerCase()===t?(this.pushToken({tokens:[29],pos:this.generatePos(e,t),value:t}),!0):!1}isCPragma(e){let t="#pragma";return e.toLowerCase()===t?(this.pushToken({tokens:[30],pos:this.generatePos(e,t),value:t}),!0):!1}isCDefined(e){let t="#defined";return e.toLowerCase()===t?(this.pushToken({tokens:[31],pos:this.generatePos(e,t),value:t}),!0):!1}isCIf(e){let t="#if";return e.toLowerCase()===t?(this.pushToken({tokens:[32],pos:this.generatePos(e,t),value:t}),!0):!1}isCIfDef(e){let t="#ifdef";return e.toLowerCase()===t?(this.pushToken({tokens:[33],pos:this.generatePos(e,t),value:t}),!0):!1}isCIfNDef(e){let t="#ifndef";return e.toLowerCase()===t?(this.pushToken({tokens:[34],pos:this.generatePos(e,t),value:t}),!0):!1}isCElIf(e){let t="#elif";return e.toLowerCase()===t?(this.pushToken({tokens:[35],pos:this.generatePos(e,t),value:t}),!0):!1}isCElse(e){let t="#else";return e.toLowerCase()===t?(this.pushToken({tokens:[36],pos:this.generatePos(e,t),value:t}),!0):!1}isCEndIf(e){let t="#endif";return e.toLowerCase()===t?(this.pushToken({tokens:[37],pos:this.generatePos(e,t),value:t}),!0):!1}isCTrue(e){let t="true";return e==t?(this.pushToken({tokens:[38],value:t,pos:this.generatePos(e,t)}),!0):!1}isCFalse(e){let t="false";return e==t?(this.pushToken({tokens:[39],value:t,pos:this.generatePos(e,t)}),!0):!1}generatePos(e,t){return{line:this.lineNumber,col:this.columnNumber-e.length+this.lineNumberOfEscapedChars,len:t.length}}};var Qe=class extends F{constructor(e){super(e),this.semanticTokenType="keyword",this.semanticTokenModifiers="declaration"}};var Rm=require("fs"),uo=require("path");var AE=z(J());var $t=class extends zr{constructor(t,n){super(n);this.name=t;this.docSymbolsMeta={name:this.name.toString(),kind:AE.SymbolKind.Variable},this.semanticTokenType="macro",this.semanticTokenModifiers="declaration"}toString(){return this.name}};var Ju=class extends F{constructor(t,n){super(n);this.operator=t;this.semanticTokenType="operator",this.semanticTokenModifiers="declaration"}toString(){return this.operator}};var IE=z(J());var Xu=class extends Qe{toString(){return"..."}},fs=class extends F{constructor(t,n){super();this.functionName=t;this.params=n;this.addChild(t),this.params.forEach(s=>this.addChild(s))}getDocumentSymbols(t){return this.uri!==t?[]:[{name:this.functionName.name,kind:IE.SymbolKind.Function,range:Q(this),selectionRange:Q(this),children:this.params.flatMap(n=>n.getDocumentSymbols(t))}]}toString(){return`${this.functionName}(${this.params.map(t=>t.toString()).join(",")})`}};var Pm=z(J());var gn=class extends zr{constructor(t,n,s){super(n);this.value=t;this.docSymbolsMeta={name:`param${s+1}`,kind:Pm.SymbolKind.Variable},this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.value}},hs=class extends zr{constructor(t,n){super();this.functionName=t;this.params=n;this.addChild(t),this.params.forEach(s=>this.addChild(s))}getDocumentSymbols(t){return this.uri!==t?[]:[{name:this.functionName.name,kind:Pm.SymbolKind.Function,range:Q(this),selectionRange:Q(this),children:this.params.flatMap(n=>n?.getDocumentSymbols(t)??[])}]}toString(){return`${this.functionName.toString()}(${this.params.map(t=>t?.toString()??"<NULL>").join(",")})`}isTrue(t){return this.functionName.name==="defined"?!!(this.params.length===1&&this.params[0]&&t.has(this.params[0].value)):super.isTrue(t)}};var ps=class{constructor(){this.positionStack=[];this._issues=[];this.issueLengthPositionStack=[];this.moveEndOfLine=(e,t=!0)=>{let n=e.pos.line;if(this.currentToken?.pos.line!==n||this.currentToken?.uri!==e.uri)return;let s=this.currentToken,i=s;for(;this.currentToken?.pos.line===n;)i=this.moveToNextToken;if(t){let o=new F(G(s,i));this._issues.push(C(22,o))}return i};this.parsing=new Promise(e=>{setTimeout(()=>{this.parse().then(e)})})}reset(){this.issueLengthPositionStack=[],this.positionStack=[],this._issues=[]}get issues(){return this._issues}get stable(){return this.parsing}get done(){return this.peekIndex()>=this.tokens.length}get moveToNextToken(){let e=this.currentToken;if(e)return this.moveStackIndex(),e}enqueueToStack(){this.issueLengthPositionStack.push(this._issues.length),this.positionStack.push(this.peekIndex())}popStack(){let e=this.issueLengthPositionStack.pop()??0;e!==this._issues.length&&this._issues.splice(e),this.positionStack.pop()}mergeStack(){let e=this.issueLengthPositionStack.pop(),t=this.positionStack.pop();if(t===void 0||e===void 0)throw new Error("Index out of bounds");this.positionStack[this.positionStack.length-1]=t}peekIndex(e=1){let t=this.positionStack.at(-1*e);if(t===void 0)throw new Error("Index out of bounds");return t}get currentToken(){return this.tokens.at(this.peekIndex())}get prevToken(){let e=this.peekIndex()-1;if(e!==-1)return this.tokens[e]}moveStackIndex(){let e=this.positionStack.length-1;if(this.positionStack[e]===void 0)throw new Error("Index out of bounds");this.positionStack[e]!==this.tokens.length&&this.positionStack[e]++}checkConcurrentTokens(e){this.enqueueToStack();let t=[];return e.every(n=>{let s=this.currentToken,i=n(s),o=!1;return i!=="no"&&s&&(t.push(s),this.moveToNextToken,o=Xt(s,this.currentToken)),i==="yes"&&o}),this.mergeStack(),t}consumeAnyConcurrentTokens(e){this.enqueueToStack();let t=[],n,s=!0;for(;e.some(i=>i(this.currentToken)==="yes"&&s);)t.push(this.currentToken),n=this.currentToken,this.moveToNextToken,s=Xt(n,this.currentToken);return this.mergeStack(),t}getDocumentSymbols(e){return this.allAstItems.flatMap(t=>t.getDocumentSymbols(e))}getWorkspaceSymbols(){return this.allAstItems.flatMap(e=>e.getWorkspaceSymbols())}buildSemanticTokens(e,t){let n=[],s=(i,o,a)=>{if(!a?.start||!a?.end||a.start.uri!==t||a.end.uri!==t)return;let c=a.end.pos.col-a.start.pos.col+a.end.pos.len;n.push({line:a.start.pos.line,char:a.start.pos.col,length:a.end===a.start?a.end.pos.len:c,tokenType:i,tokenModifiers:o})};this.allAstItems.forEach(i=>{i.buildSemanticTokens(s)}),n.sort((i,o)=>i.line===o.line?i.char-o.char:i.line-o.line).forEach(i=>e.push(i.line,i.char,i.length,i.tokenType,i.tokenModifiers))}processCIdentifier(e,t){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,48].map(Pe));if(!n.length){this.popStack();return}let s=n.map(o=>o.value).join("");if(!s.match(/^[_A-Za-z]/)){this.popStack();return}let i=new $t(s,G(n[0],n.at(-1)));return!t&&i.name!=="defined"&&(e.get(i.name)||this._issues.push(C(42,i))),this.mergeStack(),i}isOperator(){this.enqueueToStack();let e=this.moveToNextToken;if(!e){this.popStack();return}let t=e,n;if($(e,40)?(n="&",$(this.currentToken,40)&&(n="&&",t=this.moveToNextToken)):$(e,10)?(n="!",$(this.currentToken,0)&&(n="!=",t=this.moveToNextToken)):$(e,8)?(n="|",$(this.currentToken,8)&&(n="||",t=this.moveToNextToken)):$(e,9)?n="^":$(e,4)?(n=">",$(this.currentToken,4)?(n="<<",t=this.moveToNextToken):$(this.currentToken,0)&&(n=">=",t=this.moveToNextToken)):$(e,5)?(n="<",$(this.currentToken,5)?(n=">>",t=this.moveToNextToken):$(this.currentToken,0)&&(n="<=",t=this.moveToNextToken)):$(e,15)?n="+":$(e,16)?n="-":$(e,17)?n="*":$(e,13)?n="/":$(e,18)?n="%":$(e,46)?$(this.currentToken,46)&&(n="##",t=this.moveToNextToken):$(e,0)&&$(this.currentToken,0)&&(n="==",t=this.moveToNextToken),n){let s=new Ju(n,G(e,t));return this.mergeStack(),s}this.popStack()}parseScopedBlock(e,t,n){this.enqueueToStack();let s=this.moveToNextToken;if(!s||!e(s)){this.popStack();return}let i=this.peekIndex(),o=()=>{this.positionStack[this.positionStack.length-1]=i},a=p=>p.flatMap(b=>"items"in b?a(b.items):b),c=[s],l=[];l[0]={rewind:o,tokens:[]};let u=this.currentToken;for(;u&&!t(u);){if(n?.(u)){let p=this.peekIndex()+1,b=()=>{this.positionStack[this.positionStack.length-1]=p};c.push(u),l[l.length]={rewind:b,tokens:[]}}else if(e(u)){let p=this.parseScopedBlock(e,t,n);p&&(c.push(p),l[l.length-1].tokens.push(...a(p.items))),u=this.currentToken;continue}else c.push(u),l[l.length-1].tokens.push(u);this.moveToNextToken,u=this.currentToken}let d=u;d&&t(d)&&(this.moveToNextToken,c.push(d));let f={startToken:s,items:c,splitTokens:l,endToken:d};return this.mergeStack(),f}isFunctionCall(e){this.enqueueToStack();let t=this.processCIdentifier(e,!1);if(!t){this.popStack();return}let n=this.processMacroCallParams();if(!n){this.popStack();return}if(t.name==="defined")n.length>1?this._issues.push(C(44,t)):n.length<1&&this._issues.push(C(45,t));else{let i=e.get(t.name)?.macro;i&&(i?.identifier instanceof fs?n.length>i.identifier.params.length?this._issues.push(C(44,t,void 0,[i])):n.length<i.identifier.params.length&&this._issues.push(C(45,t,void 0,[i])):this._issues.push(C(43,t)))}let s=new hs(t,n);return s.lastToken=this.prevToken,this.mergeStack(),s}processHex(){this.enqueueToStack();let e=this.checkConcurrentTokens([Je("0"),Je("x")]);if(e.length!==2){this.popStack();return}let t=this.consumeAnyConcurrentTokens([19,20].map(Pe));if(!t.length){this.popStack();return}let n=Number.parseInt(t.map(i=>i.value).join(""),16),s=new _t(n,G(e[0],t.at(-1)));return this.mergeStack(),s}processDec(){this.enqueueToStack();let e=this.consumeAnyConcurrentTokens([19].map(Pe));if(!e.length){this.popStack();return}let t=Number.parseInt(e.map(s=>s.value).join(""),10),n=new _t(t,G(e[0],e.at(-1)));return this.mergeStack(),n}processEnclosedExpression(e){this.enqueueToStack();let t,n,s;if($(this.currentToken,42))return t=this.moveToNextToken,n=t,s=this.processExpression(e,!0),s&&(s=new Zs(new Zs(s,!0),!1)),$(this.currentToken,43)?n=this.moveToNextToken:this._issues.push(C(26,new F(G(t)))),this.mergeStack(),s;this.popStack()}processExpression(e,t=!1){this.enqueueToStack();let n;if(n=this.processEnclosedExpression(e)||this.isFunctionCall(e)||this.processCIdentifier(e,!1)||this.processHex()||this.processDec(),!n){this.popStack();return}if(t){let s=this.isOperator();for(;s;){let i=this.processExpression(e);i?n instanceof Zs?n.addExpression(s,i):n=new Zs(n,!1,{operator:s,expression:i}):this._issues.push(C(27,s)),s=this.isOperator()}}return this.mergeStack(),n}processMacroCallParams(){if(!$(this.currentToken,42))return;let e=this.parseScopedBlock(n=>!!$(n,42),n=>!!$(n,43),n=>!!$(n,24));return e?.items.length===2&&$(e.endToken,43)?[]:e?.splitTokens.map((n,s)=>n.tokens.length===0?null:new gn(n.tokens.map((i,o)=>{let a=i.value;return i.pos.line===n.tokens.at(o+1)?.pos.line&&(a=a.padEnd(n.tokens[o+1].pos.col-i.pos.col," ")),a}).join(""),G(n.tokens[0],n.tokens.at(-1)),s))}};var Zu=class r extends ps{constructor(t){super();this.uri=t;this.comments=[];this.tokens=[]}cleanUpComments(){let t=[];for(let n=0;n<this.tokens.length;n++){let s=r.processBlockComments(this.tokens,n)||r.processLineComments(this.tokens,n);s&&(n=s.index,t.push(...s.tokenUsed),this.comments.push(...s.comments))}t.reverse().forEach(n=>this.tokens.splice(n,1))}get allAstItems(){return this.comments}reset(){super.reset(),this.comments=[]}reparse(){return this.reset(),this.parse()}async parse(){this.tokens=Xr().requestTokens(this.uri,!0),this.cleanUpComments()}static processBlockComments(t,n){let s=[],i=()=>(s.push(n++),t[n]),o=()=>t[n],a=()=>t[n-1],c=o(),l=c;if(!c||!$(c,13)||(l=i(),!$(l,17)||c.pos.line!==l.pos.line||c.pos.col+1!==l.pos.col))return;let u=()=>!(!$(a(),17)||!$(o(),13)||!Xt(a(),o())),d=l.pos.line,f=c,p=[];l=i();do{if(o()?.pos.line!==d){let g=new mn(G(f,a()));p.push(g),d=o().pos.line??0,f=o()}l=i()}while(n<t.length&&!u());let b=new mn(G(f,o()));return p.push(b),i(),{comments:p,tokenUsed:s,index:n-1}}static processLineComments(t,n){let s=[];if(!$(t[n],13)||t.length===n+1||!$(t[n+1],13)||!Xt(t[n],t[n+1]))return;let i=[];for(;t[n].pos.line===t.at(n+1)?.pos.line;)s.push(n++);s.push(n++);let o=t[s.at(-1)],a=new mn(G(t[s[0]],t[s.at(-1)]));return i.push(a),{comments:i,tokenUsed:s,index:n-1}}};var ME=z(J()),ed=class extends F{constructor(t,n){super(t);this.content=n}toString(){let t=this.content.filter(n=>!$(n,14));return t.map((n,s)=>{let i=n.value;return n.pos.line===t.at(s+1)?.pos.line?i=i.padEnd(t[s+1].pos.col-n.pos.col," "):t.at(s+1)&&(i=i.padEnd(i.length+1," ")),i}).join("")}},Ea=class extends F{constructor(t,n,s){super();this.keyword=t;this.identifier=n;this.content=s;this.addChild(t),this.addChild(this.identifier),this.content&&this.addChild(this.content)}get name(){return this.identifier instanceof $t?this.identifier.name:this.identifier.functionName.name}toString(){return this.toStringCache??=[this.identifier.toString(),...this.content?[this.content?.toString()]:[]].join(" "),this.toStringCache}toMarkupContent(){return{kind:ME.MarkupKind.Markdown,value:["```cpp",`#define ${this.toString()}`,"```"].join(`
|
|
257
|
+
`)}}};var ri=class extends F{constructor(e){super(e)}},Na=class extends F{constructor(t,n){super();this.keyword=t;this.content=n;this.active=!1;this.addChild(t)}},Pa=class extends Na{constructor(t,n,s){super(t,s);this.identifier=n;this.addChild(n),this.addChild(s)}useBlock(t){return this.identifier&&t.has(this.identifier.name)}},td=class extends Na{constructor(t,n,s){super(t,s);this.expression=n;this.addChild(n),this.addChild(s)}useBlock(t){return this.expression instanceof hs?this.expression.functionName.name==="defined"?this.expression&&t.has(this.expression.params.at(0)?.value??""):this.expression.isTrue(t):this.expression?.isTrue(t)}},rd=class extends Pa{useBlock(e){return this.identifier&&!e.has(this.identifier.name)}},Ra=class extends Na{};var lo=class extends F{constructor(t,n,s){super();this.ifDef=t;this.endIf=n;this.elseOption=s;this.addChild(t),s&&this.addChild(s),this.addChild(n)}getInValidTokenRange(t,n){let s=[],i=a=>n.findIndex(c=>c===a);if(!this.ifDef.identifier)return[{start:i(this.tokenIndexes.start),end:i(this.tokenIndexes.end)}];s.push({start:i(this.ifDef.tokenIndexes.start),end:i(this.ifDef.identifier.tokenIndexes.end)});let o=this.ifDef.useBlock(t);return o?this.ifDef.active=!0:this.elseOption&&(this.elseOption.active=!0),!o&&this.ifDef.content&&s.push({start:i(this.ifDef.content.tokenIndexes.start),end:i(this.ifDef.content.tokenIndexes.end)}),this.elseOption&&(s.push({start:i(this.elseOption.tokenIndexes.start),end:i(this.elseOption.keyword.tokenIndexes.end)}),o&&this.elseOption.content&&s.push({start:i(this.elseOption.content.tokenIndexes.start),end:i(this.elseOption.content.tokenIndexes.end)})),this.endIf&&s.push({start:i(this.endIf.tokenIndexes.start),end:i(this.endIf.tokenIndexes.end)}),s}},ms=class extends F{constructor(t,n,s){super();this.ifBlocks=t;this.endIf=n;this.elseOption=s;t.forEach(i=>this.addChild(i)),s&&this.addChild(s),this.addChild(n)}getInValidTokenRange(t,n){let s=[],i=a=>n.findIndex(c=>c===a),o=!1;return this.ifBlocks.forEach((a,c)=>{s.push({start:i(a.tokenIndexes.start),end:i(a.expression?.tokenIndexes.end??a.keyword.tokenIndexes.end)}),!o&&a.useBlock(t)?(a.active=!0,o=!0):a.content&&s.push({start:i(a.content.tokenIndexes.start),end:i(a.content.tokenIndexes.end)})}),this.elseOption&&(s.push({start:i(this.elseOption.keyword.tokenIndexes.start),end:i(this.elseOption.keyword.tokenIndexes.end)}),o&&this.elseOption.content?s.push({start:i(this.elseOption.content.tokenIndexes.start),end:i(this.elseOption.content.tokenIndexes.end)}):this.elseOption.active=!0),this.endIf&&s.push({start:i(this.endIf.tokenIndexes.start),end:i(this.endIf.tokenIndexes.end)}),s}};var Ca=z(J());var fo=class extends ps{constructor(t,n,s){super();this.uri=t;this.incudes=n;this.tokens=[];this.nodes=[];this.dtsIncludes=[];this.macroSnapShot=new Map;this.macros=new Map;this.macroStart=!1;s&&(Array.from(s).forEach(([i,o])=>this.macroSnapShot.set(i,o)),Array.from(s).forEach(([i,o])=>this.macros.set(i,o)))}get currentToken(){let t=this.prevToken,n=pn(t,this.tokens.at(this.peekIndex()))||!t||$(t,14)&&t.pos.line+1===this.tokens.at(this.peekIndex())?.pos.line;if(!(this.macroStart&&!n))return this.macroStart&&$(this.tokens.at(this.peekIndex()),14)?(this.moveStackIndex(),this.currentToken):this.tokens.at(this.peekIndex())}reset(t){super.reset(),this.macros.clear(),t?(this.macroSnapShot.clear(),Array.from(t).forEach(([n,s])=>this.macroSnapShot.set(n,s)),Array.from(t).forEach(([n,s])=>this.macros.set(n,s))):Array.from(this.macroSnapShot).forEach(([n,s])=>this.macros.set(n,s)),this.nodes=[],this.dtsIncludes=[]}async reparse(t){let n=this.stable;return this.parsing=new Promise(s=>{n.then(()=>{if(t&&t.size===this.macroSnapShot.size){let i=Array.from(t);if(Array.from(this.macroSnapShot).every(([o,a],c)=>{let[l,u]=i[c];return l===o&&u.macro.toString()===a.macro.toString()})){console.log("header file cache hit",this.uri),s();return}}this.reset(t),this.parse().then(s)})}),this.parsing}async parse(){let t=new Zu(this.uri);if(await t.stable,this.tokens=t.tokens,this.nodes.push(...t.allAstItems),this.positionStack.push(0),this.tokens.length!==0){for(;!this.done;)await this.lineProcessor();if(this.positionStack.length!==1)throw new Error("Incorrect final stack size")}}async lineProcessor(){if(this.enqueueToStack(),!(!this.prevToken||this.prevToken.pos.line!==this.currentToken?.pos.line||this.prevToken.uri!==this.currentToken?.uri)){this.moveEndOfLine(this.prevToken,!1),this.mergeStack();return}let n=this.currentToken,s=await this.processInclude()||this.processDefinitions()||this.processUndef()||this.processIfDefBlocks();n&&this.moveEndOfLine(n,!!s),this.mergeStack()}processDefinitions(){this.enqueueToStack();let t=this.peekIndex(),n=this.moveToNextToken;if(!n||!$(n,25))return this.popStack(),!1;this.macroStart=!0;let s=new Qe(G(n)),i=this.isFunctionDefinition()||this.processCIdentifier(this.macros,!0);if(!i)return this._issues.push(C(30,s)),this.mergeStack(),this.macroStart=!1,!0;let o=this.consumeDefinitionContent(),a;o.length&&(a=new ed(G(o[0],o.at(-1)),o));let c=new Ea(s,i,a);this.macros.set(c.name,{macro:c,resolver:Aw(c.toString())}),this.nodes.push(c);let l=this.peekIndex();return this.tokens.splice(t,l-t),this.positionStack[this.positionStack.length-1]=t,this.mergeStack(),this.macroStart=!1,!0}processUndef(){this.enqueueToStack();let t=this.peekIndex(),n=this.moveToNextToken;if(!n||!$(n,28))return this.popStack(),!1;this.macroStart=!0;let s=new Qe(G(n)),i=this.processCIdentifier(this.macros,!0);if(!i)return this._issues.push(C(30,s)),this.mergeStack(),this.macroStart=!1,!0;let o=new Ea(s,i);this.macros.delete(i.name),this.nodes.push(o);let a=this.peekIndex();return this.tokens.splice(t,a-t),this.positionStack[this.positionStack.length-1]=t,this.mergeStack(),this.macroStart=!1,!0}consumeDefinitionContent(){let t=[];for(;this.currentToken;){let n=this.moveToNextToken;n&&t.push(n)}return t}isFunctionDefinition(){this.enqueueToStack();let t=this.processCIdentifier(this.macros,!0);if(!t){this.popStack();return}let n=this.moveToNextToken;if(!$(n,42)||!Xt(t.lastToken,n)){this.popStack();return}let s=[],i=this.processCIdentifier(this.macros,!0)||this.processVariadic();for(;i;)s.push(i),!$(this.currentToken,24)&&!$(this.currentToken,43)?this._issues.push(C(28,i)):$(this.currentToken,43)||(n=this.moveToNextToken),i=this.processCIdentifier(this.macros,!0)||this.processVariadic();let o=new fs(t,s);return $(this.currentToken,43)?(n=this.moveToNextToken,o.lastToken=n):(o.lastToken=this.prevToken,this._issues.push(C(26,s.at(-1)??o))),this.mergeStack(),o}processVariadic(){this.enqueueToStack();let t=this.checkConcurrentTokens([Pe(45),Pe(45),Pe(45)]);if(t.length!==3){this.popStack();return}let n=new Xu(G(t[0],t.at(-1)));return this.mergeStack(),n}processIfDefBlocks(){let t=this.peekIndex(),n=this.parseScopedBlock(o=>!!o&&[33,34,32].some(a=>$(o,a))&&!pn(o.prevToken,o),o=>!!o&&[37].some(a=>$(o,a))&&!pn(o.prevToken,o),o=>!!o&&[36,35].some(a=>$(o,a))&&!pn(o.prevToken,o));if(!n)return;let s;$(n.startToken,32)?s=this.processIfBlock(n,(o,a,c)=>new td(o,a??null,c)):s=this.processIfDefBlock(n,(o,a,c)=>$(n.startToken,33)?new Pa(o,a??null,c):new rd(o,a??null,c)),this.nodes.push(s),s.getInValidTokenRange(this.macros,this.tokens).reverse().forEach(o=>{this.tokens.splice(o.start,o.end-o.start+1)}),[...s instanceof ms?s.ifBlocks:[s.ifDef],...s.elseOption?[s.elseOption]:[]].forEach(o=>{!o.active&&o.content&&this._issues.push(C(47,o.content,Ca.DiagnosticSeverity.Hint,[],[Ca.DiagnosticTag.Unnecessary]))}),this.positionStack[this.positionStack.length-1]=t}processIfDefBlock(t,n){this.enqueueToStack(),this.macroStart=!0;let s=new Qe(G(t.startToken));t.splitTokens[0].rewind();let i=this.processCIdentifier(this.macros,!0);i||this._issues.push(C(31,s)),this.macroStart=!1;let o,a=i?.lastToken.nextToken??s.lastToken.nextToken;a&&t.splitTokens[0].tokens.find(f=>f===a)&&(o=new ri(G(a,t.splitTokens[0].tokens.at(-1))));let c=n(s,i??null,o??null),l;if(t.splitTokens.length>1){let f=t.splitTokens[1].tokens[0].prevToken,p=new Qe(G(f)),b;t.splitTokens[1].tokens.length&&(b=new ri(G(t.splitTokens[1].tokens[0],t.splitTokens[1].tokens.at(-1)))),l=new Ra(p,b??null)}let u;t.endToken?u=new Qe(G(t.endToken)):this._issues.push(C(46,s));let d=new lo(c,u??null,l);return this.mergeStack(),d}processIfBlock(t,n){this.enqueueToStack();let s=new Qe(G(t.startToken)),i=[],o;t.splitTokens.forEach((l,u)=>{l.rewind();let d=this.prevToken,f=new Qe(G(d));this.macroStart=!0;let p=this.processExpression(this.macros,!0)||this.processCIdentifier(this.macros,!0);if(this.macroStart=!1,u===t.splitTokens.length-1&&$(d,36)){let g=d,_=new Qe(G(g)),w;l.tokens.length&&(w=new ri(G(l.tokens[0],l.tokens.at(-1)))),o=new Ra(_,w??null)}else{p||this._issues.push(C(31,s));let g,_=p?.lastToken.nextToken??s.lastToken.nextToken;_&&l.tokens.find(T=>T===_)&&(g=new ri(G(_,t.splitTokens[u].tokens.at(-1))));let w=n(f,p??null,g??null);i.push(w)}});let a;t.endToken?a=new Qe(G(t.endToken)):this._issues.push(C(46,s));let c=new ms(i,a??null,o);return this.mergeStack(),c}get allAstItems(){return[...this.dtsIncludes,...this.nodes]}resolveInclude(t){if(t.path.path)return t.path.relative?[(0,uo.resolve)((0,uo.dirname)(t.uri),t.path.path),...this.incudes.map(n=>(0,uo.resolve)(n,t.path.path))].find(n=>(0,Rm.existsSync)(n)):this.incudes.map(n=>(0,uo.resolve)(n,t.path.path)).find(n=>(0,Rm.existsSync)(n))}async processInclude(){this.enqueueToStack();let t=this.peekIndex(),n=this.currentToken;if(!n)return this.popStack(),!1;let s=n,i=n;if($(n,26))this.moveToNextToken;else{let g=this.checkConcurrentTokens([Pe(13),Je("include"),Pe(13)]);if(g.length!==3)return this.popStack(),!1;s=g[0],i=g.at(-1)}let o=s,a=new Qe(G(s,i));n=this.moveToNextToken;let c=n,l=!!$(n,21);if(!c||!l&&!$(n,5))return o&&this.moveEndOfLine(o),this.mergeStack(),!0;let u="";if(l)u=n?.value??"";else for(;this.currentToken?.pos.line===o.pos.line&&!$(this.currentToken,4);)u+=this.currentToken?.value??"",n=this.moveToNextToken;let d=new ro(u,l,G(c,n)),f=new cs(a,d);this.dtsIncludes.push(f),l||(this.currentToken?.pos.line!==o.pos.line||!$(this.currentToken,4)?this._issues.push(C(12,f)):(n=this.moveToNextToken,d.lastToken=n)),this.mergeStack();let p=this.peekIndex(),b=this.resolveInclude(f);if(f.resolvedPath=b,b||this._issues.push(C(36,f.path,Ca.DiagnosticSeverity.Warning)),b){Xr().requestTokens(b,!0);let g=await Da().getCPreprocessorParser(b,this.incudes,this.macros,this.uri);await g.stable,this._issues.push(...g.issues),this.macros.clear(),Array.from(g.macros).forEach(([_,w])=>this.macros.set(_,w)),b.endsWith(".h")?this.tokens.splice(t,p-t):this.tokens.splice(t,p-t,...g.tokens),this.nodes.push(...g.nodes),this.dtsIncludes.push(...g.dtsIncludes)}else this.tokens.splice(t,p-t);return this.positionStack[this.positionStack.length-1]=t,!0}};var xE,Cm=class{constructor(){this.headerFiles=new Map;this.includeOwners=new WeakMap}getCPreprocessorParser(e,t,n,s){let i=`${Array.from(n).map(l=>l[1].macro.toString()).join("::")}`,o=this.headerFiles.get(e)?.get(i);if(o)return o.reparse(n),o;console.log("No cpreprocess cache",e);let a=new fo(e,t,n),c=this.includeOwners.get(a)??new Set;return c.add(s),this.includeOwners.set(a,c),this.headerFiles.has(e)||this.headerFiles.set(e,new Map),this.headerFiles.get(e)?.set(i,a),a}reset(e){let t=this.headerFiles.get(e);t&&Array.from(t).forEach(n=>{n[1]&&(console.log("disposing cpreprocessor cache for",e),Array.from(this.includeOwners.get(n[1])??[]).forEach(this.reset.bind(this)),this.headerFiles.delete(e))})}};function Da(){return xE??=new Cm,xE}var LE,Dm=class r{constructor(){this.fileMap=new Map}static clone(e){let t=e.map(n=>({...n}));return t.forEach((n,s)=>{n.prevToken=t[s-1],n.nextToken=t[s+1]}),t}needsRenew(e,t){return this.fileMap.get(e)?.text!==t}renewLexer(e,t){if(Da().reset(e),!e||!(0,nd.existsSync)(e))return[];try{t??=(0,nd.readFileSync)(e).toString();let n=new Yu(t,e);return this.fileMap.set(e,n),r.clone(n.tokens)}catch{}return[]}requestTokens(e,t){let n=this.fileMap.get(e)?.tokens;return!n&&t?[...this.renewLexer(e)]:r.clone(n??[])}reset(e){Da().reset(e),this.fileMap.delete(e)}};function Xr(){return LE??=new Dm,LE}var sd=class r{constructor(e){this.context=e;this.comments=[];this.includes=[];this.roots=[];this.references=[];this.unlinkedDeletes=[];this.unlinkedRefNodes=[];this.globalDeletes=[];this.rootNode=new Ee(this.context.bindingLoader,"/");this.labelsUsedCache=new Map}static{this.getFileTopMostAst=(e,t)=>e.uri===t?[e]:e.children.flatMap(n=>r.getFileTopMostAst(n,t))}fileTopMostAst(e){return[...this.roots,...this.references,...this.unlinkedDeletes,...this.unlinkedRefNodes,...this.globalDeletes,...this.context.parser.cPreprocessorParser.allAstItems,...this.context.overlayParsers.flatMap(t=>t.cPreprocessorParser.allAstItems)].flatMap(t=>r.getFileTopMostAst(t,e))}getDeepestAstNode(e,t){let s=this.fileTopMostAst(e).find(i=>Tr(i,e,t)||Cw(Xr().requestTokens(e,!1),i,t));if(s instanceof Rt){let o=this.rootNode.getReferenceBy(s)?.getDeepestAstNode(e,t);return o?{...o,runtime:this}:{item:null,runtime:this,ast:hn(s,e,t)}}else if(s instanceof dt&&s.path){let i=this.rootNode.getDeepestAstNode(e,t);return i?{...i,runtime:this}:void 0}else if(s instanceof Re&&s.path){let i=r.getNodeFromPath(s.path.slice(1),this.rootNode)?.getDeepestAstNode(e,t);return i?{...i,runtime:this}:void 0}else if(s)return{runtime:this,item:null,ast:hn(s,e,t)}}static getNodeFromPath(e,t,n=!0){if(e.length===0)return t;let s=e[0].split("@"),i=s[0],a=s.at(1)?.split(",").map(u=>Number.parseInt(u,16)),c=e.slice(1),l=t.getNode(i,a,n);return l?r.getNodeFromPath(c,l,n):void 0}resolvePath(e,t){if(!e.at(0)?.startsWith("&"))return e;let n=this.labelsUsedCache.get(e[0].slice(1));return n||(t??=this.rootNode.allDescendantsLabels,t.find(i=>i.label.value===e.at(0)?.slice(1)&&i.parentNode instanceof qe)?.lastLinkedTo?.path)}get issues(){return[...this.labelIssues(),...this.rootNode.issues]}labelIssues(){let e=[],t=new Map;return this.rootNode.allDescendantsLabelsMapped.forEach(n=>{t.has(n.label.label.value)?t.get(n.label.label.value)?.push(n):t.set(n.label.label.value,[n])}),Array.from(t).forEach(n=>{let s=n[1];if(s.length>1){let i=s.find(a=>a.owner instanceof Ee);(!s.every(a=>a&&a.owner===i?.owner)||!i)&&e.push(C(4,s.at(0).label,$E.DiagnosticSeverity.Error,s.slice(1).map(a=>a.label),[],[s.at(0).label.label.value]))}}),e}get typesIssues(){let e=t=>[...t.nodeType?.getIssue(this,t)??[],...t.nodes.flatMap(n=>e(n))];return this.typesIssuesCache??=e(this.rootNode),this.typesIssuesCache}getOrderedNodeAst(e){return Dw([...e.definitions,...e.referencedBy])}};var qE=z(J()),id=class extends F{constructor(t){super();this.values=t;this.docSymbolsMeta={name:"Values",kind:qE.SymbolKind.String},this.values.forEach(n=>this.addChild(n))}toString(){return this.values.map(t=>t?.toString()).join(",")}toJson(){return this.values.length===1?this.values[0]?.toJson():this.values.map(t=>t?.toJson())}};var jE=z(J()),od=class extends F{constructor(t){super();this.keyword=t;this.addChild(t),this.docSymbolsMeta={name:"DTS Document version",kind:jE.SymbolKind.Function}}};var yn=class extends F{constructor(t,n){super();this.value=t;this.labels=n;this.labels.forEach(s=>{this.addChild(s)}),this.addChild(this.value)}toString(){return`${this.labels.map(t=>t.toString()).join(" ")}${this.value?.toString()??"NULL"}`}};var FE=z(J()),ad=class extends F{constructor(t,n,s){super();this.keyword=t;this.startAddress=n;this.endAddress=s;this.addChild(t),this.docSymbolsMeta={name:"Memreserve",kind:FE.SymbolKind.Function},this.addChild(n),this.addChild(s)}toString(){return`/memreserve/ 0x${this.startAddress?.value?.toString(16)} 0x${this.endAddress?.value?.toString(16)}`}};var BE=z(J()),cd=class extends F{constructor(t,n){super();this.keyword=t;this.bitsSize=n;this.addChild(t),this.docSymbolsMeta={name:"bits",kind:BE.SymbolKind.Function},this.addChild(n)}toString(){return`/bits/ ${this.bitsSize?.value?.toString()}`}};var UE=z(J()),Oa=class extends ps{constructor(t,n,s){super();this.uri=t;this.incudes=n;this.tokens=[];this.others=[];this.rootDocument=new qe;this.unhandledStatements=new dt;this.cPreprocessorParser=new fo(this.uri,this.incudes,s)}get issues(){return[...this._issues,...this.cPreprocessorParser.issues]}getFiles(){return[this.uri,...this.cPreprocessorParser.dtsIncludes.flatMap(t=>t.resolvedPath).filter(t=>!!t)]}reset(){super.reset(),this.others=[],this.rootDocument=new qe,this._issues=[],this.unhandledStatements=new dt}async reparse(){let t=performance.now(),n=this.stable;return this.parsing=new Promise(s=>{n.then(async()=>{this.reset(),await this.cPreprocessorParser.reparse(),await this.parse(),console.log("parsing",performance.now()-t),s()})}),this.parsing}async parse(){let t=performance.now();if(await this.cPreprocessorParser.stable,this.tokens=this.cPreprocessorParser.tokens,this.uri.endsWith(".h")||(this.positionStack.push(0),this.tokens.length===0))return;let n=async()=>{if(!(this.isDtsDocumentVersion()||this.isMemreserve()||this.isRootNodeDefinition(this.rootDocument)||this.isDeleteNode(this.rootDocument,"Ref")||this.isChildNode(this.rootDocument,"Ref")||this.isProperty(this.unhandledStatements)||this.isDeleteProperty(this.unhandledStatements))){let s=this.moveToNextToken;if(s){let i=new F(G(s));this._issues.push(C(22,i)),this.reportExtraEndStatements()}}};for(;!this.done;)await n();if(this.unhandledStatements.properties.forEach(s=>{this._issues.push(C(32,s))}),this.unhandledStatements.deleteProperties.forEach(s=>{this._issues.push(C(33,s))}),this.positionStack.length!==1)throw new Error("Incorrect final stack size")}isRootNodeDefinition(t){this.enqueueToStack();let n=this.moveToNextToken,s=n,i=13;if(!n||!$(n,i))return this.popStack(),!1;if(s=this.moveToNextToken,i=2,!s||!$(s,i))return this.popStack(),!1;let o=new dt;o.openScope=s,t.addNodeChild(o),this.processNode(o,"Name");let a=this.nodeEnd(o)??s;return o.firstToken=n,o.lastToken=a,this.mergeStack(),!0}nodeEnd(t){let n=this.currentToken;if($(n,3))this.moveToNextToken;else{let s=this.prevToken;if(s){let i=new F(G(s));this._issues.push(C(3,i))}return this.endStatement(!1)}return this.prevToken?.value==="}"&&(t.closeScope=this.prevToken),this.endStatement()}isNodeEnd(){return $(this.currentToken,3)||$(this.currentToken,1)}endStatement(t=!0){let n=this.currentToken;if(!$(n,1)){let s=this.prevToken;if(s&&t){let i=new F(G(this.prevToken));return this._issues.push(C(1,i)),s}}return this.moveToNextToken,this.reportExtraEndStatements(),n}reportExtraEndStatements(){for(;$(this.currentToken,1);){let t=this.moveToNextToken;if(t){let n=new F(G(t));this._issues.push(C(23,n))}}}processNode(t,n){if(this.done)return!1;let s=!1,i=!1;do{if(i=this.isChildNode(t,n)||this.isProperty(t)||this.isDeleteNode(t,n)||this.isDeleteProperty(t),!i&&!this.isNodeEnd()&&!this.done){let o=this.moveToNextToken;if(o){let a=new F(G(o));this._issues.push(C(22,a)),this.reportExtraEndStatements()}}else if(this.done)break;s=s||i}while(!this.isNodeEnd());return s}processOptionalLabelAssign(t=!1){let n=[],s=this.isLabelAssign(t);for(;s;)n.push(s),s=this.isLabelAssign(t);return n}isChildNode(t,n){this.enqueueToStack();let s;n==="Name"&&(s=this.isOmitIfNoRefNode());let i=this.processOptionalLabelAssign(),o,a,c=n==="Ref"?new Rt(i):new Re(i,s);if(n==="Ref"?a=this.isLabelRef():n==="Name"&&(o=this.isNodeName()),!a&&!o){if(!$(this.currentToken,2))return this.popStack(),!1;c.firstToken=this.currentToken,this._issues.push(C(n==="Name"?[7]:[10,11],c))}let l=!1;if(a&&c instanceof Rt?(c.labelReference=a,l=!0):o&&c instanceof Re&&(l=o.address!==void 0,c.name=o),$(this.currentToken,2)){this.moveToNextToken,c.openScope=this.prevToken;let u=!1;do u=this.processNode(c,"Name");while(u);let d=this.nodeEnd(c);c.lastToken=d}else if(l){let u=a??o;u&&this._issues.push(C(2,u))}else return this.popStack(),!1;return t.addNodeChild(c),this.mergeStack(),!0}processNodeAddress(){let t=this.prevToken,n=this.consumeAnyConcurrentTokens([19,20].map(Pe)),s=n.length?Number.parseInt(n.map(o=>o.value).join(""),16):NaN;if(t){if(Number.isNaN(s)){let o=new F(G(t));this._issues.push(C(8,o))}else if(!Number.isNaN(s)&&!Xt(t,n[0])){let o=new F(G(t,n.at(0)));this._issues.push(C(29,o))}}return new Fu(s,G(n[0]??this.prevToken,n.at(-1)))}processNodeAddresses(t){this.enqueueToStack();let n=this.checkConcurrentTokens([Pe(49)]);if(n.length){if(!Xt(t.lastToken,n[0])){let o=new F(G(t.lastToken,n[0]));this._issues.push(C(29,o))}let s=[],i=()=>{if(s.push(this.processNodeAddress()),$(this.currentToken,24)){if(this.prevToken&&!Xt(this.prevToken,this.currentToken)){let o=new F(G(this.prevToken,this.currentToken));this._issues.push(C(29,o))}this.moveToNextToken,i()}};return i(),this.mergeStack(),s}this.popStack()}isNodeName(){this.enqueueToStack();let t=this.consumeAnyConcurrentTokens([19,47,24,45,48,15,16].map(Pe));if(!t.length){this.popStack();return}let n=t.map(o=>o.value).join("");if(!n.match(/^[A-Za-z]/)){this.popStack();return}let s=new je(n,G(t[0],t.at(-1))),i=this.processNodeAddresses(s);return s.address=i,this.mergeStack(),s}isPropertyName(){this.enqueueToStack();let t=this.consumeAnyConcurrentTokens([19,47,24,45,48,15,16,44,46].map(Pe));if(!t.length){this.popStack();return}let n=new ze(t.map(s=>s.value).join(""),G(t[0],t.at(-1)));return this.mergeStack(),n}isLabelName(){this.enqueueToStack();let t=this.consumeAnyConcurrentTokens([19,47,48].map(Pe));if(!t.length){this.popStack();return}let n=t.map(i=>i.value).join("");if(!n.match(/^[A-Za-z]/)){this.popStack();return}let s=new Lt(n,G(t[0],t.at(-1)));return this.mergeStack(),s}isLabelAssign(t){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,48].map(Pe));if(!n.length){this.popStack();return}let s=n.map(c=>c.value).join("");if(!s.match(/^[A-Za-z]/)){this.popStack();return}let i=this.currentToken,o=i&&$(i,50),a=new ds(new Lt(s,G(n[0],n.at(-1))),G(n[0],o?i:n.at(-1)));if(o){let c=n.at(-1);c&&(i.pos.line!==a.firstToken.pos.line||i.pos.col!==c.pos.col+c.pos.len)&&this._issues.push(C(29,new F(G(c,i)))),this.moveToNextToken}else if(t)this._issues.push(C(24,a));else{this.popStack();return}return this.mergeStack(),a}isProperty(t){this.enqueueToStack();let n=this.processOptionalLabelAssign(),s=this.isPropertyName();if(!s)return this.popStack(),!1;if($(this.currentToken,2)||$(this.currentToken,49))return this.popStack(),!1;let i=new Ae(s,n),o;$(this.currentToken,0)?(i.assignOperatorToken=this.currentToken,this.moveToNextToken,o=this.processValue(i),o?.values.filter(c=>!!c).length||this._issues.push(C(0,i)),i.values=o??null):i.values=void 0;let a=this.endStatement();return i.lastToken=a,t.addNodeChild(i),this.mergeStack(),!0}isDtsDocumentVersion(){this.enqueueToStack();let t=this.checkConcurrentTokens([Pe(13),Je("d"),Je("ts"),Pe(16),Je("v"),Je("1")]);if(t.length!==6)return this.popStack(),!1;let n=t[0],s=n,i=new Qe;i.firstToken=n;let o=new od(i);if(this.others.push(o),$(this.currentToken,13))s=this.moveToNextToken;else return i.lastToken=t.at(-1),this._issues.push(C(21,o)),this.mergeStack(),!0;return i.lastToken=s,o.lastToken=this.endStatement(),this.mergeStack(),!0}isMemreserve(){this.enqueueToStack();let t=this.checkConcurrentTokens([Pe(13),Je("memreserve")]);if(t.length!==2)return this.popStack(),!1;let n=new Qe;n.firstToken=t[0];let i=t[0];$(this.currentToken,13)?(i=this.moveToNextToken,n.lastToken=i):(n.lastToken=t.at(-1),this._issues.push(C(21,n)));let o=this.processHex()||this.processDec(),a=o&&(this.processHex()||this.processDec()),c=new ad(n,o,a);return this.others.push(c),o||this._issues.push(C(37,n)),a||this._issues.push(C(38,o??n)),c.lastToken=this.endStatement(),this.mergeStack(),!0}processBits(){this.enqueueToStack();let t=this.checkConcurrentTokens([Pe(13),Je("b"),Je("its")]);if(t.length!==3){this.popStack();return}let n=new Qe;n.firstToken=t[0];let i=t[0];$(this.currentToken,13)?(i=this.moveToNextToken,n.lastToken=i):(n.lastToken=t.at(-1),this._issues.push(C(21,n)));let o=this.processDec(),a=new cd(n,o);return this.others.push(a),o?o.value!==8&&o.value!==16&&o.value!==32&&o.value!==64&&this._issues.push(C(40,o)):this._issues.push(C(39,n)),this._issues.push(C(41,a,UE.DiagnosticSeverity.Warning)),this.mergeStack(),a}isOmitIfNoRefNode(){this.enqueueToStack();let t=this.checkConcurrentTokens([Pe(13),Je("omit"),Pe(16),Je("if"),Pe(16),Je("no"),Pe(16),Je("ref"),Pe(13)]);if(t.length!==9){this.popStack();return}let n=new Qe(G(t[0],t.at(-1)));return this.mergeStack(),n}isDeleteNode(t,n){this.enqueueToStack();let s=this.checkConcurrentTokens([Pe(13),Je("d"),Je("e"),Je("lete"),Pe(16),Je("node")]);if(!s.length)return this.popStack(),!1;let i=s[0],o=i,a=new Qe;if(a.firstToken=i,s.length===1&&!$(this.currentToken,2)){this._issues.push(C(25,a)),a.lastToken=s.at(-1);let d=new ur(a);return t.addNodeChild(d),this.mergeStack(),!0}let c=s.map(d=>d.value??"").join("");if(!"/delete-node/".startsWith(c)||c.endsWith("-"))return this.popStack(),!1;a.lastToken=s.at(-1),c!=="/delete-node"?this._issues.push(C(c.startsWith("/delete-n")?34:25,a)):$(this.currentToken,13)?(o=this.moveToNextToken,a.lastToken=o):this._issues.push(C(21,a));let l=new ur(a);if(pn(a.tokenIndexes?.end,i)){let d=this.processNodePathRef();d&&n==="Name"&&this._issues.push(C(7,d));let f=d?void 0:this.isLabelRef();f&&n==="Name"&&this._issues.push(C(7,f));let p=d||f?void 0:this.isNodeName();p&&n==="Ref"&&this._issues.push(C(10,p)),!d&&!p&&!f&&this._issues.push(C([7,10],l)),l.nodeNameOrRef=d??f??p??null}else n==="Name"?this._issues.push(C(7,a)):n==="Ref"&&this._issues.push(C(10,a));let u=this.endStatement();return l.lastToken=u,t.addNodeChild(l),this.mergeStack(),!0}isDeleteProperty(t){this.enqueueToStack();let n=this.checkConcurrentTokens([Pe(13),Je("d"),Je("e"),Je("lete"),Pe(16),Je("property")]);if(!n.length)return this.popStack(),!1;let s=n[0],i=s,o=new Qe;if(o.firstToken=s,n.length===1&&!$(this.currentToken,2)){this._issues.push(C(25,o)),o.lastToken=n.at(-1);let u=new Ue(o);return t.addNodeChild(u),this.mergeStack(),!0}let a=n.map(u=>u.value??"").join("");if(!"/delete-property/".startsWith(a)||a.endsWith("-"))return this.popStack(),!1;o.lastToken=n.at(-1),a!=="/delete-property"?this._issues.push(C(a.startsWith("/delete-p")?35:25,o)):$(this.currentToken,13)?(i=this.moveToNextToken,o.lastToken=i):this._issues.push(C(21,o));let c=new Ue(o);if(pn(o.tokenIndexes?.end,s)){let u=this.isPropertyName();u||this._issues.push(C(6,c)),c.propertyName=u??null}else this._issues.push(C(6,o));let l=this.endStatement();return c.lastToken=l,t.addNodeChild(c),this.mergeStack(),!0}isNodePathRef(){this.enqueueToStack();let t=this.processOptionalLabelAssign(!0),n=this.processNodePathRef();if(!n){this.popStack();return}let s=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&s.push(...this.processOptionalLabelAssign(!0));let i=new Zt(t,n,s);return this.mergeStack(),i}processValue(t){this.enqueueToStack();let s=(()=>{let o=()=>(this.processStringValue()||this.isNodePathRef()||this.isLabelRefValue(t)||this.arrayValues(t)||this.processByteStringValue()||this.isExpressionValue())??null,a=o();if(!a)return[];let c=[a];for(;!$(this.currentToken,1);){let l=this.prevToken,u=this.currentToken,d=$(this.currentToken,24);if(d)this.moveToNextToken;else if(!pn(this.prevToken,this.currentToken))break;let f=o();if(u&&f===null&&d){let p=new F(G(u,this.currentToken));this._issues.push(C(0,p))}if(!d&&f===null)break;if(l&&!d&&f){let p=new F(G(l));this._issues.push(C(28,p))}c.push(f)}return c})();if(s.length===0){this.popStack();return}return this.mergeStack(),new id(s)}processStringValue(){this.enqueueToStack();let t=this.processOptionalLabelAssign(!0),n=this.moveToNextToken;if(!$(n,21)){this.popStack();return}if(!n?.value)throw new Error("Token must have value");let s=n.value;s.match(/["']$/)&&(s=s.slice(1,-1));let i=new Oe(s,G(n));n.value.match(/["']$/)||this._issues.push(C(n.value.startsWith('"')?16:17,i));let o=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(o=this.processOptionalLabelAssign(!0));let a=new Zt(t,i,o);return this.mergeStack(),a}arrayValues(t){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),s=this.processBits(),i=this.currentToken;if($(i,5))this.moveToNextToken;else{this.popStack();return}let o=this.processArrayValues(t)??null;o.openBracket=i;let a=this.processOptionalLabelAssign(!0)??[],c=new Zt(n,o,a,s);$(this.currentToken,4)?(o&&(o.closeBracket=this.currentToken),this.moveToNextToken):this._issues.push(C(12,c));let l=[];return this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(l=this.processOptionalLabelAssign(!0)),this.mergeStack(),c.endLabels.push(...l),c.firstToken=i,c.lastToken=this.prevToken,c}processByteStringValue(){this.enqueueToStack();let t=this.processOptionalLabelAssign(!0),n=this.moveToNextToken,s=n;if(!$(s,11)){this.popStack();return}let i=this.processLabeledValue(()=>this.processHexString()),o=this.processOptionalLabelAssign(!0)??[];i.forEach(u=>{let d=0;u.value?.tokenIndexes?.start===u.value?.tokenIndexes?.end&&(d=u.value?.tokenIndexes?.start?.pos.len??0),d%2!==0&&this._issues.push(C(15,u))});let a=new as(i??[]);a.openBracket=s,a.values.length===0&&(a.firstToken=n,this._issues.push(C(14,a)));let c=new Zt(t,a,o);$(this.currentToken,12)?a.openBracket=this.moveToNextToken:this._issues.push(C(5,c));let l=[];return this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(l=this.processOptionalLabelAssign(!0)),this.mergeStack(),c.endLabels.push(...l),c.firstToken=n,a.lastToken=this.prevToken,c}processLabeledValue(t){this.enqueueToStack();let n=t(),s=[];if(!n)return this.popStack(),[];for(;n;)s=[...s,n],n=t();if(s){let i=t();i&&(s=[...s,i])}return this.mergeStack(),s}processArrayValues(t){this.enqueueToStack();let n=this.processLabeledValue(()=>this.processRefValue(!1,t)||this.processLabeledHex(!1)||this.processLabeledDec(!1)||this.processLabeledExpression(!0,!1)),s=new yt(n);return n.length===0&&(s.firstToken=this.currentToken),this.mergeStack(),s}processLabeledHex(t){this.enqueueToStack();let n=this.processOptionalLabelAssign(t),s=this.processHex();if(!s){this.popStack();return}let i=new yn(s,n);return this.mergeStack(),i}processHexString(){this.enqueueToStack();let t=this.processOptionalLabelAssign(!1),n=this.checkConcurrentTokens([20,20].map(Pe));if(!n.length){this.popStack();return}let s=Number.parseInt(n.map(a=>a.value).join(""),16),i=new _t(s,G(n[0],n.at(-1))),o=new yn(i,t);return this.mergeStack(),o}processLabeledDec(t){this.enqueueToStack();let n=this.processOptionalLabelAssign(t),s=this.processDec();if(!s){this.popStack();return}let i=new yn(s,n);return this.mergeStack(),i}processLabeledExpression(t=!0,n=t){this.enqueueToStack();let s=[];t&&(s=this.processOptionalLabelAssign(n));let i=this.processExpression(this.cPreprocessorParser.macros);if(!i){this.popStack();return}let o=new yn(i,s);return this.mergeStack(),o}isExpressionValue(){this.enqueueToStack();let t=this.processOptionalLabelAssign(!1),n=this.processExpression(this.cPreprocessorParser.macros);if(!n){this.popStack();return}let s=this.processOptionalLabelAssign(!0),i=new Zt(t,n,s);return this.mergeStack(),i}isLabelRef(t){this.enqueueToStack();let n=this.currentToken;if($(n,40))this.moveToNextToken;else{this.popStack();return}let s=this.isLabelName();if(!s){let o=new _e(null);return this._issues.push(C(18,t??o)),o.firstToken=n,this.mergeStack(),o}n&&(s.firstToken.pos.line!==n.pos.line||s.firstToken.pos.col!==n.pos.col+n.pos.len)&&this._issues.push(C(29,new F(G(n,s.firstToken))));let i=new _e(s);return i.firstToken=n,this.mergeStack(),i}isLabelRefValue(t){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),s=this.isLabelRef(t);if(!s){this.popStack();return}let i=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(i=this.processOptionalLabelAssign(!0));let o=new Zt(n,s,i);return this.mergeStack(),o}processRefValue(t,n){this.enqueueToStack();let s=this.processOptionalLabelAssign(t),i=this.currentToken;if(!$(this.currentToken,40)){this.popStack();return}let o=this.processNodePathRef();if(o!==void 0){let l=new yn(o,s);return this.mergeStack(),l}let a=this.isLabelRef(n);if(a===void 0){this._issues.push(C([18,9],n));let l=new yn(null,s);return l.firstToken=s.at(0)?.firstToken??i,this.mergeStack(),l}let c=new yn(a,s);return c.firstToken=s.at(0)?.firstToken??i,this.mergeStack(),c}processNodePath(t=!0,n=new $n){this.enqueueToStack();let s;if($(this.currentToken,13))s=this.moveToNextToken;else{if(!t){this.popStack();return}this.prevToken&&this._issues.push(C(19,new F(G(this.prevToken))))}let i=this.isNodeName();return i||this._issues.push(C(7,new F(G(s??this.prevToken)))),n.addPath(i??null,s?new F(G(s)):void 0),this.processNodePath(!1,n),this.mergeStack(),n}processNodePathRef(){this.enqueueToStack();let t=this.moveToNextToken,n=t;if(!$(n,40)){this.popStack();return}let s=this.moveToNextToken;if(n=s,!$(n,2)){this.popStack();return}let i=this.processNodePath(),o=new Gr(i??null),a=this.currentToken??this.prevToken,c=a;return i?.children.forEach((l,u)=>{if(u===i?.children.length-1&&l&&c&&!Xt(l.lastToken,c)){this._issues.push(C(29,new F(G(l.lastToken,c))));return}if(u===0&&s&&!Xt(s,l?.firstToken)){this._issues.push(C(29,new F(G(s,l?.firstToken))));return}let d=i?.children[u+1];l&&d&&!Xt(l.lastToken,d.firstToken)&&this._issues.push(C(29,new F(G(l.lastToken,d?.firstToken))))}),$(a,3)?this.moveToNextToken:this.prevToken&&this._issues.push(C(3,new F(G(this.prevToken)))),o.firstToken=t,o.lastToken=a??this.prevToken,this.mergeStack(),o}get includes(){return this.allAstItems.filter(t=>t instanceof cs)}get allAstItems(){return[...this.cPreprocessorParser.allAstItems,...this.rootDocument.children,...this.others,...this.unhandledStatements.properties,...this.unhandledStatements.deleteProperties]}};var ho=z(J());var VE=require("fs"),WE=require("path");var po=class{constructor(e,t,n,s=[],i){this.includePaths=t;this.bindingLoader=n;this._issues=[];this.overlayParsers=[];this.overlays=[];this.overlays=Array.isArray(s)?s:[s],this.overlays.filter(VE.existsSync),this.parser=new Oa(e,t),this.name=i??(0,WE.basename)(e),this.parser.stable.then(()=>{this.overlayParsers=this.overlays?.map(o=>new Oa(o,t,this.parser.cPreprocessorParser.macros))??[]})}async getContextIssues(){return[...(await this.getRuntime()).issues,...this._issues]}async stable(){await Promise.all([this.parser.stable,...this.overlayParsers.map(e=>e.stable)])}async getRuntime(){return await this.stable(),this._runtime??=this.evaluate(),this._runtime}getContextFiles(){return[...this.overlayParsers.map(e=>e.uri),this.parser.uri,...this.parser.cPreprocessorParser.dtsIncludes.flatMap(e=>e.resolvedPath).filter(e=>!!e)]}isInContext(e){return this.getContextFiles().some(t=>t===e)}async getAllParsers(){return await this.stable(),[this.parser,...this.overlayParsers]}async getDocumentLinks(e,t){if(!this.isInContext(e))return[];let s=(await this.getRuntime()).rootNode.allBindingsProperties.filter(i=>i.ast.uri===e&&(!t||Tr(i.ast,e,t))).flatMap(i=>i.ast.values?.values.flatMap(o=>{let c=i.parent?.nodeTypes.find(l=>o?.value instanceof Oe&&l.compatible===o.value.value);return c?{range:Q(o.value),target:ce(c.bindingsPath)}:void 0})).filter(i=>i)??[];return[...this.parser.cPreprocessorParser.dtsIncludes.filter(i=>i.uri===e&&(!t||Tr(i,e,t))).map(i=>{let o=this.parser.cPreprocessorParser.resolveInclude(i);if(o)return{range:Q(i.path),target:ce(o)}}).filter(i=>i)??[],...s]}linkPropertiesLabelsAndNodePaths(e){let t=i=>[...i.property,...i.nodes.flatMap(t)],n=t(e.rootNode),s=e.rootNode.allDescendantsLabels;n.forEach(i=>i.ast.allDescendants.forEach(o=>{if(o instanceof _e){let a=e.resolvePath([`&${o.label?.value}`],s);if(a){let c=e.rootNode.getChild(a);o.linksTo=c,c?.linkedRefLabels.push(o)}else o.value&&this._issues.push(C(3,o,ho.DiagnosticSeverity.Error,[],[],[o.value]))}else if(o instanceof $n){let a=e.rootNode,c=o.pathParts;for(let l=0;l<c.length&&c[l];l++){let u=!1,d=c[l];if(d){let f=a?.getNode(d.name,d.address?.map(p=>p.address),!1);d.linksTo=f,!u&&!f&&(u=!0,this._issues.push(C(8,d,ho.DiagnosticSeverity.Error,[],[],[d.toString(),`${o.pathParts.filter(p=>p?.linksTo).map(p=>p?.toString()).join("/")}`]))),f?.linkedNodeNamePaths.push(d),a=f}else break}}}))}async reevaluate(e){return this.isInContext(e)?(await this.parser.reparse(),this._runtime=this.evaluate(),this._runtime):this._runtime}async evaluate(){let e=performance.now();await this.stable();let t=new sd(this);this._issues=[],this.processRoot(this.parser.rootDocument,t);for(let n=0;n<this.overlayParsers.length;n++)this.processRoot(this.overlayParsers[n].rootDocument,t);return t.includes=this.parser.includes,t.comments=this.parser.cPreprocessorParser.allAstItems.filter(n=>n instanceof mn),(await this.getAllParsers()).flatMap(n=>n.tokens).forEach((n,s)=>n.sortKey=s),this.linkPropertiesLabelsAndNodePaths(t),console.log("evaluate",performance.now()-e),t}processRoot(e,t){for(let n=0;n<e.children.length;n++){let s=e.children[n];this.processChild(s,t.rootNode,t)}}processChild(e,t,n){e instanceof qe?this.processDtcBaseNode(e,t,n):e instanceof Ae?this.processDtcProperty(e,t,n):e instanceof ur?this.processDeleteNode(e,t,n):e instanceof Ue&&this.processDeleteProperty(e,t,n)}checkNodeUniqueNames(e,t){let n=(o,a)=>o.some(c=>c.name===a.name&&(c.address===void 0||a.address===void 0||c.address.every((l,u)=>a.address?.at(u)?.address===l))),s=t.nodes.map(o=>({name:o.name,address:o.address})),i=[];e.children.forEach(o=>{if(o instanceof Re&&o.name)n(i.map(a=>({name:a.name,address:a.address?.map(c=>c.address)})),o.name)&&this._issues.push(C(2,o.name)),i.push(o.name);else if(o instanceof ur&&o.nodeNameOrRef instanceof je){let a=o.nodeNameOrRef;n(s,a)&&(i=i.filter(c=>n(i.map(l=>({name:l.name,address:l.address?.map(u=>u.address)})),c)))}})}processDtcBaseNode(e,t,n){e instanceof dt?this.processDtcRootNode(e,n):e instanceof Re?this.processDtcChildNode(e,t,n):e instanceof Rt&&this.processDtcRefNode(e,n)}processDtcRootNode(e,t){t.roots.push(e),t.rootNode.definitions.push(e),this.checkNodeUniqueNames(e,t.rootNode),[...e.children].sort((n,s)=>n instanceof Ae&&s instanceof Ue||s instanceof Ae&&n instanceof Ue?0:s instanceof Ae?1:0).forEach(n=>this.processChild(n,t.rootNode,t))}processDtcChildNode(e,t,n){if(e.name?.name){let s=e.path?n.resolvePath(e.path):void 0,o=(s?n.rootNode.getChild(s):void 0)??new Ee(this.bindingLoader,e.name.name,e.name.address?.map(a=>a.address),t);o.definitions.push(e),e.labels.forEach(a=>a.lastLinkedTo=o),t=o,this.checkNodeUniqueNames(e,o)}[...e.children].sort((s,i)=>s instanceof qe&&i instanceof qe?0:s instanceof qe?-1:0).forEach(s=>this.processChild(s,t,n))}processDtcRefNode(e,t){let n;if(e.labelReference){let s=e.resolveNodePath??(e.pathName?t.resolvePath([e.pathName]):void 0);s?(e.resolveNodePath??=[...s],n=t.rootNode.getChild(s),e.labelReference.linksTo=n,e.labels.forEach(i=>i.lastLinkedTo=n),n?.linkedRefLabels.push(e.labelReference),n?.referencedBy.push(e),e.labels.forEach(i=>{t.labelsUsedCache.set(i.label.value,s)}),n?(t.references.push(e),this.checkNodeUniqueNames(e,n)):t.unlinkedRefNodes.push(e)):(this._issues.push(C(3,e.labelReference,ho.DiagnosticSeverity.Error,[],[],[e.labelReference.label?.value??""])),t.unlinkedRefNodes.push(e))}else t.unlinkedRefNodes.push(e);[...e.children].sort((s,i)=>s instanceof qe&&i instanceof qe?0:s instanceof qe?-1:0).forEach(s=>this.processChild(s,n??new Ee(this.bindingLoader,""),t))}processDtcProperty(e,t,n){e.propertyName?.name&&t.addProperty(new Xe(e,t)),e.children.forEach(s=>this.processChild(s,t,n))}processDeleteNode(e,t,n){if(e.nodeNameOrRef instanceof je&&e.nodeNameOrRef.value){if(e.parentNode?.parentNode)if(!t.hasNode(e.nodeNameOrRef.name,e.nodeNameOrRef.address?.map(s=>s.address)))this._issues.push(C(5,e.nodeNameOrRef));else{t.deletes.push(e);let s=t.getNode(e.nodeNameOrRef.name,e.nodeNameOrRef.address?.map(i=>i.address));e.nodeNameOrRef.linksTo=s,t.deleteNode(e.nodeNameOrRef.name,e,e.nodeNameOrRef.address?.map(i=>i.address)),s?.labels.forEach(i=>{n.labelsUsedCache.delete(i.label.value)})}}else if(e.nodeNameOrRef instanceof _e&&e.nodeNameOrRef.value){let s=n.resolvePath([`&${e.nodeNameOrRef.value}`]),i;s?(i=n.rootNode.getChild(s),t.deletes.push(e),e.nodeNameOrRef.linksTo=i,i?.labels.forEach(o=>{n.labelsUsedCache.delete(o.label.value)}),i?.linkedRefLabels.push(e.nodeNameOrRef),i?.parent?.deleteNode(i.name,e,i.address),e.parentNode instanceof qe&&!e.parentNode.pathName&&n.globalDeletes.push(e)):(n.unlinkedDeletes.push(e),this._issues.push(C(3,e.nodeNameOrRef,ho.DiagnosticSeverity.Error,[],[],[e.nodeNameOrRef.value])))}else if(e.nodeNameOrRef instanceof Gr&&e.nodeNameOrRef.path&&!e.nodeNameOrRef.path.pathParts.some(s=>!s)){let s=["/",...e.nodeNameOrRef.path.pathParts.map(u=>u.toString())],i=n.rootNode,o=e.nodeNameOrRef.path.pathParts;for(let u=0;u<o.length&&o[u];u++){let d=o[u];if(d){let f=i?.getNode(d.name,d.address?.map(p=>p.address),!1);d.linksTo=f,f?.linkedNodeNamePaths.push(d),i=f}}let a=e.nodeNameOrRef.path.pathParts.every(u=>u),c=e.nodeNameOrRef.path.pathParts.find(u=>u&&!u.linksTo),l=e.nodeNameOrRef.path.pathParts.at(-1)?.linksTo;l||(n.unlinkedDeletes.push(e),c&&this._issues.push(C(8,c,ho.DiagnosticSeverity.Error,[],[],[c.toString(),`${e.nodeNameOrRef.path.pathParts.filter(u=>u?.linksTo).map(u=>u?.toString()).join("/")}`]))),t.deletes.push(e),l?.labels.forEach(u=>{n.labelsUsedCache.delete(u.label.value)}),l?.parent?.deleteNode(l.name,e,l.address),e.parentNode instanceof qe&&!e.parentNode.pathName&&n.globalDeletes.push(e)}else n.unlinkedDeletes.push(e);e.children.forEach(s=>this.processChild(s,t,n))}processDeleteProperty(e,t,n){e.propertyName?.name&&!t.hasProperty(e.propertyName.name)?this._issues.push(C(1,e.propertyName)):e.propertyName?.name&&(t.deletes.push(e),t.deleteProperty(e.propertyName.name,e)),e.children.forEach(s=>this.processChild(s,t,n))}};var ft=z(J());var HE=require("fs"),mo=require("path");function nx(r){if(!r||!(r.ast instanceof ro))return[];let e=n=>n.flatMap(s=>(0,HE.readdirSync)(s,{withFileTypes:!0,recursive:!0}).filter(i=>i.name.toLowerCase().endsWith(".dtsi")||i.name.toLowerCase().endsWith(".h")).map(i=>({label:`${(0,mo.join)((0,mo.relative)(s,i.parentPath),i.name)}`,kind:ft.CompletionItemKind.File})));if(r.ast.relative)return e([(0,mo.dirname)(r.ast.uri)]);let t=r.runtime.context.includePaths;return e(t)}var ud=(r,e)=>[...r.labels.filter(e),...r.deletedNodes.filter(t=>!e(t.by)).flatMap(t=>ud(t.node,e)),...r.nodes.flatMap(t=>ud(t,e))],Om=(r,e)=>[...r.labels,...r.deletedNodes.filter(t=>!e(t.by)).flatMap(t=>Om(t.node,e)),...r.nodes.flatMap(t=>Om(t,e))];function sx(r,e){if(!r||!(r.item instanceof Xe)||!(r.ast instanceof _e))return[];let t=n=>Om(n,e);return Array.from(new Set(t(r.runtime.rootNode).map(n=>n.label.value))).map(n=>({label:`${n}`,kind:ft.CompletionItemKind.Method}))}function ix(r,e){if(!r||r.item!==null||!(r.ast instanceof _e)||!(r.ast.parentNode instanceof Rt))return[];let t=n=>ud(n,e).filter(s=>e(s));return[...Array.from(new Set(t(r.runtime.rootNode).map(n=>n.label.value))).map(n=>({label:n,insertText:`${n} {
|
|
258
258
|
$1
|
|
259
259
|
};`,kind:ft.CompletionItemKind.Value,insertTextFormat:ft.InsertTextFormat.Snippet}))]}function ox(r,e){let t=s=>s?s.parentNode instanceof Rt||s.parentNode instanceof dt||s.parentNode instanceof Re?!1:t(s.parentNode):!0;if(!r||r.item!==null||!St(r.ast)||!t(r.ast))return[];let n=s=>ud(s,e).filter(i=>e(i));return r.ast instanceof Qe?n(r.runtime.rootNode).length?[{label:"/delete-node/",insertText:"/delete-node/ $1;",kind:ft.CompletionItemKind.Keyword,insertTextFormat:ft.InsertTextFormat.Snippet,sortText:"~"}]:r.runtime.rootNode.nodes.length?[{label:"/delete-node/ &{}",insertText:"/delete-node/ {/$1};",kind:ft.CompletionItemKind.Keyword,insertTextFormat:ft.InsertTextFormat.Snippet,sortText:"~"}]:[]:Array.from(new Set(n(r.runtime.rootNode).map(s=>s.label.value))).map(s=>({label:r.ast instanceof _e?`${s}`:`&${s}`,kind:ft.CompletionItemKind.Variable}))}function ax(r,e){if(!r||!(r.item instanceof Ee)||r.item===null||r.beforeAst&&(!(r.beforeAst?.parentNode instanceof Qt)||r.beforeAst?.parentNode instanceof Ue))return[];let t=n=>[...n.nodes,...n.deletedNodes.filter(s=>!e(s.by)).map(s=>s.node)].flatMap(s=>s.definitions.filter(i=>i instanceof Re)).filter(s=>e(s));return r.ast instanceof je||r.ast instanceof ur||r.beforeAst?.parentNode instanceof ur?Array.from(new Set(t(r.item).map(n=>n.name?.toString()))).map(n=>({label:`${n}`,kind:ft.CompletionItemKind.Variable})):t(r.item).length?[{label:"/delete-node/",kind:ft.CompletionItemKind.Keyword,insertTextFormat:ft.InsertTextFormat.Snippet,sortText:"~"}]:[]}function cx(r,e){if(!r||!(r.item instanceof Ee)||r.beforeAst&&(!(r.beforeAst?.parentNode instanceof Qt)||r.beforeAst?.parentNode instanceof ur))return[];let t=n=>[...n.property,...n.deletedProperties.filter(s=>!e(s.by)).map(s=>s.property)].flatMap(s=>[s,...s.allReplaced]).filter(s=>e(s.ast));return r.ast instanceof ze||r.ast instanceof Ue||r.beforeAst?.parentNode instanceof Ue?Array.from(new Set(t(r.item).map(n=>n.name))).map(n=>({label:`${n}`,kind:ft.CompletionItemKind.Variable})):t(r.item).length?[{label:"/delete-property/",insertText:"/delete-property/$1;",kind:ft.CompletionItemKind.Keyword,sortText:"~",insertTextFormat:ft.InsertTextFormat.Snippet}]:[]}function lx(r,e){let t=r?.ast instanceof $n?r.ast:r?.ast.parentNode;if(!r||!t||!(t instanceof $n))return[];let n=t.pathParts.slice(0,-1);if(n.some(o=>!o))return[];let s=n.map(o=>o.toString());return(()=>{let o=r.runtime.rootNode.getChildFromScope(["/",...s],e);return[...o?.nodes.filter(a=>!St(r.ast)||a.definitions.some(e))??[],...o?.deletedNodes.filter(a=>!e(a.by)).map(a=>a.node)??[]].map(a=>a.fullName)??[]})().map(o=>({label:`/${[...s,o].join("/")}`,kind:ft.CompletionItemKind.Variable}))}var ld=r=>!r||r instanceof Ae?!1:r instanceof Zt||ld(r.parentNode);function ux(r){return!r||!(r.item instanceof Xe&&r.item.ast.assignOperatorToken)?[]:!ld(r?.ast)&&!(r.ast instanceof Ae&&r.item.ast.values===null)&&!ld(r.beforeAst)&&!ld(r.afterAst)?[]:r.item.parent.nodeType instanceof Dr?Array.from([r.runtime.context.parser,...r.runtime.context.overlayParsers].at(-1)?.cPreprocessorParser.macros??[]).map(([n,s])=>s.macro.identifier instanceof fs?{label:`${s.macro.identifier.toString()} -> ${s.macro.content?.toString()??"__UNSET__"}`,insertText:`${s.macro.name}(${s.macro.identifier.params.map((i,o)=>i instanceof $t?`$${o+1}`:"").join(", ")})`,kind:ft.CompletionItemKind.Function,sortText:`~${s.macro.name}`,insertTextFormat:ft.InsertTextFormat.Snippet}:{label:s.macro.identifier.name,kind:ft.CompletionItemKind.Variable,sortText:`~${s.macro.name}`}):[]}async function KE(r,e,t,n){return Mt(r,e,(s,i)=>[...cx(s,i),...ax(s,i),...ox(s,i),...lx(s,i),...ix(s,i),...sx(s,i),...nx(s),...ux(s)],t,n)}var vn=z(J());function dx(r){if(!r||r.item===null||!(r.ast instanceof ze))return[];let e=n=>n.replacedBy?e(n.replacedBy):n,t=n=>[n.ast,...n.allReplaced.map(s=>s.ast),n.parent.deletedProperties.find(s=>s.property=n)?.by??[]].map(s=>{if(s instanceof Ae)return vn.Location.create(ce(s.uri),Q(s.propertyName??s));if(s instanceof Ue)return vn.Location.create(ce(s.uri),Q(s.propertyName??s))}).filter(s=>s);if(r.item instanceof Xe&&r.ast instanceof ze)return t(e(r.item));if(r.item instanceof Ee&&r.ast instanceof ze&&r.ast.parentNode instanceof Ue){let n=r.item.deletedProperties.find(s=>s.by===r.ast.parentNode)?.property;if(n)return t(n)}return[]}function fx(r){if(!r)return[];let e=t=>{let s=r.runtime.rootNode.getNode("aliases")?.property.filter(o=>{let a=o.ast.quickValues;if(a?.length===1&&typeof a[0]=="string"&&r.runtime.rootNode.getChild(a[0].split("/"))===t)return!0}).map(o=>o.ast)??[],i=t.parent?.deletedNodes.filter(o=>o.node===t&&(o.by.nodeNameOrRef instanceof je?o.by.nodeNameOrRef!==r.ast:!t.linkedRefLabels.some(a=>a!==r.ast))).map(o=>o.by.nodeNameOrRef)??[];return[...s,...t.linkedRefLabels,...t.linkedNodeNamePaths,...t.definitions,...i].map(o=>{if(o instanceof dt)return vn.Location.create(ce(o.uri),Q(o.name??o));if(o instanceof Re)return vn.Location.create(ce(o.uri),Q(o.name??o));if(o instanceof je)return vn.Location.create(ce(o.uri),Q(o));if(o instanceof je)return vn.Location.create(ce(o.uri),Q(o));if(o instanceof _e)return vn.Location.create(ce(o.uri),Q(o.label??o));if(o instanceof Ae)return vn.Location.create(ce((o.values??o)?.uri),Q(o.values??o))}).filter(o=>o)};if(r.item instanceof Ee&&!St(r.ast))return e(r.item);if(r.ast instanceof Lt&&r.ast.parentNode instanceof _e&&r.ast.parentNode.linksTo)return e(r.ast.parentNode.linksTo);if(r.ast instanceof je&&r.ast.linksTo)return St(r.ast)?[...e(r.ast.linksTo),vn.Location.create(ce(r.ast.uri),Q(r.ast))]:e(r.ast.linksTo);if(r?.ast instanceof Oe&&r.item instanceof Xe&&r.item.parent.name==="aliases"){let t=r.runtime.rootNode.getChild(r.ast.value.split("/"));if(t)return e(t)}return[]}async function zE(r,e,t,n){return Mt(r,e,s=>[...fx(s),...dx(s)],t,n)}var qn=z(J());function GE(r){if(!r||r.item===null||!(r.ast instanceof ze))return[];let e=n=>n.replacedBy?e(n.replacedBy):n,t=n=>[n.ast,...n.allReplaced.map(s=>s.ast),n.parent.deletedProperties.find(s=>s.property=n)?.by??[]].map(s=>{if((s instanceof Ae||s instanceof Ue)&&s.propertyName)return qn.Location.create(ce(s.uri),Q(s.propertyName))}).filter(s=>s);if(r.item instanceof Xe&&r.ast instanceof ze)return t(e(r.item));if(r.item instanceof Ee&&r.ast instanceof ze&&r.ast.parentNode instanceof Ue){let n=r.item.deletedProperties.find(s=>s.by===r.ast.parentNode)?.property;if(n)return t(n)}return[]}function YE(r,e){if(!e||!(e.ast instanceof Lt))return[];"newName"in r&&(e.ast.parentNode instanceof _e&&r.newName.startsWith("&")?r.newName=r.newName.slice(1):e.ast.parentNode instanceof ds&&r.newName.endsWith(":")&&(r.newName=r.newName.slice(0,-1)));let t=e.ast.value,n=s=>[...s.definitions.filter(i=>i instanceof Re).flatMap(i=>i.labels.map(o=>o.label)),...s.linkedRefLabels.map(i=>i.label)].filter(i=>i?.value===t).map(i=>{if(i)return qn.Location.create(ce(i.uri),Q(i))}).filter(i=>i);return e.item instanceof Ee&&!St(e.ast)?n(e.item):e.ast instanceof Lt&&e.ast.parentNode instanceof _e&&e.ast.parentNode.linksTo?n(e.ast.parentNode.linksTo):[]}function JE(r){if(!r||!(r.ast instanceof je))return[];let e=t=>{let s=r.runtime.rootNode.getNode("aliases")?.property.filter(o=>{let a=o.ast.quickValues;if(a?.length===1&&typeof a[0]=="string"){let c=r.runtime.rootNode.getChild(a[0].split("/"));if(c?.isChildOf(t)||c===t)return!0}}).map(o=>o.ast)??[],i=t.parent?.deletedNodes.filter(o=>o.node===t&&o.by.nodeNameOrRef!==r.ast).map(o=>o.by.nodeNameOrRef)??[];return[...s,...t.linkedNodeNamePaths,...t.definitions,...i].map(o=>{if(o instanceof Re&&o.name)return qn.Location.create(ce(o.uri),Q(o.name));if(o instanceof je)return qn.Location.create(ce(o.uri),Q(o));if(o instanceof Ae&&o.values?.values[0]?.value&&o.values?.values[0]?.value instanceof Oe){let a=o.values.values[0].value,c=Q(a),l=a.value.split("/"),u=t.path,d=l.slice(0,u.length-1).join("/").length+1,f=a.value.length-l.slice(0,u.length).join("/").length;return c.start.character+=1+d,c.end.character-=1+f,qn.Location.create(ce(o.values.values[0].uri),c)}}).filter(o=>o)};return r.item instanceof Ee&&!St(r.ast)?e(r.item):r.ast instanceof je&&r.ast.linksTo?St(r.ast)?[...e(r.ast.linksTo),qn.Location.create(ce(r.ast.uri),Q(r.ast))]:e(r.ast.linksTo):[]}async function XE(r,e,t,n){let s={};return(await Mt(r,e,o=>[...JE(o),...YE(r,o),...GE(o)],t,n)).forEach(o=>{s[o.uri]??=[],s[o.uri].push(qn.TextEdit.replace(o.range,r.newName))}),{changes:s}}async function QE(r,e,t,n,s){let i=await Mt(r,e,o=>[...JE(o),...YE(r,o),...GE(o)],n,s);if(i.some(o=>t.some(a=>xt(o.uri).startsWith(a))))throw new Error('Path is locked by user setting "lockRenameEdits"');return{defaultBehavior:!!i.length}}var go=z(J());function hx(r){if(!r||r.item===null||!(r.ast instanceof ze))return[];let e=n=>n.replacedBy?e(n.replacedBy):n,t=n=>[n.ast,...n.allReplaced.map(s=>s.ast)].map(s=>{if(s instanceof Ae)return go.Location.create(ce(s.uri),Q(s.propertyName??s))}).filter(s=>s);if(r.item instanceof Xe&&r.ast instanceof ze)return t(e(r.item));if(r.item instanceof Ee&&r.ast instanceof ze&&r.ast.parentNode instanceof Ue){let n=r.item.deletedProperties.find(s=>s.by===r.ast.parentNode)?.property;if(n)return t(n)}return[]}function px(r){if(!r)return[];let e=t=>[...t.definitions,...t.referencedBy].map(n=>{if(n instanceof dt)return go.Location.create(ce(n.uri),Q(n));if(n instanceof Re)return go.Location.create(ce(n.uri),Q(n));if(n instanceof Rt)return go.Location.create(ce(n.uri),Q(n))}).filter(n=>n);if(r.item instanceof Ee&&!St(r.ast))return e(r.item);if(r.ast instanceof Lt&&r.ast.parentNode instanceof _e&&r.ast.parentNode.linksTo)return e(r.ast.parentNode.linksTo);if(r.ast instanceof je&&r.ast.linksTo)return e(r.ast.linksTo);if(r?.ast instanceof Oe&&r.item instanceof Xe&&r.item.parent.name==="aliases"){let t=r.runtime.rootNode.getChild(r.ast.value.split("/"));if(t)return e(t)}return[]}function mx(r){if(r?.ast instanceof $t||r?.ast instanceof gn){let e=r.runtime.context.parser.cPreprocessorParser.macros.get(r.ast instanceof $t?r.ast.name:r.ast.value);if(e)return[go.Location.create(ce(e.macro.uri),Q(e.macro.identifier))]}return[]}async function ZE(r,e,t,n){return Mt(r,e,s=>[...px(s),...hx(s),...mx(s)],t,n)}var dd=z(J());function gx(r){if(!r||r.item===null||!(r.ast instanceof ze))return;let e=n=>n.replaces?e(n.replaces):n,t=n=>dd.Location.create(ce(n.ast.uri),Q(n.ast.propertyName??n.ast));if(r.item instanceof Xe&&r.ast instanceof ze)return t(e(r.item));if(r.item instanceof Ee&&r.ast instanceof ze&&r.ast.parentNode instanceof Ue){let n=r.item.deletedProperties.find(s=>s.by===r.ast.parentNode)?.property;if(n)return t(e(n))}}function yx(r){if(!r)return;let e=t=>{let n=t.definitions.at(0);return n?dd.Location.create(ce(n.uri),Q(n)):void 0};if(r.item instanceof Ee&&!St(r.ast))return e(r.item);if(r.ast instanceof Lt&&r.ast.parentNode instanceof _e&&r.ast.parentNode.linksTo)return e(r.ast.parentNode.linksTo);if(r.ast instanceof je&&r.ast.linksTo)return e(r.ast.linksTo);if(r?.ast instanceof Oe&&r.item instanceof Xe&&r.item.parent.name==="aliases"){let t=r.runtime.rootNode.getChild(r.ast.value.split("/"));if(t)return e(t)}}function vx(r){if(r?.ast instanceof $t||r?.ast instanceof gn){let e=r.runtime.context.parser.cPreprocessorParser.macros.get(r.ast instanceof $t?r.ast.name:r.ast.value);if(e)return dd.Location.create(ce(e.macro.uri),Q(e.macro.identifier))}}async function eN(r,e,t,n){return(await Mt(r,e,s=>[yx(s)||gx(s)||vx(s)],t,n)).at(0)}var ee=z(J());var bx=(r,e,t,n,s)=>{switch(t){case 1:return[{title:"Add semicolon",diagnostics:[n],kind:ee.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[s]:[ee.TextEdit.insert(ee.Position.create(n.range.end.line,n.range.end.character),";")]}}}];case 2:return[{title:"Add open curly",diagnostics:[n],kind:ee.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[s]:[ee.TextEdit.insert(ee.Position.create(n.range.end.line,n.range.end.character)," {")]}}}];case 29:return[{title:"Remove white space",diagnostics:[n],kind:ee.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[s]:[ee.TextEdit.replace(ee.Range.create(ee.Position.create(n.range.start.line,r.pos.col+r.pos.len),ee.Position.create(n.range.end.line,e.pos.col)),"")]}}}];case 3:return[{title:"Add close curly",diagnostics:[n],kind:ee.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[s]:[ee.TextEdit.insert(ee.Position.create(n.range.end.line,n.range.end.character),"}")]}}}];case 19:return[{title:"Add '/'",diagnostics:[n],kind:ee.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[s]:[ee.TextEdit.insert(ee.Position.create(n.range.end.line,n.range.end.character),"/")]}}}];case 28:return[{title:"Add comma",diagnostics:[n],kind:ee.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[s]:[ee.TextEdit.insert(ee.Position.create(n.range.end.line,n.range.end.character),",")]}}}];case 21:return[{title:"Add '/'",diagnostics:[n],kind:ee.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[s]:[ee.TextEdit.insert(ee.Position.create(n.range.end.line,n.range.end.character),"/")]}}}];case 23:return[{title:"Remove ';'",diagnostics:[n],kind:ee.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[s]:[ee.TextEdit.del(n.range)]}}}];case 34:return[{title:"Complete Keyword '/delete-node/",diagnostics:[n],kind:ee.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[s]:[ee.TextEdit.replace(n.range,"/delete-node/")]}}}];case 35:return[{title:"Complete Keyword '/delete-property/",diagnostics:[n],kind:ee.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[s]:[ee.TextEdit.replace(n.range,"/delete-property/")]}}}];case 25:return[{title:"Complete Keyword '/delete-property/",diagnostics:[n],kind:ee.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[s]:[ee.TextEdit.replace(n.range,"/delete-property/")]}}},{title:"Complete Keyword '/delete-node/",diagnostics:[n],kind:ee.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[s]:[ee.TextEdit.replace(n.range,"/delete-node/")]}}}];case 12:return[{title:"Add '>'",diagnostics:[n],kind:ee.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[s]:[ee.TextEdit.insert(ee.Position.create(n.range.end.line,n.range.end.character),">")]}}}];default:return}},Tx=(r,e,t,n,s,i,o)=>{if(!i)return[];switch(t){case 0:return[{title:o??`Add Property "${i.newText.split("=",1)[0].replace(";","").trim()}"`,diagnostics:[n],kind:ee.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[s]:[i]}}}];case 28:return[{title:o??"Remove Property",diagnostics:[n],kind:ee.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[s]:[i]}}}];case 27:return[{title:o??"TODO",diagnostics:[n],kind:ee.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[s]:[i]}}}];case 26:return i?[{title:o??"TODO",diagnostics:[n],kind:ee.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[s]:[i]}}}]:[];default:return}};function tN(r){let e=r.context.diagnostics.flatMap(a=>{let c=a.data;switch(c?.issues.type){case"SyntaxIssue":return c?.issues.items.flatMap(l=>bx(c.firstToken,c.lastToken,l,a,r.textDocument.uri));case"StandardTypeIssue":return c?.issues.items.flatMap(l=>Tx(c.firstToken,c.lastToken,l,a,r.textDocument.uri,c.issues.edit,c.issues.codeActionTitle))}}).filter(a=>!!a),t=e.filter(a=>a.kind===ee.CodeActionKind.SourceFixAll),n=e.filter(a=>a.title.startsWith("Add Property")),s=e.filter(a=>a.kind!==ee.CodeActionKind.SourceFixAll),i=t.flatMap(a=>a.edit?.changes?.[r.textDocument.uri]??[]),o=new Map;return n.forEach(a=>{let c=a.edit.changes[r.textDocument.uri][0],l=c.range.start.line,u=c.range.start.character;o.has(`${l}:${u}`)||o.set(`${l}:${u}`,[]),o.get(`${l}:${u}`)?.push(c)}),[...s,...t.map(a=>({...a,kind:ee.CodeActionKind.QuickFix})),...i.length?[{title:"Fix All",kind:ee.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[r.textDocument.uri]:i}}}]:[],...Array.from(o.values()).flatMap(a=>a.length>1?{title:"Add All Missing Properties",kind:ee.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[r.textDocument.uri]:a}}}:[])]}var fd=r=>!r||r instanceof Ae?!1:r instanceof Zt||fd(r.parentNode);function _x(r){if(!r||!(r.item instanceof Xe&&r.item.ast.assignOperatorToken))return[];let e=fd(r?.ast);if(!e&&!(r.ast instanceof Ae&&r.item.ast.values===null)&&!fd(r.beforeAst)&&!fd(r.afterAst))return[];let t=-1;r.item.ast.values===null?t=0:t=(r.item.ast.values?.values.findIndex(s=>s&&km(s,r.beforeAst))??-1)+1,t===-1&&(t=0);let n=r.item.parent.nodeType;return n instanceof Dr?n.properties.find(s=>s.name===r.item?.name)?.getPropertyCompletionItems(r.item,t,e)??[]:[]}function Sx(r){if(!r||!(r.item instanceof Xe&&r.ast instanceof ze&&r.item.ast.values==null||r.item instanceof Ee)||St(r.ast)||r.beforeAst?.parentNode instanceof Qt)return[];let e=t=>t.nodeType?.getPropertyListCompletionItems(t)??[];return r.item instanceof Xe?e(r.item.parent):e(r.item)}async function rN(r,e,t,n){return Mt(r,e,s=>[..._x(s),...Sx(s)],t,n)}var Am=z(J());function nN(r){return!r||r instanceof hs?r:nN(r.parentNode)}async function kx(r){if(r?.ast instanceof $t||r?.ast instanceof gn){let e=r.runtime.context.parser.cPreprocessorParser.macros.get(r?.ast instanceof $t?r.ast.name:r.ast.value);if(e){let t=nN(r.ast),n=(await r.runtime.context.getAllParsers()).at(-1);return t?{contents:{kind:Am.MarkupKind.Markdown,value:["```cpp",`#define ${e.macro.toString()} // = ${t?.evaluate(n.cPreprocessorParser.macros)}`,"```"].join(`
|
|
260
260
|
`)},range:Q(r.ast)}:{contents:{kind:Am.MarkupKind.Markdown,value:["```cpp",`#define ${e.macro.toString()} // = ${r.ast?.evaluate(n.cPreprocessorParser.macros)}`,"```"].join(`
|
|
@@ -271,4 +271,4 @@ ${n}`])]:[]}else if(e.keyword==="maxItems"||e.keyword==="minItems"){let o=i.getP
|
|
|
271
271
|
${JSON.stringify(e)}
|
|
272
272
|
${n}`])]:[C(26,s.node.definitions[0]instanceof dt?s.node.definitions[0]:s.node.definitions[0].name??s.node.definitions[0],void 0,void 0,void 0,[`${e.message??"NO MESSAGE"}:
|
|
273
273
|
${JSON.stringify(e)}
|
|
274
|
-
${n}`])]},jH=(r,e)=>KO(r,e.split("/").filter(t=>t)),KO=(r,e)=>{if(e.length===0)return{node:r,remainingInstancePath:""};let t=e[0].split("@"),n=t[0],s=t.at(1)?.split(",").map(o=>Number.parseInt(o,16)),i=r.getNode(n,s);return i?KO(i,e.slice(1)):{node:r,property:r.getProperty(e[0]),remainingInstancePath:e.slice(1).join("/")}};var xb=class r{constructor(){this.schemaIdValidators=new Map;this.ajvMap=new Map}static getNodeCompatible(e){let n=e.getProperty("compatible")?.ast.values;if(!n?.values.some(s=>!(s?.value instanceof Oe)))return n?.values.map(s=>(s?.value).value)}parseMetaSchema(e,t){fi.sync("**/*.yaml",{cwd:e}).forEach(s=>{s=(0,Ib.resolve)(e,s);try{let i=Ab.default.parse((0,Mb.readFileSync)(s,"utf-8"));t.addMetaSchema(i),this.schemaIdValidators.set(i.$id,s)}catch{}})}parseBindings(e,t){fi.sync("**/*.yaml",{cwd:e}).forEach(s=>{s=(0,Ib.resolve)(e,s);try{let i=Ab.default.parse((0,Mb.readFileSync)(s,"utf-8"));t.addSchema(i),this.schemaIdValidators.set(i.$id,s)}catch(i){console.warn(s,i.message)}})}getNodeTypes(e,t,n){let s=`${e.join(";")}::${t.join(";")}`,i=this.ajvMap.get(s);return i||(i=new GO.default({strict:!1,strictSchema:!1,strictNumbers:!1}),i.addMetaSchema(Ob),this.ajvMap.set(s,i),e.forEach(c=>this.parseMetaSchema(c,i)),t.forEach(c=>this.parseBindings(c,i))),r.getNodeCompatible(n)?.map(c=>{try{let l=Array.from(this.schemaIdValidators.keys()).find(f=>f.endsWith(`/${c}.yaml#`));if(!l)return;let u=new uh(i,l);u.bindingsPath=this.schemaIdValidators.get(l),u.compatible=c;let d=i.getSchema(l);return u.description=(d?.schema).description,u.examples=(d?.schema).examples,u.maintainers=(d?.schema).maintainers,u}catch(l){console.warn(l.message)}}).filter(c=>c)??[]}},zO,YO=()=>(zO??=new xb,zO);var ZO=z(hy());var Qo=require("path"),eA=require("fs");var Rn=z(J()),FH=r=>{switch(r){case"string":return V(3);case"int":return V(1);case"boolean":return V(0);case"array":return V(4);case"uint8-array":return V(6);case"string-array":return V(5);case"phandle":return V(1);case"phandles":return V(4);case"phandle-array":return V(4);case"path":return V([3,1]);case"compound":return V(8)}},JO=(r,e)=>{switch(r){case"string":return typeof e=="string"?e:void 0;case"int":return typeof e=="number"?e:void 0;case"boolean":return;case"array":return Array.isArray(e)&&e.every(t=>typeof t=="number")?e:void 0;case"uint8-array":return Array.isArray(e)&&e.every(t=>typeof t=="number")?e:void 0;case"string-array":return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:void 0;case"phandle":return;case"phandles":return;case"phandle-array":return;case"path":return;case"compound":return}},dh=(r,e)=>{if(e=e.include.reduce((t,n)=>{let s=r.find(i=>(0,Qo.basename)(i.filePath)===n.name);if(s){let i=n["property-blocklist"];return t.include=t.include.filter(o=>o!==n),BH(r,s,t,i)??t}return console.warn(`Unable to find ${n}`),t},e),e["child-binding"]&&(e["child-binding"].include=tA(e["child-binding"].include),e["child-binding"]=dh(r,e["child-binding"])),!e.include.length)return e},BH=(r,e,t,n=[])=>{let s=dh(r,e),i=dh(r,t);if(!s||!i)return;let o=new Set;Object.keys(s?.properties??{}).forEach(d=>o.add(d)),Object.keys(i?.properties??{}).forEach(d=>o.add(d));let a={};Array.from(o).forEach(d=>{let f=n?.some(b=>b===d)?{}:s.properties?.[d]??{},p=i.properties?.[d]??{};a={...a,[d]:{...f,...p}}}),i.properties=a;let c=new Set;return Object.keys(s).filter(d=>d.endsWith("-cells")).forEach(d=>c.add(d)),Object.keys(s).filter(d=>d.endsWith("-cells")).forEach(d=>c.add(d)),Array.from(c).forEach(d=>{let f=s[d]??[],p=i[d]??[];i[d]=Array.from([...f,...p])}),i},tA=r=>r?typeof r=="string"?[{name:r}]:r.map(e=>typeof e!="string"?e:{name:e}):[],Lb=class r{constructor(){this.typeCache=new Map;this.readFolders=[]}static getNodeCompatible(e){let n=e.getProperty("compatible")?.ast.values;if(!n?.values.some(s=>!(s?.value instanceof Oe)))return n?.values.map(s=>(s?.value).value)}getNodeTypes(e,t){let n=r.getNodeCompatible(t);if(!n)return[ti(t)];let s=n.map(o=>this.typeCache.get(o)?.(t)).filter(o=>o);if(s.length)return s;this.loadTypeAndCache(e);let i=n.map(o=>this.typeCache.get(o)?.(t)).filter(o=>o);return i.length?i:[ti(t)]}loadTypeAndCache(e){e=Array.isArray(e)?e:[e],e.forEach(t=>{if(this.readFolders.indexOf(t)!==-1)return;this.readFolders.push(t);let s=fi.sync("**/*.yaml",{cwd:t,ignore:"test/*"}).map(o=>{o=(0,Qo.resolve)(t,o);try{let a=ZO.default.parse((0,eA.readFileSync)(o,"utf-8"));return{...a,include:tA(a.include),filePath:o}}catch(a){console.warn(a)}}).filter(o=>!!o),i=s.map(o=>dh(s,o)).filter(o=>!!o&&!o.include.length);UH(i,this.typeCache)})}},XO,rA=()=>(XO??=new Lb,XO),UH=(r,e)=>r.forEach(t=>{let n=t.compatible??(t.filePath?(0,Qo.basename)(t.filePath,"yaml"):void 0);n&&e.set(n,s=>nA(t,s))}),nA=(r,e)=>{let t=ti(e);t.compatible=r.compatible??(r.filePath?(0,Qo.basename)(r.filePath,"yaml"):void 0),t.description=r.description,t.bindingsPath=r.filePath,t.bus=typeof r.bus=="string"?[r.bus]:r.bus,t.onBus=r["on-bus"];let s=Object.keys(r).filter(i=>i.endsWith("-cells")).map(i=>({specifier:i.replace(/-cells$/,""),values:r[i]}));if(r.properties&&Object.keys(r.properties).forEach(i=>{let o=r.properties[i];VH(t,i,o),t.cellsValues=s}),r["child-binding"]){let i=r["child-binding"];t.childNodeType=o=>nA(i,o)}return t},VH=(r,e,t)=>{let n=r.properties.find(s=>typeof s.name=="string"&&s.getNameMatch(e));if(n){n.required=()=>t.required?"required":"optional",n.values=()=>t.enum??[],n.constValue=JO(t.type,t.const);let s=n.additionalTypeCheck;n.additionalTypeCheck=i=>[...QO(t,e)(i),...s?.(i)??[]]}else{let s=new H(e,FH(t.type),t.required?"required":"optional",void 0,t.enum,QO(t,e));s.description=t.description?[t.description]:void 0,s.constValue=JO(t.type,t.const),r.addProperty(s)}},QO=(r,e)=>{let t=r;return n=>{let s=n.parent.root,i=[];if(t.const){let o=n.ast.quickValues;if(o?.length==1){let a=Array.isArray(t.const)?t.const:[t.const];Array.isArray(o[0])&&a.length===o[0].length&&o[0].every((l,u)=>typeof l=="number"&&Number.isNaN(l)||a[u]===l)||i.push(C(25,n.ast.values??n.ast,Rn.DiagnosticSeverity.Error,[],[],[`Binding expects values to be "${t.type}" with value: ${t.const}`]))}}if(t.deprecated&&i.push(C(14,n.ast,Rn.DiagnosticSeverity.Warning,[],[Rn.DiagnosticTag.Deprecated],[n.name])),(t.type==="phandle"||t.type==="phandles"||t.type==="path")&&er(n.ast.values)?.forEach(a=>{Yr(a,s)||i.push(C(23,a,Rn.DiagnosticSeverity.Error))}),t.type==="path"&&n.ast.values?.values.at(0)?.value instanceof Oe){let o=n.ast.values?.values.at(0)?.value,a=[];o.value.split("/").every(c=>{let l=s.getNode(c);return l?a.push(c):i.push(C(24,o,Rn.DiagnosticSeverity.Error,[],[],[c,`/${a.join("/")}`])),!l})}if(t.type==="phandle-array"){let o=er(n.ast.values),a=0;for(;o&&a<o.length;){let c=o.at(a),l=Yr(c,s);if(!l){i.push(C(23,c??n.ast,Rn.DiagnosticSeverity.Error));break}let u="";e.endsWith("-gpios")?u="gpio":u=t["specifier-space"]??e.slice(0,-1);let d=l.getProperty(`#${u}-cells`);if(!d){i.push(C(16,n.ast,Rn.DiagnosticSeverity.Error,[...l.nodeNameOrLabelRef],[],[n.name,`#${u}-cells`,`/${l.path.slice(1).join("/")}`]));break}let f=d?Ce(d,0,0)??0:0;if(1+f>o.length-a){let p=l.nodeType?.cellsValues?.find(b=>b.specifier===u)?.values;i.push(C(20,c??n.ast,Rn.DiagnosticSeverity.Error,[],[],[n.name,`<${["phandel",...p??[],...Array.from({length:f-(p?.length??0)},()=>"cell")].join(" ")}>`]));break}a+=1+f}}return i}};var fh=(r,e)=>({getNodeTypes:async t=>{switch(e){case"Zephyr":return rA().getNodeTypes(r.zephyrBindings,t);case"DevicetreeOrg":return YO().getNodeTypes(r.deviceOrgBindingsMetaSchema,r.deviceOrgTreeBindings,t)}}});var qb=z(J());var $b=r=>!r.openScope||!r.closeScope?.prevToken?r.nodes.flatMap($b):[{startLine:r.openScope.pos.line,startCharacter:r.openScope.pos.col,endLine:r.closeScope.prevToken.pos.line,endCharacter:r.closeScope.prevToken.pos.col,kind:qb.FoldingRangeKind.Region},...r.nodes.flatMap($b)],sA=r=>{let e=[];return[...r instanceof ms?r.ifBlocks.map(t=>({start:(t.expression??t.keyword).lastToken,end:t.content?.lastToken??(t.expression??t.keyword).lastToken})):[{start:(r.ifDef.identifier??r.ifDef.keyword).lastToken,end:r.ifDef.content?.lastToken}],r.elseOption?{start:r.elseOption.keyword.lastToken,end:r.elseOption.content?.lastToken}:null].forEach(t=>{!t||!t.end||e.push({startLine:t.start.pos.line,startCharacter:t.start.pos.col,endLine:t.end.pos.line,endCharacter:t.end.pos.col+t.end.pos.len,kind:qb.FoldingRangeKind.Region})}),e},WH=r=>r instanceof qe?$b(r):r instanceof lo||r instanceof ms?sA(r):[];function iA(r,e){return e.allAstItems.flatMap(t=>[t,...t.allDescendants]).filter(t=>t.uri===r).flatMap(WH)}var Ei=z(J());function HH(r){if(!r||!(r.ast instanceof je)&&!(r.ast instanceof Lt))return[];let e=t=>t.nodeType?.bindingsPath?[Ei.Location.create(ce(t.nodeType.bindingsPath),Ei.Range.create(Ei.Position.create(0,0),Ei.Position.create(0,0)))]:[];return r.item instanceof Ee&&!St(r.ast)?e(r.item):r.ast instanceof Lt&&r.ast.parentNode instanceof _e&&r.ast.parentNode.linksTo?e(r.ast.parentNode.linksTo):r.ast instanceof je&&r.ast.linksTo?e(r.ast.linksTo):[]}async function oA(r,e,t,n){return Mt(r,e,s=>[...HH(s)],t,n)}var Cn=require("path");var ph=require("fs");var KH=(r,e)=>{Xr().reset(r),Xr().requestTokens(r,!0),e(r)},hh=class{constructor(e,t,n){this.file=e;this.cb=t;this.hasDocumentOpen=n;this.count=0}watch(){if(this.count++,this.count===1){console.log("create watch for",this.file);let e=this.file,t=this.cb;this.onChange=()=>{if(this.hasDocumentOpen(e)){console.log("skipping on change document is open",e);return}console.log("onChange",e),KH(e,t)},(0,ph.watchFile)(e,this.onChange)}}unwatch(){this.count--,this.count===0&&(console.log("dispose watch for",this.file),(0,ph.unwatchFile)(this.file,this.onChange),this.onChange=void 0)}};var We=[],nt,jb,tl=new WeakMap,mh=new Map,Fb=r=>{We.some(e=>e===r)||(We.push(r),aA(r))},aA=async r=>{await r.stable(),r.getContextFiles().forEach(e=>{mh.has(e)||mh.set(e,new hh(e,zb,t=>!!yh(t))),mh.get(e)?.watch()})},Wb=async r=>{let e=We.indexOf(r);e!==-1&&(vh(r),tl.delete(r),console.log(`cleaning up context with ID ${r.name} and uri ${r.parser.uri}`),We.splice(e,1),cA(r))},cA=async r=>{await r.stable(),r.getContextFiles().forEach(e=>mh.get(e)?.unwatch())},zH=r=>{let e=tl.get(r);if(!e?.abort.signal.aborted)return Promise.all([e?.promise,r.getRuntime()])},At=async()=>{await Kb,await Promise.all(We.map(zH))},gh=r=>{let e=lA(r);return We.filter(t=>!e.some(n=>n===t))},lA=r=>We.filter(e=>{let t=r.contexts?.find(n=>n.dtsFile===e.parser.uri);return!!t&&t.overlays?.every(n=>e.overlays.some(s=>s===n))}),GH=async(r,e)=>{if(r===e)return!0;let t=(await r.getAllParsers()).flatMap(s=>s.cPreprocessorParser.dtsIncludes),n=(await e.getAllParsers()).flatMap(s=>s.cPreprocessorParser.dtsIncludes);return t.length?t.every(s=>n.some(i=>i.resolvedPath===s.resolvedPath&&i.firstToken.pos.col===s.firstToken.pos.col&&i.firstToken.pos.len===s.firstToken.pos.len&&i.firstToken.pos.line===s.firstToken.pos.line&&i.lastToken.pos.col===s.lastToken.pos.col&&i.lastToken.pos.len===s.lastToken.pos.len&&i.lastToken.pos.line===s.lastToken.pos.line)):e.getContextFiles().some(s=>s===r.parser.uri)},uA=r=>gh(pe).indexOf(r)!==-1,dA=async r=>{if(!uA(r))return;let e=gh(pe),t=await lA(pe),n=await ju(e),s=[...r.overlayParsers.map(a=>a.uri),r.parser.uri,...r.parser.includes.map(a=>a.resolvedPath)];if(We.indexOf(r)===-1)return;let i=await Promise.all(n.flatMap(a=>[...t,...e.filter(c=>c!==a.context)].map(async c=>({context:a.context,same:await GH(a.context,c)})))),o=n.filter(a=>i.some(c=>c.context===a.context&&c.same)||a.context!==r&&a.context.parser.uri===r.parser.uri&&s.some(c=>c&&a.files.indexOf(c)!==-1)).map(a=>a.context);o.length&&o.forEach(Wb)},ve=(0,xe.createConnection)(xe.ProposedFeatures.all),$s=new xe.TextDocuments(Lu),Hb=!1,Bb=!1,fA=!1,Ub;ve.onInitialize(r=>{Ub=r.workspaceFolders,ve.console.log(`[Server(${process.pid}) ${Ub?.[0].uri}] Started and initialize received`);let e=r.capabilities;Hb=!!(e.workspace&&e.workspace.configuration),Bb=!!(e.workspace&&e.workspace.workspaceFolders),fA=!!e.workspace?.diagnostics?.refreshSupport;let t={capabilities:{typeDefinitionProvider:!0,workspaceSymbolProvider:!0,textDocumentSync:xe.TextDocumentSyncKind.Incremental,renameProvider:{prepareProvider:!0},completionProvider:{resolveProvider:!0,triggerCharacters:["&","="," "]},codeActionProvider:{codeActionKinds:[xe.CodeActionKind.QuickFix,xe.CodeActionKind.SourceFixAll]},documentSymbolProvider:!0,semanticTokensProvider:{legend:{tokenTypes:$u,tokenModifiers:qu},full:!0},documentLinkProvider:{resolveProvider:!1},foldingRangeProvider:!0,definitionProvider:!0,declarationProvider:!0,referencesProvider:!0,documentFormattingProvider:!0,hoverProvider:!0}};return Bb&&(t.capabilities.workspace={workspaceFolders:{changeNotifications:!0,supported:!0}}),t});ve.onInitialized(()=>{Hb&&ve.client.register(xe.DidChangeConfigurationNotification.type,{}),Bb&&ve.workspace.onDidChangeWorkspaceFolders(async r=>{ve.console.log("Workspace folder change event received"),await Kb,await mA(pe,pe)})});var hA={defaultBindingType:"Zephyr",defaultZephyrBindings:[],defaultIncludePaths:[],defaultDeviceOrgBindingsMetaSchema:[],defaultDeviceOrgTreeBindings:[],contexts:[],lockRenameEdits:[],allowAdhocContexts:!0,autoChangeContext:!0},pe=hA,pA=new Map,Vb=!1,Kb=new Promise(r=>{let e=setInterval(()=>{Vb&&(r(),clearInterval(e))},100)}),Zo=async r=>{let e=(await ve.workspace.getWorkspaceFolders()??Ub)?.map(t=>xt(t.uri));return e?.length&&(r=r.replaceAll("${workspaceFolder}",e[0])),r},YH=r=>{if(r.cwd||pe.cwd){let e=r.cwd??pe.cwd;r.includePaths??=pe.defaultIncludePaths,r.zephyrBindings??=pe.defaultIncludePaths,r.bindingType??=pe.defaultBindingType,r.deviceOrgTreeBindings??=pe.defaultDeviceOrgTreeBindings,r.deviceOrgBindingsMetaSchema??=pe.defaultDeviceOrgBindingsMetaSchema,e&&r.bindingType==="Zephyr"&&(!r.zephyrBindings||r.zephyrBindings.length===0)&&(r.zephyrBindings=["./zephyr/dts/bindings"]),r.zephyrBindings=r.zephyrBindings?.map(t=>(0,Cn.resolve)(e,t)),r.deviceOrgTreeBindings=r.deviceOrgTreeBindings?.map(t=>(0,Cn.resolve)(e,t)),r.deviceOrgBindingsMetaSchema=r.deviceOrgBindingsMetaSchema?.map(t=>(0,Cn.resolve)(e,t)),r.includePaths=r.includePaths?.map(t=>(0,Cn.resolve)(e,t)),r.dtsFile=(0,Cn.resolve)(e,r.dtsFile)}},JH=async r=>{r.cwd=r.cwd?await Zo(r.cwd):void 0,r.defaultDeviceOrgBindingsMetaSchema=await Promise.all((r.defaultDeviceOrgBindingsMetaSchema??[]).map(Zo)),r.defaultDeviceOrgTreeBindings=await Promise.all((r.defaultDeviceOrgTreeBindings??[]).map(Zo)),r.defaultIncludePaths=await Promise.all((r.defaultIncludePaths??[]).map(Zo)),r.defaultZephyrBindings=await Promise.all((r.defaultZephyrBindings??[]).map(Zo)),r.lockRenameEdits=await Promise.all((r.lockRenameEdits??[]).map(Zo)),r.defaultIncludePaths=(r.defaultIncludePaths??[]).map(e=>r.cwd?(0,Cn.resolve)(r.cwd,e):e),r.cwd&&r.defaultBindingType==="Zephyr"&&!r.defaultZephyrBindings&&(r.defaultZephyrBindings=["./zephyr/dts/bindings"]),r.defaultZephyrBindings=(r.defaultZephyrBindings??[]).map(e=>r.cwd?(0,Cn.resolve)(r.cwd,e):e),r.defaultDeviceOrgBindingsMetaSchema=(r.defaultDeviceOrgBindingsMetaSchema??[]).map(e=>r.cwd?(0,Cn.resolve)(r.cwd,e):e),r.defaultDeviceOrgTreeBindings=(r.defaultDeviceOrgTreeBindings??[]).map(e=>r.cwd?(0,Cn.resolve)(r.cwd,e):e),r.contexts?.forEach(YH)},mA=async(r,e)=>{await JH(e),console.log("Resolve settings",JSON.stringify(e,void 0," ")),We.forEach(Wb),tl=new WeakMap,e.contexts?.forEach((n,s)=>{let i=n.bindingType,o=new po(n.dtsFile,n.includePaths??[],i?fh({zephyrBindings:n.zephyrBindings??[],deviceOrgBindingsMetaSchema:n.deviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:n.deviceOrgTreeBindings??[]},i):void 0,n.overlays,n.ctxName);Fb(o),console.log(`New context with ID ${o.name} for ${n.dtsFile}`)});let t=r?gh(r):[];t.map(n=>{let s=e.defaultBindingType,i=new po(n.parser.uri,e.defaultIncludePaths??[],s?fh({zephyrBindings:e.defaultZephyrBindings??[],deviceOrgBindingsMetaSchema:e.defaultDeviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:e.defaultDeviceOrgTreeBindings??[]},s):void 0);return console.log(`New context with ID ${i.name} for ${n.parser.uri}`),i}).forEach(Fb),t=gh(e),t.forEach(dA),jb&&rl(jb,!0),fA&&ve.languages.diagnostics.refresh()};ve.onDidChangeConfiguration(async r=>{let e;Vb&&(e=pe),r.settings&&(console.log("Configuration changed",JSON.stringify(r,void 0," ")),Hb&&pA.clear(),pe={...hA,...r.settings?.devicetree},await mA(e,pe),Vb=!0)});$s.onDidClose(r=>{let e=xt(r.document.uri),t=nt;if(!t)return;(t?.getContextFiles()??[]).filter(i=>i!==e).some(i=>yh(i))||(uA(t)?Wb(t):vh(t),nt=void 0),pA.delete(r.document.uri)});$s.onDidOpen(async r=>{await At();let e=nt,t=xt(r.document.uri);e||ve.sendDiagnostics({uri:r.document.uri,version:$s.get(r.document.uri)?.version,diagnostics:[{severity:xe.DiagnosticSeverity.Warning,range:xe.Range.create(xe.Position.create(0,0),xe.Position.create(0,0)),message:"File has no context",source:"devicetree"}]}),zb(t)});var XH=r=>{switch(r){case 0:return"Expected value";case 1:return"Expected ';'";case 2:return"Expected '{'";case 3:return"Expected '}'";case 4:return"Expected '['";case 5:return"Expected ']'";case 12:return"Expected '>'";case 13:return"Expected '<'";case 16:return`Expected '"'`;case 17:return`Expected "'"\\`;case 24:return"Missing ':'";case 21:return"Missing '/'";case 26:return'Expected ")"';case 28:return'Missing ","';case 6:return"Expected property name";case 7:return"Expected node name";case 8:return"Expected node address";case 9:return"Expected node path";case 10:return"Expected node reference";case 11:return"Expected root node name";case 14:return"Expected bytestring";case 15:return"Expected two digits for each byte in bytestring";case 20:return"Hex values are not allowed";case 18:return"Expected label name";case 19:return"Expected '/' at the start of a node path";case 23:return"Found ';' without a statement";case 25:return"Did you mean /delete-node/ or /delete-property/?";case 34:return"Did you mean /delete-node/?";case 35:return"Did you mean /delete-property/?";case 22:return"Unknown syntax";case 27:return"Expected expression";case 31:return"Expected macro identifier";case 30:return"Expected macro identifier or function like macro";case 29:return"White space is not allowed";case 32:return"Properties can only be defined in a node";case 33:return"Properties can only be deleted inside a node";case 36:return"Unable to resolve include";case 37:return"Expedted start address";case 38:return"Expected end address";case 39:case 40:return"Expected 8|16|32|64";case 42:return"Unkown macro name";case 43:return"Expected function like macro";case 44:return"Macro expects less arguments";case 45:return"Macro expects more arguments";case 46:return"Missing #ENDIF";case 47:return"Block Unused";case 41:return"This syntax is not officially part of the DTS V0.4 standard"}},QH=r=>r.issues.map(e=>{switch(e){case 0:return`Property "${r.templateStrings[0]}" is replaced by a later definition`;case 1:return"Cannot delete a property before it has been defined";case 2:return"Node name already defined";case 5:return"Cannot delete a node before it has been defined";case 3:return`No node with that reference "${r.templateStrings[0]}" has been defined`;case 8:return`No node with name "${r.templateStrings[0]}" could be found in "/${r.templateStrings[1]}".`;case 4:return`Label name "${r.templateStrings[0]}" already defined`;case 6:return`Property "${r.templateStrings[0]}" was deleted`;case 7:return`Node "${r.templateStrings[0]}" was deleted`;case 9:return`The following node "${r.templateStrings[1]}" shall be present in "${r.templateStrings[0]}" node.`}}).join(" or "),ZH=r=>{switch(r){case 0:return"Property name already defined.";case 2:return"Defined here";case 4:return"Defined here";case 7:case 6:return"Deleted here";case 9:return"Node";default:return"TODO"}},eK=r=>r.issues.map(e=>{switch(e){case 9:return`Only these value are allowed ${r.templateStrings[0]}`;case 1:return"INTRO should be empty";case 8:return"INTRO can only be assigned one value";case 5:return"INTRO should be assigned a U32";case 6:return"INTRO should be assigned a U64";case 7:return"INTRO should be assigned a 'property encoded array'";case 2:return"INTRO should be assigned a string";case 3:return"INTRO should be assigned a string list";case 4:return`INTRO expects ${r.templateStrings[1]} values`;case 0:return"INTRO is required";case 11:return"INTRO should be omitted";case 28:return"INTRO name is not permited under this node";case 10:return"INTRO first value must match node address";case 12:return"INTRO should be 'cpu'";case 13:return"INTRO should be 'memory'";case 14:return"INTRO is deprecated and should not be used'";case 15:return`INTRO ${r.templateStrings[1]}'`;case 19:return"INTRO value must be unique in the entire Devicetree";case 20:return`INTRO should have format ${r.templateStrings[1]}`;case 16:return`INTRO requires property "${r.templateStrings[1]}" in node path "${r.templateStrings[2]}"`;case 18:return"Unable to resolve interrupt parent node";case 17:return`INTRO expects ${r.templateStrings[1]} interrupt cells`;case 21:return`INTRO should have format ${r.templateStrings[1]}`;case 22:return"Node is disabled";case 23:return"Unable to resolve handle";case 24:return`Unable to find "${r.templateStrings[0]}" in ${r.templateStrings[1]}`;case 25:return r.templateStrings[0];case 26:return r.templateStrings[0];case 27:return r.templateStrings[0];case 29:return r.templateStrings[0]}}).join(" or ").replace("INTRO",`Property "${r.templateStrings[0]}"`).replaceAll("INTRO ",""),tK=r=>{switch(r){case 16:case 0:return"Node";case 17:return"Property";case 15:return"Ignored reason";case 19:return"Conflicting properties";case 8:return"Additional value";case 22:return"Disabled by";default:return"TODO"}},zb=async r=>{await Kb;let e=Ow(We,r);if(e.length)e.forEach(t=>{tl.get(t.context)?.abort.abort();let n=new AbortController,s=new Promise(i=>{setTimeout(async()=>{if(n.signal.aborted){i();return}let o=performance.now(),a=gA(t.context);cA(t.context),await t.context.reevaluate(r),aA(t.context),Gb(t.context).then(c=>{vh(t.context,a),c.items.map(l=>({uri:l.uri,version:l.version??void 0,diagnostics:l.items})).forEach(l=>{ve.sendDiagnostics(l)})}),i(),console.log("reevaluate",performance.now()-o)},50)});tl.set(t.context,{abort:n,promise:s})});else{if(pe.allowAdhocContexts===!1)return;let t=pe.defaultBindingType,n=new po(r,pe.defaultIncludePaths??[],t?fh({zephyrBindings:pe.defaultZephyrBindings??[],deviceOrgBindingsMetaSchema:pe.defaultDeviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:pe.defaultDeviceOrgTreeBindings??[]},t):void 0);console.log(`New ad hoc context with ID ${n.name} for ${r}`),Fb(n),rl(r),await n.parser.stable,dA(n)}};$s.onDidChangeContent(async r=>{let e=xt(r.document.uri),t=r.document.getText(),n=Xr();n.needsRenew(e,t)&&(console.log("Content changed"),n.renewLexer(e,t),zb(e))});var rK=r=>$s.keys().find(e=>Mw(xt(e),r)),yh=r=>{let e=rK(r);if(e)return $s.get(e)},gA=r=>r.getContextFiles().map(e=>({uri:ce(e),version:yh(e)?.version,diagnostics:[]})),vh=async(r,e=gA(r))=>await Promise.all(e.map(t=>ve.sendDiagnostics({uri:t.uri,version:$s.get(t.uri)?.version,diagnostics:[]}))),Gb=async r=>{await r.stable();let e=performance.now(),t=await Promise.all(r.getContextFiles().map(async n=>{let s=await nK(r,n);return{uri:ce(n),kind:xe.DocumentDiagnosticReportKind.Full,items:s,version:yh(n)?.version??null}}));return console.log("workspace diagnostics",r.name,performance.now()-e),{items:[...t]}};ve.languages.diagnostics.onWorkspace(async()=>{await At();let r=nt;return r?Gb(r):{items:[]}});async function nK(r,e){try{let t=[];return r.isInContext(e)?(r.parser.issues.filter(i=>i.astElement.uri===e).forEach(i=>{let o={severity:i.severity,range:Q(i.astElement),message:i.issues?i.issues.map(XH).join(" or "):"",source:"devicetree",tags:i.tags,data:{firstToken:{pos:i.astElement.firstToken.pos,tokens:i.astElement.firstToken.tokens,value:i.astElement.firstToken.value},lastToken:{pos:i.astElement.lastToken.pos,tokens:i.astElement.lastToken.tokens,value:i.astElement.lastToken.value},issues:{type:"SyntaxIssue",items:i.issues,edit:i.edit,codeActionTitle:i.codeActionTitle}}};t.push(o)}),(await r.getContextIssues()??[]).filter(i=>i.astElement.uri===e).forEach(i=>{let o={severity:i.severity,range:Q(i.astElement),message:QH(i),source:"devicetree",tags:i.tags,relatedInformation:[...i.linkedTo.map(a=>({message:i.issues.map(ZH).join(" or "),location:{uri:ce(a.uri),range:Q(a)}}))]};t.push(o)}),(await r.getRuntime())?.typesIssues.filter(i=>i.astElement.uri===e).forEach(i=>{let o={severity:i.severity,range:Q(i.astElement),message:eK(i),relatedInformation:[...i.linkedTo.map(a=>({message:i.issues.map(tK).join(" or "),location:{uri:ce(a.uri),range:Q(a)}}))],source:"devicetree",tags:i.tags,data:{firstToken:{pos:i.astElement.firstToken.pos,tokens:i.astElement.firstToken.tokens,value:i.astElement.firstToken.value},lastToken:{pos:i.astElement.lastToken.pos,tokens:i.astElement.lastToken.tokens,value:i.astElement.lastToken.value},issues:{type:"StandardTypeIssue",items:i.issues,edit:i.edit,codeActionTitle:i.codeActionTitle}}};t.push(o)}),t):[{severity:xe.DiagnosticSeverity.Warning,range:xe.Range.create(xe.Position.create(0,0),xe.Position.create(0,0)),message:"File not in use by the active context",source:"devicetree"}]}catch(t){throw console.error(t),t}}ve.onDidChangeWatchedFiles(r=>{ve.console.log("We received a file change event")});ve.onCompletion(async r=>(await At(),We?[...await KE(r,We,nt,pe.preferredContext),...await rN(r,We,nt,pe.preferredContext)]:[]));ve.onCompletionResolve(r=>r);$s.listen(ve);ve.listen();var rl=async(r,e=!1)=>{if(!e&&pe.autoChangeContext===!1||(jb=r,await At(),nt?.getContextFiles().find(s=>s===r)))return;let t=nt;nt=Qs(We,r,void 0,pe.preferredContext)?.context;let n=nt;t!==n&&(t&&await vh(t),n&&Gb(n).then(s=>{s.items.map(i=>({uri:i.uri,version:i.version??void 0,diagnostics:i.items})).forEach(i=>{ve.sendDiagnostics(i)})}),console.log(`(ID: ${n?.name??-1}) activeContext:`,n?.parser.uri),We.forEach((s,i)=>{console.log(`Context with ID ${s.name} for ${s.parser.uri}`)}))};ve.onDocumentSymbol(async r=>{await At();let e=xt(r.textDocument.uri);await rl(e);let n=await nt?.parser;return n?n.getDocumentSymbols(e):[]});ve.onWorkspaceSymbol(async()=>{await At();let r=nt;return r?(await r.getAllParsers()).flatMap(e=>e.getWorkspaceSymbols()):[]});ve.languages.semanticTokens.on(async r=>{try{await At();let e=xt(r.textDocument.uri);await rl(e);let t=new xe.SemanticTokensBuilder,n=await Qs(We,e,nt,pe.preferredContext),s=n?.context.isInContext(e);return!n||!s?{data:[]}:(n.context.parser.buildSemanticTokens(t,e),t.build())}catch(e){throw console.log(e),e}});ve.onDocumentLinks(async r=>{let e=xt(r.textDocument.uri);return await At(),(await Qs(We,e,nt,pe.preferredContext))?.context.getDocumentLinks(e)});ve.onPrepareRename(async r=>(await At(),QE(r,We,pe.lockRenameEdits??[],nt,pe.preferredContext)));ve.onRenameRequest(async r=>(await At(),XE(r,We,nt,pe.preferredContext)));ve.onReferences(async r=>(await At(),zE(r,We,nt,pe.preferredContext)));ve.onDefinition(async r=>{let e=xt(r.textDocument.uri);await At();let n=(await(await Qs(We,e,nt,pe.preferredContext))?.context.getDocumentLinks(e,r.position))?.filter(s=>s.target).map(s=>xe.Location.create(s.target,s.range))??[];return n.length?n:ZE(r,We,nt,pe.preferredContext)});ve.onDeclaration(async r=>(await At(),eN(r,We,nt,pe.preferredContext)));ve.onCodeAction(async r=>tN(r));ve.onDocumentFormatting(async r=>{let e=xt(r.textDocument.uri);await At();let t=await Qs(We,e,nt,pe.preferredContext);return t?Ww(r,t.context):[]});ve.onHover(async r=>(await At(),(await sN(r,We,nt,pe.preferredContext)).at(0)));ve.onRequest("devicetree/contexts",async()=>(await At(),We.map(r=>r.parser.uri)));ve.onFoldingRanges(async r=>{await At();let e=xt(r.textDocument.uri);await rl(e);let t=nt,n=t?.isInContext(e);if(!t||!n)return[];let s=(await t.getAllParsers()).find(i=>i.getFiles().some(o=>o===e));return s?iA(e,s):[]});ve.onTypeDefinition(async r=>(await At(),oA(r,We,nt)));
|
|
274
|
+
${n}`])]},jH=(r,e)=>KO(r,e.split("/").filter(t=>t)),KO=(r,e)=>{if(e.length===0)return{node:r,remainingInstancePath:""};let t=e[0].split("@"),n=t[0],s=t.at(1)?.split(",").map(o=>Number.parseInt(o,16)),i=r.getNode(n,s);return i?KO(i,e.slice(1)):{node:r,property:r.getProperty(e[0]),remainingInstancePath:e.slice(1).join("/")}};var xb=class r{constructor(){this.schemaIdValidators=new Map;this.ajvMap=new Map}static getNodeCompatible(e){let n=e.getProperty("compatible")?.ast.values;if(!n?.values.some(s=>!(s?.value instanceof Oe)))return n?.values.map(s=>(s?.value).value)}parseMetaSchema(e,t){fi.sync("**/*.yaml",{cwd:e}).forEach(s=>{s=(0,Ib.resolve)(e,s);try{let i=Ab.default.parse((0,Mb.readFileSync)(s,"utf-8"));t.addMetaSchema(i),this.schemaIdValidators.set(i.$id,s)}catch{}})}parseBindings(e,t){fi.sync("**/*.yaml",{cwd:e}).forEach(s=>{s=(0,Ib.resolve)(e,s);try{let i=Ab.default.parse((0,Mb.readFileSync)(s,"utf-8"));t.addSchema(i),this.schemaIdValidators.set(i.$id,s)}catch(i){console.warn(s,i.message)}})}getNodeTypes(e,t,n){let s=`${e.join(";")}::${t.join(";")}`,i=this.ajvMap.get(s);return i||(i=new GO.default({strict:!1,strictSchema:!1,strictNumbers:!1}),i.addMetaSchema(Ob),this.ajvMap.set(s,i),e.forEach(c=>this.parseMetaSchema(c,i)),t.forEach(c=>this.parseBindings(c,i))),r.getNodeCompatible(n)?.map(c=>{try{let l=Array.from(this.schemaIdValidators.keys()).find(f=>f.endsWith(`/${c}.yaml#`));if(!l)return;let u=new uh(i,l);u.bindingsPath=this.schemaIdValidators.get(l),u.compatible=c;let d=i.getSchema(l);return u.description=(d?.schema).description,u.examples=(d?.schema).examples,u.maintainers=(d?.schema).maintainers,u}catch(l){console.warn(l.message)}}).filter(c=>c)??[]}},zO,YO=()=>(zO??=new xb,zO);var ZO=z(hy());var Qo=require("path"),eA=require("fs");var Rn=z(J()),FH=r=>{switch(r){case"string":return V(3);case"int":return V(1);case"boolean":return V(0);case"array":return V(4);case"uint8-array":return V(6);case"string-array":return V(5);case"phandle":return V(1);case"phandles":return V(4);case"phandle-array":return V(4);case"path":return V([3,1]);case"compound":return V(8)}},JO=(r,e)=>{switch(r){case"string":return typeof e=="string"?e:void 0;case"int":return typeof e=="number"?e:void 0;case"boolean":return;case"array":return Array.isArray(e)&&e.every(t=>typeof t=="number")?e:void 0;case"uint8-array":return Array.isArray(e)&&e.every(t=>typeof t=="number")?e:void 0;case"string-array":return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:void 0;case"phandle":return;case"phandles":return;case"phandle-array":return;case"path":return;case"compound":return}},dh=(r,e)=>{if(e=e.include.reduce((t,n)=>{let s=r.find(i=>(0,Qo.basename)(i.filePath)===n.name);if(s){let i=n["property-blocklist"];return t.include=t.include.filter(o=>o!==n),BH(r,s,t,i)??t}return console.warn(`Unable to find ${n}`),t},e),e["child-binding"]&&(e["child-binding"].include=tA(e["child-binding"].include),e["child-binding"]=dh(r,e["child-binding"])),!e.include.length)return e},BH=(r,e,t,n=[])=>{let s=dh(r,e),i=dh(r,t);if(!s||!i)return;let o=new Set;Object.keys(s?.properties??{}).forEach(d=>o.add(d)),Object.keys(i?.properties??{}).forEach(d=>o.add(d));let a={};Array.from(o).forEach(d=>{let f=n?.some(b=>b===d)?{}:s.properties?.[d]??{},p=i.properties?.[d]??{};a={...a,[d]:{...f,...p}}}),i.properties=a;let c=new Set;return Object.keys(s).filter(d=>d.endsWith("-cells")).forEach(d=>c.add(d)),Object.keys(s).filter(d=>d.endsWith("-cells")).forEach(d=>c.add(d)),Array.from(c).forEach(d=>{let f=s[d]??[],p=i[d]??[];i[d]=Array.from([...f,...p])}),i},tA=r=>r?typeof r=="string"?[{name:r}]:r.map(e=>typeof e!="string"?e:{name:e}):[],Lb=class r{constructor(){this.typeCache=new Map;this.readFolders=[]}static getNodeCompatible(e){let n=e.getProperty("compatible")?.ast.values;if(!n?.values.some(s=>!(s?.value instanceof Oe)))return n?.values.map(s=>(s?.value).value)}getNodeTypes(e,t){let n=r.getNodeCompatible(t);if(!n)return[ti(t)];let s=n.map(o=>this.typeCache.get(o)?.(t)).filter(o=>o);if(s.length)return s;this.loadTypeAndCache(e);let i=n.map(o=>this.typeCache.get(o)?.(t)).filter(o=>o);return i.length?i:[ti(t)]}loadTypeAndCache(e){e=Array.isArray(e)?e:[e],e.forEach(t=>{if(this.readFolders.indexOf(t)!==-1)return;this.readFolders.push(t);let s=fi.sync("**/*.yaml",{cwd:t,ignore:"test/*"}).map(o=>{o=(0,Qo.resolve)(t,o);try{let a=ZO.default.parse((0,eA.readFileSync)(o,"utf-8"));return{...a,include:tA(a.include),filePath:o}}catch(a){console.warn(a)}}).filter(o=>!!o),i=s.map(o=>dh(s,o)).filter(o=>!!o&&!o.include.length);UH(i,this.typeCache)})}},XO,rA=()=>(XO??=new Lb,XO),UH=(r,e)=>r.forEach(t=>{let n=t.compatible??(t.filePath?(0,Qo.basename)(t.filePath,"yaml"):void 0);n&&e.set(n,s=>nA(t,s))}),nA=(r,e)=>{let t=ti(e);t.compatible=r.compatible??(r.filePath?(0,Qo.basename)(r.filePath,"yaml"):void 0),t.description=r.description,t.bindingsPath=r.filePath,t.bus=typeof r.bus=="string"?[r.bus]:r.bus,t.onBus=r["on-bus"];let s=Object.keys(r).filter(i=>i.endsWith("-cells")).map(i=>({specifier:i.replace(/-cells$/,""),values:r[i]}));if(r.properties&&Object.keys(r.properties).forEach(i=>{let o=r.properties[i];VH(t,i,o),t.cellsValues=s}),r["child-binding"]){let i=r["child-binding"];t.childNodeType=o=>nA(i,o)}return t},VH=(r,e,t)=>{let n=r.properties.find(s=>typeof s.name=="string"&&s.getNameMatch(e));if(n){n.required=()=>t.required?"required":"optional",n.values=()=>t.enum??[],n.constValue=JO(t.type,t.const);let s=n.additionalTypeCheck;n.additionalTypeCheck=i=>[...QO(t,e)(i),...s?.(i)??[]]}else{let s=new H(e,FH(t.type),t.required?"required":"optional",void 0,t.enum,QO(t,e));s.description=t.description?[t.description]:void 0,s.constValue=JO(t.type,t.const),r.addProperty(s)}},QO=(r,e)=>{let t=r;return n=>{let s=n.parent.root,i=[];if(t.const){let o=n.ast.quickValues;if(o?.length==1){let a=Array.isArray(t.const)?t.const:[t.const];Array.isArray(o[0])&&a.length===o[0].length&&o[0].every((l,u)=>typeof l=="number"&&Number.isNaN(l)||a[u]===l)||i.push(C(25,n.ast.values??n.ast,Rn.DiagnosticSeverity.Error,[],[],[`Binding expects values to be "${t.type}" with value: ${t.const}`]))}}if(t.deprecated&&i.push(C(14,n.ast,Rn.DiagnosticSeverity.Warning,[],[Rn.DiagnosticTag.Deprecated],[n.name])),(t.type==="phandle"||t.type==="phandles"||t.type==="path")&&er(n.ast.values)?.forEach(a=>{Yr(a,s)||i.push(C(23,a,Rn.DiagnosticSeverity.Error))}),t.type==="path"&&n.ast.values?.values.at(0)?.value instanceof Oe){let o=n.ast.values?.values.at(0)?.value,a=[];o.value.split("/").every(c=>{let l=s.getNode(c);return l?a.push(c):i.push(C(24,o,Rn.DiagnosticSeverity.Error,[],[],[c,`/${a.join("/")}`])),!l})}if(t.type==="phandle-array"){let o=er(n.ast.values),a=0;for(;o&&a<o.length;){let c=o.at(a),l=Yr(c,s);if(!l){i.push(C(23,c??n.ast,Rn.DiagnosticSeverity.Error));break}let u="";e.endsWith("-gpios")?u="gpio":u=t["specifier-space"]??e.slice(0,-1);let d=l.getProperty(`#${u}-cells`);if(!d){i.push(C(16,n.ast,Rn.DiagnosticSeverity.Error,[...l.nodeNameOrLabelRef],[],[n.name,`#${u}-cells`,`/${l.path.slice(1).join("/")}`]));break}let f=d?Ce(d,0,0)??0:0;if(1+f>o.length-a){let p=l.nodeType?.cellsValues?.find(b=>b.specifier===u)?.values;i.push(C(20,c??n.ast,Rn.DiagnosticSeverity.Error,[],[],[n.name,`<${["phandel",...p??[],...Array.from({length:f-(p?.length??0)},()=>"cell")].join(" ")}>`]));break}a+=1+f}}return i}};var fh=(r,e)=>({getNodeTypes:async t=>{switch(e){case"Zephyr":return rA().getNodeTypes(r.zephyrBindings,t);case"DevicetreeOrg":return YO().getNodeTypes(r.deviceOrgBindingsMetaSchema,r.deviceOrgTreeBindings,t)}}});var qb=z(J());var $b=r=>!r.openScope||!r.closeScope?.prevToken?r.nodes.flatMap($b):[{startLine:r.openScope.pos.line,startCharacter:r.openScope.pos.col,endLine:r.closeScope.prevToken.pos.line,endCharacter:r.closeScope.prevToken.pos.col,kind:qb.FoldingRangeKind.Region},...r.nodes.flatMap($b)],sA=r=>{let e=[];return[...r instanceof ms?r.ifBlocks.map(t=>({start:(t.expression??t.keyword).lastToken,end:t.content?.lastToken??(t.expression??t.keyword).lastToken})):[{start:(r.ifDef.identifier??r.ifDef.keyword).lastToken,end:r.ifDef.content?.lastToken}],r.elseOption?{start:r.elseOption.keyword.lastToken,end:r.elseOption.content?.lastToken}:null].forEach(t=>{!t||!t.end||e.push({startLine:t.start.pos.line,startCharacter:t.start.pos.col,endLine:t.end.pos.line,endCharacter:t.end.pos.col+t.end.pos.len,kind:qb.FoldingRangeKind.Region})}),e},WH=r=>r instanceof qe?$b(r):r instanceof lo||r instanceof ms?sA(r):[];function iA(r,e){return e.allAstItems.flatMap(t=>[t,...t.allDescendants]).filter(t=>t.uri===r).flatMap(WH)}var Ei=z(J());function HH(r){if(!r||!(r.ast instanceof je)&&!(r.ast instanceof Lt))return[];let e=t=>t.nodeType?.bindingsPath?[Ei.Location.create(ce(t.nodeType.bindingsPath),Ei.Range.create(Ei.Position.create(0,0),Ei.Position.create(0,0)))]:[];return r.item instanceof Ee&&!St(r.ast)?e(r.item):r.ast instanceof Lt&&r.ast.parentNode instanceof _e&&r.ast.parentNode.linksTo?e(r.ast.parentNode.linksTo):r.ast instanceof je&&r.ast.linksTo?e(r.ast.linksTo):[]}async function oA(r,e,t,n){return Mt(r,e,s=>[...HH(s)],t,n)}var Cn=require("path");var ph=require("fs");var KH=(r,e)=>{Xr().reset(r),Xr().requestTokens(r,!0),e(r)},hh=class{constructor(e,t,n){this.file=e;this.cb=t;this.hasDocumentOpen=n;this.count=0}watch(){if(this.count++,this.count===1){console.log("create watch for",this.file);let e=this.file,t=this.cb;this.onChange=()=>{if(this.hasDocumentOpen(e)){console.log("skipping on change document is open",e);return}console.log("onChange",e),KH(e,t)},(0,ph.watchFile)(e,this.onChange)}}unwatch(){this.count--,this.count===0&&(console.log("dispose watch for",this.file),(0,ph.unwatchFile)(this.file,this.onChange),this.onChange=void 0)}};var We=[],nt,jb,tl=new WeakMap,mh=new Map,Fb=r=>{We.some(e=>e===r)||(We.push(r),aA(r))},aA=async r=>{await r.stable(),r.getContextFiles().forEach(e=>{mh.has(e)||mh.set(e,new hh(e,zb,t=>!!yh(t))),mh.get(e)?.watch()})},Wb=async r=>{let e=We.indexOf(r);e!==-1&&(vh(r),tl.delete(r),console.log(`cleaning up context with ID ${r.name} and uri ${r.parser.uri}`),We.splice(e,1),cA(r))},cA=async r=>{await r.stable(),r.getContextFiles().forEach(e=>mh.get(e)?.unwatch())},zH=r=>{let e=tl.get(r);if(!e?.abort.signal.aborted)return Promise.all([e?.promise,r.getRuntime()])},At=async()=>{await Kb,await Promise.all(We.map(zH))},gh=r=>{let e=lA(r);return We.filter(t=>!e.some(n=>n===t))},lA=r=>We.filter(e=>{let t=r.contexts?.find(n=>n.dtsFile===e.parser.uri);return!!t&&t.overlays?.every(n=>e.overlays.some(s=>s===n))}),GH=async(r,e)=>{if(r===e)return!0;let t=(await r.getAllParsers()).flatMap(s=>s.cPreprocessorParser.dtsIncludes),n=(await e.getAllParsers()).flatMap(s=>s.cPreprocessorParser.dtsIncludes);return t.length?t.every(s=>n.some(i=>i.resolvedPath===s.resolvedPath&&i.firstToken.pos.col===s.firstToken.pos.col&&i.firstToken.pos.len===s.firstToken.pos.len&&i.firstToken.pos.line===s.firstToken.pos.line&&i.lastToken.pos.col===s.lastToken.pos.col&&i.lastToken.pos.len===s.lastToken.pos.len&&i.lastToken.pos.line===s.lastToken.pos.line)):e.getContextFiles().some(s=>s===r.parser.uri)},uA=r=>gh(pe).indexOf(r)!==-1,dA=async r=>{if(!uA(r))return;let e=gh(pe),t=await lA(pe),n=await ju(e),s=[...r.overlayParsers.map(a=>a.uri),r.parser.uri,...r.parser.includes.map(a=>a.resolvedPath)];if(We.indexOf(r)===-1)return;let i=await Promise.all(n.flatMap(a=>[...t,...e.filter(c=>c!==a.context)].map(async c=>({context:a.context,same:await GH(a.context,c)})))),o=n.filter(a=>i.some(c=>c.context===a.context&&c.same)||a.context!==r&&a.context.parser.uri===r.parser.uri&&s.some(c=>c&&a.files.indexOf(c)!==-1)).map(a=>a.context);o.length&&o.forEach(Wb)},ve=(0,xe.createConnection)(xe.ProposedFeatures.all),$s=new xe.TextDocuments(Lu),Hb=!1,Bb=!1,fA=!1,Ub;ve.onInitialize(r=>{Ub=r.workspaceFolders,ve.console.log(`[Server(${process.pid}) ${Ub?.[0].uri}] Started and initialize received`);let e=r.capabilities;Hb=!!(e.workspace&&e.workspace.configuration),Bb=!!(e.workspace&&e.workspace.workspaceFolders),fA=!!e.workspace?.diagnostics?.refreshSupport;let t={capabilities:{typeDefinitionProvider:!0,workspaceSymbolProvider:!0,textDocumentSync:xe.TextDocumentSyncKind.Incremental,renameProvider:{prepareProvider:!0},completionProvider:{resolveProvider:!0,triggerCharacters:["&","="," "]},codeActionProvider:{codeActionKinds:[xe.CodeActionKind.QuickFix,xe.CodeActionKind.SourceFixAll]},documentSymbolProvider:!0,semanticTokensProvider:{legend:{tokenTypes:$u,tokenModifiers:qu},full:!0},documentLinkProvider:{resolveProvider:!1},foldingRangeProvider:!0,definitionProvider:!0,declarationProvider:!0,referencesProvider:!0,documentFormattingProvider:!0,hoverProvider:!0}};return Bb&&(t.capabilities.workspace={workspaceFolders:{changeNotifications:!0,supported:!0}}),t});ve.onInitialized(()=>{Hb&&ve.client.register(xe.DidChangeConfigurationNotification.type,{}),Bb&&ve.workspace.onDidChangeWorkspaceFolders(async r=>{ve.console.log("Workspace folder change event received"),await Kb,await mA(pe,pe)})});var hA={defaultBindingType:"Zephyr",defaultZephyrBindings:[],defaultIncludePaths:[],defaultDeviceOrgBindingsMetaSchema:[],defaultDeviceOrgTreeBindings:[],contexts:[],lockRenameEdits:[],allowAdhocContexts:!0,autoChangeContext:!0},pe=hA,pA=new Map,Vb=!1,Kb=new Promise(r=>{let e=setInterval(()=>{Vb&&(r(),clearInterval(e))},100)}),Zo=async r=>{let e=(await ve.workspace.getWorkspaceFolders()??Ub)?.map(t=>xt(t.uri));return e?.length&&(r=r.replaceAll("${workspaceFolder}",e[0])),r},YH=r=>{if(r.cwd||pe.cwd){let e=r.cwd??pe.cwd;r.includePaths??=pe.defaultIncludePaths,r.zephyrBindings??=pe.defaultIncludePaths,r.bindingType??=pe.defaultBindingType,r.deviceOrgTreeBindings??=pe.defaultDeviceOrgTreeBindings,r.deviceOrgBindingsMetaSchema??=pe.defaultDeviceOrgBindingsMetaSchema,e&&r.bindingType==="Zephyr"&&(!r.zephyrBindings||r.zephyrBindings.length===0)&&(r.zephyrBindings=["./zephyr/dts/bindings"]),r.zephyrBindings=r.zephyrBindings?.map(t=>(0,Cn.resolve)(e,t)),r.deviceOrgTreeBindings=r.deviceOrgTreeBindings?.map(t=>(0,Cn.resolve)(e,t)),r.deviceOrgBindingsMetaSchema=r.deviceOrgBindingsMetaSchema?.map(t=>(0,Cn.resolve)(e,t)),r.includePaths=r.includePaths?.map(t=>(0,Cn.resolve)(e,t)),r.dtsFile=(0,Cn.resolve)(e,r.dtsFile)}},JH=async r=>{r.cwd=r.cwd?await Zo(r.cwd):void 0,r.defaultDeviceOrgBindingsMetaSchema=await Promise.all((r.defaultDeviceOrgBindingsMetaSchema??[]).map(Zo)),r.defaultDeviceOrgTreeBindings=await Promise.all((r.defaultDeviceOrgTreeBindings??[]).map(Zo)),r.defaultIncludePaths=await Promise.all((r.defaultIncludePaths??[]).map(Zo)),r.defaultZephyrBindings=await Promise.all((r.defaultZephyrBindings??[]).map(Zo)),r.lockRenameEdits=await Promise.all((r.lockRenameEdits??[]).map(Zo)),r.defaultIncludePaths=(r.defaultIncludePaths??[]).map(e=>r.cwd?(0,Cn.resolve)(r.cwd,e):e),r.cwd&&r.defaultBindingType==="Zephyr"&&!r.defaultZephyrBindings&&(r.defaultZephyrBindings=["./zephyr/dts/bindings"]),r.defaultZephyrBindings=(r.defaultZephyrBindings??[]).map(e=>r.cwd?(0,Cn.resolve)(r.cwd,e):e),r.defaultDeviceOrgBindingsMetaSchema=(r.defaultDeviceOrgBindingsMetaSchema??[]).map(e=>r.cwd?(0,Cn.resolve)(r.cwd,e):e),r.defaultDeviceOrgTreeBindings=(r.defaultDeviceOrgTreeBindings??[]).map(e=>r.cwd?(0,Cn.resolve)(r.cwd,e):e),r.contexts?.forEach(YH)},mA=async(r,e)=>{await JH(e),console.log("Resolve settings",JSON.stringify(e,void 0," ")),We.forEach(Wb),tl=new WeakMap,e.contexts?.forEach((n,s)=>{let i=n.bindingType,o=new po(n.dtsFile,n.includePaths??[],i?fh({zephyrBindings:n.zephyrBindings??[],deviceOrgBindingsMetaSchema:n.deviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:n.deviceOrgTreeBindings??[]},i):void 0,n.overlays,n.ctxName);Fb(o),console.log(`New context with ID ${o.name} for ${n.dtsFile}`)});let t=r?gh(r):[];t.map(n=>{let s=e.defaultBindingType,i=new po(n.parser.uri,e.defaultIncludePaths??[],s?fh({zephyrBindings:e.defaultZephyrBindings??[],deviceOrgBindingsMetaSchema:e.defaultDeviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:e.defaultDeviceOrgTreeBindings??[]},s):void 0);return console.log(`New context with ID ${i.name} for ${n.parser.uri}`),i}).forEach(Fb),t=gh(e),t.forEach(dA),jb&&rl(jb,!0),fA&&ve.languages.diagnostics.refresh()};ve.onDidChangeConfiguration(async r=>{let e;Vb&&(e=pe),r.settings&&(console.log("Configuration changed",JSON.stringify(r,void 0," ")),Hb&&pA.clear(),pe={...hA,...r.settings?.devicetree},await mA(e,pe),Vb=!0)});$s.onDidClose(r=>{let e=xt(r.document.uri),t=nt;if(!t)return;(t?.getContextFiles()??[]).filter(i=>i!==e).some(i=>yh(i))||(uA(t)?Wb(t):vh(t),nt=void 0),pA.delete(r.document.uri)});$s.onDidOpen(async r=>{await At();let e=nt,t=xt(r.document.uri);e||ve.sendDiagnostics({uri:r.document.uri,version:$s.get(r.document.uri)?.version,diagnostics:[{severity:xe.DiagnosticSeverity.Warning,range:xe.Range.create(xe.Position.create(0,0),xe.Position.create(0,0)),message:"File has no context",source:"devicetree"}]}),zb(t)});var XH=r=>{switch(r){case 0:return"Expected value";case 1:return"Expected ';'";case 2:return"Expected '{'";case 3:return"Expected '}'";case 4:return"Expected '['";case 5:return"Expected ']'";case 12:return"Expected '>'";case 13:return"Expected '<'";case 16:return`Expected '"'`;case 17:return`Expected "'"\\`;case 24:return"Missing ':'";case 21:return"Missing '/'";case 26:return'Expected ")"';case 28:return'Missing ","';case 6:return"Expected property name";case 7:return"Expected node name";case 8:return"Expected node address";case 9:return"Expected node path";case 10:return"Expected node reference";case 11:return"Expected root node name";case 14:return"Expected bytestring";case 15:return"Expected two digits for each byte in bytestring";case 20:return"Hex values are not allowed";case 18:return"Expected label name";case 19:return"Expected '/' at the start of a node path";case 23:return"Found ';' without a statement";case 25:return"Did you mean /delete-node/ or /delete-property/?";case 34:return"Did you mean /delete-node/?";case 35:return"Did you mean /delete-property/?";case 22:return"Unknown syntax";case 27:return"Expected expression";case 31:return"Expected macro identifier";case 30:return"Expected macro identifier or function like macro";case 29:return"White space is not allowed";case 32:return"Properties can only be defined in a node";case 33:return"Properties can only be deleted inside a node";case 36:return"Unable to resolve include";case 37:return"Expected start address";case 38:return"Expected end address";case 39:case 40:return"Expected 8|16|32|64";case 42:return"Unknown macro name";case 43:return"Expected function like macro";case 44:return"Macro expects less arguments";case 45:return"Macro expects more arguments";case 46:return"Missing #ENDIF";case 47:return"Block Unused";case 41:return"This syntax is not officially part of the DTS V0.4 standard"}},QH=r=>r.issues.map(e=>{switch(e){case 0:return`Property "${r.templateStrings[0]}" is replaced by a later definition`;case 1:return"Cannot delete a property before it has been defined";case 2:return"Node name already defined";case 5:return"Cannot delete a node before it has been defined";case 3:return`No node with that reference "${r.templateStrings[0]}" has been defined`;case 8:return`No node with name "${r.templateStrings[0]}" could be found in "/${r.templateStrings[1]}".`;case 4:return`Label name "${r.templateStrings[0]}" already defined`;case 6:return`Property "${r.templateStrings[0]}" was deleted`;case 7:return`Node "${r.templateStrings[0]}" was deleted`;case 9:return`The following node "${r.templateStrings[1]}" shall be present in "${r.templateStrings[0]}" node.`}}).join(" or "),ZH=r=>{switch(r){case 0:return"Property name already defined.";case 2:return"Defined here";case 4:return"Defined here";case 7:case 6:return"Deleted here";case 9:return"Node";default:return"TODO"}},eK=r=>r.issues.map(e=>{switch(e){case 9:return`Only these value are allowed ${r.templateStrings[0]}`;case 1:return"INTRO should be empty";case 8:return"INTRO can only be assigned one value";case 5:return"INTRO should be assigned a U32";case 6:return"INTRO should be assigned a U64";case 7:return"INTRO should be assigned a 'property encoded array'";case 2:return"INTRO should be assigned a string";case 3:return"INTRO should be assigned a string list";case 4:return`INTRO expects ${r.templateStrings[1]} values`;case 0:return"INTRO is required";case 11:return"INTRO should be omitted";case 28:return"INTRO name is not permitted under this node";case 10:return"INTRO first value must match node address";case 12:return"INTRO should be 'cpu'";case 13:return"INTRO should be 'memory'";case 14:return"INTRO is deprecated and should not be used'";case 15:return`INTRO ${r.templateStrings[1]}'`;case 19:return"INTRO value must be unique in the entire Devicetree";case 20:return`INTRO should have format ${r.templateStrings[1]}`;case 16:return`INTRO requires property "${r.templateStrings[1]}" in node path "${r.templateStrings[2]}"`;case 18:return"Unable to resolve interrupt parent node";case 17:return`INTRO expects ${r.templateStrings[1]} interrupt cells`;case 21:return`INTRO should have format ${r.templateStrings[1]}`;case 22:return"Node is disabled";case 23:return"Unable to resolve handle";case 24:return`Unable to find "${r.templateStrings[0]}" in ${r.templateStrings[1]}`;case 25:return r.templateStrings[0];case 26:return r.templateStrings[0];case 27:return r.templateStrings[0];case 29:return r.templateStrings[0]}}).join(" or ").replace("INTRO",`Property "${r.templateStrings[0]}"`).replaceAll("INTRO ",""),tK=r=>{switch(r){case 16:case 0:return"Node";case 17:return"Property";case 15:return"Ignored reason";case 19:return"Conflicting properties";case 8:return"Additional value";case 22:return"Disabled by";default:return"TODO"}},zb=async r=>{await Kb;let e=Ow(We,r);if(e.length)e.forEach(t=>{tl.get(t.context)?.abort.abort();let n=new AbortController,s=new Promise(i=>{setTimeout(async()=>{if(n.signal.aborted){i();return}let o=performance.now(),a=gA(t.context);cA(t.context),await t.context.reevaluate(r),aA(t.context),Gb(t.context).then(c=>{vh(t.context,a),c.items.map(l=>({uri:l.uri,version:l.version??void 0,diagnostics:l.items})).forEach(l=>{ve.sendDiagnostics(l)})}),i(),console.log("reevaluate",performance.now()-o)},50)});tl.set(t.context,{abort:n,promise:s})});else{if(pe.allowAdhocContexts===!1)return;let t=pe.defaultBindingType,n=new po(r,pe.defaultIncludePaths??[],t?fh({zephyrBindings:pe.defaultZephyrBindings??[],deviceOrgBindingsMetaSchema:pe.defaultDeviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:pe.defaultDeviceOrgTreeBindings??[]},t):void 0);console.log(`New ad hoc context with ID ${n.name} for ${r}`),Fb(n),rl(r),await n.parser.stable,dA(n)}};$s.onDidChangeContent(async r=>{let e=xt(r.document.uri),t=r.document.getText(),n=Xr();n.needsRenew(e,t)&&(console.log("Content changed"),n.renewLexer(e,t),zb(e))});var rK=r=>$s.keys().find(e=>Mw(xt(e),r)),yh=r=>{let e=rK(r);if(e)return $s.get(e)},gA=r=>r.getContextFiles().map(e=>({uri:ce(e),version:yh(e)?.version,diagnostics:[]})),vh=async(r,e=gA(r))=>await Promise.all(e.map(t=>ve.sendDiagnostics({uri:t.uri,version:$s.get(t.uri)?.version,diagnostics:[]}))),Gb=async r=>{await r.stable();let e=performance.now(),t=await Promise.all(r.getContextFiles().map(async n=>{let s=await nK(r,n);return{uri:ce(n),kind:xe.DocumentDiagnosticReportKind.Full,items:s,version:yh(n)?.version??null}}));return console.log("workspace diagnostics",r.name,performance.now()-e),{items:[...t]}};ve.languages.diagnostics.onWorkspace(async()=>{await At();let r=nt;return r?Gb(r):{items:[]}});async function nK(r,e){try{let t=[];return r.isInContext(e)?(r.parser.issues.filter(i=>i.astElement.uri===e).forEach(i=>{let o={severity:i.severity,range:Q(i.astElement),message:i.issues?i.issues.map(XH).join(" or "):"",source:"devicetree",tags:i.tags,data:{firstToken:{pos:i.astElement.firstToken.pos,tokens:i.astElement.firstToken.tokens,value:i.astElement.firstToken.value},lastToken:{pos:i.astElement.lastToken.pos,tokens:i.astElement.lastToken.tokens,value:i.astElement.lastToken.value},issues:{type:"SyntaxIssue",items:i.issues,edit:i.edit,codeActionTitle:i.codeActionTitle}}};t.push(o)}),(await r.getContextIssues()??[]).filter(i=>i.astElement.uri===e).forEach(i=>{let o={severity:i.severity,range:Q(i.astElement),message:QH(i),source:"devicetree",tags:i.tags,relatedInformation:[...i.linkedTo.map(a=>({message:i.issues.map(ZH).join(" or "),location:{uri:ce(a.uri),range:Q(a)}}))]};t.push(o)}),(await r.getRuntime())?.typesIssues.filter(i=>i.astElement.uri===e).forEach(i=>{let o={severity:i.severity,range:Q(i.astElement),message:eK(i),relatedInformation:[...i.linkedTo.map(a=>({message:i.issues.map(tK).join(" or "),location:{uri:ce(a.uri),range:Q(a)}}))],source:"devicetree",tags:i.tags,data:{firstToken:{pos:i.astElement.firstToken.pos,tokens:i.astElement.firstToken.tokens,value:i.astElement.firstToken.value},lastToken:{pos:i.astElement.lastToken.pos,tokens:i.astElement.lastToken.tokens,value:i.astElement.lastToken.value},issues:{type:"StandardTypeIssue",items:i.issues,edit:i.edit,codeActionTitle:i.codeActionTitle}}};t.push(o)}),t):[{severity:xe.DiagnosticSeverity.Warning,range:xe.Range.create(xe.Position.create(0,0),xe.Position.create(0,0)),message:"File not in use by the active context",source:"devicetree"}]}catch(t){throw console.error(t),t}}ve.onDidChangeWatchedFiles(r=>{ve.console.log("We received a file change event")});ve.onCompletion(async r=>(await At(),We?[...await KE(r,We,nt,pe.preferredContext),...await rN(r,We,nt,pe.preferredContext)]:[]));ve.onCompletionResolve(r=>r);$s.listen(ve);ve.listen();var rl=async(r,e=!1)=>{if(!e&&pe.autoChangeContext===!1||(jb=r,await At(),nt?.getContextFiles().find(s=>s===r)))return;let t=nt;nt=Qs(We,r,void 0,pe.preferredContext)?.context;let n=nt;t!==n&&(t&&await vh(t),n&&Gb(n).then(s=>{s.items.map(i=>({uri:i.uri,version:i.version??void 0,diagnostics:i.items})).forEach(i=>{ve.sendDiagnostics(i)})}),console.log(`(ID: ${n?.name??-1}) activeContext:`,n?.parser.uri),We.forEach((s,i)=>{console.log(`Context with ID ${s.name} for ${s.parser.uri}`)}))};ve.onDocumentSymbol(async r=>{await At();let e=xt(r.textDocument.uri);await rl(e);let n=await nt?.parser;return n?n.getDocumentSymbols(e):[]});ve.onWorkspaceSymbol(async()=>{await At();let r=nt;return r?(await r.getAllParsers()).flatMap(e=>e.getWorkspaceSymbols()):[]});ve.languages.semanticTokens.on(async r=>{try{await At();let e=xt(r.textDocument.uri);await rl(e);let t=new xe.SemanticTokensBuilder,n=await Qs(We,e,nt,pe.preferredContext),s=n?.context.isInContext(e);return!n||!s?{data:[]}:(n.context.parser.buildSemanticTokens(t,e),t.build())}catch(e){throw console.log(e),e}});ve.onDocumentLinks(async r=>{let e=xt(r.textDocument.uri);return await At(),(await Qs(We,e,nt,pe.preferredContext))?.context.getDocumentLinks(e)});ve.onPrepareRename(async r=>(await At(),QE(r,We,pe.lockRenameEdits??[],nt,pe.preferredContext)));ve.onRenameRequest(async r=>(await At(),XE(r,We,nt,pe.preferredContext)));ve.onReferences(async r=>(await At(),zE(r,We,nt,pe.preferredContext)));ve.onDefinition(async r=>{let e=xt(r.textDocument.uri);await At();let n=(await(await Qs(We,e,nt,pe.preferredContext))?.context.getDocumentLinks(e,r.position))?.filter(s=>s.target).map(s=>xe.Location.create(s.target,s.range))??[];return n.length?n:ZE(r,We,nt,pe.preferredContext)});ve.onDeclaration(async r=>(await At(),eN(r,We,nt,pe.preferredContext)));ve.onCodeAction(async r=>tN(r));ve.onDocumentFormatting(async r=>{let e=xt(r.textDocument.uri);await At();let t=await Qs(We,e,nt,pe.preferredContext);return t?Ww(r,t.context):[]});ve.onHover(async r=>(await At(),(await sN(r,We,nt,pe.preferredContext)).at(0)));ve.onRequest("devicetree/contexts",async()=>(await At(),We.map(r=>r.parser.uri)));ve.onFoldingRanges(async r=>{await At();let e=xt(r.textDocument.uri);await rl(e);let t=nt,n=t?.isInContext(e);if(!t||!n)return[];let s=(await t.getAllParsers()).find(i=>i.getFiles().some(o=>o===e));return s?iA(e,s):[]});ve.onTypeDefinition(async r=>(await At(),oA(r,We,nt)));
|