devicetree-language-server 0.5.6 → 0.5.7

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 CHANGED
@@ -176,21 +176,22 @@ ${r.comment}`:r.comment}this.doc.range[2]=r.offset;break}default:this.errors.pus
176
176
  `:""},this._extScope=e,this._scope=new $n.Scope({parent:e}),this._nodes=[new Sb]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,i){let s=this._scope.toName(r);return n!==void 0&&i&&(this._constants[s.str]=n),this._leafNode(new gb(e,s,n)),s}const(e,r,n){return this._def($n.varKinds.const,e,r,n)}let(e,r,n){return this._def($n.varKinds.let,e,r,n)}var(e,r,n){return this._def($n.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Hh(e,r,n))}add(e,r){return this._leafNode(new yb(e,_e.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==Ie.nil&&this._leafNode(new _b(e)),this}object(...e){let r=["{"];for(let[n,i]of e)r.length>1&&r.push(","),r.push(n),(n!==i||this.opts.es5)&&(r.push(":"),(0,Ie.addCodeArg)(r,i));return r.push("}"),new Ie._Code(r)}if(e,r,n){if(this._blockNode(new to(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new to(e))}else(){return this._elseNode(new Ca)}endIf(){return this._endBlockNode(to,Ca)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Nb(e),r)}forRange(e,r,n,i,s=this.opts.es5?$n.varKinds.var:$n.varKinds.let){let o=this._scope.toName(e);return this._for(new Rb(s,o,r,n),()=>i(o))}forOf(e,r,n,i=$n.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let o=r instanceof Ie.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,Ie._)`${o}.length`,a=>{this.var(s,(0,Ie._)`${o}[${a}]`),n(s)})}return this._for(new Vh("of",i,s,r),()=>n(s))}forIn(e,r,n,i=this.opts.es5?$n.varKinds.var:$n.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,Ie._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Vh("in",i,s,r),()=>n(s))}endFor(){return this._endBlockNode(ro)}label(e){return this._leafNode(new vb(e))}break(e){return this._leafNode(new Tb(e))}return(e){let r=new Hl;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Hl)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let i=new Pb;if(this._blockNode(i),this.code(e),r){let s=this.name("e");this._currNode=i.catch=new Vl(s),r(s)}return n&&(this._currNode=i.finally=new zl,this.code(n)),this._endBlockNode(Vl,zl)}throw(e){return this._leafNode(new bb(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=Ie.nil,n,i){return this._blockNode(new Ul(e,r,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(Ul)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof to))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};_e.CodeGen=kb;function no(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function zh(t,e){return e instanceof Ie._CodeOrName?no(t,e.names):t}function Da(t,e,r){if(t instanceof Ie.Name)return n(t);if(!i(t))return t;return new Ie._Code(t._items.reduce((s,o)=>(o instanceof Ie.Name&&(o=n(o)),o instanceof Ie._Code?s.push(...o._items):s.push(o),s),[]));function n(s){let o=r[s.str];return o===void 0||e[s.str]!==1?s:(delete e[s.str],o)}function i(s){return s instanceof Ie._Code&&s._items.some(o=>o instanceof Ie.Name&&e[o.str]===1&&r[o.str]!==void 0)}}function jG(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Cq(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,Ie._)`!${wb(t)}`}_e.not=Cq;var UG=Dq(_e.operators.AND);function HG(...t){return t.reduce(UG)}_e.and=HG;var VG=Dq(_e.operators.OR);function zG(...t){return t.reduce(VG)}_e.or=zG;function Dq(t){return(e,r)=>e===Ie.nil?r:r===Ie.nil?e:(0,Ie._)`${wb(e)} ${t} ${wb(r)}`}function wb(t){return t instanceof Ie.Name?t:(0,Ie._)`(${t})`}});var ke=R(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.checkStrictMode=Se.getErrorPath=Se.Type=Se.useFunc=Se.setEvaluated=Se.evaluatedPropsToName=Se.mergeEvaluated=Se.eachItem=Se.unescapeJsonPointer=Se.escapeJsonPointer=Se.escapeFragment=Se.unescapeFragment=Se.schemaRefOrVal=Se.schemaHasRulesButRef=Se.schemaHasRules=Se.checkUnknownRules=Se.alwaysValidSchema=Se.toHash=void 0;var st=Te(),WG=Fl();function GG(t){let e={};for(let r of t)e[r]=!0;return e}Se.toHash=GG;function YG(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Oq(t,e),!Mq(e,t.self.RULES.all))}Se.alwaysValidSchema=YG;function Oq(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let i=n.RULES.keywords;for(let s in e)i[s]||Lq(t,`unknown keyword: "${s}"`)}Se.checkUnknownRules=Oq;function Mq(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}Se.schemaHasRules=Mq;function KG(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}Se.schemaHasRulesButRef=KG;function XG({topSchemaRef:t,schemaPath:e},r,n,i){if(!i){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,st._)`${r}`}return(0,st._)`${t}${e}${(0,st.getProperty)(n)}`}Se.schemaRefOrVal=XG;function JG(t){return xq(decodeURIComponent(t))}Se.unescapeFragment=JG;function QG(t){return encodeURIComponent(Cb(t))}Se.escapeFragment=QG;function Cb(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}Se.escapeJsonPointer=Cb;function xq(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}Se.unescapeJsonPointer=xq;function ZG(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}Se.eachItem=ZG;function Aq({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(i,s,o,a)=>{let c=o===void 0?s:o instanceof st.Name?(s instanceof st.Name?t(i,s,o):e(i,s,o),o):s instanceof st.Name?(e(i,o,s),s):r(s,o);return a===st.Name&&!(c instanceof st.Name)?n(i,c):c}}Se.mergeEvaluated={props:Aq({mergeNames:(t,e,r)=>t.if((0,st._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,st._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,st._)`${r} || {}`).code((0,st._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,st._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,st._)`${r} || {}`),Db(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:qq}),items:Aq({mergeNames:(t,e,r)=>t.if((0,st._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,st._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,st._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,st._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function qq(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,st._)`{}`);return e!==void 0&&Db(t,r,e),r}Se.evaluatedPropsToName=qq;function Db(t,e,r){Object.keys(r).forEach(n=>t.assign((0,st._)`${e}${(0,st.getProperty)(n)}`,!0))}Se.setEvaluated=Db;var Iq={};function eY(t,e){return t.scopeValue("func",{ref:e,code:Iq[e.code]||(Iq[e.code]=new WG._Code(e.code))})}Se.useFunc=eY;var Eb;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Eb||(Se.Type=Eb={}));function tY(t,e,r){if(t instanceof st.Name){let n=e===Eb.Num;return r?n?(0,st._)`"[" + ${t} + "]"`:(0,st._)`"['" + ${t} + "']"`:n?(0,st._)`"/" + ${t}`:(0,st._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,st.getProperty)(t).toString():"/"+Cb(t)}Se.getErrorPath=tY;function Lq(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}Se.checkStrictMode=Lq});var mn=R(Ab=>{"use strict";Object.defineProperty(Ab,"__esModule",{value:!0});var pr=Te(),rY={data:new pr.Name("data"),valCxt:new pr.Name("valCxt"),instancePath:new pr.Name("instancePath"),parentData:new pr.Name("parentData"),parentDataProperty:new pr.Name("parentDataProperty"),rootData:new pr.Name("rootData"),dynamicAnchors:new pr.Name("dynamicAnchors"),vErrors:new pr.Name("vErrors"),errors:new pr.Name("errors"),this:new pr.Name("this"),self:new pr.Name("self"),scope:new pr.Name("scope"),json:new pr.Name("json"),jsonPos:new pr.Name("jsonPos"),jsonLen:new pr.Name("jsonLen"),jsonPart:new pr.Name("jsonPart")};Ab.default=rY});var Wl=R(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.extendErrors=hr.resetErrorsCount=hr.reportExtraError=hr.reportError=hr.keyword$DataError=hr.keywordError=void 0;var xe=Te(),Gh=ke(),Sr=mn();hr.keywordError={message:({keyword:t})=>(0,xe.str)`must pass "${t}" keyword validation`};hr.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,xe.str)`"${t}" keyword must be ${e} ($data)`:(0,xe.str)`"${t}" keyword is invalid ($data)`};function nY(t,e=hr.keywordError,r,n){let{it:i}=t,{gen:s,compositeRule:o,allErrors:a}=i,c=Fq(t,e,r);n??(o||a)?$q(s,c):Bq(i,(0,xe._)`[${c}]`)}hr.reportError=nY;function iY(t,e=hr.keywordError,r){let{it:n}=t,{gen:i,compositeRule:s,allErrors:o}=n,a=Fq(t,e,r);$q(i,a),s||o||Bq(n,Sr.default.vErrors)}hr.reportExtraError=iY;function sY(t,e){t.assign(Sr.default.errors,e),t.if((0,xe._)`${Sr.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,xe._)`${Sr.default.vErrors}.length`,e),()=>t.assign(Sr.default.vErrors,null)))}hr.resetErrorsCount=sY;function oY({gen:t,keyword:e,schemaValue:r,data:n,errsCount:i,it:s}){if(i===void 0)throw new Error("ajv implementation error");let o=t.name("err");t.forRange("i",i,Sr.default.errors,a=>{t.const(o,(0,xe._)`${Sr.default.vErrors}[${a}]`),t.if((0,xe._)`${o}.instancePath === undefined`,()=>t.assign((0,xe._)`${o}.instancePath`,(0,xe.strConcat)(Sr.default.instancePath,s.errorPath))),t.assign((0,xe._)`${o}.schemaPath`,(0,xe.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,xe._)`${o}.schema`,r),t.assign((0,xe._)`${o}.data`,n))})}hr.extendErrors=oY;function $q(t,e){let r=t.const("err",e);t.if((0,xe._)`${Sr.default.vErrors} === null`,()=>t.assign(Sr.default.vErrors,(0,xe._)`[${r}]`),(0,xe._)`${Sr.default.vErrors}.push(${r})`),t.code((0,xe._)`${Sr.default.errors}++`)}function Bq(t,e){let{gen:r,validateName:n,schemaEnv:i}=t;i.$async?r.throw((0,xe._)`new ${t.ValidationError}(${e})`):(r.assign((0,xe._)`${n}.errors`,e),r.return(!1))}var io={keyword:new xe.Name("keyword"),schemaPath:new xe.Name("schemaPath"),params:new xe.Name("params"),propertyName:new xe.Name("propertyName"),message:new xe.Name("message"),schema:new xe.Name("schema"),parentSchema:new xe.Name("parentSchema")};function Fq(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,xe._)`{}`:aY(t,e,r)}function aY(t,e,r={}){let{gen:n,it:i}=t,s=[cY(i,r),lY(t,r)];return uY(t,e,s),n.object(...s)}function cY({errorPath:t},{instancePath:e}){let r=e?(0,xe.str)`${t}${(0,Gh.getErrorPath)(e,Gh.Type.Str)}`:t;return[Sr.default.instancePath,(0,xe.strConcat)(Sr.default.instancePath,r)]}function lY({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let i=n?e:(0,xe.str)`${e}/${t}`;return r&&(i=(0,xe.str)`${i}${(0,Gh.getErrorPath)(r,Gh.Type.Str)}`),[io.schemaPath,i]}function uY(t,{params:e,message:r},n){let{keyword:i,data:s,schemaValue:o,it:a}=t,{opts:c,propertyName:l,topSchemaRef:u,schemaPath:d}=a;n.push([io.keyword,i],[io.params,typeof e=="function"?e(t):e||(0,xe._)`{}`]),c.messages&&n.push([io.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([io.schema,o],[io.parentSchema,(0,xe._)`${u}${d}`],[Sr.default.data,s]),l&&n.push([io.propertyName,l])}});var Uq=R(Aa=>{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.boolOrEmptySchema=Aa.topBoolOrEmptySchema=void 0;var dY=Wl(),fY=Te(),pY=mn(),hY={message:"boolean schema is false"};function mY(t){let{gen:e,schema:r,validateName:n}=t;r===!1?jq(t,!1):typeof r=="object"&&r.$async===!0?e.return(pY.default.data):(e.assign((0,fY._)`${n}.errors`,null),e.return(!0))}Aa.topBoolOrEmptySchema=mY;function gY(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),jq(t)):r.var(e,!0)}Aa.boolOrEmptySchema=gY;function jq(t,e){let{gen:r,data:n}=t,i={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,dY.reportError)(i,hY,void 0,e)}});var Ib=R(Ia=>{"use strict";Object.defineProperty(Ia,"__esModule",{value:!0});Ia.getRules=Ia.isJSONType=void 0;var yY=["string","number","integer","boolean","null","object","array"],vY=new Set(yY);function TY(t){return typeof t=="string"&&vY.has(t)}Ia.isJSONType=TY;function bY(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}Ia.getRules=bY});var Ob=R(_s=>{"use strict";Object.defineProperty(_s,"__esModule",{value:!0});_s.shouldUseRule=_s.shouldUseGroup=_s.schemaHasRulesForType=void 0;function _Y({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&Hq(t,n)}_s.schemaHasRulesForType=_Y;function Hq(t,e){return e.rules.some(r=>Vq(t,r))}_s.shouldUseGroup=Hq;function Vq(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}_s.shouldUseRule=Vq});var Gl=R(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.reportTypeError=mr.checkDataTypes=mr.checkDataType=mr.coerceAndCheckDataType=mr.getJSONTypes=mr.getSchemaTypes=mr.DataType=void 0;var SY=Ib(),NY=Ob(),RY=Wl(),be=Te(),zq=ke(),Oa;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Oa||(mr.DataType=Oa={}));function PY(t){let e=Wq(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}mr.getSchemaTypes=PY;function Wq(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(SY.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}mr.getJSONTypes=Wq;function kY(t,e){let{gen:r,data:n,opts:i}=t,s=wY(e,i.coerceTypes),o=e.length>0&&!(s.length===0&&e.length===1&&(0,NY.schemaHasRulesForType)(t,e[0]));if(o){let a=xb(e,n,i.strictNumbers,Oa.Wrong);r.if(a,()=>{s.length?EY(t,e,s):qb(t)})}return o}mr.coerceAndCheckDataType=kY;var Gq=new Set(["string","number","integer","boolean","null"]);function wY(t,e){return e?t.filter(r=>Gq.has(r)||e==="array"&&r==="array"):[]}function EY(t,e,r){let{gen:n,data:i,opts:s}=t,o=n.let("dataType",(0,be._)`typeof ${i}`),a=n.let("coerced",(0,be._)`undefined`);s.coerceTypes==="array"&&n.if((0,be._)`${o} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>n.assign(i,(0,be._)`${i}[0]`).assign(o,(0,be._)`typeof ${i}`).if(xb(e,i,s.strictNumbers),()=>n.assign(a,i))),n.if((0,be._)`${a} !== undefined`);for(let l of r)(Gq.has(l)||l==="array"&&s.coerceTypes==="array")&&c(l);n.else(),qb(t),n.endIf(),n.if((0,be._)`${a} !== undefined`,()=>{n.assign(i,a),CY(t,a)});function c(l){switch(l){case"string":n.elseIf((0,be._)`${o} == "number" || ${o} == "boolean"`).assign(a,(0,be._)`"" + ${i}`).elseIf((0,be._)`${i} === null`).assign(a,(0,be._)`""`);return;case"number":n.elseIf((0,be._)`${o} == "boolean" || ${i} === null
177
177
  || (${o} == "string" && ${i} && ${i} == +${i})`).assign(a,(0,be._)`+${i}`);return;case"integer":n.elseIf((0,be._)`${o} === "boolean" || ${i} === null
178
178
  || (${o} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(a,(0,be._)`+${i}`);return;case"boolean":n.elseIf((0,be._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(a,!1).elseIf((0,be._)`${i} === "true" || ${i} === 1`).assign(a,!0);return;case"null":n.elseIf((0,be._)`${i} === "" || ${i} === 0 || ${i} === false`),n.assign(a,null);return;case"array":n.elseIf((0,be._)`${o} === "string" || ${o} === "number"
179
- || ${o} === "boolean" || ${i} === null`).assign(a,(0,be._)`[${i}]`)}}}function CY({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,be._)`${e} !== undefined`,()=>t.assign((0,be._)`${e}[${r}]`,n))}function Mb(t,e,r,n=Oa.Correct){let i=n===Oa.Correct?be.operators.EQ:be.operators.NEQ,s;switch(t){case"null":return(0,be._)`${e} ${i} null`;case"array":s=(0,be._)`Array.isArray(${e})`;break;case"object":s=(0,be._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=o((0,be._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=o();break;default:return(0,be._)`typeof ${e} ${i} ${t}`}return n===Oa.Correct?s:(0,be.not)(s);function o(a=be.nil){return(0,be.and)((0,be._)`typeof ${e} == "number"`,a,r?(0,be._)`isFinite(${e})`:be.nil)}}mr.checkDataType=Mb;function xb(t,e,r,n){if(t.length===1)return Mb(t[0],e,r,n);let i,s=(0,zq.toHash)(t);if(s.array&&s.object){let o=(0,be._)`typeof ${e} != "object"`;i=s.null?o:(0,be._)`!${e} || ${o}`,delete s.null,delete s.array,delete s.object}else i=be.nil;s.number&&delete s.integer;for(let o in s)i=(0,be.and)(i,Mb(o,e,r,n));return i}mr.checkDataTypes=xb;var DY={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,be._)`{type: ${t}}`:(0,be._)`{type: ${e}}`};function qb(t){let e=AY(t);(0,RY.reportError)(e,DY)}mr.reportTypeError=qb;function AY(t){let{gen:e,data:r,schema:n}=t,i=(0,zq.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:t}}});var Kq=R(Yh=>{"use strict";Object.defineProperty(Yh,"__esModule",{value:!0});Yh.assignDefaults=void 0;var Ma=Te(),IY=ke();function OY(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let i in r)Yq(t,i,r[i].default);else e==="array"&&Array.isArray(n)&&n.forEach((i,s)=>Yq(t,s,i.default))}Yh.assignDefaults=OY;function Yq(t,e,r){let{gen:n,compositeRule:i,data:s,opts:o}=t;if(r===void 0)return;let a=(0,Ma._)`${s}${(0,Ma.getProperty)(e)}`;if(i){(0,IY.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,Ma._)`${a} === undefined`;o.useDefaults==="empty"&&(c=(0,Ma._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Ma._)`${a} = ${(0,Ma.stringify)(r)}`)}});var gn=R(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.validateUnion=Ze.validateArray=Ze.usePattern=Ze.callValidateCode=Ze.schemaProperties=Ze.allSchemaProperties=Ze.noPropertyInData=Ze.propertyInData=Ze.isOwnProperty=Ze.hasPropFunc=Ze.reportMissingProp=Ze.checkMissingProp=Ze.checkReportMissingProp=void 0;var gt=Te(),Lb=ke(),Ss=mn(),MY=ke();function xY(t,e){let{gen:r,data:n,it:i}=t;r.if(Bb(r,n,e,i.opts.ownProperties),()=>{t.setParams({missingProperty:(0,gt._)`${e}`},!0),t.error()})}Ze.checkReportMissingProp=xY;function qY({gen:t,data:e,it:{opts:r}},n,i){return(0,gt.or)(...n.map(s=>(0,gt.and)(Bb(t,e,s,r.ownProperties),(0,gt._)`${i} = ${s}`)))}Ze.checkMissingProp=qY;function LY(t,e){t.setParams({missingProperty:e},!0),t.error()}Ze.reportMissingProp=LY;function Xq(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,gt._)`Object.prototype.hasOwnProperty`})}Ze.hasPropFunc=Xq;function $b(t,e,r){return(0,gt._)`${Xq(t)}.call(${e}, ${r})`}Ze.isOwnProperty=$b;function $Y(t,e,r,n){let i=(0,gt._)`${e}${(0,gt.getProperty)(r)} !== undefined`;return n?(0,gt._)`${i} && ${$b(t,e,r)}`:i}Ze.propertyInData=$Y;function Bb(t,e,r,n){let i=(0,gt._)`${e}${(0,gt.getProperty)(r)} === undefined`;return n?(0,gt.or)(i,(0,gt.not)($b(t,e,r))):i}Ze.noPropertyInData=Bb;function Jq(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}Ze.allSchemaProperties=Jq;function BY(t,e){return Jq(e).filter(r=>!(0,Lb.alwaysValidSchema)(t,e[r]))}Ze.schemaProperties=BY;function FY({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:s},it:o},a,c,l){let u=l?(0,gt._)`${t}, ${e}, ${n}${i}`:e,d=[[Ss.default.instancePath,(0,gt.strConcat)(Ss.default.instancePath,s)],[Ss.default.parentData,o.parentData],[Ss.default.parentDataProperty,o.parentDataProperty],[Ss.default.rootData,Ss.default.rootData]];o.opts.dynamicRef&&d.push([Ss.default.dynamicAnchors,Ss.default.dynamicAnchors]);let f=(0,gt._)`${u}, ${r.object(...d)}`;return c!==gt.nil?(0,gt._)`${a}.call(${c}, ${f})`:(0,gt._)`${a}(${f})`}Ze.callValidateCode=FY;var jY=(0,gt._)`new RegExp`;function UY({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:i}=e.code,s=i(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,gt._)`${i.code==="new RegExp"?jY:(0,MY.useFunc)(t,i)}(${r}, ${n})`})}Ze.usePattern=UY;function HY(t){let{gen:e,data:r,keyword:n,it:i}=t,s=e.name("valid");if(i.allErrors){let a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(s,!0),o(()=>e.break()),s;function o(a){let c=e.const("len",(0,gt._)`${r}.length`);e.forRange("i",0,c,l=>{t.subschema({keyword:n,dataProp:l,dataPropType:Lb.Type.Num},s),e.if((0,gt.not)(s),a)})}}Ze.validateArray=HY;function VY(t){let{gen:e,schema:r,keyword:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Lb.alwaysValidSchema)(i,c))&&!i.opts.unevaluated)return;let o=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,l)=>{let u=t.subschema({keyword:n,schemaProp:l,compositeRule:!0},a);e.assign(o,(0,gt._)`${o} || ${a}`),t.mergeValidEvaluated(u,a)||e.if((0,gt.not)(o))})),t.result(o,()=>t.reset(),()=>t.error(!0))}Ze.validateUnion=VY});var eL=R(ai=>{"use strict";Object.defineProperty(ai,"__esModule",{value:!0});ai.validateKeywordUsage=ai.validSchemaType=ai.funcKeywordCode=ai.macroKeywordCode=void 0;var Nr=Te(),so=mn(),zY=gn(),WY=Wl();function GY(t,e){let{gen:r,keyword:n,schema:i,parentSchema:s,it:o}=t,a=e.macro.call(o.self,i,s,o),c=Zq(r,n,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);let l=r.name("valid");t.subschema({schema:a,schemaPath:Nr.nil,errSchemaPath:`${o.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),t.pass(l,()=>t.error(!0))}ai.macroKeywordCode=GY;function YY(t,e){var r;let{gen:n,keyword:i,schema:s,parentSchema:o,$data:a,it:c}=t;XY(c,e);let l=!a&&e.compile?e.compile.call(c.self,s,o,c):e.validate,u=Zq(n,i,l),d=n.let("valid");t.block$data(d,f),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function f(){if(e.errors===!1)h(),e.modifying&&Qq(t),v(()=>t.error());else{let S=e.async?p():g();e.modifying&&Qq(t),v(()=>KY(t,S))}}function p(){let S=n.let("ruleErrs",null);return n.try(()=>h((0,Nr._)`await `),_=>n.assign(d,!1).if((0,Nr._)`${_} instanceof ${c.ValidationError}`,()=>n.assign(S,(0,Nr._)`${_}.errors`),()=>n.throw(_))),S}function g(){let S=(0,Nr._)`${u}.errors`;return n.assign(S,null),h(Nr.nil),S}function h(S=e.async?(0,Nr._)`await `:Nr.nil){let _=c.opts.passContext?so.default.this:so.default.self,T=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,Nr._)`${S}${(0,zY.callValidateCode)(t,u,_,T)}`,e.modifying)}function v(S){var _;n.if((0,Nr.not)((_=e.valid)!==null&&_!==void 0?_:d),S)}}ai.funcKeywordCode=YY;function Qq(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Nr._)`${n.parentData}[${n.parentDataProperty}]`))}function KY(t,e){let{gen:r}=t;r.if((0,Nr._)`Array.isArray(${e})`,()=>{r.assign(so.default.vErrors,(0,Nr._)`${so.default.vErrors} === null ? ${e} : ${so.default.vErrors}.concat(${e})`).assign(so.default.errors,(0,Nr._)`${so.default.vErrors}.length`),(0,WY.extendErrors)(t)},()=>t.error())}function XY({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Zq(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Nr.stringify)(r)})}function JY(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}ai.validSchemaType=JY;function QY({schema:t,opts:e,self:r,errSchemaPath:n},i,s){if(Array.isArray(i.keyword)?!i.keyword.includes(s):i.keyword!==s)throw new Error("ajv implementation error");let o=i.dependencies;if(o?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${o.join(",")}`);if(i.validateSchema&&!i.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}ai.validateKeywordUsage=QY});var rL=R(Ns=>{"use strict";Object.defineProperty(Ns,"__esModule",{value:!0});Ns.extendSubschemaMode=Ns.extendSubschemaData=Ns.getSubschema=void 0;var ci=Te(),tL=ke();function ZY(t,{keyword:e,schemaProp:r,schema:n,schemaPath:i,errSchemaPath:s,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=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,ci._)`${t.schemaPath}${(0,ci.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,ci._)`${t.schemaPath}${(0,ci.getProperty)(e)}${(0,ci.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,tL.escapeFragment)(r)}`}}if(n!==void 0){if(i===void 0||s===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:i,topSchemaRef:o,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Ns.getSubschema=ZY;function eK(t,e,{dataProp:r,dataPropType:n,data:i,dataTypes:s,propertyName:o}){if(i!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:l,dataPathArr:u,opts:d}=e,f=a.let("data",(0,ci._)`${e.data}${(0,ci.getProperty)(r)}`,!0);c(f),t.errorPath=(0,ci.str)`${l}${(0,tL.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,ci._)`${r}`,t.dataPathArr=[...u,t.parentDataProperty]}if(i!==void 0){let l=i instanceof ci.Name?i:a.let("data",i,!0);c(l),o!==void 0&&(t.propertyName=o)}s&&(t.dataTypes=s);function c(l){t.data=l,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,l]}}Ns.extendSubschemaData=eK;function tK(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:i,allErrors:s}){n!==void 0&&(t.compositeRule=n),i!==void 0&&(t.createErrors=i),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Ns.extendSubschemaMode=tK});var Fb=R((JRe,nL)=>{"use strict";nL.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,i,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!t(e[i],r[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[i]))return!1;for(i=n;i--!==0;){var o=s[i];if(!t(e[o],r[o]))return!1}return!0}return e!==e&&r!==r}});var sL=R((QRe,iL)=>{"use strict";var Rs=iL.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},i=r.post||function(){};Kh(e,n,i,t,"",t)};Rs.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Rs.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Rs.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Rs.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 Kh(t,e,r,n,i,s,o,a,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,i,s,o,a,c,l);for(var u in n){var d=n[u];if(Array.isArray(d)){if(u in Rs.arrayKeywords)for(var f=0;f<d.length;f++)Kh(t,e,r,d[f],i+"/"+u+"/"+f,s,i,u,n,f)}else if(u in Rs.propsKeywords){if(d&&typeof d=="object")for(var p in d)Kh(t,e,r,d[p],i+"/"+u+"/"+rK(p),s,i,u,n,p)}else(u in Rs.keywords||t.allKeys&&!(u in Rs.skipKeywords))&&Kh(t,e,r,d,i+"/"+u,s,i,u,n)}r(n,i,s,o,a,c,l)}}function rK(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Yl=R(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.getSchemaRefs=Br.resolveUrl=Br.normalizeId=Br._getFullPath=Br.getFullPath=Br.inlineRef=void 0;var nK=ke(),iK=Fb(),sK=sL(),oK=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function aK(t,e=!0){return typeof t=="boolean"?!0:e===!0?!jb(t):e?oL(t)<=e:!1}Br.inlineRef=aK;var cK=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function jb(t){for(let e in t){if(cK.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(jb)||typeof r=="object"&&jb(r))return!0}return!1}function oL(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!oK.has(r)&&(typeof t[r]=="object"&&(0,nK.eachItem)(t[r],n=>e+=oL(n)),e===1/0))return 1/0}return e}function aL(t,e="",r){r!==!1&&(e=xa(e));let n=t.parse(e);return cL(t,n)}Br.getFullPath=aL;function cL(t,e){return t.serialize(e).split("#")[0]+"#"}Br._getFullPath=cL;var lK=/#\/?$/;function xa(t){return t?t.replace(lK,""):""}Br.normalizeId=xa;function uK(t,e,r){return r=xa(r),t.resolve(e,r)}Br.resolveUrl=uK;var dK=/^[a-z_][-a-z0-9._]*$/i;function fK(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,i=xa(t[r]||e),s={"":i},o=aL(n,i,!1),a={},c=new Set;return sK(t,{allKeys:!0},(d,f,p,g)=>{if(g===void 0)return;let h=o+f,v=s[g];typeof d[r]=="string"&&(v=S.call(this,d[r])),_.call(this,d.$anchor),_.call(this,d.$dynamicAnchor),s[f]=v;function S(T){let P=this.opts.uriResolver.resolve;if(T=xa(v?P(v,T):T),c.has(T))throw u(T);c.add(T);let C=this.refs[T];return typeof C=="string"&&(C=this.refs[C]),typeof C=="object"?l(d,C.schema,T):T!==xa(h)&&(T[0]==="#"?(l(d,a[T],T),a[T]=d):this.refs[T]=h),T}function _(T){if(typeof T=="string"){if(!dK.test(T))throw new Error(`invalid anchor "${T}"`);S.call(this,`#${T}`)}}}),a;function l(d,f,p){if(f!==void 0&&!iK(d,f))throw u(p)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Br.getSchemaRefs=fK});var Jl=R(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.getData=Ps.KeywordCxt=Ps.validateFunctionCode=void 0;var pL=Uq(),lL=Gl(),Hb=Ob(),Xh=Gl(),pK=Kq(),Xl=eL(),Ub=rL(),oe=Te(),pe=mn(),hK=Yl(),Ii=ke(),Kl=Wl();function mK(t){if(gL(t)&&(yL(t),mL(t))){vK(t);return}hL(t,()=>(0,pL.topBoolOrEmptySchema)(t))}Ps.validateFunctionCode=mK;function hL({gen:t,validateName:e,schema:r,schemaEnv:n,opts:i},s){i.code.es5?t.func(e,(0,oe._)`${pe.default.data}, ${pe.default.valCxt}`,n.$async,()=>{t.code((0,oe._)`"use strict"; ${uL(r,i)}`),yK(t,i),t.code(s)}):t.func(e,(0,oe._)`${pe.default.data}, ${gK(i)}`,n.$async,()=>t.code(uL(r,i)).code(s))}function gK(t){return(0,oe._)`{${pe.default.instancePath}="", ${pe.default.parentData}, ${pe.default.parentDataProperty}, ${pe.default.rootData}=${pe.default.data}${t.dynamicRef?(0,oe._)`, ${pe.default.dynamicAnchors}={}`:oe.nil}}={}`}function yK(t,e){t.if(pe.default.valCxt,()=>{t.var(pe.default.instancePath,(0,oe._)`${pe.default.valCxt}.${pe.default.instancePath}`),t.var(pe.default.parentData,(0,oe._)`${pe.default.valCxt}.${pe.default.parentData}`),t.var(pe.default.parentDataProperty,(0,oe._)`${pe.default.valCxt}.${pe.default.parentDataProperty}`),t.var(pe.default.rootData,(0,oe._)`${pe.default.valCxt}.${pe.default.rootData}`),e.dynamicRef&&t.var(pe.default.dynamicAnchors,(0,oe._)`${pe.default.valCxt}.${pe.default.dynamicAnchors}`)},()=>{t.var(pe.default.instancePath,(0,oe._)`""`),t.var(pe.default.parentData,(0,oe._)`undefined`),t.var(pe.default.parentDataProperty,(0,oe._)`undefined`),t.var(pe.default.rootData,pe.default.data),e.dynamicRef&&t.var(pe.default.dynamicAnchors,(0,oe._)`{}`)})}function vK(t){let{schema:e,opts:r,gen:n}=t;hL(t,()=>{r.$comment&&e.$comment&&TL(t),NK(t),n.let(pe.default.vErrors,null),n.let(pe.default.errors,0),r.unevaluated&&TK(t),vL(t),kK(t)})}function TK(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,oe._)`${r}.evaluated`),e.if((0,oe._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,oe._)`${t.evaluated}.props`,(0,oe._)`undefined`)),e.if((0,oe._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,oe._)`${t.evaluated}.items`,(0,oe._)`undefined`))}function uL(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,oe._)`/*# sourceURL=${r} */`:oe.nil}function bK(t,e){if(gL(t)&&(yL(t),mL(t))){_K(t,e);return}(0,pL.boolOrEmptySchema)(t,e)}function mL({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function gL(t){return typeof t.schema!="boolean"}function _K(t,e){let{schema:r,gen:n,opts:i}=t;i.$comment&&r.$comment&&TL(t),RK(t),PK(t);let s=n.const("_errs",pe.default.errors);vL(t,s),n.var(e,(0,oe._)`${s} === ${pe.default.errors}`)}function yL(t){(0,Ii.checkUnknownRules)(t),SK(t)}function vL(t,e){if(t.opts.jtd)return dL(t,[],!1,e);let r=(0,lL.getSchemaTypes)(t.schema),n=(0,lL.coerceAndCheckDataType)(t,r);dL(t,r,!n,e)}function SK(t){let{schema:e,errSchemaPath:r,opts:n,self:i}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Ii.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function NK(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Ii.checkStrictMode)(t,"default is ignored in the schema root")}function RK(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,hK.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function PK(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function TL({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:i}){let s=r.$comment;if(i.$comment===!0)t.code((0,oe._)`${pe.default.self}.logger.log(${s})`);else if(typeof i.$comment=="function"){let o=(0,oe.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,oe._)`${pe.default.self}.opts.$comment(${s}, ${o}, ${a}.schema)`)}}function kK(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:i,opts:s}=t;r.$async?e.if((0,oe._)`${pe.default.errors} === 0`,()=>e.return(pe.default.data),()=>e.throw((0,oe._)`new ${i}(${pe.default.vErrors})`)):(e.assign((0,oe._)`${n}.errors`,pe.default.vErrors),s.unevaluated&&wK(t),e.return((0,oe._)`${pe.default.errors} === 0`))}function wK({gen:t,evaluated:e,props:r,items:n}){r instanceof oe.Name&&t.assign((0,oe._)`${e}.props`,r),n instanceof oe.Name&&t.assign((0,oe._)`${e}.items`,n)}function dL(t,e,r,n){let{gen:i,schema:s,data:o,allErrors:a,opts:c,self:l}=t,{RULES:u}=l;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Ii.schemaHasRulesButRef)(s,u))){i.block(()=>_L(t,"$ref",u.all.$ref.definition));return}c.jtd||EK(t,e),i.block(()=>{for(let f of u.rules)d(f);d(u.post)});function d(f){(0,Hb.shouldUseGroup)(s,f)&&(f.type?(i.if((0,Xh.checkDataType)(f.type,o,c.strictNumbers)),fL(t,f),e.length===1&&e[0]===f.type&&r&&(i.else(),(0,Xh.reportTypeError)(t)),i.endIf()):fL(t,f),a||i.if((0,oe._)`${pe.default.errors} === ${n||0}`))}}function fL(t,e){let{gen:r,schema:n,opts:{useDefaults:i}}=t;i&&(0,pK.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Hb.shouldUseRule)(n,s)&&_L(t,s.keyword,s.definition,e.type)})}function EK(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(CK(t,e),t.opts.allowUnionTypes||DK(t,e),AK(t,t.dataTypes))}function CK(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{bL(t.dataTypes,r)||Vb(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),OK(t,e)}}function DK(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Vb(t,"use allowUnionTypes to allow union type keyword")}function AK(t,e){let r=t.self.RULES.all;for(let n in r){let i=r[n];if(typeof i=="object"&&(0,Hb.shouldUseRule)(t.schema,i)){let{type:s}=i.definition;s.length&&!s.some(o=>IK(e,o))&&Vb(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function IK(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function bL(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function OK(t,e){let r=[];for(let n of t.dataTypes)bL(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Vb(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Ii.checkStrictMode)(t,e,t.opts.strictTypes)}var Jh=class{constructor(e,r,n){if((0,Xl.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Ii.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",SL(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Xl.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",pe.default.errors))}result(e,r,n){this.failResult((0,oe.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,oe.not)(e),void 0,r)}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:r}=this;this.fail((0,oe._)`${r} !== undefined && (${(0,oe.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?Kl.reportExtraError:Kl.reportError)(this,this.def.error,r)}$dataError(){(0,Kl.reportError)(this,this.def.$dataError||Kl.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Kl.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=oe.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=oe.nil,r=oe.nil){if(!this.$data)return;let{gen:n,schemaCode:i,schemaType:s,def:o}=this;n.if((0,oe.or)((0,oe._)`${i} === undefined`,r)),e!==oe.nil&&n.assign(e,!0),(s.length||o.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==oe.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:i,it:s}=this;return(0,oe.or)(o(),a());function o(){if(n.length){if(!(r instanceof oe.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,oe._)`${(0,Xh.checkDataTypes)(c,r,s.opts.strictNumbers,Xh.DataType.Wrong)}`}return oe.nil}function a(){if(i.validateSchema){let c=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,oe._)`!${c}(${r})`}return oe.nil}}subschema(e,r){let n=(0,Ub.getSubschema)(this.it,e);(0,Ub.extendSubschemaData)(n,this.it,e),(0,Ub.extendSubschemaMode)(n,e);let i={...this.it,...n,items:void 0,props:void 0};return bK(i,r),i}mergeEvaluated(e,r){let{it:n,gen:i}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Ii.mergeEvaluated.props(i,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Ii.mergeEvaluated.items(i,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:i}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return i.if(r,()=>this.mergeEvaluated(e,oe.Name)),!0}};Ps.KeywordCxt=Jh;function _L(t,e,r,n){let i=new Jh(t,r,e);"code"in r?r.code(i,n):i.$data&&r.validate?(0,Xl.funcKeywordCode)(i,r):"macro"in r?(0,Xl.macroKeywordCode)(i,r):(r.compile||r.validate)&&(0,Xl.funcKeywordCode)(i,r)}var MK=/^\/(?:[^~]|~0|~1)*$/,xK=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function SL(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let i,s;if(t==="")return pe.default.rootData;if(t[0]==="/"){if(!MK.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);i=t,s=pe.default.rootData}else{let l=xK.exec(t);if(!l)throw new Error(`Invalid JSON-pointer: ${t}`);let u=+l[1];if(i=l[2],i==="#"){if(u>=e)throw new Error(c("property/index",u));return n[e-u]}if(u>e)throw new Error(c("data",u));if(s=r[e-u],!i)return s}let o=s,a=i.split("/");for(let l of a)l&&(s=(0,oe._)`${s}${(0,oe.getProperty)((0,Ii.unescapeJsonPointer)(l))}`,o=(0,oe._)`${o} && ${s}`);return o;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${e}`}}Ps.getData=SL});var Qh=R(Wb=>{"use strict";Object.defineProperty(Wb,"__esModule",{value:!0});var zb=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Wb.default=zb});var Ql=R(Kb=>{"use strict";Object.defineProperty(Kb,"__esModule",{value:!0});var Gb=Yl(),Yb=class extends Error{constructor(e,r,n,i){super(i||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Gb.resolveUrl)(e,r,n),this.missingSchema=(0,Gb.normalizeId)((0,Gb.getFullPath)(e,this.missingRef))}};Kb.default=Yb});var Zl=R(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.resolveSchema=yn.getCompilingSchema=yn.resolveRef=yn.compileSchema=yn.SchemaEnv=void 0;var Bn=Te(),qK=Qh(),oo=mn(),Fn=Yl(),NL=ke(),LK=Jl(),qa=class{constructor(e){var r;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=(r=e.baseId)!==null&&r!==void 0?r:(0,Fn.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};yn.SchemaEnv=qa;function Jb(t){let e=RL.call(this,t);if(e)return e;let r=(0,Fn.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:s}=this.opts,o=new Bn.CodeGen(this.scope,{es5:n,lines:i,ownProperties:s}),a;t.$async&&(a=o.scopeValue("Error",{ref:qK.default,code:(0,Bn._)`require("ajv/dist/runtime/validation_error").default`}));let c=o.scopeName("validate");t.validateName=c;let l={gen:o,allErrors:this.opts.allErrors,data:oo.default.data,parentData:oo.default.parentData,parentDataProperty:oo.default.parentDataProperty,dataNames:[oo.default.data],dataPathArr:[Bn.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Bn.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Bn.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Bn._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(t),(0,LK.validateFunctionCode)(l),o.optimize(this.opts.code.optimize);let d=o.toString();u=`${o.scopeRefs(oo.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,t));let p=new Function(`${oo.default.self}`,`${oo.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=t.schema,p.schemaEnv=t,t.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:o._values}),this.opts.unevaluated){let{props:g,items:h}=l;p.evaluated={props:g instanceof Bn.Name?void 0:g,items:h instanceof Bn.Name?void 0:h,dynamicProps:g instanceof Bn.Name,dynamicItems:h instanceof Bn.Name},p.source&&(p.source.evaluated=(0,Bn.stringify)(p.evaluated))}return t.validate=p,t}catch(d){throw delete t.validate,delete t.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(t)}}yn.compileSchema=Jb;function $K(t,e,r){var n;r=(0,Fn.resolveUrl)(this.opts.uriResolver,e,r);let i=t.refs[r];if(i)return i;let s=jK.call(this,t,r);if(s===void 0){let o=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;o&&(s=new qa({schema:o,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=BK.call(this,s)}yn.resolveRef=$K;function BK(t){return(0,Fn.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Jb.call(this,t)}function RL(t){for(let e of this._compilations)if(FK(e,t))return e}yn.getCompilingSchema=RL;function FK(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function jK(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Zh.call(this,t,e)}function Zh(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Fn._getFullPath)(this.opts.uriResolver,r),i=(0,Fn.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===i)return Xb.call(this,r,t);let s=(0,Fn.normalizeId)(n),o=this.refs[s]||this.schemas[s];if(typeof o=="string"){let a=Zh.call(this,t,o);return typeof a?.schema!="object"?void 0:Xb.call(this,r,a)}if(typeof o?.schema=="object"){if(o.validate||Jb.call(this,o),s===(0,Fn.normalizeId)(e)){let{schema:a}=o,{schemaId:c}=this.opts,l=a[c];return l&&(i=(0,Fn.resolveUrl)(this.opts.uriResolver,i,l)),new qa({schema:a,schemaId:c,root:t,baseId:i})}return Xb.call(this,r,o)}}yn.resolveSchema=Zh;var UK=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Xb(t,{baseId:e,schema:r,root:n}){var i;if(((i=t.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,NL.unescapeFragment)(a)];if(c===void 0)return;r=c;let l=typeof r=="object"&&r[this.opts.schemaId];!UK.has(a)&&l&&(e=(0,Fn.resolveUrl)(this.opts.uriResolver,e,l))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,NL.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Fn.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=Zh.call(this,n,a)}let{schemaId:o}=this.opts;if(s=s||new qa({schema:r,schemaId:o,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var PL=R((iPe,HK)=>{HK.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 wL=R((sPe,kL)=>{"use strict";var VK={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};kL.exports={HEX:VK}});var xL=R((oPe,ML)=>{"use strict";var{HEX:zK}=wL(),WK=/^(?:(?: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 AL(t){if(OL(t,".")<3)return{host:t,isIPV4:!1};let e=t.match(WK)||[],[r]=e;return r?{host:YK(r,"."),isIPV4:!0}:{host:t,isIPV4:!1}}function Qb(t,e=!1){let r="",n=!0;for(let i of t){if(zK[i]===void 0)return;i!=="0"&&n===!0&&(n=!1),n||(r+=i)}return e&&r.length===0&&(r="0"),r}function GK(t){let e=0,r={error:!1,address:"",zone:""},n=[],i=[],s=!1,o=!1,a=!1;function c(){if(i.length){if(s===!1){let l=Qb(i);if(l!==void 0)n.push(l);else return r.error=!0,!1}i.length=0}return!0}for(let l=0;l<t.length;l++){let u=t[l];if(!(u==="["||u==="]"))if(u===":"){if(o===!0&&(a=!0),!c())break;if(e++,n.push(":"),e>7){r.error=!0;break}l-1>=0&&t[l-1]===":"&&(o=!0);continue}else if(u==="%"){if(!c())break;s=!0}else{i.push(u);continue}}return i.length&&(s?r.zone=i.join(""):a?n.push(i.join("")):n.push(Qb(i))),r.address=n.join(""),r}function IL(t){if(OL(t,":")<2)return{host:t,isIPV6:!1};let e=GK(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,escapedHost:n,isIPV6:!0}}}function YK(t,e){let r="",n=!0,i=t.length;for(let s=0;s<i;s++){let o=t[s];o==="0"&&n?(s+1<=i&&t[s+1]===e||s+1===i)&&(r+=o,n=!1):(o===e?n=!0:n=!1,r+=o)}return r}function OL(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}var EL=/^\.\.?\//u,CL=/^\/\.(?:\/|$)/u,DL=/^\/\.\.(?:\/|$)/u,KK=/^\/?(?:.|\n)*?(?=\/|$)/u;function XK(t){let e=[];for(;t.length;)if(t.match(EL))t=t.replace(EL,"");else if(t.match(CL))t=t.replace(CL,"/");else if(t.match(DL))t=t.replace(DL,"/"),e.pop();else if(t==="."||t==="..")t="";else{let r=t.match(KK);if(r){let n=r[0];t=t.slice(n.length),e.push(n)}else throw new Error("Unexpected dot segment condition")}return e.join("")}function JK(t,e){let r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function QK(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host),n=AL(r);if(n.isIPV4)r=n.host;else{let i=IL(n.host);i.isIPV6===!0?r=`[${i.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}ML.exports={recomposeAuthority:QK,normalizeComponentEncoding:JK,removeDotSegments:XK,normalizeIPv4:AL,normalizeIPv6:IL,stringArrayToHexStripped:Qb}});var jL=R((aPe,FL)=>{"use strict";var ZK=/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu,e3=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function qL(t){return typeof t.secure=="boolean"?t.secure:String(t.scheme).toLowerCase()==="wss"}function LL(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function $L(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function t3(t){return t.secure=qL(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function r3(t){if((t.port===(qL(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function n3(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(e3);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let i=`${n}:${e.nid||t.nid}`,s=Zb[i];t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function i3(t,e){let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),i=`${r}:${e.nid||n}`,s=Zb[i];s&&(t=s.serialize(t,e));let o=t,a=t.nss;return o.path=`${n||e.nid}:${a}`,e.skipEscape=!0,o}function s3(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!ZK.test(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function o3(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var BL={scheme:"http",domainHost:!0,parse:LL,serialize:$L},a3={scheme:"https",domainHost:BL.domainHost,parse:LL,serialize:$L},em={scheme:"ws",domainHost:!0,parse:t3,serialize:r3},c3={scheme:"wss",domainHost:em.domainHost,parse:em.parse,serialize:em.serialize},l3={scheme:"urn",parse:n3,serialize:i3,skipNormalize:!0},u3={scheme:"urn:uuid",parse:s3,serialize:o3,skipNormalize:!0},Zb={http:BL,https:a3,ws:em,wss:c3,urn:l3,"urn:uuid":u3};FL.exports=Zb});var HL=R((cPe,rm)=>{"use strict";var{normalizeIPv6:d3,normalizeIPv4:f3,removeDotSegments:eu,recomposeAuthority:p3,normalizeComponentEncoding:tm}=xL(),e_=jL();function h3(t,e){return typeof t=="string"?t=li(Oi(t,e),e):typeof t=="object"&&(t=Oi(li(t,e),e)),t}function m3(t,e,r){let n=Object.assign({scheme:"null"},r),i=UL(Oi(t,n),Oi(e,n),n,!0);return li(i,{...n,skipEscape:!0})}function UL(t,e,r,n){let i={};return n||(t=Oi(li(t,r),r),e=Oi(li(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(i.scheme=e.scheme,i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=eu(e.path||""),i.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=eu(e.path||""),i.query=e.query):(e.path?(e.path.charAt(0)==="/"?i.path=eu(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?i.path="/"+e.path:t.path?i.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:i.path=e.path,i.path=eu(i.path)),i.query=e.query):(i.path=t.path,e.query!==void 0?i.query=e.query:i.query=t.query),i.userinfo=t.userinfo,i.host=t.host,i.port=t.port),i.scheme=t.scheme),i.fragment=e.fragment,i}function g3(t,e,r){return typeof t=="string"?(t=unescape(t),t=li(tm(Oi(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=li(tm(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=li(tm(Oi(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=li(tm(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function li(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),i=[],s=e_[(n.scheme||r.scheme||"").toLowerCase()];s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&i.push(r.scheme,":");let o=p3(r);if(o!==void 0&&(n.reference!=="suffix"&&i.push("//"),i.push(o),r.path&&r.path.charAt(0)!=="/"&&i.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=eu(a)),o===void 0&&(a=a.replace(/^\/\//u,"/%2F")),i.push(a)}return r.query!==void 0&&i.push("?",r.query),r.fragment!==void 0&&i.push("#",r.fragment),i.join("")}var y3=Array.from({length:127},(t,e)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(e)));function v3(t){let e=0;for(let r=0,n=t.length;r<n;++r)if(e=t.charCodeAt(r),e>126||y3[e])return!0;return!1}var T3=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Oi(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},i=t.indexOf("%")!==-1,s=!1;r.reference==="suffix"&&(t=(r.scheme?r.scheme+":":"")+"//"+t);let o=t.match(T3);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=f3(n.host);if(c.isIPV4===!1){let l=d3(c.host);n.host=l.host.toLowerCase(),s=l.isIPV6}else n.host=c.host,s=!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",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let a=e_[(r.scheme||n.scheme||"").toLowerCase()];if(!r.unicodeSupport&&(!a||!a.unicodeSupport)&&n.host&&(r.domainHost||a&&a.domainHost)&&s===!1&&v3(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)&&(i&&n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),i&&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,r)}else n.error=n.error||"URI can not be parsed.";return n}var t_={SCHEMES:e_,normalize:h3,resolve:m3,resolveComponents:UL,equal:g3,serialize:li,parse:Oi};rm.exports=t_;rm.exports.default=t_;rm.exports.fastUri=t_});var zL=R(r_=>{"use strict";Object.defineProperty(r_,"__esModule",{value:!0});var VL=HL();VL.code='require("ajv/dist/runtime/uri").default';r_.default=VL});var ZL=R(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.CodeGen=nr.Name=nr.nil=nr.stringify=nr.str=nr._=nr.KeywordCxt=void 0;var b3=Jl();Object.defineProperty(nr,"KeywordCxt",{enumerable:!0,get:function(){return b3.KeywordCxt}});var La=Te();Object.defineProperty(nr,"_",{enumerable:!0,get:function(){return La._}});Object.defineProperty(nr,"str",{enumerable:!0,get:function(){return La.str}});Object.defineProperty(nr,"stringify",{enumerable:!0,get:function(){return La.stringify}});Object.defineProperty(nr,"nil",{enumerable:!0,get:function(){return La.nil}});Object.defineProperty(nr,"Name",{enumerable:!0,get:function(){return La.Name}});Object.defineProperty(nr,"CodeGen",{enumerable:!0,get:function(){return La.CodeGen}});var _3=Qh(),XL=Ql(),S3=Ib(),tu=Zl(),N3=Te(),ru=Yl(),nm=Gl(),i_=ke(),WL=PL(),R3=zL(),JL=(t,e)=>new RegExp(t,e);JL.code="new RegExp";var P3=["removeAdditional","useDefaults","coerceTypes"],k3=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),w3={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."},E3={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},GL=200;function C3(t){var e,r,n,i,s,o,a,c,l,u,d,f,p,g,h,v,S,_,T,P,C,$,F,H,me;let Xe=t.strict,jt=(e=t.code)===null||e===void 0?void 0:e.optimize,Ne=jt===!0||jt===void 0?1:jt||0,Kr=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:JL,Mi=(i=t.uriResolver)!==null&&i!==void 0?i:R3.default;return{strictSchema:(o=(s=t.strictSchema)!==null&&s!==void 0?s:Xe)!==null&&o!==void 0?o:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:Xe)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=t.strictTypes)!==null&&l!==void 0?l:Xe)!==null&&u!==void 0?u:"log",strictTuples:(f=(d=t.strictTuples)!==null&&d!==void 0?d:Xe)!==null&&f!==void 0?f:"log",strictRequired:(g=(p=t.strictRequired)!==null&&p!==void 0?p:Xe)!==null&&g!==void 0?g:!1,code:t.code?{...t.code,optimize:Ne,regExp:Kr}:{optimize:Ne,regExp:Kr},loopRequired:(h=t.loopRequired)!==null&&h!==void 0?h:GL,loopEnum:(v=t.loopEnum)!==null&&v!==void 0?v:GL,meta:(S=t.meta)!==null&&S!==void 0?S:!0,messages:(_=t.messages)!==null&&_!==void 0?_:!0,inlineRefs:(T=t.inlineRefs)!==null&&T!==void 0?T:!0,schemaId:(P=t.schemaId)!==null&&P!==void 0?P:"$id",addUsedSchema:(C=t.addUsedSchema)!==null&&C!==void 0?C:!0,validateSchema:($=t.validateSchema)!==null&&$!==void 0?$:!0,validateFormats:(F=t.validateFormats)!==null&&F!==void 0?F:!0,unicodeRegExp:(H=t.unicodeRegExp)!==null&&H!==void 0?H:!0,int32range:(me=t.int32range)!==null&&me!==void 0?me:!0,uriResolver:Mi}}var nu=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...C3(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new N3.ValueScope({scope:{},prefixes:k3,es5:r,lines:n}),this.logger=x3(e.logger);let i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,S3.getRules)(),YL.call(this,w3,e,"NOT SUPPORTED"),YL.call(this,E3,e,"DEPRECATED","warn"),this._metaOpts=O3.call(this),e.formats&&A3.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&I3.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),D3.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,i=WL;n==="id"&&(i={...WL},i.id=i.$id,delete i.$id),r&&e&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){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 i=n(r);return"$async"in n||(this.errors=n.errors),i}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return i.call(this,e,r);async function i(u,d){await s.call(this,u.$schema);let f=this._addSchema(u,d);return f.validate||o.call(this,f)}async function s(u){u&&!this.getSchema(u)&&await i.call(this,{$ref:u},!0)}async function o(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof XL.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 s.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,r)}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,r,n,i=this.opts.validateSchema){if(Array.isArray(e)){for(let o of e)this.addSchema(o,void 0,n,i);return this}let s;if(typeof e=="object"){let{schemaId:o}=this.opts;if(s=e[o],s!==void 0&&typeof s!="string")throw new Error(`schema ${o} must be string`)}return r=(0,ru.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,i,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){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 i=this.validate(n,e);if(!i&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return i}getSchema(e){let r;for(;typeof(r=KL.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,i=new tu.SchemaEnv({schema:{},schemaId:n});if(r=tu.resolveSchema.call(this,i,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}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 r=KL.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,ru.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.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(L3.call(this,n,r),!r)return(0,i_.eachItem)(n,s=>n_.call(this,s)),this;B3.call(this,r);let i={...r,type:(0,nm.getJSONTypes)(r.type),schemaType:(0,nm.getJSONTypes)(r.schemaType)};return(0,i_.eachItem)(n,i.type.length===0?s=>n_.call(this,s,i):s=>i.type.forEach(o=>n_.call(this,s,i,o))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let i=n.rules.findIndex(s=>s.keyword===e);i>=0&&n.rules.splice(i,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(i=>`${n}${i.instancePath} ${i.message}`).reduce((i,s)=>i+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let i of r){let s=i.split("/").slice(1),o=e;for(let a of s)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]=QL(u))}}return e}_removeAllSchemas(e,r){for(let n in e){let i=e[n];(!r||r.test(n))&&(typeof i=="string"?delete e[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete e[n]))}}_addSchema(e,r,n,i=this.opts.validateSchema,s=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,ru.normalizeId)(o||n);let l=ru.getSchemaRefs.call(this,e,n);return c=new tu.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:l}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),i&&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):tu.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{tu.compileSchema.call(this,e)}finally{this.opts=r}}};nu.ValidationError=_3.default;nu.MissingRefError=XL.default;nr.default=nu;function YL(t,e,r,n="error"){for(let i in t){let s=i;s in e&&this.logger[n](`${r}: option ${i}. ${t[s]}`)}}function KL(t){return t=(0,ru.normalizeId)(t),this.schemas[t]||this.refs[t]}function D3(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function A3(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function I3(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function O3(){let t={...this.opts};for(let e of P3)delete t[e];return t}var M3={log(){},warn(){},error(){}};function x3(t){if(t===!1)return M3;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var q3=/^[a-z_$][a-z0-9_$:-]*$/i;function L3(t,e){let{RULES:r}=this;if((0,i_.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!q3.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 n_(t,e,r){var n;let i=e?.post;if(r&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,o=i?s.post:s.rules.find(({type:c})=>c===r);if(o||(o={type:r,rules:[]},s.rules.push(o)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,nm.getJSONTypes)(e.type),schemaType:(0,nm.getJSONTypes)(e.schemaType)}};e.before?$3.call(this,o,a,e.before):o.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function $3(t,e,r){let n=t.rules.findIndex(i=>i.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function B3(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=QL(e)),t.validateSchema=this.compile(e,!0))}var F3={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function QL(t){return{anyOf:[t,F3]}}});var e1=R(s_=>{"use strict";Object.defineProperty(s_,"__esModule",{value:!0});var j3={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};s_.default=j3});var om=R(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.callRef=ao.getValidate=void 0;var U3=Ql(),t1=gn(),Fr=Te(),$a=mn(),r1=Zl(),im=ke(),H3={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:i,schemaEnv:s,validateName:o,opts:a,self:c}=n,{root:l}=s;if((r==="#"||r==="#/")&&i===l.baseId)return d();let u=r1.resolveRef.call(c,l,i,r);if(u===void 0)throw new U3.default(n.opts.uriResolver,i,r);if(u instanceof r1.SchemaEnv)return f(u);return p(u);function d(){if(s===l)return sm(t,o,s,s.$async);let g=e.scopeValue("root",{ref:l});return sm(t,(0,Fr._)`${g}.validate`,l,l.$async)}function f(g){let h=n1(t,g);sm(t,h,g,g.$async)}function p(g){let h=e.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,Fr.stringify)(g)}:{ref:g}),v=e.name("valid"),S=t.subschema({schema:g,dataTypes:[],schemaPath:Fr.nil,topSchemaRef:h,errSchemaPath:r},v);t.mergeEvaluated(S),t.ok(v)}}};function n1(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Fr._)`${r.scopeValue("wrapper",{ref:e})}.validate`}ao.getValidate=n1;function sm(t,e,r,n){let{gen:i,it:s}=t,{allErrors:o,schemaEnv:a,opts:c}=s,l=c.passContext?$a.default.this:Fr.nil;n?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let g=i.let("valid");i.try(()=>{i.code((0,Fr._)`await ${(0,t1.callValidateCode)(t,e,l)}`),p(e),o||i.assign(g,!0)},h=>{i.if((0,Fr._)`!(${h} instanceof ${s.ValidationError})`,()=>i.throw(h)),f(h),o||i.assign(g,!1)}),t.ok(g)}function d(){t.result((0,t1.callValidateCode)(t,e,l),()=>p(e),()=>f(e))}function f(g){let h=(0,Fr._)`${g}.errors`;i.assign($a.default.vErrors,(0,Fr._)`${$a.default.vErrors} === null ? ${h} : ${$a.default.vErrors}.concat(${h})`),i.assign($a.default.errors,(0,Fr._)`${$a.default.vErrors}.length`)}function p(g){var h;if(!s.opts.unevaluated)return;let v=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(s.props=im.mergeEvaluated.props(i,v.props,s.props));else{let S=i.var("props",(0,Fr._)`${g}.evaluated.props`);s.props=im.mergeEvaluated.props(i,S,s.props,Fr.Name)}if(s.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(s.items=im.mergeEvaluated.items(i,v.items,s.items));else{let S=i.var("items",(0,Fr._)`${g}.evaluated.items`);s.items=im.mergeEvaluated.items(i,S,s.items,Fr.Name)}}}ao.callRef=sm;ao.default=H3});var i1=R(o_=>{"use strict";Object.defineProperty(o_,"__esModule",{value:!0});var V3=e1(),z3=om(),W3=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",V3.default,z3.default];o_.default=W3});var s1=R(a_=>{"use strict";Object.defineProperty(a_,"__esModule",{value:!0});var am=Te(),ks=am.operators,cm={maximum:{okStr:"<=",ok:ks.LTE,fail:ks.GT},minimum:{okStr:">=",ok:ks.GTE,fail:ks.LT},exclusiveMaximum:{okStr:"<",ok:ks.LT,fail:ks.GTE},exclusiveMinimum:{okStr:">",ok:ks.GT,fail:ks.LTE}},G3={message:({keyword:t,schemaCode:e})=>(0,am.str)`must be ${cm[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,am._)`{comparison: ${cm[t].okStr}, limit: ${e}}`},Y3={keyword:Object.keys(cm),type:"number",schemaType:"number",$data:!0,error:G3,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,am._)`${r} ${cm[e].fail} ${n} || isNaN(${r})`)}};a_.default=Y3});var o1=R(c_=>{"use strict";Object.defineProperty(c_,"__esModule",{value:!0});var iu=Te(),K3={message:({schemaCode:t})=>(0,iu.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,iu._)`{multipleOf: ${t}}`},X3={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:K3,code(t){let{gen:e,data:r,schemaCode:n,it:i}=t,s=i.opts.multipleOfPrecision,o=e.let("res"),a=s?(0,iu._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${s}`:(0,iu._)`${o} !== parseInt(${o})`;t.fail$data((0,iu._)`(${n} === 0 || (${o} = ${r}/${n}, ${a}))`)}};c_.default=X3});var c1=R(l_=>{"use strict";Object.defineProperty(l_,"__esModule",{value:!0});function a1(t){let e=t.length,r=0,n=0,i;for(;n<e;)r++,i=t.charCodeAt(n++),i>=55296&&i<=56319&&n<e&&(i=t.charCodeAt(n),(i&64512)===56320&&n++);return r}l_.default=a1;a1.code='require("ajv/dist/runtime/ucs2length").default'});var l1=R(u_=>{"use strict";Object.defineProperty(u_,"__esModule",{value:!0});var co=Te(),J3=ke(),Q3=c1(),Z3={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,co.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,co._)`{limit: ${t}}`},eX={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Z3,code(t){let{keyword:e,data:r,schemaCode:n,it:i}=t,s=e==="maxLength"?co.operators.GT:co.operators.LT,o=i.opts.unicode===!1?(0,co._)`${r}.length`:(0,co._)`${(0,J3.useFunc)(t.gen,Q3.default)}(${r})`;t.fail$data((0,co._)`${o} ${s} ${n}`)}};u_.default=eX});var u1=R(d_=>{"use strict";Object.defineProperty(d_,"__esModule",{value:!0});var tX=gn(),lm=Te(),rX={message:({schemaCode:t})=>(0,lm.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,lm._)`{pattern: ${t}}`},nX={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:rX,code(t){let{data:e,$data:r,schema:n,schemaCode:i,it:s}=t,o=s.opts.unicodeRegExp?"u":"",a=r?(0,lm._)`(new RegExp(${i}, ${o}))`:(0,tX.usePattern)(t,n);t.fail$data((0,lm._)`!${a}.test(${e})`)}};d_.default=nX});var d1=R(f_=>{"use strict";Object.defineProperty(f_,"__esModule",{value:!0});var su=Te(),iX={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,su.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,su._)`{limit: ${t}}`},sX={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:iX,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxProperties"?su.operators.GT:su.operators.LT;t.fail$data((0,su._)`Object.keys(${r}).length ${i} ${n}`)}};f_.default=sX});var f1=R(p_=>{"use strict";Object.defineProperty(p_,"__esModule",{value:!0});var ou=gn(),au=Te(),oX=ke(),aX={message:({params:{missingProperty:t}})=>(0,au.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,au._)`{missingProperty: ${t}}`},cX={keyword:"required",type:"object",schemaType:"array",$data:!0,error:aX,code(t){let{gen:e,schema:r,schemaCode:n,data:i,$data:s,it:o}=t,{opts:a}=o;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(o.allErrors?l():u(),a.strictRequired){let p=t.parentSchema.properties,{definedProperties:g}=t.it;for(let h of r)if(p?.[h]===void 0&&!g.has(h)){let v=o.schemaEnv.baseId+o.errSchemaPath,S=`required property "${h}" is not defined at "${v}" (strictRequired)`;(0,oX.checkStrictMode)(o,S,o.opts.strictRequired)}}function l(){if(c||s)t.block$data(au.nil,d);else for(let p of r)(0,ou.checkReportMissingProp)(t,p)}function u(){let p=e.let("missing");if(c||s){let g=e.let("valid",!0);t.block$data(g,()=>f(p,g)),t.ok(g)}else e.if((0,ou.checkMissingProp)(t,r,p)),(0,ou.reportMissingProp)(t,p),e.else()}function d(){e.forOf("prop",n,p=>{t.setParams({missingProperty:p}),e.if((0,ou.noPropertyInData)(e,i,p,a.ownProperties),()=>t.error())})}function f(p,g){t.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(g,(0,ou.propertyInData)(e,i,p,a.ownProperties)),e.if((0,au.not)(g),()=>{t.error(),e.break()})},au.nil)}}};p_.default=cX});var p1=R(h_=>{"use strict";Object.defineProperty(h_,"__esModule",{value:!0});var cu=Te(),lX={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,cu.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,cu._)`{limit: ${t}}`},uX={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:lX,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxItems"?cu.operators.GT:cu.operators.LT;t.fail$data((0,cu._)`${r}.length ${i} ${n}`)}};h_.default=uX});var um=R(m_=>{"use strict";Object.defineProperty(m_,"__esModule",{value:!0});var h1=Fb();h1.code='require("ajv/dist/runtime/equal").default';m_.default=h1});var m1=R(y_=>{"use strict";Object.defineProperty(y_,"__esModule",{value:!0});var g_=Gl(),ir=Te(),dX=ke(),fX=um(),pX={message:({params:{i:t,j:e}})=>(0,ir.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,ir._)`{i: ${t}, j: ${e}}`},hX={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:pX,code(t){let{gen:e,data:r,$data:n,schema:i,parentSchema:s,schemaCode:o,it:a}=t;if(!n&&!i)return;let c=e.let("valid"),l=s.items?(0,g_.getSchemaTypes)(s.items):[];t.block$data(c,u,(0,ir._)`${o} === false`),t.ok(c);function u(){let g=e.let("i",(0,ir._)`${r}.length`),h=e.let("j");t.setParams({i:g,j:h}),e.assign(c,!0),e.if((0,ir._)`${g} > 1`,()=>(d()?f:p)(g,h))}function d(){return l.length>0&&!l.some(g=>g==="object"||g==="array")}function f(g,h){let v=e.name("item"),S=(0,g_.checkDataTypes)(l,v,a.opts.strictNumbers,g_.DataType.Wrong),_=e.const("indices",(0,ir._)`{}`);e.for((0,ir._)`;${g}--;`,()=>{e.let(v,(0,ir._)`${r}[${g}]`),e.if(S,(0,ir._)`continue`),l.length>1&&e.if((0,ir._)`typeof ${v} == "string"`,(0,ir._)`${v} += "_"`),e.if((0,ir._)`typeof ${_}[${v}] == "number"`,()=>{e.assign(h,(0,ir._)`${_}[${v}]`),t.error(),e.assign(c,!1).break()}).code((0,ir._)`${_}[${v}] = ${g}`)})}function p(g,h){let v=(0,dX.useFunc)(e,fX.default),S=e.name("outer");e.label(S).for((0,ir._)`;${g}--;`,()=>e.for((0,ir._)`${h} = ${g}; ${h}--;`,()=>e.if((0,ir._)`${v}(${r}[${g}], ${r}[${h}])`,()=>{t.error(),e.assign(c,!1).break(S)})))}}};y_.default=hX});var g1=R(T_=>{"use strict";Object.defineProperty(T_,"__esModule",{value:!0});var v_=Te(),mX=ke(),gX=um(),yX={message:"must be equal to constant",params:({schemaCode:t})=>(0,v_._)`{allowedValue: ${t}}`},vX={keyword:"const",$data:!0,error:yX,code(t){let{gen:e,data:r,$data:n,schemaCode:i,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,v_._)`!${(0,mX.useFunc)(e,gX.default)}(${r}, ${i})`):t.fail((0,v_._)`${s} !== ${r}`)}};T_.default=vX});var y1=R(b_=>{"use strict";Object.defineProperty(b_,"__esModule",{value:!0});var lu=Te(),TX=ke(),bX=um(),_X={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,lu._)`{allowedValues: ${t}}`},SX={keyword:"enum",schemaType:"array",$data:!0,error:_X,code(t){let{gen:e,data:r,$data:n,schema:i,schemaCode:s,it:o}=t;if(!n&&i.length===0)throw new Error("enum must have non-empty array");let a=i.length>=o.opts.loopEnum,c,l=()=>c??(c=(0,TX.useFunc)(e,bX.default)),u;if(a||n)u=e.let("valid"),t.block$data(u,d);else{if(!Array.isArray(i))throw new Error("ajv implementation error");let p=e.const("vSchema",s);u=(0,lu.or)(...i.map((g,h)=>f(p,h)))}t.pass(u);function d(){e.assign(u,!1),e.forOf("v",s,p=>e.if((0,lu._)`${l()}(${r}, ${p})`,()=>e.assign(u,!0).break()))}function f(p,g){let h=i[g];return typeof h=="object"&&h!==null?(0,lu._)`${l()}(${r}, ${p}[${g}])`:(0,lu._)`${r} === ${h}`}}};b_.default=SX});var v1=R(__=>{"use strict";Object.defineProperty(__,"__esModule",{value:!0});var NX=s1(),RX=o1(),PX=l1(),kX=u1(),wX=d1(),EX=f1(),CX=p1(),DX=m1(),AX=g1(),IX=y1(),OX=[NX.default,RX.default,PX.default,kX.default,wX.default,EX.default,CX.default,DX.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},AX.default,IX.default];__.default=OX});var N_=R(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});uu.validateAdditionalItems=void 0;var lo=Te(),S_=ke(),MX={message:({params:{len:t}})=>(0,lo.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,lo._)`{limit: ${t}}`},xX={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:MX,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,S_.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}T1(t,n)}};function T1(t,e){let{gen:r,schema:n,data:i,keyword:s,it:o}=t;o.items=!0;let a=r.const("len",(0,lo._)`${i}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,lo._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,S_.alwaysValidSchema)(o,n)){let l=r.var("valid",(0,lo._)`${a} <= ${e.length}`);r.if((0,lo.not)(l),()=>c(l)),t.ok(l)}function c(l){r.forRange("i",e.length,a,u=>{t.subschema({keyword:s,dataProp:u,dataPropType:S_.Type.Num},l),o.allErrors||r.if((0,lo.not)(l),()=>r.break())})}}uu.validateAdditionalItems=T1;uu.default=xX});var R_=R(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});du.validateTuple=void 0;var b1=Te(),dm=ke(),qX=gn(),LX={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return _1(t,"additionalItems",e);r.items=!0,!(0,dm.alwaysValidSchema)(r,e)&&t.ok((0,qX.validateArray)(t))}};function _1(t,e,r=t.schema){let{gen:n,parentSchema:i,data:s,keyword:o,it:a}=t;u(i),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=dm.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),l=n.const("len",(0,b1._)`${s}.length`);r.forEach((d,f)=>{(0,dm.alwaysValidSchema)(a,d)||(n.if((0,b1._)`${l} > ${f}`,()=>t.subschema({keyword:o,schemaProp:f,dataProp:f},c)),t.ok(c))});function u(d){let{opts:f,errSchemaPath:p}=a,g=r.length,h=g===d.minItems&&(g===d.maxItems||d[e]===!1);if(f.strictTuples&&!h){let v=`"${o}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,dm.checkStrictMode)(a,v,f.strictTuples)}}}du.validateTuple=_1;du.default=LX});var S1=R(P_=>{"use strict";Object.defineProperty(P_,"__esModule",{value:!0});var $X=R_(),BX={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,$X.validateTuple)(t,"items")};P_.default=BX});var R1=R(k_=>{"use strict";Object.defineProperty(k_,"__esModule",{value:!0});var N1=Te(),FX=ke(),jX=gn(),UX=N_(),HX={message:({params:{len:t}})=>(0,N1.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,N1._)`{limit: ${t}}`},VX={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:HX,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:i}=r;n.items=!0,!(0,FX.alwaysValidSchema)(n,e)&&(i?(0,UX.validateAdditionalItems)(t,i):t.ok((0,jX.validateArray)(t)))}};k_.default=VX});var P1=R(w_=>{"use strict";Object.defineProperty(w_,"__esModule",{value:!0});var vn=Te(),fm=ke(),zX={message:({params:{min:t,max:e}})=>e===void 0?(0,vn.str)`must contain at least ${t} valid item(s)`:(0,vn.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,vn._)`{minContains: ${t}}`:(0,vn._)`{minContains: ${t}, maxContains: ${e}}`},WX={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:zX,code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:s}=t,o,a,{minContains:c,maxContains:l}=n;s.opts.next?(o=c===void 0?1:c,a=l):o=1;let u=e.const("len",(0,vn._)`${i}.length`);if(t.setParams({min:o,max:a}),a===void 0&&o===0){(0,fm.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,fm.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,fm.alwaysValidSchema)(s,r)){let h=(0,vn._)`${u} >= ${o}`;a!==void 0&&(h=(0,vn._)`${h} && ${u} <= ${a}`),t.pass(h);return}s.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,vn._)`${i}.length > 0`,f)):(e.let(d,!1),f()),t.result(d,()=>t.reset());function f(){let h=e.name("_valid"),v=e.let("count",0);p(h,()=>e.if(h,()=>g(v)))}function p(h,v){e.forRange("i",0,u,S=>{t.subschema({keyword:"contains",dataProp:S,dataPropType:fm.Type.Num,compositeRule:!0},h),v()})}function g(h){e.code((0,vn._)`${h}++`),a===void 0?e.if((0,vn._)`${h} >= ${o}`,()=>e.assign(d,!0).break()):(e.if((0,vn._)`${h} > ${a}`,()=>e.assign(d,!1).break()),o===1?e.assign(d,!0):e.if((0,vn._)`${h} >= ${o}`,()=>e.assign(d,!0)))}}};w_.default=WX});var pm=R(ui=>{"use strict";Object.defineProperty(ui,"__esModule",{value:!0});ui.validateSchemaDeps=ui.validatePropertyDeps=ui.error=void 0;var E_=Te(),GX=ke(),fu=gn();ui.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,E_.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,E_._)`{property: ${t},
179
+ || ${o} === "boolean" || ${i} === null`).assign(a,(0,be._)`[${i}]`)}}}function CY({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,be._)`${e} !== undefined`,()=>t.assign((0,be._)`${e}[${r}]`,n))}function Mb(t,e,r,n=Oa.Correct){let i=n===Oa.Correct?be.operators.EQ:be.operators.NEQ,s;switch(t){case"null":return(0,be._)`${e} ${i} null`;case"array":s=(0,be._)`Array.isArray(${e})`;break;case"object":s=(0,be._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=o((0,be._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=o();break;default:return(0,be._)`typeof ${e} ${i} ${t}`}return n===Oa.Correct?s:(0,be.not)(s);function o(a=be.nil){return(0,be.and)((0,be._)`typeof ${e} == "number"`,a,r?(0,be._)`isFinite(${e})`:be.nil)}}mr.checkDataType=Mb;function xb(t,e,r,n){if(t.length===1)return Mb(t[0],e,r,n);let i,s=(0,zq.toHash)(t);if(s.array&&s.object){let o=(0,be._)`typeof ${e} != "object"`;i=s.null?o:(0,be._)`!${e} || ${o}`,delete s.null,delete s.array,delete s.object}else i=be.nil;s.number&&delete s.integer;for(let o in s)i=(0,be.and)(i,Mb(o,e,r,n));return i}mr.checkDataTypes=xb;var DY={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,be._)`{type: ${t}}`:(0,be._)`{type: ${e}}`};function qb(t){let e=AY(t);(0,RY.reportError)(e,DY)}mr.reportTypeError=qb;function AY(t){let{gen:e,data:r,schema:n}=t,i=(0,zq.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:t}}});var Kq=R(Yh=>{"use strict";Object.defineProperty(Yh,"__esModule",{value:!0});Yh.assignDefaults=void 0;var Ma=Te(),IY=ke();function OY(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let i in r)Yq(t,i,r[i].default);else e==="array"&&Array.isArray(n)&&n.forEach((i,s)=>Yq(t,s,i.default))}Yh.assignDefaults=OY;function Yq(t,e,r){let{gen:n,compositeRule:i,data:s,opts:o}=t;if(r===void 0)return;let a=(0,Ma._)`${s}${(0,Ma.getProperty)(e)}`;if(i){(0,IY.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,Ma._)`${a} === undefined`;o.useDefaults==="empty"&&(c=(0,Ma._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Ma._)`${a} = ${(0,Ma.stringify)(r)}`)}});var gn=R(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.validateUnion=Ze.validateArray=Ze.usePattern=Ze.callValidateCode=Ze.schemaProperties=Ze.allSchemaProperties=Ze.noPropertyInData=Ze.propertyInData=Ze.isOwnProperty=Ze.hasPropFunc=Ze.reportMissingProp=Ze.checkMissingProp=Ze.checkReportMissingProp=void 0;var gt=Te(),Lb=ke(),Ss=mn(),MY=ke();function xY(t,e){let{gen:r,data:n,it:i}=t;r.if(Bb(r,n,e,i.opts.ownProperties),()=>{t.setParams({missingProperty:(0,gt._)`${e}`},!0),t.error()})}Ze.checkReportMissingProp=xY;function qY({gen:t,data:e,it:{opts:r}},n,i){return(0,gt.or)(...n.map(s=>(0,gt.and)(Bb(t,e,s,r.ownProperties),(0,gt._)`${i} = ${s}`)))}Ze.checkMissingProp=qY;function LY(t,e){t.setParams({missingProperty:e},!0),t.error()}Ze.reportMissingProp=LY;function Xq(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,gt._)`Object.prototype.hasOwnProperty`})}Ze.hasPropFunc=Xq;function $b(t,e,r){return(0,gt._)`${Xq(t)}.call(${e}, ${r})`}Ze.isOwnProperty=$b;function $Y(t,e,r,n){let i=(0,gt._)`${e}${(0,gt.getProperty)(r)} !== undefined`;return n?(0,gt._)`${i} && ${$b(t,e,r)}`:i}Ze.propertyInData=$Y;function Bb(t,e,r,n){let i=(0,gt._)`${e}${(0,gt.getProperty)(r)} === undefined`;return n?(0,gt.or)(i,(0,gt.not)($b(t,e,r))):i}Ze.noPropertyInData=Bb;function Jq(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}Ze.allSchemaProperties=Jq;function BY(t,e){return Jq(e).filter(r=>!(0,Lb.alwaysValidSchema)(t,e[r]))}Ze.schemaProperties=BY;function FY({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:s},it:o},a,c,l){let u=l?(0,gt._)`${t}, ${e}, ${n}${i}`:e,d=[[Ss.default.instancePath,(0,gt.strConcat)(Ss.default.instancePath,s)],[Ss.default.parentData,o.parentData],[Ss.default.parentDataProperty,o.parentDataProperty],[Ss.default.rootData,Ss.default.rootData]];o.opts.dynamicRef&&d.push([Ss.default.dynamicAnchors,Ss.default.dynamicAnchors]);let f=(0,gt._)`${u}, ${r.object(...d)}`;return c!==gt.nil?(0,gt._)`${a}.call(${c}, ${f})`:(0,gt._)`${a}(${f})`}Ze.callValidateCode=FY;var jY=(0,gt._)`new RegExp`;function UY({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:i}=e.code,s=i(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,gt._)`${i.code==="new RegExp"?jY:(0,MY.useFunc)(t,i)}(${r}, ${n})`})}Ze.usePattern=UY;function HY(t){let{gen:e,data:r,keyword:n,it:i}=t,s=e.name("valid");if(i.allErrors){let a=e.let("valid",!0);return o(()=>e.assign(a,!1)),a}return e.var(s,!0),o(()=>e.break()),s;function o(a){let c=e.const("len",(0,gt._)`${r}.length`);e.forRange("i",0,c,l=>{t.subschema({keyword:n,dataProp:l,dataPropType:Lb.Type.Num},s),e.if((0,gt.not)(s),a)})}}Ze.validateArray=HY;function VY(t){let{gen:e,schema:r,keyword:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Lb.alwaysValidSchema)(i,c))&&!i.opts.unevaluated)return;let o=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,l)=>{let u=t.subschema({keyword:n,schemaProp:l,compositeRule:!0},a);e.assign(o,(0,gt._)`${o} || ${a}`),t.mergeValidEvaluated(u,a)||e.if((0,gt.not)(o))})),t.result(o,()=>t.reset(),()=>t.error(!0))}Ze.validateUnion=VY});var e1=R(ai=>{"use strict";Object.defineProperty(ai,"__esModule",{value:!0});ai.validateKeywordUsage=ai.validSchemaType=ai.funcKeywordCode=ai.macroKeywordCode=void 0;var Nr=Te(),so=mn(),zY=gn(),WY=Wl();function GY(t,e){let{gen:r,keyword:n,schema:i,parentSchema:s,it:o}=t,a=e.macro.call(o.self,i,s,o),c=Zq(r,n,a);o.opts.validateSchema!==!1&&o.self.validateSchema(a,!0);let l=r.name("valid");t.subschema({schema:a,schemaPath:Nr.nil,errSchemaPath:`${o.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),t.pass(l,()=>t.error(!0))}ai.macroKeywordCode=GY;function YY(t,e){var r;let{gen:n,keyword:i,schema:s,parentSchema:o,$data:a,it:c}=t;XY(c,e);let l=!a&&e.compile?e.compile.call(c.self,s,o,c):e.validate,u=Zq(n,i,l),d=n.let("valid");t.block$data(d,f),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function f(){if(e.errors===!1)h(),e.modifying&&Qq(t),v(()=>t.error());else{let S=e.async?p():g();e.modifying&&Qq(t),v(()=>KY(t,S))}}function p(){let S=n.let("ruleErrs",null);return n.try(()=>h((0,Nr._)`await `),_=>n.assign(d,!1).if((0,Nr._)`${_} instanceof ${c.ValidationError}`,()=>n.assign(S,(0,Nr._)`${_}.errors`),()=>n.throw(_))),S}function g(){let S=(0,Nr._)`${u}.errors`;return n.assign(S,null),h(Nr.nil),S}function h(S=e.async?(0,Nr._)`await `:Nr.nil){let _=c.opts.passContext?so.default.this:so.default.self,T=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,Nr._)`${S}${(0,zY.callValidateCode)(t,u,_,T)}`,e.modifying)}function v(S){var _;n.if((0,Nr.not)((_=e.valid)!==null&&_!==void 0?_:d),S)}}ai.funcKeywordCode=YY;function Qq(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Nr._)`${n.parentData}[${n.parentDataProperty}]`))}function KY(t,e){let{gen:r}=t;r.if((0,Nr._)`Array.isArray(${e})`,()=>{r.assign(so.default.vErrors,(0,Nr._)`${so.default.vErrors} === null ? ${e} : ${so.default.vErrors}.concat(${e})`).assign(so.default.errors,(0,Nr._)`${so.default.vErrors}.length`),(0,WY.extendErrors)(t)},()=>t.error())}function XY({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Zq(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Nr.stringify)(r)})}function JY(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}ai.validSchemaType=JY;function QY({schema:t,opts:e,self:r,errSchemaPath:n},i,s){if(Array.isArray(i.keyword)?!i.keyword.includes(s):i.keyword!==s)throw new Error("ajv implementation error");let o=i.dependencies;if(o?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${o.join(",")}`);if(i.validateSchema&&!i.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(i.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}ai.validateKeywordUsage=QY});var r1=R(Ns=>{"use strict";Object.defineProperty(Ns,"__esModule",{value:!0});Ns.extendSubschemaMode=Ns.extendSubschemaData=Ns.getSubschema=void 0;var ci=Te(),t1=ke();function ZY(t,{keyword:e,schemaProp:r,schema:n,schemaPath:i,errSchemaPath:s,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=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,ci._)`${t.schemaPath}${(0,ci.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,ci._)`${t.schemaPath}${(0,ci.getProperty)(e)}${(0,ci.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,t1.escapeFragment)(r)}`}}if(n!==void 0){if(i===void 0||s===void 0||o===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:i,topSchemaRef:o,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Ns.getSubschema=ZY;function eK(t,e,{dataProp:r,dataPropType:n,data:i,dataTypes:s,propertyName:o}){if(i!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:l,dataPathArr:u,opts:d}=e,f=a.let("data",(0,ci._)`${e.data}${(0,ci.getProperty)(r)}`,!0);c(f),t.errorPath=(0,ci.str)`${l}${(0,t1.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,ci._)`${r}`,t.dataPathArr=[...u,t.parentDataProperty]}if(i!==void 0){let l=i instanceof ci.Name?i:a.let("data",i,!0);c(l),o!==void 0&&(t.propertyName=o)}s&&(t.dataTypes=s);function c(l){t.data=l,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,l]}}Ns.extendSubschemaData=eK;function tK(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:i,allErrors:s}){n!==void 0&&(t.compositeRule=n),i!==void 0&&(t.createErrors=i),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Ns.extendSubschemaMode=tK});var Fb=R((JRe,n1)=>{"use strict";n1.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,i,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!t(e[i],r[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[i]))return!1;for(i=n;i--!==0;){var o=s[i];if(!t(e[o],r[o]))return!1}return!0}return e!==e&&r!==r}});var s1=R((QRe,i1)=>{"use strict";var Rs=i1.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},i=r.post||function(){};Kh(e,n,i,t,"",t)};Rs.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Rs.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Rs.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Rs.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 Kh(t,e,r,n,i,s,o,a,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,i,s,o,a,c,l);for(var u in n){var d=n[u];if(Array.isArray(d)){if(u in Rs.arrayKeywords)for(var f=0;f<d.length;f++)Kh(t,e,r,d[f],i+"/"+u+"/"+f,s,i,u,n,f)}else if(u in Rs.propsKeywords){if(d&&typeof d=="object")for(var p in d)Kh(t,e,r,d[p],i+"/"+u+"/"+rK(p),s,i,u,n,p)}else(u in Rs.keywords||t.allKeys&&!(u in Rs.skipKeywords))&&Kh(t,e,r,d,i+"/"+u,s,i,u,n)}r(n,i,s,o,a,c,l)}}function rK(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Yl=R(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Br.getSchemaRefs=Br.resolveUrl=Br.normalizeId=Br._getFullPath=Br.getFullPath=Br.inlineRef=void 0;var nK=ke(),iK=Fb(),sK=s1(),oK=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function aK(t,e=!0){return typeof t=="boolean"?!0:e===!0?!jb(t):e?o1(t)<=e:!1}Br.inlineRef=aK;var cK=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function jb(t){for(let e in t){if(cK.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(jb)||typeof r=="object"&&jb(r))return!0}return!1}function o1(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!oK.has(r)&&(typeof t[r]=="object"&&(0,nK.eachItem)(t[r],n=>e+=o1(n)),e===1/0))return 1/0}return e}function a1(t,e="",r){r!==!1&&(e=xa(e));let n=t.parse(e);return c1(t,n)}Br.getFullPath=a1;function c1(t,e){return t.serialize(e).split("#")[0]+"#"}Br._getFullPath=c1;var lK=/#\/?$/;function xa(t){return t?t.replace(lK,""):""}Br.normalizeId=xa;function uK(t,e,r){return r=xa(r),t.resolve(e,r)}Br.resolveUrl=uK;var dK=/^[a-z_][-a-z0-9._]*$/i;function fK(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,i=xa(t[r]||e),s={"":i},o=a1(n,i,!1),a={},c=new Set;return sK(t,{allKeys:!0},(d,f,p,g)=>{if(g===void 0)return;let h=o+f,v=s[g];typeof d[r]=="string"&&(v=S.call(this,d[r])),_.call(this,d.$anchor),_.call(this,d.$dynamicAnchor),s[f]=v;function S(T){let P=this.opts.uriResolver.resolve;if(T=xa(v?P(v,T):T),c.has(T))throw u(T);c.add(T);let C=this.refs[T];return typeof C=="string"&&(C=this.refs[C]),typeof C=="object"?l(d,C.schema,T):T!==xa(h)&&(T[0]==="#"?(l(d,a[T],T),a[T]=d):this.refs[T]=h),T}function _(T){if(typeof T=="string"){if(!dK.test(T))throw new Error(`invalid anchor "${T}"`);S.call(this,`#${T}`)}}}),a;function l(d,f,p){if(f!==void 0&&!iK(d,f))throw u(p)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Br.getSchemaRefs=fK});var Jl=R(Ps=>{"use strict";Object.defineProperty(Ps,"__esModule",{value:!0});Ps.getData=Ps.KeywordCxt=Ps.validateFunctionCode=void 0;var p1=Uq(),l1=Gl(),Hb=Ob(),Xh=Gl(),pK=Kq(),Xl=e1(),Ub=r1(),oe=Te(),pe=mn(),hK=Yl(),Ii=ke(),Kl=Wl();function mK(t){if(g1(t)&&(y1(t),m1(t))){vK(t);return}h1(t,()=>(0,p1.topBoolOrEmptySchema)(t))}Ps.validateFunctionCode=mK;function h1({gen:t,validateName:e,schema:r,schemaEnv:n,opts:i},s){i.code.es5?t.func(e,(0,oe._)`${pe.default.data}, ${pe.default.valCxt}`,n.$async,()=>{t.code((0,oe._)`"use strict"; ${u1(r,i)}`),yK(t,i),t.code(s)}):t.func(e,(0,oe._)`${pe.default.data}, ${gK(i)}`,n.$async,()=>t.code(u1(r,i)).code(s))}function gK(t){return(0,oe._)`{${pe.default.instancePath}="", ${pe.default.parentData}, ${pe.default.parentDataProperty}, ${pe.default.rootData}=${pe.default.data}${t.dynamicRef?(0,oe._)`, ${pe.default.dynamicAnchors}={}`:oe.nil}}={}`}function yK(t,e){t.if(pe.default.valCxt,()=>{t.var(pe.default.instancePath,(0,oe._)`${pe.default.valCxt}.${pe.default.instancePath}`),t.var(pe.default.parentData,(0,oe._)`${pe.default.valCxt}.${pe.default.parentData}`),t.var(pe.default.parentDataProperty,(0,oe._)`${pe.default.valCxt}.${pe.default.parentDataProperty}`),t.var(pe.default.rootData,(0,oe._)`${pe.default.valCxt}.${pe.default.rootData}`),e.dynamicRef&&t.var(pe.default.dynamicAnchors,(0,oe._)`${pe.default.valCxt}.${pe.default.dynamicAnchors}`)},()=>{t.var(pe.default.instancePath,(0,oe._)`""`),t.var(pe.default.parentData,(0,oe._)`undefined`),t.var(pe.default.parentDataProperty,(0,oe._)`undefined`),t.var(pe.default.rootData,pe.default.data),e.dynamicRef&&t.var(pe.default.dynamicAnchors,(0,oe._)`{}`)})}function vK(t){let{schema:e,opts:r,gen:n}=t;h1(t,()=>{r.$comment&&e.$comment&&T1(t),NK(t),n.let(pe.default.vErrors,null),n.let(pe.default.errors,0),r.unevaluated&&TK(t),v1(t),kK(t)})}function TK(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,oe._)`${r}.evaluated`),e.if((0,oe._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,oe._)`${t.evaluated}.props`,(0,oe._)`undefined`)),e.if((0,oe._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,oe._)`${t.evaluated}.items`,(0,oe._)`undefined`))}function u1(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,oe._)`/*# sourceURL=${r} */`:oe.nil}function bK(t,e){if(g1(t)&&(y1(t),m1(t))){_K(t,e);return}(0,p1.boolOrEmptySchema)(t,e)}function m1({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function g1(t){return typeof t.schema!="boolean"}function _K(t,e){let{schema:r,gen:n,opts:i}=t;i.$comment&&r.$comment&&T1(t),RK(t),PK(t);let s=n.const("_errs",pe.default.errors);v1(t,s),n.var(e,(0,oe._)`${s} === ${pe.default.errors}`)}function y1(t){(0,Ii.checkUnknownRules)(t),SK(t)}function v1(t,e){if(t.opts.jtd)return d1(t,[],!1,e);let r=(0,l1.getSchemaTypes)(t.schema),n=(0,l1.coerceAndCheckDataType)(t,r);d1(t,r,!n,e)}function SK(t){let{schema:e,errSchemaPath:r,opts:n,self:i}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Ii.schemaHasRulesButRef)(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function NK(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Ii.checkStrictMode)(t,"default is ignored in the schema root")}function RK(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,hK.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function PK(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function T1({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:i}){let s=r.$comment;if(i.$comment===!0)t.code((0,oe._)`${pe.default.self}.logger.log(${s})`);else if(typeof i.$comment=="function"){let o=(0,oe.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,oe._)`${pe.default.self}.opts.$comment(${s}, ${o}, ${a}.schema)`)}}function kK(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:i,opts:s}=t;r.$async?e.if((0,oe._)`${pe.default.errors} === 0`,()=>e.return(pe.default.data),()=>e.throw((0,oe._)`new ${i}(${pe.default.vErrors})`)):(e.assign((0,oe._)`${n}.errors`,pe.default.vErrors),s.unevaluated&&wK(t),e.return((0,oe._)`${pe.default.errors} === 0`))}function wK({gen:t,evaluated:e,props:r,items:n}){r instanceof oe.Name&&t.assign((0,oe._)`${e}.props`,r),n instanceof oe.Name&&t.assign((0,oe._)`${e}.items`,n)}function d1(t,e,r,n){let{gen:i,schema:s,data:o,allErrors:a,opts:c,self:l}=t,{RULES:u}=l;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Ii.schemaHasRulesButRef)(s,u))){i.block(()=>_1(t,"$ref",u.all.$ref.definition));return}c.jtd||EK(t,e),i.block(()=>{for(let f of u.rules)d(f);d(u.post)});function d(f){(0,Hb.shouldUseGroup)(s,f)&&(f.type?(i.if((0,Xh.checkDataType)(f.type,o,c.strictNumbers)),f1(t,f),e.length===1&&e[0]===f.type&&r&&(i.else(),(0,Xh.reportTypeError)(t)),i.endIf()):f1(t,f),a||i.if((0,oe._)`${pe.default.errors} === ${n||0}`))}}function f1(t,e){let{gen:r,schema:n,opts:{useDefaults:i}}=t;i&&(0,pK.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Hb.shouldUseRule)(n,s)&&_1(t,s.keyword,s.definition,e.type)})}function EK(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(CK(t,e),t.opts.allowUnionTypes||DK(t,e),AK(t,t.dataTypes))}function CK(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{b1(t.dataTypes,r)||Vb(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),OK(t,e)}}function DK(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Vb(t,"use allowUnionTypes to allow union type keyword")}function AK(t,e){let r=t.self.RULES.all;for(let n in r){let i=r[n];if(typeof i=="object"&&(0,Hb.shouldUseRule)(t.schema,i)){let{type:s}=i.definition;s.length&&!s.some(o=>IK(e,o))&&Vb(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function IK(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function b1(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function OK(t,e){let r=[];for(let n of t.dataTypes)b1(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Vb(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Ii.checkStrictMode)(t,e,t.opts.strictTypes)}var Jh=class{constructor(e,r,n){if((0,Xl.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Ii.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",S1(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Xl.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",pe.default.errors))}result(e,r,n){this.failResult((0,oe.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,oe.not)(e),void 0,r)}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:r}=this;this.fail((0,oe._)`${r} !== undefined && (${(0,oe.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?Kl.reportExtraError:Kl.reportError)(this,this.def.error,r)}$dataError(){(0,Kl.reportError)(this,this.def.$dataError||Kl.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Kl.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=oe.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=oe.nil,r=oe.nil){if(!this.$data)return;let{gen:n,schemaCode:i,schemaType:s,def:o}=this;n.if((0,oe.or)((0,oe._)`${i} === undefined`,r)),e!==oe.nil&&n.assign(e,!0),(s.length||o.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==oe.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:i,it:s}=this;return(0,oe.or)(o(),a());function o(){if(n.length){if(!(r instanceof oe.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,oe._)`${(0,Xh.checkDataTypes)(c,r,s.opts.strictNumbers,Xh.DataType.Wrong)}`}return oe.nil}function a(){if(i.validateSchema){let c=e.scopeValue("validate$data",{ref:i.validateSchema});return(0,oe._)`!${c}(${r})`}return oe.nil}}subschema(e,r){let n=(0,Ub.getSubschema)(this.it,e);(0,Ub.extendSubschemaData)(n,this.it,e),(0,Ub.extendSubschemaMode)(n,e);let i={...this.it,...n,items:void 0,props:void 0};return bK(i,r),i}mergeEvaluated(e,r){let{it:n,gen:i}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Ii.mergeEvaluated.props(i,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Ii.mergeEvaluated.items(i,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:i}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return i.if(r,()=>this.mergeEvaluated(e,oe.Name)),!0}};Ps.KeywordCxt=Jh;function _1(t,e,r,n){let i=new Jh(t,r,e);"code"in r?r.code(i,n):i.$data&&r.validate?(0,Xl.funcKeywordCode)(i,r):"macro"in r?(0,Xl.macroKeywordCode)(i,r):(r.compile||r.validate)&&(0,Xl.funcKeywordCode)(i,r)}var MK=/^\/(?:[^~]|~0|~1)*$/,xK=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function S1(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let i,s;if(t==="")return pe.default.rootData;if(t[0]==="/"){if(!MK.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);i=t,s=pe.default.rootData}else{let l=xK.exec(t);if(!l)throw new Error(`Invalid JSON-pointer: ${t}`);let u=+l[1];if(i=l[2],i==="#"){if(u>=e)throw new Error(c("property/index",u));return n[e-u]}if(u>e)throw new Error(c("data",u));if(s=r[e-u],!i)return s}let o=s,a=i.split("/");for(let l of a)l&&(s=(0,oe._)`${s}${(0,oe.getProperty)((0,Ii.unescapeJsonPointer)(l))}`,o=(0,oe._)`${o} && ${s}`);return o;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${e}`}}Ps.getData=S1});var Qh=R(Wb=>{"use strict";Object.defineProperty(Wb,"__esModule",{value:!0});var zb=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Wb.default=zb});var Ql=R(Kb=>{"use strict";Object.defineProperty(Kb,"__esModule",{value:!0});var Gb=Yl(),Yb=class extends Error{constructor(e,r,n,i){super(i||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Gb.resolveUrl)(e,r,n),this.missingSchema=(0,Gb.normalizeId)((0,Gb.getFullPath)(e,this.missingRef))}};Kb.default=Yb});var Zl=R(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.resolveSchema=yn.getCompilingSchema=yn.resolveRef=yn.compileSchema=yn.SchemaEnv=void 0;var Bn=Te(),qK=Qh(),oo=mn(),Fn=Yl(),N1=ke(),LK=Jl(),qa=class{constructor(e){var r;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=(r=e.baseId)!==null&&r!==void 0?r:(0,Fn.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};yn.SchemaEnv=qa;function Jb(t){let e=R1.call(this,t);if(e)return e;let r=(0,Fn.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:s}=this.opts,o=new Bn.CodeGen(this.scope,{es5:n,lines:i,ownProperties:s}),a;t.$async&&(a=o.scopeValue("Error",{ref:qK.default,code:(0,Bn._)`require("ajv/dist/runtime/validation_error").default`}));let c=o.scopeName("validate");t.validateName=c;let l={gen:o,allErrors:this.opts.allErrors,data:oo.default.data,parentData:oo.default.parentData,parentDataProperty:oo.default.parentDataProperty,dataNames:[oo.default.data],dataPathArr:[Bn.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:o.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Bn.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Bn.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Bn._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(t),(0,LK.validateFunctionCode)(l),o.optimize(this.opts.code.optimize);let d=o.toString();u=`${o.scopeRefs(oo.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,t));let p=new Function(`${oo.default.self}`,`${oo.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=t.schema,p.schemaEnv=t,t.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:o._values}),this.opts.unevaluated){let{props:g,items:h}=l;p.evaluated={props:g instanceof Bn.Name?void 0:g,items:h instanceof Bn.Name?void 0:h,dynamicProps:g instanceof Bn.Name,dynamicItems:h instanceof Bn.Name},p.source&&(p.source.evaluated=(0,Bn.stringify)(p.evaluated))}return t.validate=p,t}catch(d){throw delete t.validate,delete t.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(t)}}yn.compileSchema=Jb;function $K(t,e,r){var n;r=(0,Fn.resolveUrl)(this.opts.uriResolver,e,r);let i=t.refs[r];if(i)return i;let s=jK.call(this,t,r);if(s===void 0){let o=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;o&&(s=new qa({schema:o,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=BK.call(this,s)}yn.resolveRef=$K;function BK(t){return(0,Fn.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Jb.call(this,t)}function R1(t){for(let e of this._compilations)if(FK(e,t))return e}yn.getCompilingSchema=R1;function FK(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function jK(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Zh.call(this,t,e)}function Zh(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Fn._getFullPath)(this.opts.uriResolver,r),i=(0,Fn.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===i)return Xb.call(this,r,t);let s=(0,Fn.normalizeId)(n),o=this.refs[s]||this.schemas[s];if(typeof o=="string"){let a=Zh.call(this,t,o);return typeof a?.schema!="object"?void 0:Xb.call(this,r,a)}if(typeof o?.schema=="object"){if(o.validate||Jb.call(this,o),s===(0,Fn.normalizeId)(e)){let{schema:a}=o,{schemaId:c}=this.opts,l=a[c];return l&&(i=(0,Fn.resolveUrl)(this.opts.uriResolver,i,l)),new qa({schema:a,schemaId:c,root:t,baseId:i})}return Xb.call(this,r,o)}}yn.resolveSchema=Zh;var UK=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Xb(t,{baseId:e,schema:r,root:n}){var i;if(((i=t.fragment)===null||i===void 0?void 0:i[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,N1.unescapeFragment)(a)];if(c===void 0)return;r=c;let l=typeof r=="object"&&r[this.opts.schemaId];!UK.has(a)&&l&&(e=(0,Fn.resolveUrl)(this.opts.uriResolver,e,l))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,N1.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Fn.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=Zh.call(this,n,a)}let{schemaId:o}=this.opts;if(s=s||new qa({schema:r,schemaId:o,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var P1=R((iPe,HK)=>{HK.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 w1=R((sPe,k1)=>{"use strict";var VK={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};k1.exports={HEX:VK}});var x1=R((oPe,M1)=>{"use strict";var{HEX:zK}=w1(),WK=/^(?:(?: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 A1(t){if(O1(t,".")<3)return{host:t,isIPV4:!1};let e=t.match(WK)||[],[r]=e;return r?{host:YK(r,"."),isIPV4:!0}:{host:t,isIPV4:!1}}function Qb(t,e=!1){let r="",n=!0;for(let i of t){if(zK[i]===void 0)return;i!=="0"&&n===!0&&(n=!1),n||(r+=i)}return e&&r.length===0&&(r="0"),r}function GK(t){let e=0,r={error:!1,address:"",zone:""},n=[],i=[],s=!1,o=!1,a=!1;function c(){if(i.length){if(s===!1){let l=Qb(i);if(l!==void 0)n.push(l);else return r.error=!0,!1}i.length=0}return!0}for(let l=0;l<t.length;l++){let u=t[l];if(!(u==="["||u==="]"))if(u===":"){if(o===!0&&(a=!0),!c())break;if(e++,n.push(":"),e>7){r.error=!0;break}l-1>=0&&t[l-1]===":"&&(o=!0);continue}else if(u==="%"){if(!c())break;s=!0}else{i.push(u);continue}}return i.length&&(s?r.zone=i.join(""):a?n.push(i.join("")):n.push(Qb(i))),r.address=n.join(""),r}function I1(t){if(O1(t,":")<2)return{host:t,isIPV6:!1};let e=GK(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,escapedHost:n,isIPV6:!0}}}function YK(t,e){let r="",n=!0,i=t.length;for(let s=0;s<i;s++){let o=t[s];o==="0"&&n?(s+1<=i&&t[s+1]===e||s+1===i)&&(r+=o,n=!1):(o===e?n=!0:n=!1,r+=o)}return r}function O1(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}var E1=/^\.\.?\//u,C1=/^\/\.(?:\/|$)/u,D1=/^\/\.\.(?:\/|$)/u,KK=/^\/?(?:.|\n)*?(?=\/|$)/u;function XK(t){let e=[];for(;t.length;)if(t.match(E1))t=t.replace(E1,"");else if(t.match(C1))t=t.replace(C1,"/");else if(t.match(D1))t=t.replace(D1,"/"),e.pop();else if(t==="."||t==="..")t="";else{let r=t.match(KK);if(r){let n=r[0];t=t.slice(n.length),e.push(n)}else throw new Error("Unexpected dot segment condition")}return e.join("")}function JK(t,e){let r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function QK(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host),n=A1(r);if(n.isIPV4)r=n.host;else{let i=I1(n.host);i.isIPV6===!0?r=`[${i.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}M1.exports={recomposeAuthority:QK,normalizeComponentEncoding:JK,removeDotSegments:XK,normalizeIPv4:A1,normalizeIPv6:I1,stringArrayToHexStripped:Qb}});var j1=R((aPe,F1)=>{"use strict";var ZK=/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu,e3=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;function q1(t){return typeof t.secure=="boolean"?t.secure:String(t.scheme).toLowerCase()==="wss"}function L1(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function $1(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function t3(t){return t.secure=q1(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function r3(t){if((t.port===(q1(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function n3(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(e3);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let i=`${n}:${e.nid||t.nid}`,s=Zb[i];t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function i3(t,e){let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),i=`${r}:${e.nid||n}`,s=Zb[i];s&&(t=s.serialize(t,e));let o=t,a=t.nss;return o.path=`${n||e.nid}:${a}`,e.skipEscape=!0,o}function s3(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!ZK.test(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function o3(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var B1={scheme:"http",domainHost:!0,parse:L1,serialize:$1},a3={scheme:"https",domainHost:B1.domainHost,parse:L1,serialize:$1},em={scheme:"ws",domainHost:!0,parse:t3,serialize:r3},c3={scheme:"wss",domainHost:em.domainHost,parse:em.parse,serialize:em.serialize},l3={scheme:"urn",parse:n3,serialize:i3,skipNormalize:!0},u3={scheme:"urn:uuid",parse:s3,serialize:o3,skipNormalize:!0},Zb={http:B1,https:a3,ws:em,wss:c3,urn:l3,"urn:uuid":u3};F1.exports=Zb});var H1=R((cPe,rm)=>{"use strict";var{normalizeIPv6:d3,normalizeIPv4:f3,removeDotSegments:eu,recomposeAuthority:p3,normalizeComponentEncoding:tm}=x1(),e_=j1();function h3(t,e){return typeof t=="string"?t=li(Oi(t,e),e):typeof t=="object"&&(t=Oi(li(t,e),e)),t}function m3(t,e,r){let n=Object.assign({scheme:"null"},r),i=U1(Oi(t,n),Oi(e,n),n,!0);return li(i,{...n,skipEscape:!0})}function U1(t,e,r,n){let i={};return n||(t=Oi(li(t,r),r),e=Oi(li(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(i.scheme=e.scheme,i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=eu(e.path||""),i.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(i.userinfo=e.userinfo,i.host=e.host,i.port=e.port,i.path=eu(e.path||""),i.query=e.query):(e.path?(e.path.charAt(0)==="/"?i.path=eu(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?i.path="/"+e.path:t.path?i.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:i.path=e.path,i.path=eu(i.path)),i.query=e.query):(i.path=t.path,e.query!==void 0?i.query=e.query:i.query=t.query),i.userinfo=t.userinfo,i.host=t.host,i.port=t.port),i.scheme=t.scheme),i.fragment=e.fragment,i}function g3(t,e,r){return typeof t=="string"?(t=unescape(t),t=li(tm(Oi(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=li(tm(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=li(tm(Oi(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=li(tm(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function li(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),i=[],s=e_[(n.scheme||r.scheme||"").toLowerCase()];s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&i.push(r.scheme,":");let o=p3(r);if(o!==void 0&&(n.reference!=="suffix"&&i.push("//"),i.push(o),r.path&&r.path.charAt(0)!=="/"&&i.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=eu(a)),o===void 0&&(a=a.replace(/^\/\//u,"/%2F")),i.push(a)}return r.query!==void 0&&i.push("?",r.query),r.fragment!==void 0&&i.push("#",r.fragment),i.join("")}var y3=Array.from({length:127},(t,e)=>/[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(e)));function v3(t){let e=0;for(let r=0,n=t.length;r<n;++r)if(e=t.charCodeAt(r),e>126||y3[e])return!0;return!1}var T3=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Oi(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},i=t.indexOf("%")!==-1,s=!1;r.reference==="suffix"&&(t=(r.scheme?r.scheme+":":"")+"//"+t);let o=t.match(T3);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=f3(n.host);if(c.isIPV4===!1){let l=d3(c.host);n.host=l.host.toLowerCase(),s=l.isIPV6}else n.host=c.host,s=!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",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let a=e_[(r.scheme||n.scheme||"").toLowerCase()];if(!r.unicodeSupport&&(!a||!a.unicodeSupport)&&n.host&&(r.domainHost||a&&a.domainHost)&&s===!1&&v3(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)&&(i&&n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),i&&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,r)}else n.error=n.error||"URI can not be parsed.";return n}var t_={SCHEMES:e_,normalize:h3,resolve:m3,resolveComponents:U1,equal:g3,serialize:li,parse:Oi};rm.exports=t_;rm.exports.default=t_;rm.exports.fastUri=t_});var z1=R(r_=>{"use strict";Object.defineProperty(r_,"__esModule",{value:!0});var V1=H1();V1.code='require("ajv/dist/runtime/uri").default';r_.default=V1});var Z1=R(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.CodeGen=nr.Name=nr.nil=nr.stringify=nr.str=nr._=nr.KeywordCxt=void 0;var b3=Jl();Object.defineProperty(nr,"KeywordCxt",{enumerable:!0,get:function(){return b3.KeywordCxt}});var La=Te();Object.defineProperty(nr,"_",{enumerable:!0,get:function(){return La._}});Object.defineProperty(nr,"str",{enumerable:!0,get:function(){return La.str}});Object.defineProperty(nr,"stringify",{enumerable:!0,get:function(){return La.stringify}});Object.defineProperty(nr,"nil",{enumerable:!0,get:function(){return La.nil}});Object.defineProperty(nr,"Name",{enumerable:!0,get:function(){return La.Name}});Object.defineProperty(nr,"CodeGen",{enumerable:!0,get:function(){return La.CodeGen}});var _3=Qh(),X1=Ql(),S3=Ib(),tu=Zl(),N3=Te(),ru=Yl(),nm=Gl(),i_=ke(),W1=P1(),R3=z1(),J1=(t,e)=>new RegExp(t,e);J1.code="new RegExp";var P3=["removeAdditional","useDefaults","coerceTypes"],k3=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),w3={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."},E3={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},G1=200;function C3(t){var e,r,n,i,s,o,a,c,l,u,d,f,p,g,h,v,S,_,T,P,C,$,F,H,me;let Xe=t.strict,jt=(e=t.code)===null||e===void 0?void 0:e.optimize,Ne=jt===!0||jt===void 0?1:jt||0,Kr=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:J1,Mi=(i=t.uriResolver)!==null&&i!==void 0?i:R3.default;return{strictSchema:(o=(s=t.strictSchema)!==null&&s!==void 0?s:Xe)!==null&&o!==void 0?o:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:Xe)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=t.strictTypes)!==null&&l!==void 0?l:Xe)!==null&&u!==void 0?u:"log",strictTuples:(f=(d=t.strictTuples)!==null&&d!==void 0?d:Xe)!==null&&f!==void 0?f:"log",strictRequired:(g=(p=t.strictRequired)!==null&&p!==void 0?p:Xe)!==null&&g!==void 0?g:!1,code:t.code?{...t.code,optimize:Ne,regExp:Kr}:{optimize:Ne,regExp:Kr},loopRequired:(h=t.loopRequired)!==null&&h!==void 0?h:G1,loopEnum:(v=t.loopEnum)!==null&&v!==void 0?v:G1,meta:(S=t.meta)!==null&&S!==void 0?S:!0,messages:(_=t.messages)!==null&&_!==void 0?_:!0,inlineRefs:(T=t.inlineRefs)!==null&&T!==void 0?T:!0,schemaId:(P=t.schemaId)!==null&&P!==void 0?P:"$id",addUsedSchema:(C=t.addUsedSchema)!==null&&C!==void 0?C:!0,validateSchema:($=t.validateSchema)!==null&&$!==void 0?$:!0,validateFormats:(F=t.validateFormats)!==null&&F!==void 0?F:!0,unicodeRegExp:(H=t.unicodeRegExp)!==null&&H!==void 0?H:!0,int32range:(me=t.int32range)!==null&&me!==void 0?me:!0,uriResolver:Mi}}var nu=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...C3(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new N3.ValueScope({scope:{},prefixes:k3,es5:r,lines:n}),this.logger=x3(e.logger);let i=e.validateFormats;e.validateFormats=!1,this.RULES=(0,S3.getRules)(),Y1.call(this,w3,e,"NOT SUPPORTED"),Y1.call(this,E3,e,"DEPRECATED","warn"),this._metaOpts=O3.call(this),e.formats&&A3.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&I3.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),D3.call(this),e.validateFormats=i}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,i=W1;n==="id"&&(i={...W1},i.id=i.$id,delete i.$id),r&&e&&this.addMetaSchema(i,i[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){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 i=n(r);return"$async"in n||(this.errors=n.errors),i}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return i.call(this,e,r);async function i(u,d){await s.call(this,u.$schema);let f=this._addSchema(u,d);return f.validate||o.call(this,f)}async function s(u){u&&!this.getSchema(u)&&await i.call(this,{$ref:u},!0)}async function o(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof X1.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 s.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,r)}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,r,n,i=this.opts.validateSchema){if(Array.isArray(e)){for(let o of e)this.addSchema(o,void 0,n,i);return this}let s;if(typeof e=="object"){let{schemaId:o}=this.opts;if(s=e[o],s!==void 0&&typeof s!="string")throw new Error(`schema ${o} must be string`)}return r=(0,ru.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,i,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){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 i=this.validate(n,e);if(!i&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return i}getSchema(e){let r;for(;typeof(r=K1.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,i=new tu.SchemaEnv({schema:{},schemaId:n});if(r=tu.resolveSchema.call(this,i,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}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 r=K1.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,ru.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.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(L3.call(this,n,r),!r)return(0,i_.eachItem)(n,s=>n_.call(this,s)),this;B3.call(this,r);let i={...r,type:(0,nm.getJSONTypes)(r.type),schemaType:(0,nm.getJSONTypes)(r.schemaType)};return(0,i_.eachItem)(n,i.type.length===0?s=>n_.call(this,s,i):s=>i.type.forEach(o=>n_.call(this,s,i,o))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let i=n.rules.findIndex(s=>s.keyword===e);i>=0&&n.rules.splice(i,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(i=>`${n}${i.instancePath} ${i.message}`).reduce((i,s)=>i+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let i of r){let s=i.split("/").slice(1),o=e;for(let a of s)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]=Q1(u))}}return e}_removeAllSchemas(e,r){for(let n in e){let i=e[n];(!r||r.test(n))&&(typeof i=="string"?delete e[n]:i&&!i.meta&&(this._cache.delete(i.schema),delete e[n]))}}_addSchema(e,r,n,i=this.opts.validateSchema,s=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,ru.normalizeId)(o||n);let l=ru.getSchemaRefs.call(this,e,n);return c=new tu.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:l}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),i&&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):tu.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{tu.compileSchema.call(this,e)}finally{this.opts=r}}};nu.ValidationError=_3.default;nu.MissingRefError=X1.default;nr.default=nu;function Y1(t,e,r,n="error"){for(let i in t){let s=i;s in e&&this.logger[n](`${r}: option ${i}. ${t[s]}`)}}function K1(t){return t=(0,ru.normalizeId)(t),this.schemas[t]||this.refs[t]}function D3(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function A3(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function I3(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function O3(){let t={...this.opts};for(let e of P3)delete t[e];return t}var M3={log(){},warn(){},error(){}};function x3(t){if(t===!1)return M3;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var q3=/^[a-z_$][a-z0-9_$:-]*$/i;function L3(t,e){let{RULES:r}=this;if((0,i_.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!q3.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 n_(t,e,r){var n;let i=e?.post;if(r&&i)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,o=i?s.post:s.rules.find(({type:c})=>c===r);if(o||(o={type:r,rules:[]},s.rules.push(o)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,nm.getJSONTypes)(e.type),schemaType:(0,nm.getJSONTypes)(e.schemaType)}};e.before?$3.call(this,o,a,e.before):o.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function $3(t,e,r){let n=t.rules.findIndex(i=>i.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function B3(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Q1(e)),t.validateSchema=this.compile(e,!0))}var F3={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Q1(t){return{anyOf:[t,F3]}}});var eL=R(s_=>{"use strict";Object.defineProperty(s_,"__esModule",{value:!0});var j3={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};s_.default=j3});var om=R(ao=>{"use strict";Object.defineProperty(ao,"__esModule",{value:!0});ao.callRef=ao.getValidate=void 0;var U3=Ql(),tL=gn(),Fr=Te(),$a=mn(),rL=Zl(),im=ke(),H3={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:i,schemaEnv:s,validateName:o,opts:a,self:c}=n,{root:l}=s;if((r==="#"||r==="#/")&&i===l.baseId)return d();let u=rL.resolveRef.call(c,l,i,r);if(u===void 0)throw new U3.default(n.opts.uriResolver,i,r);if(u instanceof rL.SchemaEnv)return f(u);return p(u);function d(){if(s===l)return sm(t,o,s,s.$async);let g=e.scopeValue("root",{ref:l});return sm(t,(0,Fr._)`${g}.validate`,l,l.$async)}function f(g){let h=nL(t,g);sm(t,h,g,g.$async)}function p(g){let h=e.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,Fr.stringify)(g)}:{ref:g}),v=e.name("valid"),S=t.subschema({schema:g,dataTypes:[],schemaPath:Fr.nil,topSchemaRef:h,errSchemaPath:r},v);t.mergeEvaluated(S),t.ok(v)}}};function nL(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Fr._)`${r.scopeValue("wrapper",{ref:e})}.validate`}ao.getValidate=nL;function sm(t,e,r,n){let{gen:i,it:s}=t,{allErrors:o,schemaEnv:a,opts:c}=s,l=c.passContext?$a.default.this:Fr.nil;n?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let g=i.let("valid");i.try(()=>{i.code((0,Fr._)`await ${(0,tL.callValidateCode)(t,e,l)}`),p(e),o||i.assign(g,!0)},h=>{i.if((0,Fr._)`!(${h} instanceof ${s.ValidationError})`,()=>i.throw(h)),f(h),o||i.assign(g,!1)}),t.ok(g)}function d(){t.result((0,tL.callValidateCode)(t,e,l),()=>p(e),()=>f(e))}function f(g){let h=(0,Fr._)`${g}.errors`;i.assign($a.default.vErrors,(0,Fr._)`${$a.default.vErrors} === null ? ${h} : ${$a.default.vErrors}.concat(${h})`),i.assign($a.default.errors,(0,Fr._)`${$a.default.vErrors}.length`)}function p(g){var h;if(!s.opts.unevaluated)return;let v=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(s.props=im.mergeEvaluated.props(i,v.props,s.props));else{let S=i.var("props",(0,Fr._)`${g}.evaluated.props`);s.props=im.mergeEvaluated.props(i,S,s.props,Fr.Name)}if(s.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(s.items=im.mergeEvaluated.items(i,v.items,s.items));else{let S=i.var("items",(0,Fr._)`${g}.evaluated.items`);s.items=im.mergeEvaluated.items(i,S,s.items,Fr.Name)}}}ao.callRef=sm;ao.default=H3});var iL=R(o_=>{"use strict";Object.defineProperty(o_,"__esModule",{value:!0});var V3=eL(),z3=om(),W3=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",V3.default,z3.default];o_.default=W3});var sL=R(a_=>{"use strict";Object.defineProperty(a_,"__esModule",{value:!0});var am=Te(),ks=am.operators,cm={maximum:{okStr:"<=",ok:ks.LTE,fail:ks.GT},minimum:{okStr:">=",ok:ks.GTE,fail:ks.LT},exclusiveMaximum:{okStr:"<",ok:ks.LT,fail:ks.GTE},exclusiveMinimum:{okStr:">",ok:ks.GT,fail:ks.LTE}},G3={message:({keyword:t,schemaCode:e})=>(0,am.str)`must be ${cm[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,am._)`{comparison: ${cm[t].okStr}, limit: ${e}}`},Y3={keyword:Object.keys(cm),type:"number",schemaType:"number",$data:!0,error:G3,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,am._)`${r} ${cm[e].fail} ${n} || isNaN(${r})`)}};a_.default=Y3});var oL=R(c_=>{"use strict";Object.defineProperty(c_,"__esModule",{value:!0});var iu=Te(),K3={message:({schemaCode:t})=>(0,iu.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,iu._)`{multipleOf: ${t}}`},X3={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:K3,code(t){let{gen:e,data:r,schemaCode:n,it:i}=t,s=i.opts.multipleOfPrecision,o=e.let("res"),a=s?(0,iu._)`Math.abs(Math.round(${o}) - ${o}) > 1e-${s}`:(0,iu._)`${o} !== parseInt(${o})`;t.fail$data((0,iu._)`(${n} === 0 || (${o} = ${r}/${n}, ${a}))`)}};c_.default=X3});var cL=R(l_=>{"use strict";Object.defineProperty(l_,"__esModule",{value:!0});function aL(t){let e=t.length,r=0,n=0,i;for(;n<e;)r++,i=t.charCodeAt(n++),i>=55296&&i<=56319&&n<e&&(i=t.charCodeAt(n),(i&64512)===56320&&n++);return r}l_.default=aL;aL.code='require("ajv/dist/runtime/ucs2length").default'});var lL=R(u_=>{"use strict";Object.defineProperty(u_,"__esModule",{value:!0});var co=Te(),J3=ke(),Q3=cL(),Z3={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,co.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,co._)`{limit: ${t}}`},eX={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Z3,code(t){let{keyword:e,data:r,schemaCode:n,it:i}=t,s=e==="maxLength"?co.operators.GT:co.operators.LT,o=i.opts.unicode===!1?(0,co._)`${r}.length`:(0,co._)`${(0,J3.useFunc)(t.gen,Q3.default)}(${r})`;t.fail$data((0,co._)`${o} ${s} ${n}`)}};u_.default=eX});var uL=R(d_=>{"use strict";Object.defineProperty(d_,"__esModule",{value:!0});var tX=gn(),lm=Te(),rX={message:({schemaCode:t})=>(0,lm.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,lm._)`{pattern: ${t}}`},nX={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:rX,code(t){let{data:e,$data:r,schema:n,schemaCode:i,it:s}=t,o=s.opts.unicodeRegExp?"u":"",a=r?(0,lm._)`(new RegExp(${i}, ${o}))`:(0,tX.usePattern)(t,n);t.fail$data((0,lm._)`!${a}.test(${e})`)}};d_.default=nX});var dL=R(f_=>{"use strict";Object.defineProperty(f_,"__esModule",{value:!0});var su=Te(),iX={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,su.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,su._)`{limit: ${t}}`},sX={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:iX,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxProperties"?su.operators.GT:su.operators.LT;t.fail$data((0,su._)`Object.keys(${r}).length ${i} ${n}`)}};f_.default=sX});var fL=R(p_=>{"use strict";Object.defineProperty(p_,"__esModule",{value:!0});var ou=gn(),au=Te(),oX=ke(),aX={message:({params:{missingProperty:t}})=>(0,au.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,au._)`{missingProperty: ${t}}`},cX={keyword:"required",type:"object",schemaType:"array",$data:!0,error:aX,code(t){let{gen:e,schema:r,schemaCode:n,data:i,$data:s,it:o}=t,{opts:a}=o;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(o.allErrors?l():u(),a.strictRequired){let p=t.parentSchema.properties,{definedProperties:g}=t.it;for(let h of r)if(p?.[h]===void 0&&!g.has(h)){let v=o.schemaEnv.baseId+o.errSchemaPath,S=`required property "${h}" is not defined at "${v}" (strictRequired)`;(0,oX.checkStrictMode)(o,S,o.opts.strictRequired)}}function l(){if(c||s)t.block$data(au.nil,d);else for(let p of r)(0,ou.checkReportMissingProp)(t,p)}function u(){let p=e.let("missing");if(c||s){let g=e.let("valid",!0);t.block$data(g,()=>f(p,g)),t.ok(g)}else e.if((0,ou.checkMissingProp)(t,r,p)),(0,ou.reportMissingProp)(t,p),e.else()}function d(){e.forOf("prop",n,p=>{t.setParams({missingProperty:p}),e.if((0,ou.noPropertyInData)(e,i,p,a.ownProperties),()=>t.error())})}function f(p,g){t.setParams({missingProperty:p}),e.forOf(p,n,()=>{e.assign(g,(0,ou.propertyInData)(e,i,p,a.ownProperties)),e.if((0,au.not)(g),()=>{t.error(),e.break()})},au.nil)}}};p_.default=cX});var pL=R(h_=>{"use strict";Object.defineProperty(h_,"__esModule",{value:!0});var cu=Te(),lX={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,cu.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,cu._)`{limit: ${t}}`},uX={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:lX,code(t){let{keyword:e,data:r,schemaCode:n}=t,i=e==="maxItems"?cu.operators.GT:cu.operators.LT;t.fail$data((0,cu._)`${r}.length ${i} ${n}`)}};h_.default=uX});var um=R(m_=>{"use strict";Object.defineProperty(m_,"__esModule",{value:!0});var hL=Fb();hL.code='require("ajv/dist/runtime/equal").default';m_.default=hL});var mL=R(y_=>{"use strict";Object.defineProperty(y_,"__esModule",{value:!0});var g_=Gl(),ir=Te(),dX=ke(),fX=um(),pX={message:({params:{i:t,j:e}})=>(0,ir.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,ir._)`{i: ${t}, j: ${e}}`},hX={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:pX,code(t){let{gen:e,data:r,$data:n,schema:i,parentSchema:s,schemaCode:o,it:a}=t;if(!n&&!i)return;let c=e.let("valid"),l=s.items?(0,g_.getSchemaTypes)(s.items):[];t.block$data(c,u,(0,ir._)`${o} === false`),t.ok(c);function u(){let g=e.let("i",(0,ir._)`${r}.length`),h=e.let("j");t.setParams({i:g,j:h}),e.assign(c,!0),e.if((0,ir._)`${g} > 1`,()=>(d()?f:p)(g,h))}function d(){return l.length>0&&!l.some(g=>g==="object"||g==="array")}function f(g,h){let v=e.name("item"),S=(0,g_.checkDataTypes)(l,v,a.opts.strictNumbers,g_.DataType.Wrong),_=e.const("indices",(0,ir._)`{}`);e.for((0,ir._)`;${g}--;`,()=>{e.let(v,(0,ir._)`${r}[${g}]`),e.if(S,(0,ir._)`continue`),l.length>1&&e.if((0,ir._)`typeof ${v} == "string"`,(0,ir._)`${v} += "_"`),e.if((0,ir._)`typeof ${_}[${v}] == "number"`,()=>{e.assign(h,(0,ir._)`${_}[${v}]`),t.error(),e.assign(c,!1).break()}).code((0,ir._)`${_}[${v}] = ${g}`)})}function p(g,h){let v=(0,dX.useFunc)(e,fX.default),S=e.name("outer");e.label(S).for((0,ir._)`;${g}--;`,()=>e.for((0,ir._)`${h} = ${g}; ${h}--;`,()=>e.if((0,ir._)`${v}(${r}[${g}], ${r}[${h}])`,()=>{t.error(),e.assign(c,!1).break(S)})))}}};y_.default=hX});var gL=R(T_=>{"use strict";Object.defineProperty(T_,"__esModule",{value:!0});var v_=Te(),mX=ke(),gX=um(),yX={message:"must be equal to constant",params:({schemaCode:t})=>(0,v_._)`{allowedValue: ${t}}`},vX={keyword:"const",$data:!0,error:yX,code(t){let{gen:e,data:r,$data:n,schemaCode:i,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,v_._)`!${(0,mX.useFunc)(e,gX.default)}(${r}, ${i})`):t.fail((0,v_._)`${s} !== ${r}`)}};T_.default=vX});var yL=R(b_=>{"use strict";Object.defineProperty(b_,"__esModule",{value:!0});var lu=Te(),TX=ke(),bX=um(),_X={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,lu._)`{allowedValues: ${t}}`},SX={keyword:"enum",schemaType:"array",$data:!0,error:_X,code(t){let{gen:e,data:r,$data:n,schema:i,schemaCode:s,it:o}=t;if(!n&&i.length===0)throw new Error("enum must have non-empty array");let a=i.length>=o.opts.loopEnum,c,l=()=>c??(c=(0,TX.useFunc)(e,bX.default)),u;if(a||n)u=e.let("valid"),t.block$data(u,d);else{if(!Array.isArray(i))throw new Error("ajv implementation error");let p=e.const("vSchema",s);u=(0,lu.or)(...i.map((g,h)=>f(p,h)))}t.pass(u);function d(){e.assign(u,!1),e.forOf("v",s,p=>e.if((0,lu._)`${l()}(${r}, ${p})`,()=>e.assign(u,!0).break()))}function f(p,g){let h=i[g];return typeof h=="object"&&h!==null?(0,lu._)`${l()}(${r}, ${p}[${g}])`:(0,lu._)`${r} === ${h}`}}};b_.default=SX});var vL=R(__=>{"use strict";Object.defineProperty(__,"__esModule",{value:!0});var NX=sL(),RX=oL(),PX=lL(),kX=uL(),wX=dL(),EX=fL(),CX=pL(),DX=mL(),AX=gL(),IX=yL(),OX=[NX.default,RX.default,PX.default,kX.default,wX.default,EX.default,CX.default,DX.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},AX.default,IX.default];__.default=OX});var N_=R(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});uu.validateAdditionalItems=void 0;var lo=Te(),S_=ke(),MX={message:({params:{len:t}})=>(0,lo.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,lo._)`{limit: ${t}}`},xX={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:MX,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,S_.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}TL(t,n)}};function TL(t,e){let{gen:r,schema:n,data:i,keyword:s,it:o}=t;o.items=!0;let a=r.const("len",(0,lo._)`${i}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,lo._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,S_.alwaysValidSchema)(o,n)){let l=r.var("valid",(0,lo._)`${a} <= ${e.length}`);r.if((0,lo.not)(l),()=>c(l)),t.ok(l)}function c(l){r.forRange("i",e.length,a,u=>{t.subschema({keyword:s,dataProp:u,dataPropType:S_.Type.Num},l),o.allErrors||r.if((0,lo.not)(l),()=>r.break())})}}uu.validateAdditionalItems=TL;uu.default=xX});var R_=R(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});du.validateTuple=void 0;var bL=Te(),dm=ke(),qX=gn(),LX={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return _L(t,"additionalItems",e);r.items=!0,!(0,dm.alwaysValidSchema)(r,e)&&t.ok((0,qX.validateArray)(t))}};function _L(t,e,r=t.schema){let{gen:n,parentSchema:i,data:s,keyword:o,it:a}=t;u(i),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=dm.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),l=n.const("len",(0,bL._)`${s}.length`);r.forEach((d,f)=>{(0,dm.alwaysValidSchema)(a,d)||(n.if((0,bL._)`${l} > ${f}`,()=>t.subschema({keyword:o,schemaProp:f,dataProp:f},c)),t.ok(c))});function u(d){let{opts:f,errSchemaPath:p}=a,g=r.length,h=g===d.minItems&&(g===d.maxItems||d[e]===!1);if(f.strictTuples&&!h){let v=`"${o}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,dm.checkStrictMode)(a,v,f.strictTuples)}}}du.validateTuple=_L;du.default=LX});var SL=R(P_=>{"use strict";Object.defineProperty(P_,"__esModule",{value:!0});var $X=R_(),BX={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,$X.validateTuple)(t,"items")};P_.default=BX});var RL=R(k_=>{"use strict";Object.defineProperty(k_,"__esModule",{value:!0});var NL=Te(),FX=ke(),jX=gn(),UX=N_(),HX={message:({params:{len:t}})=>(0,NL.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,NL._)`{limit: ${t}}`},VX={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:HX,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:i}=r;n.items=!0,!(0,FX.alwaysValidSchema)(n,e)&&(i?(0,UX.validateAdditionalItems)(t,i):t.ok((0,jX.validateArray)(t)))}};k_.default=VX});var PL=R(w_=>{"use strict";Object.defineProperty(w_,"__esModule",{value:!0});var vn=Te(),fm=ke(),zX={message:({params:{min:t,max:e}})=>e===void 0?(0,vn.str)`must contain at least ${t} valid item(s)`:(0,vn.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,vn._)`{minContains: ${t}}`:(0,vn._)`{minContains: ${t}, maxContains: ${e}}`},WX={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:zX,code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:s}=t,o,a,{minContains:c,maxContains:l}=n;s.opts.next?(o=c===void 0?1:c,a=l):o=1;let u=e.const("len",(0,vn._)`${i}.length`);if(t.setParams({min:o,max:a}),a===void 0&&o===0){(0,fm.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&o>a){(0,fm.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,fm.alwaysValidSchema)(s,r)){let h=(0,vn._)`${u} >= ${o}`;a!==void 0&&(h=(0,vn._)`${h} && ${u} <= ${a}`),t.pass(h);return}s.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,vn._)`${i}.length > 0`,f)):(e.let(d,!1),f()),t.result(d,()=>t.reset());function f(){let h=e.name("_valid"),v=e.let("count",0);p(h,()=>e.if(h,()=>g(v)))}function p(h,v){e.forRange("i",0,u,S=>{t.subschema({keyword:"contains",dataProp:S,dataPropType:fm.Type.Num,compositeRule:!0},h),v()})}function g(h){e.code((0,vn._)`${h}++`),a===void 0?e.if((0,vn._)`${h} >= ${o}`,()=>e.assign(d,!0).break()):(e.if((0,vn._)`${h} > ${a}`,()=>e.assign(d,!1).break()),o===1?e.assign(d,!0):e.if((0,vn._)`${h} >= ${o}`,()=>e.assign(d,!0)))}}};w_.default=WX});var pm=R(ui=>{"use strict";Object.defineProperty(ui,"__esModule",{value:!0});ui.validateSchemaDeps=ui.validatePropertyDeps=ui.error=void 0;var E_=Te(),GX=ke(),fu=gn();ui.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,E_.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,E_._)`{property: ${t},
180
180
  missingProperty: ${n},
181
181
  depsCount: ${e},
182
- deps: ${r}}`};var YX={keyword:"dependencies",type:"object",schemaType:"object",error:ui.error,code(t){let[e,r]=KX(t);k1(t,e),w1(t,r)}};function KX({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let i=Array.isArray(t[n])?e:r;i[n]=t[n]}return[e,r]}function k1(t,e=t.schema){let{gen:r,data:n,it:i}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let o in e){let a=e[o];if(a.length===0)continue;let c=(0,fu.propertyInData)(r,n,o,i.opts.ownProperties);t.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),i.allErrors?r.if(c,()=>{for(let l of a)(0,fu.checkReportMissingProp)(t,l)}):(r.if((0,E_._)`${c} && (${(0,fu.checkMissingProp)(t,a,s)})`),(0,fu.reportMissingProp)(t,s),r.else())}}ui.validatePropertyDeps=k1;function w1(t,e=t.schema){let{gen:r,data:n,keyword:i,it:s}=t,o=r.name("valid");for(let a in e)(0,GX.alwaysValidSchema)(s,e[a])||(r.if((0,fu.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:i,schemaProp:a},o);t.mergeValidEvaluated(c,o)},()=>r.var(o,!0)),t.ok(o))}ui.validateSchemaDeps=w1;ui.default=YX});var C1=R(C_=>{"use strict";Object.defineProperty(C_,"__esModule",{value:!0});var E1=Te(),XX=ke(),JX={message:"property name must be valid",params:({params:t})=>(0,E1._)`{propertyName: ${t.propertyName}}`},QX={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:JX,code(t){let{gen:e,schema:r,data:n,it:i}=t;if((0,XX.alwaysValidSchema)(i,r))return;let s=e.name("valid");e.forIn("key",n,o=>{t.setParams({propertyName:o}),t.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},s),e.if((0,E1.not)(s),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(s)}};C_.default=QX});var A_=R(D_=>{"use strict";Object.defineProperty(D_,"__esModule",{value:!0});var hm=gn(),jn=Te(),ZX=mn(),mm=ke(),e4={message:"must NOT have additional properties",params:({params:t})=>(0,jn._)`{additionalProperty: ${t.additionalProperty}}`},t4={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:e4,code(t){let{gen:e,schema:r,parentSchema:n,data:i,errsCount:s,it:o}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=o;if(o.props=!0,c.removeAdditional!=="all"&&(0,mm.alwaysValidSchema)(o,r))return;let l=(0,hm.allSchemaProperties)(n.properties),u=(0,hm.allSchemaProperties)(n.patternProperties);d(),t.ok((0,jn._)`${s} === ${ZX.default.errors}`);function d(){e.forIn("key",i,v=>{!l.length&&!u.length?g(v):e.if(f(v),()=>g(v))})}function f(v){let S;if(l.length>8){let _=(0,mm.schemaRefOrVal)(o,n.properties,"properties");S=(0,hm.isOwnProperty)(e,_,v)}else l.length?S=(0,jn.or)(...l.map(_=>(0,jn._)`${v} === ${_}`)):S=jn.nil;return u.length&&(S=(0,jn.or)(S,...u.map(_=>(0,jn._)`${(0,hm.usePattern)(t,_)}.test(${v})`))),(0,jn.not)(S)}function p(v){e.code((0,jn._)`delete ${i}[${v}]`)}function g(v){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(v);return}if(r===!1){t.setParams({additionalProperty:v}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,mm.alwaysValidSchema)(o,r)){let S=e.name("valid");c.removeAdditional==="failing"?(h(v,S,!1),e.if((0,jn.not)(S),()=>{t.reset(),p(v)})):(h(v,S),a||e.if((0,jn.not)(S),()=>e.break()))}}function h(v,S,_){let T={keyword:"additionalProperties",dataProp:v,dataPropType:mm.Type.Str};_===!1&&Object.assign(T,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(T,S)}}};D_.default=t4});var I1=R(O_=>{"use strict";Object.defineProperty(O_,"__esModule",{value:!0});var r4=Jl(),D1=gn(),I_=ke(),A1=A_(),n4={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&A1.default.code(new r4.KeywordCxt(s,A1.default,"additionalProperties"));let o=(0,D1.allSchemaProperties)(r);for(let d of o)s.definedProperties.add(d);s.opts.unevaluated&&o.length&&s.props!==!0&&(s.props=I_.mergeEvaluated.props(e,(0,I_.toHash)(o),s.props));let a=o.filter(d=>!(0,I_.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,D1.propertyInData)(e,i,d,s.opts.ownProperties)),u(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function l(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function u(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};O_.default=n4});var q1=R(M_=>{"use strict";Object.defineProperty(M_,"__esModule",{value:!0});var O1=gn(),gm=Te(),M1=ke(),x1=ke(),i4={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:i,it:s}=t,{opts:o}=s,a=(0,O1.allSchemaProperties)(r),c=a.filter(h=>(0,M1.alwaysValidSchema)(s,r[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let l=o.strictSchema&&!o.allowMatchingProperties&&i.properties,u=e.name("valid");s.props!==!0&&!(s.props instanceof gm.Name)&&(s.props=(0,x1.evaluatedPropsToName)(e,s.props));let{props:d}=s;f();function f(){for(let h of a)l&&p(h),s.allErrors?g(h):(e.var(u,!0),g(h),e.if(u))}function p(h){for(let v in l)new RegExp(h).test(v)&&(0,M1.checkStrictMode)(s,`property ${v} matches pattern ${h} (use allowMatchingProperties)`)}function g(h){e.forIn("key",n,v=>{e.if((0,gm._)`${(0,O1.usePattern)(t,h)}.test(${v})`,()=>{let S=c.includes(h);S||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:v,dataPropType:x1.Type.Str},u),s.opts.unevaluated&&d!==!0?e.assign((0,gm._)`${d}[${v}]`,!0):!S&&!s.allErrors&&e.if((0,gm.not)(u),()=>e.break())})})}}};M_.default=i4});var L1=R(x_=>{"use strict";Object.defineProperty(x_,"__esModule",{value:!0});var s4=ke(),o4={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,s4.alwaysValidSchema)(n,r)){t.fail();return}let i=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),t.failResult(i,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};x_.default=o4});var $1=R(q_=>{"use strict";Object.defineProperty(q_,"__esModule",{value:!0});var a4=gn(),c4={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:a4.validateUnion,error:{message:"must match a schema in anyOf"}};q_.default=c4});var B1=R(L_=>{"use strict";Object.defineProperty(L_,"__esModule",{value:!0});var ym=Te(),l4=ke(),u4={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,ym._)`{passingSchemas: ${t.passing}}`},d4={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:u4,code(t){let{gen:e,schema:r,parentSchema:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;let s=r,o=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(l),t.result(o,()=>t.reset(),()=>t.error(!0));function l(){s.forEach((u,d)=>{let f;(0,l4.alwaysValidSchema)(i,u)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,ym._)`${c} && ${o}`).assign(o,!1).assign(a,(0,ym._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(o,!0),e.assign(a,d),f&&t.mergeEvaluated(f,ym.Name)})})}}};L_.default=d4});var F1=R($_=>{"use strict";Object.defineProperty($_,"__esModule",{value:!0});var f4=ke(),p4={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let i=e.name("valid");r.forEach((s,o)=>{if((0,f4.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:o},i);t.ok(i),t.mergeEvaluated(a)})}};$_.default=p4});var H1=R(B_=>{"use strict";Object.defineProperty(B_,"__esModule",{value:!0});var vm=Te(),U1=ke(),h4={message:({params:t})=>(0,vm.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,vm._)`{failingKeyword: ${t.ifClause}}`},m4={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:h4,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,U1.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=j1(n,"then"),s=j1(n,"else");if(!i&&!s)return;let o=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),i&&s){let u=e.let("ifClause");t.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else i?e.if(a,l("then")):e.if((0,vm.not)(a),l("else"));t.pass(o,()=>t.error(!0));function c(){let u=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(u)}function l(u,d){return()=>{let f=t.subschema({keyword:u},a);e.assign(o,a),t.mergeValidEvaluated(f,o),d?e.assign(d,(0,vm._)`${u}`):t.setParams({ifClause:u})}}}};function j1(t,e){let r=t.schema[e];return r!==void 0&&!(0,U1.alwaysValidSchema)(t,r)}B_.default=m4});var V1=R(F_=>{"use strict";Object.defineProperty(F_,"__esModule",{value:!0});var g4=ke(),y4={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,g4.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};F_.default=y4});var z1=R(j_=>{"use strict";Object.defineProperty(j_,"__esModule",{value:!0});var v4=N_(),T4=S1(),b4=R_(),_4=R1(),S4=P1(),N4=pm(),R4=C1(),P4=A_(),k4=I1(),w4=q1(),E4=L1(),C4=$1(),D4=B1(),A4=F1(),I4=H1(),O4=V1();function M4(t=!1){let e=[E4.default,C4.default,D4.default,A4.default,I4.default,O4.default,R4.default,P4.default,N4.default,k4.default,w4.default];return t?e.push(T4.default,_4.default):e.push(v4.default,b4.default),e.push(S4.default),e}j_.default=M4});var W1=R(U_=>{"use strict";Object.defineProperty(U_,"__esModule",{value:!0});var Ot=Te(),x4={message:({schemaCode:t})=>(0,Ot.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Ot._)`{format: ${t}}`},q4={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:x4,code(t,e){let{gen:r,data:n,$data:i,schema:s,schemaCode:o,it:a}=t,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;i?f():p();function f(){let g=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,Ot._)`${g}[${o}]`),v=r.let("fType"),S=r.let("format");r.if((0,Ot._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(v,(0,Ot._)`${h}.type || "string"`).assign(S,(0,Ot._)`${h}.validate`),()=>r.assign(v,(0,Ot._)`"string"`).assign(S,h)),t.fail$data((0,Ot.or)(_(),T()));function _(){return c.strictSchema===!1?Ot.nil:(0,Ot._)`${o} && !${S}`}function T(){let P=u.$async?(0,Ot._)`(${h}.async ? await ${S}(${n}) : ${S}(${n}))`:(0,Ot._)`${S}(${n})`,C=(0,Ot._)`(typeof ${S} == "function" ? ${P} : ${S}.test(${n}))`;return(0,Ot._)`${S} && ${S} !== true && ${v} === ${e} && !${C}`}}function p(){let g=d.formats[s];if(!g){_();return}if(g===!0)return;let[h,v,S]=T(g);h===e&&t.pass(P());function _(){if(c.strictSchema===!1){d.logger.warn(C());return}throw new Error(C());function C(){return`unknown format "${s}" ignored in schema at path "${l}"`}}function T(C){let $=C instanceof RegExp?(0,Ot.regexpCode)(C):c.code.formats?(0,Ot._)`${c.code.formats}${(0,Ot.getProperty)(s)}`:void 0,F=r.scopeValue("formats",{key:s,ref:C,code:$});return typeof C=="object"&&!(C instanceof RegExp)?[C.type||"string",C.validate,(0,Ot._)`${F}.validate`]:["string",C,F]}function P(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!u.$async)throw new Error("async format in sync schema");return(0,Ot._)`await ${S}(${n})`}return typeof v=="function"?(0,Ot._)`${S}(${n})`:(0,Ot._)`${S}.test(${n})`}}}};U_.default=q4});var G1=R(H_=>{"use strict";Object.defineProperty(H_,"__esModule",{value:!0});var L4=W1(),$4=[L4.default];H_.default=$4});var Y1=R(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.contentVocabulary=Ba.metadataVocabulary=void 0;Ba.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ba.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var X1=R(V_=>{"use strict";Object.defineProperty(V_,"__esModule",{value:!0});var B4=i1(),F4=v1(),j4=z1(),U4=G1(),K1=Y1(),H4=[B4.default,F4.default,(0,j4.default)(),U4.default,K1.metadataVocabulary,K1.contentVocabulary];V_.default=H4});var W_=R(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});pu.dynamicAnchor=void 0;var z_=Te(),V4=mn(),J1=Zl(),z4=om(),W4={keyword:"$dynamicAnchor",schemaType:"string",code:t=>Q1(t,t.schema)};function Q1(t,e){let{gen:r,it:n}=t;n.schemaEnv.root.dynamicAnchors[e]=!0;let i=(0,z_._)`${V4.default.dynamicAnchors}${(0,z_.getProperty)(e)}`,s=n.errSchemaPath==="#"?n.validateName:G4(t);r.if((0,z_._)`!${i}`,()=>r.assign(i,s))}pu.dynamicAnchor=Q1;function G4(t){let{schemaEnv:e,schema:r,self:n}=t.it,{root:i,baseId:s,localRefs:o,meta:a}=e.root,{schemaId:c}=n.opts,l=new J1.SchemaEnv({schema:r,schemaId:c,root:i,baseId:s,localRefs:o,meta:a});return J1.compileSchema.call(n,l),(0,z4.getValidate)(t,l)}pu.default=W4});var G_=R(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});hu.dynamicRef=void 0;var Z1=Te(),Y4=mn(),e$=om(),K4={keyword:"$dynamicRef",schemaType:"string",code:t=>t$(t,t.schema)};function t$(t,e){let{gen:r,keyword:n,it:i}=t;if(e[0]!=="#")throw new Error(`"${n}" only supports hash fragment reference`);let s=e.slice(1);if(i.allErrors)o();else{let c=r.let("valid",!1);o(c),t.ok(c)}function o(c){if(i.schemaEnv.root.dynamicAnchors[s]){let l=r.let("_v",(0,Z1._)`${Y4.default.dynamicAnchors}${(0,Z1.getProperty)(s)}`);r.if(l,a(l,c),a(i.validateName,c))}else a(i.validateName,c)()}function a(c,l){return l?()=>r.block(()=>{(0,e$.callRef)(t,c),r.let(l,!0)}):()=>(0,e$.callRef)(t,c)}}hu.dynamicRef=t$;hu.default=K4});var r$=R(Y_=>{"use strict";Object.defineProperty(Y_,"__esModule",{value:!0});var X4=W_(),J4=ke(),Q4={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,X4.dynamicAnchor)(t,""):(0,J4.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};Y_.default=Q4});var n$=R(K_=>{"use strict";Object.defineProperty(K_,"__esModule",{value:!0});var Z4=G_(),e9={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,Z4.dynamicRef)(t,t.schema)};K_.default=e9});var i$=R(X_=>{"use strict";Object.defineProperty(X_,"__esModule",{value:!0});var t9=W_(),r9=G_(),n9=r$(),i9=n$(),s9=[t9.default,r9.default,n9.default,i9.default];X_.default=s9});var o$=R(J_=>{"use strict";Object.defineProperty(J_,"__esModule",{value:!0});var s$=pm(),o9={keyword:"dependentRequired",type:"object",schemaType:"object",error:s$.error,code:t=>(0,s$.validatePropertyDeps)(t)};J_.default=o9});var a$=R(Q_=>{"use strict";Object.defineProperty(Q_,"__esModule",{value:!0});var a9=pm(),c9={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,a9.validateSchemaDeps)(t)};Q_.default=c9});var c$=R(Z_=>{"use strict";Object.defineProperty(Z_,"__esModule",{value:!0});var l9=ke(),u9={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:r}){e.contains===void 0&&(0,l9.checkStrictMode)(r,`"${t}" without "contains" is ignored`)}};Z_.default=u9});var l$=R(eS=>{"use strict";Object.defineProperty(eS,"__esModule",{value:!0});var d9=o$(),f9=a$(),p9=c$(),h9=[d9.default,f9.default,p9.default];eS.default=h9});var d$=R(tS=>{"use strict";Object.defineProperty(tS,"__esModule",{value:!0});var ws=Te(),u$=ke(),m9=mn(),g9={message:"must NOT have unevaluated properties",params:({params:t})=>(0,ws._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},y9={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:g9,code(t){let{gen:e,schema:r,data:n,errsCount:i,it:s}=t;if(!i)throw new Error("ajv implementation error");let{allErrors:o,props:a}=s;a instanceof ws.Name?e.if((0,ws._)`${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))),s.props=!0,t.ok((0,ws._)`${i} === ${m9.default.errors}`);function c(d){if(r===!1){t.setParams({unevaluatedProperty:d}),t.error(),o||e.break();return}if(!(0,u$.alwaysValidSchema)(s,r)){let f=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:d,dataPropType:u$.Type.Str},f),o||e.if((0,ws.not)(f),()=>e.break())}}function l(d,f){return(0,ws._)`!${d} || !${d}[${f}]`}function u(d,f){let p=[];for(let g in d)d[g]===!0&&p.push((0,ws._)`${f} !== ${g}`);return(0,ws.and)(...p)}}};tS.default=y9});var p$=R(rS=>{"use strict";Object.defineProperty(rS,"__esModule",{value:!0});var uo=Te(),f$=ke(),v9={message:({params:{len:t}})=>(0,uo.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,uo._)`{limit: ${t}}`},T9={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:v9,code(t){let{gen:e,schema:r,data:n,it:i}=t,s=i.items||0;if(s===!0)return;let o=e.const("len",(0,uo._)`${n}.length`);if(r===!1)t.setParams({len:s}),t.fail((0,uo._)`${o} > ${s}`);else if(typeof r=="object"&&!(0,f$.alwaysValidSchema)(i,r)){let c=e.var("valid",(0,uo._)`${o} <= ${s}`);e.if((0,uo.not)(c),()=>a(c,s)),t.ok(c)}i.items=!0;function a(c,l){e.forRange("i",l,o,u=>{t.subschema({keyword:"unevaluatedItems",dataProp:u,dataPropType:f$.Type.Num},c),i.allErrors||e.if((0,uo.not)(c),()=>e.break())})}}};rS.default=T9});var h$=R(nS=>{"use strict";Object.defineProperty(nS,"__esModule",{value:!0});var b9=d$(),_9=p$(),S9=[b9.default,_9.default];nS.default=S9});var g$=R(Tm=>{"use strict";Object.defineProperty(Tm,"__esModule",{value:!0});Tm.DiscrError=void 0;var m$;(function(t){t.Tag="tag",t.Mapping="mapping"})(m$||(Tm.DiscrError=m$={}))});var v$=R(sS=>{"use strict";Object.defineProperty(sS,"__esModule",{value:!0});var Fa=Te(),iS=g$(),y$=Zl(),N9=Ql(),R9=ke(),P9={message:({params:{discrError:t,tagName:e}})=>t===iS.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Fa._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},k9={keyword:"discriminator",type:"object",schemaType:"object",error:P9,code(t){let{gen:e,data:r,schema:n,parentSchema:i,it:s}=t,{oneOf:o}=i;if(!s.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,Fa._)`${r}${(0,Fa.getProperty)(a)}`);e.if((0,Fa._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:iS.DiscrError.Tag,tag:l,tagName:a})),t.ok(c);function u(){let p=f();e.if(!1);for(let g in p)e.elseIf((0,Fa._)`${l} === ${g}`),e.assign(c,d(p[g]));e.else(),t.error(!1,{discrError:iS.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(p){let g=e.name("valid"),h=t.subschema({keyword:"oneOf",schemaProp:p},g);return t.mergeEvaluated(h,Fa.Name),g}function f(){var p;let g={},h=S(i),v=!0;for(let P=0;P<o.length;P++){let C=o[P];if(C?.$ref&&!(0,R9.schemaHasRulesButRef)(C,s.self.RULES)){let F=C.$ref;if(C=y$.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,F),C instanceof y$.SchemaEnv&&(C=C.schema),C===void 0)throw new N9.default(s.opts.uriResolver,s.baseId,F)}let $=(p=C?.properties)===null||p===void 0?void 0:p[a];if(typeof $!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);v=v&&(h||S(C)),_($,P)}if(!v)throw new Error(`discriminator: "${a}" must be required`);return g;function S({required:P}){return Array.isArray(P)&&P.includes(a)}function _(P,C){if(P.const)T(P.const,C);else if(P.enum)for(let $ of P.enum)T($,C);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function T(P,C){if(typeof P!="string"||P in g)throw new Error(`discriminator: "${a}" values must be unique strings`);g[P]=C}}}};sS.default=k9});var T$=R((cke,w9)=>{w9.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 b$=R((lke,E9)=>{E9.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 _$=R((uke,C9)=>{C9.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 S$=R((dke,D9)=>{D9.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 N$=R((fke,A9)=>{A9.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 R$=R((pke,I9)=>{I9.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 P$=R((hke,O9)=>{O9.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 k$=R(oS=>{"use strict";Object.defineProperty(oS,"__esModule",{value:!0});var M9=T$(),x9=b$(),q9=_$(),L9=S$(),$9=N$(),B9=R$(),F9=P$(),j9=["/properties"];function U9(t){return[M9,x9,q9,L9,e(this,$9),B9,e(this,F9)].forEach(r=>this.addMetaSchema(r,void 0,!1)),this;function e(r,n){return t?r.$dataMetaSchema(n,j9):n}}oS.default=U9});var w$=R((yt,cS)=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.MissingRefError=yt.ValidationError=yt.CodeGen=yt.Name=yt.nil=yt.stringify=yt.str=yt._=yt.KeywordCxt=yt.Ajv2019=void 0;var H9=ZL(),V9=X1(),z9=i$(),W9=l$(),G9=h$(),Y9=v$(),K9=k$(),aS="https://json-schema.org/draft/2019-09/schema",ja=class extends H9.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(z9.default),V9.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(W9.default),this.addVocabulary(G9.default),this.opts.discriminator&&this.addKeyword(Y9.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:r}=this.opts;r&&(K9.default.call(this,e),this.refs["http://json-schema.org/schema"]=aS)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(aS)?aS:void 0)}};yt.Ajv2019=ja;cS.exports=yt=ja;cS.exports.Ajv2019=ja;Object.defineProperty(yt,"__esModule",{value:!0});yt.default=ja;var X9=Jl();Object.defineProperty(yt,"KeywordCxt",{enumerable:!0,get:function(){return X9.KeywordCxt}});var Ua=Te();Object.defineProperty(yt,"_",{enumerable:!0,get:function(){return Ua._}});Object.defineProperty(yt,"str",{enumerable:!0,get:function(){return Ua.str}});Object.defineProperty(yt,"stringify",{enumerable:!0,get:function(){return Ua.stringify}});Object.defineProperty(yt,"nil",{enumerable:!0,get:function(){return Ua.nil}});Object.defineProperty(yt,"Name",{enumerable:!0,get:function(){return Ua.Name}});Object.defineProperty(yt,"CodeGen",{enumerable:!0,get:function(){return Ua.CodeGen}});var J9=Qh();Object.defineProperty(yt,"ValidationError",{enumerable:!0,get:function(){return J9.default}});var Q9=Ql();Object.defineProperty(yt,"MissingRefError",{enumerable:!0,get:function(){return Q9.default}})});var Ga=require("path"),lt=L(nw());var ef=class t{constructor(e,r,n,i){this._uri=e,this._languageId=r,this._version=n,this._content=i,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){let r=this.offsetAt(e.start),n=this.offsetAt(e.end);return this._content.substring(r,n)}return this._content}update(e,r){for(let n of e)if(t.isIncremental(n)){let i=sw(n.range),s=this.offsetAt(i.start),o=this.offsetAt(i.end);this._content=this._content.substring(0,s)+n.text+this._content.substring(o,this._content.length);let a=Math.max(i.start.line,0),c=Math.max(i.end.line,0),l=this._lineOffsets,u=iw(n.text,!1,s);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-s);if(d!==0)for(let f=a+1+u.length,p=l.length;f<p;f++)l[f]=l[f]+d}else if(t.isFull(n))this._content=n.text,this._lineOffsets=void 0;else throw new Error("Unknown change event received");this._version=r}getLineOffsets(){return this._lineOffsets===void 0&&(this._lineOffsets=iw(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let r=this.getLineOffsets(),n=0,i=r.length;if(i===0)return{line:0,character:e};for(;n<i;){let o=Math.floor((n+i)/2);r[o]>e?i=o:n=o+1}let s=n-1;return{line:s,character:e-r[s]}}offsetAt(e){let r=this.getLineOffsets();if(e.line>=r.length)return this._content.length;if(e.line<0)return 0;let n=r[e.line],i=e.line+1<r.length?r[e.line+1]:this._content.length;return Math.max(Math.min(n+e.character,i),n)}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){let r=e;return r!=null&&typeof r.text=="string"&&r.range!==void 0&&(r.rangeLength===void 0||typeof r.rangeLength=="number")}static isFull(e){let r=e;return r!=null&&typeof r.text=="string"&&r.range===void 0&&r.rangeLength===void 0}},Yi;(function(t){function e(i,s,o,a){return new ef(i,s,o,a)}t.create=e;function r(i,s,o){if(i instanceof ef)return i.update(s,o),i;throw new Error("TextDocument.update: document must be created by TextDocument.create")}t.update=r;function n(i,s){let o=i.getText(),a=Cy(s.map(qj),(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=i.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=i.offsetAt(u.range.end)}return l.push(o.substr(c)),l.join("")}t.applyEdits=n})(Yi||(Yi={}));function Cy(t,e){if(t.length<=1)return t;let r=t.length/2|0,n=t.slice(0,r),i=t.slice(r);Cy(n,e),Cy(i,e);let s=0,o=0,a=0;for(;s<n.length&&o<i.length;)e(n[s],i[o])<=0?t[a++]=n[s++]:t[a++]=i[o++];for(;s<n.length;)t[a++]=n[s++];for(;o<i.length;)t[a++]=i[o++];return t}function iw(t,e,r=0){let n=e?[r]:[];for(let i=0;i<t.length;i++){let s=t.charCodeAt(i);(s===13||s===10)&&(s===13&&i+1<t.length&&t.charCodeAt(i+1)===10&&i++,n.push(r+i+1))}return n}function sw(t){let e=t.start,r=t.end;return e.line>r.line||e.line===r.line&&e.character>r.character?{start:r,end:e}:t}function qj(t){let e=sw(t.range);return e!==t.range?{newText:t.newText,range:e}:t}var tf=["namespace","class","enum","interface","struct","typeParameter","type","parameter","variable","property","enumMember","decorator","event","function","method","macro","label","comment","string","keyword","number","regexp","operator"],rf=["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"];var Ay=L(require("url")),aw=require("crypto"),cw=require("path"),Ki=L(j());var Dy=L(j());var Cr=L(j());var Z=class{constructor(e){this._children=[];this.syntaxIssues=[];this.resetableIssues=[];this._firstToken=e?.start,this._lastToken=e?.end}get issues(){return[...this.syntaxIssues,...this.resetableIssues]}resetIssues(){this.resetableIssues=[],this.children.forEach(e=>e.resetIssues())}get serializeIssues(){return this.issues.map(e=>e())}get firstToken(){return this._firstToken??this._children[0].tokenIndexes.start}set firstToken(e){this._firstToken=e}get rangeTokens(){return{start:this.firstToken,end:this.lastToken}}get lastToken(){return this._lastToken??this._children.at(-1)?.lastToken??this.firstToken}set lastToken(e){this._lastToken=e}get uri(){return this.firstToken.uri}getTopMostAstNodeForFile(e){return de(e,this.uri)?[this]:this.children.flatMap(r=>r.getTopMostAstNodeForFile(e))}get tokenIndexes(){return{start:this.firstToken,end:this.lastToken}}getDocumentSymbols(e){if(!this.docSymbolsMeta)return this.children.flatMap(n=>n.getDocumentSymbols(e)??[]);if(!de(this.uri,e))return[];let r=fe(this);return[{name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind,range:r,selectionRange:r,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(![Cr.SymbolKind.File,Cr.SymbolKind.Class,Cr.SymbolKind.Constant].some(n=>n===e))return[];let r=fe(this);return[{location:Cr.Location.create(ve(this.uri),r),name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind},...this.children.flatMap(n=>n.getWorkspaceSymbols()??[]).filter(n=>n.kind===Cr.SymbolKind.File||n.kind===Cr.SymbolKind.Class||n.kind===Cr.SymbolKind.Constant)]}buildSemanticTokens(e){this._children.forEach(r=>r.buildSemanticTokens(e)),!(!this.semanticTokenType||!this.semanticTokenModifiers)&&e(yi(this.semanticTokenType),vi(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}isAncestorOf(e){return this.children.some(r=>r===e||r.isAncestorOf(e))}toPrettyString(e){return this.toString()}toString(e){return"TODO"}get range(){return Cr.Range.create(Cr.Position.create(this.firstToken.pos.line,this.firstToken.pos.col),Cr.Position.create(this.lastToken.pos.line,this.lastToken.pos.colEnd))}get serializeUri(){return ve(this.uri)}serialize(e){return{uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var we=class extends Z{toJson(){return-1}resolve(e){return nf(this.toString(),e)}evaluate(e){return Ee(`${this.operator?this.operator.toString():""}${this.resolve(e)}`)}isTrue(e){return Ee(`!!(${this.operator?this.operator.toString():""}${this.resolve(e)})`)}toPrettyString(e){let r=this.evaluate(e);return`${r.toString()} /* ${this.toString()}${typeof r=="number"?` = 0x${r.toString(16)}`:""} */`}serialize(e){return{type:"EXPRESSION",value:this.toString(),evaluated:this.evaluate(e),uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}},Gn=class extends we{constructor(r,n,i){super();this.expression=r;this.wrapped=n;this.addChild(r),i&&(this.addChild(i.operator),this.addChild(i.expression),this.join=[],this.join?.push(i))}get firstToken(){return this.openBracket?this.openBracket:super.firstToken}get lastToken(){return this.closeBracket?this.closeBracket:super.lastToken}addExpression(r,n){this.addChild(r),this.addChild(n),this.join??=[],this.join?.push({operator:r,expression:n})}toString(){let r=this.children.map(n=>n.toString()).join(" ");return this.wrapped?`(${r})`:`${r}`}isTrue(r){let n=`(${this.children.map(i=>i instanceof we?i.resolve(r):i.toString()).join(" ")})`;return Ee(`!!(${this.operator?this.operator.toString():""}${n})`)}};var Yn=class extends we{constructor(r,n,i){super(n);this.value=r;this.docSymbolsMeta={name:`param${i+1}`,kind:Dy.SymbolKind.Variable},this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.value}},Ti=class extends we{constructor(r,n){super();this.functionName=r;this.params=n;this.addChild(r),this.params.forEach(i=>this.addChild(i))}getDocumentSymbols(r){return de(this.uri,r)?[{name:this.functionName.name,kind:Dy.SymbolKind.Function,range:fe(this),selectionRange:fe(this),children:this.params.flatMap(n=>n?.getDocumentSymbols(r)??[])}]:[]}toString(){return`${this.functionName.toString()}(${this.params.map(r=>r?.toString()??"<NULL>").join(",")})`}isTrue(r){if(this.functionName.name==="defined"){let n=!!(this.params.length===1&&this.params[0]&&r.has(this.params[0].value));return this.operator?Ee(`!!(${this.operator}${n})`):n}return super.isTrue(r)}};var Vr=(t,e,r=!0,n=!0)=>({start:{line:t?.pos.line??0,character:r?t?.pos.col??0:(t?.pos.col??0)+(t?.pos.len??0)},end:{line:e?.pos.line??0,character:n?(e?.pos.col??0)+(e?.pos.len??0):e?.pos.col??0}});var fe=t=>Vr(t.tokenIndexes.start,t.tokenIndexes.end),lw=" ",uw=t=>{lw=t},Uo=()=>lw,yi=t=>tf.findIndex(e=>e===t),vi=t=>rf.findIndex(e=>e===t),Iy=(t,e,r)=>!de(t.uri,e)||r.line<t.pos.line?!1:r.line>t.pos.line?!0:r.character>t.pos.colEnd,Lj=(t,e,r)=>de(t.uri,e)?r.line<t.pos.line?!0:r.line>t.pos.line?!1:r.character<t.pos.col:!1,nn=(t,e,r)=>!!(de(t.uri,e)&&t.tokenIndexes?.start&&t.tokenIndexes?.end&&(t.tokenIndexes.start.pos.line<r.line||t.tokenIndexes.start.pos.line===r.line&&t.tokenIndexes.start.pos.col<=r.character)&&(t.tokenIndexes.end.pos.line>r.line||t.tokenIndexes.end.pos.line===r.line&&t.tokenIndexes.end.pos.colEnd>=r.character)),dw=(t,e,r)=>!!(de(t.uri,e)&&t.lastToken.value!==";"&&t.tokenIndexes?.start&&t.tokenIndexes?.end&&(t.tokenIndexes.start.pos.line===r.line||t.tokenIndexes.end.pos.line===r.line)&&r.character>=t.tokenIndexes.end.pos.colEnd),fw=(t,e,r)=>{if(!t)return!1;let i=t.filter(s=>s.pos.line===r.line).at(-1);return i&&i.pos.col>=r.character?!1:e.tokenIndexes?.end===i};var Kn=(t,e,r)=>{let n=t,i=t;for(;i;)n=i,i=[...n.children].reverse().find(s=>nn(s,e,r));return n},mc=(t,e,r)=>{let n=t,i=t;for(;i;)n=i,i=[...n.children].find(s=>Lj(s.lastToken,e,r));return n===t?void 0:n},gc=(t,e,r)=>{let n=t,i=t;for(;i;)n=i,i=[...n.children].reverse().find(s=>Iy(s.firstToken,e,r));return n===t?void 0:n},G=(t,e,r,{severity:n=Ki.DiagnosticSeverity.Error,linkedTo:i=[],tags:s,templateStrings:o=[],edit:a,codeActionTitle:c,inclusiveStart:l,inclusiveEnd:u}={severity:Ki.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let d=Vr(e.start,e.end,l,u),f={issues:Array.isArray(t)?t:[t],range:d,uri:e.start.uri,severity:n,linkedTo:i.map(({range:h,uri:v})=>({range:h,uri:v,templateStrings:[]})),tags:s,templateStrings:o,edit:a,codeActionTitle:c},p,g=()=>(p??={severity:f.severity,range:d,message:f.issues?f.issues.map(Fj).join(" or "):"",source:"devicetree",tags:f.tags,data:{firstToken:{pos:e.start.pos,tokens:e.start.tokens,value:e.start.value},lastToken:{pos:e.end.pos,tokens:e.end.tokens,value:e.end.value},issues:{type:"SyntaxIssue",items:f.issues,edit:f.edit,codeActionTitle:f.codeActionTitle}}},p);return r?.syntaxIssues.push(g),{raw:f,diagnostic:g}},qt=(t,e,r,{severity:n=Ki.DiagnosticSeverity.Error,linkedTo:i=[],tags:s,templateStrings:o=[],edit:a,codeActionTitle:c,linkedToTemplateStrings:l=[]}={severity:Ki.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[],linkedToTemplateStrings:[]})=>{let u=Vr(e.start,e.end),d={issues:Array.isArray(t)?t:[t],range:u,uri:e.start.uri,severity:n,linkedTo:i.map(({range:g,uri:h},v)=>({range:g,uri:h,templateStrings:l.at(v)??[]})),tags:s,templateStrings:o,edit:a,codeActionTitle:c},f,p=()=>(f??={severity:d.severity,range:u,message:jj(d),source:"devicetree",tags:d.tags,relatedInformation:[...d.linkedTo.map(g=>({message:d.issues.map(h=>Uj(h,g.templateStrings)).join(" or "),location:{uri:ve(g.uri),range:g.range}}))]},f);return r?.resetableIssues.push(p),{raw:d,diagnostic:p}},B=(t,e,r,{severity:n=Ki.DiagnosticSeverity.Error,linkedTo:i=[],tags:s,templateStrings:o=[],edit:a,codeActionTitle:c}={severity:Ki.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let l=Vr(e.start,e.end),u={issues:Array.isArray(t)?t:[t],range:l,severity:n,uri:e.start.uri,linkedTo:i.map(({range:p,uri:g})=>({range:p,uri:g,templateStrings:[]})),tags:s,templateStrings:o,edit:a,codeActionTitle:c},d,f=()=>(d??={severity:u.severity,range:l,message:Hj(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(Vj).join(" or "),location:{uri:ve(p.uri),range:p.range}}))],source:"devicetree",tags:u.tags,data:{firstToken:{pos:e.start.pos,tokens:e.start.tokens,value:e.start.value},lastToken:{pos:e.end.pos,tokens:e.end.tokens,value:e.end.value},issues:{type:"StandardTypeIssue",items:u.issues,edit:u.edit,codeActionTitle:u.codeActionTitle}}},d);return r?.resetableIssues.push(f),{raw:u,diagnostic:f}},pw=(t,e)=>[...t].sort((n,i)=>{let s=e.getSortKey(n),o=e.getSortKey(i);if(s===void 0||o===void 0)throw new Error("Sort keys must be set");if(s!==o)return s-o;if(!n.tokenIndexes?.end||!i.tokenIndexes?.end)throw new Error("Must have token indexes");return n.tokenIndexes.end.pos.line!==i.tokenIndexes.end.pos.line?n.tokenIndexes.end.pos.line-i.tokenIndexes.end.pos.line:n.tokenIndexes.end.pos.col-i.tokenIndexes.end.pos.col});async function _t(t,e,r){let n=Ae(t.textDocument.uri);if(!e)return[];let i=performance.now(),o=(await e.getRuntime()).getDeepestAstNode(n,t.position),a=e.getSortKey(o?.ast);return console.log(`search: ${performance.now()-i}ms`),r(o,l=>{let u=t.position;return de(l.uri,n)?!!(l.tokenIndexes?.end&&(l.tokenIndexes.end.pos.line<u.line||l.tokenIndexes.end.pos.line===u.line&&l.tokenIndexes.end.pos.colEnd<=u.character)):a!==void 0&&(e.getSortKey(l)??-1)<=a})}function W(t,e){return{start:t,end:e??t}}var U=(t,e)=>t?.tokens.some(r=>r===e),rt=(t,e=!1)=>r=>r?.value&&(e?t.toLowerCase()===r.value.toLowerCase():t===r.value)?"yes":$j(t)(r),je=t=>e=>e?.tokens.some(r=>r===t)?"yes":"no",$j=t=>e=>e?.value&&t.startsWith(e.value)?"partial":"no",En=(t,e)=>!!t&&!!e&&t.pos.line===e.pos.line&&de(t.uri,e.uri),Lt=(t,e)=>t?.adjacentToken&&t.adjacentToken.value===e?.value||e?.adjacentToken&&e.adjacentToken.value===t?.value?!0:!!t&&!!e&&En(t,e)&&t.pos.colEnd===e.pos.col,af=t=>t.map((e,r)=>({index:r,context:e,files:e.getContextFiles()})),sn=(t,e,r,n)=>{if("id"in e){let s=t?.find(o=>o.id===e.id);return s||void 0}if("name"in e){let s=t?.find(o=>o.ctxNames.includes(e.name));return s||void 0}return r?.getContextFiles().find(s=>de(s,e.uri))?r:af(t).sort(s=>s.context.id===n?-1:0).find(s=>s.files.some(o=>de(o,e.uri)))?.context},Oy=(t,e)=>af(t).filter(n=>n.files.some(i=>de(i,e))).map(n=>n.context),hw=t=>{let e=/^(\w+)\s+(.+)$/,r=/^(\w+)\(([^)]*)\)\s+(.+)$/,n=/^(\w+)\(([^)]*),\s*\.\.\.\)\s+(.+)$/,i;if(i=n.exec(t)){let[,,s,o]=i,a=s.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(i=r.exec(t)){let[,,s,o]=i,a=s.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(i=e.exec(t)){let[,,s]=i;return s.trim()}},nf=(t,e)=>{let r=o=>o.replace(/(\w+)\s*##\s*(\w+)/g,(a,c,l)=>c+l),n=o=>o.replace(/#(\w+)/g,(a,c)=>`"${c}"`),i=t,s;do s=i,i=r(s),i=n(i),i=i.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(i!==s);return i};function Bj(t){return t.replace(/'(.)'/g,(e,r)=>r.charCodeAt(0).toString()).replace(/(0x[a-f\d]+|\d+)[ul]*/gi,"$1")}function Ee(t){try{return(0,eval)(Bj(t))}catch(e){console.log(e instanceof Error?e.message:e)}return t}var ve=t=>Ay.default.pathToFileURL(t).toString(),Ae=t=>tt(Ay.default.fileURLToPath(t)),de=(t,e)=>!t||!e?!1:t===e,tt=t=>(0,cw.normalize)(process.platform==="win32"?t.toLowerCase():t),bi=t=>(0,aw.createHash)("sha256").update([tt(t.dtsFile),...t.includePaths.map(tt),...t.overlays.map(tt),t.bindingType,...t.zephyrBindings.map(tt),...t.deviceOrgBindingsMetaSchema.map(tt),...t.deviceOrgTreeBindings.map(tt)].join(":")).digest("hex"),Fj=t=>{switch(t){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 49:return"Node name shall start with a lower or upper case character";case 50:return"Node unit address should not start with 0x";case 51:return"Node unit address should not end with with ULL";case 8:return"Expected node address";case 9:return"Expected node path";case 48:return"Expected node path reference";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 52:return"Unknown Node Address syntax";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"}},jj=t=>t.issues.map(e=>{switch(e){case 0:return`Property "${t.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 "${t.templateStrings[0]}" has been defined`;case 8:return`No node with name "${t.templateStrings[0]}" could be found in "/${t.templateStrings[1]}".`;case 4:return`Label name "${t.templateStrings[0]}" already defined`;case 6:return`Property "${t.templateStrings[0]}" was deleted`;case 7:return`Node "${t.templateStrings[0]}" was deleted`;case 9:return`The following node "${t.templateStrings[1]}" shall be present in "${t.templateStrings[0]}" node.`;case 10:return`The following node "${t.templateStrings[0]}" address range collides with another node. Address start: "${t.templateStrings[1]}", end: "${t.templateStrings[2]}".`}}).join(" or "),Uj=(t,e)=>{switch(t){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";case 10:return`Node "${e[0]}". Address start: "${e[1]}", end: "${e[2]}".`;default:return"TODO"}},Hj=t=>t.issues.map(e=>{switch(e){case 9:return`Only these value are allowed ${t.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 ${t.templateStrings[1]} values`;case 0:return"INTRO is required";case 11:return"INTRO should be omitted";case 27:return"INTRO name is not permitted under this node";case 34:return"INTRO name is not defined in the type binding for this node";case 10:return"INTRO address 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 ${t.templateStrings[1]}'`;case 18:return"INTRO value must be unique in the entire Devicetree";case 19:return`INTRO should have format ${t.templateStrings[1]}`;case 16:return`INTRO requires property "${t.templateStrings[1]}" in node path "${t.templateStrings[2]}"`;case 17:return"Unable to resolve interrupt parent node";case 20:return`INTRO should have format ${t.templateStrings[1]}`;case 21:return"Node is disabled";case 22:return"Unable to resolve handle";case 23:return`Unable to find "${t.templateStrings[0]}" in ${t.templateStrings[1]}`;case 24:return t.templateStrings[0];case 25:return t.templateStrings[0];case 26:return t.templateStrings[0];case 28:return t.templateStrings[0];case 35:return"Unable to find mapping range for address";case 29:return`INTRO exceeds address space available for this mapping. The range ends at ${t.templateStrings[2]}, the node ends at ${t.templateStrings[1]}`;case 30:return"Map entry overlaps with others entries";case 31:return"Unable to match to a nexus map entry";case 32:return`Unknown node type "${t.templateStrings[0]}"`;case 33:return`Missing name for "${t.templateStrings[0]}" index ${t.templateStrings[1]}"`;case 36:return"Node address is missing";case 37:return`Binding should be used on bus type${t.templateStrings.length?"s":""}: ${t.templateStrings.join(" or ")}`}}).join(" or ").replace("INTRO",`Property "${t.templateStrings[0]}"`).replaceAll("INTRO ",""),Vj=t=>{switch(t){case 16:case 0:return"Node";case 15:return"Ignored reason";case 18:return"Conflicting properties";case 8:return"Additional value";case 21:return"Disabled by";case 29:return"Mapping range";case 30:return"Map entry";case 31:return"Nexus map entries";case 33:return"Names property";case 35:return"Range property";default:return"TODO"}},rn=(t,e)=>{let r=Math.max(t.length,e.length);for(let n=0;n<r;n++){let i=t[t.length-r+n]??0,s=e[e.length-r+n]??0;if(i<s)return-1;if(i>s)return 1}return 0},Xi=(t,e)=>{let r=Math.max(t.length,e.length),n=new Array(r).fill(0),i=0;for(let s=0;s<r;s++){let o=t[t.length-1-s]??0,a=e[e.length-1-s]??0,c=o+a+i;n[r-1-s]=c>>>0,i=c>4294967295?1:0}return i&&n.unshift(1),n},zj=(t,e)=>{let r=Math.max(t.length,e.length),n=new Array(r).fill(0),i=0;for(let s=0;s<r;s++){let o=t[t.length-1-s]??0,a=e[e.length-1-s]??0;o-=i,o<a?(o+=4294967296,i=1):i=0,n[r-1-s]=o-a>>>0}for(;n.length>1&&n[0]===0;)n.shift();return n},Wj=(t,e)=>Xi(t,e),mw=(t,e)=>{let r=[];for(let n of t){let i=n.childAddress,s=n.length,o=Xi(i,s);if(rn(e,i)>=0&&rn(e,o)<0){let a=zj(e,i),c=n.parentAddress,l=Wj(c,a),u=Xi(c,s);r.push({start:l,end:u,range:Vr(n.rangeTokens.start,n.rangeTokens.end),uri:n.rangeTokens.start.uri})}}return r};function gw(t){return Array.isArray(t)&&Array.isArray(t[0])}function yc(t){return!t||t instanceof Ti?t:yc(t.parentNode)}function My(t,e){let r=t.getText(),n=e.slice().sort((s,o)=>{let a=t.offsetAt(s.range.start),c=t.offsetAt(o.range.start);if(a!==c)return c-a;let l=t.offsetAt(s.range.end),u=t.offsetAt(o.range.end);if(l!==u)return u-l;let d=a===l&&s.newText.length>0,f=c===u&&o.newText.length>0;return d!==f?d?1:-1:0}),i=r;for(let s of n){let o=t.offsetAt(s.range.start),a=t.offsetAt(s.range.end);i=i.slice(0,o)+s.newText+i.slice(a)}return i}function ow(t,e){return t.line<e.line?-1:t.line>e.line?1:t.character<e.character?-1:t.character>e.character?1:0}function yw(t,e){return ow(t.end,e.start)>0&&ow(t.start,e.end)<0}var vw=(t,e)=>{let r=Tw(t,e),n=bw(t,e);r&&(t.topComment=r.comment),n&&(t.endComment=n.comment)},Tw=(t,e)=>{let r=e.find(i=>i.lastToken===t.firstToken.prevToken&&(i.lastToken.pos.line===t.firstToken.pos.line||i.lastToken.pos.line+1===t.firstToken.pos.line));if(!r||r.astBeforeComment)return;r.astAfterComment=t;let n=Tw(r,e);return n&&(n.comment.astAfterComment=t,r.astAfterComment=void 0),{comment:n?.comment??r,commentIsBefore:!0}},bw=(t,e)=>{let r=e.find(i=>i.firstToken.prevToken===t.lastToken&&i.firstToken.pos.line===t.lastToken.pos.line);if(!r)return;r.astBeforeComment=t;let n=bw(r,e);return n&&(n.comment.astBeforeComment=t,r.astBeforeComment=void 0),{comment:n?.comment??r,commentIsBefore:!1}},Ho=(t,e,r)=>{let n=[42,44,45,36];return r||n.push(52,32,8,49),t.severity===Ki.DiagnosticSeverity.Error&&de(t.uri,e)&&!n.some(i=>t.issues.includes(i))};var Oc=require("fs"),xC=require("path");var Cn=L(j());var Pw=L(j());var _w=L(j());var ie=class extends Z{constructor(r,n){super(n);this.value=r;this.semanticTokenType="string",this.semanticTokenModifiers="declaration",this.docSymbolsMeta={name:this.value,kind:_w.SymbolKind.String}}toString(){return`"${this.value.toString()}"`}toJson(){return this.value}serialize(){return{type:"STRING",value:this.value,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var Nw=L(j());var Sw=L(j());var Zt=class extends we{constructor(r,n){super(n);this.value=r;this.docSymbolsMeta={name:this.value.toString(),kind:Sw.SymbolKind.Number},this.semanticTokenType="number",this.semanticTokenModifiers="declaration"}toString(r){return this.value.toString(r)}toJson(){return this.value}toPrettyString(r){let n=this.evaluate(r);return`${n.toString()} /* ${typeof n=="number"?`0x${n.toString(16)}`:""} */`}serialize(){return{type:"NUMBER_VALUE",value:this.toString(),evaluated:this.value,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var $t=class extends Z{constructor(r){super();this.values=r;this.docSymbolsMeta={name:"Cell Array",kind:Nw.SymbolKind.Array},this.values.forEach(n=>this.addChild(n))}toString(){return`<${this.values.map(r=>r.toString()).join(" ")}>`}toPrettyString(r){return`<${this.values.map(n=>n.toPrettyString(r)).join(" ")}>`}toJson(){if(this.values.length===1)return this.values[0].value?.toJson();if(this.values.length===2&&this.values.every(r=>r.value instanceof Zt)){let r=new ArrayBuffer(8),n=new DataView(r);return this.values.map(i=>i.value.value).forEach((i,s)=>{n.setUint32(s*4,i)}),n.getBigUint64(0)}return this.values.map(r=>r.value?.toJson()??NaN)}serialize(r){return{type:"ARRAY_VALUE",value:this.values.map(n=>n.value?.serialize(r)??null),uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var Rw=L(j());var _i=class extends Z{constructor(r){super();this.values=r;this.docSymbolsMeta={name:"Byte String Value",kind:Rw.SymbolKind.Array},this.values.forEach(n=>this.addChild(n))}toString(){return`[${this.values.map(r=>r.toString(16).padStart(2,"0")).join(" ")}]`}toJson(){return this.values.map(r=>r.value?.toJson()??NaN)}serialize(){return{type:"BYTESTRING",values:this.values.map(r=>r.value?{value:r.value.toString(16),range:r.value.range,evaluated:r.value.value}:null),uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var Qe=class extends Z{constructor(r,n){super(n);this.name=r;this.semanticTokenType="property",this.semanticTokenModifiers="declaration"}toString(){return this.name}serialize(){return{value:this.name,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}},Ye=class extends Z{constructor(r,n=[]){super();this.propertyName=r;this.labels=n;this._values=void 0;this.docSymbolsMeta={name:this.propertyName?.name??"Unknown",kind:Pw.SymbolKind.Property},this.labels.forEach(i=>this.addChild(i)),this.addChild(r)}set values(r){if(this._values)throw new Error("Only one property name is allowed");this._values=r,this.addChild(r)}get values(){return this._values}get quickValues(){return this.values?.values.map(r=>r?r.value instanceof ie?r.value.value:r.value instanceof $t?r.value.values.map(n=>n.value instanceof Zt?n.value.value:NaN):r.value instanceof _i?r.value.values.map(n=>n.value?.value??NaN):NaN:null)}getFlatAstValues(){return this.values?.values.flatMap(r=>r?r.value instanceof ie?r.value:r.value instanceof $t?r.value.values.map(n=>n.value):r.value instanceof _i?r.value.values.map(n=>n.value):r.value:null)}toString(){return`${this.propertyName?.toString()??"__UNSET__"}${this.assignOperatorToken?` = ${this._values?.values.map(r=>r?.toString()??"NULL").join(", ")??"NULL"}`:""};`}toPrettyString(r){return`${this.propertyName?.toString()??"__UNSET__"}${this.assignOperatorToken?` = ${this._values?.values.map(n=>n?.toPrettyString(r)??"NULL").join(", ")??"NULL"}`:""};`}serialize(r){return{name:this.propertyName?.serialize()??null,values:this.values?.values.map(n=>n?.value?.serialize(r)??null)??null,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var kw=L(j());var vr=class extends Z{constructor(r,n){super();this.keyword=n;this.addChild(n),this.docSymbolsMeta={name:r,kind:kw.SymbolKind.Function}}};var Dr=class extends vr{constructor(r){super("Delete Node",r);this._nodeNameOrRef=null}set nodeNameOrRef(r){if(this._nodeNameOrRef)throw new Error("Only one property name is allowed");this._nodeNameOrRef=r,this.addChild(r)}get nodeNameOrRef(){return this._nodeNameOrRef}};var pt=class extends vr{constructor(r){super("Delete Property",r);this._propertyName=null}set propertyName(r){if(this._propertyName)throw new Error("Only only property name is allowed");this._propertyName=r,this.addChild(r)}get propertyName(){return this._propertyName}};var ww=L(j());var se=class extends Z{constructor(r){super();this.label=r;this.docSymbolsMeta={name:`&${this.label?.value??"NULL"}`,kind:ww.SymbolKind.Key},this.addChild(r)}get value(){return this.label?.value}toString(){return`&${this.label?.value??"NULL"}`}toJson(){return-1}serialize(){return{type:"LABEL_REF",label:this.label?.toString()??null,nodePath:this.linksTo?.pathString??null,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var ct=class t extends Z{constructor(){super()}get path(){if(!this.pathName)return["__UNDEFINED__"];if(!this.parentNode||this instanceof St)return[this.pathName];if(!(this.parentNode instanceof t))return;let e=this.parentNode.path;return e?[...e,this.pathName]:[this.pathName]}get pathName(){}get nodes(){return this.children.filter(e=>e instanceof t)}get deleteNodes(){return this.children.filter(e=>e instanceof Dr)}addNodeChild(e){this.addChild(e)}},St=class extends ct{constructor(){super(),this.docSymbolsMeta={name:"/",kind:Cn.SymbolKind.Class}}get properties(){return this.children.filter(e=>e instanceof Ye)}get name(){return new He("/",W(this.firstToken))}get deleteProperties(){return this.children.filter(e=>e instanceof pt)}get nodes(){return this.children.filter(e=>e instanceof Ue)}get pathName(){return"/"}serialize(e){return{type:"ROOT",properties:this.properties.map(r=>r.serialize(e)),nodes:this.nodes.map(r=>r.serialize(e)),uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}},Wt=class extends ct{constructor(r=[]){super();this.labels=r;this._reference=null;this.docSymbolsMeta={name:"DTC Name",kind:Cn.SymbolKind.Class},r.forEach(n=>{super.addChild(n)})}get serializeIssues(){return[...this.issues,...this.reference?.issues??[]].map(r=>r())}set reference(r){if(this._reference)throw new Error("Only on label reference is allowed");this._reference=r;let n;r instanceof se?n=r.value:n=r?.path?.pathParts.at(-1)?.name??"DTC Name",this.docSymbolsMeta={name:n??"DTC Name",kind:Cn.SymbolKind.Class},this.addChild(r)}get path(){return this.resolveNodePath?this.resolveNodePath:super.path}get reference(){return this._reference}get nodes(){return this.children.filter(r=>r instanceof Ue)}get pathName(){if(this.reference instanceof se&&this.reference.label?.value)return`&${this.reference.label.value}`}get properties(){return this.children.filter(r=>r instanceof Ye)}get deleteProperties(){return this.children.filter(r=>r instanceof pt)}serialize(r){return{type:"REF",name:this.reference?.serialize()??null,properties:this.properties.map(n=>n.serialize(r)),nodes:this.nodes.map(n=>n.serialize(r)),uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}},Ue=class t extends ct{constructor(r=[],n){super();this.labels=r;this.omitIfNoRef=n;this._name=null;this.docSymbolsMeta={name:"DTC Name",kind:Cn.SymbolKind.Class},n&&this.addChild(n),r.forEach(i=>{this.addChild(i)})}get serializeIssues(){return[...this.issues,...this.name?.issues??[]].map(r=>r())}set name(r){if(this._name)throw new Error("Only on label reference is allowed");this._name=r,this.docSymbolsMeta={name:this._name?.toString()??"DTC Name",kind:Cn.SymbolKind.Class},this.addChild(r)}get name(){return this._name}get nodes(){return this.children.filter(r=>r instanceof t)}get pathName(){return this._name?.toString()}get properties(){return this.children.filter(r=>r instanceof Ye)}get deleteProperties(){return this.children.filter(r=>r instanceof pt)}serialize(r){return{type:"CHILD",name:this.name?.serialize()??null,properties:this.properties.map(n=>n.serialize(r)),nodes:this.nodes.map(n=>n.serialize(r)),uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}},vc=class extends Z{constructor(r,n){super(n);this.address=r;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.address?.map((r,n)=>r.toString(16).padStart(n?8:0,"0")).join("")??"NaN"}serialize(){return{address:this.address,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}},He=class extends Z{constructor(r,n,i){super(n);this.name=r;this._address=i;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}get value(){return this.name}get address(){return this._address}set address(r){if(this._address)throw new Error("Address can only be set once");r&&(this.lastToken=void 0,this._address=r,r.forEach(n=>this.addChild(n)))}get fullAddress(){return this._address?[...this._address.flatMap(r=>r.address)]:void 0}toString(){return this._address!==void 0?`${this.name}@${this._address.map(r=>r.toString()).join(",")}`:this.name}buildSemanticTokens(r){if(!this.tokenIndexes?.start||!this.tokenIndexes.start.value)return;let n={...this.tokenIndexes.start,pos:{...this.tokenIndexes.start.pos,len:this.name.length}};r(yi("type"),vi("declaration"),{start:n,end:n}),this.address!==void 0&&this.address.forEach(i=>{r(yi("decorator"),vi("declaration"),{start:i.firstToken,end:i.lastToken}),i.buildSemanticTokens(r)})}get serializeIssues(){return[...this.issues,...this._address?.flatMap(r=>r.issues)??[]].map(r=>r())}serialize(){return{fullName:this.toString(),name:{name:this.name,uri:this.serializeUri,range:Cn.Range.create(Cn.Position.create(this.tokenIndexes.start.pos.line,this.tokenIndexes.start.pos.col),Cn.Position.create(this.tokenIndexes.start.pos.line,this.tokenIndexes.start.pos.colEnd)),issues:this.serializeIssues},address:this.address?.map(r=>r.serialize())??null,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var ln=L(j());var Tr=class extends Z{constructor(r,n,i,s){super();this.startLabels=r;this.value=n;this.endLabels=i;this.bits=s;this.startLabels.forEach(o=>{this.addChild(o)}),this.addChild(s),this.addChild(n),this.endLabels.forEach(o=>{this.addChild(o)})}toString(){return`${[this.value?.toString()??"NULL",...this.endLabels.map(r=>r.toString())].join(" ")}`}toPrettyString(r){return`${[this.value?.toPrettyString(r)??"NULL",...this.endLabels.map(n=>n.toString())].join(" ")}`}toJson(){return this.value?.toJson()}};var Ut=t=>t instanceof vr?!0:t instanceof ct?!1:t.parentNode?Ut(t.parentNode):!1;var xy=t=>{if(t instanceof Ye)return t;if(!(t instanceof ct))return t.parentNode?xy(t.parentNode):void 0},js=t=>!t||t instanceof Ye?!1:t instanceof Tr||js(t.parentNode),Vo=t=>[...t.map(e=>{if(e instanceof Ue||e instanceof St)return e.name;if(e instanceof Wt)return e.reference})].filter(e=>!!e),qy=(t,e)=>e?e.parentNode===t||qy(t,e.parentNode):!1;var wt=L(j());var Ew=L(j());var Dn=class extends Z{constructor(){super();this._pathParts=[]}addPath(r,n){this._pathParts.push(r),n&&this.addChild(n),this.addChild(r)}get pathParts(){return[...this._pathParts]}toString(){return this._pathParts.map(r=>r?.toString()??"<NULL>").join("/")}buildSemanticTokens(r){this._children.forEach(n=>{n instanceof He?n.buildSemanticTokens(r):r(yi("operator"),vi("declaration"),n.tokenIndexes)})}},nt=class extends Z{constructor(r){super();this.path=r;this.docSymbolsMeta={name:`/${this.path?.toString()??""}`,kind:Ew.SymbolKind.Namespace},this.addChild(r)}toString(){return`&${this.path?.toString()??"NULL"}`}toJson(){return-1}serialize(){return{type:"NODE_PATH",nodePath:this.path?.toString()??null,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var te=L(j());var Cw=require("path"),cf=L(j());var Si=class extends Z{constructor(r,n){super();this.keyword=r;this.path=n;this.docSymbolsMeta={name:`Include ${n}`,kind:cf.SymbolKind.File},this.addChild(r),this.addChild(n)}get resolvedPath(){return this._resolvedPath}set resolvedPath(r){this.docSymbolsMeta={name:`Include ${r}`,kind:cf.SymbolKind.File},this._resolvedPath=r}},zo=class extends Z{constructor(r,n,i){super(i);this._path=r;this.relative=n;this.docSymbolsMeta={name:(0,Cw.basename)(this.path),kind:cf.SymbolKind.File},this.semanticTokenType="string",this.semanticTokenModifiers="declaration"}get path(){return this.relative?this._path.slice(1,-1):this._path}};var on=class extends Z{constructor(r){super();this.comments=r;r.forEach(this.addChild.bind(this))}toString(){return this.comments.map(r=>r.toString()).join(`
182
+ deps: ${r}}`};var YX={keyword:"dependencies",type:"object",schemaType:"object",error:ui.error,code(t){let[e,r]=KX(t);kL(t,e),wL(t,r)}};function KX({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let i=Array.isArray(t[n])?e:r;i[n]=t[n]}return[e,r]}function kL(t,e=t.schema){let{gen:r,data:n,it:i}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let o in e){let a=e[o];if(a.length===0)continue;let c=(0,fu.propertyInData)(r,n,o,i.opts.ownProperties);t.setParams({property:o,depsCount:a.length,deps:a.join(", ")}),i.allErrors?r.if(c,()=>{for(let l of a)(0,fu.checkReportMissingProp)(t,l)}):(r.if((0,E_._)`${c} && (${(0,fu.checkMissingProp)(t,a,s)})`),(0,fu.reportMissingProp)(t,s),r.else())}}ui.validatePropertyDeps=kL;function wL(t,e=t.schema){let{gen:r,data:n,keyword:i,it:s}=t,o=r.name("valid");for(let a in e)(0,GX.alwaysValidSchema)(s,e[a])||(r.if((0,fu.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:i,schemaProp:a},o);t.mergeValidEvaluated(c,o)},()=>r.var(o,!0)),t.ok(o))}ui.validateSchemaDeps=wL;ui.default=YX});var CL=R(C_=>{"use strict";Object.defineProperty(C_,"__esModule",{value:!0});var EL=Te(),XX=ke(),JX={message:"property name must be valid",params:({params:t})=>(0,EL._)`{propertyName: ${t.propertyName}}`},QX={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:JX,code(t){let{gen:e,schema:r,data:n,it:i}=t;if((0,XX.alwaysValidSchema)(i,r))return;let s=e.name("valid");e.forIn("key",n,o=>{t.setParams({propertyName:o}),t.subschema({keyword:"propertyNames",data:o,dataTypes:["string"],propertyName:o,compositeRule:!0},s),e.if((0,EL.not)(s),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(s)}};C_.default=QX});var A_=R(D_=>{"use strict";Object.defineProperty(D_,"__esModule",{value:!0});var hm=gn(),jn=Te(),ZX=mn(),mm=ke(),e4={message:"must NOT have additional properties",params:({params:t})=>(0,jn._)`{additionalProperty: ${t.additionalProperty}}`},t4={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:e4,code(t){let{gen:e,schema:r,parentSchema:n,data:i,errsCount:s,it:o}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=o;if(o.props=!0,c.removeAdditional!=="all"&&(0,mm.alwaysValidSchema)(o,r))return;let l=(0,hm.allSchemaProperties)(n.properties),u=(0,hm.allSchemaProperties)(n.patternProperties);d(),t.ok((0,jn._)`${s} === ${ZX.default.errors}`);function d(){e.forIn("key",i,v=>{!l.length&&!u.length?g(v):e.if(f(v),()=>g(v))})}function f(v){let S;if(l.length>8){let _=(0,mm.schemaRefOrVal)(o,n.properties,"properties");S=(0,hm.isOwnProperty)(e,_,v)}else l.length?S=(0,jn.or)(...l.map(_=>(0,jn._)`${v} === ${_}`)):S=jn.nil;return u.length&&(S=(0,jn.or)(S,...u.map(_=>(0,jn._)`${(0,hm.usePattern)(t,_)}.test(${v})`))),(0,jn.not)(S)}function p(v){e.code((0,jn._)`delete ${i}[${v}]`)}function g(v){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(v);return}if(r===!1){t.setParams({additionalProperty:v}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,mm.alwaysValidSchema)(o,r)){let S=e.name("valid");c.removeAdditional==="failing"?(h(v,S,!1),e.if((0,jn.not)(S),()=>{t.reset(),p(v)})):(h(v,S),a||e.if((0,jn.not)(S),()=>e.break()))}}function h(v,S,_){let T={keyword:"additionalProperties",dataProp:v,dataPropType:mm.Type.Str};_===!1&&Object.assign(T,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(T,S)}}};D_.default=t4});var IL=R(O_=>{"use strict";Object.defineProperty(O_,"__esModule",{value:!0});var r4=Jl(),DL=gn(),I_=ke(),AL=A_(),n4={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:i,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&AL.default.code(new r4.KeywordCxt(s,AL.default,"additionalProperties"));let o=(0,DL.allSchemaProperties)(r);for(let d of o)s.definedProperties.add(d);s.opts.unevaluated&&o.length&&s.props!==!0&&(s.props=I_.mergeEvaluated.props(e,(0,I_.toHash)(o),s.props));let a=o.filter(d=>!(0,I_.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,DL.propertyInData)(e,i,d,s.opts.ownProperties)),u(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function l(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function u(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};O_.default=n4});var qL=R(M_=>{"use strict";Object.defineProperty(M_,"__esModule",{value:!0});var OL=gn(),gm=Te(),ML=ke(),xL=ke(),i4={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:i,it:s}=t,{opts:o}=s,a=(0,OL.allSchemaProperties)(r),c=a.filter(h=>(0,ML.alwaysValidSchema)(s,r[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let l=o.strictSchema&&!o.allowMatchingProperties&&i.properties,u=e.name("valid");s.props!==!0&&!(s.props instanceof gm.Name)&&(s.props=(0,xL.evaluatedPropsToName)(e,s.props));let{props:d}=s;f();function f(){for(let h of a)l&&p(h),s.allErrors?g(h):(e.var(u,!0),g(h),e.if(u))}function p(h){for(let v in l)new RegExp(h).test(v)&&(0,ML.checkStrictMode)(s,`property ${v} matches pattern ${h} (use allowMatchingProperties)`)}function g(h){e.forIn("key",n,v=>{e.if((0,gm._)`${(0,OL.usePattern)(t,h)}.test(${v})`,()=>{let S=c.includes(h);S||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:v,dataPropType:xL.Type.Str},u),s.opts.unevaluated&&d!==!0?e.assign((0,gm._)`${d}[${v}]`,!0):!S&&!s.allErrors&&e.if((0,gm.not)(u),()=>e.break())})})}}};M_.default=i4});var LL=R(x_=>{"use strict";Object.defineProperty(x_,"__esModule",{value:!0});var s4=ke(),o4={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,s4.alwaysValidSchema)(n,r)){t.fail();return}let i=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),t.failResult(i,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};x_.default=o4});var $L=R(q_=>{"use strict";Object.defineProperty(q_,"__esModule",{value:!0});var a4=gn(),c4={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:a4.validateUnion,error:{message:"must match a schema in anyOf"}};q_.default=c4});var BL=R(L_=>{"use strict";Object.defineProperty(L_,"__esModule",{value:!0});var ym=Te(),l4=ke(),u4={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,ym._)`{passingSchemas: ${t.passing}}`},d4={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:u4,code(t){let{gen:e,schema:r,parentSchema:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;let s=r,o=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(l),t.result(o,()=>t.reset(),()=>t.error(!0));function l(){s.forEach((u,d)=>{let f;(0,l4.alwaysValidSchema)(i,u)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,ym._)`${c} && ${o}`).assign(o,!1).assign(a,(0,ym._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(o,!0),e.assign(a,d),f&&t.mergeEvaluated(f,ym.Name)})})}}};L_.default=d4});var FL=R($_=>{"use strict";Object.defineProperty($_,"__esModule",{value:!0});var f4=ke(),p4={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let i=e.name("valid");r.forEach((s,o)=>{if((0,f4.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:o},i);t.ok(i),t.mergeEvaluated(a)})}};$_.default=p4});var HL=R(B_=>{"use strict";Object.defineProperty(B_,"__esModule",{value:!0});var vm=Te(),UL=ke(),h4={message:({params:t})=>(0,vm.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,vm._)`{failingKeyword: ${t.ifClause}}`},m4={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:h4,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,UL.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let i=jL(n,"then"),s=jL(n,"else");if(!i&&!s)return;let o=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),i&&s){let u=e.let("ifClause");t.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else i?e.if(a,l("then")):e.if((0,vm.not)(a),l("else"));t.pass(o,()=>t.error(!0));function c(){let u=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(u)}function l(u,d){return()=>{let f=t.subschema({keyword:u},a);e.assign(o,a),t.mergeValidEvaluated(f,o),d?e.assign(d,(0,vm._)`${u}`):t.setParams({ifClause:u})}}}};function jL(t,e){let r=t.schema[e];return r!==void 0&&!(0,UL.alwaysValidSchema)(t,r)}B_.default=m4});var VL=R(F_=>{"use strict";Object.defineProperty(F_,"__esModule",{value:!0});var g4=ke(),y4={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,g4.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};F_.default=y4});var zL=R(j_=>{"use strict";Object.defineProperty(j_,"__esModule",{value:!0});var v4=N_(),T4=SL(),b4=R_(),_4=RL(),S4=PL(),N4=pm(),R4=CL(),P4=A_(),k4=IL(),w4=qL(),E4=LL(),C4=$L(),D4=BL(),A4=FL(),I4=HL(),O4=VL();function M4(t=!1){let e=[E4.default,C4.default,D4.default,A4.default,I4.default,O4.default,R4.default,P4.default,N4.default,k4.default,w4.default];return t?e.push(T4.default,_4.default):e.push(v4.default,b4.default),e.push(S4.default),e}j_.default=M4});var WL=R(U_=>{"use strict";Object.defineProperty(U_,"__esModule",{value:!0});var Ot=Te(),x4={message:({schemaCode:t})=>(0,Ot.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Ot._)`{format: ${t}}`},q4={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:x4,code(t,e){let{gen:r,data:n,$data:i,schema:s,schemaCode:o,it:a}=t,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;i?f():p();function f(){let g=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,Ot._)`${g}[${o}]`),v=r.let("fType"),S=r.let("format");r.if((0,Ot._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(v,(0,Ot._)`${h}.type || "string"`).assign(S,(0,Ot._)`${h}.validate`),()=>r.assign(v,(0,Ot._)`"string"`).assign(S,h)),t.fail$data((0,Ot.or)(_(),T()));function _(){return c.strictSchema===!1?Ot.nil:(0,Ot._)`${o} && !${S}`}function T(){let P=u.$async?(0,Ot._)`(${h}.async ? await ${S}(${n}) : ${S}(${n}))`:(0,Ot._)`${S}(${n})`,C=(0,Ot._)`(typeof ${S} == "function" ? ${P} : ${S}.test(${n}))`;return(0,Ot._)`${S} && ${S} !== true && ${v} === ${e} && !${C}`}}function p(){let g=d.formats[s];if(!g){_();return}if(g===!0)return;let[h,v,S]=T(g);h===e&&t.pass(P());function _(){if(c.strictSchema===!1){d.logger.warn(C());return}throw new Error(C());function C(){return`unknown format "${s}" ignored in schema at path "${l}"`}}function T(C){let $=C instanceof RegExp?(0,Ot.regexpCode)(C):c.code.formats?(0,Ot._)`${c.code.formats}${(0,Ot.getProperty)(s)}`:void 0,F=r.scopeValue("formats",{key:s,ref:C,code:$});return typeof C=="object"&&!(C instanceof RegExp)?[C.type||"string",C.validate,(0,Ot._)`${F}.validate`]:["string",C,F]}function P(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!u.$async)throw new Error("async format in sync schema");return(0,Ot._)`await ${S}(${n})`}return typeof v=="function"?(0,Ot._)`${S}(${n})`:(0,Ot._)`${S}.test(${n})`}}}};U_.default=q4});var GL=R(H_=>{"use strict";Object.defineProperty(H_,"__esModule",{value:!0});var L4=WL(),$4=[L4.default];H_.default=$4});var YL=R(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.contentVocabulary=Ba.metadataVocabulary=void 0;Ba.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ba.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var XL=R(V_=>{"use strict";Object.defineProperty(V_,"__esModule",{value:!0});var B4=iL(),F4=vL(),j4=zL(),U4=GL(),KL=YL(),H4=[B4.default,F4.default,(0,j4.default)(),U4.default,KL.metadataVocabulary,KL.contentVocabulary];V_.default=H4});var W_=R(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});pu.dynamicAnchor=void 0;var z_=Te(),V4=mn(),JL=Zl(),z4=om(),W4={keyword:"$dynamicAnchor",schemaType:"string",code:t=>QL(t,t.schema)};function QL(t,e){let{gen:r,it:n}=t;n.schemaEnv.root.dynamicAnchors[e]=!0;let i=(0,z_._)`${V4.default.dynamicAnchors}${(0,z_.getProperty)(e)}`,s=n.errSchemaPath==="#"?n.validateName:G4(t);r.if((0,z_._)`!${i}`,()=>r.assign(i,s))}pu.dynamicAnchor=QL;function G4(t){let{schemaEnv:e,schema:r,self:n}=t.it,{root:i,baseId:s,localRefs:o,meta:a}=e.root,{schemaId:c}=n.opts,l=new JL.SchemaEnv({schema:r,schemaId:c,root:i,baseId:s,localRefs:o,meta:a});return JL.compileSchema.call(n,l),(0,z4.getValidate)(t,l)}pu.default=W4});var G_=R(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});hu.dynamicRef=void 0;var ZL=Te(),Y4=mn(),e$=om(),K4={keyword:"$dynamicRef",schemaType:"string",code:t=>t$(t,t.schema)};function t$(t,e){let{gen:r,keyword:n,it:i}=t;if(e[0]!=="#")throw new Error(`"${n}" only supports hash fragment reference`);let s=e.slice(1);if(i.allErrors)o();else{let c=r.let("valid",!1);o(c),t.ok(c)}function o(c){if(i.schemaEnv.root.dynamicAnchors[s]){let l=r.let("_v",(0,ZL._)`${Y4.default.dynamicAnchors}${(0,ZL.getProperty)(s)}`);r.if(l,a(l,c),a(i.validateName,c))}else a(i.validateName,c)()}function a(c,l){return l?()=>r.block(()=>{(0,e$.callRef)(t,c),r.let(l,!0)}):()=>(0,e$.callRef)(t,c)}}hu.dynamicRef=t$;hu.default=K4});var r$=R(Y_=>{"use strict";Object.defineProperty(Y_,"__esModule",{value:!0});var X4=W_(),J4=ke(),Q4={keyword:"$recursiveAnchor",schemaType:"boolean",code(t){t.schema?(0,X4.dynamicAnchor)(t,""):(0,J4.checkStrictMode)(t.it,"$recursiveAnchor: false is ignored")}};Y_.default=Q4});var n$=R(K_=>{"use strict";Object.defineProperty(K_,"__esModule",{value:!0});var Z4=G_(),e9={keyword:"$recursiveRef",schemaType:"string",code:t=>(0,Z4.dynamicRef)(t,t.schema)};K_.default=e9});var i$=R(X_=>{"use strict";Object.defineProperty(X_,"__esModule",{value:!0});var t9=W_(),r9=G_(),n9=r$(),i9=n$(),s9=[t9.default,r9.default,n9.default,i9.default];X_.default=s9});var o$=R(J_=>{"use strict";Object.defineProperty(J_,"__esModule",{value:!0});var s$=pm(),o9={keyword:"dependentRequired",type:"object",schemaType:"object",error:s$.error,code:t=>(0,s$.validatePropertyDeps)(t)};J_.default=o9});var a$=R(Q_=>{"use strict";Object.defineProperty(Q_,"__esModule",{value:!0});var a9=pm(),c9={keyword:"dependentSchemas",type:"object",schemaType:"object",code:t=>(0,a9.validateSchemaDeps)(t)};Q_.default=c9});var c$=R(Z_=>{"use strict";Object.defineProperty(Z_,"__esModule",{value:!0});var l9=ke(),u9={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:t,parentSchema:e,it:r}){e.contains===void 0&&(0,l9.checkStrictMode)(r,`"${t}" without "contains" is ignored`)}};Z_.default=u9});var l$=R(eS=>{"use strict";Object.defineProperty(eS,"__esModule",{value:!0});var d9=o$(),f9=a$(),p9=c$(),h9=[d9.default,f9.default,p9.default];eS.default=h9});var d$=R(tS=>{"use strict";Object.defineProperty(tS,"__esModule",{value:!0});var ws=Te(),u$=ke(),m9=mn(),g9={message:"must NOT have unevaluated properties",params:({params:t})=>(0,ws._)`{unevaluatedProperty: ${t.unevaluatedProperty}}`},y9={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:g9,code(t){let{gen:e,schema:r,data:n,errsCount:i,it:s}=t;if(!i)throw new Error("ajv implementation error");let{allErrors:o,props:a}=s;a instanceof ws.Name?e.if((0,ws._)`${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))),s.props=!0,t.ok((0,ws._)`${i} === ${m9.default.errors}`);function c(d){if(r===!1){t.setParams({unevaluatedProperty:d}),t.error(),o||e.break();return}if(!(0,u$.alwaysValidSchema)(s,r)){let f=e.name("valid");t.subschema({keyword:"unevaluatedProperties",dataProp:d,dataPropType:u$.Type.Str},f),o||e.if((0,ws.not)(f),()=>e.break())}}function l(d,f){return(0,ws._)`!${d} || !${d}[${f}]`}function u(d,f){let p=[];for(let g in d)d[g]===!0&&p.push((0,ws._)`${f} !== ${g}`);return(0,ws.and)(...p)}}};tS.default=y9});var p$=R(rS=>{"use strict";Object.defineProperty(rS,"__esModule",{value:!0});var uo=Te(),f$=ke(),v9={message:({params:{len:t}})=>(0,uo.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,uo._)`{limit: ${t}}`},T9={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:v9,code(t){let{gen:e,schema:r,data:n,it:i}=t,s=i.items||0;if(s===!0)return;let o=e.const("len",(0,uo._)`${n}.length`);if(r===!1)t.setParams({len:s}),t.fail((0,uo._)`${o} > ${s}`);else if(typeof r=="object"&&!(0,f$.alwaysValidSchema)(i,r)){let c=e.var("valid",(0,uo._)`${o} <= ${s}`);e.if((0,uo.not)(c),()=>a(c,s)),t.ok(c)}i.items=!0;function a(c,l){e.forRange("i",l,o,u=>{t.subschema({keyword:"unevaluatedItems",dataProp:u,dataPropType:f$.Type.Num},c),i.allErrors||e.if((0,uo.not)(c),()=>e.break())})}}};rS.default=T9});var h$=R(nS=>{"use strict";Object.defineProperty(nS,"__esModule",{value:!0});var b9=d$(),_9=p$(),S9=[b9.default,_9.default];nS.default=S9});var g$=R(Tm=>{"use strict";Object.defineProperty(Tm,"__esModule",{value:!0});Tm.DiscrError=void 0;var m$;(function(t){t.Tag="tag",t.Mapping="mapping"})(m$||(Tm.DiscrError=m$={}))});var v$=R(sS=>{"use strict";Object.defineProperty(sS,"__esModule",{value:!0});var Fa=Te(),iS=g$(),y$=Zl(),N9=Ql(),R9=ke(),P9={message:({params:{discrError:t,tagName:e}})=>t===iS.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Fa._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},k9={keyword:"discriminator",type:"object",schemaType:"object",error:P9,code(t){let{gen:e,data:r,schema:n,parentSchema:i,it:s}=t,{oneOf:o}=i;if(!s.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,Fa._)`${r}${(0,Fa.getProperty)(a)}`);e.if((0,Fa._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:iS.DiscrError.Tag,tag:l,tagName:a})),t.ok(c);function u(){let p=f();e.if(!1);for(let g in p)e.elseIf((0,Fa._)`${l} === ${g}`),e.assign(c,d(p[g]));e.else(),t.error(!1,{discrError:iS.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(p){let g=e.name("valid"),h=t.subschema({keyword:"oneOf",schemaProp:p},g);return t.mergeEvaluated(h,Fa.Name),g}function f(){var p;let g={},h=S(i),v=!0;for(let P=0;P<o.length;P++){let C=o[P];if(C?.$ref&&!(0,R9.schemaHasRulesButRef)(C,s.self.RULES)){let F=C.$ref;if(C=y$.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,F),C instanceof y$.SchemaEnv&&(C=C.schema),C===void 0)throw new N9.default(s.opts.uriResolver,s.baseId,F)}let $=(p=C?.properties)===null||p===void 0?void 0:p[a];if(typeof $!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);v=v&&(h||S(C)),_($,P)}if(!v)throw new Error(`discriminator: "${a}" must be required`);return g;function S({required:P}){return Array.isArray(P)&&P.includes(a)}function _(P,C){if(P.const)T(P.const,C);else if(P.enum)for(let $ of P.enum)T($,C);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function T(P,C){if(typeof P!="string"||P in g)throw new Error(`discriminator: "${a}" values must be unique strings`);g[P]=C}}}};sS.default=k9});var T$=R((cke,w9)=>{w9.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 b$=R((lke,E9)=>{E9.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 _$=R((uke,C9)=>{C9.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 S$=R((dke,D9)=>{D9.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 N$=R((fke,A9)=>{A9.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 R$=R((pke,I9)=>{I9.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 P$=R((hke,O9)=>{O9.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 k$=R(oS=>{"use strict";Object.defineProperty(oS,"__esModule",{value:!0});var M9=T$(),x9=b$(),q9=_$(),L9=S$(),$9=N$(),B9=R$(),F9=P$(),j9=["/properties"];function U9(t){return[M9,x9,q9,L9,e(this,$9),B9,e(this,F9)].forEach(r=>this.addMetaSchema(r,void 0,!1)),this;function e(r,n){return t?r.$dataMetaSchema(n,j9):n}}oS.default=U9});var w$=R((yt,cS)=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.MissingRefError=yt.ValidationError=yt.CodeGen=yt.Name=yt.nil=yt.stringify=yt.str=yt._=yt.KeywordCxt=yt.Ajv2019=void 0;var H9=Z1(),V9=XL(),z9=i$(),W9=l$(),G9=h$(),Y9=v$(),K9=k$(),aS="https://json-schema.org/draft/2019-09/schema",ja=class extends H9.default{constructor(e={}){super({...e,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),this.addVocabulary(z9.default),V9.default.forEach(e=>this.addVocabulary(e)),this.addVocabulary(W9.default),this.addVocabulary(G9.default),this.opts.discriminator&&this.addKeyword(Y9.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:e,meta:r}=this.opts;r&&(K9.default.call(this,e),this.refs["http://json-schema.org/schema"]=aS)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(aS)?aS:void 0)}};yt.Ajv2019=ja;cS.exports=yt=ja;cS.exports.Ajv2019=ja;Object.defineProperty(yt,"__esModule",{value:!0});yt.default=ja;var X9=Jl();Object.defineProperty(yt,"KeywordCxt",{enumerable:!0,get:function(){return X9.KeywordCxt}});var Ua=Te();Object.defineProperty(yt,"_",{enumerable:!0,get:function(){return Ua._}});Object.defineProperty(yt,"str",{enumerable:!0,get:function(){return Ua.str}});Object.defineProperty(yt,"stringify",{enumerable:!0,get:function(){return Ua.stringify}});Object.defineProperty(yt,"nil",{enumerable:!0,get:function(){return Ua.nil}});Object.defineProperty(yt,"Name",{enumerable:!0,get:function(){return Ua.Name}});Object.defineProperty(yt,"CodeGen",{enumerable:!0,get:function(){return Ua.CodeGen}});var J9=Qh();Object.defineProperty(yt,"ValidationError",{enumerable:!0,get:function(){return J9.default}});var Q9=Ql();Object.defineProperty(yt,"MissingRefError",{enumerable:!0,get:function(){return Q9.default}})});var Ga=require("path"),lt=L(nw());var ef=class t{constructor(e,r,n,i){this._uri=e,this._languageId=r,this._version=n,this._content=i,this._lineOffsets=void 0}get uri(){return this._uri}get languageId(){return this._languageId}get version(){return this._version}getText(e){if(e){let r=this.offsetAt(e.start),n=this.offsetAt(e.end);return this._content.substring(r,n)}return this._content}update(e,r){for(let n of e)if(t.isIncremental(n)){let i=sw(n.range),s=this.offsetAt(i.start),o=this.offsetAt(i.end);this._content=this._content.substring(0,s)+n.text+this._content.substring(o,this._content.length);let a=Math.max(i.start.line,0),c=Math.max(i.end.line,0),l=this._lineOffsets,u=iw(n.text,!1,s);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-s);if(d!==0)for(let f=a+1+u.length,p=l.length;f<p;f++)l[f]=l[f]+d}else if(t.isFull(n))this._content=n.text,this._lineOffsets=void 0;else throw new Error("Unknown change event received");this._version=r}getLineOffsets(){return this._lineOffsets===void 0&&(this._lineOffsets=iw(this._content,!0)),this._lineOffsets}positionAt(e){e=Math.max(Math.min(e,this._content.length),0);let r=this.getLineOffsets(),n=0,i=r.length;if(i===0)return{line:0,character:e};for(;n<i;){let o=Math.floor((n+i)/2);r[o]>e?i=o:n=o+1}let s=n-1;return{line:s,character:e-r[s]}}offsetAt(e){let r=this.getLineOffsets();if(e.line>=r.length)return this._content.length;if(e.line<0)return 0;let n=r[e.line],i=e.line+1<r.length?r[e.line+1]:this._content.length;return Math.max(Math.min(n+e.character,i),n)}get lineCount(){return this.getLineOffsets().length}static isIncremental(e){let r=e;return r!=null&&typeof r.text=="string"&&r.range!==void 0&&(r.rangeLength===void 0||typeof r.rangeLength=="number")}static isFull(e){let r=e;return r!=null&&typeof r.text=="string"&&r.range===void 0&&r.rangeLength===void 0}},Yi;(function(t){function e(i,s,o,a){return new ef(i,s,o,a)}t.create=e;function r(i,s,o){if(i instanceof ef)return i.update(s,o),i;throw new Error("TextDocument.update: document must be created by TextDocument.create")}t.update=r;function n(i,s){let o=i.getText(),a=Cy(s.map(qj),(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=i.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=i.offsetAt(u.range.end)}return l.push(o.substr(c)),l.join("")}t.applyEdits=n})(Yi||(Yi={}));function Cy(t,e){if(t.length<=1)return t;let r=t.length/2|0,n=t.slice(0,r),i=t.slice(r);Cy(n,e),Cy(i,e);let s=0,o=0,a=0;for(;s<n.length&&o<i.length;)e(n[s],i[o])<=0?t[a++]=n[s++]:t[a++]=i[o++];for(;s<n.length;)t[a++]=n[s++];for(;o<i.length;)t[a++]=i[o++];return t}function iw(t,e,r=0){let n=e?[r]:[];for(let i=0;i<t.length;i++){let s=t.charCodeAt(i);(s===13||s===10)&&(s===13&&i+1<t.length&&t.charCodeAt(i+1)===10&&i++,n.push(r+i+1))}return n}function sw(t){let e=t.start,r=t.end;return e.line>r.line||e.line===r.line&&e.character>r.character?{start:r,end:e}:t}function qj(t){let e=sw(t.range);return e!==t.range?{newText:t.newText,range:e}:t}var tf=["namespace","class","enum","interface","struct","typeParameter","type","parameter","variable","property","enumMember","decorator","event","function","method","macro","label","comment","string","keyword","number","regexp","operator"],rf=["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"];var Ay=L(require("url")),aw=require("crypto"),cw=require("path"),Ki=L(j());var Dy=L(j());var Cr=L(j());var Z=class{constructor(e){this._children=[];this.syntaxIssues=[];this.resetableIssues=[];this._firstToken=e?.start,this._lastToken=e?.end}get issues(){return[...this.syntaxIssues,...this.resetableIssues]}resetIssues(){this.resetableIssues=[],this.children.forEach(e=>e.resetIssues())}get serializeIssues(){return this.issues.map(e=>e())}get firstToken(){return this._firstToken??this._children[0].tokenIndexes.start}set firstToken(e){this._firstToken=e}get rangeTokens(){return{start:this.firstToken,end:this.lastToken}}get lastToken(){return this._lastToken??this._children.at(-1)?.lastToken??this.firstToken}set lastToken(e){this._lastToken=e}get uri(){return this.firstToken.uri}getTopMostAstNodeForFile(e){return de(e,this.uri)?[this]:this.children.flatMap(r=>r.getTopMostAstNodeForFile(e))}get tokenIndexes(){return{start:this.firstToken,end:this.lastToken}}getDocumentSymbols(e){if(!this.docSymbolsMeta)return this.children.flatMap(n=>n.getDocumentSymbols(e)??[]);if(!de(this.uri,e))return[];let r=fe(this);return[{name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind,range:r,selectionRange:r,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(![Cr.SymbolKind.File,Cr.SymbolKind.Class,Cr.SymbolKind.Constant].some(n=>n===e))return[];let r=fe(this);return[{location:Cr.Location.create(ve(this.uri),r),name:this.docSymbolsMeta.name?this.docSymbolsMeta.name:"__UNSET__",kind:this.docSymbolsMeta.kind},...this.children.flatMap(n=>n.getWorkspaceSymbols()??[]).filter(n=>n.kind===Cr.SymbolKind.File||n.kind===Cr.SymbolKind.Class||n.kind===Cr.SymbolKind.Constant)]}buildSemanticTokens(e){this._children.forEach(r=>r.buildSemanticTokens(e)),!(!this.semanticTokenType||!this.semanticTokenModifiers)&&e(yi(this.semanticTokenType),vi(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}isAncestorOf(e){return this.children.some(r=>r===e||r.isAncestorOf(e))}toPrettyString(e){return this.toString()}toString(e){return"TODO"}get range(){return Cr.Range.create(Cr.Position.create(this.firstToken.pos.line,this.firstToken.pos.col),Cr.Position.create(this.lastToken.pos.line,this.lastToken.pos.colEnd))}get serializeUri(){return ve(this.uri)}serialize(e){return{uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var we=class extends Z{toJson(){return-1}resolve(e){return nf(this.toString(),e)}evaluate(e){return Ee(`${this.operator?this.operator.toString():""}${this.resolve(e)}`)}isTrue(e){return Ee(`!!(${this.operator?this.operator.toString():""}${this.resolve(e)})`)}toPrettyString(e){let r=this.evaluate(e);return`${r.toString()} /* ${this.toString()}${typeof r=="number"?` = 0x${r.toString(16)}`:""} */`}serialize(e){return{type:"EXPRESSION",value:this.toString(),evaluated:this.evaluate(e),uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}},Gn=class extends we{constructor(r,n,i){super();this.expression=r;this.wrapped=n;this.addChild(r),i&&(this.addChild(i.operator),this.addChild(i.expression),this.join=[],this.join?.push(i))}get firstToken(){return this.openBracket?this.openBracket:super.firstToken}get lastToken(){return this.closeBracket?this.closeBracket:super.lastToken}addExpression(r,n){this.addChild(r),this.addChild(n),this.join??=[],this.join?.push({operator:r,expression:n})}toString(){let r=this.children.map(n=>n.toString()).join(" ");return this.wrapped?`(${r})`:`${r}`}isTrue(r){let n=`(${this.children.map(i=>i instanceof we?i.resolve(r):i.toString()).join(" ")})`;return Ee(`!!(${this.operator?this.operator.toString():""}${n})`)}};var Yn=class extends we{constructor(r,n,i){super(n);this.value=r;this.docSymbolsMeta={name:`param${i+1}`,kind:Dy.SymbolKind.Variable},this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.value}},Ti=class extends we{constructor(r,n){super();this.functionName=r;this.params=n;this.addChild(r),this.params.forEach(i=>this.addChild(i))}getDocumentSymbols(r){return de(this.uri,r)?[{name:this.functionName.name,kind:Dy.SymbolKind.Function,range:fe(this),selectionRange:fe(this),children:this.params.flatMap(n=>n?.getDocumentSymbols(r)??[])}]:[]}toString(){return`${this.functionName.toString()}(${this.params.map(r=>r?.toString()??"<NULL>").join(",")})`}isTrue(r){if(this.functionName.name==="defined"){let n=!!(this.params.length===1&&this.params[0]&&r.has(this.params[0].value));return this.operator?Ee(`!!(${this.operator}${n})`):n}return super.isTrue(r)}};var Vr=(t,e,r=!0,n=!0)=>({start:{line:t?.pos.line??0,character:r?t?.pos.col??0:(t?.pos.col??0)+(t?.pos.len??0)},end:{line:e?.pos.line??0,character:n?(e?.pos.col??0)+(e?.pos.len??0):e?.pos.col??0}});var fe=t=>Vr(t.tokenIndexes.start,t.tokenIndexes.end),lw=" ",uw=t=>{lw=t},Uo=()=>lw,yi=t=>tf.findIndex(e=>e===t),vi=t=>rf.findIndex(e=>e===t),Iy=(t,e,r)=>!de(t.uri,e)||r.line<t.pos.line?!1:r.line>t.pos.line?!0:r.character>t.pos.colEnd,Lj=(t,e,r)=>de(t.uri,e)?r.line<t.pos.line?!0:r.line>t.pos.line?!1:r.character<t.pos.col:!1,nn=(t,e,r)=>!!(de(t.uri,e)&&t.tokenIndexes?.start&&t.tokenIndexes?.end&&(t.tokenIndexes.start.pos.line<r.line||t.tokenIndexes.start.pos.line===r.line&&t.tokenIndexes.start.pos.col<=r.character)&&(t.tokenIndexes.end.pos.line>r.line||t.tokenIndexes.end.pos.line===r.line&&t.tokenIndexes.end.pos.colEnd>=r.character)),dw=(t,e,r)=>!!(de(t.uri,e)&&t.lastToken.value!==";"&&t.tokenIndexes?.start&&t.tokenIndexes?.end&&(t.tokenIndexes.start.pos.line===r.line||t.tokenIndexes.end.pos.line===r.line)&&r.character>=t.tokenIndexes.end.pos.colEnd),fw=(t,e,r)=>{if(!t)return!1;let i=t.filter(s=>s.pos.line===r.line).at(-1);return i&&i.pos.col>=r.character?!1:e.tokenIndexes?.end===i};var Kn=(t,e,r)=>{let n=t,i=t;for(;i;)n=i,i=[...n.children].reverse().find(s=>nn(s,e,r));return n},mc=(t,e,r)=>{let n=t,i=t;for(;i;)n=i,i=[...n.children].find(s=>Lj(s.lastToken,e,r));return n===t?void 0:n},gc=(t,e,r)=>{let n=t,i=t;for(;i;)n=i,i=[...n.children].reverse().find(s=>Iy(s.firstToken,e,r));return n===t?void 0:n},G=(t,e,r,{severity:n=Ki.DiagnosticSeverity.Error,linkedTo:i=[],tags:s,templateStrings:o=[],edit:a,codeActionTitle:c,inclusiveStart:l,inclusiveEnd:u}={severity:Ki.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let d=Vr(e.start,e.end,l,u),f={issues:Array.isArray(t)?t:[t],range:d,uri:e.start.uri,severity:n,linkedTo:i.map(({range:h,uri:v})=>({range:h,uri:v,templateStrings:[]})),tags:s,templateStrings:o,edit:a,codeActionTitle:c},p,g=()=>(p??={severity:f.severity,range:d,message:f.issues?f.issues.map(Fj).join(" or "):"",source:"devicetree",tags:f.tags,data:{firstToken:{pos:e.start.pos,tokens:e.start.tokens,value:e.start.value},lastToken:{pos:e.end.pos,tokens:e.end.tokens,value:e.end.value},issues:{type:"SyntaxIssue",items:f.issues,edit:f.edit,codeActionTitle:f.codeActionTitle}}},p);return r?.syntaxIssues.push(g),{raw:f,diagnostic:g}},qt=(t,e,r,{severity:n=Ki.DiagnosticSeverity.Error,linkedTo:i=[],tags:s,templateStrings:o=[],edit:a,codeActionTitle:c,linkedToTemplateStrings:l=[]}={severity:Ki.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[],linkedToTemplateStrings:[]})=>{let u=Vr(e.start,e.end),d={issues:Array.isArray(t)?t:[t],range:u,uri:e.start.uri,severity:n,linkedTo:i.map(({range:g,uri:h},v)=>({range:g,uri:h,templateStrings:l.at(v)??[]})),tags:s,templateStrings:o,edit:a,codeActionTitle:c},f,p=()=>(f??={severity:d.severity,range:u,message:jj(d),source:"devicetree",tags:d.tags,relatedInformation:[...d.linkedTo.map(g=>({message:d.issues.map(h=>Uj(h,g.templateStrings)).join(" or "),location:{uri:ve(g.uri),range:g.range}}))]},f);return r?.resetableIssues.push(p),{raw:d,diagnostic:p}},B=(t,e,r,{severity:n=Ki.DiagnosticSeverity.Error,linkedTo:i=[],tags:s,templateStrings:o=[],edit:a,codeActionTitle:c}={severity:Ki.DiagnosticSeverity.Error,linkedTo:[],templateStrings:[]})=>{let l=Vr(e.start,e.end),u={issues:Array.isArray(t)?t:[t],range:l,severity:n,uri:e.start.uri,linkedTo:i.map(({range:p,uri:g})=>({range:p,uri:g,templateStrings:[]})),tags:s,templateStrings:o,edit:a,codeActionTitle:c},d,f=()=>(d??={severity:u.severity,range:l,message:Hj(u),relatedInformation:[...u.linkedTo.map(p=>({message:u.issues.map(Vj).join(" or "),location:{uri:ve(p.uri),range:p.range}}))],source:"devicetree",tags:u.tags,data:{firstToken:{pos:e.start.pos,tokens:e.start.tokens,value:e.start.value},lastToken:{pos:e.end.pos,tokens:e.end.tokens,value:e.end.value},issues:{type:"StandardTypeIssue",items:u.issues,edit:u.edit,codeActionTitle:u.codeActionTitle}}},d);return r?.resetableIssues.push(f),{raw:u,diagnostic:f}},pw=(t,e)=>[...t].sort((n,i)=>{let s=e.getSortKey(n),o=e.getSortKey(i);if(s===void 0||o===void 0)throw new Error("Sort keys must be set");if(s!==o)return s-o;if(!n.tokenIndexes?.end||!i.tokenIndexes?.end)throw new Error("Must have token indexes");return n.tokenIndexes.end.pos.line!==i.tokenIndexes.end.pos.line?n.tokenIndexes.end.pos.line-i.tokenIndexes.end.pos.line:n.tokenIndexes.end.pos.col-i.tokenIndexes.end.pos.col});async function _t(t,e,r){let n=Ae(t.textDocument.uri);if(!e)return[];let i=performance.now(),o=(await e.getRuntime()).getDeepestAstNode(n,t.position),a=e.getSortKey(o?.ast);return console.log(`search: ${performance.now()-i}ms`),r(o,l=>{let u=t.position;return de(l.uri,n)?!!(l.tokenIndexes?.end&&(l.tokenIndexes.end.pos.line<u.line||l.tokenIndexes.end.pos.line===u.line&&l.tokenIndexes.end.pos.colEnd<=u.character)):a!==void 0&&(e.getSortKey(l)??-1)<=a})}function W(t,e){return{start:t,end:e??t}}var U=(t,e)=>t?.tokens.some(r=>r===e),rt=(t,e=!1)=>r=>r?.value&&(e?t.toLowerCase()===r.value.toLowerCase():t===r.value)?"yes":$j(t)(r),je=t=>e=>e?.tokens.some(r=>r===t)?"yes":"no",$j=t=>e=>e?.value&&t.startsWith(e.value)?"partial":"no",En=(t,e)=>!!t&&!!e&&t.pos.line===e.pos.line&&de(t.uri,e.uri),Lt=(t,e)=>t?.adjacentToken&&t.adjacentToken.value===e?.value||e?.adjacentToken&&e.adjacentToken.value===t?.value?!0:!!t&&!!e&&En(t,e)&&t.pos.colEnd===e.pos.col,af=t=>t.map((e,r)=>({index:r,context:e,files:e.getContextFiles()})),sn=(t,e,r,n)=>{if("id"in e){let s=t?.find(o=>o.id===e.id);return s||void 0}if("name"in e){let s=t?.find(o=>o.ctxNames.includes(e.name));return s||void 0}return r?.getContextFiles().find(s=>de(s,e.uri))?r:af(t).sort(s=>s.context.id===n?-1:0).find(s=>s.files.some(o=>de(o,e.uri)))?.context},Oy=(t,e)=>af(t).filter(n=>n.files.some(i=>de(i,e))).map(n=>n.context),hw=t=>{let e=/^(\w+)\s+(.+)$/,r=/^(\w+)\(([^)]*)\)\s+(.+)$/,n=/^(\w+)\(([^)]*),\s*\.\.\.\)\s+(.+)$/,i;if(i=n.exec(t)){let[,,s,o]=i,a=s.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(i=r.exec(t)){let[,,s,o]=i,a=s.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(i=e.exec(t)){let[,,s]=i;return s.trim()}},nf=(t,e)=>{let r=o=>o.replace(/(\w+)\s*##\s*(\w+)/g,(a,c,l)=>c+l),n=o=>o.replace(/#(\w+)/g,(a,c)=>`"${c}"`),i=t,s;do s=i,i=r(s),i=n(i),i=i.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(i!==s);return i};function Bj(t){return t.replace(/'(.)'/g,(e,r)=>r.charCodeAt(0).toString()).replace(/(0x[a-f\d]+|\d+)[ul]*/gi,"$1")}function Ee(t){try{return(0,eval)(Bj(t))}catch(e){console.log(e instanceof Error?e.message:e)}return t}var ve=t=>Ay.default.pathToFileURL(t).toString(),Ae=t=>tt(Ay.default.fileURLToPath(t)),de=(t,e)=>!t||!e?!1:t===e,tt=t=>(0,cw.normalize)(process.platform==="win32"?t.toLowerCase():t),bi=t=>(0,aw.createHash)("sha256").update([tt(t.dtsFile),...t.includePaths.map(tt),...t.overlays.map(tt),t.bindingType,...t.zephyrBindings.map(tt),...t.deviceOrgBindingsMetaSchema.map(tt),...t.deviceOrgTreeBindings.map(tt)].join(":")).digest("hex"),Fj=t=>{switch(t){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 49:return"Node name shall start with a lower or upper case character";case 50:return"Node unit address should not start with 0x";case 51:return"Node unit address should not end with with ULL";case 8:return"Expected node address";case 9:return"Expected node path";case 48:return"Expected node path reference";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 52:return"Unknown Node Address syntax";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"}},jj=t=>t.issues.map(e=>{switch(e){case 0:return`Property "${t.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 "${t.templateStrings[0]}" has been defined`;case 8:return`No node with name "${t.templateStrings[0]}" could be found in "/${t.templateStrings[1]}".`;case 4:return`Label name "${t.templateStrings[0]}" already defined`;case 6:return`Property "${t.templateStrings[0]}" was deleted`;case 7:return`Node "${t.templateStrings[0]}" was deleted`;case 9:return`The following node "${t.templateStrings[1]}" shall be present in "${t.templateStrings[0]}" node.`;case 10:return`The following node "${t.templateStrings[0]}" address range collides with another node. Address start: "${t.templateStrings[1]}", end: "${t.templateStrings[2]}".`}}).join(" or "),Uj=(t,e)=>{switch(t){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";case 10:return`Node "${e[0]}". Address start: "${e[1]}", end: "${e[2]}".`;default:return"TODO"}},Hj=t=>t.issues.map(e=>{switch(e){case 9:return`Only these value are allowed ${t.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 ${t.templateStrings[1]} values`;case 0:return"INTRO is required";case 11:return"INTRO should be omitted";case 27:return"INTRO name is not permitted under this node";case 34:return"INTRO name is not defined in the type binding for this node";case 10:return"INTRO address 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 ${t.templateStrings[1]}'`;case 18:return"INTRO value must be unique in the entire Devicetree";case 19:return`INTRO should have format ${t.templateStrings[1]}`;case 16:return`INTRO requires property "${t.templateStrings[1]}" in node path "${t.templateStrings[2]}"`;case 17:return"Unable to resolve interrupt parent node";case 20:return`INTRO should have format ${t.templateStrings[1]}`;case 21:return"Node is disabled";case 22:return"Unable to resolve handle";case 23:return`Unable to find "${t.templateStrings[0]}" in ${t.templateStrings[1]}`;case 24:return t.templateStrings[0];case 25:return t.templateStrings[0];case 26:return t.templateStrings[0];case 28:return t.templateStrings[0];case 35:return"Unable to find mapping range for address";case 29:return`INTRO exceeds address space available for this mapping. The range ends at ${t.templateStrings[2]}, the node ends at ${t.templateStrings[1]}`;case 30:return"Map entry overlaps with others entries";case 31:return"Unable to match to a nexus map entry";case 32:return`Unknown node type "${t.templateStrings[0]}"`;case 33:return`Missing name for "${t.templateStrings[0]}" index ${t.templateStrings[1]}"`;case 36:return"Node address is missing";case 37:return`Binding should be used on bus type${t.templateStrings.length?"s":""}: ${t.templateStrings.join(" or ")}`}}).join(" or ").replace("INTRO",`Property "${t.templateStrings[0]}"`).replaceAll("INTRO ",""),Vj=t=>{switch(t){case 16:case 0:return"Node";case 15:return"Ignored reason";case 18:return"Conflicting properties";case 8:return"Additional value";case 21:return"Disabled by";case 29:return"Mapping range";case 30:return"Map entry";case 31:return"Nexus map entries";case 33:return"Names property";case 35:return"Range property";default:return"TODO"}},rn=(t,e)=>{let r=Math.max(t.length,e.length);for(let n=0;n<r;n++){let i=t[t.length-r+n]??0,s=e[e.length-r+n]??0;if(i<s)return-1;if(i>s)return 1}return 0},Xi=(t,e)=>{let r=Math.max(t.length,e.length),n=new Array(r).fill(0),i=0;for(let s=0;s<r;s++){let o=t[t.length-1-s]??0,a=e[e.length-1-s]??0,c=o+a+i;n[r-1-s]=c>>>0,i=c>4294967295?1:0}return i&&n.unshift(1),n},zj=(t,e)=>{let r=Math.max(t.length,e.length),n=new Array(r).fill(0),i=0;for(let s=0;s<r;s++){let o=t[t.length-1-s]??0,a=e[e.length-1-s]??0;o-=i,o<a?(o+=4294967296,i=1):i=0,n[r-1-s]=o-a>>>0}for(;n.length>1&&n[0]===0;)n.shift();return n},Wj=(t,e)=>Xi(t,e),mw=(t,e)=>{let r=[];for(let n of t){let i=n.childAddress,s=n.length,o=Xi(i,s);if(rn(e,i)>=0&&rn(e,o)<0){let a=zj(e,i),c=n.parentAddress,l=Wj(c,a),u=Xi(c,s);r.push({start:l,end:u,range:Vr(n.rangeTokens.start,n.rangeTokens.end),uri:n.rangeTokens.start.uri})}}return r};function gw(t){return Array.isArray(t)&&Array.isArray(t[0])}function yc(t){return!t||t instanceof Ti?t:yc(t.parentNode)}function My(t,e){let r=t.getText(),n=e.slice().sort((s,o)=>{let a=t.offsetAt(s.range.start),c=t.offsetAt(o.range.start);if(a!==c)return c-a;let l=t.offsetAt(s.range.end),u=t.offsetAt(o.range.end);if(l!==u)return u-l;let d=a===l&&s.newText.length>0,f=c===u&&o.newText.length>0;return d!==f?d?1:-1:0}),i=r;for(let s of n){let o=t.offsetAt(s.range.start),a=t.offsetAt(s.range.end);i=i.slice(0,o)+s.newText+i.slice(a)}return i}function ow(t,e){return t.line<e.line?-1:t.line>e.line?1:t.character<e.character?-1:t.character>e.character?1:0}function yw(t,e){return ow(t.end,e.start)>0&&ow(t.start,e.end)<0}var vw=(t,e)=>{let r=Tw(t,e),n=bw(t,e);r&&(t.topComment=r.comment),n&&(t.endComment=n.comment)},Tw=(t,e)=>{let r=e.find(i=>i.lastToken===t.firstToken.prevToken&&(i.lastToken.pos.line===t.firstToken.pos.line||i.lastToken.pos.line+1===t.firstToken.pos.line));if(!r||r.astBeforeComment)return;r.astAfterComment=t;let n=Tw(r,e);return n&&(n.comment.astAfterComment=t,r.astAfterComment=void 0),{comment:n?.comment??r,commentIsBefore:!0}},bw=(t,e)=>{let r=e.find(i=>i.firstToken.prevToken===t.lastToken&&i.firstToken.pos.line===t.lastToken.pos.line);if(!r)return;r.astBeforeComment=t;let n=bw(r,e);return n&&(n.comment.astBeforeComment=t,r.astBeforeComment=void 0),{comment:n?.comment??r,commentIsBefore:!1}},Ho=(t,e,r)=>{let n=[42,44,45,36];return r||n.push(52,32,8,49),t.severity===Ki.DiagnosticSeverity.Error&&de(t.uri,e)&&!n.some(i=>t.issues.includes(i))};var Oc=require("fs"),xC=require("path");var Cn=L(j());var Pw=L(j());var _w=L(j());var ie=class extends Z{constructor(r,n){super(n);this.value=r;this.semanticTokenType="string",this.semanticTokenModifiers="declaration",this.docSymbolsMeta={name:this.value,kind:_w.SymbolKind.String}}toString(){return`"${this.value.toString()}"`}toJson(){return this.value}serialize(){return{type:"STRING",value:this.value,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var Nw=L(j());var Sw=L(j());var Zt=class extends we{constructor(r,n){super(n);this.value=r;this.docSymbolsMeta={name:this.value.toString(),kind:Sw.SymbolKind.Number},this.semanticTokenType="number",this.semanticTokenModifiers="declaration"}toString(r){return this.value.toString(r)}toJson(){return this.value}toPrettyString(r){let n=this.evaluate(r);return`${n.toString()} /* ${typeof n=="number"?`0x${n.toString(16)}`:""} */`}serialize(){return{type:"NUMBER_VALUE",value:this.toString(),evaluated:this.value,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var $t=class extends Z{constructor(r){super();this.values=r;this.docSymbolsMeta={name:"Cell Array",kind:Nw.SymbolKind.Array},this.values.forEach(n=>this.addChild(n))}toString(){return`<${this.values.map(r=>r.toString()).join(" ")}>`}toPrettyString(r){return`<${this.values.map(n=>n.toPrettyString(r)).join(" ")}>`}toJson(){if(this.values.length===1)return this.values[0].value?.toJson();if(this.values.length===2&&this.values.every(r=>r.value instanceof Zt)){let r=new ArrayBuffer(8),n=new DataView(r);return this.values.map(i=>i.value.value).forEach((i,s)=>{n.setUint32(s*4,i)}),n.getBigUint64(0)}return this.values.map(r=>r.value?.toJson()??NaN)}serialize(r){return{type:"ARRAY_VALUE",value:this.values.map(n=>n.value?.serialize(r)??null),uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var Rw=L(j());var _i=class extends Z{constructor(r){super();this.values=r;this.docSymbolsMeta={name:"Byte String Value",kind:Rw.SymbolKind.Array},this.values.forEach(n=>this.addChild(n))}toString(){return`[${this.values.map(r=>r.toString(16).padStart(2,"0")).join(" ")}]`}toJson(){return this.values.map(r=>r.value?.toJson()??NaN)}serialize(){return{type:"BYTESTRING",values:this.values.map(r=>r.value?{value:r.value.toString(16),range:r.value.range,evaluated:r.value.value}:null),uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var Qe=class extends Z{constructor(r,n){super(n);this.name=r;this.semanticTokenType="property",this.semanticTokenModifiers="declaration"}toString(){return this.name}serialize(){return{value:this.name,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}},Ye=class extends Z{constructor(r,n=[]){super();this.propertyName=r;this.labels=n;this._values=void 0;this.docSymbolsMeta={name:this.propertyName?.name??"Unknown",kind:Pw.SymbolKind.Property},this.labels.forEach(i=>this.addChild(i)),this.addChild(r)}set values(r){if(this._values)throw new Error("Only one property name is allowed");this._values=r,this.addChild(r)}get values(){return this._values}get quickValues(){return this.values?.values.map(r=>r?r.value instanceof ie?r.value.value:r.value instanceof $t?r.value.values.map(n=>n.value instanceof Zt?n.value.value:NaN):r.value instanceof _i?r.value.values.map(n=>n.value?.value??NaN):NaN:null)}getFlatAstValues(){return this.values?.values.flatMap(r=>r?r.value instanceof ie?r.value:r.value instanceof $t?r.value.values.map(n=>n.value):r.value instanceof _i?r.value.values.map(n=>n.value):r.value:null)}toString(){return`${this.propertyName?.toString()??"__UNSET__"}${this.assignOperatorToken?` = ${this._values?.values.map(r=>r?.toString()??"NULL").join(", ")??"NULL"}`:""};`}toPrettyString(r){return`${this.propertyName?.toString()??"__UNSET__"}${this.assignOperatorToken?` = ${this._values?.values.map(n=>n?.toPrettyString(r)??"NULL").join(", ")??"NULL"}`:""};`}serialize(r){return{name:this.propertyName?.serialize()??null,values:this.values?.values.map(n=>n?.value?.serialize(r)??null)??null,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var kw=L(j());var vr=class extends Z{constructor(r,n){super();this.keyword=n;this.addChild(n),this.docSymbolsMeta={name:r,kind:kw.SymbolKind.Function}}};var Dr=class extends vr{constructor(r){super("Delete Node",r);this._nodeNameOrRef=null}set nodeNameOrRef(r){if(this._nodeNameOrRef)throw new Error("Only one property name is allowed");this._nodeNameOrRef=r,this.addChild(r)}get nodeNameOrRef(){return this._nodeNameOrRef}};var pt=class extends vr{constructor(r){super("Delete Property",r);this._propertyName=null}set propertyName(r){if(this._propertyName)throw new Error("Only only property name is allowed");this._propertyName=r,this.addChild(r)}get propertyName(){return this._propertyName}};var ww=L(j());var se=class extends Z{constructor(r){super();this.label=r;this.docSymbolsMeta={name:`&${this.label?.value??"NULL"}`,kind:ww.SymbolKind.Key},this.addChild(r)}get value(){return this.label?.value}toString(){return`&${this.label?.value??"NULL"}`}toJson(){return-1}serialize(){return{type:"LABEL_REF",label:this.label?.toString()??null,nodePath:this.linksTo?.pathString??null,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var ct=class t extends Z{constructor(){super()}get path(){if(!this.pathName)return["__UNDEFINED__"];if(!this.parentNode||this instanceof St)return[this.pathName];if(!(this.parentNode instanceof t))return;let e=this.parentNode.path;return e?[...e,this.pathName]:[this.pathName]}get pathName(){}get nodes(){return this.children.filter(e=>e instanceof t)}get deleteNodes(){return this.children.filter(e=>e instanceof Dr)}addNodeChild(e){this.addChild(e)}},St=class extends ct{constructor(){super(),this.docSymbolsMeta={name:"/",kind:Cn.SymbolKind.Class}}get properties(){return this.children.filter(e=>e instanceof Ye)}get name(){return new He("/",W(this.firstToken))}get deleteProperties(){return this.children.filter(e=>e instanceof pt)}get nodes(){return this.children.filter(e=>e instanceof Ue)}get pathName(){return"/"}serialize(e){return{type:"ROOT",properties:this.properties.map(r=>r.serialize(e)),nodes:this.nodes.map(r=>r.serialize(e)),uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}},Wt=class extends ct{constructor(r=[]){super();this.labels=r;this._reference=null;this.docSymbolsMeta={name:"DTC Name",kind:Cn.SymbolKind.Class},r.forEach(n=>{super.addChild(n)})}get serializeIssues(){return[...this.issues,...this.reference?.issues??[]].map(r=>r())}set reference(r){if(this._reference)throw new Error("Only on label reference is allowed");this._reference=r;let n;r instanceof se?n=r.value:n=r?.path?.pathParts.at(-1)?.name??"DTC Name",this.docSymbolsMeta={name:n??"DTC Name",kind:Cn.SymbolKind.Class},this.addChild(r)}get path(){return this.resolveNodePath?this.resolveNodePath:super.path}get reference(){return this._reference}get nodes(){return this.children.filter(r=>r instanceof Ue)}get pathName(){if(this.reference instanceof se&&this.reference.label?.value)return`&${this.reference.label.value}`}get properties(){return this.children.filter(r=>r instanceof Ye)}get deleteProperties(){return this.children.filter(r=>r instanceof pt)}serialize(r){return{type:"REF",name:this.reference?.serialize()??null,properties:this.properties.map(n=>n.serialize(r)),nodes:this.nodes.map(n=>n.serialize(r)),uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}},Ue=class t extends ct{constructor(r=[],n){super();this.labels=r;this.omitIfNoRef=n;this._name=null;this.docSymbolsMeta={name:"DTC Name",kind:Cn.SymbolKind.Class},n&&this.addChild(n),r.forEach(i=>{this.addChild(i)})}get serializeIssues(){return[...this.issues,...this.name?.issues??[]].map(r=>r())}set name(r){if(this._name)throw new Error("Only on label reference is allowed");this._name=r,this.docSymbolsMeta={name:this._name?.toString()??"DTC Name",kind:Cn.SymbolKind.Class},this.addChild(r)}get name(){return this._name}get nodes(){return this.children.filter(r=>r instanceof t)}get pathName(){return this._name?.toString()}get properties(){return this.children.filter(r=>r instanceof Ye)}get deleteProperties(){return this.children.filter(r=>r instanceof pt)}serialize(r){return{type:"CHILD",name:this.name?.serialize()??null,properties:this.properties.map(n=>n.serialize(r)),nodes:this.nodes.map(n=>n.serialize(r)),uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}},vc=class extends Z{constructor(r,n){super(n);this.address=r;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}toString(){return this.address?.map((r,n)=>r.toString(16).padStart(n?8:0,"0")).join("")??"NaN"}serialize(){return{address:this.address,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}},He=class extends Z{constructor(r,n,i){super(n);this.name=r;this._address=i;this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}get value(){return this.name}get address(){return this._address}set address(r){if(this._address)throw new Error("Address can only be set once");r&&(this.lastToken=void 0,this._address=r,r.forEach(n=>this.addChild(n)))}get fullAddress(){return this._address?[...this._address.flatMap(r=>r.address)]:void 0}toString(){return this._address!==void 0?`${this.name}@${this._address.map(r=>r.toString()).join(",")}`:this.name}buildSemanticTokens(r){if(!this.tokenIndexes?.start||!this.tokenIndexes.start.value)return;let n={...this.tokenIndexes.start,pos:{...this.tokenIndexes.start.pos,len:this.name.length}};r(yi("type"),vi("declaration"),{start:n,end:n}),this.address!==void 0&&this.address.forEach(i=>{r(yi("decorator"),vi("declaration"),{start:i.firstToken,end:i.lastToken}),i.buildSemanticTokens(r)})}get serializeIssues(){return[...this.issues,...this._address?.flatMap(r=>r.issues)??[]].map(r=>r())}serialize(){return{fullName:this.toString(),name:{name:this.name,uri:this.serializeUri,range:Cn.Range.create(Cn.Position.create(this.tokenIndexes.start.pos.line,this.tokenIndexes.start.pos.col),Cn.Position.create(this.tokenIndexes.start.pos.line,this.tokenIndexes.start.pos.colEnd)),issues:this.serializeIssues},address:this.address?.map(r=>r.serialize())??null,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var ln=L(j());var Tr=class extends Z{constructor(r,n,i,s){super();this.startLabels=r;this.value=n;this.endLabels=i;this.bits=s;this.startLabels.forEach(o=>{this.addChild(o)}),this.addChild(s),this.addChild(n),this.endLabels.forEach(o=>{this.addChild(o)})}toString(){return`${[this.value?.toString()??"NULL",...this.endLabels.map(r=>r.toString())].join(" ")}`}toPrettyString(r){return`${[this.value?.toPrettyString(r)??"NULL",...this.endLabels.map(n=>n.toString())].join(" ")}`}toJson(){return this.value?.toJson()}};var Ut=t=>t instanceof vr?!0:t instanceof ct?!1:t.parentNode?Ut(t.parentNode):!1;var xy=t=>{if(t instanceof Ye)return t;if(!(t instanceof ct))return t.parentNode?xy(t.parentNode):void 0},js=t=>!t||t instanceof Ye?!1:t instanceof Tr||js(t.parentNode),Vo=t=>[...t.map(e=>{if(e instanceof Ue||e instanceof St)return e.name;if(e instanceof Wt)return e.reference})].filter(e=>!!e),qy=(t,e)=>e?e.parentNode===t||qy(t,e.parentNode):!1;var wt=L(j());var Ew=L(j());var Dn=class extends Z{constructor(){super();this._pathParts=[]}addPath(r,n){this._pathParts.push(r),n&&this.addChild(n),this.addChild(r)}get pathParts(){return[...this._pathParts]}toString(){return this._pathParts.map(r=>r?.toString()??"<NULL>").join("/")}buildSemanticTokens(r){this._children.forEach(n=>{n instanceof He?n.buildSemanticTokens(r):r(yi("operator"),vi("declaration"),n.tokenIndexes)})}},nt=class extends Z{constructor(r){super();this.path=r;this.docSymbolsMeta={name:`/${this.path?.toString()??""}`,kind:Ew.SymbolKind.Namespace},this.addChild(r)}toString(){return`&${this.path?.toString()??"NULL"}`}toJson(){return-1}serialize(){return{type:"NODE_PATH",nodePath:this.path?.toString()??null,uri:this.serializeUri,range:this.range,issues:this.serializeIssues}}};var ee=L(j());var Cw=require("path"),cf=L(j());var Si=class extends Z{constructor(r,n){super();this.keyword=r;this.path=n;this.docSymbolsMeta={name:`Include ${n}`,kind:cf.SymbolKind.File},this.addChild(r),this.addChild(n)}get resolvedPath(){return this._resolvedPath}set resolvedPath(r){this.docSymbolsMeta={name:`Include ${r}`,kind:cf.SymbolKind.File},this._resolvedPath=r}},zo=class extends Z{constructor(r,n,i){super(i);this._path=r;this.relative=n;this.docSymbolsMeta={name:(0,Cw.basename)(this.path),kind:cf.SymbolKind.File},this.semanticTokenType="string",this.semanticTokenModifiers="declaration"}get path(){return this.relative?this._path.slice(1,-1):this._path}};var on=class extends Z{constructor(r){super();this.comments=r;r.forEach(this.addChild.bind(this))}toString(){return this.comments.map(r=>r.toString()).join(`
183
183
  `)}},an=class extends Z{constructor(e){super(e),this.semanticTokenType="comment",this.semanticTokenModifiers="documentation"}toString(){let e,r=this.firstToken,n="";for(;r!==this.lastToken;)n+=r?.value.padStart(r.value.length+(e?r.pos.col-e.pos.colEnd:0)," "),e=r,r=r?.nextToken;r&&(n+=r?.value.padStart(r.value.length+(e?r.pos.col-e.pos.colEnd:0)," "));let i=n.match(/^\s*(?:(?:\/\/|\/\*+)\s*)?(.*?)\s*(?:\*\/)?\s*$/s);return i?i[1]:""}};var Dw=L(j());var Ct=class extends we{constructor(r,n){super(n);this.name=r;this.docSymbolsMeta={name:this.name.toString(),kind:Dw.SymbolKind.Variable},this.semanticTokenType="macro",this.semanticTokenModifiers="declaration"}toString(){return this.name}};var _f=L(j());var Ly=L(j());var Ji=class extends Z{constructor(r,n){super(n);this.label=r;this.docSymbolsMeta={name:this.label.value,kind:Ly.SymbolKind.Constant},this.semanticTokenType="variable",this.semanticTokenModifiers="declaration",this.addChild(r)}toString(){return`${this.label.toString()}:`}},er=class extends Z{constructor(r,n){super(n);this.value=r;this.docSymbolsMeta={name:this.value,kind:Ly.SymbolKind.Variable},this.semanticTokenType="variable",this.semanticTokenModifiers="declaration"}buildSemanticTokens(r){let n=this.parentNode;if(!(n instanceof se&&n.linksTo)){super.buildSemanticTokens(r);return}r(yi("type"),vi("declaration"),{start:this.firstToken,end:this.lastToken})}toString(){return`${this.value}`}};var ht=class extends Z{constructor(e){super(e),this.semanticTokenType="keyword",this.semanticTokenModifiers="declaration"}};var Aw=L(j());var lf=class extends Z{constructor(r){super();this.values=r;this.docSymbolsMeta={name:"Values",kind:Aw.SymbolKind.String},this.values.forEach(n=>this.addChild(n))}toString(){return this.values.map(r=>r?.toString()).join(",")}toJson(){return this.values.length===1?this.values[0]?.toJson():this.values.map(r=>r?.toJson())}};var Iw=L(j());var uf=class extends Z{constructor(r){super();this.keyword=r;this.addChild(r),this.docSymbolsMeta={name:"DTS Document version",kind:Iw.SymbolKind.Function}}};var Xn=class extends Z{constructor(r,n){super();this.value=r;this.labels=n;this.labels.forEach(i=>{this.addChild(i)}),this.addChild(this.value)}toString(r){return`${this.labels.map(n=>n.toString()).join(" ")}${this.value?.toString(r)??"NULL"}`}toPrettyString(r){return`${this.labels.map(n=>n.toString()).join(" ")}${this.value?.toPrettyString(r)??"NULL"}`}};var df=class extends Z{constructor(r,n){super(n);this.operator=r;this.semanticTokenType="operator",this.semanticTokenModifiers="declaration"}toString(){return this.operator}};var Ow=L(j());var ff=class extends ht{toString(){return"..."}},Jn=class extends Z{constructor(r,n){super();this.functionName=r;this.params=n;this.addChild(r),this.params.forEach(i=>this.addChild(i))}getDocumentSymbols(r){return de(this.uri,r)?[{name:this.functionName.name,kind:Ow.SymbolKind.Function,range:fe(this),selectionRange:fe(this),children:this.params.flatMap(n=>n.getDocumentSymbols(r))}]:[]}toString(){return`${this.functionName}(${this.params.map(r=>r.toString()).join(",")})`}};var Qi=class{constructor(){this.positionStack=[];this._issues=[];this.issueLengthPositionStack=[];this.moveEndOfLine=(e,r=!0)=>{let n=e.pos.line;if(this.currentToken?.pos.line!==n||!de(this.currentToken?.uri,e.uri))return;let i=this.currentToken,s=i;for(;this.currentToken?.pos.line===n&&de(this.currentToken?.uri,e.uri);)s=this.moveToNextToken;return r&&this._issues.push(G(22,W(i,s),null)),s};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(),r=this.positionStack.pop();if(r===void 0||e===void 0)throw new Error("Index out of bounds");this.positionStack[this.positionStack.length-1]=r}peekIndex(e=1){let r=this.positionStack.at(-1*e);if(r===void 0)throw new Error("Index out of bounds");return r}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 r=[];return e.every(n=>{let i=this.currentToken,s=n(i),o=!1;return s!=="no"&&i&&(r.push(i),this.moveToNextToken,o=Lt(i,this.currentToken)),s==="yes"&&o}),this.mergeStack(),r}consumeAnyConcurrentTokens(e){this.enqueueToStack();let r=[],n,i=!0;for(;e.some(s=>s(this.currentToken)==="yes"&&i);)r.push(this.currentToken),n=this.moveToNextToken,i=Lt(n,this.currentToken);return this.mergeStack(),r}getDocumentSymbols(e){return this.allAstItems.flatMap(r=>r.getDocumentSymbols(e))}getWorkspaceSymbols(){return this.allAstItems.flatMap(e=>e.getWorkspaceSymbols())}buildSemanticTokens(e,r){let n=[],i=(s,o,a)=>{if(!a?.start||!a?.end||!de(a.start.uri,r)||!de(a.end.uri,r))return;let c=a.end.pos.colEnd-a.start.pos.col;n.push({line:a.start.pos.line,char:a.start.pos.col,length:a.end===a.start?a.end.pos.len:c,tokenType:s,tokenModifiers:o})};this.allAstItems.forEach(s=>{s.buildSemanticTokens(i)}),n.sort((s,o)=>s.line===o.line?s.char-o.char:s.line-o.line).forEach(s=>e.push(s.line,s.char,s.length,s.tokenType,s.tokenModifiers))}processCIdentifier(e,r){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,48].map(je));if(!n.length){this.popStack();return}let i=n.map(o=>o.value).join("");if(!i.match(/^[_A-Za-z]/)){this.popStack();return}let s=new Ct(i,W(n[0],n.at(-1)));return!r&&s.name!=="defined"&&(e.get(s.name)||this._issues.push(G(42,s.rangeTokens,s))),this.mergeStack(),s}isOperator(){this.enqueueToStack();let e=this.moveToNextToken;if(!e){this.popStack();return}let r=e,n;if(U(e,40)?(n="&",U(this.currentToken,40)&&(n="&&",r=this.moveToNextToken)):U(e,6)?(n="!",U(this.currentToken,0)&&(n="!=",r=this.moveToNextToken)):U(e,10)?n="~":U(e,8)?(n="|",U(this.currentToken,8)&&(n="||",r=this.moveToNextToken)):U(e,9)?n="^":U(e,4)?(n=">",U(this.currentToken,4)?(n="<<",r=this.moveToNextToken):U(this.currentToken,0)&&(n=">=",r=this.moveToNextToken)):U(e,5)?(n="<",U(this.currentToken,5)?(n=">>",r=this.moveToNextToken):U(this.currentToken,0)&&(n="<=",r=this.moveToNextToken)):U(e,15)?n="+":U(e,16)?n="-":U(e,17)?n="*":U(e,13)?n="/":U(e,18)?n="%":U(e,46)?U(this.currentToken,46)&&(n="##",r=this.moveToNextToken):U(e,0)&&U(this.currentToken,0)&&(n="==",r=this.moveToNextToken),n){let i=new df(n,W(e,r));return this.mergeStack(),i}this.popStack()}parseScopedBlock(e,r,n){this.enqueueToStack();let i=this.moveToNextToken;if(!i||!e(i)){this.popStack();return}let s=this.peekIndex(),o=()=>{this.positionStack[this.positionStack.length-1]=s},a=g=>g.flatMap(h=>"items"in h?a(h.items):h),c=[i],l=[],u=[];u[0]={rewind:o,tokens:[]};let d=this.currentToken;for(;d&&!r(d);){if(n?.(d)){let g=this.peekIndex()+1,h=()=>{this.positionStack[this.positionStack.length-1]=g};c.push(d),l.push(d),u[u.length]={rewind:h,tokens:[]}}else if(e(d)){let g=this.parseScopedBlock(e,r,n);g&&(c.push(g),u[u.length-1].tokens.push(...a(g.items))),d=this.currentToken;continue}else c.push(d),u[u.length-1].tokens.push(d);this.moveToNextToken,d=this.currentToken}let f=d;f&&r(f)&&(this.moveToNextToken,c.push(f));let p={startToken:i,items:c,splitTokens:u,endToken:f,separatorTokens:l};return this.mergeStack(),p}isFunctionCall(e){this.enqueueToStack();let r=this.processCIdentifier(e,!1);if(!r){this.popStack();return}if(!Lt(r.lastToken,this.currentToken)){this.popStack();return}let n=this.processMacroCallParams();if(!n){this.popStack();return}if(r.name==="defined")n.length>1?this._issues.push(G(44,r.rangeTokens,r)):n.length<1&&this._issues.push(G(45,r.rangeTokens,r));else{let s=e.get(r.name)?.macro;s&&(s?.identifier instanceof Jn?n.length>s.identifier.params.length?this._issues.push(G(44,r.rangeTokens,r,{linkedTo:[s]})):n.length<s.identifier.params.length&&this._issues.push(G(45,r.rangeTokens,r,{linkedTo:[s]})):this._issues.push(G(43,r.rangeTokens,r)))}let i=new Ti(r,n);return i.lastToken=this.prevToken,this.mergeStack(),i}processHex(){this.enqueueToStack();let e=this.checkConcurrentTokens([rt("0"),rt("x",!0)]);if(e.length!==2){this.popStack();return}let r=this.consumeAnyConcurrentTokens([19,20].map(je));if(!r.length){this.popStack();return}let n=Number.parseInt(r.map(s=>s.value).join(""),16),i=new Zt(n,W(e[0],r.at(-1)));return this.mergeStack(),i}processDec(e=!1){this.enqueueToStack();let r;e&&(U(this.currentToken,16)||U(this.currentToken,15))&&Lt(this.currentToken,this.currentToken?.nextToken)&&(r=this.moveToNextToken);let n=this.consumeAnyConcurrentTokens([19].map(je));if(!n.length){this.popStack();return}let i=Number.parseInt(n.map(o=>o.value).join(""),10);r&&U(r,16)&&(i=4294967295-i);let s=new Zt(i,W(r??n[0],n.at(-1)));return this.mergeStack(),s}processEnclosedExpression(e,r){this.enqueueToStack();let n,i;if(U(this.currentToken,42)){let s;n=this.moveToNextToken,i=n;let o=this.processExpression(e,r,!0);return o&&(s=new Gn(o,!0),o=new Gn(s,!1),s.openBracket=n),U(this.currentToken,43)?(i=this.moveToNextToken,s&&(s.closeBracket=i)):n&&this._issues.push(G(26,W(n),r)),this.mergeStack(),o}this.popStack()}processExpression(e,r,n=!1){this.enqueueToStack();let i,s;if(n&&(s=this.isOperator()),i=this.processEnclosedExpression(e,r)||this.isFunctionCall(e)||this.processCIdentifier(e,!1)||this.processHex()||this.processDec(!0),!i){this.popStack();return}if(s&&(i.operator=s),n){let o=this.isOperator();for(;o;){let a=this.processExpression(e,r,!0);a?i instanceof Gn?i.addExpression(o,a):i=new Gn(i,!1,{operator:o,expression:a}):this._issues.push(G(27,o.rangeTokens,r)),o=this.isOperator()}}return this.mergeStack(),i}processMacroCallParams(){if(!U(this.currentToken,42))return;let e=this.parseScopedBlock(n=>!!U(n,42),n=>!!U(n,43),n=>!!U(n,24));return e?.items.length===2&&U(e.endToken,43)?[]:e?.splitTokens.map((n,i)=>{if(n.tokens.length===0)return null;let s=new Yn(n.tokens.map((o,a)=>{let c=o.value;return o.pos.line===n.tokens.at(a+1)?.pos.line?c=c.padEnd(n.tokens[a+1].pos.col-o.pos.col," "):o.value==="\\"&&(c=c.slice(0,-1)),c}).join(""),W(n.tokens[0],n.tokens.at(-1)),i);return s.splitToken=e.separatorTokens.at(i),s})}};var Fy=require("fs"),Yo=require("path"),kc=L(j());var _c=require("fs");var Wo=class t{constructor(e,r){this.text=e;this.uri=r;this.inComment=!1;this.lineNumber=0;this.columnNumber=0;this._tokens=[];let n=this.text.replace(/\r\n/g,`
184
184
  `).trimEnd();this.lines=n.split(`
185
185
  `);for(let i=0;i<this.lines.length;i++)this.lines[i]+=`
186
186
  `;this.lexIt()}get tokens(){return this._tokens}isWhiteSpace(){let e=this.currentChar;if(!e)return!1;let r=e.charCodeAt(0);return r===32||r===9||r===10||r===13||r===12||r===11}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(){for(;!this.isOnLastLine;)if(this.columnNumber=0,this.lineNumber++,this.lines[this.lineNumber].length>0)return!0;return!1}moveOnLine(){let r=this.lines[this.lineNumber].length;return this.columnNumber>=r?this.moveToNextLine():(this.columnNumber++,this.columnNumber>=r&&this.moveToNextLine(),!0)}move(){return this.lineNumber>=this.lines.length?!1:this.moveOnLine()}get currentChar(){if(this.lineNumber>=this.lines.length)return null;let e=this.lines[this.lineNumber];return this.columnNumber>=e.length?null:e[this.columnNumber]}static{this.SYNTAX_CHARS=new Set(["^","~","|","!","\\","<",">",";","=","/","{","}","[","]","(",")","*","%","&",".",":","+","@","-","_",",","x","X","?"])}static isSyntaxChar(e){return e?t.SYNTAX_CHARS.has(e):!1}static isLetterCode(e){return e>=65&&e<=90||e>=97&&e<=122}getWord(){let e="";for(;!this.isWhiteSpace()&&(e.length&&!t.isSyntaxChar(this.currentChar)||!e.length);){if(e+=this.currentChar??"",e.length===1&&t.isSyntaxChar(this.currentChar)){this.move();break}let r=this.lineNumber;if(!this.move()||this.lineNumber!==r)return e}return this.inComment&&e==="*"&&this.currentChar==="/"&&(this.inComment=!1),this.inCommentLineStart!==void 0&&this.lineNumber!==this.inCommentLineStart&&(this.inCommentLineStart=void 0,this.inComment=!1),!this.inComment&&e==="/"&&this.currentChar==="*"&&(this.inCommentLineStart=void 0,this.inComment=!0),!this.inComment&&e==="/"&&this.currentChar==="/"&&(this.inCommentLineStart=this.lineNumber,this.inComment=!0),e}getString(e){let r=e,n;for(;this.currentChar!==e;){if(this.currentChar===`
187
187
  `){let a=this.lineNumber,c=this.columnNumber,l=r.length;this.pushToken({tokens:[21],value:r,pos:{col:c-l,line:a,len:l,colEnd:c},adjacentToken:n}),n=this._tokens.at(-1),r=""}else if(this.currentChar==="\\"){let a=this.lineNumber;if(r+=this.currentChar??"",this.move())a===this.lineNumber&&(r+=this.currentChar??"");else break}else r+=this.currentChar??"";if(!this.move())break}r+=e;let i=this.lineNumber,s=this.columnNumber+1,o=r.length;this.pushToken({tokens:[21],value:r,pos:{col:s-o,line:i,len:o,colEnd:s},adjacentToken:n}),this.move()}lexIt(){for(;!this.endOfFile;){for(;this.isWhiteSpace();)this.move();let e=this.getWord();e&&this.process(e)}}static{this.SINGLE_CHAR_TOKENS=new Map([["{",[2]],["}",[3]],["(",[42]],[")",[43]],["[",[11]],["]",[12]],[";",[1]],[":",[50]],["=",[0]],[">",[4]],["<",[5]],["!",[6]],["|",[8]],["^",[9]],["&",[40,7]],["~",[10]],["/",[13]],["\\",[14]],["+",[15]],["-",[16]],["*",[17]],["%",[18]],["?",[44]],[".",[45]],["_",[48]],["@",[49]],[",",[24]]])}static{this.KEYWORD_TOKENS=new Map([["true",38],["false",39],["#define",25],["#include",26],["#line",27],["#undef",28],["#error",29],["#pragma",30],["#defined",31],["#if",32],["#ifdef",33],["#ifndef",34],["#elif",35],["#else",36],["#endif",37]])}process(e){let r=this.isString(e);if(!r){let i=t.KEYWORD_TOKENS.get(e.toLowerCase());if(i&&(r=!0,this.pushToken({tokens:[i],value:e.toLowerCase(),pos:this.generatePos(e,e.toLowerCase())}),i===39||i===38))if(Lt(this.tokens.at(-2),this.tokens.at(-1)))r=!1,this.tokens.pop();else return!0}if(r||(r=this.isDigit(e)||this.isHexDigit(e)||this.isLetters(e)),!r&&e.length===1){let i=t.SINGLE_CHAR_TOKENS.get(e);if(i)return r=!0,this.pushToken({tokens:i,value:e,pos:this.generatePos(e,e)}),!0}if(r||(r=this.isHash(e)||this.unknownToken(e)),!r)throw new Error(`Lexer is not complete!!! Could not find token for "${e}"`);let n=this._tokens[this._tokens.length-1];return r&&!n?.tokens.some(i=>i===21)&&n&&n.pos.len<e.length?this.process(e.slice(n.pos.len)):!0}pushToken(e){let r={tokens:e.tokens,pos:e.pos,value:e.value,uri:this.uri,adjacentToken:e.adjacentToken},n=this._tokens[this._tokens.length-1];r.prevToken=n,n&&(n.nextToken=r),this._tokens.push(r)}isLetters(e){let r=e[0]?.charCodeAt(0);if(t.isLetterCode(r)){let n="";for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);if(t.isLetterCode(s))n+=e[i];else break}return this.pushToken({tokens:[47],value:n,pos:this.generatePos(e,n)}),!0}return!1}isDigit(e){let r=e[0],n=r?.charCodeAt(0);return n>=48&&n<=57?(this.pushToken({tokens:[20,19],value:r,pos:this.generatePos(e,r)}),!0):!1}isHexDigit(e){let r=e[0],n=r?.charCodeAt(0);return n>=65&&n<=70||n>=97&&n<=102?(this.pushToken({tokens:[20,47],value:r,pos:this.generatePos(e,r)}),!0):!1}isHash(e){let r="#";return e.startsWith(r)?(this.pushToken({tokens:[46],pos:this.generatePos(e,r),value:r}),!0):!1}unknownToken(e){return this.pushToken({tokens:[41],pos:this.generatePos(e," "),value:e}),!0}isString(e){if(this.inComment)return!1;let r=e[0];if(r==='"'||r==="'"){let n=e.length-1;if(this.columnNumber+1<n)throw new Error("Error while rewinding");return this.columnNumber-=n,this.getString(r),!0}return!1}generatePos(e,r){let n=this.columnNumber-e.length,i=r.length;return{line:this.lineNumber,col:n,len:i,colEnd:n+i}}};var $y,pf=class{constructor(){this.headerFiles=new Map;this.includeOwners=new WeakMap}getCPreprocessorParser(e,r,n,i){e=tt(e);let s=`${Array.from(n).map(l=>l[1].macro.toString()).join("::")}`,o=this.headerFiles.get(e)?.get(s);if(o)return o.reparse(n),o;console.log("No cpreprocess cache",e);let a=new Go(e,r,n),c=this.includeOwners.get(a)??new Set;return c.add(i),this.includeOwners.set(a,c),this.headerFiles.has(e)||this.headerFiles.set(e,new Map),this.headerFiles.get(e)?.set(s,a),a}reset(e){e=tt(e);let r=this.headerFiles.get(e);r&&Array.from(r).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 bc(){return $y??=new pf,$y}function Mw(){$y=new pf}var By,hf=class t{constructor(){this.fileMap=new Map}static clone(e){let r=e.map(n=>({...n}));return r.forEach((n,i)=>{n.prevToken=r[i-1],n.nextToken=r[i+1]}),r}needsRenew(e,r){return e=tt(e),this.fileMap.get(e)?.text!==r}getDocument(e,r){return Yi.create(e,"devicetree",0,r??this.fileMap.get(e)?.text??(0,_c.readFileSync)(e).toString())}renewLexer(e,r){if(e=tt(e),bc().reset(e),!r&&!(0,_c.existsSync)(e))return[];try{r??=(0,_c.readFileSync)(e).toString();let n=new Wo(r,e);return this.fileMap.set(e,n),t.clone(n.tokens)}catch{}return[]}requestTokens(e,r){e=tt(e);let n=this.fileMap.get(e)?.tokens;return!n&&r?[...this.renewLexer(e)]:t.clone(n??[])}reset(e){e=tt(e),bc().reset(e),this.fileMap.delete(e)}};function Ar(){return By??=new hf,By}function xw(){By=new hf}var mf=class t extends Qi{constructor(r,n=()=>Ar().requestTokens(this.uri,!0)){super();this.uri=r;this.getTokens=n;this.comments=[];this.tokens=[]}cleanUpComments(){let r=[];for(let n=0;n<this.tokens.length;n++){let i=t.processBlockComment(this.tokens,n)||t.processLineComment(this.tokens,n);i&&(n=i.index,r.push(...i.tokenUsed),this.comments.push(i.comment))}if(r.length>0){let n=new Set(r),i=[];for(let s=0;s<this.tokens.length;s++)n.has(s)||i.push(this.tokens[s]);this.tokens=i}}get allAstItems(){return this.comments}reset(){super.reset(),this.comments=[]}reparse(){return this.reset(),this.parse()}async parse(){this.tokens=this.getTokens(),this.cleanUpComments()}static processBlockComment(r,n){let i=[],s=()=>(i.push(n++),r[n]),o=()=>r[n],a=()=>r[n-1],c=o(),l=c;if(!c||!U(c,13)||(l=s(),!U(l,17)||c.pos.line!==l.pos.line||c.pos.col+1!==l.pos.col))return;let u=()=>!(!U(a(),17)||!U(o(),13)||!Lt(a(),o())),d=l.pos.line,f=c,p=[];l=s();do{if(o()?.pos.line!==d){let v=new an(W(f,a()));p.push(v),d=o().pos.line??0,f=o()}l=s()}while(n<r.length&&!u());let g=new an(W(f,o()));p.push(g);let h=new on(p);return s(),{comment:h,tokenUsed:i,index:n-1}}static processLineComment(r,n){let i=[];if(!U(r[n],13)||r.length===n+1||!U(r[n+1],13)||!Lt(r[n],r[n+1]))return;for(;r[n].pos.line===r.at(n+1)?.pos.line;)i.push(n++);return i.push(n++),{comment:new an(W(r[i[0]],r[i.at(-1)])),tokenUsed:i,index:n-1}}};var qw=L(j());var gf=class extends Z{constructor(r,n){super(r);this.content=n}toString(){let r=this.content.filter(n=>!U(n,14));return r.map((n,i)=>{let s=n.value;return n.pos.line===r.at(i+1)?.pos.line?s=s.padEnd(r[i+1].pos.col-n.pos.col," "):r.at(i+1)&&(s=s.padEnd(s.length+1," ")),s}).join("")}},Sc=class extends Z{constructor(r,n,i){super();this.keyword=r;this.identifier=n;this.content=i;this.addChild(r),this.addChild(this.identifier),this.content&&this.addChild(this.content)}get name(){return this.identifier instanceof Ct?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:qw.MarkupKind.Markdown,value:["```cpp",`#define ${this.toString()}`,"```"].join(`
188
188
  `)}}};var Us=class extends Z{constructor(e){super(e)}},Nc=class extends Z{constructor(r,n){super();this.keyword=r;this.content=n;this.active=!1;this.addChild(r)}},Rc=class extends Nc{constructor(r,n,i){super(r,i);this.identifier=n;this.addChild(n),this.addChild(i)}useBlock(r){return this.identifier&&r.has(this.identifier.name)}},yf=class extends Nc{constructor(r,n,i){super(r,i);this.expression=n;this.addChild(n),this.addChild(i)}useBlock(r){return this.expression?.isTrue(r)}},vf=class extends Rc{useBlock(e){return this.identifier&&!e.has(this.identifier.name)}},Pc=class extends Nc{};var Zi=class extends Z{constructor(r,n,i){super();this.ifDef=r;this.endIf=n;this.elseOption=i;this.addChild(r),i&&this.addChild(i),this.addChild(n)}getInValidTokenRange(r,n){let i=[],s=a=>n.findIndex(c=>c===a);if(!this.ifDef.identifier)return[{start:s(this.tokenIndexes.start),end:s(this.tokenIndexes.end)}];i.push({start:s(this.ifDef.tokenIndexes.start),end:s(this.ifDef.identifier.tokenIndexes.end)});let o=this.ifDef.useBlock(r);return o?this.ifDef.active=!0:this.elseOption&&(this.elseOption.active=!0),!o&&this.ifDef.content&&i.push({start:s(this.ifDef.content.tokenIndexes.start),end:s(this.ifDef.content.tokenIndexes.end)}),this.elseOption&&(i.push({start:s(this.elseOption.tokenIndexes.start),end:s(this.elseOption.keyword.tokenIndexes.end)}),o&&this.elseOption.content&&i.push({start:s(this.elseOption.content.tokenIndexes.start),end:s(this.elseOption.content.tokenIndexes.end)})),this.endIf&&i.push({start:s(this.endIf.tokenIndexes.start),end:s(this.endIf.tokenIndexes.end)}),i}},es=class extends Z{constructor(r,n,i){super();this.ifBlocks=r;this.endIf=n;this.elseOption=i;r.forEach(s=>this.addChild(s)),i&&this.addChild(i),this.addChild(n)}getInValidTokenRange(r,n){let i=[],s=a=>n.findIndex(c=>c===a),o=!1;return this.ifBlocks.forEach(a=>{i.push({start:s(a.tokenIndexes.start),end:s(a.expression?.tokenIndexes.end??a.keyword.tokenIndexes.end)}),!o&&a.useBlock(r)?(a.active=!0,o=!0):a.content&&i.push({start:s(a.content.tokenIndexes.start),end:s(a.content.tokenIndexes.end)})}),this.elseOption&&(i.push({start:s(this.elseOption.keyword.tokenIndexes.start),end:s(this.elseOption.keyword.tokenIndexes.end)}),o&&this.elseOption.content?i.push({start:s(this.elseOption.content.tokenIndexes.start),end:s(this.elseOption.content.tokenIndexes.end)}):this.elseOption.active=!0),this.endIf&&i.push({start:s(this.endIf.tokenIndexes.start),end:s(this.endIf.tokenIndexes.end)}),i}};var Go=class extends Qi{constructor(r,n,i,s,o){super();this.uri=r;this.incudes=n;this.getTokens=s;this.skipIncludes=o;this.tokens=[];this.nodes=[];this._comments=[];this.dtsIncludes=[];this.macroSnapShot=new Map;this.macros=new Map;this.macroStart=!1;i&&(Array.from(i).forEach(([a,c])=>this.macroSnapShot.set(a,c)),Array.from(i).forEach(([a,c])=>this.macros.set(a,c)))}get comments(){return this._comments}get currentToken(){let r=this.prevToken,n=En(r,this.tokens.at(this.peekIndex()))||!r||U(r,14)&&r.pos.line+1===this.tokens.at(this.peekIndex())?.pos.line;if(!(this.macroStart&&!n))return this.macroStart&&U(this.tokens.at(this.peekIndex()),14)?(this.moveStackIndex(),this.currentToken):this.tokens.at(this.peekIndex())}reset(r){super.reset(),this.macros.clear(),r?(this.macroSnapShot.clear(),Array.from(r).forEach(([n,i])=>this.macroSnapShot.set(n,i)),Array.from(r).forEach(([n,i])=>this.macros.set(n,i))):Array.from(this.macroSnapShot).forEach(([n,i])=>this.macros.set(n,i)),this.nodes=[],this.dtsIncludes=[]}async reparse(r){let n=this.stable;return this.parsing=new Promise(i=>{n.then(()=>{if(r&&r.size===this.macroSnapShot.size){let s=Array.from(r);if(Array.from(this.macroSnapShot).every(([o,a],c)=>{let[l,u]=s[c];return l===o&&u.macro.toString()===a.macro.toString()})){console.log("header file cache hit",this.uri),i();return}}this.reset(r),this.parse().then(i)})}),this.parsing}async parse(){let r=new mf(this.uri,this.getTokens);if(await r.stable,this.tokens=r.tokens,this._comments=r.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||!de(this.prevToken.uri,this.currentToken.uri))){this.moveEndOfLine(this.prevToken,!1),this.mergeStack();return}let n=this.currentToken,i=await this.processInclude()||this.processDefinitions()||this.processUndef()||this.processIfDefBlocks();n&&this.moveEndOfLine(n,!!i),this.mergeStack()}processDefinitions(){this.enqueueToStack();let r=this.peekIndex(),n=this.moveToNextToken;if(!n||!U(n,25))return this.popStack(),!1;this.macroStart=!0;let i=new ht(W(n)),s=this.isFunctionDefinition()||this.processCIdentifier(this.macros,!0);if(!s)return this._issues.push(G(30,i.rangeTokens,i)),this.mergeStack(),this.macroStart=!1,!0;let o=this.consumeDefinitionContent(),a;o.length&&(a=new gf(W(o[0],o.at(-1)),o));let c=new Sc(i,s,a);this.macros.set(c.name,{macro:c,resolver:hw(c.toString())}),this.nodes.push(c);let l=this.peekIndex();return this.tokens.splice(r,l-r),this.positionStack[this.positionStack.length-1]=r,this.mergeStack(),this.macroStart=!1,!0}processUndef(){this.enqueueToStack();let r=this.peekIndex(),n=this.moveToNextToken;if(!n||!U(n,28))return this.popStack(),!1;this.macroStart=!0;let i=new ht(W(n)),s=this.processCIdentifier(this.macros,!0);if(!s)return this._issues.push(G(30,i.rangeTokens,i)),this.mergeStack(),this.macroStart=!1,!0;let o=new Sc(i,s);this.macros.delete(s.name),this.nodes.push(o);let a=this.peekIndex();return this.tokens.splice(r,a-r),this.positionStack[this.positionStack.length-1]=r,this.mergeStack(),this.macroStart=!1,!0}consumeDefinitionContent(){let r=[];for(;this.currentToken;){let n=this.moveToNextToken;n&&r.push(n)}return r}isFunctionDefinition(){this.enqueueToStack();let r=this.processCIdentifier(this.macros,!0);if(!r){this.popStack();return}let n=this.moveToNextToken;if(!U(n,42)||!Lt(r.lastToken,n)){this.popStack();return}let i=[],s=this.processCIdentifier(this.macros,!0)||this.processVariadic();for(;s;)i.push(s),!U(this.currentToken,24)&&!U(this.currentToken,43)?this._issues.push(G(28,s.rangeTokens,s)):U(this.currentToken,43)||(n=this.moveToNextToken),s=this.processCIdentifier(this.macros,!0)||this.processVariadic();let o=new Jn(r,i);if(U(this.currentToken,43))n=this.moveToNextToken,o.lastToken=n;else{o.lastToken=this.prevToken;let a=i.at(-1)??o;this._issues.push(G(26,a.rangeTokens,a))}return this.mergeStack(),o}processVariadic(){this.enqueueToStack();let r=this.checkConcurrentTokens([je(45),je(45),je(45)]);if(r.length!==3){this.popStack();return}let n=new ff(W(r[0],r.at(-1)));return this.mergeStack(),n}processIfDefBlocks(){let r=this.peekIndex(),n=this.parseScopedBlock(o=>!!o&&[33,34,32].some(a=>U(o,a))&&!En(o.prevToken,o),o=>!!o&&[37].some(a=>U(o,a))&&!En(o.prevToken,o),o=>!!o&&[36,35].some(a=>U(o,a))&&!En(o.prevToken,o));if(!n)return;let i;U(n.startToken,32)?i=this.processIfBlock(n,(o,a,c)=>new yf(o,a??null,c)):i=this.processIfDefBlock(n,(o,a,c)=>U(n.startToken,33)?new Rc(o,a??null,c):new vf(o,a??null,c)),this.nodes.push(i),i.getInValidTokenRange(this.macros,this.tokens).reverse().forEach(o=>{this.tokens.splice(o.start,o.end-o.start+1)}),[...i instanceof es?i.ifBlocks:[i.ifDef],...i.elseOption?[i.elseOption]:[]].forEach(o=>{!o.active&&o.content&&this._issues.push(G(47,o.content.rangeTokens,o.content,{severity:kc.DiagnosticSeverity.Hint,tags:[kc.DiagnosticTag.Unnecessary]}))}),this.positionStack[this.positionStack.length-1]=r}processIfDefBlock(r,n){this.enqueueToStack(),this.macroStart=!0;let i=new ht(W(r.startToken));r.splitTokens[0].rewind();let s=this.processCIdentifier(this.macros,!0);s||this._issues.push(G(31,i.rangeTokens,i)),this.macroStart=!1;let o,a=s?.lastToken.nextToken??i.lastToken.nextToken;a&&r.splitTokens[0].tokens.find(f=>f===a)&&(o=new Us(W(a,r.splitTokens[0].tokens.at(-1))));let c=n(i,s??null,o??null),l;if(r.splitTokens.length>1){let f=r.splitTokens[1].tokens[0].prevToken,p=new ht(W(f)),g;r.splitTokens[1].tokens.length&&(g=new Us(W(r.splitTokens[1].tokens[0],r.splitTokens[1].tokens.at(-1)))),l=new Pc(p,g??null)}let u;r.endToken?u=new ht(W(r.endToken)):this._issues.push(G(46,i.rangeTokens,i));let d=new Zi(c,u??null,l);return this.mergeStack(),d}processIfBlock(r,n){this.enqueueToStack();let i=new ht(W(r.startToken)),s=[],o;r.splitTokens.forEach((l,u)=>{l.rewind();let d=this.prevToken,f=new ht(W(d));this.macroStart=!0;let p=this.processExpression(this.macros,f,!0)||this.processCIdentifier(this.macros,!0);if(this.macroStart=!1,u===r.splitTokens.length-1&&U(d,36)){let h=d,v=new ht(W(h)),S;l.tokens.length&&(S=new Us(W(l.tokens[0],l.tokens.at(-1)))),o=new Pc(v,S??null)}else{p||this._issues.push(G(31,i.rangeTokens,i));let h,v=p?.lastToken.nextToken??i.lastToken.nextToken;v&&l.tokens.find(_=>_===v)&&(h=new Us(W(v,r.splitTokens[u].tokens.at(-1))));let S=n(f,p??null,h??null);s.push(S)}});let a;r.endToken?a=new ht(W(r.endToken)):this._issues.push(G(46,i.rangeTokens,i));let c=new es(s,a??null,o);return this.mergeStack(),c}get allAstItems(){return[...this.dtsIncludes,...this.nodes,...this.comments]}resolveInclude(r){if(r.path.path)return r.path.relative?[(0,Yo.resolve)((0,Yo.dirname)(r.uri),r.path.path),...this.incudes.map(n=>(0,Yo.resolve)(n,r.path.path))].find(n=>(0,Fy.existsSync)(n)):this.incudes.map(n=>(0,Yo.resolve)(n,r.path.path)).find(n=>(0,Fy.existsSync)(n))}async processInclude(){this.enqueueToStack();let r=this.peekIndex(),n=this.currentToken;if(!n)return this.popStack(),!1;let i=n,s=n;if(U(n,26))this.moveToNextToken;else{let h=this.checkConcurrentTokens([je(13),rt("include"),je(13)]);if(h.length!==3)return this.popStack(),!1;i=h[0],s=h.at(-1)}let o=i,a=new ht(W(i,s));n=this.moveToNextToken;let c=n,l=!!U(n,21);if(!c||!l&&!U(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&&!U(this.currentToken,4);)u+=this.currentToken?.value??"",n=this.moveToNextToken;let d=new zo(u,l,W(c,n)),f=new Si(a,d);this.dtsIncludes.push(f),l||(this.currentToken?.pos.line!==o.pos.line||!U(this.currentToken,4)?this._issues.push(G(12,f.rangeTokens,f)):(n=this.moveToNextToken,d.lastToken=n)),this.mergeStack();let p=this.peekIndex(),g=this.resolveInclude(f);if(f.resolvedPath=g,g||this._issues.push(G(36,f.path.rangeTokens,f.path,{severity:kc.DiagnosticSeverity.Warning})),g&&!this.skipIncludes){Ar().requestTokens(g,!0);let h=await bc().getCPreprocessorParser(g,this.incudes,this.macros,this.uri);await h.stable,this._issues.push(...h.issues),this.macros.clear(),Array.from(h.macros).forEach(([v,S])=>this.macros.set(v,S)),g.endsWith(".h")?this.tokens.splice(r,p-r):this.tokens.splice(r,p-r,...h.tokens),this.nodes.push(...h.nodes),this.dtsIncludes.push(...h.dtsIncludes)}else this.tokens.splice(r,p-r);return this.positionStack[this.positionStack.length-1]=r,!0}};var Lw=L(j());var Tf=class extends Z{constructor(r,n,i){super();this.keyword=r;this.startAddress=n;this.endAddress=i;this.addChild(r),this.docSymbolsMeta={name:"Memreserve",kind:Lw.SymbolKind.Function},this.addChild(n),this.addChild(i)}toString(){return`/memreserve/ 0x${this.startAddress?.value?.toString(16)} 0x${this.endAddress?.value?.toString(16)}`}};var $w=L(j());var bf=class extends Z{constructor(r,n){super();this.keyword=r;this.bitsSize=n;this.addChild(r),this.docSymbolsMeta={name:"bits",kind:$w.SymbolKind.Function},this.addChild(n)}toString(){return`/bits/ ${this.bitsSize?.value?.toString()}`}};var Hs=class extends Qi{constructor(r,n,i,s,o){super();this.uri=r;this.incudes=n;this.tokens=[];this.others=[];this.rootDocument=new ct;this.unhandledStatements=new St;this.cPreprocessorParser=new Go(this.uri,this.incudes,i,s,o)}get issues(){return[...this._issues,...this.cPreprocessorParser.issues]}getFiles(){return[this.uri,...this.cPreprocessorParser.dtsIncludes.flatMap(r=>r.resolvedPath).filter(r=>!!r)]}reset(){super.reset(),this.others=[],this.rootDocument=new ct,this._issues=[],this.unhandledStatements=new St}async reparse(){let r=performance.now(),n=this.stable;return this.parsing=new Promise(i=>{n.then(async()=>{this.reset(),await this.cPreprocessorParser.reparse(),await this.parse(),console.log("parsing",performance.now()-r),i()})}),this.parsing}async parse(){if(await this.cPreprocessorParser.stable,this.tokens=this.cPreprocessorParser.tokens,tt(this.uri).endsWith(".h")||(this.positionStack.push(0),this.tokens.length===0))return;let r=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)||this.isChildNode(this.unhandledStatements,"Name"))){let s=this.moveToNextToken;s&&(this._issues.push(G(22,W(s),null)),this.reportExtraEndStatements())}};for(;!this.done;)await r();this.unhandledStatements.properties.forEach(s=>{this._issues.push(G(32,s.rangeTokens,s))}),this.unhandledStatements.deleteProperties.forEach(s=>{this._issues.push(G(33,s.rangeTokens,s))});let n=this.allAstItems.flatMap(s=>[s,...s.allDescendants]),i=this.cPreprocessorParser.comments;if(i.length&&n.forEach(s=>{(s instanceof ct||s instanceof Ye)&&vw(s,i)}),this.positionStack.length!==1)throw new Error("Incorrect final stack size")}isRootNodeDefinition(r){this.enqueueToStack();let n=this.moveToNextToken,i=n,s=13;if(!n||!U(n,s))return this.popStack(),!1;if(i=this.moveToNextToken,s=2,!i||!U(i,s))return this.popStack(),!1;let o=new St;o.openScope=i,r.addNodeChild(o),this.processNode(o,"Name");let a=this.nodeEnd(o)??i;return o.firstToken=n,o.lastToken=a,this.mergeStack(),!0}nodeEnd(r){let n=this.currentToken;if(U(n,3))this.moveToNextToken;else{let i=this.prevToken;return i&&this._issues.push(G(3,W(i),r)),this.endStatement(r,!1)}return this.prevToken?.value==="}"&&(r.closeScope=this.prevToken),this.endStatement(r)}isNodeEnd(){return U(this.currentToken,3)||U(this.currentToken,1)}endStatement(r,n=!0){let i=this.currentToken;if(!U(i,1)){let s=this.prevToken;if(s&&n)return this._issues.push(G(1,W(this.prevToken),r)),s}return this.moveToNextToken,this.reportExtraEndStatements(),i}reportExtraEndStatements(){for(;U(this.currentToken,1);){let r=this.moveToNextToken;r&&this._issues.push(G(23,W(r),null))}}processNode(r,n){if(this.done)return!1;let i=!1,s=!1;do{if(s=this.isChildNode(r,n)||this.isProperty(r)||this.isDeleteNode(r,n)||this.isDeleteProperty(r),!s&&!this.isNodeEnd()&&!this.done){let o=this.moveToNextToken;o&&(this._issues.push(G(22,W(o),null)),this.reportExtraEndStatements())}else if(this.done)break;i=i||s}while(!this.isNodeEnd());return i}processOptionalLabelAssign(r=!1){let n=[],i=this.isLabelAssign(r);for(;i;)n.push(i),i=this.isLabelAssign(r);return n}isChildNode(r,n){this.enqueueToStack();let i;n==="Name"&&(i=this.isOmitIfNoRefNode());let s=this.processOptionalLabelAssign(),o,a,c=n==="Ref"?new Wt(s):new Ue(s,i);if(n==="Ref"?(this.enqueueToStack(),a=this.processNodePathRef(c),!a||!U(this.currentToken,2)?(this.popStack(),a=void 0):this.mergeStack(),a??=this.isLabelRef(c)):n==="Name"&&(o=this.isNodeName()),!a&&!o){if(!U(this.currentToken,2))return this.popStack(),!1;c.firstToken=this.currentToken,this._issues.push(G(n==="Name"?[7]:[10,48,11],W(c.firstToken,this.currentToken?.nextToken),c))}let l=!1;if(a&&c instanceof Wt?(c.reference=a,l=!0):o&&c instanceof Ue&&(l=o.address!==void 0,c.name=o),U(this.currentToken,2)){c.openScope=this.moveToNextToken;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(G(2,u.rangeTokens,u))}else return this.popStack(),!1;return r.addNodeChild(c),this.mergeStack(),!0}processNodeAddress(r){let n=this.prevToken;this.enqueueToStack();let i=this.checkConcurrentTokens([rt("0"),rt("x",!0)]);i.length!==2?(i=[],this.popStack()):(this._issues.push(G(50,W(i[0],i[1]),r,{severity:_f.DiagnosticSeverity.Warning})),n=i.at(-1),this.mergeStack());let s=this.consumeAnyConcurrentTokens([19,20,48].map(je)),o=l=>{l.length%8!==0&&(l=l.padStart(Math.ceil(l.length/8)*8,"0"));let u=[];for(let d=0;d<l.length;d+=8){let f=l.slice(d,d+8);u.push(parseInt(f,16)>>>0)}return u},a=s.length?o(s.filter(l=>l.value!=="_").map(l=>l.value).join("")):[NaN];return n&&(a.some(l=>Number.isNaN(l))?this._issues.push(G(8,W(n),r)):!Number.isNaN(a)&&!Lt(n,s[0])&&this._issues.push(G(29,W(n,s.at(0)),r,{inclusiveStart:!1,inclusiveEnd:!1}))),this.currentToken?.value.toUpperCase()==="ULL"&&(this._issues.push(G(51,W(this.currentToken),r,{severity:_f.DiagnosticSeverity.Warning})),this.moveToNextToken),new vc(a,W(i.at(0)??s[0]??this.prevToken,this.prevToken))}processNodeAddresses(r){this.enqueueToStack();let n=this.checkConcurrentTokens([je(49)]);if(n.length){Lt(r.lastToken,n[0])||this._issues.push(G(29,W(r.lastToken,n[0]),r,{inclusiveStart:!1,inclusiveEnd:!1}));let i=[],s=()=>{i.push(this.processNodeAddress(r)),U(this.currentToken,24)&&(this.prevToken&&!Lt(this.prevToken,this.currentToken)&&this._issues.push(G(29,W(this.prevToken,this.currentToken),r,{inclusiveStart:!1,inclusiveEnd:!1})),this.moveToNextToken,s())};s();let o=this.currentToken;for(;!U(this.currentToken,2)&&!U(this.currentToken,1)&&!U(this.currentToken,3)&&En(this.currentToken,i.at(-1)?.lastToken);)this.moveToNextToken;if(o&&o!==this.currentToken){this._issues.push(G(52,W(o,this.currentToken),r));let a=new vc([],W(o,this.prevToken));i.push(a)}return this.mergeStack(),i}this.popStack()}isNodeName(){this.enqueueToStack();let r=this.consumeAnyConcurrentTokens([19,47,24,45,48,15,16].map(je));if(!r.length){this.popStack();return}let n=r.map(o=>o.value).join(""),i=new He(n,W(r[0],r.at(-1))),s=this.processNodeAddresses(i);return i.address=s,n.match(/^[A-Za-z]/)||this._issues.push(G(49,i.rangeTokens,i)),this.mergeStack(),i}isPropertyName(){this.enqueueToStack();let r=this.consumeAnyConcurrentTokens([19,47,24,45,48,15,16,44,46].map(je));if(!r.length){this.popStack();return}let n=new Qe(r.map(i=>i.value).join(""),W(r[0],r.at(-1)));return this.mergeStack(),n}isLabelName(){this.enqueueToStack();let r=this.consumeAnyConcurrentTokens([19,47,48].map(je));if(!r.length){this.popStack();return}let n=r.map(s=>s.value).join("");if(!n.match(/^[A-Za-z]/)){this.popStack();return}let i=new er(n,W(r[0],r.at(-1)));return this.mergeStack(),i}isLabelAssign(r){this.enqueueToStack();let n=this.consumeAnyConcurrentTokens([19,47,48].map(je));if(!n.length){this.popStack();return}let i=n.map(c=>c.value).join("");if(!i.match(/^[A-Za-z]/)){this.popStack();return}let s=this.currentToken,o=s&&U(s,50),a=new Ji(new er(i,W(n[0],n.at(-1))),W(n[0],o?s:n.at(-1)));if(o){let c=n.at(-1);c&&(s.pos.line!==a.firstToken.pos.line||s.pos.col!==c.pos.colEnd)&&this._issues.push(G(29,W(c,s),a,{inclusiveStart:!1,inclusiveEnd:!1})),this.moveToNextToken}else if(r)this._issues.push(G(24,a.rangeTokens,a));else{this.popStack();return}return this.mergeStack(),a}isProperty(r){this.enqueueToStack();let n=this.processOptionalLabelAssign(),i=this.isPropertyName();if(!i)return this.popStack(),!1;if(U(this.currentToken,2)||U(this.currentToken,49))return this.popStack(),!1;let s=new Ye(i,n),o;U(this.currentToken,0)?(s.assignOperatorToken=this.moveToNextToken,o=this.processValue(r),o?.values.filter(c=>!!c).length||this._issues.push(G(0,s.rangeTokens,s)),s.values=o??null):s.values=void 0;let a=this.endStatement(s);return s.lastToken=a,r.addNodeChild(s),this.mergeStack(),!0}isDtsDocumentVersion(){this.enqueueToStack();let r=this.checkConcurrentTokens([je(13),rt("d"),rt("ts"),je(16),rt("v"),rt("1")]);if(r.length!==6)return this.popStack(),!1;let n=r[0],i=n,s=new ht;s.firstToken=n;let o=new uf(s);if(this.others.push(o),U(this.currentToken,13))i=this.moveToNextToken;else return s.lastToken=r.at(-1),this._issues.push(G(21,o.rangeTokens,o)),this.mergeStack(),!0;return s.lastToken=i,o.lastToken=this.endStatement(o),this.mergeStack(),!0}isMemreserve(){this.enqueueToStack();let r=this.checkConcurrentTokens([je(13),rt("memreserve")]);if(r.length!==2)return this.popStack(),!1;let n=new ht;n.firstToken=r[0];let s=r[0];U(this.currentToken,13)?(s=this.moveToNextToken,n.lastToken=s):(n.lastToken=r.at(-1),this._issues.push(G(21,n.rangeTokens,n)));let o=this.processHex()||this.processDec(),a=o&&(this.processHex()||this.processDec()),c=new Tf(n,o,a);if(this.others.push(c),o||this._issues.push(G(37,n.rangeTokens,n)),!a){let l=o??n;this._issues.push(G(38,l.rangeTokens,c))}return c.lastToken=this.endStatement(c),this.mergeStack(),!0}processBits(){this.enqueueToStack();let r=this.checkConcurrentTokens([je(13),rt("b"),rt("its")]);if(r.length!==3){this.popStack();return}let n=new ht;n.firstToken=r[0];let s=r[0];U(this.currentToken,13)?(s=this.moveToNextToken,n.lastToken=s):(n.lastToken=r.at(-1),this._issues.push(G(21,n.rangeTokens,n)));let o=this.processDec(),a=new bf(n,o);return this.others.push(a),o?o.value!==8&&o.value!==16&&o.value!==32&&o.value!==64&&this._issues.push(G(40,o.rangeTokens,o)):this._issues.push(G(39,n.rangeTokens,n)),this._issues.push(G(41,a.rangeTokens,a,{severity:_f.DiagnosticSeverity.Warning})),this.mergeStack(),a}isOmitIfNoRefNode(){this.enqueueToStack();let r=this.checkConcurrentTokens([je(13),rt("omit"),je(16),rt("if"),je(16),rt("no"),je(16),rt("ref"),je(13)]);if(r.length!==9){this.popStack();return}let n=new ht(W(r[0],r.at(-1)));return this.mergeStack(),n}isDeleteNode(r,n){this.enqueueToStack();let i=this.checkConcurrentTokens([je(13),rt("d"),rt("e"),rt("lete"),je(16),rt("node")]);if(!i.length)return this.popStack(),!1;let s=i[0],o=s,a=new ht;if(a.firstToken=s,i.length===1&&!U(this.currentToken,2)){this._issues.push(G(25,a.rangeTokens,a)),a.lastToken=i.at(-1);let d=new Dr(a);return r.addNodeChild(d),this.mergeStack(),!0}let c=i.map(d=>d.value??"").join("");if(!"/delete-node/".startsWith(c)||c.endsWith("-"))return this.popStack(),!1;a.lastToken=i.at(-1),c!=="/delete-node"?this._issues.push(G(c.startsWith("/delete-n")?34:25,a.rangeTokens,a)):U(this.currentToken,13)?(o=this.moveToNextToken,a.lastToken=o):this._issues.push(G(21,a.rangeTokens,a));let l=new Dr(a);if(En(a.tokenIndexes?.end,s)){let d=this.processNodePathRef(r);d&&n==="Name"&&this._issues.push(G(7,d.rangeTokens,d));let f=d?void 0:this.isLabelRef(r);f&&n==="Name"&&this._issues.push(G(7,f.rangeTokens,f));let p=d||f?void 0:this.isNodeName();p&&n==="Ref"&&this._issues.push(G(10,p.rangeTokens,p)),!d&&!p&&!f&&this._issues.push(G([7,10],l.rangeTokens,l)),l.nodeNameOrRef=d??f??p??null}else n==="Name"?this._issues.push(G(7,a.rangeTokens,a)):n==="Ref"&&this._issues.push(G(10,a.rangeTokens,a));let u=this.endStatement(l);return l.lastToken=u,r.addNodeChild(l),this.mergeStack(),!0}isDeleteProperty(r){this.enqueueToStack();let n=this.checkConcurrentTokens([je(13),rt("d"),rt("e"),rt("lete"),je(16),rt("property")]);if(!n.length)return this.popStack(),!1;let i=n[0],s=i,o=new ht;if(o.firstToken=i,n.length===1&&!U(this.currentToken,2)){this._issues.push(G(25,o.rangeTokens,o)),o.lastToken=n.at(-1);let u=new pt(o);return r.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(G(a.startsWith("/delete-p")?35:25,o.rangeTokens,o)):U(this.currentToken,13)?(s=this.moveToNextToken,o.lastToken=s):this._issues.push(G(21,o.rangeTokens,o));let c=new pt(o);if(En(o.tokenIndexes?.end,i)){let u=this.isPropertyName();u||this._issues.push(G(6,c.rangeTokens,c)),c.propertyName=u??null}else this._issues.push(G(6,o.rangeTokens,o));let l=this.endStatement(c);return c.lastToken=l,r.addNodeChild(c),this.mergeStack(),!0}isNodePathRef(r){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),i=this.processNodePathRef(r);if(!i){this.popStack();return}let s=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&s.push(...this.processOptionalLabelAssign(!0));let o=new Tr(n,i,s);return this.mergeStack(),o}processValue(r){this.enqueueToStack();let i=(()=>{let o=()=>(this.processStringValue()||this.isNodePathRef(r)||this.isLabelRefValue(r)||this.arrayValues(r)||this.processByteStringValue()||this.isExpressionValue(r))??null,a=o();if(!a)return[];let c=[a];for(;!U(this.currentToken,1);){let l=this.prevToken,u=this.currentToken,d,f=U(this.currentToken,24);if(f)d=this.currentToken,this.moveToNextToken;else if(!En(this.prevToken,this.currentToken))break;let p=o();if(u&&p===null&&f){let h=new Z(W(u,this.currentToken));this._issues.push(G(0,h.rangeTokens,h))}if(!f&&p===null)break;if(l&&!f&&p){let h=new Z(W(l));this._issues.push(G(28,h.rangeTokens,h))}let g=c.at(-1);g&&(g.nextValueSeparator??=d),c.push(p)}return c})();if(i.length===0){this.popStack();return}return this.mergeStack(),new lf(i)}processStringValue(){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),n=this.consumeAnyConcurrentTokens([je(21)]);if(!n.length){this.popStack();return}if(n.some(l=>!l?.value))throw new Error("Token must have value");let i=n.map(l=>l.value).join(`
189
- `),s=i;s.match(/["']$/)&&(s=s.slice(1,-1));let o=new ie(s,W(n[0],n.at(-1)));i.match(/["']$/)||this._issues.push(G(i.startsWith('"')?16:17,o.rangeTokens,o));let a=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(a=this.processOptionalLabelAssign(!0));let c=new Tr(r,o,a);return this.mergeStack(),c}arrayValues(r){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),i=this.processBits(),s=this.currentToken;if(U(s,5))this.moveToNextToken;else{this.popStack();return}let o=this.processArrayValues(r)??null;o.openBracket=s;let a=this.processOptionalLabelAssign(!0)??[],c=new Tr(n,o,a,i);if(!U(this.currentToken,4))this._issues.push(G(12,c.rangeTokens,c));else{let u=this.moveToNextToken;o&&(o.closeBracket=u)}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=s,c.lastToken=this.prevToken,c}processByteStringValue(){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),n=this.moveToNextToken,i=n;if(!U(i,11)){this.popStack();return}let s=this.processLabeledValue(()=>this.processHexString()),o=this.processOptionalLabelAssign(!0)??[];s.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(G(15,u.rangeTokens,u))});let a=new _i(s??[]);a.openBracket=i,a.values.length===0&&(a.firstToken=n,this._issues.push(G(14,a.rangeTokens,a)));let c=new Tr(r,a,o);U(this.currentToken,12)?a.closeBracket=this.moveToNextToken:this._issues.push(G(5,c.rangeTokens,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(r){this.enqueueToStack();let n=r(),i=[];if(!n)return this.popStack(),[];for(;n;)i.push(n),n=r();if(i.length){let s=r();s&&i.push(s)}return this.mergeStack(),i}processArrayValues(r){this.enqueueToStack();let n=this.processLabeledValue(()=>this.processRefValue(r,!1)||this.processLabeledHex(!1)||this.processLabeledDec(!1)||this.processLabeledExpression(!0,!1,r)),i=new $t(n);return n.length===0&&(i.firstToken=this.currentToken),this.mergeStack(),i}processLabeledHex(r){this.enqueueToStack();let n=this.processOptionalLabelAssign(r),i=this.processHex();if(!i){this.popStack();return}let s=new Xn(i,n);return this.mergeStack(),s}processHexString(){this.enqueueToStack();let r=this.processOptionalLabelAssign(!1),n=this.checkConcurrentTokens([20,20].map(je));if(!n.length){this.popStack();return}let i=Number.parseInt(n.map(a=>a.value).join(""),16),s=new Zt(i,W(n[0],n.at(-1))),o=new Xn(s,r);return this.mergeStack(),o}processLabeledDec(r){this.enqueueToStack();let n=this.processOptionalLabelAssign(r),i=this.processDec();if(!i){this.popStack();return}let s=new Xn(i,n);return this.mergeStack(),s}processLabeledExpression(r=!0,n=r,i){this.enqueueToStack();let s=[];r&&(s=this.processOptionalLabelAssign(n));let o=this.processExpression(this.cPreprocessorParser.macros,i);if(!o){this.popStack();return}let a=new Xn(o,s);return this.mergeStack(),a}isExpressionValue(r){this.enqueueToStack();let n=this.processOptionalLabelAssign(!1),i=this.processExpression(this.cPreprocessorParser.macros,r);if(!i){this.popStack();return}let s=this.processOptionalLabelAssign(!0),o=new Tr(n,i,s);return this.mergeStack(),o}isLabelRef(r){this.enqueueToStack();let n=this.currentToken;if(!n||!U(n,40)){this.popStack();return}else this.moveToNextToken;let i=this.isLabelName();if(!i){let o=new se(null);return this._issues.push(G(18,W(n),r)),o.firstToken=n,this.mergeStack(),o}n&&(i.firstToken.pos.line!==n.pos.line||i.firstToken.pos.col!==n.pos.colEnd)&&this._issues.push(G(29,W(n,i.firstToken),r,{inclusiveStart:!1,inclusiveEnd:!1}));let s=new se(i);return s.firstToken=n,this.mergeStack(),s}isLabelRefValue(r){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),i=this.isLabelRef(r);if(!i){this.popStack();return}let s=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(s=this.processOptionalLabelAssign(!0));let o=new Tr(n,i,s);return this.mergeStack(),o}processRefValue(r,n){this.enqueueToStack();let i=this.processOptionalLabelAssign(n),s=this.currentToken;if(!s||!U(s,40)){this.popStack();return}let o=this.processNodePathRef(r);if(o!==void 0){let l=new Xn(o,i);return this.mergeStack(),l}let a=this.isLabelRef(r);if(a===void 0){this._issues.push(G([18,9],W(s),r));let l=new Xn(null,i);return l.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),l}let c=new Xn(a,i);return c.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),c}processNodePath(r=!0,n=new Dn){this.enqueueToStack();let i;if(U(this.currentToken,13))i=this.moveToNextToken;else{if(!r){this.popStack();return}this.prevToken&&this._issues.push(G(19,W(this.prevToken),n))}let s=this.isNodeName();if(s||this._issues.push(G(7,W(i??this.prevToken),n)),n.addPath(s??null,i?new Z(W(i)):void 0),r&&!i&&n.children.length===0){this.mergeStack();return}return this.processNodePath(!1,n),this.mergeStack(),n}processNodePathRef(r){this.enqueueToStack();let n=this.moveToNextToken,i=n;if(!U(i,40)){this.popStack();return}let s=this.moveToNextToken;if(i=s,!U(i,2)){this.popStack();return}n&&!Lt(n,s)&&this._issues.push(G(29,W(n,s),r,{inclusiveStart:!1,inclusiveEnd:!1}));let o=this.processNodePath(),a=new nt(o??null),c=this.currentToken??this.prevToken,l=c;return o?.children.forEach((u,d)=>{if(d===o?.children.length-1&&u&&l&&!Lt(u.lastToken,l)){this._issues.push(G(29,W(u.lastToken,l),r,{inclusiveStart:!1,inclusiveEnd:!1}));return}if(d===0&&s&&!Lt(s,u?.firstToken)){this._issues.push(G(29,W(s,u?.firstToken),r,{inclusiveStart:!1,inclusiveEnd:!1}));return}let f=o?.children[d+1];u&&f&&!Lt(u.lastToken,f.firstToken)&&this._issues.push(G(29,W(u.lastToken,f?.firstToken),r,{inclusiveStart:!1,inclusiveEnd:!1}))}),U(c,3)?this.moveToNextToken:this.prevToken&&this._issues.push(G(3,W(this.prevToken),r)),a.firstToken=n,a.lastToken=c??this.prevToken,this.mergeStack(),a}get includes(){return this.allAstItems.filter(r=>r instanceof Si)}get allAstItems(){return[...this.cPreprocessorParser.allAstItems,...this.rootDocument.children,...this.others,...this.unhandledStatements.properties,...this.unhandledStatements.deleteProperties,...this.unhandledStatements.nodes]}};var Gj=async(t,e,r)=>{let n=te.Position.create(t.pos.line,t.pos.col),i=r.find(s=>nn(s,e,n));if(i)return Kn(i,e,n)},jy=t=>{if(t)return t instanceof ct?t:jy(t?.parentNode)},Xo=(t,e,r=0)=>{if(!e||!de(e.uri,t)||!e.parentNode?.uri)return r;let n=jy(e.parentNode);return Xo(t,n,r+1)},Yj=(t,e)=>async r=>{let n=t.filter(a=>!(a instanceof Si)&&!(a instanceof an)&&!(a instanceof on)&&!(a instanceof Zi)),i=await Gj(r.firstToken,e,n);if(!i||i===r||r.allDescendants.some(a=>a===i))return{level:0};let s=jy(i);return{level:Xo(e,s),inAst:i}};async function Fw(t,e){let r=Ae(t.textDocument.uri),n=new Hs(r,[],void 0,()=>new Wo(e,r).tokens,!0);await n.stable;let i=n.issues.filter(s=>Ho(s.raw,r,!1));if(i?.length)throw new te.ResponseError(te.ErrorCodes.InternalError,"Unable to format. File has syntax issues.",i.map(s=>s.diagnostic()));return jw(t,n.allAstItems,r,e.split(`
190
- `))}async function jw(t,e,r,n){let i=Yj(e,r),s=[];s.push(...(await Promise.all(e.flatMap(async a=>await Vw(t,a,r,i,n)))).flat()),t.options.trimTrailingWhitespace&&s.push(...Jj(n,s));let o=Kj(e,n);return o.length?s.filter(a=>!Xj(a.range.start,o)):s}async function Uy(t,e,r){let n=r.split(`
191
- `),i=Ae(t.textDocument.uri),s=await e.getRuntime(),o=s.fileTopMostAsts(i);if(s.includes.filter(c=>de(c.resolvedPath,i)).length>1){let c=[];o.forEach(l=>{c.some(u=>u.firstToken.pos.line===l.firstToken.pos.line&&u.firstToken.pos.col===l.firstToken.pos.col)||c.push(l)}),o=c}return jw(t,o,i,n)}var Kj=(t,e)=>{let r=te.Position.create(e.length-1,e.at(-1)?.length??0),n=[],i;return t.filter(o=>(o instanceof on||o instanceof an)&&/^dts-format (on|off)$/.test(o.toString().trim())).sort((o,a)=>o.firstToken.pos.line-a.firstToken.pos.line).forEach(o=>{let a=o.toString().trim();if(a==="dts-format off")i={start:te.Position.create(o.firstToken.pos.line,o instanceof on?o.firstToken.pos.colEnd:0)};else if(a==="dts-format on"&&i){let c=te.Position.create(o.lastToken.pos.line,o instanceof on?o.lastToken.pos.colEnd-1:e[o.lastToken.pos.line-1].length);n.push(te.Range.create(i.start,c)),i=void 0}}),i&&n.push(te.Range.create(i.start,r)),n};function Bw(t,e){return t.line<e.line?-1:t.line>e.line?1:t.character<e.character?-1:t.character>e.character?1:0}var Xj=(t,e)=>e.some(r=>Bw(t,r.start)>=0&&Bw(t,r.end)<=0),Jj=(t,e)=>{let r=[];return t.forEach((n,i)=>{let s=n.trimEnd();if(s.length!==n.length){let o=te.Range.create(te.Position.create(i,s.length),te.Position.create(i,n.length));e.some(a=>yw(o,a.range))||r.push(te.TextEdit.del(o))}}),r},Nf=(t,e,r=1,n=!1,i=t.prevToken)=>{if(i){let s=t.pos.line-i.pos.line;if(s-r&&(s!==2&&r!==0||r===0||n))return te.TextEdit.replace(te.Range.create(te.Position.create(i.pos.line,i.pos.colEnd),te.Position.create(t.pos.line-(r?1:0),r?e[t.pos.line-(r?1:0)].length:t.pos.col)),"".padEnd(r-(n?1:0),`
192
- `))}else if(t.pos.line)return te.TextEdit.del(te.Range.create(te.Position.create(0,0),te.Position.create(t.pos.line,0)))},Uw=(t,e,r,n="",i=1)=>{let s=t.pos.line===t.prevToken?.pos.line;if(t.prevToken&&s)return te.TextEdit.replace(te.Range.create(te.Position.create(t.prevToken.pos.line,t.prevToken.pos.colEnd),te.Position.create(t.pos.line,t.pos.col)),`${`
193
- `.repeat(i)}${"".padStart(e*r.length,r)}${n}`)},Hy=(t,e,r,n,i="")=>{let s=`${"".padStart(e*r.length,r)}${i}`,o=te.Range.create(te.Position.create(t.pos.line,0),te.Position.create(t.pos.line,t.pos.col)),a=dU(n,o);return s===a?[]:[te.TextEdit.replace(te.Range.create(te.Position.create(t.pos.line,0),te.Position.create(t.pos.line,t.pos.col)),s)]},mt=(t,e,r=1,n=!1)=>{if(!t.nextToken)return[];if(t.nextToken?.pos.line!==t.pos.line){if(n)return[];let i=Nf(t.nextToken,e,0);if(!i)throw new Error("remove new LinesEdit must be defined");return r&&(i.newText=`${"".padEnd(r," ")}${i.newText}`),[i]}return r===0?[te.TextEdit.del(te.Range.create(te.Position.create(t.pos.line,t.pos.colEnd),te.Position.create(t.nextToken.pos.line,t.nextToken.pos.col)))]:t.nextToken.pos.line===t.pos.line&&t.pos.colEnd===t.nextToken.pos.col?[te.TextEdit.insert(te.Position.create(t.nextToken.pos.line,t.nextToken.pos.col),"".padEnd(r," "))]:[te.TextEdit.replace(te.Range.create(te.Position.create(t.pos.line,t.pos.colEnd),te.Position.create(t.nextToken.pos.line,t.nextToken.pos.col)),"".padEnd(r," "))]},wc=(t,e)=>t.slice(1).flatMap(r=>r.firstToken.prevToken?mt(r.firstToken.prevToken,e):[]),Qj=async(t,e,r,n,i,s,o)=>{if(!de(e.uri,r))return[];let a=[];if(a.push(...Ir(e.firstToken,n,i,s,void 0,e.firstToken.prevToken?.value==="{"&&!e.topComment||e.topComment?1:2,!0)),e instanceof Ue||e instanceof Wt)if(a.push(...wc(e.labels,s)),e instanceof Ue){e.labels.length&&e.name&&e.name.firstToken.prevToken&&a.push(...mt(e.name.firstToken.prevToken,s));let c=e.name&&e.openScope?mt(e.name.lastToken,s):[];a.push(...c)}else{e.labels.length&&e.reference?.firstToken.prevToken&&a.push(...mt(e.reference.firstToken.prevToken,s));let c=e.reference&&e.openScope?mt(e.reference.lastToken,s):[];a.push(...c)}else e instanceof St&&e.firstToken.value==="/"&&e.openScope&&a.push(...mt(e.firstToken,s,1));return a.push(...(await Promise.all(e.children.flatMap(c=>Vw(t,c,r,o,s,n+1)))).flat()),e.closeScope&&(e.openScope&&e.closeScope.prevToken===e.openScope?a.push(...mt(e.openScope,s,0)):a.push(...Ir(e.closeScope,n,i,s,void 0,1,!0))),e.lastToken.value===";"&&e.closeScope&&a.push(...Ec(e.closeScope,e.lastToken)),a},Zj=(t,e,r,n,i,s)=>{let o=[];if(o.push(...wc(e.labels,s)),e.labels.length&&e.value?.firstToken.prevToken&&o.push(...mt(e.value.firstToken.prevToken,s)),e.firstToken.prevToken)if(e.firstToken.pos.line!==e.firstToken.prevToken?.pos.line&&e.firstToken.prevToken!==i){let a=Nf(e.firstToken,s,1,!0);a&&o.push(a),o.push(...Hy(e.firstToken,r,n.singleIndent,s,Ko(n,t+4)))}else o.push(...mt(e.firstToken.prevToken,s,i&&e.firstToken.prevToken===i?0:1));return e.value instanceof we&&o.push(...Sf(e.value,s,r,n,t+4)),o},eU=(t,e,r,n,i)=>{let s=[];return e instanceof $t||e instanceof _i?e.openBracket&&e.openBracket?.nextToken===e.closeBracket?s.push(...mt(e.openBracket,i,0)):(s.push(...e.values.flatMap(o=>Zj(t,o,r,n,e.openBracket,i))),e.closeBracket?.prevToken&&(e.values.at(-1)?.lastToken===e.closeBracket?.prevToken||e.closeBracket?.prevToken.value==="/"&&e.closeBracket?.prevToken?.prevToken?.value==="*"?s.push(...mt(e.closeBracket.prevToken,i,e.closeBracket.prevToken===e.values.at(-1)?.lastToken?0:1)):s.push(...Ir(e.closeBracket,r,n.singleIndent,i)))):e instanceof we&&s.push(...Sf(e,i,r,n,t)),s},Sf=(t,e,r,n,i)=>t instanceof Ti?tU(t,e):t instanceof Gn?rU(t,e,r,n,i):[],tU=(t,e)=>{let r=[];return r.push(...mt(t.functionName.lastToken,e,0)),t.params.forEach((n,i)=>{n?.firstToken.prevToken&&r.push(...mt(n?.firstToken.prevToken,e,i?1:0)),n?.splitToken&&r.push(...Ec(n.lastToken,n.splitToken))}),t.lastToken.value===")"&&t.lastToken.prevToken&&r.push(...mt(t.lastToken.prevToken,e,0)),r},rU=(t,e,r,n,i)=>{let s=[];return t.openBracket&&t.openBracket.nextToken&&(t.openBracket.pos.line===t.openBracket.nextToken.pos.line?s.push(...mt(t.openBracket,e,0)):s.push(...Ir(t.openBracket,r,n.singleIndent,e,Ko(n,i)))),s.push(...Sf(t.expression,e,r,n,i)),t.join?.forEach(o=>{o.operator.firstToken.prevToken&&s.push(...mt(o.operator.firstToken.prevToken,e)),o.expression.firstToken.prevToken?.pos.line===o.expression.firstToken.pos.line?s.push(...mt(o.expression.firstToken.prevToken,e)):s.push(...Ir(o.expression.firstToken,r,n.singleIndent,e,Ko(n,i))),s.push(...Sf(o.expression,e,r,n,i))}),!t.join?.length&&!(t.expression instanceof Gn)&&(t.expression instanceof Ti||t.expression instanceof Ct)&&(t.openBracket&&s.push(te.TextEdit.del(te.Range.create(te.Position.create(t.openBracket.pos.line,t.openBracket.pos.col),te.Position.create(t.openBracket.pos.line,t.openBracket.pos.colEnd)))),t.closeBracket&&s.push(te.TextEdit.del(te.Range.create(te.Position.create(t.closeBracket.pos.line,t.closeBracket.pos.col),te.Position.create(t.closeBracket.pos.line,t.closeBracket.pos.colEnd))))),t.closeBracket&&t.closeBracket.prevToken&&s.push(...mt(t.closeBracket.prevToken,e,0)),s},nU=(t,e,r,n,i)=>{let s=[];return s.push(...wc(e.startLabels,i)),s.push(...eU(t,e.value,r,n,i)),s.push(...wc(e.endLabels,i)),s},Ko=(t,e)=>{if(t.insertSpaces)return"".padStart(e," ");let r=Math.floor(e/t.tabSize),n=e%t.tabSize;return`${"".padStart(r," ")}${"".padStart(n," ")}`},iU=(t,e,r,n,i,s)=>{let o=[];return e.values.forEach((a,c)=>{if(!a)return[];let l=a.firstToken.prevToken,u=c?e.values.at(c-1):void 0;if(l)if(l.pos.line===a.firstToken.pos.line)if(l.value===","&&u?.lastToken.pos.line!==a.firstToken.pos.line&&l.prevToken?.pos.line!==a.firstToken.pos.line){let d=Uw(a.firstToken,r,n.singleIndent,Ko(n,t+3));d&&o.push(d)}else o.push(...mt(l,i,1));else if(s&&a.firstToken.prevToken===s)o.push(...mt(s,i));else{let d=Nf(a.firstToken,i,1,!0);d&&o.push(d),o.push(...Hy(a.firstToken,r,n.singleIndent,i,Ko(n,t+3)))}o.push(...nU(t,a,r,n,i)),a.nextValueSeparator&&o.push(...Ec(a.lastToken,a.nextValueSeparator))}),o},sU=(t,e,r,n,i)=>{if(!de(t.uri,i))return[];let s=[];return s.push(...Ir(t.firstToken,e,r.singleIndent,n,void 0,void 0,t.firstToken.prevToken?.value==="{")),s.push(...wc(t.labels,n)),t.labels.length&&t.propertyName?.firstToken.prevToken&&s.push(...mt(t.propertyName.firstToken.prevToken,n)),t.values&&(t.propertyName&&s.push(...mt(t.propertyName?.lastToken,n)),s.push(...iU(t.propertyName?.name.length??0,t.values,e,r,n,t.assignOperatorToken))),t.lastToken.value===";"&&s.push(...Ec(t.children.at(-1).lastToken,t.lastToken)),s},Ir=(t,e,r,n,i,s,o)=>{let a=[],c=Uw(t,e,r,i,s);if(c)a.push(c);else{let l=Nf(t,n,s,o);l&&a.push(l),a.push(...Hy(t,e,r,n,i))}return a},Ec=(t,e)=>t.pos.line===e.pos.line&&t.pos.colEnd+1===e.pos.colEnd?[]:t.nextToken===e?[te.TextEdit.replace(te.Range.create(te.Position.create(t.pos.line,t.pos.colEnd),te.Position.create(e.pos.line,e.pos.colEnd)),e.value)]:[te.TextEdit.insert(te.Position.create(t.pos.line,t.pos.colEnd),e.value),te.TextEdit.del(te.Range.create(te.Position.create(e.prevToken?.pos.line??e.pos.line,e.prevToken?.pos.colEnd??e.pos.col),te.Position.create(e.pos.line,e.pos.colEnd)))],oU=(t,e,r,n)=>{let i=[];i.push(...Ir(t.firstToken,e,r,n));let s=mt(t.keyword.lastToken,n);return i.push(...s),t.lastToken.value===";"&&i.push(...Ec(t.children.at(-1).lastToken,t.lastToken)),i},aU=(t,e,r,n,i)=>{if(r===void 0)return[];if(!de(t.uri,e))return[];let s=[];s.push(...Ir(t.firstToken,r.level,n,i));let o=mt(t.keyword.lastToken,i);return s.push(...o),s},cU=(t,e,r,n,i)=>t.comments.length===1&&t.firstToken.pos.line===t.firstToken.prevToken?.pos.line?[]:t.comments.flatMap((s,o)=>lU(s,t,e,r,n,o?o===t.comments.length-1?"last":"comment":"first",i)),Hw=(t,e,r="")=>{let n=e?xy(e):void 0;if(!n)return r;let i=js(e),s=n.propertyName?.name.length??0;return`${`${Ko(t,s+(i?4:3)+(r.length-r.trimStart().length))}`}${r.trimStart()}`},lU=(t,e,r,n,i,s,o)=>{if(!t.firstToken.prevToken)return Ir(t.firstToken,r?.level??0,n,i);if(t.firstToken.pos.line===t.firstToken.prevToken?.pos.line)return mt(t.firstToken.prevToken,i,1);if(r===void 0)return[];let a,c;s==="first"&&!e.astBeforeComment&&e.astAfterComment instanceof ct&&(a=!0,c=e.firstToken.prevToken?.value==="{"?1:2);let l=[],u="",d=t.toString();switch(s==="last"&&d.trim()!==""&&t.lastToken.prevToken&&(s="comment",l.push(...Ir(t.lastToken.prevToken,r?.level??0,n,i," "))),s){case"comment":u=t.firstToken.value==="*"?" ":" * ";break;case"first":break;case"last":u=" ";break}return r?.inAst instanceof ct?l.push(...Ir(t.firstToken,r?.level??0,n,i,u,c,a)):l.push(...Ir(t.firstToken,r?.level??0,n,i,Hw(o,r?.inAst,u),c,a)),l},uU=(t,e,r,n,i)=>{if(!t.firstToken.prevToken)return Ir(t.firstToken,e?.level??0,r,n);if(t.firstToken.pos.line===t.firstToken.prevToken.pos.line)return[];let o,a;return!t.astBeforeComment&&t.astAfterComment instanceof ct&&(o=!0,a=t.firstToken.prevToken?.value==="{"?1:2),Ir(t.firstToken,e?.level??0,r,n,Hw(i,e?.inAst),a,o)},Vw=async(t,e,r,n,i,s=0)=>{let o=t.options.tabSize,a=t.options.insertSpaces,c=a?"".padStart(o," "):" ",l={tabSize:o,insertSpaces:a,singleIndent:c};return uw(c),e instanceof ct?Qj(t,e,r,s,c,i,n):e instanceof Ye?sU(e,s,l,i,r):e instanceof vr?oU(e,s,c,i):e instanceof Si?aU(e,r,await n(e),c,i):e instanceof an?uU(e,await n(e),c,i,l):e instanceof on?cU(e,await n(e),c,i,l):[]};function dU(t,e){let r=t[e.start.line],n=t[e.end.line];if(e.start.line===e.end.line)return r.substring(e.start.character,e.end.character);let i=t.slice(e.start.line+1,e.end.line);return[r.substring(e.start.character),...i,n.substring(0,e.end.character)].join(`
189
+ `),s=i;s.match(/["']$/)&&(s=s.slice(1,-1));let o=new ie(s,W(n[0],n.at(-1)));i.match(/["']$/)||this._issues.push(G(i.startsWith('"')?16:17,o.rangeTokens,o));let a=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(a=this.processOptionalLabelAssign(!0));let c=new Tr(r,o,a);return this.mergeStack(),c}arrayValues(r){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),i=this.processBits(),s=this.currentToken;if(U(s,5))this.moveToNextToken;else{this.popStack();return}let o=this.processArrayValues(r)??null;o.openBracket=s;let a=this.processOptionalLabelAssign(!0)??[],c=new Tr(n,o,a,i);if(!U(this.currentToken,4))this._issues.push(G(12,c.rangeTokens,c));else{let u=this.moveToNextToken;o&&(o.closeBracket=u)}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=s,c.lastToken=this.prevToken,c}processByteStringValue(){this.enqueueToStack();let r=this.processOptionalLabelAssign(!0),n=this.moveToNextToken,i=n;if(!U(i,11)){this.popStack();return}let s=this.processLabeledValue(()=>this.processHexString()),o=this.processOptionalLabelAssign(!0)??[];s.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(G(15,u.rangeTokens,u))});let a=new _i(s??[]);a.openBracket=i,a.values.length===0&&(a.firstToken=n,this._issues.push(G(14,a.rangeTokens,a)));let c=new Tr(r,a,o);U(this.currentToken,12)?a.closeBracket=this.moveToNextToken:this._issues.push(G(5,c.rangeTokens,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(r){this.enqueueToStack();let n=r(),i=[];if(!n)return this.popStack(),[];for(;n;)i.push(n),n=r();if(i.length){let s=r();s&&i.push(s)}return this.mergeStack(),i}processArrayValues(r){this.enqueueToStack();let n=this.processLabeledValue(()=>this.processRefValue(r,!1)||this.processLabeledHex(!1)||this.processLabeledDec(!1)||this.processLabeledExpression(!0,!1,r)),i=new $t(n);return n.length===0&&(i.firstToken=this.currentToken),this.mergeStack(),i}processLabeledHex(r){this.enqueueToStack();let n=this.processOptionalLabelAssign(r),i=this.processHex();if(!i){this.popStack();return}let s=new Xn(i,n);return this.mergeStack(),s}processHexString(){this.enqueueToStack();let r=this.processOptionalLabelAssign(!1),n=this.checkConcurrentTokens([20,20].map(je));if(!n.length){this.popStack();return}let i=Number.parseInt(n.map(a=>a.value).join(""),16),s=new Zt(i,W(n[0],n.at(-1))),o=new Xn(s,r);return this.mergeStack(),o}processLabeledDec(r){this.enqueueToStack();let n=this.processOptionalLabelAssign(r),i=this.processDec();if(!i){this.popStack();return}let s=new Xn(i,n);return this.mergeStack(),s}processLabeledExpression(r=!0,n=r,i){this.enqueueToStack();let s=[];r&&(s=this.processOptionalLabelAssign(n));let o=this.processExpression(this.cPreprocessorParser.macros,i);if(!o){this.popStack();return}let a=new Xn(o,s);return this.mergeStack(),a}isExpressionValue(r){this.enqueueToStack();let n=this.processOptionalLabelAssign(!1),i=this.processExpression(this.cPreprocessorParser.macros,r);if(!i){this.popStack();return}let s=this.processOptionalLabelAssign(!0),o=new Tr(n,i,s);return this.mergeStack(),o}isLabelRef(r){this.enqueueToStack();let n=this.currentToken;if(!n||!U(n,40)){this.popStack();return}else this.moveToNextToken;let i=this.isLabelName();if(!i){let o=new se(null);return this._issues.push(G(18,W(n),r)),o.firstToken=n,this.mergeStack(),o}n&&(i.firstToken.pos.line!==n.pos.line||i.firstToken.pos.col!==n.pos.colEnd)&&this._issues.push(G(29,W(n,i.firstToken),r,{inclusiveStart:!1,inclusiveEnd:!1}));let s=new se(i);return s.firstToken=n,this.mergeStack(),s}isLabelRefValue(r){this.enqueueToStack();let n=this.processOptionalLabelAssign(!0),i=this.isLabelRef(r);if(!i){this.popStack();return}let s=[];this.currentToken&&this.currentToken.pos.line===this.currentToken.prevToken?.pos.line&&(s=this.processOptionalLabelAssign(!0));let o=new Tr(n,i,s);return this.mergeStack(),o}processRefValue(r,n){this.enqueueToStack();let i=this.processOptionalLabelAssign(n),s=this.currentToken;if(!s||!U(s,40)){this.popStack();return}let o=this.processNodePathRef(r);if(o!==void 0){let l=new Xn(o,i);return this.mergeStack(),l}let a=this.isLabelRef(r);if(a===void 0){this._issues.push(G([18,9],W(s),r));let l=new Xn(null,i);return l.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),l}let c=new Xn(a,i);return c.firstToken=i.at(0)?.firstToken??s,this.mergeStack(),c}processNodePath(r=!0,n=new Dn){this.enqueueToStack();let i;if(U(this.currentToken,13))i=this.moveToNextToken;else{if(!r){this.popStack();return}this.prevToken&&this._issues.push(G(19,W(this.prevToken),n))}let s=this.isNodeName();if(s||this._issues.push(G(7,W(i??this.prevToken),n)),n.addPath(s??null,i?new Z(W(i)):void 0),r&&!i&&n.children.length===0){this.mergeStack();return}return this.processNodePath(!1,n),this.mergeStack(),n}processNodePathRef(r){this.enqueueToStack();let n=this.moveToNextToken,i=n;if(!U(i,40)){this.popStack();return}let s=this.moveToNextToken;if(i=s,!U(i,2)){this.popStack();return}n&&!Lt(n,s)&&this._issues.push(G(29,W(n,s),r,{inclusiveStart:!1,inclusiveEnd:!1}));let o=this.processNodePath(),a=new nt(o??null),c=this.currentToken??this.prevToken,l=c;return o?.children.forEach((u,d)=>{if(d===o?.children.length-1&&u&&l&&!Lt(u.lastToken,l)){this._issues.push(G(29,W(u.lastToken,l),r,{inclusiveStart:!1,inclusiveEnd:!1}));return}if(d===0&&s&&!Lt(s,u?.firstToken)){this._issues.push(G(29,W(s,u?.firstToken),r,{inclusiveStart:!1,inclusiveEnd:!1}));return}let f=o?.children[d+1];u&&f&&!Lt(u.lastToken,f.firstToken)&&this._issues.push(G(29,W(u.lastToken,f?.firstToken),r,{inclusiveStart:!1,inclusiveEnd:!1}))}),U(c,3)?this.moveToNextToken:this.prevToken&&this._issues.push(G(3,W(this.prevToken),r)),a.firstToken=n,a.lastToken=c??this.prevToken,this.mergeStack(),a}get includes(){return this.allAstItems.filter(r=>r instanceof Si)}get allAstItems(){return[...this.cPreprocessorParser.allAstItems,...this.rootDocument.children,...this.others,...this.unhandledStatements.properties,...this.unhandledStatements.deleteProperties,...this.unhandledStatements.nodes]}};var Gj=async(t,e,r)=>{let n=ee.Position.create(t.pos.line,t.pos.col),i=r.find(s=>nn(s,e,n));if(i)return Kn(i,e,n)},jy=t=>{if(t)return t instanceof ct?t:jy(t?.parentNode)},Xo=(t,e,r=0)=>{if(!e||!de(e.uri,t)||!e.parentNode?.uri)return r;let n=jy(e.parentNode);return Xo(t,n,r+1)},Yj=(t,e)=>async r=>{let n=t.filter(a=>!(a instanceof Si)&&!(a instanceof an)&&!(a instanceof on)&&!(a instanceof Zi)),i=await Gj(r.firstToken,e,n);if(!i||i===r||r.allDescendants.some(a=>a===i))return{level:0};let s=jy(i);return{level:Xo(e,s),inAst:i}};async function Fw(t,e){let r=Ae(t.textDocument.uri),n=new Hs(r,[],void 0,()=>new Wo(e,r).tokens,!0);await n.stable;let i=n.issues.filter(s=>Ho(s.raw,r,!1));if(i?.length)throw new ee.ResponseError(ee.ErrorCodes.InternalError,"Unable to format. File has syntax issues.",i.map(s=>s.diagnostic()));return jw(t,n.allAstItems,r,e.split(`
190
+ `))}async function jw(t,e,r,n){let i=Yj(e,r),s=[];if(s.push(...(await Promise.all(e.flatMap(async a=>await Vw(t,a,r,i,n)))).flat()),t.options.trimTrailingWhitespace&&s.push(...Jj(n,s)),t.options.insertFinalNewline&&n.at(-1)?.trim()!==""&&s.push(ee.TextEdit.insert(ee.Position.create(n.length,0),`
191
+ `)),t.options.trimFinalNewlines){let a=0;for(;n.at(-(1+a))?.trim()==="";)a++;a>1&&s.push(ee.TextEdit.del(ee.Range.create(ee.Position.create(n.length-a,0),ee.Position.create(n.length-1,0))))}let o=Kj(e,n);return o.length?s.filter(a=>!Xj(a.range.start,o)):s}async function Uy(t,e,r){let n=r.split(`
192
+ `),i=Ae(t.textDocument.uri),s=await e.getRuntime(),o=s.fileTopMostAsts(i);if(s.includes.filter(c=>de(c.resolvedPath,i)).length>1){let c=[];o.forEach(l=>{c.some(u=>u.firstToken.pos.line===l.firstToken.pos.line&&u.firstToken.pos.col===l.firstToken.pos.col)||c.push(l)}),o=c}return jw(t,o,i,n)}var Kj=(t,e)=>{let r=ee.Position.create(e.length-1,e.at(-1)?.length??0),n=[],i;return t.filter(o=>(o instanceof on||o instanceof an)&&/^dts-format (on|off)$/.test(o.toString().trim())).sort((o,a)=>o.firstToken.pos.line-a.firstToken.pos.line).forEach(o=>{let a=o.toString().trim();if(a==="dts-format off")i={start:ee.Position.create(o.firstToken.pos.line,o instanceof on?o.firstToken.pos.colEnd:0)};else if(a==="dts-format on"&&i){let c=ee.Position.create(o.lastToken.pos.line,o instanceof on?o.lastToken.pos.colEnd-1:e[o.lastToken.pos.line-1].length);n.push(ee.Range.create(i.start,c)),i=void 0}}),i&&n.push(ee.Range.create(i.start,r)),n};function Bw(t,e){return t.line<e.line?-1:t.line>e.line?1:t.character<e.character?-1:t.character>e.character?1:0}var Xj=(t,e)=>e.some(r=>Bw(t,r.start)>=0&&Bw(t,r.end)<=0),Jj=(t,e)=>{let r=[];return t.forEach((n,i)=>{let s=n.trimEnd();if(s.length!==n.length){let o=ee.Range.create(ee.Position.create(i,s.length),ee.Position.create(i,n.length));e.some(a=>yw(o,a.range))||r.push(ee.TextEdit.del(o))}}),r},Nf=(t,e,r=1,n=!1,i=t.prevToken)=>{if(i){let s=t.pos.line-i.pos.line;if(s-r&&(s!==2&&r!==0||r===0||n))return ee.TextEdit.replace(ee.Range.create(ee.Position.create(i.pos.line,i.pos.colEnd),ee.Position.create(t.pos.line-(r?1:0),r?e[t.pos.line-(r?1:0)].length:t.pos.col)),"".padEnd(r-(n?1:0),`
193
+ `))}else if(t.pos.line)return ee.TextEdit.del(ee.Range.create(ee.Position.create(0,0),ee.Position.create(t.pos.line,0)))},Uw=(t,e,r,n="",i=1)=>{let s=t.pos.line===t.prevToken?.pos.line;if(t.prevToken&&s)return ee.TextEdit.replace(ee.Range.create(ee.Position.create(t.prevToken.pos.line,t.prevToken.pos.colEnd),ee.Position.create(t.pos.line,t.pos.col)),`${`
194
+ `.repeat(i)}${"".padStart(e*r.length,r)}${n}`)},Hy=(t,e,r,n,i="")=>{let s=`${"".padStart(e*r.length,r)}${i}`,o=ee.Range.create(ee.Position.create(t.pos.line,0),ee.Position.create(t.pos.line,t.pos.col)),a=dU(n,o);return s===a?[]:[ee.TextEdit.replace(ee.Range.create(ee.Position.create(t.pos.line,0),ee.Position.create(t.pos.line,t.pos.col)),s)]},mt=(t,e,r=1,n=!1)=>{if(!t.nextToken)return[];if(t.nextToken?.pos.line!==t.pos.line){if(n)return[];let i=Nf(t.nextToken,e,0);if(!i)throw new Error("remove new LinesEdit must be defined");return r&&(i.newText=`${"".padEnd(r," ")}${i.newText}`),[i]}return r===0?[ee.TextEdit.del(ee.Range.create(ee.Position.create(t.pos.line,t.pos.colEnd),ee.Position.create(t.nextToken.pos.line,t.nextToken.pos.col)))]:t.nextToken.pos.line===t.pos.line&&t.pos.colEnd===t.nextToken.pos.col?[ee.TextEdit.insert(ee.Position.create(t.nextToken.pos.line,t.nextToken.pos.col),"".padEnd(r," "))]:[ee.TextEdit.replace(ee.Range.create(ee.Position.create(t.pos.line,t.pos.colEnd),ee.Position.create(t.nextToken.pos.line,t.nextToken.pos.col)),"".padEnd(r," "))]},wc=(t,e)=>t.slice(1).flatMap(r=>r.firstToken.prevToken?mt(r.firstToken.prevToken,e):[]),Qj=async(t,e,r,n,i,s,o)=>{if(!de(e.uri,r))return[];let a=[];if(a.push(...Ir(e.firstToken,n,i,s,void 0,e.firstToken.prevToken?.value==="{"&&!e.topComment||e.topComment?1:2,!0)),e instanceof Ue||e instanceof Wt)if(a.push(...wc(e.labels,s)),e instanceof Ue){e.labels.length&&e.name&&e.name.firstToken.prevToken&&a.push(...mt(e.name.firstToken.prevToken,s));let c=e.name&&e.openScope?mt(e.name.lastToken,s):[];a.push(...c)}else{e.labels.length&&e.reference?.firstToken.prevToken&&a.push(...mt(e.reference.firstToken.prevToken,s));let c=e.reference&&e.openScope?mt(e.reference.lastToken,s):[];a.push(...c)}else e instanceof St&&e.firstToken.value==="/"&&e.openScope&&a.push(...mt(e.firstToken,s,1));return a.push(...(await Promise.all(e.children.flatMap(c=>Vw(t,c,r,o,s,n+1)))).flat()),e.closeScope&&(e.openScope&&e.closeScope.prevToken===e.openScope?a.push(...mt(e.openScope,s,0)):a.push(...Ir(e.closeScope,n,i,s,void 0,1,!0))),e.lastToken.value===";"&&e.closeScope&&a.push(...Ec(e.closeScope,e.lastToken)),a},Zj=(t,e,r,n,i,s)=>{let o=[];if(o.push(...wc(e.labels,s)),e.labels.length&&e.value?.firstToken.prevToken&&o.push(...mt(e.value.firstToken.prevToken,s)),e.firstToken.prevToken)if(e.firstToken.pos.line!==e.firstToken.prevToken?.pos.line&&e.firstToken.prevToken!==i){let a=Nf(e.firstToken,s,1,!0);a&&o.push(a),o.push(...Hy(e.firstToken,r,n.singleIndent,s,Ko(n,t+4)))}else o.push(...mt(e.firstToken.prevToken,s,i&&e.firstToken.prevToken===i?0:1));return e.value instanceof we&&o.push(...Sf(e.value,s,r,n,t+4)),o},eU=(t,e,r,n,i)=>{let s=[];return e instanceof $t||e instanceof _i?e.openBracket&&e.openBracket?.nextToken===e.closeBracket?s.push(...mt(e.openBracket,i,0)):(s.push(...e.values.flatMap(o=>Zj(t,o,r,n,e.openBracket,i))),e.closeBracket?.prevToken&&(e.values.at(-1)?.lastToken===e.closeBracket?.prevToken||e.closeBracket?.prevToken.value==="/"&&e.closeBracket?.prevToken?.prevToken?.value==="*"?s.push(...mt(e.closeBracket.prevToken,i,e.closeBracket.prevToken===e.values.at(-1)?.lastToken?0:1)):s.push(...Ir(e.closeBracket,r,n.singleIndent,i)))):e instanceof we&&s.push(...Sf(e,i,r,n,t)),s},Sf=(t,e,r,n,i)=>t instanceof Ti?tU(t,e):t instanceof Gn?rU(t,e,r,n,i):[],tU=(t,e)=>{let r=[];return r.push(...mt(t.functionName.lastToken,e,0)),t.params.forEach((n,i)=>{n?.firstToken.prevToken&&r.push(...mt(n?.firstToken.prevToken,e,i?1:0)),n?.splitToken&&r.push(...Ec(n.lastToken,n.splitToken))}),t.lastToken.value===")"&&t.lastToken.prevToken&&r.push(...mt(t.lastToken.prevToken,e,0)),r},rU=(t,e,r,n,i)=>{let s=[];return t.openBracket&&t.openBracket.nextToken&&(t.openBracket.pos.line===t.openBracket.nextToken.pos.line?s.push(...mt(t.openBracket,e,0)):s.push(...Ir(t.openBracket,r,n.singleIndent,e,Ko(n,i)))),s.push(...Sf(t.expression,e,r,n,i)),t.join?.forEach(o=>{o.operator.firstToken.prevToken&&s.push(...mt(o.operator.firstToken.prevToken,e)),o.expression.firstToken.prevToken?.pos.line===o.expression.firstToken.pos.line?s.push(...mt(o.expression.firstToken.prevToken,e)):s.push(...Ir(o.expression.firstToken,r,n.singleIndent,e,Ko(n,i))),s.push(...Sf(o.expression,e,r,n,i))}),!t.join?.length&&!(t.expression instanceof Gn)&&(t.expression instanceof Ti||t.expression instanceof Ct)&&(t.openBracket&&s.push(ee.TextEdit.del(ee.Range.create(ee.Position.create(t.openBracket.pos.line,t.openBracket.pos.col),ee.Position.create(t.openBracket.pos.line,t.openBracket.pos.colEnd)))),t.closeBracket&&s.push(ee.TextEdit.del(ee.Range.create(ee.Position.create(t.closeBracket.pos.line,t.closeBracket.pos.col),ee.Position.create(t.closeBracket.pos.line,t.closeBracket.pos.colEnd))))),t.closeBracket&&t.closeBracket.prevToken&&s.push(...mt(t.closeBracket.prevToken,e,0)),s},nU=(t,e,r,n,i)=>{let s=[];return s.push(...wc(e.startLabels,i)),s.push(...eU(t,e.value,r,n,i)),s.push(...wc(e.endLabels,i)),s},Ko=(t,e)=>{if(t.insertSpaces)return"".padStart(e," ");let r=Math.floor(e/t.tabSize),n=e%t.tabSize;return`${"".padStart(r," ")}${"".padStart(n," ")}`},iU=(t,e,r,n,i,s)=>{let o=[];return e.values.forEach((a,c)=>{if(!a)return[];let l=a.firstToken.prevToken,u=c?e.values.at(c-1):void 0;if(l)if(l.pos.line===a.firstToken.pos.line)if(l.value===","&&u?.lastToken.pos.line!==a.firstToken.pos.line&&l.prevToken?.pos.line!==a.firstToken.pos.line){let d=Uw(a.firstToken,r,n.singleIndent,Ko(n,t+3));d&&o.push(d)}else o.push(...mt(l,i,1));else if(s&&a.firstToken.prevToken===s)o.push(...mt(s,i));else{let d=Nf(a.firstToken,i,1,!0);d&&o.push(d),o.push(...Hy(a.firstToken,r,n.singleIndent,i,Ko(n,t+3)))}o.push(...nU(t,a,r,n,i)),a.nextValueSeparator&&o.push(...Ec(a.lastToken,a.nextValueSeparator))}),o},sU=(t,e,r,n,i)=>{if(!de(t.uri,i))return[];let s=[];return s.push(...Ir(t.firstToken,e,r.singleIndent,n,void 0,void 0,t.firstToken.prevToken?.value==="{")),s.push(...wc(t.labels,n)),t.labels.length&&t.propertyName?.firstToken.prevToken&&s.push(...mt(t.propertyName.firstToken.prevToken,n)),t.values&&(t.propertyName&&s.push(...mt(t.propertyName?.lastToken,n)),s.push(...iU(t.propertyName?.name.length??0,t.values,e,r,n,t.assignOperatorToken))),t.lastToken.value===";"&&s.push(...Ec(t.children.at(-1).lastToken,t.lastToken)),s},Ir=(t,e,r,n,i,s,o)=>{let a=[],c=Uw(t,e,r,i,s);if(c)a.push(c);else{let l=Nf(t,n,s,o);l&&a.push(l),a.push(...Hy(t,e,r,n,i))}return a},Ec=(t,e)=>t.pos.line===e.pos.line&&t.pos.colEnd+1===e.pos.colEnd?[]:t.nextToken===e?[ee.TextEdit.replace(ee.Range.create(ee.Position.create(t.pos.line,t.pos.colEnd),ee.Position.create(e.pos.line,e.pos.colEnd)),e.value)]:[ee.TextEdit.insert(ee.Position.create(t.pos.line,t.pos.colEnd),e.value),ee.TextEdit.del(ee.Range.create(ee.Position.create(e.prevToken?.pos.line??e.pos.line,e.prevToken?.pos.colEnd??e.pos.col),ee.Position.create(e.pos.line,e.pos.colEnd)))],oU=(t,e,r,n)=>{let i=[];i.push(...Ir(t.firstToken,e,r,n));let s=mt(t.keyword.lastToken,n);return i.push(...s),t.lastToken.value===";"&&i.push(...Ec(t.children.at(-1).lastToken,t.lastToken)),i},aU=(t,e,r,n,i)=>{if(r===void 0)return[];if(!de(t.uri,e))return[];let s=[];s.push(...Ir(t.firstToken,r.level,n,i));let o=mt(t.keyword.lastToken,i);return s.push(...o),s},cU=(t,e,r,n,i)=>t.comments.length===1&&t.firstToken.pos.line===t.firstToken.prevToken?.pos.line?[]:t.comments.flatMap((s,o)=>lU(s,t,e,r,n,o?o===t.comments.length-1?"last":"comment":"first",i)),Hw=(t,e,r="")=>{let n=e?xy(e):void 0;if(!n)return r;let i=js(e),s=n.propertyName?.name.length??0;return`${`${Ko(t,s+(i?4:3)+(r.length-r.trimStart().length))}`}${r.trimStart()}`},lU=(t,e,r,n,i,s,o)=>{if(!t.firstToken.prevToken)return Ir(t.firstToken,r?.level??0,n,i);if(t.firstToken.pos.line===t.firstToken.prevToken?.pos.line)return mt(t.firstToken.prevToken,i,1);if(r===void 0)return[];let a,c;s==="first"&&!e.astBeforeComment&&e.astAfterComment instanceof ct&&(a=!0,c=e.firstToken.prevToken?.value==="{"?1:2);let l=[],u="",d=t.toString();switch(s==="last"&&d.trim()!==""&&t.lastToken.prevToken&&(s="comment",l.push(...Ir(t.lastToken.prevToken,r?.level??0,n,i," "))),s){case"comment":u=t.firstToken.value==="*"?" ":" * ";break;case"first":break;case"last":u=" ";break}return r?.inAst instanceof ct?l.push(...Ir(t.firstToken,r?.level??0,n,i,u,c,a)):l.push(...Ir(t.firstToken,r?.level??0,n,i,Hw(o,r?.inAst,u),c,a)),l},uU=(t,e,r,n,i)=>{if(!t.firstToken.prevToken)return Ir(t.firstToken,e?.level??0,r,n);if(t.firstToken.pos.line===t.firstToken.prevToken.pos.line)return[];let o,a;return!t.astBeforeComment&&t.astAfterComment instanceof ct&&(o=!0,a=t.firstToken.prevToken?.value==="{"?1:2),Ir(t.firstToken,e?.level??0,r,n,Hw(i,e?.inAst),a,o)},Vw=async(t,e,r,n,i,s=0)=>{let o=t.options.tabSize,a=t.options.insertSpaces,c=a?"".padStart(o," "):" ",l={tabSize:o,insertSpaces:a,singleIndent:c};return uw(c),e instanceof ct?Qj(t,e,r,s,c,i,n):e instanceof Ye?sU(e,s,l,i,r):e instanceof vr?oU(e,s,c,i):e instanceof Si?aU(e,r,await n(e),c,i):e instanceof an?uU(e,await n(e),c,i,l):e instanceof on?cU(e,await n(e),c,i,l):[]};function dU(t,e){let r=t[e.start.line],n=t[e.end.line];if(e.start.line===e.end.line)return r.substring(e.start.character,e.end.character);let i=t.slice(e.start.line+1,e.end.line);return[r.substring(e.start.character),...i,n.substring(0,e.end.character)].join(`
194
195
  `)}function fU(t){switch(t){case"EMPTY":return"EMPTY";case"U32":return"U32";case"U64":return"U64";case"STRING":return"STRING";case"PROP_ENCODED_ARRAY":return"PROP_ENCODED_ARRAY";case"STRINGLIST":return"STRINGLIST";case"BYTESTRING":return"BYTESTRING";case"ANY":return"ANY";case"UNKNOWN":return"UNKNOWN"}}var X=class{constructor(e,r,n="optional",i=void 0,s,o){this.name=e;this.type=r;this.def=i;this.additionalTypeCheck=o;this.hideAutoComplete=!1;this.list=!1;this.onHover=()=>({kind:wt.MarkupKind.Markdown,value:["### Type","**DTS native type** ",`${this.type.map(e=>e.types.map(fU).join(" or ")).join(",")}
195
196
 
196
197
  `,...this.bindingType?["**Binding type** ",`${this.bindingType}
@@ -282,7 +283,7 @@ ${" ".repeat(r-1)}}; ${i?" */":""}`}serialize(e){let r=this.mappedReg(e),n=[...t
282
283
  `)}}get allReplaced(){return this.replaces?[this.replaces,...this.replaces.allReplaced]:[]}toString(){return this.ast.toString()}toPrettyString(e){return this.ast.toPrettyString(e)}};var Qn=class t{constructor(e){this.context=e;this.comments=[];this.includes=[];this.roots=[];this.references=[];this.unlinkedDeletes=[];this.unlinkedRefNodes=[];this.globalDeletes=[];this.rootNode=new J(this.context.bindingLoader,"/");this.labelsUsedCache=new Map;this.fileTopMostAstCache=new Map}fileTopMostAsts(e){let r=this.fileTopMostAstCache.get(e);if(r)return r;let n=[...this.context.parser.cPreprocessorParser.allAstItems,...this.roots,...this.references,...this.unlinkedDeletes,...this.unlinkedRefNodes,...this.globalDeletes,...this.context.overlayParsers.flatMap(i=>[...i.cPreprocessorParser.allAstItems,...i.unhandledStatements.children]),...this.context.parser.unhandledStatements.children].flatMap(i=>i.getTopMostAstNodeForFile(e));return this.fileTopMostAstCache.set(e,n),n}getDeepestAstNode(e,r){let i=this.fileTopMostAsts(e).find(s=>nn(s,e,r)||fw(Ar().requestTokens(e,!1),s,r));if(i instanceof Wt){let o=this.rootNode.getReferenceBy(i)?.getDeepestAstNode(e,r);return o?{...o,runtime:this}:{item:null,runtime:this,ast:Kn(i,e,r)}}else if(i instanceof St&&i.path){let s=this.rootNode.getDeepestAstNode(e,r);return s?{...s,runtime:this}:void 0}else if(i instanceof Ue&&i.path){let s=t.getNodeFromPath(i.path.slice(1),this.rootNode)?.getDeepestAstNode(e,r);return s?{...s,runtime:this}:void 0}else if(i)return{runtime:this,item:null,ast:Kn(i,e,r)}}static getNodeFromPath(e,r,n=!0){if(e.length===0)return r;let i=e[0].split("@"),s=i[0],a=i.at(1)?.split(",").map(u=>Number.parseInt(u,16)),c=e.slice(1),l=r.getNode(s,a,n);return l?t.getNodeFromPath(c,l,n):void 0}resolvePath(e,r){if(!e.at(0)?.startsWith("&"))return e;let n=this.labelsUsedCache.get(e[0].slice(1));return n||(r??=this.rootNode.allDescendantsLabels,r.find(s=>s.label.value===e.at(0)?.slice(1)&&s.parentNode instanceof ct)?.lastLinkedTo?.path)}get issues(){return this.issuesCache??=[...this.labelIssues(),...this.rootNode.getIssues(this.context.macros)],this.issuesCache}labelIssues(){let e=[],r=new Map;return this.rootNode.allDescendantsLabelsMapped.forEach(n=>{r.has(n.label.label.value)?r.get(n.label.label.value)?.push(n):r.set(n.label.label.value,[n])}),Array.from(r).forEach(n=>{let i=n[1];if(i.length>1){let s=i.find(a=>a.owner instanceof J);(!i.every(a=>a&&a.owner===s?.owner)||!s)&&e.push(qt(4,i[0].label.rangeTokens,i[0].label,{linkedTo:i.slice(1).map(a=>a.label),templateStrings:[i.at(0).label.label.value]}))}}),e}get typesIssues(){let e=r=>[...r.nodeType?.getIssue(this,r)??[],...r.nodes.flatMap(n=>e(n))];return this.typesIssuesCache??=e(this.rootNode),this.typesIssuesCache}getOrderedNodeAst(e){return pw([...e.definitions,...e.referencedBy],this.context)}};var Mf=class t{constructor(e,r){this.settings=e;this.bindingLoader=r;this._issues=[];this.overlayParsers=[];this.overlays=[];this.ctxNames_=new Set;this.sortKeys=new WeakMap;let n={includePaths:[],overlays:[],zephyrBindings:[],deviceOrgTreeBindings:[],deviceOrgBindingsMetaSchema:[],...e,ctxName:e.ctxName??(0,xC.basename)(e.dtsFile),lockRenameEdits:[]};this.overlays=n.overlays,this.overlays.filter(Oc.existsSync),this.parser=new Hs(n.dtsFile,n.includePaths),this.ctxNames_.add(n.ctxName),this.id=bi(n),this.parser.stable.then(()=>{this.overlayParsers=this.overlays?.map(i=>new Hs(i,n.includePaths,this.parser.cPreprocessorParser.macros))??[]})}get macros(){return[this.parser,...this.overlayParsers].at(-1).cPreprocessorParser.macros}get ctxNames(){return Array.from(this.ctxNames_)}addCtxName(e){this.ctxNames_.add(e)}removeCtxName(e){this.ctxNames_.delete(e)}async getContextIssues(){return[...(await this.getRuntime()).issues,...this._issues]}async getFileTree(){let e=new Map,r=i=>({file:i,includes:(e.get(i)??[]).map(s=>r(s.resolvedPath??s.path))});return(await this.getRuntime()).includes.forEach(i=>{let s=e.get(i.uri);s||(s=[],e.set(i.uri,s)),s.push({path:i.path.path,resolvedPath:i.resolvedPath})}),{mainDtsPath:r(this.parser.uri),overlays:this.overlays.map(r)}}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.flatMap(e=>e.getFiles()),...this.parser.getFiles()]}isInContext(e){return this.getContextFiles().some(r=>de(r,e))}getUriParser(e){let r=this.overlayParsers.find(n=>n.getFiles().some(i=>de(i,e)));return r??=this.parser.getFiles().some(n=>de(n,e))?this.parser:void 0,r}async getAllParsers(){return await this.stable(),[this.parser,...this.overlayParsers]}async getDocumentLinks(e,r){if(!this.isInContext(e))return[];let i=(await this.getRuntime()).rootNode.allBindingsProperties.filter(s=>de(s.ast.uri,e)&&(!r||nn(s.ast,e,r))).flatMap(s=>s.ast.values?.values.flatMap(o=>{let c=s.parent?.nodeTypes.find(l=>o?.value instanceof ie&&l.compatible===o.value.value);return c?{range:fe(o.value),target:ve(c.bindingsPath)}:void 0})).filter(s=>s)??[];return[...this.parser.cPreprocessorParser.dtsIncludes.filter(s=>de(s.uri,e)&&(!r||nn(s,e,r))).map(s=>{let o=this.parser.cPreprocessorParser.resolveInclude(s);if(o)return{range:fe(s.path),target:ve(o)}}).filter(s=>s)??[],...i]}linkPropertiesLabelsAndNodePaths(e){let r=s=>[...s.properties,...s.nodes.flatMap(r)],n=r(e.rootNode),i=e.rootNode.allDescendantsLabels;n.forEach(s=>s.ast.allDescendants.forEach(o=>{if(o instanceof se){let a=e.resolvePath([`&${o.label?.value}`],i);if(a){let c=e.rootNode.getChild(a);o.linksTo=c,c?.linkedRefLabels.push(o)}else o.value&&this._issues.push(qt(3,o.rangeTokens,o,{templateStrings:[o.value]}))}else o instanceof Dn&&this.linkNodePath(o,e.rootNode)}))}linkNodePath(e,r){let n=r,i=e.pathParts;for(let s=0;s<i.length&&i[s];s++){let o=!1,a=i[s];if(a){let c=n?.getNode(a.name,a.fullAddress,!1);a.linksTo=c,!o&&!c&&(o=!0,this._issues.push(qt(8,a.rangeTokens,a,{templateStrings:[a.toString(),`${e.pathParts.filter(l=>l?.linksTo).map(l=>l?.toString()).join("/")}`]}))),c?.linkedNodeNamePaths.push(a),n=c}else break}}async reevaluate(e){let r=this.getUriParser(e);return r?(this.sortKeys=new WeakMap,await r.reparse(),this._runtime=this.evaluate(),this._runtime):this._runtime}getSortKey(e){if(e)return this.sortKeys.get(e.firstToken)}async evaluate(){let e=performance.now();await this.stable();let r=new Qn(this);this._issues=[],this.parser.rootDocument.resetIssues(),this.processRoot(this.parser.rootDocument,r);for(let n=0;n<this.overlayParsers.length;n++)this.overlayParsers[n].rootDocument.resetIssues(),this.processRoot(this.overlayParsers[n].rootDocument,r);return r.includes=this.parser.includes,r.comments=this.parser.cPreprocessorParser.allAstItems.filter(n=>n instanceof an),(await this.getAllParsers()).flatMap(n=>n.tokens).forEach((n,i)=>this.sortKeys.set(n,i)),this.linkPropertiesLabelsAndNodePaths(r),this.reportNodeNameAndPropertyClashes(r),console.log(`(ID: ${this.id}) evaluate`,performance.now()-e),r}reportNodeNameAndPropertyClashes(e){let r=n=>{n.properties.forEach(i=>{n.nodes.filter(o=>o.address===void 0&&o.name===i.ast.propertyName?.name&&o.definitions.at(-1)?.name).forEach(o=>this._issues.push(qt(2,o.definitions.at(-1).name.rangeTokens,o.definitions.at(-1).name,{linkedTo:[i.ast,...i.allReplaced.map(a=>a.ast)]})))}),n.nodes.forEach(r)};r(e.rootNode)}processRoot(e,r){for(let n=0;n<e.children.length;n++){let i=e.children[n];this.processChild(i,r.rootNode,r)}}processChild(e,r,n){e instanceof ct?this.processDtcBaseNode(e,r,n):e instanceof Ye?this.processDtcProperty(e,r,n):e instanceof Dr?this.processDeleteNode(e,r,n):e instanceof pt&&this.processDeleteProperty(e,r,n)}checkNodeUniqueNames(e,r){let n=(o,a)=>o.filter(c=>c.name===a.name&&(c.address===a.fullAddress&&c.address===void 0||rn(c.address??[],a.fullAddress??[])===0)).map(c=>c.issueAst),i=r.nodes.map(o=>({name:o.name,address:o.address,issueAst:o.definitions[0].name??o.definitions[0]})),s=[];e.children.forEach(o=>{if(o instanceof Ue&&o.name){let a=n(s.map(c=>({name:c.name,address:c.fullAddress,issueAst:c})),o.name);a.length&&this._issues.push(qt(2,o.name.rangeTokens,o.name,{linkedTo:a})),s.push(o.name)}else if(o instanceof Dr&&o.nodeNameOrRef instanceof He){let a=o.nodeNameOrRef;n(i,a)&&(s=s.filter(c=>n(s.map(l=>({name:l.name,address:l.fullAddress,issueAst:l})),c).length))}})}getCompileCommands(){if(!(!this.settings.compileCommands||!(0,Oc.existsSync)(this.settings.compileCommands)))return JSON.parse((0,Oc.readFileSync)(this.settings.compileCommands).toString())}processDtcBaseNode(e,r,n){e instanceof St?this.processDtcRootNode(e,n):e instanceof Ue?this.processDtcChildNode(e,r,n):e instanceof Wt&&this.processDtcRefNode(e,n)}processDtcRootNode(e,r){r.roots.push(e),r.rootNode.definitions.push(e),this.checkNodeUniqueNames(e,r.rootNode),e.children.forEach(n=>this.processChild(n,r.rootNode,r))}processDtcChildNode(e,r,n){if(e.name?.name){let i=e.path?n.resolvePath(e.path):void 0,o=(i?n.rootNode.getChild(i):void 0)??new J(this.bindingLoader,e.name.name,e.name.fullAddress,r);o.definitions.push(e),e.labels.forEach(a=>a.lastLinkedTo=o),r=o,this.checkNodeUniqueNames(e,o)}e.children.forEach(i=>this.processChild(i,r,n))}processDtcRefNodeLabelRef(e,r,n){let i,s=e.resolveNodePath??(e.pathName?n.resolvePath([e.pathName]):void 0);return s?(e.resolveNodePath??=[...s],i=n.rootNode.getChild(s),r.linksTo=i,e.labels.forEach(o=>o.lastLinkedTo=i),i?.linkedRefLabels.push(r),i?.referencedBy.push(e),e.labels.forEach(o=>{n.labelsUsedCache.set(o.label.value,s)}),i?(n.references.push(e),this.checkNodeUniqueNames(e,i)):n.unlinkedRefNodes.push(e)):(this._issues.push(qt(3,r.rangeTokens,r,{templateStrings:[r.label?.value??""]})),n.unlinkedRefNodes.push(e)),i}processDtcRefNodeNodePathRef(e,r,n){let i;r.path&&this.linkNodePath(r.path,n.rootNode);let o=r.path?.pathParts.at(-1)?.linksTo?.path;return o?(e.resolveNodePath??=o,i=n.rootNode.getChild(o),e.labels.forEach(a=>a.lastLinkedTo=i),i?.referencedBy.push(e),e.labels.forEach(a=>{n.labelsUsedCache.set(a.label.value,o)}),i?(n.references.push(e),this.checkNodeUniqueNames(e,i)):n.unlinkedRefNodes.push(e)):n.unlinkedRefNodes.push(e),i}processDtcRefNode(e,r){let n;e.reference?e.reference instanceof se?n=this.processDtcRefNodeLabelRef(e,e.reference,r):n=this.processDtcRefNodeNodePathRef(e,e.reference,r):r.unlinkedRefNodes.push(e),e.children.forEach(i=>this.processChild(i,n??new J(this.bindingLoader,""),r))}processDtcProperty(e,r,n){e.propertyName?.name&&r.addProperty(new Ke(e,r)),e.children.forEach(i=>this.processChild(i,r,n))}processDeleteNode(e,r,n){if(e.nodeNameOrRef instanceof He&&e.nodeNameOrRef.value){if(e.parentNode?.parentNode)if(!r.hasNode(e.nodeNameOrRef.name,e.nodeNameOrRef.fullAddress))this._issues.push(qt(5,e.nodeNameOrRef.rangeTokens,e.nodeNameOrRef));else{r.deletes.push(e);let i=r.getNode(e.nodeNameOrRef.name,e.nodeNameOrRef.fullAddress);e.nodeNameOrRef.linksTo=i,r.deleteNode(e.nodeNameOrRef.name,e,e.nodeNameOrRef.fullAddress),i?.labels.forEach(s=>{n.labelsUsedCache.delete(s.label.value)})}}else if(e.nodeNameOrRef instanceof se&&e.nodeNameOrRef.value){let i=n.resolvePath([`&${e.nodeNameOrRef.value}`]),s;i?(s=n.rootNode.getChild(i),r.deletes.push(e),e.nodeNameOrRef.linksTo=s,s?.labels.forEach(o=>{n.labelsUsedCache.delete(o.label.value)}),s?.linkedRefLabels.push(e.nodeNameOrRef),s?.parent?.deleteNode(s.name,e,s.address),e.parentNode instanceof ct&&!e.parentNode.pathName&&n.globalDeletes.push(e)):(n.unlinkedDeletes.push(e),this._issues.push(qt(3,e.nodeNameOrRef.rangeTokens,e.nodeNameOrRef,{templateStrings:[e.nodeNameOrRef.value]})))}else if(e.nodeNameOrRef instanceof nt&&e.nodeNameOrRef.path&&!e.nodeNameOrRef.path.pathParts.some(i=>!i)){let i=n.rootNode,s=e.nodeNameOrRef.path.pathParts;for(let c=0;c<s.length&&s[c];c++){let l=s[c];if(l){let u=i?.getNode(l.name,l.fullAddress,!1);l.linksTo=u,u?.linkedNodeNamePaths.push(l),i=u}}let o=e.nodeNameOrRef.path.pathParts.find(c=>c&&!c.linksTo),a=e.nodeNameOrRef.path.pathParts.at(-1)?.linksTo;a||(n.unlinkedDeletes.push(e),o&&this._issues.push(qt(8,o.rangeTokens,o,{templateStrings:[o.toString(),`${e.nodeNameOrRef.path.pathParts.filter(c=>c?.linksTo).map(c=>c?.toString()).join("/")}`]}))),r.deletes.push(e),a?.labels.forEach(c=>{n.labelsUsedCache.delete(c.label.value)}),a?.parent?.deleteNode(a.name,e,a.address),e.parentNode instanceof ct&&!e.parentNode.pathName&&n.globalDeletes.push(e)}else n.unlinkedDeletes.push(e);e.children.forEach(i=>this.processChild(i,r,n))}processDeleteProperty(e,r,n){e.propertyName?.name&&!r.hasProperty(e.propertyName.name)?this._issues.push(qt(1,e.propertyName.rangeTokens,e.propertyName)):e.propertyName?.name&&(r.deletes.push(e),r.deleteProperty(e.propertyName.name,e)),e.children.forEach(i=>this.processChild(i,r,n))}static#e(e,r,n){let i=n.get(r);i||(i=[],n.set(r,i)),i.push(e)}async getSyntaxIssues(e=new Map,r){return(await this.getAllParsers()).forEach(n=>{r?n.issues.filter(i=>r(i.raw)).forEach(i=>t.#e(i.diagnostic(),i.raw.uri,e)):n.issues.forEach(i=>t.#e(i.diagnostic(),i.raw.uri,e))}),e}async getDiagnostics(){let e=new Map;try{return await this.getSyntaxIssues(e),(await this.getContextIssues()??[]).forEach(i=>t.#e(i.diagnostic(),i.raw.uri,e)),(await this.getRuntime())?.typesIssues.forEach(i=>t.#e(i.diagnostic(),i.raw.uri,e)),e}catch(r){throw console.error(r),r}}async toFullString(){return`/dts-v1/;
283
284
  ${(await this.getRuntime()).rootNode.toFullString((await this.getAllParsers()).at(-1).cPreprocessorParser.macros)}`}async serialize(){return await this.stable,await this.getDiagnostics(),(await this?.getRuntime())?.rootNode.serialize((await this.getAllParsers()).at(-1).cPreprocessorParser.macros)}};var qC=require("fs"),ta=require("path"),At=L(j());function mU(t){if(!t||!(t.ast instanceof zo))return[];let e=n=>n.flatMap(i=>{try{return(0,qC.readdirSync)(i,{withFileTypes:!0,recursive:!0}).filter(s=>s.name.toLowerCase().endsWith(".dtsi")||s.name.toLowerCase().endsWith(".h")).map(s=>({label:`${(0,ta.join)((0,ta.relative)(i,s.parentPath),s.name)}`,kind:At.CompletionItemKind.File}))}catch{return[]}});if(t.ast.relative)return e([(0,ta.dirname)(t.ast.uri)]);let r=t.runtime.context.settings.includePaths??[];return e(r)}var xf=(t,e)=>[...t.labels.filter(e),...t.deletedNodes.filter(r=>!e(r.by)).flatMap(r=>xf(r.node,e)),...t.nodes.flatMap(r=>xf(r,e))],nv=(t,e)=>[...t.labels,...t.deletedNodes.filter(r=>!e(r.by)).flatMap(r=>nv(r.node,e)),...t.nodes.flatMap(r=>nv(r,e))];function gU(t,e){if(!t||!(t.item instanceof Ke)||!(t.ast instanceof se))return[];let r=i=>nv(i,e),n=new Map;return r(t.runtime.rootNode).forEach(i=>n.set(i.label.value,i)),Array.from(n).map(([,i])=>({label:`${i.label.value}`,kind:At.CompletionItemKind.Method,documentation:i.lastLinkedTo?.toMarkupContent(t.runtime.context.macros)}))}function yU(t,e){if(!t||t.item!==null||!(t.ast instanceof se)||!(t.ast.parentNode instanceof Wt))return[];let r=n=>xf(n,e).filter(i=>e(i));return[...Array.from(new Set(r(t.runtime.rootNode).map(n=>n.label.value))).map(n=>({label:n,insertText:t.ast.lastToken.nextToken?.value==="{"?n:`${n} {
284
285
  $1
285
- };`,kind:At.CompletionItemKind.Value,insertTextFormat:At.InsertTextFormat.Snippet}))]}function vU(t,e){let r=s=>s?s.parentNode instanceof Wt||s.parentNode instanceof St||s.parentNode instanceof Ue?!1:r(s.parentNode):!0;if(!t||t.item!==null||!Ut(t.ast)||!r(t.ast))return[];let n=s=>xf(s,e).filter(o=>e(o));if(t.ast instanceof ht)return n(t.runtime.rootNode).length?[{label:"/delete-node/",insertText:"/delete-node/ $1;",kind:At.CompletionItemKind.Keyword,insertTextFormat:At.InsertTextFormat.Snippet,sortText:"~"}]:t.runtime.rootNode.nodes.length?[{label:"/delete-node/ &{}",insertText:"/delete-node/ {/$1};",kind:At.CompletionItemKind.Keyword,insertTextFormat:At.InsertTextFormat.Snippet,sortText:"~"}]:[];let i=new Map;return n(t.runtime.rootNode).forEach(s=>i.set(s.label.value,s)),Array.from(i).map(([,s])=>({label:t.ast instanceof se?`${s.label.value}`:`&${s.label.value}`,kind:At.CompletionItemKind.Variable,documentation:s.lastLinkedTo?.toMarkupContent(t.runtime.context.macros)}))}function TU(t,e){if(!t||!(t.item instanceof J)||t.item===null||t.beforeAst&&(!(t.beforeAst?.parentNode instanceof vr)||t.beforeAst?.parentNode instanceof pt))return[];let r=n=>[...n.nodes,...n.deletedNodes.filter(i=>!e(i.by)).map(i=>i.node)].flatMap(i=>({node:i,astNodes:i.definitions.filter(s=>s instanceof Ue)})).filter(i=>i.astNodes.some(e));return t.ast instanceof He||t.ast instanceof Dr||t.beforeAst?.parentNode instanceof Dr?r(t.item).map(n=>({label:`${n.astNodes.at(0)?.name?.toString()}`,kind:At.CompletionItemKind.Variable,documentation:n.node.toMarkupContent(t.runtime.context.macros)})):r(t.item).length?[{label:"/delete-node/",kind:At.CompletionItemKind.Keyword,insertTextFormat:At.InsertTextFormat.Snippet,sortText:"~"}]:[]}function bU(t,e){if(!t||!(t.item instanceof J)||t.beforeAst&&(!(t.beforeAst?.parentNode instanceof vr)||t.beforeAst?.parentNode instanceof Dr))return[];let r=n=>[...n.properties,...n.deletedProperties.filter(i=>!e(i.by)).map(i=>i.property)].flatMap(i=>[i,...i.allReplaced]).filter(i=>e(i.ast));if(t.ast instanceof Qe||t.ast instanceof pt||t.beforeAst?.parentNode instanceof pt){let n=new Map;return r(t.item).forEach(i=>n.set(i.name,i)),Array.from(n).map(([,i])=>({label:`${i.name}`,kind:At.CompletionItemKind.Variable,documentation:i.ast.toPrettyString(t.runtime.context.macros)}))}return r(t.item).length?[{label:"/delete-property/",insertText:"/delete-property/$1;",kind:At.CompletionItemKind.Keyword,sortText:"~",insertTextFormat:At.InsertTextFormat.Snippet}]:[]}function _U(t,e){let r=t?.ast instanceof Dn?t.ast:t?.ast.parentNode;if(!t||!r||!(r instanceof Dn))return[];let n=r.pathParts.slice(0,-1);if(n.some(o=>!o))return[];let i=n.map(o=>o.toString());return(()=>{let o=t.runtime.rootNode.getChildFromScope(["/",...i],e);return[...o?.nodes.filter(a=>!Ut(t.ast)||a.definitions.some(e))??[],...o?.deletedNodes.filter(a=>!e(a.by)).map(a=>a.node)??[]]})().map(o=>({label:`/${[...i,o.fullName].join("/")}`,kind:At.CompletionItemKind.Variable,documentation:o.toMarkupContent(t.runtime.context.macros)}))}function SU(t){return!t||!(t.item instanceof Ke&&t.item.ast.assignOperatorToken)||t.ast instanceof ie?[]:!js(t?.ast)&&!(t.ast instanceof Ye&&t.item.ast.values===null)&&!js(t.beforeAst)&&!js(t.afterAst)?[]:t.item.parent.nodeType instanceof Nt?Array.from([t.runtime.context.parser,...t.runtime.context.overlayParsers].at(-1)?.cPreprocessorParser.macros??[]).map(([,n])=>n.macro.identifier instanceof Jn?{label:`${n.macro.identifier.toString()}`,insertText:`${n.macro.name}(${n.macro.identifier.params.map((i,s)=>i instanceof Ct?`$${s+1}`:"").join(", ")})`,kind:At.CompletionItemKind.Function,sortText:`~${n.macro.name}`,insertTextFormat:At.InsertTextFormat.Snippet}:{label:n.macro.identifier.name,kind:At.CompletionItemKind.Variable,sortText:`~${n.macro.name}`}):[]}async function LC(t,e){return _t(t,e,(r,n)=>[...bU(r,n),...TU(r,n),...vU(r,n),..._U(r,n),...yU(r,n),...gU(r,n),...mU(r),...SU(r)])}var mp=L(j());var BC=require("child_process");var iv=t=>/[A-Za-z0-9_]/.test(t);function NU(t,e){let r=[];for(let n=0;n<e;n++){let i=t[n];i==="("?r.push(n):i===")"&&r.pop()}return r.length?r[r.length-1]:void 0}function $C(t,e){let r=1;for(let n=e+1;n<t.length;n++){let i=t[n];if(i==="(")r++;else if(i===")"&&(r--,r===0))return n}}function FC(t,e,r){let n=[],i=0,s=!1,o=!1,a=e;for(let f=e;f<r;f++){let p=t[f];if(p==="'"&&!o)s=!s;else if(p==='"'&&!s)o=!o;else if(!s&&!o){if(p==="(")i++;else if(p===")")i--;else if(p===","&&i===0){let g=a,h=f,v=g,S=h;for(;v<S&&/\s/.test(t[v]);)v++;for(;S>v&&/\s/.test(t[S-1]);)S--;n.push({start:g,end:h,text:t.slice(v,S)}),a=f+1}}}let c=a,l=r,u=c,d=l;for(;u<d&&/\s/.test(t[u]);)u++;for(;d>u&&/\s/.test(t[d-1]);)d--;return n.push({start:c,end:l,text:t.slice(u,d)}),n}function sv(t){let e=t.trim(),r=/^([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*)\)$/.exec(e);if(!r)return{macro:e};let n=r[1],i=r[2],s=FC(i,0,i.length),o={macro:n,args:[]};return o.args=s.map(a=>{let c=sv(a.text);return c.parent=o,c}),o}function Ni(t,e){let r=t.getText(),n=t.offsetAt(e),i=n,s=n;for(;i>0&&iv(r[i-1]);)i--;for(;s<r.length&&iv(r[s]);)s++;if(r[s]==="("){let v=$C(r,s);v!==void 0&&(s=v+1)}let o=r.slice(i,s),a=o.trim().length?sv(o):void 0,c=NU(r,n);if(c===void 0)return a;let l=$C(r,c);if(l===void 0||!(c<n&&n<=l))return a;let u=c,d=u;for(;d>0&&iv(r[d-1]);)d--;let f=r.slice(d,u);if(!f)return a;let p=FC(r,c+1,l),g={macro:f,args:[]};g.args=p.map(v=>{let S=sv(v.text);return S.parent=g,S});let h=-1;for(let v=0;v<p.length;v++){let S=p[v];if(n>=S.start&&n<=S.end){h=v;break}}if(h>=0){let v=g.args[h];return v.argIndexInParent=h,v}return g}function RU(t,e,r){let i=t.getText().split(/\r?\n/),s=new RegExp(`^\\s*#\\s*define\\s+(${e})\\b(\\s*\\([^)]*\\))?\\s*(.*)$`);for(let o=Math.min(r.line,i.length-1);o>=0;o--){let a=i[o],c=s.exec(a);if(c){let l=a.indexOf(c[0]),u=a.indexOf(c[3],l);return zr.create(o,u>=0?u:a.length)}}}async function ns(t,e,r,n){let i=jC(t,e,r);if(i)return i;let s=await kU(e,n,Ae(t.uri));if(s)return[s,r]}function jC(t,e,r){if(e.startsWith("DT_"))return;let n=RU(t,e,r);if(!n)return;let i=Ni(t,n);if(i)return[i,n]}var PU=(t,e)=>new Promise(r=>{let n=(0,BC.spawn)(t,e,{stdio:["ignore","pipe","pipe"]}),i="";n.stdout.on("data",s=>{i+=s.toString()}),n.on("close",s=>{r(s?"":i)})});async function kU(t,e,r){let n=e.getCompileCommands()?.find(s=>de(s.file,r));if(!n)return;let i=`${n.command.replace(/-(o|c)\s+\S+/g,"")} -E -dM ${n.file}`;try{let[s,...o]=i.split(" "),a=await PU(s,o.filter(u=>!!u)),c=Yi.create(`macros://${n.file}`,"devicetree",0,a),l=jC(c,t,c.positionAt(a.length-1));if(l)return l[0]}catch(s){console.error(s)}}function ee(t){return t.toLowerCase().replace(/[@,-\.]/g,"_")}var Mc=L(j());async function UC({macro:t,context:e}){if(t.macro&&"DT_ALIAS".startsWith(t.macro))return[{label:"DT_ALIAS(...)",insertText:"DT_ALIAS($1)",kind:Mc.CompletionItemKind.Function,insertTextFormat:Mc.InsertTextFormat.Snippet}];if(t.parent?.macro!=="DT_ALIAS"||t.argIndexInParent!==0)return[];let r=await e.getRuntime();return r.rootNode.getNode("aliases")?.properties.map(n=>{let i=n.ast.getFlatAstValues()?.at(0),s;return i instanceof se?s=i.linksTo:i instanceof Dn&&(s=i.pathParts.at(-1)?.linksTo),{label:ee(n.name),kind:Mc.CompletionItemKind.Property,documentation:s?.toMarkupContent(r.context.macros)}})??[]}var xc=L(j());async function ur(t,e,r){if(!t)return;let i=t?.properties.find(s=>ee(s.name)===e)?.ast.getFlatAstValues();return i?.length===0?!0:i?.map(s=>{if(s instanceof nt)return s.path?.pathParts.at(-1)?.linksTo;if(s instanceof se)return s.linksTo;if(s instanceof ie)return s.value;if(s instanceof we){let o=s.evaluate(r.macros);return typeof o=="number"?o:s.toString()}})}async function qf({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PROP"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return o?ur(o,s[1].macro,r):void 0}async function HC(t,e){let r=await qf(t,e);if(typeof r=="boolean")return;let n=r?.at(0);if(r?.length===1&&n instanceof J)return n}async function VC(t,e,r,n){if(r=typeof r=="number"?r:Ee(r),typeof r!="number")return;let i=await ur(t,e,n);if(i===!0)return!0;if(!i)return;let s=i.at(r);if(s)return i.length===1&&i[0]instanceof J?i[0]:s}async function Lf({document:t,macro:e,context:r,position:n},i){if(!(e.macro!=="DT_PROP_BY_IDX"||e.args?.length!==3))return VC(await i({document:t,macro:e.args[0],context:r,position:n}),e.args[1].macro,e.args[2].macro,r)}async function zC(t,e){let r=await Lf(t,e);if(typeof r!="boolean"&&r instanceof J)return r}async function Mr(t,{document:e,context:r,macro:n,position:i},s){return t||(await s({document:e,macro:n,context:r,position:i})??n.macro)}async function $f(t,e,r,n){return Mr(await ur(t,e,r.context),r,n)}async function ra({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_PROP_OR"||e.args?.length!==3)return;let[s,o,a]=e.args,c=await i({document:t,macro:s,context:r,position:n});return await $f(c,o.macro,{macro:a,document:t,context:r,position:n},i)}async function WC(t,e){let r=await ra(t,e);if(r instanceof J)return r;if(typeof r=="boolean")return;let n=r?.at(0);if(r?.length===1&&n instanceof J)return n}async function GC(t){let e=t?.nodeType?.onBus,r=t?.parent?.nodeType?.bus;return t&&r?.length&&r?.some(n=>n===e)?t.parent??void 0:void 0}async function Bf(t,e){let r=t.macro.args;if(t.macro.macro!=="DT_BUS"||r?.length!==1)return;let n=await e({...t,macro:r[0]});return await GC(n)}async function Ff(t,e){let r=(await t.getRuntime()).rootNode.getChild(["/","chosen"]);if(!r)return;let s=r?.properties.find(o=>ee(o.name)===e)?.ast.getFlatAstValues()?.at(0);if(s instanceof se)return s.linksTo;if(s instanceof nt)return s.path?.pathParts.at(-1)?.linksTo}async function jf(t){let e=t.macro.args;if(!(t.macro.macro!=="DT_CHOSEN"||e?.length!==1))return await Ff(t.context,e[0].macro)}async function Uf(t,e){let r=await e?.getRuntime();if(r){let n=Qn.getNodeFromPath(["aliases"],r.rootNode,!0),i=n?.properties.find(o=>ee(o.name)===t);if(!i)return;let s=i.ast.getFlatAstValues();return s?.[0]instanceof ie?n=r.rootNode.getChild(s[0].value.split("/")):s?.[0]instanceof se?n=s[0].linksTo:s?.[0]instanceof nt&&(n=s[0].path?.pathParts.at(-1)?.linksTo),n}}async function Hf({macro:t,context:e}){if(!(t.macro!=="DT_ALIAS"||t.args?.length!==1))return Uf(t.args[0].macro,e)}async function YC(t,e){return t?.nodes.find(r=>ee(r.name)===e)}async function Vf({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_CHILD"||e.args?.length!==2)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});return YC(s,e.args[1].macro)}var ov=(t,e)=>t.nodes.filter(r=>!r.disabled&&r.nodeType).flatMap(r=>[r.nodeType.compatible,...Array.from(r.nodeType.extends)].filter(n=>!!n).map(n=>ee(n)).includes(e)?[r,...ov(r,e)]:ov(r,e));async function KC(t,e){let r=await e?.getRuntime();if(r)return ov(r.rootNode,t)}async function av({macro:t,context:e}){if(!(t.macro!=="DT_COMPAT_GET_ANY_STATUS_OKAY"||t.args?.length!==1))return KC(t.args[0].macro,e)}async function XC(t){return(await av(t))?.at(0)}async function JC(t){return t?.parent?.parent??void 0}async function zf({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_GPARENT"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});return JC(s)}var cv=(t,e)=>t.nodes.filter(r=>r.nodeType).sort((r,n)=>r.disabled===n.disabled?0:r.disabled?1:-1).flatMap(r=>[r.nodeType.compatible,...Array.from(r.nodeType.extends)].filter(n=>!!n).map(n=>ee(n)).includes(e)?[r,...cv(r,e)]:cv(r,e));async function QC(t,e,r){let n=await r?.getRuntime();if(n)return cv(n.rootNode,e).at(t)}async function Wf({macro:t,context:e}){if(t.macro!=="DT_INST"||t.args?.length!==2)return;let r=Ee(t.args[0].macro);if(typeof r=="number")return QC(r,t.args[1].macro,e)}async function ZC(t,e){let r=await e?.getRuntime(),n=r?.resolvePath([`&${t.trim()}`]);if(r&&n)return Qn.getNodeFromPath(n.slice(1),r.rootNode,!0)}async function Gf({macro:t,context:e}){if(!(t.macro!=="DT_NODELABEL"||t.args?.length!==1))return ZC(t.args[0].macro,e)}async function eD(t){return t?.parent??void 0}async function Yf({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_PARENT"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});return eD(s)}var tD=(t,e)=>{if(!e.length)return t;let r=e.splice(0,1)[0],n=t.nodes.find(i=>ee(i.fullName)===r);return n?tD(n,e):void 0};async function Kf(t,e){let r=await e?.getRuntime();if(r)return tD(r.rootNode,t)}async function Xf({macro:t,context:e}){let r=t.args;if(!(t.macro!=="DT_PATH"||!r?.length))return Kf(r.map(n=>n.macro),e)}async function Jf({macro:t,context:e}){let r=t.args;if(!(t.macro!=="DT_ROOT"||r?.length))return(await e.getRuntime()).rootNode}async function na(t,e,r){let n=t?.properties.find(c=>ee(c.name)===e);if(!n)return;let i=n?.ast.quickValues?.at(r),s=n.parent.nodeType;if(Array.isArray(i)||!s||!(s instanceof Nt))return;let a=s.properties.find(c=>c.getNameMatch(n.name))?.values(n).findIndex(c=>c===i)??-1;return a===-1?void 0:a}async function Qf(t,e,r,n,i){return Mr(await na(t,e,r),n,i)}async function Zf({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_ENUM_IDX_BY_IDX_OR"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return await Qf(o,s[1].macro,a,{macro:s[3],document:t,context:r,position:n},i)}async function ep({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_ENUM_IDX_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return await Qf(o,s[1].macro,0,{macro:s[2],document:t,context:r,position:n},i)}async function is(t,e,r,n,i){let s=t?.properties.find(d=>ee(d.name)===e),o=s?.parent.nodeType;if(!o||!(o instanceof Nt))return;if(typeof r=="string"){let d=s.nexusMapsTo.at(0)?.specifierSpace;if(r=(d?s.parent.getProperty(`${d}-names`)?.ast.quickValues:void 0)?.findIndex(p=>typeof p=="string"&&p.toLowerCase()===r)??-1,r===-1)return}let a=s.nexusMapsTo.at(r),l=a?.target.nodeType?.cellsValues?.find(d=>a.specifierSpace&&d.specifier===a.specifierSpace)?.values?.indexOf(n);if(l===void 0||l===-1)return;let u=a?.mappingValuesAst.at(l);if(u instanceof we){let d=u.evaluate(i.macros);return typeof d!="number"?u.toString():d}}async function ia(t,e,r,n,i,s){return Mr(await is(t,e,r,n,i.context),i,s)}async function tp({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHA_BY_IDX_OR"||s?.length!==5)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return ia(o,s[1].macro,a,s[3].macro,{macro:s[4],document:t,context:r,position:n},i)}async function rp({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHA_BY_NAME_OR"||s?.length!==5)return;let o=await i({document:t,macro:s[0],context:r,position:n});return ia(o,s[1].macro,s[2].macro,s[3].macro,{macro:s[4],document:t,context:r,position:n},i)}async function Zn(t,e,r=0){let n=t?.properties.find(s=>ee(s.name)===e);if(r=typeof r=="number"?r:Ee(r??"0"),typeof r!="number")return;let i=n?.ast.getFlatAstValues()?.at(r);if(i instanceof se)return i.linksTo;if(i instanceof nt)return i.path?.pathParts.at(-1)?.linksTo}async function ss({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHANDLE"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return Zn(o,s[1].macro,0)}async function ei({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHANDLE_BY_IDX"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return Zn(o,s[1].macro,s.at(2)?.macro)}async function rD(t,e,r){let n=t?.properties.find(l=>ee(l.name)===e);if(!n)return;let i=n.parent.nodeType;if(!i||!(i instanceof Nt))return;let s=n.nexusMapsTo.at(0)?.specifierSpace,a=(s?n.parent.getProperty(`${s}-names`)?.ast.quickValues:void 0)?.findIndex(l=>typeof l=="string"&&l.toLowerCase()===r)??-1;return a===-1?void 0:n.nexusMapsTo.at(a)?.target}async function np({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHANDLE_BY_NAME"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return await rD(o,s[1].macro,s[2].macro)}async function ip({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHA_OR"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:r,position:n});return ia(o,s[1].macro,0,s[2].macro,{macro:s[3],document:t,context:r,position:n},i)}async function sp({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_PROP_BY_PHANDLE_IDX_OR"||e.args?.length!==5)return;let s=await Zn(await i({document:t,macro:e.args[0],context:r,position:n}),e.args[1].macro,e.args[2].macro);return $f(s,e.args[3].macro,{macro:e.args[4],document:t,context:r,position:n},i)}async function op(t,e){if(!t)return;let r=t?.properties.find(n=>ee(n.name)===e);return r?.nexusMapsTo.length?r.nexusMapsTo.length:r?.ast.getFlatAstValues()?.length}async function nD(t,e,r,n){if(t)return Mr(await op(t,e),r,n)}async function ap({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PROP_LEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return o?nD(o,s[1].macro,{macro:s[2],document:t,context:r,position:n},i):void 0}async function sa(t,e){if(!t)return;let n=t?.properties.find(i=>ee(i.name)===e)?.ast.getFlatAstValues();if(n?.length===1&&n[0]instanceof ie)return ee(n[0].value)}async function iD(t,e,r,n){if(t)return Mr(await sa(t,e),r,n)}async function cp({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_TOKEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return iD(o,s[1].macro,{document:t,macro:s[2],context:r,position:n},i)}async function lp(t,e){if(!t)return;let n=t?.properties.find(i=>ee(i.name)===e)?.ast.getFlatAstValues();if(n?.length===1&&n[0]instanceof ie)return n[0].value}async function sD(t,e,r,n){if(t)return Mr(await lp(t,e),r,n)}async function up({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_UNQUOTED_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return sD(o,s[1].macro,{document:t,macro:s[2],context:r,position:n},i)}async function dp(t,e){return(await sa(t,e))?.toUpperCase()}async function oD(t,e,r,n){if(t)return Mr(await dp(t,e),r,n)}async function fp({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_UPPER_TOKEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return oD(o,s[1].macro,{document:t,macro:s[2],context:r,position:n},i)}function An(t){return async(e,r)=>{let n=await t(e,r);if(n instanceof J)return n}}async function M({macro:t,document:e,context:r,position:n}){["DT_ALIAS","DT_NODELABEL"].some(a=>a===t.parent?.macro)||t.parent?.macro==="DT_CHILD"&&t.argIndexInParent===1?t=t.parent:t.parent?.macro==="DT_HAS_ALIAS"?(t=t.parent,t.macro="DT_ALIAS"):t.parent?.macro==="DT_PATH"&&(t.parent.args=t.parent.args?.slice(0,(t.argIndexInParent??0)+1)??[],t=t.parent);let s=await[Bf,jf,Hf,Vf,XC,zf,Wf,Gf,Yf,Xf,ss,ei,np,zC,HC,WC,Jf,An(Zf),An(ep),An(tp),An(rp),An(ip),An(sp),An(ap),An(ra),An(cp),An(up),An(fp)].reduce((a,c)=>a.then(l=>l||c({macro:t,document:e,context:r,position:n},M)),Promise.resolve(void 0));if(s)return Array.isArray(s)?s.at(0):s;let o=await ns(e,t.macro,n,r);if(o)return M({document:e,macro:o[0],context:r,position:n})}async function aD({macro:t,document:e,context:r,position:n}){return t.macro&&t.macro&&"DT_CHILD".startsWith(t.macro)?[{label:"DT_CHILD(...)",insertText:"DT_CHILD($1, $2)",kind:xc.CompletionItemKind.Function,insertTextFormat:xc.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_CHILD"||t.argIndexInParent!==1||!t.parent.args?.length?[]:(await M({document:e,macro:t.parent.args[0],context:r,position:n}))?.nodes.map(s=>({label:ee(s.fullName),kind:xc.CompletionItemKind.Class,documentation:s.toMarkupContent(r.macros)}))??[]}var qc=L(j());function cD({macro:t,context:e}){return t.macro&&"DT_COMPAT_GET_ANY_STATUS_OKAY".startsWith(t.macro)?[{label:"DT_COMPAT_GET_ANY_STATUS_OKAY(...)",insertText:"DT_COMPAT_GET_ANY_STATUS_OKAY($1)",kind:qc.CompletionItemKind.Function,insertTextFormat:qc.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_COMPAT_GET_ANY_STATUS_OKAY"||t.argIndexInParent!==0?[]:e.bindingLoader?.getBindings().map(r=>({label:ee(r),kind:qc.CompletionItemKind.Property}))??[]}var Lc=L(j());function lD({macro:t,context:e}){return t.macro&&"DT_INST".startsWith(t.macro)?[{label:"DT_INST(...)",insertText:"DT_INST($1, $2)",kind:Lc.CompletionItemKind.Function,insertTextFormat:Lc.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_INST"||t.argIndexInParent!==1?[]:e.bindingLoader?.getBindings().map(r=>({label:ee(r),kind:Lc.CompletionItemKind.Property}))??[]}var $c=L(j());async function uD({macro:t,context:e}){if(t.macro&&"DT_NODELABEL".startsWith(t.macro))return[{label:"DT_NODELABEL(...)",insertText:"DT_NODELABEL($1)",kind:$c.CompletionItemKind.Function,insertTextFormat:$c.InsertTextFormat.Snippet}];let r=await e.getRuntime();return t.parent?.macro!=="DT_NODELABEL"||t.argIndexInParent!==0?[]:await Promise.all(r.rootNode.allDescendantsLabels.map(async n=>({label:n.label.value,kind:$c.CompletionItemKind.Property,documentation:n.lastLinkedTo?.toMarkupContent(r.context.macros)}))??[])}var Bc=L(j());async function dD({macro:t,context:e}){return t.macro&&t.macro&&"DT_PATH".startsWith(t.macro)?[{label:"DT_PATH(...)",insertText:"DT_PATH($1)",kind:Bc.CompletionItemKind.Function,insertTextFormat:Bc.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_PATH"||!t.parent.args?.length?[]:(await Kf(t.parent.args.slice(0,-1).map(n=>n.macro),e))?.nodes.map(n=>({label:ee(n.fullName),kind:Bc.CompletionItemKind.Class,documentation:n.toMarkupContent(e.macros)}))??[]}var fD=L(j());async function pD({macro:t,context:e}){if(t.macro&&t.macro&&"DT_ROOT".startsWith(t.macro)){let r=await e.getRuntime();return[{label:"DT_ROOT",kind:fD.CompletionItemKind.Class,documentation:r.rootNode.toMarkupContent(r.context.macros)}]}return[]}var pp=L(j());function hD({macro:t}){return t.macro&&t.macro&&"DT_SAME_NODE".startsWith(t.macro)?[{label:"DT_SAME_NODE(...)",insertText:"DT_SAME_NODE($1, $2)",kind:pp.CompletionItemKind.Snippet,insertTextFormat:pp.InsertTextFormat.Snippet}]:[]}var Fc=L(j());async function Q({macro:t,document:e,position:r,context:n},i,s,o,a,c=l=>M({document:e,macro:l,context:n,position:r})){if(t.macro&&t.macro&&i.startsWith(t.macro))return[{label:`${i}(...)`,insertText:`${i}(${Array(o).map((d,f)=>`${f+1}`).join(", ")})`,kind:Fc.CompletionItemKind.Function,insertTextFormat:Fc.InsertTextFormat.Snippet}];if(t.parent?.macro!==i||t.argIndexInParent!==s||!t.parent.args?.length)return[];let l=await c(t.parent.args[0]);return(a?l?.properties.filter(a):l?.properties)?.map(d=>({label:ee(d.name),kind:Fc.CompletionItemKind.Property,documentation:d.toPrettyString(n.macros)}))??[]}async function mD(t){return Q(t,"DT_ENUM_HAS_VALUE",1,3)}async function gD(t){return Q(t,"DT_ENUM_HAS_VALUE_BY_IDX",1,4)}async function yD(t){return Q(t,"DT_ENUM_IDX",1,2)}async function vD(t){return Q(t,"DT_ENUM_IDX_BY_IDX",1,3)}async function TD(t){return Q(t,"DT_ENUM_IDX_BY_IDX_OR",1,4)}async function bD(t){return Q(t,"DT_ENUM_IDX_OR",1,3)}var _D=L(j());async function Ri({macro:t,document:e,context:r,position:n},i,s,o){if(t.parent?.macro!==i||t.argIndexInParent!==s||!t.parent.args?.length)return[];let c=(await M({document:e,macro:t.parent.args[0],context:r,position:n}))?.properties.find(f=>ee(f.name)===t.parent?.args?.at(1)?.macro),l=0;if(typeof o=="string"){let f=c?.nexusMapsTo.at(0)?.specifierSpace;if(l=(f?c.parent.getProperty(`${f}-names`)?.ast.quickValues:void 0)?.findIndex(g=>typeof g=="string"&&g.toLowerCase()===o)??-1,l===-1)return[]}let u=c?.nexusMapsTo.at(l);return u?.target.nodeType?.cellsValues?.find(f=>u.specifierSpace&&f.specifier===u.specifierSpace)?.values.map(f=>({label:ee(f),kind:_D.CompletionItemKind.Property}))??[]}async function SD(t){return t.macro.argIndexInParent===2?Ri(t,"DT_PHA",2,0):Q(t,"DT_PHA",1,3,e=>!!e.nexusMapsTo.length)}var ND=L(j());async function wU({document:t,macro:e,position:r,context:n},i){if(e.parent?.macro!==i||!e.parent.args?.length)return[];let o=(await M({document:t,macro:e.parent.args[0],context:n,position:r}))?.properties.find(a=>ee(a.name)===e.parent?.args?.at(1)?.macro);return Array(o?.nexusMapsTo.length??0)?.map((a,c)=>({label:c.toString(),kind:ND.CompletionItemKind.Property}))??[]}async function RD(t){if(t.macro.argIndexInParent===2)return wU(t,"DT_PHA_BY_IDX");if(t.macro.argIndexInParent===3){let e=t.macro.parent?.args?Ee(t.macro.parent.args[2].macro):void 0;return typeof e!="number"?[]:Ri(t,"DT_PHA_BY_IDX",3,e)}return Q(t,"DT_PHA_BY_IDX",1,3,e=>!!e.nexusMapsTo.length)}var PD=L(j());async function jc({document:t,macro:e,context:r,position:n},i){if(e.parent?.macro!==i||!e.parent.args?.length)return[];let o=(await M({document:t,macro:e.parent.args[0],context:r,position:n}))?.properties.find(l=>ee(l.name)===e.parent?.args?.at(1)?.macro),a=o?.nexusMapsTo.at(0)?.specifierSpace;return(a?o.parent.getProperty(`${a}-names`)?.ast.quickValues:void 0)?.filter(l=>typeof l=="string")?.map(l=>({label:l,kind:PD.CompletionItemKind.Property}))??[]}async function kD(t){let{macro:e}=t;return e.argIndexInParent===2?jc(t,"DT_PHA_BY_NAME"):e.argIndexInParent===3?e.parent?.args?.[2]?.macro?Ri(t,"DT_PHA_BY_NAME",3,e.parent.args[2].macro):[]:Q(t,"DT_PHA_BY_NAME",1,3,r=>!!r.nexusMapsTo.length)}async function wD(t){let{macro:e}=t;return e.argIndexInParent===2?jc(t,"DT_PHA_BY_NAME_OR"):e.argIndexInParent===3?e.parent?.args?.[2]?.macro?Ri(t,"DT_PHA_BY_NAME_OR",3,e.parent.args[2].macro):[]:Q(t,"DT_PHA_BY_NAME_OR",1,3,r=>!!r.nexusMapsTo.length)}async function ED(t){let{macro:e}=t;return e.argIndexInParent===2?Ri(t,"DT_PHA_OR",2,0):Q(t,"DT_PHA_OR",1,3,r=>!!r.nexusMapsTo.length)}async function hp(t){return Q(t,"DT_PHANDLE",1,2,e=>!!e.ast.getFlatAstValues()?.some(r=>r instanceof se||r instanceof nt))}async function oa(t){return Q(t,"DT_PHANDLE_BY_IDX",1,3,e=>!!e.ast.getFlatAstValues()?.some(r=>r instanceof se||r instanceof nt))}async function CD(t){let{macro:e}=t;return e.argIndexInParent===2?jc(t,"DT_PHANDLE_BY_NAME"):Q(t,"DT_PHANDLE_BY_NAME",1,3,r=>!!r.ast.getFlatAstValues()?.some(n=>n instanceof se||n instanceof nt))}async function DD(t){return Q(t,"DT_PROP",1,2,e=>!e.nexusMapsTo.length)}async function AD(t){return Q(t,"DT_PROP_BY_IDX",1,3,e=>!e.nexusMapsTo.length)}async function ID(t){let{macro:e}=t;return(e.argIndexInParent===1||e.argIndexInParent===2)&&e.parent?.macro==="DT_PROP_BY_PHANDLE_IDX"?oa({...t,macro:{...e,parent:e.parent?{...e.parent,macro:"DT_PHANDLE_BY_IDX"}:void 0}}):Q(t,"DT_PROP_BY_PHANDLE_IDX",3,4,r=>!r.nexusMapsTo.length,()=>ei({...t,macro:{macro:"DT_PHANDLE_BY_IDX",args:e.parent?.args?.slice(0,3)}},M))}async function OD(t){let{macro:e}=t;return e.argIndexInParent===1&&e.parent?.macro==="DT_PROP_BY_PHANDLE"?hp({...t,macro:{...e,parent:e.parent?{...e.parent,macro:"DT_PHANDLE"}:void 0}}):Q(t,"DT_PROP_BY_PHANDLE",2,3,r=>!r.nexusMapsTo.length,()=>ss({...t,macro:{macro:"DT_PHANDLE",args:e.parent?.args?.slice(0,2)}},M))}async function MD(t){let{macro:e}=t;return(e.argIndexInParent===1||e.argIndexInParent===2)&&e.parent?.macro==="DT_PROP_BY_PHANDLE_IDX_OR"?oa({...t,macro:{...e,parent:e.parent?{...e.parent,macro:"DT_PHANDLE_BY_IDX"}:void 0}}):Q(t,"DT_PROP_BY_PHANDLE_IDX_OR",3,5,r=>!r.nexusMapsTo.length,()=>ei({...t,macro:{macro:"DT_PHANDLE_BY_IDX",args:e.parent?.args?.slice(0,3)}},M))}async function xD(t){return Q(t,"DT_PROP_HAS_IDX",1,3,e=>!e.nexusMapsTo.length)}async function qD(t){return Q(t,"DT_PROP_HAS_NAME",1,3,e=>!e.nexusMapsTo.length)}async function LD(t){return Q(t,"DT_PROP_LAST",1,2,e=>!e.nexusMapsTo.length)}async function $D(t){return Q(t,"DT_PROP_LEN",1,2,e=>!e.nexusMapsTo.length)}async function BD(t){return Q(t,"DT_PROP_LEN_OR",1,2,e=>!e.nexusMapsTo.length)}async function FD(t){return Q(t,"DT_PROP_OR",1,2,e=>!e.nexusMapsTo.length)}async function jD(t){return Q(t,"DT_STRING_TOKEN",1,2,e=>{let r=e.ast.getFlatAstValues();return r?.length===1&&r[0]instanceof ie})}async function UD(t){return Q(t,"DT_STRING_TOKEN_BY_IDX",1,3,e=>{let r=e.ast.getFlatAstValues();return!!r?.length&&r.every(n=>n instanceof ie)})}async function HD(t){return Q(t,"DT_STRING_TOKEN_OR",1,3,e=>{let r=e.ast.getFlatAstValues();return r?.length===1&&r[0]instanceof ie})}async function VD(t){return Q(t,"DT_STRING_UNQUOTED",1,2,e=>{let r=e.ast.getFlatAstValues();return r?.length===1&&r[0]instanceof ie})}async function zD(t){return Q(t,"DT_STRING_UNQUOTED_BY_IDX",1,3,e=>{let r=e.ast.getFlatAstValues();return!!r?.length&&r.every(n=>n instanceof ie)})}async function WD(t){return Q(t,"DT_STRING_UNQUOTED_OR",1,3,e=>{let r=e.ast.getFlatAstValues();return r?.length===1&&r[0]instanceof ie})}async function GD(t){return Q(t,"DT_STRING_UPPER_TOKEN",1,2,e=>{let r=e.ast.getFlatAstValues();return r?.length===1&&r[0]instanceof ie})}async function YD(t){return Q(t,"DT_STRING_UPPER_TOKEN_BY_IDX",1,3,e=>{let r=e.ast.getFlatAstValues();return!!r?.length&&r.every(n=>n instanceof ie)})}async function KD(t){return Q(t,"DT_STRING_UPPER_TOKEN_OR",1,3,e=>{let r=e.ast.getFlatAstValues();return r?.length===1&&r[0]instanceof ie})}var Uc=L(j());async function XD({macro:t,context:e}){return t.parent?.macro==="DT_ON_BUS"&&t.argIndexInParent===1?e.bindingLoader?.getBusTypes().map(r=>({label:ee(r),kind:Uc.CompletionItemKind.Enum}))??[]:t.macro&&"DT_ON_BUS".startsWith(t.macro)?[{label:"DT_ON_BUS(...)",insertText:"DT_ON_BUS($1, $2)",kind:Uc.CompletionItemKind.Function,insertTextFormat:Uc.InsertTextFormat.Snippet}]:[]}async function JD(t){return Q(t,"DT_CHOSEN",0,1,void 0,async()=>(await t.context.getRuntime()).rootNode.getChild(["/","chosen"]))}async function QD(t){return Q(t,"DT_HAS_CHOSEN",0,1,void 0,async()=>(await t.context.getRuntime()).rootNode.getChild(["/","chosen"]))}var EU=["DT_BUS","DT_CHILD_NUM","DT_CHILD_NUM_STATUS_OKAY","DT_GPARENT","DT_HAS_ALIAS","DT_NODE_CHILD_IDX","DT_NODE_FULL_NAME","DT_NODE_FULL_NAME_TOKEN","DT_NODE_FULL_NAME_UNQUOTED","DT_NODE_FULL_NAME_UPPER_TOKEN","DT_NODE_HASH","DT_NODE_PATH","DT_NODELABEL_STRING_ARRAY","DT_PARENT"];async function ZD(t,e,r){if(!r)return[];let n=Ni(r,t.position);return n?(await Promise.all([XD,JD,QD,UC,aD,cD,lD,CU,uD,dD,pD,hD,gD,mD,vD,TD,yD,bD,RD,kD,wD,SD,oa,CD,hp,ED,AD,OD,ID,MD,DD,xD,qD,LD,$D,BD,FD,jD,UD,HD,VD,zD,WD,GD,YD,KD].flatMap(async i=>await i({document:r,context:e,macro:n,position:t.position})))).flat():[]}function CU({macro:t}){return t.macro?EU.filter(e=>e.startsWith(t.macro)).map(e=>({label:`${e}(...)`,insertText:`${e}($1)`,kind:mp.CompletionItemKind.Function,insertTextFormat:mp.InsertTextFormat.Snippet})):[]}var ti=L(j());function DU(t){if(!t||t.item===null||!(t.ast instanceof Qe))return[];let e=n=>n.replacedBy?e(n.replacedBy):n,r=n=>[n.ast,...n.allReplaced.map(i=>i.ast),n.parent.deletedProperties.find(i=>i.property===n)?.by??[]].map(i=>{if(i instanceof Ye)return ti.Location.create(ve(i.uri),fe(i.propertyName??i));if(i instanceof pt)return ti.Location.create(ve(i.uri),fe(i.propertyName??i))}).filter(i=>i);if(t.item instanceof Ke&&t.ast instanceof Qe)return r(e(t.item));if(t.item instanceof J&&t.ast instanceof Qe&&t.ast.parentNode instanceof pt){let n=t.item.deletedProperties.find(i=>i.by===t.ast.parentNode)?.property;if(n)return r(n)}return[]}function AU(t){if(!t)return[];let e=r=>{let i=t.runtime.rootNode.getNode("aliases")?.properties.filter(o=>{let a=o.ast.quickValues;if(a?.length===1&&typeof a[0]=="string"&&t.runtime.rootNode.getChild(a[0].split("/"))===r)return!0}).map(o=>o.ast)??[],s=r.parent?.deletedNodes.filter(o=>o.node===r&&(o.by.nodeNameOrRef instanceof He?o.by.nodeNameOrRef!==t.ast:!r.linkedRefLabels.some(a=>a!==t.ast))).map(o=>o.by.nodeNameOrRef)??[];return[...i,...r.linkedRefLabels,...r.linkedNodeNamePaths,...r.definitions,...s].map(o=>{if(o instanceof St)return ti.Location.create(ve(o.uri),fe(o.name??o));if(o instanceof Ue)return ti.Location.create(ve(o.uri),fe(o.name??o));if(o instanceof He)return ti.Location.create(ve(o.uri),fe(o));if(o instanceof He)return ti.Location.create(ve(o.uri),fe(o));if(o instanceof se)return ti.Location.create(ve(o.uri),fe(o.label??o));if(o instanceof Ye)return ti.Location.create(ve((o.values??o)?.uri),fe(o.values??o))}).filter(o=>o)};if(t.item instanceof J&&!Ut(t.ast))return e(t.item);if(t.ast instanceof er&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo)return e(t.ast.parentNode.linksTo);if(t.ast instanceof He&&t.ast.linksTo)return Ut(t.ast)?[...e(t.ast.linksTo),ti.Location.create(ve(t.ast.uri),fe(t.ast))]:e(t.ast.linksTo);if(t?.ast instanceof ie&&t.item instanceof Ke&&t.item.parent.name==="aliases"){let r=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(r)return e(r)}return[]}async function eA(t,e){return _t(t,e,r=>[...AU(r),...DU(r)])}var Pi=L(j());function tA(t){if(!t||t.item===null||!(t.ast instanceof Qe))return[];let e=n=>n.replacedBy?e(n.replacedBy):n,r=n=>[n.ast,...n.allReplaced.map(i=>i.ast),n.parent.deletedProperties.find(i=>i.property===n)?.by??[]].map(i=>{if((i instanceof Ye||i instanceof pt)&&i.propertyName)return Pi.Location.create(ve(i.uri),fe(i.propertyName))}).filter(i=>i);if(t.item instanceof Ke&&t.ast instanceof Qe)return r(e(t.item));if(t.item instanceof J&&t.ast instanceof Qe&&t.ast.parentNode instanceof pt){let n=t.item.deletedProperties.find(i=>i.by===t.ast.parentNode)?.property;if(n)return r(n)}return[]}function rA(t,e){if(!e||!(e.ast instanceof er))return[];"newName"in t&&(e.ast.parentNode instanceof se&&t.newName.startsWith("&")?t.newName=t.newName.slice(1):e.ast.parentNode instanceof Ji&&t.newName.endsWith(":")&&(t.newName=t.newName.slice(0,-1)));let r=e.ast.value,n=i=>[...i.definitions.filter(s=>s instanceof Ue).flatMap(s=>s.labels.map(o=>o.label)),...i.referencedBy.flatMap(s=>s.labels.map(o=>o.label)),...i.linkedRefLabels.map(s=>s.label)].filter(s=>s?.value===r).map(s=>{if(s)return Pi.Location.create(ve(s.uri),fe(s))}).filter(s=>s);return e.item instanceof J&&!Ut(e.ast)?n(e.item):e.ast instanceof er&&e.ast.parentNode instanceof se&&e.ast.parentNode.linksTo?n(e.ast.parentNode.linksTo):[]}function nA(t){if(!t||!(t.ast instanceof He))return[];let e=r=>{let i=t.runtime.rootNode.getNode("aliases")?.properties.filter(o=>{let a=o.ast.quickValues;if(a?.length===1&&typeof a[0]=="string"){let c=t.runtime.rootNode.getChild(a[0].split("/"));if(c?.isChildOf(r)||c===r)return!0}}).map(o=>o.ast)??[],s=r.parent?.deletedNodes.filter(o=>o.node===r&&o.by.nodeNameOrRef!==t.ast).map(o=>o.by.nodeNameOrRef)??[];return[...i,...r.linkedNodeNamePaths,...r.definitions,...s].map(o=>{if(o instanceof Ue&&o.name)return Pi.Location.create(ve(o.uri),fe(o.name));if(o instanceof He)return Pi.Location.create(ve(o.uri),fe(o));if(o instanceof Ye&&o.values?.values[0]?.value&&o.values?.values[0]?.value instanceof ie){let a=o.values.values[0].value,c=fe(a),l=a.value.split("/"),u=r.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,Pi.Location.create(ve(o.values.values[0].uri),c)}}).filter(o=>o)};return t.item instanceof J&&!Ut(t.ast)?e(t.item):t.ast instanceof He&&t.ast.linksTo?Ut(t.ast)?[...e(t.ast.linksTo),Pi.Location.create(ve(t.ast.uri),fe(t.ast))]:e(t.ast.linksTo):[]}async function iA(t,e){let r={};return(await _t(t,e,i=>[...nA(i),...rA(t,i),...tA(i)])).forEach(i=>{r[i.uri]??=[],r[i.uri].push(Pi.TextEdit.replace(i.range,t.newName))}),{changes:r}}async function sA(t,e){let r=await _t(t,e,n=>[...nA(n),...rA(t,n),...tA(n)]);if(r.some(n=>e?.settings.lockRenameEdits?.some(i=>Ae(n.uri).startsWith(i))))throw new Error('Path is locked by user setting "lockRenameEdits"');return{defaultBehavior:!!r.length}}var aa=L(j());var gp=t=>[...t.definitions,...t.referencedBy].map(e=>{if(e instanceof St)return aa.Location.create(ve(e.uri),fe(e));if(e instanceof Ue)return aa.Location.create(ve(e.uri),fe(e));if(e instanceof Wt)return aa.Location.create(ve(e.uri),fe(e))}).filter(e=>e),aA=t=>t.replacedBy?aA(t.replacedBy):t,oA=t=>[t.ast,...t.allReplaced.map(e=>e.ast)].map(e=>{if(e instanceof Ye)return aa.Location.create(ve(e.uri),fe(e.propertyName??e))}).filter(e=>e);function IU(t){if(!t||t.item===null||!(t.ast instanceof Qe))return[];if(t.item instanceof Ke&&t.ast instanceof Qe)return oA(aA(t.item));if(t.item instanceof J&&t.ast instanceof Qe&&t.ast.parentNode instanceof pt){let e=t.item.deletedProperties.find(r=>r.by===t.ast.parentNode)?.property;if(e)return oA(e)}return[]}function OU(t){if(!t)return[];if(t.item instanceof J&&!Ut(t.ast))return gp(t.item);if(t.ast instanceof er&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo)return gp(t.ast.parentNode.linksTo);if(t.ast instanceof He&&t.ast.linksTo)return gp(t.ast.linksTo);if(t?.ast instanceof ie&&t.item instanceof Ke&&t.item.parent.name==="aliases"){let e=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(e)return gp(e)}return[]}function MU(t){if(t?.ast instanceof Ct||t?.ast instanceof Yn){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t.ast instanceof Ct?t.ast.name:t.ast.value);if(e)return[aa.Location.create(ve(e.macro.uri),fe(e.macro.identifier))]}return[]}async function cA(t,e){return _t(t,e,r=>[...OU(r),...IU(r),...MU(r)])}var Hc=L(j());var os=t=>{let e=t.definitions.at(0);return e?Hc.Location.create(ve(e.uri),fe(e)):void 0},yp=t=>t.replaces?yp(t.replaces):t,vp=t=>{let e=yp(t);return e?Hc.Location.create(ve(e.ast.uri),fe(e.ast)):void 0};function xU(t){if(!t||t.item===null||!(t.ast instanceof Qe))return;let e=r=>Hc.Location.create(ve(r.ast.uri),fe(r.ast.propertyName??r.ast));if(t.item instanceof Ke&&t.ast instanceof Qe)return e(yp(t.item));if(t.item instanceof J&&t.ast instanceof Qe&&t.ast.parentNode instanceof pt){let r=t.item.deletedProperties.find(n=>n.by===t.ast.parentNode)?.property;if(r)return e(yp(r))}}function qU(t){if(t){if(t.item instanceof J&&!Ut(t.ast))return os(t.item);if(t.ast instanceof er&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo)return os(t.ast.parentNode.linksTo);if(t.ast instanceof He&&t.ast.linksTo)return os(t.ast.linksTo);if(t?.ast instanceof ie&&t.item instanceof Ke&&t.item.parent.name==="aliases"){let e=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(e)return os(e)}}}function LU(t){if(t?.ast instanceof Ct||t?.ast instanceof Yn){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t.ast instanceof Ct?t.ast.name:t.ast.value);if(e)return Hc.Location.create(ve(e.macro.uri),fe(e.macro.identifier))}}async function lA(t,e){return(await _t(t,e,r=>[qU(r)||xU(r)||LU(r)])).at(0)}var $U=["DT_PROP","DT_PROP_LEN","DT_PROP_LEN_OR","DT_PROP_HAS_IDX","DT_PROP_HAS_NAME","DT_PROP_BY_IDX","DT_PROP_LAST","DT_PROP_OR","DT_ENUM_IDX_BY_IDX","DT_ENUM_IDX","DT_ENUM_IDX_BY_IDX_OR","DT_ENUM_IDX_OR","DT_ENUM_HAS_VALUE_BY_IDX","DT_ENUM_HAS_VALUE","DT_STRING_TOKEN","DT_STRING_TOKEN_OR","DT_STRING_UPPER_TOKEN","DT_STRING_UPPER_TOKEN_OR","DT_STRING_UNQUOTED","DT_STRING_UNQUOTED_OR","DT_STRING_TOKEN_BY_IDX","DT_STRING_UPPER_TOKEN_BY_IDX","DT_STRING_UNQUOTED_BY_IDX","DT_PROP_BY_PHANDLE_IDX","DT_PROP_BY_PHANDLE_IDX_OR","DT_PROP_BY_PHANDLE","DT_PHA_BY_IDX","DT_PHA_BY_IDX_OR","DT_PHA","DT_PHA_OR","DT_PHA_BY_NAME","DT_PHA_BY_NAME_OR","DT_PHANDLE_BY_NAME","DT_PHANDLE_BY_IDX","DT_PHANDLE"];async function Tp({macro:t,document:e,context:r,position:n}){if($U.some(i=>i===t.parent?.macro)&&t.argIndexInParent===1&&t.parent?.args?.[0])return(await M({document:e,context:r,position:n,macro:t.parent.args[0]}))?.properties.find(s=>ee(s.name)===t.macro);if(["DT_PROP_BY_PHANDLE"].some(i=>i===t.parent?.macro)&&t.argIndexInParent===2&&t.parent?.args?.[0]&&t.parent?.args?.[1])return(await ss({document:e,context:r,position:n,macro:{macro:"DT_PHANDLE",args:t.parent.args.slice(0,2)}},M))?.properties.find(s=>ee(s.name)===t.macro);if(["DT_PROP_BY_PHANDLE_IDX","DT_PROP_BY_PHANDLE_IDX_OR"].some(i=>i===t.parent?.macro)&&t.argIndexInParent===3&&t.parent?.args?.[0]&&t.parent?.args?.[1]&&t.parent?.args?.[3])return(await ei({document:e,context:r,position:n,macro:{macro:"DT_PHANDLE_BY_IDX",args:t.parent.args.slice(0,3)}},M))?.properties.find(s=>ee(s.name)===t.macro);if(["DT_CHOSEN","DT_HAS_CHOSEN"].some(i=>i===t.parent?.macro)&&t.argIndexInParent===0&&t.parent?.args?.[0])return(await r.getRuntime()).rootNode.getChild(["/","chosen"])?.properties.find(i=>ee(i.name)===t.macro)}async function uA(t,e,r){if(!r)return;let n=Ni(r,t.position);return dA(n,t.position,e,r)}async function dA(t,e,r,n){if(!t?.macro)return;let i=await M({document:n,macro:t,context:r,position:e});if(i)return os(i);let s=await Tp({document:n,macro:t,context:r,position:e});if(s)return vp(s);let o=await ns(n,t.macro,e,r);if(o)return dA(o[0],o[1],r,n)}async function fA(t,e,r){if(!r)return;let n=Ni(r,t.position);return pA(n,t.position,e,r)}async function pA(t,e,r,n){if(!t?.macro)return;let i=await M({document:n,macro:t,context:r,position:e});if(i)return os(i);let s=await Tp({document:n,macro:t,context:r,position:e});if(s)return vp(s);let o=await ns(n,t.macro,e,r);if(o)return pA(o[0],o[1],r,n)}var le=L(j());var BU=(t,e,r,n,i)=>{switch(r){case 1:return[{title:"Add semicolon",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character),";")]}}}];case 2:return[{title:"Add open curly",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character)," {")]}}}];case 29:return[{title:"Remove white space",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.replace(le.Range.create(le.Position.create(n.range.start.line,t.pos.colEnd),le.Position.create(n.range.end.line,e.pos.col)),"")]}}}];case 3:return[{title:"Add close curly",diagnostics:[n],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character),"}")]}}}];case 19:return[{title:"Add '/'",diagnostics:[n],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character),"/")]}}}];case 28:return[{title:"Add comma",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character),",")]}}}];case 21:return[{title:"Add '/'",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character),"/")]}}}];case 23:return[{title:"Remove ';'",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.del(n.range)]}}}];case 34:return[{title:"Complete Keyword '/delete-node/",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.replace(n.range,"/delete-node/")]}}}];case 35:return[{title:"Complete Keyword '/delete-property/",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.replace(n.range,"/delete-property/")]}}}];case 25:return[{title:"Complete Keyword '/delete-property/",diagnostics:[n],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.replace(n.range,"/delete-property/")]}}},{title:"Complete Keyword '/delete-node/",diagnostics:[n],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.replace(n.range,"/delete-node/")]}}}];case 12:return[{title:"Add '>'",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character),">")]}}}];default:return}},FU=(t,e,r,n,i)=>{if(!n?.length)return[];switch(t){case 0:return[{title:i??`Add Property "${n[0].newText.split("=",1)[0].replace(";","").trim()}"`,diagnostics:[e],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[r]:n}}}];case 27:return[{title:i??"Remove Property",diagnostics:[e],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[r]:n}}}];case 26:return[{title:i??"TODO",diagnostics:[e],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[r]:n}}}];case 36:return[{title:i??"TODO",diagnostics:[e],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[r]:n}}}];case 25:return n?[{title:i??"TODO",diagnostics:[e],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[r]:n}}}]:[];default:return}};function hA(t){let e=t.context.diagnostics.flatMap(a=>{let c=a.data;switch(c?.issues.type){case"SyntaxIssue":return c?.issues.items.flatMap(l=>BU(c.firstToken,c.lastToken,l,a,t.textDocument.uri));case"StandardTypeIssue":return c?.issues.items.flatMap(l=>FU(l,a,t.textDocument.uri,c.issues.edit?Array.isArray(c.issues.edit)?c.issues.edit:[c.issues.edit]:void 0,c.issues.codeActionTitle))}}).filter(a=>!!a),r=e.filter(a=>a.kind===le.CodeActionKind.SourceFixAll),n=e.filter(a=>a.title.startsWith("Add Property")),i=e.filter(a=>a.kind!==le.CodeActionKind.SourceFixAll),s=r.flatMap(a=>a.edit?.changes?.[t.textDocument.uri]??[]),o=new Map;return n.forEach(a=>{let c=a.edit.changes[t.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)}),[...i,...r.map(a=>({...a,kind:le.CodeActionKind.QuickFix})),...s.length?[{title:"Fix All",kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[t.textDocument.uri]:s}}}]:[],...Array.from(o.values()).flatMap(a=>a.length>1?{title:"Add All Missing Properties",kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[t.textDocument.uri]:a}}}:[])]}var mA=L(j());var bp=t=>!t||t instanceof Ye?!1:t instanceof Tr||bp(t.parentNode);function jU(t){if(!t||!(t.item instanceof Ke&&t.item.ast.assignOperatorToken))return[];let e=bp(t?.ast);if(!e&&!(t.ast instanceof Ye&&t.item.ast.values===null)&&!bp(t.beforeAst)&&!bp(t.afterAst))return[];let r=-1;if(t.item.ast.values===null?r=0:r=(t.item.ast.values?.values.findIndex(i=>i&&qy(i,t.beforeAst))??-1)+1,r===-1&&(r=0),t.item.name==="compatible"){let s=t.item.parent.nodeTypes.filter(c=>c).at(-1),o=t.item.ast.quickValues,a;return s instanceof Nt&&s.extends.size&&(a=Array.from(s.extends).filter(c=>!o||!o.includes(c))),o?.filter(c=>c)?.length&&!a?[]:(a??=t.runtime.context.bindingLoader?.getBindings()??[],a.filter(c=>!o||!o.includes(c)).map(c=>({label:`"${c}"`,kind:mA.CompletionItemKind.Variable,insertText:e?c:`"${c}"`})))}let n=t.item.parent.nodeType;return n instanceof Nt?n.properties.find(i=>i.name===t.item?.name)?.getPropertyCompletionItems(t.item,r,e)??[]:[]}function UU(t){if(!t||!(t.item instanceof Ke&&t.ast instanceof Qe&&t.item.ast.values==null||t.item instanceof J)||Ut(t.ast)||t.beforeAst?.parentNode instanceof vr)return[];let e=r=>r.nodeType?.getPropertyListCompletionItems(r)??[];return t.item instanceof Ke?e(t.item.parent):e(t.item)}async function gA(t,e){return _t(t,e,r=>[...jU(r),...UU(r)])}var _p=L(j());async function HU(t){if(t?.ast instanceof Ct||t?.ast instanceof Yn){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t?.ast instanceof Ct?t.ast.name:t.ast.value);if(e){let r=yc(t.ast),n=(await t.runtime.context.getAllParsers()).at(-1);if(r){let i=r?.evaluate(n.cPreprocessorParser.macros);return{contents:{kind:_p.MarkupKind.Markdown,value:["```cpp",`#define ${e.macro.toString()} // = ${i}${typeof i=="number"?` (0x${i.toString(16)})`:""}`,"```"].join(`
286
+ };`,kind:At.CompletionItemKind.Value,insertTextFormat:At.InsertTextFormat.Snippet}))]}function vU(t,e){let r=s=>s?s.parentNode instanceof Wt||s.parentNode instanceof St||s.parentNode instanceof Ue?!1:r(s.parentNode):!0;if(!t||t.item!==null||!Ut(t.ast)||!r(t.ast))return[];let n=s=>xf(s,e).filter(o=>e(o));if(t.ast instanceof ht)return n(t.runtime.rootNode).length?[{label:"/delete-node/",insertText:"/delete-node/ $1;",kind:At.CompletionItemKind.Keyword,insertTextFormat:At.InsertTextFormat.Snippet,sortText:"~"}]:t.runtime.rootNode.nodes.length?[{label:"/delete-node/ &{}",insertText:"/delete-node/ {/$1};",kind:At.CompletionItemKind.Keyword,insertTextFormat:At.InsertTextFormat.Snippet,sortText:"~"}]:[];let i=new Map;return n(t.runtime.rootNode).forEach(s=>i.set(s.label.value,s)),Array.from(i).map(([,s])=>({label:t.ast instanceof se?`${s.label.value}`:`&${s.label.value}`,kind:At.CompletionItemKind.Variable,documentation:s.lastLinkedTo?.toMarkupContent(t.runtime.context.macros)}))}function TU(t,e){if(!t||!(t.item instanceof J)||t.item===null||t.beforeAst&&(!(t.beforeAst?.parentNode instanceof vr)||t.beforeAst?.parentNode instanceof pt))return[];let r=n=>[...n.nodes,...n.deletedNodes.filter(i=>!e(i.by)).map(i=>i.node)].flatMap(i=>({node:i,astNodes:i.definitions.filter(s=>s instanceof Ue)})).filter(i=>i.astNodes.some(e));return t.ast instanceof He||t.ast instanceof Dr||t.beforeAst?.parentNode instanceof Dr?r(t.item).map(n=>({label:`${n.astNodes.at(0)?.name?.toString()}`,kind:At.CompletionItemKind.Variable,documentation:n.node.toMarkupContent(t.runtime.context.macros)})):r(t.item).length?[{label:"/delete-node/",kind:At.CompletionItemKind.Keyword,insertTextFormat:At.InsertTextFormat.Snippet,sortText:"~"}]:[]}function bU(t,e){if(!t||!(t.item instanceof J)||t.beforeAst&&(!(t.beforeAst?.parentNode instanceof vr)||t.beforeAst?.parentNode instanceof Dr))return[];let r=n=>[...n.properties,...n.deletedProperties.filter(i=>!e(i.by)).map(i=>i.property)].flatMap(i=>[i,...i.allReplaced]).filter(i=>e(i.ast));if(t.ast instanceof Qe||t.ast instanceof pt||t.beforeAst?.parentNode instanceof pt){let n=new Map;return r(t.item).forEach(i=>n.set(i.name,i)),Array.from(n).map(([,i])=>({label:`${i.name}`,kind:At.CompletionItemKind.Variable,documentation:i.ast.toPrettyString(t.runtime.context.macros)}))}return r(t.item).length?[{label:"/delete-property/",insertText:"/delete-property/$1;",kind:At.CompletionItemKind.Keyword,sortText:"~",insertTextFormat:At.InsertTextFormat.Snippet}]:[]}function _U(t,e){let r=t?.ast instanceof Dn?t.ast:t?.ast.parentNode;if(!t||!r||!(r instanceof Dn))return[];let n=r.pathParts.slice(0,-1);if(n.some(o=>!o))return[];let i=n.map(o=>o.toString());return(()=>{let o=t.runtime.rootNode.getChildFromScope(["/",...i],e);return[...o?.nodes.filter(a=>!Ut(t.ast)||a.definitions.some(e))??[],...o?.deletedNodes.filter(a=>!e(a.by)).map(a=>a.node)??[]]})().map(o=>({label:`/${[...i,o.fullName].join("/")}`,kind:At.CompletionItemKind.Variable,documentation:o.toMarkupContent(t.runtime.context.macros)}))}function SU(t){return!t||!(t.item instanceof Ke&&t.item.ast.assignOperatorToken)||t.ast instanceof ie?[]:!js(t?.ast)&&!(t.ast instanceof Ye&&t.item.ast.values===null)&&!js(t.beforeAst)&&!js(t.afterAst)?[]:t.item.parent.nodeType instanceof Nt?Array.from([t.runtime.context.parser,...t.runtime.context.overlayParsers].at(-1)?.cPreprocessorParser.macros??[]).map(([,n])=>n.macro.identifier instanceof Jn?{label:`${n.macro.identifier.toString()}`,insertText:`${n.macro.name}(${n.macro.identifier.params.map((i,s)=>i instanceof Ct?`$${s+1}`:"").join(", ")})`,kind:At.CompletionItemKind.Function,sortText:`~${n.macro.name}`,insertTextFormat:At.InsertTextFormat.Snippet}:{label:n.macro.identifier.name,kind:At.CompletionItemKind.Variable,sortText:`~${n.macro.name}`}):[]}async function LC(t,e){return _t(t,e,(r,n)=>[...bU(r,n),...TU(r,n),...vU(r,n),..._U(r,n),...yU(r,n),...gU(r,n),...mU(r),...SU(r)])}var mp=L(j());var BC=require("child_process");var iv=t=>/[A-Za-z0-9_]/.test(t);function NU(t,e){let r=[];for(let n=0;n<e;n++){let i=t[n];i==="("?r.push(n):i===")"&&r.pop()}return r.length?r[r.length-1]:void 0}function $C(t,e){let r=1;for(let n=e+1;n<t.length;n++){let i=t[n];if(i==="(")r++;else if(i===")"&&(r--,r===0))return n}}function FC(t,e,r){let n=[],i=0,s=!1,o=!1,a=e;for(let f=e;f<r;f++){let p=t[f];if(p==="'"&&!o)s=!s;else if(p==='"'&&!s)o=!o;else if(!s&&!o){if(p==="(")i++;else if(p===")")i--;else if(p===","&&i===0){let g=a,h=f,v=g,S=h;for(;v<S&&/\s/.test(t[v]);)v++;for(;S>v&&/\s/.test(t[S-1]);)S--;n.push({start:g,end:h,text:t.slice(v,S)}),a=f+1}}}let c=a,l=r,u=c,d=l;for(;u<d&&/\s/.test(t[u]);)u++;for(;d>u&&/\s/.test(t[d-1]);)d--;return n.push({start:c,end:l,text:t.slice(u,d)}),n}function sv(t){let e=t.trim(),r=/^([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*)\)$/.exec(e);if(!r)return{macro:e};let n=r[1],i=r[2],s=FC(i,0,i.length),o={macro:n,args:[]};return o.args=s.map(a=>{let c=sv(a.text);return c.parent=o,c}),o}function Ni(t,e){let r=t.getText(),n=t.offsetAt(e),i=n,s=n;for(;i>0&&iv(r[i-1]);)i--;for(;s<r.length&&iv(r[s]);)s++;if(r[s]==="("){let v=$C(r,s);v!==void 0&&(s=v+1)}let o=r.slice(i,s),a=o.trim().length?sv(o):void 0,c=NU(r,n);if(c===void 0)return a;let l=$C(r,c);if(l===void 0||!(c<n&&n<=l))return a;let u=c,d=u;for(;d>0&&iv(r[d-1]);)d--;let f=r.slice(d,u);if(!f)return a;let p=FC(r,c+1,l),g={macro:f,args:[]};g.args=p.map(v=>{let S=sv(v.text);return S.parent=g,S});let h=-1;for(let v=0;v<p.length;v++){let S=p[v];if(n>=S.start&&n<=S.end){h=v;break}}if(h>=0){let v=g.args[h];return v.argIndexInParent=h,v}return g}function RU(t,e,r){let i=t.getText().split(/\r?\n/),s=new RegExp(`^\\s*#\\s*define\\s+(${e})\\b(\\s*\\([^)]*\\))?\\s*(.*)$`);for(let o=Math.min(r.line,i.length-1);o>=0;o--){let a=i[o],c=s.exec(a);if(c){let l=a.indexOf(c[0]),u=a.indexOf(c[3],l);return zr.create(o,u>=0?u:a.length)}}}async function ns(t,e,r,n){let i=jC(t,e,r);if(i)return i;let s=await kU(e,n,Ae(t.uri));if(s)return[s,r]}function jC(t,e,r){if(e.startsWith("DT_"))return;let n=RU(t,e,r);if(!n)return;let i=Ni(t,n);if(i)return[i,n]}var PU=(t,e)=>new Promise(r=>{let n=(0,BC.spawn)(t,e,{stdio:["ignore","pipe","pipe"]}),i="";n.stdout.on("data",s=>{i+=s.toString()}),n.on("close",s=>{r(s?"":i)})});async function kU(t,e,r){let n=e.getCompileCommands()?.find(s=>de(s.file,r));if(!n)return;let i=`${n.command.replace(/-(o|c)\s+\S+/g,"")} -E -dM ${n.file}`;try{let[s,...o]=i.split(" "),a=await PU(s,o.filter(u=>!!u)),c=Yi.create(`macros://${n.file}`,"devicetree",0,a),l=jC(c,t,c.positionAt(a.length-1));if(l)return l[0]}catch(s){console.error(s)}}function te(t){return t.toLowerCase().replace(/[@,-\.]/g,"_")}var Mc=L(j());async function UC({macro:t,context:e}){if(t.macro&&"DT_ALIAS".startsWith(t.macro))return[{label:"DT_ALIAS(...)",insertText:"DT_ALIAS($1)",kind:Mc.CompletionItemKind.Function,insertTextFormat:Mc.InsertTextFormat.Snippet}];if(t.parent?.macro!=="DT_ALIAS"||t.argIndexInParent!==0)return[];let r=await e.getRuntime();return r.rootNode.getNode("aliases")?.properties.map(n=>{let i=n.ast.getFlatAstValues()?.at(0),s;return i instanceof se?s=i.linksTo:i instanceof Dn&&(s=i.pathParts.at(-1)?.linksTo),{label:te(n.name),kind:Mc.CompletionItemKind.Property,documentation:s?.toMarkupContent(r.context.macros)}})??[]}var xc=L(j());async function ur(t,e,r){if(!t)return;let i=t?.properties.find(s=>te(s.name)===e)?.ast.getFlatAstValues();return i?.length===0?!0:i?.map(s=>{if(s instanceof nt)return s.path?.pathParts.at(-1)?.linksTo;if(s instanceof se)return s.linksTo;if(s instanceof ie)return s.value;if(s instanceof we){let o=s.evaluate(r.macros);return typeof o=="number"?o:s.toString()}})}async function qf({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PROP"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return o?ur(o,s[1].macro,r):void 0}async function HC(t,e){let r=await qf(t,e);if(typeof r=="boolean")return;let n=r?.at(0);if(r?.length===1&&n instanceof J)return n}async function VC(t,e,r,n){if(r=typeof r=="number"?r:Ee(r),typeof r!="number")return;let i=await ur(t,e,n);if(i===!0)return!0;if(!i)return;let s=i.at(r);if(s)return i.length===1&&i[0]instanceof J?i[0]:s}async function Lf({document:t,macro:e,context:r,position:n},i){if(!(e.macro!=="DT_PROP_BY_IDX"||e.args?.length!==3))return VC(await i({document:t,macro:e.args[0],context:r,position:n}),e.args[1].macro,e.args[2].macro,r)}async function zC(t,e){let r=await Lf(t,e);if(typeof r!="boolean"&&r instanceof J)return r}async function Mr(t,{document:e,context:r,macro:n,position:i},s){return t||(await s({document:e,macro:n,context:r,position:i})??n.macro)}async function $f(t,e,r,n){return Mr(await ur(t,e,r.context),r,n)}async function ra({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_PROP_OR"||e.args?.length!==3)return;let[s,o,a]=e.args,c=await i({document:t,macro:s,context:r,position:n});return await $f(c,o.macro,{macro:a,document:t,context:r,position:n},i)}async function WC(t,e){let r=await ra(t,e);if(r instanceof J)return r;if(typeof r=="boolean")return;let n=r?.at(0);if(r?.length===1&&n instanceof J)return n}async function GC(t){let e=t?.nodeType?.onBus,r=t?.parent?.nodeType?.bus;return t&&r?.length&&r?.some(n=>n===e)?t.parent??void 0:void 0}async function Bf(t,e){let r=t.macro.args;if(t.macro.macro!=="DT_BUS"||r?.length!==1)return;let n=await e({...t,macro:r[0]});return await GC(n)}async function Ff(t,e){let r=(await t.getRuntime()).rootNode.getChild(["/","chosen"]);if(!r)return;let s=r?.properties.find(o=>te(o.name)===e)?.ast.getFlatAstValues()?.at(0);if(s instanceof se)return s.linksTo;if(s instanceof nt)return s.path?.pathParts.at(-1)?.linksTo}async function jf(t){let e=t.macro.args;if(!(t.macro.macro!=="DT_CHOSEN"||e?.length!==1))return await Ff(t.context,e[0].macro)}async function Uf(t,e){let r=await e?.getRuntime();if(r){let n=Qn.getNodeFromPath(["aliases"],r.rootNode,!0),i=n?.properties.find(o=>te(o.name)===t);if(!i)return;let s=i.ast.getFlatAstValues();return s?.[0]instanceof ie?n=r.rootNode.getChild(s[0].value.split("/")):s?.[0]instanceof se?n=s[0].linksTo:s?.[0]instanceof nt&&(n=s[0].path?.pathParts.at(-1)?.linksTo),n}}async function Hf({macro:t,context:e}){if(!(t.macro!=="DT_ALIAS"||t.args?.length!==1))return Uf(t.args[0].macro,e)}async function YC(t,e){return t?.nodes.find(r=>te(r.name)===e)}async function Vf({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_CHILD"||e.args?.length!==2)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});return YC(s,e.args[1].macro)}var ov=(t,e)=>t.nodes.filter(r=>!r.disabled&&r.nodeType).flatMap(r=>[r.nodeType.compatible,...Array.from(r.nodeType.extends)].filter(n=>!!n).map(n=>te(n)).includes(e)?[r,...ov(r,e)]:ov(r,e));async function KC(t,e){let r=await e?.getRuntime();if(r)return ov(r.rootNode,t)}async function av({macro:t,context:e}){if(!(t.macro!=="DT_COMPAT_GET_ANY_STATUS_OKAY"||t.args?.length!==1))return KC(t.args[0].macro,e)}async function XC(t){return(await av(t))?.at(0)}async function JC(t){return t?.parent?.parent??void 0}async function zf({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_GPARENT"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});return JC(s)}var cv=(t,e)=>t.nodes.filter(r=>r.nodeType).sort((r,n)=>r.disabled===n.disabled?0:r.disabled?1:-1).flatMap(r=>[r.nodeType.compatible,...Array.from(r.nodeType.extends)].filter(n=>!!n).map(n=>te(n)).includes(e)?[r,...cv(r,e)]:cv(r,e));async function QC(t,e,r){let n=await r?.getRuntime();if(n)return cv(n.rootNode,e).at(t)}async function Wf({macro:t,context:e}){if(t.macro!=="DT_INST"||t.args?.length!==2)return;let r=Ee(t.args[0].macro);if(typeof r=="number")return QC(r,t.args[1].macro,e)}async function ZC(t,e){let r=await e?.getRuntime(),n=r?.resolvePath([`&${t.trim()}`]);if(r&&n)return Qn.getNodeFromPath(n.slice(1),r.rootNode,!0)}async function Gf({macro:t,context:e}){if(!(t.macro!=="DT_NODELABEL"||t.args?.length!==1))return ZC(t.args[0].macro,e)}async function eD(t){return t?.parent??void 0}async function Yf({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_PARENT"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});return eD(s)}var tD=(t,e)=>{if(!e.length)return t;let r=e.splice(0,1)[0],n=t.nodes.find(i=>te(i.fullName)===r);return n?tD(n,e):void 0};async function Kf(t,e){let r=await e?.getRuntime();if(r)return tD(r.rootNode,t)}async function Xf({macro:t,context:e}){let r=t.args;if(!(t.macro!=="DT_PATH"||!r?.length))return Kf(r.map(n=>n.macro),e)}async function Jf({macro:t,context:e}){let r=t.args;if(!(t.macro!=="DT_ROOT"||r?.length))return(await e.getRuntime()).rootNode}async function na(t,e,r){let n=t?.properties.find(c=>te(c.name)===e);if(!n)return;let i=n?.ast.quickValues?.at(r),s=n.parent.nodeType;if(Array.isArray(i)||!s||!(s instanceof Nt))return;let a=s.properties.find(c=>c.getNameMatch(n.name))?.values(n).findIndex(c=>c===i)??-1;return a===-1?void 0:a}async function Qf(t,e,r,n,i){return Mr(await na(t,e,r),n,i)}async function Zf({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_ENUM_IDX_BY_IDX_OR"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return await Qf(o,s[1].macro,a,{macro:s[3],document:t,context:r,position:n},i)}async function ep({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_ENUM_IDX_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return await Qf(o,s[1].macro,0,{macro:s[2],document:t,context:r,position:n},i)}async function is(t,e,r,n,i){let s=t?.properties.find(d=>te(d.name)===e),o=s?.parent.nodeType;if(!o||!(o instanceof Nt))return;if(typeof r=="string"){let d=s.nexusMapsTo.at(0)?.specifierSpace;if(r=(d?s.parent.getProperty(`${d}-names`)?.ast.quickValues:void 0)?.findIndex(p=>typeof p=="string"&&p.toLowerCase()===r)??-1,r===-1)return}let a=s.nexusMapsTo.at(r),l=a?.target.nodeType?.cellsValues?.find(d=>a.specifierSpace&&d.specifier===a.specifierSpace)?.values?.indexOf(n);if(l===void 0||l===-1)return;let u=a?.mappingValuesAst.at(l);if(u instanceof we){let d=u.evaluate(i.macros);return typeof d!="number"?u.toString():d}}async function ia(t,e,r,n,i,s){return Mr(await is(t,e,r,n,i.context),i,s)}async function tp({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHA_BY_IDX_OR"||s?.length!==5)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return ia(o,s[1].macro,a,s[3].macro,{macro:s[4],document:t,context:r,position:n},i)}async function rp({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHA_BY_NAME_OR"||s?.length!==5)return;let o=await i({document:t,macro:s[0],context:r,position:n});return ia(o,s[1].macro,s[2].macro,s[3].macro,{macro:s[4],document:t,context:r,position:n},i)}async function Zn(t,e,r=0){let n=t?.properties.find(s=>te(s.name)===e);if(r=typeof r=="number"?r:Ee(r??"0"),typeof r!="number")return;let i=n?.ast.getFlatAstValues()?.at(r);if(i instanceof se)return i.linksTo;if(i instanceof nt)return i.path?.pathParts.at(-1)?.linksTo}async function ss({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHANDLE"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return Zn(o,s[1].macro,0)}async function ei({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHANDLE_BY_IDX"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return Zn(o,s[1].macro,s.at(2)?.macro)}async function rD(t,e,r){let n=t?.properties.find(l=>te(l.name)===e);if(!n)return;let i=n.parent.nodeType;if(!i||!(i instanceof Nt))return;let s=n.nexusMapsTo.at(0)?.specifierSpace,a=(s?n.parent.getProperty(`${s}-names`)?.ast.quickValues:void 0)?.findIndex(l=>typeof l=="string"&&l.toLowerCase()===r)??-1;return a===-1?void 0:n.nexusMapsTo.at(a)?.target}async function np({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHANDLE_BY_NAME"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return await rD(o,s[1].macro,s[2].macro)}async function ip({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHA_OR"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:r,position:n});return ia(o,s[1].macro,0,s[2].macro,{macro:s[3],document:t,context:r,position:n},i)}async function sp({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_PROP_BY_PHANDLE_IDX_OR"||e.args?.length!==5)return;let s=await Zn(await i({document:t,macro:e.args[0],context:r,position:n}),e.args[1].macro,e.args[2].macro);return $f(s,e.args[3].macro,{macro:e.args[4],document:t,context:r,position:n},i)}async function op(t,e){if(!t)return;let r=t?.properties.find(n=>te(n.name)===e);return r?.nexusMapsTo.length?r.nexusMapsTo.length:r?.ast.getFlatAstValues()?.length}async function nD(t,e,r,n){if(t)return Mr(await op(t,e),r,n)}async function ap({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PROP_LEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return o?nD(o,s[1].macro,{macro:s[2],document:t,context:r,position:n},i):void 0}async function sa(t,e){if(!t)return;let n=t?.properties.find(i=>te(i.name)===e)?.ast.getFlatAstValues();if(n?.length===1&&n[0]instanceof ie)return te(n[0].value)}async function iD(t,e,r,n){if(t)return Mr(await sa(t,e),r,n)}async function cp({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_TOKEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return iD(o,s[1].macro,{document:t,macro:s[2],context:r,position:n},i)}async function lp(t,e){if(!t)return;let n=t?.properties.find(i=>te(i.name)===e)?.ast.getFlatAstValues();if(n?.length===1&&n[0]instanceof ie)return n[0].value}async function sD(t,e,r,n){if(t)return Mr(await lp(t,e),r,n)}async function up({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_UNQUOTED_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return sD(o,s[1].macro,{document:t,macro:s[2],context:r,position:n},i)}async function dp(t,e){return(await sa(t,e))?.toUpperCase()}async function oD(t,e,r,n){if(t)return Mr(await dp(t,e),r,n)}async function fp({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_UPPER_TOKEN_OR"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return oD(o,s[1].macro,{document:t,macro:s[2],context:r,position:n},i)}function An(t){return async(e,r)=>{let n=await t(e,r);if(n instanceof J)return n}}async function M({macro:t,document:e,context:r,position:n}){["DT_ALIAS","DT_NODELABEL"].some(a=>a===t.parent?.macro)||t.parent?.macro==="DT_CHILD"&&t.argIndexInParent===1?t=t.parent:t.parent?.macro==="DT_HAS_ALIAS"?(t=t.parent,t.macro="DT_ALIAS"):t.parent?.macro==="DT_PATH"&&(t.parent.args=t.parent.args?.slice(0,(t.argIndexInParent??0)+1)??[],t=t.parent);let s=await[Bf,jf,Hf,Vf,XC,zf,Wf,Gf,Yf,Xf,ss,ei,np,zC,HC,WC,Jf,An(Zf),An(ep),An(tp),An(rp),An(ip),An(sp),An(ap),An(ra),An(cp),An(up),An(fp)].reduce((a,c)=>a.then(l=>l||c({macro:t,document:e,context:r,position:n},M)),Promise.resolve(void 0));if(s)return Array.isArray(s)?s.at(0):s;let o=await ns(e,t.macro,n,r);if(o)return M({document:e,macro:o[0],context:r,position:n})}async function aD({macro:t,document:e,context:r,position:n}){return t.macro&&t.macro&&"DT_CHILD".startsWith(t.macro)?[{label:"DT_CHILD(...)",insertText:"DT_CHILD($1, $2)",kind:xc.CompletionItemKind.Function,insertTextFormat:xc.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_CHILD"||t.argIndexInParent!==1||!t.parent.args?.length?[]:(await M({document:e,macro:t.parent.args[0],context:r,position:n}))?.nodes.map(s=>({label:te(s.fullName),kind:xc.CompletionItemKind.Class,documentation:s.toMarkupContent(r.macros)}))??[]}var qc=L(j());function cD({macro:t,context:e}){return t.macro&&"DT_COMPAT_GET_ANY_STATUS_OKAY".startsWith(t.macro)?[{label:"DT_COMPAT_GET_ANY_STATUS_OKAY(...)",insertText:"DT_COMPAT_GET_ANY_STATUS_OKAY($1)",kind:qc.CompletionItemKind.Function,insertTextFormat:qc.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_COMPAT_GET_ANY_STATUS_OKAY"||t.argIndexInParent!==0?[]:e.bindingLoader?.getBindings().map(r=>({label:te(r),kind:qc.CompletionItemKind.Property}))??[]}var Lc=L(j());function lD({macro:t,context:e}){return t.macro&&"DT_INST".startsWith(t.macro)?[{label:"DT_INST(...)",insertText:"DT_INST($1, $2)",kind:Lc.CompletionItemKind.Function,insertTextFormat:Lc.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_INST"||t.argIndexInParent!==1?[]:e.bindingLoader?.getBindings().map(r=>({label:te(r),kind:Lc.CompletionItemKind.Property}))??[]}var $c=L(j());async function uD({macro:t,context:e}){if(t.macro&&"DT_NODELABEL".startsWith(t.macro))return[{label:"DT_NODELABEL(...)",insertText:"DT_NODELABEL($1)",kind:$c.CompletionItemKind.Function,insertTextFormat:$c.InsertTextFormat.Snippet}];let r=await e.getRuntime();return t.parent?.macro!=="DT_NODELABEL"||t.argIndexInParent!==0?[]:await Promise.all(r.rootNode.allDescendantsLabels.map(async n=>({label:n.label.value,kind:$c.CompletionItemKind.Property,documentation:n.lastLinkedTo?.toMarkupContent(r.context.macros)}))??[])}var Bc=L(j());async function dD({macro:t,context:e}){return t.macro&&t.macro&&"DT_PATH".startsWith(t.macro)?[{label:"DT_PATH(...)",insertText:"DT_PATH($1)",kind:Bc.CompletionItemKind.Function,insertTextFormat:Bc.InsertTextFormat.Snippet}]:t.parent?.macro!=="DT_PATH"||!t.parent.args?.length?[]:(await Kf(t.parent.args.slice(0,-1).map(n=>n.macro),e))?.nodes.map(n=>({label:te(n.fullName),kind:Bc.CompletionItemKind.Class,documentation:n.toMarkupContent(e.macros)}))??[]}var fD=L(j());async function pD({macro:t,context:e}){if(t.macro&&t.macro&&"DT_ROOT".startsWith(t.macro)){let r=await e.getRuntime();return[{label:"DT_ROOT",kind:fD.CompletionItemKind.Class,documentation:r.rootNode.toMarkupContent(r.context.macros)}]}return[]}var pp=L(j());function hD({macro:t}){return t.macro&&t.macro&&"DT_SAME_NODE".startsWith(t.macro)?[{label:"DT_SAME_NODE(...)",insertText:"DT_SAME_NODE($1, $2)",kind:pp.CompletionItemKind.Snippet,insertTextFormat:pp.InsertTextFormat.Snippet}]:[]}var Fc=L(j());async function Q({macro:t,document:e,position:r,context:n},i,s,o,a,c=l=>M({document:e,macro:l,context:n,position:r})){if(t.macro&&t.macro&&i.startsWith(t.macro))return[{label:`${i}(...)`,insertText:`${i}(${Array(o).map((d,f)=>`${f+1}`).join(", ")})`,kind:Fc.CompletionItemKind.Function,insertTextFormat:Fc.InsertTextFormat.Snippet}];if(t.parent?.macro!==i||t.argIndexInParent!==s||!t.parent.args?.length)return[];let l=await c(t.parent.args[0]);return(a?l?.properties.filter(a):l?.properties)?.map(d=>({label:te(d.name),kind:Fc.CompletionItemKind.Property,documentation:d.toPrettyString(n.macros)}))??[]}async function mD(t){return Q(t,"DT_ENUM_HAS_VALUE",1,3)}async function gD(t){return Q(t,"DT_ENUM_HAS_VALUE_BY_IDX",1,4)}async function yD(t){return Q(t,"DT_ENUM_IDX",1,2)}async function vD(t){return Q(t,"DT_ENUM_IDX_BY_IDX",1,3)}async function TD(t){return Q(t,"DT_ENUM_IDX_BY_IDX_OR",1,4)}async function bD(t){return Q(t,"DT_ENUM_IDX_OR",1,3)}var _D=L(j());async function Ri({macro:t,document:e,context:r,position:n},i,s,o){if(t.parent?.macro!==i||t.argIndexInParent!==s||!t.parent.args?.length)return[];let c=(await M({document:e,macro:t.parent.args[0],context:r,position:n}))?.properties.find(f=>te(f.name)===t.parent?.args?.at(1)?.macro),l=0;if(typeof o=="string"){let f=c?.nexusMapsTo.at(0)?.specifierSpace;if(l=(f?c.parent.getProperty(`${f}-names`)?.ast.quickValues:void 0)?.findIndex(g=>typeof g=="string"&&g.toLowerCase()===o)??-1,l===-1)return[]}let u=c?.nexusMapsTo.at(l);return u?.target.nodeType?.cellsValues?.find(f=>u.specifierSpace&&f.specifier===u.specifierSpace)?.values.map(f=>({label:te(f),kind:_D.CompletionItemKind.Property}))??[]}async function SD(t){return t.macro.argIndexInParent===2?Ri(t,"DT_PHA",2,0):Q(t,"DT_PHA",1,3,e=>!!e.nexusMapsTo.length)}var ND=L(j());async function wU({document:t,macro:e,position:r,context:n},i){if(e.parent?.macro!==i||!e.parent.args?.length)return[];let o=(await M({document:t,macro:e.parent.args[0],context:n,position:r}))?.properties.find(a=>te(a.name)===e.parent?.args?.at(1)?.macro);return Array(o?.nexusMapsTo.length??0)?.map((a,c)=>({label:c.toString(),kind:ND.CompletionItemKind.Property}))??[]}async function RD(t){if(t.macro.argIndexInParent===2)return wU(t,"DT_PHA_BY_IDX");if(t.macro.argIndexInParent===3){let e=t.macro.parent?.args?Ee(t.macro.parent.args[2].macro):void 0;return typeof e!="number"?[]:Ri(t,"DT_PHA_BY_IDX",3,e)}return Q(t,"DT_PHA_BY_IDX",1,3,e=>!!e.nexusMapsTo.length)}var PD=L(j());async function jc({document:t,macro:e,context:r,position:n},i){if(e.parent?.macro!==i||!e.parent.args?.length)return[];let o=(await M({document:t,macro:e.parent.args[0],context:r,position:n}))?.properties.find(l=>te(l.name)===e.parent?.args?.at(1)?.macro),a=o?.nexusMapsTo.at(0)?.specifierSpace;return(a?o.parent.getProperty(`${a}-names`)?.ast.quickValues:void 0)?.filter(l=>typeof l=="string")?.map(l=>({label:l,kind:PD.CompletionItemKind.Property}))??[]}async function kD(t){let{macro:e}=t;return e.argIndexInParent===2?jc(t,"DT_PHA_BY_NAME"):e.argIndexInParent===3?e.parent?.args?.[2]?.macro?Ri(t,"DT_PHA_BY_NAME",3,e.parent.args[2].macro):[]:Q(t,"DT_PHA_BY_NAME",1,3,r=>!!r.nexusMapsTo.length)}async function wD(t){let{macro:e}=t;return e.argIndexInParent===2?jc(t,"DT_PHA_BY_NAME_OR"):e.argIndexInParent===3?e.parent?.args?.[2]?.macro?Ri(t,"DT_PHA_BY_NAME_OR",3,e.parent.args[2].macro):[]:Q(t,"DT_PHA_BY_NAME_OR",1,3,r=>!!r.nexusMapsTo.length)}async function ED(t){let{macro:e}=t;return e.argIndexInParent===2?Ri(t,"DT_PHA_OR",2,0):Q(t,"DT_PHA_OR",1,3,r=>!!r.nexusMapsTo.length)}async function hp(t){return Q(t,"DT_PHANDLE",1,2,e=>!!e.ast.getFlatAstValues()?.some(r=>r instanceof se||r instanceof nt))}async function oa(t){return Q(t,"DT_PHANDLE_BY_IDX",1,3,e=>!!e.ast.getFlatAstValues()?.some(r=>r instanceof se||r instanceof nt))}async function CD(t){let{macro:e}=t;return e.argIndexInParent===2?jc(t,"DT_PHANDLE_BY_NAME"):Q(t,"DT_PHANDLE_BY_NAME",1,3,r=>!!r.ast.getFlatAstValues()?.some(n=>n instanceof se||n instanceof nt))}async function DD(t){return Q(t,"DT_PROP",1,2,e=>!e.nexusMapsTo.length)}async function AD(t){return Q(t,"DT_PROP_BY_IDX",1,3,e=>!e.nexusMapsTo.length)}async function ID(t){let{macro:e}=t;return(e.argIndexInParent===1||e.argIndexInParent===2)&&e.parent?.macro==="DT_PROP_BY_PHANDLE_IDX"?oa({...t,macro:{...e,parent:e.parent?{...e.parent,macro:"DT_PHANDLE_BY_IDX"}:void 0}}):Q(t,"DT_PROP_BY_PHANDLE_IDX",3,4,r=>!r.nexusMapsTo.length,()=>ei({...t,macro:{macro:"DT_PHANDLE_BY_IDX",args:e.parent?.args?.slice(0,3)}},M))}async function OD(t){let{macro:e}=t;return e.argIndexInParent===1&&e.parent?.macro==="DT_PROP_BY_PHANDLE"?hp({...t,macro:{...e,parent:e.parent?{...e.parent,macro:"DT_PHANDLE"}:void 0}}):Q(t,"DT_PROP_BY_PHANDLE",2,3,r=>!r.nexusMapsTo.length,()=>ss({...t,macro:{macro:"DT_PHANDLE",args:e.parent?.args?.slice(0,2)}},M))}async function MD(t){let{macro:e}=t;return(e.argIndexInParent===1||e.argIndexInParent===2)&&e.parent?.macro==="DT_PROP_BY_PHANDLE_IDX_OR"?oa({...t,macro:{...e,parent:e.parent?{...e.parent,macro:"DT_PHANDLE_BY_IDX"}:void 0}}):Q(t,"DT_PROP_BY_PHANDLE_IDX_OR",3,5,r=>!r.nexusMapsTo.length,()=>ei({...t,macro:{macro:"DT_PHANDLE_BY_IDX",args:e.parent?.args?.slice(0,3)}},M))}async function xD(t){return Q(t,"DT_PROP_HAS_IDX",1,3,e=>!e.nexusMapsTo.length)}async function qD(t){return Q(t,"DT_PROP_HAS_NAME",1,3,e=>!e.nexusMapsTo.length)}async function LD(t){return Q(t,"DT_PROP_LAST",1,2,e=>!e.nexusMapsTo.length)}async function $D(t){return Q(t,"DT_PROP_LEN",1,2,e=>!e.nexusMapsTo.length)}async function BD(t){return Q(t,"DT_PROP_LEN_OR",1,2,e=>!e.nexusMapsTo.length)}async function FD(t){return Q(t,"DT_PROP_OR",1,2,e=>!e.nexusMapsTo.length)}async function jD(t){return Q(t,"DT_STRING_TOKEN",1,2,e=>{let r=e.ast.getFlatAstValues();return r?.length===1&&r[0]instanceof ie})}async function UD(t){return Q(t,"DT_STRING_TOKEN_BY_IDX",1,3,e=>{let r=e.ast.getFlatAstValues();return!!r?.length&&r.every(n=>n instanceof ie)})}async function HD(t){return Q(t,"DT_STRING_TOKEN_OR",1,3,e=>{let r=e.ast.getFlatAstValues();return r?.length===1&&r[0]instanceof ie})}async function VD(t){return Q(t,"DT_STRING_UNQUOTED",1,2,e=>{let r=e.ast.getFlatAstValues();return r?.length===1&&r[0]instanceof ie})}async function zD(t){return Q(t,"DT_STRING_UNQUOTED_BY_IDX",1,3,e=>{let r=e.ast.getFlatAstValues();return!!r?.length&&r.every(n=>n instanceof ie)})}async function WD(t){return Q(t,"DT_STRING_UNQUOTED_OR",1,3,e=>{let r=e.ast.getFlatAstValues();return r?.length===1&&r[0]instanceof ie})}async function GD(t){return Q(t,"DT_STRING_UPPER_TOKEN",1,2,e=>{let r=e.ast.getFlatAstValues();return r?.length===1&&r[0]instanceof ie})}async function YD(t){return Q(t,"DT_STRING_UPPER_TOKEN_BY_IDX",1,3,e=>{let r=e.ast.getFlatAstValues();return!!r?.length&&r.every(n=>n instanceof ie)})}async function KD(t){return Q(t,"DT_STRING_UPPER_TOKEN_OR",1,3,e=>{let r=e.ast.getFlatAstValues();return r?.length===1&&r[0]instanceof ie})}var Uc=L(j());async function XD({macro:t,context:e}){return t.parent?.macro==="DT_ON_BUS"&&t.argIndexInParent===1?e.bindingLoader?.getBusTypes().map(r=>({label:te(r),kind:Uc.CompletionItemKind.Enum}))??[]:t.macro&&"DT_ON_BUS".startsWith(t.macro)?[{label:"DT_ON_BUS(...)",insertText:"DT_ON_BUS($1, $2)",kind:Uc.CompletionItemKind.Function,insertTextFormat:Uc.InsertTextFormat.Snippet}]:[]}async function JD(t){return Q(t,"DT_CHOSEN",0,1,void 0,async()=>(await t.context.getRuntime()).rootNode.getChild(["/","chosen"]))}async function QD(t){return Q(t,"DT_HAS_CHOSEN",0,1,void 0,async()=>(await t.context.getRuntime()).rootNode.getChild(["/","chosen"]))}var EU=["DT_BUS","DT_CHILD_NUM","DT_CHILD_NUM_STATUS_OKAY","DT_GPARENT","DT_HAS_ALIAS","DT_NODE_CHILD_IDX","DT_NODE_FULL_NAME","DT_NODE_FULL_NAME_TOKEN","DT_NODE_FULL_NAME_UNQUOTED","DT_NODE_FULL_NAME_UPPER_TOKEN","DT_NODE_HASH","DT_NODE_PATH","DT_NODELABEL_STRING_ARRAY","DT_PARENT"];async function ZD(t,e,r){if(!r)return[];let n=Ni(r,t.position);return n?(await Promise.all([XD,JD,QD,UC,aD,cD,lD,CU,uD,dD,pD,hD,gD,mD,vD,TD,yD,bD,RD,kD,wD,SD,oa,CD,hp,ED,AD,OD,ID,MD,DD,xD,qD,LD,$D,BD,FD,jD,UD,HD,VD,zD,WD,GD,YD,KD].flatMap(async i=>await i({document:r,context:e,macro:n,position:t.position})))).flat():[]}function CU({macro:t}){return t.macro?EU.filter(e=>e.startsWith(t.macro)).map(e=>({label:`${e}(...)`,insertText:`${e}($1)`,kind:mp.CompletionItemKind.Function,insertTextFormat:mp.InsertTextFormat.Snippet})):[]}var ti=L(j());function DU(t){if(!t||t.item===null||!(t.ast instanceof Qe))return[];let e=n=>n.replacedBy?e(n.replacedBy):n,r=n=>[n.ast,...n.allReplaced.map(i=>i.ast),n.parent.deletedProperties.find(i=>i.property===n)?.by??[]].map(i=>{if(i instanceof Ye)return ti.Location.create(ve(i.uri),fe(i.propertyName??i));if(i instanceof pt)return ti.Location.create(ve(i.uri),fe(i.propertyName??i))}).filter(i=>i);if(t.item instanceof Ke&&t.ast instanceof Qe)return r(e(t.item));if(t.item instanceof J&&t.ast instanceof Qe&&t.ast.parentNode instanceof pt){let n=t.item.deletedProperties.find(i=>i.by===t.ast.parentNode)?.property;if(n)return r(n)}return[]}function AU(t){if(!t)return[];let e=r=>{let i=t.runtime.rootNode.getNode("aliases")?.properties.filter(o=>{let a=o.ast.quickValues;if(a?.length===1&&typeof a[0]=="string"&&t.runtime.rootNode.getChild(a[0].split("/"))===r)return!0}).map(o=>o.ast)??[],s=r.parent?.deletedNodes.filter(o=>o.node===r&&(o.by.nodeNameOrRef instanceof He?o.by.nodeNameOrRef!==t.ast:!r.linkedRefLabels.some(a=>a!==t.ast))).map(o=>o.by.nodeNameOrRef)??[];return[...i,...r.linkedRefLabels,...r.linkedNodeNamePaths,...r.definitions,...s].map(o=>{if(o instanceof St)return ti.Location.create(ve(o.uri),fe(o.name??o));if(o instanceof Ue)return ti.Location.create(ve(o.uri),fe(o.name??o));if(o instanceof He)return ti.Location.create(ve(o.uri),fe(o));if(o instanceof He)return ti.Location.create(ve(o.uri),fe(o));if(o instanceof se)return ti.Location.create(ve(o.uri),fe(o.label??o));if(o instanceof Ye)return ti.Location.create(ve((o.values??o)?.uri),fe(o.values??o))}).filter(o=>o)};if(t.item instanceof J&&!Ut(t.ast))return e(t.item);if(t.ast instanceof er&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo)return e(t.ast.parentNode.linksTo);if(t.ast instanceof He&&t.ast.linksTo)return Ut(t.ast)?[...e(t.ast.linksTo),ti.Location.create(ve(t.ast.uri),fe(t.ast))]:e(t.ast.linksTo);if(t?.ast instanceof ie&&t.item instanceof Ke&&t.item.parent.name==="aliases"){let r=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(r)return e(r)}return[]}async function eA(t,e){return _t(t,e,r=>[...AU(r),...DU(r)])}var Pi=L(j());function tA(t){if(!t||t.item===null||!(t.ast instanceof Qe))return[];let e=n=>n.replacedBy?e(n.replacedBy):n,r=n=>[n.ast,...n.allReplaced.map(i=>i.ast),n.parent.deletedProperties.find(i=>i.property===n)?.by??[]].map(i=>{if((i instanceof Ye||i instanceof pt)&&i.propertyName)return Pi.Location.create(ve(i.uri),fe(i.propertyName))}).filter(i=>i);if(t.item instanceof Ke&&t.ast instanceof Qe)return r(e(t.item));if(t.item instanceof J&&t.ast instanceof Qe&&t.ast.parentNode instanceof pt){let n=t.item.deletedProperties.find(i=>i.by===t.ast.parentNode)?.property;if(n)return r(n)}return[]}function rA(t,e){if(!e||!(e.ast instanceof er))return[];"newName"in t&&(e.ast.parentNode instanceof se&&t.newName.startsWith("&")?t.newName=t.newName.slice(1):e.ast.parentNode instanceof Ji&&t.newName.endsWith(":")&&(t.newName=t.newName.slice(0,-1)));let r=e.ast.value,n=i=>[...i.definitions.filter(s=>s instanceof Ue).flatMap(s=>s.labels.map(o=>o.label)),...i.referencedBy.flatMap(s=>s.labels.map(o=>o.label)),...i.linkedRefLabels.map(s=>s.label)].filter(s=>s?.value===r).map(s=>{if(s)return Pi.Location.create(ve(s.uri),fe(s))}).filter(s=>s);return e.item instanceof J&&!Ut(e.ast)?n(e.item):e.ast instanceof er&&e.ast.parentNode instanceof se&&e.ast.parentNode.linksTo?n(e.ast.parentNode.linksTo):[]}function nA(t){if(!t||!(t.ast instanceof He))return[];let e=r=>{let i=t.runtime.rootNode.getNode("aliases")?.properties.filter(o=>{let a=o.ast.quickValues;if(a?.length===1&&typeof a[0]=="string"){let c=t.runtime.rootNode.getChild(a[0].split("/"));if(c?.isChildOf(r)||c===r)return!0}}).map(o=>o.ast)??[],s=r.parent?.deletedNodes.filter(o=>o.node===r&&o.by.nodeNameOrRef!==t.ast).map(o=>o.by.nodeNameOrRef)??[];return[...i,...r.linkedNodeNamePaths,...r.definitions,...s].map(o=>{if(o instanceof Ue&&o.name)return Pi.Location.create(ve(o.uri),fe(o.name));if(o instanceof He)return Pi.Location.create(ve(o.uri),fe(o));if(o instanceof Ye&&o.values?.values[0]?.value&&o.values?.values[0]?.value instanceof ie){let a=o.values.values[0].value,c=fe(a),l=a.value.split("/"),u=r.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,Pi.Location.create(ve(o.values.values[0].uri),c)}}).filter(o=>o)};return t.item instanceof J&&!Ut(t.ast)?e(t.item):t.ast instanceof He&&t.ast.linksTo?Ut(t.ast)?[...e(t.ast.linksTo),Pi.Location.create(ve(t.ast.uri),fe(t.ast))]:e(t.ast.linksTo):[]}async function iA(t,e){let r={};return(await _t(t,e,i=>[...nA(i),...rA(t,i),...tA(i)])).forEach(i=>{r[i.uri]??=[],r[i.uri].push(Pi.TextEdit.replace(i.range,t.newName))}),{changes:r}}async function sA(t,e){let r=await _t(t,e,n=>[...nA(n),...rA(t,n),...tA(n)]);if(r.some(n=>e?.settings.lockRenameEdits?.some(i=>Ae(n.uri).startsWith(i))))throw new Error('Path is locked by user setting "lockRenameEdits"');return{defaultBehavior:!!r.length}}var aa=L(j());var gp=t=>[...t.definitions,...t.referencedBy].map(e=>{if(e instanceof St)return aa.Location.create(ve(e.uri),fe(e));if(e instanceof Ue)return aa.Location.create(ve(e.uri),fe(e));if(e instanceof Wt)return aa.Location.create(ve(e.uri),fe(e))}).filter(e=>e),aA=t=>t.replacedBy?aA(t.replacedBy):t,oA=t=>[t.ast,...t.allReplaced.map(e=>e.ast)].map(e=>{if(e instanceof Ye)return aa.Location.create(ve(e.uri),fe(e.propertyName??e))}).filter(e=>e);function IU(t){if(!t||t.item===null||!(t.ast instanceof Qe))return[];if(t.item instanceof Ke&&t.ast instanceof Qe)return oA(aA(t.item));if(t.item instanceof J&&t.ast instanceof Qe&&t.ast.parentNode instanceof pt){let e=t.item.deletedProperties.find(r=>r.by===t.ast.parentNode)?.property;if(e)return oA(e)}return[]}function OU(t){if(!t)return[];if(t.item instanceof J&&!Ut(t.ast))return gp(t.item);if(t.ast instanceof er&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo)return gp(t.ast.parentNode.linksTo);if(t.ast instanceof He&&t.ast.linksTo)return gp(t.ast.linksTo);if(t?.ast instanceof ie&&t.item instanceof Ke&&t.item.parent.name==="aliases"){let e=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(e)return gp(e)}return[]}function MU(t){if(t?.ast instanceof Ct||t?.ast instanceof Yn){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t.ast instanceof Ct?t.ast.name:t.ast.value);if(e)return[aa.Location.create(ve(e.macro.uri),fe(e.macro.identifier))]}return[]}async function cA(t,e){return _t(t,e,r=>[...OU(r),...IU(r),...MU(r)])}var Hc=L(j());var os=t=>{let e=t.definitions.at(0);return e?Hc.Location.create(ve(e.uri),fe(e)):void 0},yp=t=>t.replaces?yp(t.replaces):t,vp=t=>{let e=yp(t);return e?Hc.Location.create(ve(e.ast.uri),fe(e.ast)):void 0};function xU(t){if(!t||t.item===null||!(t.ast instanceof Qe))return;let e=r=>Hc.Location.create(ve(r.ast.uri),fe(r.ast.propertyName??r.ast));if(t.item instanceof Ke&&t.ast instanceof Qe)return e(yp(t.item));if(t.item instanceof J&&t.ast instanceof Qe&&t.ast.parentNode instanceof pt){let r=t.item.deletedProperties.find(n=>n.by===t.ast.parentNode)?.property;if(r)return e(yp(r))}}function qU(t){if(t){if(t.item instanceof J&&!Ut(t.ast))return os(t.item);if(t.ast instanceof er&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo)return os(t.ast.parentNode.linksTo);if(t.ast instanceof He&&t.ast.linksTo)return os(t.ast.linksTo);if(t?.ast instanceof ie&&t.item instanceof Ke&&t.item.parent.name==="aliases"){let e=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(e)return os(e)}}}function LU(t){if(t?.ast instanceof Ct||t?.ast instanceof Yn){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t.ast instanceof Ct?t.ast.name:t.ast.value);if(e)return Hc.Location.create(ve(e.macro.uri),fe(e.macro.identifier))}}async function lA(t,e){return(await _t(t,e,r=>[qU(r)||xU(r)||LU(r)])).at(0)}var $U=["DT_PROP","DT_PROP_LEN","DT_PROP_LEN_OR","DT_PROP_HAS_IDX","DT_PROP_HAS_NAME","DT_PROP_BY_IDX","DT_PROP_LAST","DT_PROP_OR","DT_ENUM_IDX_BY_IDX","DT_ENUM_IDX","DT_ENUM_IDX_BY_IDX_OR","DT_ENUM_IDX_OR","DT_ENUM_HAS_VALUE_BY_IDX","DT_ENUM_HAS_VALUE","DT_STRING_TOKEN","DT_STRING_TOKEN_OR","DT_STRING_UPPER_TOKEN","DT_STRING_UPPER_TOKEN_OR","DT_STRING_UNQUOTED","DT_STRING_UNQUOTED_OR","DT_STRING_TOKEN_BY_IDX","DT_STRING_UPPER_TOKEN_BY_IDX","DT_STRING_UNQUOTED_BY_IDX","DT_PROP_BY_PHANDLE_IDX","DT_PROP_BY_PHANDLE_IDX_OR","DT_PROP_BY_PHANDLE","DT_PHA_BY_IDX","DT_PHA_BY_IDX_OR","DT_PHA","DT_PHA_OR","DT_PHA_BY_NAME","DT_PHA_BY_NAME_OR","DT_PHANDLE_BY_NAME","DT_PHANDLE_BY_IDX","DT_PHANDLE"];async function Tp({macro:t,document:e,context:r,position:n}){if($U.some(i=>i===t.parent?.macro)&&t.argIndexInParent===1&&t.parent?.args?.[0])return(await M({document:e,context:r,position:n,macro:t.parent.args[0]}))?.properties.find(s=>te(s.name)===t.macro);if(["DT_PROP_BY_PHANDLE"].some(i=>i===t.parent?.macro)&&t.argIndexInParent===2&&t.parent?.args?.[0]&&t.parent?.args?.[1])return(await ss({document:e,context:r,position:n,macro:{macro:"DT_PHANDLE",args:t.parent.args.slice(0,2)}},M))?.properties.find(s=>te(s.name)===t.macro);if(["DT_PROP_BY_PHANDLE_IDX","DT_PROP_BY_PHANDLE_IDX_OR"].some(i=>i===t.parent?.macro)&&t.argIndexInParent===3&&t.parent?.args?.[0]&&t.parent?.args?.[1]&&t.parent?.args?.[3])return(await ei({document:e,context:r,position:n,macro:{macro:"DT_PHANDLE_BY_IDX",args:t.parent.args.slice(0,3)}},M))?.properties.find(s=>te(s.name)===t.macro);if(["DT_CHOSEN","DT_HAS_CHOSEN"].some(i=>i===t.parent?.macro)&&t.argIndexInParent===0&&t.parent?.args?.[0])return(await r.getRuntime()).rootNode.getChild(["/","chosen"])?.properties.find(i=>te(i.name)===t.macro)}async function uA(t,e,r){if(!r)return;let n=Ni(r,t.position);return dA(n,t.position,e,r)}async function dA(t,e,r,n){if(!t?.macro)return;let i=await M({document:n,macro:t,context:r,position:e});if(i)return os(i);let s=await Tp({document:n,macro:t,context:r,position:e});if(s)return vp(s);let o=await ns(n,t.macro,e,r);if(o)return dA(o[0],o[1],r,n)}async function fA(t,e,r){if(!r)return;let n=Ni(r,t.position);return pA(n,t.position,e,r)}async function pA(t,e,r,n){if(!t?.macro)return;let i=await M({document:n,macro:t,context:r,position:e});if(i)return os(i);let s=await Tp({document:n,macro:t,context:r,position:e});if(s)return vp(s);let o=await ns(n,t.macro,e,r);if(o)return pA(o[0],o[1],r,n)}var le=L(j());var BU=(t,e,r,n,i)=>{switch(r){case 1:return[{title:"Add semicolon",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character),";")]}}}];case 2:return[{title:"Add open curly",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character)," {")]}}}];case 29:return[{title:"Remove white space",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.replace(le.Range.create(le.Position.create(n.range.start.line,t.pos.colEnd),le.Position.create(n.range.end.line,e.pos.col)),"")]}}}];case 3:return[{title:"Add close curly",diagnostics:[n],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character),"}")]}}}];case 19:return[{title:"Add '/'",diagnostics:[n],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character),"/")]}}}];case 28:return[{title:"Add comma",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character),",")]}}}];case 21:return[{title:"Add '/'",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character),"/")]}}}];case 23:return[{title:"Remove ';'",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.del(n.range)]}}}];case 34:return[{title:"Complete Keyword '/delete-node/",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.replace(n.range,"/delete-node/")]}}}];case 35:return[{title:"Complete Keyword '/delete-property/",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.replace(n.range,"/delete-property/")]}}}];case 25:return[{title:"Complete Keyword '/delete-property/",diagnostics:[n],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.replace(n.range,"/delete-property/")]}}},{title:"Complete Keyword '/delete-node/",diagnostics:[n],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.replace(n.range,"/delete-node/")]}}}];case 12:return[{title:"Add '>'",diagnostics:[n],kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[i]:[le.TextEdit.insert(le.Position.create(n.range.end.line,n.range.end.character),">")]}}}];default:return}},FU=(t,e,r,n,i)=>{if(!n?.length)return[];switch(t){case 0:return[{title:i??`Add Property "${n[0].newText.split("=",1)[0].replace(";","").trim()}"`,diagnostics:[e],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[r]:n}}}];case 27:return[{title:i??"Remove Property",diagnostics:[e],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[r]:n}}}];case 26:return[{title:i??"TODO",diagnostics:[e],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[r]:n}}}];case 36:return[{title:i??"TODO",diagnostics:[e],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[r]:n}}}];case 25:return n?[{title:i??"TODO",diagnostics:[e],kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[r]:n}}}]:[];default:return}};function hA(t){let e=t.context.diagnostics.flatMap(a=>{let c=a.data;switch(c?.issues.type){case"SyntaxIssue":return c?.issues.items.flatMap(l=>BU(c.firstToken,c.lastToken,l,a,t.textDocument.uri));case"StandardTypeIssue":return c?.issues.items.flatMap(l=>FU(l,a,t.textDocument.uri,c.issues.edit?Array.isArray(c.issues.edit)?c.issues.edit:[c.issues.edit]:void 0,c.issues.codeActionTitle))}}).filter(a=>!!a),r=e.filter(a=>a.kind===le.CodeActionKind.SourceFixAll),n=e.filter(a=>a.title.startsWith("Add Property")),i=e.filter(a=>a.kind!==le.CodeActionKind.SourceFixAll),s=r.flatMap(a=>a.edit?.changes?.[t.textDocument.uri]??[]),o=new Map;return n.forEach(a=>{let c=a.edit.changes[t.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)}),[...i,...r.map(a=>({...a,kind:le.CodeActionKind.QuickFix})),...s.length?[{title:"Fix All",kind:le.CodeActionKind.SourceFixAll,isPreferred:!0,edit:{changes:{[t.textDocument.uri]:s}}}]:[],...Array.from(o.values()).flatMap(a=>a.length>1?{title:"Add All Missing Properties",kind:le.CodeActionKind.QuickFix,isPreferred:!0,edit:{changes:{[t.textDocument.uri]:a}}}:[])]}var mA=L(j());var bp=t=>!t||t instanceof Ye?!1:t instanceof Tr||bp(t.parentNode);function jU(t){if(!t||!(t.item instanceof Ke&&t.item.ast.assignOperatorToken))return[];let e=bp(t?.ast);if(!e&&!(t.ast instanceof Ye&&t.item.ast.values===null)&&!bp(t.beforeAst)&&!bp(t.afterAst))return[];let r=-1;if(t.item.ast.values===null?r=0:r=(t.item.ast.values?.values.findIndex(i=>i&&qy(i,t.beforeAst))??-1)+1,r===-1&&(r=0),t.item.name==="compatible"){let s=t.item.parent.nodeTypes.filter(c=>c).at(-1),o=t.item.ast.quickValues,a;return s instanceof Nt&&s.extends.size&&(a=Array.from(s.extends).filter(c=>!o||!o.includes(c))),o?.filter(c=>c)?.length&&!a?[]:(a??=t.runtime.context.bindingLoader?.getBindings()??[],a.filter(c=>!o||!o.includes(c)).map(c=>({label:`"${c}"`,kind:mA.CompletionItemKind.Variable,insertText:e?c:`"${c}"`})))}let n=t.item.parent.nodeType;return n instanceof Nt?n.properties.find(i=>i.name===t.item?.name)?.getPropertyCompletionItems(t.item,r,e)??[]:[]}function UU(t){if(!t||!(t.item instanceof Ke&&t.ast instanceof Qe&&t.item.ast.values==null||t.item instanceof J)||Ut(t.ast)||t.beforeAst?.parentNode instanceof vr)return[];let e=r=>r.nodeType?.getPropertyListCompletionItems(r)??[];return t.item instanceof Ke?e(t.item.parent):e(t.item)}async function gA(t,e){return _t(t,e,r=>[...jU(r),...UU(r)])}var _p=L(j());async function HU(t){if(t?.ast instanceof Ct||t?.ast instanceof Yn){let e=t.runtime.context.parser.cPreprocessorParser.macros.get(t?.ast instanceof Ct?t.ast.name:t.ast.value);if(e){let r=yc(t.ast),n=(await t.runtime.context.getAllParsers()).at(-1);if(r){let i=r?.evaluate(n.cPreprocessorParser.macros);return{contents:{kind:_p.MarkupKind.Markdown,value:["```cpp",`#define ${e.macro.toString()} // = ${i}${typeof i=="number"?` (0x${i.toString(16)})`:""}`,"```"].join(`
286
287
  `)},range:fe(t.ast)}}return{contents:{kind:_p.MarkupKind.Markdown,value:["```cpp",`#define ${e.macro.toString()} // = ${t.ast?.evaluate(n.cPreprocessorParser.macros)}`,"```"].join(`
287
288
  `)},range:fe(t.ast)}}}}async function VU(t){if(!t)return;let e=(await t.runtime.context.getAllParsers()).at(-1);if(t?.ast instanceof He){let r=t.ast.linksTo;if(r)return{contents:r.toMarkupContent(e.cPreprocessorParser.macros),range:fe(t.ast)}}if(t?.ast.parentNode instanceof se){let r=t.ast.parentNode.linksTo;if(r)return{contents:r.toMarkupContent(e.cPreprocessorParser.macros),range:fe(t.ast)}}if(t?.ast instanceof ie&&t.item instanceof Ke&&t.item.parent.name==="aliases"){let r=t.runtime.rootNode.getChild(t.ast.value.split("/"));if(r)return{contents:r.toMarkupContent(e.cPreprocessorParser.macros),range:fe(t.ast)}}if(t?.item instanceof J)return{contents:t.item.toMarkupContent(e.cPreprocessorParser.macros),range:fe(t.ast)}}function zU(t){if(t?.item instanceof Ke&&t.ast instanceof Qe){let e=t.item.onHover(),r=t.item.parent.nodeType?.getOnPropertyHover(t.item.name);if(e||r)return{contents:{kind:_p.MarkupKind.Markdown,value:`${e?.value??""}
288
289
  ${r?.value??""}`},range:fe(t.ast)}}}function yA(t,e){return _t(t,e,async r=>[await VU(r)||zU(r)||await HU(r)])}async function vA(t){let e=await Hf(t);if(e)return{contents:e.toMarkupContent(t.context.macros)}}async function TA(t){let e=await Vf(t,M);if(e)return{contents:e.toMarkupContent(t.context.macros)}}var SA=L(j());async function bA(t){return t?.nodes.length??0}async function _A({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_CHILD_NUM"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});return bA(s)}async function NA(t){let e=await _A(t,M);return e!==void 0?{contents:{kind:SA.MarkupKind.Markdown,value:e.toString()}}:void 0}async function RA(t){let e=await av(t);if(e)return e?.length?{contents:{kind:ts.Markdown,value:e.map((r,n)=>{let i=r.toMarkupContent(t.context.macros);return`## Node ${n+1}
@@ -290,7 +291,7 @@ ${r?.value??""}`},range:fe(t.ast)}}}function yA(t,e){return _t(t,e,async r=>[awa
290
291
  ${i.value}
291
292
  `}).join(`
292
293
 
293
- `)}}:{contents:{kind:ts.Markdown,value:`No node matched compat ${t.macro.args[0].macro}`}}}async function PA(t){let e=await zf(t,M);if(e)return{contents:e.toMarkupContent(t.context.macros)}}async function kA(t,e){return!!await Uf(t,e)}async function wA({macro:t,context:e}){if(!(t.macro!=="DT_HAS_ALIAS"||t.args?.length!==1))return kA(t.args[0].macro,e)}async function EA(t){let e=await wA(t);if(e!==void 0)return{contents:{kind:ts.Markdown,value:e?"1":"0"}}}var DA=L(j());async function Vc(t,e){if(t)switch(e){case"Unquoted":return t.fullName;case"Quoted":return`"${t.fullName}"`;case"Token":return ee(t.fullName);case"Upper Token":return ee(t.fullName).toUpperCase()}}async function CA({document:t,macro:e,context:r,position:n},i){if(e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});switch(e.macro){case"DT_NODE_FULL_NAME":return Vc(s,"Quoted");case"DT_NODE_FULL_NAME_TOKEN":return Vc(s,"Token");case"DT_NODE_FULL_NAME_UNQUOTED":return Vc(s,"Unquoted");case"DT_NODE_FULL_NAME_UPPER_TOKEN":return Vc(s,"Upper Token")}}async function AA(t){let e=await CA(t,M);if(e)return{contents:{kind:DA.MarkupKind.Markdown,value:e}}}var MA=L(j());async function IA(t){return t?.pathString}async function OA({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_NODE_PATH"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});return IA(s)}async function xA(t){let e=await OA(t,M);if(e)return{contents:{kind:MA.MarkupKind.Markdown,value:`"${e}"`}}}async function qA(t){let e=await Gf(t);if(e)return{contents:e.toMarkupContent(t.context.macros)}}var BA=L(j());async function LA(t){return t?.labels.map(e=>e.label)}async function $A({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_NODELABEL_STRING_ARRAY"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});return LA(s)}async function FA(t){let e=await $A(t,M);if(e)return{contents:{kind:BA.MarkupKind.Markdown,value:`{ ${e.map(r=>`"${r}"`).join(", ")} }`}}}async function jA(t){let e=await Yf(t,M);if(e)return{contents:e.toMarkupContent(t.context.macros)}}async function UA(t){let e=await Xf(t);if(e)return{contents:e.toMarkupContent(t.context.macros)}}var VA=L(j());async function HA({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_SAME_NODE"||e.args?.length!==2)return;if(await r?.getRuntime()){let o=await i({document:t,macro:e.args[0],context:r,position:n}),a=await i({document:t,macro:e.args[1],context:r,position:n});return!!a&&!!o&&a===o}}async function zA(t){let e=await HA(t,M);if(e!==void 0)return{contents:{kind:VA.MarkupKind.Markdown,value:e?"1":"0"}}}var GA=L(j());async function WA({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_ENUM_IDX_BY_IDX"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return await na(o,s[1].macro,a)}async function YA(t){let e=await WA(t,M);return e?{contents:{kind:GA.MarkupKind.Markdown,value:e.toString()}}:void 0}var XA=L(j());async function KA({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHA_BY_IDX"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return is(o,s[1].macro,a,s[3].macro,r)}async function JA(t){let e=await KA(t,M);return e?{contents:{kind:XA.MarkupKind.Markdown,value:e.toString()}}:void 0}async function QA(t){let e=await ei(t,M);if(e)return{contents:e.toMarkupContent(t.context.macros)}}async function ZA(t){let e=await np(t,M);if(e)return{contents:e.toMarkupContent(t.context.macros)}}var zc=L(j());async function it(t,e){if(e){if(typeof e=="boolean")return{contents:{kind:zc.MarkupKind.Markdown,value:e?"1":"0"}};if(typeof e=="string")return{contents:{kind:zc.MarkupKind.Markdown,value:e}};if(e instanceof J)return{contents:e.toMarkupContent(t.macros)};if(e.length===1&&e[0]instanceof J)return{contents:e[0].toMarkupContent(t.macros)};if(e.every(r=>typeof r=="number"))return{contents:{kind:zc.MarkupKind.Markdown,value:e.length===1?e[0].toString():`{${e.join(", ")}}`}};if(e.every(r=>typeof r=="string"))return{contents:{kind:zc.MarkupKind.Markdown,value:e.length===1?`"${e[0]}"`:`{${e.map(r=>`"${r}"`).join(", ")}}`}}}}async function e0(t){let e=await qf(t,M);return it(t.context,e)}var lv=L(j());async function t0(t){let e=await Lf(t,M);if(e===!0)return{contents:{kind:lv.MarkupKind.Markdown,value:"1"}};if(e)return e instanceof J?{contents:e.toMarkupContent(t.context.macros)}:{contents:{kind:lv.MarkupKind.Markdown,value:e.toString()}}}async function r0(t){let e=await ra(t,M);return it(t.context,e)}async function n0({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_PROP_BY_PHANDLE_IDX"||e.args?.length!==4)return;let s=await Zn(await i({document:t,macro:e.args[0],context:r,position:n}),e.args[1].macro,e.args[2].macro);return await ur(s,e.args[3].macro,r)}async function i0(t){return it(t.context,await n0(t,M))}async function s0(t){let e=await Jf(t);if(e)return{contents:e.toMarkupContent(t.context.macros)}}var c0=L(j());async function o0(t){return t?.nodes.filter(e=>!e.disabled).length??0}async function a0({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_CHILD_NUM_STATUS_OKAY"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});return o0(s)}async function l0(t){let e=await a0(t,M);return e!==void 0?{contents:{kind:c0.MarkupKind.Markdown,value:e.toString()}}:void 0}async function u0(t){let e=await ss(t,M);if(e)return{contents:e.toMarkupContent(t.context.macros)}}var f0=L(j());async function d0({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHA"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return is(o,s[1].macro,0,s[2].macro,r)}async function p0(t){let e=await d0(t,M);return e?{contents:{kind:f0.MarkupKind.Markdown,value:e.toString()}}:void 0}var h0=L(j());async function m0(t){let e=await tp(t,M);return e instanceof J?it(t.context,e):e?{contents:{kind:h0.MarkupKind.Markdown,value:e.toString()}}:void 0}var y0=L(j());async function g0({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHA_BY_NAME"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:r,position:n});return is(o,s[1].macro,s[2].macro,s[3].macro,r)}async function v0(t){let e=await g0(t,M);return e?{contents:{kind:y0.MarkupKind.Markdown,value:e.toString()}}:void 0}var T0=L(j());async function b0(t){let e=await rp(t,M);return e instanceof J?it(t.context,e):e?{contents:{kind:T0.MarkupKind.Markdown,value:e.toString()}}:void 0}var _0=L(j());async function S0(t){let e=await ip(t,M);return e instanceof J?it(t.context,e):e?{contents:{kind:_0.MarkupKind.Markdown,value:e.toString()}}:void 0}var N0=L(j());async function R0(t){let e=await Zf(t,M);return e instanceof J?it(t.context,e):e?{contents:{kind:N0.MarkupKind.Markdown,value:e.toString()}}:void 0}var k0=L(j());async function P0({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_ENUM_IDX"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return await na(o,s[1].macro,0)}async function w0(t){let e=await P0(t,M);return e?{contents:{kind:k0.MarkupKind.Markdown,value:e.toString()}}:void 0}var E0=L(j());async function C0(t){let e=await ep(t,M);return e instanceof J?it(t.context,e):e?{contents:{kind:E0.MarkupKind.Markdown,value:e.toString()}}:void 0}async function D0({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_PROP_BY_PHANDLE"||e.args?.length!==3)return;let s=await Zn(await i({document:t,macro:e.args[0],context:r,position:n}),e.args[1].macro);return ur(s,e.args[2].macro,r)}async function A0(t){return it(t.context,await D0(t,M))}async function I0(t){return it(t.context,await sp(t,M))}var x0=L(j());var O0=L(require("util"));async function Sp(t,e,r,n){let i=t?.properties.find(o=>ee(o.name)===e);if(!i)return;let s=i?.ast.quickValues?.at(r);if(s!==void 0)return O0.default.isDeepStrictEqual(Ee(n),s)}async function M0({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_ENUM_HAS_VALUE"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return await Sp(o,s[1].macro,0,s[2].macro)}async function q0(t){let e=await M0(t,M);return e!==void 0?{contents:{kind:x0.MarkupKind.Markdown,value:e?"1":"0"}}:void 0}var $0=L(j());async function L0({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_ENUM_HAS_VALUE_BY_IDX"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return await Sp(o,s[1].macro,a,s[3].macro)}async function B0(t){let e=await L0(t,M);return e!==void 0?{contents:{kind:$0.MarkupKind.Markdown,value:e?"1":"0"}}:void 0}var U0=L(j());async function F0(t,e,r,n){let i=await ur(t,e,n);if(i===void 0)return!1;if(r=typeof r=="number"?r:Ee(r??"0"),typeof r=="number")return Array.isArray(i)?i.length<r:r===0}async function j0({document:t,macro:e,context:r,position:n},i){let s=e.args;return e.macro!=="DT_PROP_HAS_IDX"||s?.length!==3?void 0:!!await F0(await i({document:t,macro:s[0],context:r,position:n}),s[1].macro,s[2].macro,r)}async function H0(t){let e=await j0(t,M);return e===void 0?void 0:{contents:{kind:U0.MarkupKind.Markdown,value:e?"1":"0"}}}var W0=L(j());async function V0(t,e,r,n){let i=t?.properties.find(u=>ee(u.name)===e),s=i?.parent.nodeType;if(!s||!(s instanceof Nt)||await ur(t,e,n)===void 0)return;let a=i.nexusMapsTo.at(0)?.specifierSpace,l=(a?i.parent.getProperty(`${a}-names`)?.ast.quickValues:void 0)?.findIndex(u=>typeof u=="string"&&u.toLowerCase()===r)??-1;return l===-1?void 0:l}async function z0({document:t,macro:e,context:r,position:n},i){let s=e.args;return e.macro!=="DT_PROP_HAS_NAME"||s?.length!==3?void 0:!!await V0(await i({document:t,macro:s[0],context:r,position:n}),s[1].macro,s[2].macro,r)}async function G0(t){let e=await z0(t,M);return e===void 0?void 0:{contents:{kind:W0.MarkupKind.Markdown,value:e?"1":"0"}}}async function Y0(t){let e=await Wf(t);if(e)return{contents:e.toMarkupContent(t.context.macros)}}var X0=L(j());async function K0({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PROP_LEN"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return o?op(o,s[1].macro):void 0}async function J0(t){let e=await K0(t,M);return e?{contents:{kind:X0.MarkupKind.Markdown,value:e.toString()}}:void 0}var Q0=L(j());async function Z0(t){let e=await ap(t,M);return e instanceof J?it(t.context,e):e?{contents:{kind:Q0.MarkupKind.Markdown,value:e.toString()}}:void 0}var uv=L(j());async function eI(t,e,r){let n=await ur(t,e,r);if(n===!0)return!0;if(!n)return;let i=n.at(-1);if(i)return n.length===1&&n[0]instanceof J?n[0]:i}async function tI({document:t,macro:e,context:r,position:n},i){if(!(e.macro!=="DT_PROP_LAST"||e.args?.length!==2))return eI(await i({document:t,macro:e.args[0],context:r,position:n}),e.args[1].macro,r)}async function rI(t){let e=await tI(t,M);if(e===!0)return{contents:{kind:uv.MarkupKind.Markdown,value:"1"}};if(e)return e instanceof J?{contents:e.toMarkupContent(t.context.macros)}:{contents:{kind:uv.MarkupKind.Markdown,value:e.toString()}}}var iI=L(j());async function nI({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_TOKEN"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return o?sa(o,s[1].macro):void 0}async function sI(t){let e=await nI(t,M);if(e)return{contents:{kind:iI.MarkupKind.Markdown,value:e.toString()}}}var aI=L(j());async function Np(t,e,r){if(!t)return;let i=t?.properties.find(s=>ee(s.name)===e)?.ast.getFlatAstValues();if(!(!i||i.length<=1)&&i[r]instanceof ie)return ee(i[r].value)}async function oI({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_TOKEN_BY_IDX"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return o?Np(o,s[1].macro,a):void 0}async function cI(t){let e=await oI(t,M);if(e)return{contents:{kind:aI.MarkupKind.Markdown,value:e.toString()}}}var lI=L(j());async function uI(t){let e=await cp(t,M);if(e)return e instanceof J?it(t.context,e):{contents:{kind:lI.MarkupKind.Markdown,value:e.toString()}}}var pI=L(j());async function dI(t,e,r){if(!t)return;let i=t?.properties.find(s=>ee(s.name)===e)?.ast.getFlatAstValues();if(!(!i||i.length<=1)&&i[r]instanceof ie)return i[r].value}async function fI({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_UNQUOTED_BY_IDX"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return o?dI(o,s[1].macro,a):void 0}async function hI(t){let e=await fI(t,M);if(e)return{contents:{kind:pI.MarkupKind.Markdown,value:e.toString()}}}var gI=L(j());async function mI({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_UNQUOTED"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return o?lp(o,s[1].macro):void 0}async function yI(t){let e=await mI(t,M);if(e)return{contents:{kind:gI.MarkupKind.Markdown,value:e.toString()}}}var vI=L(j());async function TI(t){let e=await up(t,M);if(e)return e instanceof J?it(t.context,e):{contents:{kind:vI.MarkupKind.Markdown,value:e.toString()}}}var SI=L(j());async function bI(t,e,r){return(await Np(t,e,r))?.toUpperCase()}async function _I({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_UPPER_TOKEN_BY_IDX"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return o?bI(o,s[1].macro,a):void 0}async function NI(t){let e=await _I(t,M);if(e)return{contents:{kind:SI.MarkupKind.Markdown,value:e.toString()}}}var PI=L(j());async function RI({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_UPPER_TOKEN"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return o?dp(o,s[1].macro):void 0}async function kI(t){let e=await RI(t,M);if(e)return{contents:{kind:PI.MarkupKind.Markdown,value:e.toString()}}}var wI=L(j());async function EI(t){let e=await fp(t,M);if(e)return e instanceof J?it(t.context,e):{contents:{kind:wI.MarkupKind.Markdown,value:e.toString()}}}async function CI(t){let e=await Bf(t,M);return e?{contents:e.toMarkupContent(t.context.macros)}:void 0}var II=L(j());async function DI(t,e){if(!t)return;let r=t.nodeType?.onBus;return r?ee(r)===e:!1}async function AI(t,e){let r=t.macro.args;if(t.macro.macro!=="DT_ON_BUS"||r?.length!==2)return;let n=await e({...t,macro:r[0]});return await DI(n,r[1].macro)}async function OI(t){let e=await AI(t,M);return e!==void 0?{contents:{kind:II.MarkupKind.Markdown,value:e?"1":"0"}}:void 0}async function MI(t){let e=await jf(t);return e?{contents:e.toMarkupContent(t.context.macros)}:void 0}var LI=L(j());async function xI(t,e){return!!await Ff(t,e)}async function qI(t){let e=t.macro.args;if(!(t.macro.macro!=="DT_HAS_CHOSEN"||e?.length!==1))return await xI(t.context,e[0].macro)}async function $I(t){let e=await qI(t);return e!==void 0?{contents:{kind:LI.MarkupKind.Markdown,value:e?"1":"0"}}:void 0}async function WU(t){return[CI,OI,MI,$I,vA,TA,NA,l0,RA,PA,EA,Y0,s0,UA,xA,AA,qA,FA,jA,zA].reduce((e,r)=>e.then(n=>n||r(t)),Promise.resolve(void 0))}async function GU(t){return[B0,q0,YA,R0,w0,C0,JA,m0,v0,b0,p0,QA,ZA,u0,S0,t0,A0,i0,I0,H0,G0,e0,rI,J0,Z0,r0,cI,sI,uI,hI,yI,TI,NI,kI,EI].reduce((e,r)=>e.then(n=>n||r(t)),Promise.resolve(void 0))}async function BI(t,e,r){if(!r)return;let n=Ni(r,t.position);return FI(n,t.position,e,r)}async function FI(t,e,r,n){if(!t?.macro)return;let i=await WU({position:e,context:r,document:n,macro:t})||await GU({position:e,context:r,document:n,macro:t});if(i)return i;let s=await M({document:n,macro:t,context:r,position:e});if(s)return{contents:s.toMarkupContent(r.macros)};let o=await ns(n,t.macro,e,r);if(o)return FI(o[0],o[1],r,n)}var uS=require("path"),dS=require("fs");var aO=L(ZI(),1);var Gc=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")};var tH={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Yc=t=>t.replace(/[[\]\\-]/g,"\\$&"),rH=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),eO=t=>t.join(""),tO=(t,e)=>{let r=e;if(t.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=r+1,o=!1,a=!1,c=!1,l=!1,u=r,d="";e:for(;s<t.length;){let h=t.charAt(s);if((h==="!"||h==="^")&&s===r+1){l=!0,s++;continue}if(h==="]"&&o&&!c){u=s+1;break}if(o=!0,h==="\\"&&!c){c=!0,s++;continue}if(h==="["&&!c){for(let[v,[S,_,T]]of Object.entries(tH))if(t.startsWith(v,s)){if(d)return["$.",!1,t.length-r,!0];s+=v.length,T?i.push(S):n.push(S),a=a||_;continue e}}if(c=!1,d){h>d?n.push(Yc(d)+"-"+Yc(h)):h===d&&n.push(Yc(h)),d="",s++;continue}if(t.startsWith("-]",s+1)){n.push(Yc(h+"-")),s+=2;continue}if(t.startsWith("-",s+1)){d=h,s+=2;continue}n.push(Yc(h)),s++}if(u<s)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,t.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!l){let h=n[0].length===2?n[0].slice(-1):n[0];return[rH(h),!1,u-r,!1]}let f="["+(l?"^":"")+eO(n)+"]",p="["+(l?"":"^")+eO(i)+"]";return[n.length&&i.length?"("+f+"|"+p+")":n.length?f:p,a,u-r,!0]};var In=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var nH=new Set(["!","?","+","*","@"]),rO=t=>nH.has(t),iH="(?!(?:^|/)\\.\\.?(?:$|/))",Rp="(?!\\.)",sH=new Set(["[","."]),oH=new Set(["..","."]),aH=new Set("().*{}+?[]^$\\!"),cH=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),pv="[^/]",nO=pv+"*?",iO=pv+"+?",ca=class t{type;#e;#t;#i=!1;#r=[];#o;#f;#l;#d=!1;#a;#c;#s=!1;constructor(e,r,n={}){this.type=e,e&&(this.#t=!0),this.#o=r,this.#e=this.#o?this.#o.#e:this,this.#a=this.#e===this?n:this.#e.#a,this.#l=this.#e===this?[]:this.#e.#l,e==="!"&&!this.#e.#d&&this.#l.push(this),this.#f=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#c!==void 0?this.#c:this.type?this.#c=this.type+"("+this.#r.map(e=>String(e)).join("|")+")":this.#c=this.#r.map(e=>String(e)).join("")}#y(){if(this!==this.#e)throw new Error("should only call on root");if(this.#d)return this;this.toString(),this.#d=!0;let e;for(;e=this.#l.pop();){if(e.type!=="!")continue;let r=e,n=r.#o;for(;n;){for(let i=r.#f+1;!n.type&&i<n.#r.length;i++)for(let s of e.#r){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#r[i])}r=n,n=r.#o}}return this}push(...e){for(let r of e)if(r!==""){if(typeof r!="string"&&!(r instanceof t&&r.#o===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let e=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#d&&this.#o?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#o?.isStart())return!1;if(this.#f===0)return!0;let e=this.#o;for(let r=0;r<this.#f;r++){let n=e.#r[r];if(!(n instanceof t&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let e=this.#o?this.#o.#r.length:0;return this.#f===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let r=new t(this.type,e);for(let n of this.#r)r.copyIn(n);return r}static#v(e,r,n,i){let s=!1,o=!1,a=-1,c=!1;if(r.type===null){let p=n,g="";for(;p<e.length;){let h=e.charAt(p++);if(s||h==="\\"){s=!s,g+=h;continue}if(o){p===a+1?(h==="^"||h==="!")&&(c=!0):h==="]"&&!(p===a+2&&c)&&(o=!1),g+=h;continue}else if(h==="["){o=!0,a=p,c=!1,g+=h;continue}if(!i.noext&&rO(h)&&e.charAt(p)==="("){r.push(g),g="";let v=new t(h,r);p=t.#v(e,v,p,i),r.push(v);continue}g+=h}return r.push(g),p}let l=n+1,u=new t(null,r),d=[],f="";for(;l<e.length;){let p=e.charAt(l++);if(s||p==="\\"){s=!s,f+=p;continue}if(o){l===a+1?(p==="^"||p==="!")&&(c=!0):p==="]"&&!(l===a+2&&c)&&(o=!1),f+=p;continue}else if(p==="["){o=!0,a=l,c=!1,f+=p;continue}if(rO(p)&&e.charAt(l)==="("){u.push(f),f="";let g=new t(p,u);u.push(g),l=t.#v(e,g,l,i);continue}if(p==="|"){u.push(f),f="",d.push(u),u=new t(null,r);continue}if(p===")")return f===""&&r.#r.length===0&&(r.#s=!0),u.push(f),f="",r.push(...d,u),l;f+=p}return r.type=null,r.#t=void 0,r.#r=[e.substring(n-1)],l}static fromGlob(e,r={}){let n=new t(null,void 0,r);return t.#v(e,n,0,r),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[r,n,i,s]=this.toRegExpSource();if(!(i||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:e})}get options(){return this.#a}toRegExpSource(e){let r=e??!!this.#a.dot;if(this.#e===this&&this.#y(),!this.type){let c=this.isStart()&&this.isEnd(),l=this.#r.map(p=>{let[g,h,v,S]=typeof p=="string"?t.#p(p,this.#t,c):p.toRegExpSource(e);return this.#t=this.#t||v,this.#i=this.#i||S,g}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&oH.has(this.#r[0]))){let g=sH,h=r&&g.has(l.charAt(0))||l.startsWith("\\.")&&g.has(l.charAt(2))||l.startsWith("\\.\\.")&&g.has(l.charAt(4)),v=!r&&!e&&g.has(l.charAt(0));u=h?iH:v?Rp:""}let d="";return this.isEnd()&&this.#e.#d&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+l+d,In(l),this.#t=!!this.#t,this.#i]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#h(r);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString();return this.#r=[c],this.type=null,this.#t=void 0,[c,In(this.toString()),!1,!1]}let o=!n||e||r||!Rp?"":this.#h(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let a="";if(this.type==="!"&&this.#s)a=(this.isStart()&&!r?Rp:"")+iO;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!e?Rp:"")+nO+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=i+s+c}return[a,In(s),this.#t=!!this.#t,this.#i]}#h(e){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,s,o]=r.toRegExpSource(e);return this.#i=this.#i||o,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#p(e,r,n=!1){let i=!1,s="",o=!1;for(let a=0;a<e.length;a++){let c=e.charAt(a);if(i){i=!1,s+=(aH.has(c)?"\\":"")+c;continue}if(c==="\\"){a===e.length-1?s+="\\\\":i=!0;continue}if(c==="["){let[l,u,d,f]=tO(e,a);if(d){s+=l,o=o||u,a+=d-1,r=r||f;continue}}if(c==="*"){n&&e==="*"?s+=iO:s+=nO,r=!0;continue}if(c==="?"){s+=pv,r=!0;continue}s+=cH(c)}return[s,In(e),!!r,o]}};var la=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&");var br=(t,e,r={})=>(Gc(e),!r.nocomment&&e.charAt(0)==="#"?!1:new Wr(e,r).match(t)),lH=/^\*+([^+@!?\*\[\(]*)$/,uH=t=>e=>!e.startsWith(".")&&e.endsWith(t),dH=t=>e=>e.endsWith(t),fH=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),pH=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),hH=/^\*+\.\*+$/,mH=t=>!t.startsWith(".")&&t.includes("."),gH=t=>t!=="."&&t!==".."&&t.includes("."),yH=/^\.\*+$/,vH=t=>t!=="."&&t!==".."&&t.startsWith("."),TH=/^\*+$/,bH=t=>t.length!==0&&!t.startsWith("."),_H=t=>t.length!==0&&t!=="."&&t!=="..",SH=/^\?+([^+@!?\*\[\(]*)?$/,NH=([t,e=""])=>{let r=cO([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},RH=([t,e=""])=>{let r=lO([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},PH=([t,e=""])=>{let r=lO([t]);return e?n=>r(n)&&n.endsWith(e):r},kH=([t,e=""])=>{let r=cO([t]);return e?n=>r(n)&&n.endsWith(e):r},cO=([t])=>{let e=t.length;return r=>r.length===e&&!r.startsWith(".")},lO=([t])=>{let e=t.length;return r=>r.length===e&&r!=="."&&r!==".."},uO=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",sO={win32:{sep:"\\"},posix:{sep:"/"}},wH=uO==="win32"?sO.win32.sep:sO.posix.sep;br.sep=wH;var tr=Symbol("globstar **");br.GLOBSTAR=tr;var EH="[^/]",CH=EH+"*?",DH="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",AH="(?:(?!(?:\\/|^)\\.).)*?",IH=(t,e={})=>r=>br(r,t,e);br.filter=IH;var un=(t,e={})=>Object.assign({},t,e),OH=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return br;let e=br;return Object.assign((n,i,s={})=>e(n,i,un(t,s)),{Minimatch:class extends e.Minimatch{constructor(i,s={}){super(i,un(t,s))}static defaults(i){return e.defaults(un(t,i)).Minimatch}},AST:class extends e.AST{constructor(i,s,o={}){super(i,s,un(t,o))}static fromGlob(i,s={}){return e.AST.fromGlob(i,un(t,s))}},unescape:(n,i={})=>e.unescape(n,un(t,i)),escape:(n,i={})=>e.escape(n,un(t,i)),filter:(n,i={})=>e.filter(n,un(t,i)),defaults:n=>e.defaults(un(t,n)),makeRe:(n,i={})=>e.makeRe(n,un(t,i)),braceExpand:(n,i={})=>e.braceExpand(n,un(t,i)),match:(n,i,s={})=>e.match(n,i,un(t,s)),sep:e.sep,GLOBSTAR:tr})};br.defaults=OH;var dO=(t,e={})=>(Gc(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:(0,aO.default)(t));br.braceExpand=dO;var MH=(t,e={})=>new Wr(t,e).makeRe();br.makeRe=MH;var xH=(t,e,r={})=>{let n=new Wr(e,r);return t=t.filter(i=>n.match(i)),n.options.nonull&&!t.length&&t.push(e),t};br.match=xH;var oO=/[?*]|[+@!]\(.*?\)|\[|\]/,qH=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Wr=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,r={}){Gc(e),r=r||{},this.options=r,this.pattern=e,this.platform=r.platform||uO,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let r of e)if(typeof r!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,r=this.options;if(!r.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!oO.test(s[2]))&&!oO.test(s[3]),l=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(u=>this.parse(u))];if(l)return[s[0],...s.slice(1).map(u=>this.parse(u))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let n=0;n<e.length;n++)for(let i=0;i<e[n].length;i++)e[n][i]==="**"&&(e[n][i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):r>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(e){return e.map(r=>(r=r.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let s=e[i];i===1&&s===""&&e[0]===""||(s==="."||s==="")&&(r=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(r=!0,e.pop())}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let i=e[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(r=!0,e.splice(n-1,2),n-=2)}}while(r);return e.length===0?[""]:e}firstPhasePreProcess(e){let r=!1;do{r=!1;for(let n of e){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let a=n[i+1],c=n[i+2],l=n[i+3];if(a!==".."||!c||c==="."||c===".."||!l||l==="."||l==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",e.push(u),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let o=n[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){r=!0;let c=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...c),n.length===0&&n.push(""),s-=2}}}}while(r);return e}secondPhasePreProcess(e){for(let r=0;r<e.length-1;r++)for(let n=r+1;n<e.length;n++){let i=this.partsMatch(e[r],e[n],!this.preserveMultipleSlashes);if(i){e[r]=[],e[n]=i;break}}return e.filter(r=>r.length)}partsMatch(e,r,n=!1){let i=0,s=0,o=[],a="";for(;i<e.length&&s<r.length;)if(e[i]===r[s])o.push(a==="b"?r[s]:e[i]),i++,s++;else if(n&&e[i]==="**"&&r[s]===e[i+1])o.push(e[i]),i++;else if(n&&r[s]==="**"&&e[i]===r[s+1])o.push(r[s]),s++;else if(e[i]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(a==="b")return!1;a="a",o.push(e[i]),i++,s++}else if(r[s]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return!1;a="b",o.push(r[s]),i++,s++}else return!1;return e.length===r.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,r=!1,n=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=e.slice(n)),this.negate=r}matchOne(e,r,n=!1){let i=this.options;if(this.isWindows){let h=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),v=!h&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),S=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),_=!S&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),T=v?3:h?0:void 0,P=_?3:S?0:void 0;if(typeof T=="number"&&typeof P=="number"){let[C,$]=[e[T],r[P]];C.toLowerCase()===$.toLowerCase()&&(r[P]=C,P>T?r=r.slice(P):T>P&&(e=e.slice(T)))}}let{optimizationLevel:s=1}=this.options;s>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:r}),this.debug("matchOne",e.length,r.length);for(var o=0,a=0,c=e.length,l=r.length;o<c&&a<l;o++,a++){this.debug("matchOne loop");var u=r[a],d=e[o];if(this.debug(r,u,d),u===!1)return!1;if(u===tr){this.debug("GLOBSTAR",[r,u,d]);var f=o,p=a+1;if(p===l){for(this.debug("** at the end");o<c;o++)if(e[o]==="."||e[o]===".."||!i.dot&&e[o].charAt(0)===".")return!1;return!0}for(;f<c;){var g=e[f];if(this.debug(`
294
+ `)}}:{contents:{kind:ts.Markdown,value:`No node matched compat ${t.macro.args[0].macro}`}}}async function PA(t){let e=await zf(t,M);if(e)return{contents:e.toMarkupContent(t.context.macros)}}async function kA(t,e){return!!await Uf(t,e)}async function wA({macro:t,context:e}){if(!(t.macro!=="DT_HAS_ALIAS"||t.args?.length!==1))return kA(t.args[0].macro,e)}async function EA(t){let e=await wA(t);if(e!==void 0)return{contents:{kind:ts.Markdown,value:e?"1":"0"}}}var DA=L(j());async function Vc(t,e){if(t)switch(e){case"Unquoted":return t.fullName;case"Quoted":return`"${t.fullName}"`;case"Token":return te(t.fullName);case"Upper Token":return te(t.fullName).toUpperCase()}}async function CA({document:t,macro:e,context:r,position:n},i){if(e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});switch(e.macro){case"DT_NODE_FULL_NAME":return Vc(s,"Quoted");case"DT_NODE_FULL_NAME_TOKEN":return Vc(s,"Token");case"DT_NODE_FULL_NAME_UNQUOTED":return Vc(s,"Unquoted");case"DT_NODE_FULL_NAME_UPPER_TOKEN":return Vc(s,"Upper Token")}}async function AA(t){let e=await CA(t,M);if(e)return{contents:{kind:DA.MarkupKind.Markdown,value:e}}}var MA=L(j());async function IA(t){return t?.pathString}async function OA({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_NODE_PATH"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});return IA(s)}async function xA(t){let e=await OA(t,M);if(e)return{contents:{kind:MA.MarkupKind.Markdown,value:`"${e}"`}}}async function qA(t){let e=await Gf(t);if(e)return{contents:e.toMarkupContent(t.context.macros)}}var BA=L(j());async function LA(t){return t?.labels.map(e=>e.label)}async function $A({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_NODELABEL_STRING_ARRAY"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});return LA(s)}async function FA(t){let e=await $A(t,M);if(e)return{contents:{kind:BA.MarkupKind.Markdown,value:`{ ${e.map(r=>`"${r}"`).join(", ")} }`}}}async function jA(t){let e=await Yf(t,M);if(e)return{contents:e.toMarkupContent(t.context.macros)}}async function UA(t){let e=await Xf(t);if(e)return{contents:e.toMarkupContent(t.context.macros)}}var VA=L(j());async function HA({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_SAME_NODE"||e.args?.length!==2)return;if(await r?.getRuntime()){let o=await i({document:t,macro:e.args[0],context:r,position:n}),a=await i({document:t,macro:e.args[1],context:r,position:n});return!!a&&!!o&&a===o}}async function zA(t){let e=await HA(t,M);if(e!==void 0)return{contents:{kind:VA.MarkupKind.Markdown,value:e?"1":"0"}}}var GA=L(j());async function WA({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_ENUM_IDX_BY_IDX"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return await na(o,s[1].macro,a)}async function YA(t){let e=await WA(t,M);return e?{contents:{kind:GA.MarkupKind.Markdown,value:e.toString()}}:void 0}var XA=L(j());async function KA({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHA_BY_IDX"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return is(o,s[1].macro,a,s[3].macro,r)}async function JA(t){let e=await KA(t,M);return e?{contents:{kind:XA.MarkupKind.Markdown,value:e.toString()}}:void 0}async function QA(t){let e=await ei(t,M);if(e)return{contents:e.toMarkupContent(t.context.macros)}}async function ZA(t){let e=await np(t,M);if(e)return{contents:e.toMarkupContent(t.context.macros)}}var zc=L(j());async function it(t,e){if(e){if(typeof e=="boolean")return{contents:{kind:zc.MarkupKind.Markdown,value:e?"1":"0"}};if(typeof e=="string")return{contents:{kind:zc.MarkupKind.Markdown,value:e}};if(e instanceof J)return{contents:e.toMarkupContent(t.macros)};if(e.length===1&&e[0]instanceof J)return{contents:e[0].toMarkupContent(t.macros)};if(e.every(r=>typeof r=="number"))return{contents:{kind:zc.MarkupKind.Markdown,value:e.length===1?e[0].toString():`{${e.join(", ")}}`}};if(e.every(r=>typeof r=="string"))return{contents:{kind:zc.MarkupKind.Markdown,value:e.length===1?`"${e[0]}"`:`{${e.map(r=>`"${r}"`).join(", ")}}`}}}}async function e0(t){let e=await qf(t,M);return it(t.context,e)}var lv=L(j());async function t0(t){let e=await Lf(t,M);if(e===!0)return{contents:{kind:lv.MarkupKind.Markdown,value:"1"}};if(e)return e instanceof J?{contents:e.toMarkupContent(t.context.macros)}:{contents:{kind:lv.MarkupKind.Markdown,value:e.toString()}}}async function r0(t){let e=await ra(t,M);return it(t.context,e)}async function n0({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_PROP_BY_PHANDLE_IDX"||e.args?.length!==4)return;let s=await Zn(await i({document:t,macro:e.args[0],context:r,position:n}),e.args[1].macro,e.args[2].macro);return await ur(s,e.args[3].macro,r)}async function i0(t){return it(t.context,await n0(t,M))}async function s0(t){let e=await Jf(t);if(e)return{contents:e.toMarkupContent(t.context.macros)}}var c0=L(j());async function o0(t){return t?.nodes.filter(e=>!e.disabled).length??0}async function a0({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_CHILD_NUM_STATUS_OKAY"||e.args?.length!==1)return;let s=await i({document:t,macro:e.args[0],context:r,position:n});return o0(s)}async function l0(t){let e=await a0(t,M);return e!==void 0?{contents:{kind:c0.MarkupKind.Markdown,value:e.toString()}}:void 0}async function u0(t){let e=await ss(t,M);if(e)return{contents:e.toMarkupContent(t.context.macros)}}var f0=L(j());async function d0({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHA"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return is(o,s[1].macro,0,s[2].macro,r)}async function p0(t){let e=await d0(t,M);return e?{contents:{kind:f0.MarkupKind.Markdown,value:e.toString()}}:void 0}var h0=L(j());async function m0(t){let e=await tp(t,M);return e instanceof J?it(t.context,e):e?{contents:{kind:h0.MarkupKind.Markdown,value:e.toString()}}:void 0}var y0=L(j());async function g0({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PHA_BY_NAME"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:r,position:n});return is(o,s[1].macro,s[2].macro,s[3].macro,r)}async function v0(t){let e=await g0(t,M);return e?{contents:{kind:y0.MarkupKind.Markdown,value:e.toString()}}:void 0}var T0=L(j());async function b0(t){let e=await rp(t,M);return e instanceof J?it(t.context,e):e?{contents:{kind:T0.MarkupKind.Markdown,value:e.toString()}}:void 0}var _0=L(j());async function S0(t){let e=await ip(t,M);return e instanceof J?it(t.context,e):e?{contents:{kind:_0.MarkupKind.Markdown,value:e.toString()}}:void 0}var N0=L(j());async function R0(t){let e=await Zf(t,M);return e instanceof J?it(t.context,e):e?{contents:{kind:N0.MarkupKind.Markdown,value:e.toString()}}:void 0}var k0=L(j());async function P0({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_ENUM_IDX"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return await na(o,s[1].macro,0)}async function w0(t){let e=await P0(t,M);return e?{contents:{kind:k0.MarkupKind.Markdown,value:e.toString()}}:void 0}var E0=L(j());async function C0(t){let e=await ep(t,M);return e instanceof J?it(t.context,e):e?{contents:{kind:E0.MarkupKind.Markdown,value:e.toString()}}:void 0}async function D0({document:t,macro:e,context:r,position:n},i){if(e.macro!=="DT_PROP_BY_PHANDLE"||e.args?.length!==3)return;let s=await Zn(await i({document:t,macro:e.args[0],context:r,position:n}),e.args[1].macro);return ur(s,e.args[2].macro,r)}async function A0(t){return it(t.context,await D0(t,M))}async function I0(t){return it(t.context,await sp(t,M))}var x0=L(j());var O0=L(require("util"));async function Sp(t,e,r,n){let i=t?.properties.find(o=>te(o.name)===e);if(!i)return;let s=i?.ast.quickValues?.at(r);if(s!==void 0)return O0.default.isDeepStrictEqual(Ee(n),s)}async function M0({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_ENUM_HAS_VALUE"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n});return await Sp(o,s[1].macro,0,s[2].macro)}async function q0(t){let e=await M0(t,M);return e!==void 0?{contents:{kind:x0.MarkupKind.Markdown,value:e?"1":"0"}}:void 0}var $0=L(j());async function L0({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_ENUM_HAS_VALUE_BY_IDX"||s?.length!==4)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return await Sp(o,s[1].macro,a,s[3].macro)}async function B0(t){let e=await L0(t,M);return e!==void 0?{contents:{kind:$0.MarkupKind.Markdown,value:e?"1":"0"}}:void 0}var U0=L(j());async function F0(t,e,r,n){let i=await ur(t,e,n);if(i===void 0)return!1;if(r=typeof r=="number"?r:Ee(r??"0"),typeof r=="number")return Array.isArray(i)?i.length<r:r===0}async function j0({document:t,macro:e,context:r,position:n},i){let s=e.args;return e.macro!=="DT_PROP_HAS_IDX"||s?.length!==3?void 0:!!await F0(await i({document:t,macro:s[0],context:r,position:n}),s[1].macro,s[2].macro,r)}async function H0(t){let e=await j0(t,M);return e===void 0?void 0:{contents:{kind:U0.MarkupKind.Markdown,value:e?"1":"0"}}}var W0=L(j());async function V0(t,e,r,n){let i=t?.properties.find(u=>te(u.name)===e),s=i?.parent.nodeType;if(!s||!(s instanceof Nt)||await ur(t,e,n)===void 0)return;let a=i.nexusMapsTo.at(0)?.specifierSpace,l=(a?i.parent.getProperty(`${a}-names`)?.ast.quickValues:void 0)?.findIndex(u=>typeof u=="string"&&u.toLowerCase()===r)??-1;return l===-1?void 0:l}async function z0({document:t,macro:e,context:r,position:n},i){let s=e.args;return e.macro!=="DT_PROP_HAS_NAME"||s?.length!==3?void 0:!!await V0(await i({document:t,macro:s[0],context:r,position:n}),s[1].macro,s[2].macro,r)}async function G0(t){let e=await z0(t,M);return e===void 0?void 0:{contents:{kind:W0.MarkupKind.Markdown,value:e?"1":"0"}}}async function Y0(t){let e=await Wf(t);if(e)return{contents:e.toMarkupContent(t.context.macros)}}var X0=L(j());async function K0({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_PROP_LEN"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return o?op(o,s[1].macro):void 0}async function J0(t){let e=await K0(t,M);return e?{contents:{kind:X0.MarkupKind.Markdown,value:e.toString()}}:void 0}var Q0=L(j());async function Z0(t){let e=await ap(t,M);return e instanceof J?it(t.context,e):e?{contents:{kind:Q0.MarkupKind.Markdown,value:e.toString()}}:void 0}var uv=L(j());async function eI(t,e,r){let n=await ur(t,e,r);if(n===!0)return!0;if(!n)return;let i=n.at(-1);if(i)return n.length===1&&n[0]instanceof J?n[0]:i}async function tI({document:t,macro:e,context:r,position:n},i){if(!(e.macro!=="DT_PROP_LAST"||e.args?.length!==2))return eI(await i({document:t,macro:e.args[0],context:r,position:n}),e.args[1].macro,r)}async function rI(t){let e=await tI(t,M);if(e===!0)return{contents:{kind:uv.MarkupKind.Markdown,value:"1"}};if(e)return e instanceof J?{contents:e.toMarkupContent(t.context.macros)}:{contents:{kind:uv.MarkupKind.Markdown,value:e.toString()}}}var iI=L(j());async function nI({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_TOKEN"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return o?sa(o,s[1].macro):void 0}async function sI(t){let e=await nI(t,M);if(e)return{contents:{kind:iI.MarkupKind.Markdown,value:e.toString()}}}var aI=L(j());async function Np(t,e,r){if(!t)return;let i=t?.properties.find(s=>te(s.name)===e)?.ast.getFlatAstValues();if(!(!i||i.length<=1)&&i[r]instanceof ie)return te(i[r].value)}async function oI({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_TOKEN_BY_IDX"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return o?Np(o,s[1].macro,a):void 0}async function cI(t){let e=await oI(t,M);if(e)return{contents:{kind:aI.MarkupKind.Markdown,value:e.toString()}}}var lI=L(j());async function uI(t){let e=await cp(t,M);if(e)return e instanceof J?it(t.context,e):{contents:{kind:lI.MarkupKind.Markdown,value:e.toString()}}}var pI=L(j());async function dI(t,e,r){if(!t)return;let i=t?.properties.find(s=>te(s.name)===e)?.ast.getFlatAstValues();if(!(!i||i.length<=1)&&i[r]instanceof ie)return i[r].value}async function fI({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_UNQUOTED_BY_IDX"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return o?dI(o,s[1].macro,a):void 0}async function hI(t){let e=await fI(t,M);if(e)return{contents:{kind:pI.MarkupKind.Markdown,value:e.toString()}}}var gI=L(j());async function mI({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_UNQUOTED"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return o?lp(o,s[1].macro):void 0}async function yI(t){let e=await mI(t,M);if(e)return{contents:{kind:gI.MarkupKind.Markdown,value:e.toString()}}}var vI=L(j());async function TI(t){let e=await up(t,M);if(e)return e instanceof J?it(t.context,e):{contents:{kind:vI.MarkupKind.Markdown,value:e.toString()}}}var SI=L(j());async function bI(t,e,r){return(await Np(t,e,r))?.toUpperCase()}async function _I({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_UPPER_TOKEN_BY_IDX"||s?.length!==3)return;let o=await i({document:t,macro:s[0],context:r,position:n}),a=Ee(s[2].macro);if(typeof a=="number")return o?bI(o,s[1].macro,a):void 0}async function NI(t){let e=await _I(t,M);if(e)return{contents:{kind:SI.MarkupKind.Markdown,value:e.toString()}}}var PI=L(j());async function RI({document:t,macro:e,context:r,position:n},i){let s=e.args;if(e.macro!=="DT_STRING_UPPER_TOKEN"||s?.length!==2)return;let o=await i({document:t,macro:s[0],context:r,position:n});return o?dp(o,s[1].macro):void 0}async function kI(t){let e=await RI(t,M);if(e)return{contents:{kind:PI.MarkupKind.Markdown,value:e.toString()}}}var wI=L(j());async function EI(t){let e=await fp(t,M);if(e)return e instanceof J?it(t.context,e):{contents:{kind:wI.MarkupKind.Markdown,value:e.toString()}}}async function CI(t){let e=await Bf(t,M);return e?{contents:e.toMarkupContent(t.context.macros)}:void 0}var II=L(j());async function DI(t,e){if(!t)return;let r=t.nodeType?.onBus;return r?te(r)===e:!1}async function AI(t,e){let r=t.macro.args;if(t.macro.macro!=="DT_ON_BUS"||r?.length!==2)return;let n=await e({...t,macro:r[0]});return await DI(n,r[1].macro)}async function OI(t){let e=await AI(t,M);return e!==void 0?{contents:{kind:II.MarkupKind.Markdown,value:e?"1":"0"}}:void 0}async function MI(t){let e=await jf(t);return e?{contents:e.toMarkupContent(t.context.macros)}:void 0}var LI=L(j());async function xI(t,e){return!!await Ff(t,e)}async function qI(t){let e=t.macro.args;if(!(t.macro.macro!=="DT_HAS_CHOSEN"||e?.length!==1))return await xI(t.context,e[0].macro)}async function $I(t){let e=await qI(t);return e!==void 0?{contents:{kind:LI.MarkupKind.Markdown,value:e?"1":"0"}}:void 0}async function WU(t){return[CI,OI,MI,$I,vA,TA,NA,l0,RA,PA,EA,Y0,s0,UA,xA,AA,qA,FA,jA,zA].reduce((e,r)=>e.then(n=>n||r(t)),Promise.resolve(void 0))}async function GU(t){return[B0,q0,YA,R0,w0,C0,JA,m0,v0,b0,p0,QA,ZA,u0,S0,t0,A0,i0,I0,H0,G0,e0,rI,J0,Z0,r0,cI,sI,uI,hI,yI,TI,NI,kI,EI].reduce((e,r)=>e.then(n=>n||r(t)),Promise.resolve(void 0))}async function BI(t,e,r){if(!r)return;let n=Ni(r,t.position);return FI(n,t.position,e,r)}async function FI(t,e,r,n){if(!t?.macro)return;let i=await WU({position:e,context:r,document:n,macro:t})||await GU({position:e,context:r,document:n,macro:t});if(i)return i;let s=await M({document:n,macro:t,context:r,position:e});if(s)return{contents:s.toMarkupContent(r.macros)};let o=await ns(n,t.macro,e,r);if(o)return FI(o[0],o[1],r,n)}var uS=require("path"),dS=require("fs");var aO=L(ZI(),1);var Gc=t=>{if(typeof t!="string")throw new TypeError("invalid pattern");if(t.length>65536)throw new TypeError("pattern is too long")};var tH={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Yc=t=>t.replace(/[[\]\\-]/g,"\\$&"),rH=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),eO=t=>t.join(""),tO=(t,e)=>{let r=e;if(t.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],i=[],s=r+1,o=!1,a=!1,c=!1,l=!1,u=r,d="";e:for(;s<t.length;){let h=t.charAt(s);if((h==="!"||h==="^")&&s===r+1){l=!0,s++;continue}if(h==="]"&&o&&!c){u=s+1;break}if(o=!0,h==="\\"&&!c){c=!0,s++;continue}if(h==="["&&!c){for(let[v,[S,_,T]]of Object.entries(tH))if(t.startsWith(v,s)){if(d)return["$.",!1,t.length-r,!0];s+=v.length,T?i.push(S):n.push(S),a=a||_;continue e}}if(c=!1,d){h>d?n.push(Yc(d)+"-"+Yc(h)):h===d&&n.push(Yc(h)),d="",s++;continue}if(t.startsWith("-]",s+1)){n.push(Yc(h+"-")),s+=2;continue}if(t.startsWith("-",s+1)){d=h,s+=2;continue}n.push(Yc(h)),s++}if(u<s)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,t.length-r,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!l){let h=n[0].length===2?n[0].slice(-1):n[0];return[rH(h),!1,u-r,!1]}let f="["+(l?"^":"")+eO(n)+"]",p="["+(l?"":"^")+eO(i)+"]";return[n.length&&i.length?"("+f+"|"+p+")":n.length?f:p,a,u-r,!0]};var In=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/\[([^\/\\])\]/g,"$1"):t.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");var nH=new Set(["!","?","+","*","@"]),rO=t=>nH.has(t),iH="(?!(?:^|/)\\.\\.?(?:$|/))",Rp="(?!\\.)",sH=new Set(["[","."]),oH=new Set(["..","."]),aH=new Set("().*{}+?[]^$\\!"),cH=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),pv="[^/]",nO=pv+"*?",iO=pv+"+?",ca=class t{type;#e;#t;#i=!1;#r=[];#o;#f;#l;#d=!1;#a;#c;#s=!1;constructor(e,r,n={}){this.type=e,e&&(this.#t=!0),this.#o=r,this.#e=this.#o?this.#o.#e:this,this.#a=this.#e===this?n:this.#e.#a,this.#l=this.#e===this?[]:this.#e.#l,e==="!"&&!this.#e.#d&&this.#l.push(this),this.#f=this.#o?this.#o.#r.length:0}get hasMagic(){if(this.#t!==void 0)return this.#t;for(let e of this.#r)if(typeof e!="string"&&(e.type||e.hasMagic))return this.#t=!0;return this.#t}toString(){return this.#c!==void 0?this.#c:this.type?this.#c=this.type+"("+this.#r.map(e=>String(e)).join("|")+")":this.#c=this.#r.map(e=>String(e)).join("")}#y(){if(this!==this.#e)throw new Error("should only call on root");if(this.#d)return this;this.toString(),this.#d=!0;let e;for(;e=this.#l.pop();){if(e.type!=="!")continue;let r=e,n=r.#o;for(;n;){for(let i=r.#f+1;!n.type&&i<n.#r.length;i++)for(let s of e.#r){if(typeof s=="string")throw new Error("string part in extglob AST??");s.copyIn(n.#r[i])}r=n,n=r.#o}}return this}push(...e){for(let r of e)if(r!==""){if(typeof r!="string"&&!(r instanceof t&&r.#o===this))throw new Error("invalid part: "+r);this.#r.push(r)}}toJSON(){let e=this.type===null?this.#r.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#r.map(r=>r.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===this.#e||this.#e.#d&&this.#o?.type==="!")&&e.push({}),e}isStart(){if(this.#e===this)return!0;if(!this.#o?.isStart())return!1;if(this.#f===0)return!0;let e=this.#o;for(let r=0;r<this.#f;r++){let n=e.#r[r];if(!(n instanceof t&&n.type==="!"))return!1}return!0}isEnd(){if(this.#e===this||this.#o?.type==="!")return!0;if(!this.#o?.isEnd())return!1;if(!this.type)return this.#o?.isEnd();let e=this.#o?this.#o.#r.length:0;return this.#f===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){let r=new t(this.type,e);for(let n of this.#r)r.copyIn(n);return r}static#v(e,r,n,i){let s=!1,o=!1,a=-1,c=!1;if(r.type===null){let p=n,g="";for(;p<e.length;){let h=e.charAt(p++);if(s||h==="\\"){s=!s,g+=h;continue}if(o){p===a+1?(h==="^"||h==="!")&&(c=!0):h==="]"&&!(p===a+2&&c)&&(o=!1),g+=h;continue}else if(h==="["){o=!0,a=p,c=!1,g+=h;continue}if(!i.noext&&rO(h)&&e.charAt(p)==="("){r.push(g),g="";let v=new t(h,r);p=t.#v(e,v,p,i),r.push(v);continue}g+=h}return r.push(g),p}let l=n+1,u=new t(null,r),d=[],f="";for(;l<e.length;){let p=e.charAt(l++);if(s||p==="\\"){s=!s,f+=p;continue}if(o){l===a+1?(p==="^"||p==="!")&&(c=!0):p==="]"&&!(l===a+2&&c)&&(o=!1),f+=p;continue}else if(p==="["){o=!0,a=l,c=!1,f+=p;continue}if(rO(p)&&e.charAt(l)==="("){u.push(f),f="";let g=new t(p,u);u.push(g),l=t.#v(e,g,l,i);continue}if(p==="|"){u.push(f),f="",d.push(u),u=new t(null,r);continue}if(p===")")return f===""&&r.#r.length===0&&(r.#s=!0),u.push(f),f="",r.push(...d,u),l;f+=p}return r.type=null,r.#t=void 0,r.#r=[e.substring(n-1)],l}static fromGlob(e,r={}){let n=new t(null,void 0,r);return t.#v(e,n,0,r),n}toMMPattern(){if(this!==this.#e)return this.#e.toMMPattern();let e=this.toString(),[r,n,i,s]=this.toRegExpSource();if(!(i||this.#t||this.#a.nocase&&!this.#a.nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(s?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:e})}get options(){return this.#a}toRegExpSource(e){let r=e??!!this.#a.dot;if(this.#e===this&&this.#y(),!this.type){let c=this.isStart()&&this.isEnd(),l=this.#r.map(p=>{let[g,h,v,S]=typeof p=="string"?t.#p(p,this.#t,c):p.toRegExpSource(e);return this.#t=this.#t||v,this.#i=this.#i||S,g}).join(""),u="";if(this.isStart()&&typeof this.#r[0]=="string"&&!(this.#r.length===1&&oH.has(this.#r[0]))){let g=sH,h=r&&g.has(l.charAt(0))||l.startsWith("\\.")&&g.has(l.charAt(2))||l.startsWith("\\.\\.")&&g.has(l.charAt(4)),v=!r&&!e&&g.has(l.charAt(0));u=h?iH:v?Rp:""}let d="";return this.isEnd()&&this.#e.#d&&this.#o?.type==="!"&&(d="(?:$|\\/)"),[u+l+d,In(l),this.#t=!!this.#t,this.#i]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",s=this.#h(r);if(this.isStart()&&this.isEnd()&&!s&&this.type!=="!"){let c=this.toString();return this.#r=[c],this.type=null,this.#t=void 0,[c,In(this.toString()),!1,!1]}let o=!n||e||r||!Rp?"":this.#h(!0);o===s&&(o=""),o&&(s=`(?:${s})(?:${o})*?`);let a="";if(this.type==="!"&&this.#s)a=(this.isStart()&&!r?Rp:"")+iO;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!e?Rp:"")+nO+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=i+s+c}return[a,In(s),this.#t=!!this.#t,this.#i]}#h(e){return this.#r.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,i,s,o]=r.toRegExpSource(e);return this.#i=this.#i||o,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#p(e,r,n=!1){let i=!1,s="",o=!1;for(let a=0;a<e.length;a++){let c=e.charAt(a);if(i){i=!1,s+=(aH.has(c)?"\\":"")+c;continue}if(c==="\\"){a===e.length-1?s+="\\\\":i=!0;continue}if(c==="["){let[l,u,d,f]=tO(e,a);if(d){s+=l,o=o||u,a+=d-1,r=r||f;continue}}if(c==="*"){n&&e==="*"?s+=iO:s+=nO,r=!0;continue}if(c==="?"){s+=pv,r=!0;continue}s+=cH(c)}return[s,In(e),!!r,o]}};var la=(t,{windowsPathsNoEscape:e=!1}={})=>e?t.replace(/[?*()[\]]/g,"[$&]"):t.replace(/[?*()[\]\\]/g,"\\$&");var br=(t,e,r={})=>(Gc(e),!r.nocomment&&e.charAt(0)==="#"?!1:new Wr(e,r).match(t)),lH=/^\*+([^+@!?\*\[\(]*)$/,uH=t=>e=>!e.startsWith(".")&&e.endsWith(t),dH=t=>e=>e.endsWith(t),fH=t=>(t=t.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(t)),pH=t=>(t=t.toLowerCase(),e=>e.toLowerCase().endsWith(t)),hH=/^\*+\.\*+$/,mH=t=>!t.startsWith(".")&&t.includes("."),gH=t=>t!=="."&&t!==".."&&t.includes("."),yH=/^\.\*+$/,vH=t=>t!=="."&&t!==".."&&t.startsWith("."),TH=/^\*+$/,bH=t=>t.length!==0&&!t.startsWith("."),_H=t=>t.length!==0&&t!=="."&&t!=="..",SH=/^\?+([^+@!?\*\[\(]*)?$/,NH=([t,e=""])=>{let r=cO([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},RH=([t,e=""])=>{let r=lO([t]);return e?(e=e.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(e)):r},PH=([t,e=""])=>{let r=lO([t]);return e?n=>r(n)&&n.endsWith(e):r},kH=([t,e=""])=>{let r=cO([t]);return e?n=>r(n)&&n.endsWith(e):r},cO=([t])=>{let e=t.length;return r=>r.length===e&&!r.startsWith(".")},lO=([t])=>{let e=t.length;return r=>r.length===e&&r!=="."&&r!==".."},uO=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",sO={win32:{sep:"\\"},posix:{sep:"/"}},wH=uO==="win32"?sO.win32.sep:sO.posix.sep;br.sep=wH;var tr=Symbol("globstar **");br.GLOBSTAR=tr;var EH="[^/]",CH=EH+"*?",DH="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",AH="(?:(?!(?:\\/|^)\\.).)*?",IH=(t,e={})=>r=>br(r,t,e);br.filter=IH;var un=(t,e={})=>Object.assign({},t,e),OH=t=>{if(!t||typeof t!="object"||!Object.keys(t).length)return br;let e=br;return Object.assign((n,i,s={})=>e(n,i,un(t,s)),{Minimatch:class extends e.Minimatch{constructor(i,s={}){super(i,un(t,s))}static defaults(i){return e.defaults(un(t,i)).Minimatch}},AST:class extends e.AST{constructor(i,s,o={}){super(i,s,un(t,o))}static fromGlob(i,s={}){return e.AST.fromGlob(i,un(t,s))}},unescape:(n,i={})=>e.unescape(n,un(t,i)),escape:(n,i={})=>e.escape(n,un(t,i)),filter:(n,i={})=>e.filter(n,un(t,i)),defaults:n=>e.defaults(un(t,n)),makeRe:(n,i={})=>e.makeRe(n,un(t,i)),braceExpand:(n,i={})=>e.braceExpand(n,un(t,i)),match:(n,i,s={})=>e.match(n,i,un(t,s)),sep:e.sep,GLOBSTAR:tr})};br.defaults=OH;var dO=(t,e={})=>(Gc(t),e.nobrace||!/\{(?:(?!\{).)*\}/.test(t)?[t]:(0,aO.default)(t));br.braceExpand=dO;var MH=(t,e={})=>new Wr(t,e).makeRe();br.makeRe=MH;var xH=(t,e,r={})=>{let n=new Wr(e,r);return t=t.filter(i=>n.match(i)),n.options.nonull&&!t.length&&t.push(e),t};br.match=xH;var oO=/[?*]|[+@!]\(.*?\)|\[|\]/,qH=t=>t.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Wr=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(e,r={}){Gc(e),r=r||{},this.options=r,this.pattern=e,this.platform=r.platform||uO,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let e of this.set)for(let r of e)if(typeof r!="string")return!0;return!1}debug(...e){}make(){let e=this.pattern,r=this.options;if(!r.nocomment&&e.charAt(0)==="#"){this.comment=!0;return}if(!e){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...s)=>console.error(...s)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(s=>this.slashSplit(s));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((s,o,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=s[0]===""&&s[1]===""&&(s[2]==="?"||!oO.test(s[2]))&&!oO.test(s[3]),l=/^[a-z]:/i.test(s[0]);if(c)return[...s.slice(0,4),...s.slice(4).map(u=>this.parse(u))];if(l)return[s[0],...s.slice(1).map(u=>this.parse(u))]}return s.map(c=>this.parse(c))});if(this.debug(this.pattern,i),this.set=i.filter(s=>s.indexOf(!1)===-1),this.isWindows)for(let s=0;s<this.set.length;s++){let o=this.set[s];o[0]===""&&o[1]===""&&this.globParts[s][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let n=0;n<e.length;n++)for(let i=0;i<e[n].length;i++)e[n][i]==="**"&&(e[n][i]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):r>=1?e=this.levelOneOptimize(e):e=this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let i=n;for(;r[i+1]==="**";)i++;i!==n&&r.splice(n,i-n)}return r})}levelOneOptimize(e){return e.map(r=>(r=r.reduce((n,i)=>{let s=n[n.length-1];return i==="**"&&s==="**"?n:i===".."&&s&&s!==".."&&s!=="."&&s!=="**"?(n.pop(),n):(n.push(i),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let i=1;i<e.length-1;i++){let s=e[i];i===1&&s===""&&e[0]===""||(s==="."||s==="")&&(r=!0,e.splice(i,1),i--)}e[0]==="."&&e.length===2&&(e[1]==="."||e[1]==="")&&(r=!0,e.pop())}let n=0;for(;(n=e.indexOf("..",n+1))!==-1;){let i=e[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(r=!0,e.splice(n-1,2),n-=2)}}while(r);return e.length===0?[""]:e}firstPhasePreProcess(e){let r=!1;do{r=!1;for(let n of e){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let a=n[i+1],c=n[i+2],l=n[i+3];if(a!==".."||!c||c==="."||c===".."||!l||l==="."||l==="..")continue;r=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",e.push(u),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let s=0;for(;(s=n.indexOf("..",s+1))!==-1;){let o=n[s-1];if(o&&o!=="."&&o!==".."&&o!=="**"){r=!0;let c=s===1&&n[s+1]==="**"?["."]:[];n.splice(s-1,2,...c),n.length===0&&n.push(""),s-=2}}}}while(r);return e}secondPhasePreProcess(e){for(let r=0;r<e.length-1;r++)for(let n=r+1;n<e.length;n++){let i=this.partsMatch(e[r],e[n],!this.preserveMultipleSlashes);if(i){e[r]=[],e[n]=i;break}}return e.filter(r=>r.length)}partsMatch(e,r,n=!1){let i=0,s=0,o=[],a="";for(;i<e.length&&s<r.length;)if(e[i]===r[s])o.push(a==="b"?r[s]:e[i]),i++,s++;else if(n&&e[i]==="**"&&r[s]===e[i+1])o.push(e[i]),i++;else if(n&&r[s]==="**"&&e[i]===r[s+1])o.push(r[s]),s++;else if(e[i]==="*"&&r[s]&&(this.options.dot||!r[s].startsWith("."))&&r[s]!=="**"){if(a==="b")return!1;a="a",o.push(e[i]),i++,s++}else if(r[s]==="*"&&e[i]&&(this.options.dot||!e[i].startsWith("."))&&e[i]!=="**"){if(a==="a")return!1;a="b",o.push(r[s]),i++,s++}else return!1;return e.length===r.length&&o}parseNegate(){if(this.nonegate)return;let e=this.pattern,r=!1,n=0;for(let i=0;i<e.length&&e.charAt(i)==="!";i++)r=!r,n++;n&&(this.pattern=e.slice(n)),this.negate=r}matchOne(e,r,n=!1){let i=this.options;if(this.isWindows){let h=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),v=!h&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),S=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),_=!S&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),T=v?3:h?0:void 0,P=_?3:S?0:void 0;if(typeof T=="number"&&typeof P=="number"){let[C,$]=[e[T],r[P]];C.toLowerCase()===$.toLowerCase()&&(r[P]=C,P>T?r=r.slice(P):T>P&&(e=e.slice(T)))}}let{optimizationLevel:s=1}=this.options;s>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:r}),this.debug("matchOne",e.length,r.length);for(var o=0,a=0,c=e.length,l=r.length;o<c&&a<l;o++,a++){this.debug("matchOne loop");var u=r[a],d=e[o];if(this.debug(r,u,d),u===!1)return!1;if(u===tr){this.debug("GLOBSTAR",[r,u,d]);var f=o,p=a+1;if(p===l){for(this.debug("** at the end");o<c;o++)if(e[o]==="."||e[o]===".."||!i.dot&&e[o].charAt(0)===".")return!1;return!0}for(;f<c;){var g=e[f];if(this.debug(`
294
295
  globstar while`,e,f,r,p,g),this.matchOne(e.slice(f),r.slice(p),n))return this.debug("globstar found match!",f,c,g),!0;if(g==="."||g===".."||!i.dot&&g.charAt(0)==="."){this.debug("dot detected!",e,f,r,p);break}this.debug("globstar swallow a segment, and continue"),f++}return!!(n&&(this.debug(`
295
296
  >>> no match, partial?`,e,f,r,p),f===c))}let h;if(typeof u=="string"?(h=d===u,this.debug("string match",u,d,h)):(h=u.test(d),this.debug("pattern match",u,d,h)),!h)return!1}if(o===c&&a===l)return!0;if(o===c)return n;if(a===l)return o===c-1&&e[o]==="";throw new Error("wtf?")}braceExpand(){return dO(this.pattern,this.options)}parse(e){Gc(e);let r=this.options;if(e==="**")return tr;if(e==="")return"";let n,i=null;(n=e.match(TH))?i=r.dot?_H:bH:(n=e.match(lH))?i=(r.nocase?r.dot?pH:fH:r.dot?dH:uH)(n[1]):(n=e.match(SH))?i=(r.nocase?r.dot?RH:NH:r.dot?PH:kH)(n):(n=e.match(hH))?i=r.dot?gH:mH:(n=e.match(yH))&&(i=vH);let s=ca.fromGlob(e,this.options).toMMPattern();return i&&typeof s=="object"&&Reflect.defineProperty(s,"test",{value:i}),s}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let e=this.set;if(!e.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?CH:r.dot?DH:AH,i=new Set(r.nocase?["i"]:[]),s=e.map(c=>{let l=c.map(u=>{if(u instanceof RegExp)for(let d of u.flags.split(""))i.add(d);return typeof u=="string"?qH(u):u===tr?tr:u._src});return l.forEach((u,d)=>{let f=l[d+1],p=l[d-1];u!==tr||p===tr||(p===void 0?f!==void 0&&f!==tr?l[d+1]="(?:\\/|"+n+"\\/)?"+f:l[d]=n:f===void 0?l[d-1]=p+"(?:\\/|"+n+")?":f!==tr&&(l[d-1]=p+"(?:\\/|\\/"+n+"\\/)"+f,l[d+1]=tr))}),l.filter(u=>u!==tr).join("/")}).join("|"),[o,a]=e.length>1?["(?:",")"]:["",""];s="^"+o+s+a+"$",this.negate&&(s="^(?!"+s+").+$");try{this.regexp=new RegExp(s,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e,r=this.partial){if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&r)return!0;let n=this.options;this.isWindows&&(e=e.split("\\").join("/"));let i=this.slashSplit(e);this.debug(this.pattern,"split",i);let s=this.set;this.debug(this.pattern,"set",s);let o=i[i.length-1];if(!o)for(let a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a=0;a<s.length;a++){let c=s[a],l=i;if(n.matchBase&&c.length===1&&(l=[o]),this.matchOne(l,c,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(e){return br.defaults(e).Minimatch}};br.AST=ca;br.Minimatch=Wr;br.escape=la;br.unescape=In;var xO=require("node:url");var ua=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,pO=new Set,hv=typeof process=="object"&&process?process:{},hO=(t,e,r,n)=>{typeof hv.emitWarning=="function"?hv.emitWarning(t,e,r,n):console.error(`[${r}] ${e}: ${t}`)},Pp=globalThis.AbortController,fO=globalThis.AbortSignal;if(typeof Pp>"u"){fO=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(n,i){this._onabort.push(i)}},Pp=class{constructor(){e()}signal=new fO;abort(n){if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(let i of this.signal._onabort)i(n);this.signal.onabort?.(n)}}};let t=hv.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,hO("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}var LH=t=>!pO.has(t),FSe=Symbol("type"),as=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),mO=t=>as(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?da:null:null,da=class extends Array{constructor(e){super(e),this.fill(0)}},mv=class t{heap;length;static#e=!1;static create(e){let r=mO(e);if(!r)return[];t.#e=!0;let n=new t(e,r);return t.#e=!1,n}constructor(e,r){if(!t.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},Kc=class t{#e;#t;#i;#r;#o;#f;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#l;#d;#a;#c;#s;#y;#v;#h;#p;#N;#g;#R;#P;#b;#_;#S;#m;static unsafeExposeInternals(e){return{starts:e.#P,ttls:e.#b,sizes:e.#R,keyMap:e.#a,keyList:e.#c,valList:e.#s,next:e.#y,prev:e.#v,get head(){return e.#h},get tail(){return e.#p},free:e.#N,isBackgroundFetch:r=>e.#u(r),backgroundFetch:(r,n,i,s)=>e.#$(r,n,i,s),moveToTail:r=>e.#F(r),indexes:r=>e.#w(r),rindexes:r=>e.#E(r),isStale:r=>e.#T(r)}}get max(){return this.#e}get maxSize(){return this.#t}get calculatedSize(){return this.#d}get size(){return this.#l}get fetchMethod(){return this.#o}get memoMethod(){return this.#f}get dispose(){return this.#i}get disposeAfter(){return this.#r}constructor(e){let{max:r=0,ttl:n,ttlResolution:i=1,ttlAutopurge:s,updateAgeOnGet:o,updateAgeOnHas:a,allowStale:c,dispose:l,disposeAfter:u,noDisposeOnSet:d,noUpdateTTL:f,maxSize:p=0,maxEntrySize:g=0,sizeCalculation:h,fetchMethod:v,memoMethod:S,noDeleteOnFetchRejection:_,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:P,allowStaleOnFetchAbort:C,ignoreFetchAbort:$}=e;if(r!==0&&!as(r))throw new TypeError("max option must be a nonnegative integer");let F=r?mO(r):Array;if(!F)throw new Error("invalid max value: "+r);if(this.#e=r,this.#t=p,this.maxEntrySize=g||this.#t,this.sizeCalculation=h,this.sizeCalculation){if(!this.#t&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(S!==void 0&&typeof S!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#f=S,v!==void 0&&typeof v!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#o=v,this.#S=!!v,this.#a=new Map,this.#c=new Array(r).fill(void 0),this.#s=new Array(r).fill(void 0),this.#y=new F(r),this.#v=new F(r),this.#h=0,this.#p=0,this.#N=mv.create(r),this.#l=0,this.#d=0,typeof l=="function"&&(this.#i=l),typeof u=="function"?(this.#r=u,this.#g=[]):(this.#r=void 0,this.#g=void 0),this.#_=!!this.#i,this.#m=!!this.#r,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!f,this.noDeleteOnFetchRejection=!!_,this.allowStaleOnFetchRejection=!!P,this.allowStaleOnFetchAbort=!!C,this.ignoreFetchAbort=!!$,this.maxEntrySize!==0){if(this.#t!==0&&!as(this.#t))throw new TypeError("maxSize must be a positive integer if specified");if(!as(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#D()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!a,this.ttlResolution=as(i)||i===0?i:1,this.ttlAutopurge=!!s,this.ttl=n||0,this.ttl){if(!as(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#C()}if(this.#e===0&&this.ttl===0&&this.#t===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#t){let H="LRU_CACHE_UNBOUNDED";LH(H)&&(pO.add(H),hO("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",H,t))}}getRemainingTTL(e){return this.#a.has(e)?1/0:0}#C(){let e=new da(this.#e),r=new da(this.#e);this.#b=e,this.#P=r,this.#I=(s,o,a=ua.now())=>{if(r[s]=o!==0?a:0,e[s]=o,o!==0&&this.ttlAutopurge){let c=setTimeout(()=>{this.#T(s)&&this.#A(this.#c[s],"expire")},o+1);c.unref&&c.unref()}},this.#k=s=>{r[s]=e[s]!==0?ua.now():0},this.#n=(s,o)=>{if(e[o]){let a=e[o],c=r[o];if(!a||!c)return;s.ttl=a,s.start=c,s.now=n||i();let l=s.now-c;s.remainingTTL=a-l}};let n=0,i=()=>{let s=ua.now();if(this.ttlResolution>0){n=s;let o=setTimeout(()=>n=0,this.ttlResolution);o.unref&&o.unref()}return s};this.getRemainingTTL=s=>{let o=this.#a.get(s);if(o===void 0)return 0;let a=e[o],c=r[o];if(!a||!c)return 1/0;let l=(n||i())-c;return a-l},this.#T=s=>{let o=r[s],a=e[s];return!!a&&!!o&&(n||i())-o>a}}#k=()=>{};#n=()=>{};#I=()=>{};#T=()=>!1;#D(){let e=new da(this.#e);this.#d=0,this.#R=e,this.#O=r=>{this.#d-=e[r],e[r]=0},this.#x=(r,n,i,s)=>{if(this.#u(n))return 0;if(!as(i))if(s){if(typeof s!="function")throw new TypeError("sizeCalculation must be a function");if(i=s(n,r),!as(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i},this.#M=(r,n,i)=>{if(e[r]=n,this.#t){let s=this.#t-e[r];for(;this.#d>s;)this.#L(!0)}this.#d+=e[r],i&&(i.entrySize=n,i.totalCalculatedSize=this.#d)}}#O=e=>{};#M=(e,r,n)=>{};#x=(e,r,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#w({allowStale:e=this.allowStale}={}){if(this.#l)for(let r=this.#p;!(!this.#q(r)||((e||!this.#T(r))&&(yield r),r===this.#h));)r=this.#v[r]}*#E({allowStale:e=this.allowStale}={}){if(this.#l)for(let r=this.#h;!(!this.#q(r)||((e||!this.#T(r))&&(yield r),r===this.#p));)r=this.#y[r]}#q(e){return e!==void 0&&this.#a.get(this.#c[e])===e}*entries(){for(let e of this.#w())this.#s[e]!==void 0&&this.#c[e]!==void 0&&!this.#u(this.#s[e])&&(yield[this.#c[e],this.#s[e]])}*rentries(){for(let e of this.#E())this.#s[e]!==void 0&&this.#c[e]!==void 0&&!this.#u(this.#s[e])&&(yield[this.#c[e],this.#s[e]])}*keys(){for(let e of this.#w()){let r=this.#c[e];r!==void 0&&!this.#u(this.#s[e])&&(yield r)}}*rkeys(){for(let e of this.#E()){let r=this.#c[e];r!==void 0&&!this.#u(this.#s[e])&&(yield r)}}*values(){for(let e of this.#w())this.#s[e]!==void 0&&!this.#u(this.#s[e])&&(yield this.#s[e])}*rvalues(){for(let e of this.#E())this.#s[e]!==void 0&&!this.#u(this.#s[e])&&(yield this.#s[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,r={}){for(let n of this.#w()){let i=this.#s[n],s=this.#u(i)?i.__staleWhileFetching:i;if(s!==void 0&&e(s,this.#c[n],this))return this.get(this.#c[n],r)}}forEach(e,r=this){for(let n of this.#w()){let i=this.#s[n],s=this.#u(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(r,s,this.#c[n],this)}}rforEach(e,r=this){for(let n of this.#E()){let i=this.#s[n],s=this.#u(i)?i.__staleWhileFetching:i;s!==void 0&&e.call(r,s,this.#c[n],this)}}purgeStale(){let e=!1;for(let r of this.#E({allowStale:!0}))this.#T(r)&&(this.#A(this.#c[r],"expire"),e=!0);return e}info(e){let r=this.#a.get(e);if(r===void 0)return;let n=this.#s[r],i=this.#u(n)?n.__staleWhileFetching:n;if(i===void 0)return;let s={value:i};if(this.#b&&this.#P){let o=this.#b[r],a=this.#P[r];if(o&&a){let c=o-(ua.now()-a);s.ttl=c,s.start=Date.now()}}return this.#R&&(s.size=this.#R[r]),s}dump(){let e=[];for(let r of this.#w({allowStale:!0})){let n=this.#c[r],i=this.#s[r],s=this.#u(i)?i.__staleWhileFetching:i;if(s===void 0||n===void 0)continue;let o={value:s};if(this.#b&&this.#P){o.ttl=this.#b[r];let a=ua.now()-this.#P[r];o.start=Math.floor(Date.now()-a)}this.#R&&(o.size=this.#R[r]),e.unshift([n,o])}return e}load(e){this.clear();for(let[r,n]of e){if(n.start){let i=Date.now()-n.start;n.start=ua.now()-i}this.set(r,n.value,n)}}set(e,r,n={}){if(r===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:s,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=n,{noUpdateTTL:l=this.noUpdateTTL}=n,u=this.#x(e,r,n.size||0,a);if(this.maxEntrySize&&u>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#A(e,"set"),this;let d=this.#l===0?void 0:this.#a.get(e);if(d===void 0)d=this.#l===0?this.#p:this.#N.length!==0?this.#N.pop():this.#l===this.#e?this.#L(!1):this.#l,this.#c[d]=e,this.#s[d]=r,this.#a.set(e,d),this.#y[this.#p]=d,this.#v[d]=this.#p,this.#p=d,this.#l++,this.#M(d,u,c),c&&(c.set="add"),l=!1;else{this.#F(d);let f=this.#s[d];if(r!==f){if(this.#S&&this.#u(f)){f.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=f;p!==void 0&&!o&&(this.#_&&this.#i?.(p,e,"set"),this.#m&&this.#g?.push([p,e,"set"]))}else o||(this.#_&&this.#i?.(f,e,"set"),this.#m&&this.#g?.push([f,e,"set"]));if(this.#O(d),this.#M(d,u,c),this.#s[d]=r,c){c.set="replace";let p=f&&this.#u(f)?f.__staleWhileFetching:f;p!==void 0&&(c.oldValue=p)}}else c&&(c.set="update")}if(i!==0&&!this.#b&&this.#C(),this.#b&&(l||this.#I(d,i,s),c&&this.#n(c,d)),!o&&this.#m&&this.#g){let f=this.#g,p;for(;p=f?.shift();)this.#r?.(...p)}return this}pop(){try{for(;this.#l;){let e=this.#s[this.#h];if(this.#L(!0),this.#u(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#m&&this.#g){let e=this.#g,r;for(;r=e?.shift();)this.#r?.(...r)}}}#L(e){let r=this.#h,n=this.#c[r],i=this.#s[r];return this.#S&&this.#u(i)?i.__abortController.abort(new Error("evicted")):(this.#_||this.#m)&&(this.#_&&this.#i?.(i,n,"evict"),this.#m&&this.#g?.push([i,n,"evict"])),this.#O(r),e&&(this.#c[r]=void 0,this.#s[r]=void 0,this.#N.push(r)),this.#l===1?(this.#h=this.#p=0,this.#N.length=0):this.#h=this.#y[r],this.#a.delete(n),this.#l--,r}has(e,r={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=r,s=this.#a.get(e);if(s!==void 0){let o=this.#s[s];if(this.#u(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#T(s))i&&(i.has="stale",this.#n(i,s));else return n&&this.#k(s),i&&(i.has="hit",this.#n(i,s)),!0}else i&&(i.has="miss");return!1}peek(e,r={}){let{allowStale:n=this.allowStale}=r,i=this.#a.get(e);if(i===void 0||!n&&this.#T(i))return;let s=this.#s[i];return this.#u(s)?s.__staleWhileFetching:s}#$(e,r,n,i){let s=r===void 0?void 0:this.#s[r];if(this.#u(s))return s;let o=new Pp,{signal:a}=n;a?.addEventListener("abort",()=>o.abort(a.reason),{signal:o.signal});let c={signal:o.signal,options:n,context:i},l=(h,v=!1)=>{let{aborted:S}=o.signal,_=n.ignoreFetchAbort&&h!==void 0;if(n.status&&(S&&!v?(n.status.fetchAborted=!0,n.status.fetchError=o.signal.reason,_&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),S&&!_&&!v)return d(o.signal.reason);let T=p;return this.#s[r]===p&&(h===void 0?T.__staleWhileFetching?this.#s[r]=T.__staleWhileFetching:this.#A(e,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(e,h,c.options))),h},u=h=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=h),d(h)),d=h=>{let{aborted:v}=o.signal,S=v&&n.allowStaleOnFetchAbort,_=S||n.allowStaleOnFetchRejection,T=_||n.noDeleteOnFetchRejection,P=p;if(this.#s[r]===p&&(!T||P.__staleWhileFetching===void 0?this.#A(e,"fetch"):S||(this.#s[r]=P.__staleWhileFetching)),_)return n.status&&P.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),P.__staleWhileFetching;if(P.__returned===P)throw h},f=(h,v)=>{let S=this.#o?.(e,s,c);S&&S instanceof Promise&&S.then(_=>h(_===void 0?void 0:_),v),o.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(h(void 0),n.allowStaleOnFetchAbort&&(h=_=>l(_,!0)))})};n.status&&(n.status.fetchDispatched=!0);let p=new Promise(f).then(l,u),g=Object.assign(p,{__abortController:o,__staleWhileFetching:s,__returned:void 0});return r===void 0?(this.set(e,g,{...c.options,status:void 0}),r=this.#a.get(e)):this.#s[r]=g,g}#u(e){if(!this.#S)return!1;let r=e;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof Pp}async fetch(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:c=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:f=this.allowStaleOnFetchRejection,ignoreFetchAbort:p=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:h,forceRefresh:v=!1,status:S,signal:_}=r;if(!this.#S)return S&&(S.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,status:S});let T={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:s,ttl:o,noDisposeOnSet:a,size:c,sizeCalculation:l,noUpdateTTL:u,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:f,allowStaleOnFetchAbort:g,ignoreFetchAbort:p,status:S,signal:_},P=this.#a.get(e);if(P===void 0){S&&(S.fetch="miss");let C=this.#$(e,P,T,h);return C.__returned=C}else{let C=this.#s[P];if(this.#u(C)){let Xe=n&&C.__staleWhileFetching!==void 0;return S&&(S.fetch="inflight",Xe&&(S.returnedStale=!0)),Xe?C.__staleWhileFetching:C.__returned=C}let $=this.#T(P);if(!v&&!$)return S&&(S.fetch="hit"),this.#F(P),i&&this.#k(P),S&&this.#n(S,P),C;let F=this.#$(e,P,T,h),me=F.__staleWhileFetching!==void 0&&n;return S&&(S.fetch=$?"stale":"refresh",me&&$&&(S.returnedStale=!0)),me?F.__staleWhileFetching:F.__returned=F}}async forceFetch(e,r={}){let n=await this.fetch(e,r);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,r={}){let n=this.#f;if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:s,...o}=r,a=this.get(e,o);if(!s&&a!==void 0)return a;let c=n(e,a,{options:o,context:i});return this.set(e,c,o),c}get(e,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:s=this.noDeleteOnStaleGet,status:o}=r,a=this.#a.get(e);if(a!==void 0){let c=this.#s[a],l=this.#u(c);return o&&this.#n(o,a),this.#T(a)?(o&&(o.get="stale"),l?(o&&n&&c.__staleWhileFetching!==void 0&&(o.returnedStale=!0),n?c.__staleWhileFetching:void 0):(s||this.#A(e,"expire"),o&&n&&(o.returnedStale=!0),n?c:void 0)):(o&&(o.get="hit"),l?c.__staleWhileFetching:(this.#F(a),i&&this.#k(a),c))}else o&&(o.get="miss")}#B(e,r){this.#v[r]=e,this.#y[e]=r}#F(e){e!==this.#p&&(e===this.#h?this.#h=this.#y[e]:this.#B(this.#v[e],this.#y[e]),this.#B(this.#p,e),this.#p=e)}delete(e){return this.#A(e,"delete")}#A(e,r){let n=!1;if(this.#l!==0){let i=this.#a.get(e);if(i!==void 0)if(n=!0,this.#l===1)this.#j(r);else{this.#O(i);let s=this.#s[i];if(this.#u(s)?s.__abortController.abort(new Error("deleted")):(this.#_||this.#m)&&(this.#_&&this.#i?.(s,e,r),this.#m&&this.#g?.push([s,e,r])),this.#a.delete(e),this.#c[i]=void 0,this.#s[i]=void 0,i===this.#p)this.#p=this.#v[i];else if(i===this.#h)this.#h=this.#y[i];else{let o=this.#v[i];this.#y[o]=this.#y[i];let a=this.#y[i];this.#v[a]=this.#v[i]}this.#l--,this.#N.push(i)}}if(this.#m&&this.#g?.length){let i=this.#g,s;for(;s=i?.shift();)this.#r?.(...s)}return n}clear(){return this.#j("delete")}#j(e){for(let r of this.#E({allowStale:!0})){let n=this.#s[r];if(this.#u(n))n.__abortController.abort(new Error("deleted"));else{let i=this.#c[r];this.#_&&this.#i?.(n,i,e),this.#m&&this.#g?.push([n,i,e])}}if(this.#a.clear(),this.#s.fill(void 0),this.#c.fill(void 0),this.#b&&this.#P&&(this.#b.fill(0),this.#P.fill(0)),this.#R&&this.#R.fill(0),this.#h=0,this.#p=0,this.#N.length=0,this.#d=0,this.#l=0,this.#m&&this.#g){let r=this.#g,n;for(;n=r?.shift();)this.#r?.(...n)}}};var ha=require("node:path"),PO=require("node:url"),ii=require("fs"),GH=L(require("node:fs"),1),us=require("node:fs/promises");var Ip=require("node:events"),Sv=L(require("node:stream"),1),bO=require("node:string_decoder"),gO=typeof process=="object"&&process?process:{stdout:null,stderr:null},$H=t=>!!t&&typeof t=="object"&&(t instanceof ls||t instanceof Sv.default||BH(t)||FH(t)),BH=t=>!!t&&typeof t=="object"&&t instanceof Ip.EventEmitter&&typeof t.pipe=="function"&&t.pipe!==Sv.default.Writable.prototype.pipe,FH=t=>!!t&&typeof t=="object"&&t instanceof Ip.EventEmitter&&typeof t.write=="function"&&typeof t.end=="function",ki=Symbol("EOF"),wi=Symbol("maybeEmitEnd"),cs=Symbol("emittedEnd"),kp=Symbol("emittingEnd"),Xc=Symbol("emittedError"),wp=Symbol("closed"),yO=Symbol("read"),Ep=Symbol("flush"),vO=Symbol("flushChunk"),On=Symbol("encoding"),fa=Symbol("decoder"),Gt=Symbol("flowing"),Jc=Symbol("paused"),pa=Symbol("resume"),Yt=Symbol("buffer"),_r=Symbol("pipes"),Kt=Symbol("bufferLength"),gv=Symbol("bufferPush"),Cp=Symbol("bufferShift"),dr=Symbol("objectMode"),It=Symbol("destroyed"),yv=Symbol("error"),vv=Symbol("emitData"),TO=Symbol("emitEnd"),Tv=Symbol("emitEnd2"),ri=Symbol("async"),bv=Symbol("abort"),Dp=Symbol("aborted"),Qc=Symbol("signal"),Vs=Symbol("dataListeners"),Gr=Symbol("discarded"),Zc=t=>Promise.resolve().then(t),jH=t=>t(),UH=t=>t==="end"||t==="finish"||t==="prefinish",HH=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,VH=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Ap=class{src;dest;opts;ondrain;constructor(e,r,n){this.src=e,this.dest=r,this.opts=n,this.ondrain=()=>e[pa](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},_v=class extends Ap{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,r,n){super(e,r,n),this.proxyErrors=i=>r.emit("error",i),e.on("error",this.proxyErrors)}},zH=t=>!!t.objectMode,WH=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",ls=class extends Ip.EventEmitter{[Gt]=!1;[Jc]=!1;[_r]=[];[Yt]=[];[dr];[On];[ri];[fa];[ki]=!1;[cs]=!1;[kp]=!1;[wp]=!1;[Xc]=null;[Kt]=0;[It]=!1;[Qc];[Dp]=!1;[Vs]=0;[Gr]=!1;writable=!0;readable=!0;constructor(...e){let r=e[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");zH(r)?(this[dr]=!0,this[On]=null):WH(r)?(this[On]=r.encoding,this[dr]=!1):(this[dr]=!1,this[On]=null),this[ri]=!!r.async,this[fa]=this[On]?new bO.StringDecoder(this[On]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[Yt]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[_r]});let{signal:n}=r;n&&(this[Qc]=n,n.aborted?this[bv]():n.addEventListener("abort",()=>this[bv]()))}get bufferLength(){return this[Kt]}get encoding(){return this[On]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[dr]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[ri]}set async(e){this[ri]=this[ri]||!!e}[bv](){this[Dp]=!0,this.emit("abort",this[Qc]?.reason),this.destroy(this[Qc]?.reason)}get aborted(){return this[Dp]}set aborted(e){}write(e,r,n){if(this[Dp])return!1;if(this[ki])throw new Error("write after end");if(this[It])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(n=r,r="utf8"),r||(r="utf8");let i=this[ri]?Zc:jH;if(!this[dr]&&!Buffer.isBuffer(e)){if(VH(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(HH(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[dr]?(this[Gt]&&this[Kt]!==0&&this[Ep](!0),this[Gt]?this.emit("data",e):this[gv](e),this[Kt]!==0&&this.emit("readable"),n&&i(n),this[Gt]):e.length?(typeof e=="string"&&!(r===this[On]&&!this[fa]?.lastNeed)&&(e=Buffer.from(e,r)),Buffer.isBuffer(e)&&this[On]&&(e=this[fa].write(e)),this[Gt]&&this[Kt]!==0&&this[Ep](!0),this[Gt]?this.emit("data",e):this[gv](e),this[Kt]!==0&&this.emit("readable"),n&&i(n),this[Gt]):(this[Kt]!==0&&this.emit("readable"),n&&i(n),this[Gt])}read(e){if(this[It])return null;if(this[Gr]=!1,this[Kt]===0||e===0||e&&e>this[Kt])return this[wi](),null;this[dr]&&(e=null),this[Yt].length>1&&!this[dr]&&(this[Yt]=[this[On]?this[Yt].join(""):Buffer.concat(this[Yt],this[Kt])]);let r=this[yO](e||null,this[Yt][0]);return this[wi](),r}[yO](e,r){if(this[dr])this[Cp]();else{let n=r;e===n.length||e===null?this[Cp]():typeof n=="string"?(this[Yt][0]=n.slice(e),r=n.slice(0,e),this[Kt]-=e):(this[Yt][0]=n.subarray(e),r=n.subarray(0,e),this[Kt]-=e)}return this.emit("data",r),!this[Yt].length&&!this[ki]&&this.emit("drain"),r}end(e,r,n){return typeof e=="function"&&(n=e,e=void 0),typeof r=="function"&&(n=r,r="utf8"),e!==void 0&&this.write(e,r),n&&this.once("end",n),this[ki]=!0,this.writable=!1,(this[Gt]||!this[Jc])&&this[wi](),this}[pa](){this[It]||(!this[Vs]&&!this[_r].length&&(this[Gr]=!0),this[Jc]=!1,this[Gt]=!0,this.emit("resume"),this[Yt].length?this[Ep]():this[ki]?this[wi]():this.emit("drain"))}resume(){return this[pa]()}pause(){this[Gt]=!1,this[Jc]=!0,this[Gr]=!1}get destroyed(){return this[It]}get flowing(){return this[Gt]}get paused(){return this[Jc]}[gv](e){this[dr]?this[Kt]+=1:this[Kt]+=e.length,this[Yt].push(e)}[Cp](){return this[dr]?this[Kt]-=1:this[Kt]-=this[Yt][0].length,this[Yt].shift()}[Ep](e=!1){do;while(this[vO](this[Cp]())&&this[Yt].length);!e&&!this[Yt].length&&!this[ki]&&this.emit("drain")}[vO](e){return this.emit("data",e),this[Gt]}pipe(e,r){if(this[It])return e;this[Gr]=!1;let n=this[cs];return r=r||{},e===gO.stdout||e===gO.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,n?r.end&&e.end():(this[_r].push(r.proxyErrors?new _v(this,e,r):new Ap(this,e,r)),this[ri]?Zc(()=>this[pa]()):this[pa]()),e}unpipe(e){let r=this[_r].find(n=>n.dest===e);r&&(this[_r].length===1?(this[Gt]&&this[Vs]===0&&(this[Gt]=!1),this[_r]=[]):this[_r].splice(this[_r].indexOf(r),1),r.unpipe())}addListener(e,r){return this.on(e,r)}on(e,r){let n=super.on(e,r);if(e==="data")this[Gr]=!1,this[Vs]++,!this[_r].length&&!this[Gt]&&this[pa]();else if(e==="readable"&&this[Kt]!==0)super.emit("readable");else if(UH(e)&&this[cs])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[Xc]){let i=r;this[ri]?Zc(()=>i.call(this,this[Xc])):i.call(this,this[Xc])}return n}removeListener(e,r){return this.off(e,r)}off(e,r){let n=super.off(e,r);return e==="data"&&(this[Vs]=this.listeners("data").length,this[Vs]===0&&!this[Gr]&&!this[_r].length&&(this[Gt]=!1)),n}removeAllListeners(e){let r=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[Vs]=0,!this[Gr]&&!this[_r].length&&(this[Gt]=!1)),r}get emittedEnd(){return this[cs]}[wi](){!this[kp]&&!this[cs]&&!this[It]&&this[Yt].length===0&&this[ki]&&(this[kp]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[wp]&&this.emit("close"),this[kp]=!1)}emit(e,...r){let n=r[0];if(e!=="error"&&e!=="close"&&e!==It&&this[It])return!1;if(e==="data")return!this[dr]&&!n?!1:this[ri]?(Zc(()=>this[vv](n)),!0):this[vv](n);if(e==="end")return this[TO]();if(e==="close"){if(this[wp]=!0,!this[cs]&&!this[It])return!1;let s=super.emit("close");return this.removeAllListeners("close"),s}else if(e==="error"){this[Xc]=n,super.emit(yv,n);let s=!this[Qc]||this.listeners("error").length?super.emit("error",n):!1;return this[wi](),s}else if(e==="resume"){let s=super.emit("resume");return this[wi](),s}else if(e==="finish"||e==="prefinish"){let s=super.emit(e);return this.removeAllListeners(e),s}let i=super.emit(e,...r);return this[wi](),i}[vv](e){for(let n of this[_r])n.dest.write(e)===!1&&this.pause();let r=this[Gr]?!1:super.emit("data",e);return this[wi](),r}[TO](){return this[cs]?!1:(this[cs]=!0,this.readable=!1,this[ri]?(Zc(()=>this[Tv]()),!0):this[Tv]())}[Tv](){if(this[fa]){let r=this[fa].end();if(r){for(let n of this[_r])n.dest.write(r);this[Gr]||super.emit("data",r)}}for(let r of this[_r])r.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[dr]||(e.dataLength=0);let r=this.promise();return this.on("data",n=>{e.push(n),this[dr]||(e.dataLength+=n.length)}),await r,e}async concat(){if(this[dr])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[On]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,r)=>{this.on(It,()=>r(new Error("stream destroyed"))),this.on("error",n=>r(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Gr]=!1;let e=!1,r=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return r();let i=this.read();if(i!==null)return Promise.resolve({done:!1,value:i});if(this[ki])return r();let s,o,a=d=>{this.off("data",c),this.off("end",l),this.off(It,u),r(),o(d)},c=d=>{this.off("error",a),this.off("end",l),this.off(It,u),this.pause(),s({value:d,done:!!this[ki]})},l=()=>{this.off("error",a),this.off("data",c),this.off(It,u),r(),s({done:!0,value:void 0})},u=()=>a(new Error("stream destroyed"));return new Promise((d,f)=>{o=f,s=d,this.once(It,u),this.once("error",a),this.once("end",l),this.once("data",c)})},throw:r,return:r,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Gr]=!1;let e=!1,r=()=>(this.pause(),this.off(yv,r),this.off(It,r),this.off("end",r),e=!0,{done:!0,value:void 0}),n=()=>{if(e)return r();let i=this.read();return i===null?r():{done:!1,value:i}};return this.once("end",r),this.once(yv,r),this.once(It,r),{next:n,throw:r,return:r,[Symbol.iterator](){return this}}}destroy(e){if(this[It])return e?this.emit("error",e):this.emit(It),this;this[It]=!0,this[Gr]=!0,this[Yt].length=0,this[Kt]=0;let r=this;return typeof r.close=="function"&&!this[wp]&&r.close(),e?this.emit("error",e):this.emit(It),this}static get isStream(){return $H}};var YH=ii.realpathSync.native,tl={lstatSync:ii.lstatSync,readdir:ii.readdir,readdirSync:ii.readdirSync,readlinkSync:ii.readlinkSync,realpathSync:YH,promises:{lstat:us.lstat,readdir:us.readdir,readlink:us.readlink,realpath:us.realpath}},kO=t=>!t||t===tl||t===GH?tl:{...tl,...t,promises:{...tl.promises,...t.promises||{}}},wO=/^\\\\\?\\([a-z]:)\\?$/i,KH=t=>t.replace(/\//g,"\\").replace(wO,"$1\\"),XH=/[\\\/]/,fn=0,EO=1,CO=2,ni=4,DO=6,AO=8,zs=10,IO=12,dn=15,el=~dn,Nv=16,_O=32,rl=64,Mn=128,Op=256,xp=512,SO=rl|Mn|xp,JH=1023,Rv=t=>t.isFile()?AO:t.isDirectory()?ni:t.isSymbolicLink()?zs:t.isCharacterDevice()?CO:t.isBlockDevice()?DO:t.isSocket()?IO:t.isFIFO()?EO:fn,NO=new Map,nl=t=>{let e=NO.get(t);if(e)return e;let r=t.normalize("NFKD");return NO.set(t,r),r},RO=new Map,Mp=t=>{let e=RO.get(t);if(e)return e;let r=nl(t.toLowerCase());return RO.set(t,r),r},qp=class extends Kc{constructor(){super({max:256})}},Pv=class extends Kc{constructor(e=16*1024){super({maxSize:e,sizeCalculation:r=>r.length+1})}},OO=Symbol("PathScurry setAsCwd"),fr=class{name;root;roots;parent;nocase;isCWD=!1;#e;#t;get dev(){return this.#t}#i;get mode(){return this.#i}#r;get nlink(){return this.#r}#o;get uid(){return this.#o}#f;get gid(){return this.#f}#l;get rdev(){return this.#l}#d;get blksize(){return this.#d}#a;get ino(){return this.#a}#c;get size(){return this.#c}#s;get blocks(){return this.#s}#y;get atimeMs(){return this.#y}#v;get mtimeMs(){return this.#v}#h;get ctimeMs(){return this.#h}#p;get birthtimeMs(){return this.#p}#N;get atime(){return this.#N}#g;get mtime(){return this.#g}#R;get ctime(){return this.#R}#P;get birthtime(){return this.#P}#b;#_;#S;#m;#C;#k;#n;#I;#T;#D;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(e,r=fn,n,i,s,o,a){this.name=e,this.#b=s?Mp(e):nl(e),this.#n=r&JH,this.nocase=s,this.roots=i,this.root=n||this,this.#I=o,this.#S=a.fullpath,this.#C=a.relative,this.#k=a.relativePosix,this.parent=a.parent,this.parent?this.#e=this.parent.#e:this.#e=kO(a.fs)}depth(){return this.#_!==void 0?this.#_:this.parent?this.#_=this.parent.depth()+1:this.#_=0}childrenCache(){return this.#I}resolve(e){if(!e)return this;let r=this.getRootString(e),i=e.substring(r.length).split(this.splitSep);return r?this.getRoot(r).#O(i):this.#O(i)}#O(e){let r=this;for(let n of e)r=r.child(n);return r}children(){let e=this.#I.get(this);if(e)return e;let r=Object.assign([],{provisional:0});return this.#I.set(this,r),this.#n&=~Nv,r}child(e,r){if(e===""||e===".")return this;if(e==="..")return this.parent||this;let n=this.children(),i=this.nocase?Mp(e):nl(e);for(let c of n)if(c.#b===i)return c;let s=this.parent?this.sep:"",o=this.#S?this.#S+s+e:void 0,a=this.newChild(e,fn,{...r,parent:this,fullpath:o});return this.canReaddir()||(a.#n|=Mn),n.push(a),a}relative(){if(this.isCWD)return"";if(this.#C!==void 0)return this.#C;let e=this.name,r=this.parent;if(!r)return this.#C=this.name;let n=r.relative();return n+(!n||!r.parent?"":this.sep)+e}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#k!==void 0)return this.#k;let e=this.name,r=this.parent;if(!r)return this.#k=this.fullpathPosix();let n=r.relativePosix();return n+(!n||!r.parent?"":"/")+e}fullpath(){if(this.#S!==void 0)return this.#S;let e=this.name,r=this.parent;if(!r)return this.#S=this.name;let i=r.fullpath()+(r.parent?this.sep:"")+e;return this.#S=i}fullpathPosix(){if(this.#m!==void 0)return this.#m;if(this.sep==="/")return this.#m=this.fullpath();if(!this.parent){let i=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(i)?this.#m=`//?/${i}`:this.#m=i}let e=this.parent,r=e.fullpathPosix(),n=r+(!r||!e.parent?"":"/")+this.name;return this.#m=n}isUnknown(){return(this.#n&dn)===fn}isType(e){return this[`is${e}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#n&dn)===AO}isDirectory(){return(this.#n&dn)===ni}isCharacterDevice(){return(this.#n&dn)===CO}isBlockDevice(){return(this.#n&dn)===DO}isFIFO(){return(this.#n&dn)===EO}isSocket(){return(this.#n&dn)===IO}isSymbolicLink(){return(this.#n&zs)===zs}lstatCached(){return this.#n&_O?this:void 0}readlinkCached(){return this.#T}realpathCached(){return this.#D}readdirCached(){let e=this.children();return e.slice(0,e.provisional)}canReadlink(){if(this.#T)return!0;if(!this.parent)return!1;let e=this.#n&dn;return!(e!==fn&&e!==zs||this.#n&Op||this.#n&Mn)}calledReaddir(){return!!(this.#n&Nv)}isENOENT(){return!!(this.#n&Mn)}isNamed(e){return this.nocase?this.#b===Mp(e):this.#b===nl(e)}async readlink(){let e=this.#T;if(e)return e;if(this.canReadlink()&&this.parent)try{let r=await this.#e.promises.readlink(this.fullpath()),n=(await this.parent.realpath())?.resolve(r);if(n)return this.#T=n}catch(r){this.#u(r.code);return}}readlinkSync(){let e=this.#T;if(e)return e;if(this.canReadlink()&&this.parent)try{let r=this.#e.readlinkSync(this.fullpath()),n=this.parent.realpathSync()?.resolve(r);if(n)return this.#T=n}catch(r){this.#u(r.code);return}}#M(e){this.#n|=Nv;for(let r=e.provisional;r<e.length;r++){let n=e[r];n&&n.#x()}}#x(){this.#n&Mn||(this.#n=(this.#n|Mn)&el,this.#w())}#w(){let e=this.children();e.provisional=0;for(let r of e)r.#x()}#E(){this.#n|=xp,this.#q()}#q(){if(this.#n&rl)return;let e=this.#n;(e&dn)===ni&&(e&=el),this.#n=e|rl,this.#w()}#L(e=""){e==="ENOTDIR"||e==="EPERM"?this.#q():e==="ENOENT"?this.#x():this.children().provisional=0}#$(e=""){e==="ENOTDIR"?this.parent.#q():e==="ENOENT"&&this.#x()}#u(e=""){let r=this.#n;r|=Op,e==="ENOENT"&&(r|=Mn),(e==="EINVAL"||e==="UNKNOWN")&&(r&=el),this.#n=r,e==="ENOTDIR"&&this.parent&&this.parent.#q()}#B(e,r){return this.#A(e,r)||this.#F(e,r)}#F(e,r){let n=Rv(e),i=this.newChild(e.name,n,{parent:this}),s=i.#n&dn;return s!==ni&&s!==zs&&s!==fn&&(i.#n|=rl),r.unshift(i),r.provisional++,i}#A(e,r){for(let n=r.provisional;n<r.length;n++){let i=r[n];if((this.nocase?Mp(e.name):nl(e.name))===i.#b)return this.#j(e,i,n,r)}}#j(e,r,n,i){let s=r.name;return r.#n=r.#n&el|Rv(e),s!==e.name&&(r.name=e.name),n!==i.provisional&&(n===i.length-1?i.pop():i.splice(n,1),i.unshift(r)),i.provisional++,r}async lstat(){if((this.#n&Mn)===0)try{return this.#z(await this.#e.promises.lstat(this.fullpath())),this}catch(e){this.#$(e.code)}}lstatSync(){if((this.#n&Mn)===0)try{return this.#z(this.#e.lstatSync(this.fullpath())),this}catch(e){this.#$(e.code)}}#z(e){let{atime:r,atimeMs:n,birthtime:i,birthtimeMs:s,blksize:o,blocks:a,ctime:c,ctimeMs:l,dev:u,gid:d,ino:f,mode:p,mtime:g,mtimeMs:h,nlink:v,rdev:S,size:_,uid:T}=e;this.#N=r,this.#y=n,this.#P=i,this.#p=s,this.#d=o,this.#s=a,this.#R=c,this.#h=l,this.#t=u,this.#f=d,this.#a=f,this.#i=p,this.#g=g,this.#v=h,this.#r=v,this.#l=S,this.#c=_,this.#o=T;let P=Rv(e);this.#n=this.#n&el|P|_O,P!==fn&&P!==ni&&P!==zs&&(this.#n|=rl)}#H=[];#V=!1;#W(e){this.#V=!1;let r=this.#H.slice();this.#H.length=0,r.forEach(n=>n(null,e))}readdirCB(e,r=!1){if(!this.canReaddir()){r?e(null,[]):queueMicrotask(()=>e(null,[]));return}let n=this.children();if(this.calledReaddir()){let s=n.slice(0,n.provisional);r?e(null,s):queueMicrotask(()=>e(null,s));return}if(this.#H.push(e),this.#V)return;this.#V=!0;let i=this.fullpath();this.#e.readdir(i,{withFileTypes:!0},(s,o)=>{if(s)this.#L(s.code),n.provisional=0;else{for(let a of o)this.#B(a,n);this.#M(n)}this.#W(n.slice(0,n.provisional))})}#U;async readdir(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let r=this.fullpath();if(this.#U)await this.#U;else{let n=()=>{};this.#U=new Promise(i=>n=i);try{for(let i of await this.#e.promises.readdir(r,{withFileTypes:!0}))this.#B(i,e);this.#M(e)}catch(i){this.#L(i.code),e.provisional=0}this.#U=void 0,n()}return e.slice(0,e.provisional)}readdirSync(){if(!this.canReaddir())return[];let e=this.children();if(this.calledReaddir())return e.slice(0,e.provisional);let r=this.fullpath();try{for(let n of this.#e.readdirSync(r,{withFileTypes:!0}))this.#B(n,e);this.#M(e)}catch(n){this.#L(n.code),e.provisional=0}return e.slice(0,e.provisional)}canReaddir(){if(this.#n&SO)return!1;let e=dn&this.#n;return e===fn||e===ni||e===zs}shouldWalk(e,r){return(this.#n&ni)===ni&&!(this.#n&SO)&&!e.has(this)&&(!r||r(this))}async realpath(){if(this.#D)return this.#D;if(!((xp|Op|Mn)&this.#n))try{let e=await this.#e.promises.realpath(this.fullpath());return this.#D=this.resolve(e)}catch{this.#E()}}realpathSync(){if(this.#D)return this.#D;if(!((xp|Op|Mn)&this.#n))try{let e=this.#e.realpathSync(this.fullpath());return this.#D=this.resolve(e)}catch{this.#E()}}[OO](e){if(e===this)return;e.isCWD=!1,this.isCWD=!0;let r=new Set([]),n=[],i=this;for(;i&&i.parent;)r.add(i),i.#C=n.join(this.sep),i.#k=n.join("/"),i=i.parent,n.push("..");for(i=e;i&&i.parent&&!r.has(i);)i.#C=void 0,i.#k=void 0,i=i.parent}},Lp=class t extends fr{sep="\\";splitSep=XH;constructor(e,r=fn,n,i,s,o,a){super(e,r,n,i,s,o,a)}newChild(e,r=fn,n={}){return new t(e,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(e){return ha.win32.parse(e).root}getRoot(e){if(e=KH(e.toUpperCase()),e===this.root.name)return this.root;for(let[r,n]of Object.entries(this.roots))if(this.sameRoot(e,r))return this.roots[e]=n;return this.roots[e]=new ma(e,this).root}sameRoot(e,r=this.root.name){return e=e.toUpperCase().replace(/\//g,"\\").replace(wO,"$1\\"),e===r}},$p=class t extends fr{splitSep="/";sep="/";constructor(e,r=fn,n,i,s,o,a){super(e,r,n,i,s,o,a)}getRootString(e){return e.startsWith("/")?"/":""}getRoot(e){return this.root}newChild(e,r=fn,n={}){return new t(e,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}},Bp=class{root;rootPath;roots;cwd;#e;#t;#i;nocase;#r;constructor(e=process.cwd(),r,n,{nocase:i,childrenCacheSize:s=16*1024,fs:o=tl}={}){this.#r=kO(o),(e instanceof URL||e.startsWith("file://"))&&(e=(0,PO.fileURLToPath)(e));let a=r.resolve(e);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#e=new qp,this.#t=new qp,this.#i=new Pv(s);let c=a.substring(this.rootPath.length).split(n);if(c.length===1&&!c[0]&&c.pop(),i===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=i,this.root=this.newRoot(this.#r),this.roots[this.rootPath]=this.root;let l=this.root,u=c.length-1,d=r.sep,f=this.rootPath,p=!1;for(let g of c){let h=u--;l=l.child(g,{relative:new Array(h).fill("..").join(d),relativePosix:new Array(h).fill("..").join("/"),fullpath:f+=(p?"":d)+g}),p=!0}this.cwd=l}depth(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.depth()}childrenCache(){return this.#i}resolve(...e){let r="";for(let s=e.length-1;s>=0;s--){let o=e[s];if(!(!o||o===".")&&(r=r?`${o}/${r}`:o,this.isAbsolute(o)))break}let n=this.#e.get(r);if(n!==void 0)return n;let i=this.cwd.resolve(r).fullpath();return this.#e.set(r,i),i}resolvePosix(...e){let r="";for(let s=e.length-1;s>=0;s--){let o=e[s];if(!(!o||o===".")&&(r=r?`${o}/${r}`:o,this.isAbsolute(o)))break}let n=this.#t.get(r);if(n!==void 0)return n;let i=this.cwd.resolve(r).fullpathPosix();return this.#t.set(r,i),i}relative(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relative()}relativePosix(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.relativePosix()}basename(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.name}dirname(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),(e.parent||e).fullpath()}async readdir(e=this.cwd,r={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(r=e,e=this.cwd);let{withFileTypes:n}=r;if(e.canReaddir()){let i=await e.readdir();return n?i:i.map(s=>s.name)}else return[]}readdirSync(e=this.cwd,r={withFileTypes:!0}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(r=e,e=this.cwd);let{withFileTypes:n=!0}=r;return e.canReaddir()?n?e.readdirSync():e.readdirSync().map(i=>i.name):[]}async lstat(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstat()}lstatSync(e=this.cwd){return typeof e=="string"&&(e=this.cwd.resolve(e)),e.lstatSync()}async readlink(e=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(r=e.withFileTypes,e=this.cwd);let n=await e.readlink();return r?n:n?.fullpath()}readlinkSync(e=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(r=e.withFileTypes,e=this.cwd);let n=e.readlinkSync();return r?n:n?.fullpath()}async realpath(e=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(r=e.withFileTypes,e=this.cwd);let n=await e.realpath();return r?n:n?.fullpath()}realpathSync(e=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(r=e.withFileTypes,e=this.cwd);let n=e.realpathSync();return r?n:n?.fullpath()}async walk(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=r,a=[];(!s||s(e))&&a.push(n?e:e.fullpath());let c=new Set,l=(d,f)=>{c.add(d),d.readdirCB((p,g)=>{if(p)return f(p);let h=g.length;if(!h)return f();let v=()=>{--h===0&&f()};for(let S of g)(!s||s(S))&&a.push(n?S:S.fullpath()),i&&S.isSymbolicLink()?S.realpath().then(_=>_?.isUnknown()?_.lstat():_).then(_=>_?.shouldWalk(c,o)?l(_,v):v()):S.shouldWalk(c,o)?l(S,v):v()},!0)},u=e;return new Promise((d,f)=>{l(u,p=>{if(p)return f(p);d(a)})})}walkSync(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=r,a=[];(!s||s(e))&&a.push(n?e:e.fullpath());let c=new Set([e]);for(let l of c){let u=l.readdirSync();for(let d of u){(!s||s(d))&&a.push(n?d:d.fullpath());let f=d;if(d.isSymbolicLink()){if(!(i&&(f=d.realpathSync())))continue;f.isUnknown()&&f.lstatSync()}f.shouldWalk(c,o)&&c.add(f)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(e=this.cwd,r={}){return typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(r=e,e=this.cwd),this.stream(e,r)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=r;(!s||s(e))&&(yield n?e:e.fullpath());let a=new Set([e]);for(let c of a){let l=c.readdirSync();for(let u of l){(!s||s(u))&&(yield n?u:u.fullpath());let d=u;if(u.isSymbolicLink()){if(!(i&&(d=u.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(a,o)&&a.add(d)}}}stream(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=r,a=new ls({objectMode:!0});(!s||s(e))&&a.write(n?e:e.fullpath());let c=new Set,l=[e],u=0,d=()=>{let f=!1;for(;!f;){let p=l.shift();if(!p){u===0&&a.end();return}u++,c.add(p);let g=(v,S,_=!1)=>{if(v)return a.emit("error",v);if(i&&!_){let T=[];for(let P of S)P.isSymbolicLink()&&T.push(P.realpath().then(C=>C?.isUnknown()?C.lstat():C));if(T.length){Promise.all(T).then(()=>g(null,S,!0));return}}for(let T of S)T&&(!s||s(T))&&(a.write(n?T:T.fullpath())||(f=!0));u--;for(let T of S){let P=T.realpathCached()||T;P.shouldWalk(c,o)&&l.push(P)}f&&!a.flowing?a.once("drain",d):h||d()},h=!0;p.readdirCB(g,!0),h=!1}};return d(),a}streamSync(e=this.cwd,r={}){typeof e=="string"?e=this.cwd.resolve(e):e instanceof fr||(r=e,e=this.cwd);let{withFileTypes:n=!0,follow:i=!1,filter:s,walkFilter:o}=r,a=new ls({objectMode:!0}),c=new Set;(!s||s(e))&&a.write(n?e:e.fullpath());let l=[e],u=0,d=()=>{let f=!1;for(;!f;){let p=l.shift();if(!p){u===0&&a.end();return}u++,c.add(p);let g=p.readdirSync();for(let h of g)(!s||s(h))&&(a.write(n?h:h.fullpath())||(f=!0));u--;for(let h of g){let v=h;if(h.isSymbolicLink()){if(!(i&&(v=h.realpathSync())))continue;v.isUnknown()&&v.lstatSync()}v.shouldWalk(c,o)&&l.push(v)}}f&&!a.flowing&&a.once("drain",d)};return d(),a}chdir(e=this.cwd){let r=this.cwd;this.cwd=typeof e=="string"?this.cwd.resolve(e):e,this.cwd[OO](r)}},ma=class extends Bp{sep="\\";constructor(e=process.cwd(),r={}){let{nocase:n=!0}=r;super(e,ha.win32,"\\",{...r,nocase:n}),this.nocase=n;for(let i=this.cwd;i;i=i.parent)i.nocase=this.nocase}parseRootPath(e){return ha.win32.parse(e).root.toUpperCase()}newRoot(e){return new Lp(this.rootPath,ni,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")||e.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(e)}},ga=class extends Bp{sep="/";constructor(e=process.cwd(),r={}){let{nocase:n=!1}=r;super(e,ha.posix,"/",{...r,nocase:n}),this.nocase=n}parseRootPath(e){return"/"}newRoot(e){return new $p(this.rootPath,ni,void 0,this.roots,this.nocase,this.childrenCache(),{fs:e})}isAbsolute(e){return e.startsWith("/")}},il=class extends ga{constructor(e=process.cwd(),r={}){let{nocase:n=!0}=r;super(e,{...r,nocase:n})}},zSe=process.platform==="win32"?Lp:$p,MO=process.platform==="win32"?ma:process.platform==="darwin"?il:ga;var QH=t=>t.length>=1,ZH=t=>t.length>=1,ya=class t{#e;#t;#i;length;#r;#o;#f;#l;#d;#a;#c=!0;constructor(e,r,n,i){if(!QH(e))throw new TypeError("empty pattern list");if(!ZH(r))throw new TypeError("empty glob list");if(r.length!==e.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=e.length,n<0||n>=this.length)throw new TypeError("index out of range");if(this.#e=e,this.#t=r,this.#i=n,this.#r=i,this.#i===0){if(this.isUNC()){let[s,o,a,c,...l]=this.#e,[u,d,f,p,...g]=this.#t;l[0]===""&&(l.shift(),g.shift());let h=[s,o,a,c,""].join("/"),v=[u,d,f,p,""].join("/");this.#e=[h,...l],this.#t=[v,...g],this.length=this.#e.length}else if(this.isDrive()||this.isAbsolute()){let[s,...o]=this.#e,[a,...c]=this.#t;o[0]===""&&(o.shift(),c.shift());let l=s+"/",u=a+"/";this.#e=[l,...o],this.#t=[u,...c],this.length=this.#e.length}}}pattern(){return this.#e[this.#i]}isString(){return typeof this.#e[this.#i]=="string"}isGlobstar(){return this.#e[this.#i]===tr}isRegExp(){return this.#e[this.#i]instanceof RegExp}globString(){return this.#f=this.#f||(this.#i===0?this.isAbsolute()?this.#t[0]+this.#t.slice(1).join("/"):this.#t.join("/"):this.#t.slice(this.#i).join("/"))}hasMore(){return this.length>this.#i+1}rest(){return this.#o!==void 0?this.#o:this.hasMore()?(this.#o=new t(this.#e,this.#t,this.#i+1,this.#r),this.#o.#a=this.#a,this.#o.#d=this.#d,this.#o.#l=this.#l,this.#o):this.#o=null}isUNC(){let e=this.#e;return this.#d!==void 0?this.#d:this.#d=this.#r==="win32"&&this.#i===0&&e[0]===""&&e[1]===""&&typeof e[2]=="string"&&!!e[2]&&typeof e[3]=="string"&&!!e[3]}isDrive(){let e=this.#e;return this.#l!==void 0?this.#l:this.#l=this.#r==="win32"&&this.#i===0&&this.length>1&&typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0])}isAbsolute(){let e=this.#e;return this.#a!==void 0?this.#a:this.#a=e[0]===""&&e.length>1||this.isDrive()||this.isUNC()}root(){let e=this.#e[0];return typeof e=="string"&&this.isAbsolute()&&this.#i===0?e:""}checkFollowGlobstar(){return!(this.#i===0||!this.isGlobstar()||!this.#c)}markFollowGlobstar(){return this.#i===0||!this.isGlobstar()||!this.#c?!1:(this.#c=!1,!0)}};var eV=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",va=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(e,{nobrace:r,nocase:n,noext:i,noglobstar:s,platform:o=eV}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=o,this.mmopts={dot:!0,nobrace:r,nocase:n,noext:i,noglobstar:s,optimizationLevel:2,platform:o,nocomment:!0,nonegate:!0};for(let a of e)this.add(a)}add(e){let r=new Wr(e,this.mmopts);for(let n=0;n<r.set.length;n++){let i=r.set[n],s=r.globParts[n];if(!i||!s)throw new Error("invalid pattern object");for(;i[0]==="."&&s[0]===".";)i.shift(),s.shift();let o=new ya(i,s,0,this.platform),a=new Wr(o.globString(),this.mmopts),c=s[s.length-1]==="**",l=o.isAbsolute();l?this.absolute.push(a):this.relative.push(a),c&&(l?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(e){let r=e.fullpath(),n=`${r}/`,i=e.relative()||".",s=`${i}/`;for(let o of this.relative)if(o.match(i)||o.match(s))return!0;for(let o of this.absolute)if(o.match(r)||o.match(n))return!0;return!1}childrenIgnored(e){let r=e.fullpath()+"/",n=(e.relative()||".")+"/";for(let i of this.relativeChildren)if(i.match(n))return!0;for(let i of this.absoluteChildren)if(i.match(r))return!0;return!1}};var kv=class t{store;constructor(e=new Map){this.store=e}copy(){return new t(new Map(this.store))}hasWalked(e,r){return this.store.get(e.fullpath())?.has(r.globString())}storeWalked(e,r){let n=e.fullpath(),i=this.store.get(n);i?i.add(r.globString()):this.store.set(n,new Set([r.globString()]))}},wv=class{store=new Map;add(e,r,n){let i=(r?2:0)|(n?1:0),s=this.store.get(e);this.store.set(e,s===void 0?i:i&s)}entries(){return[...this.store.entries()].map(([e,r])=>[e,!!(r&2),!!(r&1)])}},Ev=class{store=new Map;add(e,r){if(!e.canReaddir())return;let n=this.store.get(e);n?n.find(i=>i.globString()===r.globString())||n.push(r):this.store.set(e,[r])}get(e){let r=this.store.get(e);if(!r)throw new Error("attempting to walk unknown path");return r}entries(){return this.keys().map(e=>[e,this.store.get(e)])}keys(){return[...this.store.keys()].filter(e=>e.canReaddir())}},sl=class t{hasWalkedCache;matches=new wv;subwalks=new Ev;patterns;follow;dot;opts;constructor(e,r){this.opts=e,this.follow=!!e.follow,this.dot=!!e.dot,this.hasWalkedCache=r?r.copy():new kv}processPatterns(e,r){this.patterns=r;let n=r.map(i=>[e,i]);for(let[i,s]of n){this.hasWalkedCache.storeWalked(i,s);let o=s.root(),a=s.isAbsolute()&&this.opts.absolute!==!1;if(o){i=i.resolve(o==="/"&&this.opts.root!==void 0?this.opts.root:o);let d=s.rest();if(d)s=d;else{this.matches.add(i,!0,!1);continue}}if(i.isENOENT())continue;let c,l,u=!1;for(;typeof(c=s.pattern())=="string"&&(l=s.rest());)i=i.resolve(c),s=l,u=!0;if(c=s.pattern(),l=s.rest(),u){if(this.hasWalkedCache.hasWalked(i,s))continue;this.hasWalkedCache.storeWalked(i,s)}if(typeof c=="string"){let d=c===".."||c===""||c===".";this.matches.add(i.resolve(c),a,d);continue}else if(c===tr){(!i.isSymbolicLink()||this.follow||s.checkFollowGlobstar())&&this.subwalks.add(i,s);let d=l?.pattern(),f=l?.rest();if(!l||(d===""||d===".")&&!f)this.matches.add(i,a,d===""||d===".");else if(d===".."){let p=i.parent||i;f?this.hasWalkedCache.hasWalked(p,f)||this.subwalks.add(p,f):this.matches.add(p,a,!0)}}else c instanceof RegExp&&this.subwalks.add(i,s)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new t(this.opts,this.hasWalkedCache)}filterEntries(e,r){let n=this.subwalks.get(e),i=this.child();for(let s of r)for(let o of n){let a=o.isAbsolute(),c=o.pattern(),l=o.rest();c===tr?i.testGlobstar(s,o,l,a):c instanceof RegExp?i.testRegExp(s,c,l,a):i.testString(s,c,l,a)}return i}testGlobstar(e,r,n,i){if((this.dot||!e.name.startsWith("."))&&(r.hasMore()||this.matches.add(e,i,!1),e.canReaddir()&&(this.follow||!e.isSymbolicLink()?this.subwalks.add(e,r):e.isSymbolicLink()&&(n&&r.checkFollowGlobstar()?this.subwalks.add(e,n):r.markFollowGlobstar()&&this.subwalks.add(e,r)))),n){let s=n.pattern();if(typeof s=="string"&&s!==".."&&s!==""&&s!==".")this.testString(e,s,n.rest(),i);else if(s===".."){let o=e.parent||e;this.subwalks.add(o,n)}else s instanceof RegExp&&this.testRegExp(e,s,n.rest(),i)}}testRegExp(e,r,n,i){r.test(e.name)&&(n?this.subwalks.add(e,n):this.matches.add(e,i,!1))}testString(e,r,n,i){e.isNamed(r)&&(n?this.subwalks.add(e,n):this.matches.add(e,i,!1))}};var tV=(t,e)=>typeof t=="string"?new va([t],e):Array.isArray(t)?new va(t,e):t,Fp=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#e=[];#t;#i;signal;maxDepth;includeChildMatches;constructor(e,r,n){if(this.patterns=e,this.path=r,this.opts=n,this.#i=!n.posix&&n.platform==="win32"?"\\":"/",this.includeChildMatches=n.includeChildMatches!==!1,(n.ignore||!this.includeChildMatches)&&(this.#t=tV(n.ignore??[],n),!this.includeChildMatches&&typeof this.#t.add!="function")){let i="cannot ignore child matches, ignore lacks add() method.";throw new Error(i)}this.maxDepth=n.maxDepth||1/0,n.signal&&(this.signal=n.signal,this.signal.addEventListener("abort",()=>{this.#e.length=0}))}#r(e){return this.seen.has(e)||!!this.#t?.ignored?.(e)}#o(e){return!!this.#t?.childrenIgnored?.(e)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let e;for(;!this.paused&&(e=this.#e.shift());)e()}onResume(e){this.signal?.aborted||(this.paused?this.#e.push(e):e())}async matchCheck(e,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||await e.realpath(),!n)return;e=n}let s=e.isUnknown()||this.opts.stat?await e.lstat():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let o=await s.realpath();o&&(o.isUnknown()||this.opts.stat)&&await o.lstat()}return this.matchCheckTest(s,r)}matchCheckTest(e,r){return e&&(this.maxDepth===1/0||e.depth()<=this.maxDepth)&&(!r||e.canReaddir())&&(!this.opts.nodir||!e.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!e.isSymbolicLink()||!e.realpathCached()?.isDirectory())&&!this.#r(e)?e:void 0}matchCheckSync(e,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=e.realpathCached()||e.realpathSync(),!n)return;e=n}let s=e.isUnknown()||this.opts.stat?e.lstatSync():e;if(this.opts.follow&&this.opts.nodir&&s?.isSymbolicLink()){let o=s.realpathSync();o&&(o?.isUnknown()||this.opts.stat)&&o.lstatSync()}return this.matchCheckTest(s,r)}matchFinish(e,r){if(this.#r(e))return;if(!this.includeChildMatches&&this.#t?.add){let s=`${e.relativePosix()}/**`;this.#t.add(s)}let n=this.opts.absolute===void 0?r:this.opts.absolute;this.seen.add(e);let i=this.opts.mark&&e.isDirectory()?this.#i:"";if(this.opts.withFileTypes)this.matchEmit(e);else if(n){let s=this.opts.posix?e.fullpathPosix():e.fullpath();this.matchEmit(s+i)}else{let s=this.opts.posix?e.relativePosix():e.relative(),o=this.opts.dotRelative&&!s.startsWith(".."+this.#i)?"."+this.#i:"";this.matchEmit(s?o+s+i:"."+i)}}async match(e,r,n){let i=await this.matchCheck(e,n);i&&this.matchFinish(i,r)}matchSync(e,r,n){let i=this.matchCheckSync(e,n);i&&this.matchFinish(i,r)}walkCB(e,r,n){this.signal?.aborted&&n(),this.walkCB2(e,r,new sl(this.opts),n)}walkCB2(e,r,n,i){if(this.#o(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2(e,r,n,i));return}n.processPatterns(e,r);let s=1,o=()=>{--s===0&&i()};for(let[a,c,l]of n.matches.entries())this.#r(a)||(s++,this.match(a,c,l).then(()=>o()));for(let a of n.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;s++;let c=a.readdirCached();a.calledReaddir()?this.walkCB3(a,c,n,o):a.readdirCB((l,u)=>this.walkCB3(a,u,n,o),!0)}o()}walkCB3(e,r,n,i){n=n.filterEntries(e,r);let s=1,o=()=>{--s===0&&i()};for(let[a,c,l]of n.matches.entries())this.#r(a)||(s++,this.match(a,c,l).then(()=>o()));for(let[a,c]of n.subwalks.entries())s++,this.walkCB2(a,c,n.child(),o);o()}walkCBSync(e,r,n){this.signal?.aborted&&n(),this.walkCB2Sync(e,r,new sl(this.opts),n)}walkCB2Sync(e,r,n,i){if(this.#o(e))return i();if(this.signal?.aborted&&i(),this.paused){this.onResume(()=>this.walkCB2Sync(e,r,n,i));return}n.processPatterns(e,r);let s=1,o=()=>{--s===0&&i()};for(let[a,c,l]of n.matches.entries())this.#r(a)||this.matchSync(a,c,l);for(let a of n.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;s++;let c=a.readdirSync();this.walkCB3Sync(a,c,n,o)}o()}walkCB3Sync(e,r,n,i){n=n.filterEntries(e,r);let s=1,o=()=>{--s===0&&i()};for(let[a,c,l]of n.matches.entries())this.#r(a)||this.matchSync(a,c,l);for(let[a,c]of n.subwalks.entries())s++,this.walkCB2Sync(a,c,n.child(),o);o()}},ol=class extends Fp{matches=new Set;constructor(e,r,n){super(e,r,n)}matchEmit(e){this.matches.add(e)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((e,r)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?r(this.signal.reason):e(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},al=class extends Fp{results;constructor(e,r,n){super(e,r,n),this.results=new ls({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(e){this.results.write(e),this.results.flowing||this.pause()}stream(){let e=this.path;return e.isUnknown()?e.lstat().then(()=>{this.walkCB(e,this.patterns,()=>this.results.end())}):this.walkCB(e,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var rV=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",xn=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(e,r){if(!r)throw new TypeError("glob options required");if(this.withFileTypes=!!r.withFileTypes,this.signal=r.signal,this.follow=!!r.follow,this.dot=!!r.dot,this.dotRelative=!!r.dotRelative,this.nodir=!!r.nodir,this.mark=!!r.mark,r.cwd?(r.cwd instanceof URL||r.cwd.startsWith("file://"))&&(r.cwd=(0,xO.fileURLToPath)(r.cwd)):this.cwd="",this.cwd=r.cwd||"",this.root=r.root,this.magicalBraces=!!r.magicalBraces,this.nobrace=!!r.nobrace,this.noext=!!r.noext,this.realpath=!!r.realpath,this.absolute=r.absolute,this.includeChildMatches=r.includeChildMatches!==!1,this.noglobstar=!!r.noglobstar,this.matchBase=!!r.matchBase,this.maxDepth=typeof r.maxDepth=="number"?r.maxDepth:1/0,this.stat=!!r.stat,this.ignore=r.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof e=="string"&&(e=[e]),this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(e=e.map(c=>c.replace(/\\/g,"/"))),this.matchBase){if(r.noglobstar)throw new TypeError("base matching requires globstar");e=e.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=e,this.platform=r.platform||rV,this.opts={...r,platform:this.platform},r.scurry){if(this.scurry=r.scurry,r.nocase!==void 0&&r.nocase!==r.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let c=r.platform==="win32"?ma:r.platform==="darwin"?il:r.platform?ga:MO;this.scurry=new c(this.cwd,{nocase:r.nocase,fs:r.fs})}this.nocase=this.scurry.nocase;let n=this.platform==="darwin"||this.platform==="win32",i={...r,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:n,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},s=this.pattern.map(c=>new Wr(c,i)),[o,a]=s.reduce((c,l)=>(c[0].push(...l.set),c[1].push(...l.globParts),c),[[],[]]);this.patterns=o.map((c,l)=>{let u=a[l];if(!u)throw new Error("invalid pattern object");return new ya(c,u,0,this.platform)})}async walk(){return[...await new ol(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new ol(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new al(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new al(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var Cv=(t,e={})=>{Array.isArray(t)||(t=[t]);for(let r of t)if(new Wr(r,e).hasMagic())return!0;return!1};function jp(t,e={}){return new xn(t,e).streamSync()}function LO(t,e={}){return new xn(t,e).stream()}function $O(t,e={}){return new xn(t,e).walkSync()}async function qO(t,e={}){return new xn(t,e).walk()}function Up(t,e={}){return new xn(t,e).iterateSync()}function BO(t,e={}){return new xn(t,e).iterate()}var nV=jp,iV=Object.assign(LO,{sync:jp}),sV=Up,oV=Object.assign(BO,{sync:Up}),aV=Object.assign($O,{stream:jp,iterate:Up}),Ws=Object.assign(qO,{glob:qO,globSync:$O,sync:aV,globStream:LO,stream:iV,globStreamSync:jp,streamSync:nV,globIterate:BO,iterate:oV,globIterateSync:Up,iterateSync:sV,Glob:xn,hasMagic:Cv,escape:la,unescape:In});Ws.glob=Ws;var fS=L(ub()),D$=L(w$());var lS={};TB(lS,{$id:()=>eJ,$schema:()=>Z9,default:()=>sJ,definitions:()=>rJ,properties:()=>iJ,title:()=>tJ,type:()=>nJ});var Z9="http://json-schema.org/draft-07/schema#",eJ="http://json-schema.org/draft-07/schema#",tJ="Core schema meta-schema",rJ={schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},nJ=["object","boolean"],iJ={$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},sJ={$schema:Z9,$id:eJ,title:tJ,definitions:rJ,type:nJ,properties:iJ,default:!0};var Yr=L(j());var bm=class extends Cc{constructor(r,n){super();this.ajv=r;this.schemaKey=n;this.validate=this.ajv.getSchema(this.schemaKey)}getIssue(r,n){let i=[];if(n.disabled){let o=n.getProperty("status");return[...n.definitions,...n.referencedBy].forEach(a=>i.push(B(21,a.rangeTokens,a,{severity:Yr.DiagnosticSeverity.Hint,linkedTo:[...o?.ast?[o?.ast]:[]],tags:[Yr.DiagnosticTag.Unnecessary]}))),i}let s=J.toJson(n);try{this.validate?(this.validate(s),this.validate.errors&&(this.validate.errors.forEach(o=>i.push(...oJ(r,o,n,this.schemaKey))),console.log(this.schemaKey,`${n.pathString}`,this.validate.errors,s))):console.log("no validate")}catch(o){console.log(this.schemaKey,`${n.pathString}`,this.schemaKey,o)}return i}getOnPropertyHover(r){let n=(this.validate?.schema).properties?.[r];if(n&&typeof n=="object"&&"description"in n)return{kind:Yr.MarkupKind.Markdown,value:[...n.description?["### Description",Array.isArray(n.description)?n.description.join(`
296
297
 
@@ -303,4 +304,4 @@ ${n}`]})]:[]}else if(e.keyword==="maxItems"||e.keyword==="minItems"){let a=s.get
303
304
  ${JSON.stringify(e)}
304
305
  ${n}`]})];let o=i.node.definitions[0]instanceof St?i.node.definitions[0]:i.node.definitions[0].name??i.node.definitions[0];return[B(25,o.rangeTokens,o,{templateStrings:[`${e.message??"NO MESSAGE"}:
305
306
  ${JSON.stringify(e)}
306
- ${n}`]})]},aJ=(t,e)=>E$(t,e.split("/").filter(r=>r)),E$=(t,e)=>{if(e.length===0)return{node:t,remainingInstancePath:""};let r=e[0].split("@"),n=r[0],i=r.at(1)?.split(",").map(o=>Number.parseInt(o,16)),s=t.getNode(n,i);return s?E$(s,e.slice(1)):{node:t,property:t.getProperty(e[0]),remainingInstancePath:e.slice(1).join("/")}};var pS=class t{constructor(){this.schemaIdValidators=new Map;this.ajvMap=new Map}static getNodeCompatible(e){let n=e.getProperty("compatible")?.ast.values;if(!n?.values.some(i=>!(i?.value instanceof ie)))return n?.values.map(i=>(i?.value).value)}parseMetaSchema(e,r){Ws.sync("**/*.yaml",{cwd:e}).forEach(i=>{i=(0,uS.resolve)(e,i);try{let s=fS.default.parse((0,dS.readFileSync)(i,"utf-8"));r.addMetaSchema(s),this.schemaIdValidators.set(s.$id,i)}catch{}})}parseBindings(e,r){Ws.sync("**/*.yaml",{cwd:e}).forEach(i=>{i=(0,uS.resolve)(e,i);try{let s=fS.default.parse((0,dS.readFileSync)(i,"utf-8"));r.addSchema(s),this.schemaIdValidators.set(s.$id,i)}catch(s){console.warn(i,s.message)}})}getNodeTypes(e,r,n){let i=`${e.join(";")}::${r.join(";")}`,s=this.ajvMap.get(i);return s||(s=new D$.default({strict:!1,strictSchema:!1,strictNumbers:!1}),s.addMetaSchema(lS),this.ajvMap.set(i,s),e.forEach(c=>this.parseMetaSchema(c,s)),r.forEach(c=>this.parseBindings(c,s))),t.getNodeCompatible(n)?.map(c=>{try{let l=Array.from(this.schemaIdValidators.keys()).find(f=>f.endsWith(`/${c}.yaml#`));if(!l)return;let u=new bm(s,l);u.bindingsPath=this.schemaIdValidators.get(l),u.compatible=c;let d=s.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)??[]}getBindings(){return Array.from(this.schemaIdValidators.keys())}},C$,hS=()=>(C$??=new pS,C$);var mu=require("path"),L$=require("fs"),$$=L(require("path")),B$=L(ub());var Tn=L(j());var A$=()=>{let t=new X("nonposted-mmio",z("EMPTY"),"optional");return t.description=["Specifies that direct children of this bus should use non-posted memory accesses (i.e. a non-posted mapping mode) for MMIO ranges."],t};function I$(){let t=lr();t.noMismatchPropertiesAllowed=!0;let e=t.properties.find(n=>n.name==="compatible");e.required=()=>"required";let r=t.properties.find(n=>n.name==="ranges");return r.required=()=>"required",t.addProperty(A$()),t}var O$=t=>{switch(t){case"string":return z("STRING");case"int":return z("U32");case"boolean":return z("EMPTY");case"array":return z("PROP_ENCODED_ARRAY");case"uint8-array":return z("BYTESTRING");case"string-array":return z("STRINGLIST");case"phandle":return z("U32");case"phandles":return z("PROP_ENCODED_ARRAY");case"phandle-array":return z("PROP_ENCODED_ARRAY");case"path":return z(["STRING","U32"]);case"compound":return z("ANY");default:return z("ANY")}},M$=(t,e)=>{switch(t){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(r=>typeof r=="number")?e:void 0;case"uint8-array":return Array.isArray(e)&&e.every(r=>typeof r=="number")?e:void 0;case"string-array":return Array.isArray(e)&&e.every(r=>typeof r=="string")?e:void 0;case"phandle":return;case"phandles":return;case"phandle-array":return;case"path":return;case"compound":return}},_m=(t,e)=>{if(e.extends??=[],e=e.include.reduce((r,n)=>{let i=t.find(s=>(0,mu.basename)(s.filePath)===n.name);if(i){let s=n["property-blocklist"],o=n["property-allowlist"];return e.extends?.push(...r.include.map(a=>(0,mu.basename)(a.name,".yaml"))),r.include=r.include.filter(a=>a!==n),cJ(t,i,r,s,o)??r}return console.warn(`Unable to find ${n.name}`),r},e),e["child-binding"]&&(e["child-binding"].include=F$(e["child-binding"].include),e["child-binding"]=_m(t,e["child-binding"])),!e.include.length)return e},cJ=(t,e,r,n=[],i)=>{let s=_m(t,e),o=_m(t,r);if(!s||!o)return;let a=new Set;Object.keys(s?.properties??{}).forEach(f=>a.add(f)),Object.keys(o?.properties??{}).forEach(f=>a.add(f));let c={};Array.from(a).forEach(f=>{let p=n?.some(h=>h===f)||i&&!i.some(h=>h===f)?void 0:s.properties?.[f]??void 0,g=o.properties?.[f]??void 0;(p||g)&&(c={...c,[f]:{...p??g}})}),o.properties=c,o.extends??=[],o.extends.push(...s.extends??[]);let l=new Set;return Object.keys(s).filter(f=>f.endsWith("-cells")).forEach(f=>l.add(f)),Object.keys(s).filter(f=>f.endsWith("-cells")).forEach(f=>l.add(f)),Array.from(l).forEach(f=>{let p=s[f]??[],g=o[f]??[];o[f]=Array.from([...p,...g])}),o["on-bus"]??=s["on-bus"],o.bus?o.bus.push(...s.bus??[]):o.bus=s.bus,o},F$=t=>t?typeof t=="string"?[{name:t}]:t.map(e=>typeof e!="string"?e:{name:e}):[],mS=class t{constructor(){this.typeCache=new Map;this.processedFolders=new Set;this.zephyrBindingCache=new Map}static getCompatibleKeys(e,r){return!r||!r.nodeType?.bus?.length?[e]:[...r.nodeType.bus.map(n=>`${e}::${n}`),e]}static getNodeCompatible(e){let i=e.getProperty("compatible")?.ast.values?.values.filter(s=>s&&s.value instanceof ie);if(i?.length)return i.map(s=>s?.value?{name:s.value.value,ast:s.value}:void 0)}getNodeTypes(e,r){let n=t.getNodeCompatible(e)?.filter(a=>a);if(!n?.length){if(e.name==="zephyr,user"){let a=r.split(":"),l=Array.from(this.zephyrBindingCache.keys()).filter(d=>a.some(f=>d.startsWith(f))).flatMap(d=>this.zephyrBindingCache.get(d)).find(d=>d.filePath.endsWith("/base.yaml")),u=l?gS(l,e):void 0;if(u){u.warnMismatchProperties=!1;let d=u.properties.find(f=>f.name==="compatible");d&&(d.required=()=>"optional")}return{type:[u??rs(e)],issues:[]}}return{type:[rs(e)],issues:[]}}let i=n.flatMap(a=>t.getCompatibleKeys(a.name,e.parent).map(c=>this.typeCache.get(r)?.get(c)?.(e)).filter(c=>!!c)),s=this.getBusTypes(),o=n.flatMap(a=>{let c=t.getCompatibleKeys(a.name,e.parent).some(l=>this.typeCache.get(r)?.has(l));if(!c){let l=s.filter(u=>this.typeCache.get(r)?.has(`${a.name}::${u}`));if(l.length)return B(37,a.ast.rangeTokens,a.ast,{templateStrings:l})}return c?[]:[B(32,a.ast.rangeTokens,a.ast,{severity:Tn.DiagnosticSeverity.Hint,tags:[Tn.DiagnosticTag.Unnecessary],templateStrings:[a.name]})]});return{type:i.length?i:[rs(e)],issues:o}}loadTypeAndCache(e,r){e=Array.isArray(e)?e:[e];let n=e.filter(o=>this.processedFolders.has(o)).flatMap(o=>Array.from(this.zephyrBindingCache.entries()).flatMap(([a,c])=>a.startsWith(o)?[c]:[]));n.push(...e.filter(o=>!this.processedFolders.has(o)).flatMap(o=>(this.processedFolders.add(o),Ws.sync("**/*.yaml",{cwd:o,ignore:"test/*"}).map(c=>{if(c=(0,mu.resolve)(o,c),this.zephyrBindingCache.has(c))return this.zephyrBindingCache.get(c);try{let l=B$.default.parse((0,L$.readFileSync)(c,"utf-8")),u=F$(l?.include),d={...l,bus:l.bus?Array.isArray(l.bus)?l.bus:[l.bus]:void 0,include:u,rawInclude:[...u],filePath:c};return this.zephyrBindingCache.set(c,d),d}catch(l){console.warn(l)}}).filter(c=>!!c))));let i=n.map(o=>_m(n,o)).filter(o=>!!o&&!o.include.length),s=this.typeCache.get(r);s||(s=new Map,s.set("simple-bus",()=>I$()),this.typeCache.set(r,s)),lJ(i,s)}getBindings(e){return Array.from(this.typeCache.get(e)?.keys()??[]).map(r=>r.split("::",1)[0])}getBusTypes(){let e=Array.from(this.zephyrBindingCache.values()).flatMap(r=>r.bus?.filter(n=>!!n)??[]).filter(r=>!!r);return Array.from(new Set(e))}getDocumentLinks(e,r){let n=this.zephyrBindingCache.get(Ae(e.uri));if(!n)return[];let i=e.getText();return n.rawInclude.map(o=>{let c=new RegExp(o.name).exec(i);if(c){let l=e.positionAt(c.index),u=e.positionAt(c.index+c[0].length),d=Array.from(this.zephyrBindingCache.keys()).find(f=>f.endsWith(`${$$.default.sep}${o.name}`)&&r.some(p=>f.startsWith(p)));return d?{range:Tn.Range.create(l,u),target:ve(d)}:void 0}}).filter(o=>!!o)}},x$,Ha=()=>(x$??=new mS,x$),lJ=(t,e)=>t.forEach(r=>{r.compatible&&e.set(r["on-bus"]?`${r.compatible}::${r["on-bus"]}`:r.compatible,n=>gS(r,n))}),gS=(t,e)=>{let r=rs(e);r.compatible=t.compatible,r.description=t.description,r.bindingsPath=t.filePath,r.bus=typeof t.bus=="string"?[t.bus]:Array.from(new Set(t.bus)),r.onBus=t["on-bus"],t.extends?.forEach(s=>r.extends.add(s)),r.warnMismatchProperties=!0;let i=Object.keys(t).filter(s=>s.endsWith("-cells")).map(s=>({specifier:s.replace(/-cells$/,""),values:t[s]}));if(t.properties&&Object.keys(t.properties).forEach(s=>{let o=t.properties[s];uJ(r,s,o),r.cellsValues=i}),t["child-binding"]){let s=t["child-binding"];r.childNodeType=o=>gS(s,o)}return r},uJ=(t,e,r)=>{let n=t.properties.find(i=>i.getNameMatch(e));if(n&&typeof n.name=="string"){n.required=()=>r.required?"required":"optional",n.values=()=>r.enum??[],n.constValue=M$(r.type,r.const),n.bindingType=r.type;let i=n.additionalTypeCheck;n.additionalTypeCheck=(s,o)=>[...q$(r,e,n)(s,o),...i?.(s,o)??[]]}else{let i=r.type==="compound"?n?.type:O$(r.type);i??=O$(r.type);let s=new X(e,i,r.required?"required":"optional",void 0,r.enum);s.additionalTypeCheck=(o,a)=>{let c=[...n?.additionalTypeCheck?.(o,a)??[],...q$(r,e,s)(o,a)];return s.signatureArgs??=n?.signatureArgs,s.signatureArgsCyclic??=!!n?.signatureArgsCyclic,c},s.description=r.description?[r.description]:n?.description,s.bindingType=r.type,s.constValue=M$(r.type,r.const),t.addProperty(s)}},q$=(t,e,r)=>{let n=t;return(i,s)=>{let o=i.parent.root,a=[];if(n.const){let l=i.ast.quickValues;if(l?.length==1){let u=Array.isArray(n.const)?n.const:[n.const];if(!(Array.isArray(l[0])&&u.length===l[0].length&&l[0].every((f,p)=>typeof f=="number"&&Number.isNaN(f)||u[p]===f))){let f=i.ast.values??i.ast;a.push(B(24,f.rangeTokens,f,{templateStrings:[`Binding expects values to be "${n.type}" with value: ${n.const}`]}))}}}if(n.deprecated&&a.push(B(14,i.ast.rangeTokens,i.ast,{severity:Tn.DiagnosticSeverity.Warning,tags:[Tn.DiagnosticTag.Deprecated],templateStrings:[i.name]})),(n.type==="phandle"||n.type==="phandles"||n.type==="path")&&Oe(i.ast.values)?.forEach(u=>{cn(u,o)||a.push(B(22,u.rangeTokens,u))}),n.type==="path"&&i.ast.values?.values.at(0)?.value instanceof ie){let l=i.ast.values?.values.at(0)?.value,u=[];l.value.split("/").every(d=>{let f=o.getNode(d);return f?u.push(d):a.push(B(23,l.rangeTokens,l,{templateStrings:[d,`/${u.join("/")}`]})),!f})}let c=i.name.match(/^(.*)-(\d+)$/);if(n.type==="phandles"&&c){let l="";e.endsWith("-gpios")?l="gpio":l=n["specifier-space"]??c[1];let u=Number.parseInt(c[2],10),d=i.parent.getProperty(`${l}-names`);d&&(d.ast.quickValues?.at(u)||a.push(B(33,i.ast.rangeTokens,i.ast,{severity:Tn.DiagnosticSeverity.Warning,linkedTo:[d.ast],templateStrings:[i.name,u.toString()]})))}if(n.type==="phandle-array"){let l=Oe(i.ast.values),u=0,d=[],f=0;for(;l&&u<l.length;){let p=l.at(u),g=cn(p,o);if(!g){let F=p??i.ast;a.push(B(22,F.rangeTokens,F));break}let h="";e.endsWith("-gpios")?h="gpio":h=n["specifier-space"]??e.slice(0,-1);let v=g.getProperty(`#${h}-cells`);if(!v){a.push(B(16,i.ast.rangeTokens,i.ast,{linkedTo:[...g.nodeNameOrLabelRef],templateStrings:[i.name,`#${h}-cells`,`/${g.path.slice(1).join("/")}`]}));break}let S=v?qe(v,0,0,s)??0:0,_=g.nodeType?.cellsValues?.find(F=>F.specifier===h)?.values;if(d.push([`${f}_phandle`,..._?.map(F=>`${f}_${F}`)??[],...Array.from({length:S-(_?.length??0)},(F,H)=>`${f}_cell${S-(_?.length??0)?H:""}`)]),1+S>l.length-u){let F=p??i.ast;a.push(B(19,F.rangeTokens,F,{templateStrings:[i.name,`<${d.at(-1).join(" ")}>`]}));break}u+=1+S;let T=l.slice(u-S,u),P={mappingValuesAst:T,specifierSpace:h,target:g};i.nexusMapsTo.push(P);let C=g.getProperty(`${h}-map`);if(C){let F=g.getNexusMapEntryMatch(h,s,T);F?.match?P.mapItem=F.match:a.push(B(31,F.entry.rangeTokens,F.entry,{linkedTo:[C.ast]}))}T.every(F=>F instanceof we)&&g.spesifierNexusMapping.push({expressions:T,node:i.parent,property:i});let $=i.parent.getProperty(`${h}-names`);p&&$&&($.ast.quickValues?.at(f)||a.push(B(33,W(p.firstToken,l.at(u-1)?.lastToken),i.ast,{severity:Tn.DiagnosticSeverity.Warning,linkedTo:[$.ast],templateStrings:[i.name,f.toString()]}))),f++}d.push([`${f}_phandle`,`${f}_cell...`]),r.signatureArgs=d.map(p=>p.map(g=>Tn.ParameterInformation.create(g)))}return a}};var j$=(t,e)=>{let r=t.zephyrBindings.join(":");return e==="Zephyr"&&Ha().loadTypeAndCache(t.zephyrBindings,r),{files:t,type:e,getNodeTypes:n=>{switch(e){case"Zephyr":return Ha().getNodeTypes(n,r);case"DevicetreeOrg":return{type:hS().getNodeTypes(t.deviceOrgBindingsMetaSchema,t.deviceOrgTreeBindings,n),issues:[]}}},getBindings:()=>{switch(e){case"Zephyr":return Ha().getBindings(r);case"DevicetreeOrg":return hS().getBindings()}},getBusTypes:()=>{switch(e){case"Zephyr":return Ha().getBusTypes();case"DevicetreeOrg":return[]}},getDocumentLinks(n){if(!n)return[];switch(e){case"Zephyr":return Ha().getDocumentLinks(n,t.zephyrBindings);case"DevicetreeOrg":return[]}}}};var Sm=L(j());var dJ=t=>!t.lastToken.prevToken||!t.lastToken.prevToken.prevToken?[]:[{startLine:t.firstToken.pos.line,startCharacter:t.firstToken.pos.col,endLine:t.lastToken.prevToken.prevToken.pos.line,endCharacter:t.lastToken.prevToken.prevToken.pos.col,kind:Sm.FoldingRangeKind.Comment}],yS=t=>!t.openScope||!t.closeScope?.prevToken?t.nodes.flatMap(yS):[{startLine:t.openScope.pos.line,startCharacter:t.openScope.pos.col,endLine:t.closeScope.prevToken.pos.line,endCharacter:t.closeScope.prevToken.pos.col,kind:Sm.FoldingRangeKind.Region},...t.nodes.flatMap(yS)],U$=t=>{let e=[];return[...t instanceof es?t.ifBlocks.map(r=>({start:(r.expression??r.keyword).lastToken,end:r.content?.lastToken??(r.expression??r.keyword).lastToken})):[{start:(t.ifDef.identifier??t.ifDef.keyword).lastToken,end:t.ifDef.content?.lastToken}],t.elseOption?{start:t.elseOption.keyword.lastToken,end:t.elseOption.content?.lastToken}:null].forEach(r=>{!r||!r.end||e.push({startLine:r.start.pos.line,startCharacter:r.start.pos.col,endLine:r.end.pos.line,endCharacter:r.end.pos.colEnd,kind:Sm.FoldingRangeKind.Region})}),e},fJ=t=>t instanceof ct?yS(t):t instanceof Zi||t instanceof es?U$(t):t instanceof on?dJ(t):[];function H$(t,e){return e.allAstItems.flatMap(r=>[r,...r.allDescendants]).filter(r=>de(r.uri,t)).flatMap(fJ)}var po=L(j());function pJ(t){if(!t||!(t.ast instanceof He)&&!(t.ast instanceof er))return[];let e=r=>r.nodeType?.bindingsPath?[po.Location.create(ve(r.nodeType.bindingsPath),po.Range.create(po.Position.create(0,0),po.Position.create(0,0)))]:[];return t.item instanceof J&&!Ut(t.ast)?e(t.item):t.ast instanceof er&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo?e(t.ast.parentNode.linksTo):t.ast instanceof He&&t.ast.linksTo?e(t.ast.linksTo):[]}async function V$(t,e){return _t(t,e,r=>[...pJ(r)])}var Rm=require("fs");var hJ=(t,e)=>{Ar().reset(t),Ar().requestTokens(t,!0),e(t)},Nm=class{constructor(e,r,n){this.file=e;this.cb=r;this.hasDocumentOpen=n}#e=0;watch(){if(this.count++,this.count===1){console.log("create watch for",this.file);let e=this.file,r=this.cb;this.onChange=()=>{if(this.hasDocumentOpen(e)){console.log("skipping on change document is open",e);return}console.log("onChange",e),hJ(e,r)},(0,Rm.watchFile)(e,this.onChange)}}unwatch(){this.count===1&&(console.log("dispose watch for",this.file),(0,Rm.unwatchFile)(this.file,this.onChange),this.onChange=void 0),this.count--}get count(){return this.#e}set count(e){this.#e=e,e<0&&(this.#e=0,console.warn("unwatching an un watched file",this.file))}};var Xt=L(require("path")),vS=require("fs");var Un=t=>{if(t)return Array.isArray(t)?t:[t]},mJ=t=>({...t,deviceOrgBindingsMetaSchema:Un(t.deviceOrgBindingsMetaSchema),deviceOrgTreeBindings:Un(t.deviceOrgTreeBindings),includePaths:Un(t.includePaths),lockRenameEdits:Un(t.lockRenameEdits),zephyrBindings:Un(t.zephyrBindings),overlays:Un(t.overlays)}),z$=t=>({...t,defaultDeviceOrgBindingsMetaSchema:Un(t.defaultDeviceOrgBindingsMetaSchema),defaultDeviceOrgTreeBindings:Un(t.defaultDeviceOrgTreeBindings),defaultIncludePaths:Un(t.defaultIncludePaths),defaultLockRenameEdits:Un(t.defaultLockRenameEdits),defaultZephyrBindings:Un(t.defaultZephyrBindings),contexts:t.contexts?.map(mJ)}),bn=async(t,e)=>(e&&(t=t.replaceAll("${workspaceFolder}",e)),t),ho={defaultBindingType:"Zephyr",defaultZephyrBindings:[],defaultIncludePaths:[],defaultDeviceOrgBindingsMetaSchema:[],defaultDeviceOrgTreeBindings:[],contexts:[],defaultLockRenameEdits:[],allowAdhocContexts:!0,autoChangeContext:!0},TS=async(t,e,r)=>{let n=(t.cwd?await bn(t.cwd,r):void 0)??e.cwd,i=await Promise.all((t.includePaths??e.defaultIncludePaths).map(p=>bn(p,r))),s=await Promise.all((t.zephyrBindings??e.defaultZephyrBindings).map(p=>bn(p,r))),o=t.bindingType??e.defaultBindingType,a=await Promise.all((t.deviceOrgTreeBindings??e.defaultDeviceOrgTreeBindings).map(p=>bn(p,r))),c=await Promise.all((t.deviceOrgBindingsMetaSchema??e.defaultDeviceOrgBindingsMetaSchema).map(p=>bn(p,r))),l=await Promise.all((t.lockRenameEdits??e.defaultLockRenameEdits).map(p=>bn(p,r)));n&&o==="Zephyr"&&(!s||s.length===0)&&(s=["./zephyr/dts/bindings"]);let u=t.dtsFile,d=t.overlays??[],f=t.compileCommands;return n&&(s=s.map(p=>(0,Xt.resolve)(n,p)).filter(p=>(0,vS.existsSync)(p)),a=a?.map(p=>(0,Xt.resolve)(n,p)),c=c.map(p=>(0,Xt.resolve)(n,p)),i=i.map(p=>(0,Xt.resolve)(n,p)),u=(0,Xt.resolve)(n,u),d=d.map(p=>(0,Xt.resolve)(n,p)),l=l.map(p=>(0,Xt.resolve)(n,p)),f=f?(0,Xt.resolve)(n,f):void 0),{ctxName:t.ctxName??(0,Xt.basename)(u),cwd:n?tt(n):void 0,includePaths:i.map(tt),zephyrBindings:s.map(tt),bindingType:o,deviceOrgTreeBindings:a.map(tt),deviceOrgBindingsMetaSchema:c.map(tt),dtsFile:tt(u),overlays:d.map(tt),lockRenameEdits:l.map(tt),compileCommands:f?tt(f):void 0}},gu=async(t,e)=>{let r=t.cwd?await bn(t.cwd,e):void 0,n=t.defaultBindingType,i=t.defaultDeviceOrgBindingsMetaSchema=await Promise.all((t.defaultDeviceOrgBindingsMetaSchema??[]).map(d=>bn(d,e))),s=t.defaultDeviceOrgTreeBindings=await Promise.all((t.defaultDeviceOrgTreeBindings??[]).map(d=>bn(d,e))),o=t.defaultIncludePaths=await Promise.all((t.defaultIncludePaths??[]).map(d=>bn(d,e))),a=t.defaultZephyrBindings=await Promise.all((t.defaultZephyrBindings??[]).map(d=>bn(d,e))),c=t.defaultLockRenameEdits=await Promise.all((t.defaultLockRenameEdits??[]).map(d=>bn(d,e)));r&&(o=t.defaultIncludePaths=(t.defaultIncludePaths??[]).map(d=>(0,Xt.resolve)(r,d)),n==="Zephyr"&&!t.defaultZephyrBindings&&(a=["./zephyr/dts/bindings"]),a=a.map(d=>(0,Xt.resolve)(r,d)),i=i.map(d=>(0,Xt.resolve)(r,d)),s=(t.defaultDeviceOrgTreeBindings??[]).map(d=>(0,Xt.resolve)(r,d)),c=c.map(d=>(0,Xt.resolve)(r,d)));let l={cwd:r,defaultDeviceOrgBindingsMetaSchema:i,defaultDeviceOrgTreeBindings:s,defaultIncludePaths:o,defaultZephyrBindings:a,defaultLockRenameEdits:c,defaultBindingType:n,autoChangeContext:t.autoChangeContext??ho.autoChangeContext,allowAdhocContexts:t.allowAdhocContexts??ho.allowAdhocContexts},u=(await Promise.all(t.contexts?.map(d=>TS(d,l,e))??[])).filter(d=>[d.dtsFile,...d.overlays].every(f=>(0,vS.existsSync)(f)&&Xt.default.isAbsolute(f)));return{...l,contexts:u}};var W$=t=>`DT_PROP(${bS(t.parent)}, ${t.name.replaceAll("-","_")}))`,G$=t=>t.parent.labels.map(e=>`DT_PROP(DT_NODELABEL(${e.label.toString()}), ${t.name.replaceAll("-","_")})`);var bS=t=>`DT_PATH(${t.path.slice(1).map(e=>e.replace("@","_").replaceAll("-","_")).join(",")})`,Y$=t=>t.labels.map(e=>`DT_NODELABEL(${e.label.toString()})`),K$=t=>{let e=[];return Qn.getNodeFromPath(["aliases"],t.root)?.properties.filter(i=>{if(i.ast.quickValues?.at(0)===t.pathString)return!0;let s=i.ast.values?.values.at(0)?.value;if(s instanceof se&&s.linksTo===t||s instanceof nt&&s.path?.pathParts.at(-1)?.linksTo===t)return!0})?.forEach(i=>e.push(`DT_ALIAS(${i.name.replaceAll("-","_")})`)),e};function gJ(t,e){if(!t||!(t.item instanceof Ke)||!(t.ast instanceof Qe))return[];let r=[];return e.settings.bindingType==="Zephyr"&&(r.push({type:"dt_zephyr_macro_prop_node_path",data:W$(t.item)}),G$(t.item).forEach(n=>{r.push({type:"dt_zephyr_macro_prop_node_label",data:n})})),r}function yJ(t,e){if(!t||t.item===null)return[];let r;if(t.item instanceof J?r=t.item:t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo?r=t.ast.parentNode.linksTo:t.ast instanceof He&&t.ast.linksTo&&(r=t.ast.linksTo),!r)return[];let n=[{type:"path",data:r.pathString}];return e.settings.bindingType==="Zephyr"&&(Y$(r).forEach(i=>{n.push({type:"dt_zephyr_macro_node_label",data:i})}),n.push({type:"dt_zephyr_macro_node_path",data:bS(r)}),K$(r).forEach(i=>{n.push({type:"dt_zephyr_macro_prop_node_alias",data:i})})),n}async function X$(t,e){return e?_t(t,e,r=>[...yJ(r,e),...gJ(r,e)]):[]}var J$=L(j());function vJ(t){return!t||!(t.item instanceof Ke)?void 0:t.item.parent.nodeType?.getSignatureHelp?.(t.item,t.ast,t.beforeAst,t.afterAst)}async function TJ(t){let e=yc(t?.ast);if(!e||!e.params.length||!t?.ast||t.ast===e.functionName)return;let n=(await t.runtime.context.getAllParsers()).at(-1).cPreprocessorParser.macros.get(e.functionName.name)?.macro.identifier;if(!n||!(n instanceof Jn))return;let i=n.params.map(o=>({label:o instanceof Ct?o.name:"..."})),s=e.params.find(o=>o&&(t.ast===o||o.isAncestorOf(t.ast)));return s??=t.afterAst?e.params.find(o=>o&&(t.afterAst===o||o.isAncestorOf(t.afterAst))):void 0,s??=t.beforeAst?e.params.find(o=>o&&(t.beforeAst===o||o.isAncestorOf(t.beforeAst))):void 0,{signatures:[J$.SignatureInformation.create(`${e.functionName.name}(${i.map(o=>o.label).join(", ")})`,void 0,...i.flat())],activeSignature:0,activeParameter:s?e.params.indexOf(s):void 0}}async function Q$(t,e){if(e)return(await _t(t,e,async r=>[await TJ(r)||vJ(r)])).at(0)}var Z$=require("timers"),eB=require("events");var _S=class extends eB.EventEmitter{constructor(e=3e3,r=1e3){super(),this.thresholdBytes=e*1024*1024,this.interval=(0,Z$.setInterval)(()=>{let n=process.memoryUsage().heapUsed;n>this.thresholdBytes&&this.emit("thresholdExceeded",{usedMb:(n/1024/1024).toFixed(2),thresholdMb:e})},r)}stop(){clearInterval(this.interval)}},bJ=new _S(3e3),tB=()=>{bJ.on("thresholdExceeded",({usedMb:t,thresholdMb:e})=>{console.warn(`[HeapMonitor] Heap usage exceeded ${e}MB: ${t}MB used`),xw(),Mw()})};var Ve=[],ce,za,Pm=new WeakMap,yu=new Map;tB();var nB=t=>{t.getContextFiles().forEach(e=>{yu.has(e)||yu.set(e,new Nm(e,wS,r=>!!km(r))),yu.get(e)?.watch()})},PS=async t=>{let e=Ve.indexOf(t);if(e===-1)return;wm(t,void 0,!0),Pm.delete(t),console.log(`(ID: ${t.id}) cleaning Context for [${t.ctxNames.join(",")}]`);let r=await Cs(t);if(ne.sendNotification("devicetree/contextDeleted",{ctxNames:t.ctxNames.map(n=>n.toString()),id:t.id,...await t.getFileTree(),settings:t.settings,active:ce===t,type:r.type}),Ve.splice(e,1),await ES(),t===ce&&(ce=void 0,Ve.length)){let n=za?sn(Ve,{uri:za}):void 0;n??=Ve[0],console.log("Active context was deleted. Forcing active to",n.id),await Jt({id:n.id},!0)}t.getContextFiles().map(n=>yu.get(n)?.unwatch())},_J=t=>{let e=Pm.get(t);if(!e?.abort.signal.aborted)return Promise.all([e?.promise,t.getRuntime()])},$e=async()=>{await Promise.all(Ve.map(_J))},kS=async t=>(await iB()).indexOf(t)!==-1,iB=async()=>{let t=await sB();return Ve.filter(e=>!t.some(r=>r===e))},sB=async()=>{let t=await RS();return Ve.filter(e=>t.contexts.find(r=>bi(r)===e.id))},SJ=async()=>{let t=await wJ();return Ve.filter(e=>t.contexts.find(r=>bi(r)===e.id))},NJ=async t=>(await SJ()).indexOf(t)!==-1,RJ=async(t,e)=>{if(t===e)return!0;let r=(await t.getAllParsers()).flatMap(i=>i.cPreprocessorParser.dtsIncludes).filter(i=>i.resolvedPath),n=(await e.getAllParsers()).flatMap(i=>i.cPreprocessorParser.dtsIncludes).filter(i=>i.resolvedPath);return n.some(i=>de(i.resolvedPath,t.parser.uri))&&r.length?r.every(i=>n.some(s=>s.resolvedPath===i.resolvedPath&&s.firstToken.pos.col===i.firstToken.pos.col&&s.firstToken.pos.len===i.firstToken.pos.len&&s.firstToken.pos.line===i.firstToken.pos.line&&s.lastToken.pos.col===i.lastToken.pos.col&&s.lastToken.pos.len===i.lastToken.pos.len&&s.lastToken.pos.line===i.lastToken.pos.line)):e.getContextFiles().some(i=>de(i,t.parser.uri))},PJ=async t=>{if(!await kS(t))return;let e=await iB(),r=await sB(),n=await af(e);if(Ve.indexOf(t)===-1)return;let i=await Promise.all(n.flatMap(a=>[...r,...e.filter(c=>c!==a.context)].map(async c=>({context:a.context,same:await RJ(a.context,c)})))),s=t.getContextFiles(),o=n.filter(a=>i.some(c=>c.context===a.context&&c.same)||a.context!==t&&de(a.context.parser.uri,t.parser.uri)&&s.some(c=>c&&a.files.indexOf(c)!==-1)).map(a=>a.context);o.length&&await Promise.all(o.map(PS))},ne=(0,lt.createConnection)(lt.ProposedFeatures.all),gr=new lt.TextDocuments(Yi),oB=!1,SS=!1,aB=!1,cB=!1,lB=!1,NS;ne.onInitialize(t=>{NS=t.workspaceFolders??[],ne.console.log(`[Server(${process.pid}) ${NS?.at(0)?.uri} Version 0.5.6 ] Started and initialize received`);let e=t.capabilities;oB=!!(e.workspace&&e.workspace.configuration),SS=!!(e.workspace&&e.workspace.workspaceFolders),aB=!!e.workspace?.diagnostics?.refreshSupport,cB=!!e.workspace?.semanticTokens?.refreshSupport,lB=!!e.workspace?.foldingRange?.refreshSupport;let r={capabilities:{typeDefinitionProvider:!0,workspaceSymbolProvider:!0,textDocumentSync:lt.TextDocumentSyncKind.Incremental,renameProvider:{prepareProvider:!0},completionProvider:{resolveProvider:!0,triggerCharacters:["&","="," ",'"',"(",","]},codeActionProvider:{codeActionKinds:[lt.CodeActionKind.QuickFix,lt.CodeActionKind.SourceFixAll]},documentSymbolProvider:!0,semanticTokensProvider:{legend:{tokenTypes:tf,tokenModifiers:rf},full:!0},documentLinkProvider:{resolveProvider:!1},foldingRangeProvider:!0,definitionProvider:!0,declarationProvider:!0,referencesProvider:!0,documentFormattingProvider:!0,hoverProvider:!0,signatureHelpProvider:{triggerCharacters:["<","("],retriggerCharacters:[" ",","]}}};return SS&&(r.capabilities.workspace={workspaceFolders:{changeNotifications:!0,supported:!0}}),r});ne.onInitialized(()=>{oB&&ne.client.register(lt.DidChangeConfigurationNotification.type,{}),SS&&ne.workspace.onDidChangeWorkspaceFolders(async t=>{ne.console.log("Workspace folder change event received"),await _u()})});var kJ=async()=>{let t=uB();return t={...ho,...t},gu(t,await bu())},RS=async()=>{let t=CJ();return t={...ho,...t},gu(t,await bu())},wJ=async()=>{let t=DJ();return t={...ho,...t},gu(t,await bu())},Tu=async()=>{let t=EJ();return t={...ho,...t},gu(t,await bu())},bu=async()=>(await ne.workspace.getWorkspaceFolders()??NS)?.map(e=>Ae(e.uri))?.at(0),rB=async t=>{let e=sn(Ve,{id:bi(t)});if(e)return e.ctxNames.includes(t.ctxName)||console.log(`(ID: ${e.id}) Adding name ${t.ctxName} for [${e.ctxNames.join(",")}]`),e.addCtxName(t.ctxName),e;let r=bi(t);console.log(`(ID: ${r}) New context [${t.ctxName}]`),console.log(`(ID: ${r}) Settings: ${JSON.stringify(t,void 0," ")}`);let n=(0,Ga.join)((0,Ga.dirname)(t.dtsFile),"dts","bindings"),i=new Mf(t,t.bindingType?j$({zephyrBindings:t.zephyrBindings?[n,...t.zephyrBindings]:[n],deviceOrgBindingsMetaSchema:t.deviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:t.deviceOrgTreeBindings??[]},t.bindingType):void 0);Ve.push(i),await i.stable(),nB(i);let s=await Cs(i);return ne.sendNotification("devicetree/contextCreated",{ctxNames:i.ctxNames.map(o=>o.toString()),id:i.id,...await i.getFileTree(),settings:i.settings,active:i===ce,type:s.type}),await PJ(i),await ES(),i},_u=async()=>{let t=await RS(),e=await Tu();e.allowAdhocContexts||(e=await RS());let r=e.contexts.map(bi),n=Ve.filter(i=>!r.includes(i.id));await Promise.all(n.map(PS)),await t.contexts?.reduce((i,s)=>i.then(async()=>{await rB(s)}),Promise.resolve()),e.allowAdhocContexts&&await(await kJ()).contexts?.reduce((s,o)=>s.then(async()=>{sn(Ve,{uri:o.dtsFile})||await rB(o)}),Promise.resolve()),za?await Jt({uri:za}):!ce&&Ve.length&&(console.log(`No active context using first context (ID: ${Ve[0].id}) [${Ve[0].ctxNames.join(",")}]`),await Jt({id:Ve[0].id}))},_n,Es,vu=new Map,Va=new Map,EJ=()=>!Es&&!_n?void 0:{...Es,..._n,contexts:[..._n?.contexts??[],...Array.from(Va.values()),...Array.from(vu.values())]},uB=()=>!Es&&!_n?void 0:{...Es,..._n,contexts:[...Array.from(vu.values())]},CJ=()=>!Es&&!_n?void 0:{...Es,..._n,contexts:[..._n?.contexts??[],...Array.from(Va.values())]},DJ=()=>!Es&&!_n?void 0:{..._n,contexts:[..._n?.contexts??[]]};function AJ(t){let e={...t};for(let r in e)e[r]===null&&delete e[r];return e}var dB=async()=>{let t=await Tu();console.log("Resolved settings",JSON.stringify(t,void 0," ")),ne.sendNotification("devicetree/settingsChanged",t),await _u(),$e().then(()=>{aB&&ne.languages.diagnostics.refresh()})},IJ=async()=>{let t=ce?.getContextFiles();await Promise.all(Array.from(gr.keys()).filter(Ft).map(async e=>{t?.some(r=>de(r,Ae(e)))||await ne.sendDiagnostics({uri:e,version:gr.get(e)?.version,diagnostics:[{severity:lt.DiagnosticSeverity.Information,range:lt.Range.create(lt.Position.create(0,0),lt.Position.create(0,0)),message:"File not in active context",source:"devicetree"}]})}))},wS=async t=>{let e=Oy(Ve,t);if(e.length)e.sort((r,n)=>r===ce?-1:n===ce?1:0).forEach(r=>{Pm.get(r)?.abort.abort();let n=new AbortController,i=new Promise(s=>{setTimeout(async()=>{if(n.signal.aborted){s();return}let o=performance.now(),a=ce===r,c=a?fB(r):[],l=r.getContextFiles();await r.reevaluate(t),nB(r),l.forEach(u=>yu.get(u)?.unwatch()),a&&CS(r)?.length&&Em(r).then(u=>{let d=u.items.map(f=>({uri:f.uri,version:f.version??void 0,diagnostics:f.items}));wm(r,c.filter(f=>d.every(p=>p.uri!==f.uri))),d.forEach(f=>{ne.sendDiagnostics(f)}),Wa.set(r,!0)}),r.serialize().then(async u=>{let[d,f]=await Promise.all([Cs(r),r.getFileTree()]),p={node:u,ctx:{ctxNames:r.ctxNames.map(g=>g.toString()),id:r.id,...f,settings:r.settings,active:a,type:d.type}};ce===r&&ne.sendNotification("devicetree/activeContextStableNotification",p),ne.sendNotification("devicetree/contextStableNotification",p)}),s(),console.log("reevaluate",performance.now()-o)},50)});Pm.set(r,{abort:n,promise:i})});else{if((await Tu()).allowAdhocContexts===!1)return;await _u(),await Jt({uri:t})}},OJ=t=>gr.keys().find(e=>de(Ae(e),t)),km=t=>{let e=OJ(t);if(e)return gr.get(e)},fB=t=>t.getContextFiles().map(e=>({uri:ve(e),version:km(e)?.version,diagnostics:[]})),Wa=new WeakMap,wm=async(t,e=fB(t),r=!1)=>{if(!r&&t!==ce)return;let n=performance.now();await Promise.all(e.filter(i=>t===ce||!ce?.getContextFiles().some(s=>de(Ae(i.uri),s))).map(i=>ne.sendDiagnostics({uri:i.uri,version:gr.get(i.uri)?.version,diagnostics:[]}))),Wa.delete(t),console.log(`(ID: ${t.id})`,"clear workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-n)},Em=async t=>{await t.stable();let e=performance.now(),r=await t.getDiagnostics(),n=t.getContextFiles().map(i=>({uri:ve(i),kind:lt.DocumentDiagnosticReportKind.Full,items:r.get(i)??[],version:km(i)?.version??null}));return console.log(`(ID: ${t.id})`,"workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-e),{items:[...n]}},ES=async()=>{let t=await Promise.all(Ve.map(Cs));console.log("======== Context List ========"),t.forEach(e=>{console.log(`(ID: ${e.ctx.id}) [${e.ctx.ctxNames.join(",")}]`,`[${e.type}]`,ce===e.ctx?" [ACTIVE]":"")}),console.log("==============================")},Cs=async t=>{let e=await kS(t),r=!e&&await NJ(t);return{ctx:t,type:e?"Ad Hoc":r?"User":"3rd Party"}},Jt=async(t,e=!1)=>{if("uri"in t){if(!Ft(t.uri))return!1;za=t.uri,console.log("Active File Uri",za)}let r=await Tu();if(ce&&!e&&!r.autoChangeContext||(await $e(),!e&&ce?.getContextFiles().find(o=>"uri"in t&&de(o,t.uri))))return!1;let n=ce,i=sn(Ve,t),s=n!==i;return s&&(n&&wm(n),ce=i,i?(Cs(i).then(async o=>{let a=await i.getFileTree();!i||i!==ce&&!Ve.includes(i)||ne.sendNotification("devicetree/newActiveContext",{ctxNames:i.ctxNames.map(c=>c.toString()),id:i.id,...a,settings:i.settings,active:ce===i,type:o.type})}),CS(i)?.length&&Em(i).then(o=>{o.items.map(a=>({uri:a.uri,version:a.version??void 0,diagnostics:a.items})).forEach(a=>{ne.sendDiagnostics(a)})}).finally(()=>Wa.set(i,!0)),await ES()):ne.sendNotification("devicetree/newActiveContext",void 0)),lB&&ne.languages.foldingRange.refresh(),cB&&ne.languages.semanticTokens.refresh(),s},Ft=t=>[".dts",".dtsi",".dtso",".overlay"].some(e=>t.endsWith(e));gr.listen(ne);var CS=t=>t?.getContextFiles()?.filter(e=>km(e));gr.onDidClose(async t=>{let e=Ae(t.document.uri);if(!Ft(e))return;let r=Oy(Ve,e);if(r.length===0){vu.delete(e),ne.sendDiagnostics({uri:t.document.uri,version:gr.get(t.document.uri)?.version,diagnostics:[]});return}await Promise.all(r.map(async n=>{!!CS(n)?.filter(s=>s!==e).length?ce?.getContextFiles().some(s=>de(s,e))||ne.sendDiagnostics({uri:t.document.uri,version:gr.get(t.document.uri)?.version,diagnostics:[]}):await kS(n)?(await PS(n),vu.delete(n.settings.dtsFile)):wm(n)}))});gr.onDidOpen(async t=>{let e=Ae(t.document.uri);if(!Ft(e))return;await $e(),IJ();let r=sn(Ve,{uri:e});if(console.log("onDidOpen",r?.id,e),r)r!==ce?await Jt({id:r.id}):r===ce&&!Wa.get(r)&&Em(r).then(({items:n})=>n.map(i=>({uri:i.uri,version:i.version??void 0,diagnostics:i.items})).forEach(async i=>{ne.sendDiagnostics(i)})).finally(()=>Wa.set(r,!0));else{let n={ctxName:(0,Ga.basename)(e),dtsFile:e};vu.set(e,n),await wS(e)}});gr.onDidChangeContent(async t=>{let e=Ae(t.document.uri);if(!Ft(e))return;let r=t.document.getText(),n=Ar();n.needsRenew(e,r)&&(console.log("Content changed"),n.renewLexer(e,r),await wS(e))});ne.onDidChangeConfiguration(async t=>{t?.settings?.devicetree&&(_n=z$(AJ(t.settings.devicetree)),console.log("Configuration changed",JSON.stringify(t,void 0," ")),await dB())});ne.listen();ne.languages.diagnostics.onWorkspace(async()=>{await $e();let t=ce;return t?Em(t).finally(()=>{Wa.set(t,!0)}):{items:[]}});ne.onDidChangeWatchedFiles(t=>{ne.console.log("We received a file change event")});ne.onCompletion(async t=>{let e=Ae(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&ce&&ce.bindingLoader?.type==="Zephyr")return ZD(t,ce,gr.get(t.textDocument.uri));if(!Ft(e))return[];await $e(),Jt({uri:e});let r=yr(e);return r?[...await LC(t,r),...await gA(t,r)]:[]});ne.onCompletionResolve(t=>t);var yr=t=>{let e=uB();return sn(Ve,{uri:t},ce,e?.preferredContext)};ne.onDocumentSymbol(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return[];await $e();let r=yr(e);return r?r.getUriParser(e)?.getDocumentSymbols(e):[]});ne.onWorkspaceSymbol(async()=>{await $e();let t=ce;return t?(await t.getAllParsers()).flatMap(e=>e.getWorkspaceSymbols()):[]});ne.languages.semanticTokens.on(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return{data:[]};try{await $e();let r=yr(e),n=new lt.SemanticTokensBuilder,i=r?.isInContext(e);return!r||!i?{data:[]}:((await r.getAllParsers()).forEach(s=>s.buildSemanticTokens(n,e)),n.build())}catch(r){throw console.log(r),r}});ne.onDocumentLinks(async t=>{await $e();let e=Ae(t.textDocument.uri);return Ft(e)?yr(e)?.getDocumentLinks(e):e.endsWith(".yaml")&&ce?ce.bindingLoader?.getDocumentLinks?.(gr.get(t.textDocument.uri))??[]:[]});ne.onPrepareRename(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return sA(t,r)});ne.onRenameRequest(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return iA(t,r)});ne.onReferences(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return eA(t,r)});ne.onDefinition(async t=>{let e=Ae(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&ce&&ce.bindingLoader?.type==="Zephyr")return uA(t,ce,gr.get(t.textDocument.uri));if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e),n=(await r?.getDocumentLinks(e,t.position))?.filter(i=>i.target).map(i=>lt.Location.create(i.target,i.range))??[];return n.length?n:cA(t,r)});ne.onDeclaration(async t=>{let e=Ae(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&ce&&ce.bindingLoader?.type==="Zephyr")return fA(t,ce,gr.get(t.textDocument.uri));if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return lA(t,r)});ne.onCodeAction(async t=>{let e=Ae(t.textDocument.uri);if(Ft(e))return hA(t)});ne.onDocumentFormatting(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return r?(await r.getSyntaxIssues(void 0,i=>Ho(i,e,!1))).get(e)?.length?[]:Uy(t,r,Ar().getDocument(e).getText()):[]});ne.onHover(async t=>{let e=Ae(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&ce&&ce.bindingLoader?.type==="Zephyr")return BI(t,ce,gr.get(t.textDocument.uri));if(!Ft(e))return;await $e();let r=yr(e);return(await yA(t,r)).at(0)});ne.onFoldingRanges(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e();let r=yr(e),n=r?.isInContext(e);if(!r||!n)return[];let i=(await r.getAllParsers()).find(s=>s.getFiles().some(o=>o===e));return i?H$(e,i):[]});ne.onTypeDefinition(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return V$(t,r)});ne.onSignatureHelp(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return Q$(t,r)});ne.onRequest("devicetree/getContexts",async()=>(await $e(),Promise.all(Ve.map(async t=>{let e=await Cs(t);return{ctxNames:t.ctxNames.map(r=>r.toString()),id:t.id,...await t.getFileTree(),settings:t.settings,active:ce===t,type:e.type}}))));ne.onRequest("devicetree/setActive",async t=>(await $e(),console.log("devicetree/setActive",t),await Jt(t,!0)));ne.onRequest("devicetree/getActiveContext",async()=>{if(await $e(),console.log("devicetree/getActiveContext"),!ce)return;let t=await Cs(ce);return ce?{ctxNames:ce.ctxNames.map(e=>e.toString()),id:ce.id,...await ce.getFileTree(),settings:ce.settings,active:!0,type:t.type}:void 0});ne.onRequest("devicetree/setDefaultSettings",async t=>{await $e(),Es=t,console.log("Integration Settings",t),await dB()});ne.onRequest("devicetree/requestContext",async t=>{await $e();let e=await Tu(),r=await TS(t,e,await bu());console.log("devicetree/requestContext",r);let n=bi(r),i=Array.from(Va).find(([,a])=>a.ctxName===t.ctxName);if(i){let a=i[0].split(":",1)[0];sn(Ve,{name:t.ctxName.toString()})?.removeCtxName(t.ctxName),console.log(`Removing integration context with ID ${a} and name ${t.ctxName}`),Va.delete(i[0])}Va.set(`${n}:${t.ctxName}`,t),await _u();let s=Ve.find(a=>a.id===n);if(!s)throw new Error("Failed to create context");let o=await Cs(s);return{ctxNames:s.ctxNames.map(a=>a.toString()),id:n,...await s.getFileTree(),settings:s.settings,active:!0,type:o.type}});ne.onRequest("devicetree/removeContext",async({id:t,name:e})=>{await $e(),Va.delete(`${t}:${e}`);let r=sn(Ve,{id:t});if(r){if(r.removeCtxName(e),r.ctxNames.length){console.log("Context will not be deleted as it is still in use by others");return}await _u()}});ne.onRequest("devicetree/compiledDtsOutput",async t=>(await $e(),t?sn(Ve,{id:t})?.toFullString():void 0));ne.onRequest("devicetree/serializedContext",async t=>(await $e(),t?sn(Ve,{id:t})?.serialize():void 0));ne.onRequest("devicetree/activePath",async t=>{if(await $e(),!ce)return;let e=r=>{if(r?.item)return r.item instanceof J?{nodePath:r.item.pathString}:{nodePath:r.item.parent.pathString,propertyName:r.item.name}};return(await _t(t,ce,r=>[e(r)])).at(0)});ne.onRequest("devicetree/customActions",async t=>(await $e(),X$(t,ce)));ne.onRequest("devicetree/activeFileUri",async t=>{await $e(),Jt({uri:t})});var MJ=async(t,e,r)=>{if((await e.getSyntaxIssues(void 0,a=>Ho(a,r,!1))).get(r)?.length)throw new Error("Unable to format. Files has syntax issues.");let i=Ar().getDocument(r),s=await Uy(t,e,i.getText());return s.length===0?void 0:My(i,s)};ne.onRequest("devicetree/formattingText",async t=>{await $e();let e=Ae(t.textDocument.uri),r=yr(e);if(r)return Jt({uri:e}),MJ(t,r,e);let n=Ar().getDocument(e,t.text),i=await Fw(t,n.getText());return i.length===0?n.getText():My(n,i)});ne.onRequest("devicetree/diagnosticIssues",async({uri:t,full:e})=>{await $e();let r=Ae(t);Jt({uri:r});let n=yr(r);if(!n)return[];let i=e?(await n.getDiagnostics()).get(r):(await n.getSyntaxIssues(void 0,s=>Ho(s,r,!!e))).get(r);if(i?.length)return i});ne.onRequest("devicetree/evalMacros",async({macros:t,ctxId:e})=>{await $e();let r=sn(Ve,{id:e});return r?t.map(n=>{let i=nf(n,r.macros),s=Ee(i);return{macro:n,evaluated:typeof s=="number"?s:i}}):[]});
307
+ ${n}`]})]},aJ=(t,e)=>E$(t,e.split("/").filter(r=>r)),E$=(t,e)=>{if(e.length===0)return{node:t,remainingInstancePath:""};let r=e[0].split("@"),n=r[0],i=r.at(1)?.split(",").map(o=>Number.parseInt(o,16)),s=t.getNode(n,i);return s?E$(s,e.slice(1)):{node:t,property:t.getProperty(e[0]),remainingInstancePath:e.slice(1).join("/")}};var pS=class t{constructor(){this.schemaIdValidators=new Map;this.ajvMap=new Map}static getNodeCompatible(e){let n=e.getProperty("compatible")?.ast.values;if(!n?.values.some(i=>!(i?.value instanceof ie)))return n?.values.map(i=>(i?.value).value)}parseMetaSchema(e,r){Ws.sync("**/*.yaml",{cwd:e}).forEach(i=>{i=(0,uS.resolve)(e,i);try{let s=fS.default.parse((0,dS.readFileSync)(i,"utf-8"));r.addMetaSchema(s),this.schemaIdValidators.set(s.$id,i)}catch{}})}parseBindings(e,r){Ws.sync("**/*.yaml",{cwd:e}).forEach(i=>{i=(0,uS.resolve)(e,i);try{let s=fS.default.parse((0,dS.readFileSync)(i,"utf-8"));r.addSchema(s),this.schemaIdValidators.set(s.$id,i)}catch(s){console.warn(i,s.message)}})}getNodeTypes(e,r,n){let i=`${e.join(";")}::${r.join(";")}`,s=this.ajvMap.get(i);return s||(s=new D$.default({strict:!1,strictSchema:!1,strictNumbers:!1}),s.addMetaSchema(lS),this.ajvMap.set(i,s),e.forEach(c=>this.parseMetaSchema(c,s)),r.forEach(c=>this.parseBindings(c,s))),t.getNodeCompatible(n)?.map(c=>{try{let l=Array.from(this.schemaIdValidators.keys()).find(f=>f.endsWith(`/${c}.yaml#`));if(!l)return;let u=new bm(s,l);u.bindingsPath=this.schemaIdValidators.get(l),u.compatible=c;let d=s.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)??[]}getBindings(){return Array.from(this.schemaIdValidators.keys())}},C$,hS=()=>(C$??=new pS,C$);var mu=require("path"),L$=require("fs"),$$=L(require("path")),B$=L(ub());var Tn=L(j());var A$=()=>{let t=new X("nonposted-mmio",z("EMPTY"),"optional");return t.description=["Specifies that direct children of this bus should use non-posted memory accesses (i.e. a non-posted mapping mode) for MMIO ranges."],t};function I$(){let t=lr();t.noMismatchPropertiesAllowed=!0;let e=t.properties.find(n=>n.name==="compatible");e.required=()=>"required";let r=t.properties.find(n=>n.name==="ranges");return r.required=()=>"required",t.addProperty(A$()),t}var O$=t=>{switch(t){case"string":return z("STRING");case"int":return z("U32");case"boolean":return z("EMPTY");case"array":return z("PROP_ENCODED_ARRAY");case"uint8-array":return z("BYTESTRING");case"string-array":return z("STRINGLIST");case"phandle":return z("U32");case"phandles":return z("PROP_ENCODED_ARRAY");case"phandle-array":return z("PROP_ENCODED_ARRAY");case"path":return z(["STRING","U32"]);case"compound":return z("ANY");default:return z("ANY")}},M$=(t,e)=>{switch(t){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(r=>typeof r=="number")?e:void 0;case"uint8-array":return Array.isArray(e)&&e.every(r=>typeof r=="number")?e:void 0;case"string-array":return Array.isArray(e)&&e.every(r=>typeof r=="string")?e:void 0;case"phandle":return;case"phandles":return;case"phandle-array":return;case"path":return;case"compound":return}},_m=(t,e)=>{if(e.extends??=[],e=e.include.reduce((r,n)=>{let i=t.find(s=>(0,mu.basename)(s.filePath)===n.name);if(i){let s=n["property-blocklist"],o=n["property-allowlist"];return e.extends?.push(...r.include.map(a=>(0,mu.basename)(a.name,".yaml"))),r.include=r.include.filter(a=>a!==n),cJ(t,i,r,s,o)??r}return console.warn(`Unable to find ${n.name}`),r},e),e["child-binding"]&&(e["child-binding"].include=F$(e["child-binding"].include),e["child-binding"]=_m(t,e["child-binding"])),!e.include.length)return e},cJ=(t,e,r,n=[],i)=>{let s=_m(t,e),o=_m(t,r);if(!s||!o)return;let a=new Set;Object.keys(s?.properties??{}).forEach(f=>a.add(f)),Object.keys(o?.properties??{}).forEach(f=>a.add(f));let c={};Array.from(a).forEach(f=>{let p=n?.some(h=>h===f)||i&&!i.some(h=>h===f)?void 0:s.properties?.[f]??void 0,g=o.properties?.[f]??void 0;(p||g)&&(c={...c,[f]:{...p??g}})}),o.properties=c,o.extends??=[],o.extends.push(...s.extends??[]);let l=new Set;return Object.keys(s).filter(f=>f.endsWith("-cells")).forEach(f=>l.add(f)),Object.keys(s).filter(f=>f.endsWith("-cells")).forEach(f=>l.add(f)),Array.from(l).forEach(f=>{let p=s[f]??[],g=o[f]??[];o[f]=Array.from([...p,...g])}),o["on-bus"]??=s["on-bus"],o.bus?o.bus.push(...s.bus??[]):o.bus=s.bus,o},F$=t=>t?typeof t=="string"?[{name:t}]:t.map(e=>typeof e!="string"?e:{name:e}):[],mS=class t{constructor(){this.typeCache=new Map;this.processedFolders=new Set;this.zephyrBindingCache=new Map}static getCompatibleKeys(e,r){return!r||!r.nodeType?.bus?.length?[e]:[...r.nodeType.bus.map(n=>`${e}::${n}`),e]}static getNodeCompatible(e){let i=e.getProperty("compatible")?.ast.values?.values.filter(s=>s&&s.value instanceof ie);if(i?.length)return i.map(s=>s?.value?{name:s.value.value,ast:s.value}:void 0)}getNodeTypes(e,r){let n=t.getNodeCompatible(e)?.filter(a=>a);if(!n?.length){if(e.name==="zephyr,user"){let a=r.split(":"),l=Array.from(this.zephyrBindingCache.keys()).filter(d=>a.some(f=>d.startsWith(f))).flatMap(d=>this.zephyrBindingCache.get(d)).find(d=>d.filePath.endsWith("/base.yaml")),u=l?gS(l,e):void 0;if(u){u.warnMismatchProperties=!1;let d=u.properties.find(f=>f.name==="compatible");d&&(d.required=()=>"optional")}return{type:[u??rs(e)],issues:[]}}return{type:[rs(e)],issues:[]}}let i=n.flatMap(a=>t.getCompatibleKeys(a.name,e.parent).map(c=>this.typeCache.get(r)?.get(c)?.(e)).filter(c=>!!c)),s=this.getBusTypes(),o=n.flatMap(a=>{let c=t.getCompatibleKeys(a.name,e.parent).some(l=>this.typeCache.get(r)?.has(l));if(!c){let l=s.filter(u=>this.typeCache.get(r)?.has(`${a.name}::${u}`));if(l.length)return B(37,a.ast.rangeTokens,a.ast,{templateStrings:l})}return c?[]:[B(32,a.ast.rangeTokens,a.ast,{severity:Tn.DiagnosticSeverity.Hint,tags:[Tn.DiagnosticTag.Unnecessary],templateStrings:[a.name]})]});return{type:i.length?i:[rs(e)],issues:o}}loadTypeAndCache(e,r){e=Array.isArray(e)?e:[e];let n=e.filter(o=>this.processedFolders.has(o)).flatMap(o=>Array.from(this.zephyrBindingCache.entries()).flatMap(([a,c])=>a.startsWith(o)?[c]:[]));n.push(...e.filter(o=>!this.processedFolders.has(o)).flatMap(o=>(this.processedFolders.add(o),Ws.sync("**/*.yaml",{cwd:o,ignore:"test/*"}).map(c=>{if(c=(0,mu.resolve)(o,c),this.zephyrBindingCache.has(c))return this.zephyrBindingCache.get(c);try{let l=B$.default.parse((0,L$.readFileSync)(c,"utf-8")),u=F$(l?.include),d={...l,bus:l.bus?Array.isArray(l.bus)?l.bus:[l.bus]:void 0,include:u,rawInclude:[...u],filePath:c};return this.zephyrBindingCache.set(c,d),d}catch(l){console.warn(l)}}).filter(c=>!!c))));let i=n.map(o=>_m(n,o)).filter(o=>!!o&&!o.include.length),s=this.typeCache.get(r);s||(s=new Map,s.set("simple-bus",()=>I$()),this.typeCache.set(r,s)),lJ(i,s)}getBindings(e){return Array.from(this.typeCache.get(e)?.keys()??[]).map(r=>r.split("::",1)[0])}getBusTypes(){let e=Array.from(this.zephyrBindingCache.values()).flatMap(r=>r.bus?.filter(n=>!!n)??[]).filter(r=>!!r);return Array.from(new Set(e))}getDocumentLinks(e,r){let n=this.zephyrBindingCache.get(Ae(e.uri));if(!n)return[];let i=e.getText();return n.rawInclude.map(o=>{let c=new RegExp(o.name).exec(i);if(c){let l=e.positionAt(c.index),u=e.positionAt(c.index+c[0].length),d=Array.from(this.zephyrBindingCache.keys()).find(f=>f.endsWith(`${$$.default.sep}${o.name}`)&&r.some(p=>f.startsWith(p)));return d?{range:Tn.Range.create(l,u),target:ve(d)}:void 0}}).filter(o=>!!o)}},x$,Ha=()=>(x$??=new mS,x$),lJ=(t,e)=>t.forEach(r=>{r.compatible&&e.set(r["on-bus"]?`${r.compatible}::${r["on-bus"]}`:r.compatible,n=>gS(r,n))}),gS=(t,e)=>{let r=rs(e);r.compatible=t.compatible,r.description=t.description,r.bindingsPath=t.filePath,r.bus=typeof t.bus=="string"?[t.bus]:Array.from(new Set(t.bus)),r.onBus=t["on-bus"],t.extends?.forEach(s=>r.extends.add(s)),r.warnMismatchProperties=!0;let i=Object.keys(t).filter(s=>s.endsWith("-cells")).map(s=>({specifier:s.replace(/-cells$/,""),values:t[s]}));if(t.properties&&Object.keys(t.properties).forEach(s=>{let o=t.properties[s];uJ(r,s,o),r.cellsValues=i}),t["child-binding"]){let s=t["child-binding"];r.childNodeType=o=>gS(s,o)}return r},uJ=(t,e,r)=>{let n=t.properties.find(i=>i.getNameMatch(e));if(n&&typeof n.name=="string"){n.required=()=>r.required?"required":"optional",n.values=()=>r.enum??[],n.constValue=M$(r.type,r.const),n.bindingType=r.type;let i=n.additionalTypeCheck;n.additionalTypeCheck=(s,o)=>[...q$(r,e,n)(s,o),...i?.(s,o)??[]]}else{let i=r.type==="compound"?n?.type:O$(r.type);i??=O$(r.type);let s=new X(e,i,r.required?"required":"optional",void 0,r.enum);s.additionalTypeCheck=(o,a)=>{let c=[...n?.additionalTypeCheck?.(o,a)??[],...q$(r,e,s)(o,a)];return s.signatureArgs??=n?.signatureArgs,s.signatureArgsCyclic??=!!n?.signatureArgsCyclic,c},s.description=r.description?[r.description]:n?.description,s.bindingType=r.type,s.constValue=M$(r.type,r.const),t.addProperty(s)}},q$=(t,e,r)=>{let n=t;return(i,s)=>{let o=i.parent.root,a=[];if(n.const){let l=i.ast.quickValues;if(l?.length==1){let u=Array.isArray(n.const)?n.const:[n.const];if(!(Array.isArray(l[0])&&u.length===l[0].length&&l[0].every((f,p)=>typeof f=="number"&&Number.isNaN(f)||u[p]===f))){let f=i.ast.values??i.ast;a.push(B(24,f.rangeTokens,f,{templateStrings:[`Binding expects values to be "${n.type}" with value: ${n.const}`]}))}}}if(n.deprecated&&a.push(B(14,i.ast.rangeTokens,i.ast,{severity:Tn.DiagnosticSeverity.Warning,tags:[Tn.DiagnosticTag.Deprecated],templateStrings:[i.name]})),(n.type==="phandle"||n.type==="phandles"||n.type==="path")&&Oe(i.ast.values)?.forEach(u=>{cn(u,o)||a.push(B(22,u.rangeTokens,u))}),n.type==="path"&&i.ast.values?.values.at(0)?.value instanceof ie){let l=i.ast.values?.values.at(0)?.value,u=[];l.value.split("/").every(d=>{let f=o.getNode(d);return f?u.push(d):a.push(B(23,l.rangeTokens,l,{templateStrings:[d,`/${u.join("/")}`]})),!f})}let c=i.name.match(/^(.*)-(\d+)$/);if(n.type==="phandles"&&c){let l="";e.endsWith("-gpios")?l="gpio":l=n["specifier-space"]??c[1];let u=Number.parseInt(c[2],10),d=i.parent.getProperty(`${l}-names`);d&&(d.ast.quickValues?.at(u)||a.push(B(33,i.ast.rangeTokens,i.ast,{severity:Tn.DiagnosticSeverity.Warning,linkedTo:[d.ast],templateStrings:[i.name,u.toString()]})))}if(n.type==="phandle-array"){let l=Oe(i.ast.values),u=0,d=[],f=0;for(;l&&u<l.length;){let p=l.at(u),g=cn(p,o);if(!g){let F=p??i.ast;a.push(B(22,F.rangeTokens,F));break}let h="";e.endsWith("-gpios")?h="gpio":h=n["specifier-space"]??e.slice(0,-1);let v=g.getProperty(`#${h}-cells`);if(!v){a.push(B(16,i.ast.rangeTokens,i.ast,{linkedTo:[...g.nodeNameOrLabelRef],templateStrings:[i.name,`#${h}-cells`,`/${g.path.slice(1).join("/")}`]}));break}let S=v?qe(v,0,0,s)??0:0,_=g.nodeType?.cellsValues?.find(F=>F.specifier===h)?.values;if(d.push([`${f}_phandle`,..._?.map(F=>`${f}_${F}`)??[],...Array.from({length:S-(_?.length??0)},(F,H)=>`${f}_cell${S-(_?.length??0)?H:""}`)]),1+S>l.length-u){let F=p??i.ast;a.push(B(19,F.rangeTokens,F,{templateStrings:[i.name,`<${d.at(-1).join(" ")}>`]}));break}u+=1+S;let T=l.slice(u-S,u),P={mappingValuesAst:T,specifierSpace:h,target:g};i.nexusMapsTo.push(P);let C=g.getProperty(`${h}-map`);if(C){let F=g.getNexusMapEntryMatch(h,s,T);F?.match?P.mapItem=F.match:a.push(B(31,F.entry.rangeTokens,F.entry,{linkedTo:[C.ast]}))}T.every(F=>F instanceof we)&&g.spesifierNexusMapping.push({expressions:T,node:i.parent,property:i});let $=i.parent.getProperty(`${h}-names`);p&&$&&($.ast.quickValues?.at(f)||a.push(B(33,W(p.firstToken,l.at(u-1)?.lastToken),i.ast,{severity:Tn.DiagnosticSeverity.Warning,linkedTo:[$.ast],templateStrings:[i.name,f.toString()]}))),f++}d.push([`${f}_phandle`,`${f}_cell...`]),r.signatureArgs=d.map(p=>p.map(g=>Tn.ParameterInformation.create(g)))}return a}};var j$=(t,e)=>{let r=t.zephyrBindings.join(":");return e==="Zephyr"&&Ha().loadTypeAndCache(t.zephyrBindings,r),{files:t,type:e,getNodeTypes:n=>{switch(e){case"Zephyr":return Ha().getNodeTypes(n,r);case"DevicetreeOrg":return{type:hS().getNodeTypes(t.deviceOrgBindingsMetaSchema,t.deviceOrgTreeBindings,n),issues:[]}}},getBindings:()=>{switch(e){case"Zephyr":return Ha().getBindings(r);case"DevicetreeOrg":return hS().getBindings()}},getBusTypes:()=>{switch(e){case"Zephyr":return Ha().getBusTypes();case"DevicetreeOrg":return[]}},getDocumentLinks(n){if(!n)return[];switch(e){case"Zephyr":return Ha().getDocumentLinks(n,t.zephyrBindings);case"DevicetreeOrg":return[]}}}};var Sm=L(j());var dJ=t=>!t.lastToken.prevToken||!t.lastToken.prevToken.prevToken?[]:[{startLine:t.firstToken.pos.line,startCharacter:t.firstToken.pos.col,endLine:t.lastToken.prevToken.prevToken.pos.line,endCharacter:t.lastToken.prevToken.prevToken.pos.col,kind:Sm.FoldingRangeKind.Comment}],yS=t=>!t.openScope||!t.closeScope?.prevToken?t.nodes.flatMap(yS):[{startLine:t.openScope.pos.line,startCharacter:t.openScope.pos.col,endLine:t.closeScope.prevToken.pos.line,endCharacter:t.closeScope.prevToken.pos.col,kind:Sm.FoldingRangeKind.Region},...t.nodes.flatMap(yS)],U$=t=>{let e=[];return[...t instanceof es?t.ifBlocks.map(r=>({start:(r.expression??r.keyword).lastToken,end:r.content?.lastToken??(r.expression??r.keyword).lastToken})):[{start:(t.ifDef.identifier??t.ifDef.keyword).lastToken,end:t.ifDef.content?.lastToken}],t.elseOption?{start:t.elseOption.keyword.lastToken,end:t.elseOption.content?.lastToken}:null].forEach(r=>{!r||!r.end||e.push({startLine:r.start.pos.line,startCharacter:r.start.pos.col,endLine:r.end.pos.line,endCharacter:r.end.pos.colEnd,kind:Sm.FoldingRangeKind.Region})}),e},fJ=t=>t instanceof ct?yS(t):t instanceof Zi||t instanceof es?U$(t):t instanceof on?dJ(t):[];function H$(t,e){return e.allAstItems.flatMap(r=>[r,...r.allDescendants]).filter(r=>de(r.uri,t)).flatMap(fJ)}var po=L(j());function pJ(t){if(!t||!(t.ast instanceof He)&&!(t.ast instanceof er))return[];let e=r=>r.nodeType?.bindingsPath?[po.Location.create(ve(r.nodeType.bindingsPath),po.Range.create(po.Position.create(0,0),po.Position.create(0,0)))]:[];return t.item instanceof J&&!Ut(t.ast)?e(t.item):t.ast instanceof er&&t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo?e(t.ast.parentNode.linksTo):t.ast instanceof He&&t.ast.linksTo?e(t.ast.linksTo):[]}async function V$(t,e){return _t(t,e,r=>[...pJ(r)])}var Rm=require("fs");var hJ=(t,e)=>{Ar().reset(t),Ar().requestTokens(t,!0),e(t)},Nm=class{constructor(e,r,n){this.file=e;this.cb=r;this.hasDocumentOpen=n}#e=0;watch(){if(this.count++,this.count===1){console.log("create watch for",this.file);let e=this.file,r=this.cb;this.onChange=()=>{if(this.hasDocumentOpen(e)){console.log("skipping on change document is open",e);return}console.log("onChange",e),hJ(e,r)},(0,Rm.watchFile)(e,this.onChange)}}unwatch(){this.count===1&&(console.log("dispose watch for",this.file),(0,Rm.unwatchFile)(this.file,this.onChange),this.onChange=void 0),this.count--}get count(){return this.#e}set count(e){this.#e=e,e<0&&(this.#e=0,console.warn("unwatching an un watched file",this.file))}};var Xt=L(require("path")),vS=require("fs");var Un=t=>{if(t)return Array.isArray(t)?t:[t]},mJ=t=>({...t,deviceOrgBindingsMetaSchema:Un(t.deviceOrgBindingsMetaSchema),deviceOrgTreeBindings:Un(t.deviceOrgTreeBindings),includePaths:Un(t.includePaths),lockRenameEdits:Un(t.lockRenameEdits),zephyrBindings:Un(t.zephyrBindings),overlays:Un(t.overlays)}),z$=t=>({...t,defaultDeviceOrgBindingsMetaSchema:Un(t.defaultDeviceOrgBindingsMetaSchema),defaultDeviceOrgTreeBindings:Un(t.defaultDeviceOrgTreeBindings),defaultIncludePaths:Un(t.defaultIncludePaths),defaultLockRenameEdits:Un(t.defaultLockRenameEdits),defaultZephyrBindings:Un(t.defaultZephyrBindings),contexts:t.contexts?.map(mJ)}),bn=async(t,e)=>(e&&(t=t.replaceAll("${workspaceFolder}",e)),t),ho={defaultBindingType:"Zephyr",defaultZephyrBindings:[],defaultIncludePaths:[],defaultDeviceOrgBindingsMetaSchema:[],defaultDeviceOrgTreeBindings:[],contexts:[],defaultLockRenameEdits:[],allowAdhocContexts:!0,autoChangeContext:!0},TS=async(t,e,r)=>{let n=(t.cwd?await bn(t.cwd,r):void 0)??e.cwd,i=await Promise.all((t.includePaths??e.defaultIncludePaths).map(p=>bn(p,r))),s=await Promise.all((t.zephyrBindings??e.defaultZephyrBindings).map(p=>bn(p,r))),o=t.bindingType??e.defaultBindingType,a=await Promise.all((t.deviceOrgTreeBindings??e.defaultDeviceOrgTreeBindings).map(p=>bn(p,r))),c=await Promise.all((t.deviceOrgBindingsMetaSchema??e.defaultDeviceOrgBindingsMetaSchema).map(p=>bn(p,r))),l=await Promise.all((t.lockRenameEdits??e.defaultLockRenameEdits).map(p=>bn(p,r)));n&&o==="Zephyr"&&(!s||s.length===0)&&(s=["./zephyr/dts/bindings"]);let u=t.dtsFile,d=t.overlays??[],f=t.compileCommands;return n&&(s=s.map(p=>(0,Xt.resolve)(n,p)).filter(p=>(0,vS.existsSync)(p)),a=a?.map(p=>(0,Xt.resolve)(n,p)),c=c.map(p=>(0,Xt.resolve)(n,p)),i=i.map(p=>(0,Xt.resolve)(n,p)),u=(0,Xt.resolve)(n,u),d=d.map(p=>(0,Xt.resolve)(n,p)),l=l.map(p=>(0,Xt.resolve)(n,p)),f=f?(0,Xt.resolve)(n,f):void 0),{ctxName:t.ctxName??(0,Xt.basename)(u),cwd:n?tt(n):void 0,includePaths:i.map(tt),zephyrBindings:s.map(tt),bindingType:o,deviceOrgTreeBindings:a.map(tt),deviceOrgBindingsMetaSchema:c.map(tt),dtsFile:tt(u),overlays:d.map(tt),lockRenameEdits:l.map(tt),compileCommands:f?tt(f):void 0}},gu=async(t,e)=>{let r=t.cwd?await bn(t.cwd,e):void 0,n=t.defaultBindingType,i=t.defaultDeviceOrgBindingsMetaSchema=await Promise.all((t.defaultDeviceOrgBindingsMetaSchema??[]).map(d=>bn(d,e))),s=t.defaultDeviceOrgTreeBindings=await Promise.all((t.defaultDeviceOrgTreeBindings??[]).map(d=>bn(d,e))),o=t.defaultIncludePaths=await Promise.all((t.defaultIncludePaths??[]).map(d=>bn(d,e))),a=t.defaultZephyrBindings=await Promise.all((t.defaultZephyrBindings??[]).map(d=>bn(d,e))),c=t.defaultLockRenameEdits=await Promise.all((t.defaultLockRenameEdits??[]).map(d=>bn(d,e)));r&&(o=t.defaultIncludePaths=(t.defaultIncludePaths??[]).map(d=>(0,Xt.resolve)(r,d)),n==="Zephyr"&&!t.defaultZephyrBindings&&(a=["./zephyr/dts/bindings"]),a=a.map(d=>(0,Xt.resolve)(r,d)),i=i.map(d=>(0,Xt.resolve)(r,d)),s=(t.defaultDeviceOrgTreeBindings??[]).map(d=>(0,Xt.resolve)(r,d)),c=c.map(d=>(0,Xt.resolve)(r,d)));let l={cwd:r,defaultDeviceOrgBindingsMetaSchema:i,defaultDeviceOrgTreeBindings:s,defaultIncludePaths:o,defaultZephyrBindings:a,defaultLockRenameEdits:c,defaultBindingType:n,autoChangeContext:t.autoChangeContext??ho.autoChangeContext,allowAdhocContexts:t.allowAdhocContexts??ho.allowAdhocContexts},u=(await Promise.all(t.contexts?.map(d=>TS(d,l,e))??[])).filter(d=>[d.dtsFile,...d.overlays].every(f=>(0,vS.existsSync)(f)&&Xt.default.isAbsolute(f)));return{...l,contexts:u}};var W$=t=>`DT_PROP(${bS(t.parent)}, ${t.name.replaceAll("-","_")}))`,G$=t=>t.parent.labels.map(e=>`DT_PROP(DT_NODELABEL(${e.label.toString()}), ${t.name.replaceAll("-","_")})`);var bS=t=>`DT_PATH(${t.path.slice(1).map(e=>e.replace("@","_").replaceAll("-","_")).join(",")})`,Y$=t=>t.labels.map(e=>`DT_NODELABEL(${e.label.toString()})`),K$=t=>{let e=[];return Qn.getNodeFromPath(["aliases"],t.root)?.properties.filter(i=>{if(i.ast.quickValues?.at(0)===t.pathString)return!0;let s=i.ast.values?.values.at(0)?.value;if(s instanceof se&&s.linksTo===t||s instanceof nt&&s.path?.pathParts.at(-1)?.linksTo===t)return!0})?.forEach(i=>e.push(`DT_ALIAS(${i.name.replaceAll("-","_")})`)),e};function gJ(t,e){if(!t||!(t.item instanceof Ke)||!(t.ast instanceof Qe))return[];let r=[];return e.settings.bindingType==="Zephyr"&&(r.push({type:"dt_zephyr_macro_prop_node_path",data:W$(t.item)}),G$(t.item).forEach(n=>{r.push({type:"dt_zephyr_macro_prop_node_label",data:n})})),r}function yJ(t,e){if(!t||t.item===null)return[];let r;if(t.item instanceof J?r=t.item:t.ast.parentNode instanceof se&&t.ast.parentNode.linksTo?r=t.ast.parentNode.linksTo:t.ast instanceof He&&t.ast.linksTo&&(r=t.ast.linksTo),!r)return[];let n=[{type:"path",data:r.pathString}];return e.settings.bindingType==="Zephyr"&&(Y$(r).forEach(i=>{n.push({type:"dt_zephyr_macro_node_label",data:i})}),n.push({type:"dt_zephyr_macro_node_path",data:bS(r)}),K$(r).forEach(i=>{n.push({type:"dt_zephyr_macro_prop_node_alias",data:i})})),n}async function X$(t,e){return e?_t(t,e,r=>[...yJ(r,e),...gJ(r,e)]):[]}var J$=L(j());function vJ(t){return!t||!(t.item instanceof Ke)?void 0:t.item.parent.nodeType?.getSignatureHelp?.(t.item,t.ast,t.beforeAst,t.afterAst)}async function TJ(t){let e=yc(t?.ast);if(!e||!e.params.length||!t?.ast||t.ast===e.functionName)return;let n=(await t.runtime.context.getAllParsers()).at(-1).cPreprocessorParser.macros.get(e.functionName.name)?.macro.identifier;if(!n||!(n instanceof Jn))return;let i=n.params.map(o=>({label:o instanceof Ct?o.name:"..."})),s=e.params.find(o=>o&&(t.ast===o||o.isAncestorOf(t.ast)));return s??=t.afterAst?e.params.find(o=>o&&(t.afterAst===o||o.isAncestorOf(t.afterAst))):void 0,s??=t.beforeAst?e.params.find(o=>o&&(t.beforeAst===o||o.isAncestorOf(t.beforeAst))):void 0,{signatures:[J$.SignatureInformation.create(`${e.functionName.name}(${i.map(o=>o.label).join(", ")})`,void 0,...i.flat())],activeSignature:0,activeParameter:s?e.params.indexOf(s):void 0}}async function Q$(t,e){if(e)return(await _t(t,e,async r=>[await TJ(r)||vJ(r)])).at(0)}var Z$=require("timers"),eB=require("events");var _S=class extends eB.EventEmitter{constructor(e=3e3,r=1e3){super(),this.thresholdBytes=e*1024*1024,this.interval=(0,Z$.setInterval)(()=>{let n=process.memoryUsage().heapUsed;n>this.thresholdBytes&&this.emit("thresholdExceeded",{usedMb:(n/1024/1024).toFixed(2),thresholdMb:e})},r)}stop(){clearInterval(this.interval)}},bJ=new _S(3e3),tB=()=>{bJ.on("thresholdExceeded",({usedMb:t,thresholdMb:e})=>{console.warn(`[HeapMonitor] Heap usage exceeded ${e}MB: ${t}MB used`),xw(),Mw()})};var Ve=[],ce,za,Pm=new WeakMap,yu=new Map;tB();var nB=t=>{t.getContextFiles().forEach(e=>{yu.has(e)||yu.set(e,new Nm(e,wS,r=>!!km(r))),yu.get(e)?.watch()})},PS=async t=>{let e=Ve.indexOf(t);if(e===-1)return;wm(t,void 0,!0),Pm.delete(t),console.log(`(ID: ${t.id}) cleaning Context for [${t.ctxNames.join(",")}]`);let r=await Cs(t);if(ne.sendNotification("devicetree/contextDeleted",{ctxNames:t.ctxNames.map(n=>n.toString()),id:t.id,...await t.getFileTree(),settings:t.settings,active:ce===t,type:r.type}),Ve.splice(e,1),await ES(),t===ce&&(ce=void 0,Ve.length)){let n=za?sn(Ve,{uri:za}):void 0;n??=Ve[0],console.log("Active context was deleted. Forcing active to",n.id),await Jt({id:n.id},!0)}t.getContextFiles().map(n=>yu.get(n)?.unwatch())},_J=t=>{let e=Pm.get(t);if(!e?.abort.signal.aborted)return Promise.all([e?.promise,t.getRuntime()])},$e=async()=>{await Promise.all(Ve.map(_J))},kS=async t=>(await iB()).indexOf(t)!==-1,iB=async()=>{let t=await sB();return Ve.filter(e=>!t.some(r=>r===e))},sB=async()=>{let t=await RS();return Ve.filter(e=>t.contexts.find(r=>bi(r)===e.id))},SJ=async()=>{let t=await wJ();return Ve.filter(e=>t.contexts.find(r=>bi(r)===e.id))},NJ=async t=>(await SJ()).indexOf(t)!==-1,RJ=async(t,e)=>{if(t===e)return!0;let r=(await t.getAllParsers()).flatMap(i=>i.cPreprocessorParser.dtsIncludes).filter(i=>i.resolvedPath),n=(await e.getAllParsers()).flatMap(i=>i.cPreprocessorParser.dtsIncludes).filter(i=>i.resolvedPath);return n.some(i=>de(i.resolvedPath,t.parser.uri))&&r.length?r.every(i=>n.some(s=>s.resolvedPath===i.resolvedPath&&s.firstToken.pos.col===i.firstToken.pos.col&&s.firstToken.pos.len===i.firstToken.pos.len&&s.firstToken.pos.line===i.firstToken.pos.line&&s.lastToken.pos.col===i.lastToken.pos.col&&s.lastToken.pos.len===i.lastToken.pos.len&&s.lastToken.pos.line===i.lastToken.pos.line)):e.getContextFiles().some(i=>de(i,t.parser.uri))},PJ=async t=>{if(!await kS(t))return;let e=await iB(),r=await sB(),n=await af(e);if(Ve.indexOf(t)===-1)return;let i=await Promise.all(n.flatMap(a=>[...r,...e.filter(c=>c!==a.context)].map(async c=>({context:a.context,same:await RJ(a.context,c)})))),s=t.getContextFiles(),o=n.filter(a=>i.some(c=>c.context===a.context&&c.same)||a.context!==t&&de(a.context.parser.uri,t.parser.uri)&&s.some(c=>c&&a.files.indexOf(c)!==-1)).map(a=>a.context);o.length&&await Promise.all(o.map(PS))},ne=(0,lt.createConnection)(lt.ProposedFeatures.all),gr=new lt.TextDocuments(Yi),oB=!1,SS=!1,aB=!1,cB=!1,lB=!1,NS;ne.onInitialize(t=>{NS=t.workspaceFolders??[],ne.console.log(`[Server(${process.pid}) ${NS?.at(0)?.uri} Version 0.5.7 ] Started and initialize received`);let e=t.capabilities;oB=!!(e.workspace&&e.workspace.configuration),SS=!!(e.workspace&&e.workspace.workspaceFolders),aB=!!e.workspace?.diagnostics?.refreshSupport,cB=!!e.workspace?.semanticTokens?.refreshSupport,lB=!!e.workspace?.foldingRange?.refreshSupport;let r={capabilities:{typeDefinitionProvider:!0,workspaceSymbolProvider:!0,textDocumentSync:lt.TextDocumentSyncKind.Incremental,renameProvider:{prepareProvider:!0},completionProvider:{resolveProvider:!0,triggerCharacters:["&","="," ",'"',"(",","]},codeActionProvider:{codeActionKinds:[lt.CodeActionKind.QuickFix,lt.CodeActionKind.SourceFixAll]},documentSymbolProvider:!0,semanticTokensProvider:{legend:{tokenTypes:tf,tokenModifiers:rf},full:!0},documentLinkProvider:{resolveProvider:!1},foldingRangeProvider:!0,definitionProvider:!0,declarationProvider:!0,referencesProvider:!0,documentFormattingProvider:!0,hoverProvider:!0,signatureHelpProvider:{triggerCharacters:["<","("],retriggerCharacters:[" ",","]}}};return SS&&(r.capabilities.workspace={workspaceFolders:{changeNotifications:!0,supported:!0}}),r});ne.onInitialized(()=>{oB&&ne.client.register(lt.DidChangeConfigurationNotification.type,{}),SS&&ne.workspace.onDidChangeWorkspaceFolders(async t=>{ne.console.log("Workspace folder change event received"),await _u()})});var kJ=async()=>{let t=uB();return t={...ho,...t},gu(t,await bu())},RS=async()=>{let t=CJ();return t={...ho,...t},gu(t,await bu())},wJ=async()=>{let t=DJ();return t={...ho,...t},gu(t,await bu())},Tu=async()=>{let t=EJ();return t={...ho,...t},gu(t,await bu())},bu=async()=>(await ne.workspace.getWorkspaceFolders()??NS)?.map(e=>Ae(e.uri))?.at(0),rB=async t=>{let e=sn(Ve,{id:bi(t)});if(e)return e.ctxNames.includes(t.ctxName)||console.log(`(ID: ${e.id}) Adding name ${t.ctxName} for [${e.ctxNames.join(",")}]`),e.addCtxName(t.ctxName),e;let r=bi(t);console.log(`(ID: ${r}) New context [${t.ctxName}]`),console.log(`(ID: ${r}) Settings: ${JSON.stringify(t,void 0," ")}`);let n=(0,Ga.join)((0,Ga.dirname)(t.dtsFile),"dts","bindings"),i=new Mf(t,t.bindingType?j$({zephyrBindings:t.zephyrBindings?[n,...t.zephyrBindings]:[n],deviceOrgBindingsMetaSchema:t.deviceOrgBindingsMetaSchema??[],deviceOrgTreeBindings:t.deviceOrgTreeBindings??[]},t.bindingType):void 0);Ve.push(i),await i.stable(),nB(i);let s=await Cs(i);return ne.sendNotification("devicetree/contextCreated",{ctxNames:i.ctxNames.map(o=>o.toString()),id:i.id,...await i.getFileTree(),settings:i.settings,active:i===ce,type:s.type}),await PJ(i),await ES(),i},_u=async()=>{let t=await RS(),e=await Tu();e.allowAdhocContexts||(e=await RS());let r=e.contexts.map(bi),n=Ve.filter(i=>!r.includes(i.id));await Promise.all(n.map(PS)),await t.contexts?.reduce((i,s)=>i.then(async()=>{await rB(s)}),Promise.resolve()),e.allowAdhocContexts&&await(await kJ()).contexts?.reduce((s,o)=>s.then(async()=>{sn(Ve,{uri:o.dtsFile})||await rB(o)}),Promise.resolve()),za?await Jt({uri:za}):!ce&&Ve.length&&(console.log(`No active context using first context (ID: ${Ve[0].id}) [${Ve[0].ctxNames.join(",")}]`),await Jt({id:Ve[0].id}))},_n,Es,vu=new Map,Va=new Map,EJ=()=>!Es&&!_n?void 0:{...Es,..._n,contexts:[..._n?.contexts??[],...Array.from(Va.values()),...Array.from(vu.values())]},uB=()=>!Es&&!_n?void 0:{...Es,..._n,contexts:[...Array.from(vu.values())]},CJ=()=>!Es&&!_n?void 0:{...Es,..._n,contexts:[..._n?.contexts??[],...Array.from(Va.values())]},DJ=()=>!Es&&!_n?void 0:{..._n,contexts:[..._n?.contexts??[]]};function AJ(t){let e={...t};for(let r in e)e[r]===null&&delete e[r];return e}var dB=async()=>{let t=await Tu();console.log("Resolved settings",JSON.stringify(t,void 0," ")),ne.sendNotification("devicetree/settingsChanged",t),await _u(),$e().then(()=>{aB&&ne.languages.diagnostics.refresh()})},IJ=async()=>{let t=ce?.getContextFiles();await Promise.all(Array.from(gr.keys()).filter(Ft).map(async e=>{t?.some(r=>de(r,Ae(e)))||await ne.sendDiagnostics({uri:e,version:gr.get(e)?.version,diagnostics:[{severity:lt.DiagnosticSeverity.Information,range:lt.Range.create(lt.Position.create(0,0),lt.Position.create(0,0)),message:"File not in active context",source:"devicetree"}]})}))},wS=async t=>{let e=Oy(Ve,t);if(e.length)e.sort((r,n)=>r===ce?-1:n===ce?1:0).forEach(r=>{Pm.get(r)?.abort.abort();let n=new AbortController,i=new Promise(s=>{setTimeout(async()=>{if(n.signal.aborted){s();return}let o=performance.now(),a=ce===r,c=a?fB(r):[],l=r.getContextFiles();await r.reevaluate(t),nB(r),l.forEach(u=>yu.get(u)?.unwatch()),a&&CS(r)?.length&&Em(r).then(u=>{let d=u.items.map(f=>({uri:f.uri,version:f.version??void 0,diagnostics:f.items}));wm(r,c.filter(f=>d.every(p=>p.uri!==f.uri))),d.forEach(f=>{ne.sendDiagnostics(f)}),Wa.set(r,!0)}),r.serialize().then(async u=>{let[d,f]=await Promise.all([Cs(r),r.getFileTree()]),p={node:u,ctx:{ctxNames:r.ctxNames.map(g=>g.toString()),id:r.id,...f,settings:r.settings,active:a,type:d.type}};ce===r&&ne.sendNotification("devicetree/activeContextStableNotification",p),ne.sendNotification("devicetree/contextStableNotification",p)}),s(),console.log("reevaluate",performance.now()-o)},50)});Pm.set(r,{abort:n,promise:i})});else{if((await Tu()).allowAdhocContexts===!1)return;await _u(),await Jt({uri:t})}},OJ=t=>gr.keys().find(e=>de(Ae(e),t)),km=t=>{let e=OJ(t);if(e)return gr.get(e)},fB=t=>t.getContextFiles().map(e=>({uri:ve(e),version:km(e)?.version,diagnostics:[]})),Wa=new WeakMap,wm=async(t,e=fB(t),r=!1)=>{if(!r&&t!==ce)return;let n=performance.now();await Promise.all(e.filter(i=>t===ce||!ce?.getContextFiles().some(s=>de(Ae(i.uri),s))).map(i=>ne.sendDiagnostics({uri:i.uri,version:gr.get(i.uri)?.version,diagnostics:[]}))),Wa.delete(t),console.log(`(ID: ${t.id})`,"clear workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-n)},Em=async t=>{await t.stable();let e=performance.now(),r=await t.getDiagnostics(),n=t.getContextFiles().map(i=>({uri:ve(i),kind:lt.DocumentDiagnosticReportKind.Full,items:r.get(i)??[],version:km(i)?.version??null}));return console.log(`(ID: ${t.id})`,"workspace diagnostics",`[${t.ctxNames.join(",")}]`,performance.now()-e),{items:[...n]}},ES=async()=>{let t=await Promise.all(Ve.map(Cs));console.log("======== Context List ========"),t.forEach(e=>{console.log(`(ID: ${e.ctx.id}) [${e.ctx.ctxNames.join(",")}]`,`[${e.type}]`,ce===e.ctx?" [ACTIVE]":"")}),console.log("==============================")},Cs=async t=>{let e=await kS(t),r=!e&&await NJ(t);return{ctx:t,type:e?"Ad Hoc":r?"User":"3rd Party"}},Jt=async(t,e=!1)=>{if("uri"in t){if(!Ft(t.uri))return!1;za=t.uri,console.log("Active File Uri",za)}let r=await Tu();if(ce&&!e&&!r.autoChangeContext||(await $e(),!e&&ce?.getContextFiles().find(o=>"uri"in t&&de(o,t.uri))))return!1;let n=ce,i=sn(Ve,t),s=n!==i;return s&&(n&&wm(n),ce=i,i?(Cs(i).then(async o=>{let a=await i.getFileTree();!i||i!==ce&&!Ve.includes(i)||ne.sendNotification("devicetree/newActiveContext",{ctxNames:i.ctxNames.map(c=>c.toString()),id:i.id,...a,settings:i.settings,active:ce===i,type:o.type})}),CS(i)?.length&&Em(i).then(o=>{o.items.map(a=>({uri:a.uri,version:a.version??void 0,diagnostics:a.items})).forEach(a=>{ne.sendDiagnostics(a)})}).finally(()=>Wa.set(i,!0)),await ES()):ne.sendNotification("devicetree/newActiveContext",void 0)),lB&&ne.languages.foldingRange.refresh(),cB&&ne.languages.semanticTokens.refresh(),s},Ft=t=>[".dts",".dtsi",".dtso",".overlay"].some(e=>t.endsWith(e));gr.listen(ne);var CS=t=>t?.getContextFiles()?.filter(e=>km(e));gr.onDidClose(async t=>{let e=Ae(t.document.uri);if(!Ft(e))return;let r=Oy(Ve,e);if(r.length===0){vu.delete(e),ne.sendDiagnostics({uri:t.document.uri,version:gr.get(t.document.uri)?.version,diagnostics:[]});return}await Promise.all(r.map(async n=>{!!CS(n)?.filter(s=>s!==e).length?ce?.getContextFiles().some(s=>de(s,e))||ne.sendDiagnostics({uri:t.document.uri,version:gr.get(t.document.uri)?.version,diagnostics:[]}):await kS(n)?(await PS(n),vu.delete(n.settings.dtsFile)):wm(n)}))});gr.onDidOpen(async t=>{let e=Ae(t.document.uri);if(!Ft(e))return;await $e(),IJ();let r=sn(Ve,{uri:e});if(console.log("onDidOpen",r?.id,e),r)r!==ce?await Jt({id:r.id}):r===ce&&!Wa.get(r)&&Em(r).then(({items:n})=>n.map(i=>({uri:i.uri,version:i.version??void 0,diagnostics:i.items})).forEach(async i=>{ne.sendDiagnostics(i)})).finally(()=>Wa.set(r,!0));else{let n={ctxName:(0,Ga.basename)(e),dtsFile:e};vu.set(e,n),await wS(e)}});gr.onDidChangeContent(async t=>{let e=Ae(t.document.uri);if(!Ft(e))return;let r=t.document.getText(),n=Ar();n.needsRenew(e,r)&&(console.log("Content changed"),n.renewLexer(e,r),await wS(e))});ne.onDidChangeConfiguration(async t=>{t?.settings?.devicetree&&(_n=z$(AJ(t.settings.devicetree)),console.log("Configuration changed",JSON.stringify(t,void 0," ")),await dB())});ne.listen();ne.languages.diagnostics.onWorkspace(async()=>{await $e();let t=ce;return t?Em(t).finally(()=>{Wa.set(t,!0)}):{items:[]}});ne.onDidChangeWatchedFiles(t=>{ne.console.log("We received a file change event")});ne.onCompletion(async t=>{let e=Ae(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&ce&&ce.bindingLoader?.type==="Zephyr")return ZD(t,ce,gr.get(t.textDocument.uri));if(!Ft(e))return[];await $e(),Jt({uri:e});let r=yr(e);return r?[...await LC(t,r),...await gA(t,r)]:[]});ne.onCompletionResolve(t=>t);var yr=t=>{let e=uB();return sn(Ve,{uri:t},ce,e?.preferredContext)};ne.onDocumentSymbol(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return[];await $e();let r=yr(e);return r?r.getUriParser(e)?.getDocumentSymbols(e):[]});ne.onWorkspaceSymbol(async()=>{await $e();let t=ce;return t?(await t.getAllParsers()).flatMap(e=>e.getWorkspaceSymbols()):[]});ne.languages.semanticTokens.on(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return{data:[]};try{await $e();let r=yr(e),n=new lt.SemanticTokensBuilder,i=r?.isInContext(e);return!r||!i?{data:[]}:((await r.getAllParsers()).forEach(s=>s.buildSemanticTokens(n,e)),n.build())}catch(r){throw console.log(r),r}});ne.onDocumentLinks(async t=>{await $e();let e=Ae(t.textDocument.uri);return Ft(e)?yr(e)?.getDocumentLinks(e):e.endsWith(".yaml")&&ce?ce.bindingLoader?.getDocumentLinks?.(gr.get(t.textDocument.uri))??[]:[]});ne.onPrepareRename(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return sA(t,r)});ne.onRenameRequest(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return iA(t,r)});ne.onReferences(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return eA(t,r)});ne.onDefinition(async t=>{let e=Ae(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&ce&&ce.bindingLoader?.type==="Zephyr")return uA(t,ce,gr.get(t.textDocument.uri));if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e),n=(await r?.getDocumentLinks(e,t.position))?.filter(i=>i.target).map(i=>lt.Location.create(i.target,i.range))??[];return n.length?n:cA(t,r)});ne.onDeclaration(async t=>{let e=Ae(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&ce&&ce.bindingLoader?.type==="Zephyr")return fA(t,ce,gr.get(t.textDocument.uri));if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return lA(t,r)});ne.onCodeAction(async t=>{let e=Ae(t.textDocument.uri);if(Ft(e))return hA(t)});ne.onDocumentFormatting(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return r?(await r.getSyntaxIssues(void 0,i=>Ho(i,e,!1))).get(e)?.length?[]:Uy(t,r,Ar().getDocument(e).getText()):[]});ne.onHover(async t=>{let e=Ae(t.textDocument.uri);if((e.endsWith(".c")||e.endsWith(".cpp"))&&ce&&ce.bindingLoader?.type==="Zephyr")return BI(t,ce,gr.get(t.textDocument.uri));if(!Ft(e))return;await $e();let r=yr(e);return(await yA(t,r)).at(0)});ne.onFoldingRanges(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e();let r=yr(e),n=r?.isInContext(e);if(!r||!n)return[];let i=(await r.getAllParsers()).find(s=>s.getFiles().some(o=>o===e));return i?H$(e,i):[]});ne.onTypeDefinition(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return V$(t,r)});ne.onSignatureHelp(async t=>{let e=Ae(t.textDocument.uri);if(!Ft(e))return;await $e(),Jt({uri:e});let r=yr(e);return Q$(t,r)});ne.onRequest("devicetree/getContexts",async()=>(await $e(),Promise.all(Ve.map(async t=>{let e=await Cs(t);return{ctxNames:t.ctxNames.map(r=>r.toString()),id:t.id,...await t.getFileTree(),settings:t.settings,active:ce===t,type:e.type}}))));ne.onRequest("devicetree/setActive",async t=>(await $e(),console.log("devicetree/setActive",t),await Jt(t,!0)));ne.onRequest("devicetree/getActiveContext",async()=>{if(await $e(),console.log("devicetree/getActiveContext"),!ce)return;let t=await Cs(ce);return ce?{ctxNames:ce.ctxNames.map(e=>e.toString()),id:ce.id,...await ce.getFileTree(),settings:ce.settings,active:!0,type:t.type}:void 0});ne.onRequest("devicetree/setDefaultSettings",async t=>{await $e(),Es=t,console.log("Integration Settings",t),await dB()});ne.onRequest("devicetree/requestContext",async t=>{await $e();let e=await Tu(),r=await TS(t,e,await bu());console.log("devicetree/requestContext",r);let n=bi(r),i=Array.from(Va).find(([,a])=>a.ctxName===t.ctxName);if(i){let a=i[0].split(":",1)[0];sn(Ve,{name:t.ctxName.toString()})?.removeCtxName(t.ctxName),console.log(`Removing integration context with ID ${a} and name ${t.ctxName}`),Va.delete(i[0])}Va.set(`${n}:${t.ctxName}`,t),await _u();let s=Ve.find(a=>a.id===n);if(!s)throw new Error("Failed to create context");let o=await Cs(s);return{ctxNames:s.ctxNames.map(a=>a.toString()),id:n,...await s.getFileTree(),settings:s.settings,active:!0,type:o.type}});ne.onRequest("devicetree/removeContext",async({id:t,name:e})=>{await $e(),Va.delete(`${t}:${e}`);let r=sn(Ve,{id:t});if(r){if(r.removeCtxName(e),r.ctxNames.length){console.log("Context will not be deleted as it is still in use by others");return}await _u()}});ne.onRequest("devicetree/compiledDtsOutput",async t=>(await $e(),t?sn(Ve,{id:t})?.toFullString():void 0));ne.onRequest("devicetree/serializedContext",async t=>(await $e(),t?sn(Ve,{id:t})?.serialize():void 0));ne.onRequest("devicetree/activePath",async t=>{if(await $e(),!ce)return;let e=r=>{if(r?.item)return r.item instanceof J?{nodePath:r.item.pathString}:{nodePath:r.item.parent.pathString,propertyName:r.item.name}};return(await _t(t,ce,r=>[e(r)])).at(0)});ne.onRequest("devicetree/customActions",async t=>(await $e(),X$(t,ce)));ne.onRequest("devicetree/activeFileUri",async t=>{await $e(),Jt({uri:t})});var MJ=async(t,e,r)=>{if((await e.getSyntaxIssues(void 0,a=>Ho(a,r,!1))).get(r)?.length)throw new Error("Unable to format. Files has syntax issues.");let i=Ar().getDocument(r),s=await Uy(t,e,i.getText());return s.length===0?void 0:My(i,s)};ne.onRequest("devicetree/formattingText",async t=>{await $e();let e=Ae(t.textDocument.uri),r=yr(e);if(r)return Jt({uri:e}),MJ(t,r,e);let n=Ar().getDocument(e,t.text),i=await Fw(t,n.getText());return i.length===0?n.getText():My(n,i)});ne.onRequest("devicetree/diagnosticIssues",async({uri:t,full:e})=>{await $e();let r=Ae(t);Jt({uri:r});let n=yr(r);if(!n)return[];let i=e?(await n.getDiagnostics()).get(r):(await n.getSyntaxIssues(void 0,s=>Ho(s,r,!!e))).get(r);if(i?.length)return i});ne.onRequest("devicetree/evalMacros",async({macros:t,ctxId:e})=>{await $e();let r=sn(Ve,{id:e});return r?t.map(n=>{let i=nf(n,r.macros),s=Ee(i);return{macro:n,evaluated:typeof s=="number"?s:i}}):[]});