import{b as O,E as e,s as t,C as n,t as a,L as r,a as l,i as o,f as s,x as i,l as y}from"./index-BiV-b1K2.js";function $(O){return 45==O||46==O||58==O||O>=65&&O<=90||95==O||O>=97&&O<=122||O>=161}let c=null,p=null,S=0;function g(O,e){let t=O.pos+e;if(p==O&&S==t)return c;for(;9==(n=O.peek(e))||10==n||13==n||32==n;)e++;var n;let a="";for(;;){let t=O.peek(e);if(!$(t))break;a+=String.fromCharCode(t),e++}return p=O,S=t,c=a||null}function u(O,e){this.name=O,this.parent=e,this.hash=e?e.hash:0;for(let t=0;t1==e?new u(g(n,1)||"",O):O,reduce:(O,e)=>11==e&&O?O.parent:O,reuse(O,e,t,n){let a=e.type.id;return 1==a||13==a?new u(g(n,1)||"",O):O},hash:O=>O?O.hash:0,strict:!1}),f=new e(((O,e)=>{if(60==O.next)if(O.advance(),47==O.next){O.advance();let t=g(O,0);if(!t)return O.acceptToken(5);if(e.context&&t==e.context.name)return O.acceptToken(2);for(let n=e.context;n;n=n.parent)if(n.name==t)return O.acceptToken(3,-2);O.acceptToken(4)}else if(33!=O.next&&63!=O.next)return O.acceptToken(1)}),{contextual:!0});function d(O,t){return new e((e=>{let n=0,a=t.charCodeAt(0);O:for(;!(e.next<0);e.advance(),n++)if(e.next==a){for(let O=1;O"),T=d(37,"]]>"),h=t({Text:a.content,"StartTag StartCloseTag EndTag SelfCloseEndTag":a.angleBracket,TagName:a.tagName,"MismatchedCloseTag/Tagname":[a.tagName,a.invalid],AttributeName:a.attributeName,AttributeValue:a.attributeValue,Is:a.definitionOperator,"EntityReference CharacterReference":a.character,Comment:a.blockComment,ProcessingInst:a.processingInstruction,DoctypeDecl:a.documentMeta,Cdata:a.special(a.string)}),_=O.deserialize({version:14,states:",SOQOaOOOrOxO'#CfOzOpO'#CiO!tOaO'#CgOOOP'#Cg'#CgO!{OrO'#CrO#TOtO'#CsO#]OpO'#CtOOOP'#DS'#DSOOOP'#Cv'#CvQQOaOOOOOW'#Cw'#CwO#eOxO,59QO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%y;'S;=`&_<%lO%yXDTV{WOr%ysv%yw#d%y#d#eDj#e;'S%y;'S;=`&_<%lO%yXDoV{WOr%ysv%yw#X%y#X#Y9i#Y;'S%y;'S;=`&_<%lO%yXE]T!PP{WOr%ysv%yw;'S%y;'S;=`&_<%lO%yZEuWaQVP{WOr$nrs%_sv$nw!^$n!^!_%y!_;'S$n;'S;=`&e<%lO$n_FhW[UVP{WOr$nrs%_sv$nw!^$n!^!_%y!_;'S$n;'S;=`&e<%lO$nZGXYVP{WOr$nrs%_sv$nw!^$n!^!_%y!_!`$n!`!aGw!a;'S$n;'S;=`&e<%lO$nZHQW!OQVP{WOr$nrs%_sv$nw!^$n!^!_%y!_;'S$n;'S;=`&e<%lO$nZHqYVP{WOr$nrs%_sv$nw!^$n!^!_%y!_#P$n#P#QIa#Q;'S$n;'S;=`&e<%lO$nZIhYVP{WOr$nrs%_sv$nw!^$n!^!_%y!_!`$n!`!aJW!a;'S$n;'S;=`&e<%lO$nZJaWwQVP{WOr$nrs%_sv$nw!^$n!^!_%y!_;'S$n;'S;=`&e<%lO$n",tokenizers:[f,V,P,T,0,1,2,3],topRules:{Document:[0,6]},tokenPrec:0});function W(O,e){let t=e&&e.getChild("TagName");return t?O.sliceString(t.from,t.to):""}function b(O,e){let t=e&&e.firstChild;return t&&"OpenTag"==t.name?W(O,t):""}function v(O){for(let e=O&&O.parent;e;e=e.parent)if("Element"==e.name)return e;return null}class C{constructor(O,e,t){this.attrs=e,this.attrValues=t,this.children=[],this.name=O.name,this.completion=Object.assign(Object.assign({type:"type"},O.completion||{}),{label:this.name}),this.openCompletion=Object.assign(Object.assign({},this.completion),{label:"<"+this.name}),this.closeCompletion=Object.assign(Object.assign({},this.completion),{label:"",boost:2}),this.closeNameCompletion=Object.assign(Object.assign({},this.completion),{label:this.name+">"}),this.text=O.textContent?O.textContent.map((O=>({label:O,type:"text"}))):[]}}const w=/^[:\-\.\w\u00b7-\uffff]*$/;function x(O){return Object.assign(Object.assign({type:"property"},O.completion||{}),{label:O.name})}function X(O){return"string"==typeof O?{label:`"${O}"`,type:"constant"}:/^"/.test(O.label)?O:Object.assign(Object.assign({},O),{label:`"${O.label}"`})}function Q(O,e){let t=[],n=[],a=Object.create(null);for(let s of e){let O=x(s);t.push(O),s.global&&n.push(O),s.values&&(a[s.name]=s.values.map(X))}let r=[],l=[],o=Object.create(null);for(let s of O){let O=n,e=a;s.attributes&&(O=O.concat(s.attributes.map((O=>"string"==typeof O?t.find((e=>e.label==O))||{label:O,type:"property"}:(O.values&&(e==a&&(e=Object.create(e)),e[O.name]=O.values.map(X)),x(O))))));let i=new C(s,O,e);o[i.name]=i,r.push(i),s.top&&l.push(i)}l.length||(l=r);for(let s=0;s{var e;let{doc:t}=O.state,s=function(O,e){var t;let n=y(O).resolveInner(e,-1),a=null;for(let r=n;!a&&r.parent;r=r.parent)"OpenTag"!=r.name&&"CloseTag"!=r.name&&"SelfClosingTag"!=r.name&&"MismatchedCloseTag"!=r.name||(a=r);if(a&&(a.to>e||a.lastChild.type.isError)){let O=a.parent;if("TagName"==n.name)return"CloseTag"==a.name||"MismatchedCloseTag"==a.name?{type:"closeTag",from:n.from,context:O}:{type:"openTag",from:n.from,context:v(O)};if("AttributeName"==n.name)return{type:"attrName",from:n.from,context:a};if("AttributeValue"==n.name)return{type:"attrValue",from:n.from,context:a};let t=n==a||"Attribute"==n.name?n.childBefore(e):n;return"StartTag"==(null==t?void 0:t.name)?{type:"openTag",from:e,context:v(O)}:"StartCloseTag"==(null==t?void 0:t.name)&&t.to<=e?{type:"closeTag",from:e,context:O}:"Is"==(null==t?void 0:t.name)?{type:"attrValue",from:e,context:a}:t?{type:"attrName",from:e,context:a}:null}if("StartCloseTag"==n.name)return{type:"closeTag",from:e,context:n.parent};for(;n.parent&&n.to==e&&!(null===(t=n.lastChild)||void 0===t?void 0:t.type.isError);)n=n.parent;return"Element"==n.name||"Text"==n.name||"Document"==n.name?{type:"tag",from:e,context:"Element"==n.name?n:v(n)}:null}(O.state,O.pos);if(!s||"tag"==s.type&&!O.explicit)return null;let{type:i,from:$,context:c}=s;if("openTag"==i){let O=l,e=b(t,c);if(e){let t=o[e];O=(null==t?void 0:t.children)||r}return{from:$,options:O.map((O=>O.completion)),validFor:w}}if("closeTag"==i){let n=b(t,c);return n?{from:$,to:O.pos+(">"==t.sliceString(O.pos,O.pos+1)?1:0),options:[(null===(e=o[n])||void 0===e?void 0:e.closeNameCompletion)||{label:n+">",type:"type"}],validFor:w}:null}if("attrName"==i){let O=o[W(t,c)];return{from:$,options:(null==O?void 0:O.attrs)||n,validFor:w}}if("attrValue"==i){let e=function(O,e,t){let n=e&&e.getChildren("Attribute").find((O=>O.from<=t&&O.to>=t)),a=n&&n.getChild("AttributeName");return a?O.sliceString(a.from,a.to):""}(t,c,$);if(!e)return null;let n=o[W(t,c)],r=((null==n?void 0:n.attrValues)||a)[e];return r&&r.length?{from:$,to:O.pos+('"'==t.sliceString(O.pos,O.pos+1)?1:0),options:r,validFor:/^"[^"]*"?$/}:null}if("tag"==i){let e=b(t,c),n=o[e],a=[],s=c&&c.lastChild;!e||s&&"CloseTag"==s.name&&W(t,s)==e||a.push(n?n.closeCompletion:{label:"",type:"type",boost:2});let i=a.concat(((null==n?void 0:n.children)||(c?r:l)).map((O=>O.openCompletion)));if(c&&(null==n?void 0:n.text.length)){let e=c.firstChild;e.to>O.pos-20&&!/\S/.test(O.state.sliceDoc(e.to,O.pos))&&(i=i.concat(n.text))}return{from:$,options:i,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}return null}}const E=l.define({name:"xml",parser:_.configure({props:[o.add({Element(O){let e=/^\s*<\//.test(O.textAfter);return O.lineIndent(O.node.from)+(e?0:O.unit)},"OpenTag CloseTag SelfClosingTag":O=>O.column(O.node.from)+O.unit}),s.add({Element(O){let e=O.firstChild,t=O.lastChild;return e&&"OpenTag"==e.name?{from:e.to,to:"CloseTag"==t.name?t.from:O.to}:null}}),i.add({"OpenTag CloseTag":O=>O.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"\x3c!--",close:"--\x3e"}},indentOnInput:/^\s*<\/$/}});function G(O={}){return new r(E,E.data.of({autocomplete:Q(O.elements||[],O.attributes||[])}))}export{Q as completeFromSchema,G as xml,E as xmlLanguage};