!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(n){"use strict";n.defineMode("smarty",function(e,t){var f,l=t.rightDelimiter||"}",s=t.leftDelimiter||"{",d=t.version||2,p=n.getMode(e,t.baseMode||"null"),u=["debug","extends","function","include","literal"],c={operatorChars:/[+\-*&%=<>!?]/,validIdentifier:/[a-zA-Z0-9_]/,stringChar:/['"]/};function h(e,t){return f=t,e}function b(e,t){for(var r,n,i=e.string,a=e.pos;;){var o=i.indexOf(s,a);if(a=o+s.length,-1==o||(r=e,null==(n=o+s.length)&&(n=r.pos),3!==d||"{"!=s||n!=r.string.length&&!/\s/.test(r.string.charAt(n))))break}if(o==e.pos)return e.match(s),e.eat("*")?function(e,t,r){return(t.tokenize=r)(e,t)}(e,t,function(r,n){return function(e,t){for(;!e.eol();){if(e.match(n)){t.tokenize=b;break}e.next()}return r}}("comment","*"+l)):(t.depth++,t.tokenize=k,f="startTag","tag");-1<o&&(e.string=i.slice(0,o));var u=p.token(e,t.base);return-1<o&&(e.string=i),u}function k(e,t){if(e.match(l,!0))return 3===d?(t.depth--,t.depth<=0&&(t.tokenize=b)):t.tokenize=b,h("tag",null);if(e.match(s,!0))return t.depth++,h("tag","startTag");var r=e.next();if("$"==r)return e.eatWhile(c.validIdentifier),h("variable-2","variable");if("|"==r)return h("operator","pipe");if("."==r)return h("operator","property");if(c.stringChar.test(r))return t.tokenize=function(i){return function(e,t){for(var r=null,n=null;!e.eol();){if(n=e.peek(),e.next()==i&&"\\"!==r){t.tokenize=k;break}r=n}return"string"}}(r),h("string","string");if(c.operatorChars.test(r))return e.eatWhile(c.operatorChars),h("operator","operator");if("["==r||"]"==r)return h("bracket","bracket");if("("==r||")"==r)return h("bracket","operator");if(/\d/.test(r))return e.eatWhile(/\d/),h("number","number");if("variable"==t.last){if("@"==r)return e.eatWhile(c.validIdentifier),h("property","property");if("|"==r)return e.eatWhile(c.validIdentifier),h("qualifier","modifier")}else{if("pipe"==t.last)return e.eatWhile(c.validIdentifier),h("qualifier","modifier");if("whitespace"==t.last)return e.eatWhile(c.validIdentifier),h("attribute","modifier")}if("property"==t.last)return e.eatWhile(c.validIdentifier),h("property",null);if(/\s/.test(r))return f="whitespace",null;var n="";"/"!=r&&(n+=r);for(var i=null;i=e.eat(c.validIdentifier);)n+=i;for(var a=0,o=u.length;a<o;a++)if(u[a]==n)return h("keyword","keyword");return/\s/.test(r)?null:h("tag","tag")}return{startState:function(){return{base:n.startState(p),tokenize:b,last:null,depth:0}},copyState:function(e){return{base:n.copyState(p,e.base),tokenize:e.tokenize,last:e.last,depth:e.depth}},innerMode:function(e){if(e.tokenize==b)return{mode:p,state:e.base}},token:function(e,t){var r=t.tokenize(e,t);return t.last=f,r},indent:function(e,t,r){return e.tokenize==b&&p.indent?p.indent(e.base,t,r):n.Pass},blockCommentStart:s+"*",blockCommentEnd:"*"+l}}),n.defineMIME("text/x-smarty","smarty")});