(function(c){typeof exports=="object"&&typeof module=="object"?c(require("../../lib/codemirror")):typeof define=="function"&&define.amd?define(["../../lib/codemirror"],c):c(CodeMirror)})(function(c){"use strict";c.defineMode("coffeescript",function(y,x){var v="error";function p(e){return new RegExp("^(("+e.join(")|(")+"))\\b")}var w=/^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>>?=?|%=?|&=?|\|=?|\^=?|\~|!|\?|(or|and|\|\||&&|\?)=)/,b=/^(?:[()\[\]{},:`=;]|\.\.?\.?)/,k=/^[_A-Za-z$][_A-Za-z$0-9]*/,z=/^@[_A-Za-z$][_A-Za-z$0-9]*/,a=p(["and","or","not","is","isnt","in","instanceof","typeof"]),d=["for","while","loop","if","unless","else","switch","try","catch","finally","class"],A=["break","by","continue","debugger","delete","do","in","of","new","return","then","this","@","throw","when","until","extends"],E=p(d.concat(A));d=p(d);var S=/^('{3}|\"{3}|['\"])/,M=/^(\/{3}|\/)/,O=["Infinity","NaN","undefined","null","true","false","on","off","yes","no"],R=p(O);function l(e,n){if(e.sol()){n.scope.align===null&&(n.scope.align=!1);var i=n.scope.offset;if(e.eatSpace()){var f=e.indentation();return f>i&&n.scope.type=="coffee"?"indent":f<i?"dedent":null}else i>0&&h(e,n)}if(e.eatSpace())return null;var r=e.peek();if(e.match("####"))return e.skipToEnd(),"comment";if(e.match("###"))return n.tokenize=I,n.tokenize(e,n);if(r==="#")return e.skipToEnd(),"comment";if(e.match(/^-?[0-9\.]/,!1)){var u=!1;if(e.match(/^-?\d*\.\d+(e[\+\-]?\d+)?/i)&&(u=!0),e.match(/^-?\d+\.\d*/)&&(u=!0),e.match(/^-?\.\d+/)&&(u=!0),u)return e.peek()=="."&&e.backUp(1),"number";var o=!1;if(e.match(/^-?0x[0-9a-f]+/i)&&(o=!0),e.match(/^-?[1-9]\d*(e[\+\-]?\d+)?/)&&(o=!0),e.match(/^-?0(?![\dx])/i)&&(o=!0),o)return"number"}if(e.match(S))return n.tokenize=g(e.current(),!1,"string"),n.tokenize(e,n);if(e.match(M)){if(e.current()!="/"||e.match(/^.*\//,!1))return n.tokenize=g(e.current(),!0,"string-2"),n.tokenize(e,n);e.backUp(1)}return e.match(w)||e.match(a)?"operator":e.match(b)?"punctuation":e.match(R)?"atom":e.match(z)||n.prop&&e.match(k)?"property":e.match(E)?"keyword":e.match(k)?"variable":(e.next(),v)}function g(e,n,i){return function(f,r){for(;!f.eol();)if(f.eatWhile(/[^'"\/\\]/),f.eat("\\")){if(f.next(),n&&f.eol())return i}else{if(f.match(e))return r.tokenize=l,i;f.eat(/['"\/]/)}return n&&(x.singleLineStringErrors?i=v:r.tokenize=l),i}}function I(e,n){for(;!e.eol();){if(e.eatWhile(/[^#]/),e.match("###")){n.tokenize=l;break}e.eatWhile("#")}return"comment"}function t(e,n,i){i=i||"coffee";for(var f=0,r=!1,u=null,o=n.scope;o;o=o.prev)if(o.type==="coffee"||o.type=="}"){f=o.offset+y.indentUnit;break}i!=="coffee"?(r=null,u=e.column()+e.current().length):n.scope.align&&(n.scope.align=!1),n.scope={offset:f,type:i,prev:n.scope,align:r,alignOffset:u}}function h(e,n){if(n.scope.prev)if(n.scope.type==="coffee"){for(var i=e.indentation(),f=!1,r=n.scope;r;r=r.prev)if(i===r.offset){f=!0;break}if(!f)return!0;for(;n.scope.prev&&n.scope.offset!==i;)n.scope=n.scope.prev;return!1}else return n.scope=n.scope.prev,!1}function Z(e,n){var i=n.tokenize(e,n),f=e.current();f==="return"&&(n.dedent=!0),((f==="->"||f==="=>")&&e.eol()||i==="indent")&&t(e,n);var r="[({".indexOf(f);if(r!==-1&&t(e,n,"])}".slice(r,r+1)),d.exec(f)&&t(e,n),f=="then"&&h(e,n),i==="dedent"&&h(e,n))return v;if(r="])}".indexOf(f),r!==-1){for(;n.scope.type=="coffee"&&n.scope.prev;)n.scope=n.scope.prev;n.scope.type==f&&(n.scope=n.scope.prev)}return n.dedent&&e.eol()&&(n.scope.type=="coffee"&&n.scope.prev&&(n.scope=n.scope.prev),n.dedent=!1),i}var _={startState:function(e){return{tokenize:l,scope:{offset:e||0,type:"coffee",prev:null,align:!1},prop:!1,dedent:0}},token:function(e,n){var i=n.scope.align===null&&n.scope;i&&e.sol()&&(i.align=!1);var f=Z(e,n);return f&&f!="comment"&&(i&&(i.align=!0),n.prop=f=="punctuation"&&e.current()=="."),f},indent:function(e,n){if(e.tokenize!=l)return 0;var i=e.scope,f=n&&"])}".indexOf(n.charAt(0))>-1;if(f)for(;i.type=="coffee"&&i.prev;)i=i.prev;var r=f&&i.type===n.charAt(0);return i.align?i.alignOffset-(r?1:0):(r?i.prev:i).offset},lineComment:"#",fold:"indent"};return _}),c.defineMIME("application/vnd.coffeescript","coffeescript"),c.defineMIME("text/x-coffeescript","coffeescript"),c.defineMIME("text/coffeescript","coffeescript")});
