!function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../css/css"],e):e(CodeMirror)}(function(r){"use strict";r.defineMode("sass",function(s){var e=r.mimeModes["text/css"],o=e.propertyKeywords||{},i=e.colorKeywords||{},a=e.valueKeywords||{},u=e.fontProperties||{};var f,c=new RegExp("^"+["true","false","null","auto"].join("|")),p=new RegExp("^"+["\\(","\\)","=",">","<","==",">=","<=","\\+","-","\\!=","/","\\*","%","and","or","not",";","\\{","\\}",":"].join("|")),l=/^::?[a-zA-Z_][\w\-]*/;function h(e){return!e.peek()||e.match(/\s+$/,!1)}function m(e,r){var t=e.peek();return")"===t?(e.next(),r.tokenizer=v,"operator"):"("===t?(e.next(),e.eatSpace(),"operator"):(r.tokenizer="'"===t||'"'===t?k(e.next()):k(")",!1),"string")}function d(t,n){return function(e,r){return e.sol()&&e.indentation()<=t?(r.tokenizer=v)(e,r):(n&&e.skipTo("*/")?(e.next(),e.next(),r.tokenizer=v):e.skipToEnd(),"comment")}}function k(a,u){return null==u&&(u=!0),function e(r,t){var n=r.next(),o=r.peek(),i=r.string.charAt(r.pos-2);return"\\"!==n&&o===a||n===a&&"\\"!==i?(n!==a&&u&&r.next(),h(r)&&(t.cursorHalf=0),t.tokenizer=v,"string"):"#"===n&&"{"===o?(t.tokenizer=w(e),r.next(),"operator"):"string"}}function w(t){return function(e,r){return"}"===e.peek()?(e.next(),r.tokenizer=t,"operator"):v(e,r)}}function x(e){if(0==e.indentCount){e.indentCount++;var r=e.scopes[0].offset+s.indentUnit;e.scopes.unshift({offset:r})}}function y(e){1!=e.scopes.length&&e.scopes.shift()}function v(e,r){var t=e.peek();if(e.match("/*"))return r.tokenizer=d(e.indentation(),!0),r.tokenizer(e,r);if(e.match("//"))return r.tokenizer=d(e.indentation(),!1),r.tokenizer(e,r);if(e.match("#{"))return r.tokenizer=w(v),"operator";if('"'===t||"'"===t)return e.next(),r.tokenizer=k(t),"string";if(r.cursorHalf){if("#"===t&&(e.next(),e.match(/[0-9a-fA-F]{6}|[0-9a-fA-F]{3}/)))return h(e)&&(r.cursorHalf=0),"number";if(e.match(/^-?[0-9\.]+/))return h(e)&&(r.cursorHalf=0),"number";if(e.match(/^(px|em|in)\b/))return h(e)&&(r.cursorHalf=0),"unit";if(e.match(c))return h(e)&&(r.cursorHalf=0),"keyword";if(e.match(/^url/)&&"("===e.peek())return r.tokenizer=m,h(e)&&(r.cursorHalf=0),"atom";if("$"===t)return e.next(),e.eatWhile(/[\w-]/),h(e)&&(r.cursorHalf=0),"variable-2";if("!"===t)return e.next(),r.cursorHalf=0,e.match(/^[\w]+/)?"keyword":"operator";if(e.match(p))return h(e)&&(r.cursorHalf=0),"operator";if(e.eatWhile(/[\w-]/))return h(e)&&(r.cursorHalf=0),f=e.current().toLowerCase(),a.hasOwnProperty(f)?"atom":i.hasOwnProperty(f)?"keyword":o.hasOwnProperty(f)?(r.prevProp=e.current().toLowerCase(),"property"):"tag";if(h(e))return r.cursorHalf=0,null}else{if("-"===t&&e.match(/^-\w+-/))return"meta";if("."===t){if(e.next(),e.match(/^[\w-]+/))return x(r),"qualifier";if("#"===e.peek())return x(r),"tag"}if("#"===t){if(e.next(),e.match(/^[\w-]+/))return x(r),"builtin";if("#"===e.peek())return x(r),"tag"}if("$"===t)return e.next(),e.eatWhile(/[\w-]/),"variable-2";if(e.match(/^-?[0-9\.]+/))return"number";if(e.match(/^(px|em|in)\b/))return"unit";if(e.match(c))return"keyword";if(e.match(/^url/)&&"("===e.peek())return r.tokenizer=m,"atom";if("="===t&&e.match(/^=[\w-]+/))return x(r),"meta";if("+"===t&&e.match(/^\+[\w-]+/))return"variable-3";if("@"===t&&e.match(/@extend/)&&(e.match(/\s*[\w]/)||y(r)),e.match(/^@(else if|if|media|else|for|each|while|mixin|function)/))return x(r),"def";if("@"===t)return e.next(),e.eatWhile(/[\w-]/),"def";if(e.eatWhile(/[\w-]/)){if(e.match(/ *: *[\w-\+\$#!\("']/,!1)){f=e.current().toLowerCase();var n=r.prevProp+"-"+f;return o.hasOwnProperty(n)?"property":o.hasOwnProperty(f)?(r.prevProp=f,"property"):u.hasOwnProperty(f)?"property":"tag"}return e.match(/ *:/,!1)?(x(r),r.cursorHalf=1,r.prevProp=e.current().toLowerCase(),"property"):(e.match(/ *,/,!1)||x(r),"tag")}if(":"===t)return e.match(l)?"variable-3":(e.next(),r.cursorHalf=1,"operator")}return e.match(p)?"operator":(e.next(),null)}return{startState:function(){return{tokenizer:v,scopes:[{offset:0,type:"sass"}],indentCount:0,cursorHalf:0,definedVars:[],definedMixins:[]}},token:function(e,r){var t=function(e,r){e.sol()&&(r.indentCount=0);var t=r.tokenizer(e,r),n=e.current();if("@return"!==n&&"}"!==n||y(r),null!==t){for(var o=e.pos-n.length+s.indentUnit*r.indentCount,i=[],a=0;a<r.scopes.length;a++){var u=r.scopes[a];u.offset<=o&&i.push(u)}r.scopes=i}return t}(e,r);return r.lastToken={style:t,content:e.current()},t},indent:function(e){return e.scopes[0].offset}}},"css"),r.defineMIME("text/x-sass","sass")});