!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}((function(e){"use strict";e.defineMode("xquery",(function(){var e=function(){function e(e){return{type:e,style:"keyword"}}for(var t=e("operator"),n={type:"atom",style:"atom"},r={type:"axis_specifier",style:"qualifier"},i={",":{type:"punctuation",style:null}},a=["after","all","allowing","ancestor","ancestor-or-self","any","array","as","ascending","at","attribute","base-uri","before","boundary-space","by","case","cast","castable","catch","child","collation","comment","construction","contains","content","context","copy","copy-namespaces","count","decimal-format","declare","default","delete","descendant","descendant-or-self","descending","diacritics","different","distance","document","document-node","element","else","empty","empty-sequence","encoding","end","entire","every","exactly","except","external","first","following","following-sibling","for","from","ftand","ftnot","ft-option","ftor","function","fuzzy","greatest","group","if","import","in","inherit","insensitive","insert","instance","intersect","into","invoke","is","item","language","last","lax","least","let","levels","lowercase","map","modify","module","most","namespace","next","no","node","nodes","no-inherit","no-preserve","not","occurs","of","only","option","order","ordered","ordering","paragraph","paragraphs","parent","phrase","preceding","preceding-sibling","preserve","previous","processing-instruction","relationship","rename","replace","return","revalidation","same","satisfies","schema","schema-attribute","schema-element","score","self","sensitive","sentence","sentences","sequence","skip","sliding","some","stable","start","stemming","stop","strict","strip","switch","text","then","thesaurus","times","to","transform","treat","try","tumbling","type","typeswitch","union","unordered","update","updating","uppercase","using","validate","value","variable","version","weight","when","where","wildcards","window","with","without","word","words","xquery"],o=0,s=a.length;o",">=","<","<=",".","|","?","and","or","div","idiv","mod","*","/","+","-"];for(o=0,s=u.length;o\"\'\/?]/);)b+=k;return t(f,x,function(e,t){return function(r,i){return r.eatSpace(),t&&r.eat(">")?(p(i),i.tokenize=n,"tag"):(r.eat("/")||d(i,{type:"tag",name:e,tokenize:n}),r.eat(">")?(i.tokenize=n,"tag"):(i.tokenize=o,"tag"))}}(b,v))}if("{"==g)return d(x,{type:"codeblock"}),null;if("}"==g)return p(x),null;if(l(x))return">"==g?"tag":"/"==g&&f.eat(">")?(p(x),"tag"):"variable";if(/\d/.test(g))return f.match(/^\d*(?:\.\d*)?(?:E[+\-]?\d+)?/),"atom";if("("===g&&f.eat(":"))return d(x,{type:"comment"}),t(f,x,r);if(h||'"'!==g&&"'"!==g){if("$"===g)return t(f,x,a);if(":"===g&&f.eat("="))return"keyword";if("("===g)return d(x,{type:"paren"}),null;if(")"===g)return p(x),null;if("["===g)return d(x,{type:"bracket"}),null;if("]"===g)return p(x),null;var z=e.propertyIsEnumerable(g)&&e[g];if(h&&'"'===g)for(;'"'!==f.next(););if(h&&"'"===g)for(;"'"!==f.next(););z||f.eatWhile(/[\w\$_-]/);var w=f.eat(":");!f.eat(":")&&w&&f.eatWhile(/[\w\$_-]/),f.match(/^[ \t]*\(/,!1)&&(y=!0);var I=f.current();return z=e.propertyIsEnumerable(I)&&e[I],y&&!z&&(z={type:"function_call",style:"variable def"}),function(e){return m(e,"xmlconstructor")}(x)?(p(x),"variable"):("element"!=I&&"attribute"!=I&&"axis_specifier"!=z.type||d(x,{type:"xmlconstructor"}),z?z.style:"variable")}return t(f,x,i(g))}function r(e,t){for(var n,r=!1,i=!1,a=0;n=e.next();){if(")"==n&&r){if(!(a>0)){p(t);break}a--}else":"==n&&i&&a++;r=":"==n,i="("==n}return"comment"}function i(e,t){return function(r,a){var o;if(function(e){return m(e,"string")}(a)&&r.current()==e)return p(a),t&&(a.tokenize=t),"string";if(d(a,{type:"string",name:e,tokenize:i(e,t)}),r.match("{",!1)&&f(a))return a.tokenize=n,"string";for(;o=r.next();){if(o==e){p(a),t&&(a.tokenize=t);break}if(r.match("{",!1)&&f(a))return a.tokenize=n,"string"}return"string"}}function a(e,t){var r=/[\w\$_-]/;if(e.eat('"')){for(;'"'!==e.next(););e.eat(":")}else e.eatWhile(r),e.match(":=",!1)||e.eat(":");return e.eatWhile(r),t.tokenize=n,"variable"}function o(e,r){var a=e.next();return"/"==a&&e.eat(">")?(f(r)&&p(r),l(r)&&p(r),"tag"):">"==a?(f(r)&&p(r),"tag"):"="==a?null:'"'==a||"'"==a?t(e,r,i(a,o)):(f(r)||d(r,{type:"attribute",tokenize:o}),e.eat(/[a-zA-Z_:]/),e.eatWhile(/[-a-zA-Z0-9_:.]/),e.eatSpace(),(e.match(">",!1)||e.match("/",!1))&&(p(r),r.tokenize=n),"attribute")}function s(e,t){for(var r;r=e.next();)if("-"==r&&e.match("->",!0))return t.tokenize=n,"comment"}function c(e,t){for(var r;r=e.next();)if("]"==r&&e.match("]",!0))return t.tokenize=n,"comment"}function u(e,t){for(var r;r=e.next();)if("?"==r&&e.match(">",!0))return t.tokenize=n,"comment meta"}function l(e){return m(e,"tag")}function f(e){return m(e,"attribute")}function m(e,t){return e.stack.length&&e.stack[e.stack.length-1].type==t}function d(e,t){e.stack.push(t)}function p(e){e.stack.pop();var t=e.stack.length&&e.stack[e.stack.length-1].tokenize;e.tokenize=t||n}return{startState:function(){return{tokenize:n,cc:[],stack:[]}},token:function(e,t){return e.eatSpace()?null:t.tokenize(e,t)},blockCommentStart:"(:",blockCommentEnd:":)"}})),e.defineMIME("application/xquery","xquery")}));