@abco20/btxml-checker 0.1.1 → 0.1.2

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/syntax.js CHANGED
@@ -1,8 +1,8 @@
1
- var b={Error:"error",Warning:"warning",Info:"info"};function Z(e,n,r,i,t="",a,s){return{code:e,severity:n,message:r,uri:t,...i?{range:i}:{},...a?{details:a}:{},...s?{data:s}:{}}}function W(e,n,r){return{line:e,character:n,offset:r}}function h(e,n){return{start:e,end:n}}function C(e,n){return e?e.start.offset<=n&&n<=e.end.offset:!1}function ae(e){let{document:n,diagnostics:r,options:i,partial:t}=e,a=r.some(l=>l.severity===b.Error),s="generic-xml";if(a)s="invalid-xml";else if(n.root){let l=n.root,m=l.children.some(f=>f.kind==="element"&&f.name==="BehaviorTree"),u=l.children.some(f=>f.kind==="element"&&f.name==="TreeNodesModel"),o=l.attributes.some(f=>f.name==="BTCPP_format"&&f.value==="4"),d=l.name==="TreeNodesModel"||l.name==="root"&&!m&&u;i.kind==="model-xml"||d?s="model-document":(l.name==="BehaviorTree"||l.name==="root"&&(o||m)||i.kind==="bt-xml")&&(s="bt-document")}return n.kind=s,n.isBtXml=s==="bt-document"||s==="model-document",!a&&!t?{ok:!0,document:n,diagnostics:r,partial:!1}:{ok:!1,document:n,diagnostics:r,partial:t}}function De(e){if(e.name==="input_port"||e.name==="output_port")return!1;let n=e.children||[],r=n.some(t=>t.kind==="text"&&t.text.trim()!==""),i=n.some(t=>t.kind==="element");return r&&i}function re(e,n){if(e.kind==="element"){De(e)&&n(e);for(let r of e.children||[])re(r,n)}}function S(e,n){let r=0,i=0;for(let t=0;t<Math.min(n,e.length);t++)e[t]===`
2
- `?(r++,i=0):i++;return W(r,i,n)}function ie(e,n,r,i){for(let t=0;t<e.length;t++){if(e[t]!=="&")continue;let a=e.slice(t+1),s=t;if(a.startsWith("amp;")){t+=4;continue}if(a.startsWith("lt;")){t+=3;continue}if(a.startsWith("gt;")){t+=3;continue}if(a.startsWith("quot;")){t+=5;continue}if(a.startsWith("apos;")){t+=5;continue}if(a.startsWith("#")){let d=1;if(a[d]==="x"||a[d]==="X"){d++;let y="";for(;d<a.length&&/[0-9a-fA-F]/.test(a[d]);)y+=a[d],d++;if(d<a.length&&a[d]===";"){d++;let R=e.slice(s,s+1+d),M=S(r,n+s),B=S(r,n+s+R.length);if(y){let _=Number.parseInt(y,16);if(_>0&&_<=1114111&&(_<55296||_>57343)){t+=d-1;continue}i("XML014_INVALID_NUMERIC_ENTITY",b.Error,`invalid numeric XML entity \`${R}\``,M,B,{primaryLabel:"this numeric entity is outside the valid Unicode range",help:"replace it with a valid Unicode code point or normal text"}),t+=d-1;continue}i("XML001_INVALID_SYNTAX",b.Error,`malformed numeric XML entity \`${R}\``,M,B,{primaryLabel:"this entity is incomplete",help:"use a valid numeric entity such as `&#10;` or escape the ampersand as `&amp;`"}),t+=d-1;continue}let k=e.slice(s,s+1+d),N=S(r,n+s),L=S(r,n+s+k.length);i("XML001_INVALID_SYNTAX",b.Error,`malformed numeric XML entity \`${k}\``,N,L,{primaryLabel:"this entity is incomplete",help:"use a valid numeric entity such as `&#10;` or escape the ampersand as `&amp;`"}),t+=d-1;continue}let f="";for(;d<a.length&&/[0-9]/.test(a[d]);)f+=a[d],d++;if(d<a.length&&a[d]===";"){d++;let y=e.slice(s,s+1+d),k=S(r,n+s),N=S(r,n+s+y.length);if(f){let L=Number.parseInt(f,10);if(L>0&&L<=1114111&&(L<55296||L>57343)){t+=d-1;continue}i("XML014_INVALID_NUMERIC_ENTITY",b.Error,`invalid numeric XML entity \`${y}\``,k,N,{primaryLabel:"this numeric entity is outside the valid Unicode range",help:"replace it with a valid Unicode code point or normal text"}),t+=d-1;continue}i("XML001_INVALID_SYNTAX",b.Error,`malformed numeric XML entity \`${y}\``,k,N,{primaryLabel:"this entity is incomplete",help:"use a valid numeric entity such as `&#10;` or escape the ampersand as `&amp;`"}),t+=d-1;continue}let p=e.slice(s,s+1+d),E=S(r,n+s),x=S(r,n+s+p.length);i("XML001_INVALID_SYNTAX",b.Error,`malformed numeric XML entity \`${p}\``,E,x,{primaryLabel:"this entity is incomplete",help:"use a valid numeric entity such as `&#10;` or escape the ampersand as `&amp;`"}),t+=d-1;continue}let l=a.match(/^[a-zA-Z][a-zA-Z0-9]*;/);if(l){let d=`&${l[0]}`,f=S(r,n+s),p=S(r,n+s+d.length);i("XML013_UNKNOWN_ENTITY",b.Error,`unknown XML entity \`${d}\``,f,p,{primaryLabel:"this entity is not one of XML's predefined entities",help:"use one of `&amp;`, `&lt;`, `&gt;`, `&quot;`, `&apos;`, or a valid numeric entity"}),t+=d.length-1;continue}let m=a.match(/^[a-zA-Z][a-zA-Z0-9]*/);if(m){let d=`&${m[0]}`,f=S(r,n+s),p=S(r,n+s+d.length);i("XML001_INVALID_SYNTAX",b.Error,"bare ampersand in XML content",f,p,{primaryLabel:"escape `&` as `&amp;`",help:"replace `&` with `&amp;` unless this is a valid XML entity"}),t+=d.length-1;continue}let u=S(r,n+s),o=S(r,n+s+1);i("XML001_INVALID_SYNTAX",b.Error,"bare ampersand in XML content",u,o,{primaryLabel:"escape `&` as `&amp;`",help:"replace `&` with `&amp;` unless this is a valid XML entity"})}}function j(e){return e.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&#x([0-9a-fA-F]+);/g,(n,r)=>{let i=Number.parseInt(r,16);return i<=0||i>1114111||i>=55296&&i<=57343?n:String.fromCodePoint(i)}).replace(/&#([0-9]+);/g,(n,r)=>{let i=Number.parseInt(r,10);return i<=0||i>1114111||i>=55296&&i<=57343?n:String.fromCodePoint(i)})}function se(e){let n="",r=[0];for(let i=0;i<e.length;){let t=Le(e,i);if(!t){n+=e[i]??"",i+=1,r.push(i);continue}n+=t.value,i=t.end,r.push(i)}return{value:n,offsets:r}}function Le(e,n){let r=e.slice(n);if(r.startsWith("&quot;")||r.startsWith("&apos;")||r.startsWith("&lt;")||r.startsWith("&gt;")||r.startsWith("&amp;")){let s=r.startsWith("&quot;")?"&quot;":r.startsWith("&apos;")?"&apos;":r.startsWith("&lt;")?"&lt;":r.startsWith("&gt;")?"&gt;":"&amp;";return{value:j(s),end:n+s.length}}let t=/^&#x([0-9a-fA-F]+);/.exec(r);if(t){let s=t[0];return{value:j(s),end:n+s.length}}let a=/^&#([0-9]+);/.exec(r);if(a){let s=a[0];return{value:j(s),end:n+s.length}}}function le(e){return W(e.line,e.character,e.offset)}function ke(e){return!!e&&/[A-Za-z_:]/.test(e||"")}function Ae(e){return!!e&&/[A-Za-z0-9_.:\-]/.test(e||"")}function Ne(e){return e===" "||e===" "||e===`
3
- `||e==="\r"}function Be(e){let n=e.codePointAt(0);return n!==void 0&&n<32&&e!==" "&&e!==`
4
- `&&e!=="\r"}function z(e,n={}){let r=[],i=n.mode==="tolerant",t={uri:n.uri||"",path:n.path,kind:"generic-xml",isBtXml:!1,xmlDeclaration:void 0,root:void 0,nodes:[],diagnostics:r,originalText:e},a=0,s=0,l=0,m=[],u=!1;function o(){return W(s,l,a)}function d(){return a>=e.length}function f(c=0){return e[a+c]}function p(c=1){for(let v=0;v<c;v+=1)e[a++]===`
5
- `?(s+=1,l=0):l+=1}function E(){for(;!d()&&Ne(f());)p()}let x=(c,v,T,X,g,D)=>{r.push(Z(c,v,T,h(X,g),t.uri,D))};function y(c,v,T,X,g,D){r.push(Z(c,v,T,X&&g?h(X,g):void 0,t.uri,D))}function k(){if(!ke(f()))return"";let c=a;for(p();!d()&&Ae(f());)p();return e.slice(c,a)}function N(){let c=f();if(c!=='"'&&c!=="'")return{value:"",ok:!1};let v=o();p();let T=o(),X=a;for(;!d()&&f()!==c&&f()!=="<";)p();let g=o();if(d()||f()!==c)return{value:e.slice(X,a),ok:!1,valueRange:h(v,g),valueContentRange:h(T,g)};let D=e.slice(X,a);p(),ie(D,T.offset,e,x);let I=se(D);return{value:I.value,valueOffsets:I.offsets,ok:!0,valueRange:h(v,o()),valueContentRange:h(T,g)}}function L(){let c=[],v=new Set;for(;;){E();let T=f();if(!T||T===">"||T==="/"&&f(1)===">")break;let X=o(),g=k(),D=o();if(!g)break;E();let I=o();if(f()!=="="){if(x("XML001_INVALID_SYNTAX",b.Error,"invalid attribute syntax",X,D,{primaryLabel:`expected \`=\` after attribute \`${g}\``,help:`write the attribute as \`${g}="..."\``}),u=!0,i)continue;break}p();let Re=o();E();let ne=o(),w=N(),$=o();if(!w.ok&&(x("XML005_INVALID_ATTRIBUTE_VALUE",b.Error,"invalid attribute value",ne,$,{primaryLabel:"expected a quoted attribute value",help:`write the value with quotes, for example \`${g}="value"\``}),u=!0,!i)||(v.has(g)?x("XML004_DUPLICATE_ATTRIBUTE",b.Error,`duplicate attribute \`${g}\``,X,$,{primaryLabel:`attribute \`${g}\` is already defined on this element`,help:`remove one of the duplicate \`${g}\` attributes`}):v.add(g),c.push({name:g,value:w.value,...w.valueOffsets?{valueOffsets:w.valueOffsets}:{},range:h(X,$),fullRange:h(X,$),nameRange:h(X,D),equalsRange:h(I,Re),valueRange:w.valueRange||h(ne,$),valueContentRange:w.valueContentRange||h(ne,$)}),!w.ok&&i))break}return c}function R(c){m.length>0?m[m.length-1].children.push(c):(t.nodes.push(c),!t.root&&c.kind==="element"&&(t.root=c))}function M(){let c=o(),v=a;for(;!d()&&f()!=="<";)p();let T=e.slice(v,a);if(T.length===0)return;for(let g of T)if(Be(g)){x("XML007_INVALID_CHARACTER",b.Error,"invalid XML character",c,o(),{primaryLabel:"this control character is not allowed in XML",help:"remove the character or replace it with valid text"});break}ie(T,v,e,x);let X={kind:"text",text:j(T),range:h(c,o()),fullRange:h(c,o())};R(X)}function B(){let c=o();p(4);let v=o(),T=a;for(;!d()&&!(f()==="-"&&f(1)==="-"&&f(2)===">");)p();let X=e.slice(T,a);if(d()){if(x("XML001_INVALID_SYNTAX",b.Error,"unterminated XML comment",c,o(),{primaryLabel:"comment started here but no closing `-->` was found",help:"close the comment with `-->`"}),u=!0,!i)return;let I={kind:"comment",text:X,range:h(c,o()),fullRange:h(c,o()),contentRange:h(v,o())};R(I);return}(X.includes("--")||X.endsWith("-"))&&x("XML001_INVALID_SYNTAX",b.Error,"invalid XML comment",v,o(),{primaryLabel:"XML comments cannot contain `--`",help:"remove `--` from the comment body or split it into separate comments"});let g=o();p(3);let D={kind:"comment",text:X,range:h(c,o()),fullRange:h(c,o()),contentRange:h(v,g)};R(D)}function _(){let c=o();p(5),E();let v=L();E(),f()==="?"&&f(1)===">"?p(2):x("XML001_INVALID_SYNTAX",b.Error,"invalid XML declaration",c,o(),{primaryLabel:"expected `?>` to close the XML declaration",help:'close the declaration as `<?xml version="1.0" encoding="UTF-8"?>`'});let T={range:h(c,o()),attributes:v};for(let X of v)X.name==="version"&&(T.version=X.value),X.name==="encoding"&&(T.encoding=X.value),X.name==="standalone"&&(T.standalone=X.value);t.xmlDeclaration=T}function F(){let c=o();p(2),E();let v=o(),T=k(),X=o();if(E(),f()!==">")for(x("XML001_INVALID_SYNTAX",b.Error,"invalid closing tag syntax",c,o(),{primaryLabel:"expected `>` to close the tag",help:"close the tag with `>`"}),u=!0;!d()&&f()!==">";)p();f()===">"&&p();let g=m.pop();if(!g||g.name!==T){let D=g?g.name:T||"",I=T||"";x("XML006_MISSING_CLOSING_TAG",b.Error,`mismatched closing tag \`</${I}>\``,c,o(),{primaryLabel:`opened as \`<${D}>\` but closed as \`</${I}>\``,help:`change the closing tag to \`</${D}>\` or fix the nesting`});return}g.closeTagRange=h(c,o()),g.endTagRange=h(c,o()),g.nameRange||(g.nameRange=h(v,X)),g.range=h(g.range.start,o()),g.fullRange=h(g.range.start,o())}for(;!d();)if(f()==="<")if(f(1)==="?")if(e.slice(a,a+5).toLowerCase()==="<?xml"&&e.charAt(a+5)===" ")_();else{let c=o();for(;!d()&&!(f()==="?"&&f(1)===">");)p();d()||p(2),x("XML012_UNSUPPORTED_PROCESSING_INSTRUCTION",b.Error,"processing instruction is not supported",c,o(),{primaryLabel:"only the XML declaration is supported",help:"remove this processing instruction"})}else if(f(1)==="!"&&f(2)==="-"&&f(3)==="-")B();else if(f(1)==="!"&&f(2)==="["&&e.slice(a+3,a+9)==="CDATA["){let c=o();for(p(8);!d()&&!(f()==="]"&&f(1)==="]"&&f(2)===">");)p();d()||p(3),x("XML010_UNSUPPORTED_CDATA",b.Error,"CDATA is not supported",c,o(),{primaryLabel:"CDATA sections are not supported by btxml",help:"replace the CDATA section with normal escaped XML text",notes:["escape `<` as `&lt;`, `>` as `&gt;`, and `&` as `&amp;`"]})}else if(f(1)==="!"&&e.slice(a+2,a+9)==="DOCTYPE"){let c=o();for(p(8);!d()&&f()!==">";)p();d()||p(1),x("XML011_UNSUPPORTED_DOCTYPE",b.Error,"DOCTYPE is not supported",c,o(),{primaryLabel:"DOCTYPE declarations are not supported by btxml",help:"remove the DOCTYPE declaration"})}else if(f(1)==="/")F();else{let c=o();p();let v=o(),T=k(),X=o();if(!T){if(x("XML001_INVALID_SYNTAX",b.Error,"invalid XML tag",c,o(),{primaryLabel:"expected an XML element name after `<`",help:"start the tag with a valid XML name such as `<root>` or `<BehaviorTree>`"}),u=!0,i){p();continue}break}let g={kind:"element",name:T,attributes:[],children:[],range:h(c,c),fullRange:h(c,c),openTagRange:h(c,c),startTagRange:h(c,c),nameRange:h(v,X),selfClosing:!1};if(g.attributes=L(),E(),f()==="/"&&f(1)===">"){p(2),g.selfClosing=!0,g.openTagRange=h(c,o()),g.startTagRange=g.openTagRange,g.range=h(c,o()),g.fullRange=h(c,o()),R(g);continue}if(f()!==">"){if(x("XML001_INVALID_SYNTAX",b.Error,"invalid XML tag",c,o(),{primaryLabel:"expected `>` or `/>` to close the start tag",help:"close the start tag with `>` or make it self-closing with `/>`"}),u=!0,i){g.openTagRange=h(c,o()),g.startTagRange=g.openTagRange,g.range=h(c,o()),g.fullRange=h(c,o()),R(g);continue}break}p(),g.openTagRange=h(c,o()),g.startTagRange=g.openTagRange,g.range=h(c,o()),g.fullRange=h(c,o()),R(g),m.push(g)}else M();if(m.length>0){let c=m[m.length-1];if(x("XML006_MISSING_CLOSING_TAG",b.Error,`missing closing tag for \`<${c.name}>\``,c.openTagRange.start,c.openTagRange.end,{primaryLabel:"this tag is not closed",help:`add \`</${c.name}>\` before the end of the file`}),u=!0,i)for(;m.length>0;){let v=m.pop();if(!v)break;v.range=h(v.range.start,o()),v.fullRange=h(v.range.start,o())}}let O=t.nodes.filter(c=>c.kind==="element");O.length===0?y("XML002_MISSING_ROOT",b.Error,"missing root element",void 0,void 0,{help:'add a single root element, usually `<root BTCPP_format="4">...</root>`'}):O.length>1&&y("XML003_MULTIPLE_ROOTS",b.Error,"multiple root elements",void 0,void 0,{primaryLabel:"this document has more than one top-level element",help:'wrap the document content in one `<root BTCPP_format="4">...</root>` element'});let P=t.root;if(P)for(let c of t.nodes)c!==P&&c.kind==="text"&&c.text.trim().length>0&&x("XML016_TEXT_OUTSIDE_ROOT",b.Error,"text outside root element",c.range.start,c.range.end,{primaryLabel:"non-whitespace text appears outside the root element",help:"move this text inside `<root>` or remove it"});if(!t.xmlDeclaration)y("XML008_MISSING_DECLARATION",b.Warning,"missing XML declaration",void 0,void 0,{help:'add `<?xml version="1.0" encoding="UTF-8"?>` at the top of the file',notes:["this is a warning because BehaviorTree.CPP can still parse many files without a declaration"]});else if(t.xmlDeclaration.encoding&&t.xmlDeclaration.encoding.toUpperCase()!=="UTF-8"){let c=t.xmlDeclaration.encoding;x("XML009_INVALID_ENCODING",b.Warning,"XML encoding should be UTF-8",t.xmlDeclaration.range.start,t.xmlDeclaration.range.end,{primaryLabel:`declared encoding is \`${c}\``,help:'change the XML declaration to `encoding="UTF-8"`'})}return P&&re(P,c=>{x("XML015_UNSUPPORTED_MIXED_CONTENT",b.Warning,"mixed XML content is not supported",le(c.range.start),le(c.range.end),{primaryLabel:"this element contains both text and child elements",help:"move the text into an attribute or split it into separate elements",notes:["text inside `<input_port>` and `<output_port>` remains allowed"]})}),ae({document:t,diagnostics:r,partial:u,options:n})}var Y={indentWidth:2,xmlDeclaration:"always",blankLineBetweenBehaviorTrees:!0,lineEnding:"lf"};function ue(e){if(!e)return Y;let n=typeof e.indentWidth=="number"?e.indentWidth:Y.indentWidth,r=e.xmlDeclaration==="always"||e.xmlDeclaration==="never"||e.xmlDeclaration==="preserve"?e.xmlDeclaration:Y.xmlDeclaration,i=typeof e.blankLineBetweenBehaviorTrees=="boolean"?e.blankLineBetweenBehaviorTrees:Y.blankLineBetweenBehaviorTrees,t=e.lineEnding==="lf"||e.lineEnding==="crlf"||e.lineEnding==="auto"?e.lineEnding:Y.lineEnding;return{indentWidth:n,xmlDeclaration:r,blankLineBetweenBehaviorTrees:i,lineEnding:t}}function G(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function K(e){return G(e).replace(/"/g,"&quot;")}function Ce(e){return e.filter(n=>!(n.kind==="text"&&n.text.trim()===""))}function _e(e,n,r){return`${" ".repeat(e*r)}${n}`}function U(e,n,r,i){let t=" ".repeat(n*i),a=e.attributes||[];if(a.length===0)return[`${t}<${e.name}${r}`];if(a.length===1)return[`${t}<${e.name} ${a[0].name}="${K(a[0].value)}"${r}`];let s=[`${t}<${e.name} ${a[0].name}="${K(a[0].value)}"`],l=" ".repeat(t.length+1+e.name.length+1);for(let m=1;m<a.length;m+=1){let u=a[m],o=m===a.length-1?r:"";s.push(`${l}${u.name}="${K(u.value)}"${o}`)}return s}function Q(e,n,r,i){let t=" ".repeat(n*r);if(e.kind==="comment")return[`${t}<!--${e.text}-->`];if(e.kind==="text"){let o=e.text.trim();return o?[_e(n,G(o),r)]:[]}let a=Ce(e.children||[]),s=e.kind==="element"&&(e.name==="input_port"||e.name==="output_port"),l=(e.children||[]).filter(o=>o.kind==="text").map(o=>o.text).join("").trim(),m=a.some(o=>o.kind==="element"||o.kind==="comment");if(l&&m&&!s&&i.push({code:"XML015_UNSUPPORTED_MIXED_CONTENT",severity:"error",message:"Mixed XML content is not supported by btxml-checker formatter",uri:""}),l&&!m){if((e.attributes||[]).length<=1){let o=(e.attributes||[]).length===0?"":` ${e.attributes[0].name}="${K(e.attributes[0].value)}"`;return[`${t}<${e.name}${o}>${G(l)}</${e.name}>`]}return U(e,n,`>${G(l)}</${e.name}>`,r)}if(a.length===0){if(e.selfClosing)return U(e,n,"/>".slice(0),r);let o=U(e,n,">",r);return o.push(`${t}</${e.name}>`),o}let u=U(e,n,">",r);for(let o of e.children||[])o.kind==="text"&&o.text.trim()===""||u.push(...Q(o,n+1,r,i));return u.push(`${t}</${e.name}>`),u}function Ie(e){return e.filter(n=>!(n.kind==="text"&&n.text.trim()===""))}function ce(e,n,r,i){let t=[],a=Ie(e);for(let s=0;s<a.length;s+=1){let l=a[s],m=a[s-1],u=a[s+1],o=r&&l.kind==="element"&&l.name==="BehaviorTree"&&m&&m.kind==="element"&&m.name==="BehaviorTree",d=l.kind==="element"&&l.name==="TreeNodesModel"&&m!==void 0&&m.kind!=="comment",f=l.kind==="comment"&&u&&u.kind==="element"&&u.name==="TreeNodesModel"&&m!==void 0;(o||d||f)&&t.length>0&&t[t.length-1]!==""&&t.push(""),l.kind==="element"?(t.push(...Q(l,1,n,i)),l.name==="TreeNodesModel"&&t.push("")):t.push(...Q(l,1,n,i))}return t}function me(e,n={}){let r=z(e);if(!r.ok||!r.document||!r.document.root)return{ok:!1,skipped:!1,diagnostics:r.diagnostics};if(r.diagnostics.find(x=>["XML010_UNSUPPORTED_CDATA","XML011_UNSUPPORTED_DOCTYPE","XML012_UNSUPPORTED_PROCESSING_INSTRUCTION","XML013_UNKNOWN_ENTITY","XML014_INVALID_NUMERIC_ENTITY","XML001_INVALID_SYNTAX"].includes(x.code)))return{ok:!1,skipped:!1,diagnostics:r.diagnostics};if(r.document.kind==="generic-xml"&&!n.force)return{ok:!0,skipped:!0,diagnostics:[]};let t=r.document.root,a=ue(n),s=a.indentWidth,l=[],m=r.document.xmlDeclaration!==void 0;if((a.xmlDeclaration==="always"||a.xmlDeclaration==="preserve"&&m)&&l.push('<?xml version="1.0" encoding="UTF-8"?>'),l.push(...U(t,0,">",s)),l.push(...ce(t.children||[],s,a.blankLineBetweenBehaviorTrees,r.diagnostics)),l.push(`</${t.name}>`),r.diagnostics.some(x=>x.code==="XML015_UNSUPPORTED_MIXED_CONTENT"))return{ok:!1,skipped:!1,diagnostics:r.diagnostics};let u=`
1
+ var b={Error:"error",Warning:"warning",Info:"info"};function z(e,n,r,i,t="",a,s){return{code:e,severity:n,message:r,uri:t,...i?{range:i}:{},...a?{details:a}:{},...s?{data:s}:{}}}function W(e,n,r){return{line:e,character:n,offset:r}}function h(e,n){return{start:e,end:n}}function _(e,n){return e?e.start.offset<=n&&n<=e.end.offset:!1}function se(e){let{document:n,diagnostics:r,options:i,partial:t}=e,a=r.some(l=>l.severity===b.Error),s="generic-xml";if(a)s="invalid-xml";else if(n.root){let l=n.root,m=l.children.some(f=>f.kind==="element"&&f.name==="BehaviorTree"),u=l.children.some(f=>f.kind==="element"&&f.name==="TreeNodesModel"),o=l.attributes.some(f=>f.name==="BTCPP_format"&&f.value==="4"),d=l.name==="TreeNodesModel"||l.name==="root"&&!m&&u;i.kind==="model-xml"||d?s="model-document":(l.name==="BehaviorTree"||l.name==="root"&&(o||m)||i.kind==="bt-xml")&&(s="bt-document")}return n.kind=s,n.isBtXml=s==="bt-document"||s==="model-document",!a&&!t?{ok:!0,document:n,diagnostics:r,partial:!1}:{ok:!1,document:n,diagnostics:r,partial:t}}function Le(e){if(e.name==="input_port"||e.name==="output_port")return!1;let n=e.children||[],r=n.some(t=>t.kind==="text"&&t.text.trim()!==""),i=n.some(t=>t.kind==="element");return r&&i}function ie(e,n){if(e.kind==="element"){Le(e)&&n(e);for(let r of e.children||[])ie(r,n)}}function S(e,n){let r=0,i=0;for(let t=0;t<Math.min(n,e.length);t++)e[t]===`
2
+ `?(r++,i=0):i++;return W(r,i,n)}function oe(e,n,r,i){for(let t=0;t<e.length;t++){if(e[t]!=="&")continue;let a=e.slice(t+1),s=t;if(a.startsWith("amp;")){t+=4;continue}if(a.startsWith("lt;")){t+=3;continue}if(a.startsWith("gt;")){t+=3;continue}if(a.startsWith("quot;")){t+=5;continue}if(a.startsWith("apos;")){t+=5;continue}if(a.startsWith("#")){let d=1;if(a[d]==="x"||a[d]==="X"){d++;let y="";for(;d<a.length&&/[0-9a-fA-F]/.test(a[d]);)y+=a[d],d++;if(d<a.length&&a[d]===";"){d++;let R=e.slice(s,s+1+d),I=S(r,n+s),C=S(r,n+s+R.length);if(y){let M=Number.parseInt(y,16);if(M>0&&M<=1114111&&(M<55296||M>57343)){t+=d-1;continue}i("XML014_INVALID_NUMERIC_ENTITY",b.Error,`invalid numeric XML entity \`${R}\``,I,C,{primaryLabel:"this numeric entity is outside the valid Unicode range",help:"replace it with a valid Unicode code point or normal text"}),t+=d-1;continue}i("XML001_INVALID_SYNTAX",b.Error,`malformed numeric XML entity \`${R}\``,I,C,{primaryLabel:"this entity is incomplete",help:"use a valid numeric entity such as `&#10;` or escape the ampersand as `&amp;`"}),t+=d-1;continue}let k=e.slice(s,s+1+d),B=S(r,n+s),L=S(r,n+s+k.length);i("XML001_INVALID_SYNTAX",b.Error,`malformed numeric XML entity \`${k}\``,B,L,{primaryLabel:"this entity is incomplete",help:"use a valid numeric entity such as `&#10;` or escape the ampersand as `&amp;`"}),t+=d-1;continue}let f="";for(;d<a.length&&/[0-9]/.test(a[d]);)f+=a[d],d++;if(d<a.length&&a[d]===";"){d++;let y=e.slice(s,s+1+d),k=S(r,n+s),B=S(r,n+s+y.length);if(f){let L=Number.parseInt(f,10);if(L>0&&L<=1114111&&(L<55296||L>57343)){t+=d-1;continue}i("XML014_INVALID_NUMERIC_ENTITY",b.Error,`invalid numeric XML entity \`${y}\``,k,B,{primaryLabel:"this numeric entity is outside the valid Unicode range",help:"replace it with a valid Unicode code point or normal text"}),t+=d-1;continue}i("XML001_INVALID_SYNTAX",b.Error,`malformed numeric XML entity \`${y}\``,k,B,{primaryLabel:"this entity is incomplete",help:"use a valid numeric entity such as `&#10;` or escape the ampersand as `&amp;`"}),t+=d-1;continue}let p=e.slice(s,s+1+d),E=S(r,n+s),x=S(r,n+s+p.length);i("XML001_INVALID_SYNTAX",b.Error,`malformed numeric XML entity \`${p}\``,E,x,{primaryLabel:"this entity is incomplete",help:"use a valid numeric entity such as `&#10;` or escape the ampersand as `&amp;`"}),t+=d-1;continue}let l=a.match(/^[a-zA-Z][a-zA-Z0-9]*;/);if(l){let d=`&${l[0]}`,f=S(r,n+s),p=S(r,n+s+d.length);i("XML013_UNKNOWN_ENTITY",b.Error,`unknown XML entity \`${d}\``,f,p,{primaryLabel:"this entity is not one of XML's predefined entities",help:"use one of `&amp;`, `&lt;`, `&gt;`, `&quot;`, `&apos;`, or a valid numeric entity"}),t+=d.length-1;continue}let m=a.match(/^[a-zA-Z][a-zA-Z0-9]*/);if(m){let d=`&${m[0]}`,f=S(r,n+s),p=S(r,n+s+d.length);i("XML001_INVALID_SYNTAX",b.Error,"bare ampersand in XML content",f,p,{primaryLabel:"escape `&` as `&amp;`",help:"replace `&` with `&amp;` unless this is a valid XML entity"}),t+=d.length-1;continue}let u=S(r,n+s),o=S(r,n+s+1);i("XML001_INVALID_SYNTAX",b.Error,"bare ampersand in XML content",u,o,{primaryLabel:"escape `&` as `&amp;`",help:"replace `&` with `&amp;` unless this is a valid XML entity"})}}function j(e){return e.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&#x([0-9a-fA-F]+);/g,(n,r)=>{let i=Number.parseInt(r,16);return i<=0||i>1114111||i>=55296&&i<=57343?n:String.fromCodePoint(i)}).replace(/&#([0-9]+);/g,(n,r)=>{let i=Number.parseInt(r,10);return i<=0||i>1114111||i>=55296&&i<=57343?n:String.fromCodePoint(i)})}function le(e){let n="",r=[0];for(let i=0;i<e.length;){let t=ke(e,i);if(!t){n+=e[i]??"",i+=1,r.push(i);continue}n+=t.value,i=t.end,r.push(i)}return{value:n,offsets:r}}function ke(e,n){let r=e.slice(n);if(r.startsWith("&quot;")||r.startsWith("&apos;")||r.startsWith("&lt;")||r.startsWith("&gt;")||r.startsWith("&amp;")){let s=r.startsWith("&quot;")?"&quot;":r.startsWith("&apos;")?"&apos;":r.startsWith("&lt;")?"&lt;":r.startsWith("&gt;")?"&gt;":"&amp;";return{value:j(s),end:n+s.length}}let t=/^&#x([0-9a-fA-F]+);/.exec(r);if(t){let s=t[0];return{value:j(s),end:n+s.length}}let a=/^&#([0-9]+);/.exec(r);if(a){let s=a[0];return{value:j(s),end:n+s.length}}}function ue(e){return W(e.line,e.character,e.offset)}function Ae(e){return!!e&&/[A-Za-z_:]/.test(e||"")}function Ne(e){return!!e&&/[A-Za-z0-9_.:\-]/.test(e||"")}function Be(e){return e===" "||e===" "||e===`
3
+ `||e==="\r"}function Ce(e){let n=e.codePointAt(0);return n!==void 0&&n<32&&e!==" "&&e!==`
4
+ `&&e!=="\r"}function G(e,n={}){let r=[],i=n.mode==="tolerant",t={uri:n.uri||"",path:n.path,kind:"generic-xml",isBtXml:!1,xmlDeclaration:void 0,root:void 0,nodes:[],diagnostics:r,originalText:e},a=0,s=0,l=0,m=[],u=!1;function o(){return W(s,l,a)}function d(){return a>=e.length}function f(c=0){return e[a+c]}function p(c=1){for(let T=0;T<c;T+=1)e[a++]===`
5
+ `?(s+=1,l=0):l+=1}function E(){for(;!d()&&Be(f());)p()}let x=(c,T,v,X,g,D)=>{r.push(z(c,T,v,h(X,g),t.uri,D))};function y(c,T,v,X,g,D){r.push(z(c,T,v,X&&g?h(X,g):void 0,t.uri,D))}function k(){if(!Ae(f()))return"";let c=a;for(p();!d()&&Ne(f());)p();return e.slice(c,a)}function B(){let c=f();if(c!=='"'&&c!=="'")return{value:"",ok:!1};let T=o();p();let v=o(),X=a;for(;!d()&&f()!==c&&f()!=="<";)p();let g=o();if(d()||f()!==c)return{value:e.slice(X,a),ok:!1,valueRange:h(T,g),valueContentRange:h(v,g)};let D=e.slice(X,a);p(),oe(D,v.offset,e,x);let P=le(D);return{value:P.value,valueOffsets:P.offsets,ok:!0,valueRange:h(T,o()),valueContentRange:h(v,g)}}function L(){let c=[],T=new Set;for(;;){E();let v=f();if(!v||v===">"||v==="/"&&f(1)===">")break;let X=o(),g=k(),D=o();if(!g)break;E();let P=o();if(f()!=="="){if(x("XML001_INVALID_SYNTAX",b.Error,"invalid attribute syntax",X,D,{primaryLabel:`expected \`=\` after attribute \`${g}\``,help:`write the attribute as \`${g}="..."\``}),u=!0,i)continue;break}p();let De=o();E();let re=o(),w=B(),$=o();if(!w.ok&&(x("XML005_INVALID_ATTRIBUTE_VALUE",b.Error,"invalid attribute value",re,$,{primaryLabel:"expected a quoted attribute value",help:`write the value with quotes, for example \`${g}="value"\``}),u=!0,!i)||(T.has(g)?x("XML004_DUPLICATE_ATTRIBUTE",b.Error,`duplicate attribute \`${g}\``,X,$,{primaryLabel:`attribute \`${g}\` is already defined on this element`,help:`remove one of the duplicate \`${g}\` attributes`}):T.add(g),c.push({name:g,value:w.value,...w.valueOffsets?{valueOffsets:w.valueOffsets}:{},range:h(X,$),fullRange:h(X,$),nameRange:h(X,D),equalsRange:h(P,De),valueRange:w.valueRange||h(re,$),valueContentRange:w.valueContentRange||h(re,$)}),!w.ok&&i))break}return c}function R(c){m.length>0?m[m.length-1].children.push(c):(t.nodes.push(c),!t.root&&c.kind==="element"&&(t.root=c))}function I(){let c=o(),T=a;for(;!d()&&f()!=="<";)p();let v=e.slice(T,a);if(v.length===0)return;for(let g of v)if(Ce(g)){x("XML007_INVALID_CHARACTER",b.Error,"invalid XML character",c,o(),{primaryLabel:"this control character is not allowed in XML",help:"remove the character or replace it with valid text"});break}oe(v,T,e,x);let X={kind:"text",text:j(v),range:h(c,o()),fullRange:h(c,o())};R(X)}function C(){let c=o();p(4);let T=o(),v=a;for(;!d()&&!(f()==="-"&&f(1)==="-"&&f(2)===">");)p();let X=e.slice(v,a);if(d()){if(x("XML001_INVALID_SYNTAX",b.Error,"unterminated XML comment",c,o(),{primaryLabel:"comment started here but no closing `-->` was found",help:"close the comment with `-->`"}),u=!0,!i)return;let P={kind:"comment",text:X,range:h(c,o()),fullRange:h(c,o()),contentRange:h(T,o())};R(P);return}(X.includes("--")||X.endsWith("-"))&&x("XML001_INVALID_SYNTAX",b.Error,"invalid XML comment",T,o(),{primaryLabel:"XML comments cannot contain `--`",help:"remove `--` from the comment body or split it into separate comments"});let g=o();p(3);let D={kind:"comment",text:X,range:h(c,o()),fullRange:h(c,o()),contentRange:h(T,g)};R(D)}function M(){let c=o();p(5),E();let T=L();E(),f()==="?"&&f(1)===">"?p(2):x("XML001_INVALID_SYNTAX",b.Error,"invalid XML declaration",c,o(),{primaryLabel:"expected `?>` to close the XML declaration",help:'close the declaration as `<?xml version="1.0" encoding="UTF-8"?>`'});let v={range:h(c,o()),attributes:T};for(let X of T)X.name==="version"&&(v.version=X.value),X.name==="encoding"&&(v.encoding=X.value),X.name==="standalone"&&(v.standalone=X.value);t.xmlDeclaration=v}function F(){let c=o();p(2),E();let T=o(),v=k(),X=o();if(E(),f()!==">")for(x("XML001_INVALID_SYNTAX",b.Error,"invalid closing tag syntax",c,o(),{primaryLabel:"expected `>` to close the tag",help:"close the tag with `>`"}),u=!0;!d()&&f()!==">";)p();f()===">"&&p();let g=m.pop();if(!g||g.name!==v){let D=g?g.name:v||"",P=v||"";x("XML006_MISSING_CLOSING_TAG",b.Error,`mismatched closing tag \`</${P}>\``,c,o(),{primaryLabel:`opened as \`<${D}>\` but closed as \`</${P}>\``,help:`change the closing tag to \`</${D}>\` or fix the nesting`});return}g.closeTagRange=h(c,o()),g.endTagRange=h(c,o()),g.nameRange||(g.nameRange=h(T,X)),g.range=h(g.range.start,o()),g.fullRange=h(g.range.start,o())}for(;!d();)if(f()==="<")if(f(1)==="?")if(e.slice(a,a+5).toLowerCase()==="<?xml"&&e.charAt(a+5)===" ")M();else{let c=o();for(;!d()&&!(f()==="?"&&f(1)===">");)p();d()||p(2),x("XML012_UNSUPPORTED_PROCESSING_INSTRUCTION",b.Error,"processing instruction is not supported",c,o(),{primaryLabel:"only the XML declaration is supported",help:"remove this processing instruction"})}else if(f(1)==="!"&&f(2)==="-"&&f(3)==="-")C();else if(f(1)==="!"&&f(2)==="["&&e.slice(a+3,a+9)==="CDATA["){let c=o();for(p(8);!d()&&!(f()==="]"&&f(1)==="]"&&f(2)===">");)p();d()||p(3),x("XML010_UNSUPPORTED_CDATA",b.Error,"CDATA is not supported",c,o(),{primaryLabel:"CDATA sections are not supported by btxml",help:"replace the CDATA section with normal escaped XML text",notes:["escape `<` as `&lt;`, `>` as `&gt;`, and `&` as `&amp;`"]})}else if(f(1)==="!"&&e.slice(a+2,a+9)==="DOCTYPE"){let c=o();for(p(8);!d()&&f()!==">";)p();d()||p(1),x("XML011_UNSUPPORTED_DOCTYPE",b.Error,"DOCTYPE is not supported",c,o(),{primaryLabel:"DOCTYPE declarations are not supported by btxml",help:"remove the DOCTYPE declaration"})}else if(f(1)==="/")F();else{let c=o();p();let T=o(),v=k(),X=o();if(!v){if(x("XML001_INVALID_SYNTAX",b.Error,"invalid XML tag",c,o(),{primaryLabel:"expected an XML element name after `<`",help:"start the tag with a valid XML name such as `<root>` or `<BehaviorTree>`"}),u=!0,i){p();continue}break}let g={kind:"element",name:v,attributes:[],children:[],range:h(c,c),fullRange:h(c,c),openTagRange:h(c,c),startTagRange:h(c,c),nameRange:h(T,X),selfClosing:!1};if(g.attributes=L(),E(),f()==="/"&&f(1)===">"){p(2),g.selfClosing=!0,g.openTagRange=h(c,o()),g.startTagRange=g.openTagRange,g.range=h(c,o()),g.fullRange=h(c,o()),R(g);continue}if(f()!==">"){if(x("XML001_INVALID_SYNTAX",b.Error,"invalid XML tag",c,o(),{primaryLabel:"expected `>` or `/>` to close the start tag",help:"close the start tag with `>` or make it self-closing with `/>`"}),u=!0,i){g.openTagRange=h(c,o()),g.startTagRange=g.openTagRange,g.range=h(c,o()),g.fullRange=h(c,o()),R(g);continue}break}p(),g.openTagRange=h(c,o()),g.startTagRange=g.openTagRange,g.range=h(c,o()),g.fullRange=h(c,o()),R(g),m.push(g)}else I();if(m.length>0){let c=m[m.length-1];if(x("XML006_MISSING_CLOSING_TAG",b.Error,`missing closing tag for \`<${c.name}>\``,c.openTagRange.start,c.openTagRange.end,{primaryLabel:"this tag is not closed",help:`add \`</${c.name}>\` before the end of the file`}),u=!0,i)for(;m.length>0;){let T=m.pop();if(!T)break;T.range=h(T.range.start,o()),T.fullRange=h(T.range.start,o())}}let O=t.nodes.filter(c=>c.kind==="element");O.length===0?y("XML002_MISSING_ROOT",b.Error,"missing root element",void 0,void 0,{help:'add a single root element, usually `<root BTCPP_format="4">...</root>`'}):O.length>1&&y("XML003_MULTIPLE_ROOTS",b.Error,"multiple root elements",void 0,void 0,{primaryLabel:"this document has more than one top-level element",help:'wrap the document content in one `<root BTCPP_format="4">...</root>` element'});let A=t.root,Z=A?.name==="BehaviorTree"||A?.name==="TreeNodesModel"||A?.name==="root"&&(A.attributes.some(c=>c.name==="BTCPP_format"&&c.value==="4")||A.children.some(c=>c.kind==="element"&&(c.name==="BehaviorTree"||c.name==="TreeNodesModel")));if(A)for(let c of t.nodes)c!==A&&c.kind==="text"&&c.text.trim().length>0&&x("XML016_TEXT_OUTSIDE_ROOT",b.Error,"text outside root element",c.range.start,c.range.end,{primaryLabel:"non-whitespace text appears outside the root element",help:"move this text inside `<root>` or remove it"});if(!t.xmlDeclaration&&!Z)y("XML008_MISSING_DECLARATION",b.Warning,"missing XML declaration",void 0,void 0,{help:'add `<?xml version="1.0" encoding="UTF-8"?>` at the top of the file',notes:["this is a warning because BehaviorTree.CPP can still parse many files without a declaration"]});else if(t.xmlDeclaration?.encoding&&t.xmlDeclaration.encoding.toUpperCase()!=="UTF-8"){let c=t.xmlDeclaration.encoding;x("XML009_INVALID_ENCODING",b.Warning,"XML encoding should be UTF-8",t.xmlDeclaration.range.start,t.xmlDeclaration.range.end,{primaryLabel:`declared encoding is \`${c}\``,help:'change the XML declaration to `encoding="UTF-8"`'})}return A&&ie(A,c=>{x("XML015_UNSUPPORTED_MIXED_CONTENT",b.Warning,"mixed XML content is not supported",ue(c.range.start),ue(c.range.end),{primaryLabel:"this element contains both text and child elements",help:"move the text into an attribute or split it into separate elements",notes:["text inside `<input_port>` and `<output_port>` remains allowed"]})}),se({document:t,diagnostics:r,partial:u,options:n})}var Y={indentWidth:2,xmlDeclaration:"always",blankLineBetweenBehaviorTrees:!0,lineEnding:"lf"};function ce(e){if(!e)return Y;let n=typeof e.indentWidth=="number"?e.indentWidth:Y.indentWidth,r=e.xmlDeclaration==="always"||e.xmlDeclaration==="never"||e.xmlDeclaration==="preserve"?e.xmlDeclaration:Y.xmlDeclaration,i=typeof e.blankLineBetweenBehaviorTrees=="boolean"?e.blankLineBetweenBehaviorTrees:Y.blankLineBetweenBehaviorTrees,t=e.lineEnding==="lf"||e.lineEnding==="crlf"||e.lineEnding==="auto"?e.lineEnding:Y.lineEnding;return{indentWidth:n,xmlDeclaration:r,blankLineBetweenBehaviorTrees:i,lineEnding:t}}function K(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Q(e){return K(e).replace(/"/g,"&quot;")}function _e(e){return e.filter(n=>!(n.kind==="text"&&n.text.trim()===""))}function Me(e,n,r){return`${" ".repeat(e*r)}${n}`}function U(e,n,r,i){let t=" ".repeat(n*i),a=e.attributes||[];if(a.length===0)return[`${t}<${e.name}${r}`];if(a.length===1)return[`${t}<${e.name} ${a[0].name}="${Q(a[0].value)}"${r}`];let s=[`${t}<${e.name} ${a[0].name}="${Q(a[0].value)}"`],l=" ".repeat(t.length+1+e.name.length+1);for(let m=1;m<a.length;m+=1){let u=a[m],o=m===a.length-1?r:"";s.push(`${l}${u.name}="${Q(u.value)}"${o}`)}return s}function J(e,n,r,i){let t=" ".repeat(n*r);if(e.kind==="comment")return[`${t}<!--${e.text}-->`];if(e.kind==="text"){let o=e.text.trim();return o?[Me(n,K(o),r)]:[]}let a=_e(e.children||[]),s=e.kind==="element"&&(e.name==="input_port"||e.name==="output_port"),l=(e.children||[]).filter(o=>o.kind==="text").map(o=>o.text).join("").trim(),m=a.some(o=>o.kind==="element"||o.kind==="comment");if(l&&m&&!s&&i.push({code:"XML015_UNSUPPORTED_MIXED_CONTENT",severity:"error",message:"Mixed XML content is not supported by btxml-checker formatter",uri:""}),l&&!m){if((e.attributes||[]).length<=1){let o=(e.attributes||[]).length===0?"":` ${e.attributes[0].name}="${Q(e.attributes[0].value)}"`;return[`${t}<${e.name}${o}>${K(l)}</${e.name}>`]}return U(e,n,`>${K(l)}</${e.name}>`,r)}if(a.length===0){if(e.selfClosing)return U(e,n,"/>".slice(0),r);let o=U(e,n,">",r);return o.push(`${t}</${e.name}>`),o}let u=U(e,n,">",r);for(let o of e.children||[])o.kind==="text"&&o.text.trim()===""||u.push(...J(o,n+1,r,i));return u.push(`${t}</${e.name}>`),u}function Pe(e){return e.filter(n=>!(n.kind==="text"&&n.text.trim()===""))}function me(e,n,r,i){let t=[],a=Pe(e);for(let s=0;s<a.length;s+=1){let l=a[s],m=a[s-1],u=a[s+1],o=r&&l.kind==="element"&&l.name==="BehaviorTree"&&m&&m.kind==="element"&&m.name==="BehaviorTree",d=l.kind==="element"&&l.name==="TreeNodesModel"&&m!==void 0&&m.kind!=="comment",f=l.kind==="comment"&&u&&u.kind==="element"&&u.name==="TreeNodesModel"&&m!==void 0;(o||d||f)&&t.length>0&&t[t.length-1]!==""&&t.push(""),l.kind==="element"?(t.push(...J(l,1,n,i)),l.name==="TreeNodesModel"&&t.push("")):t.push(...J(l,1,n,i))}return t}function de(e,n={}){let r=G(e);if(!r.ok||!r.document||!r.document.root)return{ok:!1,skipped:!1,diagnostics:r.diagnostics};if(r.diagnostics.find(x=>["XML010_UNSUPPORTED_CDATA","XML011_UNSUPPORTED_DOCTYPE","XML012_UNSUPPORTED_PROCESSING_INSTRUCTION","XML013_UNKNOWN_ENTITY","XML014_INVALID_NUMERIC_ENTITY","XML001_INVALID_SYNTAX"].includes(x.code)))return{ok:!1,skipped:!1,diagnostics:r.diagnostics};if(r.document.kind==="generic-xml"&&!n.force)return{ok:!0,skipped:!0,diagnostics:[]};let t=r.document.root,a=ce(n),s=a.indentWidth,l=[],m=r.document.xmlDeclaration!==void 0;if((a.xmlDeclaration==="always"||a.xmlDeclaration==="preserve"&&m)&&l.push('<?xml version="1.0" encoding="UTF-8"?>'),l.push(...U(t,0,">",s)),l.push(...me(t.children||[],s,a.blankLineBetweenBehaviorTrees,r.diagnostics)),l.push(`</${t.name}>`),r.diagnostics.some(x=>x.code==="XML015_UNSUPPORTED_MIXED_CONTENT"))return{ok:!1,skipped:!1,diagnostics:r.diagnostics};let u=`
6
6
  `;(a.lineEnding==="crlf"||a.lineEnding==="auto"&&e.includes(`\r
7
7
  `))&&(u=`\r
8
- `);let o=l.join(u),d=u.replace(/\\/g,"\\\\").replace(/\r/g,"\\r").replace(/\n/g,"\\n"),f=new RegExp(`(?:${d})+$`,"u"),E=`${o.replace(f,"")}${u}`;return{ok:!0,text:E,changed:E!==e,skipped:!1,diagnostics:r.diagnostics.filter(x=>x.severity!==b.Error)}}function V(e,n){if(!(!C(e.range,n)&&!C(e.fullRange,n))){for(let r of e.children){if(r.kind!=="element")continue;let i=V(r,n);if(i)return i}return e}}function J(e){return e.kind==="element"}function de(e,n){return e.attributes.find(r=>r.name===n)}function fe(e){return e.children.filter(J)}function ge(e){return e.children.filter(n=>n.kind==="text").map(n=>n.text).join("")}function pe(e,n){let r;if(e.kind==="element"?r=e:r=e.root,!r)return;let i=t=>{n(t);for(let a of t.children)J(a)&&i(a)};i(r)}var be=/^[A-Za-z_:][A-Za-z0-9_.:-]*/,Me=/([A-Za-z_:][A-Za-z0-9_.:-]*)\s*=\s*("([^"]*)"|'([^']*)')/gs;function Pe(e,n){let r=[],i=0;for(;i<n;){let t=e.indexOf("<",i);if(t<0||t>=n)break;if(e.startsWith("<!--",t)){let u=e.indexOf("-->",t+4);if(u<0||u+3>n)break;i=u+3;continue}if(e.startsWith("<![CDATA[",t)){let u=e.indexOf("]]>",t+9);if(u<0||u+3>n)break;i=u+3;continue}if(e.startsWith("<?",t)){let u=e.indexOf("?>",t+2);if(u<0||u+2>n)break;i=u+2;continue}if(e.startsWith("<!",t)){let u=e.indexOf(">",t+2);if(u<0||u+1>n)break;i=u+1;continue}if(e[t+1]==="/"){let o=e.slice(t+2).match(be)?.[0];if(o){for(let f=r.length-1;f>=0;f-=1)if(r[f]===o){r.length=f;break}}let d=e.indexOf(">",t+2);if(d<0||d>=n)break;i=d+1;continue}let s=e.slice(t+1).match(/^\s*([A-Za-z_:][A-Za-z0-9_.:-]*)/)?.[1];if(!s){i=t+1;continue}let l=e.indexOf(">",t+1);if(l<0||l>=n)break;e.slice(t+1,l).trimEnd().endsWith("/")||r.push(s),i=l+1}return r.at(-1)}function H(e,n){let r=e.positionAt(n);return h(r,r)}function A(e,n,r){return h(e.positionAt(n),e.positionAt(r))}function ee(e){return{name:e.name,value:e.value,range:A(e.document,e.nameStart,e.valueEnd),fullRange:A(e.document,e.nameStart,e.valueEnd),nameRange:A(e.document,e.nameStart,e.nameEnd),equalsRange:e.equalsStart!==void 0&&e.equalsEnd!==void 0?A(e.document,e.equalsStart,e.equalsEnd):void 0,valueRange:A(e.document,e.valueStart,e.valueEnd),valueContentRange:e.valueContentStart!==void 0&&e.valueContentEnd!==void 0?A(e.document,e.valueContentStart,e.valueContentEnd):void 0}}function we(e,n,r){let i=[];for(let t of n.matchAll(Me)){let a=t.index??0,s=t[1],l=t[2],m=t[3],u=t[4],o=t[0].indexOf(s),d=t[0].indexOf("=",o+s.length),f=t[0].indexOf(l,d+1),p=r+a+f,E=p+l.length;i.push(ee({document:e,name:s,value:m??u??"",nameStart:r+a+o,nameEnd:r+a+o+s.length,equalsStart:r+a+d,equalsEnd:r+a+d+1,valueStart:p,valueEnd:E,valueContentStart:p+1,valueContentEnd:E-1}))}return i}function Oe(e,n){let r=Math.max(0,n-4e3),i=e.text.slice(r,n),t=i.lastIndexOf("<"),a=i.lastIndexOf(">");if(t<0||t<a||!i.startsWith("</",t))return;let s=r+t,l=i.slice(t+2);if(!/\s/.test(l))return{kind:"closing-tag-name",tagNamePrefix:l,replacementRange:A(e,s+2,n)}}function he(e,n){let r=Math.max(0,n-4e3),i=e.text.slice(r,n),t=i.lastIndexOf("<"),a=i.lastIndexOf(">");if(t<0||t<a)return;let s=r+t,l=s+1,m=i.slice(t+1);if(/^\s*[!?/]/.test(m))return;let u=m.match(/^\s*/)?.[0].length??0,o=m.slice(u).match(be);if(!o)return{kind:"tag-name"};let d=o[0],f=u,p=f+d.length,E=A(e,l+f,l+p),x={kind:"element",name:d,attributes:we(e,m,l),children:[],range:A(e,s,n),fullRange:A(e,s,n),openTagRange:A(e,s,n),startTagRange:A(e,s,n),nameRange:E,selfClosing:!1};if(m.length<=p&&!/\s/.test(m.slice(p)))return{kind:"tag-name",element:x,replacementRange:E};let y=m.match(/(?:^|\s)([A-Za-z_:][A-Za-z0-9_.:-]*)\s*=\s*(?:(['"])([^"']*)|([^\s>"']*))?$/s);if(y){let L=y[0].indexOf(y[1]),R=(y.index??0)+L,M=R+y[1].length,B=m.indexOf("=",M),_=y[2],F=y[4]??"";if(_){let P=m.indexOf(_,B+1),c=l+P+1,v=ee({document:e,name:y[1],value:y[3]??"",nameStart:l+R,nameEnd:l+M,equalsStart:l+B,equalsEnd:l+B+1,valueStart:l+P,valueEnd:n,valueContentStart:c,valueContentEnd:n});return{kind:"attribute-value",element:x,attribute:v,valuePrefix:e.text.slice(c,n)}}let O=F.length>0?n-l-F.length:n-l;return{kind:"attribute-value",element:x,attribute:ee({document:e,name:y[1],value:F,nameStart:l+R,nameEnd:l+M,equalsStart:l+B,equalsEnd:l+B+1,valueStart:l+O,valueEnd:n,valueContentStart:l+O,valueContentEnd:n}),valuePrefix:e.text.slice(l+O,n)}}let k=m.match(/(?:^|\s)([A-Za-z_:][A-Za-z0-9_.:-]*)?$/s);if(k){let N=k[1]??"",L=n-l-N.length;return{kind:"attribute-name",element:x,attribute:ee({document:e,name:N,value:"",nameStart:l+L,nameEnd:n,valueStart:n,valueEnd:n})}}return{kind:"attribute-name",element:x,attribute:{name:"",value:"",range:H(e,n),fullRange:H(e,n),nameRange:H(e,n),valueRange:H(e,n)}}}function xe(e){let{document:n,parsed:r,position:i}=e,t=i.offset,a=n.text.length>0?{kind:"text"}:{kind:"unknown"},s=Oe(n,t);if(s)return{kind:"closing-tag-name",tagNamePrefix:s.tagNamePrefix,replacementRange:s.replacementRange,tagText:Pe(n.text,t)};if(r?.root){let u=V(r.root,t);if(u){for(let o of u.attributes){if(C(o.nameRange,t))return{kind:"attribute-name",element:u,attribute:o};if(C(o.valueRange,t)||C(o.valueContentRange,t))return{kind:"attribute-value",element:u,attribute:o,valuePrefix:o.valueContentRange&&t>=o.valueContentRange.start.offset?n.text.slice(o.valueContentRange.start.offset,t):""}}if(C(u.nameRange||u.openTagRange,t))return{kind:"tag-name",element:u,replacementRange:u.nameRange};if(C(u.openTagRange,t)){let o=he(n,t);if(o)return o.kind==="tag-name"?{...o,element:o.element??u}:o}a={kind:"element",element:u}}}let l=he(n,t);if(l)return l;let m=n.text.slice(Math.max(0,t-200),t);return/<!--\s*btxml-disable-next-line\s+[A-Z0-9_]*$/.test(m)?{kind:"comment"}:a}var oe=/[A-Za-z_:][A-Za-z0-9_.:-]*/y;function q(e,n){oe.lastIndex=n;let r=oe.exec(e);if(r)return{name:r[0],end:oe.lastIndex}}function $e(e,n){for(let r=e.length-1;r>=0;r-=1)if(e[r]===n){e.length=r;return}}function ve(e,n,r){let i=n+2,t,a=0;for(;i<r;){if(!t&&a>0){if(e.startsWith("<!--",i)){let l=e.indexOf("-->",i+4);if(l<0||l+3>r)return;i=l+3;continue}if(e.startsWith("<![CDATA[",i)){let l=e.indexOf("]]>",i+9);if(l<0||l+3>r)return;i=l+3;continue}if(e.startsWith("<?",i)){let l=e.indexOf("?>",i+2);if(l<0||l+2>r)return;i=l+2;continue}}let s=e[i];if(t){s===t&&(t=void 0),i+=1;continue}if(s==='"'||s==="'"){t=s,i+=1;continue}if(s==="["){a+=1,i+=1;continue}if(s==="]"&&a>0){a-=1,i+=1;continue}if(s===">"&&a===0)return i;i+=1}}function te(e,n){let r=[],i=0;for(;i<n;){let t=e.indexOf("<",i);if(t<0||t>=n)break;if(i=t,e.startsWith("<!--",i)){let o=e.indexOf("-->",i+4);if(o<0||o+3>n)return{context:"comment",stack:r};i=o+3;continue}if(e.startsWith("<![CDATA[",i)){let o=e.indexOf("]]>",i+9);if(o<0||o+3>n)return{context:"cdata",stack:r};i=o+3;continue}if(e.startsWith("<?",i)){let o=e.indexOf("?>",i+2);if(o<0||o+2>n)return{context:"pi",stack:r};i=o+2;continue}if(e.startsWith("<!",i)){let o=ve(e,i,n);if(o===void 0)return{context:"doctype",stack:r};i=o+1;continue}if(e[i+1]==="/"){let o=i+2;for(;o<n&&/\s/.test(e[o]||"");)o+=1;let d=q(e,o),f=d?.end??o,p=e.indexOf(">",f);if(p<0||p>=n)return{context:"text",stack:r};d&&$e(r,d.name),i=p+1;continue}let a=i+1;for(;a<n&&/\s/.test(e[a]||"");)a+=1;let s=q(e,a);if(!s){i+=1;continue}let l=s.end,m;for(;l<n;){let o=e[l];if(m){o===m&&(m=void 0),l+=1;continue}if(o==='"'||o==="'"){m=o,l+=1;continue}if(o===">")break;l+=1}if(m)return{context:"attribute-value",stack:r};if(l>=n)return{context:"text",stack:r};let u=l-1;for(;u>s.end&&/\s/.test(e[u]||"");)u-=1;e[u]!=="/"&&r.push(s.name),i=l+1}return{context:"text",stack:r}}function Te(e,n,r){let i=n;for(;i<r;){let t=e[i];if(t===">")return;if(t==="/"){i+=1;continue}if(!/\s/.test(t))return i;i+=1}}function We(e,n,r){let i={},t=n;for(;t<r;){for(;t<r&&/\s/.test(e[t]||"");)t+=1;if(t>=r)break;if(e[t]==="/"){t+=1;continue}let a=q(e,t);if(!a){t+=1;continue}for(t=a.end;t<r&&/\s/.test(e[t]||"");)t+=1;if(e[t]!=="="){i[a.name]=void 0;continue}for(t+=1;t<r&&/\s/.test(e[t]||"");)t+=1;if(t>=r){i[a.name]=void 0;break}let s=e[t];if(s==='"'||s==="'"){let m=t+1;for(t=m;t<r&&e[t]!==s;)t+=1;i[a.name]=e.slice(m,t),t<r&&(t+=1);continue}let l=t;for(;t<r&&!/\s/.test(e[t]||"");)t+=1;i[a.name]=e.slice(l,t)}return i}function Xe(e,n,r){let i=n,t,a=!1,s="none",l=Te(e,n,r);for(;i<r;){let m=e[i];if(t){m===t&&(t=void 0),i+=1;continue}if(m==='"'||m==="'"){s==="expect-value"&&(s="none"),t=m,i+=1;continue}if(m===">")return{firstAttributeOffset:l,hasTagEnd:!0,quote:t,sawSlashOutsideQuotes:a,valueState:s};if(m==="="){s="expect-value",i+=1;continue}if(/\s/.test(m)){s==="unquoted-value"&&(s="none"),i+=1;continue}if(m==="/"){s==="none"?a=!0:s="unquoted-value",i+=1;continue}s==="expect-value"&&(s="unquoted-value"),i+=1}return{firstAttributeOffset:l,hasTagEnd:!1,quote:t,sawSlashOutsideQuotes:a,valueState:s}}function ye(e,n){if(n<2||te(e,n).context!=="text")return;let i=e.lastIndexOf("<",n-1);if(i<0||e[i+1]==="/"||e[i+1]==="!"||e[i+1]==="?"||e.slice(i,n).includes(">"))return;let t=i+1;for(;/\s/.test(e[t]||"");)t+=1;let a=q(e,t);if(!a||a.end>n-1)return;let s=Xe(e,a.end,n-1);if(!(s.hasTagEnd||s.quote)&&!s.sawSlashOutsideQuotes&&s.valueState==="none")return{tagName:a.name,tagStartOffset:i,firstAttributeOffset:s.firstAttributeOffset}}function Ee(e,n){if(n<1||e[n-1]!==">"||te(e,n).context!=="text")return;let i=e.lastIndexOf("<",n-1);if(i<0||e[i+1]==="/"||e[i+1]==="!"||e[i+1]==="?")return;let t=i+1;for(;/\s/.test(e[t]||"");)t+=1;let a=q(e,t);if(!a)return;let s=Xe(e,a.end,n-1);if(s.hasTagEnd||s.quote)return;let l=n-2;for(;l>a.end&&/\s/.test(e[l]||"");)l-=1;let m=e[l]==="/"?"/>":">";return{attributes:We(e,a.end,n-1),tagName:a.name,tagStartOffset:i,tagEndOffset:n,firstAttributeOffset:s.firstAttributeOffset,closingToken:m}}function Se(e,n){let r=0;for(;r<n;){let i=e.indexOf("<",r);if(i<0||i>=n)return;if(r=i,e.startsWith("<!--",r)){let u=e.indexOf("-->",r+4);if(u<0||u+3>n)return;r=u+3;continue}if(e.startsWith("<![CDATA[",r)){let u=e.indexOf("]]>",r+9);if(u<0||u+3>n)return;r=u+3;continue}if(e.startsWith("<?",r)){let u=e.indexOf("?>",r+2);if(u<0||u+2>n)return;r=u+2;continue}if(e.startsWith("<!",r)){let u=ve(e,r,n);if(u===void 0)return;r=u+1;continue}if(e[r+1]==="/"){let u=e.indexOf(">",r+2);if(u<0||u>=n)return;r=u+1;continue}let t=r+1;for(;t<n&&/\s/.test(e[t]||"");)t+=1;let a=q(e,t);if(!a){r+=1;continue}let s=Te(e,a.end,n),l=a.end,m;for(;l<n;){let u=e[l];if(m){u===m&&(m=void 0),l+=1;continue}if(u==='"'||u==="'"){m=u,l+=1;continue}if(u===">")break;l+=1}if(m)return;if(l>=n)return{tagName:a.name,tagStartOffset:r,firstAttributeOffset:s};r=l+1}}export{V as findElementAt,Se as findIncompleteOpenStartTag,Ee as findJustClosedStartTag,ye as findOpenStartTagAtSlash,me as formatBtXml,de as getAttribute,fe as getElementChildren,ge as getElementText,xe as inspectXmlCursor,J as isElement,z as parseBtXml,S as positionAt,te as scanXmlPrefix,pe as walkElements};
8
+ `);let o=l.join(u),d=u.replace(/\\/g,"\\\\").replace(/\r/g,"\\r").replace(/\n/g,"\\n"),f=new RegExp(`(?:${d})+$`,"u"),E=`${o.replace(f,"")}${u}`;return{ok:!0,text:E,changed:E!==e,skipped:!1,diagnostics:r.diagnostics.filter(x=>x.severity!==b.Error)}}function V(e,n){if(!(!_(e.range,n)&&!_(e.fullRange,n))){for(let r of e.children){if(r.kind!=="element")continue;let i=V(r,n);if(i)return i}return e}}function H(e){return e.kind==="element"}function fe(e,n){return e.attributes.find(r=>r.name===n)}function ge(e){return e.children.filter(H)}function pe(e){return e.children.filter(n=>n.kind==="text").map(n=>n.text).join("")}function he(e,n){let r;if(e.kind==="element"?r=e:r=e.root,!r)return;let i=t=>{n(t);for(let a of t.children)H(a)&&i(a)};i(r)}var xe=/^[A-Za-z_:][A-Za-z0-9_.:-]*/,Ie=/([A-Za-z_:][A-Za-z0-9_.:-]*)\s*=\s*("([^"]*)"|'([^']*)')/gs;function we(e,n){let r=[],i=0;for(;i<n;){let t=e.indexOf("<",i);if(t<0||t>=n)break;if(e.startsWith("<!--",t)){let u=e.indexOf("-->",t+4);if(u<0||u+3>n)break;i=u+3;continue}if(e.startsWith("<![CDATA[",t)){let u=e.indexOf("]]>",t+9);if(u<0||u+3>n)break;i=u+3;continue}if(e.startsWith("<?",t)){let u=e.indexOf("?>",t+2);if(u<0||u+2>n)break;i=u+2;continue}if(e.startsWith("<!",t)){let u=e.indexOf(">",t+2);if(u<0||u+1>n)break;i=u+1;continue}if(e[t+1]==="/"){let o=e.slice(t+2).match(xe)?.[0];if(o){for(let f=r.length-1;f>=0;f-=1)if(r[f]===o){r.length=f;break}}let d=e.indexOf(">",t+2);if(d<0||d>=n)break;i=d+1;continue}let s=e.slice(t+1).match(/^\s*([A-Za-z_:][A-Za-z0-9_.:-]*)/)?.[1];if(!s){i=t+1;continue}let l=e.indexOf(">",t+1);if(l<0||l>=n)break;e.slice(t+1,l).trimEnd().endsWith("/")||r.push(s),i=l+1}return r.at(-1)}function ee(e,n){let r=e.positionAt(n);return h(r,r)}function N(e,n,r){return h(e.positionAt(n),e.positionAt(r))}function te(e){return{name:e.name,value:e.value,range:N(e.document,e.nameStart,e.valueEnd),fullRange:N(e.document,e.nameStart,e.valueEnd),nameRange:N(e.document,e.nameStart,e.nameEnd),equalsRange:e.equalsStart!==void 0&&e.equalsEnd!==void 0?N(e.document,e.equalsStart,e.equalsEnd):void 0,valueRange:N(e.document,e.valueStart,e.valueEnd),valueContentRange:e.valueContentStart!==void 0&&e.valueContentEnd!==void 0?N(e.document,e.valueContentStart,e.valueContentEnd):void 0}}function Oe(e,n,r){let i=[];for(let t of n.matchAll(Ie)){let a=t.index??0,s=t[1],l=t[2],m=t[3],u=t[4],o=t[0].indexOf(s),d=t[0].indexOf("=",o+s.length),f=t[0].indexOf(l,d+1),p=r+a+f,E=p+l.length;i.push(te({document:e,name:s,value:m??u??"",nameStart:r+a+o,nameEnd:r+a+o+s.length,equalsStart:r+a+d,equalsEnd:r+a+d+1,valueStart:p,valueEnd:E,valueContentStart:p+1,valueContentEnd:E-1}))}return i}function $e(e,n){let r=Math.max(0,n-4e3),i=e.text.slice(r,n),t=i.lastIndexOf("<"),a=i.lastIndexOf(">");if(t<0||t<a||!i.startsWith("</",t))return;let s=r+t,l=i.slice(t+2);if(!/\s/.test(l))return{kind:"closing-tag-name",tagNamePrefix:l,replacementRange:N(e,s+2,n)}}function be(e,n){let r=Math.max(0,n-4e3),i=e.text.slice(r,n),t=i.lastIndexOf("<"),a=i.lastIndexOf(">");if(t<0||t<a)return;let s=r+t,l=s+1,m=i.slice(t+1);if(/^\s*[!?/]/.test(m))return;let u=m.match(/^\s*/)?.[0].length??0,o=m.slice(u).match(xe);if(!o)return{kind:"tag-name"};let d=o[0],f=u,p=f+d.length,E=N(e,l+f,l+p),x={kind:"element",name:d,attributes:Oe(e,m,l),children:[],range:N(e,s,n),fullRange:N(e,s,n),openTagRange:N(e,s,n),startTagRange:N(e,s,n),nameRange:E,selfClosing:!1};if(m.length<=p&&!/\s/.test(m.slice(p)))return{kind:"tag-name",element:x,replacementRange:E};let y=m.match(/(?:^|\s)([A-Za-z_:][A-Za-z0-9_.:-]*)\s*=\s*(?:(['"])([^"']*)|([^\s>"']*))?$/s);if(y){let L=y[0].indexOf(y[1]),R=(y.index??0)+L,I=R+y[1].length,C=m.indexOf("=",I),M=y[2],F=y[4]??"";if(M){let A=m.indexOf(M,C+1),Z=l+A+1,c=te({document:e,name:y[1],value:y[3]??"",nameStart:l+R,nameEnd:l+I,equalsStart:l+C,equalsEnd:l+C+1,valueStart:l+A,valueEnd:n,valueContentStart:Z,valueContentEnd:n});return{kind:"attribute-value",element:x,attribute:c,valuePrefix:e.text.slice(Z,n)}}let O=F.length>0?n-l-F.length:n-l;return{kind:"attribute-value",element:x,attribute:te({document:e,name:y[1],value:F,nameStart:l+R,nameEnd:l+I,equalsStart:l+C,equalsEnd:l+C+1,valueStart:l+O,valueEnd:n,valueContentStart:l+O,valueContentEnd:n}),valuePrefix:e.text.slice(l+O,n)}}let k=m.match(/(?:^|\s)([A-Za-z_:][A-Za-z0-9_.:-]*)?$/s);if(k){let B=k[1]??"",L=n-l-B.length;return{kind:"attribute-name",element:x,attribute:te({document:e,name:B,value:"",nameStart:l+L,nameEnd:n,valueStart:n,valueEnd:n})}}return{kind:"attribute-name",element:x,attribute:{name:"",value:"",range:ee(e,n),fullRange:ee(e,n),nameRange:ee(e,n),valueRange:ee(e,n)}}}function Te(e){let{document:n,parsed:r,position:i}=e,t=i.offset,a=n.text.length>0?{kind:"text"}:{kind:"unknown"},s=$e(n,t);if(s)return{kind:"closing-tag-name",tagNamePrefix:s.tagNamePrefix,replacementRange:s.replacementRange,tagText:we(n.text,t)};if(r?.root){let u=V(r.root,t);if(u){for(let o of u.attributes){if(_(o.nameRange,t))return{kind:"attribute-name",element:u,attribute:o};if(_(o.valueRange,t)||_(o.valueContentRange,t))return{kind:"attribute-value",element:u,attribute:o,valuePrefix:o.valueContentRange&&t>=o.valueContentRange.start.offset?n.text.slice(o.valueContentRange.start.offset,t):""}}if(_(u.nameRange||u.openTagRange,t))return{kind:"tag-name",element:u,replacementRange:u.nameRange};if(_(u.openTagRange,t)){let o=be(n,t);if(o)return o.kind==="tag-name"?{...o,element:o.element??u}:o}a={kind:"element",element:u}}}let l=be(n,t);if(l)return l;let m=n.text.slice(Math.max(0,t-200),t);return/<!--\s*btxml-disable-next-line\s+[A-Z0-9_]*$/.test(m)?{kind:"comment"}:a}var ae=/[A-Za-z_:][A-Za-z0-9_.:-]*/y;function q(e,n){ae.lastIndex=n;let r=ae.exec(e);if(r)return{name:r[0],end:ae.lastIndex}}function We(e,n){for(let r=e.length-1;r>=0;r-=1)if(e[r]===n){e.length=r;return}}function ve(e,n,r){let i=n+2,t,a=0;for(;i<r;){if(!t&&a>0){if(e.startsWith("<!--",i)){let l=e.indexOf("-->",i+4);if(l<0||l+3>r)return;i=l+3;continue}if(e.startsWith("<![CDATA[",i)){let l=e.indexOf("]]>",i+9);if(l<0||l+3>r)return;i=l+3;continue}if(e.startsWith("<?",i)){let l=e.indexOf("?>",i+2);if(l<0||l+2>r)return;i=l+2;continue}}let s=e[i];if(t){s===t&&(t=void 0),i+=1;continue}if(s==='"'||s==="'"){t=s,i+=1;continue}if(s==="["){a+=1,i+=1;continue}if(s==="]"&&a>0){a-=1,i+=1;continue}if(s===">"&&a===0)return i;i+=1}}function ne(e,n){let r=[],i=0;for(;i<n;){let t=e.indexOf("<",i);if(t<0||t>=n)break;if(i=t,e.startsWith("<!--",i)){let o=e.indexOf("-->",i+4);if(o<0||o+3>n)return{context:"comment",stack:r};i=o+3;continue}if(e.startsWith("<![CDATA[",i)){let o=e.indexOf("]]>",i+9);if(o<0||o+3>n)return{context:"cdata",stack:r};i=o+3;continue}if(e.startsWith("<?",i)){let o=e.indexOf("?>",i+2);if(o<0||o+2>n)return{context:"pi",stack:r};i=o+2;continue}if(e.startsWith("<!",i)){let o=ve(e,i,n);if(o===void 0)return{context:"doctype",stack:r};i=o+1;continue}if(e[i+1]==="/"){let o=i+2;for(;o<n&&/\s/.test(e[o]||"");)o+=1;let d=q(e,o),f=d?.end??o,p=e.indexOf(">",f);if(p<0||p>=n)return{context:"text",stack:r};d&&We(r,d.name),i=p+1;continue}let a=i+1;for(;a<n&&/\s/.test(e[a]||"");)a+=1;let s=q(e,a);if(!s){i+=1;continue}let l=s.end,m;for(;l<n;){let o=e[l];if(m){o===m&&(m=void 0),l+=1;continue}if(o==='"'||o==="'"){m=o,l+=1;continue}if(o===">")break;l+=1}if(m)return{context:"attribute-value",stack:r};if(l>=n)return{context:"text",stack:r};let u=l-1;for(;u>s.end&&/\s/.test(e[u]||"");)u-=1;e[u]!=="/"&&r.push(s.name),i=l+1}return{context:"text",stack:r}}function Xe(e,n,r){let i=n;for(;i<r;){let t=e[i];if(t===">")return;if(t==="/"){i+=1;continue}if(!/\s/.test(t))return i;i+=1}}function Ue(e,n,r){let i={},t=n;for(;t<r;){for(;t<r&&/\s/.test(e[t]||"");)t+=1;if(t>=r)break;if(e[t]==="/"){t+=1;continue}let a=q(e,t);if(!a){t+=1;continue}for(t=a.end;t<r&&/\s/.test(e[t]||"");)t+=1;if(e[t]!=="="){i[a.name]=void 0;continue}for(t+=1;t<r&&/\s/.test(e[t]||"");)t+=1;if(t>=r){i[a.name]=void 0;break}let s=e[t];if(s==='"'||s==="'"){let m=t+1;for(t=m;t<r&&e[t]!==s;)t+=1;i[a.name]=e.slice(m,t),t<r&&(t+=1);continue}let l=t;for(;t<r&&!/\s/.test(e[t]||"");)t+=1;i[a.name]=e.slice(l,t)}return i}function ye(e,n,r){let i=n,t,a=!1,s="none",l=Xe(e,n,r);for(;i<r;){let m=e[i];if(t){m===t&&(t=void 0),i+=1;continue}if(m==='"'||m==="'"){s==="expect-value"&&(s="none"),t=m,i+=1;continue}if(m===">")return{firstAttributeOffset:l,hasTagEnd:!0,quote:t,sawSlashOutsideQuotes:a,valueState:s};if(m==="="){s="expect-value",i+=1;continue}if(/\s/.test(m)){s==="unquoted-value"&&(s="none"),i+=1;continue}if(m==="/"){s==="none"?a=!0:s="unquoted-value",i+=1;continue}s==="expect-value"&&(s="unquoted-value"),i+=1}return{firstAttributeOffset:l,hasTagEnd:!1,quote:t,sawSlashOutsideQuotes:a,valueState:s}}function Ee(e,n){if(n<2||ne(e,n).context!=="text")return;let i=e.lastIndexOf("<",n-1);if(i<0||e[i+1]==="/"||e[i+1]==="!"||e[i+1]==="?"||e.slice(i,n).includes(">"))return;let t=i+1;for(;/\s/.test(e[t]||"");)t+=1;let a=q(e,t);if(!a||a.end>n-1)return;let s=ye(e,a.end,n-1);if(!(s.hasTagEnd||s.quote)&&!s.sawSlashOutsideQuotes&&s.valueState==="none")return{tagName:a.name,tagStartOffset:i,firstAttributeOffset:s.firstAttributeOffset}}function Se(e,n){if(n<1||e[n-1]!==">"||ne(e,n).context!=="text")return;let i=e.lastIndexOf("<",n-1);if(i<0||e[i+1]==="/"||e[i+1]==="!"||e[i+1]==="?")return;let t=i+1;for(;/\s/.test(e[t]||"");)t+=1;let a=q(e,t);if(!a)return;let s=ye(e,a.end,n-1);if(s.hasTagEnd||s.quote)return;let l=n-2;for(;l>a.end&&/\s/.test(e[l]||"");)l-=1;let m=e[l]==="/"?"/>":">";return{attributes:Ue(e,a.end,n-1),tagName:a.name,tagStartOffset:i,tagEndOffset:n,firstAttributeOffset:s.firstAttributeOffset,closingToken:m}}function Re(e,n){let r=0;for(;r<n;){let i=e.indexOf("<",r);if(i<0||i>=n)return;if(r=i,e.startsWith("<!--",r)){let u=e.indexOf("-->",r+4);if(u<0||u+3>n)return;r=u+3;continue}if(e.startsWith("<![CDATA[",r)){let u=e.indexOf("]]>",r+9);if(u<0||u+3>n)return;r=u+3;continue}if(e.startsWith("<?",r)){let u=e.indexOf("?>",r+2);if(u<0||u+2>n)return;r=u+2;continue}if(e.startsWith("<!",r)){let u=ve(e,r,n);if(u===void 0)return;r=u+1;continue}if(e[r+1]==="/"){let u=e.indexOf(">",r+2);if(u<0||u>=n)return;r=u+1;continue}let t=r+1;for(;t<n&&/\s/.test(e[t]||"");)t+=1;let a=q(e,t);if(!a){r+=1;continue}let s=Xe(e,a.end,n),l=a.end,m;for(;l<n;){let u=e[l];if(m){u===m&&(m=void 0),l+=1;continue}if(u==='"'||u==="'"){m=u,l+=1;continue}if(u===">")break;l+=1}if(m)return;if(l>=n)return{tagName:a.name,tagStartOffset:r,firstAttributeOffset:s};r=l+1}}export{V as findElementAt,Re as findIncompleteOpenStartTag,Se as findJustClosedStartTag,Ee as findOpenStartTagAtSlash,de as formatBtXml,fe as getAttribute,ge as getElementChildren,pe as getElementText,Te as inspectXmlCursor,H as isElement,G as parseBtXml,S as positionAt,ne as scanXmlPrefix,he as walkElements};
@@ -1,6 +1,6 @@
1
1
  import { S as SourceRange } from './diagnostic-B5htzyJ9.js';
2
- import { T as TreeNodeKind$1, a as TreeNodeModelDef, N as NodeModelSource, P as PortDef } from './public-types-B2noBQY9.js';
3
- import { N as NodeUsageResolution, P as PortUsageResolution, S as SubTreeResolution, U as UsageResolverConfig, a as NodeUsagePolicy } from './types-SY4-jKCn.js';
2
+ import { T as TreeNodeKind$1, a as TreeNodeModelDef, N as NodeModelSource, P as PortDef, B as BlackboardScope } from './public-types-DCvVgnqw.js';
3
+ import { N as NodeUsageResolution, P as PortUsageResolution, S as SubTreeResolution, U as UsageResolverConfig, a as NodeUsagePolicy } from './types-BRzExVMv.js';
4
4
 
5
5
  type TreeNodeKind = TreeNodeKind$1;
6
6
  type BuildSemanticDocumentViewOptions = {
@@ -10,8 +10,10 @@ type BuildSemanticDocumentViewOptions = {
10
10
  interface BlackboardReferenceView {
11
11
  readonly raw: string;
12
12
  readonly key: string;
13
+ readonly scope: BlackboardScope;
14
+ readonly identity: string;
13
15
  readonly range: SourceRange;
14
- readonly syntax: "braced" | "bare" | "invalid";
16
+ readonly syntax: "braced" | "shorthand" | "invalid";
15
17
  }
16
18
  interface SemanticAttributeView {
17
19
  readonly name: string;
@@ -1,6 +1,6 @@
1
1
  import { a as BtXmlElement, b as BtXmlAttribute } from './ast-BbfR3S_b.js';
2
- import { B as BehaviorTreeDef, a as TreeNodeModelDef, P as PortDef } from './public-types-B2noBQY9.js';
3
- import { S as SemanticIndex, R as ResolveSubTreeInput } from './types-BaOc_AYN.js';
2
+ import { b as BehaviorTreeDef, a as TreeNodeModelDef, P as PortDef } from './public-types-DCvVgnqw.js';
3
+ import { S as SemanticIndex, R as ResolveSubTreeInput } from './types-f9KgrQFd.js';
4
4
 
5
5
  type SubTreeResolution = {
6
6
  readonly status: "resolved";
@@ -1,6 +1,6 @@
1
1
  import { R as ResolvedBtxmlConfig } from './types-BgqDzlJ8.js';
2
2
  import { D as Diagnostic, S as SourceRange, a as DiagnosticDetails, b as DiagnosticData, R as RelatedInformation } from './diagnostic-B5htzyJ9.js';
3
- import { a as TreeNodeModelDef, M as ModelSourceRef } from './public-types-B2noBQY9.js';
3
+ import { a as TreeNodeModelDef, M as ModelSourceRef } from './public-types-DCvVgnqw.js';
4
4
  import { z } from 'zod';
5
5
 
6
6
  declare const modelAugmentationFileSchema: z.ZodObject<{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abco20/btxml-checker",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {