diff --git a/dist/less.js b/dist/less.js index 98c00a7f7..17d34f139 100644 --- a/dist/less.js +++ b/dist/less.js @@ -1,8 +1,8 @@ /*! - * Less - Leaner CSS v2.7.3 + * Less - Leaner CSS v3.0.0 * http://lesscss.org * - * Copyright (c) 2009-2017, Alexis Sellier + * Copyright (c) 2009-2018, Alexis Sellier * Licensed under the Apache-2.0 License. * */ @@ -56,22 +56,40 @@ module.exports = function(window, options) { options.onReady = true; } + options.javascriptEnabled = (options.javascriptEnabled || options.inlineJavaScript) ? true : false; + }; -},{"./browser":3,"./utils":10}],2:[function(require,module,exports){ +},{"./browser":3,"./utils":11}],2:[function(require,module,exports){ /** * Kicks off less and compiles any stylesheets * used in the browser distributed version of less * to kick-start less using the browser api */ -/*global window, document */ +/* global window, document */ + +// TODO - consider switching this out for a recommendation for this polyfill? +// +// Browsers have good Promise support +require("promise/polyfill"); -// shim Promise if required -require('promise/polyfill.js'); +var options = require('../less/default-options')(); -var options = window.less || {}; +if (window.less) { + for (key in window.less) { + if (window.less.hasOwnProperty(key)) { + options[key] = window.less[key]; + } + } +} require("./add-default-options")(window, options); +options.plugins = options.plugins || []; + +if (window.LESS_PLUGINS) { + options.plugins = options.plugins.concat(window.LESS_PLUGINS); +} + var less = module.exports = require("./index")(window, options); window.less = less; @@ -92,7 +110,7 @@ if (options.onReady) { if (/!watch/.test(window.location.hash)) { less.watch(); } - // Simulate synchronous stylesheet loading by blocking page rendering + // Simulate synchronous stylesheet loading by hiding page rendering if (!options.async) { css = 'body { display: none !important }'; head = document.head || document.getElementsByTagName('head')[0]; @@ -111,7 +129,7 @@ if (options.onReady) { less.pageLoadFinished = less.refresh(less.env === 'development').then(resolveOrReject, resolveOrReject); } -},{"./add-default-options":1,"./index":8,"promise/polyfill.js":97}],3:[function(require,module,exports){ +},{"../less/default-options":16,"./add-default-options":1,"./index":8,"promise/polyfill":100}],3:[function(require,module,exports){ var utils = require("./utils"); module.exports = { createCSS: function (document, styles, sheet) { @@ -177,7 +195,7 @@ module.exports = { } }; -},{"./utils":10}],4:[function(require,module,exports){ +},{"./utils":11}],4:[function(require,module,exports){ // Cache system is a bit outdated and could do with work module.exports = function(window, options, logger) { @@ -197,8 +215,8 @@ module.exports = function(window, options, logger) { if (modifyVars) { cache.setItem(path + ':vars', JSON.stringify(modifyVars)); } - } catch(e) { - //TODO - could do with adding more robust error handling + } catch (e) { + // TODO - could do with adding more robust error handling logger.error('failed to save "' + path + '" to local storage for caching.'); } } @@ -248,7 +266,7 @@ module.exports = function(window, less, options) { } }; - if (e.extract) { + if (e.line) { errorline(e, 0, ''); errorline(e, 1, 'line'); errorline(e, 2, ''); @@ -336,7 +354,7 @@ module.exports = function(window, less, options) { } function removeErrorConsole(path) { - //no action + // no action } function removeError(path) { @@ -354,7 +372,7 @@ module.exports = function(window, less, options) { var filename = e.filename || rootHref; var errors = []; var content = (e.type || "Syntax") + "Error: " + (e.message || 'There is an error in your .less file') + - " in " + filename + " "; + " in " + filename; var errorline = function (e, i, classname) { if (e.extract[i] !== undefined) { @@ -364,11 +382,11 @@ module.exports = function(window, less, options) { } }; - if (e.extract) { + if (e.line) { errorline(e, 0, ''); errorline(e, 1, 'line'); errorline(e, 2, ''); - content += 'on line ' + e.line + ', column ' + (e.column + 1) + ':\n' + + content += ' on line ' + e.line + ', column ' + (e.column + 1) + ':\n' + errors.join('\n'); } if (e.stack && (e.extract || options.logLevel >= 4)) { @@ -393,8 +411,8 @@ module.exports = function(window, less, options) { }; }; -},{"./browser":3,"./utils":10}],6:[function(require,module,exports){ -/*global window, XMLHttpRequest */ +},{"./browser":3,"./utils":11}],6:[function(require,module,exports){ +/* global window, XMLHttpRequest */ module.exports = function(options, logger) { @@ -402,22 +420,7 @@ module.exports = function(options, logger) { var fileCache = {}; - //TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load - - function getXMLHttpRequest() { - if (window.XMLHttpRequest && (window.location.protocol !== "file:" || !("ActiveXObject" in window))) { - return new XMLHttpRequest(); - } else { - try { - /*global ActiveXObject */ - return new ActiveXObject("Microsoft.XMLHTTP"); - } catch (e) { - logger.error("browser doesn't support AJAX."); - return null; - } - } - } - + // TODOS - move log somewhere. pathDiff and doing something similar in node. use pathDiff in the other browser file for the initial load var FileManager = function() { }; @@ -434,7 +437,7 @@ module.exports = function(options, logger) { }; FileManager.prototype.doXHR = function doXHR(url, type, callback, errback) { - var xhr = getXMLHttpRequest(); + var xhr = new XMLHttpRequest(); var async = options.isFileProtocol ? options.fileAsync : true; if (typeof xhr.overrideMimeType === 'function') { @@ -478,43 +481,50 @@ module.exports = function(options, logger) { fileCache = {}; }; - FileManager.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment, callback) { + FileManager.prototype.loadFile = function loadFile(filename, currentDirectory, options, environment) { + // TODO: Add prefix support like less-node? + // What about multiple paths? + if (currentDirectory && !this.isPathAbsolute(filename)) { filename = currentDirectory + filename; } + filename = options.ext ? this.tryAppendExtension(filename, options.ext) : filename; + options = options || {}; // sheet may be set to the stylesheet for the initial load or a collection of properties including // some context variables for imports var hrefParts = this.extractUrlParts(filename, window.location.href); var href = hrefParts.url; - - if (options.useFileCache && fileCache[href]) { - try { - var lessText = fileCache[href]; - callback(null, { contents: lessText, filename: href, webInfo: { lastModified: new Date() }}); - } catch (e) { - callback({filename: href, message: "Error loading file " + href + " error was " + e.message}); + var self = this; + + return new Promise(function(resolve, reject) { + if (options.useFileCache && fileCache[href]) { + try { + var lessText = fileCache[href]; + return resolve({ contents: lessText, filename: href, webInfo: { lastModified: new Date() }}); + } catch (e) { + return reject({ filename: href, message: "Error loading file " + href + " error was " + e.message }); + } } - return; - } - this.doXHR(href, options.mime, function doXHRCallback(data, lastModified) { - // per file cache - fileCache[href] = data; + self.doXHR(href, options.mime, function doXHRCallback(data, lastModified) { + // per file cache + fileCache[href] = data; - // Use remote copy (re-parse) - callback(null, { contents: data, filename: href, webInfo: { lastModified: lastModified }}); - }, function doXHRError(status, url) { - callback({ type: 'File', message: "'" + url + "' wasn't found (" + status + ")", href: href }); + // Use remote copy (re-parse) + resolve({ contents: data, filename: href, webInfo: { lastModified: lastModified }}); + }, function doXHRError(status, url) { + reject({ type: 'File', message: "'" + url + "' wasn't found (" + status + ")", href: href }); + }); }); }; return FileManager; }; -},{"../less/environment/abstract-file-manager.js":15}],7:[function(require,module,exports){ +},{"../less/environment/abstract-file-manager.js":17}],7:[function(require,module,exports){ module.exports = function() { var functionRegistry = require("./../less/functions/function-registry"); @@ -544,7 +554,7 @@ module.exports = function() { functionRegistry.addMultiple(imageFunctions); }; -},{"./../less/functions/function-registry":22}],8:[function(require,module,exports){ +},{"./../less/functions/function-registry":26}],8:[function(require,module,exports){ // // index.js // Should expose the additional browser functions on to the less object @@ -555,42 +565,29 @@ var addDataAttr = require("./utils").addDataAttr, module.exports = function(window, options) { var document = window.document; var less = require('../less')(); - - //module.exports = less; + less.options = options; var environment = less.environment, FileManager = require("./file-manager")(options, less.logger), fileManager = new FileManager(); environment.addFileManager(fileManager); less.FileManager = FileManager; + less.PluginLoader = require("./plugin-loader"); require("./log-listener")(less, options); var errors = require("./error-reporting")(window, less, options); var cache = less.cache = options.cache || require("./cache")(window, options, less.logger); require('./image-size')(less.environment); - //Setup user functions + // Setup user functions - Deprecate? if (options.functions) { less.functions.functionRegistry.addMultiple(options.functions); } var typePattern = /^text\/(x-)?less$/; - function postProcessCSS(styles) { // deprecated, use a plugin for postprocesstasks - if (options.postProcessor && typeof options.postProcessor === 'function') { - styles = options.postProcessor.call(styles, styles) || styles; - } - return styles; - } - function clone(obj) { - var cloned = {}; - for (var prop in obj) { - if (obj.hasOwnProperty(prop)) { - cloned[prop] = obj[prop]; - } - } - return cloned; + return JSON.parse(JSON.stringify(obj || {})); } // only really needed for phantom @@ -614,7 +611,7 @@ module.exports = function(window, options) { var lessText = style.innerHTML || ''; instanceOptions.filename = document.location.href.replace(/#.*$/, ''); - /*jshint loopfunc:true */ + /* jshint loopfunc:true */ // use closure to store current style less.render(lessText, instanceOptions, bind(function(style, e, result) { @@ -670,7 +667,7 @@ module.exports = function(window, options) { } - //TODO add tests around how this behaves when reloading + // TODO add tests around how this behaves when reloading errors.remove(path); instanceOptions.rootFileInfo = newFileInfo; @@ -679,20 +676,20 @@ module.exports = function(window, options) { e.href = path; callback(e); } else { - result.css = postProcessCSS(result.css); cache.setCSS(sheet.href, webInfo.lastModified, instanceOptions.modifyVars, result.css); callback(null, result.css, data, sheet, webInfo, path); } }); } - fileManager.loadFile(sheet.href, null, instanceOptions, environment, function(e, loadedFile) { - if (e) { - callback(e); - return; - } - loadInitialFileCallback(loadedFile); - }); + fileManager.loadFile(sheet.href, null, instanceOptions, environment) + .then(function(loadedFile) { + loadInitialFileCallback(loadedFile); + }).catch(function(err) { + console.log(err); + callback(err); + }); + } function loadStyleSheets(callback, reload, modifyVars) { @@ -832,7 +829,7 @@ module.exports = function(window, options) { return less; }; -},{"../less":31,"./browser":3,"./cache":4,"./error-reporting":5,"./file-manager":6,"./image-size":7,"./log-listener":9,"./utils":10}],9:[function(require,module,exports){ +},{"../less":35,"./browser":3,"./cache":4,"./error-reporting":5,"./file-manager":6,"./image-size":7,"./log-listener":9,"./plugin-loader":10,"./utils":11}],9:[function(require,module,exports){ module.exports = function(less, options) { var logLevel_debug = 4, @@ -878,6 +875,33 @@ module.exports = function(less, options) { }; },{}],10:[function(require,module,exports){ +// TODO: Add tests for browser @plugin +/*global window */ + +var AbstractPluginLoader = require("../less/environment/abstract-plugin-loader.js"); + +/** + * Browser Plugin Loader + */ +var PluginLoader = function(less) { + this.less = less; + // shim for browser require? + this.require = require; +}; + +PluginLoader.prototype = new AbstractPluginLoader(); + +PluginLoader.prototype.loadPlugin = function(filename, basePath, context, environment, fileManager) { + return new Promise(function(fulfill, reject) { + fileManager.loadFile(filename, basePath, context, environment) + .then(fulfill).catch(reject); + }); +}; + +module.exports = PluginLoader; + + +},{"../less/environment/abstract-plugin-loader.js":18}],11:[function(require,module,exports){ module.exports = { extractId: function(href) { return href.replace(/^[a-z-]+:\/+?[^\/]+/, '') // Remove protocol & domain @@ -896,14 +920,14 @@ module.exports = { try { options[opt] = JSON.parse(tag.dataset[opt]); } - catch(_) {} + catch (_) {} } } } } }; -},{}],11:[function(require,module,exports){ +},{}],12:[function(require,module,exports){ var contexts = {}; module.exports = contexts; @@ -946,18 +970,18 @@ contexts.Parse = function(options) { }; var evalCopyProperties = [ - 'paths', // additional include paths - 'compress', // whether to compress - 'ieCompat', // whether to enforce IE compatibility (IE8 data-uri) - 'strictMath', // whether math has to be within parenthesis - 'strictUnits', // whether units need to evaluate correctly - 'sourceMap', // whether to output a source map - 'importMultiple', // whether we are currently importing multiple copies - 'urlArgs', // whether to add args into url tokens - 'javascriptEnabled',// option - whether JavaScript is enabled. if undefined, defaults to true - 'pluginManager', // Used as the plugin manager for the session - 'importantScope' // used to bubble up !important statements - ]; + 'paths', // additional include paths + 'compress', // whether to compress + 'ieCompat', // whether to enforce IE compatibility (IE8 data-uri) + 'strictMath', // whether math has to be within parenthesis + 'strictUnits', // whether units need to evaluate correctly + 'sourceMap', // whether to output a source map + 'importMultiple', // whether we are currently importing multiple copies + 'urlArgs', // whether to add args into url tokens + 'javascriptEnabled', // option - whether Inline JavaScript is enabled. if undefined, defaults to false + 'pluginManager', // Used as the plugin manager for the session + 'importantScope' // used to bubble up !important statements +]; contexts.Eval = function(options, frames) { copyFromOriginal(options, this, evalCopyProperties); @@ -979,7 +1003,11 @@ contexts.Eval.prototype.outOfParenthesis = function () { this.parensStack.pop(); }; +contexts.Eval.prototype.mathOn = true; contexts.Eval.prototype.isMathOn = function () { + if (!this.mathOn) { + return false; + } return this.strictMath ? (this.parensStack && this.parensStack.length) : true; }; @@ -989,13 +1017,13 @@ contexts.Eval.prototype.isPathRelative = function (path) { contexts.Eval.prototype.normalizePath = function( path ) { var - segments = path.split("/").reverse(), - segment; + segments = path.split("/").reverse(), + segment; path = []; while (segments.length !== 0 ) { segment = segments.pop(); - switch( segment ) { + switch ( segment ) { case ".": break; case "..": @@ -1014,9 +1042,9 @@ contexts.Eval.prototype.normalizePath = function( path ) { return path.join("/"); }; -//todo - do the same for the toCSS ? +// todo - do the same for the toCSS ? -},{}],12:[function(require,module,exports){ +},{}],13:[function(require,module,exports){ module.exports = { 'aliceblue':'#f0f8ff', 'antiquewhite':'#faebd7', @@ -1167,13 +1195,13 @@ module.exports = { 'yellow':'#ffff00', 'yellowgreen':'#9acd32' }; -},{}],13:[function(require,module,exports){ +},{}],14:[function(require,module,exports){ module.exports = { colors: require("./colors"), unitConversions: require("./unit-conversions") }; -},{"./colors":12,"./unit-conversions":14}],14:[function(require,module,exports){ +},{"./colors":13,"./unit-conversions":15}],15:[function(require,module,exports){ module.exports = { length: { 'm': 1, @@ -1195,7 +1223,73 @@ module.exports = { 'turn': 1 } }; -},{}],15:[function(require,module,exports){ +},{}],16:[function(require,module,exports){ +// Export a new default each time +module.exports = function() { + return { + /* Outputs a makefile import dependency list to stdout. */ + depends: false, + + /* Compress using less built-in compression. + * This does an okay job but does not utilise all the tricks of + * dedicated css compression. */ + compress: false, + + /* Runs the less parser and just reports errors without any output. */ + lint: false, + + /* Sets available include paths. + * If the file in an @import rule does not exist at that exact location, + * less will look for it at the location(s) passed to this option. + * You might use this for instance to specify a path to a library which + * you want to be referenced simply and relatively in the less files. */ + paths: [], + + /* color output in the terminal */ + color: true, + + /* The strictImports controls whether the compiler will allow an @import inside of either + * @media blocks or (a later addition) other selector blocks. + * See: https://github.com/less/less.js/issues/656 */ + strictImports: false, + + /* Allow Imports from Insecure HTTPS Hosts */ + insecure: false, + + /* Allows you to add a path to every generated import and url in your css. + * This does not affect less import statements that are processed, just ones + * that are left in the output css. */ + rootpath: '', + + /* By default URLs are kept as-is, so if you import a file in a sub-directory + * that references an image, exactly the same URL will be output in the css. + * This option allows you to re-write URL's in imported files so that the + * URL is always relative to the base imported file */ + relativeUrls: false, + + /* Compatibility with IE8. Used for limiting data-uri length */ + ieCompat: false, // true until 3.0 + + /* Without this option on, Less will try and process all math in your css */ + strictMath: false, + + /* Without this option, less attempts to guess at the output unit when it does maths. */ + strictUnits: false, + + /* Effectively the declaration is put at the top of your base Less file, + * meaning it can be used but it also can be overridden if this variable + * is defined in the file. */ + globalVars: null, + + /* As opposed to the global variable option, this puts the declaration at the + * end of your base file, meaning it will override anything defined in your Less file. */ + modifyVars: null, + + /* This option allows you to specify a argument to go on to every URL. */ + urlArgs: '' + } +} +},{}],17:[function(require,module,exports){ var abstractFileManager = function() { }; @@ -1233,13 +1327,14 @@ abstractFileManager.prototype.alwaysMakePathsAbsolute = function() { abstractFileManager.prototype.isPathAbsolute = function(filename) { return (/^(?:[a-z-]+:|\/|\\|#)/i).test(filename); }; - +// TODO: pull out / replace? abstractFileManager.prototype.join = function(basePath, laterPath) { if (!basePath) { return laterPath; } return basePath + laterPath; }; + abstractFileManager.prototype.pathDiff = function pathDiff(url, baseUrl) { // diff between two paths to create a relative path @@ -1273,7 +1368,7 @@ abstractFileManager.prototype.extractUrlParts = function extractUrlParts(url, ba var urlPartsRegex = /^((?:[a-z-]+:)?\/{2}(?:[^\/\?#]*\/)|([\/\\]))?((?:[^\/\\\?#]*[\/\\])*)([^\/\\\?#]*)([#\?].*)?$/i, urlParts = url.match(urlPartsRegex), - returner = {}, directories = [], i, baseUrlParts; + returner = {}, rawDirectories = [], directories = [], i, baseUrlParts; if (!urlParts) { throw new Error("Could not parse sheet href - '" + url + "'"); @@ -1292,27 +1387,26 @@ abstractFileManager.prototype.extractUrlParts = function extractUrlParts(url, ba } if (urlParts[3]) { - directories = urlParts[3].replace(/\\/g, "/").split("/"); + rawDirectories = urlParts[3].replace(/\\/g, "/").split("/"); - // extract out . before .. so .. doesn't absorb a non-directory - for (i = 0; i < directories.length; i++) { - if (directories[i] === ".") { - directories.splice(i, 1); - i -= 1; - } - } + // collapse '..' and skip '.' + for (i = 0; i < rawDirectories.length; i++) { - for (i = 0; i < directories.length; i++) { - if (directories[i] === ".." && i > 0) { - directories.splice(i - 1, 2); - i -= 2; + if (rawDirectories[i] === "..") { + directories.pop(); } + else if (rawDirectories[i] !== ".") { + directories.push(rawDirectories[i]); + } + } } returner.hostPart = urlParts[1]; returner.directories = directories; + returner.rawPath = (urlParts[1] || "") + rawDirectories.join("/"); returner.path = (urlParts[1] || "") + directories.join("/"); + returner.filename = urlParts[4]; returner.fileUrl = returner.path + (urlParts[4] || ""); returner.url = returner.fileUrl + (urlParts[5] || ""); return returner; @@ -1320,7 +1414,178 @@ abstractFileManager.prototype.extractUrlParts = function extractUrlParts(url, ba module.exports = abstractFileManager; -},{}],16:[function(require,module,exports){ +},{}],18:[function(require,module,exports){ +var functionRegistry = require("../functions/function-registry"), + LessError = require('../less-error'); + +var AbstractPluginLoader = function() { +}; + +function error(msg, type) { + throw new LessError( + { + type: type || 'Syntax', + message: msg + } + ); +} +AbstractPluginLoader.prototype.evalPlugin = function(contents, context, imports, pluginOptions, fileInfo) { + + var loader, + registry, + pluginObj, + localModule, + pluginManager, + filename; + + pluginManager = context.pluginManager; + + if (fileInfo) { + if (typeof fileInfo === "string") { + filename = fileInfo; + } + else { + filename = fileInfo.filename; + } + } + var shortname = (new this.less.FileManager()).extractUrlParts(filename).filename; + + if (filename) { + pluginObj = pluginManager.get(filename); + + if (pluginObj) { + this.trySetOptions(pluginObj, filename, shortname, pluginOptions); + try { + if (pluginObj.use) { + pluginObj.use.call(this.context, pluginObj); + } + } + catch (e) { + e.message = 'Error during @plugin call'; + return new this.less.LessError(e, imports, filename); + } + return pluginObj; + } + } + localModule = { + exports: {}, + pluginManager: pluginManager, + fileInfo: fileInfo + }; + registry = functionRegistry.create(); + + var registerPlugin = function(obj) { + pluginObj = obj; + }; + + try { + loader = new Function("module", "require", "registerPlugin", "functions", "tree", "less", "fileInfo", contents); + loader(localModule, this.require, registerPlugin, registry, this.less.tree, this.less, fileInfo); + } catch (e) { + return new this.less.LessError(e, imports, filename); + } + + if (!pluginObj) { + pluginObj = localModule.exports; + } + pluginObj = this.validatePlugin(pluginObj, filename, shortname); + + if (pluginObj) { + // Run on first load + pluginManager.addPlugin(pluginObj, fileInfo.filename, registry); + pluginObj.functions = registry.getLocalFunctions(); + pluginObj.imports = imports; + pluginObj.filename = filename; + + this.trySetOptions(pluginObj, filename, shortname, pluginOptions); + + // Run every @plugin call + try { + if (pluginObj.use) { + pluginObj.use.call(this.context, pluginObj); + } + } + catch (e) { + e.message = 'Error during @plugin call'; + return new this.less.LessError(e, imports, filename); + } + + } + else { + return new this.less.LessError({ message: "Not a valid plugin" }); + } + + return pluginObj; + +}; + +AbstractPluginLoader.prototype.trySetOptions = function(plugin, filename, name, options) { + if (options) { + if (!plugin.setOptions) { + error("Options have been provided but the plugin " + name + " does not support any options."); + return null; + } + try { + plugin.setOptions(options); + } + catch (e) { + error("Error setting options on plugin " + name + '\n' + e.message); + return null; + } + } +}; + +AbstractPluginLoader.prototype.validatePlugin = function(plugin, filename, name) { + if (plugin) { + // support plugins being a function + // so that the plugin can be more usable programmatically + if (typeof plugin === "function") { + plugin = new plugin(); + } + + if (plugin.minVersion) { + if (this.compareVersion(plugin.minVersion, this.less.version) < 0) { + error("Plugin " + name + " requires version " + this.versionToString(plugin.minVersion)); + return null; + } + } + return plugin; + } + return null; +}; + +AbstractPluginLoader.prototype.compareVersion = function(aVersion, bVersion) { + if (typeof aVersion === "string") { + aVersion = aVersion.match(/^(\d+)\.?(\d+)?\.?(\d+)?/); + aVersion.shift(); + } + for (var i = 0; i < aVersion.length; i++) { + if (aVersion[i] !== bVersion[i]) { + return parseInt(aVersion[i]) > parseInt(bVersion[i]) ? -1 : 1; + } + } + return 0; +}; +AbstractPluginLoader.prototype.versionToString = function(version) { + var versionString = ""; + for (var i = 0; i < version.length; i++) { + versionString += (versionString ? "." : "") + version[i]; + } + return versionString; +}; +AbstractPluginLoader.prototype.printUsage = function(plugins) { + for (var i = 0; i < plugins.length; i++) { + var plugin = plugins[i]; + if (plugin.printUsage) { + plugin.printUsage(); + } + } +}; + +module.exports = AbstractPluginLoader; + + +},{"../functions/function-registry":26,"../less-error":36}],19:[function(require,module,exports){ var logger = require("../logger"); var environment = function(externalEnvironment, fileManagers) { this.fileManagers = fileManagers || []; @@ -1373,7 +1638,24 @@ environment.prototype.clearFileManagers = function () { module.exports = environment; -},{"../logger":33}],17:[function(require,module,exports){ +},{"../logger":37}],20:[function(require,module,exports){ + +var functionRegistry = require("./function-registry"), + Anonymous = require("../tree/anonymous"), + Keyword = require("../tree/keyword"); + +functionRegistry.addMultiple({ + boolean: function(condition) { + return condition ? Keyword.True : Keyword.False; + }, + + 'if': function(condition, trueValue, falseValue) { + return condition ? trueValue + : (falseValue || new Anonymous); + } +}); + +},{"../tree/anonymous":48,"../tree/keyword":68,"./function-registry":26}],21:[function(require,module,exports){ var Color = require("../tree/color"), functionRegistry = require("./function-registry"); @@ -1449,7 +1731,7 @@ for (var f in colorBlendModeFunctions) { functionRegistry.addMultiple(colorBlend); -},{"../tree/color":50,"./function-registry":22}],18:[function(require,module,exports){ +},{"../tree/color":53,"./function-registry":26}],22:[function(require,module,exports){ var Dimension = require("../tree/dimension"), Color = require("../tree/color"), Quoted = require("../tree/quoted"), @@ -1730,7 +2012,7 @@ colorFunctions = { if (typeof dark === 'undefined') { dark = colorFunctions.rgba(0, 0, 0, 1.0); } - //Figure out which is actually light and dark! + // Figure out which is actually light and dark: if (dark.luma() > light.luma()) { var t = light; light = dark; @@ -1747,6 +2029,44 @@ colorFunctions = { return dark; } }, + // Changes made in 2.7.0 - Reverted in 3.0.0 + // contrast: function (color, color1, color2, threshold) { + // // Return which of `color1` and `color2` has the greatest contrast with `color` + // // according to the standard WCAG contrast ratio calculation. + // // http://www.w3.org/TR/WCAG20/#contrast-ratiodef + // // The threshold param is no longer used, in line with SASS. + // // filter: contrast(3.2); + // // should be kept as is, so check for color + // if (!color.rgb) { + // return null; + // } + // if (typeof color1 === 'undefined') { + // color1 = colorFunctions.rgba(0, 0, 0, 1.0); + // } + // if (typeof color2 === 'undefined') { + // color2 = colorFunctions.rgba(255, 255, 255, 1.0); + // } + // var contrast1, contrast2; + // var luma = color.luma(); + // var luma1 = color1.luma(); + // var luma2 = color2.luma(); + // // Calculate contrast ratios for each color + // if (luma > luma1) { + // contrast1 = (luma + 0.05) / (luma1 + 0.05); + // } else { + // contrast1 = (luma1 + 0.05) / (luma + 0.05); + // } + // if (luma > luma2) { + // contrast2 = (luma + 0.05) / (luma2 + 0.05); + // } else { + // contrast2 = (luma2 + 0.05) / (luma + 0.05); + // } + // if (contrast1 > contrast2) { + // return color1; + // } else { + // return color2; + // } + // }, argb: function (color) { return new Anonymous(color.toARGB()); }, @@ -1773,10 +2093,11 @@ colorFunctions = { }; functionRegistry.addMultiple(colorFunctions); -},{"../tree/anonymous":46,"../tree/color":50,"../tree/dimension":56,"../tree/quoted":73,"./function-registry":22}],19:[function(require,module,exports){ +},{"../tree/anonymous":48,"../tree/color":53,"../tree/dimension":60,"../tree/quoted":77,"./function-registry":26}],23:[function(require,module,exports){ module.exports = function(environment) { var Quoted = require("../tree/quoted"), URL = require("../tree/url"), + utils = require('../utils'), functionRegistry = require("./function-registry"), fallback = function(functionThis, node) { return new URL(node, functionThis.index, functionThis.currentFileInfo).eval(functionThis.context); @@ -1802,8 +2123,10 @@ module.exports = function(environment) { fragment = filePath.slice(fragmentStart); filePath = filePath.slice(0, fragmentStart); } + var context = utils.clone(this.context); + context.rawBuffer = true; - var fileManager = environment.getFileManager(filePath, currentDirectory, this.context, environment, true); + var fileManager = environment.getFileManager(filePath, currentDirectory, context, environment, true); if (!fileManager) { return fallback(this, filePathNode); @@ -1829,7 +2152,7 @@ module.exports = function(environment) { useBase64 = /;base64$/.test(mimetype); } - var fileSync = fileManager.loadFileSync(filePath, currentDirectory, this.context, environment); + var fileSync = fileManager.loadFileSync(filePath, currentDirectory, context, environment); if (!fileSync.contents) { logger.warn("Skipped data-uri embedding of " + filePath + " because file not found"); return fallback(this, filePathNode || mimetypeNode); @@ -1860,7 +2183,7 @@ module.exports = function(environment) { }); }; -},{"../logger":33,"../tree/quoted":73,"../tree/url":80,"./function-registry":22}],20:[function(require,module,exports){ +},{"../logger":37,"../tree/quoted":77,"../tree/url":82,"../utils":86,"./function-registry":26}],24:[function(require,module,exports){ var Keyword = require("../tree/keyword"), functionRegistry = require("./function-registry"); @@ -1889,7 +2212,7 @@ functionRegistry.add("default", defaultFunc.eval.bind(defaultFunc)); module.exports = defaultFunc; -},{"../tree/keyword":65,"./function-registry":22}],21:[function(require,module,exports){ +},{"../tree/keyword":68,"./function-registry":26}],25:[function(require,module,exports){ var Expression = require("../tree/expression"); var functionCaller = function(name, context, index, currentFileInfo) { @@ -1903,8 +2226,8 @@ var functionCaller = function(name, context, index, currentFileInfo) { functionCaller.prototype.isValid = function() { return Boolean(this.func); }; -functionCaller.prototype.call = function(args) { +functionCaller.prototype.call = function(args) { // This code is terrible and should be replaced as per this issue... // https://github.com/less/less.js/issues/2477 if (Array.isArray(args)) { @@ -1937,7 +2260,7 @@ functionCaller.prototype.call = function(args) { module.exports = functionCaller; -},{"../tree/expression":59}],22:[function(require,module,exports){ +},{"../tree/expression":62}],26:[function(require,module,exports){ function makeRegistry( base ) { return { _data: {}, @@ -1947,7 +2270,7 @@ function makeRegistry( base ) { name = name.toLowerCase(); if (this._data.hasOwnProperty(name)) { - //TODO warn + // TODO warn } this._data[name] = func; }, @@ -1960,21 +2283,28 @@ function makeRegistry( base ) { get: function(name) { return this._data[name] || ( base && base.get( name )); }, - inherit : function() { + getLocalFunctions: function() { + return this._data; + }, + inherit: function() { return makeRegistry( this ); + }, + create: function(base) { + return makeRegistry(base); } }; } module.exports = makeRegistry( null ); -},{}],23:[function(require,module,exports){ +},{}],27:[function(require,module,exports){ module.exports = function(environment) { var functions = { functionRegistry: require("./function-registry"), functionCaller: require("./function-caller") }; - //register functions + // register functions + require("./boolean"); require("./default"); require("./color"); require("./color-blending"); @@ -1988,7 +2318,7 @@ module.exports = function(environment) { return functions; }; -},{"./color":18,"./color-blending":17,"./data-uri":19,"./default":20,"./function-caller":21,"./function-registry":22,"./math":25,"./number":26,"./string":27,"./svg":28,"./types":29}],24:[function(require,module,exports){ +},{"./boolean":20,"./color":22,"./color-blending":21,"./data-uri":23,"./default":24,"./function-caller":25,"./function-registry":26,"./math":29,"./number":30,"./string":31,"./svg":32,"./types":33}],28:[function(require,module,exports){ var Dimension = require("../tree/dimension"); var MathHelper = function() { @@ -2005,7 +2335,7 @@ MathHelper._math = function (fn, unit, n) { return new Dimension(fn(parseFloat(n.value)), unit); }; module.exports = MathHelper; -},{"../tree/dimension":56}],25:[function(require,module,exports){ +},{"../tree/dimension":60}],29:[function(require,module,exports){ var functionRegistry = require("./function-registry"), mathHelper = require("./math-helper.js"); @@ -2036,7 +2366,7 @@ mathFunctions.round = function (n, f) { functionRegistry.addMultiple(mathFunctions); -},{"./function-registry":22,"./math-helper.js":24}],26:[function(require,module,exports){ +},{"./function-registry":26,"./math-helper.js":28}],30:[function(require,module,exports){ var Dimension = require("../tree/dimension"), Anonymous = require("../tree/anonymous"), functionRegistry = require("./function-registry"), @@ -2044,7 +2374,7 @@ var Dimension = require("../tree/dimension"), var minMax = function (isMin, args) { args = Array.prototype.slice.call(args); - switch(args.length) { + switch (args.length) { case 0: throw { type: "Argument", message: "one or more arguments required" }; } var i, j, current, currentUnified, referenceUnified, unit, unitStatic, unitClone, @@ -2066,7 +2396,7 @@ var minMax = function (isMin, args) { j = values[""] !== undefined && unit !== "" && unit === unitStatic ? values[""] : values[unit]; if (j === undefined) { if (unitStatic !== undefined && unit !== unitStatic) { - throw{ type: "Argument", message: "incompatible types" }; + throw { type: "Argument", message: "incompatible types" }; } values[unit] = order.length; order.push(current); @@ -2119,7 +2449,7 @@ functionRegistry.addMultiple({ } }); -},{"../tree/anonymous":46,"../tree/dimension":56,"./function-registry":22,"./math-helper.js":24}],27:[function(require,module,exports){ +},{"../tree/anonymous":48,"../tree/dimension":60,"./function-registry":26,"./math-helper.js":28}],31:[function(require,module,exports){ var Quoted = require("../tree/quoted"), Anonymous = require("../tree/anonymous"), JavaScript = require("../tree/javascript"), @@ -2141,12 +2471,12 @@ functionRegistry.addMultiple({ result = result.replace(new RegExp(pattern.value, flags ? flags.value : ''), replacement); return new Quoted(string.quote || '', result, string.escaped); }, - '%': function (string /* arg, arg, ...*/) { + '%': function (string /* arg, arg, ... */) { var args = Array.prototype.slice.call(arguments, 1), result = string.value; for (var i = 0; i < args.length; i++) { - /*jshint loopfunc:true */ + /* jshint loopfunc:true */ result = result.replace(/%[sda]/i, function(token) { var value = ((args[i].type === "Quoted") && token.match(/s/i)) ? args[i].value : args[i].toCSS(); @@ -2158,7 +2488,7 @@ functionRegistry.addMultiple({ } }); -},{"../tree/anonymous":46,"../tree/javascript":63,"../tree/quoted":73,"./function-registry":22}],28:[function(require,module,exports){ +},{"../tree/anonymous":48,"../tree/javascript":66,"../tree/quoted":77,"./function-registry":26}],32:[function(require,module,exports){ module.exports = function(environment) { var Dimension = require("../tree/dimension"), Color = require("../tree/color"), @@ -2176,12 +2506,12 @@ module.exports = function(environment) { renderEnv = {compress: false}, returner, directionValue = direction.toCSS(renderEnv), - i, color, position, positionValue, alpha; + i, color, position, positionValue, alpha; function throwArgumentDescriptor() { throw { type: "Argument", - message: "svg-gradient expects direction, start_color [start_position], [color position,]...," + - " end_color [end_position] or direction, color list" }; + message: "svg-gradient expects direction, start_color [start_position], [color position,]...," + + " end_color [end_position] or direction, color list" }; } if (arguments.length == 2) { @@ -2222,7 +2552,7 @@ module.exports = function(environment) { '' + '<' + gradientType + 'Gradient id="gradient" gradientUnits="userSpaceOnUse" ' + gradientDirectionSvg + '>'; - for (i = 0; i < stops.length; i+= 1) { + for (i = 0; i < stops.length; i += 1) { if (stops[i] instanceof Expression) { color = stops[i].value[0]; position = stops[i].value[1]; @@ -2248,7 +2578,7 @@ module.exports = function(environment) { }); }; -},{"../tree/color":50,"../tree/dimension":56,"../tree/expression":59,"../tree/quoted":73,"../tree/url":80,"./function-registry":22}],29:[function(require,module,exports){ +},{"../tree/color":53,"../tree/dimension":60,"../tree/expression":62,"../tree/quoted":77,"../tree/url":82,"./function-registry":26}],33:[function(require,module,exports){ var Keyword = require("../tree/keyword"), DetachedRuleset = require("../tree/detached-ruleset"), Dimension = require("../tree/dimension"), @@ -2339,10 +2669,12 @@ functionRegistry.addMultiple({ } }); -},{"../tree/anonymous":46,"../tree/color":50,"../tree/detached-ruleset":55,"../tree/dimension":56,"../tree/keyword":65,"../tree/operation":71,"../tree/quoted":73,"../tree/url":80,"./function-registry":22}],30:[function(require,module,exports){ +},{"../tree/anonymous":48,"../tree/color":53,"../tree/detached-ruleset":59,"../tree/dimension":60,"../tree/keyword":68,"../tree/operation":74,"../tree/quoted":77,"../tree/url":82,"./function-registry":26}],34:[function(require,module,exports){ var contexts = require("./contexts"), Parser = require('./parser/parser'), - FunctionImporter = require('./plugins/function-importer'); + LessError = require('./less-error'), + utils = require('./utils'), + PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise; module.exports = function(environment) { @@ -2355,7 +2687,8 @@ module.exports = function(environment) { // 'entryPath' - absolute path to the entry file // 'reference' - whether the file should not be output and only output parts that are referenced - var ImportManager = function(context, rootFileInfo) { + var ImportManager = function(less, context, rootFileInfo) { + this.less = less; this.rootFilename = rootFileInfo.filename; this.paths = context.paths || []; // Search paths, when importing this.contents = {}; // map - filename to contents of all the files @@ -2367,16 +2700,19 @@ module.exports = function(environment) { this.queue = []; // Files which haven't been imported yet this.files = {}; // Holds the imported parse trees. }; + /** * Add an import to be imported * @param path - the raw path - * @param tryAppendLessExtension - whether to try appending the less extension (if the path has no extension) + * @param tryAppendExtension - whether to try appending a file extension (.less or .js if the path has no extension) * @param currentFileInfo - the current file info (used for instance to work out relative paths) * @param importOptions - import options * @param callback - callback for when it is imported */ - ImportManager.prototype.push = function (path, tryAppendLessExtension, currentFileInfo, importOptions, callback) { - var importManager = this; + ImportManager.prototype.push = function (path, tryAppendExtension, currentFileInfo, importOptions, callback) { + var importManager = this, + pluginLoader = this.context.pluginManager.Loader; + this.queue.push(path); var fileParsedFunc = function (e, root, fullPath) { @@ -2387,7 +2723,9 @@ module.exports = function(environment) { callback(null, {rules:[]}, false, null); } else { - importManager.files[fullPath] = root; + if (!importManager.files[fullPath]) { + importManager.files[fullPath] = { root: root, options: importOptions }; + } if (e && !importManager.error) { importManager.error = e; } callback(e, root, importedEqualsRoot, fullPath); } @@ -2407,12 +2745,9 @@ module.exports = function(environment) { return; } - if (tryAppendLessExtension) { - path = fileManager.tryAppendExtension(path, importOptions.plugin ? ".js" : ".less"); - } - var loadFileCallback = function(loadedFile) { - var resolvedFilename = loadedFile.filename, + var plugin, + resolvedFilename = loadedFile.filename, contents = loadedFile.contents.replace(/^\uFEFF/, ''); // Pass on an updated rootpath if path of imported file is relative and file @@ -2444,44 +2779,71 @@ module.exports = function(environment) { newFileInfo.reference = true; } - if (importOptions.plugin) { - new FunctionImporter(newEnv, newFileInfo).eval(contents, function (e, root) { - fileParsedFunc(e, root, resolvedFilename); - }); + if (importOptions.isPlugin) { + plugin = pluginLoader.evalPlugin(contents, newEnv, importManager, importOptions.pluginArgs, newFileInfo); + if (plugin instanceof LessError) { + fileParsedFunc(plugin, null, resolvedFilename); + } + else { + fileParsedFunc(null, plugin, resolvedFilename); + } } else if (importOptions.inline) { fileParsedFunc(null, contents, resolvedFilename); } else { - new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) { - fileParsedFunc(e, root, resolvedFilename); - }); + + // import (multiple) parse trees apparently get altered and can't be cached. + // TODO: investigate why this is + if (importManager.files[resolvedFilename] + && !importManager.files[resolvedFilename].options.multiple + && !importOptions.multiple) { + + fileParsedFunc(null, importManager.files[resolvedFilename].root, resolvedFilename); + } + else { + new Parser(newEnv, importManager, newFileInfo).parse(contents, function (e, root) { + fileParsedFunc(e, root, resolvedFilename); + }); + } } }; + var promise, context = utils.clone(this.context); - var promise = fileManager.loadFile(path, currentFileInfo.currentDirectory, this.context, environment, - function(err, loadedFile) { - if (err) { - fileParsedFunc(err); - } else { - loadFileCallback(loadedFile); - } - }); + if (tryAppendExtension) { + context.ext = importOptions.isPlugin ? ".js" : ".less"; + } + + if (importOptions.isPlugin) { + promise = pluginLoader.loadPlugin(path, currentFileInfo.currentDirectory, context, environment, fileManager); + } + else { + promise = fileManager.loadFile(path, currentFileInfo.currentDirectory, context, environment, + function(err, loadedFile) { + if (err) { + fileParsedFunc(err); + } else { + loadFileCallback(loadedFile); + } + }); + } if (promise) { promise.then(loadFileCallback, fileParsedFunc); } + }; return ImportManager; }; -},{"./contexts":11,"./parser/parser":38,"./plugins/function-importer":40}],31:[function(require,module,exports){ +},{"./contexts":12,"./less-error":36,"./parser/parser":42,"./utils":86,"promise":undefined}],35:[function(require,module,exports){ module.exports = function(environment, fileManagers) { var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment; - var less = { - version: [2, 7, 3], + var initial = { + version: [3, 0, 0], data: require('./data'), tree: require('./tree'), Environment: (Environment = require("./environment/environment")), AbstractFileManager: require("./environment/abstract-file-manager"), + AbstractPluginLoader: require("./environment/abstract-plugin-loader"), environment: (environment = new Environment(environment, fileManagers)), visitors: require('./visitors'), Parser: require('./parser/parser'), @@ -2500,18 +2862,66 @@ module.exports = function(environment, fileManagers) { logger: require('./logger') }; - return less; -}; + // Create a public API -},{"./contexts":11,"./data":13,"./environment/abstract-file-manager":15,"./environment/environment":16,"./functions":23,"./import-manager":30,"./less-error":32,"./logger":33,"./parse":35,"./parse-tree":34,"./parser/parser":38,"./plugin-manager":39,"./render":41,"./source-map-builder":42,"./source-map-output":43,"./transform-tree":44,"./tree":62,"./utils":83,"./visitors":87}],32:[function(require,module,exports){ -var utils = require("./utils"); + var ctor = function(t) { + return function() { + var obj = Object.create(t.prototype); + t.apply(obj, Array.prototype.slice.call(arguments, 0)); + return obj; + }; + }; + var t, api = Object.create(initial); + for (var n in initial.tree) { + /* eslint guard-for-in: 0 */ + t = initial.tree[n]; + if (typeof t === "function") { + api[n.toLowerCase()] = ctor(t); + } + else { + api[n] = Object.create(null); + for (var o in t) { + /* eslint guard-for-in: 0 */ + api[n][o.toLowerCase()] = ctor(t[o]); + } + } + } -var LessError = module.exports = function LessError(e, importManager, currentFilename) { + return api; +}; +},{"./contexts":12,"./data":14,"./environment/abstract-file-manager":17,"./environment/abstract-plugin-loader":18,"./environment/environment":19,"./functions":27,"./import-manager":34,"./less-error":36,"./logger":37,"./parse":39,"./parse-tree":38,"./parser/parser":42,"./plugin-manager":43,"./render":44,"./source-map-builder":45,"./source-map-output":46,"./transform-tree":47,"./tree":65,"./utils":86,"./visitors":90}],36:[function(require,module,exports){ +var utils = require('./utils'); +/** + * This is a centralized class of any error that could be thrown internally (mostly by the parser). + * Besides standard .message it keeps some additional data like a path to the file where the error + * occurred along with line and column numbers. + * + * @class + * @extends Error + * @type {module.LessError} + * + * @prop {string} type + * @prop {string} filename + * @prop {number} index + * @prop {number} line + * @prop {number} column + * @prop {number} callLine + * @prop {number} callExtract + * @prop {string[]} extract + * + * @param {Object} e - An error object to wrap around or just a descriptive object + * @param {Object} importManager - An instance of ImportManager (see import-manager.js) + * @param {string} [currentFilename] + */ +var LessError = module.exports = function LessError(e, importManager, currentFilename) { Error.call(this); var filename = e.filename || currentFilename; + this.message = e.message; + this.stack = e.stack; + if (importManager && filename) { var input = importManager.contents[filename], loc = utils.getLocation(e.index, input), @@ -2524,17 +2934,32 @@ var LessError = module.exports = function LessError(e, importManager, currentFil this.filename = filename; this.index = e.index; this.line = typeof line === 'number' ? line + 1 : null; + this.column = col; + + if (!this.line && this.stack) { + var found = this.stack.match(/(|Function):(\d+):(\d+)/); + + if (found) { + if (found[2]) { + this.line = parseInt(found[2]) - 2; + } + if (found[3]) { + this.column = parseInt(found[3]); + } + } + } + this.callLine = callLine + 1; this.callExtract = lines[callLine]; - this.column = col; + this.extract = [ - lines[line - 1], - lines[line], - lines[line + 1] + lines[this.line - 2], + lines[this.line - 1], + lines[this.line] ]; + } - this.message = e.message; - this.stack = e.stack; + }; if (typeof Object.create === 'undefined') { @@ -2547,26 +2972,87 @@ if (typeof Object.create === 'undefined') { LessError.prototype.constructor = LessError; -},{"./utils":83}],33:[function(require,module,exports){ -module.exports = { - error: function(msg) { - this._fireEvent("error", msg); - }, - warn: function(msg) { - this._fireEvent("warn", msg); - }, - info: function(msg) { - this._fireEvent("info", msg); - }, - debug: function(msg) { - this._fireEvent("debug", msg); - }, - addListener: function(listener) { - this._listeners.push(listener); - }, - removeListener: function(listener) { - for (var i = 0; i < this._listeners.length; i++) { - if (this._listeners[i] === listener) { +/** + * An overridden version of the default Object.prototype.toString + * which uses additional information to create a helpful message. + * + * @param {Object} options + * @returns {string} + */ +LessError.prototype.toString = function(options) { + options = options || {}; + + var message = ''; + var extract = this.extract || []; + var error = []; + var stylize = function (str) { return str; }; + if (options.stylize) { + var type = typeof options.stylize; + if (type !== 'function') { + throw Error('options.stylize should be a function, got a ' + type + '!'); + } + stylize = options.stylize; + } + + if (this.line !== null) { + if (typeof extract[0] === 'string') { + error.push(stylize((this.line - 1) + ' ' + extract[0], 'grey')); + } + + if (typeof extract[1] === 'string') { + var errorTxt = this.line + ' '; + if (extract[1]) { + errorTxt += extract[1].slice(0, this.column) + + stylize(stylize(stylize(extract[1].substr(this.column, 1), 'bold') + + extract[1].slice(this.column + 1), 'red'), 'inverse'); + } + error.push(errorTxt); + } + + if (typeof extract[2] === 'string') { + error.push(stylize((this.line + 1) + ' ' + extract[2], 'grey')); + } + error = error.join('\n') + stylize('', 'reset') + '\n'; + } + + message += stylize(this.type + 'Error: ' + this.message, 'red'); + if (this.filename) { + message += stylize(' in ', 'red') + this.filename; + } + if (this.line) { + message += stylize(' on line ' + this.line + ', column ' + (this.column + 1) + ':', 'grey'); + } + + message += '\n' + error; + + if (this.callLine) { + message += stylize('from ', 'red') + (this.filename || '') + '/n'; + message += stylize(this.callLine, 'grey') + ' ' + this.callExtract + '/n'; + } + + return message; +}; + +},{"./utils":86}],37:[function(require,module,exports){ +module.exports = { + error: function(msg) { + this._fireEvent("error", msg); + }, + warn: function(msg) { + this._fireEvent("warn", msg); + }, + info: function(msg) { + this._fireEvent("info", msg); + }, + debug: function(msg) { + this._fireEvent("debug", msg); + }, + addListener: function(listener) { + this._listeners.push(listener); + }, + removeListener: function(listener) { + for (var i = 0; i < this._listeners.length; i++) { + if (this._listeners[i] === listener) { this._listeners.splice(i, 1); return; } @@ -2583,7 +3069,7 @@ module.exports = { _listeners: [] }; -},{}],34:[function(require,module,exports){ +},{}],38:[function(require,module,exports){ var LessError = require('./less-error'), transformTree = require("./transform-tree"), logger = require("./logger"); @@ -2645,19 +3131,23 @@ module.exports = function(SourceMapBuilder) { return ParseTree; }; -},{"./less-error":32,"./logger":33,"./transform-tree":44}],35:[function(require,module,exports){ +},{"./less-error":36,"./logger":37,"./transform-tree":47}],39:[function(require,module,exports){ var PromiseConstructor, contexts = require("./contexts"), Parser = require('./parser/parser'), - PluginManager = require('./plugin-manager'); + PluginManager = require('./plugin-manager'), + LessError = require('./less-error'), + utils = require('./utils'); module.exports = function(environment, ParseTree, ImportManager) { var parse = function (input, options, callback) { - options = options || {}; if (typeof options === 'function') { callback = options; - options = {}; + options = utils.defaults(this.options, {}); + } + else { + options = utils.defaults(this.options, options || {}); } if (!callback) { @@ -2677,9 +3167,8 @@ module.exports = function(environment, ParseTree, ImportManager) { } else { var context, rootFileInfo, - pluginManager = new PluginManager(this); + pluginManager = new PluginManager(this, true); - pluginManager.addPlugins(options.plugins); options.pluginManager = pluginManager; context = new contexts.Parse(options); @@ -2703,19 +3192,39 @@ module.exports = function(environment, ParseTree, ImportManager) { } } - var imports = new ImportManager(context, rootFileInfo); + var imports = new ImportManager(this, context, rootFileInfo); + this.importManager = imports; + // TODO: allow the plugins to be just a list of paths or names + // Do an async plugin queue like lessc + + if (options.plugins) { + options.plugins.forEach(function(plugin) { + var evalResult, contents; + if (plugin.fileContent) { + contents = plugin.fileContent.replace(/^\uFEFF/, ''); + evalResult = pluginManager.Loader.evalPlugin(contents, context, imports, plugin.options, plugin.filename); + if (evalResult instanceof LessError) { + return callback(evalResult); + } + } + else { + pluginManager.addPlugin(plugin); + } + }); + } + new Parser(context, imports, rootFileInfo) .parse(input, function (e, root) { - if (e) { return callback(e); } - callback(null, root, imports, options); - }, options); + if (e) { return callback(e); } + callback(null, root, imports, options); + }, options); } }; return parse; }; -},{"./contexts":11,"./parser/parser":38,"./plugin-manager":39,"promise":undefined}],36:[function(require,module,exports){ +},{"./contexts":12,"./less-error":36,"./parser/parser":42,"./plugin-manager":43,"./utils":86,"promise":undefined}],40:[function(require,module,exports){ // Split the input into chunks. module.exports = function (input, fail) { var len = input.length, level = 0, parenLevel = 0, @@ -2829,15 +3338,15 @@ module.exports = function (input, fail) { return chunks; }; -},{}],37:[function(require,module,exports){ +},{}],41:[function(require,module,exports){ var chunker = require('./chunker'); module.exports = function() { - var input, // LeSS input string + var input, // Less input string j, // current chunk saveStack = [], // holds state for backtracking furthest, // furthest index the parser has gone to - furthestPossibleErrorMessage,// if this is furthest we got to, this is the probably cause + furthestPossibleErrorMessage, // if this is furthest we got to, this is the probably cause chunks, // chunkified input current, // current chunk currentPos, // index of current chunk, in `input` @@ -2988,7 +3497,7 @@ module.exports = function() { for (var i = 1; i + currentPosition < length; i++) { var nextChar = input.charAt(i + currentPosition); - switch(nextChar) { + switch (nextChar) { case "\\": i++; continue; @@ -3041,7 +3550,7 @@ module.exports = function() { parserInput.peekNotNumeric = function() { var c = input.charCodeAt(parserInput.i); - //Is the first char of the dimension 0-9, '.', '+' or '-' + // Is the first char of the dimension 0-9, '.', '+' or '-' return (c > CHARCODE_9 || c < CHARCODE_PLUS) || c === CHARCODE_FORWARD_SLASH || c === CHARCODE_COMMA; }; @@ -3090,12 +3599,13 @@ module.exports = function() { return parserInput; }; -},{"./chunker":36}],38:[function(require,module,exports){ +},{"./chunker":40}],42:[function(require,module,exports){ var LessError = require('../less-error'), tree = require("../tree"), visitors = require("../visitors"), getParserInput = require("./parser-input"), - utils = require("../utils"); + utils = require("../utils"), + functionRegistry = require('../functions/function-registry'); // // less.js - parser @@ -3128,8 +3638,8 @@ var LessError = require('../less-error'), // Token matching is done with the `$` function, which either takes // a terminal string or regexp, or a non-terminal function to call. // It also takes care of moving all the indices forwards. -//` // + var Parser = function Parser(context, imports, fileInfo) { var parsers, parserInput = getParserInput(); @@ -3173,11 +3683,61 @@ var Parser = function Parser(context, imports, fileInfo) { }; } + /** + * Used after initial parsing to create nodes on the fly + * + * @param {String} str - string to parse + * @param {Array} parseList - array of parsers to run input through e.g. ["value", "important"] + * @param {Number} currentIndex - start number to begin indexing + * @param {Object} fileInfo - fileInfo to attach to created nodes + */ + function parseNode(str, parseList, currentIndex, fileInfo, callback) { + var result, returnNodes = []; + var parser = parserInput; + + try { + parser.start(str, false, function fail(msg, index) { + callback({ + message: msg, + index: index + currentIndex + }); + }); + for (var x = 0, p, i; (p = parseList[x]); x++) { + i = parser.i; + result = parsers[p](); + if (result) { + result._index = i + currentIndex; + result._fileInfo = fileInfo; + returnNodes.push(result); + } + else { + returnNodes.push(null); + } + } + + var endInfo = parser.end(); + if (endInfo.isFinished) { + callback(null, returnNodes); + } + else { + callback(true, null); + } + } catch (e) { + throw new LessError({ + index: e.index + currentIndex, + message: e.message + }, imports, fileInfo.filename); + } + } + // // The Parser // return { - + parserInput: parserInput, + imports: imports, + fileInfo: fileInfo, + parseNode: parseNode, // // Parse an input string into an abstract syntax tree, // @param str A string containing 'less' markup @@ -3223,9 +3783,13 @@ var Parser = function Parser(context, imports, fileInfo) { }, imports); }); - root = new(tree.Ruleset)(null, this.parsers.primary()); + tree.Node.prototype.parse = this; + root = new tree.Ruleset(null, this.parsers.primary()); + tree.Node.prototype.rootNode = root; root.root = true; root.firstRoot = true; + root.functionRegistry = functionRegistry.inherit(); + } catch (e) { return callback(new LessError(e, imports, fileInfo.filename)); } @@ -3290,7 +3854,7 @@ var Parser = function Parser(context, imports, fileInfo) { // // The basic structure of the syntax tree generated is as follows: // - // Ruleset -> Rule -> Value -> Expression -> Entity + // Ruleset -> Declaration -> Value -> Expression -> Entity // // Here's some Less code: // @@ -3304,9 +3868,9 @@ var Parser = function Parser(context, imports, fileInfo) { // And here's what the parse tree might look like: // // Ruleset (Selector '.class', [ - // Rule ("color", Value ([Expression [Color #fff]])) - // Rule ("border", Value ([Expression [Dimension 1px][Keyword "solid"][Color #000]])) - // Rule ("width", Value ([Expression [Operation " + " [Variable "@w"][Dimension 4px]]])) + // Declaration ("color", Value ([Expression [Color #fff]])) + // Declaration ("border", Value ([Expression [Dimension 1px][Keyword "solid"][Color #000]])) + // Declaration ("width", Value ([Expression [Operation " + " [Variable "@w"][Dimension 4px]]])) // Ruleset (Selector [Element '>', '.child'], [...]) // ]) // @@ -3323,7 +3887,7 @@ var Parser = function Parser(context, imports, fileInfo) { // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule, // as represented by this simplified grammar: // - // primary → (ruleset | rule)+ + // primary → (ruleset | declaration)+ // ruleset → selector+ block // block → '{' primary '}' // @@ -3353,8 +3917,8 @@ var Parser = function Parser(context, imports, fileInfo) { continue; } - node = mixin.definition() || this.rule() || this.ruleset() || - mixin.call() || this.rulesetCall() || this.entities.call() || this.directive(); + node = mixin.definition() || this.declaration() || this.ruleset() || + mixin.call() || this.variableCall() || this.entities.call() || this.atrule(); if (node) { root.push(node); } else { @@ -3412,7 +3976,7 @@ var Parser = function Parser(context, imports, fileInfo) { // black border-collapse // keyword: function () { - var k = parserInput.$char("%") || parserInput.$re(/^[_A-Za-z-][_A-Za-z0-9-]*/); + var k = parserInput.$char("%") || parserInput.$re(/^\[?[_A-Za-z-][_A-Za-z0-9-]*\]?/); if (k) { return tree.Color.fromKeyword(k) || new(tree.Keyword)(k); } @@ -3423,13 +3987,10 @@ var Parser = function Parser(context, imports, fileInfo) { // // rgb(255, 0, 255) // - // We also try to catch IE's `alpha()`, but let the `alpha` parser - // deal with the details. - // // The arguments are parsed with the `entities.arguments` parser. // call: function () { - var name, nameLC, args, alpha, index = parserInput.i; + var name, args, func, index = parserInput.i; // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18 if (parserInput.peek(/^url\(/i)) { @@ -3439,70 +4000,98 @@ var Parser = function Parser(context, imports, fileInfo) { parserInput.save(); name = parserInput.$re(/^([\w-]+|%|progid:[\w\.]+)\(/); - if (!name) { parserInput.forget(); return; } + if (!name) { + parserInput.forget(); + return; + } name = name[1]; - nameLC = name.toLowerCase(); - - if (nameLC === 'alpha') { - alpha = parsers.alpha(); - if (alpha) { + func = this.customFuncCall(name); + if (func) { + args = func.parse(); + if (args && func.stop) { parserInput.forget(); - return alpha; + return args; } } - args = this.arguments(); + args = this.arguments(args); - if (! parserInput.$char(')')) { + if (!parserInput.$char(')')) { parserInput.restore("Could not parse call arguments or missing ')'"); return; } parserInput.forget(); + return new(tree.Call)(name, args, index, fileInfo); }, - arguments: function () { - var argsSemiColon = [], argsComma = [], - expressions = [], - isSemiColonSeparated, value, arg; - - parserInput.save(); + + // + // Parsing rules for functions with non-standard args, e.g.: + // + // boolean(not(2 > 1)) + // + // This is a quick prototype, to be modified/improved when + // more custom-parsed funcs come (e.g. `selector(...)`) + // - while (true) { + customFuncCall: function (name) { + /* Ideally the table is to be moved out of here for faster perf., + but it's quite tricky since it relies on all these `parsers` + and `expect` available only here */ + return { + alpha: f(parsers.ieAlpha, true), + boolean: f(condition), + 'if': f(condition) + }[name.toLowerCase()]; + + function f(parse, stop) { + return { + parse: parse, // parsing function + stop: stop // when true - stop after parse() and return its result, + // otherwise continue for plain args + }; + } + + function condition() { + return [expect(parsers.condition, 'expected condition')]; + } + }, - arg = parsers.detachedRuleset() || this.assignment() || parsers.expression(); + arguments: function (prevArgs) { + var argsComma = prevArgs || [], + argsSemiColon = [], + isSemiColonSeparated, value; - if (!arg) { - break; - } + parserInput.save(); - value = arg; + while (true) { + if (prevArgs) { + prevArgs = false; + } else { + value = parsers.detachedRuleset() || this.assignment() || parsers.expression(); + if (!value) { + break; + } - if (arg.value && arg.value.length == 1) { - value = arg.value[0]; - } + if (value.value && value.value.length == 1) { + value = value.value[0]; + } - if (value) { - expressions.push(value); + argsComma.push(value); } - argsComma.push(value); - if (parserInput.$char(',')) { continue; } if (parserInput.$char(';') || isSemiColonSeparated) { - isSemiColonSeparated = true; - - if (expressions.length > 1) { - value = new(tree.Value)(expressions); - } + value = (argsComma.length < 1) ? argsComma[0] + : new tree.Value(argsComma); argsSemiColon.push(value); - - expressions = []; + argsComma = []; } } @@ -3560,15 +4149,17 @@ var Parser = function Parser(context, imports, fileInfo) { return; } - value = this.quoted() || this.variable() || + value = this.quoted() || this.variable() || this.property() || parserInput.$re(/^(?:(?:\\[\(\)'"])|[^\(\)'"])+/) || ""; parserInput.autoCommentAbsorb = true; expectChar(')'); - return new(tree.URL)((value.value != null || value instanceof tree.Variable) ? - value : new(tree.Anonymous)(value), index, fileInfo); + return new(tree.URL)((value.value != null || + value instanceof tree.Variable || + value instanceof tree.Property) ? + value : new(tree.Anonymous)(value, index), index, fileInfo); }, // @@ -3595,7 +4186,27 @@ var Parser = function Parser(context, imports, fileInfo) { return new(tree.Variable)("@" + curly[1], index, fileInfo); } }, + // + // A Property accessor, such as `$color`, in + // + // background-color: $color + // + property: function () { + var name, index = parserInput.i; + + if (parserInput.currentChar() === '$' && (name = parserInput.$re(/^\$[\w-]+/))) { + return new(tree.Property)(name, index, fileInfo); + } + }, + + // A property entity useing the protective {} e.g. ${prop} + propertyCurly: function () { + var curly, index = parserInput.i; + if (parserInput.currentChar() === '$' && (curly = parserInput.$re(/^\$\{([\w-]+)\}/))) { + return new(tree.Property)("$" + curly[1], index, fileInfo); + } + }, // // A Hexadecimal color // @@ -3705,15 +4316,17 @@ var Parser = function Parser(context, imports, fileInfo) { }, // - // The variable part of a variable definition. Used in the `rule` parser + // Call a variable value // - // @fink(); + // @fink() // - rulesetCall: function () { + variableCall: function () { var name; - if (parserInput.currentChar() === '@' && (name = parserInput.$re(/^(@[\w-]+)\(\s*\)\s*;/))) { - return new tree.RulesetCall(name[1]); + if (parserInput.currentChar() === '@' + && (name = parserInput.$re(/^(@[\w-]+)\(\s*\)/)) + && parsers.end()) { + return new tree.VariableCall(name[1]); } }, @@ -3730,7 +4343,7 @@ var Parser = function Parser(context, imports, fileInfo) { do { option = null; elements = null; - while (! (option = parserInput.$re(/^(all)(?=\s*(\)|,))/))) { + while (!(option = parserInput.$re(/^(all)(?=\s*(\)|,))/))) { e = this.element(); if (!e) { break; @@ -3849,7 +4462,7 @@ var Parser = function Parser(context, imports, fileInfo) { .push({ variadic: true }); break; } - arg = entities.variable() || entities.literal() || entities.keyword(); + arg = entities.variable() || entities.property() || entities.literal() || entities.keyword(); } if (!arg) { @@ -3872,7 +4485,7 @@ var Parser = function Parser(context, imports, fileInfo) { val = arg; } - if (val && val instanceof tree.Variable) { + if (val && (val instanceof tree.Variable || val instanceof tree.Property)) { if (parserInput.$char(':')) { if (expressions.length > 0) { if (isSemiColonSeparated) { @@ -4018,11 +4631,11 @@ var Parser = function Parser(context, imports, fileInfo) { var entities = this.entities; return this.comment() || entities.literal() || entities.variable() || entities.url() || - entities.call() || entities.keyword() || entities.javascript(); + entities.property() || entities.call() || entities.keyword() || entities.javascript(); }, // - // A Rule terminator. Note that we use `peek()` to check for '}', + // A Declaration terminator. Note that we use `peek()` to check for '}', // because the `block` rule will be expecting it, but we still need to make sure // it's there, if ';' was omitted. // @@ -4035,17 +4648,18 @@ var Parser = function Parser(context, imports, fileInfo) { // // alpha(opacity=88) // - alpha: function () { + ieAlpha: function () { var value; // http://jsperf.com/case-insensitive-regex-vs-strtolower-then-regex/18 - if (! parserInput.$re(/^opacity=/i)) { return; } + if (!parserInput.$re(/^opacity=/i)) { return; } value = parserInput.$re(/^\d+/); if (!value) { - value = expect(this.entities.variable, "Could not parse alpha"); + value = expect(parsers.entities.variable, "Could not parse alpha"); + value = '@{' + value.name.slice(1) + '}'; } expectChar(')'); - return new(tree.Alpha)(value); + return new tree.Quoted('', 'alpha(opacity=' + value + ')'); }, // @@ -4071,10 +4685,10 @@ var Parser = function Parser(context, imports, fileInfo) { parserInput.$re(/^\([^&()@]+\)/) || parserInput.$re(/^[\.#:](?=@)/) || this.entities.variableCurly(); - if (! e) { + if (!e) { parserInput.save(); if (parserInput.$char('(')) { - if ((v = this.selector()) && parserInput.$char(')')) { + if ((v = this.selector(false)) && parserInput.$char(')')) { e = new(tree.Paren)(v); parserInput.forget(); } else { @@ -4125,14 +4739,8 @@ var Parser = function Parser(context, imports, fileInfo) { } }, // - // A CSS selector (see selector below) - // with less extensions e.g. the ability to extend and guard - // - lessSelector: function () { - return this.selector(true); - }, - // // A CSS Selector + // with less extensions e.g. the ability to extend and guard // // .class > div + h1 // li a:hover @@ -4141,7 +4749,7 @@ var Parser = function Parser(context, imports, fileInfo) { // selector: function (isLess) { var index = parserInput.i, elements, extendList, c, e, allExtends, when, condition; - + isLess = isLess !== false; while ((isLess && (extendList = this.extend())) || (isLess && (when = parserInput.$str("when"))) || (e = this.element())) { if (when) { condition = expect(this.conditions, 'expected condition'); @@ -4172,7 +4780,7 @@ var Parser = function Parser(context, imports, fileInfo) { if (allExtends) { error("Extend must be used to extend a selector, it cannot be used on its own"); } }, attribute: function () { - if (! parserInput.$char('[')) { return; } + if (!parserInput.$char('[')) { return; } var entities = this.entities, key, val, op; @@ -4231,7 +4839,7 @@ var Parser = function Parser(context, imports, fileInfo) { } while (true) { - s = this.lessSelector(); + s = this.selector(); if (!s) { break; } @@ -4244,7 +4852,7 @@ var Parser = function Parser(context, imports, fileInfo) { if (s.condition && selectors.length > 1) { error("Guards are only currently allowed on a single selector."); } - if (! parserInput.$char(',')) { break; } + if (!parserInput.$char(',')) { break; } if (s.condition) { error("Guards are only currently allowed on a single selector."); } @@ -4262,7 +4870,7 @@ var Parser = function Parser(context, imports, fileInfo) { parserInput.restore(); } }, - rule: function (tryAnonymous) { + declaration: function () { var name, value, startOfRule = parserInput.i, c = parserInput.currentChar(), important, merge, isVariable; if (c === '.' || c === '#' || c === '&' || c === ':') { return; } @@ -4284,22 +4892,16 @@ var Parser = function Parser(context, imports, fileInfo) { // where each item is a tree.Keyword or tree.Variable merge = !isVariable && name.length > 1 && name.pop().value; - // prefer to try to parse first if its a variable or we are compressing - // but always fallback on the other one - var tryValueFirst = !tryAnonymous && (context.compress || isVariable); - - if (tryValueFirst) { - value = this.value(); + // Try to store values as anonymous + // If we need the value later we'll re-parse it in ruleset.parseValue + value = this.anonymousValue(); + if (value) { + parserInput.forget(); + // anonymous values absorb the end ';' which is required for them to work + return new (tree.Declaration)(name, value, false, merge, startOfRule, fileInfo); } + if (!value) { - value = this.anonymousValue(); - if (value) { - parserInput.forget(); - // anonymous values absorb the end ';' which is required for them to work - return new (tree.Rule)(name, value, false, merge, startOfRule, fileInfo); - } - } - if (!tryValueFirst && !value) { value = this.value(); } @@ -4308,26 +4910,25 @@ var Parser = function Parser(context, imports, fileInfo) { if (value && this.end()) { parserInput.forget(); - return new (tree.Rule)(name, value, important, merge, startOfRule, fileInfo); - } else { + return new (tree.Declaration)(name, value, important, merge, startOfRule, fileInfo); + } + else { parserInput.restore(); - if (value && !tryAnonymous) { - return this.rule(true); - } } } else { - parserInput.forget(); + parserInput.restore(); } }, anonymousValue: function () { - var match = parserInput.$re(/^([^@+\/'"*`(;{}-]*);/); + var index = parserInput.i; + var match = parserInput.$re(/^([^@\$+\/'"*`(;{}-]*);/); if (match) { - return new(tree.Anonymous)(match[1]); + return new(tree.Anonymous)(match[1], index); } }, // - // An @import directive + // An @import atrule // // @import "lib"; // @@ -4365,13 +4966,13 @@ var Parser = function Parser(context, imports, fileInfo) { var o, options = {}, optionName, value; // list of options, surrounded by parens - if (! parserInput.$char('(')) { return null; } + if (!parserInput.$char('(')) { return null; } do { o = this.importOption(); if (o) { optionName = o; value = true; - switch(optionName) { + switch (optionName) { case "css": optionName = "less"; value = false; @@ -4382,7 +4983,7 @@ var Parser = function Parser(context, imports, fileInfo) { break; } options[optionName] = value; - if (! parserInput.$char(',')) { break; } + if (!parserInput.$char(',')) { break; } } } while (o); expectChar(')'); @@ -4408,7 +5009,7 @@ var Parser = function Parser(context, imports, fileInfo) { e = this.value(); if (parserInput.$char(')')) { if (p && e) { - nodes.push(new(tree.Paren)(new(tree.Rule)(p, e, null, null, parserInput.i, fileInfo, true))); + nodes.push(new(tree.Paren)(new(tree.Declaration)(p, e, null, null, parserInput.i, fileInfo, true))); } else if (e) { nodes.push(new(tree.Paren)(e)); } else { @@ -4432,12 +5033,12 @@ var Parser = function Parser(context, imports, fileInfo) { e = this.mediaFeature(); if (e) { features.push(e); - if (! parserInput.$char(',')) { break; } + if (!parserInput.$char(',')) { break; } } else { e = entities.variable(); if (e) { features.push(e); - if (! parserInput.$char(',')) { break; } + if (!parserInput.$char(',')) { break; } } } } while (e); @@ -4477,45 +5078,68 @@ var Parser = function Parser(context, imports, fileInfo) { }, // - // A @plugin directive, used to import compiler extensions dynamically. - // - // @plugin "lib"; + + // A @plugin directive, used to import plugins dynamically. // - // Depending on our environment, importing is done differently: - // In the browser, it's an XHR request, in Node, it would be a - // file-system operation. The function used for importing is - // stored in `import`, which we pass to the Import constructor. + // @plugin (args) "lib"; // plugin: function () { - var path, + var path, args, options, index = parserInput.i, dir = parserInput.$re(/^@plugin?\s+/); if (dir) { - var options = { plugin : true }; + args = this.pluginArgs(); + + if (args) { + options = { + pluginArgs: args, + isPlugin: true + }; + } + else { + options = { isPlugin: true }; + } if ((path = this.entities.quoted() || this.entities.url())) { if (!parserInput.$char(';')) { parserInput.i = index; - error("missing semi-colon on plugin"); + error("missing semi-colon on @plugin"); } - return new(tree.Import)(path, null, options, index, fileInfo); } else { parserInput.i = index; - error("malformed plugin statement"); + error("malformed @plugin statement"); } } }, + pluginArgs: function() { + // list of options, surrounded by parens + parserInput.save(); + if (!parserInput.$char('(')) { + parserInput.restore(); + return null; + } + var args = parserInput.$re(/^\s*([^\);]+)\)\s*/); + if (args[1]) { + parserInput.forget(); + return args[1].trim(); + } + else { + parserInput.restore(); + return null; + } + }, + // - // A CSS Directive + // A CSS AtRule // // @charset "utf-8"; // - directive: function () { + atrule: function () { var index = parserInput.i, name, value, rules, nonVendorSpecificName, hasIdentifier, hasExpression, hasUnknown, hasBlock = true, isRooted = true; @@ -4537,7 +5161,7 @@ var Parser = function Parser(context, imports, fileInfo) { nonVendorSpecificName = "@" + name.slice(name.indexOf('-', 2) + 1); } - switch(nonVendorSpecificName) { + switch (nonVendorSpecificName) { case "@charset": hasIdentifier = true; hasBlock = false; @@ -4586,13 +5210,13 @@ var Parser = function Parser(context, imports, fileInfo) { if (rules || (!hasBlock && value && parserInput.$char(';'))) { parserInput.forget(); - return new (tree.Directive)(name, value, rules, index, fileInfo, + return new (tree.AtRule)(name, value, rules, index, fileInfo, context.dumpLineNumbers ? getDebugInfo(index) : null, isRooted ); } - parserInput.restore("directive options not recognised"); + parserInput.restore("at-rule options not recognised"); }, // @@ -4604,18 +5228,18 @@ var Parser = function Parser(context, imports, fileInfo) { // and before the `;`. // value: function () { - var e, expressions = []; + var e, expressions = [], index = parserInput.i; do { e = this.expression(); if (e) { expressions.push(e); - if (! parserInput.$char(',')) { break; } + if (!parserInput.$char(',')) { break; } } } while (e); if (expressions.length > 0) { - return new(tree.Value)(expressions); + return new(tree.Value)(expressions, index); } }, important: function () { @@ -4854,13 +5478,14 @@ var Parser = function Parser(context, imports, fileInfo) { operand: function () { var entities = this.entities, negate; - if (parserInput.peek(/^-[@\(]/)) { + if (parserInput.peek(/^-[@\$\(]/)) { negate = parserInput.$char('-'); } var o = this.sub() || entities.dimension() || entities.color() || entities.variable() || - entities.call() || entities.colorKeyword(); + entities.property() || entities.call() || + entities.colorKeyword(); if (negate) { o.parensInOp = true; @@ -4878,7 +5503,7 @@ var Parser = function Parser(context, imports, fileInfo) { // @var * 2 // expression: function () { - var entities = [], e, delim; + var entities = [], e, delim, index = parserInput.i; do { e = this.comment(); @@ -4893,7 +5518,7 @@ var Parser = function Parser(context, imports, fileInfo) { if (!parserInput.peek(/^\/[\/*]/)) { delim = parserInput.$char('/'); if (delim) { - entities.push(new(tree.Anonymous)(delim)); + entities.push(new(tree.Anonymous)(delim, index)); } } } @@ -4931,7 +5556,7 @@ var Parser = function Parser(context, imports, fileInfo) { match(/^(\*?)/); while (true) { - if (!match(/^((?:[\w-]+)|(?:@\{[\w-]+\}))/)) { + if (!match(/^((?:[\w-]+)|(?:[@\$]\{[\w-]+\}))/)) { break; } } @@ -4947,10 +5572,11 @@ var Parser = function Parser(context, imports, fileInfo) { } for (k = 0; k < name.length; k++) { s = name[k]; - name[k] = (s.charAt(0) !== '@') ? + name[k] = (s.charAt(0) !== '@' && s.charAt(0) !== '$') ? new(tree.Keyword)(s) : - new(tree.Variable)('@' + s.slice(2, -1), - index[k], fileInfo); + (s.charAt(0) === '@' ? + new(tree.Variable)('@' + s.slice(2, -1), index[k], fileInfo) : + new(tree.Property)('$' + s.slice(2, -1), index[k], fileInfo)); } return name; } @@ -4975,7 +5601,7 @@ Parser.serializeVars = function(vars) { module.exports = Parser; -},{"../less-error":32,"../tree":62,"../utils":83,"../visitors":87,"./parser-input":37}],39:[function(require,module,exports){ +},{"../functions/function-registry":26,"../less-error":36,"../tree":65,"../utils":86,"../visitors":90,"./parser-input":41}],43:[function(require,module,exports){ /** * Plugin Manager */ @@ -4986,7 +5612,18 @@ var PluginManager = function(less) { this.postProcessors = []; this.installedPlugins = []; this.fileManagers = []; + this.iterator = -1; + this.pluginCache = {}; + this.Loader = new less.PluginLoader(less); }; + +var pm, PluginManagerFactory = function(less, newFactory) { + if (newFactory || !pm) { + pm = new PluginManager(less); + } + return pm; + }; + /** * Adds all the plugins in the array * @param {Array} plugins @@ -5001,11 +5638,25 @@ PluginManager.prototype.addPlugins = function(plugins) { /** * * @param plugin + * @param {String} filename */ -PluginManager.prototype.addPlugin = function(plugin) { +PluginManager.prototype.addPlugin = function(plugin, filename, functionRegistry) { this.installedPlugins.push(plugin); - plugin.install(this.less, this); + if (filename) { + this.pluginCache[filename] = plugin; + } + if (plugin.install) { + plugin.install(this.less, this, functionRegistry || this.less.functions.functionRegistry); + } +}; +/** + * + * @param filename + */ +PluginManager.prototype.get = function(filename) { + return this.pluginCache[filename]; }; + /** * Adds a visitor. The visitor object has options on itself to determine * when it should run. @@ -5081,6 +5732,20 @@ PluginManager.prototype.getPostProcessors = function() { PluginManager.prototype.getVisitors = function() { return this.visitors; }; + +PluginManager.prototype.visitor = function() { + var self = this; + return { + first: function() { + self.iterator = -1; + return self.visitors[self.iterator]; + }, + get: function() { + self.iterator += 1; + return self.visitors[self.iterator]; + } + }; +}; /** * * @returns {Array} @@ -5089,53 +5754,22 @@ PluginManager.prototype.getVisitors = function() { PluginManager.prototype.getFileManagers = function() { return this.fileManagers; }; -module.exports = PluginManager; - -},{}],40:[function(require,module,exports){ -var LessError = require('../less-error'), - tree = require("../tree"); - -var FunctionImporter = module.exports = function FunctionImporter(context, fileInfo) { - this.fileInfo = fileInfo; -}; - -FunctionImporter.prototype.eval = function(contents, callback) { - var loaded = {}, - loader, - registry; - - registry = { - add: function(name, func) { - loaded[name] = func; - }, - addMultiple: function(functions) { - Object.keys(functions).forEach(function(name) { - loaded[name] = functions[name]; - }); - } - }; - try { - loader = new Function("functions", "tree", "fileInfo", contents); - loader(registry, tree, this.fileInfo); - } catch(e) { - callback(new LessError({ - message: "Plugin evaluation error: '" + e.name + ': ' + e.message.replace(/["]/g, "'") + "'" , - filename: this.fileInfo.filename - }), null ); - } - - callback(null, { functions: loaded }); -}; +// +module.exports = PluginManagerFactory; -},{"../less-error":32,"../tree":62}],41:[function(require,module,exports){ -var PromiseConstructor; +},{}],44:[function(require,module,exports){ +var PromiseConstructor, + utils = require('./utils'); module.exports = function(environment, ParseTree, ImportManager) { var render = function (input, options, callback) { if (typeof options === 'function') { callback = options; - options = {}; + options = utils.defaults(this.options, {}); + } + else { + options = utils.defaults(this.options, options || {}); } if (!callback) { @@ -5171,7 +5805,7 @@ module.exports = function(environment, ParseTree, ImportManager) { return render; }; -},{"promise":undefined}],42:[function(require,module,exports){ +},{"./utils":86,"promise":undefined}],45:[function(require,module,exports){ module.exports = function (SourceMapOutput, environment) { var SourceMapBuilder = function (options) { @@ -5200,6 +5834,9 @@ module.exports = function (SourceMapOutput, environment) { if (this.options.sourceMapInputFilename) { this.sourceMapInputFilename = sourceMapOutput.normalizeFilename(this.options.sourceMapInputFilename); } + if (this.options.sourceMapBasepath !== undefined && this.sourceMapURL !== undefined) { + this.sourceMapURL = sourceMapOutput.removeBasepath(this.sourceMapURL); + } return css + this.getCSSAppendage(); }; @@ -5242,7 +5879,7 @@ module.exports = function (SourceMapOutput, environment) { return SourceMapBuilder; }; -},{}],43:[function(require,module,exports){ +},{}],46:[function(require,module,exports){ module.exports = function (environment) { var SourceMapOutput = function (options) { @@ -5273,21 +5910,26 @@ module.exports = function (environment) { this._column = 0; }; - SourceMapOutput.prototype.normalizeFilename = function(filename) { - filename = filename.replace(/\\/g, '/'); - - if (this._sourceMapBasepath && filename.indexOf(this._sourceMapBasepath) === 0) { - filename = filename.substring(this._sourceMapBasepath.length); - if (filename.charAt(0) === '\\' || filename.charAt(0) === '/') { - filename = filename.substring(1); + SourceMapOutput.prototype.removeBasepath = function(path) { + if (this._sourceMapBasepath && path.indexOf(this._sourceMapBasepath) === 0) { + path = path.substring(this._sourceMapBasepath.length); + if (path.charAt(0) === '\\' || path.charAt(0) === '/') { + path = path.substring(1); } } + + return path; + }; + + SourceMapOutput.prototype.normalizeFilename = function(filename) { + filename = filename.replace(/\\/g, '/'); + filename = this.removeBasepath(filename); return (this._sourceMapRootpath || "") + filename; }; SourceMapOutput.prototype.add = function(chunk, fileInfo, index, mapLines) { - //ignore adding empty strings + // ignore adding empty strings if (!chunk) { return; } @@ -5382,7 +6024,7 @@ module.exports = function (environment) { return SourceMapOutput; }; -},{}],44:[function(require,module,exports){ +},{}],47:[function(require,module,exports){ var contexts = require("./contexts"), visitor = require("./visitors"), tree = require("./tree"); @@ -5398,7 +6040,7 @@ module.exports = function(root, options) { // // `{ color: new tree.Color('#f01') }` will become: // - // new tree.Rule('@color', + // new tree.Declaration('@color', // new tree.Value([ // new tree.Expression([ // new tree.Color('#f01') @@ -5410,92 +6052,61 @@ module.exports = function(root, options) { variables = Object.keys(variables).map(function (k) { var value = variables[k]; - if (! (value instanceof tree.Value)) { - if (! (value instanceof tree.Expression)) { + if (!(value instanceof tree.Value)) { + if (!(value instanceof tree.Expression)) { value = new tree.Expression([value]); } value = new tree.Value([value]); } - return new tree.Rule('@' + k, value, false, null, 0); + return new tree.Declaration('@' + k, value, false, null, 0); }); evalEnv.frames = [new tree.Ruleset(null, variables)]; } - var preEvalVisitors = [], - visitors = [ + var visitors = [ new visitor.JoinSelectorVisitor(), new visitor.MarkVisibleSelectorsVisitor(true), new visitor.ExtendVisitor(), new visitor.ToCSSVisitor({compress: Boolean(options.compress)}) - ], i; + ], v, visitorIterator; + // first() / get() allows visitors to be added while visiting if (options.pluginManager) { - var pluginVisitors = options.pluginManager.getVisitors(); - for (i = 0; i < pluginVisitors.length; i++) { - var pluginVisitor = pluginVisitors[i]; - if (pluginVisitor.isPreEvalVisitor) { - preEvalVisitors.push(pluginVisitor); - } else { - if (pluginVisitor.isPreVisitor) { - visitors.splice(0, 0, pluginVisitor); - } else { - visitors.push(pluginVisitor); - } + visitorIterator = options.pluginManager.visitor(); + visitorIterator.first(); + while ((v = visitorIterator.get())) { + if (v.isPreEvalVisitor) { + v.run(root); } } } - for (i = 0; i < preEvalVisitors.length; i++) { - preEvalVisitors[i].run(root); - } - evaldRoot = root.eval(evalEnv); - for (i = 0; i < visitors.length; i++) { + for (var i = 0; i < visitors.length; i++) { visitors[i].run(evaldRoot); } - return evaldRoot; -}; - -},{"./contexts":11,"./tree":62,"./visitors":87}],45:[function(require,module,exports){ -var Node = require("./node"); - -var Alpha = function (val) { - this.value = val; -}; -Alpha.prototype = new Node(); -Alpha.prototype.type = "Alpha"; - -Alpha.prototype.accept = function (visitor) { - this.value = visitor.visit(this.value); -}; -Alpha.prototype.eval = function (context) { - if (this.value.eval) { return new Alpha(this.value.eval(context)); } - return this; -}; -Alpha.prototype.genCSS = function (context, output) { - output.add("alpha(opacity="); - - if (this.value.genCSS) { - this.value.genCSS(context, output); - } else { - output.add(this.value); + if (options.pluginManager) { + visitorIterator.first(); + while ((v = visitorIterator.get())) { + if (!v.isPreEvalVisitor) { + v.run(evaldRoot); + } + } } - output.add(")"); + return evaldRoot; }; -module.exports = Alpha; - -},{"./node":70}],46:[function(require,module,exports){ +},{"./contexts":12,"./tree":65,"./visitors":90}],48:[function(require,module,exports){ var Node = require("./node"); var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike, visibilityInfo) { this.value = value; - this.index = index; + this._index = index; + this._fileInfo = currentFileInfo; this.mapLines = mapLines; - this.currentFileInfo = currentFileInfo; this.rulesetLike = (typeof rulesetLike === 'undefined') ? false : rulesetLike; this.allowRoot = true; this.copyVisibilityInfo(visibilityInfo); @@ -5503,7 +6114,7 @@ var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike, Anonymous.prototype = new Node(); Anonymous.prototype.type = "Anonymous"; Anonymous.prototype.eval = function () { - return new Anonymous(this.value, this.index, this.currentFileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo()); + return new Anonymous(this.value, this._index, this._fileInfo, this.mapLines, this.rulesetLike, this.visibilityInfo()); }; Anonymous.prototype.compare = function (other) { return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined; @@ -5512,11 +6123,14 @@ Anonymous.prototype.isRulesetLike = function() { return this.rulesetLike; }; Anonymous.prototype.genCSS = function (context, output) { - output.add(this.value, this.currentFileInfo, this.index, this.mapLines); + this.nodeVisible = Boolean(this.value); + if (this.nodeVisible) { + output.add(this.value, this._fileInfo, this._index, this.mapLines); + } }; module.exports = Anonymous; -},{"./node":70}],47:[function(require,module,exports){ +},{"./node":73}],49:[function(require,module,exports){ var Node = require("./node"); var Assignment = function (key, val) { @@ -5545,19 +6159,157 @@ Assignment.prototype.genCSS = function (context, output) { }; module.exports = Assignment; -},{"./node":70}],48:[function(require,module,exports){ -var Node = require("./node"); +},{"./node":73}],50:[function(require,module,exports){ +var Node = require("./node"), + Selector = require("./selector"), + Ruleset = require("./ruleset"), + Anonymous = require('./anonymous'); -var Attribute = function (key, op, value) { - this.key = key; - this.op = op; - this.value = value; -}; -Attribute.prototype = new Node(); -Attribute.prototype.type = "Attribute"; -Attribute.prototype.eval = function (context) { - return new Attribute(this.key.eval ? this.key.eval(context) : this.key, - this.op, (this.value && this.value.eval) ? this.value.eval(context) : this.value); +var AtRule = function (name, value, rules, index, currentFileInfo, debugInfo, isRooted, visibilityInfo) { + var i; + + this.name = name; + this.value = (value instanceof Node) ? value : (value ? new Anonymous(value) : value); + if (rules) { + if (Array.isArray(rules)) { + this.rules = rules; + } else { + this.rules = [rules]; + this.rules[0].selectors = (new Selector([], null, null, index, currentFileInfo)).createEmptySelectors(); + } + for (i = 0; i < this.rules.length; i++) { + this.rules[i].allowImports = true; + } + this.setParent(this.rules, this); + } + this._index = index; + this._fileInfo = currentFileInfo; + this.debugInfo = debugInfo; + this.isRooted = isRooted || false; + this.copyVisibilityInfo(visibilityInfo); + this.allowRoot = true; +}; + +AtRule.prototype = new Node(); +AtRule.prototype.type = "AtRule"; +AtRule.prototype.accept = function (visitor) { + var value = this.value, rules = this.rules; + if (rules) { + this.rules = visitor.visitArray(rules); + } + if (value) { + this.value = visitor.visit(value); + } +}; +AtRule.prototype.isRulesetLike = function() { + return this.rules || !this.isCharset(); +}; +AtRule.prototype.isCharset = function() { + return "@charset" === this.name; +}; +AtRule.prototype.genCSS = function (context, output) { + var value = this.value, rules = this.rules; + output.add(this.name, this.fileInfo(), this.getIndex()); + if (value) { + output.add(' '); + value.genCSS(context, output); + } + if (rules) { + this.outputRuleset(context, output, rules); + } else { + output.add(';'); + } +}; +AtRule.prototype.eval = function (context) { + var mediaPathBackup, mediaBlocksBackup, value = this.value, rules = this.rules; + + // media stored inside other atrule should not bubble over it + // backpup media bubbling information + mediaPathBackup = context.mediaPath; + mediaBlocksBackup = context.mediaBlocks; + // deleted media bubbling information + context.mediaPath = []; + context.mediaBlocks = []; + + if (value) { + value = value.eval(context); + } + if (rules) { + // assuming that there is only one rule at this point - that is how parser constructs the rule + rules = [rules[0].eval(context)]; + rules[0].root = true; + } + // restore media bubbling information + context.mediaPath = mediaPathBackup; + context.mediaBlocks = mediaBlocksBackup; + + return new AtRule(this.name, value, rules, + this.getIndex(), this.fileInfo(), this.debugInfo, this.isRooted, this.visibilityInfo()); +}; +AtRule.prototype.variable = function (name) { + if (this.rules) { + // assuming that there is only one rule at this point - that is how parser constructs the rule + return Ruleset.prototype.variable.call(this.rules[0], name); + } +}; +AtRule.prototype.find = function () { + if (this.rules) { + // assuming that there is only one rule at this point - that is how parser constructs the rule + return Ruleset.prototype.find.apply(this.rules[0], arguments); + } +}; +AtRule.prototype.rulesets = function () { + if (this.rules) { + // assuming that there is only one rule at this point - that is how parser constructs the rule + return Ruleset.prototype.rulesets.apply(this.rules[0]); + } +}; +AtRule.prototype.outputRuleset = function (context, output, rules) { + var ruleCnt = rules.length, i; + context.tabLevel = (context.tabLevel | 0) + 1; + + // Compressed + if (context.compress) { + output.add('{'); + for (i = 0; i < ruleCnt; i++) { + rules[i].genCSS(context, output); + } + output.add('}'); + context.tabLevel--; + return; + } + + // Non-compressed + var tabSetStr = '\n' + Array(context.tabLevel).join(" "), tabRuleStr = tabSetStr + " "; + if (!ruleCnt) { + output.add(" {" + tabSetStr + '}'); + } else { + output.add(" {" + tabRuleStr); + rules[0].genCSS(context, output); + for (i = 1; i < ruleCnt; i++) { + output.add(tabRuleStr); + rules[i].genCSS(context, output); + } + output.add(tabSetStr + '}'); + } + + context.tabLevel--; +}; +module.exports = AtRule; + +},{"./anonymous":48,"./node":73,"./ruleset":78,"./selector":79}],51:[function(require,module,exports){ +var Node = require("./node"); + +var Attribute = function (key, op, value) { + this.key = key; + this.op = op; + this.value = value; +}; +Attribute.prototype = new Node(); +Attribute.prototype.type = "Attribute"; +Attribute.prototype.eval = function (context) { + return new Attribute(this.key.eval ? this.key.eval(context) : this.key, + this.op, (this.value && this.value.eval) ? this.value.eval(context) : this.value); }; Attribute.prototype.genCSS = function (context, output) { output.add(this.toCSS(context)); @@ -5574,8 +6326,9 @@ Attribute.prototype.toCSS = function (context) { }; module.exports = Attribute; -},{"./node":70}],49:[function(require,module,exports){ +},{"./node":73}],52:[function(require,module,exports){ var Node = require("./node"), + Anonymous = require("./anonymous"), FunctionCaller = require("../functions/function-caller"); // // A function call node. @@ -5583,8 +6336,9 @@ var Node = require("./node"), var Call = function (name, args, index, currentFileInfo) { this.name = name; this.args = args; - this.index = index; - this.currentFileInfo = currentFileInfo; + this.mathOn = name === 'calc' ? false : true; + this._index = index; + this._fileInfo = currentFileInfo; }; Call.prototype = new Node(); Call.prototype.type = "Call"; @@ -5605,30 +6359,55 @@ Call.prototype.accept = function (visitor) { // The function should receive the value, not the variable. // Call.prototype.eval = function (context) { - var args = this.args.map(function (a) { return a.eval(context); }), - result, funcCaller = new FunctionCaller(this.name, context, this.index, this.currentFileInfo); + /** + * Turn off math for calc(), and switch back on for evaluating nested functions + */ + var currentMathContext = context.mathOn; + context.mathOn = this.mathOn; + var args = this.args.map(function (a) { return a.eval(context); }); + context.mathOn = currentMathContext; + + var result, funcCaller = new FunctionCaller(this.name, context, this.getIndex(), this.fileInfo()); + if (funcCaller.isValid()) { try { result = funcCaller.call(args); } catch (e) { - throw { type: e.type || "Runtime", - message: "error evaluating function `" + this.name + "`" + - (e.message ? ': ' + e.message : ''), - index: this.index, filename: this.currentFileInfo.filename }; + throw { + type: e.type || "Runtime", + message: "error evaluating function `" + this.name + "`" + + (e.message ? ': ' + e.message : ''), + index: this.getIndex(), + filename: this.fileInfo().filename, + line: e.lineNumber, + column: e.columnNumber + }; } - if (result != null) { - result.index = this.index; - result.currentFileInfo = this.currentFileInfo; + if (result !== null && result !== undefined) { + // Results that that are not nodes are cast as Anonymous nodes + // Falsy values or booleans are returned as empty nodes + if (!(result instanceof Node)) { + if (!result || result === true) { + result = new Anonymous(null); + } + else { + result = new Anonymous(result.toString()); + } + + } + result._index = this._index; + result._fileInfo = this._fileInfo; return result; } + } - return new Call(this.name, args, this.index, this.currentFileInfo); + return new Call(this.name, args, this.getIndex(), this.fileInfo()); }; Call.prototype.genCSS = function (context, output) { - output.add(this.name + "(", this.currentFileInfo, this.index); + output.add(this.name + "(", this.fileInfo(), this.getIndex()); for (var i = 0; i < this.args.length; i++) { this.args[i].genCSS(context, output); @@ -5641,7 +6420,7 @@ Call.prototype.genCSS = function (context, output) { }; module.exports = Call; -},{"../functions/function-caller":21,"./node":70}],50:[function(require,module,exports){ +},{"../functions/function-caller":25,"./anonymous":48,"./node":73}],53:[function(require,module,exports){ var Node = require("./node"), colors = require("../data/colors"); @@ -5743,7 +6522,7 @@ Color.prototype.toCSS = function (context, doNotCompress) { // we create a new Color node to hold the result. // Color.prototype.operate = function (context, op, other) { - var rgb = []; + var rgb = new Array(3); var alpha = this.alpha * (1 - other.alpha) + other.alpha; for (var c = 0; c < 3; c++) { rgb[c] = this._operate(context, op, this.rgb[c], other.rgb[c]); @@ -5776,7 +6555,7 @@ Color.prototype.toHSL = function () { } return { h: h * 360, s: s, l: l, a: a }; }; -//Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript +// Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript Color.prototype.toHSV = function () { var r = this.rgb[0] / 255, g = this.rgb[1] / 255, @@ -5796,7 +6575,7 @@ Color.prototype.toHSV = function () { if (max === min) { h = 0; } else { - switch(max) { + switch (max) { case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; @@ -5832,7 +6611,7 @@ Color.fromKeyword = function(keyword) { }; module.exports = Color; -},{"../data/colors":12,"./node":70}],51:[function(require,module,exports){ +},{"../data/colors":13,"./node":73}],54:[function(require,module,exports){ var Node = require("./node"); var Combinator = function (value) { @@ -5857,22 +6636,22 @@ Combinator.prototype.genCSS = function (context, output) { }; module.exports = Combinator; -},{"./node":70}],52:[function(require,module,exports){ +},{"./node":73}],55:[function(require,module,exports){ var Node = require("./node"), getDebugInfo = require("./debug-info"); var Comment = function (value, isLineComment, index, currentFileInfo) { this.value = value; this.isLineComment = isLineComment; - this.index = index; - this.currentFileInfo = currentFileInfo; + this._index = index; + this._fileInfo = currentFileInfo; this.allowRoot = true; }; Comment.prototype = new Node(); Comment.prototype.type = "Comment"; Comment.prototype.genCSS = function (context, output) { if (this.debugInfo) { - output.add(getDebugInfo(context, this), this.currentFileInfo, this.index); + output.add(getDebugInfo(context, this), this.fileInfo(), this.getIndex()); } output.add(this.value); }; @@ -5882,14 +6661,14 @@ Comment.prototype.isSilent = function(context) { }; module.exports = Comment; -},{"./debug-info":54,"./node":70}],53:[function(require,module,exports){ +},{"./debug-info":57,"./node":73}],56:[function(require,module,exports){ var Node = require("./node"); var Condition = function (op, l, r, i, negate) { this.op = op.trim(); this.lvalue = l; this.rvalue = r; - this.index = i; + this._index = i; this.negate = negate; }; Condition.prototype = new Node(); @@ -5921,11 +6700,11 @@ Condition.prototype.eval = function (context) { }; module.exports = Condition; -},{"./node":70}],54:[function(require,module,exports){ +},{"./node":73}],57:[function(require,module,exports){ var debugInfo = function(context, ctx, lineSeparator) { var result = ""; if (context.dumpLineNumbers && !context.compress) { - switch(context.dumpLineNumbers) { + switch (context.dumpLineNumbers) { case 'comments': result = debugInfo.asComment(ctx); break; @@ -5961,13 +6740,114 @@ debugInfo.asMediaQuery = function(ctx) { module.exports = debugInfo; -},{}],55:[function(require,module,exports){ +},{}],58:[function(require,module,exports){ var Node = require("./node"), - contexts = require("../contexts"); + Value = require("./value"), + Keyword = require("./keyword"), + Anonymous = require("./anonymous"); + +var Declaration = function (name, value, important, merge, index, currentFileInfo, inline, variable) { + this.name = name; + this.value = (value instanceof Node) ? value : new Value([value ? new Anonymous(value) : null]); + this.important = important ? ' ' + important.trim() : ''; + this.merge = merge; + this._index = index; + this._fileInfo = currentFileInfo; + this.inline = inline || false; + this.variable = (variable !== undefined) ? variable + : (name.charAt && (name.charAt(0) === '@')); + this.allowRoot = true; + this.setParent(this.value, this); +}; + +function evalName(context, name) { + var value = "", i, n = name.length, + output = {add: function (s) {value += s;}}; + for (i = 0; i < n; i++) { + name[i].eval(context).genCSS(context, output); + } + return value; +} + +Declaration.prototype = new Node(); +Declaration.prototype.type = "Declaration"; +Declaration.prototype.genCSS = function (context, output) { + output.add(this.name + (context.compress ? ':' : ': '), this.fileInfo(), this.getIndex()); + try { + this.value.genCSS(context, output); + } + catch (e) { + e.index = this._index; + e.filename = this._fileInfo.filename; + throw e; + } + output.add(this.important + ((this.inline || (context.lastRule && context.compress)) ? "" : ";"), this._fileInfo, this._index); +}; +Declaration.prototype.eval = function (context) { + var strictMathBypass = false, name = this.name, evaldValue, variable = this.variable; + if (typeof name !== "string") { + // expand 'primitive' name directly to get + // things faster (~10% for benchmark.less): + name = (name.length === 1) && (name[0] instanceof Keyword) ? + name[0].value : evalName(context, name); + variable = false; // never treat expanded interpolation as new variable name + } + if (name === "font" && !context.strictMath) { + strictMathBypass = true; + context.strictMath = true; + } + try { + context.importantScope.push({}); + evaldValue = this.value.eval(context); + + if (!this.variable && evaldValue.type === "DetachedRuleset") { + throw { message: "Rulesets cannot be evaluated on a property.", + index: this.getIndex(), filename: this.fileInfo().filename }; + } + var important = this.important, + importantResult = context.importantScope.pop(); + if (!important && importantResult.important) { + important = importantResult.important; + } + + return new Declaration(name, + evaldValue, + important, + this.merge, + this.getIndex(), this.fileInfo(), this.inline, + variable); + } + catch (e) { + if (typeof e.index !== 'number') { + e.index = this.getIndex(); + e.filename = this.fileInfo().filename; + } + throw e; + } + finally { + if (strictMathBypass) { + context.strictMath = false; + } + } +}; +Declaration.prototype.makeImportant = function () { + return new Declaration(this.name, + this.value, + "!important", + this.merge, + this.getIndex(), this.fileInfo(), this.inline); +}; + +module.exports = Declaration; +},{"./anonymous":48,"./keyword":68,"./node":73,"./value":83}],59:[function(require,module,exports){ +var Node = require("./node"), + contexts = require("../contexts"), + utils = require("../utils"); var DetachedRuleset = function (ruleset, frames) { this.ruleset = ruleset; this.frames = frames; + this.setParent(this.ruleset, this); }; DetachedRuleset.prototype = new Node(); DetachedRuleset.prototype.type = "DetachedRuleset"; @@ -5976,7 +6856,7 @@ DetachedRuleset.prototype.accept = function (visitor) { this.ruleset = visitor.visit(this.ruleset); }; DetachedRuleset.prototype.eval = function (context) { - var frames = this.frames || context.frames.slice(0); + var frames = this.frames || utils.copyArray(context.frames); return new DetachedRuleset(this.ruleset, frames); }; DetachedRuleset.prototype.callEval = function (context) { @@ -5984,7 +6864,7 @@ DetachedRuleset.prototype.callEval = function (context) { }; module.exports = DetachedRuleset; -},{"../contexts":11,"./node":70}],56:[function(require,module,exports){ +},{"../contexts":12,"../utils":86,"./node":73}],60:[function(require,module,exports){ var Node = require("./node"), unitConversions = require("../data/unit-conversions"), Unit = require("./unit"), @@ -5995,8 +6875,12 @@ var Node = require("./node"), // var Dimension = function (value, unit) { this.value = parseFloat(value); + if (isNaN(this.value)) { + throw new Error("Dimension is not a number."); + } this.unit = (unit && unit instanceof Unit) ? unit : new Unit(unit ? [unit] : undefined); + this.setParent(this.unit, this); }; Dimension.prototype = new Node(); @@ -6044,7 +6928,7 @@ Dimension.prototype.genCSS = function (context, output) { // we default to the first Dimension's unit, // so `1px + 2` will yield `3px`. Dimension.prototype.operate = function (context, op, other) { - /*jshint noempty:false */ + /* jshint noempty:false */ var value = this._operate(context, op, this.value, other.value), unit = this.unit.clone(); @@ -6143,148 +7027,12 @@ Dimension.prototype.convertTo = function (conversions) { }; module.exports = Dimension; -},{"../data/unit-conversions":14,"./color":50,"./node":70,"./unit":79}],57:[function(require,module,exports){ -var Node = require("./node"), - Selector = require("./selector"), - Ruleset = require("./ruleset"); - -var Directive = function (name, value, rules, index, currentFileInfo, debugInfo, isRooted, visibilityInfo) { - var i; - - this.name = name; - this.value = value; - if (rules) { - if (Array.isArray(rules)) { - this.rules = rules; - } else { - this.rules = [rules]; - this.rules[0].selectors = (new Selector([], null, null, this.index, currentFileInfo)).createEmptySelectors(); - } - for (i = 0; i < this.rules.length; i++) { - this.rules[i].allowImports = true; - } - } - this.index = index; - this.currentFileInfo = currentFileInfo; - this.debugInfo = debugInfo; - this.isRooted = isRooted || false; - this.copyVisibilityInfo(visibilityInfo); - this.allowRoot = true; -}; - -Directive.prototype = new Node(); -Directive.prototype.type = "Directive"; -Directive.prototype.accept = function (visitor) { - var value = this.value, rules = this.rules; - if (rules) { - this.rules = visitor.visitArray(rules); - } - if (value) { - this.value = visitor.visit(value); - } -}; -Directive.prototype.isRulesetLike = function() { - return this.rules || !this.isCharset(); -}; -Directive.prototype.isCharset = function() { - return "@charset" === this.name; -}; -Directive.prototype.genCSS = function (context, output) { - var value = this.value, rules = this.rules; - output.add(this.name, this.currentFileInfo, this.index); - if (value) { - output.add(' '); - value.genCSS(context, output); - } - if (rules) { - this.outputRuleset(context, output, rules); - } else { - output.add(';'); - } -}; -Directive.prototype.eval = function (context) { - var mediaPathBackup, mediaBlocksBackup, value = this.value, rules = this.rules; - - //media stored inside other directive should not bubble over it - //backpup media bubbling information - mediaPathBackup = context.mediaPath; - mediaBlocksBackup = context.mediaBlocks; - //deleted media bubbling information - context.mediaPath = []; - context.mediaBlocks = []; - - if (value) { - value = value.eval(context); - } - if (rules) { - // assuming that there is only one rule at this point - that is how parser constructs the rule - rules = [rules[0].eval(context)]; - rules[0].root = true; - } - //restore media bubbling information - context.mediaPath = mediaPathBackup; - context.mediaBlocks = mediaBlocksBackup; - - return new Directive(this.name, value, rules, - this.index, this.currentFileInfo, this.debugInfo, this.isRooted, this.visibilityInfo()); -}; -Directive.prototype.variable = function (name) { - if (this.rules) { - // assuming that there is only one rule at this point - that is how parser constructs the rule - return Ruleset.prototype.variable.call(this.rules[0], name); - } -}; -Directive.prototype.find = function () { - if (this.rules) { - // assuming that there is only one rule at this point - that is how parser constructs the rule - return Ruleset.prototype.find.apply(this.rules[0], arguments); - } -}; -Directive.prototype.rulesets = function () { - if (this.rules) { - // assuming that there is only one rule at this point - that is how parser constructs the rule - return Ruleset.prototype.rulesets.apply(this.rules[0]); - } -}; -Directive.prototype.outputRuleset = function (context, output, rules) { - var ruleCnt = rules.length, i; - context.tabLevel = (context.tabLevel | 0) + 1; - - // Compressed - if (context.compress) { - output.add('{'); - for (i = 0; i < ruleCnt; i++) { - rules[i].genCSS(context, output); - } - output.add('}'); - context.tabLevel--; - return; - } - - // Non-compressed - var tabSetStr = '\n' + Array(context.tabLevel).join(" "), tabRuleStr = tabSetStr + " "; - if (!ruleCnt) { - output.add(" {" + tabSetStr + '}'); - } else { - output.add(" {" + tabRuleStr); - rules[0].genCSS(context, output); - for (i = 1; i < ruleCnt; i++) { - output.add(tabRuleStr); - rules[i].genCSS(context, output); - } - output.add(tabSetStr + '}'); - } - - context.tabLevel--; -}; -module.exports = Directive; - -},{"./node":70,"./ruleset":76,"./selector":77}],58:[function(require,module,exports){ +},{"../data/unit-conversions":15,"./color":53,"./node":73,"./unit":81}],61:[function(require,module,exports){ var Node = require("./node"), Paren = require("./paren"), Combinator = require("./combinator"); -var Element = function (combinator, value, index, currentFileInfo, info) { +var Element = function (combinator, value, index, currentFileInfo, visibilityInfo) { this.combinator = combinator instanceof Combinator ? combinator : new Combinator(combinator); @@ -6295,9 +7043,10 @@ var Element = function (combinator, value, index, currentFileInfo, info) { } else { this.value = ""; } - this.index = index; - this.currentFileInfo = currentFileInfo; - this.copyVisibilityInfo(info); + this._index = index; + this._fileInfo = currentFileInfo; + this.copyVisibilityInfo(visibilityInfo); + this.setParent(this.combinator, this); }; Element.prototype = new Node(); Element.prototype.type = "Element"; @@ -6311,17 +7060,17 @@ Element.prototype.accept = function (visitor) { Element.prototype.eval = function (context) { return new Element(this.combinator, this.value.eval ? this.value.eval(context) : this.value, - this.index, - this.currentFileInfo, this.visibilityInfo()); + this.getIndex(), + this.fileInfo(), this.visibilityInfo()); }; Element.prototype.clone = function () { return new Element(this.combinator, this.value, - this.index, - this.currentFileInfo, this.visibilityInfo()); + this.getIndex(), + this.fileInfo(), this.visibilityInfo()); }; Element.prototype.genCSS = function (context, output) { - output.add(this.toCSS(context), this.currentFileInfo, this.index); + output.add(this.toCSS(context), this.fileInfo(), this.getIndex()); }; Element.prototype.toCSS = function (context) { context = context || {}; @@ -6341,7 +7090,7 @@ Element.prototype.toCSS = function (context) { }; module.exports = Element; -},{"./combinator":51,"./node":70,"./paren":72}],59:[function(require,module,exports){ +},{"./combinator":54,"./node":73,"./paren":75}],62:[function(require,module,exports){ var Node = require("./node"), Paren = require("./paren"), Comment = require("./comment"); @@ -6399,21 +7148,21 @@ Expression.prototype.throwAwayComments = function () { }; module.exports = Expression; -},{"./comment":52,"./node":70,"./paren":72}],60:[function(require,module,exports){ +},{"./comment":55,"./node":73,"./paren":75}],63:[function(require,module,exports){ var Node = require("./node"), Selector = require("./selector"); var Extend = function Extend(selector, option, index, currentFileInfo, visibilityInfo) { this.selector = selector; this.option = option; - this.index = index; this.object_id = Extend.next_id++; this.parent_ids = [this.object_id]; - this.currentFileInfo = currentFileInfo || {}; + this._index = index; + this._fileInfo = currentFileInfo; this.copyVisibilityInfo(visibilityInfo); this.allowRoot = true; - switch(option) { + switch (option) { case "all": this.allowBefore = true; this.allowAfter = true; @@ -6423,6 +7172,7 @@ var Extend = function Extend(selector, option, index, currentFileInfo, visibilit this.allowAfter = false; break; } + this.setParent(this.selector, this); }; Extend.next_id = 0; @@ -6432,12 +7182,12 @@ Extend.prototype.accept = function (visitor) { this.selector = visitor.visit(this.selector); }; Extend.prototype.eval = function (context) { - return new Extend(this.selector.eval(context), this.option, this.index, this.currentFileInfo, this.visibilityInfo()); + return new Extend(this.selector.eval(context), this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo()); }; Extend.prototype.clone = function (context) { - return new Extend(this.selector, this.option, this.index, this.currentFileInfo, this.visibilityInfo()); + return new Extend(this.selector, this.option, this.getIndex(), this.fileInfo(), this.visibilityInfo()); }; -//it concatenates (joins) all selectors in selector array +// it concatenates (joins) all selectors in selector array Extend.prototype.findSelfSelectors = function (selectors) { var selfElements = [], i, @@ -6458,13 +7208,15 @@ Extend.prototype.findSelfSelectors = function (selectors) { }; module.exports = Extend; -},{"./node":70,"./selector":77}],61:[function(require,module,exports){ +},{"./node":73,"./selector":79}],64:[function(require,module,exports){ var Node = require("./node"), Media = require("./media"), URL = require("./url"), Quoted = require("./quoted"), Ruleset = require("./ruleset"), - Anonymous = require("./anonymous"); + Anonymous = require("./anonymous"), + utils = require("../utils"), + LessError = require("../less-error"); // // CSS @import node @@ -6480,21 +7232,23 @@ var Node = require("./node"), // var Import = function (path, features, options, index, currentFileInfo, visibilityInfo) { this.options = options; - this.index = index; + this._index = index; + this._fileInfo = currentFileInfo; this.path = path; this.features = features; - this.currentFileInfo = currentFileInfo; this.allowRoot = true; if (this.options.less !== undefined || this.options.inline) { this.css = !this.options.less || this.options.inline; } else { var pathValue = this.getPath(); - if (pathValue && /[#\.\&\?\/]css([\?;].*)?$/.test(pathValue)) { + if (pathValue && /[#\.\&\?]css([\?;].*)?$/.test(pathValue)) { this.css = true; } } this.copyVisibilityInfo(visibilityInfo); + this.setParent(this.features, this); + this.setParent(this.path, this); }; // @@ -6513,13 +7267,13 @@ Import.prototype.accept = function (visitor) { this.features = visitor.visit(this.features); } this.path = visitor.visit(this.path); - if (!this.options.plugin && !this.options.inline && this.root) { + if (!this.options.isPlugin && !this.options.inline && this.root) { this.root = visitor.visit(this.root); } }; Import.prototype.genCSS = function (context, output) { - if (this.css && this.path.currentFileInfo.reference === undefined) { - output.add("@import ", this.currentFileInfo, this.index); + if (this.css && this.path._fileInfo.reference === undefined) { + output.add("@import ", this._fileInfo, this._index); this.path.genCSS(context, output); if (this.features) { output.add(" "); @@ -6550,11 +7304,11 @@ Import.prototype.evalForImport = function (context) { path = path.value; } - return new Import(path.eval(context), this.features, this.options, this.index, this.currentFileInfo, this.visibilityInfo()); + return new Import(path.eval(context), this.features, this.options, this._index, this._fileInfo, this.visibilityInfo()); }; Import.prototype.evalPath = function (context) { var path = this.path.eval(context); - var rootpath = this.currentFileInfo && this.currentFileInfo.rootpath; + var rootpath = this._fileInfo && this._fileInfo.rootpath; if (!(path instanceof URL)) { if (rootpath) { @@ -6574,8 +7328,8 @@ Import.prototype.eval = function (context) { if (this.options.reference || this.blocksVisibility()) { if (result.length || result.length === 0) { result.forEach(function (node) { - node.addVisibilityBlock(); - } + node.addVisibilityBlock(); + } ); } else { result.addVisibilityBlock(); @@ -6587,11 +7341,21 @@ Import.prototype.doEval = function (context) { var ruleset, registry, features = this.features && this.features.eval(context); - if (this.options.plugin) { + if (this.options.isPlugin) { + if (this.root && this.root.eval) { + try { + this.root.eval(context); + } + catch (e) { + e.message = "Plugin error during evaluation"; + throw new LessError(e, this.root.imports, this.root.filename); + } + } registry = context.frames[0] && context.frames[0].functionRegistry; if ( registry && this.root && this.root.functions ) { registry.addMultiple( this.root.functions ); } + return []; } @@ -6605,20 +7369,20 @@ Import.prototype.doEval = function (context) { } if (this.options.inline) { var contents = new Anonymous(this.root, 0, - { - filename: this.importedFilename, - reference: this.path.currentFileInfo && this.path.currentFileInfo.reference - }, true, true); + { + filename: this.importedFilename, + reference: this.path._fileInfo && this.path._fileInfo.reference + }, true, true); return this.features ? new Media([contents], this.features.value) : [contents]; } else if (this.css) { - var newImport = new Import(this.evalPath(context), features, this.options, this.index); + var newImport = new Import(this.evalPath(context), features, this.options, this._index); if (!newImport.css && this.error) { throw this.error; } return newImport; } else { - ruleset = new Ruleset(null, this.root.rules.slice(0)); + ruleset = new Ruleset(null, utils.copyArray(this.root.rules)); ruleset.evalImports(context); return this.features ? new Media(ruleset.rules, this.features.value) : ruleset.rules; @@ -6626,19 +7390,19 @@ Import.prototype.doEval = function (context) { }; module.exports = Import; -},{"./anonymous":46,"./media":66,"./node":70,"./quoted":73,"./ruleset":76,"./url":80}],62:[function(require,module,exports){ -var tree = {}; +},{"../less-error":36,"../utils":86,"./anonymous":48,"./media":69,"./node":73,"./quoted":77,"./ruleset":78,"./url":82}],65:[function(require,module,exports){ +var tree = Object.create(null); tree.Node = require('./node'); -tree.Alpha = require('./alpha'); tree.Color = require('./color'); -tree.Directive = require('./directive'); +tree.AtRule = require('./atrule'); tree.DetachedRuleset = require('./detached-ruleset'); tree.Operation = require('./operation'); tree.Dimension = require('./dimension'); tree.Unit = require('./unit'); tree.Keyword = require('./keyword'); tree.Variable = require('./variable'); +tree.Property = require('./property'); tree.Ruleset = require('./ruleset'); tree.Element = require('./element'); tree.Attribute = require('./attribute'); @@ -6646,7 +7410,7 @@ tree.Combinator = require('./combinator'); tree.Selector = require('./selector'); tree.Quoted = require('./quoted'); tree.Expression = require('./expression'); -tree.Rule = require('./rule'); +tree.Declaration = require('./declaration'); tree.Call = require('./call'); tree.URL = require('./url'); tree.Import = require('./import'); @@ -6665,11 +7429,11 @@ tree.Media = require('./media'); tree.UnicodeDescriptor = require('./unicode-descriptor'); tree.Negative = require('./negative'); tree.Extend = require('./extend'); -tree.RulesetCall = require('./ruleset-call'); +tree.VariableCall = require('./variable-call'); module.exports = tree; -},{"./alpha":45,"./anonymous":46,"./assignment":47,"./attribute":48,"./call":49,"./color":50,"./combinator":51,"./comment":52,"./condition":53,"./detached-ruleset":55,"./dimension":56,"./directive":57,"./element":58,"./expression":59,"./extend":60,"./import":61,"./javascript":63,"./keyword":65,"./media":66,"./mixin-call":67,"./mixin-definition":68,"./negative":69,"./node":70,"./operation":71,"./paren":72,"./quoted":73,"./rule":74,"./ruleset":76,"./ruleset-call":75,"./selector":77,"./unicode-descriptor":78,"./unit":79,"./url":80,"./value":81,"./variable":82}],63:[function(require,module,exports){ +},{"./anonymous":48,"./assignment":49,"./atrule":50,"./attribute":51,"./call":52,"./color":53,"./combinator":54,"./comment":55,"./condition":56,"./declaration":58,"./detached-ruleset":59,"./dimension":60,"./element":61,"./expression":62,"./extend":63,"./import":64,"./javascript":66,"./keyword":68,"./media":69,"./mixin-call":70,"./mixin-definition":71,"./negative":72,"./node":73,"./operation":74,"./paren":75,"./property":76,"./quoted":77,"./ruleset":78,"./selector":79,"./unicode-descriptor":80,"./unit":81,"./url":82,"./value":83,"./variable":85,"./variable-call":84}],66:[function(require,module,exports){ var JsEvalNode = require("./js-eval-node"), Dimension = require("./dimension"), Quoted = require("./quoted"), @@ -6678,8 +7442,8 @@ var JsEvalNode = require("./js-eval-node"), var JavaScript = function (string, escaped, index, currentFileInfo) { this.escaped = escaped; this.expression = string; - this.index = index; - this.currentFileInfo = currentFileInfo; + this._index = index; + this._fileInfo = currentFileInfo; }; JavaScript.prototype = new JsEvalNode(); JavaScript.prototype.type = "JavaScript"; @@ -6689,7 +7453,7 @@ JavaScript.prototype.eval = function(context) { if (typeof result === 'number') { return new Dimension(result); } else if (typeof result === 'string') { - return new Quoted('"' + result + '"', result, this.escaped, this.index); + return new Quoted('"' + result + '"', result, this.escaped, this._index); } else if (Array.isArray(result)) { return new Anonymous(result.join(', ')); } else { @@ -6699,7 +7463,7 @@ JavaScript.prototype.eval = function(context) { module.exports = JavaScript; -},{"./anonymous":46,"./dimension":56,"./js-eval-node":64,"./quoted":73}],64:[function(require,module,exports){ +},{"./anonymous":48,"./dimension":60,"./js-eval-node":67,"./quoted":77}],67:[function(require,module,exports){ var Node = require("./node"), Variable = require("./variable"); @@ -6712,28 +7476,28 @@ JsEvalNode.prototype.evaluateJavaScript = function (expression, context) { that = this, evalContext = {}; - if (context.javascriptEnabled !== undefined && !context.javascriptEnabled) { - throw { message: "You are using JavaScript, which has been disabled.", - filename: this.currentFileInfo.filename, - index: this.index }; + if (!context.javascriptEnabled) { + throw { message: "Inline JavaScript is not enabled. Is it set in your options?", + filename: this.fileInfo().filename, + index: this.getIndex() }; } expression = expression.replace(/@\{([\w-]+)\}/g, function (_, name) { - return that.jsify(new Variable('@' + name, that.index, that.currentFileInfo).eval(context)); + return that.jsify(new Variable('@' + name, that.getIndex(), that.fileInfo()).eval(context)); }); try { expression = new Function('return (' + expression + ')'); } catch (e) { throw { message: "JavaScript evaluation error: " + e.message + " from `" + expression + "`" , - filename: this.currentFileInfo.filename, - index: this.index }; + filename: this.fileInfo().filename, + index: this.getIndex() }; } var variables = context.frames[0].variables(); for (var k in variables) { if (variables.hasOwnProperty(k)) { - /*jshint loopfunc:true */ + /* jshint loopfunc:true */ evalContext[k.slice(1)] = { value: variables[k].value, toJS: function () { @@ -6747,8 +7511,8 @@ JsEvalNode.prototype.evaluateJavaScript = function (expression, context) { result = expression.call(evalContext); } catch (e) { throw { message: "JavaScript evaluation error: '" + e.name + ': ' + e.message.replace(/["]/g, "'") + "'" , - filename: this.currentFileInfo.filename, - index: this.index }; + filename: this.fileInfo().filename, + index: this.getIndex() }; } return result; }; @@ -6762,7 +7526,7 @@ JsEvalNode.prototype.jsify = function (obj) { module.exports = JsEvalNode; -},{"./node":70,"./variable":82}],65:[function(require,module,exports){ +},{"./node":73,"./variable":85}],68:[function(require,module,exports){ var Node = require("./node"); var Keyword = function (value) { this.value = value; }; @@ -6778,29 +7542,33 @@ Keyword.False = new Keyword('false'); module.exports = Keyword; -},{"./node":70}],66:[function(require,module,exports){ +},{"./node":73}],69:[function(require,module,exports){ var Ruleset = require("./ruleset"), Value = require("./value"), Selector = require("./selector"), Anonymous = require("./anonymous"), Expression = require("./expression"), - Directive = require("./directive"); + AtRule = require("./atrule"), + utils = require("../utils"); var Media = function (value, features, index, currentFileInfo, visibilityInfo) { - this.index = index; - this.currentFileInfo = currentFileInfo; + this._index = index; + this._fileInfo = currentFileInfo; - var selectors = (new Selector([], null, null, this.index, this.currentFileInfo)).createEmptySelectors(); + var selectors = (new Selector([], null, null, this._index, this._fileInfo)).createEmptySelectors(); this.features = new Value(features); this.rules = [new Ruleset(selectors, value)]; this.rules[0].allowImports = true; this.copyVisibilityInfo(visibilityInfo); this.allowRoot = true; + this.setParent(selectors, this); + this.setParent(this.features, this); + this.setParent(this.rules, this); }; -Media.prototype = new Directive(); +Media.prototype = new AtRule(); Media.prototype.type = "Media"; -Media.prototype.isRulesetLike = true; +Media.prototype.isRulesetLike = function() { return true; }; Media.prototype.accept = function (visitor) { if (this.features) { this.features = visitor.visit(this.features); @@ -6810,7 +7578,7 @@ Media.prototype.accept = function (visitor) { } }; Media.prototype.genCSS = function (context, output) { - output.add('@media ', this.currentFileInfo, this.index); + output.add('@media ', this._fileInfo, this._index); this.features.genCSS(context, output); this.outputRuleset(context, output, this.rules); }; @@ -6820,24 +7588,13 @@ Media.prototype.eval = function (context) { context.mediaPath = []; } - var media = new Media(null, [], this.index, this.currentFileInfo, this.visibilityInfo()); + var media = new Media(null, [], this._index, this._fileInfo, this.visibilityInfo()); if (this.debugInfo) { this.rules[0].debugInfo = this.debugInfo; media.debugInfo = this.debugInfo; } - var strictMathBypass = false; - if (!context.strictMath) { - strictMathBypass = true; - context.strictMath = true; - } - try { - media.features = this.features.eval(context); - } - finally { - if (strictMathBypass) { - context.strictMath = false; - } - } + + media.features = this.features.eval(context); context.mediaPath.push(media); context.mediaBlocks.push(media); @@ -6857,10 +7614,11 @@ Media.prototype.evalTop = function (context) { // Render all dependent Media blocks. if (context.mediaBlocks.length > 1) { - var selectors = (new Selector([], null, null, this.index, this.currentFileInfo)).createEmptySelectors(); + var selectors = (new Selector([], null, null, this.getIndex(), this.fileInfo())).createEmptySelectors(); result = new Ruleset(selectors, context.mediaBlocks); result.multiMedia = true; result.copyVisibilityInfo(this.visibilityInfo()); + this.setParent(result, this); } delete context.mediaBlocks; @@ -6897,6 +7655,7 @@ Media.prototype.evalNested = function (context) { return new Expression(path); })); + this.setParent(this.features, this); // Fake a tree-node that doesn't output anything. return new Ruleset([], []); @@ -6921,11 +7680,12 @@ Media.prototype.bubbleSelectors = function (selectors) { if (!selectors) { return; } - this.rules = [new Ruleset(selectors.slice(0), [this.rules[0]])]; + this.rules = [new Ruleset(utils.copyArray(selectors), [this.rules[0]])]; + this.setParent(this.rules, this); }; module.exports = Media; -},{"./anonymous":46,"./directive":57,"./expression":59,"./ruleset":76,"./selector":77,"./value":81}],67:[function(require,module,exports){ +},{"../utils":86,"./anonymous":48,"./atrule":50,"./expression":62,"./ruleset":78,"./selector":79,"./value":83}],70:[function(require,module,exports){ var Node = require("./node"), Selector = require("./selector"), MixinDefinition = require("./mixin-definition"), @@ -6934,10 +7694,11 @@ var Node = require("./node"), var MixinCall = function (elements, args, index, currentFileInfo, important) { this.selector = new Selector(elements); this.arguments = args || []; - this.index = index; - this.currentFileInfo = currentFileInfo; + this._index = index; + this._fileInfo = currentFileInfo; this.important = important; this.allowRoot = true; + this.setParent(this.selector, this); }; MixinCall.prototype = new Node(); MixinCall.prototype.type = "MixinCall"; @@ -7045,7 +7806,7 @@ MixinCall.prototype.eval = function (context) { if ((count[defTrue] + count[defFalse]) > 1) { throw { type: 'Runtime', message: 'Ambiguous use of `default()` found when matching for `' + this.format(args) + '`', - index: this.index, filename: this.currentFileInfo.filename }; + index: this.getIndex(), filename: this.fileInfo().filename }; } } @@ -7063,7 +7824,7 @@ MixinCall.prototype.eval = function (context) { this._setVisibilityToReplacement(newRules); Array.prototype.push.apply(rules, newRules); } catch (e) { - throw { message: e.message, index: this.index, filename: this.currentFileInfo.filename, stack: e.stack }; + throw { message: e.message, index: this.getIndex(), filename: this.fileInfo().filename, stack: e.stack }; } } } @@ -7076,11 +7837,11 @@ MixinCall.prototype.eval = function (context) { if (isOneFound) { throw { type: 'Runtime', message: 'No matching definition was found for `' + this.format(args) + '`', - index: this.index, filename: this.currentFileInfo.filename }; + index: this.getIndex(), filename: this.fileInfo().filename }; } else { throw { type: 'Name', message: this.selector.toCSS().trim() + " is undefined", - index: this.index, filename: this.currentFileInfo.filename }; + index: this.getIndex(), filename: this.fileInfo().filename }; } }; @@ -7110,17 +7871,18 @@ MixinCall.prototype.format = function (args) { }; module.exports = MixinCall; -},{"../functions/default":20,"./mixin-definition":68,"./node":70,"./selector":77}],68:[function(require,module,exports){ +},{"../functions/default":24,"./mixin-definition":71,"./node":73,"./selector":79}],71:[function(require,module,exports){ var Selector = require("./selector"), Element = require("./element"), Ruleset = require("./ruleset"), - Rule = require("./rule"), + Declaration = require("./declaration"), Expression = require("./expression"), - contexts = require("../contexts"); + contexts = require("../contexts"), + utils = require("../utils"); var Definition = function (name, params, rules, condition, variadic, frames, visibilityInfo) { this.name = name; - this.selectors = [new Selector([new Element(null, name, this.index, this.currentFileInfo)])]; + this.selectors = [new Selector([new Element(null, name, this._index, this._fileInfo)])]; this.params = params; this.condition = condition; this.variadic = variadic; @@ -7155,10 +7917,10 @@ Definition.prototype.accept = function (visitor) { } }; Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArguments) { - /*jshint boss:true */ + /* jshint boss:true */ var frame = new Ruleset(null, null), varargs, arg, - params = this.params.slice(0), + params = utils.copyArray(this.params), i, j, val, name, isNamedFound, argIndex, argsLength = 0; if (mixinEnv.frames && mixinEnv.frames[0] && mixinEnv.frames[0].functionRegistry) { @@ -7167,7 +7929,7 @@ Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArgume mixinEnv = new contexts.Eval(mixinEnv, [frame].concat(mixinEnv.frames)); if (args) { - args = args.slice(0); + args = utils.copyArray(args); argsLength = args.length; for (i = 0; i < argsLength; i++) { @@ -7177,7 +7939,7 @@ Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArgume for (j = 0; j < params.length; j++) { if (!evaldArguments[j] && name === params[j].name) { evaldArguments[j] = arg.value.eval(context); - frame.prependRule(new Rule(name, arg.value.eval(context))); + frame.prependRule(new Declaration(name, arg.value.eval(context))); isNamedFound = true; break; } @@ -7205,7 +7967,7 @@ Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArgume for (j = argIndex; j < argsLength; j++) { varargs.push(args[j].value.eval(context)); } - frame.prependRule(new Rule(name, new Expression(varargs).eval(context))); + frame.prependRule(new Declaration(name, new Expression(varargs).eval(context))); } else { val = arg && arg.value; if (val) { @@ -7218,7 +7980,7 @@ Definition.prototype.evalParams = function (context, mixinEnv, args, evaldArgume ' (' + argsLength + ' for ' + this.arity + ')' }; } - frame.prependRule(new Rule(name, val)); + frame.prependRule(new Declaration(name, val)); evaldArguments[i] = val; } } @@ -7245,7 +8007,7 @@ Definition.prototype.makeImportant = function() { return result; }; Definition.prototype.eval = function (context) { - return new Definition(this.name, this.params, this.rules, this.condition, this.variadic, this.frames || context.frames.slice(0)); + return new Definition(this.name, this.params, this.rules, this.condition, this.variadic, this.frames || utils.copyArray(context.frames)); }; Definition.prototype.evalCall = function (context, args, important) { var _arguments = [], @@ -7253,9 +8015,9 @@ Definition.prototype.evalCall = function (context, args, important) { frame = this.evalParams(context, new contexts.Eval(context, mixinFrames), args, _arguments), rules, ruleset; - frame.prependRule(new Rule('@arguments', new Expression(_arguments).eval(context))); + frame.prependRule(new Declaration('@arguments', new Expression(_arguments).eval(context))); - rules = this.rules.slice(0); + rules = utils.copyArray(this.rules); ruleset = new Ruleset(null, rules); ruleset.originalRuleset = this; @@ -7268,7 +8030,7 @@ Definition.prototype.evalCall = function (context, args, important) { Definition.prototype.matchCondition = function (args, context) { if (this.condition && !this.condition.eval( new contexts.Eval(context, - [this.evalParams(context, /* the parameter variables*/ + [this.evalParams(context, /* the parameter variables */ new contexts.Eval(context, this.frames ? this.frames.concat(context.frames) : context.frames), args, [])] .concat(this.frames || []) // the parent namespace/mixin frames .concat(context.frames)))) { // the current environment frames @@ -7286,7 +8048,7 @@ Definition.prototype.matchArgs = function (args, context) { } }, 0); - if (! this.variadic) { + if (!this.variadic) { if (requiredArgsCnt < this.required) { return false; } @@ -7313,7 +8075,7 @@ Definition.prototype.matchArgs = function (args, context) { }; module.exports = Definition; -},{"../contexts":11,"./element":58,"./expression":59,"./rule":74,"./ruleset":76,"./selector":77}],69:[function(require,module,exports){ +},{"../contexts":12,"../utils":86,"./declaration":58,"./element":61,"./expression":62,"./ruleset":78,"./selector":79}],72:[function(require,module,exports){ var Node = require("./node"), Operation = require("./operation"), Dimension = require("./dimension"); @@ -7335,9 +8097,43 @@ Negative.prototype.eval = function (context) { }; module.exports = Negative; -},{"./dimension":56,"./node":70,"./operation":71}],70:[function(require,module,exports){ +},{"./dimension":60,"./node":73,"./operation":74}],73:[function(require,module,exports){ var Node = function() { + this.parent = null; + this.visibilityBlocks = undefined; + this.nodeVisible = undefined; + this.rootNode = null; + this.parsed = null; + + var self = this; + Object.defineProperty(this, "currentFileInfo", { + get: function() { return self.fileInfo(); } + }); + Object.defineProperty(this, "index", { + get: function() { return self.getIndex(); } + }); + +}; +Node.prototype.setParent = function(nodes, parent) { + function set(node) { + if (node && node instanceof Node) { + node.parent = parent; + } + } + if (Array.isArray(nodes)) { + nodes.forEach(set); + } + else { + set(nodes); + } +}; +Node.prototype.getIndex = function() { + return this._index || (this.parent && this.parent.getIndex()) || 0; }; +Node.prototype.fileInfo = function() { + return this._fileInfo || (this.parent && this.parent.fileInfo()) || {}; +}; +Node.prototype.isRulesetLike = function() { return false; }; Node.prototype.toCSS = function (context) { var strs = []; this.genCSS(context, { @@ -7367,8 +8163,8 @@ Node.prototype._operate = function (context, op, a, b) { }; Node.prototype.fround = function(context, value) { var precision = context && context.numPrecision; - //add "epsilon" to ensure numbers like 1.000000005 (represented as 1.000000004999....) are properly rounded... - return (precision == null) ? value : Number((value + 2e-16).toFixed(precision)); + // add "epsilon" to ensure numbers like 1.000000005 (represented as 1.000000004999...) are properly rounded: + return (precision) ? Number((value + 2e-16).toFixed(precision)) : value; }; Node.compare = function (a, b) { /* returns: @@ -7428,13 +8224,13 @@ Node.prototype.removeVisibilityBlock = function () { } this.visibilityBlocks = this.visibilityBlocks - 1; }; -//Turns on node visibility - if called node will be shown in output regardless -//of whether it comes from import by reference or not +// Turns on node visibility - if called node will be shown in output regardless +// of whether it comes from import by reference or not Node.prototype.ensureVisibility = function () { this.nodeVisible = true; }; -//Turns off node visibility - if called node will NOT be shown in output regardless -//of whether it comes from import by reference or not +// Turns off node visibility - if called node will NOT be shown in output regardless +// of whether it comes from import by reference or not Node.prototype.ensureInvisibility = function () { this.nodeVisible = false; }; @@ -7460,7 +8256,7 @@ Node.prototype.copyVisibilityInfo = function(info) { }; module.exports = Node; -},{}],71:[function(require,module,exports){ +},{}],74:[function(require,module,exports){ var Node = require("./node"), Color = require("./color"), Dimension = require("./dimension"); @@ -7488,7 +8284,7 @@ Operation.prototype.eval = function (context) { } if (!a.operate) { throw { type: "Operation", - message: "Operation on an invalid type" }; + message: "Operation on an invalid type" }; } return a.operate(context, this.op, b); @@ -7510,7 +8306,7 @@ Operation.prototype.genCSS = function (context, output) { module.exports = Operation; -},{"./color":50,"./dimension":56,"./node":70}],72:[function(require,module,exports){ +},{"./color":53,"./dimension":60,"./node":73}],75:[function(require,module,exports){ var Node = require("./node"); var Paren = function (node) { @@ -7523,28 +8319,100 @@ Paren.prototype.genCSS = function (context, output) { this.value.genCSS(context, output); output.add(')'); }; -Paren.prototype.eval = function (context) { - return new Paren(this.value.eval(context)); +Paren.prototype.eval = function (context) { + return new Paren(this.value.eval(context)); +}; +module.exports = Paren; + +},{"./node":73}],76:[function(require,module,exports){ +var Node = require("./node"), + Declaration = require("./declaration"); + +var Property = function (name, index, currentFileInfo) { + this.name = name; + this._index = index; + this._fileInfo = currentFileInfo; +}; +Property.prototype = new Node(); +Property.prototype.type = "Property"; +Property.prototype.eval = function (context) { + var property, name = this.name; + // TODO: shorten this reference + var mergeRules = context.pluginManager.less.visitors.ToCSSVisitor.prototype._mergeRules; + + if (this.evaluating) { + throw { type: 'Name', + message: "Recursive property reference for " + name, + filename: this.fileInfo().filename, + index: this.getIndex() }; + } + + this.evaluating = true; + + property = this.find(context.frames, function (frame) { + + var v, vArr = frame.property(name); + if (vArr) { + for (var i = 0; i < vArr.length; i++) { + v = vArr[i]; + + vArr[i] = new Declaration(v.name, + v.value, + v.important, + v.merge, + v.index, + v.currentFileInfo, + v.inline, + v.variable + ); + } + mergeRules(vArr); + + v = vArr[vArr.length - 1]; + if (v.important) { + var importantScope = context.importantScope[context.importantScope.length - 1]; + importantScope.important = v.important; + } + v = v.value.eval(context); + return v; + } + }); + if (property) { + this.evaluating = false; + return property; + } else { + throw { type: 'Name', + message: "Property '" + name + "' is undefined", + filename: this.currentFileInfo.filename, + index: this.index }; + } +}; +Property.prototype.find = function (obj, fun) { + for (var i = 0, r; i < obj.length; i++) { + r = fun.call(obj, obj[i]); + if (r) { return r; } + } + return null; }; -module.exports = Paren; +module.exports = Property; -},{"./node":70}],73:[function(require,module,exports){ +},{"./declaration":58,"./node":73}],77:[function(require,module,exports){ var Node = require("./node"), - JsEvalNode = require("./js-eval-node"), - Variable = require("./variable"); + Variable = require("./variable"), + Property = require("./property"); var Quoted = function (str, content, escaped, index, currentFileInfo) { this.escaped = (escaped == null) ? true : escaped; this.value = content || ''; this.quote = str.charAt(0); - this.index = index; - this.currentFileInfo = currentFileInfo; + this._index = index; + this._fileInfo = currentFileInfo; }; -Quoted.prototype = new JsEvalNode(); +Quoted.prototype = new Node(); Quoted.prototype.type = "Quoted"; Quoted.prototype.genCSS = function (context, output) { if (!this.escaped) { - output.add(this.quote, this.currentFileInfo, this.index); + output.add(this.quote, this.fileInfo(), this.getIndex()); } output.add(this.value); if (!this.escaped) { @@ -7552,15 +8420,16 @@ Quoted.prototype.genCSS = function (context, output) { } }; Quoted.prototype.containsVariables = function() { - return this.value.match(/(`([^`]+)`)|@\{([\w-]+)\}/); + return this.value.match(/@\{([\w-]+)\}/); }; Quoted.prototype.eval = function (context) { var that = this, value = this.value; - var javascriptReplacement = function (_, exp) { - return String(that.evaluateJavaScript(exp, context)); + var variableReplacement = function (_, name) { + var v = new Variable('@' + name, that.getIndex(), that.fileInfo()).eval(context, true); + return (v instanceof Quoted) ? v.value : v.toCSS(); }; - var interpolationReplacement = function (_, name) { - var v = new Variable('@' + name, that.index, that.currentFileInfo).eval(context, true); + var propertyReplacement = function (_, name) { + var v = new Property('$' + name, that.getIndex(), that.fileInfo()).eval(context, true); return (v instanceof Quoted) ? v.value : v.toCSS(); }; function iterativeReplace(value, regexp, replacementFnc) { @@ -7571,9 +8440,9 @@ Quoted.prototype.eval = function (context) { } while (value !== evaluatedValue); return evaluatedValue; } - value = iterativeReplace(value, /`([^`]+)`/g, javascriptReplacement); - value = iterativeReplace(value, /@\{([\w-]+)\}/g, interpolationReplacement); - return new Quoted(this.quote + value + this.quote, value, this.escaped, this.index, this.currentFileInfo); + value = iterativeReplace(value, /@\{([\w-]+)\}/g, variableReplacement); + value = iterativeReplace(value, /\$\{([\w-]+)\}/g, propertyReplacement); + return new Quoted(this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo()); }; Quoted.prototype.compare = function (other) { // when comparing quoted strings allow the quote to differ @@ -7585,142 +8454,39 @@ Quoted.prototype.compare = function (other) { }; module.exports = Quoted; -},{"./js-eval-node":64,"./node":70,"./variable":82}],74:[function(require,module,exports){ -var Node = require("./node"), - Value = require("./value"), - Keyword = require("./keyword"); - -var Rule = function (name, value, important, merge, index, currentFileInfo, inline, variable) { - this.name = name; - this.value = (value instanceof Node) ? value : new Value([value]); //value instanceof tree.Value || value instanceof tree.Ruleset ?? - this.important = important ? ' ' + important.trim() : ''; - this.merge = merge; - this.index = index; - this.currentFileInfo = currentFileInfo; - this.inline = inline || false; - this.variable = (variable !== undefined) ? variable - : (name.charAt && (name.charAt(0) === '@')); - this.allowRoot = true; -}; - -function evalName(context, name) { - var value = "", i, n = name.length, - output = {add: function (s) {value += s;}}; - for (i = 0; i < n; i++) { - name[i].eval(context).genCSS(context, output); - } - return value; -} - -Rule.prototype = new Node(); -Rule.prototype.type = "Rule"; -Rule.prototype.genCSS = function (context, output) { - output.add(this.name + (context.compress ? ':' : ': '), this.currentFileInfo, this.index); - try { - this.value.genCSS(context, output); - } - catch(e) { - e.index = this.index; - e.filename = this.currentFileInfo.filename; - throw e; - } - output.add(this.important + ((this.inline || (context.lastRule && context.compress)) ? "" : ";"), this.currentFileInfo, this.index); -}; -Rule.prototype.eval = function (context) { - var strictMathBypass = false, name = this.name, evaldValue, variable = this.variable; - if (typeof name !== "string") { - // expand 'primitive' name directly to get - // things faster (~10% for benchmark.less): - name = (name.length === 1) && (name[0] instanceof Keyword) ? - name[0].value : evalName(context, name); - variable = false; // never treat expanded interpolation as new variable name - } - if (name === "font" && !context.strictMath) { - strictMathBypass = true; - context.strictMath = true; - } - try { - context.importantScope.push({}); - evaldValue = this.value.eval(context); - - if (!this.variable && evaldValue.type === "DetachedRuleset") { - throw { message: "Rulesets cannot be evaluated on a property.", - index: this.index, filename: this.currentFileInfo.filename }; - } - var important = this.important, - importantResult = context.importantScope.pop(); - if (!important && importantResult.important) { - important = importantResult.important; - } - - return new Rule(name, - evaldValue, - important, - this.merge, - this.index, this.currentFileInfo, this.inline, - variable); - } - catch(e) { - if (typeof e.index !== 'number') { - e.index = this.index; - e.filename = this.currentFileInfo.filename; - } - throw e; - } - finally { - if (strictMathBypass) { - context.strictMath = false; - } - } -}; -Rule.prototype.makeImportant = function () { - return new Rule(this.name, - this.value, - "!important", - this.merge, - this.index, this.currentFileInfo, this.inline); -}; - -module.exports = Rule; -},{"./keyword":65,"./node":70,"./value":81}],75:[function(require,module,exports){ +},{"./node":73,"./property":76,"./variable":85}],78:[function(require,module,exports){ var Node = require("./node"), - Variable = require("./variable"); - -var RulesetCall = function (variable) { - this.variable = variable; - this.allowRoot = true; -}; -RulesetCall.prototype = new Node(); -RulesetCall.prototype.type = "RulesetCall"; -RulesetCall.prototype.eval = function (context) { - var detachedRuleset = new Variable(this.variable).eval(context); - return detachedRuleset.callEval(context); -}; -module.exports = RulesetCall; - -},{"./node":70,"./variable":82}],76:[function(require,module,exports){ -var Node = require("./node"), - Rule = require("./rule"), + Declaration = require("./declaration"), + Keyword = require("./keyword"), + Comment = require("./comment"), + Paren = require("./paren"), Selector = require("./selector"), Element = require("./element"), - Paren = require("./paren"), + Anonymous = require("./anonymous"), contexts = require("../contexts"), globalFunctionRegistry = require("../functions/function-registry"), defaultFunc = require("../functions/default"), - getDebugInfo = require("./debug-info"); + getDebugInfo = require("./debug-info"), + utils = require("../utils"); var Ruleset = function (selectors, rules, strictImports, visibilityInfo) { this.selectors = selectors; this.rules = rules; this._lookups = {}; + this._variables = null; + this._properties = null; this.strictImports = strictImports; this.copyVisibilityInfo(visibilityInfo); this.allowRoot = true; + + this.setParent(this.selectors, this); + this.setParent(this.rules, this); + }; Ruleset.prototype = new Node(); Ruleset.prototype.type = "Ruleset"; Ruleset.prototype.isRuleset = true; -Ruleset.prototype.isRulesetLike = true; +Ruleset.prototype.isRulesetLike = function() { return true; }; Ruleset.prototype.accept = function (visitor) { if (this.paths) { this.paths = visitor.visitArray(this.paths, true); @@ -7736,14 +8502,14 @@ Ruleset.prototype.eval = function (context) { selCnt, selector, i, hasOnePassingSelector = false; if (thisSelectors && (selCnt = thisSelectors.length)) { - selectors = []; + selectors = new Array(selCnt); defaultFunc.error({ type: "Syntax", message: "it is currently only allowed in parametric mixin guards," }); for (i = 0; i < selCnt; i++) { selector = thisSelectors[i].eval(context); - selectors.push(selector); + selectors[i] = selector; if (selector.evaldCondition) { hasOnePassingSelector = true; } @@ -7753,7 +8519,7 @@ Ruleset.prototype.eval = function (context) { hasOnePassingSelector = true; } - var rules = this.rules ? this.rules.slice(0) : null, + var rules = this.rules ? utils.copyArray(this.rules) : null, ruleset = new Ruleset(selectors, rules, this.strictImports, this.visibilityInfo()), rule, subRule; @@ -7801,21 +8567,21 @@ Ruleset.prototype.eval = function (context) { // Store the frames around mixin definitions, // so they can be evaluated like closures when the time comes. - var rsRules = ruleset.rules, rsRuleCnt = rsRules ? rsRules.length : 0; - for (i = 0; i < rsRuleCnt; i++) { - if (rsRules[i].evalFirst) { - rsRules[i] = rsRules[i].eval(context); + var rsRules = ruleset.rules; + for (i = 0; (rule = rsRules[i]); i++) { + if (rule.evalFirst) { + rsRules[i] = rule.eval(context); } } var mediaBlockCount = (context.mediaBlocks && context.mediaBlocks.length) || 0; // Evaluate mixin calls. - for (i = 0; i < rsRuleCnt; i++) { - if (rsRules[i].type === "MixinCall") { - /*jshint loopfunc:true */ - rules = rsRules[i].eval(context).filter(function(r) { - if ((r instanceof Rule) && r.variable) { + for (i = 0; (rule = rsRules[i]); i++) { + if (rule.type === "MixinCall") { + /* jshint loopfunc:true */ + rules = rule.eval(context).filter(function(r) { + if ((r instanceof Declaration) && r.variable) { // do not pollute the scope if the variable is // already there. consider returning false here // but we need a way to "return" variable from mixins @@ -7824,47 +8590,44 @@ Ruleset.prototype.eval = function (context) { return true; }); rsRules.splice.apply(rsRules, [i, 1].concat(rules)); - rsRuleCnt += rules.length - 1; i += rules.length - 1; ruleset.resetCache(); - } else if (rsRules[i].type === "RulesetCall") { - /*jshint loopfunc:true */ - rules = rsRules[i].eval(context).rules.filter(function(r) { - if ((r instanceof Rule) && r.variable) { + } else if (rule.type === "VariableCall") { + /* jshint loopfunc:true */ + rules = rule.eval(context).rules.filter(function(r) { + if ((r instanceof Declaration) && r.variable) { // do not pollute the scope at all return false; } return true; }); rsRules.splice.apply(rsRules, [i, 1].concat(rules)); - rsRuleCnt += rules.length - 1; i += rules.length - 1; ruleset.resetCache(); } } // Evaluate everything else - for (i = 0; i < rsRules.length; i++) { - rule = rsRules[i]; + for (i = 0; (rule = rsRules[i]); i++) { if (!rule.evalFirst) { rsRules[i] = rule = rule.eval ? rule.eval(context) : rule; } } // Evaluate everything else - for (i = 0; i < rsRules.length; i++) { - rule = rsRules[i]; + for (i = 0; (rule = rsRules[i]); i++) { // for rulesets, check if it is a css guard and can be removed if (rule instanceof Ruleset && rule.selectors && rule.selectors.length === 1) { // check if it can be folded in (e.g. & where) if (rule.selectors[0].isJustParentSelector()) { rsRules.splice(i--, 1); - for (var j = 0; j < rule.rules.length; j++) { - subRule = rule.rules[j]; - subRule.copyVisibilityInfo(rule.visibilityInfo()); - if (!(subRule instanceof Rule) || !subRule.variable) { - rsRules.splice(++i, 0, subRule); + for (var j = 0; (subRule = rule.rules[j]); j++) { + if (subRule instanceof Node) { + subRule.copyVisibilityInfo(rule.visibilityInfo()); + if (!(subRule instanceof Declaration) || !subRule.variable) { + rsRules.splice(++i, 0, subRule); + } } } } @@ -7892,7 +8655,7 @@ Ruleset.prototype.evalImports = function(context) { importRules = rules[i].eval(context); if (importRules && (importRules.length || importRules.length === 0)) { rules.splice.apply(rules, [i, 1].concat(importRules)); - i+= importRules.length - 1; + i += importRules.length - 1; } else { rules.splice(i, 1, importRules); } @@ -7931,12 +8694,13 @@ Ruleset.prototype.matchCondition = function (args, context) { Ruleset.prototype.resetCache = function () { this._rulesets = null; this._variables = null; + this._properties = null; this._lookups = {}; }; Ruleset.prototype.variables = function () { if (!this._variables) { this._variables = !this.rules ? {} : this.rules.reduce(function (hash, r) { - if (r instanceof Rule && r.variable === true) { + if (r instanceof Declaration && r.variable === true) { hash[r.name] = r; } // when evaluating variables in an import statement, imports have not been eval'd @@ -7955,17 +8719,81 @@ Ruleset.prototype.variables = function () { } return this._variables; }; +Ruleset.prototype.properties = function () { + if (!this._properties) { + this._properties = !this.rules ? {} : this.rules.reduce(function (hash, r) { + if (r instanceof Declaration && r.variable !== true) { + var name = (r.name.length === 1) && (r.name[0] instanceof Keyword) ? + r.name[0].value : r.name; + // Properties don't overwrite as they can merge + if (!hash['$' + name]) { + hash['$' + name] = [ r ]; + } + else { + hash['$' + name].push(r); + } + } + return hash; + }, {}); + } + return this._properties; +}; Ruleset.prototype.variable = function (name) { - return this.variables()[name]; + var decl = this.variables()[name]; + if (decl) { + return this.parseValue(decl); + } +}; +Ruleset.prototype.property = function (name) { + var decl = this.properties()[name]; + if (decl) { + return this.parseValue(decl); + } +}; +Ruleset.prototype.parseValue = function(toParse) { + var self = this; + function transformDeclaration(decl) { + if (decl.value instanceof Anonymous && !decl.parsed) { + this.parse.parseNode( + decl.value.value, + ["value", "important"], + decl.value.getIndex(), + decl.fileInfo(), + function(err, result) { + if (err) { + decl.parsed = true; + } + if (result) { + decl.value = result[0]; + decl.important = result[1] || ''; + decl.parsed = true; + } + }); + + return decl; + } + else { + return decl; + } + } + if (!Array.isArray(toParse)) { + return transformDeclaration.call(self, toParse); + } + else { + var nodes = []; + toParse.forEach(function(n) { + nodes.push(transformDeclaration.call(self, n)); + }); + return nodes; + } }; Ruleset.prototype.rulesets = function () { if (!this.rules) { return []; } - var filtRules = [], rules = this.rules, cnt = rules.length, + var filtRules = [], rules = this.rules, i, rule; - for (i = 0; i < cnt; i++) { - rule = rules[i]; + for (i = 0; (rule = rules[i]); i++) { if (rule.isRuleset) { filtRules.push(rule); } @@ -7980,6 +8808,7 @@ Ruleset.prototype.prependRule = function (rule) { } else { this.rules = [ rule ]; } + this.setParent(rule, this); }; Ruleset.prototype.find = function (selector, self, filter) { self = self || this; @@ -8030,25 +8859,10 @@ Ruleset.prototype.genCSS = function (context, output) { tabSetStr = context.compress ? '' : Array(context.tabLevel).join(" "), sep; - function isRulesetLikeNode(rule) { - // if it has nested rules, then it should be treated like a ruleset - // medias and comments do not have nested rules, but should be treated like rulesets anyway - // some directives and anonymous nodes are ruleset like, others are not - if (typeof rule.isRulesetLike === "boolean") { - return rule.isRulesetLike; - } else if (typeof rule.isRulesetLike === "function") { - return rule.isRulesetLike(); - } - - //anything else is assumed to be a rule - return false; - } - var charsetNodeIndex = 0; var importNodeIndex = 0; - for (i = 0; i < this.rules.length; i++) { - rule = this.rules[i]; - if (rule.type === "Comment") { + for (i = 0; (rule = this.rules[i]); i++) { + if (rule instanceof Comment) { if (importNodeIndex === i) { importNodeIndex++; } @@ -8099,15 +8913,14 @@ Ruleset.prototype.genCSS = function (context, output) { } // Compile rules and rulesets - for (i = 0; i < ruleNodes.length; i++) { - rule = ruleNodes[i]; + for (i = 0; (rule = ruleNodes[i]); i++) { if (i + 1 === ruleNodes.length) { context.lastRule = true; } var currentLastRule = context.lastRule; - if (isRulesetLikeNode(rule)) { + if (rule.isRulesetLike(rule)) { context.lastRule = false; } @@ -8119,7 +8932,7 @@ Ruleset.prototype.genCSS = function (context, output) { context.lastRule = currentLastRule; - if (!context.lastRule) { + if (!context.lastRule && rule.isVisible()) { output.add(context.compress ? '' : ('\n' + tabRuleStr)); } else { context.lastRule = false; @@ -8149,9 +8962,9 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) { if (elementsToPak.length === 0) { replacementParen = new Paren(elementsToPak[0]); } else { - var insideParent = []; + var insideParent = new Array(elementsToPak.length); for (j = 0; j < elementsToPak.length; j++) { - insideParent.push(new Element(null, elementsToPak[j], originalElement.index, originalElement.currentFileInfo)); + insideParent[j] = new Element(null, elementsToPak[j], originalElement._index, originalElement._fileInfo); } replacementParen = new Paren(new Selector(insideParent)); } @@ -8160,7 +8973,7 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) { function createSelector(containedElement, originalElement) { var element, selector; - element = new Element(null, containedElement, originalElement.index, originalElement.currentFileInfo); + element = new Element(null, containedElement, originalElement._index, originalElement._fileInfo); selector = new Selector([element]); return selector; } @@ -8173,12 +8986,12 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) { // our new selector path newSelectorPath = []; - //construct the joined selector - if & is the first thing this will be empty, + // construct the joined selector - if & is the first thing this will be empty, // if not newJoinedSelector will be the last set of elements in the selector if (beginningPath.length > 0) { - newSelectorPath = beginningPath.slice(0); + newSelectorPath = utils.copyArray(beginningPath); lastSelector = newSelectorPath.pop(); - newJoinedSelector = originalSelector.createDerived(lastSelector.elements.slice(0)); + newJoinedSelector = originalSelector.createDerived(utils.copyArray(lastSelector.elements)); } else { newJoinedSelector = originalSelector.createDerived([]); @@ -8194,7 +9007,7 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) { combinator = parentEl.combinator; } // join the elements so far with the first part of the parent - newJoinedSelector.elements.push(new Element(combinator, parentEl.value, replacedElement.index, replacedElement.currentFileInfo)); + newJoinedSelector.elements.push(new Element(combinator, parentEl.value, replacedElement._index, replacedElement._fileInfo)); newJoinedSelector.elements = newJoinedSelector.elements.concat(addPath[0].elements.slice(1)); } @@ -8203,7 +9016,7 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) { newSelectorPath.push(newJoinedSelector); } - //put together the parent selectors after the join (e.g. the rest of the parent) + // put together the parent selectors after the join (e.g. the rest of the parent) if (addPath.length > 1) { var restOfPath = addPath.slice(1); restOfPath = restOfPath.map(function (selector) { @@ -8237,9 +9050,7 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) { return; } - for (i = 0; i < selectors.length; i++) { - sel = selectors[i]; - + for (i = 0; (sel = selectors[i]); i++) { // if the previous thing in sel is a parent this needs to join on to it if (sel.length > 0) { sel[sel.length - 1] = sel[sel.length - 1].createDerived(sel[sel.length - 1].elements.concat(elements)); @@ -8267,12 +9078,12 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) { var i, j, k, currentElements, newSelectors, selectorsMultiplied, sel, el, hadParentSelector = false, length, lastSelector; function findNestedSelector(element) { var maybeSelector; - if (element.value.type !== 'Paren') { + if (!(element.value instanceof Paren)) { return null; } maybeSelector = element.value.value; - if (maybeSelector.type !== 'Selector') { + if (!(maybeSelector instanceof Selector)) { return null; } @@ -8288,8 +9099,7 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) { [] ]; - for (i = 0; i < inSelector.elements.length; i++) { - el = inSelector.elements[i]; + for (i = 0; (el = inSelector.elements[i]); i++) { // non parent reference elements just get added if (el.value !== "&") { var nestedSelector = findNestedSelector(el); @@ -8301,7 +9111,7 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) { var nestedPaths = [], replaced, replacedNewSelectors = []; replaced = replaceParentSelector(nestedPaths, context, nestedSelector); hadParentSelector = hadParentSelector || replaced; - //the nestedPaths array should have only one member - replaceParentSelector does not multiply selectors + // the nestedPaths array should have only one member - replaceParentSelector does not multiply selectors for (k = 0; k < nestedPaths.length; k++) { var replacementSelector = createSelector(createParenthesis(nestedPaths[k], el), el); addAllReplacementsIntoPath(newSelectors, [replacementSelector], el, inSelector, replacedNewSelectors); @@ -8331,7 +9141,7 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) { // the combinator used on el should now be applied to the next element instead so that // it is not lost if (sel.length > 0) { - sel[0].elements.push(new Element(el.combinator, '', el.index, el.currentFileInfo)); + sel[0].elements.push(new Element(el.combinator, '', el._index, el._fileInfo)); } selectorsMultiplied.push(sel); } @@ -8363,7 +9173,6 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) { paths.push(newSelectors[i]); lastSelector = newSelectors[i][length - 1]; newSelectors[i][length - 1] = lastSelector.createDerived(lastSelector.elements, inSelector.extendList); - //newSelectors[i][length - 1].copyVisibilityInfo(inSelector.visibilityInfo()); } } @@ -8386,12 +9195,7 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) { if (context.length > 0) { newPaths = []; for (i = 0; i < context.length; i++) { - //var concatenated = []; - //context[i].forEach(function(entry) { - // var newEntry = entry.createDerived(entry.elements, entry.extendList, entry.evaldCondition); - // newEntry.copyVisibilityInfo(selector.visibilityInfo()); - // concatenated.push(newEntry); - //}, this); + var concatenated = context[i].map(deriveSelector.bind(this, selector.visibilityInfo())); concatenated.push(selector); @@ -8410,19 +9214,21 @@ Ruleset.prototype.joinSelector = function (paths, context, selector) { }; module.exports = Ruleset; -},{"../contexts":11,"../functions/default":20,"../functions/function-registry":22,"./debug-info":54,"./element":58,"./node":70,"./paren":72,"./rule":74,"./selector":77}],77:[function(require,module,exports){ +},{"../contexts":12,"../functions/default":24,"../functions/function-registry":26,"../utils":86,"./anonymous":48,"./comment":55,"./debug-info":57,"./declaration":58,"./element":61,"./keyword":68,"./node":73,"./paren":75,"./selector":79}],79:[function(require,module,exports){ var Node = require("./node"), - Element = require("./element"); + Element = require("./element"), + LessError = require("../less-error"); var Selector = function (elements, extendList, condition, index, currentFileInfo, visibilityInfo) { - this.elements = elements; this.extendList = extendList; this.condition = condition; - this.currentFileInfo = currentFileInfo || {}; - if (!condition) { - this.evaldCondition = true; - } + this.evaldCondition = !condition; + this._index = index; + this._fileInfo = currentFileInfo; + this.elements = this.getElements(elements); + this.mixinElements_ = undefined; this.copyVisibilityInfo(visibilityInfo); + this.setParent(this.elements, this); }; Selector.prototype = new Node(); Selector.prototype.type = "Selector"; @@ -8438,16 +9244,35 @@ Selector.prototype.accept = function (visitor) { } }; Selector.prototype.createDerived = function(elements, extendList, evaldCondition) { - var info = this.visibilityInfo(); - evaldCondition = (evaldCondition != null) ? evaldCondition : this.evaldCondition; - var newSelector = new Selector(elements, extendList || this.extendList, null, this.index, this.currentFileInfo, info); - newSelector.evaldCondition = evaldCondition; + elements = this.getElements(elements); + var newSelector = new Selector(elements, extendList || this.extendList, + null, this.getIndex(), this.fileInfo(), this.visibilityInfo()); + newSelector.evaldCondition = (evaldCondition != null) ? evaldCondition : this.evaldCondition; newSelector.mediaEmpty = this.mediaEmpty; return newSelector; }; +Selector.prototype.getElements = function(els) { + if (typeof els === "string") { + this.parse.parseNode( + els, + ["selector"], + this._index, + this._fileInfo, + function(err, result) { + if (err) { + throw new LessError({ + index: err.index, + message: err.message + }, this.parse.imports, this._fileInfo.filename); + } + els = result[0].elements; + }); + } + return els; +}; Selector.prototype.createEmptySelectors = function() { - var el = new Element('', '&', this.index, this.currentFileInfo), - sels = [new Selector([el], null, null, this.index, this.currentFileInfo)]; + var el = new Element('', '&', this._index, this._fileInfo), + sels = [new Selector([el], null, null, this._index, this._fileInfo)]; sels[0].mediaEmpty = true; return sels; }; @@ -8456,14 +9281,13 @@ Selector.prototype.match = function (other) { len = elements.length, olen, i; - other.CacheElements(); - - olen = other._elements.length; + other = other.mixinElements(); + olen = other.length; if (olen === 0 || len < olen) { return 0; } else { for (i = 0; i < olen; i++) { - if (elements[i].value !== other._elements[i]) { + if (elements[i].value !== other[i]) { return 0; } } @@ -8471,9 +9295,9 @@ Selector.prototype.match = function (other) { return olen; // return number of matched elements }; -Selector.prototype.CacheElements = function() { - if (this._elements) { - return; +Selector.prototype.mixinElements = function() { + if (this.mixinElements_) { + return this.mixinElements_; } var elements = this.elements.map( function(v) { @@ -8488,7 +9312,7 @@ Selector.prototype.CacheElements = function() { elements = []; } - this._elements = elements; + return (this.mixinElements_ = elements); }; Selector.prototype.isJustParentSelector = function() { return !this.mediaEmpty && @@ -8508,14 +9332,11 @@ Selector.prototype.eval = function (context) { Selector.prototype.genCSS = function (context, output) { var i, element; if ((!context || !context.firstSelector) && this.elements[0].combinator.value === "") { - output.add(' ', this.currentFileInfo, this.index); + output.add(' ', this.fileInfo(), this.getIndex()); } - if (!this._css) { - //TODO caching? speed comparison? - for (i = 0; i < this.elements.length; i++) { - element = this.elements[i]; - element.genCSS(context, output); - } + for (i = 0; i < this.elements.length; i++) { + element = this.elements[i]; + element.genCSS(context, output); } }; Selector.prototype.getIsOutput = function() { @@ -8523,7 +9344,7 @@ Selector.prototype.getIsOutput = function() { }; module.exports = Selector; -},{"./element":58,"./node":70}],78:[function(require,module,exports){ +},{"../less-error":36,"./element":61,"./node":73}],80:[function(require,module,exports){ var Node = require("./node"); var UnicodeDescriptor = function (value) { @@ -8534,13 +9355,14 @@ UnicodeDescriptor.prototype.type = "UnicodeDescriptor"; module.exports = UnicodeDescriptor; -},{"./node":70}],79:[function(require,module,exports){ +},{"./node":73}],81:[function(require,module,exports){ var Node = require("./node"), - unitConversions = require("../data/unit-conversions"); + unitConversions = require("../data/unit-conversions"), + utils = require("../utils"); var Unit = function (numerator, denominator, backupUnit) { - this.numerator = numerator ? numerator.slice(0).sort() : []; - this.denominator = denominator ? denominator.slice(0).sort() : []; + this.numerator = numerator ? utils.copyArray(numerator).sort() : []; + this.denominator = denominator ? utils.copyArray(denominator).sort() : []; if (backupUnit) { this.backupUnit = backupUnit; } else if (numerator && numerator.length) { @@ -8551,7 +9373,7 @@ var Unit = function (numerator, denominator, backupUnit) { Unit.prototype = new Node(); Unit.prototype.type = "Unit"; Unit.prototype.clone = function () { - return new Unit(this.numerator.slice(0), this.denominator.slice(0), this.backupUnit); + return new Unit(utils.copyArray(this.numerator), utils.copyArray(this.denominator), this.backupUnit); }; Unit.prototype.genCSS = function (context, output) { // Dimension checks the unit is singular and throws an error if in strict math mode. @@ -8601,7 +9423,7 @@ Unit.prototype.usedUnits = function() { var group, result = {}, mapUnit, groupName; mapUnit = function (atomicUnit) { - /*jshint loopfunc:true */ + /* jshint loopfunc:true */ if (group.hasOwnProperty(atomicUnit) && !result[groupName]) { result[groupName] = atomicUnit; } @@ -8656,13 +9478,13 @@ Unit.prototype.cancel = function () { }; module.exports = Unit; -},{"../data/unit-conversions":14,"./node":70}],80:[function(require,module,exports){ +},{"../data/unit-conversions":15,"../utils":86,"./node":73}],82:[function(require,module,exports){ var Node = require("./node"); var URL = function (val, index, currentFileInfo, isEvald) { this.value = val; - this.currentFileInfo = currentFileInfo; - this.index = index; + this._index = index; + this._fileInfo = currentFileInfo; this.isEvald = isEvald; }; URL.prototype = new Node(); @@ -8681,7 +9503,7 @@ URL.prototype.eval = function (context) { if (!this.isEvald) { // Add the base path if the URL is relative - rootpath = this.currentFileInfo && this.currentFileInfo.rootpath; + rootpath = this.fileInfo() && this.fileInfo().rootpath; if (rootpath && typeof val.value === "string" && context.isPathRelative(val.value)) { @@ -8708,18 +9530,23 @@ URL.prototype.eval = function (context) { } } - return new URL(val, this.index, this.currentFileInfo, true); + return new URL(val, this.getIndex(), this.fileInfo(), true); }; module.exports = URL; -},{"./node":70}],81:[function(require,module,exports){ +},{"./node":73}],83:[function(require,module,exports){ var Node = require("./node"); var Value = function (value) { - this.value = value; if (!value) { throw new Error("Value requires an array argument"); } + if (!Array.isArray(value)) { + this.value = [ value ]; + } + else { + this.value = value; + } }; Value.prototype = new Node(); Value.prototype.type = "Value"; @@ -8748,13 +9575,29 @@ Value.prototype.genCSS = function (context, output) { }; module.exports = Value; -},{"./node":70}],82:[function(require,module,exports){ +},{"./node":73}],84:[function(require,module,exports){ +var Node = require("./node"), + Variable = require("./variable"); + +var VariableCall = function (variable) { + this.variable = variable; + this.allowRoot = true; +}; +VariableCall.prototype = new Node(); +VariableCall.prototype.type = "VariableCall"; +VariableCall.prototype.eval = function (context) { + var detachedRuleset = new Variable(this.variable).eval(context); + return detachedRuleset.callEval(context); +}; +module.exports = VariableCall; + +},{"./node":73,"./variable":85}],85:[function(require,module,exports){ var Node = require("./node"); var Variable = function (name, index, currentFileInfo) { this.name = name; - this.index = index; - this.currentFileInfo = currentFileInfo || {}; + this._index = index; + this._fileInfo = currentFileInfo; }; Variable.prototype = new Node(); Variable.prototype.type = "Variable"; @@ -8762,14 +9605,14 @@ Variable.prototype.eval = function (context) { var variable, name = this.name; if (name.indexOf('@@') === 0) { - name = '@' + new Variable(name.slice(1), this.index, this.currentFileInfo).eval(context).value; + name = '@' + new Variable(name.slice(1), this.getIndex(), this.fileInfo()).eval(context).value; } if (this.evaluating) { throw { type: 'Name', - message: "Recursive variable definition for " + name, - filename: this.currentFileInfo.filename, - index: this.index }; + message: "Recursive variable definition for " + name, + filename: this.fileInfo().filename, + index: this.getIndex() }; } this.evaluating = true; @@ -8789,9 +9632,9 @@ Variable.prototype.eval = function (context) { return variable; } else { throw { type: 'Name', - message: "variable " + name + " is undefined", - filename: this.currentFileInfo.filename, - index: this.index }; + message: "variable " + name + " is undefined", + filename: this.fileInfo().filename, + index: this.getIndex() }; } }; Variable.prototype.find = function (obj, fun) { @@ -8803,7 +9646,8 @@ Variable.prototype.find = function (obj, fun) { }; module.exports = Variable; -},{"./node":70}],83:[function(require,module,exports){ +},{"./node":73}],86:[function(require,module,exports){ +/* jshint proto: true */ module.exports = { getLocation: function(index, inputStream) { var n = index + 1, @@ -8822,15 +9666,64 @@ module.exports = { line: line, column: column }; + }, + copyArray: function(arr) { + var i, length = arr.length, + copy = new Array(length); + + for (i = 0; i < length; i++) { + copy[i] = arr[i]; + } + return copy; + }, + clone: function (obj) { + var cloned = {}; + for (var prop in obj) { + if (obj.hasOwnProperty(prop)) { + cloned[prop] = obj[prop]; + } + } + return cloned; + }, + defaults: function(obj1, obj2) { + if (!obj2._defaults || obj2._defaults !== obj1) { + for (var prop in obj1) { + if (obj1.hasOwnProperty(prop)) { + if (!obj2.hasOwnProperty(prop)) { + obj2[prop] = obj1[prop]; + } + else if (Array.isArray(obj1[prop]) + && Array.isArray(obj2[prop])) { + + obj1[prop].forEach(function(p) { + if (obj2[prop].indexOf(p) === -1) { + obj2[prop].push(p); + } + }); + } + } + } + } + obj2._defaults = obj1; + return obj2; + }, + merge: function(obj1, obj2) { + for (var prop in obj2) { + if (obj2.hasOwnProperty(prop)) { + obj1[prop] = obj2[prop]; + } + } + return obj1; } }; -},{}],84:[function(require,module,exports){ +},{}],87:[function(require,module,exports){ var tree = require("../tree"), Visitor = require("./visitor"), - logger = require("../logger"); + logger = require("../logger"), + utils = require("../utils"); -/*jshint loopfunc:true */ +/* jshint loopfunc:true */ var ExtendFinderVisitor = function() { this._visitor = new Visitor(this); @@ -8844,7 +9737,7 @@ ExtendFinderVisitor.prototype = { root.allExtends = this.allExtendsStack[0]; return root; }, - visitRule: function (ruleNode, visitArgs) { + visitDeclaration: function (declNode, visitArgs) { visitArgs.visitDeeper = false; }, visitMixinDefinition: function (mixinDefinitionNode, visitArgs) { @@ -8874,7 +9767,7 @@ ExtendFinderVisitor.prototype = { selector = selectorPath[selectorPath.length - 1], selExtendList = selector.extendList; - extendList = selExtendList ? selExtendList.slice(0).concat(allSelectorsExtendList) + extendList = selExtendList ? utils.copyArray(selExtendList).concat(allSelectorsExtendList) : allSelectorsExtendList; if (extendList) { @@ -8907,11 +9800,11 @@ ExtendFinderVisitor.prototype = { visitMediaOut: function (mediaNode) { this.allExtendsStack.length = this.allExtendsStack.length - 1; }, - visitDirective: function (directiveNode, visitArgs) { - directiveNode.allExtends = []; - this.allExtendsStack.push(directiveNode.allExtends); + visitAtRule: function (atRuleNode, visitArgs) { + atRuleNode.allExtends = []; + this.allExtendsStack.push(atRuleNode.allExtends); }, - visitDirectiveOut: function (directiveNode) { + visitAtRuleOut: function (atRuleNode) { this.allExtendsStack.length = this.allExtendsStack.length - 1; } }; @@ -8937,17 +9830,17 @@ ProcessExtendsVisitor.prototype = { extendList.filter(function(extend) { return !extend.hasFoundMatches && extend.parent_ids.length == 1; }).forEach(function(extend) { - var selector = "_unknown_"; - try { - selector = extend.selector.toCSS({}); - } - catch(_) {} + var selector = "_unknown_"; + try { + selector = extend.selector.toCSS({}); + } + catch (_) {} - if (!indices[extend.index + ' ' + selector]) { - indices[extend.index + ' ' + selector] = true; - logger.warn("extend '" + selector + "' has no matches"); - } - }); + if (!indices[extend.index + ' ' + selector]) { + indices[extend.index + ' ' + selector] = true; + logger.warn("extend '" + selector + "' has no matches"); + } + }); }, doExtendChaining: function (extendsList, extendsListTarget, iterationCount) { // @@ -8964,7 +9857,7 @@ ProcessExtendsVisitor.prototype = { iterationCount = iterationCount || 0; - //loop through comparing every extend with every target extend. + // loop through comparing every extend with every target extend. // a target extend is the one on the ruleset we are looking at copy/edit/pasting in place // e.g. .a:extend(.b) {} and .b:extend(.c) {} then the first extend extends the second one // and the second is the target. @@ -8994,7 +9887,7 @@ ProcessExtendsVisitor.prototype = { newSelector = extendVisitor.extendSelector(matches, selectorPath, selfSelector, extend.isVisible()); // but now we create a new extend from it - newExtend = new(tree.Extend)(targetExtend.selector, targetExtend.option, 0, targetExtend.currentFileInfo, info); + newExtend = new(tree.Extend)(targetExtend.selector, targetExtend.option, 0, targetExtend.fileInfo(), info); newExtend.selfSelectors = newSelector; // add the extend onto the list of extends for that selector @@ -9030,7 +9923,7 @@ ProcessExtendsVisitor.prototype = { selectorOne = extendsToAdd[0].selfSelectors[0].toCSS(); selectorTwo = extendsToAdd[0].selector.toCSS(); } - catch(e) {} + catch (e) {} throw { message: "extend circular reference detected. One of the circular extends is currently:" + selectorOne + ":extend(" + selectorTwo + ")"}; } @@ -9042,7 +9935,7 @@ ProcessExtendsVisitor.prototype = { return extendsToAdd; } }, - visitRule: function (ruleNode, visitArgs) { + visitDeclaration: function (ruleNode, visitArgs) { visitArgs.visitDeeper = false; }, visitMixinDefinition: function (mixinDefinitionNode, visitArgs) { @@ -9195,7 +10088,7 @@ ProcessExtendsVisitor.prototype = { }, extendSelector:function (matches, selectorPath, replacementSelector, isVisible) { - //for a set of matches, replace each match with the replacement selector + // for a set of matches, replace each match with the replacement selector var currentSelectorPathIndex = 0, currentSelectorPathElementIndex = 0, @@ -9212,8 +10105,8 @@ ProcessExtendsVisitor.prototype = { firstElement = new tree.Element( match.initialCombinator, replacementSelector.elements[0].value, - replacementSelector.elements[0].index, - replacementSelector.elements[0].currentFileInfo + replacementSelector.elements[0].getIndex(), + replacementSelector.elements[0].fileInfo() ); if (match.pathIndex > currentSelectorPathIndex && currentSelectorPathElementIndex > 0) { @@ -9274,12 +10167,12 @@ ProcessExtendsVisitor.prototype = { var lastIndex = this.allExtendsStack.length - 1; this.allExtendsStack.length = lastIndex; }, - visitDirective: function (directiveNode, visitArgs) { - var newAllExtends = directiveNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]); - newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, directiveNode.allExtends)); + visitAtRule: function (atRuleNode, visitArgs) { + var newAllExtends = atRuleNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length - 1]); + newAllExtends = newAllExtends.concat(this.doExtendChaining(newAllExtends, atRuleNode.allExtends)); this.allExtendsStack.push(newAllExtends); }, - visitDirectiveOut: function (directiveNode) { + visitAtRuleOut: function (atRuleNode) { var lastIndex = this.allExtendsStack.length - 1; this.allExtendsStack.length = lastIndex; } @@ -9287,7 +10180,7 @@ ProcessExtendsVisitor.prototype = { module.exports = ProcessExtendsVisitor; -},{"../logger":33,"../tree":62,"./visitor":91}],85:[function(require,module,exports){ +},{"../logger":37,"../tree":65,"../utils":86,"./visitor":94}],88:[function(require,module,exports){ function ImportSequencer(onSequencerEmpty) { this.imports = []; this.variableImports = []; @@ -9343,10 +10236,11 @@ ImportSequencer.prototype.tryRun = function() { module.exports = ImportSequencer; -},{}],86:[function(require,module,exports){ +},{}],89:[function(require,module,exports){ var contexts = require("../contexts"), Visitor = require("./visitor"), - ImportSequencer = require("./import-sequencer"); + ImportSequencer = require("./import-sequencer"), + utils = require("../utils"); var ImportVisitor = function(importer, finish) { @@ -9367,7 +10261,7 @@ ImportVisitor.prototype = { // process the contents this._visitor.visit(root); } - catch(e) { + catch (e) { this.error = e; } @@ -9385,7 +10279,7 @@ ImportVisitor.prototype = { if (!importNode.css || inlineCSS) { - var context = new contexts.Eval(this.context, this.context.frames.slice(0)); + var context = new contexts.Eval(this.context, utils.copyArray(this.context.frames)); var importParent = context.frames[0]; this.importCount++; @@ -9403,8 +10297,8 @@ ImportVisitor.prototype = { try { evaldImportNode = importNode.evalForImport(context); - } catch(e) { - if (!e.filename) { e.index = importNode.index; e.filename = importNode.currentFileInfo.filename; } + } catch (e) { + if (!e.filename) { e.index = importNode.getIndex(); e.filename = importNode.fileInfo().filename; } // attempt to eval properly and treat as css importNode.css = true; // if that fails, this error will be thrown @@ -9430,7 +10324,7 @@ ImportVisitor.prototype = { var onImported = this.onImported.bind(this, evaldImportNode, context), sequencedOnImported = this._sequencer.addImport(onImported); - this._importer.push(evaldImportNode.getPath(), tryAppendLessExtension, evaldImportNode.currentFileInfo, + this._importer.push(evaldImportNode.getPath(), tryAppendLessExtension, evaldImportNode.fileInfo(), evaldImportNode.options, sequencedOnImported); } else { this.importCount--; @@ -9442,14 +10336,14 @@ ImportVisitor.prototype = { onImported: function (importNode, context, e, root, importedAtRoot, fullPath) { if (e) { if (!e.filename) { - e.index = importNode.index; e.filename = importNode.currentFileInfo.filename; + e.index = importNode.getIndex(); e.filename = importNode.fileInfo().filename; } this.error = e; } var importVisitor = this, inlineCSS = importNode.options.inline, - isPlugin = importNode.options.plugin, + isPlugin = importNode.options.isPlugin, isOptional = importNode.options.optional, duplicateImport = importedAtRoot || fullPath in importVisitor.recursionDetector; @@ -9495,22 +10389,22 @@ ImportVisitor.prototype = { importVisitor._sequencer.tryRun(); } }, - visitRule: function (ruleNode, visitArgs) { - if (ruleNode.value.type === "DetachedRuleset") { - this.context.frames.unshift(ruleNode); + visitDeclaration: function (declNode, visitArgs) { + if (declNode.value.type === "DetachedRuleset") { + this.context.frames.unshift(declNode); } else { visitArgs.visitDeeper = false; } }, - visitRuleOut : function(ruleNode) { - if (ruleNode.value.type === "DetachedRuleset") { + visitDeclarationOut: function(declNode) { + if (declNode.value.type === "DetachedRuleset") { this.context.frames.shift(); } }, - visitDirective: function (directiveNode, visitArgs) { - this.context.frames.unshift(directiveNode); + visitAtRule: function (atRuleNode, visitArgs) { + this.context.frames.unshift(atRuleNode); }, - visitDirectiveOut: function (directiveNode) { + visitAtRuleOut: function (atRuleNode) { this.context.frames.shift(); }, visitMixinDefinition: function (mixinDefinitionNode, visitArgs) { @@ -9534,7 +10428,7 @@ ImportVisitor.prototype = { }; module.exports = ImportVisitor; -},{"../contexts":11,"./import-sequencer":85,"./visitor":91}],87:[function(require,module,exports){ +},{"../contexts":12,"../utils":86,"./import-sequencer":88,"./visitor":94}],90:[function(require,module,exports){ var visitors = { Visitor: require("./visitor"), ImportVisitor: require('./import-visitor'), @@ -9546,7 +10440,7 @@ var visitors = { module.exports = visitors; -},{"./extend-visitor":84,"./import-visitor":86,"./join-selector-visitor":88,"./set-tree-visibility-visitor":89,"./to-css-visitor":90,"./visitor":91}],88:[function(require,module,exports){ +},{"./extend-visitor":87,"./import-visitor":89,"./join-selector-visitor":91,"./set-tree-visibility-visitor":92,"./to-css-visitor":93,"./visitor":94}],91:[function(require,module,exports){ var Visitor = require("./visitor"); var JoinSelectorVisitor = function() { @@ -9558,7 +10452,7 @@ JoinSelectorVisitor.prototype = { run: function (root) { return this._visitor.visit(root); }, - visitRule: function (ruleNode, visitArgs) { + visitDeclaration: function (declNode, visitArgs) { visitArgs.visitDeeper = false; }, visitMixinDefinition: function (mixinDefinitionNode, visitArgs) { @@ -9571,7 +10465,7 @@ JoinSelectorVisitor.prototype = { this.contexts.push(paths); - if (! rulesetNode.root) { + if (!rulesetNode.root) { selectors = rulesetNode.selectors; if (selectors) { selectors = selectors.filter(function(selector) { return selector.getIsOutput(); }); @@ -9589,17 +10483,17 @@ JoinSelectorVisitor.prototype = { var context = this.contexts[this.contexts.length - 1]; mediaNode.rules[0].root = (context.length === 0 || context[0].multiMedia); }, - visitDirective: function (directiveNode, visitArgs) { + visitAtRule: function (atRuleNode, visitArgs) { var context = this.contexts[this.contexts.length - 1]; - if (directiveNode.rules && directiveNode.rules.length) { - directiveNode.rules[0].root = (directiveNode.isRooted || context.length === 0 || null); + if (atRuleNode.rules && atRuleNode.rules.length) { + atRuleNode.rules[0].root = (atRuleNode.isRooted || context.length === 0 || null); } } }; module.exports = JoinSelectorVisitor; -},{"./visitor":91}],89:[function(require,module,exports){ +},{"./visitor":94}],92:[function(require,module,exports){ var SetTreeVisibilityVisitor = function(visible) { this.visible = visible; }; @@ -9638,7 +10532,7 @@ SetTreeVisibilityVisitor.prototype.visit = function(node) { return node; }; module.exports = SetTreeVisibilityVisitor; -},{}],90:[function(require,module,exports){ +},{}],93:[function(require,module,exports){ var tree = require("../tree"), Visitor = require("./visitor"); @@ -9650,14 +10544,14 @@ var CSSVisitorUtils = function(context) { CSSVisitorUtils.prototype = { containsSilentNonBlockedChild: function(bodyRules) { var rule; - if (bodyRules == null) { + if (!bodyRules) { return false; } for (var r = 0; r < bodyRules.length; r++) { rule = bodyRules[r]; if (rule.isSilent && rule.isSilent(this._context) && !rule.blocksVisibility()) { - //the directive contains something that was referenced (likely by extend) - //therefore it needs to be shown in output too + // the atrule contains something that was referenced (likely by extend) + // therefore it needs to be shown in output too return true; } } @@ -9665,28 +10559,21 @@ CSSVisitorUtils.prototype = { }, keepOnlyVisibleChilds: function(owner) { - if (owner == null || owner.rules == null) { - return ; - } - - owner.rules = owner.rules.filter(function(thing) { + if (owner && owner.rules) { + owner.rules = owner.rules.filter(function(thing) { return thing.isVisible(); - } - ); + }); + } }, isEmpty: function(owner) { - if (owner == null || owner.rules == null) { - return true; - } - return owner.rules.length === 0; + return (owner && owner.rules) + ? (owner.rules.length === 0) : true; }, hasVisibleSelector: function(rulesetNode) { - if (rulesetNode == null || rulesetNode.paths == null) { - return false; - } - return rulesetNode.paths.length > 0; + return (rulesetNode && rulesetNode.paths) + ? (rulesetNode.paths.length > 0) : false; }, resolveVisibility: function (node, originalRules) { @@ -9741,11 +10628,11 @@ ToCSSVisitor.prototype = { return this._visitor.visit(root); }, - visitRule: function (ruleNode, visitArgs) { - if (ruleNode.blocksVisibility() || ruleNode.variable) { + visitDeclaration: function (declNode, visitArgs) { + if (declNode.blocksVisibility() || declNode.variable) { return; } - return ruleNode; + return declNode; }, visitMixinDefinition: function (mixinNode, visitArgs) { @@ -9779,56 +10666,63 @@ ToCSSVisitor.prototype = { return importNode; }, - visitDirective: function(directiveNode, visitArgs) { - if (directiveNode.rules && directiveNode.rules.length) { - return this.visitDirectiveWithBody(directiveNode, visitArgs); + visitAtRule: function(atRuleNode, visitArgs) { + if (atRuleNode.rules && atRuleNode.rules.length) { + return this.visitAtRuleWithBody(atRuleNode, visitArgs); } else { - return this.visitDirectiveWithoutBody(directiveNode, visitArgs); + return this.visitAtRuleWithoutBody(atRuleNode, visitArgs); + } + }, + + visitAnonymous: function(anonymousNode, visitArgs) { + if (!anonymousNode.blocksVisibility()) { + anonymousNode.accept(this._visitor); + return anonymousNode; } }, - visitDirectiveWithBody: function(directiveNode, visitArgs) { - //if there is only one nested ruleset and that one has no path, then it is - //just fake ruleset - function hasFakeRuleset(directiveNode) { - var bodyRules = directiveNode.rules; + visitAtRuleWithBody: function(atRuleNode, visitArgs) { + // if there is only one nested ruleset and that one has no path, then it is + // just fake ruleset + function hasFakeRuleset(atRuleNode) { + var bodyRules = atRuleNode.rules; return bodyRules.length === 1 && (!bodyRules[0].paths || bodyRules[0].paths.length === 0); } - function getBodyRules(directiveNode) { - var nodeRules = directiveNode.rules; - if (hasFakeRuleset(directiveNode)) { + function getBodyRules(atRuleNode) { + var nodeRules = atRuleNode.rules; + if (hasFakeRuleset(atRuleNode)) { return nodeRules[0].rules; } return nodeRules; } - //it is still true that it is only one ruleset in array - //this is last such moment - //process childs - var originalRules = getBodyRules(directiveNode); - directiveNode.accept(this._visitor); + // it is still true that it is only one ruleset in array + // this is last such moment + // process childs + var originalRules = getBodyRules(atRuleNode); + atRuleNode.accept(this._visitor); visitArgs.visitDeeper = false; - if (!this.utils.isEmpty(directiveNode)) { - this._mergeRules(directiveNode.rules[0].rules); + if (!this.utils.isEmpty(atRuleNode)) { + this._mergeRules(atRuleNode.rules[0].rules); } - return this.utils.resolveVisibility(directiveNode, originalRules); + return this.utils.resolveVisibility(atRuleNode, originalRules); }, - visitDirectiveWithoutBody: function(directiveNode, visitArgs) { - if (directiveNode.blocksVisibility()) { + visitAtRuleWithoutBody: function(atRuleNode, visitArgs) { + if (atRuleNode.blocksVisibility()) { return; } - if (directiveNode.name === "@charset") { + if (atRuleNode.name === "@charset") { // Only output the debug info together with subsequent @charset definitions - // a comment (or @media statement) before the actual @charset directive would + // a comment (or @media statement) before the actual @charset atrule would // be considered illegal css as it has to be on the first line if (this.charset) { - if (directiveNode.debugInfo) { - var comment = new tree.Comment("/* " + directiveNode.toCSS(this._context).replace(/\n/g, "") + " */\n"); - comment.debugInfo = directiveNode.debugInfo; + if (atRuleNode.debugInfo) { + var comment = new tree.Comment("/* " + atRuleNode.toCSS(this._context).replace(/\n/g, "") + " */\n"); + comment.debugInfo = atRuleNode.debugInfo; return this._visitor.visit(comment); } return; @@ -9836,7 +10730,7 @@ ToCSSVisitor.prototype = { this.charset = true; } - return directiveNode; + return atRuleNode; }, checkValidNodes: function(rules, isRoot) { @@ -9846,29 +10740,29 @@ ToCSSVisitor.prototype = { for (var i = 0; i < rules.length; i++) { var ruleNode = rules[i]; - if (isRoot && ruleNode instanceof tree.Rule && !ruleNode.variable) { + if (isRoot && ruleNode instanceof tree.Declaration && !ruleNode.variable) { throw { message: "Properties must be inside selector blocks. They cannot be in the root", - index: ruleNode.index, filename: ruleNode.currentFileInfo && ruleNode.currentFileInfo.filename}; + index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename}; } if (ruleNode instanceof tree.Call) { throw { message: "Function '" + ruleNode.name + "' is undefined", - index: ruleNode.index, filename: ruleNode.currentFileInfo && ruleNode.currentFileInfo.filename}; + index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename}; } if (ruleNode.type && !ruleNode.allowRoot) { throw { message: ruleNode.type + " node returned by a function is not valid here", - index: ruleNode.index, filename: ruleNode.currentFileInfo && ruleNode.currentFileInfo.filename}; + index: ruleNode.getIndex(), filename: ruleNode.fileInfo() && ruleNode.fileInfo().filename}; } } }, visitRuleset: function (rulesetNode, visitArgs) { - //at this point rulesets are nested into each other + // at this point rulesets are nested into each other var rule, rulesets = []; this.checkValidNodes(rulesetNode.rules, rulesetNode.firstRoot); - if (! rulesetNode.root) { - //remove invisible paths + if (!rulesetNode.root) { + // remove invisible paths this._compileRulesetPaths(rulesetNode); // remove rulesets from this ruleset body and compile them separately @@ -9894,7 +10788,7 @@ ToCSSVisitor.prototype = { } visitArgs.visitDeeper = false; - } else { //if (! rulesetNode.root) { + } else { // if (! rulesetNode.root) { rulesetNode.accept(this._visitor); visitArgs.visitDeeper = false; } @@ -9904,7 +10798,7 @@ ToCSSVisitor.prototype = { this._removeDuplicateRules(rulesetNode.rules); } - //now decide whether we keep the ruleset + // now decide whether we keep the ruleset if (this.utils.isVisibleRuleset(rulesetNode)) { rulesetNode.ensureVisibility(); rulesets.splice(0, 0, rulesetNode); @@ -9943,12 +10837,12 @@ ToCSSVisitor.prototype = { for (i = rules.length - 1; i >= 0 ; i--) { rule = rules[i]; - if (rule instanceof tree.Rule) { + if (rule instanceof tree.Declaration) { if (!ruleCache[rule.name]) { ruleCache[rule.name] = rule; } else { ruleList = ruleCache[rule.name]; - if (ruleList instanceof tree.Rule) { + if (ruleList instanceof tree.Declaration) { ruleList = ruleCache[rule.name] = [ruleCache[rule.name].toCSS(this._context)]; } var ruleCSS = rule.toCSS(this._context); @@ -9962,78 +10856,45 @@ ToCSSVisitor.prototype = { } }, - _mergeRules: function (rules) { - if (!rules) { return; } - - var groups = {}, - parts, - rule, - key; + _mergeRules: function(rules) { + if (!rules) { + return; + } + var groups = {}, + groupsArr = []; + for (var i = 0; i < rules.length; i++) { - rule = rules[i]; - - if ((rule instanceof tree.Rule) && rule.merge) { - key = [rule.name, - rule.important ? "!" : ""].join(","); - - if (!groups[key]) { - groups[key] = []; - } else { - rules.splice(i--, 1); - } - + var rule = rules[i]; + if (rule.merge) { + var key = rule.name; + groups[key] ? rules.splice(i--, 1) : + groupsArr.push(groups[key] = []); groups[key].push(rule); } } - Object.keys(groups).map(function (k) { - - function toExpression(values) { - return new (tree.Expression)(values.map(function (p) { - return p.value; - })); - } - - function toValue(values) { - return new (tree.Value)(values.map(function (p) { - return p; - })); - } - - parts = groups[k]; - - if (parts.length > 1) { - rule = parts[0]; - var spacedGroups = []; - var lastSpacedGroup = []; - parts.map(function (p) { - if (p.merge === "+") { - if (lastSpacedGroup.length > 0) { - spacedGroups.push(toExpression(lastSpacedGroup)); - } - lastSpacedGroup = []; + groupsArr.forEach(function(group) { + if (group.length > 0) { + var result = group[0], + space = [], + comma = [new tree.Expression(space)]; + group.forEach(function(rule) { + if ((rule.merge === '+') && (space.length > 0)) { + comma.push(new tree.Expression(space = [])); } - lastSpacedGroup.push(p); + space.push(rule.value); + result.important = result.important || rule.important; }); - spacedGroups.push(toExpression(lastSpacedGroup)); - rule.value = toValue(spacedGroups); + result.value = new tree.Value(comma); } }); - }, - - visitAnonymous: function(anonymousNode, visitArgs) { - if (anonymousNode.blocksVisibility()) { - return ; - } - anonymousNode.accept(this._visitor); - return anonymousNode; } }; module.exports = ToCSSVisitor; -},{"../tree":62,"./visitor":91}],91:[function(require,module,exports){ +},{"../tree":65,"./visitor":94}],94:[function(require,module,exports){ var tree = require("../tree"); var _visitArgs = { visitDeeper: true }, @@ -10046,21 +10907,21 @@ function _noop(node) { function indexNodeTypes(parent, ticker) { // add .typeIndex to tree node types for lookup table var key, child; - for (key in parent) { - if (parent.hasOwnProperty(key)) { - child = parent[key]; - switch (typeof child) { - case "function": - // ignore bound functions directly on tree which do not have a prototype - // or aren't nodes - if (child.prototype && child.prototype.type) { - child.prototype.typeIndex = ticker++; - } - break; - case "object": - ticker = indexNodeTypes(child, ticker); - break; - } + for (key in parent) { + /* eslint guard-for-in: 0 */ + child = parent[key]; + switch (typeof child) { + case "function": + // ignore bound functions directly on tree which do not have a prototype + // or aren't nodes + if (child.prototype && child.prototype.type) { + child.prototype.typeIndex = ticker++; + } + break; + case "object": + ticker = indexNodeTypes(child, ticker); + break; + } } return ticker; @@ -10187,7 +11048,7 @@ Visitor.prototype = { }; module.exports = Visitor; -},{"../tree":62}],92:[function(require,module,exports){ +},{"../tree":65}],95:[function(require,module,exports){ "use strict"; // rawAsap provides everything we need except exception management. @@ -10255,7 +11116,7 @@ RawTask.prototype.call = function () { } }; -},{"./raw":93}],93:[function(require,module,exports){ +},{"./raw":96}],96:[function(require,module,exports){ (function (global){ "use strict"; @@ -10482,7 +11343,7 @@ rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer; // https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],94:[function(require,module,exports){ +},{}],97:[function(require,module,exports){ 'use strict'; var asap = require('asap/raw'); @@ -10697,7 +11558,7 @@ function doResolve(fn, promise) { } } -},{"asap/raw":93}],95:[function(require,module,exports){ +},{"asap/raw":96}],98:[function(require,module,exports){ 'use strict'; //This file contains the ES6 extensions to the core Promises/A+ API @@ -10806,7 +11667,7 @@ Promise.prototype['catch'] = function (onRejected) { return this.then(null, onRejected); }; -},{"./core.js":94}],96:[function(require,module,exports){ +},{"./core.js":97}],99:[function(require,module,exports){ // should work in any browser without browserify if (typeof Promise.prototype.done !== 'function') { @@ -10819,7 +11680,7 @@ if (typeof Promise.prototype.done !== 'function') { }) } } -},{}],97:[function(require,module,exports){ +},{}],100:[function(require,module,exports){ // not "use strict" so we can declare global "Promise" var asap = require('asap'); @@ -10831,5 +11692,5 @@ if (typeof Promise === 'undefined') { require('./polyfill-done.js'); -},{"./lib/core.js":94,"./lib/es6-extensions.js":95,"./polyfill-done.js":96,"asap":92}]},{},[2])(2) +},{"./lib/core.js":97,"./lib/es6-extensions.js":98,"./polyfill-done.js":99,"asap":95}]},{},[2])(2) }); \ No newline at end of file diff --git a/dist/less.min.js b/dist/less.min.js index 0f9143ac8..90aa4b646 100644 --- a/dist/less.min.js +++ b/dist/less.min.js @@ -1,8 +1,8 @@ /*! - * Less - Leaner CSS v2.7.3 + * Less - Leaner CSS v3.0.0 * http://lesscss.org * - * Copyright (c) 2009-2017, Alexis Sellier + * Copyright (c) 2009-2018, Alexis Sellier * Licensed under the Apache-2.0 License. * */ @@ -10,8 +10,8 @@ /** * @license Apache-2.0 */ -!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.less=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g0||b.isFileProtocol?"development":"production");var c=/!dumpLineNumbers:(comments|mediaquery|all)/.exec(a.location.hash);c&&(b.dumpLineNumbers=c[1]),void 0===b.useFileCache&&(b.useFileCache=!0),void 0===b.onReady&&(b.onReady=!0)}},{"./browser":3,"./utils":10}],2:[function(a,b,c){function d(a){a.filename&&console.warn(a),e.async||h.removeChild(i)}a("promise/polyfill.js");var e=window.less||{};a("./add-default-options")(window,e);var f=b.exports=a("./index")(window,e);window.less=f;var g,h,i;e.onReady&&(/!watch/.test(window.location.hash)&&f.watch(),e.async||(g="body { display: none !important }",h=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style"),i.type="text/css",i.styleSheet?i.styleSheet.cssText=g:i.appendChild(document.createTextNode(g)),h.appendChild(i)),f.registerStylesheetsImmediately(),f.pageLoadFinished=f.refresh("development"===f.env).then(d,d))},{"./add-default-options":1,"./index":8,"promise/polyfill.js":97}],3:[function(a,b,c){var d=a("./utils");b.exports={createCSS:function(a,b,c){var e=c.href||"",f="less:"+(c.title||d.extractId(e)),g=a.getElementById(f),h=!1,i=a.createElement("style");i.setAttribute("type","text/css"),c.media&&i.setAttribute("media",c.media),i.id=f,i.styleSheet||(i.appendChild(a.createTextNode(b)),h=null!==g&&g.childNodes.length>0&&i.childNodes.length>0&&g.firstChild.nodeValue===i.firstChild.nodeValue);var j=a.getElementsByTagName("head")[0];if(null===g||h===!1){var k=c&&c.nextSibling||null;k?k.parentNode.insertBefore(i,k):j.appendChild(i)}if(g&&h===!1&&g.parentNode.removeChild(g),i.styleSheet)try{i.styleSheet.cssText=b}catch(l){throw new Error("Couldn't reassign styleSheet.cssText.")}},currentScript:function(a){var b=a.document;return b.currentScript||function(){var a=b.getElementsByTagName("script");return a[a.length-1]}()}}},{"./utils":10}],4:[function(a,b,c){b.exports=function(a,b,c){var d=null;if("development"!==b.env)try{d="undefined"==typeof a.localStorage?null:a.localStorage}catch(e){}return{setCSS:function(a,b,e,f){if(d){c.info("saving "+a+" to cache.");try{d.setItem(a,f),d.setItem(a+":timestamp",b),e&&d.setItem(a+":vars",JSON.stringify(e))}catch(g){c.error('failed to save "'+a+'" to local storage for caching.')}}},getCSS:function(a,b,c){var e=d&&d.getItem(a),f=d&&d.getItem(a+":timestamp"),g=d&&d.getItem(a+":vars");if(c=c||{},f&&b.lastModified&&new Date(b.lastModified).valueOf()===new Date(f).valueOf()&&(!c&&!g||JSON.stringify(c)===g))return e}}}},{}],5:[function(a,b,c){var d=a("./utils"),e=a("./browser");b.exports=function(a,b,c){function f(b,f){var g,h,i="less-error-message:"+d.extractId(f||""),j='
  • {content}
  • ',k=a.document.createElement("div"),l=[],m=b.filename||f,n=m.match(/([^\/]+(\?.*)?)$/)[1];k.id=i,k.className="less-error-message",h="

    "+(b.type||"Syntax")+"Error: "+(b.message||"There is an error in your .less file")+'

    in '+n+" ";var o=function(a,b,c){void 0!==a.extract[b]&&l.push(j.replace(/\{line\}/,(parseInt(a.line,10)||0)+(b-1)).replace(/\{class\}/,c).replace(/\{content\}/,a.extract[b]))};b.extract&&(o(b,0,""),o(b,1,"line"),o(b,2,""),h+="on line "+b.line+", column "+(b.column+1)+":

    "),b.stack&&(b.extract||c.logLevel>=4)&&(h+="
    Stack Trace
    "+b.stack.split("\n").slice(1).join("
    ")),k.innerHTML=h,e.createCSS(a.document,[".less-error-message ul, .less-error-message li {","list-style-type: none;","margin-right: 15px;","padding: 4px 0;","margin: 0;","}",".less-error-message label {","font-size: 12px;","margin-right: 15px;","padding: 4px 0;","color: #cc7777;","}",".less-error-message pre {","color: #dd6666;","padding: 4px 0;","margin: 0;","display: inline-block;","}",".less-error-message pre.line {","color: #ff0000;","}",".less-error-message h3 {","font-size: 20px;","font-weight: bold;","padding: 15px 0 5px 0;","margin: 0;","}",".less-error-message a {","color: #10a","}",".less-error-message .error {","color: red;","font-weight: bold;","padding-bottom: 2px;","border-bottom: 1px dashed red;","}"].join("\n"),{title:"error-message"}),k.style.cssText=["font-family: Arial, sans-serif","border: 1px solid #e00","background-color: #eee","border-radius: 5px","-webkit-border-radius: 5px","-moz-border-radius: 5px","color: #e00","padding: 15px","margin-bottom: 15px"].join(";"),"development"===c.env&&(g=setInterval(function(){var b=a.document,c=b.body;c&&(b.getElementById(i)?c.replaceChild(k,b.getElementById(i)):c.insertBefore(k,c.firstChild),clearInterval(g))},10))}function g(b){var c=a.document.getElementById("less-error-message:"+d.extractId(b));c&&c.parentNode.removeChild(c)}function h(a){}function i(a){c.errorReporting&&"html"!==c.errorReporting?"console"===c.errorReporting?h(a):"function"==typeof c.errorReporting&&c.errorReporting("remove",a):g(a)}function j(a,d){var e="{line} {content}",f=a.filename||d,g=[],h=(a.type||"Syntax")+"Error: "+(a.message||"There is an error in your .less file")+" in "+f+" ",i=function(a,b,c){void 0!==a.extract[b]&&g.push(e.replace(/\{line\}/,(parseInt(a.line,10)||0)+(b-1)).replace(/\{class\}/,c).replace(/\{content\}/,a.extract[b]))};a.extract&&(i(a,0,""),i(a,1,"line"),i(a,2,""),h+="on line "+a.line+", column "+(a.column+1)+":\n"+g.join("\n")),a.stack&&(a.extract||c.logLevel>=4)&&(h+="\nStack Trace\n"+a.stack),b.logger.error(h)}function k(a,b){c.errorReporting&&"html"!==c.errorReporting?"console"===c.errorReporting?j(a,b):"function"==typeof c.errorReporting&&c.errorReporting("add",a,b):f(a,b)}return{add:k,remove:i}}},{"./browser":3,"./utils":10}],6:[function(a,b,c){b.exports=function(b,c){function d(){if(window.XMLHttpRequest&&!("file:"===window.location.protocol&&"ActiveXObject"in window))return new XMLHttpRequest;try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(a){return c.error("browser doesn't support AJAX."),null}}var e=a("../less/environment/abstract-file-manager.js"),f={},g=function(){};return g.prototype=new e,g.prototype.alwaysMakePathsAbsolute=function(){return!0},g.prototype.join=function(a,b){return a?this.extractUrlParts(b,a).path:b},g.prototype.doXHR=function(a,e,f,g){function h(b,c,d){b.status>=200&&b.status<300?c(b.responseText,b.getResponseHeader("Last-Modified")):"function"==typeof d&&d(b.status,a)}var i=d(),j=!b.isFileProtocol||b.fileAsync;"function"==typeof i.overrideMimeType&&i.overrideMimeType("text/css"),c.debug("XHR: Getting '"+a+"'"),i.open("GET",a,j),i.setRequestHeader("Accept",e||"text/x-less, text/css; q=0.9, */*; q=0.5"),i.send(null),b.isFileProtocol&&!b.fileAsync?0===i.status||i.status>=200&&i.status<300?f(i.responseText):g(i.status,a):j?i.onreadystatechange=function(){4==i.readyState&&h(i,f,g)}:h(i,f,g)},g.prototype.supports=function(a,b,c,d){return!0},g.prototype.clearFileCache=function(){f={}},g.prototype.loadFile=function(a,b,c,d,e){b&&!this.isPathAbsolute(a)&&(a=b+a),c=c||{};var g=this.extractUrlParts(a,window.location.href),h=g.url;if(c.useFileCache&&f[h])try{var i=f[h];e(null,{contents:i,filename:h,webInfo:{lastModified:new Date}})}catch(j){e({filename:h,message:"Error loading file "+h+" error was "+j.message})}else this.doXHR(h,c.mime,function(a,b){f[h]=a,e(null,{contents:a,filename:h,webInfo:{lastModified:b}})},function(a,b){e({type:"File",message:"'"+b+"' wasn't found ("+a+")",href:h})})},g}},{"../less/environment/abstract-file-manager.js":15}],7:[function(a,b,c){b.exports=function(){function b(){throw{type:"Runtime",message:"Image size functions are not supported in browser version of less"}}var c=a("./../less/functions/function-registry"),d={"image-size":function(a){return b(this,a),-1},"image-width":function(a){return b(this,a),-1},"image-height":function(a){return b(this,a),-1}};c.addMultiple(d)}},{"./../less/functions/function-registry":22}],8:[function(a,b,c){var d=a("./utils").addDataAttr,e=a("./browser");b.exports=function(b,c){function f(a){return c.postProcessor&&"function"==typeof c.postProcessor&&(a=c.postProcessor.call(a,a)||a),a}function g(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function h(a,b){var c=Array.prototype.slice.call(arguments,2);return function(){var d=c.concat(Array.prototype.slice.call(arguments,0));return a.apply(b,d)}}function i(a){for(var b,d=m.getElementsByTagName("style"),e=0;e=c&&console.log(a)},info:function(a){b.logLevel>=d&&console.log(a)},warn:function(a){b.logLevel>=e&&console.warn(a)},error:function(a){b.logLevel>=f&&console.error(a)}}]);for(var g=0;g0&&(a=a.slice(0,b)),b=a.lastIndexOf("/"),b<0&&(b=a.lastIndexOf("\\")),b<0?"":a.slice(0,b+1)},d.prototype.tryAppendExtension=function(a,b){return/(\.[a-z]*$)|([\?;].*)$/.test(a)?a:a+b},d.prototype.tryAppendLessExtension=function(a){return this.tryAppendExtension(a,".less")},d.prototype.supportsSync=function(){return!1},d.prototype.alwaysMakePathsAbsolute=function(){return!1},d.prototype.isPathAbsolute=function(a){return/^(?:[a-z-]+:|\/|\\|#)/i.test(a)},d.prototype.join=function(a,b){return a?a+b:b},d.prototype.pathDiff=function(a,b){var c,d,e,f,g=this.extractUrlParts(a),h=this.extractUrlParts(b),i="";if(g.hostPart!==h.hostPart)return"";for(d=Math.max(h.directories.length,g.directories.length),c=0;c0&&(h.splice(c-1,2),c-=2)}return g.hostPart=f[1],g.directories=h,g.path=(f[1]||"")+h.join("/"),g.fileUrl=g.path+(f[4]||""),g.url=g.fileUrl+(f[5]||""),g},b.exports=d},{}],16:[function(a,b,c){var d=a("../logger"),e=function(a,b){this.fileManagers=b||[],a=a||{};for(var c=["encodeBase64","mimeLookup","charsetLookup","getSourceMapGenerator"],d=[],e=d.concat(c),f=0;f=0;h--){var i=g[h];if(i[f?"supportsSync":"supports"](a,b,c,e))return i}return null},e.prototype.addFileManager=function(a){this.fileManagers.push(a)},e.prototype.clearFileManagers=function(){this.fileManagers=[]},b.exports=e},{"../logger":33}],17:[function(a,b,c){function d(a,b,c){var d,f,g,h,i=b.alpha,j=c.alpha,k=[];g=j+i*(1-j);for(var l=0;l<3;l++)d=b.rgb[l]/255,f=c.rgb[l]/255,h=a(d,f),g&&(h=(j*f+i*(d-j*(d+f-h)))/g),k[l]=255*h;return new e(k,g)}var e=a("../tree/color"),f=a("./function-registry"),g={multiply:function(a,b){return a*b},screen:function(a,b){return a+b-a*b},overlay:function(a,b){return a*=2,a<=1?g.multiply(a,b):g.screen(a-1,b)},softlight:function(a,b){var c=1,d=a;return b>.5&&(d=1,c=a>.25?Math.sqrt(a):((16*a-12)*a+4)*a),a-(1-2*b)*d*(c-a)},hardlight:function(a,b){return g.overlay(b,a)},difference:function(a,b){return Math.abs(a-b)},exclusion:function(a,b){return a+b-2*a*b},average:function(a,b){return(a+b)/2},negation:function(a,b){return 1-Math.abs(a+b-1)}};for(var h in g)g.hasOwnProperty(h)&&(d[h]=d.bind(null,g[h]));f.addMultiple(d)},{"../tree/color":50,"./function-registry":22}],18:[function(a,b,c){function d(a){return Math.min(1,Math.max(0,a))}function e(a){return h.hsla(a.h,a.s,a.l,a.a)}function f(a){if(a instanceof i)return parseFloat(a.unit.is("%")?a.value/100:a.value);if("number"==typeof a)return a;throw{type:"Argument",message:"color functions take numbers as parameters"}}function g(a,b){return a instanceof i&&a.unit.is("%")?parseFloat(a.value*b/100):f(a)}var h,i=a("../tree/dimension"),j=a("../tree/color"),k=a("../tree/quoted"),l=a("../tree/anonymous"),m=a("./function-registry");h={rgb:function(a,b,c){return h.rgba(a,b,c,1)},rgba:function(a,b,c,d){var e=[a,b,c].map(function(a){return g(a,255)});return d=f(d),new j(e,d)},hsl:function(a,b,c){return h.hsla(a,b,c,1)},hsla:function(a,b,c,e){function g(a){return a=a<0?a+1:a>1?a-1:a,6*a<1?i+(j-i)*a*6:2*a<1?j:3*a<2?i+(j-i)*(2/3-a)*6:i}var i,j;return a=f(a)%360/360,b=d(f(b)),c=d(f(c)),e=d(f(e)),j=c<=.5?c*(b+1):c+b-c*b,i=2*c-j,h.rgba(255*g(a+1/3),255*g(a),255*g(a-1/3),e)},hsv:function(a,b,c){return h.hsva(a,b,c,1)},hsva:function(a,b,c,d){a=f(a)%360/360*360,b=f(b),c=f(c),d=f(d);var e,g;e=Math.floor(a/60%6),g=a/60-e;var i=[c,c*(1-b),c*(1-g*b),c*(1-(1-g)*b)],j=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]];return h.rgba(255*i[j[e][0]],255*i[j[e][1]],255*i[j[e][2]],d)},hue:function(a){return new i(a.toHSL().h)},saturation:function(a){return new i(100*a.toHSL().s,"%")},lightness:function(a){return new i(100*a.toHSL().l,"%")},hsvhue:function(a){return new i(a.toHSV().h)},hsvsaturation:function(a){return new i(100*a.toHSV().s,"%")},hsvvalue:function(a){return new i(100*a.toHSV().v,"%")},red:function(a){return new i(a.rgb[0])},green:function(a){return new i(a.rgb[1])},blue:function(a){return new i(a.rgb[2])},alpha:function(a){return new i(a.toHSL().a)},luma:function(a){return new i(a.luma()*a.alpha*100,"%")},luminance:function(a){var b=.2126*a.rgb[0]/255+.7152*a.rgb[1]/255+.0722*a.rgb[2]/255;return new i(b*a.alpha*100,"%")},saturate:function(a,b,c){if(!a.rgb)return null;var f=a.toHSL();return f.s+="undefined"!=typeof c&&"relative"===c.value?f.s*b.value/100:b.value/100,f.s=d(f.s),e(f)},desaturate:function(a,b,c){var f=a.toHSL();return f.s-="undefined"!=typeof c&&"relative"===c.value?f.s*b.value/100:b.value/100,f.s=d(f.s),e(f)},lighten:function(a,b,c){var f=a.toHSL();return f.l+="undefined"!=typeof c&&"relative"===c.value?f.l*b.value/100:b.value/100,f.l=d(f.l),e(f)},darken:function(a,b,c){var f=a.toHSL();return f.l-="undefined"!=typeof c&&"relative"===c.value?f.l*b.value/100:b.value/100,f.l=d(f.l),e(f)},fadein:function(a,b,c){var f=a.toHSL();return f.a+="undefined"!=typeof c&&"relative"===c.value?f.a*b.value/100:b.value/100,f.a=d(f.a),e(f)},fadeout:function(a,b,c){var f=a.toHSL();return f.a-="undefined"!=typeof c&&"relative"===c.value?f.a*b.value/100:b.value/100,f.a=d(f.a),e(f)},fade:function(a,b){var c=a.toHSL();return c.a=b.value/100,c.a=d(c.a),e(c)},spin:function(a,b){var c=a.toHSL(),d=(c.h+b.value)%360;return c.h=d<0?360+d:d,e(c)},mix:function(a,b,c){a.toHSL&&b.toHSL||(console.log(b.type),console.dir(b)),c||(c=new i(50));var d=c.value/100,e=2*d-1,f=a.toHSL().a-b.toHSL().a,g=((e*f==-1?e:(e+f)/(1+e*f))+1)/2,h=1-g,k=[a.rgb[0]*g+b.rgb[0]*h,a.rgb[1]*g+b.rgb[1]*h,a.rgb[2]*g+b.rgb[2]*h],l=a.alpha*d+b.alpha*(1-d);return new j(k,l)},greyscale:function(a){return h.desaturate(a,new i(100))},contrast:function(a,b,c,d){if(!a.rgb)return null;if("undefined"==typeof c&&(c=h.rgba(255,255,255,1)),"undefined"==typeof b&&(b=h.rgba(0,0,0,1)),b.luma()>c.luma()){var e=c;c=b,b=e}return d="undefined"==typeof d?.43:f(d),a.luma()=t&&this.context.ieCompat!==!1?(g.warn("Skipped data-uri embedding of "+i+" because its size ("+s.length+" characters) exceeds IE8-safe "+t+" characters!"),f(this,e||a)):new d(new c('"'+s+'"',s,(!1),this.index,this.currentFileInfo),this.index,this.currentFileInfo)})}},{"../logger":33,"../tree/quoted":73,"../tree/url":80,"./function-registry":22}],20:[function(a,b,c){var d=a("../tree/keyword"),e=a("./function-registry"),f={eval:function(){var a=this.value_,b=this.error_;if(b)throw b;if(null!=a)return a?d.True:d.False},value:function(a){this.value_=a},error:function(a){this.error_=a},reset:function(){this.value_=this.error_=null}};e.add("default",f.eval.bind(f)),b.exports=f},{"../tree/keyword":65,"./function-registry":22}],21:[function(a,b,c){var d=a("../tree/expression"),e=function(a,b,c,d){this.name=a.toLowerCase(),this.index=c,this.context=b,this.currentFileInfo=d,this.func=b.frames[0].functionRegistry.get(this.name)};e.prototype.isValid=function(){return Boolean(this.func)},e.prototype.call=function(a){return Array.isArray(a)&&(a=a.filter(function(a){return"Comment"!==a.type}).map(function(a){if("Expression"===a.type){var b=a.value.filter(function(a){return"Comment"!==a.type});return 1===b.length?b[0]:new d(b)}return a})),this.func.apply(this,a)},b.exports=e},{"../tree/expression":59}],22:[function(a,b,c){function d(a){return{_data:{},add:function(a,b){a=a.toLowerCase(),this._data.hasOwnProperty(a),this._data[a]=b},addMultiple:function(a){Object.keys(a).forEach(function(b){this.add(b,a[b])}.bind(this))},get:function(b){return this._data[b]||a&&a.get(b)},inherit:function(){return d(this)}}}b.exports=d(null)},{}],23:[function(a,b,c){b.exports=function(b){var c={functionRegistry:a("./function-registry"),functionCaller:a("./function-caller")};return a("./default"),a("./color"),a("./color-blending"),a("./data-uri")(b),a("./math"),a("./number"),a("./string"),a("./svg")(b),a("./types"),c}},{"./color":18,"./color-blending":17,"./data-uri":19,"./default":20,"./function-caller":21,"./function-registry":22,"./math":25,"./number":26,"./string":27,"./svg":28,"./types":29}],24:[function(a,b,c){var d=a("../tree/dimension"),e=function(){};e._math=function(a,b,c){if(!(c instanceof d))throw{type:"Argument",message:"argument must be a number"};return null==b?b=c.unit:c=c.unify(),new d(a(parseFloat(c.value)),b)},b.exports=e},{"../tree/dimension":56}],25:[function(a,b,c){var d=a("./function-registry"),e=a("./math-helper.js"),f={ceil:null,floor:null,sqrt:null,abs:null,tan:"",sin:"",cos:"",atan:"rad",asin:"rad",acos:"rad"};for(var g in f)f.hasOwnProperty(g)&&(f[g]=e._math.bind(null,Math[g],f[g]));f.round=function(a,b){var c="undefined"==typeof b?0:b.value;return e._math(function(a){return a.toFixed(c)},null,a)},d.addMultiple(f)},{"./function-registry":22,"./math-helper.js":24}],26:[function(a,b,c){var d=a("../tree/dimension"),e=a("../tree/anonymous"),f=a("./function-registry"),g=a("./math-helper.js"),h=function(a,b){switch(b=Array.prototype.slice.call(b),b.length){case 0:throw{type:"Argument",message:"one or more arguments required"}}var c,f,g,h,i,j,k,l,m=[],n={};for(c=0;ci.value)&&(m[f]=g);else{if(void 0!==k&&j!==k)throw{type:"Argument",message:"incompatible types"};n[j]=m.length,m.push(g)}else Array.isArray(b[c].value)&&Array.prototype.push.apply(b,Array.prototype.slice.call(b[c].value));return 1==m.length?m[0]:(b=m.map(function(a){return a.toCSS(this.context)}).join(this.context.compress?",":", "),new e((a?"min":"max")+"("+b+")"))};f.addMultiple({min:function(){return h(!0,arguments)},max:function(){return h(!1,arguments)},convert:function(a,b){return a.convertTo(b.value)},pi:function(){return new d(Math.PI)},mod:function(a,b){return new d(a.value%b.value,a.unit)},pow:function(a,b){if("number"==typeof a&&"number"==typeof b)a=new d(a),b=new d(b);else if(!(a instanceof d&&b instanceof d))throw{type:"Argument",message:"arguments must be numbers"};return new d(Math.pow(a.value,b.value),a.unit)},percentage:function(a){var b=g._math(function(a){return 100*a},"%",a);return b}})},{"../tree/anonymous":46,"../tree/dimension":56,"./function-registry":22,"./math-helper.js":24}],27:[function(a,b,c){var d=a("../tree/quoted"),e=a("../tree/anonymous"),f=a("../tree/javascript"),g=a("./function-registry");g.addMultiple({e:function(a){return new e(a instanceof f?a.evaluated:a.value)},escape:function(a){return new e(encodeURI(a.value).replace(/=/g,"%3D").replace(/:/g,"%3A").replace(/#/g,"%23").replace(/;/g,"%3B").replace(/\(/g,"%28").replace(/\)/g,"%29"))},replace:function(a,b,c,e){var f=a.value;return c="Quoted"===c.type?c.value:c.toCSS(),f=f.replace(new RegExp(b.value,e?e.value:""),c),new d(a.quote||"",f,a.escaped)},"%":function(a){for(var b=Array.prototype.slice.call(arguments,1),c=a.value,e=0;e",k=0;k";return j+="',j=encodeURIComponent(j),j="data:image/svg+xml,"+j,new g(new f("'"+j+"'",j,(!1),this.index,this.currentFileInfo),this.index,this.currentFileInfo)})}},{"../tree/color":50,"../tree/dimension":56,"../tree/expression":59,"../tree/quoted":73,"../tree/url":80,"./function-registry":22}],29:[function(a,b,c){var d=a("../tree/keyword"),e=a("../tree/detached-ruleset"),f=a("../tree/dimension"),g=a("../tree/color"),h=a("../tree/quoted"),i=a("../tree/anonymous"),j=a("../tree/url"),k=a("../tree/operation"),l=a("./function-registry"),m=function(a,b){return a instanceof b?d.True:d.False},n=function(a,b){if(void 0===b)throw{type:"Argument",message:"missing the required second argument to isunit."};if(b="string"==typeof b.value?b.value:b,"string"!=typeof b)throw{type:"Argument",message:"Second argument to isunit should be a unit or a string."};return a instanceof f&&a.unit.is(b)?d.True:d.False},o=function(a){var b=Array.isArray(a.value)?a.value:Array(a);return b};l.addMultiple({isruleset:function(a){return m(a,e)},iscolor:function(a){return m(a,g)},isnumber:function(a){return m(a,f)},isstring:function(a){return m(a,h)},iskeyword:function(a){return m(a,d)},isurl:function(a){return m(a,j)},ispixel:function(a){return n(a,"px")},ispercentage:function(a){return n(a,"%")},isem:function(a){return n(a,"em")},isunit:n,unit:function(a,b){if(!(a instanceof f))throw{type:"Argument",message:"the first argument to unit must be a number"+(a instanceof k?". Have you forgotten parenthesis?":"")};return b=b?b instanceof d?b.value:b.toCSS():"",new f(a.value,b)},"get-unit":function(a){return new i(a.unit)},extract:function(a,b){return b=b.value-1,o(a)[b]},length:function(a){return new f(o(a).length)}})},{"../tree/anonymous":46,"../tree/color":50,"../tree/detached-ruleset":55,"../tree/dimension":56,"../tree/keyword":65,"../tree/operation":71,"../tree/quoted":73,"../tree/url":80,"./function-registry":22}],30:[function(a,b,c){var d=a("./contexts"),e=a("./parser/parser"),f=a("./plugins/function-importer");b.exports=function(a){var b=function(a,b){this.rootFilename=b.filename,this.paths=a.paths||[],this.contents={},this.contentsIgnoredChars={},this.mime=a.mime,this.error=null,this.context=a,this.queue=[],this.files={}};return b.prototype.push=function(b,c,g,h,i){var j=this;this.queue.push(b);var k=function(a,c,d){j.queue.splice(j.queue.indexOf(b),1);var e=d===j.rootFilename;h.optional&&a?i(null,{rules:[]},!1,null):(j.files[d]=c,a&&!j.error&&(j.error=a),i(a,c,e,d))},l={relativeUrls:this.context.relativeUrls,entryPath:g.entryPath,rootpath:g.rootpath,rootFilename:g.rootFilename},m=a.getFileManager(b,g.currentDirectory,this.context,a);if(!m)return void k({message:"Could not find a file-manager for "+b});c&&(b=m.tryAppendExtension(b,h.plugin?".js":".less"));var n=function(a){var b=a.filename,c=a.contents.replace(/^\uFEFF/,"");l.currentDirectory=m.getPath(b),l.relativeUrls&&(l.rootpath=m.join(j.context.rootpath||"",m.pathDiff(l.currentDirectory,l.entryPath)),!m.isPathAbsolute(l.rootpath)&&m.alwaysMakePathsAbsolute()&&(l.rootpath=m.join(l.entryPath,l.rootpath))),l.filename=b;var i=new d.Parse(j.context);i.processImports=!1,j.contents[b]=c,(g.reference||h.reference)&&(l.reference=!0),h.plugin?new f(i,l).eval(c,function(a,c){k(a,c,b)}):h.inline?k(null,c,b):new e(i,j,l).parse(c,function(a,c){k(a,c,b)})},o=m.loadFile(b,g.currentDirectory,this.context,a,function(a,b){a?k(a):n(b)});o&&o.then(n,k)},b}},{"./contexts":11,"./parser/parser":38,"./plugins/function-importer":40}],31:[function(a,b,c){b.exports=function(b,c){var d,e,f,g,h,i={version:[2,7,3],data:a("./data"),tree:a("./tree"),Environment:h=a("./environment/environment"),AbstractFileManager:a("./environment/abstract-file-manager"),environment:b=new h(b,c),visitors:a("./visitors"),Parser:a("./parser/parser"),functions:a("./functions")(b),contexts:a("./contexts"),SourceMapOutput:d=a("./source-map-output")(b),SourceMapBuilder:e=a("./source-map-builder")(d,b),ParseTree:f=a("./parse-tree")(e),ImportManager:g=a("./import-manager")(b),render:a("./render")(b,f,g),parse:a("./parse")(b,f,g),LessError:a("./less-error"),transformTree:a("./transform-tree"),utils:a("./utils"),PluginManager:a("./plugin-manager"),logger:a("./logger")};return i}},{"./contexts":11,"./data":13,"./environment/abstract-file-manager":15,"./environment/environment":16,"./functions":23,"./import-manager":30,"./less-error":32,"./logger":33,"./parse":35,"./parse-tree":34,"./parser/parser":38,"./plugin-manager":39,"./render":41,"./source-map-builder":42,"./source-map-output":43,"./transform-tree":44,"./tree":62,"./utils":83,"./visitors":87}],32:[function(a,b,c){var d=a("./utils"),e=b.exports=function(a,b,c){Error.call(this);var e=a.filename||c;if(b&&e){var f=b.contents[e],g=d.getLocation(a.index,f),h=g.line,i=g.column,j=a.call&&d.getLocation(a.call,f).line,k=f.split("\n");this.type=a.type||"Syntax",this.filename=e,this.index=a.index,this.line="number"==typeof h?h+1:null,this.callLine=j+1,this.callExtract=k[j],this.column=i,this.extract=[k[h-1],k[h],k[h+1]]}this.message=a.message,this.stack=a.stack};if("undefined"==typeof Object.create){var f=function(){};f.prototype=Error.prototype,e.prototype=new f}else e.prototype=Object.create(Error.prototype);e.prototype.constructor=e},{"./utils":83}],33:[function(a,b,c){b.exports={error:function(a){this._fireEvent("error",a)},warn:function(a){this._fireEvent("warn",a)},info:function(a){this._fireEvent("info",a)},debug:function(a){this._fireEvent("debug",a)},addListener:function(a){this._listeners.push(a)},removeListener:function(a){for(var b=0;b=97&&j<=122||j<34))switch(j){case 40:o++,e=h;continue;case 41:if(--o<0)return b("missing opening `(`",h);continue;case 59:o||c();continue;case 123:n++,d=h;continue;case 125:if(--n<0)return b("missing opening `{`",h);n||o||c();continue;case 92:if(h96)){if(k==j){l=1;break}if(92==k){if(h==m-1)return b("unescaped `\\`",h);h++}}if(l)continue;return b("unmatched `"+String.fromCharCode(j)+"`",i);case 47:if(o||h==m-1)continue;if(k=a.charCodeAt(h+1),47==k)for(h+=2;hd&&g>f?b("missing closing `}` or `*/`",d):b("missing closing `}`",d):0!==o?b("missing closing `)`",e):(c(!0),p)}},{}],37:[function(a,b,c){var d=a("./chunker");b.exports=function(){function a(d){for(var e,f,j,p=k.i,q=c,s=k.i-i,t=k.i+h.length-s,u=k.i+=d,v=b;k.i=0){j={index:k.i,text:v.substr(k.i,x+2-k.i),isLineComment:!1},k.i+=j.text.length-1,k.commentStore.push(j);continue}}break}if(e!==l&&e!==n&&e!==m&&e!==o)break}if(h=h.slice(d+k.i-u+s),i=k.i,!h.length){if(ce||k.i===e&&a&&!f)&&(e=k.i,f=a);var b=j.pop();h=b.current,i=k.i=b.i,c=b.j},k.forget=function(){j.pop()},k.isWhitespace=function(a){var c=k.i+(a||0),d=b.charCodeAt(c);return d===l||d===o||d===m||d===n},k.$re=function(b){k.i>i&&(h=h.slice(k.i-i),i=k.i);var c=b.exec(h);return c?(a(c[0].length),"string"==typeof c?c:1===c.length?c[0]:c):null},k.$char=function(c){return b.charAt(k.i)!==c?null:(a(1),c)},k.$str=function(c){for(var d=c.length,e=0;es||a=b.length;return k.i=b.length-1,furthestChar:b[k.i]}},k}},{"./chunker":36}],38:[function(a,b,c){var d=a("../less-error"),e=a("../tree"),f=a("../visitors"),g=a("./parser-input"),h=a("../utils"),i=function j(a,b,c){function i(a,e){throw new d({index:o.i,filename:c.filename,type:e||"Syntax",message:a},b)}function k(a,b,c){var d=a instanceof Function?a.call(n):o.$re(a);return d?d:void i(b||("string"==typeof a?"expected '"+a+"' got '"+o.currentChar()+"'":"unexpected token"))}function l(a,b){return o.$char(a)?a:void i(b||"expected '"+a+"' got '"+o.currentChar()+"'")}function m(a){var b=c.filename;return{lineNumber:h.getLocation(a,o.getInput()).line+1,fileName:b}}var n,o=g();return{parse:function(g,h,i){var k,l,m,n,p=null,q="";if(l=i&&i.globalVars?j.serializeVars(i.globalVars)+"\n":"",m=i&&i.modifyVars?"\n"+j.serializeVars(i.modifyVars):"",a.pluginManager)for(var r=a.pluginManager.getPreProcessors(),s=0;s1&&(b=new e.Value(g)),d.push(b),g=[])}return o.forget(),a?d:f},literal:function(){return this.dimension()||this.color()||this.quoted()||this.unicodeDescriptor()},assignment:function(){var a,b;return o.save(),(a=o.$re(/^\w+(?=\s?=)/i))&&o.$char("=")&&(b=n.entity())?(o.forget(),new e.Assignment(a,b)):void o.restore()},url:function(){var a,b=o.i;return o.autoCommentAbsorb=!1,o.$str("url(")?(a=this.quoted()||this.variable()||o.$re(/^(?:(?:\\[\(\)'"])|[^\(\)'"])+/)||"",o.autoCommentAbsorb=!0,l(")"),new e.URL(null!=a.value||a instanceof e.Variable?a:new e.Anonymous(a),b,c)):void(o.autoCommentAbsorb=!0)},variable:function(){var a,b=o.i;if("@"===o.currentChar()&&(a=o.$re(/^@@?[\w-]+/)))return new e.Variable(a,b,c)},variableCurly:function(){var a,b=o.i;if("@"===o.currentChar()&&(a=o.$re(/^@\{([\w-]+)\}/)))return new e.Variable("@"+a[1],b,c)},color:function(){var a;if("#"===o.currentChar()&&(a=o.$re(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/))){var b=a.input.match(/^#([\w]+).*/);return b=b[1],b.match(/^[A-Fa-f0-9]+$/)||i("Invalid HEX color code"),new e.Color(a[1],(void 0),"#"+b)}},colorKeyword:function(){o.save();var a=o.autoCommentAbsorb;o.autoCommentAbsorb=!1;var b=o.$re(/^[_A-Za-z-][_A-Za-z0-9-]+/);if(o.autoCommentAbsorb=a,!b)return void o.forget();o.restore();var c=e.Color.fromKeyword(b);return c?(o.$str(b),c):void 0},dimension:function(){if(!o.peekNotNumeric()){var a=o.$re(/^([+-]?\d*\.?\d+)(%|[a-z_]+)?/i);return a?new e.Dimension(a[1],a[2]):void 0}},unicodeDescriptor:function(){var a;if(a=o.$re(/^U\+[0-9a-fA-F?]+(\-[0-9a-fA-F?]+)?/))return new e.UnicodeDescriptor(a[0])},javascript:function(){var a,b=o.i;o.save();var d=o.$char("~"),f=o.$char("`");return f?(a=o.$re(/^[^`]*`/))?(o.forget(),new e.JavaScript(a.substr(0,a.length-1),Boolean(d),b,c)):void o.restore("invalid javascript definition"):void o.restore()}},variable:function(){var a;if("@"===o.currentChar()&&(a=o.$re(/^(@[\w-]+)\s*:/)))return a[1]},rulesetCall:function(){var a;if("@"===o.currentChar()&&(a=o.$re(/^(@[\w-]+)\(\s*\)\s*;/)))return new e.RulesetCall(a[1])},extend:function(a){var b,d,f,g,h,j=o.i;if(o.$str(a?"&:extend(":":extend(")){do{for(f=null,b=null;!(f=o.$re(/^(all)(?=\s*(\)|,))/))&&(d=this.element());)b?b.push(d):b=[d];f=f&&f[1],b||i("Missing target selector for :extend()."),h=new e.Extend(new e.Selector(b),f,j,c),g?g.push(h):g=[h]}while(o.$char(","));return k(/^\)/),a&&k(/^;/),g}},extendRule:function(){return this.extend(!0)},mixin:{call:function(){var a,b,d,f,g,h,i=o.currentChar(),j=!1,k=o.i;if("."===i||"#"===i){for(o.save();;){if(a=o.i,f=o.$re(/^[#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/),!f)break;d=new e.Element(g,f,a,c),b?b.push(d):b=[d],g=o.$char(">")}return b&&(o.$char("(")&&(h=this.args(!0).args,l(")")),n.important()&&(j=!0),n.end())?(o.forget(),new e.mixin.Call(b,h,k,c,j)):void o.restore()}},args:function(a){var b,c,d,f,g,h,j,k=n.entities,l={args:null,variadic:!1},m=[],p=[],q=[];for(o.save();;){if(a)h=n.detachedRuleset()||n.expression();else{if(o.commentStore.length=0,o.$str("...")){l.variadic=!0,o.$char(";")&&!b&&(b=!0),(b?p:q).push({variadic:!0});break}h=k.variable()||k.literal()||k.keyword()}if(!h)break;f=null,h.throwAwayComments&&h.throwAwayComments(),g=h;var r=null;if(a?h.value&&1==h.value.length&&(r=h.value[0]):r=h,r&&r instanceof e.Variable)if(o.$char(":")){if(m.length>0&&(b&&i("Cannot mix ; and , as delimiter types"),c=!0),g=n.detachedRuleset()||n.expression(),!g){if(!a)return o.restore(),l.args=[],l;i("could not understand value for named argument")}f=d=r.name}else if(o.$str("...")){if(!a){l.variadic=!0,o.$char(";")&&!b&&(b=!0),(b?p:q).push({name:h.name,variadic:!0});break}j=!0}else a||(d=f=r.name,g=null);g&&m.push(g),q.push({name:f,value:g,expand:j}),o.$char(",")||(o.$char(";")||b)&&(c&&i("Cannot mix ; and , as delimiter types"),b=!0,m.length>1&&(g=new e.Value(m)),p.push({name:d,value:g,expand:j}),d=null,m=[],c=!1)}return o.forget(),l.args=b?p:q,l},definition:function(){var a,b,c,d,f=[],g=!1;if(!("."!==o.currentChar()&&"#"!==o.currentChar()||o.peek(/^[^{]*\}/)))if(o.save(),b=o.$re(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/)){a=b[1];var h=this.args(!1);if(f=h.args,g=h.variadic,!o.$char(")"))return void o.restore("Missing closing ')'");if(o.commentStore.length=0,o.$str("when")&&(d=k(n.conditions,"expected condition")),c=n.block())return o.forget(),new e.mixin.Definition(a,f,c,d,g);o.restore()}else o.forget()}},entity:function(){var a=this.entities;return this.comment()||a.literal()||a.variable()||a.url()||a.call()||a.keyword()||a.javascript()},end:function(){return o.$char(";")||o.peek("}")},alpha:function(){var a;if(o.$re(/^opacity=/i))return a=o.$re(/^\d+/),a||(a=k(this.entities.variable,"Could not parse alpha")),l(")"),new e.Alpha(a)},element:function(){var a,b,d,f=o.i;if(b=this.combinator(),a=o.$re(/^(?:\d+\.\d+|\d+)%/)||o.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/)||o.$char("*")||o.$char("&")||this.attribute()||o.$re(/^\([^&()@]+\)/)||o.$re(/^[\.#:](?=@)/)||this.entities.variableCurly(),a||(o.save(),o.$char("(")?(d=this.selector())&&o.$char(")")?(a=new e.Paren(d),o.forget()):o.restore("Missing closing ')'"):o.forget()),a)return new e.Element(b,a,f,c)},combinator:function(){var a=o.currentChar();if("/"===a){o.save();var b=o.$re(/^\/[a-z]+\//i);if(b)return o.forget(),new e.Combinator(b);o.restore()}if(">"===a||"+"===a||"~"===a||"|"===a||"^"===a){for(o.i++,"^"===a&&"^"===o.currentChar()&&(a="^^",o.i++);o.isWhitespace();)o.i++;return new e.Combinator(a)}return new e.Combinator(o.isWhitespace(-1)?" ":null)},lessSelector:function(){return this.selector(!0)},selector:function(a){for(var b,d,f,g,h,j,l,m=o.i;(a&&(d=this.extend())||a&&(j=o.$str("when"))||(g=this.element()))&&(j?l=k(this.conditions,"expected condition"):l?i("CSS guard can only be used at the end of selector"):d?h=h?h.concat(d):d:(h&&i("Extend can only be used at the end of selector"),f=o.currentChar(),b?b.push(g):b=[g],g=null),"{"!==f&&"}"!==f&&";"!==f&&","!==f&&")"!==f););return b?new e.Selector(b,h,l,m,c):void(h&&i("Extend must be used to extend a selector, it cannot be used on its own"))},attribute:function(){if(o.$char("[")){var a,b,c,d=this.entities;return(a=d.variableCurly())||(a=k(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/)),c=o.$re(/^[|~*$^]?=/),c&&(b=d.quoted()||o.$re(/^[0-9]+%/)||o.$re(/^[\w-]+/)||d.variableCurly()),l("]"),new e.Attribute(a,c,b)}},block:function(){var a;if(o.$char("{")&&(a=this.primary())&&o.$char("}"))return a},blockRuleset:function(){var a=this.block();return a&&(a=new e.Ruleset(null,a)),a},detachedRuleset:function(){var a=this.blockRuleset();if(a)return new e.DetachedRuleset(a)},ruleset:function(){var b,c,d,f;for(o.save(),a.dumpLineNumbers&&(f=m(o.i));;){if(c=this.lessSelector(),!c)break;if(b?b.push(c):b=[c],o.commentStore.length=0,c.condition&&b.length>1&&i("Guards are only currently allowed on a single selector."),!o.$char(","))break;c.condition&&i("Guards are only currently allowed on a single selector."),o.commentStore.length=0}if(b&&(d=this.block())){o.forget();var g=new e.Ruleset(b,d,a.strictImports);return a.dumpLineNumbers&&(g.debugInfo=f),g}o.restore()},rule:function(b){var d,f,g,h,i,j=o.i,k=o.currentChar();if("."!==k&&"#"!==k&&"&"!==k&&":"!==k)if(o.save(),d=this.variable()||this.ruleProperty()){if(i="string"==typeof d,i&&(f=this.detachedRuleset()),o.commentStore.length=0,!f){h=!i&&d.length>1&&d.pop().value;var l=!b&&(a.compress||i);if(l&&(f=this.value()),!f&&(f=this.anonymousValue()))return o.forget(),new e.Rule(d,f,(!1),h,j,c);l||f||(f=this.value()),g=this.important()}if(f&&this.end())return o.forget(),new e.Rule(d,f,g,h,j,c);if(o.restore(),f&&!b)return this.rule(!0)}else o.forget()},anonymousValue:function(){var a=o.$re(/^([^@+\/'"*`(;{}-]*);/);if(a)return new e.Anonymous(a[1])},"import":function(){var a,b,d=o.i,f=o.$re(/^@import?\s+/);if(f){var g=(f?this.importOptions():null)||{};if(a=this.entities.quoted()||this.entities.url())return b=this.mediaFeatures(),o.$char(";")||(o.i=d,i("missing semi-colon or unrecognised media features on import")),b=b&&new e.Value(b),new e.Import(a,b,g,d,c);o.i=d,i("malformed import statement")}},importOptions:function(){var a,b,c,d={};if(!o.$char("("))return null;do if(a=this.importOption()){switch(b=a,c=!0,b){case"css":b="less",c=!1;break;case"once":b="multiple",c=!1}if(d[b]=c,!o.$char(","))break}while(a);return l(")"),d},importOption:function(){var a=o.$re(/^(less|css|multiple|once|inline|reference|optional)/);if(a)return a[1]},mediaFeature:function(){var a,b,d=this.entities,f=[];o.save();do a=d.keyword()||d.variable(),a?f.push(a):o.$char("(")&&(b=this.property(),a=this.value(),o.$char(")")?b&&a?f.push(new e.Paren(new e.Rule(b,a,null,null,o.i,c,(!0)))):a?f.push(new e.Paren(a)):i("badly formed media feature definition"):i("Missing closing ')'","Parse"));while(a);if(o.forget(),f.length>0)return new e.Expression(f)},mediaFeatures:function(){var a,b=this.entities,c=[];do if(a=this.mediaFeature()){if(c.push(a),!o.$char(","))break}else if(a=b.variable(),a&&(c.push(a),!o.$char(",")))break;while(a);return c.length>0?c:null},media:function(){var b,d,f,g,h=o.i;return a.dumpLineNumbers&&(g=m(h)),o.save(),o.$str("@media")?(b=this.mediaFeatures(),d=this.block(),d||i("media definitions require block statements after any features"),o.forget(),f=new e.Media(d,b,h,c),a.dumpLineNumbers&&(f.debugInfo=g),f):void o.restore()},plugin:function(){var a,b=o.i,d=o.$re(/^@plugin?\s+/);if(d){var f={plugin:!0};if(a=this.entities.quoted()||this.entities.url())return o.$char(";")||(o.i=b,i("missing semi-colon on plugin")),new e.Import(a,null,f,b,c);o.i=b,i("malformed plugin statement")}},directive:function(){var b,d,f,g,h,j,k,l=o.i,n=!0,p=!0;if("@"===o.currentChar()){if(d=this["import"]()||this.plugin()||this.media())return d;if(o.save(),b=o.$re(/^@[a-z-]+/)){switch(g=b,"-"==b.charAt(1)&&b.indexOf("-",2)>0&&(g="@"+b.slice(b.indexOf("-",2)+1)),g){case"@charset":h=!0,n=!1;break;case"@namespace":j=!0,n=!1;break;case"@keyframes":case"@counter-style":h=!0;break;case"@document":case"@supports":k=!0,p=!1;break;default:k=!0}return o.commentStore.length=0,h?(d=this.entity(),d||i("expected "+b+" identifier")):j?(d=this.expression(),d||i("expected "+b+" expression")):k&&(d=(o.$re(/^[^{;]+/)||"").trim(),n="{"==o.currentChar(),d&&(d=new e.Anonymous(d))),n&&(f=this.blockRuleset()),f||!n&&d&&o.$char(";")?(o.forget(),new e.Directive(b,d,f,l,c,a.dumpLineNumbers?m(l):null,p)):void o.restore("directive options not recognised")}}},value:function(){var a,b=[];do if(a=this.expression(),a&&(b.push(a),!o.$char(",")))break;while(a);if(b.length>0)return new e.Value(b)},important:function(){if("!"===o.currentChar())return o.$re(/^! *important/)},sub:function(){var a,b;return o.save(),o.$char("(")?(a=this.addition(),a&&o.$char(")")?(o.forget(),b=new e.Expression([a]),b.parens=!0,b):void o.restore("Expected ')'")):void o.restore()},multiplication:function(){var a,b,c,d,f;if(a=this.operand()){for(f=o.isWhitespace(-1);;){if(o.peek(/^\/[*\/]/))break;if(o.save(),c=o.$char("/")||o.$char("*"),!c){o.forget();break}if(b=this.operand(),!b){o.restore();break}o.forget(),a.parensInOp=!0,b.parensInOp=!0,d=new e.Operation(c,[d||a,b],f),f=o.isWhitespace(-1)}return d||a}},addition:function(){var a,b,c,d,f;if(a=this.multiplication()){for(f=o.isWhitespace(-1);;){if(c=o.$re(/^[-+]\s+/)||!f&&(o.$char("+")||o.$char("-")),!c)break;if(b=this.multiplication(),!b)break;a.parensInOp=!0,b.parensInOp=!0,d=new e.Operation(c,[d||a,b],f),f=o.isWhitespace(-1)}return d||a}},conditions:function(){var a,b,c,d=o.i;if(a=this.condition()){for(;;){if(!o.peek(/^,\s*(not\s*)?\(/)||!o.$char(","))break;if(b=this.condition(),!b)break;c=new e.Condition("or",c||a,b,d)}return c||a}},condition:function(){function a(){return o.$str("or")}var b,c,d;if(b=this.conditionAnd(this)){if(c=a()){if(d=this.condition(),!d)return;b=new e.Condition(c,b,d)}return b}},conditionAnd:function(){function a(a){return a.negatedCondition()||a.parenthesisCondition()}function b(){return o.$str("and")}var c,d,f;if(c=a(this)){if(d=b()){if(f=this.conditionAnd(),!f)return;c=new e.Condition(d,c,f)}return c}},negatedCondition:function(){if(o.$str("not")){var a=this.parenthesisCondition();return a&&(a.negate=!a.negate),a}},parenthesisCondition:function(){function a(a){var b;return o.save(),(b=a.condition())&&o.$char(")")?(o.forget(),b):void o.restore()}var b;return o.save(),o.$str("(")?(b=a(this))?(o.forget(),b):(b=this.atomicCondition())?o.$char(")")?(o.forget(),b):void o.restore("expected ')' got '"+o.currentChar()+"'"):void o.restore():void o.restore()},atomicCondition:function(){var a,b,c,d,f=this.entities,g=o.i;if(a=this.addition()||f.keyword()||f.quoted())return o.$char(">")?d=o.$char("=")?">=":">":o.$char("<")?d=o.$char("=")?"<=":"<":o.$char("=")&&(d=o.$char(">")?"=>":o.$char("<")?"=<":"="),d?(b=this.addition()||f.keyword()||f.quoted(),b?c=new e.Condition(d,a,b,g,(!1)):i("expected expression")):c=new e.Condition("=",a,new e.Keyword("true"),g,(!1)),c},operand:function(){var a,b=this.entities;o.peek(/^-[@\(]/)&&(a=o.$char("-"));var c=this.sub()||b.dimension()||b.color()||b.variable()||b.call()||b.colorKeyword();return a&&(c.parensInOp=!0,c=new e.Negative(c)),c},expression:function(){var a,b,c=[];do a=this.comment(),a?c.push(a):(a=this.addition()||this.entity(),a&&(c.push(a),o.peek(/^\/[\/*]/)||(b=o.$char("/"),b&&c.push(new e.Anonymous(b)))));while(a);if(c.length>0)return new e.Expression(c)},property:function(){var a=o.$re(/^(\*?-?[_a-zA-Z0-9-]+)\s*:/);if(a)return a[1]},ruleProperty:function(){function a(a){var b=o.i,c=o.$re(a);if(c)return g.push(b),f.push(c[1])}var b,d,f=[],g=[];o.save();var h=o.$re(/^([_a-zA-Z0-9-]+)\s*:/);if(h)return f=[new e.Keyword(h[1])],o.forget(),f;for(a(/^(\*?)/);;)if(!a(/^((?:[\w-]+)|(?:@\{[\w-]+\}))/))break;if(f.length>1&&a(/^((?:\+_|\+)?)\s*:/)){for(o.forget(),""===f[0]&&(f.shift(),g.shift()),d=0;d=b);c++);this.preProcessors.splice(c,0,{preProcessor:a,priority:b})},d.prototype.addPostProcessor=function(a,b){var c;for(c=0;c=b);c++);this.postProcessors.splice(c,0,{postProcessor:a,priority:b})},d.prototype.addFileManager=function(a){this.fileManagers.push(a)},d.prototype.getPreProcessors=function(){for(var a=[],b=0;b0){var d,e=JSON.stringify(this._sourceMapGenerator.toJSON());this.sourceMapURL?d=this.sourceMapURL:this._sourceMapFilename&&(d=this._sourceMapFilename),this.sourceMapURL=d,this.sourceMap=e}return this._css.join("")},b}},{}],44:[function(a,b,c){var d=a("./contexts"),e=a("./visitors"),f=a("./tree");b.exports=function(a,b){b=b||{};var c,g=b.variables,h=new d.Eval(b);"object"!=typeof g||Array.isArray(g)||(g=Object.keys(g).map(function(a){var b=g[a];return b instanceof f.Value||(b instanceof f.Expression||(b=new f.Expression([b])),b=new f.Value([b])),new f.Rule("@"+a,b,(!1),null,0)}),h.frames=[new f.Ruleset(null,g)]);var i,j=[],k=[new e.JoinSelectorVisitor,new e.MarkVisibleSelectorsVisitor((!0)),new e.ExtendVisitor,new e.ToCSSVisitor({compress:Boolean(b.compress)})];if(b.pluginManager){var l=b.pluginManager.getVisitors();for(i=0;i.5?j/(2-g-h):j/(g+h),g){case c:a=(d-e)/j+(d="===a||"=<"===a||"<="===a;case 1:return">"===a||">="===a;default:return!1}}}(this.op,this.lvalue.eval(a),this.rvalue.eval(a));return this.negate?!b:b},b.exports=e},{"./node":70}],54:[function(a,b,c){var d=function(a,b,c){var e="";if(a.dumpLineNumbers&&!a.compress)switch(a.dumpLineNumbers){case"comments":e=d.asComment(b);break;case"mediaquery":e=d.asMediaQuery(b);break;case"all":e=d.asComment(b)+(c||"")+d.asMediaQuery(b)}return e};d.asComment=function(a){return"/* line "+a.debugInfo.lineNumber+", "+a.debugInfo.fileName+" */\n"},d.asMediaQuery=function(a){var b=a.debugInfo.fileName;return/^[a-z]+:\/\//i.test(b)||(b="file://"+b),"@media -sass-debug-info{filename{font-family:"+b.replace(/([.:\/\\])/g,function(a){return"\\"==a&&(a="/"),"\\"+a})+"}line{font-family:\\00003"+a.debugInfo.lineNumber+"}}\n"},b.exports=d},{}],55:[function(a,b,c){var d=a("./node"),e=a("../contexts"),f=function(a,b){this.ruleset=a,this.frames=b};f.prototype=new d,f.prototype.type="DetachedRuleset",f.prototype.evalFirst=!0,f.prototype.accept=function(a){this.ruleset=a.visit(this.ruleset)},f.prototype.eval=function(a){var b=this.frames||a.frames.slice(0);return new f(this.ruleset,b)},f.prototype.callEval=function(a){return this.ruleset.eval(this.frames?new e.Eval(a,this.frames.concat(a.frames)):a)},b.exports=f},{"../contexts":11,"./node":70}],56:[function(a,b,c){var d=a("./node"),e=a("../data/unit-conversions"),f=a("./unit"),g=a("./color"),h=function(a,b){this.value=parseFloat(a),this.unit=b&&b instanceof f?b:new f(b?[b]:void 0)};h.prototype=new d,h.prototype.type="Dimension",h.prototype.accept=function(a){this.unit=a.visit(this.unit)},h.prototype.eval=function(a){return this},h.prototype.toColor=function(){return new g([this.value,this.value,this.value])},h.prototype.genCSS=function(a,b){if(a&&a.strictUnits&&!this.unit.isSingular())throw new Error("Multiple units in dimension. Correct the units or use the unit function. Bad unit: "+this.unit.toString());var c=this.fround(a,this.value),d=String(c);if(0!==c&&c<1e-6&&c>-1e-6&&(d=c.toFixed(20).replace(/0+$/,"")),a&&a.compress){if(0===c&&this.unit.isLength())return void b.add(d);c>0&&c<1&&(d=d.substr(1))}b.add(d),this.unit.genCSS(a,b)},h.prototype.operate=function(a,b,c){var d=this._operate(a,b,this.value,c.value),e=this.unit.clone();if("+"===b||"-"===b)if(0===e.numerator.length&&0===e.denominator.length)e=c.unit.clone(),this.unit.backupUnit&&(e.backupUnit=this.unit.backupUnit);else if(0===c.unit.numerator.length&&0===e.denominator.length);else{if(c=c.convertTo(this.unit.usedUnits()),a.strictUnits&&c.unit.toString()!==e.toString())throw new Error("Incompatible units. Change the units or use the unit function. Bad units: '"+e.toString()+"' and '"+c.unit.toString()+"'.");d=this._operate(a,b,this.value,c.value)}else"*"===b?(e.numerator=e.numerator.concat(c.unit.numerator).sort(),e.denominator=e.denominator.concat(c.unit.denominator).sort(),e.cancel()):"/"===b&&(e.numerator=e.numerator.concat(c.unit.denominator).sort(),e.denominator=e.denominator.concat(c.unit.numerator).sort(),e.cancel());return new h(d,e)},h.prototype.compare=function(a){var b,c;if(a instanceof h){if(this.unit.isEmpty()||a.unit.isEmpty())b=this,c=a;else if(b=this.unify(),c=a.unify(),0!==b.unit.compare(c.unit))return;return d.numericCompare(b.value,c.value)}},h.prototype.unify=function(){return this.convertTo({length:"px",duration:"s",angle:"rad"})},h.prototype.convertTo=function(a){var b,c,d,f,g,i=this.value,j=this.unit.clone(),k={};if("string"==typeof a){for(b in e)e[b].hasOwnProperty(a)&&(k={},k[b]=a);a=k}g=function(a,b){return d.hasOwnProperty(a)?(b?i/=d[a]/d[f]:i*=d[a]/d[f],f):a};for(c in a)a.hasOwnProperty(c)&&(f=a[c],d=e[c],j.map(g));return j.cancel(),new h(i,j)},b.exports=h},{"../data/unit-conversions":14,"./color":50,"./node":70,"./unit":79}],57:[function(a,b,c){var d=a("./node"),e=a("./selector"),f=a("./ruleset"),g=function(a,b,c,d,f,g,h,i){var j;if(this.name=a,this.value=b,c)for(Array.isArray(c)?this.rules=c:(this.rules=[c],this.rules[0].selectors=new e([],null,null,this.index,f).createEmptySelectors()),j=0;j1?b=new g(this.value.map(function(b){return b.eval(a)})):1===this.value.length?(this.value[0].parens&&!this.value[0].parensInOp&&(d=!0),b=this.value[0].eval(a)):b=this,c&&a.outOfParenthesis(),this.parens&&this.parensInOp&&!a.isMathOn()&&!d&&(b=new e(b)),b},g.prototype.genCSS=function(a,b){for(var c=0;c0&&c.length&&""===c[0].combinator.value&&(c[0].combinator.value=" "),d=d.concat(a[b].elements);this.selfSelectors=[new e(d)],this.selfSelectors[0].copyVisibilityInfo(this.visibilityInfo())},b.exports=f},{"./node":70,"./selector":77}],61:[function(a,b,c){var d=a("./node"),e=a("./media"),f=a("./url"),g=a("./quoted"),h=a("./ruleset"),i=a("./anonymous"),j=function(a,b,c,d,e,f){if(this.options=c,this.index=d,this.path=a,this.features=b,this.currentFileInfo=e,this.allowRoot=!0,void 0!==this.options.less||this.options.inline)this.css=!this.options.less||this.options.inline;else{var g=this.getPath();g&&/[#\.\&\?\/]css([\?;].*)?$/.test(g)&&(this.css=!0)}this.copyVisibilityInfo(f)};j.prototype=new d,j.prototype.type="Import",j.prototype.accept=function(a){this.features&&(this.features=a.visit(this.features)),this.path=a.visit(this.path),this.options.plugin||this.options.inline||!this.root||(this.root=a.visit(this.root))},j.prototype.genCSS=function(a,b){this.css&&void 0===this.path.currentFileInfo.reference&&(b.add("@import ",this.currentFileInfo,this.index),this.path.genCSS(a,b),this.features&&(b.add(" "),this.features.genCSS(a,b)),b.add(";"))},j.prototype.getPath=function(){return this.path instanceof f?this.path.value.value:this.path.value},j.prototype.isVariableImport=function(){var a=this.path;return a instanceof f&&(a=a.value),!(a instanceof g)||a.containsVariables()},j.prototype.evalForImport=function(a){var b=this.path;return b instanceof f&&(b=b.value),new j(b.eval(a),this.features,this.options,this.index,this.currentFileInfo,this.visibilityInfo())},j.prototype.evalPath=function(a){var b=this.path.eval(a),c=this.currentFileInfo&&this.currentFileInfo.rootpath;if(!(b instanceof f)){if(c){var d=b.value;d&&a.isPathRelative(d)&&(b.value=c+d)}b.value=a.normalizePath(b.value)}return b},j.prototype.eval=function(a){var b=this.doEval(a);return(this.options.reference||this.blocksVisibility())&&(b.length||0===b.length?b.forEach(function(a){a.addVisibilityBlock()}):b.addVisibilityBlock()),b},j.prototype.doEval=function(a){var b,c,d=this.features&&this.features.eval(a);if(this.options.plugin)return c=a.frames[0]&&a.frames[0].functionRegistry,c&&this.root&&this.root.functions&&c.addMultiple(this.root.functions),[];if(this.skip&&("function"==typeof this.skip&&(this.skip=this.skip()),this.skip))return[];if(this.options.inline){var f=new i(this.root,0,{filename:this.importedFilename,reference:this.path.currentFileInfo&&this.path.currentFileInfo.reference},(!0),(!0));return this.features?new e([f],this.features.value):[f]}if(this.css){var g=new j(this.evalPath(a),d,this.options,this.index);if(!g.css&&this.error)throw this.error;return g}return b=new h(null,this.root.rules.slice(0)),b.evalImports(a),this.features?new e(b.rules,this.features.value):b.rules},b.exports=j},{"./anonymous":46,"./media":66,"./node":70,"./quoted":73,"./ruleset":76,"./url":80}],62:[function(a,b,c){var d={};d.Node=a("./node"),d.Alpha=a("./alpha"),d.Color=a("./color"),d.Directive=a("./directive"),d.DetachedRuleset=a("./detached-ruleset"),d.Operation=a("./operation"),d.Dimension=a("./dimension"),d.Unit=a("./unit"),d.Keyword=a("./keyword"),d.Variable=a("./variable"),d.Ruleset=a("./ruleset"),d.Element=a("./element"),d.Attribute=a("./attribute"),d.Combinator=a("./combinator"),d.Selector=a("./selector"),d.Quoted=a("./quoted"),d.Expression=a("./expression"),d.Rule=a("./rule"),d.Call=a("./call"),d.URL=a("./url"),d.Import=a("./import"),d.mixin={Call:a("./mixin-call"),Definition:a("./mixin-definition")},d.Comment=a("./comment"),d.Anonymous=a("./anonymous"),d.Value=a("./value"),d.JavaScript=a("./javascript"),d.Assignment=a("./assignment"),d.Condition=a("./condition"),d.Paren=a("./paren"),d.Media=a("./media"),d.UnicodeDescriptor=a("./unicode-descriptor"),d.Negative=a("./negative"),d.Extend=a("./extend"),d.RulesetCall=a("./ruleset-call"),b.exports=d},{"./alpha":45,"./anonymous":46,"./assignment":47,"./attribute":48,"./call":49,"./color":50,"./combinator":51,"./comment":52,"./condition":53,"./detached-ruleset":55,"./dimension":56,"./directive":57,"./element":58,"./expression":59,"./extend":60,"./import":61,"./javascript":63,"./keyword":65,"./media":66,"./mixin-call":67,"./mixin-definition":68,"./negative":69,"./node":70,"./operation":71,"./paren":72,"./quoted":73,"./rule":74,"./ruleset":76,"./ruleset-call":75,"./selector":77,"./unicode-descriptor":78,"./unit":79,"./url":80,"./value":81,"./variable":82}],63:[function(a,b,c){var d=a("./js-eval-node"),e=a("./dimension"),f=a("./quoted"),g=a("./anonymous"),h=function(a,b,c,d){this.escaped=b,this.expression=a,this.index=c,this.currentFileInfo=d};h.prototype=new d,h.prototype.type="JavaScript",h.prototype.eval=function(a){var b=this.evaluateJavaScript(this.expression,a);return"number"==typeof b?new e(b):"string"==typeof b?new f('"'+b+'"',b,this.escaped,this.index):new g(Array.isArray(b)?b.join(", "):b)},b.exports=h},{"./anonymous":46,"./dimension":56,"./js-eval-node":64,"./quoted":73}],64:[function(a,b,c){var d=a("./node"),e=a("./variable"),f=function(){};f.prototype=new d,f.prototype.evaluateJavaScript=function(a,b){var c,d=this,f={};if(void 0!==b.javascriptEnabled&&!b.javascriptEnabled)throw{message:"You are using JavaScript, which has been disabled.",filename:this.currentFileInfo.filename,index:this.index};a=a.replace(/@\{([\w-]+)\}/g,function(a,c){return d.jsify(new e("@"+c,d.index,d.currentFileInfo).eval(b))});try{a=new Function("return ("+a+")")}catch(g){throw{message:"JavaScript evaluation error: "+g.message+" from `"+a+"`",filename:this.currentFileInfo.filename,index:this.index}}var h=b.frames[0].variables();for(var i in h)h.hasOwnProperty(i)&&(f[i.slice(1)]={value:h[i].value,toJS:function(){return this.value.eval(b).toCSS()}});try{c=a.call(f)}catch(g){throw{message:"JavaScript evaluation error: '"+g.name+": "+g.message.replace(/["]/g,"'")+"'",filename:this.currentFileInfo.filename,index:this.index}}return c},f.prototype.jsify=function(a){return Array.isArray(a.value)&&a.value.length>1?"["+a.value.map(function(a){return a.toCSS()}).join(", ")+"]":a.toCSS()},b.exports=f},{"./node":70,"./variable":82}],65:[function(a,b,c){var d=a("./node"),e=function(a){this.value=a};e.prototype=new d,e.prototype.type="Keyword",e.prototype.genCSS=function(a,b){if("%"===this.value)throw{type:"Syntax",message:"Invalid % without number"};b.add(this.value)},e.True=new e("true"),e.False=new e("false"),b.exports=e},{"./node":70}],66:[function(a,b,c){var d=a("./ruleset"),e=a("./value"),f=a("./selector"),g=a("./anonymous"),h=a("./expression"),i=a("./directive"),j=function(a,b,c,g,h){this.index=c,this.currentFileInfo=g;var i=new f([],null,null,this.index,this.currentFileInfo).createEmptySelectors();this.features=new e(b),this.rules=[new d(i,a)],this.rules[0].allowImports=!0,this.copyVisibilityInfo(h),this.allowRoot=!0};j.prototype=new i,j.prototype.type="Media",j.prototype.isRulesetLike=!0,j.prototype.accept=function(a){this.features&&(this.features=a.visit(this.features)),this.rules&&(this.rules=a.visitArray(this.rules))},j.prototype.genCSS=function(a,b){b.add("@media ",this.currentFileInfo,this.index),this.features.genCSS(a,b),this.outputRuleset(a,b,this.rules)},j.prototype.eval=function(a){a.mediaBlocks||(a.mediaBlocks=[],a.mediaPath=[]);var b=new j(null,[],this.index,this.currentFileInfo,this.visibilityInfo());this.debugInfo&&(this.rules[0].debugInfo=this.debugInfo,b.debugInfo=this.debugInfo);var c=!1;a.strictMath||(c=!0,a.strictMath=!0);try{b.features=this.features.eval(a)}finally{c&&(a.strictMath=!1)}return a.mediaPath.push(b),a.mediaBlocks.push(b),this.rules[0].functionRegistry=a.frames[0].functionRegistry.inherit(),a.frames.unshift(this.rules[0]),b.rules=[this.rules[0].eval(a)],a.frames.shift(),a.mediaPath.pop(),0===a.mediaPath.length?b.evalTop(a):b.evalNested(a)},j.prototype.evalTop=function(a){var b=this;if(a.mediaBlocks.length>1){var c=new f([],null,null,this.index,this.currentFileInfo).createEmptySelectors();b=new d(c,a.mediaBlocks),b.multiMedia=!0,b.copyVisibilityInfo(this.visibilityInfo())}return delete a.mediaBlocks,delete a.mediaPath,b},j.prototype.evalNested=function(a){var b,c,f=a.mediaPath.concat([this]);for(b=0;b0;b--)a.splice(b,0,new g("and"));return new h(a)})),new d([],[])},j.prototype.permute=function(a){if(0===a.length)return[];if(1===a.length)return a[0];for(var b=[],c=this.permute(a.slice(1)),d=0;d0){for(n=!0,k=0;k0)p=B;else if(p=A,q[A]+q[B]>1)throw{type:"Runtime",message:"Ambiguous use of `default()` found when matching for `"+this.format(t)+"`",index:this.index,filename:this.currentFileInfo.filename};for(k=0;kthis.params.length)return!1}c=Math.min(f,this.arity);for(var g=0;gb?1:void 0},d.prototype.blocksVisibility=function(){return null==this.visibilityBlocks&&(this.visibilityBlocks=0),0!==this.visibilityBlocks},d.prototype.addVisibilityBlock=function(){null==this.visibilityBlocks&&(this.visibilityBlocks=0),this.visibilityBlocks=this.visibilityBlocks+1},d.prototype.removeVisibilityBlock=function(){null==this.visibilityBlocks&&(this.visibilityBlocks=0),this.visibilityBlocks=this.visibilityBlocks-1},d.prototype.ensureVisibility=function(){this.nodeVisible=!0},d.prototype.ensureInvisibility=function(){this.nodeVisible=!1},d.prototype.isVisible=function(){return this.nodeVisible},d.prototype.visibilityInfo=function(){return{visibilityBlocks:this.visibilityBlocks,nodeVisible:this.nodeVisible}},d.prototype.copyVisibilityInfo=function(a){a&&(this.visibilityBlocks=a.visibilityBlocks,this.nodeVisible=a.nodeVisible)},b.exports=d},{}],71:[function(a,b,c){var d=a("./node"),e=a("./color"),f=a("./dimension"),g=function(a,b,c){this.op=a.trim(),this.operands=b,this.isSpaced=c};g.prototype=new d,g.prototype.type="Operation",g.prototype.accept=function(a){this.operands=a.visit(this.operands)},g.prototype.eval=function(a){var b=this.operands[0].eval(a),c=this.operands[1].eval(a);if(a.isMathOn()){if(b instanceof f&&c instanceof e&&(b=b.toColor()),c instanceof f&&b instanceof e&&(c=c.toColor()),!b.operate)throw{type:"Operation",message:"Operation on an invalid type"};return b.operate(a,this.op,c)}return new g(this.op,[b,c],this.isSpaced)},g.prototype.genCSS=function(a,b){this.operands[0].genCSS(a,b),this.isSpaced&&b.add(" "),b.add(this.op),this.isSpaced&&b.add(" "),this.operands[1].genCSS(a,b)},b.exports=g},{"./color":50,"./dimension":56,"./node":70}],72:[function(a,b,c){var d=a("./node"),e=function(a){this.value=a};e.prototype=new d,e.prototype.type="Paren",e.prototype.genCSS=function(a,b){b.add("("),this.value.genCSS(a,b),b.add(")")},e.prototype.eval=function(a){return new e(this.value.eval(a))},b.exports=e},{"./node":70}],73:[function(a,b,c){var d=a("./node"),e=a("./js-eval-node"),f=a("./variable"),g=function(a,b,c,d,e){this.escaped=null==c||c,this.value=b||"",this.quote=a.charAt(0),this.index=d,this.currentFileInfo=e};g.prototype=new e,g.prototype.type="Quoted",g.prototype.genCSS=function(a,b){this.escaped||b.add(this.quote,this.currentFileInfo,this.index),b.add(this.value),this.escaped||b.add(this.quote)},g.prototype.containsVariables=function(){return this.value.match(/(`([^`]+)`)|@\{([\w-]+)\}/)},g.prototype.eval=function(a){function b(a,b,c){var d=a;do a=d,d=a.replace(b,c);while(a!==d);return d}var c=this,d=this.value,e=function(b,d){return String(c.evaluateJavaScript(d,a))},h=function(b,d){var e=new f("@"+d,c.index,c.currentFileInfo).eval(a,!0);return e instanceof g?e.value:e.toCSS()};return d=b(d,/`([^`]+)`/g,e),d=b(d,/@\{([\w-]+)\}/g,h),new g(this.quote+d+this.quote,d,this.escaped,this.index,this.currentFileInfo)},g.prototype.compare=function(a){return"Quoted"!==a.type||this.escaped||a.escaped?a.toCSS&&this.toCSS()===a.toCSS()?0:void 0:d.numericCompare(this.value,a.value)},b.exports=g},{"./js-eval-node":64,"./node":70,"./variable":82}],74:[function(a,b,c){function d(a,b){var c,d="",e=b.length,f={add:function(a){d+=a}};for(c=0;cd){if(!c||c(h)){e=h.find(new f(a.elements.slice(d)),b,c);for(var j=0;j0&&b.add(k),a.firstSelector=!0,h[0].genCSS(a,b),a.firstSelector=!1,e=1;e0?(e=a.slice(0),f=e.pop(),h=d.createDerived(f.elements.slice(0))):h=d.createDerived([]),b.length>0){var i=c.combinator,j=b[0].elements[0];i.emptyOrWhitespace&&!j.combinator.emptyOrWhitespace&&(i=j.combinator),h.elements.push(new g(i,j.value,c.index,c.currentFileInfo)),h.elements=h.elements.concat(b[0].elements.slice(1))}if(0!==h.elements.length&&e.push(h),b.length>1){var k=b.slice(1);k=k.map(function(a){return a.createDerived(a.elements,[])}),e=e.concat(k)}return e}function j(a,b,c,d,e){var f;for(f=0;f0?d[d.length-1]=d[d.length-1].createDerived(d[d.length-1].elements.concat(a)):d.push(new f(a))}}function l(a,b,c){function f(a){var b;return"Paren"!==a.value.type?null:(b=a.value.value,"Selector"!==b.type?null:b)}var h,m,n,o,p,q,r,s,t,u,v=!1;for(o=[],p=[[]],h=0;h0&&r[0].elements.push(new g(s.combinator,"",s.index,s.currentFileInfo)),q.push(r);else for(n=0;n0&&(a.push(p[h]),u=p[h][t-1],p[h][t-1]=u.createDerived(u.elements,c.extendList));return v}function m(a,b){var c=b.createDerived(b.elements,b.extendList,b.evaldCondition);return c.copyVisibilityInfo(a),c}var n,o,p;if(o=[],p=l(o,b,c),!p)if(b.length>0)for(o=[],n=0;n0)for(b=0;b=0&&"\n"!==b.charAt(c);)e++;return"number"==typeof a&&(d=(b.slice(0,a).match(/\n/g)||"").length),{line:d,column:e}}}},{}],84:[function(a,b,c){var d=a("../tree"),e=a("./visitor"),f=a("../logger"),g=function(){this._visitor=new e(this),this.contexts=[],this.allExtendsStack=[[]]};g.prototype={run:function(a){return a=this._visitor.visit(a),a.allExtends=this.allExtendsStack[0],a},visitRule:function(a,b){b.visitDeeper=!1},visitMixinDefinition:function(a,b){b.visitDeeper=!1},visitRuleset:function(a,b){if(!a.root){var c,e,f,g,h=[],i=a.rules,j=i?i.length:0;for(c=0;c=0||(i=[k.selfSelectors[0]],g=n.findMatch(j,i),g.length&&(j.hasFoundMatches=!0,j.selfSelectors.forEach(function(a){var b=k.visibilityInfo();h=n.extendSelector(g,i,a,j.isVisible()),l=new d.Extend(k.selector,k.option,0,k.currentFileInfo,b),l.selfSelectors=h,h[h.length-1].extendList=[l],m.push(l),l.ruleset=k.ruleset,l.parent_ids=l.parent_ids.concat(k.parent_ids,j.parent_ids),k.firstExtendOnThisSelectorPath&&(l.firstExtendOnThisSelectorPath=!0,k.ruleset.paths.push(h))})));if(m.length){if(this.extendChainCount++,c>100){var o="{unable to calculate}",p="{unable to calculate}";try{o=m[0].selfSelectors[0].toCSS(),p=m[0].selector.toCSS()}catch(q){}throw{message:"extend circular reference detected. One of the circular extends is currently:"+o+":extend("+p+")"}}return m.concat(n.doExtendChaining(m,b,c+1))}return m},visitRule:function(a,b){b.visitDeeper=!1},visitMixinDefinition:function(a,b){b.visitDeeper=!1},visitSelector:function(a,b){b.visitDeeper=!1},visitRuleset:function(a,b){if(!a.root){var c,d,e,f,g=this.allExtendsStack[this.allExtendsStack.length-1],h=[],i=this;for(e=0;e0&&k[i.matched].combinator.value!==g?i=null:i.matched++,i&&(i.finished=i.matched===k.length,i.finished&&!a.allowAfter&&(e+1k&&l>0&&(m[m.length-1].elements=m[m.length-1].elements.concat(b[k].elements.slice(l)),l=0,k++),j=g.elements.slice(l,i.index).concat([h]).concat(c.elements.slice(1)),k===i.pathIndex&&f>0?m[m.length-1].elements=m[m.length-1].elements.concat(j):(m=m.concat(b.slice(k,i.pathIndex)),m.push(new d.Selector(j))),k=i.endPathIndex,l=i.endPathElementIndex,l>=b[k].elements.length&&(l=0,k++);return k0&&(m[m.length-1].elements=m[m.length-1].elements.concat(b[k].elements.slice(l)),k++),m=m.concat(b.slice(k,b.length)),m=m.map(function(a){var b=a.createDerived(a.elements);return e?b.ensureVisibility():b.ensureInvisibility(),b})},visitMedia:function(a,b){var c=a.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);c=c.concat(this.doExtendChaining(c,a.allExtends)),this.allExtendsStack.push(c)},visitMediaOut:function(a){var b=this.allExtendsStack.length-1;this.allExtendsStack.length=b},visitDirective:function(a,b){var c=a.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);c=c.concat(this.doExtendChaining(c,a.allExtends)),this.allExtendsStack.push(c)},visitDirectiveOut:function(a){var b=this.allExtendsStack.length-1;this.allExtendsStack.length=b}},b.exports=h},{"../logger":33,"../tree":62,"./visitor":91}],85:[function(a,b,c){function d(a){this.imports=[],this.variableImports=[],this._onSequencerEmpty=a,this._currentDepth=0}d.prototype.addImport=function(a){var b=this,c={callback:a,args:null,isReady:!1};return this.imports.push(c),function(){c.args=Array.prototype.slice.call(arguments,0),c.isReady=!0,b.tryRun()}},d.prototype.addVariableImport=function(a){this.variableImports.push(a)},d.prototype.tryRun=function(){this._currentDepth++;try{for(;;){for(;this.imports.length>0;){var a=this.imports[0];if(!a.isReady)return; -this.imports=this.imports.slice(1),a.callback.apply(null,a.args)}if(0===this.variableImports.length)break;var b=this.variableImports[0];this.variableImports=this.variableImports.slice(1),b()}}finally{this._currentDepth--}0===this._currentDepth&&this._onSequencerEmpty&&this._onSequencerEmpty()},b.exports=d},{}],86:[function(a,b,c){var d=a("../contexts"),e=a("./visitor"),f=a("./import-sequencer"),g=function(a,b){this._visitor=new e(this),this._importer=a,this._finish=b,this.context=new d.Eval,this.importCount=0,this.onceFileDetectionMap={},this.recursionDetector={},this._sequencer=new f(this._onSequencerEmpty.bind(this))};g.prototype={isReplacing:!1,run:function(a){try{this._visitor.visit(a)}catch(b){this.error=b}this.isFinished=!0,this._sequencer.tryRun()},_onSequencerEmpty:function(){this.isFinished&&this._finish(this.error)},visitImport:function(a,b){var c=a.options.inline;if(!a.css||c){var e=new d.Eval(this.context,this.context.frames.slice(0)),f=e.frames[0];this.importCount++,a.isVariableImport()?this._sequencer.addVariableImport(this.processImportNode.bind(this,a,e,f)):this.processImportNode(a,e,f)}b.visitDeeper=!1},processImportNode:function(a,b,c){var d,e=a.options.inline;try{d=a.evalForImport(b)}catch(f){f.filename||(f.index=a.index,f.filename=a.currentFileInfo.filename),a.css=!0,a.error=f}if(!d||d.css&&!e)this.importCount--,this.isFinished&&this._sequencer.tryRun();else{d.options.multiple&&(b.importMultiple=!0);for(var g=void 0===d.css,h=0;h0},resolveVisibility:function(a,b){if(!a.blocksVisibility()){if(this.isEmpty(a)&&!this.containsSilentNonBlockedChild(b))return;return a}var c=a.rules[0];if(this.keepOnlyVisibleChilds(c),!this.isEmpty(c))return a.ensureVisibility(),a.removeVisibilityBlock(),a},isVisibleRuleset:function(a){return!!a.firstRoot||!this.isEmpty(a)&&!(!a.root&&!this.hasVisibleSelector(a))}};var g=function(a){this._visitor=new e(this),this._context=a,this.utils=new f(a)};g.prototype={isReplacing:!0,run:function(a){return this._visitor.visit(a)},visitRule:function(a,b){if(!a.blocksVisibility()&&!a.variable)return a},visitMixinDefinition:function(a,b){a.frames=[]},visitExtend:function(a,b){},visitComment:function(a,b){if(!a.blocksVisibility()&&!a.isSilent(this._context))return a},visitMedia:function(a,b){var c=a.rules[0].rules;return a.accept(this._visitor),b.visitDeeper=!1,this.utils.resolveVisibility(a,c)},visitImport:function(a,b){if(!a.blocksVisibility())return a},visitDirective:function(a,b){return a.rules&&a.rules.length?this.visitDirectiveWithBody(a,b):this.visitDirectiveWithoutBody(a,b)},visitDirectiveWithBody:function(a,b){function c(a){var b=a.rules;return 1===b.length&&(!b[0].paths||0===b[0].paths.length)}function d(a){var b=a.rules;return c(a)?b[0].rules:b}var e=d(a);return a.accept(this._visitor),b.visitDeeper=!1,this.utils.isEmpty(a)||this._mergeRules(a.rules[0].rules),this.utils.resolveVisibility(a,e)},visitDirectiveWithoutBody:function(a,b){if(!a.blocksVisibility()){if("@charset"===a.name){if(this.charset){if(a.debugInfo){var c=new d.Comment("/* "+a.toCSS(this._context).replace(/\n/g,"")+" */\n");return c.debugInfo=a.debugInfo,this._visitor.visit(c)}return}this.charset=!0}return a}},checkValidNodes:function(a,b){if(a)for(var c=0;c0?a.accept(this._visitor):a.rules=null,b.visitDeeper=!1}return a.rules&&(this._mergeRules(a.rules),this._removeDuplicateRules(a.rules)),this.utils.isVisibleRuleset(a)&&(a.ensureVisibility(),d.splice(0,0,a)),1===d.length?d[0]:d},_compileRulesetPaths:function(a){a.paths&&(a.paths=a.paths.filter(function(a){var b;for(" "===a[0].elements[0].combinator.value&&(a[0].elements[0].combinator=new d.Combinator("")),b=0;b=0;e--)if(c=a[e],c instanceof d.Rule)if(f[c.name]){b=f[c.name],b instanceof d.Rule&&(b=f[c.name]=[f[c.name].toCSS(this._context)]);var g=c.toCSS(this._context);b.indexOf(g)!==-1?a.splice(e,1):b.push(g)}else f[c.name]=c}},_mergeRules:function(a){if(a){for(var b,c,e,f={},g=0;g1){c=b[0];var h=[],i=[];b.map(function(a){"+"===a.merge&&(i.length>0&&h.push(e(i)),i=[]),i.push(a)}),h.push(e(i)),c.value=g(h)}})}},visitAnonymous:function(a,b){if(!a.blocksVisibility())return a.accept(this._visitor),a}},b.exports=g},{"../tree":62,"./visitor":91}],91:[function(a,b,c){function d(a){return a}function e(a,b){var c,d;for(c in a)if(a.hasOwnProperty(c))switch(d=a[c],typeof d){case"function":d.prototype&&d.prototype.type&&(d.prototype.typeIndex=b++);break;case"object":b=e(d,b)}return b}var f=a("../tree"),g={visitDeeper:!0},h=!1,i=function(a){this._implementation=a,this._visitFnCache=[],h||(e(f,1),h=!0)};i.prototype={visit:function(a){if(!a)return a;var b=a.typeIndex;if(!b)return a;var c,e=this._visitFnCache,f=this._implementation,h=b<<1,i=1|h,j=e[h],k=e[i],l=g;if(l.visitDeeper=!0,j||(c="visit"+a.type,j=f[c]||d,k=f[c+"Out"]||d,e[h]=j,e[i]=k),j!==d){var m=j.call(f,a,l);f.isReplacing&&(a=m)}return l.visitDeeper&&a&&a.accept&&a.accept(this),k!=d&&k.call(f,a),a},visitArray:function(a,b){if(!a)return a;var c,d=a.length;if(b||!this._implementation.isReplacing){for(c=0;ck){for(var b=0,c=h.length-j;b0||b.isFileProtocol?"development":"production");var c=/!dumpLineNumbers:(comments|mediaquery|all)/.exec(a.location.hash);c&&(b.dumpLineNumbers=c[1]),void 0===b.useFileCache&&(b.useFileCache=!0),void 0===b.onReady&&(b.onReady=!0),b.javascriptEnabled=!(!b.javascriptEnabled&&!b.inlineJavaScript)}},{"./browser":3,"./utils":11}],2:[function(a,b,c){function d(a){a.filename&&console.warn(a),e.async||h.removeChild(i)}a("promise/polyfill");var e=a("../less/default-options")();if(window.less)for(key in window.less)window.less.hasOwnProperty(key)&&(e[key]=window.less[key]);a("./add-default-options")(window,e),e.plugins=e.plugins||[],window.LESS_PLUGINS&&(e.plugins=e.plugins.concat(window.LESS_PLUGINS));var f=b.exports=a("./index")(window,e);window.less=f;var g,h,i;e.onReady&&(/!watch/.test(window.location.hash)&&f.watch(),e.async||(g="body { display: none !important }",h=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style"),i.type="text/css",i.styleSheet?i.styleSheet.cssText=g:i.appendChild(document.createTextNode(g)),h.appendChild(i)),f.registerStylesheetsImmediately(),f.pageLoadFinished=f.refresh("development"===f.env).then(d,d))},{"../less/default-options":16,"./add-default-options":1,"./index":8,"promise/polyfill":100}],3:[function(a,b,c){var d=a("./utils");b.exports={createCSS:function(a,b,c){var e=c.href||"",f="less:"+(c.title||d.extractId(e)),g=a.getElementById(f),h=!1,i=a.createElement("style");i.setAttribute("type","text/css"),c.media&&i.setAttribute("media",c.media),i.id=f,i.styleSheet||(i.appendChild(a.createTextNode(b)),h=null!==g&&g.childNodes.length>0&&i.childNodes.length>0&&g.firstChild.nodeValue===i.firstChild.nodeValue);var j=a.getElementsByTagName("head")[0];if(null===g||h===!1){var k=c&&c.nextSibling||null;k?k.parentNode.insertBefore(i,k):j.appendChild(i)}if(g&&h===!1&&g.parentNode.removeChild(g),i.styleSheet)try{i.styleSheet.cssText=b}catch(l){throw new Error("Couldn't reassign styleSheet.cssText.")}},currentScript:function(a){var b=a.document;return b.currentScript||function(){var a=b.getElementsByTagName("script");return a[a.length-1]}()}}},{"./utils":11}],4:[function(a,b,c){b.exports=function(a,b,c){var d=null;if("development"!==b.env)try{d="undefined"==typeof a.localStorage?null:a.localStorage}catch(e){}return{setCSS:function(a,b,e,f){if(d){c.info("saving "+a+" to cache.");try{d.setItem(a,f),d.setItem(a+":timestamp",b),e&&d.setItem(a+":vars",JSON.stringify(e))}catch(g){c.error('failed to save "'+a+'" to local storage for caching.')}}},getCSS:function(a,b,c){var e=d&&d.getItem(a),f=d&&d.getItem(a+":timestamp"),g=d&&d.getItem(a+":vars");if(c=c||{},f&&b.lastModified&&new Date(b.lastModified).valueOf()===new Date(f).valueOf()&&(!c&&!g||JSON.stringify(c)===g))return e}}}},{}],5:[function(a,b,c){var d=a("./utils"),e=a("./browser");b.exports=function(a,b,c){function f(b,f){var g,h,i="less-error-message:"+d.extractId(f||""),j='
  • {content}
  • ',k=a.document.createElement("div"),l=[],m=b.filename||f,n=m.match(/([^\/]+(\?.*)?)$/)[1];k.id=i,k.className="less-error-message",h="

    "+(b.type||"Syntax")+"Error: "+(b.message||"There is an error in your .less file")+'

    in '+n+" ";var o=function(a,b,c){void 0!==a.extract[b]&&l.push(j.replace(/\{line\}/,(parseInt(a.line,10)||0)+(b-1)).replace(/\{class\}/,c).replace(/\{content\}/,a.extract[b]))};b.line&&(o(b,0,""),o(b,1,"line"),o(b,2,""),h+="on line "+b.line+", column "+(b.column+1)+":

      "+l.join("")+"
    "),b.stack&&(b.extract||c.logLevel>=4)&&(h+="
    Stack Trace
    "+b.stack.split("\n").slice(1).join("
    ")),k.innerHTML=h,e.createCSS(a.document,[".less-error-message ul, .less-error-message li {","list-style-type: none;","margin-right: 15px;","padding: 4px 0;","margin: 0;","}",".less-error-message label {","font-size: 12px;","margin-right: 15px;","padding: 4px 0;","color: #cc7777;","}",".less-error-message pre {","color: #dd6666;","padding: 4px 0;","margin: 0;","display: inline-block;","}",".less-error-message pre.line {","color: #ff0000;","}",".less-error-message h3 {","font-size: 20px;","font-weight: bold;","padding: 15px 0 5px 0;","margin: 0;","}",".less-error-message a {","color: #10a","}",".less-error-message .error {","color: red;","font-weight: bold;","padding-bottom: 2px;","border-bottom: 1px dashed red;","}"].join("\n"),{title:"error-message"}),k.style.cssText=["font-family: Arial, sans-serif","border: 1px solid #e00","background-color: #eee","border-radius: 5px","-webkit-border-radius: 5px","-moz-border-radius: 5px","color: #e00","padding: 15px","margin-bottom: 15px"].join(";"),"development"===c.env&&(g=setInterval(function(){var b=a.document,c=b.body;c&&(b.getElementById(i)?c.replaceChild(k,b.getElementById(i)):c.insertBefore(k,c.firstChild),clearInterval(g))},10))}function g(b){var c=a.document.getElementById("less-error-message:"+d.extractId(b));c&&c.parentNode.removeChild(c)}function h(a){}function i(a){c.errorReporting&&"html"!==c.errorReporting?"console"===c.errorReporting?h(a):"function"==typeof c.errorReporting&&c.errorReporting("remove",a):g(a)}function j(a,d){var e="{line} {content}",f=a.filename||d,g=[],h=(a.type||"Syntax")+"Error: "+(a.message||"There is an error in your .less file")+" in "+f,i=function(a,b,c){void 0!==a.extract[b]&&g.push(e.replace(/\{line\}/,(parseInt(a.line,10)||0)+(b-1)).replace(/\{class\}/,c).replace(/\{content\}/,a.extract[b]))};a.line&&(i(a,0,""),i(a,1,"line"),i(a,2,""),h+=" on line "+a.line+", column "+(a.column+1)+":\n"+g.join("\n")),a.stack&&(a.extract||c.logLevel>=4)&&(h+="\nStack Trace\n"+a.stack),b.logger.error(h)}function k(a,b){c.errorReporting&&"html"!==c.errorReporting?"console"===c.errorReporting?j(a,b):"function"==typeof c.errorReporting&&c.errorReporting("add",a,b):f(a,b)}return{add:k,remove:i}}},{"./browser":3,"./utils":11}],6:[function(a,b,c){b.exports=function(b,c){var d=a("../less/environment/abstract-file-manager.js"),e={},f=function(){};return f.prototype=new d,f.prototype.alwaysMakePathsAbsolute=function(){return!0},f.prototype.join=function(a,b){return a?this.extractUrlParts(b,a).path:b},f.prototype.doXHR=function(a,d,e,f){function g(b,c,d){b.status>=200&&b.status<300?c(b.responseText,b.getResponseHeader("Last-Modified")):"function"==typeof d&&d(b.status,a)}var h=new XMLHttpRequest,i=!b.isFileProtocol||b.fileAsync;"function"==typeof h.overrideMimeType&&h.overrideMimeType("text/css"),c.debug("XHR: Getting '"+a+"'"),h.open("GET",a,i),h.setRequestHeader("Accept",d||"text/x-less, text/css; q=0.9, */*; q=0.5"),h.send(null),b.isFileProtocol&&!b.fileAsync?0===h.status||h.status>=200&&h.status<300?e(h.responseText):f(h.status,a):i?h.onreadystatechange=function(){4==h.readyState&&g(h,e,f)}:g(h,e,f)},f.prototype.supports=function(a,b,c,d){return!0},f.prototype.clearFileCache=function(){e={}},f.prototype.loadFile=function(a,b,c,d){b&&!this.isPathAbsolute(a)&&(a=b+a),a=c.ext?this.tryAppendExtension(a,c.ext):a,c=c||{};var f=this.extractUrlParts(a,window.location.href),g=f.url,h=this;return new Promise(function(a,b){if(c.useFileCache&&e[g])try{var d=e[g];return a({contents:d,filename:g,webInfo:{lastModified:new Date}})}catch(f){return b({filename:g,message:"Error loading file "+g+" error was "+f.message})}h.doXHR(g,c.mime,function(b,c){e[g]=b,a({contents:b,filename:g,webInfo:{lastModified:c}})},function(a,c){b({type:"File",message:"'"+c+"' wasn't found ("+a+")",href:g})})})},f}},{"../less/environment/abstract-file-manager.js":17}],7:[function(a,b,c){b.exports=function(){function b(){throw{type:"Runtime",message:"Image size functions are not supported in browser version of less"}}var c=a("./../less/functions/function-registry"),d={"image-size":function(a){return b(this,a),-1},"image-width":function(a){return b(this,a),-1},"image-height":function(a){return b(this,a),-1}};c.addMultiple(d)}},{"./../less/functions/function-registry":26}],8:[function(a,b,c){var d=a("./utils").addDataAttr,e=a("./browser");b.exports=function(b,c){function f(a){return JSON.parse(JSON.stringify(a||{}))}function g(a,b){var c=Array.prototype.slice.call(arguments,2);return function(){var d=c.concat(Array.prototype.slice.call(arguments,0));return a.apply(b,d)}}function h(a){for(var b,d=l.getElementsByTagName("style"),e=0;e=c&&console.log(a)},info:function(a){b.logLevel>=d&&console.log(a)},warn:function(a){b.logLevel>=e&&console.warn(a)},error:function(a){b.logLevel>=f&&console.error(a)}}]);for(var g=0;g0&&(a=a.slice(0,b)),b=a.lastIndexOf("/"),b<0&&(b=a.lastIndexOf("\\")),b<0?"":a.slice(0,b+1)},d.prototype.tryAppendExtension=function(a,b){return/(\.[a-z]*$)|([\?;].*)$/.test(a)?a:a+b},d.prototype.tryAppendLessExtension=function(a){return this.tryAppendExtension(a,".less")},d.prototype.supportsSync=function(){return!1},d.prototype.alwaysMakePathsAbsolute=function(){return!1},d.prototype.isPathAbsolute=function(a){return/^(?:[a-z-]+:|\/|\\|#)/i.test(a)},d.prototype.join=function(a,b){return a?a+b:b},d.prototype.pathDiff=function(a,b){var c,d,e,f,g=this.extractUrlParts(a),h=this.extractUrlParts(b),i="";if(g.hostPart!==h.hostPart)return"";for(d=Math.max(h.directories.length,g.directories.length),c=0;cparseInt(b[c])?-1:1;return 0},g.prototype.versionToString=function(a){for(var b="",c=0;c=0;h--){var i=g[h];if(i[f?"supportsSync":"supports"](a,b,c,e))return i}return null},e.prototype.addFileManager=function(a){this.fileManagers.push(a)},e.prototype.clearFileManagers=function(){this.fileManagers=[]},b.exports=e},{"../logger":37}],20:[function(a,b,c){var d=a("./function-registry"),e=a("../tree/anonymous"),f=a("../tree/keyword");d.addMultiple({"boolean":function(a){return a?f.True:f.False},"if":function(a,b,c){return a?b:c||new e}})},{"../tree/anonymous":48,"../tree/keyword":68,"./function-registry":26}],21:[function(a,b,c){function d(a,b,c){var d,f,g,h,i=b.alpha,j=c.alpha,k=[];g=j+i*(1-j);for(var l=0;l<3;l++)d=b.rgb[l]/255,f=c.rgb[l]/255,h=a(d,f),g&&(h=(j*f+i*(d-j*(d+f-h)))/g),k[l]=255*h;return new e(k,g)}var e=a("../tree/color"),f=a("./function-registry"),g={multiply:function(a,b){return a*b},screen:function(a,b){return a+b-a*b},overlay:function(a,b){return a*=2,a<=1?g.multiply(a,b):g.screen(a-1,b)},softlight:function(a,b){var c=1,d=a;return b>.5&&(d=1,c=a>.25?Math.sqrt(a):((16*a-12)*a+4)*a),a-(1-2*b)*d*(c-a)},hardlight:function(a,b){return g.overlay(b,a)},difference:function(a,b){return Math.abs(a-b)},exclusion:function(a,b){return a+b-2*a*b},average:function(a,b){return(a+b)/2},negation:function(a,b){return 1-Math.abs(a+b-1)}};for(var h in g)g.hasOwnProperty(h)&&(d[h]=d.bind(null,g[h]));f.addMultiple(d)},{"../tree/color":53,"./function-registry":26}],22:[function(a,b,c){function d(a){return Math.min(1,Math.max(0,a))}function e(a){return h.hsla(a.h,a.s,a.l,a.a)}function f(a){if(a instanceof i)return parseFloat(a.unit.is("%")?a.value/100:a.value);if("number"==typeof a)return a;throw{type:"Argument",message:"color functions take numbers as parameters"}}function g(a,b){return a instanceof i&&a.unit.is("%")?parseFloat(a.value*b/100):f(a)}var h,i=a("../tree/dimension"),j=a("../tree/color"),k=a("../tree/quoted"),l=a("../tree/anonymous"),m=a("./function-registry");h={rgb:function(a,b,c){return h.rgba(a,b,c,1)},rgba:function(a,b,c,d){var e=[a,b,c].map(function(a){return g(a,255)});return d=f(d),new j(e,d)},hsl:function(a,b,c){return h.hsla(a,b,c,1)},hsla:function(a,b,c,e){function g(a){return a=a<0?a+1:a>1?a-1:a,6*a<1?i+(j-i)*a*6:2*a<1?j:3*a<2?i+(j-i)*(2/3-a)*6:i}var i,j;return a=f(a)%360/360,b=d(f(b)),c=d(f(c)),e=d(f(e)),j=c<=.5?c*(b+1):c+b-c*b,i=2*c-j,h.rgba(255*g(a+1/3),255*g(a),255*g(a-1/3),e)},hsv:function(a,b,c){return h.hsva(a,b,c,1)},hsva:function(a,b,c,d){a=f(a)%360/360*360,b=f(b),c=f(c),d=f(d);var e,g;e=Math.floor(a/60%6),g=a/60-e;var i=[c,c*(1-b),c*(1-g*b),c*(1-(1-g)*b)],j=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]];return h.rgba(255*i[j[e][0]],255*i[j[e][1]],255*i[j[e][2]],d)},hue:function(a){return new i(a.toHSL().h)},saturation:function(a){return new i(100*a.toHSL().s,"%")},lightness:function(a){return new i(100*a.toHSL().l,"%")},hsvhue:function(a){return new i(a.toHSV().h)},hsvsaturation:function(a){return new i(100*a.toHSV().s,"%")},hsvvalue:function(a){return new i(100*a.toHSV().v,"%")},red:function(a){return new i(a.rgb[0])},green:function(a){return new i(a.rgb[1])},blue:function(a){return new i(a.rgb[2])},alpha:function(a){return new i(a.toHSL().a)},luma:function(a){return new i(a.luma()*a.alpha*100,"%")},luminance:function(a){var b=.2126*a.rgb[0]/255+.7152*a.rgb[1]/255+.0722*a.rgb[2]/255;return new i(b*a.alpha*100,"%")},saturate:function(a,b,c){if(!a.rgb)return null;var f=a.toHSL();return f.s+="undefined"!=typeof c&&"relative"===c.value?f.s*b.value/100:b.value/100,f.s=d(f.s),e(f)},desaturate:function(a,b,c){var f=a.toHSL();return f.s-="undefined"!=typeof c&&"relative"===c.value?f.s*b.value/100:b.value/100,f.s=d(f.s),e(f)},lighten:function(a,b,c){var f=a.toHSL();return f.l+="undefined"!=typeof c&&"relative"===c.value?f.l*b.value/100:b.value/100,f.l=d(f.l),e(f)},darken:function(a,b,c){var f=a.toHSL();return f.l-="undefined"!=typeof c&&"relative"===c.value?f.l*b.value/100:b.value/100,f.l=d(f.l),e(f)},fadein:function(a,b,c){var f=a.toHSL();return f.a+="undefined"!=typeof c&&"relative"===c.value?f.a*b.value/100:b.value/100,f.a=d(f.a),e(f)},fadeout:function(a,b,c){var f=a.toHSL();return f.a-="undefined"!=typeof c&&"relative"===c.value?f.a*b.value/100:b.value/100,f.a=d(f.a),e(f)},fade:function(a,b){var c=a.toHSL();return c.a=b.value/100,c.a=d(c.a),e(c)},spin:function(a,b){var c=a.toHSL(),d=(c.h+b.value)%360;return c.h=d<0?360+d:d,e(c)},mix:function(a,b,c){a.toHSL&&b.toHSL||(console.log(b.type),console.dir(b)),c||(c=new i(50));var d=c.value/100,e=2*d-1,f=a.toHSL().a-b.toHSL().a,g=((e*f==-1?e:(e+f)/(1+e*f))+1)/2,h=1-g,k=[a.rgb[0]*g+b.rgb[0]*h,a.rgb[1]*g+b.rgb[1]*h,a.rgb[2]*g+b.rgb[2]*h],l=a.alpha*d+b.alpha*(1-d);return new j(k,l)},greyscale:function(a){return h.desaturate(a,new i(100))},contrast:function(a,b,c,d){if(!a.rgb)return null;if("undefined"==typeof c&&(c=h.rgba(255,255,255,1)),"undefined"==typeof b&&(b=h.rgba(0,0,0,1)),b.luma()>c.luma()){var e=c;c=b,b=e}return d="undefined"==typeof d?.43:f(d),a.luma()=v&&this.context.ieCompat!==!1?(h.warn("Skipped data-uri embedding of "+j+" because its size ("+u.length+" characters) exceeds IE8-safe "+v+" characters!"),g(this,f||a)):new d(new c('"'+u+'"',u,(!1),this.index,this.currentFileInfo),this.index,this.currentFileInfo)})}},{"../logger":37,"../tree/quoted":77,"../tree/url":82,"../utils":86,"./function-registry":26}],24:[function(a,b,c){var d=a("../tree/keyword"),e=a("./function-registry"),f={eval:function(){var a=this.value_,b=this.error_;if(b)throw b;if(null!=a)return a?d.True:d.False},value:function(a){this.value_=a},error:function(a){this.error_=a},reset:function(){this.value_=this.error_=null}};e.add("default",f.eval.bind(f)),b.exports=f},{"../tree/keyword":68,"./function-registry":26}],25:[function(a,b,c){var d=a("../tree/expression"),e=function(a,b,c,d){this.name=a.toLowerCase(),this.index=c,this.context=b,this.currentFileInfo=d,this.func=b.frames[0].functionRegistry.get(this.name)};e.prototype.isValid=function(){return Boolean(this.func)},e.prototype.call=function(a){return Array.isArray(a)&&(a=a.filter(function(a){return"Comment"!==a.type}).map(function(a){if("Expression"===a.type){var b=a.value.filter(function(a){return"Comment"!==a.type});return 1===b.length?b[0]:new d(b)}return a})),this.func.apply(this,a)},b.exports=e},{"../tree/expression":62}],26:[function(a,b,c){function d(a){return{_data:{},add:function(a,b){a=a.toLowerCase(),this._data.hasOwnProperty(a),this._data[a]=b},addMultiple:function(a){Object.keys(a).forEach(function(b){this.add(b,a[b])}.bind(this))},get:function(b){return this._data[b]||a&&a.get(b)},getLocalFunctions:function(){return this._data},inherit:function(){return d(this)},create:function(a){return d(a)}}}b.exports=d(null)},{}],27:[function(a,b,c){b.exports=function(b){var c={functionRegistry:a("./function-registry"),functionCaller:a("./function-caller")};return a("./boolean"),a("./default"),a("./color"),a("./color-blending"),a("./data-uri")(b),a("./math"),a("./number"),a("./string"),a("./svg")(b),a("./types"),c}},{"./boolean":20,"./color":22,"./color-blending":21,"./data-uri":23,"./default":24,"./function-caller":25,"./function-registry":26,"./math":29,"./number":30,"./string":31,"./svg":32,"./types":33}],28:[function(a,b,c){var d=a("../tree/dimension"),e=function(){};e._math=function(a,b,c){if(!(c instanceof d))throw{ +type:"Argument",message:"argument must be a number"};return null==b?b=c.unit:c=c.unify(),new d(a(parseFloat(c.value)),b)},b.exports=e},{"../tree/dimension":60}],29:[function(a,b,c){var d=a("./function-registry"),e=a("./math-helper.js"),f={ceil:null,floor:null,sqrt:null,abs:null,tan:"",sin:"",cos:"",atan:"rad",asin:"rad",acos:"rad"};for(var g in f)f.hasOwnProperty(g)&&(f[g]=e._math.bind(null,Math[g],f[g]));f.round=function(a,b){var c="undefined"==typeof b?0:b.value;return e._math(function(a){return a.toFixed(c)},null,a)},d.addMultiple(f)},{"./function-registry":26,"./math-helper.js":28}],30:[function(a,b,c){var d=a("../tree/dimension"),e=a("../tree/anonymous"),f=a("./function-registry"),g=a("./math-helper.js"),h=function(a,b){switch(b=Array.prototype.slice.call(b),b.length){case 0:throw{type:"Argument",message:"one or more arguments required"}}var c,f,g,h,i,j,k,l,m=[],n={};for(c=0;ci.value)&&(m[f]=g);else{if(void 0!==k&&j!==k)throw{type:"Argument",message:"incompatible types"};n[j]=m.length,m.push(g)}else Array.isArray(b[c].value)&&Array.prototype.push.apply(b,Array.prototype.slice.call(b[c].value));return 1==m.length?m[0]:(b=m.map(function(a){return a.toCSS(this.context)}).join(this.context.compress?",":", "),new e((a?"min":"max")+"("+b+")"))};f.addMultiple({min:function(){return h(!0,arguments)},max:function(){return h(!1,arguments)},convert:function(a,b){return a.convertTo(b.value)},pi:function(){return new d(Math.PI)},mod:function(a,b){return new d(a.value%b.value,a.unit)},pow:function(a,b){if("number"==typeof a&&"number"==typeof b)a=new d(a),b=new d(b);else if(!(a instanceof d&&b instanceof d))throw{type:"Argument",message:"arguments must be numbers"};return new d(Math.pow(a.value,b.value),a.unit)},percentage:function(a){var b=g._math(function(a){return 100*a},"%",a);return b}})},{"../tree/anonymous":48,"../tree/dimension":60,"./function-registry":26,"./math-helper.js":28}],31:[function(a,b,c){var d=a("../tree/quoted"),e=a("../tree/anonymous"),f=a("../tree/javascript"),g=a("./function-registry");g.addMultiple({e:function(a){return new e(a instanceof f?a.evaluated:a.value)},escape:function(a){return new e(encodeURI(a.value).replace(/=/g,"%3D").replace(/:/g,"%3A").replace(/#/g,"%23").replace(/;/g,"%3B").replace(/\(/g,"%28").replace(/\)/g,"%29"))},replace:function(a,b,c,e){var f=a.value;return c="Quoted"===c.type?c.value:c.toCSS(),f=f.replace(new RegExp(b.value,e?e.value:""),c),new d(a.quote||"",f,a.escaped)},"%":function(a){for(var b=Array.prototype.slice.call(arguments,1),c=a.value,e=0;e",k=0;k";return j+="',j=encodeURIComponent(j),j="data:image/svg+xml,"+j,new g(new f("'"+j+"'",j,(!1),this.index,this.currentFileInfo),this.index,this.currentFileInfo)})}},{"../tree/color":53,"../tree/dimension":60,"../tree/expression":62,"../tree/quoted":77,"../tree/url":82,"./function-registry":26}],33:[function(a,b,c){var d=a("../tree/keyword"),e=a("../tree/detached-ruleset"),f=a("../tree/dimension"),g=a("../tree/color"),h=a("../tree/quoted"),i=a("../tree/anonymous"),j=a("../tree/url"),k=a("../tree/operation"),l=a("./function-registry"),m=function(a,b){return a instanceof b?d.True:d.False},n=function(a,b){if(void 0===b)throw{type:"Argument",message:"missing the required second argument to isunit."};if(b="string"==typeof b.value?b.value:b,"string"!=typeof b)throw{type:"Argument",message:"Second argument to isunit should be a unit or a string."};return a instanceof f&&a.unit.is(b)?d.True:d.False},o=function(a){var b=Array.isArray(a.value)?a.value:Array(a);return b};l.addMultiple({isruleset:function(a){return m(a,e)},iscolor:function(a){return m(a,g)},isnumber:function(a){return m(a,f)},isstring:function(a){return m(a,h)},iskeyword:function(a){return m(a,d)},isurl:function(a){return m(a,j)},ispixel:function(a){return n(a,"px")},ispercentage:function(a){return n(a,"%")},isem:function(a){return n(a,"em")},isunit:n,unit:function(a,b){if(!(a instanceof f))throw{type:"Argument",message:"the first argument to unit must be a number"+(a instanceof k?". Have you forgotten parenthesis?":"")};return b=b?b instanceof d?b.value:b.toCSS():"",new f(a.value,b)},"get-unit":function(a){return new i(a.unit)},extract:function(a,b){return b=b.value-1,o(a)[b]},length:function(a){return new f(o(a).length)}})},{"../tree/anonymous":48,"../tree/color":53,"../tree/detached-ruleset":59,"../tree/dimension":60,"../tree/keyword":68,"../tree/operation":74,"../tree/quoted":77,"../tree/url":82,"./function-registry":26}],34:[function(a,b,c){var d=a("./contexts"),e=a("./parser/parser"),f=a("./less-error"),g=a("./utils");"undefined"==typeof Promise?a("promise"):Promise;b.exports=function(a){var b=function(a,b,c){this.less=a,this.rootFilename=c.filename,this.paths=b.paths||[],this.contents={},this.contentsIgnoredChars={},this.mime=b.mime,this.error=null,this.context=b,this.queue=[],this.files={}};return b.prototype.push=function(b,c,h,i,j){var k=this,l=this.context.pluginManager.Loader;this.queue.push(b);var m=function(a,c,d){k.queue.splice(k.queue.indexOf(b),1);var e=d===k.rootFilename;i.optional&&a?j(null,{rules:[]},!1,null):(k.files[d]||(k.files[d]={root:c,options:i}),a&&!k.error&&(k.error=a),j(a,c,e,d))},n={relativeUrls:this.context.relativeUrls,entryPath:h.entryPath,rootpath:h.rootpath,rootFilename:h.rootFilename},o=a.getFileManager(b,h.currentDirectory,this.context,a);if(!o)return void m({message:"Could not find a file-manager for "+b});var p,q=function(a){var b,c=a.filename,g=a.contents.replace(/^\uFEFF/,"");n.currentDirectory=o.getPath(c),n.relativeUrls&&(n.rootpath=o.join(k.context.rootpath||"",o.pathDiff(n.currentDirectory,n.entryPath)),!o.isPathAbsolute(n.rootpath)&&o.alwaysMakePathsAbsolute()&&(n.rootpath=o.join(n.entryPath,n.rootpath))),n.filename=c;var j=new d.Parse(k.context);j.processImports=!1,k.contents[c]=g,(h.reference||i.reference)&&(n.reference=!0),i.isPlugin?(b=l.evalPlugin(g,j,k,i.pluginArgs,n),b instanceof f?m(b,null,c):m(null,b,c)):i.inline?m(null,g,c):!k.files[c]||k.files[c].options.multiple||i.multiple?new e(j,k,n).parse(g,function(a,b){m(a,b,c)}):m(null,k.files[c].root,c)},r=g.clone(this.context);c&&(r.ext=i.isPlugin?".js":".less"),p=i.isPlugin?l.loadPlugin(b,h.currentDirectory,r,a,o):o.loadFile(b,h.currentDirectory,r,a,function(a,b){a?m(a):q(b)}),p&&p.then(q,m)},b}},{"./contexts":12,"./less-error":36,"./parser/parser":42,"./utils":86,promise:void 0}],35:[function(a,b,c){b.exports=function(b,c){var d,e,f,g,h,i,j={version:[3,0,0],data:a("./data"),tree:a("./tree"),Environment:h=a("./environment/environment"),AbstractFileManager:a("./environment/abstract-file-manager"),AbstractPluginLoader:a("./environment/abstract-plugin-loader"),environment:b=new h(b,c),visitors:a("./visitors"),Parser:a("./parser/parser"),functions:a("./functions")(b),contexts:a("./contexts"),SourceMapOutput:d=a("./source-map-output")(b),SourceMapBuilder:e=a("./source-map-builder")(d,b),ParseTree:f=a("./parse-tree")(e),ImportManager:g=a("./import-manager")(b),render:a("./render")(b,f,g),parse:a("./parse")(b,f,g),LessError:a("./less-error"),transformTree:a("./transform-tree"),utils:a("./utils"),PluginManager:a("./plugin-manager"),logger:a("./logger")},k=function(a){return function(){var b=Object.create(a.prototype);return a.apply(b,Array.prototype.slice.call(arguments,0)),b}},l=Object.create(j);for(var m in j.tree)if(i=j.tree[m],"function"==typeof i)l[m.toLowerCase()]=k(i);else{l[m]=Object.create(null);for(var n in i)l[m][n.toLowerCase()]=k(i[n])}return l}},{"./contexts":12,"./data":14,"./environment/abstract-file-manager":17,"./environment/abstract-plugin-loader":18,"./environment/environment":19,"./functions":27,"./import-manager":34,"./less-error":36,"./logger":37,"./parse":39,"./parse-tree":38,"./parser/parser":42,"./plugin-manager":43,"./render":44,"./source-map-builder":45,"./source-map-output":46,"./transform-tree":47,"./tree":65,"./utils":86,"./visitors":90}],36:[function(a,b,c){var d=a("./utils"),e=b.exports=function(a,b,c){Error.call(this);var e=a.filename||c;if(this.message=a.message,this.stack=a.stack,b&&e){var f=b.contents[e],g=d.getLocation(a.index,f),h=g.line,i=g.column,j=a.call&&d.getLocation(a.call,f).line,k=f.split("\n");if(this.type=a.type||"Syntax",this.filename=e,this.index=a.index,this.line="number"==typeof h?h+1:null,this.column=i,!this.line&&this.stack){var l=this.stack.match(/(|Function):(\d+):(\d+)/);l&&(l[2]&&(this.line=parseInt(l[2])-2),l[3]&&(this.column=parseInt(l[3])))}this.callLine=j+1,this.callExtract=k[j],this.extract=[k[this.line-2],k[this.line-1],k[this.line]]}};if("undefined"==typeof Object.create){var f=function(){};f.prototype=Error.prototype,e.prototype=new f}else e.prototype=Object.create(Error.prototype);e.prototype.constructor=e,e.prototype.toString=function(a){a=a||{};var b="",c=this.extract||[],d=[],e=function(a){return a};if(a.stylize){var f=typeof a.stylize;if("function"!==f)throw Error("options.stylize should be a function, got a "+f+"!");e=a.stylize}if(null!==this.line){if("string"==typeof c[0]&&d.push(e(this.line-1+" "+c[0],"grey")),"string"==typeof c[1]){var g=this.line+" ";c[1]&&(g+=c[1].slice(0,this.column)+e(e(e(c[1].substr(this.column,1),"bold")+c[1].slice(this.column+1),"red"),"inverse")),d.push(g)}"string"==typeof c[2]&&d.push(e(this.line+1+" "+c[2],"grey")),d=d.join("\n")+e("","reset")+"\n"}return b+=e(this.type+"Error: "+this.message,"red"),this.filename&&(b+=e(" in ","red")+this.filename),this.line&&(b+=e(" on line "+this.line+", column "+(this.column+1)+":","grey")),b+="\n"+d,this.callLine&&(b+=e("from ","red")+(this.filename||"")+"/n",b+=e(this.callLine,"grey")+" "+this.callExtract+"/n"),b}},{"./utils":86}],37:[function(a,b,c){b.exports={error:function(a){this._fireEvent("error",a)},warn:function(a){this._fireEvent("warn",a)},info:function(a){this._fireEvent("info",a)},debug:function(a){this._fireEvent("debug",a)},addListener:function(a){this._listeners.push(a)},removeListener:function(a){for(var b=0;b=97&&j<=122||j<34))switch(j){case 40:o++,e=h;continue;case 41:if(--o<0)return b("missing opening `(`",h);continue;case 59:o||c();continue;case 123:n++,d=h;continue;case 125:if(--n<0)return b("missing opening `{`",h);n||o||c();continue;case 92:if(h96)){if(k==j){l=1;break}if(92==k){if(h==m-1)return b("unescaped `\\`",h);h++}}if(l)continue;return b("unmatched `"+String.fromCharCode(j)+"`",i);case 47:if(o||h==m-1)continue;if(k=a.charCodeAt(h+1),47==k)for(h+=2;hd&&g>f?b("missing closing `}` or `*/`",d):b("missing closing `}`",d):0!==o?b("missing closing `)`",e):(c(!0),p)}},{}],41:[function(a,b,c){var d=a("./chunker");b.exports=function(){function a(d){for(var e,f,j,p=k.i,q=c,s=k.i-i,t=k.i+h.length-s,u=k.i+=d,v=b;k.i=0){j={index:k.i,text:v.substr(k.i,x+2-k.i),isLineComment:!1},k.i+=j.text.length-1,k.commentStore.push(j);continue}}break}if(e!==l&&e!==n&&e!==m&&e!==o)break}if(h=h.slice(d+k.i-u+s),i=k.i,!h.length){if(ce||k.i===e&&a&&!f)&&(e=k.i,f=a);var b=j.pop();h=b.current,i=k.i=b.i,c=b.j},k.forget=function(){j.pop()},k.isWhitespace=function(a){var c=k.i+(a||0),d=b.charCodeAt(c);return d===l||d===o||d===m||d===n},k.$re=function(b){k.i>i&&(h=h.slice(k.i-i),i=k.i);var c=b.exec(h);return c?(a(c[0].length),"string"==typeof c?c:1===c.length?c[0]:c):null},k.$char=function(c){return b.charAt(k.i)!==c?null:(a(1),c)},k.$str=function(c){for(var d=c.length,e=0;es||a=b.length;return k.i=b.length-1,furthestChar:b[k.i]}},k}},{"./chunker":40}],42:[function(a,b,c){var d=a("../less-error"),e=a("../tree"),f=a("../visitors"),g=a("./parser-input"),h=a("../utils"),i=a("../functions/function-registry"),j=function k(a,b,c){function j(a,e){throw new d({index:q.i,filename:c.filename,type:e||"Syntax",message:a},b)}function l(a,b,c){var d=a instanceof Function?a.call(p):q.$re(a);return d?d:void j(b||("string"==typeof a?"expected '"+a+"' got '"+q.currentChar()+"'":"unexpected token"))}function m(a,b){return q.$char(a)?a:void j(b||"expected '"+a+"' got '"+q.currentChar()+"'")}function n(a){var b=c.filename;return{lineNumber:h.getLocation(a,q.getInput()).line+1,fileName:b}}function o(a,c,e,f,g){var h,i=[],j=q;try{j.start(a,!1,function(a,b){g({message:a,index:b+e})});for(var k,l,m=0;k=c[m];m++)l=j.i,h=p[k](),h?(h._index=l+e,h._fileInfo=f,i.push(h)):i.push(null);var n=j.end();n.isFinished?g(null,i):g(!0,null)}catch(o){throw new d({index:o.index+e,message:o.message},b,f.filename)}}var p,q=g();return{parserInput:q,imports:b,fileInfo:c,parseNode:o,parse:function(g,h,j){var l,m,n,o,p=null,r="";if(m=j&&j.globalVars?k.serializeVars(j.globalVars)+"\n":"",n=j&&j.modifyVars?"\n"+k.serializeVars(j.modifyVars):"",a.pluginManager)for(var s=a.pluginManager.getPreProcessors(),t=0;t")}return b&&(q.$char("(")&&(h=this.args(!0).args,m(")")),p.important()&&(j=!0),p.end())?(q.forget(),new e.mixin.Call(b,h,k,c,j)):void q.restore()}},args:function(a){var b,c,d,f,g,h,i,k=p.entities,l={args:null,variadic:!1},m=[],n=[],o=[];for(q.save();;){if(a)h=p.detachedRuleset()||p.expression();else{if(q.commentStore.length=0,q.$str("...")){l.variadic=!0,q.$char(";")&&!b&&(b=!0),(b?n:o).push({variadic:!0});break}h=k.variable()||k.property()||k.literal()||k.keyword()}if(!h)break;f=null,h.throwAwayComments&&h.throwAwayComments(),g=h;var r=null;if(a?h.value&&1==h.value.length&&(r=h.value[0]):r=h,r&&(r instanceof e.Variable||r instanceof e.Property))if(q.$char(":")){if(m.length>0&&(b&&j("Cannot mix ; and , as delimiter types"),c=!0),g=p.detachedRuleset()||p.expression(),!g){if(!a)return q.restore(),l.args=[],l;j("could not understand value for named argument")}f=d=r.name}else if(q.$str("...")){if(!a){l.variadic=!0,q.$char(";")&&!b&&(b=!0),(b?n:o).push({name:h.name,variadic:!0});break}i=!0}else a||(d=f=r.name,g=null);g&&m.push(g),o.push({name:f,value:g,expand:i}),q.$char(",")||(q.$char(";")||b)&&(c&&j("Cannot mix ; and , as delimiter types"),b=!0,m.length>1&&(g=new e.Value(m)),n.push({name:d,value:g,expand:i}),d=null,m=[],c=!1)}return q.forget(),l.args=b?n:o,l},definition:function(){var a,b,c,d,f=[],g=!1;if(!("."!==q.currentChar()&&"#"!==q.currentChar()||q.peek(/^[^{]*\}/)))if(q.save(),b=q.$re(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/)){a=b[1];var h=this.args(!1);if(f=h.args,g=h.variadic,!q.$char(")"))return void q.restore("Missing closing ')'");if(q.commentStore.length=0,q.$str("when")&&(d=l(p.conditions,"expected condition")),c=p.block())return q.forget(),new e.mixin.Definition(a,f,c,d,g);q.restore()}else q.forget()}},entity:function(){var a=this.entities;return this.comment()||a.literal()||a.variable()||a.url()||a.property()||a.call()||a.keyword()||a.javascript()},end:function(){return q.$char(";")||q.peek("}")},ieAlpha:function(){var a;if(q.$re(/^opacity=/i))return a=q.$re(/^\d+/),a||(a=l(p.entities.variable,"Could not parse alpha"),a="@{"+a.name.slice(1)+"}"),m(")"),new e.Quoted("","alpha(opacity="+a+")")},element:function(){var a,b,d,f=q.i;if(b=this.combinator(),a=q.$re(/^(?:\d+\.\d+|\d+)%/)||q.$re(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/)||q.$char("*")||q.$char("&")||this.attribute()||q.$re(/^\([^&()@]+\)/)||q.$re(/^[\.#:](?=@)/)||this.entities.variableCurly(),a||(q.save(),q.$char("(")?(d=this.selector(!1))&&q.$char(")")?(a=new e.Paren(d),q.forget()):q.restore("Missing closing ')'"):q.forget()),a)return new e.Element(b,a,f,c)},combinator:function(){var a=q.currentChar();if("/"===a){q.save();var b=q.$re(/^\/[a-z]+\//i);if(b)return q.forget(),new e.Combinator(b);q.restore()}if(">"===a||"+"===a||"~"===a||"|"===a||"^"===a){for(q.i++,"^"===a&&"^"===q.currentChar()&&(a="^^",q.i++);q.isWhitespace();)q.i++;return new e.Combinator(a)}return new e.Combinator(q.isWhitespace(-1)?" ":null)},selector:function(a){var b,d,f,g,h,i,k,m=q.i;for(a=a!==!1;(a&&(d=this.extend())||a&&(i=q.$str("when"))||(g=this.element()))&&(i?k=l(this.conditions,"expected condition"):k?j("CSS guard can only be used at the end of selector"):d?h=h?h.concat(d):d:(h&&j("Extend can only be used at the end of selector"),f=q.currentChar(),b?b.push(g):b=[g],g=null),"{"!==f&&"}"!==f&&";"!==f&&","!==f&&")"!==f););return b?new e.Selector(b,h,k,m,c):void(h&&j("Extend must be used to extend a selector, it cannot be used on its own"))},attribute:function(){if(q.$char("[")){var a,b,c,d=this.entities;return(a=d.variableCurly())||(a=l(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/)),c=q.$re(/^[|~*$^]?=/),c&&(b=d.quoted()||q.$re(/^[0-9]+%/)||q.$re(/^[\w-]+/)||d.variableCurly()),m("]"),new e.Attribute(a,c,b)}},block:function(){var a;if(q.$char("{")&&(a=this.primary())&&q.$char("}"))return a},blockRuleset:function(){var a=this.block();return a&&(a=new e.Ruleset(null,a)),a},detachedRuleset:function(){var a=this.blockRuleset();if(a)return new e.DetachedRuleset(a)},ruleset:function(){var b,c,d,f;for(q.save(),a.dumpLineNumbers&&(f=n(q.i));;){if(c=this.selector(),!c)break;if(b?b.push(c):b=[c],q.commentStore.length=0,c.condition&&b.length>1&&j("Guards are only currently allowed on a single selector."),!q.$char(","))break;c.condition&&j("Guards are only currently allowed on a single selector."),q.commentStore.length=0}if(b&&(d=this.block())){q.forget();var g=new e.Ruleset(b,d,a.strictImports);return a.dumpLineNumbers&&(g.debugInfo=f),g}q.restore()},declaration:function(){var a,b,d,f,g,h=q.i,i=q.currentChar();if("."!==i&&"#"!==i&&"&"!==i&&":"!==i)if(q.save(),a=this.variable()||this.ruleProperty()){if(g="string"==typeof a,g&&(b=this.detachedRuleset()),q.commentStore.length=0,!b){if(f=!g&&a.length>1&&a.pop().value,b=this.anonymousValue())return q.forget(),new e.Declaration(a,b,(!1),f,h,c);b||(b=this.value()),d=this.important()}if(b&&this.end())return q.forget(),new e.Declaration(a,b,d,f,h,c);q.restore()}else q.restore()},anonymousValue:function(){var a=q.i,b=q.$re(/^([^@\$+\/'"*`(;{}-]*);/);if(b)return new e.Anonymous(b[1],a)},"import":function(){var a,b,d=q.i,f=q.$re(/^@import?\s+/);if(f){var g=(f?this.importOptions():null)||{};if(a=this.entities.quoted()||this.entities.url())return b=this.mediaFeatures(),q.$char(";")||(q.i=d,j("missing semi-colon or unrecognised media features on import")),b=b&&new e.Value(b),new e.Import(a,b,g,d,c);q.i=d,j("malformed import statement")}},importOptions:function(){var a,b,c,d={};if(!q.$char("("))return null;do if(a=this.importOption()){switch(b=a,c=!0,b){case"css":b="less",c=!1;break;case"once":b="multiple",c=!1}if(d[b]=c,!q.$char(","))break}while(a);return m(")"),d},importOption:function(){var a=q.$re(/^(less|css|multiple|once|inline|reference|optional)/);if(a)return a[1]},mediaFeature:function(){var a,b,d=this.entities,f=[];q.save();do a=d.keyword()||d.variable(),a?f.push(a):q.$char("(")&&(b=this.property(),a=this.value(),q.$char(")")?b&&a?f.push(new e.Paren(new e.Declaration(b,a,null,null,q.i,c,(!0)))):a?f.push(new e.Paren(a)):j("badly formed media feature definition"):j("Missing closing ')'","Parse"));while(a);if(q.forget(),f.length>0)return new e.Expression(f)},mediaFeatures:function(){var a,b=this.entities,c=[];do if(a=this.mediaFeature()){if(c.push(a),!q.$char(","))break}else if(a=b.variable(),a&&(c.push(a),!q.$char(",")))break;while(a);return c.length>0?c:null},media:function(){var b,d,f,g,h=q.i;return a.dumpLineNumbers&&(g=n(h)),q.save(),q.$str("@media")?(b=this.mediaFeatures(),d=this.block(),d||j("media definitions require block statements after any features"),q.forget(),f=new e.Media(d,b,h,c),a.dumpLineNumbers&&(f.debugInfo=g),f):void q.restore()},plugin:function(){ +var a,b,d,f=q.i,g=q.$re(/^@plugin?\s+/);if(g){if(b=this.pluginArgs(),d=b?{pluginArgs:b,isPlugin:!0}:{isPlugin:!0},a=this.entities.quoted()||this.entities.url())return q.$char(";")||(q.i=f,j("missing semi-colon on @plugin")),new e.Import(a,null,d,f,c);q.i=f,j("malformed @plugin statement")}},pluginArgs:function(){if(q.save(),!q.$char("("))return q.restore(),null;var a=q.$re(/^\s*([^\);]+)\)\s*/);return a[1]?(q.forget(),a[1].trim()):(q.restore(),null)},atrule:function(){var b,d,f,g,h,i,k,l=q.i,m=!0,o=!0;if("@"===q.currentChar()){if(d=this["import"]()||this.plugin()||this.media())return d;if(q.save(),b=q.$re(/^@[a-z-]+/)){switch(g=b,"-"==b.charAt(1)&&b.indexOf("-",2)>0&&(g="@"+b.slice(b.indexOf("-",2)+1)),g){case"@charset":h=!0,m=!1;break;case"@namespace":i=!0,m=!1;break;case"@keyframes":case"@counter-style":h=!0;break;case"@document":case"@supports":k=!0,o=!1;break;default:k=!0}return q.commentStore.length=0,h?(d=this.entity(),d||j("expected "+b+" identifier")):i?(d=this.expression(),d||j("expected "+b+" expression")):k&&(d=(q.$re(/^[^{;]+/)||"").trim(),m="{"==q.currentChar(),d&&(d=new e.Anonymous(d))),m&&(f=this.blockRuleset()),f||!m&&d&&q.$char(";")?(q.forget(),new e.AtRule(b,d,f,l,c,a.dumpLineNumbers?n(l):null,o)):void q.restore("at-rule options not recognised")}}},value:function(){var a,b=[],c=q.i;do if(a=this.expression(),a&&(b.push(a),!q.$char(",")))break;while(a);if(b.length>0)return new e.Value(b,c)},important:function(){if("!"===q.currentChar())return q.$re(/^! *important/)},sub:function(){var a,b;return q.save(),q.$char("(")?(a=this.addition(),a&&q.$char(")")?(q.forget(),b=new e.Expression([a]),b.parens=!0,b):void q.restore("Expected ')'")):void q.restore()},multiplication:function(){var a,b,c,d,f;if(a=this.operand()){for(f=q.isWhitespace(-1);;){if(q.peek(/^\/[*\/]/))break;if(q.save(),c=q.$char("/")||q.$char("*"),!c){q.forget();break}if(b=this.operand(),!b){q.restore();break}q.forget(),a.parensInOp=!0,b.parensInOp=!0,d=new e.Operation(c,[d||a,b],f),f=q.isWhitespace(-1)}return d||a}},addition:function(){var a,b,c,d,f;if(a=this.multiplication()){for(f=q.isWhitespace(-1);;){if(c=q.$re(/^[-+]\s+/)||!f&&(q.$char("+")||q.$char("-")),!c)break;if(b=this.multiplication(),!b)break;a.parensInOp=!0,b.parensInOp=!0,d=new e.Operation(c,[d||a,b],f),f=q.isWhitespace(-1)}return d||a}},conditions:function(){var a,b,c,d=q.i;if(a=this.condition()){for(;;){if(!q.peek(/^,\s*(not\s*)?\(/)||!q.$char(","))break;if(b=this.condition(),!b)break;c=new e.Condition("or",c||a,b,d)}return c||a}},condition:function(){function a(){return q.$str("or")}var b,c,d;if(b=this.conditionAnd(this)){if(c=a()){if(d=this.condition(),!d)return;b=new e.Condition(c,b,d)}return b}},conditionAnd:function(){function a(a){return a.negatedCondition()||a.parenthesisCondition()}function b(){return q.$str("and")}var c,d,f;if(c=a(this)){if(d=b()){if(f=this.conditionAnd(),!f)return;c=new e.Condition(d,c,f)}return c}},negatedCondition:function(){if(q.$str("not")){var a=this.parenthesisCondition();return a&&(a.negate=!a.negate),a}},parenthesisCondition:function(){function a(a){var b;return q.save(),(b=a.condition())&&q.$char(")")?(q.forget(),b):void q.restore()}var b;return q.save(),q.$str("(")?(b=a(this))?(q.forget(),b):(b=this.atomicCondition())?q.$char(")")?(q.forget(),b):void q.restore("expected ')' got '"+q.currentChar()+"'"):void q.restore():void q.restore()},atomicCondition:function(){var a,b,c,d,f=this.entities,g=q.i;if(a=this.addition()||f.keyword()||f.quoted())return q.$char(">")?d=q.$char("=")?">=":">":q.$char("<")?d=q.$char("=")?"<=":"<":q.$char("=")&&(d=q.$char(">")?"=>":q.$char("<")?"=<":"="),d?(b=this.addition()||f.keyword()||f.quoted(),b?c=new e.Condition(d,a,b,g,(!1)):j("expected expression")):c=new e.Condition("=",a,new e.Keyword("true"),g,(!1)),c},operand:function(){var a,b=this.entities;q.peek(/^-[@\$\(]/)&&(a=q.$char("-"));var c=this.sub()||b.dimension()||b.color()||b.variable()||b.property()||b.call()||b.colorKeyword();return a&&(c.parensInOp=!0,c=new e.Negative(c)),c},expression:function(){var a,b,c=[],d=q.i;do a=this.comment(),a?c.push(a):(a=this.addition()||this.entity(),a&&(c.push(a),q.peek(/^\/[\/*]/)||(b=q.$char("/"),b&&c.push(new e.Anonymous(b,d)))));while(a);if(c.length>0)return new e.Expression(c)},property:function(){var a=q.$re(/^(\*?-?[_a-zA-Z0-9-]+)\s*:/);if(a)return a[1]},ruleProperty:function(){function a(a){var b=q.i,c=q.$re(a);if(c)return g.push(b),f.push(c[1])}var b,d,f=[],g=[];q.save();var h=q.$re(/^([_a-zA-Z0-9-]+)\s*:/);if(h)return f=[new e.Keyword(h[1])],q.forget(),f;for(a(/^(\*?)/);;)if(!a(/^((?:[\w-]+)|(?:[@\$]\{[\w-]+\}))/))break;if(f.length>1&&a(/^((?:\+_|\+)?)\s*:/)){for(q.forget(),""===f[0]&&(f.shift(),g.shift()),d=0;d=b);c++);this.preProcessors.splice(c,0,{preProcessor:a,priority:b})},e.prototype.addPostProcessor=function(a,b){var c;for(c=0;c=b);c++);this.postProcessors.splice(c,0,{postProcessor:a,priority:b})},e.prototype.addFileManager=function(a){this.fileManagers.push(a)},e.prototype.getPreProcessors=function(){for(var a=[],b=0;b0){var d,e=JSON.stringify(this._sourceMapGenerator.toJSON());this.sourceMapURL?d=this.sourceMapURL:this._sourceMapFilename&&(d=this._sourceMapFilename),this.sourceMapURL=d,this.sourceMap=e}return this._css.join("")},b}},{}],47:[function(a,b,c){var d=a("./contexts"),e=a("./visitors"),f=a("./tree");b.exports=function(a,b){b=b||{};var c,g=b.variables,h=new d.Eval(b);"object"!=typeof g||Array.isArray(g)||(g=Object.keys(g).map(function(a){var b=g[a];return b instanceof f.Value||(b instanceof f.Expression||(b=new f.Expression([b])),b=new f.Value([b])),new f.Declaration("@"+a,b,(!1),null,0)}),h.frames=[new f.Ruleset(null,g)]);var i,j,k=[new e.JoinSelectorVisitor,new e.MarkVisibleSelectorsVisitor((!0)),new e.ExtendVisitor,new e.ToCSSVisitor({compress:Boolean(b.compress)})];if(b.pluginManager)for(j=b.pluginManager.visitor(),j.first();i=j.get();)i.isPreEvalVisitor&&i.run(a);c=a.eval(h);for(var l=0;l.5?j/(2-g-h):j/(g+h),g){case c:a=(d-e)/j+(d="===a||"=<"===a||"<="===a;case 1:return">"===a||">="===a;default:return!1}}}(this.op,this.lvalue.eval(a),this.rvalue.eval(a));return this.negate?!b:b},b.exports=e},{"./node":73}],57:[function(a,b,c){var d=function(a,b,c){var e="";if(a.dumpLineNumbers&&!a.compress)switch(a.dumpLineNumbers){case"comments":e=d.asComment(b);break;case"mediaquery":e=d.asMediaQuery(b);break;case"all":e=d.asComment(b)+(c||"")+d.asMediaQuery(b)}return e};d.asComment=function(a){return"/* line "+a.debugInfo.lineNumber+", "+a.debugInfo.fileName+" */\n"},d.asMediaQuery=function(a){var b=a.debugInfo.fileName;return/^[a-z]+:\/\//i.test(b)||(b="file://"+b),"@media -sass-debug-info{filename{font-family:"+b.replace(/([.:\/\\])/g,function(a){return"\\"==a&&(a="/"),"\\"+a})+"}line{font-family:\\00003"+a.debugInfo.lineNumber+"}}\n"},b.exports=d},{}],58:[function(a,b,c){function d(a,b){var c,d="",e=b.length,f={add:function(a){d+=a}};for(c=0;c-1e-6&&(d=c.toFixed(20).replace(/0+$/,"")),a&&a.compress){if(0===c&&this.unit.isLength())return void b.add(d);c>0&&c<1&&(d=d.substr(1))}b.add(d),this.unit.genCSS(a,b)},h.prototype.operate=function(a,b,c){var d=this._operate(a,b,this.value,c.value),e=this.unit.clone();if("+"===b||"-"===b)if(0===e.numerator.length&&0===e.denominator.length)e=c.unit.clone(),this.unit.backupUnit&&(e.backupUnit=this.unit.backupUnit);else if(0===c.unit.numerator.length&&0===e.denominator.length);else{if(c=c.convertTo(this.unit.usedUnits()),a.strictUnits&&c.unit.toString()!==e.toString())throw new Error("Incompatible units. Change the units or use the unit function. Bad units: '"+e.toString()+"' and '"+c.unit.toString()+"'.");d=this._operate(a,b,this.value,c.value)}else"*"===b?(e.numerator=e.numerator.concat(c.unit.numerator).sort(),e.denominator=e.denominator.concat(c.unit.denominator).sort(),e.cancel()):"/"===b&&(e.numerator=e.numerator.concat(c.unit.denominator).sort(),e.denominator=e.denominator.concat(c.unit.numerator).sort(),e.cancel());return new h(d,e)},h.prototype.compare=function(a){var b,c;if(a instanceof h){if(this.unit.isEmpty()||a.unit.isEmpty())b=this,c=a;else if(b=this.unify(),c=a.unify(),0!==b.unit.compare(c.unit))return;return d.numericCompare(b.value,c.value)}},h.prototype.unify=function(){return this.convertTo({length:"px",duration:"s",angle:"rad"})},h.prototype.convertTo=function(a){var b,c,d,f,g,i=this.value,j=this.unit.clone(),k={};if("string"==typeof a){for(b in e)e[b].hasOwnProperty(a)&&(k={},k[b]=a);a=k}g=function(a,b){return d.hasOwnProperty(a)?(b?i/=d[a]/d[f]:i*=d[a]/d[f],f):a};for(c in a)a.hasOwnProperty(c)&&(f=a[c],d=e[c],j.map(g));return j.cancel(),new h(i,j)},b.exports=h},{"../data/unit-conversions":15,"./color":53,"./node":73,"./unit":81}],61:[function(a,b,c){var d=a("./node"),e=a("./paren"),f=a("./combinator"),g=function(a,b,c,d,e){this.combinator=a instanceof f?a:new f(a),this.value="string"==typeof b?b.trim():b?b:"",this._index=c,this._fileInfo=d,this.copyVisibilityInfo(e),this.setParent(this.combinator,this)};g.prototype=new d,g.prototype.type="Element",g.prototype.accept=function(a){var b=this.value;this.combinator=a.visit(this.combinator),"object"==typeof b&&(this.value=a.visit(b))},g.prototype.eval=function(a){return new g(this.combinator,this.value.eval?this.value.eval(a):this.value,this.getIndex(),this.fileInfo(),this.visibilityInfo())},g.prototype.clone=function(){return new g(this.combinator,this.value,this.getIndex(),this.fileInfo(),this.visibilityInfo())},g.prototype.genCSS=function(a,b){b.add(this.toCSS(a),this.fileInfo(),this.getIndex())},g.prototype.toCSS=function(a){a=a||{};var b=this.value,c=a.firstSelector;return b instanceof e&&(a.firstSelector=!0),b=b.toCSS?b.toCSS(a):b,a.firstSelector=c,""===b&&"&"===this.combinator.value.charAt(0)?"":this.combinator.toCSS(a)+b},b.exports=g},{"./combinator":54,"./node":73,"./paren":75}],62:[function(a,b,c){var d=a("./node"),e=a("./paren"),f=a("./comment"),g=function(a){if(this.value=a,!a)throw new Error("Expression requires an array parameter")};g.prototype=new d,g.prototype.type="Expression",g.prototype.accept=function(a){this.value=a.visitArray(this.value)},g.prototype.eval=function(a){var b,c=this.parens&&!this.parensInOp,d=!1;return c&&a.inParenthesis(),this.value.length>1?b=new g(this.value.map(function(b){return b.eval(a)})):1===this.value.length?(this.value[0].parens&&!this.value[0].parensInOp&&(d=!0),b=this.value[0].eval(a)):b=this,c&&a.outOfParenthesis(),this.parens&&this.parensInOp&&!a.isMathOn()&&!d&&(b=new e(b)),b},g.prototype.genCSS=function(a,b){for(var c=0;c0&&c.length&&""===c[0].combinator.value&&(c[0].combinator.value=" "),d=d.concat(a[b].elements);this.selfSelectors=[new e(d)],this.selfSelectors[0].copyVisibilityInfo(this.visibilityInfo())},b.exports=f},{"./node":73,"./selector":79}],64:[function(a,b,c){var d=a("./node"),e=a("./media"),f=a("./url"),g=a("./quoted"),h=a("./ruleset"),i=a("./anonymous"),j=a("../utils"),k=a("../less-error"),l=function(a,b,c,d,e,f){if(this.options=c,this._index=d,this._fileInfo=e,this.path=a,this.features=b,this.allowRoot=!0,void 0!==this.options.less||this.options.inline)this.css=!this.options.less||this.options.inline;else{var g=this.getPath();g&&/[#\.\&\?]css([\?;].*)?$/.test(g)&&(this.css=!0)}this.copyVisibilityInfo(f),this.setParent(this.features,this),this.setParent(this.path,this)};l.prototype=new d,l.prototype.type="Import",l.prototype.accept=function(a){this.features&&(this.features=a.visit(this.features)),this.path=a.visit(this.path),this.options.isPlugin||this.options.inline||!this.root||(this.root=a.visit(this.root))},l.prototype.genCSS=function(a,b){this.css&&void 0===this.path._fileInfo.reference&&(b.add("@import ",this._fileInfo,this._index),this.path.genCSS(a,b),this.features&&(b.add(" "),this.features.genCSS(a,b)),b.add(";"))},l.prototype.getPath=function(){return this.path instanceof f?this.path.value.value:this.path.value},l.prototype.isVariableImport=function(){var a=this.path;return a instanceof f&&(a=a.value),!(a instanceof g)||a.containsVariables()},l.prototype.evalForImport=function(a){var b=this.path;return b instanceof f&&(b=b.value),new l(b.eval(a),this.features,this.options,this._index,this._fileInfo,this.visibilityInfo())},l.prototype.evalPath=function(a){var b=this.path.eval(a),c=this._fileInfo&&this._fileInfo.rootpath;if(!(b instanceof f)){if(c){var d=b.value;d&&a.isPathRelative(d)&&(b.value=c+d)}b.value=a.normalizePath(b.value)}return b},l.prototype.eval=function(a){var b=this.doEval(a);return(this.options.reference||this.blocksVisibility())&&(b.length||0===b.length?b.forEach(function(a){ +a.addVisibilityBlock()}):b.addVisibilityBlock()),b},l.prototype.doEval=function(a){var b,c,d=this.features&&this.features.eval(a);if(this.options.isPlugin){if(this.root&&this.root.eval)try{this.root.eval(a)}catch(f){throw f.message="Plugin error during evaluation",new k(f,this.root.imports,this.root.filename)}return c=a.frames[0]&&a.frames[0].functionRegistry,c&&this.root&&this.root.functions&&c.addMultiple(this.root.functions),[]}if(this.skip&&("function"==typeof this.skip&&(this.skip=this.skip()),this.skip))return[];if(this.options.inline){var g=new i(this.root,0,{filename:this.importedFilename,reference:this.path._fileInfo&&this.path._fileInfo.reference},(!0),(!0));return this.features?new e([g],this.features.value):[g]}if(this.css){var m=new l(this.evalPath(a),d,this.options,this._index);if(!m.css&&this.error)throw this.error;return m}return b=new h(null,j.copyArray(this.root.rules)),b.evalImports(a),this.features?new e(b.rules,this.features.value):b.rules},b.exports=l},{"../less-error":36,"../utils":86,"./anonymous":48,"./media":69,"./node":73,"./quoted":77,"./ruleset":78,"./url":82}],65:[function(a,b,c){var d=Object.create(null);d.Node=a("./node"),d.Color=a("./color"),d.AtRule=a("./atrule"),d.DetachedRuleset=a("./detached-ruleset"),d.Operation=a("./operation"),d.Dimension=a("./dimension"),d.Unit=a("./unit"),d.Keyword=a("./keyword"),d.Variable=a("./variable"),d.Property=a("./property"),d.Ruleset=a("./ruleset"),d.Element=a("./element"),d.Attribute=a("./attribute"),d.Combinator=a("./combinator"),d.Selector=a("./selector"),d.Quoted=a("./quoted"),d.Expression=a("./expression"),d.Declaration=a("./declaration"),d.Call=a("./call"),d.URL=a("./url"),d.Import=a("./import"),d.mixin={Call:a("./mixin-call"),Definition:a("./mixin-definition")},d.Comment=a("./comment"),d.Anonymous=a("./anonymous"),d.Value=a("./value"),d.JavaScript=a("./javascript"),d.Assignment=a("./assignment"),d.Condition=a("./condition"),d.Paren=a("./paren"),d.Media=a("./media"),d.UnicodeDescriptor=a("./unicode-descriptor"),d.Negative=a("./negative"),d.Extend=a("./extend"),d.VariableCall=a("./variable-call"),b.exports=d},{"./anonymous":48,"./assignment":49,"./atrule":50,"./attribute":51,"./call":52,"./color":53,"./combinator":54,"./comment":55,"./condition":56,"./declaration":58,"./detached-ruleset":59,"./dimension":60,"./element":61,"./expression":62,"./extend":63,"./import":64,"./javascript":66,"./keyword":68,"./media":69,"./mixin-call":70,"./mixin-definition":71,"./negative":72,"./node":73,"./operation":74,"./paren":75,"./property":76,"./quoted":77,"./ruleset":78,"./selector":79,"./unicode-descriptor":80,"./unit":81,"./url":82,"./value":83,"./variable":85,"./variable-call":84}],66:[function(a,b,c){var d=a("./js-eval-node"),e=a("./dimension"),f=a("./quoted"),g=a("./anonymous"),h=function(a,b,c,d){this.escaped=b,this.expression=a,this._index=c,this._fileInfo=d};h.prototype=new d,h.prototype.type="JavaScript",h.prototype.eval=function(a){var b=this.evaluateJavaScript(this.expression,a);return"number"==typeof b?new e(b):"string"==typeof b?new f('"'+b+'"',b,this.escaped,this._index):new g(Array.isArray(b)?b.join(", "):b)},b.exports=h},{"./anonymous":48,"./dimension":60,"./js-eval-node":67,"./quoted":77}],67:[function(a,b,c){var d=a("./node"),e=a("./variable"),f=function(){};f.prototype=new d,f.prototype.evaluateJavaScript=function(a,b){var c,d=this,f={};if(!b.javascriptEnabled)throw{message:"Inline JavaScript is not enabled. Is it set in your options?",filename:this.fileInfo().filename,index:this.getIndex()};a=a.replace(/@\{([\w-]+)\}/g,function(a,c){return d.jsify(new e("@"+c,d.getIndex(),d.fileInfo()).eval(b))});try{a=new Function("return ("+a+")")}catch(g){throw{message:"JavaScript evaluation error: "+g.message+" from `"+a+"`",filename:this.fileInfo().filename,index:this.getIndex()}}var h=b.frames[0].variables();for(var i in h)h.hasOwnProperty(i)&&(f[i.slice(1)]={value:h[i].value,toJS:function(){return this.value.eval(b).toCSS()}});try{c=a.call(f)}catch(g){throw{message:"JavaScript evaluation error: '"+g.name+": "+g.message.replace(/["]/g,"'")+"'",filename:this.fileInfo().filename,index:this.getIndex()}}return c},f.prototype.jsify=function(a){return Array.isArray(a.value)&&a.value.length>1?"["+a.value.map(function(a){return a.toCSS()}).join(", ")+"]":a.toCSS()},b.exports=f},{"./node":73,"./variable":85}],68:[function(a,b,c){var d=a("./node"),e=function(a){this.value=a};e.prototype=new d,e.prototype.type="Keyword",e.prototype.genCSS=function(a,b){if("%"===this.value)throw{type:"Syntax",message:"Invalid % without number"};b.add(this.value)},e.True=new e("true"),e.False=new e("false"),b.exports=e},{"./node":73}],69:[function(a,b,c){var d=a("./ruleset"),e=a("./value"),f=a("./selector"),g=a("./anonymous"),h=a("./expression"),i=a("./atrule"),j=a("../utils"),k=function(a,b,c,g,h){this._index=c,this._fileInfo=g;var i=new f([],null,null,this._index,this._fileInfo).createEmptySelectors();this.features=new e(b),this.rules=[new d(i,a)],this.rules[0].allowImports=!0,this.copyVisibilityInfo(h),this.allowRoot=!0,this.setParent(i,this),this.setParent(this.features,this),this.setParent(this.rules,this)};k.prototype=new i,k.prototype.type="Media",k.prototype.isRulesetLike=function(){return!0},k.prototype.accept=function(a){this.features&&(this.features=a.visit(this.features)),this.rules&&(this.rules=a.visitArray(this.rules))},k.prototype.genCSS=function(a,b){b.add("@media ",this._fileInfo,this._index),this.features.genCSS(a,b),this.outputRuleset(a,b,this.rules)},k.prototype.eval=function(a){a.mediaBlocks||(a.mediaBlocks=[],a.mediaPath=[]);var b=new k(null,[],this._index,this._fileInfo,this.visibilityInfo());return this.debugInfo&&(this.rules[0].debugInfo=this.debugInfo,b.debugInfo=this.debugInfo),b.features=this.features.eval(a),a.mediaPath.push(b),a.mediaBlocks.push(b),this.rules[0].functionRegistry=a.frames[0].functionRegistry.inherit(),a.frames.unshift(this.rules[0]),b.rules=[this.rules[0].eval(a)],a.frames.shift(),a.mediaPath.pop(),0===a.mediaPath.length?b.evalTop(a):b.evalNested(a)},k.prototype.evalTop=function(a){var b=this;if(a.mediaBlocks.length>1){var c=new f([],null,null,this.getIndex(),this.fileInfo()).createEmptySelectors();b=new d(c,a.mediaBlocks),b.multiMedia=!0,b.copyVisibilityInfo(this.visibilityInfo()),this.setParent(b,this)}return delete a.mediaBlocks,delete a.mediaPath,b},k.prototype.evalNested=function(a){var b,c,f=a.mediaPath.concat([this]);for(b=0;b0;b--)a.splice(b,0,new g("and"));return new h(a)})),this.setParent(this.features,this),new d([],[])},k.prototype.permute=function(a){if(0===a.length)return[];if(1===a.length)return a[0];for(var b=[],c=this.permute(a.slice(1)),d=0;d0){for(n=!0,k=0;k0)p=B;else if(p=A,q[A]+q[B]>1)throw{type:"Runtime",message:"Ambiguous use of `default()` found when matching for `"+this.format(t)+"`",index:this.getIndex(),filename:this.fileInfo().filename};for(k=0;kthis.params.length)return!1}c=Math.min(f,this.arity);for(var g=0;gb?1:void 0},d.prototype.blocksVisibility=function(){return null==this.visibilityBlocks&&(this.visibilityBlocks=0),0!==this.visibilityBlocks},d.prototype.addVisibilityBlock=function(){null==this.visibilityBlocks&&(this.visibilityBlocks=0),this.visibilityBlocks=this.visibilityBlocks+1},d.prototype.removeVisibilityBlock=function(){null==this.visibilityBlocks&&(this.visibilityBlocks=0),this.visibilityBlocks=this.visibilityBlocks-1},d.prototype.ensureVisibility=function(){this.nodeVisible=!0},d.prototype.ensureInvisibility=function(){this.nodeVisible=!1},d.prototype.isVisible=function(){return this.nodeVisible},d.prototype.visibilityInfo=function(){return{visibilityBlocks:this.visibilityBlocks,nodeVisible:this.nodeVisible}},d.prototype.copyVisibilityInfo=function(a){a&&(this.visibilityBlocks=a.visibilityBlocks,this.nodeVisible=a.nodeVisible)},b.exports=d},{}],74:[function(a,b,c){var d=a("./node"),e=a("./color"),f=a("./dimension"),g=function(a,b,c){this.op=a.trim(),this.operands=b,this.isSpaced=c};g.prototype=new d,g.prototype.type="Operation",g.prototype.accept=function(a){this.operands=a.visit(this.operands)},g.prototype.eval=function(a){var b=this.operands[0].eval(a),c=this.operands[1].eval(a);if(a.isMathOn()){if(b instanceof f&&c instanceof e&&(b=b.toColor()),c instanceof f&&b instanceof e&&(c=c.toColor()),!b.operate)throw{type:"Operation",message:"Operation on an invalid type"};return b.operate(a,this.op,c)}return new g(this.op,[b,c],this.isSpaced)},g.prototype.genCSS=function(a,b){this.operands[0].genCSS(a,b),this.isSpaced&&b.add(" "),b.add(this.op),this.isSpaced&&b.add(" "),this.operands[1].genCSS(a,b)},b.exports=g},{"./color":53,"./dimension":60,"./node":73}],75:[function(a,b,c){var d=a("./node"),e=function(a){this.value=a};e.prototype=new d,e.prototype.type="Paren",e.prototype.genCSS=function(a,b){b.add("("),this.value.genCSS(a,b),b.add(")")},e.prototype.eval=function(a){return new e(this.value.eval(a))},b.exports=e},{"./node":73}],76:[function(a,b,c){var d=a("./node"),e=a("./declaration"),f=function(a,b,c){this.name=a,this._index=b,this._fileInfo=c};f.prototype=new d,f.prototype.type="Property",f.prototype.eval=function(a){var b,c=this.name,d=a.pluginManager.less.visitors.ToCSSVisitor.prototype._mergeRules;if(this.evaluating)throw{type:"Name",message:"Recursive property reference for "+c,filename:this.fileInfo().filename,index:this.getIndex()};if(this.evaluating=!0,b=this.find(a.frames,function(b){var f,g=b.property(c);if(g){for(var h=0;hd){if(!c||c(g)){e=g.find(new i(a.elements.slice(d)),b,c);for(var j=0;j0&&b.add(k),a.firstSelector=!0,h[0].genCSS(a,b),a.firstSelector=!1,d=1;d0?(e=p.copyArray(a),f=e.pop(),g=d.createDerived(p.copyArray(f.elements))):g=d.createDerived([]),b.length>0){var h=c.combinator,i=b[0].elements[0];h.emptyOrWhitespace&&!i.combinator.emptyOrWhitespace&&(h=i.combinator),g.elements.push(new j(h,i.value,c._index,c._fileInfo)),g.elements=g.elements.concat(b[0].elements.slice(1))}if(0!==g.elements.length&&e.push(g),b.length>1){var k=b.slice(1);k=k.map(function(a){return a.createDerived(a.elements,[])}),e=e.concat(k)}return e}function g(a,b,c,d,e){var g;for(g=0;g0?d[d.length-1]=d[d.length-1].createDerived(d[d.length-1].elements.concat(a)):d.push(new i(a))}}function l(a,b,c){function m(a){var b;return a.value instanceof h?(b=a.value.value,b instanceof i?b:null):null}var n,o,p,q,r,s,t,u,v,w,x=!1;for(q=[],r=[[]],n=0;u=c.elements[n];n++)if("&"!==u.value){var y=m(u);if(null!=y){k(q,r);var z,A=[],B=[];for(z=l(A,b,y),x=x||z,p=0;p0&&t[0].elements.push(new j(u.combinator,"",u._index,u._fileInfo)),s.push(t);else for(p=0;p0&&(a.push(r[n]),w=r[n][v-1],r[n][v-1]=w.createDerived(w.elements,c.extendList));return x}function m(a,b){var c=b.createDerived(b.elements,b.extendList,b.evaldCondition);return c.copyVisibilityInfo(a),c}var n,o,q;if(o=[],q=l(o,b,c),!q)if(b.length>0)for(o=[],n=0;n0)for(b=0;b=0&&"\n"!==b.charAt(c);)e++;return"number"==typeof a&&(d=(b.slice(0,a).match(/\n/g)||"").length),{line:d,column:e}},copyArray:function(a){var b,c=a.length,d=new Array(c);for(b=0;b=0||(i=[k.selfSelectors[0]],g=n.findMatch(j,i),g.length&&(j.hasFoundMatches=!0,j.selfSelectors.forEach(function(a){var b=k.visibilityInfo();h=n.extendSelector(g,i,a,j.isVisible()),l=new d.Extend(k.selector,k.option,0,k.fileInfo(),b),l.selfSelectors=h,h[h.length-1].extendList=[l],m.push(l),l.ruleset=k.ruleset,l.parent_ids=l.parent_ids.concat(k.parent_ids,j.parent_ids),k.firstExtendOnThisSelectorPath&&(l.firstExtendOnThisSelectorPath=!0,k.ruleset.paths.push(h))})));if(m.length){if(this.extendChainCount++,c>100){var o="{unable to calculate}",p="{unable to calculate}";try{o=m[0].selfSelectors[0].toCSS(),p=m[0].selector.toCSS()}catch(q){}throw{message:"extend circular reference detected. One of the circular extends is currently:"+o+":extend("+p+")"}}return m.concat(n.doExtendChaining(m,b,c+1))}return m},visitDeclaration:function(a,b){b.visitDeeper=!1},visitMixinDefinition:function(a,b){b.visitDeeper=!1},visitSelector:function(a,b){b.visitDeeper=!1},visitRuleset:function(a,b){if(!a.root){var c,d,e,f,g=this.allExtendsStack[this.allExtendsStack.length-1],h=[],i=this;for(e=0;e0&&k[i.matched].combinator.value!==g?i=null:i.matched++,i&&(i.finished=i.matched===k.length,i.finished&&!a.allowAfter&&(e+1k&&l>0&&(m[m.length-1].elements=m[m.length-1].elements.concat(b[k].elements.slice(l)),l=0,k++),j=g.elements.slice(l,i.index).concat([h]).concat(c.elements.slice(1)),k===i.pathIndex&&f>0?m[m.length-1].elements=m[m.length-1].elements.concat(j):(m=m.concat(b.slice(k,i.pathIndex)),m.push(new d.Selector(j))),k=i.endPathIndex,l=i.endPathElementIndex,l>=b[k].elements.length&&(l=0,k++);return k0&&(m[m.length-1].elements=m[m.length-1].elements.concat(b[k].elements.slice(l)),k++),m=m.concat(b.slice(k,b.length)),m=m.map(function(a){var b=a.createDerived(a.elements);return e?b.ensureVisibility():b.ensureInvisibility(),b})},visitMedia:function(a,b){var c=a.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);c=c.concat(this.doExtendChaining(c,a.allExtends)),this.allExtendsStack.push(c)},visitMediaOut:function(a){var b=this.allExtendsStack.length-1;this.allExtendsStack.length=b},visitAtRule:function(a,b){var c=a.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);c=c.concat(this.doExtendChaining(c,a.allExtends)),this.allExtendsStack.push(c)},visitAtRuleOut:function(a){var b=this.allExtendsStack.length-1;this.allExtendsStack.length=b}},b.exports=i},{"../logger":37,"../tree":65,"../utils":86,"./visitor":94}],88:[function(a,b,c){function d(a){this.imports=[],this.variableImports=[],this._onSequencerEmpty=a,this._currentDepth=0}d.prototype.addImport=function(a){var b=this,c={callback:a,args:null,isReady:!1};return this.imports.push(c),function(){c.args=Array.prototype.slice.call(arguments,0),c.isReady=!0,b.tryRun()}},d.prototype.addVariableImport=function(a){this.variableImports.push(a)},d.prototype.tryRun=function(){this._currentDepth++;try{for(;;){for(;this.imports.length>0;){var a=this.imports[0];if(!a.isReady)return;this.imports=this.imports.slice(1),a.callback.apply(null,a.args)}if(0===this.variableImports.length)break;var b=this.variableImports[0];this.variableImports=this.variableImports.slice(1),b()}}finally{this._currentDepth--}0===this._currentDepth&&this._onSequencerEmpty&&this._onSequencerEmpty()},b.exports=d},{}],89:[function(a,b,c){var d=a("../contexts"),e=a("./visitor"),f=a("./import-sequencer"),g=a("../utils"),h=function(a,b){this._visitor=new e(this),this._importer=a,this._finish=b,this.context=new d.Eval,this.importCount=0,this.onceFileDetectionMap={},this.recursionDetector={},this._sequencer=new f(this._onSequencerEmpty.bind(this))};h.prototype={isReplacing:!1,run:function(a){try{this._visitor.visit(a)}catch(b){this.error=b}this.isFinished=!0,this._sequencer.tryRun()},_onSequencerEmpty:function(){this.isFinished&&this._finish(this.error)},visitImport:function(a,b){var c=a.options.inline;if(!a.css||c){var e=new d.Eval(this.context,g.copyArray(this.context.frames)),f=e.frames[0];this.importCount++,a.isVariableImport()?this._sequencer.addVariableImport(this.processImportNode.bind(this,a,e,f)):this.processImportNode(a,e,f)}b.visitDeeper=!1},processImportNode:function(a,b,c){var d,e=a.options.inline;try{d=a.evalForImport(b)}catch(f){f.filename||(f.index=a.getIndex(),f.filename=a.fileInfo().filename),a.css=!0,a.error=f}if(!d||d.css&&!e)this.importCount--,this.isFinished&&this._sequencer.tryRun();else{d.options.multiple&&(b.importMultiple=!0);for(var g=void 0===d.css,h=0;h0},resolveVisibility:function(a,b){if(!a.blocksVisibility()){if(this.isEmpty(a)&&!this.containsSilentNonBlockedChild(b))return;return a}var c=a.rules[0];if(this.keepOnlyVisibleChilds(c),!this.isEmpty(c))return a.ensureVisibility(),a.removeVisibilityBlock(),a},isVisibleRuleset:function(a){return!!a.firstRoot||!this.isEmpty(a)&&!(!a.root&&!this.hasVisibleSelector(a))}};var g=function(a){this._visitor=new e(this),this._context=a,this.utils=new f(a)};g.prototype={isReplacing:!0,run:function(a){return this._visitor.visit(a)},visitDeclaration:function(a,b){if(!a.blocksVisibility()&&!a.variable)return a},visitMixinDefinition:function(a,b){a.frames=[]},visitExtend:function(a,b){},visitComment:function(a,b){if(!a.blocksVisibility()&&!a.isSilent(this._context))return a},visitMedia:function(a,b){var c=a.rules[0].rules;return a.accept(this._visitor),b.visitDeeper=!1,this.utils.resolveVisibility(a,c)},visitImport:function(a,b){if(!a.blocksVisibility())return a},visitAtRule:function(a,b){return a.rules&&a.rules.length?this.visitAtRuleWithBody(a,b):this.visitAtRuleWithoutBody(a,b)},visitAnonymous:function(a,b){if(!a.blocksVisibility())return a.accept(this._visitor),a},visitAtRuleWithBody:function(a,b){function c(a){var b=a.rules;return 1===b.length&&(!b[0].paths||0===b[0].paths.length)}function d(a){var b=a.rules;return c(a)?b[0].rules:b}var e=d(a);return a.accept(this._visitor),b.visitDeeper=!1,this.utils.isEmpty(a)||this._mergeRules(a.rules[0].rules),this.utils.resolveVisibility(a,e)},visitAtRuleWithoutBody:function(a,b){if(!a.blocksVisibility()){if("@charset"===a.name){if(this.charset){if(a.debugInfo){var c=new d.Comment("/* "+a.toCSS(this._context).replace(/\n/g,"")+" */\n");return c.debugInfo=a.debugInfo,this._visitor.visit(c)}return}this.charset=!0}return a}},checkValidNodes:function(a,b){if(a)for(var c=0;c0?a.accept(this._visitor):a.rules=null,b.visitDeeper=!1}return a.rules&&(this._mergeRules(a.rules),this._removeDuplicateRules(a.rules)),this.utils.isVisibleRuleset(a)&&(a.ensureVisibility(),d.splice(0,0,a)),1===d.length?d[0]:d},_compileRulesetPaths:function(a){a.paths&&(a.paths=a.paths.filter(function(a){var b;for(" "===a[0].elements[0].combinator.value&&(a[0].elements[0].combinator=new d.Combinator("")),b=0;b=0;e--)if(c=a[e],c instanceof d.Declaration)if(f[c.name]){b=f[c.name],b instanceof d.Declaration&&(b=f[c.name]=[f[c.name].toCSS(this._context)]);var g=c.toCSS(this._context);b.indexOf(g)!==-1?a.splice(e,1):b.push(g)}else f[c.name]=c}},_mergeRules:function(a){if(a){for(var b={},c=[],e=0;e0){var b=a[0],c=[],e=[new d.Expression(c)];a.forEach(function(a){"+"===a.merge&&c.length>0&&e.push(new d.Expression(c=[])),c.push(a.value),b.important=b.important||a.important}),b.value=new d.Value(e)}})}}},b.exports=g},{"../tree":65,"./visitor":94}],94:[function(a,b,c){function d(a){return a}function e(a,b){var c,d;for(c in a)switch(d=a[c],typeof d){case"function":d.prototype&&d.prototype.type&&(d.prototype.typeIndex=b++);break;case"object":b=e(d,b)}return b}var f=a("../tree"),g={visitDeeper:!0},h=!1,i=function(a){this._implementation=a,this._visitFnCache=[],h||(e(f,1),h=!0)};i.prototype={visit:function(a){if(!a)return a;var b=a.typeIndex;if(!b)return a;var c,e=this._visitFnCache,f=this._implementation,h=b<<1,i=1|h,j=e[h],k=e[i],l=g;if(l.visitDeeper=!0,j||(c="visit"+a.type,j=f[c]||d,k=f[c+"Out"]||d,e[h]=j,e[i]=k),j!==d){var m=j.call(f,a,l);f.isReplacing&&(a=m)}return l.visitDeeper&&a&&a.accept&&a.accept(this),k!=d&&k.call(f,a),a},visitArray:function(a,b){if(!a)return a;var c,d=a.length;if(b||!this._implementation.isReplacing){for(c=0;ck){for(var b=0,c=h.length-j;b