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