!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)}(function(x){"use strict";x.registerHelper("wordChars","r",/[\w.]/),x.defineMode("r",function(r){function e(e){for(var t={},n=0;n<e.length;++n)t[e[n]]=!0;return t}var a,t=["NULL","NA","Inf","NaN","NA_integer_","NA_real_","NA_complex_","NA_character_","TRUE","FALSE"],n=["list","quote","bquote","eval","return","call","parse","deparse"],i=["if","else","repeat","while","function","for","in","next","break"],o=(x.registerHelper("hintWords","r",t.concat(n,i)),e(t)),c=e(n),l=e(i),f=e(["if","else","repeat","while","function","for"]),u=/[+\-*\/^<>=!&|~$:]/;function d(e,t){a=null;var n,i,r=e.next();return"#"==r?(e.skipToEnd(),"comment"):"0"==r&&e.eat("x")?(e.eatWhile(/[\da-f]/i),"number"):"."==r&&e.eat(/\d/)?(e.match(/\d*(?:e[+\-]?\d+)?/),"number"):/\d/.test(r)?(e.match(/\d*(?:\.\d+)?(?:e[+\-]\d+)?L?/),"number"):"'"==r||'"'==r?(t.tokenize=(i=r,function(e,t){var n,r;if(e.eat("\\"))return"x"==(n=e.next())?e.match(/^[a-f0-9]{2}/i):("u"==n||"U"==n)&&e.eat("{")&&e.skipTo("}")?e.next():"u"==n?e.match(/^[a-f0-9]{4}/i):"U"==n?e.match(/^[a-f0-9]{8}/i):/[0-7]/.test(n)&&e.match(/^[0-7]{1,2}/),"string-2";for(;null!=(r=e.next());){if(r==i){t.tokenize=d;break}if("\\"==r){e.backUp(1);break}}return"string"}),"string"):"`"==r?(e.match(/[^`]+`/),"variable-3"):"."==r&&e.match(/.(?:[.]|\d+)/)?"keyword":/[a-zA-Z\.]/.test(r)?(e.eatWhile(/[\w\.]/),n=e.current(),o.propertyIsEnumerable(n)?"atom":l.propertyIsEnumerable(n)?(f.propertyIsEnumerable(n)&&!e.match(/\s*if(\s+|$)/,!1)&&(a="block"),"keyword"):c.propertyIsEnumerable(n)?"builtin":"variable"):"%"==r?(e.skipTo("%")&&e.next(),"operator variable-2"):"<"==r&&e.eat("-")||"<"==r&&e.match("<-")||"-"==r&&e.match(/>>?/)?"operator arrow":"="==r&&t.ctx.argList?"arg-is":u.test(r)?"$"==r?"operator dollar":(e.eatWhile(u),"operator"):/[\(\){}\[\];]/.test(r)&&";"==(a=r)?"semi":null}function s(e,t,n){e.ctx={type:t,indent:e.indent,flags:0,column:n.column(),prev:e.ctx}}function p(e,t){var n=e.ctx;e.ctx={type:n.type,indent:n.indent,flags:n.flags|t,column:n.column,prev:n.prev}}function m(e){e.indent=e.ctx.indent,e.ctx=e.ctx.prev}return{startState:function(){return{tokenize:d,ctx:{type:"top",indent:-r.indentUnit,flags:2},indent:0,afterIdent:!1}},token:function(e,t){if(e.sol()&&(0==(3&t.ctx.flags)&&(t.ctx.flags|=2),4&t.ctx.flags&&m(t),t.indent=e.indentation()),e.eatSpace())return null;var n=t.tokenize(e,t);return"comment"!=n&&0==(2&t.ctx.flags)&&p(t,1),";"!=a&&"{"!=a&&"}"!=a||"block"!=t.ctx.type||m(t),"{"==a?s(t,"}",e):"("==a?(s(t,")",e),t.afterIdent&&(t.ctx.argList=!0)):"["==a?s(t,"]",e):"block"==a?s(t,"block",e):a==t.ctx.type?m(t):"block"==t.ctx.type&&"comment"!=n&&p(t,4),t.afterIdent="variable"==n||"keyword"==n,n},indent:function(e,t){if(e.tokenize!=d)return 0;var t=t&&t.charAt(0),e=e.ctx,n=t==e.type;return"block"==(e=4&e.flags?e.prev:e).type?e.indent+("{"==t?0:r.indentUnit):1&e.flags?e.column+(n?0:1):e.indent+(n?0:r.indentUnit)},lineComment:"#"}}),x.defineMIME("text/x-rsrc","r")});