function o(t){for(var e={},r=t.split(" "),n=0;n<r.length;++n)e[r[n]]=!0;return e}var f=o("#end #else #break #stop #[[ #]] #{end} #{else} #{break} #{stop}"),i=o("#if #elseif #foreach #set #include #parse #macro #define #evaluate #{if} #{elseif} #{foreach} #{set} #{include} #{parse} #{macro} #{define} #{evaluate}"),c=o("$foreach.count $foreach.hasNext $foreach.first $foreach.last $foreach.topmost $foreach.parent.count $foreach.parent.hasNext $foreach.parent.first $foreach.parent.last $foreach.parent $velocityCount $!bodyContent $bodyContent"),k=/[+\-*&%=<>!?:\/|]/;function s(t,e,r){return e.tokenize=r,r(t,e)}function l(t,e){var r=e.beforeParams;e.beforeParams=!1;var n=t.next();if(n=="'"&&!e.inString&&e.inParams)return e.lastTokenWasBuiltin=!1,s(t,e,m(n));if(n=='"'){if(e.lastTokenWasBuiltin=!1,e.inString)return e.inString=!1,"string";if(e.inParams)return s(t,e,m(n))}else{if(/[\[\]{}\(\),;\.]/.test(n))return n=="("&&r?e.inParams=!0:n==")"&&(e.inParams=!1,e.lastTokenWasBuiltin=!0),null;if(/\d/.test(n))return e.lastTokenWasBuiltin=!1,t.eatWhile(/[\w\.]/),"number";if(n=="#"&&t.eat("*"))return e.lastTokenWasBuiltin=!1,s(t,e,p);if(n=="#"&&t.match(/ *\[ *\[/))return e.lastTokenWasBuiltin=!1,s(t,e,h);if(n=="#"&&t.eat("#"))return e.lastTokenWasBuiltin=!1,t.skipToEnd(),"comment";if(n=="$")return t.eat("!"),t.eatWhile(/[\w\d\$_\.{}-]/),c&&c.propertyIsEnumerable(t.current())?"keyword":(e.lastTokenWasBuiltin=!0,e.beforeParams=!0,"builtin");if(k.test(n))return e.lastTokenWasBuiltin=!1,t.eatWhile(k),"operator";t.eatWhile(/[\w\$_{}@]/);var a=t.current();return f&&f.propertyIsEnumerable(a)?"keyword":i&&i.propertyIsEnumerable(a)||t.current().match(/^#@?[a-z0-9_]+ *$/i)&&t.peek()=="("&&!(i&&i.propertyIsEnumerable(a.toLowerCase()))?(e.beforeParams=!0,e.lastTokenWasBuiltin=!1,"keyword"):e.inString?(e.lastTokenWasBuiltin=!1,"string"):t.pos>a.length&&t.string.charAt(t.pos-a.length-1)=="."&&e.lastTokenWasBuiltin?"builtin":(e.lastTokenWasBuiltin=!1,null)}}function m(t){return function(e,r){for(var n=!1,a,u=!1;(a=e.next())!=null;){if(a==t&&!n){u=!0;break}if(t=='"'&&e.peek()=="$"&&!n){r.inString=!0,u=!0;break}n=!n&&a=="\\"}return u&&(r.tokenize=l),"string"}}function p(t,e){for(var r=!1,n;n=t.next();){if(n=="#"&&r){e.tokenize=l;break}r=n=="*"}return"comment"}function h(t,e){for(var r=0,n;n=t.next();){if(n=="#"&&r==2){e.tokenize=l;break}n=="]"?r++:n!=" "&&(r=0)}return"meta"}const b={name:"velocity",startState:function(){return{tokenize:l,beforeParams:!1,inParams:!1,inString:!1,lastTokenWasBuiltin:!1}},token:function(t,e){return t.eatSpace()?null:e.tokenize(t,e)},languageData:{commentTokens:{line:"##",block:{open:"#*",close:"*#"}}}};export{b as t};
