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