function c(e){for(var t={},n=e.split(" "),r=0;r<n.length;++r)t[n[r]]=!0;return t}var b=c("abstract as assert boolean break byte case catch char class const continue def default do double else enum extends final finally float for goto if implements import in instanceof int interface long native new package private protected public return short static strictfp super switch synchronized threadsafe throw throws trait transient try void volatile while"),g=c("catch class def do else enum finally for if interface switch trait try while"),w=c("return break continue"),z=c("null true false this"),i;function m(e,t){var n=e.next();if(n=='"'||n=="'")return h(n,e,t);if(/[\[\]{}\(\),;\:\.]/.test(n))return i=n,null;if(/\d/.test(n))return e.eatWhile(/[\w\.]/),e.eat(/eE/)&&(e.eat(/\+\-/),e.eatWhile(/\d/)),"number";if(n=="/"){if(e.eat("*"))return t.tokenize.push(y),y(e,t);if(e.eat("/"))return e.skipToEnd(),"comment";if(k(t.lastToken,!1))return h(n,e,t)}if(n=="-"&&e.eat(">"))return i="->",null;if(/[+\-*&%=<>!?|\/~]/.test(n))return e.eatWhile(/[+\-*&%=<>|~]/),"operator";if(e.eatWhile(/[\w\$_]/),n=="@")return e.eatWhile(/[\w\$_\.]/),"meta";if(t.lastToken==".")return"property";if(e.eat(":"))return i="proplabel","property";var r=e.current();return z.propertyIsEnumerable(r)?"atom":b.propertyIsEnumerable(r)?(g.propertyIsEnumerable(r)?i="newstatement":w.propertyIsEnumerable(r)&&(i="standalone"),"keyword"):"variable"}m.isBase=!0;function h(e,t,n){var r=!1;if(e!="/"&&t.eat(e))if(t.eat(e))r=!0;else return"string";function a(o,p){for(var l=!1,u,d=!r;(u=o.next())!=null;){if(u==e&&!l){if(!r)break;if(o.match(e+e)){d=!0;break}}if(e=='"'&&u=="$"&&!l){if(o.eat("{"))return p.tokenize.push(x()),"string";if(o.match(/^\w/,!1))return p.tokenize.push(T),"string"}l=!l&&u=="\\"}return d&&p.tokenize.pop(),"string"}return n.tokenize.push(a),a(t,n)}function x(){var e=1;function t(n,r){if(n.peek()=="}"){if(e--,e==0)return r.tokenize.pop(),r.tokenize[r.tokenize.length-1](n,r)}else n.peek()=="{"&&e++;return m(n,r)}return t.isBase=!0,t}function T(e,t){var n=e.match(/^(\.|[\w\$_]+)/);return(!n||!e.match(n[0]=="."?/^[\w$_]/:/^\./))&&t.tokenize.pop(),n?n[0]=="."?null:"variable":t.tokenize[t.tokenize.length-1](e,t)}function y(e,t){for(var n=!1,r;r=e.next();){if(r=="/"&&n){t.tokenize.pop();break}n=r=="*"}return"comment"}function k(e,t){return!e||e=="operator"||e=="->"||/[\.\[\{\(,;:]/.test(e)||e=="newstatement"||e=="keyword"||e=="proplabel"||e=="standalone"&&!t}function v(e,t,n,r,a){this.indented=e,this.column=t,this.type=n,this.align=r,this.prev=a}function f(e,t,n){return e.context=new v(e.indented,t,n,null,e.context)}function s(e){var t=e.context.type;return(t==")"||t=="]"||t=="}")&&(e.indented=e.context.indented),e.context=e.context.prev}const E={name:"groovy",startState:function(e){return{tokenize:[m],context:new v(-e,0,"top",!1),indented:0,startOfLine:!0,lastToken:null}},token:function(e,t){var n=t.context;if(e.sol()&&(n.align??(n.align=!1),t.indented=e.indentation(),t.startOfLine=!0,n.type=="statement"&&!k(t.lastToken,!0)&&(s(t),n=t.context)),e.eatSpace())return null;i=null;var r=t.tokenize[t.tokenize.length-1](e,t);if(r=="comment")return r;if(n.align??(n.align=!0),(i==";"||i==":")&&n.type=="statement")s(t);else if(i=="->"&&n.type=="statement"&&n.prev.type=="}")s(t),t.context.align=!1;else if(i=="{")f(t,e.column(),"}");else if(i=="[")f(t,e.column(),"]");else if(i=="(")f(t,e.column(),")");else if(i=="}"){for(;n.type=="statement";)n=s(t);for(n.type=="}"&&(n=s(t));n.type=="statement";)n=s(t)}else i==n.type?s(t):(n.type=="}"||n.type=="top"||n.type=="statement"&&i=="newstatement")&&f(t,e.column(),"statement");return t.startOfLine=!1,t.lastToken=i||r,r},indent:function(e,t,n){if(!e.tokenize[e.tokenize.length-1].isBase)return null;var r=t&&t.charAt(0),a=e.context;a.type=="statement"&&!k(e.lastToken,!0)&&(a=a.prev);var o=r==a.type;return a.type=="statement"?a.indented+(r=="{"?0:n.unit):a.align?a.column+(o?0:1):a.indented+(o?0:n.unit)},languageData:{indentOnInput:/^\s*[{}]$/,commentTokens:{line:"//",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"'''",'"""']}}};export{E as t};
