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